@gh-symphony/cli 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1464,6 +1464,10 @@ function isFileMissing(error) {
1464
1464
  // ../core/src/observability/event-formatter.ts
1465
1465
  function formatEventMessage(event) {
1466
1466
  switch (event.event) {
1467
+ case "tracker.list":
1468
+ return `Tracker list saw ${event.issue.identifier}`;
1469
+ case "tracker.fetchByIds":
1470
+ return `Tracker fetch refreshed ${event.issue.identifier}`;
1467
1471
  case "run-dispatched":
1468
1472
  return event.issueState ? `Dispatched from ${event.issueState}` : "Dispatched";
1469
1473
  case "run-recovered":
@@ -1528,6 +1532,42 @@ function parseRunEventLine(line) {
1528
1532
  }
1529
1533
  }
1530
1534
 
1535
+ // ../core/src/observability/redaction.ts
1536
+ var REDACTED = "[REDACTED]";
1537
+ var SENSITIVE_KEY_SUBSTRINGS = [
1538
+ "authorization",
1539
+ "secret",
1540
+ "apiKey",
1541
+ "api-key",
1542
+ "api_key"
1543
+ ];
1544
+ function redactObservabilitySecrets(value) {
1545
+ return redactValue(value);
1546
+ }
1547
+ function redactValue(value) {
1548
+ if (Array.isArray(value)) {
1549
+ return value.map((item) => redactValue(item));
1550
+ }
1551
+ if (!isRecord3(value)) {
1552
+ return value;
1553
+ }
1554
+ return Object.fromEntries(
1555
+ Object.entries(value).map(([key, nested]) => [
1556
+ key,
1557
+ shouldRedactKey(key) ? REDACTED : redactValue(nested)
1558
+ ])
1559
+ );
1560
+ }
1561
+ function shouldRedactKey(key) {
1562
+ const normalizedKey = key.toLowerCase();
1563
+ return normalizedKey === "token" || normalizedKey.endsWith("token") || SENSITIVE_KEY_SUBSTRINGS.some(
1564
+ (pattern) => normalizedKey.includes(pattern.toLowerCase())
1565
+ );
1566
+ }
1567
+ function isRecord3(value) {
1568
+ return value != null && typeof value === "object";
1569
+ }
1570
+
1531
1571
  // ../core/src/observability/status-assembler.ts
1532
1572
  function isMatchingIssueRun(run, issueId, issueIdentifier) {
1533
1573
  return Boolean(
@@ -1853,108 +1893,3018 @@ function resolveShellCommandClaudeBinary(command) {
1853
1893
  }
1854
1894
  }
1855
1895
  }
1856
- return null;
1857
- }
1858
- function isClaudeBinaryName(command) {
1859
- const normalized = (command.split(/[\\/]/).pop() ?? command).toLowerCase().replace(/\.(exe|cmd|bat)$/i, "");
1860
- return normalized === "claude" || normalized === "claude-code";
1861
- }
1862
-
1863
- // ../runtime-claude/src/adapter.ts
1864
- import { randomUUID } from "crypto";
1865
- import { rm } from "fs/promises";
1866
- import { join as join5 } from "path";
1867
-
1868
- // ../runtime-claude/src/argv.ts
1869
- var DEFAULT_CLAUDE_PRINT_ARGS = [
1870
- "-p",
1871
- "--output-format",
1872
- "stream-json",
1873
- "--input-format",
1874
- "stream-json",
1875
- "--include-partial-messages",
1876
- // Claude stream-json output requires verbose mode when partial message
1877
- // events are included; keep this even when callers provide custom args.
1878
- "--verbose",
1879
- "--permission-mode",
1880
- "bypassPermissions"
1881
- ];
1882
- function buildClaudePrintArgv(options = {}) {
1883
- const args = options.baseArgs ? withRequiredClaudePrintArgs(options.baseArgs) : [...DEFAULT_CLAUDE_PRINT_ARGS];
1884
- const { session, isolation, extraArgs } = options;
1885
- if (session?.mode === "start") {
1886
- ensureFlagValue(args, "--session-id", session.sessionId);
1896
+ return null;
1897
+ }
1898
+ function isClaudeBinaryName(command) {
1899
+ const normalized = (command.split(/[\\/]/).pop() ?? command).toLowerCase().replace(/\.(exe|cmd|bat)$/i, "");
1900
+ return normalized === "claude" || normalized === "claude-code";
1901
+ }
1902
+
1903
+ // ../runtime-claude/src/adapter.ts
1904
+ import { randomUUID } from "crypto";
1905
+ import { rm } from "fs/promises";
1906
+ import { join as join5 } from "path";
1907
+
1908
+ // ../runtime-claude/src/argv.ts
1909
+ var DEFAULT_CLAUDE_PRINT_ARGS = [
1910
+ "-p",
1911
+ "--output-format",
1912
+ "stream-json",
1913
+ "--input-format",
1914
+ "stream-json",
1915
+ "--include-partial-messages",
1916
+ // Claude stream-json output requires verbose mode when partial message
1917
+ // events are included; keep this even when callers provide custom args.
1918
+ "--verbose",
1919
+ "--permission-mode",
1920
+ "bypassPermissions"
1921
+ ];
1922
+ function buildClaudePrintArgv(options = {}) {
1923
+ const args = options.baseArgs ? withRequiredClaudePrintArgs(options.baseArgs) : [...DEFAULT_CLAUDE_PRINT_ARGS];
1924
+ const { session, isolation, extraArgs } = options;
1925
+ if (session?.mode === "start") {
1926
+ ensureFlagValue(args, "--session-id", session.sessionId);
1927
+ }
1928
+ if (session?.mode === "resume") {
1929
+ ensureFlagValue(args, "--resume", session.sessionId);
1930
+ if (session.forkSession) {
1931
+ ensureFlag(args, "--fork-session");
1932
+ }
1933
+ }
1934
+ if (isolation?.bare) {
1935
+ ensureFlag(args, "--bare");
1936
+ }
1937
+ if (isolation?.strictMcpConfig) {
1938
+ ensureFlag(args, "--strict-mcp-config");
1939
+ if (isolation.mcpConfigPath) {
1940
+ ensureFlagValue(args, "--mcp-config", isolation.mcpConfigPath);
1941
+ }
1942
+ }
1943
+ if (extraArgs?.length) {
1944
+ args.push(...extraArgs);
1945
+ }
1946
+ return args;
1947
+ }
1948
+ function withRequiredClaudePrintArgs(baseArgs) {
1949
+ const args = [...baseArgs];
1950
+ ensureFlag(args, "-p");
1951
+ ensureFlagValue(args, "--output-format", "stream-json");
1952
+ ensureFlagValue(args, "--input-format", "stream-json");
1953
+ ensureFlag(args, "--include-partial-messages");
1954
+ ensureFlag(args, "--verbose");
1955
+ ensureFlagValue(args, "--permission-mode", "bypassPermissions");
1956
+ return args;
1957
+ }
1958
+ function ensureFlag(args, flag) {
1959
+ if (!args.includes(flag)) {
1960
+ args.push(flag);
1961
+ }
1962
+ }
1963
+ function ensureFlagValue(args, flag, value) {
1964
+ const index = args.indexOf(flag);
1965
+ if (index === -1) {
1966
+ args.push(flag, value);
1967
+ return;
1968
+ }
1969
+ const existingValue = args[index + 1];
1970
+ if (existingValue?.startsWith("-")) {
1971
+ args.splice(index + 1, 0, value);
1972
+ return;
1973
+ }
1974
+ if (existingValue !== value) {
1975
+ args.splice(index + 1, existingValue === void 0 ? 0 : 1, value);
1976
+ }
1977
+ }
1978
+
1979
+ // ../runtime-claude/src/mcp-compose.ts
1980
+ import { mkdir, readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
1981
+ import { basename, dirname, join as join3, resolve as resolve4 } from "path";
1982
+
1983
+ // ../tool-github-graphql/src/tool.ts
1984
+ import { readFile as readFile5, writeFile as writeFile2 } from "fs/promises";
1985
+ var DEFAULT_GITHUB_GRAPHQL_API_URL = "https://api.github.com/graphql";
1986
+ var TOKEN_REUSE_WINDOW_MS2 = 60 * 1e3;
1987
+ async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
1988
+ const token = await resolveGitHubGraphQLToken(config, {
1989
+ fetchImpl
1990
+ });
1991
+ const response = await fetchImpl(
1992
+ config.apiUrl ?? DEFAULT_GITHUB_GRAPHQL_API_URL,
1993
+ {
1994
+ method: "POST",
1995
+ headers: {
1996
+ "content-type": "application/json",
1997
+ authorization: `Bearer ${token}`
1998
+ },
1999
+ body: JSON.stringify(invocation)
2000
+ }
2001
+ );
2002
+ const payload = await response.json();
2003
+ if (!response.ok) {
2004
+ throw new Error(
2005
+ `GitHub GraphQL request failed with status ${response.status}: ${JSON.stringify(payload)}`
2006
+ );
2007
+ }
2008
+ if (payload.errors?.length) {
2009
+ throw new Error(payload.errors.map((error) => error.message).join("; "));
2010
+ }
2011
+ return payload;
2012
+ }
2013
+ async function resolveGitHubGraphQLToken(config, dependencies = {}) {
2014
+ if (config.token) {
2015
+ return config.token;
2016
+ }
2017
+ if (!config.tokenBrokerUrl || !config.tokenBrokerSecret) {
2018
+ throw new Error(
2019
+ "Either GITHUB_GRAPHQL_TOKEN or the runtime token broker configuration is required."
2020
+ );
2021
+ }
2022
+ const now = dependencies.now ?? /* @__PURE__ */ new Date();
2023
+ const readFileImpl = dependencies.readFileImpl ?? readFile5;
2024
+ const writeFileImpl = dependencies.writeFileImpl ?? writeFile2;
2025
+ const cachedToken = config.tokenCachePath ? await readCachedToken(config.tokenCachePath, readFileImpl) : null;
2026
+ if (cachedToken && cachedToken.expiresAt.getTime() - now.getTime() > TOKEN_REUSE_WINDOW_MS2) {
2027
+ return cachedToken.token;
2028
+ }
2029
+ const fetchImpl = dependencies.fetchImpl ?? fetch;
2030
+ const response = await fetchImpl(config.tokenBrokerUrl, {
2031
+ method: "POST",
2032
+ headers: {
2033
+ accept: "application/json",
2034
+ authorization: `Bearer ${config.tokenBrokerSecret}`
2035
+ }
2036
+ });
2037
+ const payload = await response.json();
2038
+ if (!response.ok || !payload.token || !payload.expiresAt) {
2039
+ throw new Error(
2040
+ payload.error ?? `Runtime token broker request failed with status ${response.status}.`
2041
+ );
2042
+ }
2043
+ if (config.tokenCachePath) {
2044
+ await writeFileImpl(config.tokenCachePath, JSON.stringify(payload), "utf8");
2045
+ }
2046
+ return payload.token;
2047
+ }
2048
+ async function readStdin() {
2049
+ const chunks = [];
2050
+ for await (const chunk of process.stdin) {
2051
+ chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
2052
+ }
2053
+ return Buffer.concat(chunks).toString("utf8");
2054
+ }
2055
+ async function main() {
2056
+ const rawInput = await readStdin();
2057
+ const invocation = JSON.parse(rawInput);
2058
+ const result = await executeGitHubGraphQL(invocation, {
2059
+ token: process.env.GITHUB_GRAPHQL_TOKEN,
2060
+ apiUrl: process.env.GITHUB_GRAPHQL_API_URL,
2061
+ tokenBrokerUrl: process.env.GITHUB_TOKEN_BROKER_URL,
2062
+ tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
2063
+ tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
2064
+ });
2065
+ process.stdout.write(`${JSON.stringify(result)}
2066
+ `);
2067
+ }
2068
+ if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
2069
+ main().catch((error) => {
2070
+ const message = error instanceof Error ? error.message : "Unknown error";
2071
+ process.stderr.write(`${message}
2072
+ `);
2073
+ process.exitCode = 1;
2074
+ });
2075
+ }
2076
+ async function readCachedToken(path, readFileImpl) {
2077
+ try {
2078
+ const payload = JSON.parse(await readFileImpl(path, "utf8"));
2079
+ if (!payload.token || !payload.expiresAt) {
2080
+ return null;
2081
+ }
2082
+ return {
2083
+ token: payload.token,
2084
+ expiresAt: new Date(payload.expiresAt)
2085
+ };
2086
+ } catch {
2087
+ return null;
2088
+ }
2089
+ }
2090
+
2091
+ // ../tool-github-graphql/src/mcp-server.ts
2092
+ import { fileURLToPath } from "url";
2093
+ var TOOL_SCHEMA = {
2094
+ name: "github_graphql",
2095
+ description: "Execute GitHub GraphQL queries for the active workspace so the agent can mutate project and issue state directly.",
2096
+ inputSchema: {
2097
+ type: "object",
2098
+ properties: {
2099
+ query: {
2100
+ type: "string",
2101
+ description: "GraphQL query or mutation document."
2102
+ },
2103
+ variables: {
2104
+ type: "object",
2105
+ description: "Variables for the GraphQL document."
2106
+ },
2107
+ operationName: {
2108
+ type: "string",
2109
+ description: "Optional GraphQL operation name."
2110
+ }
2111
+ },
2112
+ required: ["query"],
2113
+ additionalProperties: false
2114
+ }
2115
+ };
2116
+ var lineBuffer = "";
2117
+ function resolveGitHubGraphQLMcpServerEntryPoint() {
2118
+ return fileURLToPath(new URL("./mcp-server.js", import.meta.url));
2119
+ }
2120
+ function sendResponse(id, result) {
2121
+ const msg = JSON.stringify({ jsonrpc: "2.0", id, result });
2122
+ process.stdout.write(msg + "\n");
2123
+ }
2124
+ function sendError(id, code, message) {
2125
+ const msg = JSON.stringify({
2126
+ jsonrpc: "2.0",
2127
+ id,
2128
+ error: { code, message }
2129
+ });
2130
+ process.stdout.write(msg + "\n");
2131
+ }
2132
+ async function handleRequest(msg) {
2133
+ const id = msg.id ?? null;
2134
+ switch (msg.method) {
2135
+ case "initialize": {
2136
+ sendResponse(id, {
2137
+ protocolVersion: "2024-11-05",
2138
+ capabilities: { tools: {} },
2139
+ serverInfo: {
2140
+ name: "github-symphony-graphql",
2141
+ version: "0.1.0"
2142
+ }
2143
+ });
2144
+ process.stdout.write(
2145
+ JSON.stringify({
2146
+ jsonrpc: "2.0",
2147
+ method: "notifications/initialized"
2148
+ }) + "\n"
2149
+ );
2150
+ break;
2151
+ }
2152
+ case "tools/list": {
2153
+ sendResponse(id, { tools: [TOOL_SCHEMA] });
2154
+ break;
2155
+ }
2156
+ case "tools/call": {
2157
+ const params = msg.params;
2158
+ if (params.name !== "github_graphql") {
2159
+ sendError(id, -32602, `Unknown tool: ${params.name}`);
2160
+ return;
2161
+ }
2162
+ const args = params.arguments ?? {};
2163
+ const invocation = {
2164
+ query: args.query,
2165
+ variables: args.variables,
2166
+ operationName: args.operationName
2167
+ };
2168
+ try {
2169
+ const result = await executeGitHubGraphQL(invocation, {
2170
+ token: process.env.GITHUB_GRAPHQL_TOKEN,
2171
+ apiUrl: process.env.GITHUB_GRAPHQL_API_URL,
2172
+ tokenBrokerUrl: process.env.GITHUB_TOKEN_BROKER_URL,
2173
+ tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
2174
+ tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
2175
+ });
2176
+ sendResponse(id, {
2177
+ content: [
2178
+ {
2179
+ type: "text",
2180
+ text: JSON.stringify(result, null, 2)
2181
+ }
2182
+ ]
2183
+ });
2184
+ } catch (err) {
2185
+ const message = err instanceof Error ? err.message : String(err);
2186
+ sendResponse(id, {
2187
+ content: [{ type: "text", text: message }],
2188
+ isError: true
2189
+ });
2190
+ }
2191
+ break;
2192
+ }
2193
+ case "notifications/initialized":
2194
+ case "ping": {
2195
+ if (id !== null && id !== void 0) {
2196
+ sendResponse(id, {});
2197
+ }
2198
+ break;
2199
+ }
2200
+ default: {
2201
+ if (id !== null && id !== void 0) {
2202
+ sendError(id, -32601, `Method not found: ${msg.method}`);
2203
+ }
2204
+ }
2205
+ }
2206
+ }
2207
+ async function main2() {
2208
+ process.stdin.setEncoding("utf8");
2209
+ process.stdin.on("data", (chunk) => {
2210
+ lineBuffer += chunk;
2211
+ const lines = lineBuffer.split("\n");
2212
+ lineBuffer = lines.pop() ?? "";
2213
+ for (const line of lines) {
2214
+ const trimmed = line.trim();
2215
+ if (!trimmed) continue;
2216
+ try {
2217
+ const msg = JSON.parse(trimmed);
2218
+ void handleRequest(msg);
2219
+ } catch (err) {
2220
+ process.stderr.write(
2221
+ `[github-graphql-mcp] parse error: ${err instanceof Error ? err.message : String(err)}
2222
+ `
2223
+ );
2224
+ }
2225
+ }
2226
+ });
2227
+ process.stdin.on("end", () => {
2228
+ process.exit(0);
2229
+ });
2230
+ }
2231
+ if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
2232
+ main2().catch((err) => {
2233
+ process.stderr.write(
2234
+ `[github-graphql-mcp] fatal: ${err instanceof Error ? err.message : String(err)}
2235
+ `
2236
+ );
2237
+ process.exitCode = 1;
2238
+ });
2239
+ }
2240
+
2241
+ // ../tool-github-graphql/src/mcp-entry.ts
2242
+ var DEFAULT_GITHUB_GRAPHQL_API_URL2 = "https://api.github.com/graphql";
2243
+ function createGitHubGraphQLMcpServerEntry(options = {}) {
2244
+ return {
2245
+ command: "node",
2246
+ args: [resolveGitHubGraphQLMcpServerEntryPoint()],
2247
+ env: {
2248
+ GITHUB_GRAPHQL_API_URL: options.githubGraphqlApiUrl ?? DEFAULT_GITHUB_GRAPHQL_API_URL2,
2249
+ ...options.githubToken ? {
2250
+ GITHUB_GRAPHQL_TOKEN: options.githubToken
2251
+ } : {},
2252
+ ...options.githubTokenBrokerUrl ? {
2253
+ GITHUB_TOKEN_BROKER_URL: options.githubTokenBrokerUrl
2254
+ } : {},
2255
+ ...options.githubTokenBrokerSecret ? {
2256
+ GITHUB_TOKEN_BROKER_SECRET: options.githubTokenBrokerSecret
2257
+ } : {},
2258
+ ...options.githubTokenCachePath ? {
2259
+ GITHUB_TOKEN_CACHE_PATH: options.githubTokenCachePath
2260
+ } : {},
2261
+ ...options.githubProjectId ? {
2262
+ GITHUB_PROJECT_ID: options.githubProjectId
2263
+ } : {}
2264
+ }
2265
+ };
2266
+ }
2267
+
2268
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/devAssert.mjs
2269
+ function devAssert(condition, message) {
2270
+ const booleanCondition = Boolean(condition);
2271
+ if (!booleanCondition) {
2272
+ throw new Error(message);
2273
+ }
2274
+ }
2275
+
2276
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/isObjectLike.mjs
2277
+ function isObjectLike(value) {
2278
+ return typeof value == "object" && value !== null;
2279
+ }
2280
+
2281
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/invariant.mjs
2282
+ function invariant(condition, message) {
2283
+ const booleanCondition = Boolean(condition);
2284
+ if (!booleanCondition) {
2285
+ throw new Error(
2286
+ message != null ? message : "Unexpected invariant triggered."
2287
+ );
2288
+ }
2289
+ }
2290
+
2291
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/location.mjs
2292
+ var LineRegExp = /\r\n|[\n\r]/g;
2293
+ function getLocation(source, position) {
2294
+ let lastLineStart = 0;
2295
+ let line = 1;
2296
+ for (const match of source.body.matchAll(LineRegExp)) {
2297
+ typeof match.index === "number" || invariant(false);
2298
+ if (match.index >= position) {
2299
+ break;
2300
+ }
2301
+ lastLineStart = match.index + match[0].length;
2302
+ line += 1;
2303
+ }
2304
+ return {
2305
+ line,
2306
+ column: position + 1 - lastLineStart
2307
+ };
2308
+ }
2309
+
2310
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/printLocation.mjs
2311
+ function printLocation(location) {
2312
+ return printSourceLocation(
2313
+ location.source,
2314
+ getLocation(location.source, location.start)
2315
+ );
2316
+ }
2317
+ function printSourceLocation(source, sourceLocation) {
2318
+ const firstLineColumnOffset = source.locationOffset.column - 1;
2319
+ const body = "".padStart(firstLineColumnOffset) + source.body;
2320
+ const lineIndex = sourceLocation.line - 1;
2321
+ const lineOffset = source.locationOffset.line - 1;
2322
+ const lineNum = sourceLocation.line + lineOffset;
2323
+ const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
2324
+ const columnNum = sourceLocation.column + columnOffset;
2325
+ const locationStr = `${source.name}:${lineNum}:${columnNum}
2326
+ `;
2327
+ const lines = body.split(/\r\n|[\n\r]/g);
2328
+ const locationLine = lines[lineIndex];
2329
+ if (locationLine.length > 120) {
2330
+ const subLineIndex = Math.floor(columnNum / 80);
2331
+ const subLineColumnNum = columnNum % 80;
2332
+ const subLines = [];
2333
+ for (let i = 0; i < locationLine.length; i += 80) {
2334
+ subLines.push(locationLine.slice(i, i + 80));
2335
+ }
2336
+ return locationStr + printPrefixedLines([
2337
+ [`${lineNum} |`, subLines[0]],
2338
+ ...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
2339
+ ["|", "^".padStart(subLineColumnNum)],
2340
+ ["|", subLines[subLineIndex + 1]]
2341
+ ]);
2342
+ }
2343
+ return locationStr + printPrefixedLines([
2344
+ // Lines specified like this: ["prefix", "string"],
2345
+ [`${lineNum - 1} |`, lines[lineIndex - 1]],
2346
+ [`${lineNum} |`, locationLine],
2347
+ ["|", "^".padStart(columnNum)],
2348
+ [`${lineNum + 1} |`, lines[lineIndex + 1]]
2349
+ ]);
2350
+ }
2351
+ function printPrefixedLines(lines) {
2352
+ const existingLines = lines.filter(([_, line]) => line !== void 0);
2353
+ const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
2354
+ return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
2355
+ }
2356
+
2357
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/error/GraphQLError.mjs
2358
+ function toNormalizedOptions(args) {
2359
+ const firstArg = args[0];
2360
+ if (firstArg == null || "kind" in firstArg || "length" in firstArg) {
2361
+ return {
2362
+ nodes: firstArg,
2363
+ source: args[1],
2364
+ positions: args[2],
2365
+ path: args[3],
2366
+ originalError: args[4],
2367
+ extensions: args[5]
2368
+ };
2369
+ }
2370
+ return firstArg;
2371
+ }
2372
+ var GraphQLError = class _GraphQLError extends Error {
2373
+ /**
2374
+ * An array of `{ line, column }` locations within the source GraphQL document
2375
+ * which correspond to this error.
2376
+ *
2377
+ * Errors during validation often contain multiple locations, for example to
2378
+ * point out two things with the same name. Errors during execution include a
2379
+ * single location, the field which produced the error.
2380
+ *
2381
+ * Enumerable, and appears in the result of JSON.stringify().
2382
+ */
2383
+ /**
2384
+ * An array describing the JSON-path into the execution response which
2385
+ * corresponds to this error. Only included for errors during execution.
2386
+ *
2387
+ * Enumerable, and appears in the result of JSON.stringify().
2388
+ */
2389
+ /**
2390
+ * An array of GraphQL AST Nodes corresponding to this error.
2391
+ */
2392
+ /**
2393
+ * The source GraphQL document for the first location of this error.
2394
+ *
2395
+ * Note that if this Error represents more than one node, the source may not
2396
+ * represent nodes after the first node.
2397
+ */
2398
+ /**
2399
+ * An array of character offsets within the source GraphQL document
2400
+ * which correspond to this error.
2401
+ */
2402
+ /**
2403
+ * The original error thrown from a field resolver during execution.
2404
+ */
2405
+ /**
2406
+ * Extension fields to add to the formatted error.
2407
+ */
2408
+ /**
2409
+ * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
2410
+ */
2411
+ constructor(message, ...rawArgs) {
2412
+ var _this$nodes, _nodeLocations$, _ref;
2413
+ const { nodes, source, positions, path, originalError, extensions } = toNormalizedOptions(rawArgs);
2414
+ super(message);
2415
+ this.name = "GraphQLError";
2416
+ this.path = path !== null && path !== void 0 ? path : void 0;
2417
+ this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
2418
+ this.nodes = undefinedIfEmpty(
2419
+ Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0
2420
+ );
2421
+ const nodeLocations = undefinedIfEmpty(
2422
+ (_this$nodes = this.nodes) === null || _this$nodes === void 0 ? void 0 : _this$nodes.map((node) => node.loc).filter((loc) => loc != null)
2423
+ );
2424
+ this.source = source !== null && source !== void 0 ? source : nodeLocations === null || nodeLocations === void 0 ? void 0 : (_nodeLocations$ = nodeLocations[0]) === null || _nodeLocations$ === void 0 ? void 0 : _nodeLocations$.source;
2425
+ this.positions = positions !== null && positions !== void 0 ? positions : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => loc.start);
2426
+ this.locations = positions && source ? positions.map((pos) => getLocation(source, pos)) : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => getLocation(loc.source, loc.start));
2427
+ const originalExtensions = isObjectLike(
2428
+ originalError === null || originalError === void 0 ? void 0 : originalError.extensions
2429
+ ) ? originalError === null || originalError === void 0 ? void 0 : originalError.extensions : void 0;
2430
+ this.extensions = (_ref = extensions !== null && extensions !== void 0 ? extensions : originalExtensions) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */ Object.create(null);
2431
+ Object.defineProperties(this, {
2432
+ message: {
2433
+ writable: true,
2434
+ enumerable: true
2435
+ },
2436
+ name: {
2437
+ enumerable: false
2438
+ },
2439
+ nodes: {
2440
+ enumerable: false
2441
+ },
2442
+ source: {
2443
+ enumerable: false
2444
+ },
2445
+ positions: {
2446
+ enumerable: false
2447
+ },
2448
+ originalError: {
2449
+ enumerable: false
2450
+ }
2451
+ });
2452
+ if (originalError !== null && originalError !== void 0 && originalError.stack) {
2453
+ Object.defineProperty(this, "stack", {
2454
+ value: originalError.stack,
2455
+ writable: true,
2456
+ configurable: true
2457
+ });
2458
+ } else if (Error.captureStackTrace) {
2459
+ Error.captureStackTrace(this, _GraphQLError);
2460
+ } else {
2461
+ Object.defineProperty(this, "stack", {
2462
+ value: Error().stack,
2463
+ writable: true,
2464
+ configurable: true
2465
+ });
2466
+ }
2467
+ }
2468
+ get [Symbol.toStringTag]() {
2469
+ return "GraphQLError";
2470
+ }
2471
+ toString() {
2472
+ let output = this.message;
2473
+ if (this.nodes) {
2474
+ for (const node of this.nodes) {
2475
+ if (node.loc) {
2476
+ output += "\n\n" + printLocation(node.loc);
2477
+ }
2478
+ }
2479
+ } else if (this.source && this.locations) {
2480
+ for (const location of this.locations) {
2481
+ output += "\n\n" + printSourceLocation(this.source, location);
2482
+ }
2483
+ }
2484
+ return output;
2485
+ }
2486
+ toJSON() {
2487
+ const formattedError = {
2488
+ message: this.message
2489
+ };
2490
+ if (this.locations != null) {
2491
+ formattedError.locations = this.locations;
2492
+ }
2493
+ if (this.path != null) {
2494
+ formattedError.path = this.path;
2495
+ }
2496
+ if (this.extensions != null && Object.keys(this.extensions).length > 0) {
2497
+ formattedError.extensions = this.extensions;
2498
+ }
2499
+ return formattedError;
2500
+ }
2501
+ };
2502
+ function undefinedIfEmpty(array) {
2503
+ return array === void 0 || array.length === 0 ? void 0 : array;
2504
+ }
2505
+
2506
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/error/syntaxError.mjs
2507
+ function syntaxError(source, position, description) {
2508
+ return new GraphQLError(`Syntax Error: ${description}`, {
2509
+ source,
2510
+ positions: [position]
2511
+ });
2512
+ }
2513
+
2514
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/ast.mjs
2515
+ var Location = class {
2516
+ /**
2517
+ * The character offset at which this Node begins.
2518
+ */
2519
+ /**
2520
+ * The character offset at which this Node ends.
2521
+ */
2522
+ /**
2523
+ * The Token at which this Node begins.
2524
+ */
2525
+ /**
2526
+ * The Token at which this Node ends.
2527
+ */
2528
+ /**
2529
+ * The Source document the AST represents.
2530
+ */
2531
+ constructor(startToken, endToken, source) {
2532
+ this.start = startToken.start;
2533
+ this.end = endToken.end;
2534
+ this.startToken = startToken;
2535
+ this.endToken = endToken;
2536
+ this.source = source;
2537
+ }
2538
+ get [Symbol.toStringTag]() {
2539
+ return "Location";
2540
+ }
2541
+ toJSON() {
2542
+ return {
2543
+ start: this.start,
2544
+ end: this.end
2545
+ };
2546
+ }
2547
+ };
2548
+ var Token = class {
2549
+ /**
2550
+ * The kind of Token.
2551
+ */
2552
+ /**
2553
+ * The character offset at which this Node begins.
2554
+ */
2555
+ /**
2556
+ * The character offset at which this Node ends.
2557
+ */
2558
+ /**
2559
+ * The 1-indexed line number on which this Token appears.
2560
+ */
2561
+ /**
2562
+ * The 1-indexed column number at which this Token begins.
2563
+ */
2564
+ /**
2565
+ * For non-punctuation tokens, represents the interpreted value of the token.
2566
+ *
2567
+ * Note: is undefined for punctuation tokens, but typed as string for
2568
+ * convenience in the parser.
2569
+ */
2570
+ /**
2571
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
2572
+ * including ignored tokens. <SOF> is always the first node and <EOF>
2573
+ * the last.
2574
+ */
2575
+ constructor(kind, start, end, line, column, value) {
2576
+ this.kind = kind;
2577
+ this.start = start;
2578
+ this.end = end;
2579
+ this.line = line;
2580
+ this.column = column;
2581
+ this.value = value;
2582
+ this.prev = null;
2583
+ this.next = null;
2584
+ }
2585
+ get [Symbol.toStringTag]() {
2586
+ return "Token";
2587
+ }
2588
+ toJSON() {
2589
+ return {
2590
+ kind: this.kind,
2591
+ value: this.value,
2592
+ line: this.line,
2593
+ column: this.column
2594
+ };
2595
+ }
2596
+ };
2597
+ var QueryDocumentKeys = {
2598
+ Name: [],
2599
+ Document: ["definitions"],
2600
+ OperationDefinition: [
2601
+ "description",
2602
+ "name",
2603
+ "variableDefinitions",
2604
+ "directives",
2605
+ "selectionSet"
2606
+ ],
2607
+ VariableDefinition: [
2608
+ "description",
2609
+ "variable",
2610
+ "type",
2611
+ "defaultValue",
2612
+ "directives"
2613
+ ],
2614
+ Variable: ["name"],
2615
+ SelectionSet: ["selections"],
2616
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
2617
+ Argument: ["name", "value"],
2618
+ FragmentSpread: ["name", "directives"],
2619
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
2620
+ FragmentDefinition: [
2621
+ "description",
2622
+ "name",
2623
+ // Note: fragment variable definitions are deprecated and will removed in v17.0.0
2624
+ "variableDefinitions",
2625
+ "typeCondition",
2626
+ "directives",
2627
+ "selectionSet"
2628
+ ],
2629
+ IntValue: [],
2630
+ FloatValue: [],
2631
+ StringValue: [],
2632
+ BooleanValue: [],
2633
+ NullValue: [],
2634
+ EnumValue: [],
2635
+ ListValue: ["values"],
2636
+ ObjectValue: ["fields"],
2637
+ ObjectField: ["name", "value"],
2638
+ Directive: ["name", "arguments"],
2639
+ NamedType: ["name"],
2640
+ ListType: ["type"],
2641
+ NonNullType: ["type"],
2642
+ SchemaDefinition: ["description", "directives", "operationTypes"],
2643
+ OperationTypeDefinition: ["type"],
2644
+ ScalarTypeDefinition: ["description", "name", "directives"],
2645
+ ObjectTypeDefinition: [
2646
+ "description",
2647
+ "name",
2648
+ "interfaces",
2649
+ "directives",
2650
+ "fields"
2651
+ ],
2652
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
2653
+ InputValueDefinition: [
2654
+ "description",
2655
+ "name",
2656
+ "type",
2657
+ "defaultValue",
2658
+ "directives"
2659
+ ],
2660
+ InterfaceTypeDefinition: [
2661
+ "description",
2662
+ "name",
2663
+ "interfaces",
2664
+ "directives",
2665
+ "fields"
2666
+ ],
2667
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
2668
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
2669
+ EnumValueDefinition: ["description", "name", "directives"],
2670
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
2671
+ DirectiveDefinition: [
2672
+ "description",
2673
+ "name",
2674
+ "arguments",
2675
+ "directives",
2676
+ "locations"
2677
+ ],
2678
+ SchemaExtension: ["directives", "operationTypes"],
2679
+ DirectiveExtension: ["name", "directives"],
2680
+ ScalarTypeExtension: ["name", "directives"],
2681
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
2682
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
2683
+ UnionTypeExtension: ["name", "directives", "types"],
2684
+ EnumTypeExtension: ["name", "directives", "values"],
2685
+ InputObjectTypeExtension: ["name", "directives", "fields"],
2686
+ TypeCoordinate: ["name"],
2687
+ MemberCoordinate: ["name", "memberName"],
2688
+ ArgumentCoordinate: ["name", "fieldName", "argumentName"],
2689
+ DirectiveCoordinate: ["name"],
2690
+ DirectiveArgumentCoordinate: ["name", "argumentName"]
2691
+ };
2692
+ var kindValues = new Set(Object.keys(QueryDocumentKeys));
2693
+ var OperationTypeNode;
2694
+ (function(OperationTypeNode2) {
2695
+ OperationTypeNode2["QUERY"] = "query";
2696
+ OperationTypeNode2["MUTATION"] = "mutation";
2697
+ OperationTypeNode2["SUBSCRIPTION"] = "subscription";
2698
+ })(OperationTypeNode || (OperationTypeNode = {}));
2699
+
2700
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/directiveLocation.mjs
2701
+ var DirectiveLocation;
2702
+ (function(DirectiveLocation2) {
2703
+ DirectiveLocation2["QUERY"] = "QUERY";
2704
+ DirectiveLocation2["MUTATION"] = "MUTATION";
2705
+ DirectiveLocation2["SUBSCRIPTION"] = "SUBSCRIPTION";
2706
+ DirectiveLocation2["FIELD"] = "FIELD";
2707
+ DirectiveLocation2["FRAGMENT_DEFINITION"] = "FRAGMENT_DEFINITION";
2708
+ DirectiveLocation2["FRAGMENT_SPREAD"] = "FRAGMENT_SPREAD";
2709
+ DirectiveLocation2["INLINE_FRAGMENT"] = "INLINE_FRAGMENT";
2710
+ DirectiveLocation2["VARIABLE_DEFINITION"] = "VARIABLE_DEFINITION";
2711
+ DirectiveLocation2["SCHEMA"] = "SCHEMA";
2712
+ DirectiveLocation2["SCALAR"] = "SCALAR";
2713
+ DirectiveLocation2["OBJECT"] = "OBJECT";
2714
+ DirectiveLocation2["FIELD_DEFINITION"] = "FIELD_DEFINITION";
2715
+ DirectiveLocation2["ARGUMENT_DEFINITION"] = "ARGUMENT_DEFINITION";
2716
+ DirectiveLocation2["INTERFACE"] = "INTERFACE";
2717
+ DirectiveLocation2["UNION"] = "UNION";
2718
+ DirectiveLocation2["ENUM"] = "ENUM";
2719
+ DirectiveLocation2["ENUM_VALUE"] = "ENUM_VALUE";
2720
+ DirectiveLocation2["INPUT_OBJECT"] = "INPUT_OBJECT";
2721
+ DirectiveLocation2["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
2722
+ DirectiveLocation2["DIRECTIVE_DEFINITION"] = "DIRECTIVE_DEFINITION";
2723
+ })(DirectiveLocation || (DirectiveLocation = {}));
2724
+
2725
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/kinds.mjs
2726
+ var Kind;
2727
+ (function(Kind2) {
2728
+ Kind2["NAME"] = "Name";
2729
+ Kind2["DOCUMENT"] = "Document";
2730
+ Kind2["OPERATION_DEFINITION"] = "OperationDefinition";
2731
+ Kind2["VARIABLE_DEFINITION"] = "VariableDefinition";
2732
+ Kind2["SELECTION_SET"] = "SelectionSet";
2733
+ Kind2["FIELD"] = "Field";
2734
+ Kind2["ARGUMENT"] = "Argument";
2735
+ Kind2["FRAGMENT_SPREAD"] = "FragmentSpread";
2736
+ Kind2["INLINE_FRAGMENT"] = "InlineFragment";
2737
+ Kind2["FRAGMENT_DEFINITION"] = "FragmentDefinition";
2738
+ Kind2["VARIABLE"] = "Variable";
2739
+ Kind2["INT"] = "IntValue";
2740
+ Kind2["FLOAT"] = "FloatValue";
2741
+ Kind2["STRING"] = "StringValue";
2742
+ Kind2["BOOLEAN"] = "BooleanValue";
2743
+ Kind2["NULL"] = "NullValue";
2744
+ Kind2["ENUM"] = "EnumValue";
2745
+ Kind2["LIST"] = "ListValue";
2746
+ Kind2["OBJECT"] = "ObjectValue";
2747
+ Kind2["OBJECT_FIELD"] = "ObjectField";
2748
+ Kind2["DIRECTIVE"] = "Directive";
2749
+ Kind2["NAMED_TYPE"] = "NamedType";
2750
+ Kind2["LIST_TYPE"] = "ListType";
2751
+ Kind2["NON_NULL_TYPE"] = "NonNullType";
2752
+ Kind2["SCHEMA_DEFINITION"] = "SchemaDefinition";
2753
+ Kind2["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
2754
+ Kind2["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
2755
+ Kind2["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
2756
+ Kind2["FIELD_DEFINITION"] = "FieldDefinition";
2757
+ Kind2["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
2758
+ Kind2["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
2759
+ Kind2["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
2760
+ Kind2["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
2761
+ Kind2["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
2762
+ Kind2["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
2763
+ Kind2["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
2764
+ Kind2["SCHEMA_EXTENSION"] = "SchemaExtension";
2765
+ Kind2["DIRECTIVE_EXTENSION"] = "DirectiveExtension";
2766
+ Kind2["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
2767
+ Kind2["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
2768
+ Kind2["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
2769
+ Kind2["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
2770
+ Kind2["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
2771
+ Kind2["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
2772
+ Kind2["TYPE_COORDINATE"] = "TypeCoordinate";
2773
+ Kind2["MEMBER_COORDINATE"] = "MemberCoordinate";
2774
+ Kind2["ARGUMENT_COORDINATE"] = "ArgumentCoordinate";
2775
+ Kind2["DIRECTIVE_COORDINATE"] = "DirectiveCoordinate";
2776
+ Kind2["DIRECTIVE_ARGUMENT_COORDINATE"] = "DirectiveArgumentCoordinate";
2777
+ })(Kind || (Kind = {}));
2778
+
2779
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/characterClasses.mjs
2780
+ function isWhiteSpace(code) {
2781
+ return code === 9 || code === 32;
2782
+ }
2783
+ function isDigit(code) {
2784
+ return code >= 48 && code <= 57;
2785
+ }
2786
+ function isLetter(code) {
2787
+ return code >= 97 && code <= 122 || // A-Z
2788
+ code >= 65 && code <= 90;
2789
+ }
2790
+ function isNameStart(code) {
2791
+ return isLetter(code) || code === 95;
2792
+ }
2793
+ function isNameContinue(code) {
2794
+ return isLetter(code) || isDigit(code) || code === 95;
2795
+ }
2796
+
2797
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/blockString.mjs
2798
+ function dedentBlockStringLines(lines) {
2799
+ var _firstNonEmptyLine2;
2800
+ let commonIndent = Number.MAX_SAFE_INTEGER;
2801
+ let firstNonEmptyLine = null;
2802
+ let lastNonEmptyLine = -1;
2803
+ for (let i = 0; i < lines.length; ++i) {
2804
+ var _firstNonEmptyLine;
2805
+ const line = lines[i];
2806
+ const indent = leadingWhitespace(line);
2807
+ if (indent === line.length) {
2808
+ continue;
2809
+ }
2810
+ firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i;
2811
+ lastNonEmptyLine = i;
2812
+ if (i !== 0 && indent < commonIndent) {
2813
+ commonIndent = indent;
2814
+ }
2815
+ }
2816
+ return lines.map((line, i) => i === 0 ? line : line.slice(commonIndent)).slice(
2817
+ (_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0,
2818
+ lastNonEmptyLine + 1
2819
+ );
2820
+ }
2821
+ function leadingWhitespace(str) {
2822
+ let i = 0;
2823
+ while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {
2824
+ ++i;
2825
+ }
2826
+ return i;
2827
+ }
2828
+
2829
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/tokenKind.mjs
2830
+ var TokenKind;
2831
+ (function(TokenKind2) {
2832
+ TokenKind2["SOF"] = "<SOF>";
2833
+ TokenKind2["EOF"] = "<EOF>";
2834
+ TokenKind2["BANG"] = "!";
2835
+ TokenKind2["DOLLAR"] = "$";
2836
+ TokenKind2["AMP"] = "&";
2837
+ TokenKind2["PAREN_L"] = "(";
2838
+ TokenKind2["PAREN_R"] = ")";
2839
+ TokenKind2["DOT"] = ".";
2840
+ TokenKind2["SPREAD"] = "...";
2841
+ TokenKind2["COLON"] = ":";
2842
+ TokenKind2["EQUALS"] = "=";
2843
+ TokenKind2["AT"] = "@";
2844
+ TokenKind2["BRACKET_L"] = "[";
2845
+ TokenKind2["BRACKET_R"] = "]";
2846
+ TokenKind2["BRACE_L"] = "{";
2847
+ TokenKind2["PIPE"] = "|";
2848
+ TokenKind2["BRACE_R"] = "}";
2849
+ TokenKind2["NAME"] = "Name";
2850
+ TokenKind2["INT"] = "Int";
2851
+ TokenKind2["FLOAT"] = "Float";
2852
+ TokenKind2["STRING"] = "String";
2853
+ TokenKind2["BLOCK_STRING"] = "BlockString";
2854
+ TokenKind2["COMMENT"] = "Comment";
2855
+ })(TokenKind || (TokenKind = {}));
2856
+
2857
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/lexer.mjs
2858
+ var Lexer = class {
2859
+ /**
2860
+ * The previously focused non-ignored token.
2861
+ */
2862
+ /**
2863
+ * The currently focused non-ignored token.
2864
+ */
2865
+ /**
2866
+ * The (1-indexed) line containing the current token.
2867
+ */
2868
+ /**
2869
+ * The character offset at which the current line begins.
2870
+ */
2871
+ constructor(source) {
2872
+ const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
2873
+ this.source = source;
2874
+ this.lastToken = startOfFileToken;
2875
+ this.token = startOfFileToken;
2876
+ this.line = 1;
2877
+ this.lineStart = 0;
2878
+ }
2879
+ get [Symbol.toStringTag]() {
2880
+ return "Lexer";
2881
+ }
2882
+ /**
2883
+ * Advances the token stream to the next non-ignored token.
2884
+ */
2885
+ advance() {
2886
+ this.lastToken = this.token;
2887
+ const token = this.token = this.lookahead();
2888
+ return token;
2889
+ }
2890
+ /**
2891
+ * Looks ahead and returns the next non-ignored token, but does not change
2892
+ * the state of Lexer.
2893
+ */
2894
+ lookahead() {
2895
+ let token = this.token;
2896
+ if (token.kind !== TokenKind.EOF) {
2897
+ do {
2898
+ if (token.next) {
2899
+ token = token.next;
2900
+ } else {
2901
+ const nextToken = readNextToken(this, token.end);
2902
+ token.next = nextToken;
2903
+ nextToken.prev = token;
2904
+ token = nextToken;
2905
+ }
2906
+ } while (token.kind === TokenKind.COMMENT);
2907
+ }
2908
+ return token;
2909
+ }
2910
+ };
2911
+ function isPunctuatorTokenKind(kind) {
2912
+ return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.DOT || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
2913
+ }
2914
+ function isUnicodeScalarValue(code) {
2915
+ return code >= 0 && code <= 55295 || code >= 57344 && code <= 1114111;
2916
+ }
2917
+ function isSupplementaryCodePoint(body, location) {
2918
+ return isLeadingSurrogate(body.charCodeAt(location)) && isTrailingSurrogate(body.charCodeAt(location + 1));
2919
+ }
2920
+ function isLeadingSurrogate(code) {
2921
+ return code >= 55296 && code <= 56319;
2922
+ }
2923
+ function isTrailingSurrogate(code) {
2924
+ return code >= 56320 && code <= 57343;
2925
+ }
2926
+ function printCodePointAt(lexer, location) {
2927
+ const code = lexer.source.body.codePointAt(location);
2928
+ if (code === void 0) {
2929
+ return TokenKind.EOF;
2930
+ } else if (code >= 32 && code <= 126) {
2931
+ const char = String.fromCodePoint(code);
2932
+ return char === '"' ? `'"'` : `"${char}"`;
2933
+ }
2934
+ return "U+" + code.toString(16).toUpperCase().padStart(4, "0");
2935
+ }
2936
+ function createToken(lexer, kind, start, end, value) {
2937
+ const line = lexer.line;
2938
+ const col = 1 + start - lexer.lineStart;
2939
+ return new Token(kind, start, end, line, col, value);
2940
+ }
2941
+ function readNextToken(lexer, start) {
2942
+ const body = lexer.source.body;
2943
+ const bodyLength = body.length;
2944
+ let position = start;
2945
+ while (position < bodyLength) {
2946
+ const code = body.charCodeAt(position);
2947
+ switch (code) {
2948
+ // Ignored ::
2949
+ // - UnicodeBOM
2950
+ // - WhiteSpace
2951
+ // - LineTerminator
2952
+ // - Comment
2953
+ // - Comma
2954
+ //
2955
+ // UnicodeBOM :: "Byte Order Mark (U+FEFF)"
2956
+ //
2957
+ // WhiteSpace ::
2958
+ // - "Horizontal Tab (U+0009)"
2959
+ // - "Space (U+0020)"
2960
+ //
2961
+ // Comma :: ,
2962
+ case 65279:
2963
+ // <BOM>
2964
+ case 9:
2965
+ // \t
2966
+ case 32:
2967
+ // <space>
2968
+ case 44:
2969
+ ++position;
2970
+ continue;
2971
+ // LineTerminator ::
2972
+ // - "New Line (U+000A)"
2973
+ // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
2974
+ // - "Carriage Return (U+000D)" "New Line (U+000A)"
2975
+ case 10:
2976
+ ++position;
2977
+ ++lexer.line;
2978
+ lexer.lineStart = position;
2979
+ continue;
2980
+ case 13:
2981
+ if (body.charCodeAt(position + 1) === 10) {
2982
+ position += 2;
2983
+ } else {
2984
+ ++position;
2985
+ }
2986
+ ++lexer.line;
2987
+ lexer.lineStart = position;
2988
+ continue;
2989
+ // Comment
2990
+ case 35:
2991
+ return readComment(lexer, position);
2992
+ // Token ::
2993
+ // - Punctuator
2994
+ // - Name
2995
+ // - IntValue
2996
+ // - FloatValue
2997
+ // - StringValue
2998
+ //
2999
+ // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
3000
+ case 33:
3001
+ return createToken(lexer, TokenKind.BANG, position, position + 1);
3002
+ case 36:
3003
+ return createToken(lexer, TokenKind.DOLLAR, position, position + 1);
3004
+ case 38:
3005
+ return createToken(lexer, TokenKind.AMP, position, position + 1);
3006
+ case 40:
3007
+ return createToken(lexer, TokenKind.PAREN_L, position, position + 1);
3008
+ case 41:
3009
+ return createToken(lexer, TokenKind.PAREN_R, position, position + 1);
3010
+ case 46:
3011
+ if (body.charCodeAt(position + 1) === 46 && body.charCodeAt(position + 2) === 46) {
3012
+ return createToken(lexer, TokenKind.SPREAD, position, position + 3);
3013
+ }
3014
+ break;
3015
+ case 58:
3016
+ return createToken(lexer, TokenKind.COLON, position, position + 1);
3017
+ case 61:
3018
+ return createToken(lexer, TokenKind.EQUALS, position, position + 1);
3019
+ case 64:
3020
+ return createToken(lexer, TokenKind.AT, position, position + 1);
3021
+ case 91:
3022
+ return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);
3023
+ case 93:
3024
+ return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);
3025
+ case 123:
3026
+ return createToken(lexer, TokenKind.BRACE_L, position, position + 1);
3027
+ case 124:
3028
+ return createToken(lexer, TokenKind.PIPE, position, position + 1);
3029
+ case 125:
3030
+ return createToken(lexer, TokenKind.BRACE_R, position, position + 1);
3031
+ // StringValue
3032
+ case 34:
3033
+ if (body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
3034
+ return readBlockString(lexer, position);
3035
+ }
3036
+ return readString(lexer, position);
3037
+ }
3038
+ if (isDigit(code) || code === 45) {
3039
+ return readNumber(lexer, position, code);
3040
+ }
3041
+ if (isNameStart(code)) {
3042
+ return readName(lexer, position);
3043
+ }
3044
+ throw syntaxError(
3045
+ lexer.source,
3046
+ position,
3047
+ code === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) ? `Unexpected character: ${printCodePointAt(lexer, position)}.` : `Invalid character: ${printCodePointAt(lexer, position)}.`
3048
+ );
3049
+ }
3050
+ return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
3051
+ }
3052
+ function readComment(lexer, start) {
3053
+ const body = lexer.source.body;
3054
+ const bodyLength = body.length;
3055
+ let position = start + 1;
3056
+ while (position < bodyLength) {
3057
+ const code = body.charCodeAt(position);
3058
+ if (code === 10 || code === 13) {
3059
+ break;
3060
+ }
3061
+ if (isUnicodeScalarValue(code)) {
3062
+ ++position;
3063
+ } else if (isSupplementaryCodePoint(body, position)) {
3064
+ position += 2;
3065
+ } else {
3066
+ break;
3067
+ }
3068
+ }
3069
+ return createToken(
3070
+ lexer,
3071
+ TokenKind.COMMENT,
3072
+ start,
3073
+ position,
3074
+ body.slice(start + 1, position)
3075
+ );
3076
+ }
3077
+ function readNumber(lexer, start, firstCode) {
3078
+ const body = lexer.source.body;
3079
+ let position = start;
3080
+ let code = firstCode;
3081
+ let isFloat = false;
3082
+ if (code === 45) {
3083
+ code = body.charCodeAt(++position);
3084
+ }
3085
+ if (code === 48) {
3086
+ code = body.charCodeAt(++position);
3087
+ if (isDigit(code)) {
3088
+ throw syntaxError(
3089
+ lexer.source,
3090
+ position,
3091
+ `Invalid number, unexpected digit after 0: ${printCodePointAt(
3092
+ lexer,
3093
+ position
3094
+ )}.`
3095
+ );
3096
+ }
3097
+ } else {
3098
+ position = readDigits(lexer, position, code);
3099
+ code = body.charCodeAt(position);
3100
+ }
3101
+ if (code === 46) {
3102
+ isFloat = true;
3103
+ code = body.charCodeAt(++position);
3104
+ position = readDigits(lexer, position, code);
3105
+ code = body.charCodeAt(position);
3106
+ }
3107
+ if (code === 69 || code === 101) {
3108
+ isFloat = true;
3109
+ code = body.charCodeAt(++position);
3110
+ if (code === 43 || code === 45) {
3111
+ code = body.charCodeAt(++position);
3112
+ }
3113
+ position = readDigits(lexer, position, code);
3114
+ code = body.charCodeAt(position);
3115
+ }
3116
+ if (code === 46 || isNameStart(code)) {
3117
+ throw syntaxError(
3118
+ lexer.source,
3119
+ position,
3120
+ `Invalid number, expected digit but got: ${printCodePointAt(
3121
+ lexer,
3122
+ position
3123
+ )}.`
3124
+ );
3125
+ }
3126
+ return createToken(
3127
+ lexer,
3128
+ isFloat ? TokenKind.FLOAT : TokenKind.INT,
3129
+ start,
3130
+ position,
3131
+ body.slice(start, position)
3132
+ );
3133
+ }
3134
+ function readDigits(lexer, start, firstCode) {
3135
+ if (!isDigit(firstCode)) {
3136
+ throw syntaxError(
3137
+ lexer.source,
3138
+ start,
3139
+ `Invalid number, expected digit but got: ${printCodePointAt(
3140
+ lexer,
3141
+ start
3142
+ )}.`
3143
+ );
3144
+ }
3145
+ const body = lexer.source.body;
3146
+ let position = start + 1;
3147
+ while (isDigit(body.charCodeAt(position))) {
3148
+ ++position;
3149
+ }
3150
+ return position;
3151
+ }
3152
+ function readString(lexer, start) {
3153
+ const body = lexer.source.body;
3154
+ const bodyLength = body.length;
3155
+ let position = start + 1;
3156
+ let chunkStart = position;
3157
+ let value = "";
3158
+ while (position < bodyLength) {
3159
+ const code = body.charCodeAt(position);
3160
+ if (code === 34) {
3161
+ value += body.slice(chunkStart, position);
3162
+ return createToken(lexer, TokenKind.STRING, start, position + 1, value);
3163
+ }
3164
+ if (code === 92) {
3165
+ value += body.slice(chunkStart, position);
3166
+ const escape = body.charCodeAt(position + 1) === 117 ? body.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
3167
+ value += escape.value;
3168
+ position += escape.size;
3169
+ chunkStart = position;
3170
+ continue;
3171
+ }
3172
+ if (code === 10 || code === 13) {
3173
+ break;
3174
+ }
3175
+ if (isUnicodeScalarValue(code)) {
3176
+ ++position;
3177
+ } else if (isSupplementaryCodePoint(body, position)) {
3178
+ position += 2;
3179
+ } else {
3180
+ throw syntaxError(
3181
+ lexer.source,
3182
+ position,
3183
+ `Invalid character within String: ${printCodePointAt(
3184
+ lexer,
3185
+ position
3186
+ )}.`
3187
+ );
3188
+ }
3189
+ }
3190
+ throw syntaxError(lexer.source, position, "Unterminated string.");
3191
+ }
3192
+ function readEscapedUnicodeVariableWidth(lexer, position) {
3193
+ const body = lexer.source.body;
3194
+ let point = 0;
3195
+ let size = 3;
3196
+ while (size < 12) {
3197
+ const code = body.charCodeAt(position + size++);
3198
+ if (code === 125) {
3199
+ if (size < 5 || !isUnicodeScalarValue(point)) {
3200
+ break;
3201
+ }
3202
+ return {
3203
+ value: String.fromCodePoint(point),
3204
+ size
3205
+ };
3206
+ }
3207
+ point = point << 4 | readHexDigit(code);
3208
+ if (point < 0) {
3209
+ break;
3210
+ }
3211
+ }
3212
+ throw syntaxError(
3213
+ lexer.source,
3214
+ position,
3215
+ `Invalid Unicode escape sequence: "${body.slice(
3216
+ position,
3217
+ position + size
3218
+ )}".`
3219
+ );
3220
+ }
3221
+ function readEscapedUnicodeFixedWidth(lexer, position) {
3222
+ const body = lexer.source.body;
3223
+ const code = read16BitHexCode(body, position + 2);
3224
+ if (isUnicodeScalarValue(code)) {
3225
+ return {
3226
+ value: String.fromCodePoint(code),
3227
+ size: 6
3228
+ };
3229
+ }
3230
+ if (isLeadingSurrogate(code)) {
3231
+ if (body.charCodeAt(position + 6) === 92 && body.charCodeAt(position + 7) === 117) {
3232
+ const trailingCode = read16BitHexCode(body, position + 8);
3233
+ if (isTrailingSurrogate(trailingCode)) {
3234
+ return {
3235
+ value: String.fromCodePoint(code, trailingCode),
3236
+ size: 12
3237
+ };
3238
+ }
3239
+ }
3240
+ }
3241
+ throw syntaxError(
3242
+ lexer.source,
3243
+ position,
3244
+ `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`
3245
+ );
3246
+ }
3247
+ function read16BitHexCode(body, position) {
3248
+ return readHexDigit(body.charCodeAt(position)) << 12 | readHexDigit(body.charCodeAt(position + 1)) << 8 | readHexDigit(body.charCodeAt(position + 2)) << 4 | readHexDigit(body.charCodeAt(position + 3));
3249
+ }
3250
+ function readHexDigit(code) {
3251
+ return code >= 48 && code <= 57 ? code - 48 : code >= 65 && code <= 70 ? code - 55 : code >= 97 && code <= 102 ? code - 87 : -1;
3252
+ }
3253
+ function readEscapedCharacter(lexer, position) {
3254
+ const body = lexer.source.body;
3255
+ const code = body.charCodeAt(position + 1);
3256
+ switch (code) {
3257
+ case 34:
3258
+ return {
3259
+ value: '"',
3260
+ size: 2
3261
+ };
3262
+ case 92:
3263
+ return {
3264
+ value: "\\",
3265
+ size: 2
3266
+ };
3267
+ case 47:
3268
+ return {
3269
+ value: "/",
3270
+ size: 2
3271
+ };
3272
+ case 98:
3273
+ return {
3274
+ value: "\b",
3275
+ size: 2
3276
+ };
3277
+ case 102:
3278
+ return {
3279
+ value: "\f",
3280
+ size: 2
3281
+ };
3282
+ case 110:
3283
+ return {
3284
+ value: "\n",
3285
+ size: 2
3286
+ };
3287
+ case 114:
3288
+ return {
3289
+ value: "\r",
3290
+ size: 2
3291
+ };
3292
+ case 116:
3293
+ return {
3294
+ value: " ",
3295
+ size: 2
3296
+ };
3297
+ }
3298
+ throw syntaxError(
3299
+ lexer.source,
3300
+ position,
3301
+ `Invalid character escape sequence: "${body.slice(
3302
+ position,
3303
+ position + 2
3304
+ )}".`
3305
+ );
3306
+ }
3307
+ function readBlockString(lexer, start) {
3308
+ const body = lexer.source.body;
3309
+ const bodyLength = body.length;
3310
+ let lineStart = lexer.lineStart;
3311
+ let position = start + 3;
3312
+ let chunkStart = position;
3313
+ let currentLine = "";
3314
+ const blockLines = [];
3315
+ while (position < bodyLength) {
3316
+ const code = body.charCodeAt(position);
3317
+ if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
3318
+ currentLine += body.slice(chunkStart, position);
3319
+ blockLines.push(currentLine);
3320
+ const token = createToken(
3321
+ lexer,
3322
+ TokenKind.BLOCK_STRING,
3323
+ start,
3324
+ position + 3,
3325
+ // Return a string of the lines joined with U+000A.
3326
+ dedentBlockStringLines(blockLines).join("\n")
3327
+ );
3328
+ lexer.line += blockLines.length - 1;
3329
+ lexer.lineStart = lineStart;
3330
+ return token;
3331
+ }
3332
+ if (code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
3333
+ currentLine += body.slice(chunkStart, position);
3334
+ chunkStart = position + 1;
3335
+ position += 4;
3336
+ continue;
3337
+ }
3338
+ if (code === 10 || code === 13) {
3339
+ currentLine += body.slice(chunkStart, position);
3340
+ blockLines.push(currentLine);
3341
+ if (code === 13 && body.charCodeAt(position + 1) === 10) {
3342
+ position += 2;
3343
+ } else {
3344
+ ++position;
3345
+ }
3346
+ currentLine = "";
3347
+ chunkStart = position;
3348
+ lineStart = position;
3349
+ continue;
3350
+ }
3351
+ if (isUnicodeScalarValue(code)) {
3352
+ ++position;
3353
+ } else if (isSupplementaryCodePoint(body, position)) {
3354
+ position += 2;
3355
+ } else {
3356
+ throw syntaxError(
3357
+ lexer.source,
3358
+ position,
3359
+ `Invalid character within String: ${printCodePointAt(
3360
+ lexer,
3361
+ position
3362
+ )}.`
3363
+ );
3364
+ }
3365
+ }
3366
+ throw syntaxError(lexer.source, position, "Unterminated string.");
3367
+ }
3368
+ function readName(lexer, start) {
3369
+ const body = lexer.source.body;
3370
+ const bodyLength = body.length;
3371
+ let position = start + 1;
3372
+ while (position < bodyLength) {
3373
+ const code = body.charCodeAt(position);
3374
+ if (isNameContinue(code)) {
3375
+ ++position;
3376
+ } else {
3377
+ break;
3378
+ }
3379
+ }
3380
+ return createToken(
3381
+ lexer,
3382
+ TokenKind.NAME,
3383
+ start,
3384
+ position,
3385
+ body.slice(start, position)
3386
+ );
3387
+ }
3388
+
3389
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/inspect.mjs
3390
+ var MAX_ARRAY_LENGTH = 10;
3391
+ var MAX_RECURSIVE_DEPTH = 2;
3392
+ function inspect(value) {
3393
+ return formatValue(value, []);
3394
+ }
3395
+ function formatValue(value, seenValues) {
3396
+ switch (typeof value) {
3397
+ case "string":
3398
+ return JSON.stringify(value);
3399
+ case "function":
3400
+ return value.name ? `[function ${value.name}]` : "[function]";
3401
+ case "object":
3402
+ return formatObjectValue(value, seenValues);
3403
+ default:
3404
+ return String(value);
3405
+ }
3406
+ }
3407
+ function formatObjectValue(value, previouslySeenValues) {
3408
+ if (value === null) {
3409
+ return "null";
3410
+ }
3411
+ if (previouslySeenValues.includes(value)) {
3412
+ return "[Circular]";
3413
+ }
3414
+ const seenValues = [...previouslySeenValues, value];
3415
+ if (isJSONable(value)) {
3416
+ const jsonValue = value.toJSON();
3417
+ if (jsonValue !== value) {
3418
+ return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
3419
+ }
3420
+ } else if (Array.isArray(value)) {
3421
+ return formatArray(value, seenValues);
3422
+ }
3423
+ return formatObject(value, seenValues);
3424
+ }
3425
+ function isJSONable(value) {
3426
+ return typeof value.toJSON === "function";
3427
+ }
3428
+ function formatObject(object, seenValues) {
3429
+ const entries = Object.entries(object);
3430
+ if (entries.length === 0) {
3431
+ return "{}";
3432
+ }
3433
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
3434
+ return "[" + getObjectTag(object) + "]";
3435
+ }
3436
+ const properties = entries.map(
3437
+ ([key, value]) => key + ": " + formatValue(value, seenValues)
3438
+ );
3439
+ return "{ " + properties.join(", ") + " }";
3440
+ }
3441
+ function formatArray(array, seenValues) {
3442
+ if (array.length === 0) {
3443
+ return "[]";
3444
+ }
3445
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
3446
+ return "[Array]";
3447
+ }
3448
+ const len = Math.min(MAX_ARRAY_LENGTH, array.length);
3449
+ const remaining = array.length - len;
3450
+ const items = [];
3451
+ for (let i = 0; i < len; ++i) {
3452
+ items.push(formatValue(array[i], seenValues));
3453
+ }
3454
+ if (remaining === 1) {
3455
+ items.push("... 1 more item");
3456
+ } else if (remaining > 1) {
3457
+ items.push(`... ${remaining} more items`);
3458
+ }
3459
+ return "[" + items.join(", ") + "]";
3460
+ }
3461
+ function getObjectTag(object) {
3462
+ const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
3463
+ if (tag === "Object" && typeof object.constructor === "function") {
3464
+ const name = object.constructor.name;
3465
+ if (typeof name === "string" && name !== "") {
3466
+ return name;
3467
+ }
3468
+ }
3469
+ return tag;
3470
+ }
3471
+
3472
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/instanceOf.mjs
3473
+ var isProduction = globalThis.process && // eslint-disable-next-line no-undef
3474
+ process.env.NODE_ENV === "production";
3475
+ var instanceOf = (
3476
+ /* c8 ignore next 6 */
3477
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
3478
+ isProduction ? function instanceOf2(value, constructor) {
3479
+ return value instanceof constructor;
3480
+ } : function instanceOf3(value, constructor) {
3481
+ if (value instanceof constructor) {
3482
+ return true;
3483
+ }
3484
+ if (typeof value === "object" && value !== null) {
3485
+ var _value$constructor;
3486
+ const className = constructor.prototype[Symbol.toStringTag];
3487
+ const valueClassName = (
3488
+ // We still need to support constructor's name to detect conflicts with older versions of this library.
3489
+ Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name
3490
+ );
3491
+ if (className === valueClassName) {
3492
+ const stringifiedValue = inspect(value);
3493
+ throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
3494
+
3495
+ Ensure that there is only one instance of "graphql" in the node_modules
3496
+ directory. If different versions of "graphql" are the dependencies of other
3497
+ relied on modules, use "resolutions" to ensure only one version is installed.
3498
+
3499
+ https://yarnpkg.com/en/docs/selective-version-resolutions
3500
+
3501
+ Duplicate "graphql" modules cannot be used at the same time since different
3502
+ versions may have different capabilities and behavior. The data from one
3503
+ version used in the function from another could produce confusing and
3504
+ spurious results.`);
3505
+ }
3506
+ }
3507
+ return false;
3508
+ }
3509
+ );
3510
+
3511
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/source.mjs
3512
+ var Source = class {
3513
+ constructor(body, name = "GraphQL request", locationOffset = {
3514
+ line: 1,
3515
+ column: 1
3516
+ }) {
3517
+ typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
3518
+ this.body = body;
3519
+ this.name = name;
3520
+ this.locationOffset = locationOffset;
3521
+ this.locationOffset.line > 0 || devAssert(
3522
+ false,
3523
+ "line in locationOffset is 1-indexed and must be positive."
3524
+ );
3525
+ this.locationOffset.column > 0 || devAssert(
3526
+ false,
3527
+ "column in locationOffset is 1-indexed and must be positive."
3528
+ );
3529
+ }
3530
+ get [Symbol.toStringTag]() {
3531
+ return "Source";
3532
+ }
3533
+ };
3534
+ function isSource(source) {
3535
+ return instanceOf(source, Source);
3536
+ }
3537
+
3538
+ // ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/parser.mjs
3539
+ function parse(source, options) {
3540
+ const parser = new Parser(source, options);
3541
+ const document = parser.parseDocument();
3542
+ Object.defineProperty(document, "tokenCount", {
3543
+ enumerable: false,
3544
+ value: parser.tokenCount
3545
+ });
3546
+ return document;
3547
+ }
3548
+ var Parser = class {
3549
+ constructor(source, options = {}) {
3550
+ const { lexer, ..._options } = options;
3551
+ if (lexer) {
3552
+ this._lexer = lexer;
3553
+ } else {
3554
+ const sourceObj = isSource(source) ? source : new Source(source);
3555
+ this._lexer = new Lexer(sourceObj);
3556
+ }
3557
+ this._options = _options;
3558
+ this._tokenCounter = 0;
3559
+ }
3560
+ get tokenCount() {
3561
+ return this._tokenCounter;
3562
+ }
3563
+ /**
3564
+ * Converts a name lex token into a name parse node.
3565
+ */
3566
+ parseName() {
3567
+ const token = this.expectToken(TokenKind.NAME);
3568
+ return this.node(token, {
3569
+ kind: Kind.NAME,
3570
+ value: token.value
3571
+ });
3572
+ }
3573
+ // Implements the parsing rules in the Document section.
3574
+ /**
3575
+ * Document : Definition+
3576
+ */
3577
+ parseDocument() {
3578
+ return this.node(this._lexer.token, {
3579
+ kind: Kind.DOCUMENT,
3580
+ definitions: this.many(
3581
+ TokenKind.SOF,
3582
+ this.parseDefinition,
3583
+ TokenKind.EOF
3584
+ )
3585
+ });
3586
+ }
3587
+ /**
3588
+ * Definition :
3589
+ * - ExecutableDefinition
3590
+ * - TypeSystemDefinition
3591
+ * - TypeSystemExtension
3592
+ *
3593
+ * ExecutableDefinition :
3594
+ * - OperationDefinition
3595
+ * - FragmentDefinition
3596
+ *
3597
+ * TypeSystemDefinition :
3598
+ * - SchemaDefinition
3599
+ * - TypeDefinition
3600
+ * - DirectiveDefinition
3601
+ *
3602
+ * TypeDefinition :
3603
+ * - ScalarTypeDefinition
3604
+ * - ObjectTypeDefinition
3605
+ * - InterfaceTypeDefinition
3606
+ * - UnionTypeDefinition
3607
+ * - EnumTypeDefinition
3608
+ * - InputObjectTypeDefinition
3609
+ */
3610
+ parseDefinition() {
3611
+ if (this.peek(TokenKind.BRACE_L)) {
3612
+ return this.parseOperationDefinition();
3613
+ }
3614
+ const hasDescription = this.peekDescription();
3615
+ const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
3616
+ if (hasDescription && keywordToken.kind === TokenKind.BRACE_L) {
3617
+ throw syntaxError(
3618
+ this._lexer.source,
3619
+ this._lexer.token.start,
3620
+ "Unexpected description, descriptions are not supported on shorthand queries."
3621
+ );
3622
+ }
3623
+ if (keywordToken.kind === TokenKind.NAME) {
3624
+ switch (keywordToken.value) {
3625
+ case "schema":
3626
+ return this.parseSchemaDefinition();
3627
+ case "scalar":
3628
+ return this.parseScalarTypeDefinition();
3629
+ case "type":
3630
+ return this.parseObjectTypeDefinition();
3631
+ case "interface":
3632
+ return this.parseInterfaceTypeDefinition();
3633
+ case "union":
3634
+ return this.parseUnionTypeDefinition();
3635
+ case "enum":
3636
+ return this.parseEnumTypeDefinition();
3637
+ case "input":
3638
+ return this.parseInputObjectTypeDefinition();
3639
+ case "directive":
3640
+ return this.parseDirectiveDefinition();
3641
+ }
3642
+ switch (keywordToken.value) {
3643
+ case "query":
3644
+ case "mutation":
3645
+ case "subscription":
3646
+ return this.parseOperationDefinition();
3647
+ case "fragment":
3648
+ return this.parseFragmentDefinition();
3649
+ }
3650
+ if (hasDescription) {
3651
+ throw syntaxError(
3652
+ this._lexer.source,
3653
+ this._lexer.token.start,
3654
+ "Unexpected description, only GraphQL definitions support descriptions."
3655
+ );
3656
+ }
3657
+ switch (keywordToken.value) {
3658
+ case "extend":
3659
+ return this.parseTypeSystemExtension();
3660
+ }
3661
+ }
3662
+ throw this.unexpected(keywordToken);
3663
+ }
3664
+ // Implements the parsing rules in the Operations section.
3665
+ /**
3666
+ * OperationDefinition :
3667
+ * - SelectionSet
3668
+ * - OperationType Name? VariableDefinitions? Directives? SelectionSet
3669
+ */
3670
+ parseOperationDefinition() {
3671
+ const start = this._lexer.token;
3672
+ if (this.peek(TokenKind.BRACE_L)) {
3673
+ return this.node(start, {
3674
+ kind: Kind.OPERATION_DEFINITION,
3675
+ operation: OperationTypeNode.QUERY,
3676
+ description: void 0,
3677
+ name: void 0,
3678
+ variableDefinitions: [],
3679
+ directives: [],
3680
+ selectionSet: this.parseSelectionSet()
3681
+ });
3682
+ }
3683
+ const description = this.parseDescription();
3684
+ const operation = this.parseOperationType();
3685
+ let name;
3686
+ if (this.peek(TokenKind.NAME)) {
3687
+ name = this.parseName();
3688
+ }
3689
+ return this.node(start, {
3690
+ kind: Kind.OPERATION_DEFINITION,
3691
+ operation,
3692
+ description,
3693
+ name,
3694
+ variableDefinitions: this.parseVariableDefinitions(),
3695
+ directives: this.parseDirectives(false),
3696
+ selectionSet: this.parseSelectionSet()
3697
+ });
3698
+ }
3699
+ /**
3700
+ * OperationType : one of query mutation subscription
3701
+ */
3702
+ parseOperationType() {
3703
+ const operationToken = this.expectToken(TokenKind.NAME);
3704
+ switch (operationToken.value) {
3705
+ case "query":
3706
+ return OperationTypeNode.QUERY;
3707
+ case "mutation":
3708
+ return OperationTypeNode.MUTATION;
3709
+ case "subscription":
3710
+ return OperationTypeNode.SUBSCRIPTION;
3711
+ }
3712
+ throw this.unexpected(operationToken);
3713
+ }
3714
+ /**
3715
+ * VariableDefinitions : ( VariableDefinition+ )
3716
+ */
3717
+ parseVariableDefinitions() {
3718
+ return this.optionalMany(
3719
+ TokenKind.PAREN_L,
3720
+ this.parseVariableDefinition,
3721
+ TokenKind.PAREN_R
3722
+ );
3723
+ }
3724
+ /**
3725
+ * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
3726
+ */
3727
+ parseVariableDefinition() {
3728
+ return this.node(this._lexer.token, {
3729
+ kind: Kind.VARIABLE_DEFINITION,
3730
+ description: this.parseDescription(),
3731
+ variable: this.parseVariable(),
3732
+ type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
3733
+ defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
3734
+ directives: this.parseConstDirectives()
3735
+ });
3736
+ }
3737
+ /**
3738
+ * Variable : $ Name
3739
+ */
3740
+ parseVariable() {
3741
+ const start = this._lexer.token;
3742
+ this.expectToken(TokenKind.DOLLAR);
3743
+ return this.node(start, {
3744
+ kind: Kind.VARIABLE,
3745
+ name: this.parseName()
3746
+ });
3747
+ }
3748
+ /**
3749
+ * ```
3750
+ * SelectionSet : { Selection+ }
3751
+ * ```
3752
+ */
3753
+ parseSelectionSet() {
3754
+ return this.node(this._lexer.token, {
3755
+ kind: Kind.SELECTION_SET,
3756
+ selections: this.many(
3757
+ TokenKind.BRACE_L,
3758
+ this.parseSelection,
3759
+ TokenKind.BRACE_R
3760
+ )
3761
+ });
3762
+ }
3763
+ /**
3764
+ * Selection :
3765
+ * - Field
3766
+ * - FragmentSpread
3767
+ * - InlineFragment
3768
+ */
3769
+ parseSelection() {
3770
+ return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
3771
+ }
3772
+ /**
3773
+ * Field : Alias? Name Arguments? Directives? SelectionSet?
3774
+ *
3775
+ * Alias : Name :
3776
+ */
3777
+ parseField() {
3778
+ const start = this._lexer.token;
3779
+ const nameOrAlias = this.parseName();
3780
+ let alias;
3781
+ let name;
3782
+ if (this.expectOptionalToken(TokenKind.COLON)) {
3783
+ alias = nameOrAlias;
3784
+ name = this.parseName();
3785
+ } else {
3786
+ name = nameOrAlias;
3787
+ }
3788
+ return this.node(start, {
3789
+ kind: Kind.FIELD,
3790
+ alias,
3791
+ name,
3792
+ arguments: this.parseArguments(false),
3793
+ directives: this.parseDirectives(false),
3794
+ selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
3795
+ });
3796
+ }
3797
+ /**
3798
+ * Arguments[Const] : ( Argument[?Const]+ )
3799
+ */
3800
+ parseArguments(isConst) {
3801
+ const item = isConst ? this.parseConstArgument : this.parseArgument;
3802
+ return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
3803
+ }
3804
+ /**
3805
+ * Argument[Const] : Name : Value[?Const]
3806
+ */
3807
+ parseArgument(isConst = false) {
3808
+ const start = this._lexer.token;
3809
+ const name = this.parseName();
3810
+ this.expectToken(TokenKind.COLON);
3811
+ return this.node(start, {
3812
+ kind: Kind.ARGUMENT,
3813
+ name,
3814
+ value: this.parseValueLiteral(isConst)
3815
+ });
3816
+ }
3817
+ parseConstArgument() {
3818
+ return this.parseArgument(true);
3819
+ }
3820
+ // Implements the parsing rules in the Fragments section.
3821
+ /**
3822
+ * Corresponds to both FragmentSpread and InlineFragment in the spec.
3823
+ *
3824
+ * FragmentSpread : ... FragmentName Directives?
3825
+ *
3826
+ * InlineFragment : ... TypeCondition? Directives? SelectionSet
3827
+ */
3828
+ parseFragment() {
3829
+ const start = this._lexer.token;
3830
+ this.expectToken(TokenKind.SPREAD);
3831
+ const hasTypeCondition = this.expectOptionalKeyword("on");
3832
+ if (!hasTypeCondition && this.peek(TokenKind.NAME)) {
3833
+ return this.node(start, {
3834
+ kind: Kind.FRAGMENT_SPREAD,
3835
+ name: this.parseFragmentName(),
3836
+ directives: this.parseDirectives(false)
3837
+ });
3838
+ }
3839
+ return this.node(start, {
3840
+ kind: Kind.INLINE_FRAGMENT,
3841
+ typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
3842
+ directives: this.parseDirectives(false),
3843
+ selectionSet: this.parseSelectionSet()
3844
+ });
3845
+ }
3846
+ /**
3847
+ * FragmentDefinition :
3848
+ * - fragment FragmentName on TypeCondition Directives? SelectionSet
3849
+ *
3850
+ * TypeCondition : NamedType
3851
+ */
3852
+ parseFragmentDefinition() {
3853
+ const start = this._lexer.token;
3854
+ const description = this.parseDescription();
3855
+ this.expectKeyword("fragment");
3856
+ if (this._options.allowLegacyFragmentVariables === true) {
3857
+ return this.node(start, {
3858
+ kind: Kind.FRAGMENT_DEFINITION,
3859
+ description,
3860
+ name: this.parseFragmentName(),
3861
+ variableDefinitions: this.parseVariableDefinitions(),
3862
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
3863
+ directives: this.parseDirectives(false),
3864
+ selectionSet: this.parseSelectionSet()
3865
+ });
3866
+ }
3867
+ return this.node(start, {
3868
+ kind: Kind.FRAGMENT_DEFINITION,
3869
+ description,
3870
+ name: this.parseFragmentName(),
3871
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
3872
+ directives: this.parseDirectives(false),
3873
+ selectionSet: this.parseSelectionSet()
3874
+ });
3875
+ }
3876
+ /**
3877
+ * FragmentName : Name but not `on`
3878
+ */
3879
+ parseFragmentName() {
3880
+ if (this._lexer.token.value === "on") {
3881
+ throw this.unexpected();
3882
+ }
3883
+ return this.parseName();
3884
+ }
3885
+ // Implements the parsing rules in the Values section.
3886
+ /**
3887
+ * Value[Const] :
3888
+ * - [~Const] Variable
3889
+ * - IntValue
3890
+ * - FloatValue
3891
+ * - StringValue
3892
+ * - BooleanValue
3893
+ * - NullValue
3894
+ * - EnumValue
3895
+ * - ListValue[?Const]
3896
+ * - ObjectValue[?Const]
3897
+ *
3898
+ * BooleanValue : one of `true` `false`
3899
+ *
3900
+ * NullValue : `null`
3901
+ *
3902
+ * EnumValue : Name but not `true`, `false` or `null`
3903
+ */
3904
+ parseValueLiteral(isConst) {
3905
+ const token = this._lexer.token;
3906
+ switch (token.kind) {
3907
+ case TokenKind.BRACKET_L:
3908
+ return this.parseList(isConst);
3909
+ case TokenKind.BRACE_L:
3910
+ return this.parseObject(isConst);
3911
+ case TokenKind.INT:
3912
+ this.advanceLexer();
3913
+ return this.node(token, {
3914
+ kind: Kind.INT,
3915
+ value: token.value
3916
+ });
3917
+ case TokenKind.FLOAT:
3918
+ this.advanceLexer();
3919
+ return this.node(token, {
3920
+ kind: Kind.FLOAT,
3921
+ value: token.value
3922
+ });
3923
+ case TokenKind.STRING:
3924
+ case TokenKind.BLOCK_STRING:
3925
+ return this.parseStringLiteral();
3926
+ case TokenKind.NAME:
3927
+ this.advanceLexer();
3928
+ switch (token.value) {
3929
+ case "true":
3930
+ return this.node(token, {
3931
+ kind: Kind.BOOLEAN,
3932
+ value: true
3933
+ });
3934
+ case "false":
3935
+ return this.node(token, {
3936
+ kind: Kind.BOOLEAN,
3937
+ value: false
3938
+ });
3939
+ case "null":
3940
+ return this.node(token, {
3941
+ kind: Kind.NULL
3942
+ });
3943
+ default:
3944
+ return this.node(token, {
3945
+ kind: Kind.ENUM,
3946
+ value: token.value
3947
+ });
3948
+ }
3949
+ case TokenKind.DOLLAR:
3950
+ if (isConst) {
3951
+ this.expectToken(TokenKind.DOLLAR);
3952
+ if (this._lexer.token.kind === TokenKind.NAME) {
3953
+ const varName = this._lexer.token.value;
3954
+ throw syntaxError(
3955
+ this._lexer.source,
3956
+ token.start,
3957
+ `Unexpected variable "$${varName}" in constant value.`
3958
+ );
3959
+ } else {
3960
+ throw this.unexpected(token);
3961
+ }
3962
+ }
3963
+ return this.parseVariable();
3964
+ default:
3965
+ throw this.unexpected();
3966
+ }
3967
+ }
3968
+ parseConstValueLiteral() {
3969
+ return this.parseValueLiteral(true);
3970
+ }
3971
+ parseStringLiteral() {
3972
+ const token = this._lexer.token;
3973
+ this.advanceLexer();
3974
+ return this.node(token, {
3975
+ kind: Kind.STRING,
3976
+ value: token.value,
3977
+ block: token.kind === TokenKind.BLOCK_STRING
3978
+ });
3979
+ }
3980
+ /**
3981
+ * ListValue[Const] :
3982
+ * - [ ]
3983
+ * - [ Value[?Const]+ ]
3984
+ */
3985
+ parseList(isConst) {
3986
+ const item = () => this.parseValueLiteral(isConst);
3987
+ return this.node(this._lexer.token, {
3988
+ kind: Kind.LIST,
3989
+ values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R)
3990
+ });
3991
+ }
3992
+ /**
3993
+ * ```
3994
+ * ObjectValue[Const] :
3995
+ * - { }
3996
+ * - { ObjectField[?Const]+ }
3997
+ * ```
3998
+ */
3999
+ parseObject(isConst) {
4000
+ const item = () => this.parseObjectField(isConst);
4001
+ return this.node(this._lexer.token, {
4002
+ kind: Kind.OBJECT,
4003
+ fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R)
4004
+ });
4005
+ }
4006
+ /**
4007
+ * ObjectField[Const] : Name : Value[?Const]
4008
+ */
4009
+ parseObjectField(isConst) {
4010
+ const start = this._lexer.token;
4011
+ const name = this.parseName();
4012
+ this.expectToken(TokenKind.COLON);
4013
+ return this.node(start, {
4014
+ kind: Kind.OBJECT_FIELD,
4015
+ name,
4016
+ value: this.parseValueLiteral(isConst)
4017
+ });
4018
+ }
4019
+ // Implements the parsing rules in the Directives section.
4020
+ /**
4021
+ * Directives[Const] : Directive[?Const]+
4022
+ */
4023
+ parseDirectives(isConst) {
4024
+ const directives = [];
4025
+ while (this.peek(TokenKind.AT)) {
4026
+ directives.push(this.parseDirective(isConst));
4027
+ }
4028
+ return directives;
4029
+ }
4030
+ parseConstDirectives() {
4031
+ return this.parseDirectives(true);
4032
+ }
4033
+ /**
4034
+ * ```
4035
+ * Directive[Const] : @ Name Arguments[?Const]?
4036
+ * ```
4037
+ */
4038
+ parseDirective(isConst) {
4039
+ const start = this._lexer.token;
4040
+ this.expectToken(TokenKind.AT);
4041
+ return this.node(start, {
4042
+ kind: Kind.DIRECTIVE,
4043
+ name: this.parseName(),
4044
+ arguments: this.parseArguments(isConst)
4045
+ });
4046
+ }
4047
+ // Implements the parsing rules in the Types section.
4048
+ /**
4049
+ * Type :
4050
+ * - NamedType
4051
+ * - ListType
4052
+ * - NonNullType
4053
+ */
4054
+ parseTypeReference() {
4055
+ const start = this._lexer.token;
4056
+ let type;
4057
+ if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
4058
+ const innerType = this.parseTypeReference();
4059
+ this.expectToken(TokenKind.BRACKET_R);
4060
+ type = this.node(start, {
4061
+ kind: Kind.LIST_TYPE,
4062
+ type: innerType
4063
+ });
4064
+ } else {
4065
+ type = this.parseNamedType();
4066
+ }
4067
+ if (this.expectOptionalToken(TokenKind.BANG)) {
4068
+ return this.node(start, {
4069
+ kind: Kind.NON_NULL_TYPE,
4070
+ type
4071
+ });
4072
+ }
4073
+ return type;
4074
+ }
4075
+ /**
4076
+ * NamedType : Name
4077
+ */
4078
+ parseNamedType() {
4079
+ return this.node(this._lexer.token, {
4080
+ kind: Kind.NAMED_TYPE,
4081
+ name: this.parseName()
4082
+ });
4083
+ }
4084
+ // Implements the parsing rules in the Type Definition section.
4085
+ peekDescription() {
4086
+ return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
4087
+ }
4088
+ /**
4089
+ * Description : StringValue
4090
+ */
4091
+ parseDescription() {
4092
+ if (this.peekDescription()) {
4093
+ return this.parseStringLiteral();
4094
+ }
4095
+ }
4096
+ /**
4097
+ * ```
4098
+ * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
4099
+ * ```
4100
+ */
4101
+ parseSchemaDefinition() {
4102
+ const start = this._lexer.token;
4103
+ const description = this.parseDescription();
4104
+ this.expectKeyword("schema");
4105
+ const directives = this.parseConstDirectives();
4106
+ const operationTypes = this.many(
4107
+ TokenKind.BRACE_L,
4108
+ this.parseOperationTypeDefinition,
4109
+ TokenKind.BRACE_R
4110
+ );
4111
+ return this.node(start, {
4112
+ kind: Kind.SCHEMA_DEFINITION,
4113
+ description,
4114
+ directives,
4115
+ operationTypes
4116
+ });
4117
+ }
4118
+ /**
4119
+ * OperationTypeDefinition : OperationType : NamedType
4120
+ */
4121
+ parseOperationTypeDefinition() {
4122
+ const start = this._lexer.token;
4123
+ const operation = this.parseOperationType();
4124
+ this.expectToken(TokenKind.COLON);
4125
+ const type = this.parseNamedType();
4126
+ return this.node(start, {
4127
+ kind: Kind.OPERATION_TYPE_DEFINITION,
4128
+ operation,
4129
+ type
4130
+ });
4131
+ }
4132
+ /**
4133
+ * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
4134
+ */
4135
+ parseScalarTypeDefinition() {
4136
+ const start = this._lexer.token;
4137
+ const description = this.parseDescription();
4138
+ this.expectKeyword("scalar");
4139
+ const name = this.parseName();
4140
+ const directives = this.parseConstDirectives();
4141
+ return this.node(start, {
4142
+ kind: Kind.SCALAR_TYPE_DEFINITION,
4143
+ description,
4144
+ name,
4145
+ directives
4146
+ });
4147
+ }
4148
+ /**
4149
+ * ObjectTypeDefinition :
4150
+ * Description?
4151
+ * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
4152
+ */
4153
+ parseObjectTypeDefinition() {
4154
+ const start = this._lexer.token;
4155
+ const description = this.parseDescription();
4156
+ this.expectKeyword("type");
4157
+ const name = this.parseName();
4158
+ const interfaces = this.parseImplementsInterfaces();
4159
+ const directives = this.parseConstDirectives();
4160
+ const fields = this.parseFieldsDefinition();
4161
+ return this.node(start, {
4162
+ kind: Kind.OBJECT_TYPE_DEFINITION,
4163
+ description,
4164
+ name,
4165
+ interfaces,
4166
+ directives,
4167
+ fields
4168
+ });
4169
+ }
4170
+ /**
4171
+ * ImplementsInterfaces :
4172
+ * - implements `&`? NamedType
4173
+ * - ImplementsInterfaces & NamedType
4174
+ */
4175
+ parseImplementsInterfaces() {
4176
+ return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
4177
+ }
4178
+ /**
4179
+ * ```
4180
+ * FieldsDefinition : { FieldDefinition+ }
4181
+ * ```
4182
+ */
4183
+ parseFieldsDefinition() {
4184
+ return this.optionalMany(
4185
+ TokenKind.BRACE_L,
4186
+ this.parseFieldDefinition,
4187
+ TokenKind.BRACE_R
4188
+ );
4189
+ }
4190
+ /**
4191
+ * FieldDefinition :
4192
+ * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
4193
+ */
4194
+ parseFieldDefinition() {
4195
+ const start = this._lexer.token;
4196
+ const description = this.parseDescription();
4197
+ const name = this.parseName();
4198
+ const args = this.parseArgumentDefs();
4199
+ this.expectToken(TokenKind.COLON);
4200
+ const type = this.parseTypeReference();
4201
+ const directives = this.parseConstDirectives();
4202
+ return this.node(start, {
4203
+ kind: Kind.FIELD_DEFINITION,
4204
+ description,
4205
+ name,
4206
+ arguments: args,
4207
+ type,
4208
+ directives
4209
+ });
4210
+ }
4211
+ /**
4212
+ * ArgumentsDefinition : ( InputValueDefinition+ )
4213
+ */
4214
+ parseArgumentDefs() {
4215
+ return this.optionalMany(
4216
+ TokenKind.PAREN_L,
4217
+ this.parseInputValueDef,
4218
+ TokenKind.PAREN_R
4219
+ );
4220
+ }
4221
+ /**
4222
+ * InputValueDefinition :
4223
+ * - Description? Name : Type DefaultValue? Directives[Const]?
4224
+ */
4225
+ parseInputValueDef() {
4226
+ const start = this._lexer.token;
4227
+ const description = this.parseDescription();
4228
+ const name = this.parseName();
4229
+ this.expectToken(TokenKind.COLON);
4230
+ const type = this.parseTypeReference();
4231
+ let defaultValue;
4232
+ if (this.expectOptionalToken(TokenKind.EQUALS)) {
4233
+ defaultValue = this.parseConstValueLiteral();
4234
+ }
4235
+ const directives = this.parseConstDirectives();
4236
+ return this.node(start, {
4237
+ kind: Kind.INPUT_VALUE_DEFINITION,
4238
+ description,
4239
+ name,
4240
+ type,
4241
+ defaultValue,
4242
+ directives
4243
+ });
4244
+ }
4245
+ /**
4246
+ * InterfaceTypeDefinition :
4247
+ * - Description? interface Name Directives[Const]? FieldsDefinition?
4248
+ */
4249
+ parseInterfaceTypeDefinition() {
4250
+ const start = this._lexer.token;
4251
+ const description = this.parseDescription();
4252
+ this.expectKeyword("interface");
4253
+ const name = this.parseName();
4254
+ const interfaces = this.parseImplementsInterfaces();
4255
+ const directives = this.parseConstDirectives();
4256
+ const fields = this.parseFieldsDefinition();
4257
+ return this.node(start, {
4258
+ kind: Kind.INTERFACE_TYPE_DEFINITION,
4259
+ description,
4260
+ name,
4261
+ interfaces,
4262
+ directives,
4263
+ fields
4264
+ });
4265
+ }
4266
+ /**
4267
+ * UnionTypeDefinition :
4268
+ * - Description? union Name Directives[Const]? UnionMemberTypes?
4269
+ */
4270
+ parseUnionTypeDefinition() {
4271
+ const start = this._lexer.token;
4272
+ const description = this.parseDescription();
4273
+ this.expectKeyword("union");
4274
+ const name = this.parseName();
4275
+ const directives = this.parseConstDirectives();
4276
+ const types = this.parseUnionMemberTypes();
4277
+ return this.node(start, {
4278
+ kind: Kind.UNION_TYPE_DEFINITION,
4279
+ description,
4280
+ name,
4281
+ directives,
4282
+ types
4283
+ });
4284
+ }
4285
+ /**
4286
+ * UnionMemberTypes :
4287
+ * - = `|`? NamedType
4288
+ * - UnionMemberTypes | NamedType
4289
+ */
4290
+ parseUnionMemberTypes() {
4291
+ return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
4292
+ }
4293
+ /**
4294
+ * EnumTypeDefinition :
4295
+ * - Description? enum Name Directives[Const]? EnumValuesDefinition?
4296
+ */
4297
+ parseEnumTypeDefinition() {
4298
+ const start = this._lexer.token;
4299
+ const description = this.parseDescription();
4300
+ this.expectKeyword("enum");
4301
+ const name = this.parseName();
4302
+ const directives = this.parseConstDirectives();
4303
+ const values = this.parseEnumValuesDefinition();
4304
+ return this.node(start, {
4305
+ kind: Kind.ENUM_TYPE_DEFINITION,
4306
+ description,
4307
+ name,
4308
+ directives,
4309
+ values
4310
+ });
4311
+ }
4312
+ /**
4313
+ * ```
4314
+ * EnumValuesDefinition : { EnumValueDefinition+ }
4315
+ * ```
4316
+ */
4317
+ parseEnumValuesDefinition() {
4318
+ return this.optionalMany(
4319
+ TokenKind.BRACE_L,
4320
+ this.parseEnumValueDefinition,
4321
+ TokenKind.BRACE_R
4322
+ );
4323
+ }
4324
+ /**
4325
+ * EnumValueDefinition : Description? EnumValue Directives[Const]?
4326
+ */
4327
+ parseEnumValueDefinition() {
4328
+ const start = this._lexer.token;
4329
+ const description = this.parseDescription();
4330
+ const name = this.parseEnumValueName();
4331
+ const directives = this.parseConstDirectives();
4332
+ return this.node(start, {
4333
+ kind: Kind.ENUM_VALUE_DEFINITION,
4334
+ description,
4335
+ name,
4336
+ directives
4337
+ });
4338
+ }
4339
+ /**
4340
+ * EnumValue : Name but not `true`, `false` or `null`
4341
+ */
4342
+ parseEnumValueName() {
4343
+ if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") {
4344
+ throw syntaxError(
4345
+ this._lexer.source,
4346
+ this._lexer.token.start,
4347
+ `${getTokenDesc(
4348
+ this._lexer.token
4349
+ )} is reserved and cannot be used for an enum value.`
4350
+ );
4351
+ }
4352
+ return this.parseName();
4353
+ }
4354
+ /**
4355
+ * InputObjectTypeDefinition :
4356
+ * - Description? input Name Directives[Const]? InputFieldsDefinition?
4357
+ */
4358
+ parseInputObjectTypeDefinition() {
4359
+ const start = this._lexer.token;
4360
+ const description = this.parseDescription();
4361
+ this.expectKeyword("input");
4362
+ const name = this.parseName();
4363
+ const directives = this.parseConstDirectives();
4364
+ const fields = this.parseInputFieldsDefinition();
4365
+ return this.node(start, {
4366
+ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
4367
+ description,
4368
+ name,
4369
+ directives,
4370
+ fields
4371
+ });
4372
+ }
4373
+ /**
4374
+ * ```
4375
+ * InputFieldsDefinition : { InputValueDefinition+ }
4376
+ * ```
4377
+ */
4378
+ parseInputFieldsDefinition() {
4379
+ return this.optionalMany(
4380
+ TokenKind.BRACE_L,
4381
+ this.parseInputValueDef,
4382
+ TokenKind.BRACE_R
4383
+ );
4384
+ }
4385
+ /**
4386
+ * TypeSystemExtension :
4387
+ * - SchemaExtension
4388
+ * - TypeExtension
4389
+ *
4390
+ * TypeExtension :
4391
+ * - ScalarTypeExtension
4392
+ * - ObjectTypeExtension
4393
+ * - InterfaceTypeExtension
4394
+ * - UnionTypeExtension
4395
+ * - EnumTypeExtension
4396
+ * - InputObjectTypeDefinition
4397
+ * - DirectiveDefinitionExtension
4398
+ */
4399
+ parseTypeSystemExtension() {
4400
+ const keywordToken = this._lexer.lookahead();
4401
+ if (keywordToken.kind === TokenKind.NAME) {
4402
+ switch (keywordToken.value) {
4403
+ case "schema":
4404
+ return this.parseSchemaExtension();
4405
+ case "scalar":
4406
+ return this.parseScalarTypeExtension();
4407
+ case "type":
4408
+ return this.parseObjectTypeExtension();
4409
+ case "interface":
4410
+ return this.parseInterfaceTypeExtension();
4411
+ case "union":
4412
+ return this.parseUnionTypeExtension();
4413
+ case "enum":
4414
+ return this.parseEnumTypeExtension();
4415
+ case "input":
4416
+ return this.parseInputObjectTypeExtension();
4417
+ case "directive":
4418
+ if (this._options.experimentalDirectivesOnDirectiveDefinitions) {
4419
+ return this.parseDirectiveDefinitionExtension();
4420
+ }
4421
+ break;
4422
+ }
4423
+ }
4424
+ throw this.unexpected(keywordToken);
4425
+ }
4426
+ /**
4427
+ * ```
4428
+ * SchemaExtension :
4429
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
4430
+ * - extend schema Directives[Const]
4431
+ * ```
4432
+ */
4433
+ parseSchemaExtension() {
4434
+ const start = this._lexer.token;
4435
+ this.expectKeyword("extend");
4436
+ this.expectKeyword("schema");
4437
+ const directives = this.parseConstDirectives();
4438
+ const operationTypes = this.optionalMany(
4439
+ TokenKind.BRACE_L,
4440
+ this.parseOperationTypeDefinition,
4441
+ TokenKind.BRACE_R
4442
+ );
4443
+ if (directives.length === 0 && operationTypes.length === 0) {
4444
+ throw this.unexpected();
4445
+ }
4446
+ return this.node(start, {
4447
+ kind: Kind.SCHEMA_EXTENSION,
4448
+ directives,
4449
+ operationTypes
4450
+ });
4451
+ }
4452
+ /**
4453
+ * ScalarTypeExtension :
4454
+ * - extend scalar Name Directives[Const]
4455
+ */
4456
+ parseScalarTypeExtension() {
4457
+ const start = this._lexer.token;
4458
+ this.expectKeyword("extend");
4459
+ this.expectKeyword("scalar");
4460
+ const name = this.parseName();
4461
+ const directives = this.parseConstDirectives();
4462
+ if (directives.length === 0) {
4463
+ throw this.unexpected();
4464
+ }
4465
+ return this.node(start, {
4466
+ kind: Kind.SCALAR_TYPE_EXTENSION,
4467
+ name,
4468
+ directives
4469
+ });
4470
+ }
4471
+ /**
4472
+ * ObjectTypeExtension :
4473
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
4474
+ * - extend type Name ImplementsInterfaces? Directives[Const]
4475
+ * - extend type Name ImplementsInterfaces
4476
+ */
4477
+ parseObjectTypeExtension() {
4478
+ const start = this._lexer.token;
4479
+ this.expectKeyword("extend");
4480
+ this.expectKeyword("type");
4481
+ const name = this.parseName();
4482
+ const interfaces = this.parseImplementsInterfaces();
4483
+ const directives = this.parseConstDirectives();
4484
+ const fields = this.parseFieldsDefinition();
4485
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
4486
+ throw this.unexpected();
4487
+ }
4488
+ return this.node(start, {
4489
+ kind: Kind.OBJECT_TYPE_EXTENSION,
4490
+ name,
4491
+ interfaces,
4492
+ directives,
4493
+ fields
4494
+ });
4495
+ }
4496
+ /**
4497
+ * InterfaceTypeExtension :
4498
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
4499
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
4500
+ * - extend interface Name ImplementsInterfaces
4501
+ */
4502
+ parseInterfaceTypeExtension() {
4503
+ const start = this._lexer.token;
4504
+ this.expectKeyword("extend");
4505
+ this.expectKeyword("interface");
4506
+ const name = this.parseName();
4507
+ const interfaces = this.parseImplementsInterfaces();
4508
+ const directives = this.parseConstDirectives();
4509
+ const fields = this.parseFieldsDefinition();
4510
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
4511
+ throw this.unexpected();
4512
+ }
4513
+ return this.node(start, {
4514
+ kind: Kind.INTERFACE_TYPE_EXTENSION,
4515
+ name,
4516
+ interfaces,
4517
+ directives,
4518
+ fields
4519
+ });
4520
+ }
4521
+ /**
4522
+ * UnionTypeExtension :
4523
+ * - extend union Name Directives[Const]? UnionMemberTypes
4524
+ * - extend union Name Directives[Const]
4525
+ */
4526
+ parseUnionTypeExtension() {
4527
+ const start = this._lexer.token;
4528
+ this.expectKeyword("extend");
4529
+ this.expectKeyword("union");
4530
+ const name = this.parseName();
4531
+ const directives = this.parseConstDirectives();
4532
+ const types = this.parseUnionMemberTypes();
4533
+ if (directives.length === 0 && types.length === 0) {
4534
+ throw this.unexpected();
4535
+ }
4536
+ return this.node(start, {
4537
+ kind: Kind.UNION_TYPE_EXTENSION,
4538
+ name,
4539
+ directives,
4540
+ types
4541
+ });
4542
+ }
4543
+ /**
4544
+ * EnumTypeExtension :
4545
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
4546
+ * - extend enum Name Directives[Const]
4547
+ */
4548
+ parseEnumTypeExtension() {
4549
+ const start = this._lexer.token;
4550
+ this.expectKeyword("extend");
4551
+ this.expectKeyword("enum");
4552
+ const name = this.parseName();
4553
+ const directives = this.parseConstDirectives();
4554
+ const values = this.parseEnumValuesDefinition();
4555
+ if (directives.length === 0 && values.length === 0) {
4556
+ throw this.unexpected();
4557
+ }
4558
+ return this.node(start, {
4559
+ kind: Kind.ENUM_TYPE_EXTENSION,
4560
+ name,
4561
+ directives,
4562
+ values
4563
+ });
4564
+ }
4565
+ /**
4566
+ * InputObjectTypeExtension :
4567
+ * - extend input Name Directives[Const]? InputFieldsDefinition
4568
+ * - extend input Name Directives[Const]
4569
+ */
4570
+ parseInputObjectTypeExtension() {
4571
+ const start = this._lexer.token;
4572
+ this.expectKeyword("extend");
4573
+ this.expectKeyword("input");
4574
+ const name = this.parseName();
4575
+ const directives = this.parseConstDirectives();
4576
+ const fields = this.parseInputFieldsDefinition();
4577
+ if (directives.length === 0 && fields.length === 0) {
4578
+ throw this.unexpected();
4579
+ }
4580
+ return this.node(start, {
4581
+ kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
4582
+ name,
4583
+ directives,
4584
+ fields
4585
+ });
4586
+ }
4587
+ parseDirectiveDefinitionExtension() {
4588
+ const start = this._lexer.token;
4589
+ this.expectKeyword("extend");
4590
+ this.expectKeyword("directive");
4591
+ this.expectToken(TokenKind.AT);
4592
+ const name = this.parseName();
4593
+ const directives = this.parseConstDirectives();
4594
+ if (directives.length === 0) {
4595
+ throw this.unexpected();
4596
+ }
4597
+ return this.node(start, {
4598
+ kind: Kind.DIRECTIVE_EXTENSION,
4599
+ name,
4600
+ directives
4601
+ });
1887
4602
  }
1888
- if (session?.mode === "resume") {
1889
- ensureFlagValue(args, "--resume", session.sessionId);
1890
- if (session.forkSession) {
1891
- ensureFlag(args, "--fork-session");
4603
+ /**
4604
+ * ```
4605
+ * DirectiveDefinition :
4606
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
4607
+ * ```
4608
+ */
4609
+ parseDirectiveDefinition() {
4610
+ const start = this._lexer.token;
4611
+ const description = this.parseDescription();
4612
+ this.expectKeyword("directive");
4613
+ this.expectToken(TokenKind.AT);
4614
+ const name = this.parseName();
4615
+ const args = this.parseArgumentDefs();
4616
+ const directives = this._options.experimentalDirectivesOnDirectiveDefinitions ? this.parseConstDirectives() : [];
4617
+ const repeatable = this.expectOptionalKeyword("repeatable");
4618
+ this.expectKeyword("on");
4619
+ const locations = this.parseDirectiveLocations();
4620
+ return this.node(start, {
4621
+ kind: Kind.DIRECTIVE_DEFINITION,
4622
+ description,
4623
+ name,
4624
+ arguments: args,
4625
+ directives,
4626
+ repeatable,
4627
+ locations
4628
+ });
4629
+ }
4630
+ /**
4631
+ * DirectiveLocations :
4632
+ * - `|`? DirectiveLocation
4633
+ * - DirectiveLocations | DirectiveLocation
4634
+ */
4635
+ parseDirectiveLocations() {
4636
+ return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
4637
+ }
4638
+ /*
4639
+ * DirectiveLocation :
4640
+ * - ExecutableDirectiveLocation
4641
+ * - TypeSystemDirectiveLocation
4642
+ *
4643
+ * ExecutableDirectiveLocation : one of
4644
+ * `QUERY`
4645
+ * `MUTATION`
4646
+ * `SUBSCRIPTION`
4647
+ * `FIELD`
4648
+ * `FRAGMENT_DEFINITION`
4649
+ * `FRAGMENT_SPREAD`
4650
+ * `INLINE_FRAGMENT`
4651
+ *
4652
+ * TypeSystemDirectiveLocation : one of
4653
+ * `SCHEMA`
4654
+ * `SCALAR`
4655
+ * `OBJECT`
4656
+ * `FIELD_DEFINITION`
4657
+ * `ARGUMENT_DEFINITION`
4658
+ * `INTERFACE`
4659
+ * `UNION`
4660
+ * `ENUM`
4661
+ * `ENUM_VALUE`
4662
+ * `INPUT_OBJECT`
4663
+ * `INPUT_FIELD_DEFINITION`
4664
+ * `DIRECTIVE_DEFINITION`
4665
+ */
4666
+ parseDirectiveLocation() {
4667
+ const start = this._lexer.token;
4668
+ const name = this.parseName();
4669
+ if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) {
4670
+ return name;
4671
+ }
4672
+ throw this.unexpected(start);
4673
+ }
4674
+ // Schema Coordinates
4675
+ /**
4676
+ * SchemaCoordinate :
4677
+ * - Name
4678
+ * - Name . Name
4679
+ * - Name . Name ( Name : )
4680
+ * - \@ Name
4681
+ * - \@ Name ( Name : )
4682
+ */
4683
+ parseSchemaCoordinate() {
4684
+ const start = this._lexer.token;
4685
+ const ofDirective = this.expectOptionalToken(TokenKind.AT);
4686
+ const name = this.parseName();
4687
+ let memberName;
4688
+ if (!ofDirective && this.expectOptionalToken(TokenKind.DOT)) {
4689
+ memberName = this.parseName();
4690
+ }
4691
+ let argumentName;
4692
+ if ((ofDirective || memberName) && this.expectOptionalToken(TokenKind.PAREN_L)) {
4693
+ argumentName = this.parseName();
4694
+ this.expectToken(TokenKind.COLON);
4695
+ this.expectToken(TokenKind.PAREN_R);
4696
+ }
4697
+ if (ofDirective) {
4698
+ if (argumentName) {
4699
+ return this.node(start, {
4700
+ kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE,
4701
+ name,
4702
+ argumentName
4703
+ });
4704
+ }
4705
+ return this.node(start, {
4706
+ kind: Kind.DIRECTIVE_COORDINATE,
4707
+ name
4708
+ });
4709
+ } else if (memberName) {
4710
+ if (argumentName) {
4711
+ return this.node(start, {
4712
+ kind: Kind.ARGUMENT_COORDINATE,
4713
+ name,
4714
+ fieldName: memberName,
4715
+ argumentName
4716
+ });
4717
+ }
4718
+ return this.node(start, {
4719
+ kind: Kind.MEMBER_COORDINATE,
4720
+ name,
4721
+ memberName
4722
+ });
1892
4723
  }
4724
+ return this.node(start, {
4725
+ kind: Kind.TYPE_COORDINATE,
4726
+ name
4727
+ });
1893
4728
  }
1894
- if (isolation?.bare) {
1895
- ensureFlag(args, "--bare");
4729
+ // Core parsing utility functions
4730
+ /**
4731
+ * Returns a node that, if configured to do so, sets a "loc" field as a
4732
+ * location object, used to identify the place in the source that created a
4733
+ * given parsed object.
4734
+ */
4735
+ node(startToken, node) {
4736
+ if (this._options.noLocation !== true) {
4737
+ node.loc = new Location(
4738
+ startToken,
4739
+ this._lexer.lastToken,
4740
+ this._lexer.source
4741
+ );
4742
+ }
4743
+ return node;
4744
+ }
4745
+ /**
4746
+ * Determines if the next token is of a given kind
4747
+ */
4748
+ peek(kind) {
4749
+ return this._lexer.token.kind === kind;
4750
+ }
4751
+ /**
4752
+ * If the next token is of the given kind, return that token after advancing the lexer.
4753
+ * Otherwise, do not change the parser state and throw an error.
4754
+ */
4755
+ expectToken(kind) {
4756
+ const token = this._lexer.token;
4757
+ if (token.kind === kind) {
4758
+ this.advanceLexer();
4759
+ return token;
4760
+ }
4761
+ throw syntaxError(
4762
+ this._lexer.source,
4763
+ token.start,
4764
+ `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`
4765
+ );
1896
4766
  }
1897
- if (isolation?.strictMcpConfig) {
1898
- ensureFlag(args, "--strict-mcp-config");
1899
- if (isolation.mcpConfigPath) {
1900
- ensureFlagValue(args, "--mcp-config", isolation.mcpConfigPath);
4767
+ /**
4768
+ * If the next token is of the given kind, return "true" after advancing the lexer.
4769
+ * Otherwise, do not change the parser state and return "false".
4770
+ */
4771
+ expectOptionalToken(kind) {
4772
+ const token = this._lexer.token;
4773
+ if (token.kind === kind) {
4774
+ this.advanceLexer();
4775
+ return true;
1901
4776
  }
4777
+ return false;
1902
4778
  }
1903
- if (extraArgs?.length) {
1904
- args.push(...extraArgs);
4779
+ /**
4780
+ * If the next token is a given keyword, advance the lexer.
4781
+ * Otherwise, do not change the parser state and throw an error.
4782
+ */
4783
+ expectKeyword(value) {
4784
+ const token = this._lexer.token;
4785
+ if (token.kind === TokenKind.NAME && token.value === value) {
4786
+ this.advanceLexer();
4787
+ } else {
4788
+ throw syntaxError(
4789
+ this._lexer.source,
4790
+ token.start,
4791
+ `Expected "${value}", found ${getTokenDesc(token)}.`
4792
+ );
4793
+ }
1905
4794
  }
1906
- return args;
1907
- }
1908
- function withRequiredClaudePrintArgs(baseArgs) {
1909
- const args = [...baseArgs];
1910
- ensureFlag(args, "-p");
1911
- ensureFlagValue(args, "--output-format", "stream-json");
1912
- ensureFlagValue(args, "--input-format", "stream-json");
1913
- ensureFlag(args, "--include-partial-messages");
1914
- ensureFlag(args, "--verbose");
1915
- ensureFlagValue(args, "--permission-mode", "bypassPermissions");
1916
- return args;
1917
- }
1918
- function ensureFlag(args, flag) {
1919
- if (!args.includes(flag)) {
1920
- args.push(flag);
4795
+ /**
4796
+ * If the next token is a given keyword, return "true" after advancing the lexer.
4797
+ * Otherwise, do not change the parser state and return "false".
4798
+ */
4799
+ expectOptionalKeyword(value) {
4800
+ const token = this._lexer.token;
4801
+ if (token.kind === TokenKind.NAME && token.value === value) {
4802
+ this.advanceLexer();
4803
+ return true;
4804
+ }
4805
+ return false;
1921
4806
  }
1922
- }
1923
- function ensureFlagValue(args, flag, value) {
1924
- const index = args.indexOf(flag);
1925
- if (index === -1) {
1926
- args.push(flag, value);
1927
- return;
4807
+ /**
4808
+ * Helper function for creating an error when an unexpected lexed token is encountered.
4809
+ */
4810
+ unexpected(atToken) {
4811
+ const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
4812
+ return syntaxError(
4813
+ this._lexer.source,
4814
+ token.start,
4815
+ `Unexpected ${getTokenDesc(token)}.`
4816
+ );
1928
4817
  }
1929
- const existingValue = args[index + 1];
1930
- if (existingValue?.startsWith("-")) {
1931
- args.splice(index + 1, 0, value);
1932
- return;
4818
+ /**
4819
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
4820
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
4821
+ * Advances the parser to the next lex token after the closing token.
4822
+ */
4823
+ any(openKind, parseFn, closeKind) {
4824
+ this.expectToken(openKind);
4825
+ const nodes = [];
4826
+ while (!this.expectOptionalToken(closeKind)) {
4827
+ nodes.push(parseFn.call(this));
4828
+ }
4829
+ return nodes;
4830
+ }
4831
+ /**
4832
+ * Returns a list of parse nodes, determined by the parseFn.
4833
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
4834
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
4835
+ * Advances the parser to the next lex token after the closing token.
4836
+ */
4837
+ optionalMany(openKind, parseFn, closeKind) {
4838
+ if (this.expectOptionalToken(openKind)) {
4839
+ const nodes = [];
4840
+ do {
4841
+ nodes.push(parseFn.call(this));
4842
+ } while (!this.expectOptionalToken(closeKind));
4843
+ return nodes;
4844
+ }
4845
+ return [];
1933
4846
  }
1934
- if (existingValue !== value) {
1935
- args.splice(index + 1, existingValue === void 0 ? 0 : 1, value);
4847
+ /**
4848
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
4849
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
4850
+ * Advances the parser to the next lex token after the closing token.
4851
+ */
4852
+ many(openKind, parseFn, closeKind) {
4853
+ this.expectToken(openKind);
4854
+ const nodes = [];
4855
+ do {
4856
+ nodes.push(parseFn.call(this));
4857
+ } while (!this.expectOptionalToken(closeKind));
4858
+ return nodes;
4859
+ }
4860
+ /**
4861
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
4862
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
4863
+ * Advances the parser to the next lex token after last item in the list.
4864
+ */
4865
+ delimitedMany(delimiterKind, parseFn) {
4866
+ this.expectOptionalToken(delimiterKind);
4867
+ const nodes = [];
4868
+ do {
4869
+ nodes.push(parseFn.call(this));
4870
+ } while (this.expectOptionalToken(delimiterKind));
4871
+ return nodes;
4872
+ }
4873
+ advanceLexer() {
4874
+ const { maxTokens } = this._options;
4875
+ const token = this._lexer.advance();
4876
+ if (token.kind !== TokenKind.EOF) {
4877
+ ++this._tokenCounter;
4878
+ if (maxTokens !== void 0 && this._tokenCounter > maxTokens) {
4879
+ throw syntaxError(
4880
+ this._lexer.source,
4881
+ token.start,
4882
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`
4883
+ );
4884
+ }
4885
+ }
1936
4886
  }
4887
+ };
4888
+ function getTokenDesc(token) {
4889
+ const value = token.value;
4890
+ return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
4891
+ }
4892
+ function getTokenKindDesc(kind) {
4893
+ return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
1937
4894
  }
1938
4895
 
1939
- // ../runtime-claude/src/mcp-compose.ts
1940
- import { mkdir, readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
1941
- import { basename, dirname, join as join3, resolve as resolve4 } from "path";
1942
-
1943
- // ../tool-github-graphql/src/tool.ts
1944
- import { readFile as readFile5, writeFile as writeFile2 } from "fs/promises";
1945
- var DEFAULT_GITHUB_GRAPHQL_API_URL = "https://api.github.com/graphql";
1946
- var TOKEN_REUSE_WINDOW_MS2 = 60 * 1e3;
1947
- async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
1948
- const token = await resolveGitHubGraphQLToken(config, {
1949
- fetchImpl
1950
- });
4896
+ // ../tool-linear-graphql/src/tool.ts
4897
+ var DEFAULT_LINEAR_GRAPHQL_API_URL = "https://api.linear.app/graphql";
4898
+ async function executeLinearGraphQL(invocation, config, fetchImpl = fetch) {
4899
+ validateLinearGraphQLInvocation(invocation);
4900
+ const authorization = resolveLinearAuthorizationHeader(config);
1951
4901
  const response = await fetchImpl(
1952
- config.apiUrl ?? DEFAULT_GITHUB_GRAPHQL_API_URL,
4902
+ config.apiUrl ?? DEFAULT_LINEAR_GRAPHQL_API_URL,
1953
4903
  {
1954
4904
  method: "POST",
1955
4905
  headers: {
1956
4906
  "content-type": "application/json",
1957
- authorization: `Bearer ${token}`
4907
+ authorization
1958
4908
  },
1959
4909
  body: JSON.stringify(invocation)
1960
4910
  }
@@ -1962,7 +4912,7 @@ async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
1962
4912
  const payload = await response.json();
1963
4913
  if (!response.ok) {
1964
4914
  throw new Error(
1965
- `GitHub GraphQL request failed with status ${response.status}: ${JSON.stringify(payload)}`
4915
+ `Linear GraphQL request failed with status ${response.status}: ${JSON.stringify(payload)}`
1966
4916
  );
1967
4917
  }
1968
4918
  if (payload.errors?.length) {
@@ -1970,95 +4920,71 @@ async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
1970
4920
  }
1971
4921
  return payload;
1972
4922
  }
1973
- async function resolveGitHubGraphQLToken(config, dependencies = {}) {
1974
- if (config.token) {
1975
- return config.token;
1976
- }
1977
- if (!config.tokenBrokerUrl || !config.tokenBrokerSecret) {
4923
+ function validateLinearGraphQLInvocation(invocation) {
4924
+ if (typeof invocation.query !== "string" || invocation.query.trim() === "") {
1978
4925
  throw new Error(
1979
- "Either GITHUB_GRAPHQL_TOKEN or the runtime token broker configuration is required."
4926
+ "linear_graphql requires a non-empty GraphQL query string."
1980
4927
  );
1981
4928
  }
1982
- const now = dependencies.now ?? /* @__PURE__ */ new Date();
1983
- const readFileImpl = dependencies.readFileImpl ?? readFile5;
1984
- const writeFileImpl = dependencies.writeFileImpl ?? writeFile2;
1985
- const cachedToken = config.tokenCachePath ? await readCachedToken(config.tokenCachePath, readFileImpl) : null;
1986
- if (cachedToken && cachedToken.expiresAt.getTime() - now.getTime() > TOKEN_REUSE_WINDOW_MS2) {
1987
- return cachedToken.token;
1988
- }
1989
- const fetchImpl = dependencies.fetchImpl ?? fetch;
1990
- const response = await fetchImpl(config.tokenBrokerUrl, {
1991
- method: "POST",
1992
- headers: {
1993
- accept: "application/json",
1994
- authorization: `Bearer ${config.tokenBrokerSecret}`
1995
- }
1996
- });
1997
- const payload = await response.json();
1998
- if (!response.ok || !payload.token || !payload.expiresAt) {
4929
+ const document = parse(invocation.query);
4930
+ const operationCount = document.definitions.filter(
4931
+ (definition) => definition.kind === "OperationDefinition"
4932
+ ).length;
4933
+ if (operationCount !== 1) {
1999
4934
  throw new Error(
2000
- payload.error ?? `Runtime token broker request failed with status ${response.status}.`
4935
+ "linear_graphql accepts exactly one GraphQL operation per request; split multi-operation documents before calling Linear."
2001
4936
  );
2002
4937
  }
2003
- if (config.tokenCachePath) {
2004
- await writeFileImpl(config.tokenCachePath, JSON.stringify(payload), "utf8");
4938
+ }
4939
+ function resolveLinearAuthorizationHeader(config) {
4940
+ if (config.authorizationHeader) {
4941
+ return config.authorizationHeader;
2005
4942
  }
2006
- return payload.token;
4943
+ if (config.apiKey) {
4944
+ return `Bearer ${config.apiKey}`;
4945
+ }
4946
+ throw new Error(
4947
+ "Linear GraphQL auth is not configured; provide runtime LINEAR_AUTHORIZATION or LINEAR_API_KEY."
4948
+ );
2007
4949
  }
2008
- async function readStdin() {
4950
+ async function readStdin2() {
2009
4951
  const chunks = [];
2010
4952
  for await (const chunk of process.stdin) {
2011
4953
  chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
2012
4954
  }
2013
4955
  return Buffer.concat(chunks).toString("utf8");
2014
4956
  }
2015
- async function main() {
2016
- const rawInput = await readStdin();
4957
+ async function main3() {
4958
+ const rawInput = await readStdin2();
2017
4959
  const invocation = JSON.parse(rawInput);
2018
- const result = await executeGitHubGraphQL(invocation, {
2019
- token: process.env.GITHUB_GRAPHQL_TOKEN,
2020
- apiUrl: process.env.GITHUB_GRAPHQL_API_URL,
2021
- tokenBrokerUrl: process.env.GITHUB_TOKEN_BROKER_URL,
2022
- tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
2023
- tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
4960
+ const result = await executeLinearGraphQL(invocation, {
4961
+ apiKey: process.env.LINEAR_API_KEY,
4962
+ apiUrl: process.env.LINEAR_GRAPHQL_URL,
4963
+ authorizationHeader: process.env.LINEAR_AUTHORIZATION
2024
4964
  });
2025
4965
  process.stdout.write(`${JSON.stringify(result)}
2026
4966
  `);
2027
4967
  }
2028
4968
  if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
2029
- main().catch((error) => {
4969
+ main3().catch((error) => {
2030
4970
  const message = error instanceof Error ? error.message : "Unknown error";
2031
4971
  process.stderr.write(`${message}
2032
4972
  `);
2033
4973
  process.exitCode = 1;
2034
4974
  });
2035
4975
  }
2036
- async function readCachedToken(path, readFileImpl) {
2037
- try {
2038
- const payload = JSON.parse(await readFileImpl(path, "utf8"));
2039
- if (!payload.token || !payload.expiresAt) {
2040
- return null;
2041
- }
2042
- return {
2043
- token: payload.token,
2044
- expiresAt: new Date(payload.expiresAt)
2045
- };
2046
- } catch {
2047
- return null;
2048
- }
2049
- }
2050
4976
 
2051
- // ../tool-github-graphql/src/mcp-server.ts
2052
- import { fileURLToPath } from "url";
2053
- var TOOL_SCHEMA = {
2054
- name: "github_graphql",
2055
- description: "Execute GitHub GraphQL queries for the active workspace so the agent can mutate project and issue state directly.",
4977
+ // ../tool-linear-graphql/src/mcp-server.ts
4978
+ import { fileURLToPath as fileURLToPath2 } from "url";
4979
+ var TOOL_SCHEMA2 = {
4980
+ name: "linear_graphql",
4981
+ description: "Execute a single Linear GraphQL query or mutation for the active Linear issue using runtime-managed auth.",
2056
4982
  inputSchema: {
2057
4983
  type: "object",
2058
4984
  properties: {
2059
4985
  query: {
2060
4986
  type: "string",
2061
- description: "GraphQL query or mutation document."
4987
+ description: "Single GraphQL query or mutation document."
2062
4988
  },
2063
4989
  variables: {
2064
4990
  type: "object",
@@ -2073,50 +4999,49 @@ var TOOL_SCHEMA = {
2073
4999
  additionalProperties: false
2074
5000
  }
2075
5001
  };
2076
- var lineBuffer = "";
2077
- function resolveGitHubGraphQLMcpServerEntryPoint() {
2078
- return fileURLToPath(new URL("./mcp-server.js", import.meta.url));
5002
+ var lineBuffer2 = "";
5003
+ function resolveLinearGraphQLMcpServerEntryPoint() {
5004
+ return fileURLToPath2(new URL("./mcp-server.js", import.meta.url));
2079
5005
  }
2080
- function sendResponse(id, result) {
2081
- const msg = JSON.stringify({ jsonrpc: "2.0", id, result });
2082
- process.stdout.write(msg + "\n");
5006
+ function sendResponse2(id, result) {
5007
+ process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", id, result })}
5008
+ `);
2083
5009
  }
2084
- function sendError(id, code, message) {
2085
- const msg = JSON.stringify({
2086
- jsonrpc: "2.0",
2087
- id,
2088
- error: { code, message }
2089
- });
2090
- process.stdout.write(msg + "\n");
5010
+ function sendError2(id, code, message) {
5011
+ process.stdout.write(
5012
+ `${JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } })}
5013
+ `
5014
+ );
2091
5015
  }
2092
- async function handleRequest(msg) {
5016
+ async function handleRequest2(msg) {
2093
5017
  const id = msg.id ?? null;
2094
5018
  switch (msg.method) {
2095
5019
  case "initialize": {
2096
- sendResponse(id, {
5020
+ sendResponse2(id, {
2097
5021
  protocolVersion: "2024-11-05",
2098
5022
  capabilities: { tools: {} },
2099
5023
  serverInfo: {
2100
- name: "github-symphony-graphql",
5024
+ name: "github-symphony-linear-graphql",
2101
5025
  version: "0.1.0"
2102
5026
  }
2103
5027
  });
2104
5028
  process.stdout.write(
2105
- JSON.stringify({
5029
+ `${JSON.stringify({
2106
5030
  jsonrpc: "2.0",
2107
5031
  method: "notifications/initialized"
2108
- }) + "\n"
5032
+ })}
5033
+ `
2109
5034
  );
2110
5035
  break;
2111
5036
  }
2112
5037
  case "tools/list": {
2113
- sendResponse(id, { tools: [TOOL_SCHEMA] });
5038
+ sendResponse2(id, { tools: [TOOL_SCHEMA2] });
2114
5039
  break;
2115
5040
  }
2116
5041
  case "tools/call": {
2117
5042
  const params = msg.params;
2118
- if (params.name !== "github_graphql") {
2119
- sendError(id, -32602, `Unknown tool: ${params.name}`);
5043
+ if (params.name !== "linear_graphql") {
5044
+ sendError2(id, -32602, `Unknown tool: ${params.name}`);
2120
5045
  return;
2121
5046
  }
2122
5047
  const args = params.arguments ?? {};
@@ -2126,14 +5051,12 @@ async function handleRequest(msg) {
2126
5051
  operationName: args.operationName
2127
5052
  };
2128
5053
  try {
2129
- const result = await executeGitHubGraphQL(invocation, {
2130
- token: process.env.GITHUB_GRAPHQL_TOKEN,
2131
- apiUrl: process.env.GITHUB_GRAPHQL_API_URL,
2132
- tokenBrokerUrl: process.env.GITHUB_TOKEN_BROKER_URL,
2133
- tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
2134
- tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
5054
+ const result = await executeLinearGraphQL(invocation, {
5055
+ apiKey: process.env.LINEAR_API_KEY,
5056
+ apiUrl: process.env.LINEAR_GRAPHQL_URL,
5057
+ authorizationHeader: process.env.LINEAR_AUTHORIZATION
2135
5058
  });
2136
- sendResponse(id, {
5059
+ sendResponse2(id, {
2137
5060
  content: [
2138
5061
  {
2139
5062
  type: "text",
@@ -2143,7 +5066,7 @@ async function handleRequest(msg) {
2143
5066
  });
2144
5067
  } catch (err) {
2145
5068
  const message = err instanceof Error ? err.message : String(err);
2146
- sendResponse(id, {
5069
+ sendResponse2(id, {
2147
5070
  content: [{ type: "text", text: message }],
2148
5071
  isError: true
2149
5072
  });
@@ -2153,32 +5076,32 @@ async function handleRequest(msg) {
2153
5076
  case "notifications/initialized":
2154
5077
  case "ping": {
2155
5078
  if (id !== null && id !== void 0) {
2156
- sendResponse(id, {});
5079
+ sendResponse2(id, {});
2157
5080
  }
2158
5081
  break;
2159
5082
  }
2160
5083
  default: {
2161
5084
  if (id !== null && id !== void 0) {
2162
- sendError(id, -32601, `Method not found: ${msg.method}`);
5085
+ sendError2(id, -32601, `Method not found: ${msg.method}`);
2163
5086
  }
2164
5087
  }
2165
5088
  }
2166
5089
  }
2167
- async function main2() {
5090
+ async function main4() {
2168
5091
  process.stdin.setEncoding("utf8");
2169
5092
  process.stdin.on("data", (chunk) => {
2170
- lineBuffer += chunk;
2171
- const lines = lineBuffer.split("\n");
2172
- lineBuffer = lines.pop() ?? "";
5093
+ lineBuffer2 += chunk;
5094
+ const lines = lineBuffer2.split("\n");
5095
+ lineBuffer2 = lines.pop() ?? "";
2173
5096
  for (const line of lines) {
2174
5097
  const trimmed = line.trim();
2175
5098
  if (!trimmed) continue;
2176
5099
  try {
2177
5100
  const msg = JSON.parse(trimmed);
2178
- void handleRequest(msg);
5101
+ void handleRequest2(msg);
2179
5102
  } catch (err) {
2180
5103
  process.stderr.write(
2181
- `[github-graphql-mcp] parse error: ${err instanceof Error ? err.message : String(err)}
5104
+ `[linear-graphql-mcp] parse error: ${err instanceof Error ? err.message : String(err)}
2182
5105
  `
2183
5106
  );
2184
5107
  }
@@ -2189,38 +5112,22 @@ async function main2() {
2189
5112
  });
2190
5113
  }
2191
5114
  if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
2192
- main2().catch((err) => {
5115
+ main4().catch((err) => {
2193
5116
  process.stderr.write(
2194
- `[github-graphql-mcp] fatal: ${err instanceof Error ? err.message : String(err)}
5117
+ `[linear-graphql-mcp] fatal: ${err instanceof Error ? err.message : String(err)}
2195
5118
  `
2196
5119
  );
2197
5120
  process.exitCode = 1;
2198
5121
  });
2199
5122
  }
2200
5123
 
2201
- // ../tool-github-graphql/src/mcp-entry.ts
2202
- var DEFAULT_GITHUB_GRAPHQL_API_URL2 = "https://api.github.com/graphql";
2203
- function createGitHubGraphQLMcpServerEntry(options = {}) {
5124
+ // ../tool-linear-graphql/src/mcp-entry.ts
5125
+ function createLinearGraphQLMcpServerEntry(options = {}) {
2204
5126
  return {
2205
5127
  command: "node",
2206
- args: [resolveGitHubGraphQLMcpServerEntryPoint()],
5128
+ args: [resolveLinearGraphQLMcpServerEntryPoint()],
2207
5129
  env: {
2208
- GITHUB_GRAPHQL_API_URL: options.githubGraphqlApiUrl ?? DEFAULT_GITHUB_GRAPHQL_API_URL2,
2209
- ...options.githubToken ? {
2210
- GITHUB_GRAPHQL_TOKEN: options.githubToken
2211
- } : {},
2212
- ...options.githubTokenBrokerUrl ? {
2213
- GITHUB_TOKEN_BROKER_URL: options.githubTokenBrokerUrl
2214
- } : {},
2215
- ...options.githubTokenBrokerSecret ? {
2216
- GITHUB_TOKEN_BROKER_SECRET: options.githubTokenBrokerSecret
2217
- } : {},
2218
- ...options.githubTokenCachePath ? {
2219
- GITHUB_TOKEN_CACHE_PATH: options.githubTokenCachePath
2220
- } : {},
2221
- ...options.githubProjectId ? {
2222
- GITHUB_PROJECT_ID: options.githubProjectId
2223
- } : {}
5130
+ LINEAR_GRAPHQL_URL: options.linearGraphqlUrl ?? DEFAULT_LINEAR_GRAPHQL_API_URL
2224
5131
  }
2225
5132
  };
2226
5133
  }
@@ -2233,9 +5140,13 @@ async function composeClaudeMcpConfig(workspaceRoot, strictMode, symphonyTokenEn
2233
5140
  symphonyTokenEnv
2234
5141
  );
2235
5142
  const baseConfig = await readBaseMcpConfig(workspaceMcpPath);
2236
- const mergedConfig = mergeGitHubGraphQLMcpServer(baseConfig, symphonyTokenEnv);
5143
+ const mergedConfig = mergeSymphonyMcpServers(baseConfig, symphonyTokenEnv);
2237
5144
  await mkdir(dirname(finalPath), { recursive: true });
2238
- await writeFile3(finalPath, JSON.stringify(mergedConfig, null, 2) + "\n", "utf8");
5145
+ await writeFile3(
5146
+ finalPath,
5147
+ JSON.stringify(mergedConfig, null, 2) + "\n",
5148
+ "utf8"
5149
+ );
2239
5150
  return {
2240
5151
  finalPath,
2241
5152
  extraArgv: strictMode ? ["--strict-mcp-config", "--mcp-config", finalPath] : ["--mcp-config", finalPath],
@@ -2246,7 +5157,7 @@ async function readBaseMcpConfig(workspaceMcpPath) {
2246
5157
  try {
2247
5158
  const raw = await readFile6(workspaceMcpPath, "utf8");
2248
5159
  const parsed = JSON.parse(raw);
2249
- return isRecord3(parsed) ? parsed : { mcpServers: {} };
5160
+ return isRecord4(parsed) ? parsed : { mcpServers: {} };
2250
5161
  } catch (error) {
2251
5162
  if (isNodeError(error) && error.code === "ENOENT") {
2252
5163
  return { mcpServers: {} };
@@ -2254,21 +5165,29 @@ async function readBaseMcpConfig(workspaceMcpPath) {
2254
5165
  throw error;
2255
5166
  }
2256
5167
  }
2257
- function mergeGitHubGraphQLMcpServer(baseConfig, env) {
2258
- const mcpServers = isRecord3(baseConfig.mcpServers) ? baseConfig.mcpServers : {};
5168
+ function mergeSymphonyMcpServers(baseConfig, env) {
5169
+ const mcpServers = isRecord4(baseConfig.mcpServers) ? baseConfig.mcpServers : {};
5170
+ const mergedServers = {
5171
+ ...mcpServers,
5172
+ github_graphql: createGitHubGraphQLMcpServerEntry({
5173
+ githubToken: env.GITHUB_GRAPHQL_TOKEN,
5174
+ githubGraphqlApiUrl: env.GITHUB_GRAPHQL_API_URL,
5175
+ githubTokenBrokerUrl: env.GITHUB_TOKEN_BROKER_URL,
5176
+ githubTokenBrokerSecret: env.GITHUB_TOKEN_BROKER_SECRET,
5177
+ githubTokenCachePath: env.GITHUB_TOKEN_CACHE_PATH,
5178
+ githubProjectId: env.GITHUB_PROJECT_ID
5179
+ })
5180
+ };
5181
+ if (env.SYMPHONY_TRACKER_KIND === "linear") {
5182
+ mergedServers.linear_graphql = createLinearGraphQLMcpServerEntry({
5183
+ linearGraphqlUrl: env.LINEAR_GRAPHQL_URL
5184
+ });
5185
+ } else {
5186
+ delete mergedServers.linear_graphql;
5187
+ }
2259
5188
  return {
2260
5189
  ...baseConfig,
2261
- mcpServers: {
2262
- ...mcpServers,
2263
- github_graphql: createGitHubGraphQLMcpServerEntry({
2264
- githubToken: env.GITHUB_GRAPHQL_TOKEN,
2265
- githubGraphqlApiUrl: env.GITHUB_GRAPHQL_API_URL,
2266
- githubTokenBrokerUrl: env.GITHUB_TOKEN_BROKER_URL,
2267
- githubTokenBrokerSecret: env.GITHUB_TOKEN_BROKER_SECRET,
2268
- githubTokenCachePath: env.GITHUB_TOKEN_CACHE_PATH,
2269
- githubProjectId: env.GITHUB_PROJECT_ID
2270
- })
2271
- }
5190
+ mcpServers: mergedServers
2272
5191
  };
2273
5192
  }
2274
5193
  function resolveRuntimeMcpConfigPath(workspaceRoot, env) {
@@ -2280,7 +5199,7 @@ function resolveRuntimeMcpConfigPath(workspaceRoot, env) {
2280
5199
  );
2281
5200
  return join3(runtimeDir, "mcp.json");
2282
5201
  }
2283
- function isRecord3(value) {
5202
+ function isRecord4(value) {
2284
5203
  return value != null && typeof value === "object" && !Array.isArray(value);
2285
5204
  }
2286
5205
  function isNodeError(error) {
@@ -2647,6 +5566,7 @@ async function spawnClaudeTurn(input, dependencies = {}) {
2647
5566
  spawnErrorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
2648
5567
  });
2649
5568
  if ((classification.kind === "app-error" || classification.kind === "process-error") && !emittedErrorEvent) {
5569
+ const stderrSummary = summarizeClaudeStderr(records);
2650
5570
  emitEvent({
2651
5571
  name: "agent.error",
2652
5572
  payload: {
@@ -2655,9 +5575,10 @@ async function spawnClaudeTurn(input, dependencies = {}) {
2655
5575
  exitCode: outcome.exitCode,
2656
5576
  signal: outcome.signal,
2657
5577
  classification,
2658
- errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
5578
+ errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0,
5579
+ stderr: stderrSummary ?? void 0
2659
5580
  },
2660
- error: classification.reason
5581
+ error: stderrSummary ? `${classification.reason}: ${stderrSummary}` : classification.reason
2661
5582
  }
2662
5583
  });
2663
5584
  }
@@ -2673,6 +5594,13 @@ async function spawnClaudeTurn(input, dependencies = {}) {
2673
5594
  errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
2674
5595
  };
2675
5596
  }
5597
+ function summarizeClaudeStderr(records) {
5598
+ const stderrLines = records.filter((record) => record.stream === "stderr").map((record) => record.line || record.parseError).filter((line) => Boolean(line?.trim())).map((line) => line.trim());
5599
+ if (stderrLines.length === 0) {
5600
+ return null;
5601
+ }
5602
+ return stderrLines.slice(-3).join(" | ").slice(0, 1e3);
5603
+ }
2676
5604
  async function collectNdjsonStream(stream, channel, records, eventMapper, onEvent) {
2677
5605
  if (!stream) {
2678
5606
  return;
@@ -2851,7 +5779,7 @@ var ClaudeSessionStore = class {
2851
5779
  }
2852
5780
  };
2853
5781
  function parseClaudeSessionFile(value) {
2854
- if (!isRecord4(value)) {
5782
+ if (!isRecord5(value)) {
2855
5783
  throw new Error("Claude session file must be a JSON object.");
2856
5784
  }
2857
5785
  if (value.protocol !== CLAUDE_SESSION_PROTOCOL) {
@@ -2868,7 +5796,7 @@ function parseClaudeSessionFile(value) {
2868
5796
  if ("parentRunId" in value && value.parentRunId !== void 0 && typeof value.parentRunId !== "string") {
2869
5797
  throw new Error("Claude session file parentRunId must be a string.");
2870
5798
  }
2871
- if ("protocolState" in value && value.protocolState !== void 0 && !isRecord4(value.protocolState)) {
5799
+ if ("protocolState" in value && value.protocolState !== void 0 && !isRecord5(value.protocolState)) {
2872
5800
  throw new Error("Claude session file protocolState must be an object.");
2873
5801
  }
2874
5802
  return {
@@ -2876,10 +5804,10 @@ function parseClaudeSessionFile(value) {
2876
5804
  sessionId: value.sessionId,
2877
5805
  createdAt: value.createdAt,
2878
5806
  parentRunId: typeof value.parentRunId === "string" ? value.parentRunId : void 0,
2879
- protocolState: isRecord4(value.protocolState) ? value.protocolState : {}
5807
+ protocolState: isRecord5(value.protocolState) ? value.protocolState : {}
2880
5808
  };
2881
5809
  }
2882
- function isRecord4(value) {
5810
+ function isRecord5(value) {
2883
5811
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
2884
5812
  }
2885
5813
  function isFileNotFoundError(error) {
@@ -3334,6 +6262,10 @@ function buildClaudeMcpTokenEnvironment(options) {
3334
6262
  GITHUB_TOKEN_BROKER_SECRET: source.GITHUB_TOKEN_BROKER_SECRET,
3335
6263
  GITHUB_TOKEN_CACHE_PATH: source.GITHUB_TOKEN_CACHE_PATH,
3336
6264
  GITHUB_PROJECT_ID: source.GITHUB_PROJECT_ID,
6265
+ LINEAR_API_KEY: source.LINEAR_API_KEY,
6266
+ LINEAR_AUTHORIZATION: source.LINEAR_AUTHORIZATION,
6267
+ LINEAR_GRAPHQL_URL: source.LINEAR_GRAPHQL_URL,
6268
+ SYMPHONY_TRACKER_KIND: source.SYMPHONY_TRACKER_KIND,
3337
6269
  WORKSPACE_RUNTIME_DIR: options.runtimeDirectory ?? source.WORKSPACE_RUNTIME_DIR
3338
6270
  };
3339
6271
  }
@@ -3375,10 +6307,12 @@ export {
3375
6307
  safeReadDir,
3376
6308
  isFileMissing,
3377
6309
  parseRecentEvents,
6310
+ redactObservabilitySecrets,
3378
6311
  isMatchingIssueRun,
3379
6312
  mapIssueOrchestrationStateToStatus,
3380
6313
  resolveGitHubGraphQLToken,
3381
6314
  createGitHubGraphQLMcpServerEntry,
6315
+ createLinearGraphQLMcpServerEntry,
3382
6316
  createClaudePrintRuntimeAdapter,
3383
6317
  runClaudePreflight,
3384
6318
  formatClaudePreflightText,