@whop/cli 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +684 -147
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
external_exports
|
|
6
6
|
} from "./chunk-KFCNNWPI.js";
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
8
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Cli.js
|
|
9
9
|
var Cli_exports = {};
|
|
10
10
|
__export(Cli_exports, {
|
|
11
11
|
collectSkillCommands: () => collectSkillCommands,
|
|
@@ -106,7 +106,7 @@ function extractSegmentPart(segment, segmentTokenStart, segmentTokenCount, targe
|
|
|
106
106
|
return segment.slice(charStart, charEnd);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
109
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/helpers.js
|
|
110
110
|
function isRecord(value) {
|
|
111
111
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
112
112
|
}
|
|
@@ -154,7 +154,7 @@ function suggest(input, candidates) {
|
|
|
154
154
|
return best;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
157
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Completions.js
|
|
158
158
|
function register(shell, name) {
|
|
159
159
|
switch (shell) {
|
|
160
160
|
case "bash":
|
|
@@ -417,7 +417,7 @@ let _incur_complete_${id} = {|spans|
|
|
|
417
417
|
}`;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
420
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Errors.js
|
|
421
421
|
var BaseError = class extends Error {
|
|
422
422
|
name = "Incur.BaseError";
|
|
423
423
|
/** The short, human-readable error message (without details). */
|
|
@@ -491,7 +491,7 @@ function walk(error, fn) {
|
|
|
491
491
|
return current;
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
494
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Fetch.js
|
|
495
495
|
var reservedFlags = /* @__PURE__ */ new Set(["method", "body", "data", "header"]);
|
|
496
496
|
var reservedShort = { X: "method", d: "data", H: "header" };
|
|
497
497
|
function parseArgv(argv2) {
|
|
@@ -627,7 +627,7 @@ async function parseResponse(response) {
|
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
630
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Filter.js
|
|
631
631
|
function parse(expression) {
|
|
632
632
|
const paths = [];
|
|
633
633
|
const tokens = [];
|
|
@@ -1127,7 +1127,7 @@ function resolveOptions(options) {
|
|
|
1127
1127
|
};
|
|
1128
1128
|
}
|
|
1129
1129
|
|
|
1130
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
1130
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/json.js
|
|
1131
1131
|
function stringify(value, space) {
|
|
1132
1132
|
return JSON.stringify(value, (_key, value2) => {
|
|
1133
1133
|
if (typeof value2 === "bigint")
|
|
@@ -1139,7 +1139,7 @@ function normalize(value) {
|
|
|
1139
1139
|
return JSON.parse(stringify(value));
|
|
1140
1140
|
}
|
|
1141
1141
|
|
|
1142
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
1142
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/yaml.js
|
|
1143
1143
|
import { createRequire } from "module";
|
|
1144
1144
|
var cached;
|
|
1145
1145
|
async function load() {
|
|
@@ -1151,7 +1151,7 @@ function loadSync() {
|
|
|
1151
1151
|
return cached;
|
|
1152
1152
|
}
|
|
1153
1153
|
|
|
1154
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
1154
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Formatter.js
|
|
1155
1155
|
function format2(value, fmt = "toon") {
|
|
1156
1156
|
if (value == null)
|
|
1157
1157
|
return "";
|
|
@@ -1259,7 +1259,7 @@ ${String(val)}`;
|
|
|
1259
1259
|
return kvTable(obj);
|
|
1260
1260
|
}
|
|
1261
1261
|
|
|
1262
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
1262
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Parser.js
|
|
1263
1263
|
function parse2(argv2, options = {}) {
|
|
1264
1264
|
const { args: argsSchema, options: optionsSchema, alias, defaults } = options;
|
|
1265
1265
|
const optionNames = createOptionNames(optionsSchema, alias);
|
|
@@ -1676,10 +1676,10 @@ function defaultEnvSource() {
|
|
|
1676
1676
|
return {};
|
|
1677
1677
|
}
|
|
1678
1678
|
|
|
1679
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
1679
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/command.js
|
|
1680
1680
|
var sentinel = Symbol.for("incur.sentinel");
|
|
1681
1681
|
async function execute(command, options) {
|
|
1682
|
-
const { argv: argv2, inputOptions, agent, format: format3, formatExplicit, name, path: path8, version, envSource = process.env, env: envSchema, globals = {}, vars: varsSchema, middlewares = [] } = options;
|
|
1682
|
+
const { argv: argv2, inputOptions: inputOptions2, agent, format: format3, formatExplicit, name, path: path8, version, envSource = process.env, env: envSchema, globals = {}, vars: varsSchema, middlewares = [], request: request2 } = options;
|
|
1683
1683
|
const displayName = options.displayName ?? name;
|
|
1684
1684
|
const parseMode = options.parseMode ?? "argv";
|
|
1685
1685
|
const varsMap = varsSchema ? varsSchema.parse({}) : {};
|
|
@@ -1705,9 +1705,9 @@ async function execute(command, options) {
|
|
|
1705
1705
|
} else if (parseMode === "split") {
|
|
1706
1706
|
const parsed = parse2(argv2, { args: command.args });
|
|
1707
1707
|
args = parsed.args;
|
|
1708
|
-
parsedOptions = command.options ? zodParse(command.options,
|
|
1708
|
+
parsedOptions = command.options ? zodParse(command.options, inputOptions2) : {};
|
|
1709
1709
|
} else {
|
|
1710
|
-
const split2 = splitParams(
|
|
1710
|
+
const split2 = splitParams(inputOptions2, command);
|
|
1711
1711
|
args = command.args ? zodParse(command.args, split2.args) : {};
|
|
1712
1712
|
parsedOptions = command.options ? zodParse(command.options, split2.options) : {};
|
|
1713
1713
|
}
|
|
@@ -1725,6 +1725,7 @@ async function execute(command, options) {
|
|
|
1725
1725
|
name,
|
|
1726
1726
|
ok: okFn,
|
|
1727
1727
|
options: parsedOptions,
|
|
1728
|
+
request: request2,
|
|
1728
1729
|
var: varsMap,
|
|
1729
1730
|
version
|
|
1730
1731
|
});
|
|
@@ -1796,6 +1797,7 @@ async function execute(command, options) {
|
|
|
1796
1797
|
formatExplicit,
|
|
1797
1798
|
globals,
|
|
1798
1799
|
name,
|
|
1800
|
+
request: request2,
|
|
1799
1801
|
set(key, value) {
|
|
1800
1802
|
varsMap[key] = value;
|
|
1801
1803
|
},
|
|
@@ -1923,7 +1925,7 @@ function findBuiltinSubcommand(builtin, token) {
|
|
|
1923
1925
|
return builtin.subcommands?.find((sub) => sub.name === token || sub.aliases?.includes(token));
|
|
1924
1926
|
}
|
|
1925
1927
|
|
|
1926
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
1928
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Help.js
|
|
1927
1929
|
function formatRoot(name, options = {}) {
|
|
1928
1930
|
const { aliases, configFlag, description, globals, version, commands = [], root = false } = options;
|
|
1929
1931
|
const lines = [];
|
|
@@ -2209,7 +2211,7 @@ function redact(value) {
|
|
|
2209
2211
|
return `****${value.slice(-4)}`;
|
|
2210
2212
|
}
|
|
2211
2213
|
|
|
2212
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
2214
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/cta.js
|
|
2213
2215
|
function formatCtaBlock(name, block) {
|
|
2214
2216
|
if (!block || block.commands.length === 0)
|
|
2215
2217
|
return void 0;
|
|
@@ -2232,7 +2234,7 @@ function formatCta(name, cta) {
|
|
|
2232
2234
|
return { command: cmd, ...cta.description ? { description: cta.description } : void 0 };
|
|
2233
2235
|
}
|
|
2234
2236
|
|
|
2235
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
2237
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/pm.js
|
|
2236
2238
|
function detectRunner() {
|
|
2237
2239
|
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
2238
2240
|
const execPath = process.env.npm_execpath ?? "";
|
|
@@ -2243,7 +2245,7 @@ function detectRunner() {
|
|
|
2243
2245
|
return "npx";
|
|
2244
2246
|
}
|
|
2245
2247
|
|
|
2246
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
2248
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Schema.js
|
|
2247
2249
|
function toJsonSchema(schema) {
|
|
2248
2250
|
const result = external_exports.toJSONSchema(schema, {
|
|
2249
2251
|
unrepresentable: "any",
|
|
@@ -2257,39 +2259,23 @@ function toJsonSchema(schema) {
|
|
|
2257
2259
|
return result;
|
|
2258
2260
|
}
|
|
2259
2261
|
|
|
2260
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
2262
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Mcp.js
|
|
2261
2263
|
async function serve(name, version, commands, options = {}) {
|
|
2262
2264
|
const stdio = importStdioModule();
|
|
2263
2265
|
const mcp = await import("./dist-2MZJLO2W.js");
|
|
2264
2266
|
const { fromJsonSchema, McpServer } = mcp;
|
|
2265
2267
|
const StdioServerTransport = await importStdioServerTransport(mcp, stdio);
|
|
2266
2268
|
const server = new McpServer({ name, version }, options.instructions ? { instructions: options.instructions } : void 0);
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
...tool.annotations ? { annotations: tool.annotations } : void 0,
|
|
2278
|
-
...tool.instructions ? { _meta: { instructions: tool.instructions } } : void 0
|
|
2279
|
-
}, async (...callArgs) => {
|
|
2280
|
-
const params = hasInput ? callArgs[0] : {};
|
|
2281
|
-
const extra = hasInput ? callArgs[1] : callArgs[0];
|
|
2282
|
-
return callTool(tool, params, {
|
|
2283
|
-
extra,
|
|
2284
|
-
sendNotification: (n) => server.server.notification(n),
|
|
2285
|
-
name,
|
|
2286
|
-
version,
|
|
2287
|
-
middlewares: options.middlewares,
|
|
2288
|
-
env: options.env,
|
|
2289
|
-
vars: options.vars
|
|
2290
|
-
});
|
|
2291
|
-
});
|
|
2292
|
-
}
|
|
2269
|
+
registerTools(server, commands, {
|
|
2270
|
+
env: options.env,
|
|
2271
|
+
fromJsonSchema,
|
|
2272
|
+
middlewares: options.middlewares,
|
|
2273
|
+
name,
|
|
2274
|
+
sendNotification: (notification) => server.server.notification(notification),
|
|
2275
|
+
tools: options.tools,
|
|
2276
|
+
vars: options.vars,
|
|
2277
|
+
version
|
|
2278
|
+
});
|
|
2293
2279
|
const input = options.input ?? process.stdin;
|
|
2294
2280
|
const output = options.output ?? process.stdout;
|
|
2295
2281
|
const transport = new StdioServerTransport(input, output);
|
|
@@ -2325,6 +2311,7 @@ async function callTool(tool, params, options = {}) {
|
|
|
2325
2311
|
name: options.name ?? tool.name,
|
|
2326
2312
|
parseMode: "flat",
|
|
2327
2313
|
path: tool.name,
|
|
2314
|
+
request: options.request,
|
|
2328
2315
|
vars: options.vars,
|
|
2329
2316
|
version: options.version
|
|
2330
2317
|
});
|
|
@@ -2368,34 +2355,215 @@ async function callTool(tool, params, options = {}) {
|
|
|
2368
2355
|
...cta ? { _meta: { cta } } : void 0
|
|
2369
2356
|
};
|
|
2370
2357
|
}
|
|
2371
|
-
function
|
|
2358
|
+
function registerTools(server, commands, options) {
|
|
2359
|
+
const tools = collectTools(commands, [], [], options.tools);
|
|
2360
|
+
if (tools.length === 0)
|
|
2361
|
+
return;
|
|
2362
|
+
if ((options.tools?.discovery ?? "progressive") === "direct") {
|
|
2363
|
+
for (const tool of tools)
|
|
2364
|
+
registerDirectTool(server, tool, options);
|
|
2365
|
+
return;
|
|
2366
|
+
}
|
|
2367
|
+
registerDiscoveryTools(server, tools, options);
|
|
2368
|
+
}
|
|
2369
|
+
function registerDirectTool(server, tool, options) {
|
|
2370
|
+
const mergedShape = {
|
|
2371
|
+
...tool.command.args?.shape,
|
|
2372
|
+
...tool.command.options?.shape
|
|
2373
|
+
};
|
|
2374
|
+
const hasInput = Object.keys(mergedShape).length > 0;
|
|
2375
|
+
server.registerTool(tool.name, {
|
|
2376
|
+
...tool.description ? { description: tool.description } : void 0,
|
|
2377
|
+
...hasInput ? { inputSchema: external_exports.object(mergedShape) } : void 0,
|
|
2378
|
+
...tool.outputSchema ? { outputSchema: options.fromJsonSchema(tool.outputSchema) } : void 0,
|
|
2379
|
+
...tool.annotations ? { annotations: tool.annotations } : void 0,
|
|
2380
|
+
...tool.instructions ? { _meta: { instructions: tool.instructions } } : void 0
|
|
2381
|
+
}, async (...callArgs) => {
|
|
2382
|
+
const params = hasInput ? callArgs[0] : {};
|
|
2383
|
+
const extra = hasInput ? callArgs[1] : callArgs[0];
|
|
2384
|
+
return callTool(tool, params, callOptions(options, extra));
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
function registerDiscoveryTools(server, tools, options) {
|
|
2388
|
+
const byName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
2389
|
+
server.registerTool("search_tools", {
|
|
2390
|
+
description: "Search or page through available tools by capability. Returns names and descriptions without loading their schemas. Inspect a result before calling it.",
|
|
2391
|
+
inputSchema: external_exports.object({
|
|
2392
|
+
limit: external_exports.number().int().min(1).max(20).default(5).describe("Maximum matches."),
|
|
2393
|
+
offset: external_exports.number().int().min(0).default(0).describe("Matches to skip."),
|
|
2394
|
+
query: external_exports.string().default("").describe("Capability to find. Empty lists all tools.")
|
|
2395
|
+
}),
|
|
2396
|
+
annotations: catalogAnnotations
|
|
2397
|
+
}, async (params) => {
|
|
2398
|
+
const matches = searchTools(tools, params.query);
|
|
2399
|
+
const page = matches.slice(params.offset, params.offset + params.limit);
|
|
2400
|
+
return toolResult({
|
|
2401
|
+
tools: page.map((tool) => ({
|
|
2402
|
+
name: tool.name,
|
|
2403
|
+
...tool.description ? { description: tool.description } : void 0,
|
|
2404
|
+
...tool.annotations ? { annotations: tool.annotations } : void 0
|
|
2405
|
+
})),
|
|
2406
|
+
...params.offset + page.length < matches.length ? { nextOffset: params.offset + page.length } : void 0
|
|
2407
|
+
});
|
|
2408
|
+
});
|
|
2409
|
+
server.registerTool("get_tool_details", {
|
|
2410
|
+
description: "Inspect one tool returned by search_tools. Returns its complete input schema and metadata.",
|
|
2411
|
+
inputSchema: external_exports.object({ name: external_exports.string().min(1).describe("Exact tool name.") }),
|
|
2412
|
+
annotations: catalogAnnotations
|
|
2413
|
+
}, async (params) => {
|
|
2414
|
+
const tool = byName.get(params.name);
|
|
2415
|
+
if (!tool)
|
|
2416
|
+
return toolError(`Unknown tool: ${params.name}`);
|
|
2417
|
+
return toolResult({
|
|
2418
|
+
name: tool.name,
|
|
2419
|
+
...tool.description ? { description: tool.description } : void 0,
|
|
2420
|
+
inputSchema: tool.inputSchema,
|
|
2421
|
+
...tool.outputSchema ? { outputSchema: tool.outputSchema } : void 0,
|
|
2422
|
+
...tool.annotations ? { annotations: tool.annotations } : void 0,
|
|
2423
|
+
...tool.instructions ? { instructions: tool.instructions } : void 0
|
|
2424
|
+
});
|
|
2425
|
+
});
|
|
2426
|
+
server.registerTool("call_read_tool", {
|
|
2427
|
+
description: "Execute a tool marked read-only after inspecting its schema with get_tool_details.",
|
|
2428
|
+
inputSchema: callSchema,
|
|
2429
|
+
annotations: readAnnotations
|
|
2430
|
+
}, async (params, extra) => {
|
|
2431
|
+
const tool = byName.get(params.name);
|
|
2432
|
+
if (!tool)
|
|
2433
|
+
return toolError(`Unknown tool: ${params.name}`);
|
|
2434
|
+
if (tool.annotations?.readOnlyHint !== true)
|
|
2435
|
+
return toolError(`Tool is not read-only: ${params.name}`);
|
|
2436
|
+
return callTool(tool, params.arguments, callOptions(options, extra));
|
|
2437
|
+
});
|
|
2438
|
+
server.registerTool("call_write_tool", {
|
|
2439
|
+
description: "Execute a writable or unclassified tool after inspecting its schema with get_tool_details.",
|
|
2440
|
+
inputSchema: callSchema,
|
|
2441
|
+
annotations: writeAnnotations
|
|
2442
|
+
}, async (params, extra) => {
|
|
2443
|
+
const tool = byName.get(params.name);
|
|
2444
|
+
if (!tool)
|
|
2445
|
+
return toolError(`Unknown tool: ${params.name}`);
|
|
2446
|
+
if (tool.annotations?.readOnlyHint === true)
|
|
2447
|
+
return toolError(`Tool is read-only: ${params.name}`);
|
|
2448
|
+
return callTool(tool, params.arguments, callOptions(options, extra));
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
var callSchema = external_exports.object({
|
|
2452
|
+
name: external_exports.string().min(1).describe("Exact tool name."),
|
|
2453
|
+
arguments: external_exports.record(external_exports.string(), external_exports.unknown()).default({}).describe("Arguments from its schema.")
|
|
2454
|
+
});
|
|
2455
|
+
var catalogAnnotations = {
|
|
2456
|
+
destructiveHint: false,
|
|
2457
|
+
idempotentHint: true,
|
|
2458
|
+
openWorldHint: false,
|
|
2459
|
+
readOnlyHint: true
|
|
2460
|
+
};
|
|
2461
|
+
var readAnnotations = {
|
|
2462
|
+
destructiveHint: false,
|
|
2463
|
+
idempotentHint: true,
|
|
2464
|
+
openWorldHint: true,
|
|
2465
|
+
readOnlyHint: true
|
|
2466
|
+
};
|
|
2467
|
+
var writeAnnotations = {
|
|
2468
|
+
destructiveHint: true,
|
|
2469
|
+
idempotentHint: false,
|
|
2470
|
+
openWorldHint: true,
|
|
2471
|
+
readOnlyHint: false
|
|
2472
|
+
};
|
|
2473
|
+
function callOptions(options, extra) {
|
|
2474
|
+
return {
|
|
2475
|
+
env: options.env,
|
|
2476
|
+
extra,
|
|
2477
|
+
middlewares: options.middlewares,
|
|
2478
|
+
name: options.name,
|
|
2479
|
+
request: options.request?.(extra),
|
|
2480
|
+
...options.sendNotification ? { sendNotification: options.sendNotification } : void 0,
|
|
2481
|
+
vars: options.vars,
|
|
2482
|
+
version: options.version
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
function searchTools(tools, query) {
|
|
2486
|
+
const normalized = normalizeSearch(query);
|
|
2487
|
+
const terms = normalized.split(" ").filter(Boolean);
|
|
2488
|
+
return tools.map((tool) => ({ tool, score: toolScore(tool, normalized, terms) })).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name)).map(({ tool }) => tool);
|
|
2489
|
+
}
|
|
2490
|
+
function toolScore(tool, query, terms) {
|
|
2491
|
+
const name = normalizeSearch(tool.name);
|
|
2492
|
+
const description = normalizeSearch(tool.description ?? "");
|
|
2493
|
+
if (name === query)
|
|
2494
|
+
return 1e3;
|
|
2495
|
+
let score = name.startsWith(query) ? 100 : name.includes(query) ? 50 : 0;
|
|
2496
|
+
for (const term of terms) {
|
|
2497
|
+
if (name.split(" ").includes(term))
|
|
2498
|
+
score += 20;
|
|
2499
|
+
else if (name.includes(term))
|
|
2500
|
+
score += 10;
|
|
2501
|
+
if (description.includes(term))
|
|
2502
|
+
score += 2;
|
|
2503
|
+
}
|
|
2504
|
+
return score;
|
|
2505
|
+
}
|
|
2506
|
+
function normalizeSearch(value) {
|
|
2507
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
2508
|
+
}
|
|
2509
|
+
function toolResult(value) {
|
|
2510
|
+
return { content: [{ type: "text", text: stringify(value) }] };
|
|
2511
|
+
}
|
|
2512
|
+
function toolError(message) {
|
|
2513
|
+
return { ...toolResult({ error: message }), isError: true };
|
|
2514
|
+
}
|
|
2515
|
+
function collectTools(commands, prefix, parentMiddlewares = [], filter) {
|
|
2516
|
+
const tools = filterTools(collectToolEntries(commands, prefix, parentMiddlewares), filter);
|
|
2517
|
+
assertUniqueToolNames(tools);
|
|
2518
|
+
return tools.sort((a, b) => a.name.localeCompare(b.name));
|
|
2519
|
+
}
|
|
2520
|
+
function collectToolEntries(commands, prefix, parentMiddlewares = []) {
|
|
2372
2521
|
const result = [];
|
|
2373
2522
|
for (const [name, entry] of commands) {
|
|
2374
2523
|
if ("_alias" in entry)
|
|
2375
2524
|
continue;
|
|
2525
|
+
if (entry.mcp === false)
|
|
2526
|
+
continue;
|
|
2376
2527
|
const path8 = [...prefix, name];
|
|
2377
2528
|
if ("_group" in entry && entry._group) {
|
|
2378
2529
|
const groupMw = [
|
|
2379
2530
|
...parentMiddlewares,
|
|
2380
2531
|
...entry.middlewares ?? []
|
|
2381
2532
|
];
|
|
2382
|
-
result.push(...
|
|
2533
|
+
result.push(...collectToolEntries(entry.commands, path8, groupMw));
|
|
2383
2534
|
} else {
|
|
2384
|
-
const
|
|
2535
|
+
const mcp = entry.mcp === false ? void 0 : entry.mcp;
|
|
2536
|
+
const outputSchema2 = entry.output ? mcpOutputSchema(entry.output) : void 0;
|
|
2385
2537
|
result.push({
|
|
2386
|
-
name:
|
|
2387
|
-
description:
|
|
2538
|
+
name: mcp?.name ?? path8.join("_"),
|
|
2539
|
+
description: mcp?.description ?? entry.description,
|
|
2388
2540
|
inputSchema: buildToolSchema(entry.args, entry.options),
|
|
2389
|
-
...
|
|
2390
|
-
...
|
|
2391
|
-
...
|
|
2541
|
+
...outputSchema2 ? { outputSchema: outputSchema2 } : void 0,
|
|
2542
|
+
...mcp?.annotations ? { annotations: mcp.annotations } : void 0,
|
|
2543
|
+
...mcp?.instructions ? { instructions: mcp.instructions } : void 0,
|
|
2392
2544
|
command: entry,
|
|
2393
2545
|
...parentMiddlewares.length > 0 ? { middlewares: parentMiddlewares } : void 0
|
|
2394
2546
|
});
|
|
2395
2547
|
}
|
|
2396
2548
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2549
|
+
return result;
|
|
2550
|
+
}
|
|
2551
|
+
function filterTools(tools, filter) {
|
|
2552
|
+
if (!filter)
|
|
2553
|
+
return tools;
|
|
2554
|
+
const includes = filter.include?.map(patternToRegExp);
|
|
2555
|
+
const excludes = filter.exclude?.map(patternToRegExp) ?? [];
|
|
2556
|
+
return tools.filter((tool) => {
|
|
2557
|
+
if (excludes.some((pattern) => pattern.test(tool.name)))
|
|
2558
|
+
return false;
|
|
2559
|
+
if (!includes || includes.length === 0)
|
|
2560
|
+
return true;
|
|
2561
|
+
return includes.some((pattern) => pattern.test(tool.name));
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
function patternToRegExp(pattern) {
|
|
2565
|
+
const escaped = pattern.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*");
|
|
2566
|
+
return new RegExp(`^${escaped}$`);
|
|
2399
2567
|
}
|
|
2400
2568
|
function assertUniqueToolNames(tools) {
|
|
2401
2569
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2426,15 +2594,17 @@ function buildToolSchema(args, options) {
|
|
|
2426
2594
|
return { type: "object", properties };
|
|
2427
2595
|
}
|
|
2428
2596
|
|
|
2429
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
2597
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Openapi.js
|
|
2430
2598
|
var Openapi_exports = {};
|
|
2431
2599
|
__export(Openapi_exports, {
|
|
2600
|
+
coerceIfNeeded: () => coerceIfNeeded,
|
|
2432
2601
|
fromCli: () => fromCli,
|
|
2433
2602
|
generateCommands: () => generateCommands,
|
|
2434
|
-
resolve: () => resolve
|
|
2603
|
+
resolve: () => resolve,
|
|
2604
|
+
toZod: () => toZod
|
|
2435
2605
|
});
|
|
2436
2606
|
|
|
2437
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
2607
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/dereference.js
|
|
2438
2608
|
function dereference(root) {
|
|
2439
2609
|
const cache = /* @__PURE__ */ new Map();
|
|
2440
2610
|
return walk2(root, root, cache);
|
|
@@ -2486,7 +2656,7 @@ function resolvePointer(root, pointer) {
|
|
|
2486
2656
|
return current;
|
|
2487
2657
|
}
|
|
2488
2658
|
|
|
2489
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
2659
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Openapi.js
|
|
2490
2660
|
function fromCli(cli2, options = {}) {
|
|
2491
2661
|
const commands = toCommands.get(cli2);
|
|
2492
2662
|
if (!commands)
|
|
@@ -2526,7 +2696,7 @@ function splitCommandName(name) {
|
|
|
2526
2696
|
function addCommand(paths, segments, command) {
|
|
2527
2697
|
const argsSchema = command.args ? toJsonSchema(command.args) : void 0;
|
|
2528
2698
|
const optionsSchema = command.options ? toJsonSchema(command.options) : void 0;
|
|
2529
|
-
const
|
|
2699
|
+
const outputSchema2 = command.output ? toJsonSchema(command.output) : void 0;
|
|
2530
2700
|
const args = objectProperties(argsSchema);
|
|
2531
2701
|
const requiredArgs = new Set(requiredProperties(argsSchema));
|
|
2532
2702
|
const method = inferMethod(segments);
|
|
@@ -2550,7 +2720,7 @@ function addCommand(paths, segments, command) {
|
|
|
2550
2720
|
...command.description ? { summary: command.description } : void 0,
|
|
2551
2721
|
...parameters.length ? { parameters } : void 0,
|
|
2552
2722
|
...requestBody(method, optionsSchema),
|
|
2553
|
-
responses: responses(
|
|
2723
|
+
responses: responses(outputSchema2)
|
|
2554
2724
|
};
|
|
2555
2725
|
const item = paths[variant.path] ?? {};
|
|
2556
2726
|
item[method] = operation;
|
|
@@ -2700,6 +2870,8 @@ async function generateCommands(spec2, fetch3, options = {}) {
|
|
|
2700
2870
|
const operations = openapiOperations(paths);
|
|
2701
2871
|
const namespaceInfo = getNamespaceInfo(operations);
|
|
2702
2872
|
const { config } = options;
|
|
2873
|
+
if (config?.compact)
|
|
2874
|
+
compactOperations(operations);
|
|
2703
2875
|
for (const { method, operation: op, path: path8 } of operations) {
|
|
2704
2876
|
const segments = commandSegments({
|
|
2705
2877
|
method,
|
|
@@ -2713,7 +2885,7 @@ async function generateCommands(spec2, fetch3, options = {}) {
|
|
|
2713
2885
|
const queryParams = (op.parameters ?? []).filter((p) => p.in === "query");
|
|
2714
2886
|
const headerParams = headerOptions([
|
|
2715
2887
|
...(op.parameters ?? []).filter((p) => p.in === "header"),
|
|
2716
|
-
...securityHeaderParams(resolved, op)
|
|
2888
|
+
...config?.security === false ? [] : securityHeaderParams(resolved, op)
|
|
2717
2889
|
]);
|
|
2718
2890
|
const bodySchema = op.requestBody?.content?.["application/json"]?.schema;
|
|
2719
2891
|
const bodyProps = bodySchema?.properties ?? {};
|
|
@@ -2760,11 +2932,19 @@ async function generateCommands(spec2, fetch3, options = {}) {
|
|
|
2760
2932
|
const optionsSchema = Object.keys(optShape).length > 0 ? external_exports.object(optShape) : void 0;
|
|
2761
2933
|
setCommand(commands, segments, {
|
|
2762
2934
|
description: op.summary ?? op.description,
|
|
2935
|
+
mcp: {
|
|
2936
|
+
annotations: mcpAnnotations(method),
|
|
2937
|
+
// Help keeps the short summary; MCP tools surface the full prose.
|
|
2938
|
+
...op.summary && op.description && op.summary !== op.description ? { description: `${op.summary}
|
|
2939
|
+
|
|
2940
|
+
${op.description}` } : void 0
|
|
2941
|
+
},
|
|
2763
2942
|
args: argsSchema,
|
|
2764
2943
|
options: optionsSchema,
|
|
2765
2944
|
run: createHandler({
|
|
2766
2945
|
basePath: options.basePath,
|
|
2767
2946
|
fetch: fetch3,
|
|
2947
|
+
forwardHeaders: config?.forwardHeaders,
|
|
2768
2948
|
httpMethod,
|
|
2769
2949
|
path: path8,
|
|
2770
2950
|
headerParams,
|
|
@@ -2776,6 +2956,15 @@ async function generateCommands(spec2, fetch3, options = {}) {
|
|
|
2776
2956
|
}
|
|
2777
2957
|
return commands;
|
|
2778
2958
|
}
|
|
2959
|
+
function mcpAnnotations(method) {
|
|
2960
|
+
const readOnly = ["get", "head", "options", "trace"].includes(method);
|
|
2961
|
+
return {
|
|
2962
|
+
destructiveHint: !readOnly,
|
|
2963
|
+
idempotentHint: readOnly || method === "delete" || method === "put",
|
|
2964
|
+
openWorldHint: true,
|
|
2965
|
+
readOnlyHint: readOnly
|
|
2966
|
+
};
|
|
2967
|
+
}
|
|
2779
2968
|
var openapiMethods = /* @__PURE__ */ new Set([
|
|
2780
2969
|
"delete",
|
|
2781
2970
|
"get",
|
|
@@ -2829,6 +3018,58 @@ function securityHeaderParam(name, scheme) {
|
|
|
2829
3018
|
return void 0;
|
|
2830
3019
|
}
|
|
2831
3020
|
var authorizationSchemes = /* @__PURE__ */ new Set(["basic", "bearer"]);
|
|
3021
|
+
var compactPatternLimit = 100;
|
|
3022
|
+
var dateTimeFormats = /* @__PURE__ */ new Set(["date", "date-time", "duration", "time"]);
|
|
3023
|
+
function compactOperations(operations) {
|
|
3024
|
+
for (const { operation } of operations) {
|
|
3025
|
+
for (const parameter of operation.parameters ?? [])
|
|
3026
|
+
if (parameter.schema)
|
|
3027
|
+
parameter.schema = compactSchema(parameter.schema);
|
|
3028
|
+
const body = operation.requestBody?.content?.["application/json"];
|
|
3029
|
+
if (body?.schema)
|
|
3030
|
+
body.schema = compactSchema(body.schema);
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
function compactSchema(schema, seen = /* @__PURE__ */ new Map()) {
|
|
3034
|
+
const cached2 = seen.get(schema);
|
|
3035
|
+
if (cached2)
|
|
3036
|
+
return cached2;
|
|
3037
|
+
const out = { ...schema };
|
|
3038
|
+
seen.set(schema, out);
|
|
3039
|
+
delete out.example;
|
|
3040
|
+
delete out.examples;
|
|
3041
|
+
if (typeof out.pattern === "string" && out.pattern.length > compactPatternLimit)
|
|
3042
|
+
delete out.pattern;
|
|
3043
|
+
if (typeof out.format === "string" && dateTimeFormats.has(out.format))
|
|
3044
|
+
delete out.format;
|
|
3045
|
+
for (const key of ["allOf", "anyOf", "oneOf", "prefixItems"]) {
|
|
3046
|
+
if (!Array.isArray(out[key]))
|
|
3047
|
+
continue;
|
|
3048
|
+
const entries = out[key].map((entry) => compactSchema(entry, seen)).filter((entry) => Object.keys(entry).length > 0);
|
|
3049
|
+
if (entries.length > 0)
|
|
3050
|
+
out[key] = entries;
|
|
3051
|
+
else
|
|
3052
|
+
delete out[key];
|
|
3053
|
+
}
|
|
3054
|
+
for (const key of ["additionalProperties", "contains", "items", "not", "propertyNames"]) {
|
|
3055
|
+
const value = out[key];
|
|
3056
|
+
if (isSchemaObject(value))
|
|
3057
|
+
out[key] = compactSchema(value, seen);
|
|
3058
|
+
}
|
|
3059
|
+
for (const key of ["$defs", "patternProperties", "properties"]) {
|
|
3060
|
+
const value = out[key];
|
|
3061
|
+
if (!isSchemaObject(value))
|
|
3062
|
+
continue;
|
|
3063
|
+
const map = {};
|
|
3064
|
+
for (const [name, entry] of Object.entries(value))
|
|
3065
|
+
map[name] = isSchemaObject(entry) ? compactSchema(entry, seen) : entry;
|
|
3066
|
+
out[key] = map;
|
|
3067
|
+
}
|
|
3068
|
+
return out;
|
|
3069
|
+
}
|
|
3070
|
+
function isSchemaObject(value) {
|
|
3071
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3072
|
+
}
|
|
2832
3073
|
function headerOptions(parameters) {
|
|
2833
3074
|
const seen = /* @__PURE__ */ new Set();
|
|
2834
3075
|
const headers = [];
|
|
@@ -2966,10 +3207,15 @@ function createHandler(config) {
|
|
|
2966
3207
|
if (value !== void 0)
|
|
2967
3208
|
input.headers.set(p.name, String(value));
|
|
2968
3209
|
}
|
|
3210
|
+
for (const name of config.forwardHeaders ?? []) {
|
|
3211
|
+
const value = context.request?.headers.get(name);
|
|
3212
|
+
if (!input.headers.has(name) && value !== null && value !== void 0)
|
|
3213
|
+
input.headers.set(name, value);
|
|
3214
|
+
}
|
|
2969
3215
|
if (body && !input.headers.has("content-type"))
|
|
2970
3216
|
input.headers.set("content-type", "application/json");
|
|
2971
|
-
const
|
|
2972
|
-
const response = await config.fetch(
|
|
3217
|
+
const request2 = buildRequest(input);
|
|
3218
|
+
const response = await config.fetch(request2);
|
|
2973
3219
|
const output = await parseResponse(response);
|
|
2974
3220
|
if (!output.ok)
|
|
2975
3221
|
return context.error({
|
|
@@ -3005,7 +3251,174 @@ function coerceIfNeeded(schema) {
|
|
|
3005
3251
|
return desc ? coerced.describe(desc) : coerced;
|
|
3006
3252
|
}
|
|
3007
3253
|
|
|
3008
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
3254
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/McpSource.js
|
|
3255
|
+
var protocolVersion = "2025-06-18";
|
|
3256
|
+
async function resolve2(source, options = {}) {
|
|
3257
|
+
const session = sourceSession(source);
|
|
3258
|
+
await request(session, "initialize", {
|
|
3259
|
+
protocolVersion,
|
|
3260
|
+
capabilities: {},
|
|
3261
|
+
clientInfo: { name: "incur", version: options.version ?? "1.0.0" }
|
|
3262
|
+
});
|
|
3263
|
+
session.initialized = true;
|
|
3264
|
+
await request(session, "notifications/initialized");
|
|
3265
|
+
const result = await request(session, "tools/list");
|
|
3266
|
+
const listed = result.tools ?? [];
|
|
3267
|
+
if (isProgressiveCatalog(listed))
|
|
3268
|
+
return { discovery: "progressive", tools: await discoverTools(session), session };
|
|
3269
|
+
return { tools: listed, session };
|
|
3270
|
+
}
|
|
3271
|
+
function generateCommands2(resolved) {
|
|
3272
|
+
const commands = /* @__PURE__ */ new Map();
|
|
3273
|
+
for (const tool of resolved.tools) {
|
|
3274
|
+
const options = tool.inputSchema ? inputOptions(tool.inputSchema) : void 0;
|
|
3275
|
+
const output = outputSchema(tool.outputSchema);
|
|
3276
|
+
commands.set(tool.name, {
|
|
3277
|
+
description: tool.description,
|
|
3278
|
+
...tool.annotations ? { mcp: { annotations: tool.annotations } } : void 0,
|
|
3279
|
+
...options ? { options } : void 0,
|
|
3280
|
+
...output ? { output } : void 0,
|
|
3281
|
+
async run(context) {
|
|
3282
|
+
const parameters = { name: tool.name, arguments: { ...context.args, ...context.options } };
|
|
3283
|
+
const result = await request(resolved.session, "tools/call", resolved.discovery === "progressive" ? {
|
|
3284
|
+
name: tool.annotations?.readOnlyHint === true ? "call_read_tool" : "call_write_tool",
|
|
3285
|
+
arguments: parameters
|
|
3286
|
+
} : parameters);
|
|
3287
|
+
if (result.isError)
|
|
3288
|
+
return context.error({ code: "MCP_TOOL_ERROR", message: resultText(result) });
|
|
3289
|
+
return resultValue(result);
|
|
3290
|
+
}
|
|
3291
|
+
});
|
|
3292
|
+
}
|
|
3293
|
+
return commands;
|
|
3294
|
+
}
|
|
3295
|
+
function isProgressiveCatalog(tools) {
|
|
3296
|
+
if (tools.length !== 4)
|
|
3297
|
+
return false;
|
|
3298
|
+
const names = new Set(tools.map((tool) => tool.name));
|
|
3299
|
+
return names.has("search_tools") && names.has("get_tool_details") && names.has("call_read_tool") && names.has("call_write_tool");
|
|
3300
|
+
}
|
|
3301
|
+
async function discoverTools(session) {
|
|
3302
|
+
const tools = [];
|
|
3303
|
+
let offset = 0;
|
|
3304
|
+
while (offset !== void 0) {
|
|
3305
|
+
const search = await callRemoteTool(session, "search_tools", {
|
|
3306
|
+
query: "",
|
|
3307
|
+
limit: 20,
|
|
3308
|
+
offset
|
|
3309
|
+
});
|
|
3310
|
+
for (const match of search.tools ?? []) {
|
|
3311
|
+
if (!match.name)
|
|
3312
|
+
continue;
|
|
3313
|
+
const tool = await callRemoteTool(session, "get_tool_details", {
|
|
3314
|
+
name: match.name
|
|
3315
|
+
});
|
|
3316
|
+
if (tool.name)
|
|
3317
|
+
tools.push(tool);
|
|
3318
|
+
}
|
|
3319
|
+
if (search.nextOffset !== void 0 && search.nextOffset <= offset)
|
|
3320
|
+
throw new Error("MCP tool catalog returned a non-advancing offset");
|
|
3321
|
+
offset = search.nextOffset;
|
|
3322
|
+
}
|
|
3323
|
+
return tools;
|
|
3324
|
+
}
|
|
3325
|
+
async function callRemoteTool(session, name, arguments_) {
|
|
3326
|
+
const result = await request(session, "tools/call", { name, arguments: arguments_ });
|
|
3327
|
+
if (result.isError)
|
|
3328
|
+
throw new Error(resultText(result) || `MCP tool failed: ${name}`);
|
|
3329
|
+
return resultValue(result);
|
|
3330
|
+
}
|
|
3331
|
+
function sourceSession(source) {
|
|
3332
|
+
if (typeof source === "string" || source instanceof URL)
|
|
3333
|
+
return { url: new URL(source), fetch: globalThis.fetch.bind(globalThis) };
|
|
3334
|
+
return {
|
|
3335
|
+
url: new URL(source.url),
|
|
3336
|
+
fetch: source.fetch ?? globalThis.fetch.bind(globalThis),
|
|
3337
|
+
...source.headers ? { headers: source.headers } : void 0
|
|
3338
|
+
};
|
|
3339
|
+
}
|
|
3340
|
+
async function request(session, method, params) {
|
|
3341
|
+
const notification = method.startsWith("notifications/");
|
|
3342
|
+
const id = notification ? void 0 : crypto.randomUUID();
|
|
3343
|
+
const headers = new Headers(session.headers);
|
|
3344
|
+
headers.set("content-type", "application/json");
|
|
3345
|
+
headers.set("accept", "application/json, text/event-stream");
|
|
3346
|
+
if (session.id)
|
|
3347
|
+
headers.set("mcp-session-id", session.id);
|
|
3348
|
+
if (session.initialized)
|
|
3349
|
+
headers.set("MCP-Protocol-Version", protocolVersion);
|
|
3350
|
+
const body = JSON.stringify({ jsonrpc: "2.0", ...id ? { id } : void 0, method, params });
|
|
3351
|
+
const response = await session.fetch(new Request(session.url, { method: "POST", headers, body }));
|
|
3352
|
+
const sessionId = response.headers.get("mcp-session-id");
|
|
3353
|
+
if (sessionId)
|
|
3354
|
+
session.id = sessionId;
|
|
3355
|
+
if (!response.ok)
|
|
3356
|
+
throw new Error(`MCP HTTP ${response.status}`);
|
|
3357
|
+
if (notification && response.status === 202)
|
|
3358
|
+
return {};
|
|
3359
|
+
const text4 = await response.text();
|
|
3360
|
+
if (!text4)
|
|
3361
|
+
return {};
|
|
3362
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
3363
|
+
const message = contentType.includes("text/event-stream") ? parseSse(text4, id) : JSON.parse(text4);
|
|
3364
|
+
if (message.error)
|
|
3365
|
+
throw new Error(message.error.message ?? "MCP request failed");
|
|
3366
|
+
return message.result ?? {};
|
|
3367
|
+
}
|
|
3368
|
+
function parseSse(text4, id) {
|
|
3369
|
+
for (const event of text4.split(/\r?\n\r?\n/)) {
|
|
3370
|
+
const data = event.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n");
|
|
3371
|
+
if (!data)
|
|
3372
|
+
continue;
|
|
3373
|
+
const message = JSON.parse(data);
|
|
3374
|
+
if (id === void 0 || message.id === id)
|
|
3375
|
+
return message;
|
|
3376
|
+
}
|
|
3377
|
+
throw new Error("MCP SSE response did not include the matching JSON-RPC message");
|
|
3378
|
+
}
|
|
3379
|
+
function inputOptions(schema) {
|
|
3380
|
+
const properties = schema.properties ?? {};
|
|
3381
|
+
const required = new Set(schema.required ?? []);
|
|
3382
|
+
const shape = {};
|
|
3383
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
3384
|
+
let zodType = toZod(property);
|
|
3385
|
+
if (!required.has(key))
|
|
3386
|
+
zodType = zodType.optional();
|
|
3387
|
+
if (typeof property.description === "string")
|
|
3388
|
+
zodType = zodType.describe(property.description);
|
|
3389
|
+
shape[key] = coerceIfNeeded(zodType);
|
|
3390
|
+
}
|
|
3391
|
+
return Object.keys(shape).length > 0 ? external_exports.object(shape) : void 0;
|
|
3392
|
+
}
|
|
3393
|
+
function outputSchema(schema) {
|
|
3394
|
+
if (!schema || schema.type !== "object")
|
|
3395
|
+
return void 0;
|
|
3396
|
+
try {
|
|
3397
|
+
return external_exports.fromJSONSchema(schema);
|
|
3398
|
+
} catch {
|
|
3399
|
+
return void 0;
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
function resultText(result) {
|
|
3403
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
3404
|
+
return content.map((item) => item.type === "text" ? item.text : "").filter(Boolean).join("\n");
|
|
3405
|
+
}
|
|
3406
|
+
function resultValue(result) {
|
|
3407
|
+
if (result.structuredContent !== void 0)
|
|
3408
|
+
return result.structuredContent;
|
|
3409
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
3410
|
+
const textItems = content.filter((item) => item.type === "text").map((item) => item.text);
|
|
3411
|
+
if (textItems.length === 1) {
|
|
3412
|
+
try {
|
|
3413
|
+
return JSON.parse(textItems[0]);
|
|
3414
|
+
} catch {
|
|
3415
|
+
return textItems[0];
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
return textItems;
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Skill.js
|
|
3009
3422
|
import { createHash } from "crypto";
|
|
3010
3423
|
function index(name, commands, description) {
|
|
3011
3424
|
const lines = [`# ${name}`];
|
|
@@ -3160,14 +3573,14 @@ ${rows.join("\n")}`);
|
|
|
3160
3573
|
${rows.join("\n")}`);
|
|
3161
3574
|
}
|
|
3162
3575
|
if (cmd.output) {
|
|
3163
|
-
const
|
|
3164
|
-
const table2 = schemaToTable(
|
|
3576
|
+
const outputSchema2 = toJsonSchema(cmd.output);
|
|
3577
|
+
const table2 = schemaToTable(outputSchema2);
|
|
3165
3578
|
if (table2)
|
|
3166
3579
|
sections.push(`${sub} Output
|
|
3167
3580
|
|
|
3168
3581
|
${table2}`);
|
|
3169
3582
|
else {
|
|
3170
|
-
const type = resolveTypeName2(
|
|
3583
|
+
const type = resolveTypeName2(outputSchema2);
|
|
3171
3584
|
sections.push(`${sub} Output
|
|
3172
3585
|
|
|
3173
3586
|
Type: \`${type}\``);
|
|
@@ -3249,7 +3662,7 @@ function resolveTypeName2(prop) {
|
|
|
3249
3662
|
return "unknown";
|
|
3250
3663
|
}
|
|
3251
3664
|
|
|
3252
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
3665
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/SyncMcp.js
|
|
3253
3666
|
import { execFile } from "child_process";
|
|
3254
3667
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
3255
3668
|
import { homedir } from "os";
|
|
@@ -3300,8 +3713,16 @@ function registerAmp(name, command) {
|
|
|
3300
3713
|
return true;
|
|
3301
3714
|
}
|
|
3302
3715
|
function defaultCommand(name, runner) {
|
|
3716
|
+
if (isStandaloneBinary())
|
|
3717
|
+
return `"${process.execPath}" --mcp`;
|
|
3303
3718
|
return shouldUseBareCommand(name) ? `${name} --mcp` : `${runner} ${detectPackageSpecifier(name)} --mcp`;
|
|
3304
3719
|
}
|
|
3720
|
+
function isStandaloneBinary() {
|
|
3721
|
+
const bin = process.argv[1]?.replace(/\\/g, "/");
|
|
3722
|
+
if (!bin)
|
|
3723
|
+
return false;
|
|
3724
|
+
return bin.startsWith("/$bunfs/") || bin.includes("/~BUN/");
|
|
3725
|
+
}
|
|
3305
3726
|
function nodeModulesInfo() {
|
|
3306
3727
|
const normalized = process.argv[1]?.replace(/\\/g, "/");
|
|
3307
3728
|
const match = normalized?.match(/^(.+)\/node_modules\/(.+)$/);
|
|
@@ -3377,24 +3798,24 @@ function splitCommand(input) {
|
|
|
3377
3798
|
return tokens;
|
|
3378
3799
|
}
|
|
3379
3800
|
function exec(cmd, args) {
|
|
3380
|
-
return new Promise((
|
|
3801
|
+
return new Promise((resolve6, reject) => {
|
|
3381
3802
|
execFile(cmd, args, (error, stdout, stderr) => {
|
|
3382
3803
|
if (error) {
|
|
3383
3804
|
const msg = stderr?.trim() || stdout?.trim() || error.message;
|
|
3384
3805
|
reject(new Error(msg));
|
|
3385
3806
|
} else
|
|
3386
|
-
|
|
3807
|
+
resolve6({ stdout, stderr });
|
|
3387
3808
|
});
|
|
3388
3809
|
});
|
|
3389
3810
|
}
|
|
3390
3811
|
|
|
3391
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
3812
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/SyncSkills.js
|
|
3392
3813
|
import fsSync from "fs";
|
|
3393
3814
|
import fs2 from "fs/promises";
|
|
3394
3815
|
import os2 from "os";
|
|
3395
3816
|
import path2 from "path";
|
|
3396
3817
|
|
|
3397
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
3818
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/internal/agents.js
|
|
3398
3819
|
import * as fs from "fs";
|
|
3399
3820
|
import * as os from "os";
|
|
3400
3821
|
import * as path from "path";
|
|
@@ -3674,7 +4095,7 @@ function resolveParent(dir) {
|
|
|
3674
4095
|
}
|
|
3675
4096
|
}
|
|
3676
4097
|
|
|
3677
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
4098
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/SyncSkills.js
|
|
3678
4099
|
async function sync(name, commands, options = {}) {
|
|
3679
4100
|
const { depth = 1, description, global = true } = options;
|
|
3680
4101
|
const cwd = options.cwd ?? (global ? resolvePackageRoot() : process.cwd());
|
|
@@ -3835,7 +4256,7 @@ function readHash(name) {
|
|
|
3835
4256
|
return readMeta(name)?.hash;
|
|
3836
4257
|
}
|
|
3837
4258
|
|
|
3838
|
-
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+
|
|
4259
|
+
// ../../node_modules/.pnpm/incur@https+++codeload.github.com+whopio+incur+tar.gz+9e4339e90ed46153268c0183d5f49245598bed57/node_modules/incur/dist/Cli.js
|
|
3839
4260
|
var destructiveCommandHint = "Confirm with the user before executing this destructive command.";
|
|
3840
4261
|
function create(nameOrDefinition, definition) {
|
|
3841
4262
|
const name = typeof nameOrDefinition === "string" ? nameOrDefinition : nameOrDefinition.name;
|
|
@@ -3848,7 +4269,8 @@ function create(nameOrDefinition, definition) {
|
|
|
3848
4269
|
const middlewares = [];
|
|
3849
4270
|
const pending = [];
|
|
3850
4271
|
const mcpHandler = createMcpHttpHandler(name, def.version ?? "0.0.0", {
|
|
3851
|
-
stateless: def.mcp?.stateless
|
|
4272
|
+
stateless: def.mcp?.stateless,
|
|
4273
|
+
tools: def.mcp?.tools
|
|
3852
4274
|
});
|
|
3853
4275
|
if (def.openapi && rootFetch) {
|
|
3854
4276
|
pending.push((async () => {
|
|
@@ -3867,6 +4289,21 @@ function create(nameOrDefinition, definition) {
|
|
|
3867
4289
|
vars: def.vars,
|
|
3868
4290
|
command(nameOrCli, def2) {
|
|
3869
4291
|
if (typeof nameOrCli === "string") {
|
|
4292
|
+
if (isMcpSourceDefinition(def2)) {
|
|
4293
|
+
pending.push((async () => {
|
|
4294
|
+
const resolved = await resolve2(def2.mcp);
|
|
4295
|
+
const generated = generateCommands2(resolved);
|
|
4296
|
+
const entry2 = {
|
|
4297
|
+
_group: true,
|
|
4298
|
+
description: def2.description,
|
|
4299
|
+
commands: generated,
|
|
4300
|
+
...def2.outputPolicy ? { outputPolicy: def2.outputPolicy } : void 0
|
|
4301
|
+
};
|
|
4302
|
+
assertNoGlobalOptionConflicts(nameOrCli, entry2, toGlobals.get(cli2));
|
|
4303
|
+
commands.set(nameOrCli, entry2);
|
|
4304
|
+
})());
|
|
4305
|
+
return cli2;
|
|
4306
|
+
}
|
|
3870
4307
|
if (def2 && "fetch" in def2 && isFetchSource(def2.fetch)) {
|
|
3871
4308
|
const fetch3 = resolveFetch(def2.fetch);
|
|
3872
4309
|
if (def2.openapi) {
|
|
@@ -3882,7 +4319,8 @@ function create(nameOrDefinition, definition) {
|
|
|
3882
4319
|
_group: true,
|
|
3883
4320
|
description: def2.description,
|
|
3884
4321
|
commands: generated,
|
|
3885
|
-
...def2.outputPolicy ? { outputPolicy: def2.outputPolicy } : void 0
|
|
4322
|
+
...def2.outputPolicy ? { outputPolicy: def2.outputPolicy } : void 0,
|
|
4323
|
+
...def2.mcp === false ? { mcp: false } : void 0
|
|
3886
4324
|
};
|
|
3887
4325
|
assertNoGlobalOptionConflicts(nameOrCli, entry2, toGlobals.get(cli2));
|
|
3888
4326
|
commands.set(nameOrCli, entry2);
|
|
@@ -4023,7 +4461,8 @@ function create(nameOrDefinition, definition) {
|
|
|
4023
4461
|
async function serveImpl(name, commands, argv2, options = {}) {
|
|
4024
4462
|
const stdout = options.stdout ?? ((s) => process.stdout.write(s));
|
|
4025
4463
|
const exit = options.exit ?? ((code) => process.exit(code));
|
|
4026
|
-
const
|
|
4464
|
+
const tty = process.stdout.isTTY === true;
|
|
4465
|
+
let human = tty;
|
|
4027
4466
|
const configEnabled = options.config !== void 0;
|
|
4028
4467
|
const configFlag = options.config?.flag;
|
|
4029
4468
|
const displayName = resolveDisplayName(name, options.aliases);
|
|
@@ -4058,6 +4497,7 @@ async function serveImpl(name, commands, argv2, options = {}) {
|
|
|
4058
4497
|
return;
|
|
4059
4498
|
}
|
|
4060
4499
|
const { fullOutput, format: formatFlag, formatExplicit, filterOutput, tokenLimit, tokenOffset, tokenCount, llms, llmsFull, mcp: mcpFlag, help, version, schema, configPath: configPath2, configDisabled, rest } = builtinFlags;
|
|
4500
|
+
human = tty && !formatExplicit;
|
|
4061
4501
|
let globals = {};
|
|
4062
4502
|
let filtered = rest;
|
|
4063
4503
|
function parseGlobalOptions(validate) {
|
|
@@ -4091,7 +4531,8 @@ async function serveImpl(name, commands, argv2, options = {}) {
|
|
|
4091
4531
|
env: options.envSchema,
|
|
4092
4532
|
vars: options.vars,
|
|
4093
4533
|
version: options.version,
|
|
4094
|
-
...options.mcp?.instructions ? { instructions: options.mcp.instructions } : void 0
|
|
4534
|
+
...options.mcp?.instructions ? { instructions: options.mcp.instructions } : void 0,
|
|
4535
|
+
...options.mcp?.tools ? { tools: options.mcp.tools } : void 0
|
|
4095
4536
|
});
|
|
4096
4537
|
return;
|
|
4097
4538
|
}
|
|
@@ -4666,7 +5107,7 @@ async function serveImpl(name, commands, argv2, options = {}) {
|
|
|
4666
5107
|
const cta = output.meta.cta;
|
|
4667
5108
|
if (human && !fullOutput) {
|
|
4668
5109
|
if (output.ok && output.data != null && renderOutput) {
|
|
4669
|
-
const custom =
|
|
5110
|
+
const custom = options.renderer != null ? options.renderer(output.data) : null;
|
|
4670
5111
|
const rendered = custom ?? format2(output.data, format3);
|
|
4671
5112
|
const t = truncate(rendered);
|
|
4672
5113
|
writeln(t.text);
|
|
@@ -4752,8 +5193,8 @@ async function serveImpl(name, commands, argv2, options = {}) {
|
|
|
4752
5193
|
const input = parseArgv(fetchRest);
|
|
4753
5194
|
if (fetchGateway.basePath)
|
|
4754
5195
|
input.path = fetchGateway.basePath + input.path;
|
|
4755
|
-
const
|
|
4756
|
-
const response = await fetchGateway.fetch(
|
|
5196
|
+
const request2 = buildRequest(input);
|
|
5197
|
+
const response = await fetchGateway.fetch(request2);
|
|
4757
5198
|
if (isStreamingResponse(response)) {
|
|
4758
5199
|
const generator = parseStreamingResponse(response);
|
|
4759
5200
|
await handleStreaming(generator, {
|
|
@@ -4972,27 +5413,17 @@ function createMcpHttpHandler(name, version, options = {}) {
|
|
|
4972
5413
|
if (!transport) {
|
|
4973
5414
|
const { fromJsonSchema, McpServer, WebStandardStreamableHTTPServerTransport } = await import("./dist-2MZJLO2W.js");
|
|
4974
5415
|
const server = new McpServer({ name, version });
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
server.
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
const params = hasInput ? callArgs[0] : {};
|
|
4987
|
-
return callTool(tool, params, {
|
|
4988
|
-
name,
|
|
4989
|
-
version,
|
|
4990
|
-
middlewares: mcpOptions?.middlewares,
|
|
4991
|
-
env: mcpOptions?.env,
|
|
4992
|
-
vars: mcpOptions?.vars
|
|
4993
|
-
});
|
|
4994
|
-
});
|
|
4995
|
-
}
|
|
5416
|
+
registerTools(server, commands, {
|
|
5417
|
+
env: mcpOptions?.env,
|
|
5418
|
+
fromJsonSchema,
|
|
5419
|
+
middlewares: mcpOptions?.middlewares,
|
|
5420
|
+
name,
|
|
5421
|
+
request: (extra) => extra?.http?.req,
|
|
5422
|
+
sendNotification: (notification) => server.server.notification(notification),
|
|
5423
|
+
tools: options.tools,
|
|
5424
|
+
vars: mcpOptions?.vars,
|
|
5425
|
+
version
|
|
5426
|
+
});
|
|
4996
5427
|
const transportOptions = stateless ? { enableJsonResponse: true } : {
|
|
4997
5428
|
sessionIdGenerator: () => crypto.randomUUID(),
|
|
4998
5429
|
enableJsonResponse: true
|
|
@@ -5073,15 +5504,15 @@ async function fetchImpl(name, commands, req, options = {}) {
|
|
|
5073
5504
|
}
|
|
5074
5505
|
return new Response("Not Found", { status: 404 });
|
|
5075
5506
|
}
|
|
5076
|
-
let
|
|
5507
|
+
let inputOptions2 = {};
|
|
5077
5508
|
if (req.method === "GET")
|
|
5078
5509
|
for (const [key, value] of url.searchParams)
|
|
5079
|
-
|
|
5510
|
+
inputOptions2[key] = value;
|
|
5080
5511
|
else {
|
|
5081
5512
|
try {
|
|
5082
5513
|
const contentType = req.headers.get("content-type") ?? "";
|
|
5083
5514
|
if (contentType.includes("application/json"))
|
|
5084
|
-
|
|
5515
|
+
inputOptions2 = await req.json();
|
|
5085
5516
|
} catch {
|
|
5086
5517
|
}
|
|
5087
5518
|
}
|
|
@@ -5093,7 +5524,7 @@ async function fetchImpl(name, commands, req, options = {}) {
|
|
|
5093
5524
|
}
|
|
5094
5525
|
if (segments.length === 0) {
|
|
5095
5526
|
if (options.rootCommand)
|
|
5096
|
-
return executeCommand(name, options.rootCommand, [],
|
|
5527
|
+
return executeCommand(name, options.rootCommand, [], inputOptions2, req, start, options);
|
|
5097
5528
|
return jsonResponse({
|
|
5098
5529
|
ok: false,
|
|
5099
5530
|
error: { code: "COMMAND_NOT_FOUND", message: "No root command defined." },
|
|
@@ -5127,12 +5558,12 @@ async function fetchImpl(name, commands, req, options = {}) {
|
|
|
5127
5558
|
return resolved.fetchGateway.fetch(req);
|
|
5128
5559
|
const { command, path: path8, rest } = resolved;
|
|
5129
5560
|
const groupMiddlewares = "middlewares" in resolved ? resolved.middlewares : [];
|
|
5130
|
-
return executeCommand(path8, command, rest,
|
|
5561
|
+
return executeCommand(path8, command, rest, inputOptions2, req, start, {
|
|
5131
5562
|
...options,
|
|
5132
5563
|
groupMiddlewares
|
|
5133
5564
|
});
|
|
5134
5565
|
}
|
|
5135
|
-
async function executeCommand(path8, command, rest,
|
|
5566
|
+
async function executeCommand(path8, command, rest, inputOptions2, request2, start, options) {
|
|
5136
5567
|
function jsonResponse(body, status) {
|
|
5137
5568
|
return new Response(stringify(body), {
|
|
5138
5569
|
status,
|
|
@@ -5145,12 +5576,12 @@ async function executeCommand(path8, command, rest, inputOptions, start, options
|
|
|
5145
5576
|
...command.middleware ?? []
|
|
5146
5577
|
];
|
|
5147
5578
|
let globals = {};
|
|
5148
|
-
let commandInputOptions =
|
|
5579
|
+
let commandInputOptions = inputOptions2;
|
|
5149
5580
|
if (options.globals) {
|
|
5150
5581
|
const globalKeys = new Set(Object.keys(options.globals.schema.shape));
|
|
5151
5582
|
const rawGlobals = {};
|
|
5152
5583
|
commandInputOptions = {};
|
|
5153
|
-
for (const [key, value] of Object.entries(
|
|
5584
|
+
for (const [key, value] of Object.entries(inputOptions2)) {
|
|
5154
5585
|
if (globalKeys.has(key))
|
|
5155
5586
|
rawGlobals[key] = value;
|
|
5156
5587
|
else
|
|
@@ -5180,6 +5611,7 @@ async function executeCommand(path8, command, rest, inputOptions, start, options
|
|
|
5180
5611
|
name: options.name ?? path8,
|
|
5181
5612
|
parseMode: "split",
|
|
5182
5613
|
path: path8,
|
|
5614
|
+
request: request2,
|
|
5183
5615
|
vars: options.vars,
|
|
5184
5616
|
version: options.version
|
|
5185
5617
|
});
|
|
@@ -5637,10 +6069,15 @@ async function runMcpDoctor(name, commands, options) {
|
|
|
5637
6069
|
env: options.envSchema,
|
|
5638
6070
|
vars: options.vars,
|
|
5639
6071
|
version: options.version,
|
|
5640
|
-
...options.mcp?.instructions ? { instructions: options.mcp.instructions } : void 0
|
|
6072
|
+
...options.mcp?.instructions ? { instructions: options.mcp.instructions } : void 0,
|
|
6073
|
+
tools: { ...options.mcp?.tools, discovery: "direct" }
|
|
5641
6074
|
}).catch((error) => {
|
|
5642
6075
|
serveError = error;
|
|
5643
6076
|
});
|
|
6077
|
+
let serveFinished = false;
|
|
6078
|
+
void done.finally(() => {
|
|
6079
|
+
serveFinished = true;
|
|
6080
|
+
});
|
|
5644
6081
|
input.write(`${stringify({
|
|
5645
6082
|
jsonrpc: "2.0",
|
|
5646
6083
|
id: 1,
|
|
@@ -5654,7 +6091,7 @@ async function runMcpDoctor(name, commands, options) {
|
|
|
5654
6091
|
`);
|
|
5655
6092
|
input.write(`${stringify({ jsonrpc: "2.0", id: 2, method: "tools/list", params: {} })}
|
|
5656
6093
|
`);
|
|
5657
|
-
await
|
|
6094
|
+
await waitForMcpDoctorResponses(chunks, () => serveFinished);
|
|
5658
6095
|
input.end();
|
|
5659
6096
|
await done;
|
|
5660
6097
|
if (serveError)
|
|
@@ -5708,6 +6145,14 @@ async function runMcpDoctor(name, commands, options) {
|
|
|
5708
6145
|
errors
|
|
5709
6146
|
};
|
|
5710
6147
|
}
|
|
6148
|
+
async function waitForMcpDoctorResponses(chunks, finished) {
|
|
6149
|
+
const started = Date.now();
|
|
6150
|
+
while (!finished() && (chunks.join("").match(/\n/g)?.length ?? 0) < 2) {
|
|
6151
|
+
if (Date.now() - started >= 1e3)
|
|
6152
|
+
return;
|
|
6153
|
+
await new Promise((resolve6) => setTimeout(resolve6, 5));
|
|
6154
|
+
}
|
|
6155
|
+
}
|
|
5711
6156
|
function parseMcpDoctorResponses(chunks) {
|
|
5712
6157
|
const responses2 = [];
|
|
5713
6158
|
for (const line of chunks.join("").split(/\r?\n/)) {
|
|
@@ -5756,6 +6201,14 @@ function isFetchSource(value) {
|
|
|
5756
6201
|
const source = value;
|
|
5757
6202
|
return typeof source.fetch === "function" && source.url instanceof URL;
|
|
5758
6203
|
}
|
|
6204
|
+
function isMcpSourceDefinition(value) {
|
|
6205
|
+
if (typeof value !== "object" || value === null || !("mcp" in value))
|
|
6206
|
+
return false;
|
|
6207
|
+
const source = value.mcp;
|
|
6208
|
+
if (typeof source === "string" || source instanceof URL)
|
|
6209
|
+
return true;
|
|
6210
|
+
return typeof source === "object" && source !== null && "url" in source;
|
|
6211
|
+
}
|
|
5759
6212
|
function resolveFetch(source) {
|
|
5760
6213
|
if (typeof source === "function")
|
|
5761
6214
|
return source;
|
|
@@ -6046,8 +6499,8 @@ function collectCommands(commands, prefix) {
|
|
|
6046
6499
|
if (entry.description)
|
|
6047
6500
|
cmd.description = entry.description;
|
|
6048
6501
|
const inputSchema = buildInputSchema(entry.args, entry.env, entry.options);
|
|
6049
|
-
const
|
|
6050
|
-
if (inputSchema ||
|
|
6502
|
+
const outputSchema2 = entry.output ? toJsonSchema(entry.output) : void 0;
|
|
6503
|
+
if (inputSchema || outputSchema2) {
|
|
6051
6504
|
cmd.schema = {};
|
|
6052
6505
|
if (inputSchema?.args)
|
|
6053
6506
|
cmd.schema.args = inputSchema.args;
|
|
@@ -6055,8 +6508,8 @@ function collectCommands(commands, prefix) {
|
|
|
6055
6508
|
cmd.schema.env = inputSchema.env;
|
|
6056
6509
|
if (inputSchema?.options)
|
|
6057
6510
|
cmd.schema.options = inputSchema.options;
|
|
6058
|
-
if (
|
|
6059
|
-
cmd.schema.output =
|
|
6511
|
+
if (outputSchema2)
|
|
6512
|
+
cmd.schema.output = outputSchema2;
|
|
6060
6513
|
}
|
|
6061
6514
|
const examples = formatExamples(entry.examples);
|
|
6062
6515
|
if (examples) {
|
|
@@ -6138,7 +6591,7 @@ function collectSkillCommands(commands, prefix, groups, rootCommand) {
|
|
|
6138
6591
|
return result.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
6139
6592
|
}
|
|
6140
6593
|
function isDestructive(command) {
|
|
6141
|
-
return command.destructive === true || command.mcp?.annotations?.destructiveHint === true;
|
|
6594
|
+
return command.destructive === true || command.mcp !== false && command.mcp?.annotations?.destructiveHint === true;
|
|
6142
6595
|
}
|
|
6143
6596
|
function appendDestructiveHint(hint) {
|
|
6144
6597
|
if (!hint)
|
|
@@ -7005,6 +7458,66 @@ var native_spec_default = {
|
|
|
7005
7458
|
"null"
|
|
7006
7459
|
]
|
|
7007
7460
|
},
|
|
7461
|
+
tax_collection_enabled_states: {
|
|
7462
|
+
description: "US state codes (50 states plus `DC`) where the account collects tax. Replaces the full set on update. Only settable when `tax_remitted_by` is `self`.",
|
|
7463
|
+
items: {
|
|
7464
|
+
enum: [
|
|
7465
|
+
"AL",
|
|
7466
|
+
"AK",
|
|
7467
|
+
"AZ",
|
|
7468
|
+
"AR",
|
|
7469
|
+
"CA",
|
|
7470
|
+
"CO",
|
|
7471
|
+
"CT",
|
|
7472
|
+
"DE",
|
|
7473
|
+
"DC",
|
|
7474
|
+
"FL",
|
|
7475
|
+
"GA",
|
|
7476
|
+
"HI",
|
|
7477
|
+
"ID",
|
|
7478
|
+
"IL",
|
|
7479
|
+
"IN",
|
|
7480
|
+
"IA",
|
|
7481
|
+
"KS",
|
|
7482
|
+
"KY",
|
|
7483
|
+
"LA",
|
|
7484
|
+
"ME",
|
|
7485
|
+
"MD",
|
|
7486
|
+
"MA",
|
|
7487
|
+
"MI",
|
|
7488
|
+
"MN",
|
|
7489
|
+
"MS",
|
|
7490
|
+
"MO",
|
|
7491
|
+
"MT",
|
|
7492
|
+
"NE",
|
|
7493
|
+
"NV",
|
|
7494
|
+
"NH",
|
|
7495
|
+
"NJ",
|
|
7496
|
+
"NM",
|
|
7497
|
+
"NY",
|
|
7498
|
+
"NC",
|
|
7499
|
+
"ND",
|
|
7500
|
+
"OH",
|
|
7501
|
+
"OK",
|
|
7502
|
+
"OR",
|
|
7503
|
+
"PA",
|
|
7504
|
+
"RI",
|
|
7505
|
+
"SC",
|
|
7506
|
+
"SD",
|
|
7507
|
+
"TN",
|
|
7508
|
+
"TX",
|
|
7509
|
+
"UT",
|
|
7510
|
+
"VT",
|
|
7511
|
+
"VA",
|
|
7512
|
+
"WA",
|
|
7513
|
+
"WV",
|
|
7514
|
+
"WI",
|
|
7515
|
+
"WY"
|
|
7516
|
+
],
|
|
7517
|
+
type: "string"
|
|
7518
|
+
},
|
|
7519
|
+
type: "array"
|
|
7520
|
+
},
|
|
7008
7521
|
tax_identifiers: {
|
|
7009
7522
|
description: "Account tax/VAT registrations to add or update. When `tax_remitted_by` is `self`, tax is calculated and collected only in the countries where the account holds a registration.",
|
|
7010
7523
|
items: {
|
|
@@ -16891,6 +17404,15 @@ var native_spec_default = {
|
|
|
16891
17404
|
"null"
|
|
16892
17405
|
]
|
|
16893
17406
|
},
|
|
17407
|
+
income_source: {
|
|
17408
|
+
description: "Which income source the commission is on: product-sales gross profit or Whop Ads spend billed to the business.",
|
|
17409
|
+
enum: [
|
|
17410
|
+
"sales",
|
|
17411
|
+
"ad_spend"
|
|
17412
|
+
],
|
|
17413
|
+
example: "sales",
|
|
17414
|
+
type: "string"
|
|
17415
|
+
},
|
|
16894
17416
|
object: {
|
|
16895
17417
|
enum: [
|
|
16896
17418
|
"partner_business_earning"
|
|
@@ -17050,6 +17572,7 @@ var native_spec_default = {
|
|
|
17050
17572
|
"product",
|
|
17051
17573
|
"status",
|
|
17052
17574
|
"second_tier",
|
|
17575
|
+
"income_source",
|
|
17053
17576
|
"transaction_amount_usd",
|
|
17054
17577
|
"payout_percentage",
|
|
17055
17578
|
"commission_amount_usd",
|
|
@@ -26103,6 +26626,13 @@ var native_spec_default = {
|
|
|
26103
26626
|
"null"
|
|
26104
26627
|
]
|
|
26105
26628
|
},
|
|
26629
|
+
tax_collection_enabled_states: {
|
|
26630
|
+
items: {
|
|
26631
|
+
description: "US state codes (of the 50 states plus `DC`) where the account collects tax: the full set when Whop remits (`tax_remitted_by` `whop`), the configured subset when the account self-remits (`self`), and empty when neither. On update, send the complete list to replace it (only allowed when `self`).",
|
|
26632
|
+
type: "string"
|
|
26633
|
+
},
|
|
26634
|
+
type: "array"
|
|
26635
|
+
},
|
|
26106
26636
|
tax_identifiers: {
|
|
26107
26637
|
description: "Account tax/VAT registrations, each with `id`, `tax_id_type`, and `tax_id_value`. Empty when none are set.",
|
|
26108
26638
|
type: "array"
|
|
@@ -26191,6 +26721,7 @@ var native_spec_default = {
|
|
|
26191
26721
|
"product_tax_code",
|
|
26192
26722
|
"business_address",
|
|
26193
26723
|
"tax_identifiers",
|
|
26724
|
+
"tax_collection_enabled_states",
|
|
26194
26725
|
"total_usd",
|
|
26195
26726
|
"balances",
|
|
26196
26727
|
"verification",
|
|
@@ -36268,7 +36799,7 @@ import { createRequire as createRequire2 } from "module";
|
|
|
36268
36799
|
// src/lib/build-info.ts
|
|
36269
36800
|
var buildChannel = true ? "npm" : "dev";
|
|
36270
36801
|
var buildTarget = typeof WHOP_CLI_TARGET === "string" ? WHOP_CLI_TARGET : null;
|
|
36271
|
-
var buildVersion = true ? "0.
|
|
36802
|
+
var buildVersion = true ? "0.9.0" : null;
|
|
36272
36803
|
function isHomebrewPath(execPath, env = process.env) {
|
|
36273
36804
|
if (/[/\\](Cellar|homebrew|linuxbrew)[/\\]/.test(execPath)) return true;
|
|
36274
36805
|
const prefix = env.HOMEBREW_PREFIX?.trim();
|
|
@@ -37257,7 +37788,7 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
37257
37788
|
]);
|
|
37258
37789
|
var API_VERSION_HEADER = "Api-Version-Date";
|
|
37259
37790
|
var API_VERSION_DATE = native_spec_default.info["x-api-version-date"];
|
|
37260
|
-
var HIDDEN_PARAMS = /* @__PURE__ */ new Set(["
|
|
37791
|
+
var HIDDEN_PARAMS = /* @__PURE__ */ new Set(["api-version-date"]);
|
|
37261
37792
|
var AUTO_FILLED_PARAMS = /* @__PURE__ */ new Set(["company_id", "account_id"]);
|
|
37262
37793
|
function hiddenParamRefs(spec2) {
|
|
37263
37794
|
const refs = /* @__PURE__ */ new Set();
|
|
@@ -37281,9 +37812,8 @@ function isHiddenParam(p, hiddenRefs) {
|
|
|
37281
37812
|
return typeof rec.name === "string" && HIDDEN_PARAMS.has(rec.name.toLowerCase());
|
|
37282
37813
|
}
|
|
37283
37814
|
function transformParams(op, hiddenRefs) {
|
|
37284
|
-
const
|
|
37285
|
-
|
|
37286
|
-
if (!Array.isArray(params)) return rest;
|
|
37815
|
+
const params = op.parameters;
|
|
37816
|
+
if (!Array.isArray(params)) return op;
|
|
37287
37817
|
const relaxed = params.filter((p) => !isHiddenParam(p, hiddenRefs)).map((p) => {
|
|
37288
37818
|
if (p != null && typeof p === "object" && AUTO_FILLED_PARAMS.has(
|
|
37289
37819
|
String(p.name ?? "")
|
|
@@ -37292,7 +37822,7 @@ function transformParams(op, hiddenRefs) {
|
|
|
37292
37822
|
}
|
|
37293
37823
|
return p;
|
|
37294
37824
|
});
|
|
37295
|
-
return { ...
|
|
37825
|
+
return { ...op, parameters: relaxed };
|
|
37296
37826
|
}
|
|
37297
37827
|
function filterSpecByTag(spec2, tag) {
|
|
37298
37828
|
const hiddenRefs = hiddenParamRefs(spec2);
|
|
@@ -37383,7 +37913,7 @@ async function resolveActiveAccountId() {
|
|
|
37383
37913
|
return resolveAccountId(profile, normalizeApiKey(rawKey));
|
|
37384
37914
|
}
|
|
37385
37915
|
function createWhopFetch() {
|
|
37386
|
-
return async (
|
|
37916
|
+
return async (request2) => {
|
|
37387
37917
|
const profile = getActiveProfile();
|
|
37388
37918
|
const rawKey = profile ? await getValidAccessToken(profile) : process.env.WHOP_API_KEY ?? null;
|
|
37389
37919
|
if (!rawKey) {
|
|
@@ -37391,11 +37921,11 @@ function createWhopFetch() {
|
|
|
37391
37921
|
return Response.json({ message: message2 }, { status: 401 });
|
|
37392
37922
|
}
|
|
37393
37923
|
const token = normalizeApiKey(rawKey);
|
|
37394
|
-
const incomingUrl = new URL(
|
|
37395
|
-
const op = findOperation(
|
|
37924
|
+
const incomingUrl = new URL(request2.url);
|
|
37925
|
+
const op = findOperation(request2.method, incomingUrl.pathname);
|
|
37396
37926
|
const accountId = await resolveAccountId(profile, token);
|
|
37397
|
-
const method =
|
|
37398
|
-
let body =
|
|
37927
|
+
const method = request2.method.toUpperCase();
|
|
37928
|
+
let body = request2.body ? await request2.text() : void 0;
|
|
37399
37929
|
if (op && accountId) {
|
|
37400
37930
|
if (method === "GET" || method === "DELETE" || method === "HEAD") {
|
|
37401
37931
|
for (const name of ACCOUNT_FIELDS) {
|
|
@@ -37436,13 +37966,13 @@ function createWhopFetch() {
|
|
|
37436
37966
|
}
|
|
37437
37967
|
const base = apiBaseUrl().replace(/\/$/, "");
|
|
37438
37968
|
const target = `${base}${incomingUrl.pathname}${incomingUrl.search}`;
|
|
37439
|
-
const headers = new Headers(
|
|
37969
|
+
const headers = new Headers(request2.headers);
|
|
37440
37970
|
headers.set("Authorization", `Bearer ${token}`);
|
|
37441
37971
|
headers.set("Content-Type", "application/json");
|
|
37442
37972
|
if (!headers.has(API_VERSION_HEADER)) {
|
|
37443
37973
|
headers.set(API_VERSION_HEADER, API_VERSION_DATE);
|
|
37444
37974
|
}
|
|
37445
|
-
const res = await fetch(target, { method:
|
|
37975
|
+
const res = await fetch(target, { method: request2.method, headers, body });
|
|
37446
37976
|
if (res.ok) {
|
|
37447
37977
|
if (method === "POST" || method === "PATCH") {
|
|
37448
37978
|
const text5 = await res.text();
|
|
@@ -37669,7 +38199,7 @@ import { isCancel as isCancel3, select as select2, spinner as spinner2, text as
|
|
|
37669
38199
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
37670
38200
|
import { createHash as createHash3 } from "crypto";
|
|
37671
38201
|
import { existsSync as existsSync5, readFileSync as readFileSync5, readdirSync as readdirSync2 } from "fs";
|
|
37672
|
-
import { join as join6, relative as relative2, resolve as
|
|
38202
|
+
import { join as join6, relative as relative2, resolve as resolve5 } from "path";
|
|
37673
38203
|
import chalk from "chalk";
|
|
37674
38204
|
|
|
37675
38205
|
// src/journey/client.ts
|
|
@@ -37808,18 +38338,18 @@ async function waitForBuildPromotion(buildId, timeoutMs = 3e4) {
|
|
|
37808
38338
|
return latest;
|
|
37809
38339
|
}
|
|
37810
38340
|
function sleep(ms) {
|
|
37811
|
-
return new Promise((
|
|
38341
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
37812
38342
|
}
|
|
37813
38343
|
|
|
37814
38344
|
// src/apps/config.ts
|
|
37815
38345
|
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
37816
|
-
import { join as join4, resolve as
|
|
38346
|
+
import { join as join4, resolve as resolve4 } from "path";
|
|
37817
38347
|
var APP_CONFIG_FILENAME = "whop.app.json";
|
|
37818
38348
|
function findProjectDir(startDir) {
|
|
37819
|
-
let dir =
|
|
38349
|
+
let dir = resolve4(startDir ?? process.cwd());
|
|
37820
38350
|
for (let i = 0; i < 25; i++) {
|
|
37821
38351
|
if (existsSync3(join4(dir, APP_CONFIG_FILENAME))) return dir;
|
|
37822
|
-
const parent =
|
|
38352
|
+
const parent = resolve4(dir, "..");
|
|
37823
38353
|
if (parent === dir) break;
|
|
37824
38354
|
dir = parent;
|
|
37825
38355
|
}
|
|
@@ -38191,7 +38721,8 @@ async function registerSpecCommands(group, tag) {
|
|
|
38191
38721
|
const spec2 = filterSpecByTag(apps_spec_default, tag);
|
|
38192
38722
|
const generated = await Openapi_exports.generateCommands(
|
|
38193
38723
|
spec2,
|
|
38194
|
-
createWhopFetch()
|
|
38724
|
+
createWhopFetch(),
|
|
38725
|
+
{ config: { security: false } }
|
|
38195
38726
|
);
|
|
38196
38727
|
for (const [name, entry] of generated) {
|
|
38197
38728
|
if ("run" in entry) group.command(name, entry);
|
|
@@ -38210,7 +38741,7 @@ function ensurePackageManager() {
|
|
|
38210
38741
|
});
|
|
38211
38742
|
}
|
|
38212
38743
|
async function ensureViteApp(c2, pm, dirOption) {
|
|
38213
|
-
const projectDir = dirOption ?
|
|
38744
|
+
const projectDir = dirOption ? resolve5(dirOption) : findProjectDir() ?? process.cwd();
|
|
38214
38745
|
const isViteApp = existsSync5(join6(projectDir, "package.json")) && findViteConfig(projectDir) !== void 0;
|
|
38215
38746
|
if (isViteApp) return { projectDir, freshlyScaffolded: false };
|
|
38216
38747
|
if (c2.agent) {
|
|
@@ -38271,7 +38802,7 @@ async function scaffoldNewApp(c2, pm) {
|
|
|
38271
38802
|
retryable: true
|
|
38272
38803
|
});
|
|
38273
38804
|
}
|
|
38274
|
-
const targetDir =
|
|
38805
|
+
const targetDir = resolve5(`./${route}`);
|
|
38275
38806
|
if (existsSync5(targetDir) && readdirSync2(targetDir).length > 0) {
|
|
38276
38807
|
throw new DeployAbort({
|
|
38277
38808
|
code: "TARGET_NOT_EMPTY",
|
|
@@ -38500,9 +39031,9 @@ var LOG_LEVEL_COLORS = {
|
|
|
38500
39031
|
function printLogLine(row) {
|
|
38501
39032
|
const time = row.created_at.replace("T", " ").replace("Z", "");
|
|
38502
39033
|
const color = LOG_LEVEL_COLORS[row.level] ?? chalk.dim;
|
|
38503
|
-
const
|
|
39034
|
+
const request2 = row.request_method ? chalk.dim(` ${row.request_method} ${row.request_path ?? ""}`) : "";
|
|
38504
39035
|
console.log(
|
|
38505
|
-
`${chalk.dim(time)} ${color(row.level.padEnd(5))}${
|
|
39036
|
+
`${chalk.dim(time)} ${color(row.level.padEnd(5))}${request2} ${row.message}`
|
|
38506
39037
|
);
|
|
38507
39038
|
if (row.stack) console.log(chalk.dim(row.stack));
|
|
38508
39039
|
}
|
|
@@ -38634,7 +39165,7 @@ async function buildAppGroup() {
|
|
|
38634
39165
|
dir: external_exports.string().optional().describe("Project directory (defaults to the current directory)")
|
|
38635
39166
|
}),
|
|
38636
39167
|
run: async (c2) => {
|
|
38637
|
-
const projectDir = c2.options.dir ?
|
|
39168
|
+
const projectDir = c2.options.dir ? resolve5(c2.options.dir) : findProjectDir();
|
|
38638
39169
|
const config = projectDir ? readAppConfig(projectDir) : null;
|
|
38639
39170
|
if (!projectDir || !config) {
|
|
38640
39171
|
return c2.error({
|
|
@@ -39664,7 +40195,8 @@ async function buildMediaGroup(description) {
|
|
|
39664
40195
|
const spec2 = filterSpecByTag(native_spec_default, "Media");
|
|
39665
40196
|
const generated = await Openapi_exports.generateCommands(
|
|
39666
40197
|
spec2,
|
|
39667
|
-
whopFetch2
|
|
40198
|
+
whopFetch2,
|
|
40199
|
+
{ config: { security: false } }
|
|
39668
40200
|
);
|
|
39669
40201
|
const getEntry = generated.get("get");
|
|
39670
40202
|
for (const [name, entry] of generated) {
|
|
@@ -39801,13 +40333,13 @@ async function fetchAsset(c2, getEntry, id, progress) {
|
|
|
39801
40333
|
}
|
|
39802
40334
|
}
|
|
39803
40335
|
function sleep2(ms) {
|
|
39804
|
-
return new Promise((
|
|
40336
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
39805
40337
|
}
|
|
39806
40338
|
|
|
39807
40339
|
// package.json
|
|
39808
40340
|
var package_default = {
|
|
39809
40341
|
name: "@whop/cli",
|
|
39810
|
-
version: "0.
|
|
40342
|
+
version: "0.9.0",
|
|
39811
40343
|
description: "The Whop CLI \u2014 build and manage Whop apps from your terminal. Human and agent friendly.",
|
|
39812
40344
|
keywords: [
|
|
39813
40345
|
"agent",
|
|
@@ -39866,7 +40398,7 @@ var package_default = {
|
|
|
39866
40398
|
devDependencies: {
|
|
39867
40399
|
"@types/node": "25.3.5",
|
|
39868
40400
|
fflate: "0.8.2",
|
|
39869
|
-
incur: "github:whopio/incur#
|
|
40401
|
+
incur: "github:whopio/incur#9e4339e90ed46153268c0183d5f49245598bed57",
|
|
39870
40402
|
tsup: "8.5.0",
|
|
39871
40403
|
tsx: "4.19.4",
|
|
39872
40404
|
typescript: "5.9.3",
|
|
@@ -40973,7 +41505,12 @@ for (const { name, tag, description } of API_GROUPS) {
|
|
|
40973
41505
|
cli.command(await buildMediaGroup(description));
|
|
40974
41506
|
continue;
|
|
40975
41507
|
}
|
|
40976
|
-
cli.command(name, {
|
|
41508
|
+
cli.command(name, {
|
|
41509
|
+
description,
|
|
41510
|
+
fetch: fetch2,
|
|
41511
|
+
openapi: spec(tag),
|
|
41512
|
+
openapiConfig: { security: false }
|
|
41513
|
+
});
|
|
40977
41514
|
}
|
|
40978
41515
|
var cli_default = cli;
|
|
40979
41516
|
|