@wirecat/slack-cli 0.0.0-stage → 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.
- package/CHANGELOG.md +121 -0
- package/LICENSE +204 -0
- package/README.md +131 -2
- package/contracts/wirecat.json +5526 -0
- package/dist/bin/slack.d.ts +3 -0
- package/dist/bin/slack.d.ts.map +1 -0
- package/dist/bin/slack.js +40 -0
- package/dist/bin/slack.js.map +1 -0
- package/dist/bundle/agent-GOFXFUQP.js +37 -0
- package/dist/bundle/all-profiles-4C7VOT2D.js +320 -0
- package/dist/bundle/anthropic-ZD66TC5S.js +91 -0
- package/dist/bundle/app-server-QNCVEDMY.js +249 -0
- package/dist/bundle/bun-2FULBYXS.js +169 -0
- package/dist/bundle/bun-sqlite-PMS26ZUT.js +76 -0
- package/dist/bundle/chunk-2LB5BWC4.js +362 -0
- package/dist/bundle/chunk-2ZEYRHZV.js +18 -0
- package/dist/bundle/chunk-3IJ3THPV.js +7 -0
- package/dist/bundle/chunk-3IZF5ENR.js +61 -0
- package/dist/bundle/chunk-4HSVEQ3R.js +29 -0
- package/dist/bundle/chunk-4QPMHVM5.js +1007 -0
- package/dist/bundle/chunk-53LIHHXC.js +16 -0
- package/dist/bundle/chunk-5F36CXDM.js +794 -0
- package/dist/bundle/chunk-5LPREGD3.js +12636 -0
- package/dist/bundle/chunk-5R5YRYIP.js +1148 -0
- package/dist/bundle/chunk-5RSQTG7L.js +388 -0
- package/dist/bundle/chunk-5SXZETJF.js +170 -0
- package/dist/bundle/chunk-6PDQP5RM.js +50 -0
- package/dist/bundle/chunk-75BLNPN3.js +1197 -0
- package/dist/bundle/chunk-7BEO72EN.js +131 -0
- package/dist/bundle/chunk-7F6RNAIM.js +230 -0
- package/dist/bundle/chunk-AG7FP64Z.js +77 -0
- package/dist/bundle/chunk-BRXTN5LJ.js +338 -0
- package/dist/bundle/chunk-CABZAU37.js +319 -0
- package/dist/bundle/chunk-CCOSG3F2.js +24616 -0
- package/dist/bundle/chunk-CDTZSFTN.js +58 -0
- package/dist/bundle/chunk-CMZBCWND.js +1246 -0
- package/dist/bundle/chunk-CRQEEJNF.js +185 -0
- package/dist/bundle/chunk-CWYU4R65.js +358 -0
- package/dist/bundle/chunk-CZFR6JQX.js +52 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DVHX7R54.js +4072 -0
- package/dist/bundle/chunk-DYKOG7QR.js +9596 -0
- package/dist/bundle/chunk-ECDI42G6.js +100 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-ELY2TLCY.js +259 -0
- package/dist/bundle/chunk-ERRVUVKR.js +156 -0
- package/dist/bundle/chunk-FBWR4E5D.js +353 -0
- package/dist/bundle/chunk-GKS6KL57.js +6848 -0
- package/dist/bundle/chunk-H2COZZ55.js +2787 -0
- package/dist/bundle/chunk-HGXTEK7R.js +82 -0
- package/dist/bundle/chunk-HXLXM7HV.js +726 -0
- package/dist/bundle/chunk-IPP4N6HD.js +24 -0
- package/dist/bundle/chunk-IWTVR7S7.js +53 -0
- package/dist/bundle/chunk-IYJH75D4.js +63 -0
- package/dist/bundle/chunk-JCZLRT4Z.js +39 -0
- package/dist/bundle/chunk-JGRWMR5H.js +123 -0
- package/dist/bundle/chunk-JYRYQJBN.js +633 -0
- package/dist/bundle/chunk-KIKLDI74.js +161 -0
- package/dist/bundle/chunk-L4WO3XH6.js +2020 -0
- package/dist/bundle/chunk-LQDNUAK3.js +274 -0
- package/dist/bundle/chunk-LV5ONLQH.js +38 -0
- package/dist/bundle/chunk-M27Z23OZ.js +23 -0
- package/dist/bundle/chunk-M5XTZHXM.js +142 -0
- package/dist/bundle/chunk-MJBEGUIZ.js +76 -0
- package/dist/bundle/chunk-N4WOLGIV.js +2333 -0
- package/dist/bundle/chunk-N5K4OHPT.js +206 -0
- package/dist/bundle/chunk-NYAPUET7.js +108 -0
- package/dist/bundle/chunk-P4IFLOIK.js +218 -0
- package/dist/bundle/chunk-P6G2QTCD.js +288 -0
- package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
- package/dist/bundle/chunk-PU7R6XNV.js +80 -0
- package/dist/bundle/chunk-QLLBACDR.js +72 -0
- package/dist/bundle/chunk-QP7XN5KX.js +407 -0
- package/dist/bundle/chunk-QY2F6A3D.js +557 -0
- package/dist/bundle/chunk-RLIT7VAZ.js +66 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-SKGAKI62.js +86 -0
- package/dist/bundle/chunk-SQMZP5MA.js +66653 -0
- package/dist/bundle/chunk-UB6NTICY.js +95 -0
- package/dist/bundle/chunk-UBHQO5HV.js +778 -0
- package/dist/bundle/chunk-UM4RKO24.js +106 -0
- package/dist/bundle/chunk-VAHFY732.js +1068 -0
- package/dist/bundle/chunk-VGDM4C3F.js +188 -0
- package/dist/bundle/chunk-VOUAKCPM.js +41181 -0
- package/dist/bundle/chunk-WCCFJ4Q6.js +3736 -0
- package/dist/bundle/chunk-WV6EXRDV.js +46 -0
- package/dist/bundle/chunk-WVAT5TGY.js +334 -0
- package/dist/bundle/chunk-WW76JMKE.js +1243 -0
- package/dist/bundle/chunk-XXOMUKC6.js +54 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YDO6RJ2P.js +1337 -0
- package/dist/bundle/chunk-ZBCFZCJW.js +388 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-BWGRUY6L.js +37 -0
- package/dist/bundle/command-server-entry-BATOWE3Y.js +166 -0
- package/dist/bundle/decode-MZQGYXJH.js +297 -0
- package/dist/bundle/definitions-3EONB23J.js +8600 -0
- package/dist/bundle/dispatch-NYC4ARWX.js +411 -0
- package/dist/bundle/dist-AMLBQVKM.js +7577 -0
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/echarts-7OYGL2GW.js +42501 -0
- package/dist/bundle/embed-4I25DVKZ.js +38 -0
- package/dist/bundle/embedder-YXKQHAZO.js +111 -0
- package/dist/bundle/emoji-4LYX3GOS.js +4271 -0
- package/dist/bundle/failure-3YOVYZTX.js +25 -0
- package/dist/bundle/first-run-2VL2BOV7.js +29 -0
- package/dist/bundle/first-screen-C7FIWZL2.js +37 -0
- package/dist/bundle/instructions-UMNDHXG2.js +11 -0
- package/dist/bundle/mcp-V27RHILF.js +167 -0
- package/dist/bundle/meeting-combined-LS6XO4JH.js +24 -0
- package/dist/bundle/meeting-model-VIR465CY.js +25 -0
- package/dist/bundle/meeting-semantic-H5J3OOF2.js +22 -0
- package/dist/bundle/node-JJ3WDCNJ.js +2340 -0
- package/dist/bundle/node-PYFPGL4E.js +176 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-LFWPGDVP.js +74 -0
- package/dist/bundle/oauth-42VCSIVL.js +20 -0
- package/dist/bundle/open-XJ5R5LHC.js +23 -0
- package/dist/bundle/openai-RZBLV4HG.js +238 -0
- package/dist/bundle/process-DD6H3K7L.js +91 -0
- package/dist/bundle/program-OIYIBNSA.js +35443 -0
- package/dist/bundle/prompt-NQRDM5LY.js +17 -0
- package/dist/bundle/recognize-EM7H2IZS.js +26 -0
- package/dist/bundle/remote-Z6NU6QQA.js +31 -0
- package/dist/bundle/rerank-PNPCSPNF.js +52 -0
- package/dist/bundle/schemas-JMKNP4U3.js +2765 -0
- package/dist/bundle/serve-SQVGX76J.js +199 -0
- package/dist/bundle/server-NPJH45FZ.js +212 -0
- package/dist/bundle/server-Z4ZMGRAH.js +79 -0
- package/dist/bundle/slack.js +184 -0
- package/dist/bundle/sqlite-runtime-F3AJGAPN.js +20 -0
- package/dist/bundle/state-JT7ZFSXN.js +36 -0
- package/dist/bundle/store-FXGMHRF3.js +181 -0
- package/dist/bundle/store-J5ZL2USR.js +295 -0
- package/dist/bundle/store-maintenance-command-TIHOIKLZ.js +66 -0
- package/dist/bundle/surface-NW6T5OR6.js +65 -0
- package/dist/commands/api.d.ts +7 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +49 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/session.d.ts +7 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +26 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +75 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +59 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +75 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +8596 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/emoji.d.ts +2 -0
- package/dist/generated/emoji.d.ts.map +1 -0
- package/dist/generated/emoji.js +4265 -0
- package/dist/generated/emoji.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +6139 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +631 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +2426 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +3220 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +29 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +32 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/messenger.d.ts +12 -0
- package/dist/messenger.d.ts.map +1 -0
- package/dist/messenger.js +184 -0
- package/dist/messenger.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +116 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +7 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +20 -0
- package/dist/reasons.js.map +1 -0
- package/dist/setup/flow.d.ts +2 -0
- package/dist/setup/flow.d.ts.map +1 -0
- package/dist/setup/flow.js +83 -0
- package/dist/setup/flow.js.map +1 -0
- package/dist/setup/guide.d.ts +6 -0
- package/dist/setup/guide.d.ts.map +1 -0
- package/dist/setup/guide.js +13 -0
- package/dist/setup/guide.js.map +1 -0
- package/dist/setup/texts.d.ts +24 -0
- package/dist/setup/texts.d.ts.map +1 -0
- package/dist/setup/texts.js +24 -0
- package/dist/setup/texts.js.map +1 -0
- package/dist/slack/adapter.d.ts +36 -0
- package/dist/slack/adapter.d.ts.map +1 -0
- package/dist/slack/adapter.js +574 -0
- package/dist/slack/adapter.js.map +1 -0
- package/dist/slack/app-manifest.d.ts +25 -0
- package/dist/slack/app-manifest.d.ts.map +1 -0
- package/dist/slack/app-manifest.js +51 -0
- package/dist/slack/app-manifest.js.map +1 -0
- package/dist/slack/client.d.ts +45 -0
- package/dist/slack/client.d.ts.map +1 -0
- package/dist/slack/client.js +236 -0
- package/dist/slack/client.js.map +1 -0
- package/dist/slack/map.d.ts +437 -0
- package/dist/slack/map.d.ts.map +1 -0
- package/dist/slack/map.js +411 -0
- package/dist/slack/map.js.map +1 -0
- package/dist/slack/mrkdwn.d.ts +9 -0
- package/dist/slack/mrkdwn.d.ts.map +1 -0
- package/dist/slack/mrkdwn.js +56 -0
- package/dist/slack/mrkdwn.js.map +1 -0
- package/dist/slack/search.d.ts +24 -0
- package/dist/slack/search.d.ts.map +1 -0
- package/dist/slack/search.js +99 -0
- package/dist/slack/search.js.map +1 -0
- package/dist/slack/threads.d.ts +28 -0
- package/dist/slack/threads.d.ts.map +1 -0
- package/dist/slack/threads.js +56 -0
- package/dist/slack/threads.js.map +1 -0
- package/dist/slack/tokens.d.ts +17 -0
- package/dist/slack/tokens.d.ts.map +1 -0
- package/dist/slack/tokens.js +27 -0
- package/dist/slack/tokens.js.map +1 -0
- package/dist/slack/writes.d.ts +43 -0
- package/dist/slack/writes.d.ts.map +1 -0
- package/dist/slack/writes.js +277 -0
- package/dist/slack/writes.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +89 -4
- package/skills/slack-cli/SKILL.md +117 -0
- package/skills/slack-cli/references/api/api-admin.md +541 -0
- package/skills/slack-cli/references/api/api-api.md +13 -0
- package/skills/slack-cli/references/api/api-apps.md +78 -0
- package/skills/slack-cli/references/api/api-auth.md +18 -0
- package/skills/slack-cli/references/api/api-bots.md +12 -0
- package/skills/slack-cli/references/api/api-calls.md +68 -0
- package/skills/slack-cli/references/api/api-chat.md +123 -0
- package/skills/slack-cli/references/api/api-conversations.md +230 -0
- package/skills/slack-cli/references/api/api-dialog.md +13 -0
- package/skills/slack-cli/references/api/api-dnd.md +31 -0
- package/skills/slack-cli/references/api/api-emoji.md +8 -0
- package/skills/slack-cli/references/api/api-files.md +120 -0
- package/skills/slack-cli/references/api/api-migration.md +14 -0
- package/skills/slack-cli/references/api/api-pins.md +37 -0
- package/skills/slack-cli/references/api/api-reactions.md +58 -0
- package/skills/slack-cli/references/api/api-reminders.md +51 -0
- package/skills/slack-cli/references/api/api-search.md +18 -0
- package/skills/slack-cli/references/api/api-stars.md +42 -0
- package/skills/slack-cli/references/api/api-team.md +55 -0
- package/skills/slack-cli/references/api/api-usergroups.md +80 -0
- package/skills/slack-cli/references/api/api-users.md +101 -0
- package/skills/slack-cli/references/api/api-views.md +46 -0
- package/skills/slack-cli/references/api/api-workflows.md +36 -0
- package/skills/slack-cli/references/api.md +35 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
listen
|
|
5
|
+
} from "./chunk-AG7FP64Z.js";
|
|
6
|
+
import {
|
|
7
|
+
ownerLogin
|
|
8
|
+
} from "./chunk-P6G2QTCD.js";
|
|
9
|
+
import {
|
|
10
|
+
WebStandardStreamableHTTPServerTransport,
|
|
11
|
+
createMcpHandler,
|
|
12
|
+
getOAuthProtectedResourceMetadataUrl,
|
|
13
|
+
hostHeaderValidationResponse,
|
|
14
|
+
isLegacyRequest,
|
|
15
|
+
oauthMetadataResponse,
|
|
16
|
+
requireBearerAuth
|
|
17
|
+
} from "./chunk-PL5P7UKW.js";
|
|
18
|
+
import {
|
|
19
|
+
activityRecorder,
|
|
20
|
+
calledTools,
|
|
21
|
+
httpActivityFile,
|
|
22
|
+
httpLock
|
|
23
|
+
} from "./chunk-KIKLDI74.js";
|
|
24
|
+
import "./chunk-SKGAKI62.js";
|
|
25
|
+
import "./chunk-IYJH75D4.js";
|
|
26
|
+
import "./chunk-H2COZZ55.js";
|
|
27
|
+
import "./chunk-CMZBCWND.js";
|
|
28
|
+
import "./chunk-S4UUN6LD.js";
|
|
29
|
+
import "./chunk-Y5E2WNWB.js";
|
|
30
|
+
import {
|
|
31
|
+
CliError
|
|
32
|
+
} from "./chunk-QLLBACDR.js";
|
|
33
|
+
import {
|
|
34
|
+
__name
|
|
35
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
36
|
+
|
|
37
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/mcp/http/serve.js
|
|
38
|
+
import { randomUUID } from "node:crypto";
|
|
39
|
+
var MCP_PATH = "/mcp";
|
|
40
|
+
var AS_METADATA = "/.well-known/oauth-authorization-server";
|
|
41
|
+
var LOCAL = ["localhost", "127.0.0.1"];
|
|
42
|
+
var MAX_SESSIONS = 20;
|
|
43
|
+
var MAX_LOGIN_BODY = 64 * 1024;
|
|
44
|
+
var SESSION_IDLE_MS = 60 * 60 * 1e3;
|
|
45
|
+
var sessionMissing = /* @__PURE__ */ __name(() => new Response(JSON.stringify({ jsonrpc: "2.0", error: { code: -32001, message: "Session not found" }, id: null }), {
|
|
46
|
+
status: 404,
|
|
47
|
+
headers: { "content-type": "application/json" }
|
|
48
|
+
}), "sessionMissing");
|
|
49
|
+
var legacySessions = /* @__PURE__ */ __name((build, now) => {
|
|
50
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
51
|
+
const drop = /* @__PURE__ */ __name(async (id) => {
|
|
52
|
+
const one = sessions.get(id);
|
|
53
|
+
sessions.delete(id);
|
|
54
|
+
await one?.close();
|
|
55
|
+
}, "drop");
|
|
56
|
+
const handle = /* @__PURE__ */ __name(async (request, auth) => {
|
|
57
|
+
for (const [id2, one] of sessions)
|
|
58
|
+
if (now() - one.seen > SESSION_IDLE_MS)
|
|
59
|
+
await drop(id2);
|
|
60
|
+
const id = request.headers.get("mcp-session-id");
|
|
61
|
+
if (id) {
|
|
62
|
+
const known = sessions.get(id);
|
|
63
|
+
if (!known || known.clientId !== auth.clientId)
|
|
64
|
+
return sessionMissing();
|
|
65
|
+
known.seen = now();
|
|
66
|
+
return known.transport.handleRequest(request, { authInfo: auth });
|
|
67
|
+
}
|
|
68
|
+
const server = build();
|
|
69
|
+
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
70
|
+
sessionIdGenerator: /* @__PURE__ */ __name(() => randomUUID(), "sessionIdGenerator"),
|
|
71
|
+
onsessionclosed: /* @__PURE__ */ __name((closed) => void sessions.delete(closed), "onsessionclosed")
|
|
72
|
+
});
|
|
73
|
+
await server.connect(transport);
|
|
74
|
+
const response = await transport.handleRequest(request, { authInfo: auth });
|
|
75
|
+
if (!transport.sessionId) {
|
|
76
|
+
await server.close();
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
sessions.set(transport.sessionId, { transport, close: /* @__PURE__ */ __name(() => server.close(), "close"), clientId: auth.clientId, seen: now() });
|
|
80
|
+
while (sessions.size > MAX_SESSIONS)
|
|
81
|
+
await drop(sessions.keys().next().value);
|
|
82
|
+
return response;
|
|
83
|
+
}, "handle");
|
|
84
|
+
return {
|
|
85
|
+
handle,
|
|
86
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
87
|
+
for (const id of [...sessions.keys()])
|
|
88
|
+
await drop(id);
|
|
89
|
+
}, "close")
|
|
90
|
+
};
|
|
91
|
+
}, "legacySessions");
|
|
92
|
+
var metadataRequest = /* @__PURE__ */ __name((request, path, base) => {
|
|
93
|
+
const url = new URL(request.url);
|
|
94
|
+
const inserted = base && path === `${AS_METADATA}${base}`;
|
|
95
|
+
if (!inserted && url.pathname === path)
|
|
96
|
+
return request;
|
|
97
|
+
url.pathname = inserted ? AS_METADATA : path;
|
|
98
|
+
return new Request(url, { method: request.method, headers: request.headers });
|
|
99
|
+
}, "metadataRequest");
|
|
100
|
+
var toolsIn = /* @__PURE__ */ __name(async (request) => {
|
|
101
|
+
if (request.method !== "POST")
|
|
102
|
+
return [];
|
|
103
|
+
try {
|
|
104
|
+
return calledTools(await request.clone().json());
|
|
105
|
+
} catch {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
}, "toolsIn");
|
|
109
|
+
var serveOverHttp = /* @__PURE__ */ __name(async (build, options) => {
|
|
110
|
+
const { publicUrl, port, tokenFile, appName, reaches, onCode, onError, now, lockFile, version } = options;
|
|
111
|
+
const lock = lockFile ? httpLock(lockFile, {
|
|
112
|
+
pid: process.pid,
|
|
113
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
114
|
+
port,
|
|
115
|
+
publicUrl: publicUrl.href,
|
|
116
|
+
...version ? { version } : {}
|
|
117
|
+
}) : void 0;
|
|
118
|
+
if (lock?.held)
|
|
119
|
+
throw new CliError("validation_error", `${appName} already serves MCP over HTTP for this profile on port ${lock.held.port} (PID ${lock.held.pid}, since ${lock.held.startedAt})`);
|
|
120
|
+
const base = publicUrl.pathname === "/" ? "" : publicUrl.pathname.replace(/\/+$/, "");
|
|
121
|
+
const issuer = new URL(`${publicUrl.origin}${base}`);
|
|
122
|
+
const resource = new URL(`${base}${MCP_PATH}`, publicUrl.origin);
|
|
123
|
+
const mcpPath = resource.pathname;
|
|
124
|
+
const publicPath = /* @__PURE__ */ __name((path) => base && path !== base && !path.startsWith(`${base}/`) && !path.startsWith("/.well-known/") ? `${base}${path}` : path, "publicPath");
|
|
125
|
+
const login = ownerLogin({
|
|
126
|
+
issuer,
|
|
127
|
+
resource,
|
|
128
|
+
file: tokenFile,
|
|
129
|
+
appName,
|
|
130
|
+
...reaches ? { reaches } : {},
|
|
131
|
+
onCode: /* @__PURE__ */ __name((code, expires) => {
|
|
132
|
+
lock?.update({ loginCode: code, loginCodeExpiresAt: expires.toISOString() });
|
|
133
|
+
onCode(code, expires);
|
|
134
|
+
}, "onCode"),
|
|
135
|
+
...now ? { now } : {}
|
|
136
|
+
});
|
|
137
|
+
const insecure = issuer.protocol === "http:" && LOCAL.includes(issuer.hostname);
|
|
138
|
+
const mcp = createMcpHandler(build, { legacy: "reject", ...onError ? { onerror: onError } : {} });
|
|
139
|
+
const legacy = legacySessions(build, now ?? Date.now);
|
|
140
|
+
const bearer = requireBearerAuth({
|
|
141
|
+
verifier: login.verifier,
|
|
142
|
+
resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resource)
|
|
143
|
+
});
|
|
144
|
+
const activity = activityRecorder(httpActivityFile(tokenFile), now);
|
|
145
|
+
const allowedHosts = [.../* @__PURE__ */ new Set([publicUrl.hostname, ...LOCAL])];
|
|
146
|
+
const allowedOrigins = [publicUrl.origin];
|
|
147
|
+
const listening = await listen(async (request) => {
|
|
148
|
+
const refused = hostHeaderValidationResponse(request, allowedHosts);
|
|
149
|
+
if (refused)
|
|
150
|
+
return refused;
|
|
151
|
+
const path = publicPath(new URL(request.url).pathname);
|
|
152
|
+
const discovery = oauthMetadataResponse(metadataRequest(request, path, base), {
|
|
153
|
+
oauthMetadata: login.metadata,
|
|
154
|
+
resourceServerUrl: resource,
|
|
155
|
+
resourceName: appName,
|
|
156
|
+
...insecure ? { dangerouslyAllowInsecureIssuerUrl: true } : {}
|
|
157
|
+
});
|
|
158
|
+
if (discovery)
|
|
159
|
+
return discovery;
|
|
160
|
+
if (Number(request.headers.get("content-length") ?? 0) > MAX_LOGIN_BODY && path !== mcpPath)
|
|
161
|
+
return new Response("Request too large", { status: 413 });
|
|
162
|
+
const origin = request.headers.get("origin");
|
|
163
|
+
if (origin && !allowedOrigins.includes(origin))
|
|
164
|
+
return new Response("Origin not allowed", { status: 403 });
|
|
165
|
+
const answered = await login.handle(request, path);
|
|
166
|
+
if (answered)
|
|
167
|
+
return answered;
|
|
168
|
+
if (path !== mcpPath)
|
|
169
|
+
return new Response("Not found", { status: 404 });
|
|
170
|
+
const auth = await bearer(request);
|
|
171
|
+
if (auth instanceof Response)
|
|
172
|
+
return auth;
|
|
173
|
+
activity.record(auth.clientId, await toolsIn(request));
|
|
174
|
+
return await isLegacyRequest(request) ? legacy.handle(request, auth) : mcp.fetch(request, { authInfo: auth });
|
|
175
|
+
}, { host: "127.0.0.1", port }).catch((error) => {
|
|
176
|
+
login.close();
|
|
177
|
+
lock?.release();
|
|
178
|
+
throw error;
|
|
179
|
+
});
|
|
180
|
+
lock?.update({ listeningAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
181
|
+
return {
|
|
182
|
+
url: listening.url,
|
|
183
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
184
|
+
login.close();
|
|
185
|
+
activity.flush();
|
|
186
|
+
try {
|
|
187
|
+
await listening.close();
|
|
188
|
+
await legacy.close();
|
|
189
|
+
await mcp.close();
|
|
190
|
+
} finally {
|
|
191
|
+
lock?.release();
|
|
192
|
+
}
|
|
193
|
+
}, "close")
|
|
194
|
+
};
|
|
195
|
+
}, "serveOverHttp");
|
|
196
|
+
export {
|
|
197
|
+
MCP_PATH,
|
|
198
|
+
serveOverHttp
|
|
199
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
botInstructions
|
|
5
|
+
} from "./chunk-IPP4N6HD.js";
|
|
6
|
+
import {
|
|
7
|
+
skillResources
|
|
8
|
+
} from "./chunk-ZBCFZCJW.js";
|
|
9
|
+
import {
|
|
10
|
+
StdioServerTransport,
|
|
11
|
+
answeredWire,
|
|
12
|
+
serveStdio
|
|
13
|
+
} from "./chunk-JYRYQJBN.js";
|
|
14
|
+
import {
|
|
15
|
+
wholeList
|
|
16
|
+
} from "./chunk-FBWR4E5D.js";
|
|
17
|
+
import {
|
|
18
|
+
runCommandForAgent,
|
|
19
|
+
toolsFromCommands
|
|
20
|
+
} from "./chunk-WCCFJ4Q6.js";
|
|
21
|
+
import "./chunk-6PDQP5RM.js";
|
|
22
|
+
import "./chunk-BRXTN5LJ.js";
|
|
23
|
+
import {
|
|
24
|
+
answered,
|
|
25
|
+
normal,
|
|
26
|
+
registerCommands
|
|
27
|
+
} from "./chunk-QY2F6A3D.js";
|
|
28
|
+
import {
|
|
29
|
+
agentJson
|
|
30
|
+
} from "./chunk-5R5YRYIP.js";
|
|
31
|
+
import "./chunk-VOUAKCPM.js";
|
|
32
|
+
import "./chunk-QP7XN5KX.js";
|
|
33
|
+
import "./chunk-JCZLRT4Z.js";
|
|
34
|
+
import "./chunk-JGRWMR5H.js";
|
|
35
|
+
import "./chunk-M5XTZHXM.js";
|
|
36
|
+
import "./chunk-WV6EXRDV.js";
|
|
37
|
+
import {
|
|
38
|
+
callerOf
|
|
39
|
+
} from "./chunk-NYAPUET7.js";
|
|
40
|
+
import "./chunk-HXLXM7HV.js";
|
|
41
|
+
import {
|
|
42
|
+
McpServer
|
|
43
|
+
} from "./chunk-PL5P7UKW.js";
|
|
44
|
+
import "./chunk-MJBEGUIZ.js";
|
|
45
|
+
import "./chunk-ELY2TLCY.js";
|
|
46
|
+
import "./chunk-CWYU4R65.js";
|
|
47
|
+
import "./chunk-5SXZETJF.js";
|
|
48
|
+
import {
|
|
49
|
+
MESSENGER_CHANGE_REFUSAL,
|
|
50
|
+
changesMessenger,
|
|
51
|
+
flatten,
|
|
52
|
+
itemOf,
|
|
53
|
+
readOnlyLockOf,
|
|
54
|
+
readOnlyRefusal
|
|
55
|
+
} from "./chunk-5LPREGD3.js";
|
|
56
|
+
import "./chunk-2LB5BWC4.js";
|
|
57
|
+
import "./chunk-CZFR6JQX.js";
|
|
58
|
+
import "./chunk-WVAT5TGY.js";
|
|
59
|
+
import "./chunk-IYJH75D4.js";
|
|
60
|
+
import "./chunk-HGXTEK7R.js";
|
|
61
|
+
import "./chunk-VAHFY732.js";
|
|
62
|
+
import "./chunk-RLIT7VAZ.js";
|
|
63
|
+
import "./chunk-SQMZP5MA.js";
|
|
64
|
+
import "./chunk-N4WOLGIV.js";
|
|
65
|
+
import "./chunk-PU7R6XNV.js";
|
|
66
|
+
import "./chunk-UBHQO5HV.js";
|
|
67
|
+
import "./chunk-53LIHHXC.js";
|
|
68
|
+
import "./chunk-L4WO3XH6.js";
|
|
69
|
+
import "./chunk-ERRVUVKR.js";
|
|
70
|
+
import "./chunk-4HSVEQ3R.js";
|
|
71
|
+
import "./chunk-DVHX7R54.js";
|
|
72
|
+
import "./chunk-CRQEEJNF.js";
|
|
73
|
+
import "./chunk-5RSQTG7L.js";
|
|
74
|
+
import "./chunk-75BLNPN3.js";
|
|
75
|
+
import "./chunk-4QPMHVM5.js";
|
|
76
|
+
import "./chunk-LQDNUAK3.js";
|
|
77
|
+
import "./chunk-M27Z23OZ.js";
|
|
78
|
+
import "./chunk-3IJ3THPV.js";
|
|
79
|
+
import "./chunk-D72URWJE.js";
|
|
80
|
+
import "./chunk-XXOMUKC6.js";
|
|
81
|
+
import "./chunk-UB6NTICY.js";
|
|
82
|
+
import "./chunk-LV5ONLQH.js";
|
|
83
|
+
import "./chunk-H2COZZ55.js";
|
|
84
|
+
import {
|
|
85
|
+
mcpErrorResult
|
|
86
|
+
} from "./chunk-CMZBCWND.js";
|
|
87
|
+
import {
|
|
88
|
+
object
|
|
89
|
+
} from "./chunk-S4UUN6LD.js";
|
|
90
|
+
import "./chunk-Y5E2WNWB.js";
|
|
91
|
+
import "./chunk-QLLBACDR.js";
|
|
92
|
+
import "./chunk-GKS6KL57.js";
|
|
93
|
+
import {
|
|
94
|
+
__name
|
|
95
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
96
|
+
|
|
97
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/mcp/bot/server.js
|
|
98
|
+
import { randomUUID } from "node:crypto";
|
|
99
|
+
var body = /* @__PURE__ */ __name((command, value) => Array.isArray(value) ? wholeList(`bot ${command}`, value) : value !== null && typeof value === "object" && ("item" in value || "items" in value) ? value : itemOf(value !== null && typeof value === "object" ? value : { value }), "body");
|
|
100
|
+
var createBotServer = /* @__PURE__ */ __name((options) => {
|
|
101
|
+
const { bot, program, settings, env } = options;
|
|
102
|
+
const command = bot.app.command;
|
|
103
|
+
const levels = options.levels ?? (() => settings.permissions);
|
|
104
|
+
const authority = /* @__PURE__ */ __name((path) => options.authority?.(path) === true || path[0] === "config" && (path[1] === "set" || path[1] === "unset"), "authority");
|
|
105
|
+
const catalogue = {
|
|
106
|
+
includeUnavailable: true,
|
|
107
|
+
levels: settings.permissions,
|
|
108
|
+
currentLevels: levels,
|
|
109
|
+
readOnly: readOnlyLockOf(bot.app, env) !== void 0,
|
|
110
|
+
...options.keyOf ? { keyOf: options.keyOf } : {},
|
|
111
|
+
authority,
|
|
112
|
+
...options.fetchOnly ? { fetchOnly: options.fetchOnly } : {},
|
|
113
|
+
...options.fetches ? { fetches: options.fetches } : {},
|
|
114
|
+
offline: true,
|
|
115
|
+
// Another bot's copy is this bot's to read only where `read_other_bots` says so.
|
|
116
|
+
...settings.readOtherBots ? {} : { omit: ["all_bots", "bots"] }
|
|
117
|
+
};
|
|
118
|
+
const tools = [
|
|
119
|
+
...toolsFromCommands(program.commands, { ...catalogue, root: ["bot"] }),
|
|
120
|
+
...toolsFromCommands(program.commands.filter((one) => one.path[0] === "config"), {
|
|
121
|
+
...catalogue,
|
|
122
|
+
omit: ["bot", "personal", "defaults"]
|
|
123
|
+
})
|
|
124
|
+
];
|
|
125
|
+
const writes = tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command);
|
|
126
|
+
const skills = options.skill ? skillResources(bot.app, options.skill) : [];
|
|
127
|
+
const skill = skills[0];
|
|
128
|
+
let queue = Promise.resolve();
|
|
129
|
+
const invoke = /* @__PURE__ */ __name((path, input, caller) => {
|
|
130
|
+
const next = queue.then(() => runCommandForAgent(program, path, path[0] === "config" ? { ...input, bot: true } : input, {
|
|
131
|
+
profile: settings.profile,
|
|
132
|
+
readOnly: readOnlyLockOf(bot.app, env) !== void 0,
|
|
133
|
+
env,
|
|
134
|
+
levels,
|
|
135
|
+
...options.keyOf ? { keyOf: options.keyOf } : {},
|
|
136
|
+
authority,
|
|
137
|
+
...options.fetches ? { fetches: options.fetches } : {},
|
|
138
|
+
...caller ? { caller } : {}
|
|
139
|
+
}));
|
|
140
|
+
queue = next.catch(() => void 0);
|
|
141
|
+
return next;
|
|
142
|
+
}, "invoke");
|
|
143
|
+
const build = /* @__PURE__ */ __name(() => {
|
|
144
|
+
const callers = { env, client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"), connectionId: randomUUID() };
|
|
145
|
+
const server = new McpServer({ name: `${command}-bot-${settings.profile}`, version: bot.app.version }, {
|
|
146
|
+
instructions: botInstructions({
|
|
147
|
+
command,
|
|
148
|
+
name: bot.name ?? command,
|
|
149
|
+
profile: settings.profile,
|
|
150
|
+
writes,
|
|
151
|
+
...skill ? { skill: skill.instruction } : {}
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
for (const { uri, name, title, description, mimeType, read } of skills)
|
|
155
|
+
server.registerResource(name, uri, { title, description, mimeType }, read);
|
|
156
|
+
const commands = Object.fromEntries(tools.map((tool) => [
|
|
157
|
+
tool.command,
|
|
158
|
+
{
|
|
159
|
+
title: tool.title,
|
|
160
|
+
description: tool.description,
|
|
161
|
+
writes: tool.writes,
|
|
162
|
+
availability: tool.availability,
|
|
163
|
+
input: tool.input,
|
|
164
|
+
run: /* @__PURE__ */ __name(async (args, ctx) => {
|
|
165
|
+
const caller = callerOf(ctx, `${command}_${tool.command.replaceAll(" ", "_")}`, callers);
|
|
166
|
+
const answer = await invoke(tool.path, args, caller);
|
|
167
|
+
return "error" in answer ? mcpErrorResult(JSON.parse(agentJson(answer.error))) : answered(body(tool.command, answer.result));
|
|
168
|
+
}, "run")
|
|
169
|
+
}
|
|
170
|
+
]));
|
|
171
|
+
commands.status = {
|
|
172
|
+
title: "This server's bot and profile",
|
|
173
|
+
description: "Which profile this server speaks for, where its bot token comes from, which bot it is, and which writing commands are on. Sends nothing.",
|
|
174
|
+
writes: false,
|
|
175
|
+
input: object({}),
|
|
176
|
+
run: /* @__PURE__ */ __name(async () => {
|
|
177
|
+
const auth = await invoke(["bot", "auth", "show"], {});
|
|
178
|
+
const shown = "error" in auth ? auth.error : auth.result?.item ?? auth.result;
|
|
179
|
+
return answered(itemOf({
|
|
180
|
+
profile: settings.profile,
|
|
181
|
+
kind: "bot",
|
|
182
|
+
auth: shown,
|
|
183
|
+
writes: tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command),
|
|
184
|
+
permissions: levels()
|
|
185
|
+
}));
|
|
186
|
+
}, "run")
|
|
187
|
+
};
|
|
188
|
+
registerCommands(server, `${command}_bot`, commands, void 0, (asked) => {
|
|
189
|
+
const lock = readOnlyLockOf(bot.app, env);
|
|
190
|
+
const one = flatten(program.commands).find((info) => info.path[0] === "bot" && normal(info.path.slice(1).join(" ")) === asked);
|
|
191
|
+
if (lock && one && changesMessenger(one))
|
|
192
|
+
throw readOnlyRefusal(lock, MESSENGER_CHANGE_REFUSAL);
|
|
193
|
+
}, bot.app.messenger);
|
|
194
|
+
return server;
|
|
195
|
+
}, "build");
|
|
196
|
+
return { build, tools, offered: tools.map((tool) => tool.command) };
|
|
197
|
+
}, "createBotServer");
|
|
198
|
+
var serveBotOverStdio = /* @__PURE__ */ __name(async (options, note) => {
|
|
199
|
+
const { build } = createBotServer(options);
|
|
200
|
+
const wire = answeredWire(process.stdin, process.stdout);
|
|
201
|
+
const handle = serveStdio(build, {
|
|
202
|
+
transport: new StdioServerTransport(wire.input, wire.output),
|
|
203
|
+
onerror: /* @__PURE__ */ __name((error) => note(`mcp: ${error.message}`), "onerror")
|
|
204
|
+
});
|
|
205
|
+
await wire.finished();
|
|
206
|
+
wire.release();
|
|
207
|
+
await handle.close();
|
|
208
|
+
}, "serveBotOverStdio");
|
|
209
|
+
export {
|
|
210
|
+
createBotServer,
|
|
211
|
+
serveBotOverStdio
|
|
212
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
PER_RUN,
|
|
5
|
+
createServer,
|
|
6
|
+
envelope,
|
|
7
|
+
serveOverHttpUntilStopped,
|
|
8
|
+
serveOverStdio
|
|
9
|
+
} from "./chunk-5F36CXDM.js";
|
|
10
|
+
import "./chunk-YDO6RJ2P.js";
|
|
11
|
+
import "./chunk-ZBCFZCJW.js";
|
|
12
|
+
import "./chunk-JYRYQJBN.js";
|
|
13
|
+
import "./chunk-2ZEYRHZV.js";
|
|
14
|
+
import "./chunk-WW76JMKE.js";
|
|
15
|
+
import "./chunk-FBWR4E5D.js";
|
|
16
|
+
import "./chunk-WCCFJ4Q6.js";
|
|
17
|
+
import "./chunk-6PDQP5RM.js";
|
|
18
|
+
import "./chunk-BRXTN5LJ.js";
|
|
19
|
+
import "./chunk-IWTVR7S7.js";
|
|
20
|
+
import "./chunk-QY2F6A3D.js";
|
|
21
|
+
import "./chunk-5R5YRYIP.js";
|
|
22
|
+
import "./chunk-VOUAKCPM.js";
|
|
23
|
+
import "./chunk-QP7XN5KX.js";
|
|
24
|
+
import "./chunk-JCZLRT4Z.js";
|
|
25
|
+
import "./chunk-JGRWMR5H.js";
|
|
26
|
+
import "./chunk-M5XTZHXM.js";
|
|
27
|
+
import "./chunk-WV6EXRDV.js";
|
|
28
|
+
import "./chunk-NYAPUET7.js";
|
|
29
|
+
import "./chunk-HXLXM7HV.js";
|
|
30
|
+
import "./chunk-PL5P7UKW.js";
|
|
31
|
+
import "./chunk-MJBEGUIZ.js";
|
|
32
|
+
import "./chunk-ELY2TLCY.js";
|
|
33
|
+
import "./chunk-CWYU4R65.js";
|
|
34
|
+
import "./chunk-5SXZETJF.js";
|
|
35
|
+
import "./chunk-KIKLDI74.js";
|
|
36
|
+
import "./chunk-SKGAKI62.js";
|
|
37
|
+
import "./chunk-7BEO72EN.js";
|
|
38
|
+
import "./chunk-5LPREGD3.js";
|
|
39
|
+
import "./chunk-2LB5BWC4.js";
|
|
40
|
+
import "./chunk-CZFR6JQX.js";
|
|
41
|
+
import "./chunk-WVAT5TGY.js";
|
|
42
|
+
import "./chunk-IYJH75D4.js";
|
|
43
|
+
import "./chunk-HGXTEK7R.js";
|
|
44
|
+
import "./chunk-VAHFY732.js";
|
|
45
|
+
import "./chunk-RLIT7VAZ.js";
|
|
46
|
+
import "./chunk-SQMZP5MA.js";
|
|
47
|
+
import "./chunk-N4WOLGIV.js";
|
|
48
|
+
import "./chunk-PU7R6XNV.js";
|
|
49
|
+
import "./chunk-UBHQO5HV.js";
|
|
50
|
+
import "./chunk-53LIHHXC.js";
|
|
51
|
+
import "./chunk-L4WO3XH6.js";
|
|
52
|
+
import "./chunk-ERRVUVKR.js";
|
|
53
|
+
import "./chunk-4HSVEQ3R.js";
|
|
54
|
+
import "./chunk-DVHX7R54.js";
|
|
55
|
+
import "./chunk-CRQEEJNF.js";
|
|
56
|
+
import "./chunk-5RSQTG7L.js";
|
|
57
|
+
import "./chunk-75BLNPN3.js";
|
|
58
|
+
import "./chunk-4QPMHVM5.js";
|
|
59
|
+
import "./chunk-LQDNUAK3.js";
|
|
60
|
+
import "./chunk-M27Z23OZ.js";
|
|
61
|
+
import "./chunk-3IJ3THPV.js";
|
|
62
|
+
import "./chunk-D72URWJE.js";
|
|
63
|
+
import "./chunk-XXOMUKC6.js";
|
|
64
|
+
import "./chunk-UB6NTICY.js";
|
|
65
|
+
import "./chunk-LV5ONLQH.js";
|
|
66
|
+
import "./chunk-H2COZZ55.js";
|
|
67
|
+
import "./chunk-CMZBCWND.js";
|
|
68
|
+
import "./chunk-S4UUN6LD.js";
|
|
69
|
+
import "./chunk-Y5E2WNWB.js";
|
|
70
|
+
import "./chunk-QLLBACDR.js";
|
|
71
|
+
import "./chunk-GKS6KL57.js";
|
|
72
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
73
|
+
export {
|
|
74
|
+
PER_RUN,
|
|
75
|
+
createServer,
|
|
76
|
+
envelope,
|
|
77
|
+
serveOverHttpUntilStopped,
|
|
78
|
+
serveOverStdio
|
|
79
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
3
|
+
const require = __bundleRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
DESKTOP
|
|
6
|
+
} from "./chunk-3IZF5ENR.js";
|
|
7
|
+
import {
|
|
8
|
+
installerOf
|
|
9
|
+
} from "./chunk-M27Z23OZ.js";
|
|
10
|
+
import "./chunk-3IJ3THPV.js";
|
|
11
|
+
import {
|
|
12
|
+
DESCRIBE_FLAG,
|
|
13
|
+
DISPATCH_FLAG,
|
|
14
|
+
PROGRAM_PREFIX,
|
|
15
|
+
SHIM_FORMAT,
|
|
16
|
+
describeAnswer,
|
|
17
|
+
exists,
|
|
18
|
+
fileState,
|
|
19
|
+
shimFiles,
|
|
20
|
+
writeShim
|
|
21
|
+
} from "./chunk-N5K4OHPT.js";
|
|
22
|
+
import "./chunk-H2COZZ55.js";
|
|
23
|
+
import {
|
|
24
|
+
catchCrashes
|
|
25
|
+
} from "./chunk-CMZBCWND.js";
|
|
26
|
+
import "./chunk-S4UUN6LD.js";
|
|
27
|
+
import "./chunk-Y5E2WNWB.js";
|
|
28
|
+
import "./chunk-QLLBACDR.js";
|
|
29
|
+
import {
|
|
30
|
+
__name
|
|
31
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
32
|
+
|
|
33
|
+
// dist/bin/slack.js
|
|
34
|
+
import { enableCompileCache } from "node:module";
|
|
35
|
+
|
|
36
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/start.js
|
|
37
|
+
import { createHash } from "node:crypto";
|
|
38
|
+
import { existsSync, readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
39
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
40
|
+
import { fileURLToPath } from "node:url";
|
|
41
|
+
|
|
42
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/launcher.js
|
|
43
|
+
import { readFileSync } from "node:fs";
|
|
44
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
45
|
+
var posix = /* @__PURE__ */ __name((path) => path.replaceAll("\\", "/"), "posix");
|
|
46
|
+
var pnpmHome = /* @__PURE__ */ __name((path, env) => {
|
|
47
|
+
const home = env.PNPM_HOME;
|
|
48
|
+
return home && path.startsWith(`${posix(home).replace(/\/+$/, "")}/`) ? home : void 0;
|
|
49
|
+
}, "pnpmHome");
|
|
50
|
+
var layoutFolders = /* @__PURE__ */ __name((script, env) => {
|
|
51
|
+
const path = posix(script);
|
|
52
|
+
const home = pnpmHome(path, env);
|
|
53
|
+
if (home)
|
|
54
|
+
return [join(home, "bin"), home];
|
|
55
|
+
switch (installerOf(script)) {
|
|
56
|
+
case "bun":
|
|
57
|
+
return [`${path.slice(0, path.indexOf("/install/global/node_modules/"))}/bin`];
|
|
58
|
+
case "npm": {
|
|
59
|
+
const root = path.slice(0, path.indexOf("/node_modules/"));
|
|
60
|
+
return [basename(root) === "lib" ? join(dirname(root), "bin") : root];
|
|
61
|
+
}
|
|
62
|
+
default:
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
}, "layoutFolders");
|
|
66
|
+
var binFolder = /* @__PURE__ */ __name(({ name, argv1, script, env, platform }) => {
|
|
67
|
+
if (!["npm", "pnpm", "bun"].includes(installerOf(script)) && !pnpmHome(posix(script), env))
|
|
68
|
+
return void 0;
|
|
69
|
+
const extensions = platform === "win32" ? [".cmd", ".exe"] : [""];
|
|
70
|
+
const candidates = [argv1 ? dirname(argv1) : void 0, ...layoutFolders(script, env)];
|
|
71
|
+
for (const dir of new Set(candidates)) {
|
|
72
|
+
if (dir === void 0 || basename(dir) === ".bin")
|
|
73
|
+
continue;
|
|
74
|
+
for (const extension of extensions) {
|
|
75
|
+
const program = `${PROGRAM_PREFIX}${name}${extension}`;
|
|
76
|
+
if (exists(join(dir, program)))
|
|
77
|
+
return { dir, program };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return void 0;
|
|
81
|
+
}, "binFolder");
|
|
82
|
+
var installed = /* @__PURE__ */ __name((dir, program) => {
|
|
83
|
+
if (!exists(join(dir, program)))
|
|
84
|
+
return false;
|
|
85
|
+
if (!program.toLowerCase().endsWith(".exe"))
|
|
86
|
+
return true;
|
|
87
|
+
let script;
|
|
88
|
+
try {
|
|
89
|
+
script = readFileSync(join(dir, `${program.slice(0, -4)}.bunx`)).toString("utf16le").split('"')[0] ?? "";
|
|
90
|
+
} catch {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (script === "" || exists(resolve(dir, script)))
|
|
94
|
+
return true;
|
|
95
|
+
const at = posix(script).lastIndexOf("/install/global/node_modules/");
|
|
96
|
+
return at < 0 || exists(join(dirname(dir), posix(script).slice(at + 1)));
|
|
97
|
+
}, "installed");
|
|
98
|
+
var NAME = "wcat";
|
|
99
|
+
var ensureLauncher = /* @__PURE__ */ __name(({ dir, program, platform }) => {
|
|
100
|
+
try {
|
|
101
|
+
if (!exists(join(dir, program)))
|
|
102
|
+
return "failed";
|
|
103
|
+
const mine = shimFiles("launcher", { dir, name: NAME, target: program, platform });
|
|
104
|
+
const states = mine.map((file) => fileState(file.path));
|
|
105
|
+
if (states.some((one) => one.state === "foreign"))
|
|
106
|
+
return "foreign";
|
|
107
|
+
const ours = states.flatMap((one) => one.state === "ours" ? [one] : []);
|
|
108
|
+
if (ours.some(({ mark }) => mark.format > SHIM_FORMAT))
|
|
109
|
+
return "newer";
|
|
110
|
+
if (ours.some(({ mark }) => mark.kind !== "launcher"))
|
|
111
|
+
return "foreign";
|
|
112
|
+
const current = ours.find(({ mark }) => installed(dir, mark.target))?.mark.target;
|
|
113
|
+
const wanted = shimFiles("launcher", { dir, name: NAME, target: current ?? program, platform });
|
|
114
|
+
const stale = wanted.filter((file, at) => {
|
|
115
|
+
const state = states[at];
|
|
116
|
+
return state?.state !== "ours" || state.text !== file.text;
|
|
117
|
+
});
|
|
118
|
+
if (stale.length === 0)
|
|
119
|
+
return "kept";
|
|
120
|
+
for (const file of stale)
|
|
121
|
+
writeShim(file);
|
|
122
|
+
return "written";
|
|
123
|
+
} catch {
|
|
124
|
+
return "failed";
|
|
125
|
+
}
|
|
126
|
+
}, "ensureLauncher");
|
|
127
|
+
|
|
128
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/start.js
|
|
129
|
+
var wcatStart = /* @__PURE__ */ __name(async (tool, io = {}) => {
|
|
130
|
+
const argv = io.argv ?? process.argv;
|
|
131
|
+
const env = io.env ?? process.env;
|
|
132
|
+
const platform = io.platform ?? process.platform;
|
|
133
|
+
const stdout = io.stdout ?? process.stdout;
|
|
134
|
+
const [first, ...rest] = argv.slice(2);
|
|
135
|
+
if (first === DESCRIBE_FLAG) {
|
|
136
|
+
stdout.write(`${JSON.stringify(describeAnswer(tool, shippedManifest(argv[1])))}
|
|
137
|
+
`);
|
|
138
|
+
return { code: 0 };
|
|
139
|
+
}
|
|
140
|
+
if (first === DISPATCH_FLAG) {
|
|
141
|
+
const { runWcat } = await import("./dispatch-NYC4ARWX.js");
|
|
142
|
+
const code = await runWcat(rest, { env, platform, stdout, stderr: io.stderr ?? process.stderr, self: tool });
|
|
143
|
+
return { code };
|
|
144
|
+
}
|
|
145
|
+
const folder = binFolder({
|
|
146
|
+
name: tool.command,
|
|
147
|
+
argv1: argv[1],
|
|
148
|
+
script: io.script ?? fileURLToPath(new URL("wcat/start.js", import.meta.resolve("@wirecat/cli-base")).href),
|
|
149
|
+
env,
|
|
150
|
+
platform
|
|
151
|
+
});
|
|
152
|
+
return folder ? { launcher: ensureLauncher({ ...folder, platform }) } : {};
|
|
153
|
+
}, "wcatStart");
|
|
154
|
+
var shippedManifest = /* @__PURE__ */ __name((bin) => {
|
|
155
|
+
if (!bin)
|
|
156
|
+
return void 0;
|
|
157
|
+
try {
|
|
158
|
+
for (let dir = dirname2(realpathSync(bin)); ; dir = dirname2(dir)) {
|
|
159
|
+
if (existsSync(join2(dir, "package.json"))) {
|
|
160
|
+
const bytes = readFileSync2(join2(dir, "contracts", "wirecat.json"));
|
|
161
|
+
const { wcat_manifest: format, desktop } = JSON.parse(bytes.toString("utf8"));
|
|
162
|
+
if (format !== 2 || typeof desktop !== "object" || desktop === null)
|
|
163
|
+
return void 0;
|
|
164
|
+
return { desktop, sha256: createHash("sha256").update(bytes).digest("hex") };
|
|
165
|
+
}
|
|
166
|
+
if (dirname2(dir) === dir)
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
} catch {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
}, "shippedManifest");
|
|
173
|
+
|
|
174
|
+
// dist/bin/slack.js
|
|
175
|
+
enableCompileCache();
|
|
176
|
+
var stopCatching = catchCrashes({ cli: DESKTOP.command, interactive: process.stdout.isTTY === true });
|
|
177
|
+
var wcat = await wcatStart(DESKTOP);
|
|
178
|
+
if (wcat.code !== void 0) {
|
|
179
|
+
process.exitCode = wcat.code;
|
|
180
|
+
} else {
|
|
181
|
+
const { run } = await import("./program-OIYIBNSA.js");
|
|
182
|
+
process.exitCode = await run(process.argv.slice(2));
|
|
183
|
+
}
|
|
184
|
+
stopCatching();
|