forge-cw 0.1.35 → 0.1.36
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/console/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>Forge Console</title>
|
|
9
9
|
<script type="importmap">{"imports":{"preact":"/shared/preact.js","preact/hooks":"/shared/preact-hooks.js","preact/jsx-runtime":"/shared/preact-jsx-runtime.js","preact/compat":"/shared/preact-compat.js","@preact/signals":"/shared/preact-signals.js","@forge-dev/ui":"/shared/forge-dev-ui.js","@forge-dev/sdk":"/shared/forge-dev-sdk.js"}}</script>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-NDnMxbuC.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-CL35efIa.css">
|
|
12
12
|
<link rel="stylesheet" href="/shared/forge-dev-ui.css">
|
|
13
13
|
</head>
|
package/dist/index.js
CHANGED
|
@@ -760,6 +760,11 @@ var init_cw_reader = __esm({
|
|
|
760
760
|
const root = join2(this.cwDir, "accounts", account);
|
|
761
761
|
return existsSync2(join2(root, "claude")) ? join2(root, "claude") : root;
|
|
762
762
|
}
|
|
763
|
+
// the config dir Claude Code runs with (~/.claude without a CW account) and whether its settings turn claude.ai connectors off
|
|
764
|
+
claudeConfig(account) {
|
|
765
|
+
const configDir = account ? this.accountConfigDir(account) : join2(process.env.HOME ?? "", ".claude");
|
|
766
|
+
return { configDir, connectorsOff: readJsonObject(join2(configDir, "settings.json")).disableClaudeAiConnectors === true };
|
|
767
|
+
}
|
|
763
768
|
/**
|
|
764
769
|
* What Claude Code will load for a project under an account: MCPs from the account's .claude.json
|
|
765
770
|
* (user and local scope), the repo's .mcp.json and .claude/settings.json, CW's mcps/, and the account's plugins.
|
|
@@ -1453,7 +1458,8 @@ function parseCredentials(raw) {
|
|
|
1453
1458
|
const accessToken = typeof oauth?.accessToken === "string" ? oauth.accessToken : null;
|
|
1454
1459
|
if (!accessToken)
|
|
1455
1460
|
return null;
|
|
1456
|
-
|
|
1461
|
+
const scopes = Array.isArray(oauth?.scopes) ? oauth.scopes.filter((s) => typeof s === "string") : null;
|
|
1462
|
+
return { accessToken, expiresAt: typeof oauth?.expiresAt === "number" ? oauth.expiresAt : null, scopes };
|
|
1457
1463
|
} catch {
|
|
1458
1464
|
return null;
|
|
1459
1465
|
}
|
|
@@ -1678,6 +1684,103 @@ var init_usage = __esm({
|
|
|
1678
1684
|
}
|
|
1679
1685
|
});
|
|
1680
1686
|
|
|
1687
|
+
// ../core/dist/claude-connectors.js
|
|
1688
|
+
function mapConnectors(rows) {
|
|
1689
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1690
|
+
return rows.flatMap((row) => {
|
|
1691
|
+
if (!isObject2(row) || row.eligible !== true || typeof row.display_name !== "string")
|
|
1692
|
+
return [];
|
|
1693
|
+
const name = row.display_name;
|
|
1694
|
+
if (seen.has(name))
|
|
1695
|
+
return [];
|
|
1696
|
+
seen.add(name);
|
|
1697
|
+
return [{
|
|
1698
|
+
name,
|
|
1699
|
+
status: row.eligibility_reason === "connected_with_error" ? "needs_auth" : "connected",
|
|
1700
|
+
tools: Array.isArray(row.tools) ? row.tools.length : 0
|
|
1701
|
+
}];
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
function createClaudeConnectorsClient(deps = {}) {
|
|
1705
|
+
const now = deps.now ?? Date.now;
|
|
1706
|
+
const cacheMs = deps.cacheMs ?? CACHE_MS2;
|
|
1707
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1708
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
1709
|
+
async function fetchFor(configDir) {
|
|
1710
|
+
const credentials = await readCredentials(configDir, deps);
|
|
1711
|
+
if (!credentials)
|
|
1712
|
+
return { state: "not_connected", detail: null, connectors: [] };
|
|
1713
|
+
if (credentials.expiresAt !== null && credentials.expiresAt <= now()) {
|
|
1714
|
+
return { state: "expired", detail: "The stored token has expired; open a session of this account to refresh it", connectors: [] };
|
|
1715
|
+
}
|
|
1716
|
+
if (credentials.scopes && !credentials.scopes.includes(SCOPE)) {
|
|
1717
|
+
return { state: "missing_scope", detail: `The account's sign-in lacks ${SCOPE}; sign in again to load connectors`, connectors: [] };
|
|
1718
|
+
}
|
|
1719
|
+
const call = deps.fetchImpl ?? fetch;
|
|
1720
|
+
const rows = [];
|
|
1721
|
+
let page = null;
|
|
1722
|
+
try {
|
|
1723
|
+
for (let i = 0; i < MAX_PAGES; i++) {
|
|
1724
|
+
const url = page ? `${CONNECTORS_URL}&page=${encodeURIComponent(page)}` : CONNECTORS_URL;
|
|
1725
|
+
const response = await call(url, {
|
|
1726
|
+
headers: { authorization: `Bearer ${credentials.accessToken}`, "anthropic-beta": MCP_SERVERS_BETA, "anthropic-version": "2023-06-01" },
|
|
1727
|
+
signal: AbortSignal.timeout(TIMEOUT_MS4)
|
|
1728
|
+
});
|
|
1729
|
+
if (response.status === 401 || response.status === 403)
|
|
1730
|
+
return { state: "expired", detail: "Claude rejected the stored token", connectors: [] };
|
|
1731
|
+
if (!response.ok)
|
|
1732
|
+
return { state: "error", detail: `claude.ai answered ${response.status}`, connectors: [] };
|
|
1733
|
+
const body2 = await response.json();
|
|
1734
|
+
if (!isObject2(body2) || !Array.isArray(body2.data))
|
|
1735
|
+
return { state: "error", detail: "claude.ai answered an unknown shape", connectors: [] };
|
|
1736
|
+
rows.push(...body2.data);
|
|
1737
|
+
page = typeof body2.next_page === "string" && body2.next_page ? body2.next_page : null;
|
|
1738
|
+
if (!page)
|
|
1739
|
+
break;
|
|
1740
|
+
}
|
|
1741
|
+
} catch (err) {
|
|
1742
|
+
return { state: "error", detail: err instanceof Error ? err.message : String(err), connectors: [] };
|
|
1743
|
+
}
|
|
1744
|
+
return { state: "ok", detail: null, connectors: mapConnectors(rows) };
|
|
1745
|
+
}
|
|
1746
|
+
return {
|
|
1747
|
+
/** The account's claude.ai connectors; kept 5 min, and the last good list stays when a later read fails */
|
|
1748
|
+
async get(configDir, options = {}) {
|
|
1749
|
+
if (options.disabled)
|
|
1750
|
+
return { state: "disabled", detail: "disableClaudeAiConnectors is on in this account's settings", connectors: [] };
|
|
1751
|
+
const hit = cache.get(configDir);
|
|
1752
|
+
if (hit && !options.fresh && now() - hit.at < cacheMs)
|
|
1753
|
+
return hit.value;
|
|
1754
|
+
const running = inflight.get(configDir);
|
|
1755
|
+
if (running)
|
|
1756
|
+
return running;
|
|
1757
|
+
const next = fetchFor(configDir).then((value) => {
|
|
1758
|
+
if (value.state === "ok" || !hit || hit.value.state !== "ok") {
|
|
1759
|
+
cache.set(configDir, { at: now(), value });
|
|
1760
|
+
return value;
|
|
1761
|
+
}
|
|
1762
|
+
return hit.value;
|
|
1763
|
+
}).finally(() => inflight.delete(configDir));
|
|
1764
|
+
inflight.set(configDir, next);
|
|
1765
|
+
return next;
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
var CONNECTORS_URL, MCP_SERVERS_BETA, SCOPE, TIMEOUT_MS4, CACHE_MS2, MAX_PAGES, isObject2;
|
|
1770
|
+
var init_claude_connectors = __esm({
|
|
1771
|
+
"../core/dist/claude-connectors.js"() {
|
|
1772
|
+
"use strict";
|
|
1773
|
+
init_usage_claude();
|
|
1774
|
+
CONNECTORS_URL = "https://api.anthropic.com/v1/mcp_servers?limit=1000";
|
|
1775
|
+
MCP_SERVERS_BETA = "mcp-servers-2025-12-04";
|
|
1776
|
+
SCOPE = "user:mcp_servers";
|
|
1777
|
+
TIMEOUT_MS4 = 6e3;
|
|
1778
|
+
CACHE_MS2 = 5 * 6e4;
|
|
1779
|
+
MAX_PAGES = 5;
|
|
1780
|
+
isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
|
|
1681
1784
|
// ../core/dist/harness-capabilities.js
|
|
1682
1785
|
function supports(harness, cap) {
|
|
1683
1786
|
return (HARNESS_CAPABILITIES[harness ?? "claude"] ?? []).includes(cap);
|
|
@@ -1830,7 +1933,7 @@ function importApiKey(cwBin, account, harness, apiKey) {
|
|
|
1830
1933
|
child.stderr.on("data", collect);
|
|
1831
1934
|
child.stdin.on("error", () => {
|
|
1832
1935
|
});
|
|
1833
|
-
const timer = setTimeout(() => child.kill(),
|
|
1936
|
+
const timer = setTimeout(() => child.kill(), TIMEOUT_MS5);
|
|
1834
1937
|
child.on("error", (err) => {
|
|
1835
1938
|
clearTimeout(timer);
|
|
1836
1939
|
resolve11({ ok: false, error: redact(err.message) });
|
|
@@ -1843,12 +1946,12 @@ function importApiKey(cwBin, account, harness, apiKey) {
|
|
|
1843
1946
|
`);
|
|
1844
1947
|
});
|
|
1845
1948
|
}
|
|
1846
|
-
var
|
|
1949
|
+
var TIMEOUT_MS5;
|
|
1847
1950
|
var init_api_key_login = __esm({
|
|
1848
1951
|
"../core/dist/api-key-login.js"() {
|
|
1849
1952
|
"use strict";
|
|
1850
1953
|
init_cw_doctor();
|
|
1851
|
-
|
|
1954
|
+
TIMEOUT_MS5 = 6e4;
|
|
1852
1955
|
}
|
|
1853
1956
|
});
|
|
1854
1957
|
|
|
@@ -2329,6 +2432,7 @@ function cwRoutes(reader, options = {}) {
|
|
|
2329
2432
|
return c.json({ ...result2, capabilities, contextTokens: readContextTokens(reader.cwHome) });
|
|
2330
2433
|
});
|
|
2331
2434
|
const usage = createUsageClient(options.usage);
|
|
2435
|
+
const connectors = createClaudeConnectorsClient(options.connectors);
|
|
2332
2436
|
app.get("/usage", async (c) => {
|
|
2333
2437
|
const result2 = await doctor.get();
|
|
2334
2438
|
if (!result2.available)
|
|
@@ -2463,8 +2567,11 @@ function cwRoutes(reader, options = {}) {
|
|
|
2463
2567
|
app.get("/mcps", (c) => {
|
|
2464
2568
|
return c.json(reader.getMCPs(c.req.query("project"), c.req.query("account")));
|
|
2465
2569
|
});
|
|
2466
|
-
app.get("/tools", (c) => {
|
|
2467
|
-
|
|
2570
|
+
app.get("/tools", async (c) => {
|
|
2571
|
+
const tools = reader.getTools(c.req.query("project"), c.req.query("account"));
|
|
2572
|
+
const { configDir, connectorsOff } = reader.claudeConfig(tools.account);
|
|
2573
|
+
const claudeAi = await connectors.get(configDir, { disabled: connectorsOff, fresh: c.req.query("fresh") === "1" });
|
|
2574
|
+
return c.json({ ...tools, claudeAi });
|
|
2468
2575
|
});
|
|
2469
2576
|
const loadGitSession = (project, sessionDir) => {
|
|
2470
2577
|
const session = reader.getSession(project, sessionDir);
|
|
@@ -2743,6 +2850,7 @@ var init_cw_routes = __esm({
|
|
|
2743
2850
|
init_cw_types();
|
|
2744
2851
|
init_cw_doctor();
|
|
2745
2852
|
init_usage();
|
|
2853
|
+
init_claude_connectors();
|
|
2746
2854
|
init_harness_capabilities();
|
|
2747
2855
|
init_login_manager();
|
|
2748
2856
|
init_api_key_login();
|
|
@@ -6924,7 +7032,7 @@ async function mapLimit(items, limit, fn) {
|
|
|
6924
7032
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
6925
7033
|
return out;
|
|
6926
7034
|
}
|
|
6927
|
-
var PAGE_TYPES, KiokuError, NOT_INSTALLED, START_TIMEOUT_MS, WRITE_TIMEOUT_MS, TERMINAL_TIMEOUT_MS,
|
|
7035
|
+
var PAGE_TYPES, KiokuError, NOT_INSTALLED, START_TIMEOUT_MS, WRITE_TIMEOUT_MS, TERMINAL_TIMEOUT_MS, CACHE_MS3, RELEASES_CACHE_MS, SHOWN_BIN, ACTIVITY_SINCE, ACTIVITY_LIMIT, PARALLEL, TIERS, REPO, AREA, LANGUAGE, MISSING, brainName, Kioku;
|
|
6928
7036
|
var init_kioku = __esm({
|
|
6929
7037
|
"../core/dist/kioku.js"() {
|
|
6930
7038
|
"use strict";
|
|
@@ -6952,7 +7060,7 @@ var init_kioku = __esm({
|
|
|
6952
7060
|
START_TIMEOUT_MS = 2e4;
|
|
6953
7061
|
WRITE_TIMEOUT_MS = 6e4;
|
|
6954
7062
|
TERMINAL_TIMEOUT_MS = 3 * 6e4;
|
|
6955
|
-
|
|
7063
|
+
CACHE_MS3 = 5 * 6e4;
|
|
6956
7064
|
RELEASES_CACHE_MS = 10 * 6e4;
|
|
6957
7065
|
SHOWN_BIN = "kioku";
|
|
6958
7066
|
ACTIVITY_SINCE = "2w";
|
|
@@ -6992,7 +7100,7 @@ var init_kioku = __esm({
|
|
|
6992
7100
|
}
|
|
6993
7101
|
async status(fresh = false) {
|
|
6994
7102
|
const previous = this.snapshot;
|
|
6995
|
-
if (fresh || !previous || this.now() - previous.at >
|
|
7103
|
+
if (fresh || !previous || this.now() - previous.at > CACHE_MS3) {
|
|
6996
7104
|
const value = this.read();
|
|
6997
7105
|
this.snapshot = { at: this.now(), value };
|
|
6998
7106
|
value.catch(() => {
|
|
@@ -7538,7 +7646,7 @@ function checkSdk(range, version = SDK_VERSION) {
|
|
|
7538
7646
|
return import_semver2.default.satisfies(version, range) ? null : `needs SDK ${range}, Forge has ${version}`;
|
|
7539
7647
|
}
|
|
7540
7648
|
function checkManifest(raw, moduleDir) {
|
|
7541
|
-
if (!
|
|
7649
|
+
if (!isObject3(raw))
|
|
7542
7650
|
return { kind: "invalid", reason: "/: must be an object" };
|
|
7543
7651
|
if (raw.sdk === void 0) {
|
|
7544
7652
|
if (V1_FIELDS.some((f) => raw[f] !== void 0))
|
|
@@ -7561,15 +7669,15 @@ function checkManifest(raw, moduleDir) {
|
|
|
7561
7669
|
err(`/${key}`, "must be a string");
|
|
7562
7670
|
}
|
|
7563
7671
|
if (raw.view !== void 0) {
|
|
7564
|
-
if (!
|
|
7672
|
+
if (!isObject3(raw.view) || typeof raw.view.entry !== "string" || raw.view.entry === "")
|
|
7565
7673
|
err("/view/entry", "required string");
|
|
7566
7674
|
else if (raw.view.title !== void 0 && typeof raw.view.title !== "string")
|
|
7567
7675
|
err("/view/title", "must be a string");
|
|
7568
|
-
if (
|
|
7676
|
+
if (isObject3(raw.view) && raw.view.banner !== void 0 && (typeof raw.view.banner !== "string" || raw.view.banner === ""))
|
|
7569
7677
|
err("/view/banner", "must be a non-empty string");
|
|
7570
7678
|
}
|
|
7571
7679
|
if (raw.permissions !== void 0) {
|
|
7572
|
-
if (!
|
|
7680
|
+
if (!isObject3(raw.permissions))
|
|
7573
7681
|
err("/permissions", "must be an object");
|
|
7574
7682
|
else {
|
|
7575
7683
|
for (const [key, value] of Object.entries(raw.permissions)) {
|
|
@@ -7587,7 +7695,7 @@ function checkManifest(raw, moduleDir) {
|
|
|
7587
7695
|
}
|
|
7588
7696
|
}
|
|
7589
7697
|
if (raw.settings !== void 0) {
|
|
7590
|
-
if (!
|
|
7698
|
+
if (!isObject3(raw.settings) || !isObject3(raw.settings.schema))
|
|
7591
7699
|
err("/settings/schema", "required object");
|
|
7592
7700
|
else
|
|
7593
7701
|
for (const [key, def] of Object.entries(raw.settings.schema))
|
|
@@ -7603,7 +7711,7 @@ function checkManifest(raw, moduleDir) {
|
|
|
7603
7711
|
return { kind: "invalid", reason: sdkReason };
|
|
7604
7712
|
}
|
|
7605
7713
|
if (errors.length === 0) {
|
|
7606
|
-
const entries = [["/server", raw.server], ["/view/entry",
|
|
7714
|
+
const entries = [["/server", raw.server], ["/view/entry", isObject3(raw.view) ? raw.view.entry : void 0], ["/view/banner", isObject3(raw.view) ? raw.view.banner : void 0]];
|
|
7607
7715
|
for (const [path, value] of entries) {
|
|
7608
7716
|
if (typeof value === "string" && !insideFolder(moduleDir, value))
|
|
7609
7717
|
err(path, "points outside the module folder");
|
|
@@ -7614,12 +7722,12 @@ function checkManifest(raw, moduleDir) {
|
|
|
7614
7722
|
return { kind: "v1", manifest: raw };
|
|
7615
7723
|
}
|
|
7616
7724
|
function checkSettingDef(def, path, allowList, err) {
|
|
7617
|
-
if (!
|
|
7725
|
+
if (!isObject3(def))
|
|
7618
7726
|
return err(path, "must be an object");
|
|
7619
7727
|
if (def.type === "list") {
|
|
7620
7728
|
if (!allowList)
|
|
7621
7729
|
return err(`${path}/type`, "lists do not nest");
|
|
7622
|
-
if (!
|
|
7730
|
+
if (!isObject3(def.item))
|
|
7623
7731
|
return err(`${path}/item`, "required object");
|
|
7624
7732
|
for (const [key, sub] of Object.entries(def.item))
|
|
7625
7733
|
checkSettingDef(sub, `${path}/item/${key}`, false, err);
|
|
@@ -7654,7 +7762,7 @@ function manifestFileFor(dir) {
|
|
|
7654
7762
|
}
|
|
7655
7763
|
}
|
|
7656
7764
|
function validateSettings(schema, values) {
|
|
7657
|
-
const input =
|
|
7765
|
+
const input = isObject3(values) ? values : {};
|
|
7658
7766
|
const errors = [];
|
|
7659
7767
|
const value = {};
|
|
7660
7768
|
for (const [key, def] of Object.entries(schema)) {
|
|
@@ -7665,8 +7773,8 @@ function validateSettings(schema, values) {
|
|
|
7665
7773
|
continue;
|
|
7666
7774
|
}
|
|
7667
7775
|
value[key] = raw.map((item, i) => {
|
|
7668
|
-
const obj2 =
|
|
7669
|
-
if (!
|
|
7776
|
+
const obj2 = isObject3(item) ? item : {};
|
|
7777
|
+
if (!isObject3(item))
|
|
7670
7778
|
errors.push({ path: `${key}[${i}]`, message: "must be an object" });
|
|
7671
7779
|
const out = {};
|
|
7672
7780
|
for (const [field, sub] of Object.entries(def.item)) {
|
|
@@ -7716,7 +7824,7 @@ function scalar(def, raw, path, errors) {
|
|
|
7716
7824
|
return typeof v === "string" && def.values.includes(v) ? v : fail(`must be one of ${def.values.join(", ")}`);
|
|
7717
7825
|
}
|
|
7718
7826
|
}
|
|
7719
|
-
var import_semver2, V1_FIELDS, TOP_LEVEL, PERMISSIONS, BOOLEAN_PERMISSIONS, SCALAR_TYPES, FORMATS,
|
|
7827
|
+
var import_semver2, V1_FIELDS, TOP_LEVEL, PERMISSIONS, BOOLEAN_PERMISSIONS, SCALAR_TYPES, FORMATS, isObject3, isStringArray;
|
|
7720
7828
|
var init_module_manifest = __esm({
|
|
7721
7829
|
"../core/dist/module-manifest.js"() {
|
|
7722
7830
|
"use strict";
|
|
@@ -7729,7 +7837,7 @@ var init_module_manifest = __esm({
|
|
|
7729
7837
|
BOOLEAN_PERMISSIONS = /* @__PURE__ */ new Set(["pty", "agent"]);
|
|
7730
7838
|
SCALAR_TYPES = /* @__PURE__ */ new Set(["string", "number", "boolean", "enum"]);
|
|
7731
7839
|
FORMATS = /* @__PURE__ */ new Set(["path", "cw-project", "url"]);
|
|
7732
|
-
|
|
7840
|
+
isObject3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
7733
7841
|
isStringArray = (v) => Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
7734
7842
|
}
|
|
7735
7843
|
});
|