@clawpay-hedera/sdk 0.1.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/README.md +294 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +137 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client/hedera-payment.d.ts +25 -0
- package/dist/client/hedera-payment.d.ts.map +1 -0
- package/dist/client/hedera-payment.js +68 -0
- package/dist/client/hedera-payment.js.map +1 -0
- package/dist/client/with-x402-client.d.ts +27 -0
- package/dist/client/with-x402-client.d.ts.map +1 -0
- package/dist/client/with-x402-client.js +136 -0
- package/dist/client/with-x402-client.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/handler/proxy/hooks/analytics-hook.d.ts +299 -0
- package/dist/handler/proxy/hooks/analytics-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/analytics-hook.js +133 -0
- package/dist/handler/proxy/hooks/analytics-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.d.ts +20 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.js +34 -0
- package/dist/handler/proxy/hooks/auth-headers-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.d.ts +133 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.js +138 -0
- package/dist/handler/proxy/hooks/hcs-audit-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/logging-hook.d.ts +100 -0
- package/dist/handler/proxy/hooks/logging-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/logging-hook.js +14 -0
- package/dist/handler/proxy/hooks/logging-hook.js.map +1 -0
- package/dist/handler/proxy/hooks/x402-hook.d.ts +246 -0
- package/dist/handler/proxy/hooks/x402-hook.d.ts.map +1 -0
- package/dist/handler/proxy/hooks/x402-hook.js +219 -0
- package/dist/handler/proxy/hooks/x402-hook.js.map +1 -0
- package/dist/handler/proxy/hooks.d.ts +12111 -0
- package/dist/handler/proxy/hooks.d.ts.map +1 -0
- package/dist/handler/proxy/hooks.js +142 -0
- package/dist/handler/proxy/hooks.js.map +1 -0
- package/dist/handler/proxy/index.d.ts +3 -0
- package/dist/handler/proxy/index.d.ts.map +1 -0
- package/dist/handler/proxy/index.js +489 -0
- package/dist/handler/proxy/index.js.map +1 -0
- package/dist/handler/server/index.d.ts +25 -0
- package/dist/handler/server/index.d.ts.map +1 -0
- package/dist/handler/server/index.js +38 -0
- package/dist/handler/server/index.js.map +1 -0
- package/dist/handler/server/platform-detection.d.ts +32 -0
- package/dist/handler/server/platform-detection.d.ts.map +1 -0
- package/dist/handler/server/platform-detection.js +441 -0
- package/dist/handler/server/platform-detection.js.map +1 -0
- package/dist/handler/server/plugins/with-x402.d.ts +21 -0
- package/dist/handler/server/plugins/with-x402.d.ts.map +1 -0
- package/dist/handler/server/plugins/with-x402.js +290 -0
- package/dist/handler/server/plugins/with-x402.js.map +1 -0
- package/dist/handler/server/templates/x402-server.d.ts +16 -0
- package/dist/handler/server/templates/x402-server.d.ts.map +1 -0
- package/dist/handler/server/templates/x402-server.js +13 -0
- package/dist/handler/server/templates/x402-server.js.map +1 -0
- package/dist/handler/shared/hedera-price.d.ts +26 -0
- package/dist/handler/shared/hedera-price.d.ts.map +1 -0
- package/dist/handler/shared/hedera-price.js +54 -0
- package/dist/handler/shared/hedera-price.js.map +1 -0
- package/dist/handler.d.ts +14 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +12 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/networks/hedera.d.ts +52 -0
- package/dist/networks/hedera.d.ts.map +1 -0
- package/dist/networks/hedera.js +61 -0
- package/dist/networks/hedera.js.map +1 -0
- package/dist/server/stdio/index.d.ts +2 -0
- package/dist/server/stdio/index.d.ts.map +1 -0
- package/dist/server/stdio/index.js +91 -0
- package/dist/server/stdio/index.js.map +1 -0
- package/dist/server/stdio/proxy-server.d.ts +9 -0
- package/dist/server/stdio/proxy-server.d.ts.map +1 -0
- package/dist/server/stdio/proxy-server.js +53 -0
- package/dist/server/stdio/proxy-server.js.map +1 -0
- package/dist/server/stdio/start-stdio-server.d.ts +28 -0
- package/dist/server/stdio/start-stdio-server.d.ts.map +1 -0
- package/dist/server/stdio/start-stdio-server.js +84 -0
- package/dist/server/stdio/start-stdio-server.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -0
- package/dist/utils/signer.d.ts +4 -0
- package/dist/utils/signer.d.ts.map +1 -0
- package/dist/utils/signer.js +58 -0
- package/dist/utils/signer.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
function jsonResponse(obj, status = 200) {
|
|
2
|
+
return new Response(JSON.stringify(obj), {
|
|
3
|
+
status,
|
|
4
|
+
headers: { "content-type": "application/json" },
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
async function wrapUpstreamResponse(upstream) {
|
|
8
|
+
// Clone headers to avoid immutable header guards on upstream responses
|
|
9
|
+
const headers = new Headers(upstream.headers);
|
|
10
|
+
// If the runtime already decompressed the body, avoid advertising compression again
|
|
11
|
+
headers.delete("content-encoding");
|
|
12
|
+
headers.delete("content-length");
|
|
13
|
+
headers.delete("transfer-encoding");
|
|
14
|
+
// Read the body content to avoid "Response body object should not be disturbed or locked" error
|
|
15
|
+
// This ensures the body is fully consumed before creating a new Response
|
|
16
|
+
const body = await upstream.arrayBuffer();
|
|
17
|
+
return new Response(body, {
|
|
18
|
+
status: upstream.status,
|
|
19
|
+
statusText: upstream.statusText,
|
|
20
|
+
headers,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function withProxy(targetUrl, hooks) {
|
|
24
|
+
return async (req) => {
|
|
25
|
+
console.log(`[${new Date().toISOString()}] Target URL: ${targetUrl}`);
|
|
26
|
+
// Preserve original body for non-JSON requests
|
|
27
|
+
if (!req.headers.get("content-type")?.includes("json")) {
|
|
28
|
+
const upstream = await fetch(targetUrl, {
|
|
29
|
+
method: req.method,
|
|
30
|
+
headers: req.headers,
|
|
31
|
+
body: req.body,
|
|
32
|
+
duplex: 'half'
|
|
33
|
+
});
|
|
34
|
+
return await wrapUpstreamResponse(upstream);
|
|
35
|
+
}
|
|
36
|
+
// Parse JSON while preserving original body stream
|
|
37
|
+
let originalRpc = null;
|
|
38
|
+
let originalBodyText = null;
|
|
39
|
+
try {
|
|
40
|
+
// Clone request to preserve original body for forwarding
|
|
41
|
+
const clonedReq = req.clone();
|
|
42
|
+
originalBodyText = await clonedReq.text();
|
|
43
|
+
// Parse JSON for hook processing
|
|
44
|
+
originalRpc = JSON.parse(originalBodyText);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
// If JSON parsing fails, forward original body
|
|
48
|
+
const upstream = await fetch(targetUrl, {
|
|
49
|
+
method: req.method,
|
|
50
|
+
headers: req.headers,
|
|
51
|
+
body: req.body,
|
|
52
|
+
duplex: 'half'
|
|
53
|
+
});
|
|
54
|
+
return await wrapUpstreamResponse(upstream);
|
|
55
|
+
}
|
|
56
|
+
if (!originalRpc || Array.isArray(originalRpc)) {
|
|
57
|
+
// Forward original body for non-object JSON
|
|
58
|
+
const upstream = await fetch(targetUrl, {
|
|
59
|
+
method: req.method,
|
|
60
|
+
headers: req.headers,
|
|
61
|
+
body: originalBodyText,
|
|
62
|
+
duplex: 'half'
|
|
63
|
+
});
|
|
64
|
+
return await wrapUpstreamResponse(upstream);
|
|
65
|
+
}
|
|
66
|
+
// Generalized MCP routing
|
|
67
|
+
const method = String(originalRpc["method"] || "");
|
|
68
|
+
const isNotification = !("id" in originalRpc);
|
|
69
|
+
const url = new URL(req.url);
|
|
70
|
+
const extra = {
|
|
71
|
+
requestId: crypto.randomUUID(),
|
|
72
|
+
sessionId: originalRpc?.params?._meta?.sessionId,
|
|
73
|
+
originalUrl: req.url,
|
|
74
|
+
targetUrl,
|
|
75
|
+
inboundHeaders: new Headers(req.headers),
|
|
76
|
+
serverId: url.searchParams.get("id"),
|
|
77
|
+
};
|
|
78
|
+
// Notifications: allow hooks to observe, then forward
|
|
79
|
+
if (isNotification) {
|
|
80
|
+
const notification = originalRpc;
|
|
81
|
+
for (const h of hooks) {
|
|
82
|
+
if (h.processNotification) {
|
|
83
|
+
try {
|
|
84
|
+
await h.processNotification(notification);
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
if (h.processNotificationError) {
|
|
88
|
+
await h.processNotificationError({ code: 0, message: e?.message || "notification_error" }, notification);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const forwardHeaders = new Headers(req.headers);
|
|
94
|
+
forwardHeaders.delete("content-length");
|
|
95
|
+
forwardHeaders.delete("host");
|
|
96
|
+
forwardHeaders.delete("connection");
|
|
97
|
+
forwardHeaders.delete("transfer-encoding");
|
|
98
|
+
forwardHeaders.delete("content-encoding");
|
|
99
|
+
forwardHeaders.set("content-type", "application/json");
|
|
100
|
+
// Forward original body text instead of reconstructing JSON
|
|
101
|
+
const upstream = await fetch(targetUrl, { method: req.method, headers: forwardHeaders, body: originalBodyText });
|
|
102
|
+
return await wrapUpstreamResponse(upstream);
|
|
103
|
+
}
|
|
104
|
+
// Helper for non-tool methods
|
|
105
|
+
const handleGeneric = async (currentReq, runRequest, runResponse, runError, methodName) => {
|
|
106
|
+
const originalRpcLocal = originalRpc;
|
|
107
|
+
for (const h of hooks) {
|
|
108
|
+
const r = await (runRequest(h, currentReq) || Promise.resolve(null));
|
|
109
|
+
if (!r)
|
|
110
|
+
continue;
|
|
111
|
+
if (r.resultType === "continue") {
|
|
112
|
+
currentReq = r.request;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (r.resultType === "continueAsync") {
|
|
116
|
+
const id = originalRpcLocal?.id ?? 0;
|
|
117
|
+
const envelope = { jsonrpc: "2.0", id, result: r.response };
|
|
118
|
+
return jsonResponse(envelope, 200);
|
|
119
|
+
}
|
|
120
|
+
if (r.resultType === "respond") {
|
|
121
|
+
const id = originalRpcLocal?.id ?? 0;
|
|
122
|
+
const envelope = { jsonrpc: "2.0", id, result: r.response };
|
|
123
|
+
return jsonResponse(envelope, 200);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const forwardHeaders = new Headers(req.headers);
|
|
127
|
+
for (const h of hooks) {
|
|
128
|
+
if (h.prepareUpstreamHeaders) {
|
|
129
|
+
try {
|
|
130
|
+
await h.prepareUpstreamHeaders(forwardHeaders, req, extra);
|
|
131
|
+
}
|
|
132
|
+
catch { }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
forwardHeaders.delete("content-length");
|
|
136
|
+
forwardHeaders.delete("host");
|
|
137
|
+
forwardHeaders.delete("connection");
|
|
138
|
+
forwardHeaders.delete("transfer-encoding");
|
|
139
|
+
forwardHeaders.delete("content-encoding");
|
|
140
|
+
forwardHeaders.set("content-type", "application/json");
|
|
141
|
+
let upstream;
|
|
142
|
+
try {
|
|
143
|
+
// Check if hooks modified the request - if so, reconstruct body
|
|
144
|
+
const hasModifications = currentReq !== originalRpcLocal;
|
|
145
|
+
if (hasModifications) {
|
|
146
|
+
// Hooks modified the request, reconstruct body
|
|
147
|
+
upstream = await fetch(targetUrl, {
|
|
148
|
+
method: req.method,
|
|
149
|
+
headers: forwardHeaders,
|
|
150
|
+
body: JSON.stringify({
|
|
151
|
+
...originalRpcLocal,
|
|
152
|
+
method: methodName,
|
|
153
|
+
params: currentReq?.params ?? originalRpcLocal["params"]
|
|
154
|
+
}),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// No modifications, forward original body
|
|
159
|
+
upstream = await fetch(targetUrl, {
|
|
160
|
+
method: req.method,
|
|
161
|
+
headers: forwardHeaders,
|
|
162
|
+
body: originalBodyText,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
for (const h of hooks.slice().reverse()) {
|
|
168
|
+
const rr = await (runError(h, { code: 0, message: e?.message || "upstream_error" }, currentReq) || Promise.resolve(null));
|
|
169
|
+
if (rr && rr.resultType === "respond") {
|
|
170
|
+
const id = originalRpcLocal?.id ?? 0;
|
|
171
|
+
const envelope = { jsonrpc: "2.0", id, result: rr.response };
|
|
172
|
+
return jsonResponse(envelope, 200);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return jsonResponse({ jsonrpc: "2.0", id: originalRpcLocal?.id ?? 0, error: { code: -32000, message: "Upstream fetch failed" } }, 502);
|
|
176
|
+
}
|
|
177
|
+
const contentType = upstream.headers.get("content-type") || "";
|
|
178
|
+
const isJson = contentType.includes("application/json");
|
|
179
|
+
const isStreaming = contentType.includes("text/event-stream");
|
|
180
|
+
// Clone response before consuming body to avoid "Response body object should not be disturbed or locked" error
|
|
181
|
+
const clonedUpstream = upstream.clone();
|
|
182
|
+
let data;
|
|
183
|
+
if (isStreaming) {
|
|
184
|
+
let text = null;
|
|
185
|
+
try {
|
|
186
|
+
text = await upstream.text();
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
const dataLines = text.split('\n').filter(line => line.startsWith('data: ')).map(line => line.substring(6));
|
|
193
|
+
if (dataLines.length === 0) {
|
|
194
|
+
data = JSON.parse(text);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const lastMessage = dataLines[dataLines.length - 1];
|
|
198
|
+
data = JSON.parse(lastMessage);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (isJson) {
|
|
206
|
+
try {
|
|
207
|
+
data = await upstream.json();
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
return await wrapUpstreamResponse(upstream);
|
|
215
|
+
}
|
|
216
|
+
const maybeRpc = data;
|
|
217
|
+
if (maybeRpc && typeof maybeRpc === "object" && "jsonrpc" in maybeRpc) {
|
|
218
|
+
if ("error" in maybeRpc) {
|
|
219
|
+
for (const h of hooks.slice().reverse()) {
|
|
220
|
+
const rr = await (runError(h, { code: maybeRpc.error?.code ?? -32000, message: maybeRpc.error?.message ?? "error" }, currentReq) || Promise.resolve(null));
|
|
221
|
+
if (rr && rr.resultType === "respond") {
|
|
222
|
+
const id = originalRpcLocal?.id ?? 0;
|
|
223
|
+
const envelope = { jsonrpc: "2.0", id, result: rr.response };
|
|
224
|
+
return jsonResponse(envelope, 200);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
228
|
+
}
|
|
229
|
+
if ("result" in maybeRpc) {
|
|
230
|
+
let currentRes = (maybeRpc["result"] ?? null);
|
|
231
|
+
for (const h of hooks.slice().reverse()) {
|
|
232
|
+
const r = await (runResponse(h, currentRes, currentReq) || Promise.resolve(null));
|
|
233
|
+
if (r && r.resultType === "continue") {
|
|
234
|
+
currentRes = r.response;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const id = originalRpcLocal?.id ?? 0;
|
|
239
|
+
const envelope = { jsonrpc: "2.0", id, result: currentRes };
|
|
240
|
+
const headers = new Headers(upstream.headers);
|
|
241
|
+
headers.delete("content-encoding");
|
|
242
|
+
headers.delete("content-length");
|
|
243
|
+
headers.delete("transfer-encoding");
|
|
244
|
+
headers.set("content-type", "application/json");
|
|
245
|
+
return new Response(JSON.stringify(envelope), { status: upstream.status, statusText: upstream.statusText, headers });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
249
|
+
};
|
|
250
|
+
switch (method) {
|
|
251
|
+
case "tools/call": {
|
|
252
|
+
// Specialized tools/call handler with retry support
|
|
253
|
+
let currentReq = originalRpc;
|
|
254
|
+
let attempts = 0;
|
|
255
|
+
const maxRetries = 1;
|
|
256
|
+
// Track hook response retries separately to prevent infinite loops
|
|
257
|
+
// This counter is independent of attempts since hook responses don't consume upstream requests
|
|
258
|
+
let hookResponseRetries = 0;
|
|
259
|
+
const maxHookResponseRetries = 10; // Prevent infinite loops from hook responses
|
|
260
|
+
while (true) {
|
|
261
|
+
// Call request hooks on each iteration (including retries)
|
|
262
|
+
// This allows hooks to intercept retries before the fetch happens
|
|
263
|
+
let hookResponse = null;
|
|
264
|
+
for (const h of hooks) {
|
|
265
|
+
if (!h.processCallToolRequest)
|
|
266
|
+
continue;
|
|
267
|
+
const r = await h.processCallToolRequest(currentReq, extra);
|
|
268
|
+
if (r.resultType === "continue") {
|
|
269
|
+
currentReq = r.request;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (r.resultType === "continueAsync") {
|
|
273
|
+
const id = originalRpc?.id ?? 0;
|
|
274
|
+
const envelope = { jsonrpc: "2.0", id, result: r.response };
|
|
275
|
+
return jsonResponse(envelope, 200);
|
|
276
|
+
}
|
|
277
|
+
if (r.resultType === "respond") {
|
|
278
|
+
hookResponse = r.response;
|
|
279
|
+
break; // Stop processing request hooks, but we'll process response hooks below
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// If a hook returned a response, process it through response hooks before returning
|
|
283
|
+
if (hookResponse) {
|
|
284
|
+
let currentRes = hookResponse;
|
|
285
|
+
let requestedRetry = null;
|
|
286
|
+
for (const h of hooks.slice().reverse()) {
|
|
287
|
+
if (!h.processCallToolResult)
|
|
288
|
+
continue;
|
|
289
|
+
const r = await h.processCallToolResult(currentRes, currentReq, extra);
|
|
290
|
+
if (r.resultType === "continue") {
|
|
291
|
+
currentRes = r.response;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (r?.resultType === "retry") {
|
|
295
|
+
// If a response hook requests retry, track it and check retry limit
|
|
296
|
+
requestedRetry = { request: r.request };
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
if (r?.resultType === "abort") {
|
|
300
|
+
const rr = r;
|
|
301
|
+
return jsonResponse({ error: rr.reason, body: rr.body }, 400);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// If retry was requested, check retry limit before continuing
|
|
305
|
+
// Note: We don't increment attempts here because no upstream request was made.
|
|
306
|
+
// The attempts counter should only track actual upstream requests, not hook responses.
|
|
307
|
+
// We use a separate counter for hook response retries to prevent infinite loops.
|
|
308
|
+
if (requestedRetry) {
|
|
309
|
+
if (hookResponseRetries < maxHookResponseRetries) {
|
|
310
|
+
hookResponseRetries++;
|
|
311
|
+
currentReq = requestedRetry.request;
|
|
312
|
+
continue; // Retry the request (without incrementing attempts)
|
|
313
|
+
}
|
|
314
|
+
// Max hook response retries exceeded, return the current response (fall through)
|
|
315
|
+
}
|
|
316
|
+
// Return the response (either no retry requested, or retry limit exceeded)
|
|
317
|
+
const id = originalRpc?.id ?? 0;
|
|
318
|
+
const envelope = { jsonrpc: "2.0", id, result: currentRes };
|
|
319
|
+
return jsonResponse(envelope, 200);
|
|
320
|
+
}
|
|
321
|
+
const forwardHeaders = new Headers(req.headers);
|
|
322
|
+
for (const h of hooks) {
|
|
323
|
+
if (h.prepareUpstreamHeaders) {
|
|
324
|
+
try {
|
|
325
|
+
await h.prepareUpstreamHeaders(forwardHeaders, req, extra);
|
|
326
|
+
}
|
|
327
|
+
catch { }
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
forwardHeaders.delete("content-length");
|
|
331
|
+
forwardHeaders.delete("host");
|
|
332
|
+
forwardHeaders.delete("connection");
|
|
333
|
+
forwardHeaders.delete("transfer-encoding");
|
|
334
|
+
forwardHeaders.delete("content-encoding");
|
|
335
|
+
forwardHeaders.set("content-type", "application/json");
|
|
336
|
+
// Check if hooks modified the request - if so, reconstruct body
|
|
337
|
+
const hasModifications = currentReq !== originalRpc;
|
|
338
|
+
let upstream;
|
|
339
|
+
if (hasModifications) {
|
|
340
|
+
// Hooks modified the request, reconstruct body
|
|
341
|
+
upstream = await fetch(targetUrl, {
|
|
342
|
+
method: req.method,
|
|
343
|
+
headers: forwardHeaders,
|
|
344
|
+
body: JSON.stringify({
|
|
345
|
+
...originalRpc,
|
|
346
|
+
method: "tools/call",
|
|
347
|
+
params: currentReq.params ?? originalRpc["params"]
|
|
348
|
+
}),
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
// No modifications, forward original body
|
|
353
|
+
upstream = await fetch(targetUrl, {
|
|
354
|
+
method: req.method,
|
|
355
|
+
headers: forwardHeaders,
|
|
356
|
+
body: originalBodyText,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
const contentType = upstream.headers.get("content-type") || "";
|
|
360
|
+
const isJson = contentType.includes("application/json");
|
|
361
|
+
const isStreaming = contentType.includes("text/event-stream");
|
|
362
|
+
// Clone response before consuming body to avoid "Response body object should not be disturbed or locked" error
|
|
363
|
+
const clonedUpstream = upstream.clone();
|
|
364
|
+
let data;
|
|
365
|
+
if (isStreaming) {
|
|
366
|
+
let text = null;
|
|
367
|
+
try {
|
|
368
|
+
text = await upstream.text();
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
const dataLines = text.split('\n').filter(line => line.startsWith('data: ')).map(line => line.substring(6));
|
|
375
|
+
if (dataLines.length === 0) {
|
|
376
|
+
data = JSON.parse(text);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
const lastMessage = dataLines[dataLines.length - 1];
|
|
380
|
+
data = JSON.parse(lastMessage);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else if (isJson) {
|
|
388
|
+
try {
|
|
389
|
+
data = await upstream.json();
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
return await wrapUpstreamResponse(upstream);
|
|
397
|
+
}
|
|
398
|
+
const maybeRpc = data;
|
|
399
|
+
if (maybeRpc && typeof maybeRpc === "object" && "jsonrpc" in maybeRpc && "result" in maybeRpc) {
|
|
400
|
+
let currentRes = (maybeRpc["result"] ?? null);
|
|
401
|
+
let requestedRetry = null;
|
|
402
|
+
for (const h of hooks.slice().reverse()) {
|
|
403
|
+
if (!h.processCallToolResult)
|
|
404
|
+
continue;
|
|
405
|
+
const r = await h.processCallToolResult(currentRes, currentReq, extra);
|
|
406
|
+
if (r.resultType === "continue") {
|
|
407
|
+
currentRes = r.response;
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
if (r?.resultType === "retry") {
|
|
411
|
+
requestedRetry = { request: r.request };
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
if (r?.resultType === "abort") {
|
|
415
|
+
const rr = r;
|
|
416
|
+
return jsonResponse({ error: rr.reason, body: rr.body }, 400);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (requestedRetry && attempts < maxRetries) {
|
|
420
|
+
attempts++;
|
|
421
|
+
currentReq = requestedRetry.request;
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
const id = originalRpc?.id ?? 0;
|
|
425
|
+
const envelope = { jsonrpc: "2.0", id, result: currentRes };
|
|
426
|
+
const headers = new Headers(upstream.headers);
|
|
427
|
+
headers.delete("content-encoding");
|
|
428
|
+
headers.delete("content-length");
|
|
429
|
+
headers.delete("transfer-encoding");
|
|
430
|
+
headers.set("content-type", "application/json");
|
|
431
|
+
return new Response(JSON.stringify(envelope), { status: upstream.status, statusText: upstream.statusText, headers });
|
|
432
|
+
}
|
|
433
|
+
// If upstream returns bare result-like, wrap it
|
|
434
|
+
if (maybeRpc && typeof maybeRpc === "object" && !("jsonrpc" in maybeRpc) && ("content" in maybeRpc || "isError" in maybeRpc)) {
|
|
435
|
+
let currentRes = maybeRpc;
|
|
436
|
+
let requestedRetry = null;
|
|
437
|
+
for (const h of hooks.slice().reverse()) {
|
|
438
|
+
if (!h.processCallToolResult)
|
|
439
|
+
continue;
|
|
440
|
+
const r = await h.processCallToolResult(currentRes, currentReq, extra);
|
|
441
|
+
if (r.resultType === "continue") {
|
|
442
|
+
currentRes = r.response;
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
if (r?.resultType === "retry") {
|
|
446
|
+
requestedRetry = { request: r.request };
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
if (r?.resultType === "abort") {
|
|
450
|
+
const rr = r;
|
|
451
|
+
return jsonResponse({ error: rr.reason, body: rr.body }, 400);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (requestedRetry && attempts < maxRetries) {
|
|
455
|
+
attempts++;
|
|
456
|
+
currentReq = requestedRetry.request;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
const id = originalRpc?.id ?? 0;
|
|
460
|
+
const envelope = { jsonrpc: "2.0", id, result: currentRes };
|
|
461
|
+
const headers = new Headers(upstream.headers);
|
|
462
|
+
headers.delete("content-encoding");
|
|
463
|
+
headers.delete("content-length");
|
|
464
|
+
headers.delete("transfer-encoding");
|
|
465
|
+
headers.set("content-type", "application/json");
|
|
466
|
+
return new Response(JSON.stringify(envelope), { status: upstream.status, statusText: upstream.statusText, headers });
|
|
467
|
+
}
|
|
468
|
+
// Fallback
|
|
469
|
+
return await wrapUpstreamResponse(clonedUpstream);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
case "initialize":
|
|
473
|
+
return handleGeneric(originalRpc, (h, reqObj) => h.processInitializeRequest ? h.processInitializeRequest(reqObj, extra) : null, (h, res, reqObj) => h.processInitializeResult ? h.processInitializeResult(res, reqObj, extra) : null, (h, err, reqObj) => h.processInitializeError ? h.processInitializeError(err, reqObj, extra) : null, "initialize");
|
|
474
|
+
case "tools/list":
|
|
475
|
+
return handleGeneric(originalRpc, (h, reqObj) => h.processListToolsRequest ? h.processListToolsRequest(reqObj, extra) : null, (h, res, reqObj) => h.processListToolsResult ? h.processListToolsResult(res, reqObj, extra) : null, (h, err, reqObj) => h.processListToolsError ? h.processListToolsError(err, reqObj, extra) : null, "tools/list");
|
|
476
|
+
case "prompts/list":
|
|
477
|
+
return handleGeneric(originalRpc, (h, reqObj) => h.processListPromptsRequest ? h.processListPromptsRequest(reqObj, extra) : null, (h, res, reqObj) => h.processListPromptsResult ? h.processListPromptsResult(res, reqObj, extra) : null, (h, err, reqObj) => h.processListPromptsError ? h.processListPromptsError(err, reqObj, extra) : null, "prompts/list");
|
|
478
|
+
case "resources/list":
|
|
479
|
+
return handleGeneric(originalRpc, (h, reqObj) => h.processListResourcesRequest ? h.processListResourcesRequest(reqObj, extra) : null, (h, res, reqObj) => h.processListResourcesResult ? h.processListResourcesResult(res, reqObj, extra) : null, (h, err, reqObj) => h.processListResourcesError ? h.processListResourcesError(err, reqObj, extra) : null, "resources/list");
|
|
480
|
+
case "resources/templates/list":
|
|
481
|
+
return handleGeneric(originalRpc, (h, reqObj) => h.processListResourceTemplatesRequest ? h.processListResourceTemplatesRequest(reqObj, extra) : null, (h, res, reqObj) => h.processListResourceTemplatesResult ? h.processListResourceTemplatesResult(res, reqObj, extra) : null, (h, err, reqObj) => h.processListResourceTemplatesError ? h.processListResourceTemplatesError(err, reqObj, extra) : null, "resources/templates/list");
|
|
482
|
+
case "resources/read":
|
|
483
|
+
return handleGeneric(originalRpc, (h, reqObj) => h.processReadResourceRequest ? h.processReadResourceRequest(reqObj, extra) : null, (h, res, reqObj) => h.processReadResourceResult ? h.processReadResourceResult(res, reqObj, extra) : null, (h, err, reqObj) => h.processReadResourceError ? h.processReadResourceError(err, reqObj, extra) : null, "resources/read");
|
|
484
|
+
default:
|
|
485
|
+
return handleGeneric(originalRpc, (h, reqObj) => h.processOtherRequest ? h.processOtherRequest(reqObj, extra) : null, (h, res, reqObj) => h.processOtherResult ? h.processOtherResult(res, reqObj, extra) : null, (h, err, reqObj) => h.processOtherError ? h.processOtherError(err, reqObj, extra) : null, method);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handler/proxy/index.ts"],"names":[],"mappings":"AAqBA,SAAS,YAAY,CAAC,GAAY,EAAE,MAAM,GAAG,GAAG;IAC5C,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QACrC,MAAM;QACN,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAClD,CAAC,CAAC;AACP,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,QAAkB;IAClD,uEAAuE;IACvE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,oFAAoF;IACpF,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACnC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACjC,OAAO,CAAC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,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EACtG,gBAAgB,CACnB,CAAC;YACN;gBACI,OAAO,aAAa,CAChB,WAAyB,EACzB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAClF,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAC1F,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EACxF,MAAM,CACT,CAAC;QACV,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { createMcpHandler as baseCreateMcpHandler } from "mcp-handler";
|
|
3
|
+
type InnerServerOptions = NonNullable<Parameters<typeof baseCreateMcpHandler>[1]>;
|
|
4
|
+
type Config = NonNullable<Parameters<typeof baseCreateMcpHandler>[2]>;
|
|
5
|
+
/** A plugin takes a server and returns an augmented server type. */
|
|
6
|
+
export type ServerPlugin<S extends McpServer = McpServer, R extends McpServer = S> = (server: S) => R;
|
|
7
|
+
/** Apply a tuple of plugins to a server type (left-to-right) for typing. */
|
|
8
|
+
export type ApplyPlugins<S extends McpServer, W extends readonly ServerPlugin[]> = W extends readonly [] ? S : W extends readonly [infer F, ...infer R] ? F extends ServerPlugin<infer _In, infer Out> ? ApplyPlugins<Out, Extract<R, readonly ServerPlugin[]>> : S : S;
|
|
9
|
+
/** Preserve tuple info so TS can infer exact augmented type. */
|
|
10
|
+
export declare function makePlugins<W extends readonly ServerPlugin[]>(...plugins: W): W;
|
|
11
|
+
/** Compose to a single plugin (right-to-left) if you like function style. */
|
|
12
|
+
export declare function composePlugins<W extends readonly ServerPlugin[]>(...plugins: W): <S extends McpServer>(server: S) => ApplyPlugins<S, W>;
|
|
13
|
+
export type ServerOptions<W extends readonly ServerPlugin[] = []> = InnerServerOptions & {
|
|
14
|
+
/** Dynamically augment the McpServer instance with your plugins. */
|
|
15
|
+
plugins?: W;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* createMcpHandlerWithPlugins
|
|
19
|
+
* Wraps your existing handler to:
|
|
20
|
+
* - apply plugins at runtime (mutating/augmenting the same server instance)
|
|
21
|
+
* - thread plugin types to the `initializeServer` callback (no casts needed)
|
|
22
|
+
*/
|
|
23
|
+
export default function createMcpHandler<W extends readonly ServerPlugin[] = []>(initializeServer: ((server: ApplyPlugins<McpServer, W>) => Promise<void>) | ((server: ApplyPlugins<McpServer, W>) => void), serverOptions?: ServerOptions<W>, config?: Config): (request: Request) => Promise<Response>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/handler/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEvE,KAAK,kBAAkB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,KAAK,MAAM,GAAG,WAAW,CAAC,UAA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YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GACvD,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,EAClD,aAAa,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,EAChC,MAAM,CAAC,EAAE,MAAM,GACd,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAsBzC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createMcpHandler as baseCreateMcpHandler } from "mcp-handler";
|
|
2
|
+
/** Preserve tuple info so TS can infer exact augmented type. */
|
|
3
|
+
export function makePlugins(...plugins) {
|
|
4
|
+
return plugins;
|
|
5
|
+
}
|
|
6
|
+
/** Compose to a single plugin (right-to-left) if you like function style. */
|
|
7
|
+
export function composePlugins(...plugins) {
|
|
8
|
+
return (server) => {
|
|
9
|
+
let result = server;
|
|
10
|
+
for (let i = plugins.length - 1; i >= 0; i--) {
|
|
11
|
+
result = plugins[i]?.(result);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* createMcpHandlerWithPlugins
|
|
18
|
+
* Wraps your existing handler to:
|
|
19
|
+
* - apply plugins at runtime (mutating/augmenting the same server instance)
|
|
20
|
+
* - thread plugin types to the `initializeServer` callback (no casts needed)
|
|
21
|
+
*/
|
|
22
|
+
export default function createMcpHandler(initializeServer, serverOptions, config) {
|
|
23
|
+
return baseCreateMcpHandler(async (server) => {
|
|
24
|
+
// Apply plugins in-place (support plugins that return same instance or a new one)
|
|
25
|
+
const ws = (serverOptions?.plugins ?? []);
|
|
26
|
+
let augmented = server;
|
|
27
|
+
for (const w of ws) {
|
|
28
|
+
const out = w(augmented);
|
|
29
|
+
// If plugin returns a new object, keep it; otherwise keep the original.
|
|
30
|
+
augmented = (out ?? augmented);
|
|
31
|
+
}
|
|
32
|
+
// Call the user's initializer with the *augmented* type
|
|
33
|
+
await initializeServer(augmented);
|
|
34
|
+
},
|
|
35
|
+
// Pass through options and config unchanged
|
|
36
|
+
serverOptions, config);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handler/server/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA0BvE,gEAAgE;AAChE,MAAM,UAAU,WAAW,CACzB,GAAG,OAAU;IAEb,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAC5B,GAAG,OAAU;IAEb,OAAO,CAAsB,MAAS,EAAsB,EAAE;QAC5D,IAAI,MAAM,GAAY,MAAM,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAmB,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,MAA4B,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC;AAUD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAGtC,gBAEkD,EAClD,aAAgC,EAChC,MAAe;IAGf,OAAO,oBAAoB,CACzB,KAAK,EAAE,MAAiB,EAAE,EAAE;QAC1B,kFAAkF;QAClF,MAAM,EAAE,GAAG,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,CAA4B,CAAC;QACrE,IAAI,SAAS,GAAc,MAAM,CAAC;QAClC,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,CAAC,CAAC,SAAiC,CAAC,CAAC;YACjD,wEAAwE;YACxE,SAAS,GAAG,CAAC,GAAG,IAAI,SAAS,CAAc,CAAC;QAC9C,CAAC;QAED,wDAAwD;QACxD,MAAO,gBAA+D,CACpE,SAAuC,CACxC,CAAC;IACJ,CAAC;IACD,4CAA4C;IAC5C,aAAmC,EACnC,MAAM,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type HostingPlatform = 'Vercel' | 'Netlify' | 'Cloudflare Pages' | 'Cloudflare Workers' | 'Railway' | 'Render' | 'Heroku' | 'Fly.io' | 'AWS Lambda' | 'AWS Elastic Beanstalk' | 'AWS Amplify' | 'Azure Functions' | 'GCP Cloud Functions' | 'GCP Cloud Run' | 'Deno Deploy' | 'Supabase Edge Functions' | 'Bun.sh' | 'GitHub Pages' | 'GitLab Pages' | 'DigitalOcean App' | 'Kubernetes' | 'Docker' | 'Edge Runtime' | 'Bare‑metal' | 'Unknown';
|
|
2
|
+
export type RuntimeEnvironment = 'Node.js' | 'Bun' | 'Deno' | 'Edge' | 'Unknown';
|
|
3
|
+
export interface RuntimeInfo {
|
|
4
|
+
name: RuntimeEnvironment;
|
|
5
|
+
version?: string;
|
|
6
|
+
isEdge: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PlatformInfo {
|
|
9
|
+
platform: HostingPlatform;
|
|
10
|
+
runtime: RuntimeInfo;
|
|
11
|
+
signatureEnv: Record<string, string>;
|
|
12
|
+
urls: string[];
|
|
13
|
+
isEdgeRuntime: boolean;
|
|
14
|
+
isContainer: boolean;
|
|
15
|
+
isCloudVM: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function detectPlatform(env?: NodeJS.ProcessEnv): Promise<HostingPlatform>;
|
|
18
|
+
export declare function generatePotentialUrls(env?: NodeJS.ProcessEnv): string[];
|
|
19
|
+
export declare function gatherPlatformInfo(env?: NodeJS.ProcessEnv): Promise<PlatformInfo>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if the current environment is a specific platform
|
|
22
|
+
*/
|
|
23
|
+
export declare function isPlatform(targetPlatform: HostingPlatform, env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Get a summary of the current runtime environment
|
|
26
|
+
*/
|
|
27
|
+
export declare function getRuntimeSummary(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Clear the platform detection cache (useful for testing)
|
|
30
|
+
*/
|
|
31
|
+
export declare function clearDetectionCache(): void;
|
|
32
|
+
//# sourceMappingURL=platform-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-detection.d.ts","sourceRoot":"","sources":["../../../src/handler/server/platform-detection.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,eAAe,GACvB,QAAQ,GAAG,SAAS,GAAG,kBAAkB,GAAG,oBAAoB,GAChE,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAC1C,YAAY,GAAG,uBAAuB,GAAG,aAAa,GAAG,iBAAiB,GAC1E,qBAAqB,GAAG,eAAe,GACvC,aAAa,GAAG,yBAAyB,GAAG,QAAQ,GACpD,cAAc,GAAG,cAAc,GAAG,kBAAkB,GACpD,YAAY,GAAG,QAAQ,GAAG,cAAc,GACxC,YAAY,GAAG,SAAS,CAAC;AAE7B,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AAcD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,WAAW,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;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