@hunt-labs/bytekit-mcp 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/dist/__tests__/build-docs-bundle.test.d.ts +2 -0
- package/dist/__tests__/build-docs-bundle.test.d.ts.map +1 -0
- package/dist/__tests__/build-docs-bundle.test.js +133 -0
- package/dist/__tests__/build-docs-bundle.test.js.map +1 -0
- package/dist/__tests__/cli.test.d.ts +2 -0
- package/dist/__tests__/cli.test.d.ts.map +1 -0
- package/dist/__tests__/cli.test.js +41 -0
- package/dist/__tests__/cli.test.js.map +1 -0
- package/dist/__tests__/client.test.d.ts +2 -0
- package/dist/__tests__/client.test.d.ts.map +1 -0
- package/dist/__tests__/client.test.js +248 -0
- package/dist/__tests__/client.test.js.map +1 -0
- package/dist/__tests__/integration.test.d.ts +2 -0
- package/dist/__tests__/integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration.test.js +116 -0
- package/dist/__tests__/integration.test.js.map +1 -0
- package/dist/__tests__/package-manifest.test.d.ts +2 -0
- package/dist/__tests__/package-manifest.test.d.ts.map +1 -0
- package/dist/__tests__/package-manifest.test.js +71 -0
- package/dist/__tests__/package-manifest.test.js.map +1 -0
- package/dist/__tests__/prompts.test.d.ts +2 -0
- package/dist/__tests__/prompts.test.d.ts.map +1 -0
- package/dist/__tests__/prompts.test.js +92 -0
- package/dist/__tests__/prompts.test.js.map +1 -0
- package/dist/__tests__/resources.test.d.ts +2 -0
- package/dist/__tests__/resources.test.d.ts.map +1 -0
- package/dist/__tests__/resources.test.js +67 -0
- package/dist/__tests__/resources.test.js.map +1 -0
- package/dist/__tests__/server-info.test.d.ts +2 -0
- package/dist/__tests__/server-info.test.d.ts.map +1 -0
- package/dist/__tests__/server-info.test.js +14 -0
- package/dist/__tests__/server-info.test.js.map +1 -0
- package/dist/__tests__/tools.test.d.ts +2 -0
- package/dist/__tests__/tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools.test.js +452 -0
- package/dist/__tests__/tools.test.js.map +1 -0
- package/dist/cli.d.ts +28 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +85 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +159 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +167 -0
- package/dist/client.js.map +1 -0
- package/dist/docs-bundle/docs-bundle.json +472 -0
- package/dist/docs-bundle/helpers.d.ts +55 -0
- package/dist/docs-bundle/helpers.d.ts.map +1 -0
- package/dist/docs-bundle/helpers.js +104 -0
- package/dist/docs-bundle/helpers.js.map +1 -0
- package/dist/docs-bundle/load-bundle.d.ts +16 -0
- package/dist/docs-bundle/load-bundle.d.ts.map +1 -0
- package/dist/docs-bundle/load-bundle.js +26 -0
- package/dist/docs-bundle/load-bundle.js.map +1 -0
- package/dist/http.d.ts +27 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +51 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/truncate.d.ts +9 -0
- package/dist/lib/truncate.d.ts.map +1 -0
- package/dist/lib/truncate.js +27 -0
- package/dist/lib/truncate.js.map +1 -0
- package/dist/prompts/extract-structured-data.d.ts +3 -0
- package/dist/prompts/extract-structured-data.d.ts.map +1 -0
- package/dist/prompts/extract-structured-data.js +31 -0
- package/dist/prompts/extract-structured-data.js.map +1 -0
- package/dist/prompts/research-topic.d.ts +3 -0
- package/dist/prompts/research-topic.d.ts.map +1 -0
- package/dist/prompts/research-topic.js +40 -0
- package/dist/prompts/research-topic.js.map +1 -0
- package/dist/prompts/summarize-webpage.d.ts +3 -0
- package/dist/prompts/summarize-webpage.d.ts.map +1 -0
- package/dist/prompts/summarize-webpage.js +28 -0
- package/dist/prompts/summarize-webpage.js.map +1 -0
- package/dist/resources/account.d.ts +4 -0
- package/dist/resources/account.d.ts.map +1 -0
- package/dist/resources/account.js +16 -0
- package/dist/resources/account.js.map +1 -0
- package/dist/resources/screenshot.d.ts +4 -0
- package/dist/resources/screenshot.d.ts.map +1 -0
- package/dist/resources/screenshot.js +18 -0
- package/dist/resources/screenshot.js.map +1 -0
- package/dist/tools/__tests__/docs-tools.test.d.ts +8 -0
- package/dist/tools/__tests__/docs-tools.test.d.ts.map +1 -0
- package/dist/tools/__tests__/docs-tools.test.js +194 -0
- package/dist/tools/__tests__/docs-tools.test.js.map +1 -0
- package/dist/tools/__tests__/fixture-bundle.json +27 -0
- package/dist/tools/get-account.d.ts +4 -0
- package/dist/tools/get-account.d.ts.map +1 -0
- package/dist/tools/get-account.js +45 -0
- package/dist/tools/get-account.js.map +1 -0
- package/dist/tools/get-doc.d.ts +3 -0
- package/dist/tools/get-doc.d.ts.map +1 -0
- package/dist/tools/get-doc.js +71 -0
- package/dist/tools/get-doc.js.map +1 -0
- package/dist/tools/get-result.d.ts +4 -0
- package/dist/tools/get-result.d.ts.map +1 -0
- package/dist/tools/get-result.js +44 -0
- package/dist/tools/get-result.js.map +1 -0
- package/dist/tools/list-docs.d.ts +3 -0
- package/dist/tools/list-docs.d.ts.map +1 -0
- package/dist/tools/list-docs.js +33 -0
- package/dist/tools/list-docs.js.map +1 -0
- package/dist/tools/scrape-url.d.ts +4 -0
- package/dist/tools/scrape-url.d.ts.map +1 -0
- package/dist/tools/scrape-url.js +57 -0
- package/dist/tools/scrape-url.js.map +1 -0
- package/dist/tools/screenshot-url.d.ts +4 -0
- package/dist/tools/screenshot-url.d.ts.map +1 -0
- package/dist/tools/screenshot-url.js +59 -0
- package/dist/tools/screenshot-url.js.map +1 -0
- package/dist/tools/search-docs.d.ts +3 -0
- package/dist/tools/search-docs.d.ts.map +1 -0
- package/dist/tools/search-docs.js +96 -0
- package/dist/tools/search-docs.js.map +1 -0
- package/dist/tools/web-search.d.ts +11 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +76 -0
- package/dist/tools/web-search.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper utilities for the docs-bundle build script.
|
|
3
|
+
*
|
|
4
|
+
* All functions here are pure (no I/O), making them testable in isolation
|
|
5
|
+
* without spinning up the Next.js server. The build script imports them at
|
|
6
|
+
* runtime; the test suite imports them for unit coverage.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Maps a page slug (array of path segments) to a human-readable section
|
|
10
|
+
* label for the bundle schema.
|
|
11
|
+
*
|
|
12
|
+
* Slug segments come from the fumadocs source manifest and mirror the
|
|
13
|
+
* directory structure under `content/docs/`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function slugToSection(slug: string[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns true for the root landing page, which should be excluded from
|
|
18
|
+
* the bundle (it contains only JSX nav cards, no prose content).
|
|
19
|
+
*
|
|
20
|
+
* The landing page is identified by an empty slug or a slug of ["index"].
|
|
21
|
+
*/
|
|
22
|
+
export declare function isIndexPage(slug: string[]): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Joins slug segments into a URL path string.
|
|
25
|
+
*
|
|
26
|
+
* e.g. ['guides', 'authentication'] → 'guides/authentication'
|
|
27
|
+
*/
|
|
28
|
+
export declare function slugToUrlPath(slug: string[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parses the llms.txt response to extract page slugs.
|
|
31
|
+
*
|
|
32
|
+
* Two line formats are supported (issue #2059 changed the format):
|
|
33
|
+
* - New: "- <title>: https://bytekit.com/docs/api/md/<slug> — <description>"
|
|
34
|
+
* The link targets the raw-markdown route (/docs/api/md/<slug>) and an
|
|
35
|
+
* optional em-dash description follows the URL.
|
|
36
|
+
* - Old: "- <title>: https://bytekit.com/docs/<slug>"
|
|
37
|
+
* The link targets the HTML page (/docs/<slug>) with no description.
|
|
38
|
+
*
|
|
39
|
+
* The URL is extracted as the FIRST http(s) token on the line (robust to
|
|
40
|
+
* colons in the title and to a trailing " — <description>" suffix, neither of
|
|
41
|
+
* which contain an http token). The slug is derived by stripping the raw-markdown
|
|
42
|
+
* route prefix (/docs/api/md/) when present, else the /docs/ prefix.
|
|
43
|
+
*
|
|
44
|
+
* Lines without an http URL, or whose URL resolves to the root /docs page
|
|
45
|
+
* (the docs index, which keeps its HTML URL and has an empty slug), are ignored.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseLlmsTxt(text: string): Array<string[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Extracts the page title from the rendered markdown.
|
|
50
|
+
*
|
|
51
|
+
* The getLLMText() function in the docs app always prepends a level-1 heading
|
|
52
|
+
* as the first line: `# <title>`. We strip it and return just the text.
|
|
53
|
+
*/
|
|
54
|
+
export declare function extractTitle(markdown: string): string;
|
|
55
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/docs-bundle/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAEpD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CA4B1D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMrD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper utilities for the docs-bundle build script.
|
|
3
|
+
*
|
|
4
|
+
* All functions here are pure (no I/O), making them testable in isolation
|
|
5
|
+
* without spinning up the Next.js server. The build script imports them at
|
|
6
|
+
* runtime; the test suite imports them for unit coverage.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Maps a page slug (array of path segments) to a human-readable section
|
|
10
|
+
* label for the bundle schema.
|
|
11
|
+
*
|
|
12
|
+
* Slug segments come from the fumadocs source manifest and mirror the
|
|
13
|
+
* directory structure under `content/docs/`.
|
|
14
|
+
*/
|
|
15
|
+
export function slugToSection(slug) {
|
|
16
|
+
const first = slug[0];
|
|
17
|
+
if (first === 'guides')
|
|
18
|
+
return 'Guides';
|
|
19
|
+
if (first === 'api')
|
|
20
|
+
return 'API Reference';
|
|
21
|
+
if (first === 'sdk')
|
|
22
|
+
return 'SDK Reference';
|
|
23
|
+
return 'General';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns true for the root landing page, which should be excluded from
|
|
27
|
+
* the bundle (it contains only JSX nav cards, no prose content).
|
|
28
|
+
*
|
|
29
|
+
* The landing page is identified by an empty slug or a slug of ["index"].
|
|
30
|
+
*/
|
|
31
|
+
export function isIndexPage(slug) {
|
|
32
|
+
return slug.length === 0 || (slug.length === 1 && slug[0] === 'index');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Joins slug segments into a URL path string.
|
|
36
|
+
*
|
|
37
|
+
* e.g. ['guides', 'authentication'] → 'guides/authentication'
|
|
38
|
+
*/
|
|
39
|
+
export function slugToUrlPath(slug) {
|
|
40
|
+
return slug.join('/');
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parses the llms.txt response to extract page slugs.
|
|
44
|
+
*
|
|
45
|
+
* Two line formats are supported (issue #2059 changed the format):
|
|
46
|
+
* - New: "- <title>: https://bytekit.com/docs/api/md/<slug> — <description>"
|
|
47
|
+
* The link targets the raw-markdown route (/docs/api/md/<slug>) and an
|
|
48
|
+
* optional em-dash description follows the URL.
|
|
49
|
+
* - Old: "- <title>: https://bytekit.com/docs/<slug>"
|
|
50
|
+
* The link targets the HTML page (/docs/<slug>) with no description.
|
|
51
|
+
*
|
|
52
|
+
* The URL is extracted as the FIRST http(s) token on the line (robust to
|
|
53
|
+
* colons in the title and to a trailing " — <description>" suffix, neither of
|
|
54
|
+
* which contain an http token). The slug is derived by stripping the raw-markdown
|
|
55
|
+
* route prefix (/docs/api/md/) when present, else the /docs/ prefix.
|
|
56
|
+
*
|
|
57
|
+
* Lines without an http URL, or whose URL resolves to the root /docs page
|
|
58
|
+
* (the docs index, which keeps its HTML URL and has an empty slug), are ignored.
|
|
59
|
+
*/
|
|
60
|
+
export function parseLlmsTxt(text) {
|
|
61
|
+
const slugs = [];
|
|
62
|
+
for (const line of text.split('\n')) {
|
|
63
|
+
const trimmed = line.trim();
|
|
64
|
+
if (!trimmed.startsWith('- '))
|
|
65
|
+
continue;
|
|
66
|
+
// Extract URL — the first whitespace-delimited http(s) token on the line.
|
|
67
|
+
// This ignores a leading title (which may contain colons) and a trailing
|
|
68
|
+
// " — <description>" suffix (neither contains an http token).
|
|
69
|
+
const urlMatch = trimmed.match(/https?:\/\/\S+/);
|
|
70
|
+
if (!urlMatch)
|
|
71
|
+
continue;
|
|
72
|
+
const url = urlMatch[0];
|
|
73
|
+
try {
|
|
74
|
+
const pathname = new URL(url).pathname; // e.g. /docs/api/md/guides/authentication
|
|
75
|
+
// Prefer the raw-markdown route prefix (/docs/api/md/) so the derived slug
|
|
76
|
+
// is the page slug, not the md-route path. Fall back to the /docs/ prefix
|
|
77
|
+
// for the old HTML-URL format and the docs-index line.
|
|
78
|
+
const mdMatch = pathname.match(/^\/docs\/api\/md\/(.+)$/);
|
|
79
|
+
const afterDocs = mdMatch ? mdMatch[1] : pathname.replace(/^\/docs\/?/, '');
|
|
80
|
+
if (!afterDocs)
|
|
81
|
+
continue; // root /docs page — the landing page index
|
|
82
|
+
const slug = afterDocs.split('/').filter(Boolean);
|
|
83
|
+
slugs.push(slug);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// ignore malformed URLs
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return slugs;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Extracts the page title from the rendered markdown.
|
|
93
|
+
*
|
|
94
|
+
* The getLLMText() function in the docs app always prepends a level-1 heading
|
|
95
|
+
* as the first line: `# <title>`. We strip it and return just the text.
|
|
96
|
+
*/
|
|
97
|
+
export function extractTitle(markdown) {
|
|
98
|
+
const firstLine = markdown.split('\n')[0] ?? '';
|
|
99
|
+
if (firstLine.startsWith('# ')) {
|
|
100
|
+
return firstLine.slice(2).trim();
|
|
101
|
+
}
|
|
102
|
+
return firstLine.trim();
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/docs-bundle/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAc;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACxC,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,eAAe,CAAC;IAC5C,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,eAAe,CAAC;IAC5C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAc;IACxC,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAc;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QAExC,0EAA0E;QAC1E,yEAAyE;QACzE,8DAA8D;QAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ;YAAE,SAAS;QACxB,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAExB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,0CAA0C;YAClF,2EAA2E;YAC3E,0EAA0E;YAC1E,uDAAuD;YACvD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC1D,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YAC7E,IAAI,CAAC,SAAS;gBAAE,SAAS,CAAC,2CAA2C;YACrE,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChD,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IACD,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the generated docs-bundle.json from disk.
|
|
3
|
+
*
|
|
4
|
+
* The bundle is produced by `pnpm --filter @hunt-labs/bytekit-mcp prebuild`
|
|
5
|
+
* (which runs `scripts/build-docs-bundle.ts`). It is gitignored because it
|
|
6
|
+
* is a build artifact. If it doesn't exist, this function throws with a
|
|
7
|
+
* clear message telling the operator how to build it.
|
|
8
|
+
*/
|
|
9
|
+
export interface BundleEntry {
|
|
10
|
+
title: string;
|
|
11
|
+
section: string;
|
|
12
|
+
body: string;
|
|
13
|
+
}
|
|
14
|
+
export type DocBundle = Record<string, BundleEntry>;
|
|
15
|
+
export declare function loadBundle(): Promise<DocBundle>;
|
|
16
|
+
//# sourceMappingURL=load-bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-bundle.d.ts","sourceRoot":"","sources":["../../src/docs-bundle/load-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAIpD,wBAAsB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,CAcrD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the generated docs-bundle.json from disk.
|
|
3
|
+
*
|
|
4
|
+
* The bundle is produced by `pnpm --filter @hunt-labs/bytekit-mcp prebuild`
|
|
5
|
+
* (which runs `scripts/build-docs-bundle.ts`). It is gitignored because it
|
|
6
|
+
* is a build artifact. If it doesn't exist, this function throws with a
|
|
7
|
+
* clear message telling the operator how to build it.
|
|
8
|
+
*/
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { join, dirname } from 'node:path';
|
|
12
|
+
const BUNDLE_PATH = join(dirname(fileURLToPath(import.meta.url)), 'docs-bundle.json');
|
|
13
|
+
export async function loadBundle() {
|
|
14
|
+
try {
|
|
15
|
+
const raw = await readFile(BUNDLE_PATH, 'utf8');
|
|
16
|
+
return JSON.parse(raw);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
const isNotFound = err instanceof Error && err.code === 'ENOENT';
|
|
20
|
+
if (isNotFound) {
|
|
21
|
+
throw new Error('docs bundle not built yet — run: pnpm --filter @hunt-labs/bytekit-mcp prebuild', { cause: err });
|
|
22
|
+
}
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=load-bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-bundle.js","sourceRoot":"","sources":["../../src/docs-bundle/load-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAU1C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;AAEtF,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAc,CAAC;IACtC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,UAAU,GAAG,GAAG,YAAY,KAAK,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,CAAC;QAC5F,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,gFAAgF,EAChF,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;QACJ,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP adapter for mounting the MCP server on the gateway.
|
|
3
|
+
*
|
|
4
|
+
* Uses WebStandardStreamableHTTPServerTransport which works with Web standard
|
|
5
|
+
* Request/Response (compatible with Hono). Creates a fresh server+transport
|
|
6
|
+
* per request (stateless mode, ~0.05ms overhead).
|
|
7
|
+
*
|
|
8
|
+
* Phase 2 (issue #1182): the loopback HTTP round-trip is eliminated. The gateway
|
|
9
|
+
* passes an in-process fetch function that dispatches directly through the Hono
|
|
10
|
+
* app without a network hop. No Redis token mint/resolve, no localhost loopback.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Handle an MCP request via the Streamable HTTP transport.
|
|
14
|
+
*
|
|
15
|
+
* Each call creates a fresh McpServer + transport (stateless mode).
|
|
16
|
+
* The transport is single-use per the MCP SDK requirement.
|
|
17
|
+
*
|
|
18
|
+
* @param request - The incoming Web standard Request
|
|
19
|
+
* @param fetchFn - An in-process fetch function provided by the gateway that
|
|
20
|
+
* dispatches API calls (e.g. /v1/scrape, /v1/screenshots)
|
|
21
|
+
* in-process as `Request` objects. The gateway stores the
|
|
22
|
+
* pre-resolved AuthContext in AsyncLocalStorage so the auth
|
|
23
|
+
* middleware can short-circuit the DB lookup for these calls.
|
|
24
|
+
* Called with `(request: Request)` — never with a string URL.
|
|
25
|
+
*/
|
|
26
|
+
export declare function handleMcpRequest(request: Request, fetchFn: (req: Request) => Promise<Response>): Promise<Response>;
|
|
27
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,GAC3C,OAAO,CAAC,QAAQ,CAAC,CA0BnB"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP adapter for mounting the MCP server on the gateway.
|
|
3
|
+
*
|
|
4
|
+
* Uses WebStandardStreamableHTTPServerTransport which works with Web standard
|
|
5
|
+
* Request/Response (compatible with Hono). Creates a fresh server+transport
|
|
6
|
+
* per request (stateless mode, ~0.05ms overhead).
|
|
7
|
+
*
|
|
8
|
+
* Phase 2 (issue #1182): the loopback HTTP round-trip is eliminated. The gateway
|
|
9
|
+
* passes an in-process fetch function that dispatches directly through the Hono
|
|
10
|
+
* app without a network hop. No Redis token mint/resolve, no localhost loopback.
|
|
11
|
+
*/
|
|
12
|
+
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
13
|
+
import { createServer, BytekitClient } from './index.js';
|
|
14
|
+
/**
|
|
15
|
+
* Handle an MCP request via the Streamable HTTP transport.
|
|
16
|
+
*
|
|
17
|
+
* Each call creates a fresh McpServer + transport (stateless mode).
|
|
18
|
+
* The transport is single-use per the MCP SDK requirement.
|
|
19
|
+
*
|
|
20
|
+
* @param request - The incoming Web standard Request
|
|
21
|
+
* @param fetchFn - An in-process fetch function provided by the gateway that
|
|
22
|
+
* dispatches API calls (e.g. /v1/scrape, /v1/screenshots)
|
|
23
|
+
* in-process as `Request` objects. The gateway stores the
|
|
24
|
+
* pre-resolved AuthContext in AsyncLocalStorage so the auth
|
|
25
|
+
* middleware can short-circuit the DB lookup for these calls.
|
|
26
|
+
* Called with `(request: Request)` — never with a string URL.
|
|
27
|
+
*/
|
|
28
|
+
export async function handleMcpRequest(request, fetchFn) {
|
|
29
|
+
// Adapt fetchFn to the broader `(input, init?) => Promise<Response>` signature
|
|
30
|
+
// that BytekitClient uses (matches the global fetch signature). Constructs
|
|
31
|
+
// a Request object when called with a string URL + RequestInit.
|
|
32
|
+
const adaptedFetch = (input, init) => {
|
|
33
|
+
const req = input instanceof Request ? input : new Request(input, init);
|
|
34
|
+
return fetchFn(req);
|
|
35
|
+
};
|
|
36
|
+
// BytekitClient uses an empty apiKey because auth is injected via
|
|
37
|
+
// AsyncLocalStorage in the gateway — no Bearer token is needed.
|
|
38
|
+
const client = new BytekitClient({
|
|
39
|
+
apiKey: '',
|
|
40
|
+
baseUrl: 'http://in-process',
|
|
41
|
+
fetch: adaptedFetch,
|
|
42
|
+
});
|
|
43
|
+
const server = createServer(client);
|
|
44
|
+
// Stateless mode: omit sessionIdGenerator to disable sessions.
|
|
45
|
+
// Using Object.create to satisfy exactOptionalPropertyTypes.
|
|
46
|
+
const opts = Object.create(null);
|
|
47
|
+
const transport = new WebStandardStreamableHTTPServerTransport(opts);
|
|
48
|
+
await server.connect(transport);
|
|
49
|
+
return transport.handleRequest(request);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,wCAAwC,EAAE,MAAM,+DAA+D,CAAC;AACzH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgB,EAChB,OAA4C;IAE5C,+EAA+E;IAC/E,2EAA2E;IAC3E,gEAAgE;IAChE,MAAM,YAAY,GAAG,CAAC,KAA6B,EAAE,IAAkB,EAAqB,EAAE;QAC5F,MAAM,GAAG,GAAG,KAAK,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACxE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,kEAAkE;IAClE,gEAAgE;IAChE,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC;QAC/B,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,mBAAmB;QAC5B,KAAK,EAAE,YAAY;KACpB,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAEpC,+DAA+D;IAC/D,6DAA6D;IAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAA4B,CAAC;IAC5D,MAAM,SAAS,GAAG,IAAI,wCAAwC,CAAC,IAAI,CAAC,CAAC;IAErE,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server factory for ByteKit.
|
|
3
|
+
*
|
|
4
|
+
* Creates an McpServer instance with all tools, resources, and prompts registered.
|
|
5
|
+
* Used by both the CLI (stdio transport) and the gateway (HTTP transport).
|
|
6
|
+
*/
|
|
7
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
import type { BytekitClient } from './client.js';
|
|
9
|
+
/**
|
|
10
|
+
* Server identity advertised over the MCP `initialize` handshake. Exported so
|
|
11
|
+
* the name/version contract is unit-testable without a live server (issue #2066;
|
|
12
|
+
* the live post-deploy curl check is part b, #2067).
|
|
13
|
+
*/
|
|
14
|
+
export declare const serverInfo: {
|
|
15
|
+
readonly name: "bytekit";
|
|
16
|
+
readonly version: "0.1.0";
|
|
17
|
+
};
|
|
18
|
+
export declare function createServer(client: BytekitClient): McpServer;
|
|
19
|
+
export { BytekitClient } from './client.js';
|
|
20
|
+
export type { ScrapeParams, ScrapeResult, SearchParams, SearchResult, SearchResponse, ScreenshotParams, ScreenshotResult, AccountResult, UsageResult, } from './client.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAqBjD;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CA0B7D;AAGD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server factory for ByteKit.
|
|
3
|
+
*
|
|
4
|
+
* Creates an McpServer instance with all tools, resources, and prompts registered.
|
|
5
|
+
* Used by both the CLI (stdio transport) and the gateway (HTTP transport).
|
|
6
|
+
*/
|
|
7
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
// Tools
|
|
9
|
+
import { scrapeUrlTool } from './tools/scrape-url.js';
|
|
10
|
+
import { webSearchTool } from './tools/web-search.js';
|
|
11
|
+
import { screenshotUrlTool } from './tools/screenshot-url.js';
|
|
12
|
+
import { getResultTool } from './tools/get-result.js';
|
|
13
|
+
import { getAccountTool } from './tools/get-account.js';
|
|
14
|
+
import { listDocsTool } from './tools/list-docs.js';
|
|
15
|
+
import { searchDocsTool } from './tools/search-docs.js';
|
|
16
|
+
import { getDocTool } from './tools/get-doc.js';
|
|
17
|
+
// Resources
|
|
18
|
+
import { accountResource } from './resources/account.js';
|
|
19
|
+
import { screenshotResource } from './resources/screenshot.js';
|
|
20
|
+
// Prompts
|
|
21
|
+
import { summarizeWebpagePrompt } from './prompts/summarize-webpage.js';
|
|
22
|
+
import { extractStructuredDataPrompt } from './prompts/extract-structured-data.js';
|
|
23
|
+
import { researchTopicPrompt } from './prompts/research-topic.js';
|
|
24
|
+
/**
|
|
25
|
+
* Server identity advertised over the MCP `initialize` handshake. Exported so
|
|
26
|
+
* the name/version contract is unit-testable without a live server (issue #2066;
|
|
27
|
+
* the live post-deploy curl check is part b, #2067).
|
|
28
|
+
*/
|
|
29
|
+
export const serverInfo = {
|
|
30
|
+
name: 'bytekit',
|
|
31
|
+
version: '0.1.0',
|
|
32
|
+
};
|
|
33
|
+
export function createServer(client) {
|
|
34
|
+
const server = new McpServer({
|
|
35
|
+
name: serverInfo.name,
|
|
36
|
+
version: serverInfo.version,
|
|
37
|
+
});
|
|
38
|
+
// Register tools
|
|
39
|
+
scrapeUrlTool(server, client);
|
|
40
|
+
webSearchTool(server, client);
|
|
41
|
+
screenshotUrlTool(server, client);
|
|
42
|
+
getResultTool(server, client);
|
|
43
|
+
getAccountTool(server, client);
|
|
44
|
+
listDocsTool(server);
|
|
45
|
+
searchDocsTool(server);
|
|
46
|
+
getDocTool(server);
|
|
47
|
+
// Register resources
|
|
48
|
+
accountResource(server, client);
|
|
49
|
+
screenshotResource(server, client);
|
|
50
|
+
// Register prompts
|
|
51
|
+
summarizeWebpagePrompt(server);
|
|
52
|
+
extractStructuredDataPrompt(server);
|
|
53
|
+
researchTopicPrompt(server);
|
|
54
|
+
return server;
|
|
55
|
+
}
|
|
56
|
+
// Re-export client for convenience
|
|
57
|
+
export { BytekitClient } from './client.js';
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,QAAQ;AACR,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,YAAY;AACZ,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,UAAU;AACV,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,OAAO;CACR,CAAC;AAEX,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,OAAO,EAAE,UAAU,CAAC,OAAO;KAC5B,CAAC,CAAC;IAEH,iBAAiB;IACjB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,UAAU,CAAC,MAAM,CAAC,CAAC;IAEnB,qBAAqB;IACrB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnC,mBAAmB;IACnB,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC/B,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,mCAAmC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate text content to a maximum byte size while preserving valid UTF-8.
|
|
3
|
+
* Returns the truncated text with a suffix indicating truncation + content URL.
|
|
4
|
+
*/
|
|
5
|
+
export declare function truncateContent(text: string, maxBytes?: number, contentUrl?: string): {
|
|
6
|
+
text: string;
|
|
7
|
+
truncated: boolean;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=truncate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../src/lib/truncate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAkB,EAC5B,UAAU,CAAC,EAAE,MAAM,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAyBtC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate text content to a maximum byte size while preserving valid UTF-8.
|
|
3
|
+
* Returns the truncated text with a suffix indicating truncation + content URL.
|
|
4
|
+
*/
|
|
5
|
+
const MAX_BYTES = 100 * 1024; // 100KB
|
|
6
|
+
export function truncateContent(text, maxBytes = MAX_BYTES, contentUrl) {
|
|
7
|
+
const byteLength = Buffer.byteLength(text, 'utf8');
|
|
8
|
+
if (byteLength <= maxBytes) {
|
|
9
|
+
return { text, truncated: false };
|
|
10
|
+
}
|
|
11
|
+
// Binary search for the character index that fits within maxBytes
|
|
12
|
+
// This handles multi-byte UTF-8 characters correctly
|
|
13
|
+
const buf = Buffer.from(text, 'utf8');
|
|
14
|
+
const sliced = buf.subarray(0, maxBytes);
|
|
15
|
+
// Decode back to string -- Buffer.toString will handle incomplete multi-byte
|
|
16
|
+
// sequences at the boundary by replacing them, but we trim to last complete char
|
|
17
|
+
let truncated = sliced.toString('utf8');
|
|
18
|
+
// Remove any replacement character at the end (from incomplete multi-byte sequence)
|
|
19
|
+
while (truncated.endsWith('\uFFFD')) {
|
|
20
|
+
truncated = truncated.slice(0, -1);
|
|
21
|
+
}
|
|
22
|
+
const suffix = contentUrl
|
|
23
|
+
? `\n\n---\n[Content truncated. Full content available at: ${contentUrl}]`
|
|
24
|
+
: '\n\n---\n[Content truncated at 100KB]';
|
|
25
|
+
return { text: truncated + suffix, truncated: true };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=truncate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.js","sourceRoot":"","sources":["../../src/lib/truncate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,QAAQ;AAEtC,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,WAAmB,SAAS,EAC5B,UAAmB;IAEnB,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnD,IAAI,UAAU,IAAI,QAAQ,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;IAED,kEAAkE;IAClE,qDAAqD;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAEzC,6EAA6E;IAC7E,iFAAiF;IACjF,IAAI,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAExC,oFAAoF;IACpF,OAAO,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,MAAM,GAAG,UAAU;QACvB,CAAC,CAAC,2DAA2D,UAAU,GAAG;QAC1E,CAAC,CAAC,uCAAuC,CAAC;IAE5C,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-structured-data.d.ts","sourceRoot":"","sources":["../../src/prompts/extract-structured-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmCnE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function extractStructuredDataPrompt(server) {
|
|
3
|
+
server.prompt('extract_structured_data', 'Scrape a URL and extract structured data matching a given schema or description.', {
|
|
4
|
+
url: z.string().url().describe('The URL to extract data from'),
|
|
5
|
+
schema: z
|
|
6
|
+
.string()
|
|
7
|
+
.describe('Description of the data to extract (e.g., "product name, price, rating" or a JSON schema)'),
|
|
8
|
+
}, (params) => ({
|
|
9
|
+
messages: [
|
|
10
|
+
{
|
|
11
|
+
role: 'user',
|
|
12
|
+
content: {
|
|
13
|
+
type: 'text',
|
|
14
|
+
text: [
|
|
15
|
+
`Please scrape the following URL and extract structured data from it:`,
|
|
16
|
+
``,
|
|
17
|
+
`URL: ${params.url}`,
|
|
18
|
+
`Data to extract: ${params.schema}`,
|
|
19
|
+
``,
|
|
20
|
+
`Steps:`,
|
|
21
|
+
`1. Use the scrape_url tool to fetch the page content (with formats: ["markdown"])`,
|
|
22
|
+
`2. Analyze the content to find the requested data fields`,
|
|
23
|
+
`3. Return the extracted data as a clean JSON object`,
|
|
24
|
+
`4. If any fields are not found, set them to null and note which ones were missing`,
|
|
25
|
+
].join('\n'),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=extract-structured-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-structured-data.js","sourceRoot":"","sources":["../../src/prompts/extract-structured-data.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,2BAA2B,CAAC,MAAiB;IAC3D,MAAM,CAAC,MAAM,CACX,yBAAyB,EACzB,kFAAkF,EAClF;QACE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;QAC9D,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,QAAQ,CACP,2FAA2F,CAC5F;KACJ,EACD,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE;wBACJ,sEAAsE;wBACtE,EAAE;wBACF,QAAQ,MAAM,CAAC,GAAG,EAAE;wBACpB,oBAAoB,MAAM,CAAC,MAAM,EAAE;wBACnC,EAAE;wBACF,QAAQ;wBACR,mFAAmF;wBACnF,0DAA0D;wBAC1D,qDAAqD;wBACrD,mFAAmF;qBACpF,CAAC,IAAI,CAAC,IAAI,CAAC;iBACb;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research-topic.d.ts","sourceRoot":"","sources":["../../src/prompts/research-topic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2C3D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function researchTopicPrompt(server) {
|
|
3
|
+
server.prompt('research_topic', 'Research a topic by scraping multiple URLs and synthesizing findings.', {
|
|
4
|
+
topic: z.string().describe('The topic to research'),
|
|
5
|
+
urls: z.string().describe('Comma-separated list of URLs to scrape for research'),
|
|
6
|
+
}, (params) => {
|
|
7
|
+
const urlList = params.urls
|
|
8
|
+
.split(',')
|
|
9
|
+
.map((u) => u.trim())
|
|
10
|
+
.filter(Boolean);
|
|
11
|
+
const urlSteps = urlList.map((url, i) => ` ${i + 1}. Scrape: ${url}`).join('\n');
|
|
12
|
+
return {
|
|
13
|
+
messages: [
|
|
14
|
+
{
|
|
15
|
+
role: 'user',
|
|
16
|
+
content: {
|
|
17
|
+
type: 'text',
|
|
18
|
+
text: [
|
|
19
|
+
`Please research the following topic by scraping the provided URLs:`,
|
|
20
|
+
``,
|
|
21
|
+
`Topic: ${params.topic}`,
|
|
22
|
+
``,
|
|
23
|
+
`Steps:`,
|
|
24
|
+
`1. Scrape each URL using the scrape_url tool (with formats: ["markdown"]):`,
|
|
25
|
+
urlSteps,
|
|
26
|
+
`2. Read and analyze all the scraped content`,
|
|
27
|
+
`3. Synthesize findings into a research summary:`,
|
|
28
|
+
` - Overview of the topic`,
|
|
29
|
+
` - Key findings from each source`,
|
|
30
|
+
` - Common themes and patterns`,
|
|
31
|
+
` - Contradictions or disagreements between sources`,
|
|
32
|
+
` - Conclusions and recommendations`,
|
|
33
|
+
].join('\n'),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=research-topic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research-topic.js","sourceRoot":"","sources":["../../src/prompts/research-topic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,MAAM,CAAC,MAAM,CACX,gBAAgB,EAChB,uEAAuE,EACvE;QACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QACnD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;KACjF,EACD,CAAC,MAAM,EAAE,EAAE;QACT,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI;aACxB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,OAAO,CAAC,CAAC;QACnB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEnF,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAe;oBACrB,OAAO,EAAE;wBACP,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE;4BACJ,oEAAoE;4BACpE,EAAE;4BACF,UAAU,MAAM,CAAC,KAAK,EAAE;4BACxB,EAAE;4BACF,QAAQ;4BACR,4EAA4E;4BAC5E,QAAQ;4BACR,6CAA6C;4BAC7C,iDAAiD;4BACjD,4BAA4B;4BAC5B,oCAAoC;4BACpC,iCAAiC;4BACjC,sDAAsD;4BACtD,sCAAsC;yBACvC,CAAC,IAAI,CAAC,IAAI,CAAC;qBACb;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarize-webpage.d.ts","sourceRoot":"","sources":["../../src/prompts/summarize-webpage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA8B9D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function summarizeWebpagePrompt(server) {
|
|
3
|
+
server.prompt('summarize_webpage', 'Scrape a URL and produce a structured summary of the content.', { url: z.string().url().describe('The URL to summarize') }, (params) => ({
|
|
4
|
+
messages: [
|
|
5
|
+
{
|
|
6
|
+
role: 'user',
|
|
7
|
+
content: {
|
|
8
|
+
type: 'text',
|
|
9
|
+
text: [
|
|
10
|
+
`Please scrape the following URL and summarize its content:`,
|
|
11
|
+
``,
|
|
12
|
+
`URL: ${params.url}`,
|
|
13
|
+
``,
|
|
14
|
+
`Steps:`,
|
|
15
|
+
`1. Use the scrape_url tool to fetch the page content (with formats: ["markdown"])`,
|
|
16
|
+
`2. Read the returned content carefully`,
|
|
17
|
+
`3. Produce a structured summary with:`,
|
|
18
|
+
` - Title and main topic`,
|
|
19
|
+
` - Key points (3-5 bullet points)`,
|
|
20
|
+
` - Notable data, statistics, or claims`,
|
|
21
|
+
` - Overall tone and perspective`,
|
|
22
|
+
].join('\n'),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=summarize-webpage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarize-webpage.js","sourceRoot":"","sources":["../../src/prompts/summarize-webpage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,MAAM,CACX,mBAAmB,EACnB,+DAA+D,EAC/D,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,EAC1D,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE;wBACJ,4DAA4D;wBAC5D,EAAE;wBACF,QAAQ,MAAM,CAAC,GAAG,EAAE;wBACpB,EAAE;wBACF,QAAQ;wBACR,mFAAmF;wBACnF,wCAAwC;wBACxC,uCAAuC;wBACvC,2BAA2B;wBAC3B,qCAAqC;wBACrC,0CAA0C;wBAC1C,mCAAmC;qBACpC,CAAC,IAAI,CAAC,IAAI,CAAC;iBACb;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/resources/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAqB9E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function accountResource(server, client) {
|
|
2
|
+
server.resource('account', 'bytekit://account', { description: 'Current ByteKit account details and usage' }, async () => {
|
|
3
|
+
const [account, usage] = await Promise.all([client.getAccount(), client.getUsage()]);
|
|
4
|
+
const text = JSON.stringify({ account, usage }, null, 2);
|
|
5
|
+
return {
|
|
6
|
+
contents: [
|
|
7
|
+
{
|
|
8
|
+
uri: 'bytekit://account',
|
|
9
|
+
mimeType: 'application/json',
|
|
10
|
+
text,
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/resources/account.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,eAAe,CAAC,MAAiB,EAAE,MAAqB;IACtE,MAAM,CAAC,QAAQ,CACb,SAAS,EACT,mBAAmB,EACnB,EAAE,WAAW,EAAE,2CAA2C,EAAE,EAC5D,KAAK,IAAI,EAAE;QACT,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAErF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEzD,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,mBAAmB;oBACxB,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI;iBACL;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|