@stigg/typescript-mcp 0.1.0-alpha.8
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/LICENSE +201 -0
- package/README.md +99 -0
- package/auth.d.mts +6 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +6 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +22 -0
- package/auth.js.map +1 -0
- package/auth.mjs +17 -0
- package/auth.mjs.map +1 -0
- package/code-tool-types.d.mts +14 -0
- package/code-tool-types.d.mts.map +1 -0
- package/code-tool-types.d.ts +14 -0
- package/code-tool-types.d.ts.map +1 -0
- package/code-tool-types.js +4 -0
- package/code-tool-types.js.map +1 -0
- package/code-tool-types.mjs +3 -0
- package/code-tool-types.mjs.map +1 -0
- package/code-tool.d.mts +15 -0
- package/code-tool.d.mts.map +1 -0
- package/code-tool.d.ts +15 -0
- package/code-tool.d.ts.map +1 -0
- package/code-tool.js +108 -0
- package/code-tool.js.map +1 -0
- package/code-tool.mjs +105 -0
- package/code-tool.mjs.map +1 -0
- package/docs-search-tool.d.mts +57 -0
- package/docs-search-tool.d.mts.map +1 -0
- package/docs-search-tool.d.ts +57 -0
- package/docs-search-tool.d.ts.map +1 -0
- package/docs-search-tool.js +55 -0
- package/docs-search-tool.js.map +1 -0
- package/docs-search-tool.mjs +51 -0
- package/docs-search-tool.mjs.map +1 -0
- package/http.d.mts +14 -0
- package/http.d.mts.map +1 -0
- package/http.d.ts +14 -0
- package/http.d.ts.map +1 -0
- package/http.js +107 -0
- package/http.js.map +1 -0
- package/http.mjs +99 -0
- package/http.mjs.map +1 -0
- package/index.d.mts +3 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +59 -0
- package/index.js.map +1 -0
- package/index.mjs +57 -0
- package/index.mjs.map +1 -0
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +419 -0
- package/methods.js.map +1 -0
- package/methods.mjs +415 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +16 -0
- package/options.d.mts.map +1 -0
- package/options.d.ts +16 -0
- package/options.d.ts.map +1 -0
- package/options.js +99 -0
- package/options.js.map +1 -0
- package/options.mjs +92 -0
- package/options.mjs.map +1 -0
- package/package.json +185 -0
- package/server.d.mts +29 -0
- package/server.d.mts.map +1 -0
- package/server.d.ts +29 -0
- package/server.d.ts.map +1 -0
- package/server.js +143 -0
- package/server.js.map +1 -0
- package/server.mjs +133 -0
- package/server.mjs.map +1 -0
- package/src/auth.ts +25 -0
- package/src/code-tool-types.ts +16 -0
- package/src/code-tool.ts +139 -0
- package/src/docs-search-tool.ts +68 -0
- package/src/http.ts +138 -0
- package/src/index.ts +65 -0
- package/src/methods.ts +440 -0
- package/src/options.ts +129 -0
- package/src/server.ts +181 -0
- package/src/stdio.ts +13 -0
- package/src/tsconfig.json +11 -0
- package/src/types.ts +123 -0
- package/src/util.ts +25 -0
- package/stdio.d.mts +3 -0
- package/stdio.d.mts.map +1 -0
- package/stdio.d.ts +3 -0
- package/stdio.d.ts.map +1 -0
- package/stdio.js +14 -0
- package/stdio.js.map +1 -0
- package/stdio.mjs +10 -0
- package/stdio.mjs.map +1 -0
- package/types.d.mts +59 -0
- package/types.d.mts.map +1 -0
- package/types.d.ts +59 -0
- package/types.d.ts.map +1 -0
- package/types.js +58 -0
- package/types.js.map +1 -0
- package/types.mjs +53 -0
- package/types.mjs.map +1 -0
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
package/code-tool.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { asErrorResult, asTextContentResult, } from "./types.mjs";
|
|
3
|
+
import { readEnv, requireValue } from "./util.mjs";
|
|
4
|
+
const prompt = `Runs JavaScript code to interact with the Stigg API.
|
|
5
|
+
|
|
6
|
+
You are a skilled programmer writing code to interface with the service.
|
|
7
|
+
Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
|
|
8
|
+
For example:
|
|
9
|
+
|
|
10
|
+
\`\`\`
|
|
11
|
+
async function run(client) {
|
|
12
|
+
const customerResponse = await client.v1.customers.retrieve('REPLACE_ME');
|
|
13
|
+
|
|
14
|
+
console.log(customerResponse.data);
|
|
15
|
+
}
|
|
16
|
+
\`\`\`
|
|
17
|
+
|
|
18
|
+
You will be returned anything that your function returns, plus the results of any console.log statements.
|
|
19
|
+
Do not add try-catch blocks for single API calls. The tool will handle errors for you.
|
|
20
|
+
Do not add comments unless necessary for generating better code.
|
|
21
|
+
Code will run in a container, and cannot interact with the network outside of the given SDK client.
|
|
22
|
+
Variables will not persist between calls, so make sure to return or log any data you might need later.`;
|
|
23
|
+
/**
|
|
24
|
+
* A tool that runs code against a copy of the SDK.
|
|
25
|
+
*
|
|
26
|
+
* Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
|
|
27
|
+
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
28
|
+
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
29
|
+
*
|
|
30
|
+
* @param endpoints - The endpoints to include in the list.
|
|
31
|
+
*/
|
|
32
|
+
export function codeTool({ blockedMethods }) {
|
|
33
|
+
const metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
34
|
+
const tool = {
|
|
35
|
+
name: 'execute',
|
|
36
|
+
description: prompt,
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
code: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'Code to execute.',
|
|
43
|
+
},
|
|
44
|
+
intent: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Task you are trying to perform. Used for improving the service.',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ['code'],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const handler = async ({ reqContext, args, }) => {
|
|
53
|
+
const code = args.code;
|
|
54
|
+
const intent = args.intent;
|
|
55
|
+
const client = reqContext.client;
|
|
56
|
+
// Do very basic blocking of code that includes forbidden method names.
|
|
57
|
+
//
|
|
58
|
+
// WARNING: This is not secure against obfuscation and other evasion methods. If
|
|
59
|
+
// stronger security blocks are required, then these should be enforced in the downstream
|
|
60
|
+
// API (e.g., by having users call the MCP server with API keys with limited permissions).
|
|
61
|
+
if (blockedMethods) {
|
|
62
|
+
const blockedMatches = blockedMethods.filter((method) => code.includes(method.fullyQualifiedName));
|
|
63
|
+
if (blockedMatches.length > 0) {
|
|
64
|
+
return asErrorResult(`The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches
|
|
65
|
+
.map((m) => m.fullyQualifiedName)
|
|
66
|
+
.join(', ')}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
|
|
70
|
+
// Setting a Stainless API key authenticates requests to the code tool endpoint.
|
|
71
|
+
const res = await fetch(codeModeEndpoint, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
client_envs: JSON.stringify({
|
|
77
|
+
STIGG_API_KEY: requireValue(readEnv('STIGG_API_KEY') ?? client.apiKey, 'set STIGG_API_KEY environment variable or provide apiKey client option'),
|
|
78
|
+
STIGG_BASE_URL: readEnv('STIGG_BASE_URL') ?? client.baseURL ?? undefined,
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
body: JSON.stringify({
|
|
82
|
+
project_name: 'stigg',
|
|
83
|
+
code,
|
|
84
|
+
intent,
|
|
85
|
+
client_opts: {},
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
if (!res.ok) {
|
|
89
|
+
throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
|
|
90
|
+
}
|
|
91
|
+
const { is_error, result, log_lines, err_lines } = (await res.json());
|
|
92
|
+
const hasLogs = log_lines.length > 0 || err_lines.length > 0;
|
|
93
|
+
const output = {
|
|
94
|
+
result,
|
|
95
|
+
...(log_lines.length > 0 && { log_lines }),
|
|
96
|
+
...(err_lines.length > 0 && { err_lines }),
|
|
97
|
+
};
|
|
98
|
+
if (is_error) {
|
|
99
|
+
return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
|
|
100
|
+
}
|
|
101
|
+
return asTextContentResult(output);
|
|
102
|
+
};
|
|
103
|
+
return { metadata, tool, handler };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=code-tool.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAKL,aAAa,EACb,mBAAmB,GACpB;OAEM,EAAE,OAAO,EAAE,YAAY,EAAE;AAIhC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;uGAkBwF,CAAC;AAExG;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAE,cAAc,EAA+C;IACtF,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE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IACrC,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Metadata, McpRequestContext } from "./types.mjs";
|
|
2
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
export declare const metadata: Metadata;
|
|
4
|
+
export declare const tool: Tool;
|
|
5
|
+
export declare const handler: ({ reqContext, args, }: {
|
|
6
|
+
reqContext: McpRequestContext;
|
|
7
|
+
args: Record<string, unknown> | undefined;
|
|
8
|
+
}) => Promise<import("./types").ToolCallResult>;
|
|
9
|
+
declare const _default: {
|
|
10
|
+
metadata: Metadata;
|
|
11
|
+
tool: {
|
|
12
|
+
inputSchema: {
|
|
13
|
+
[x: string]: unknown;
|
|
14
|
+
type: "object";
|
|
15
|
+
properties?: {
|
|
16
|
+
[x: string]: object;
|
|
17
|
+
} | undefined;
|
|
18
|
+
required?: string[] | undefined;
|
|
19
|
+
};
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string | undefined;
|
|
22
|
+
outputSchema?: {
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
type: "object";
|
|
25
|
+
properties?: {
|
|
26
|
+
[x: string]: object;
|
|
27
|
+
} | undefined;
|
|
28
|
+
required?: string[] | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
annotations?: {
|
|
31
|
+
title?: string | undefined;
|
|
32
|
+
readOnlyHint?: boolean | undefined;
|
|
33
|
+
destructiveHint?: boolean | undefined;
|
|
34
|
+
idempotentHint?: boolean | undefined;
|
|
35
|
+
openWorldHint?: boolean | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
execution?: {
|
|
38
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
_meta?: {
|
|
41
|
+
[x: string]: unknown;
|
|
42
|
+
} | undefined;
|
|
43
|
+
icons?: {
|
|
44
|
+
src: string;
|
|
45
|
+
mimeType?: string | undefined;
|
|
46
|
+
sizes?: string[] | undefined;
|
|
47
|
+
theme?: "light" | "dark" | undefined;
|
|
48
|
+
}[] | undefined;
|
|
49
|
+
title?: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
handler: ({ reqContext, args, }: {
|
|
52
|
+
reqContext: McpRequestContext;
|
|
53
|
+
args: Record<string, unknown> | undefined;
|
|
54
|
+
}) => Promise<import("./types").ToolCallResult>;
|
|
55
|
+
};
|
|
56
|
+
export default _default;
|
|
57
|
+
//# sourceMappingURL=docs-search-tool.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search-tool.d.mts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAE,iBAAiB,EAAuB;OACpD,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,uBAG3B;IACD,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,8CAgBA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAnBC;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;KAC3C;;AAkBD,wBAA2C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Metadata, McpRequestContext } from "./types.js";
|
|
2
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
export declare const metadata: Metadata;
|
|
4
|
+
export declare const tool: Tool;
|
|
5
|
+
export declare const handler: ({ reqContext, args, }: {
|
|
6
|
+
reqContext: McpRequestContext;
|
|
7
|
+
args: Record<string, unknown> | undefined;
|
|
8
|
+
}) => Promise<import("./types").ToolCallResult>;
|
|
9
|
+
declare const _default: {
|
|
10
|
+
metadata: Metadata;
|
|
11
|
+
tool: {
|
|
12
|
+
inputSchema: {
|
|
13
|
+
[x: string]: unknown;
|
|
14
|
+
type: "object";
|
|
15
|
+
properties?: {
|
|
16
|
+
[x: string]: object;
|
|
17
|
+
} | undefined;
|
|
18
|
+
required?: string[] | undefined;
|
|
19
|
+
};
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string | undefined;
|
|
22
|
+
outputSchema?: {
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
type: "object";
|
|
25
|
+
properties?: {
|
|
26
|
+
[x: string]: object;
|
|
27
|
+
} | undefined;
|
|
28
|
+
required?: string[] | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
annotations?: {
|
|
31
|
+
title?: string | undefined;
|
|
32
|
+
readOnlyHint?: boolean | undefined;
|
|
33
|
+
destructiveHint?: boolean | undefined;
|
|
34
|
+
idempotentHint?: boolean | undefined;
|
|
35
|
+
openWorldHint?: boolean | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
execution?: {
|
|
38
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
_meta?: {
|
|
41
|
+
[x: string]: unknown;
|
|
42
|
+
} | undefined;
|
|
43
|
+
icons?: {
|
|
44
|
+
src: string;
|
|
45
|
+
mimeType?: string | undefined;
|
|
46
|
+
sizes?: string[] | undefined;
|
|
47
|
+
theme?: "light" | "dark" | undefined;
|
|
48
|
+
}[] | undefined;
|
|
49
|
+
title?: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
handler: ({ reqContext, args, }: {
|
|
52
|
+
reqContext: McpRequestContext;
|
|
53
|
+
args: Record<string, unknown> | undefined;
|
|
54
|
+
}) => Promise<import("./types").ToolCallResult>;
|
|
55
|
+
};
|
|
56
|
+
export default _default;
|
|
57
|
+
//# sourceMappingURL=docs-search-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search-tool.d.ts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAE,iBAAiB,EAAuB;OACpD,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,uBAG3B;IACD,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,8CAgBA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAnBC;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;KAC3C;;AAkBD,wBAA2C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.handler = exports.tool = exports.metadata = void 0;
|
|
5
|
+
const types_1 = require("./types.js");
|
|
6
|
+
exports.metadata = {
|
|
7
|
+
resource: 'all',
|
|
8
|
+
operation: 'read',
|
|
9
|
+
tags: [],
|
|
10
|
+
httpMethod: 'get',
|
|
11
|
+
};
|
|
12
|
+
exports.tool = {
|
|
13
|
+
name: 'search_docs',
|
|
14
|
+
description: 'Search for documentation for how to use the client to interact with the API.',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
query: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The query to search for.',
|
|
21
|
+
},
|
|
22
|
+
language: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'The language for the SDK to search for.',
|
|
25
|
+
enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
|
|
26
|
+
},
|
|
27
|
+
detail: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'The amount of detail to return.',
|
|
30
|
+
enum: ['default', 'verbose'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ['query', 'language'],
|
|
34
|
+
},
|
|
35
|
+
annotations: {
|
|
36
|
+
readOnlyHint: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/stigg/docs/search';
|
|
40
|
+
const handler = async ({ reqContext, args, }) => {
|
|
41
|
+
const body = args;
|
|
42
|
+
const query = new URLSearchParams(body).toString();
|
|
43
|
+
const result = await fetch(`${docsSearchURL}?${query}`, {
|
|
44
|
+
headers: {
|
|
45
|
+
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
if (!result.ok) {
|
|
49
|
+
throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
|
|
50
|
+
}
|
|
51
|
+
return (0, types_1.asTextContentResult)(await result.json());
|
|
52
|
+
};
|
|
53
|
+
exports.handler = handler;
|
|
54
|
+
exports.default = { metadata: exports.metadata, tool: exports.tool, handler: exports.handler };
|
|
55
|
+
//# sourceMappingURL=docs-search-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search-tool.js","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,sCAA2E;AAG9D,QAAA,QAAQ,GAAa;IAChC,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,EAA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QACf,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,yCAAyC,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,2BAAmB,EAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AAtBW,QAAA,OAAO,WAsBlB;AAEF,kBAAe,EAAE,QAAQ,EAAR,gBAAQ,EAAE,IAAI,EAAJ,YAAI,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { asTextContentResult } from "./types.mjs";
|
|
3
|
+
export const metadata = {
|
|
4
|
+
resource: 'all',
|
|
5
|
+
operation: 'read',
|
|
6
|
+
tags: [],
|
|
7
|
+
httpMethod: 'get',
|
|
8
|
+
};
|
|
9
|
+
export const tool = {
|
|
10
|
+
name: 'search_docs',
|
|
11
|
+
description: 'Search for documentation for how to use the client to interact with the API.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
query: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'The query to search for.',
|
|
18
|
+
},
|
|
19
|
+
language: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'The language for the SDK to search for.',
|
|
22
|
+
enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
|
|
23
|
+
},
|
|
24
|
+
detail: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'The amount of detail to return.',
|
|
27
|
+
enum: ['default', 'verbose'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ['query', 'language'],
|
|
31
|
+
},
|
|
32
|
+
annotations: {
|
|
33
|
+
readOnlyHint: true,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/stigg/docs/search';
|
|
37
|
+
export const handler = async ({ reqContext, args, }) => {
|
|
38
|
+
const body = args;
|
|
39
|
+
const query = new URLSearchParams(body).toString();
|
|
40
|
+
const result = await fetch(`${docsSearchURL}?${query}`, {
|
|
41
|
+
headers: {
|
|
42
|
+
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
if (!result.ok) {
|
|
46
|
+
throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
|
|
47
|
+
}
|
|
48
|
+
return asTextContentResult(await result.json());
|
|
49
|
+
};
|
|
50
|
+
export default { metadata, tool, handler };
|
|
51
|
+
//# sourceMappingURL=docs-search-tool.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search-tool.mjs","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAA+B,mBAAmB,EAAE;AAG3D,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,8EAA8E;IAC3F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;gBACtD,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,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import { McpOptions } from "./options.mjs";
|
|
4
|
+
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, debug, }: {
|
|
5
|
+
clientOptions?: ClientOptions;
|
|
6
|
+
mcpOptions: McpOptions;
|
|
7
|
+
debug: boolean;
|
|
8
|
+
}) => express.Express;
|
|
9
|
+
export declare const launchStreamableHTTPServer: ({ mcpOptions, debug, port, }: {
|
|
10
|
+
mcpOptions: McpOptions;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
port: number | string | undefined;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=http.d.mts.map
|
package/http.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,mBAAmB;OAC1C,OAAO,MAAM,SAAS;OAItB,EAAE,UAAU,EAAE;AA0ErB,eAAO,MAAM,iBAAiB,GAAI,uCAI/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,OAAO,CAAC,OAwBX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,8BAI9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAYA,CAAC"}
|
package/http.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClientOptions } from '@stigg/typescript';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import { McpOptions } from "./options.js";
|
|
4
|
+
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, debug, }: {
|
|
5
|
+
clientOptions?: ClientOptions;
|
|
6
|
+
mcpOptions: McpOptions;
|
|
7
|
+
debug: boolean;
|
|
8
|
+
}) => express.Express;
|
|
9
|
+
export declare const launchStreamableHTTPServer: ({ mcpOptions, debug, port, }: {
|
|
10
|
+
mcpOptions: McpOptions;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
port: number | string | undefined;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=http.d.ts.map
|
package/http.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,mBAAmB;OAC1C,OAAO,MAAM,SAAS;OAItB,EAAE,UAAU,EAAE;AA0ErB,eAAO,MAAM,iBAAiB,GAAI,uCAI/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,OAAO,CAAC,OAwBX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,8BAI9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAYA,CAAC"}
|
package/http.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.launchStreamableHTTPServer = exports.streamableHTTPApp = void 0;
|
|
8
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
9
|
+
const express_1 = __importDefault(require("express"));
|
|
10
|
+
const morgan_1 = __importDefault(require("morgan"));
|
|
11
|
+
const morgan_body_1 = __importDefault(require("morgan-body"));
|
|
12
|
+
const auth_1 = require("./auth.js");
|
|
13
|
+
const server_1 = require("./server.js");
|
|
14
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
15
|
+
const stainlessApiKey = (0, auth_1.getStainlessApiKey)(req, mcpOptions);
|
|
16
|
+
const server = await (0, server_1.newMcpServer)(stainlessApiKey);
|
|
17
|
+
try {
|
|
18
|
+
const authOptions = (0, auth_1.parseClientAuthHeaders)(req, false);
|
|
19
|
+
await (0, server_1.initMcpServer)({
|
|
20
|
+
server: server,
|
|
21
|
+
mcpOptions: mcpOptions,
|
|
22
|
+
clientOptions: {
|
|
23
|
+
...clientOptions,
|
|
24
|
+
...authOptions,
|
|
25
|
+
},
|
|
26
|
+
stainlessApiKey: stainlessApiKey,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
res.status(401).json({
|
|
31
|
+
jsonrpc: '2.0',
|
|
32
|
+
error: {
|
|
33
|
+
code: -32000,
|
|
34
|
+
message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return server;
|
|
40
|
+
};
|
|
41
|
+
const post = (options) => async (req, res) => {
|
|
42
|
+
const server = await newServer({ ...options, req, res });
|
|
43
|
+
// If we return null, we already set the authorization error.
|
|
44
|
+
if (server === null)
|
|
45
|
+
return;
|
|
46
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport();
|
|
47
|
+
await server.connect(transport);
|
|
48
|
+
await transport.handleRequest(req, res, req.body);
|
|
49
|
+
};
|
|
50
|
+
const get = async (req, res) => {
|
|
51
|
+
res.status(405).json({
|
|
52
|
+
jsonrpc: '2.0',
|
|
53
|
+
error: {
|
|
54
|
+
code: -32000,
|
|
55
|
+
message: 'Method not supported',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const del = async (req, res) => {
|
|
60
|
+
res.status(405).json({
|
|
61
|
+
jsonrpc: '2.0',
|
|
62
|
+
error: {
|
|
63
|
+
code: -32000,
|
|
64
|
+
message: 'Method not supported',
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
69
|
+
const app = (0, express_1.default)();
|
|
70
|
+
app.set('query parser', 'extended');
|
|
71
|
+
app.use(express_1.default.json());
|
|
72
|
+
if (debug) {
|
|
73
|
+
(0, morgan_body_1.default)(app, {
|
|
74
|
+
logAllReqHeader: true,
|
|
75
|
+
logAllResHeader: true,
|
|
76
|
+
logRequestBody: true,
|
|
77
|
+
logResponseBody: true,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
app.use((0, morgan_1.default)('combined'));
|
|
82
|
+
}
|
|
83
|
+
app.get('/health', async (req, res) => {
|
|
84
|
+
res.status(200).send('OK');
|
|
85
|
+
});
|
|
86
|
+
app.get('/', get);
|
|
87
|
+
app.post('/', post({ clientOptions, mcpOptions }));
|
|
88
|
+
app.delete('/', del);
|
|
89
|
+
return app;
|
|
90
|
+
};
|
|
91
|
+
exports.streamableHTTPApp = streamableHTTPApp;
|
|
92
|
+
const launchStreamableHTTPServer = async ({ mcpOptions, debug, port, }) => {
|
|
93
|
+
const app = (0, exports.streamableHTTPApp)({ mcpOptions, debug });
|
|
94
|
+
const server = app.listen(port);
|
|
95
|
+
const address = server.address();
|
|
96
|
+
if (typeof address === 'string') {
|
|
97
|
+
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
98
|
+
}
|
|
99
|
+
else if (address !== null) {
|
|
100
|
+
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
exports.launchStreamableHTTPServer = launchStreamableHTTPServer;
|
|
107
|
+
//# sourceMappingURL=http.js.map
|
package/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AAEnG,sDAA8B;AAC9B,oDAA4B;AAC5B,8DAAqC;AACrC,oCAAoE;AAEpE,wCAAuD;AAEvD,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,UAAU,EACV,GAAG,EACH,GAAG,GAMJ,EAA6B,EAAE;IAC9B,MAAM,eAAe,GAAG,IAAA,yBAAkB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,EAAC,eAAe,CAAC,CAAC;IAEnD,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAA,6BAAsB,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAEvD,MAAM,IAAA,sBAAa,EAAC;YAClB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,UAAU;YACtB,aAAa,EAAE;gBACb,GAAG,aAAa;gBAChB,GAAG,WAAW;aACf;YACD,eAAe,EAAE,eAAe;SACjC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,iBAAiB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;aAC3E;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,IAAI,GACR,CAAC,OAAiE,EAAE,EAAE,CACtE,KAAK,EAAE,GAAoB,EAAE,GAAqB,EAAE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AAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CAAC;AApBW,QAAA,0BAA0B,8BAoBrC"}
|
package/http.mjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import morgan from 'morgan';
|
|
5
|
+
import morganBody from 'morgan-body';
|
|
6
|
+
import { getStainlessApiKey, parseClientAuthHeaders } from "./auth.mjs";
|
|
7
|
+
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
8
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
9
|
+
const stainlessApiKey = getStainlessApiKey(req, mcpOptions);
|
|
10
|
+
const server = await newMcpServer(stainlessApiKey);
|
|
11
|
+
try {
|
|
12
|
+
const authOptions = parseClientAuthHeaders(req, false);
|
|
13
|
+
await initMcpServer({
|
|
14
|
+
server: server,
|
|
15
|
+
mcpOptions: mcpOptions,
|
|
16
|
+
clientOptions: {
|
|
17
|
+
...clientOptions,
|
|
18
|
+
...authOptions,
|
|
19
|
+
},
|
|
20
|
+
stainlessApiKey: stainlessApiKey,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
res.status(401).json({
|
|
25
|
+
jsonrpc: '2.0',
|
|
26
|
+
error: {
|
|
27
|
+
code: -32000,
|
|
28
|
+
message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return server;
|
|
34
|
+
};
|
|
35
|
+
const post = (options) => async (req, res) => {
|
|
36
|
+
const server = await newServer({ ...options, req, res });
|
|
37
|
+
// If we return null, we already set the authorization error.
|
|
38
|
+
if (server === null)
|
|
39
|
+
return;
|
|
40
|
+
const transport = new StreamableHTTPServerTransport();
|
|
41
|
+
await server.connect(transport);
|
|
42
|
+
await transport.handleRequest(req, res, req.body);
|
|
43
|
+
};
|
|
44
|
+
const get = async (req, res) => {
|
|
45
|
+
res.status(405).json({
|
|
46
|
+
jsonrpc: '2.0',
|
|
47
|
+
error: {
|
|
48
|
+
code: -32000,
|
|
49
|
+
message: 'Method not supported',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const del = async (req, res) => {
|
|
54
|
+
res.status(405).json({
|
|
55
|
+
jsonrpc: '2.0',
|
|
56
|
+
error: {
|
|
57
|
+
code: -32000,
|
|
58
|
+
message: 'Method not supported',
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
63
|
+
const app = express();
|
|
64
|
+
app.set('query parser', 'extended');
|
|
65
|
+
app.use(express.json());
|
|
66
|
+
if (debug) {
|
|
67
|
+
morganBody(app, {
|
|
68
|
+
logAllReqHeader: true,
|
|
69
|
+
logAllResHeader: true,
|
|
70
|
+
logRequestBody: true,
|
|
71
|
+
logResponseBody: true,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
app.use(morgan('combined'));
|
|
76
|
+
}
|
|
77
|
+
app.get('/health', async (req, res) => {
|
|
78
|
+
res.status(200).send('OK');
|
|
79
|
+
});
|
|
80
|
+
app.get('/', get);
|
|
81
|
+
app.post('/', post({ clientOptions, mcpOptions }));
|
|
82
|
+
app.delete('/', del);
|
|
83
|
+
return app;
|
|
84
|
+
};
|
|
85
|
+
export const launchStreamableHTTPServer = async ({ mcpOptions, debug, port, }) => {
|
|
86
|
+
const app = streamableHTTPApp({ mcpOptions, debug });
|
|
87
|
+
const server = app.listen(port);
|
|
88
|
+
const address = server.address();
|
|
89
|
+
if (typeof address === 'string') {
|
|
90
|
+
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
91
|
+
}
|
|
92
|
+
else if (address !== null) {
|
|
93
|
+
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=http.mjs.map
|
package/http.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAE3F,OAAO,MAAM,SAAS;OACtB,MAAM,MAAM,QAAQ;OACpB,UAAU,MAAM,aAAa;OAC7B,EAAE,kBAAkB,EAAE,sBAAsB,EAAE;OAE9C,EAAE,aAAa,EAAE,YAAY,EAAE;AAEtC,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,UAAU,EACV,GAAG,EACH,GAAG,GAMJ,EAA6B,EAAE;IAC9B,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,eAAe,CAAC,CAAC;IAEnD,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAEvD,MAAM,aAAa,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,UAAU;YACtB,aAAa,EAAE;gBACb,GAAG,aAAa;gBAChB,GAAG,WAAW;aACf;YACD,eAAe,EAAE,eAAe;SACjC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,O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;IACrD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CAAC"}
|
package/index.d.mts
ADDED
package/index.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
|