@bendyline/docblocks-cli 1.1.1 → 2.0.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 +60 -76
- package/dist/commands/build.d.ts +11 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +61 -45
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/convert.d.ts +12 -2
- package/dist/commands/convert.d.ts.map +1 -1
- package/dist/commands/convert.js +272 -101
- package/dist/commands/convert.js.map +1 -1
- package/dist/commands/mcp.d.ts +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +90 -4
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/parse.js +1 -1
- package/dist/commands/parse.js.map +1 -1
- package/dist/commands/serve.d.ts +33 -0
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +340 -3
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/themes.js +1 -1
- package/dist/commands/themes.js.map +1 -1
- package/dist/commands/transforms.js +1 -1
- package/dist/commands/transforms.js.map +1 -1
- package/dist/commands/video.d.ts +8 -1
- package/dist/commands/video.d.ts.map +1 -1
- package/dist/commands/video.js +50 -30
- package/dist/commands/video.js.map +1 -1
- package/dist/contained-file.d.ts +8 -0
- package/dist/contained-file.d.ts.map +1 -0
- package/dist/contained-file.js +77 -0
- package/dist/contained-file.js.map +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/agentic-tools.d.ts +16 -0
- package/dist/mcp/agentic-tools.d.ts.map +1 -0
- package/dist/mcp/agentic-tools.js +967 -0
- package/dist/mcp/agentic-tools.js.map +1 -0
- package/dist/mcp/artifact-store.d.ts +98 -0
- package/dist/mcp/artifact-store.d.ts.map +1 -0
- package/dist/mcp/artifact-store.js +542 -0
- package/dist/mcp/artifact-store.js.map +1 -0
- package/dist/mcp/authority.d.ts +53 -0
- package/dist/mcp/authority.d.ts.map +1 -0
- package/dist/mcp/authority.js +433 -0
- package/dist/mcp/authority.js.map +1 -0
- package/dist/mcp/conversion-service.d.ts +111 -0
- package/dist/mcp/conversion-service.d.ts.map +1 -0
- package/dist/mcp/conversion-service.js +512 -0
- package/dist/mcp/conversion-service.js.map +1 -0
- package/dist/mcp/discovery-tools.d.ts +4 -0
- package/dist/mcp/discovery-tools.d.ts.map +1 -0
- package/dist/mcp/discovery-tools.js +114 -0
- package/dist/mcp/discovery-tools.js.map +1 -0
- package/dist/mcp/document-service.d.ts +47 -0
- package/dist/mcp/document-service.d.ts.map +1 -0
- package/dist/mcp/document-service.js +424 -0
- package/dist/mcp/document-service.js.map +1 -0
- package/dist/mcp/error-result.d.ts +17 -0
- package/dist/mcp/error-result.d.ts.map +1 -0
- package/dist/mcp/error-result.js +82 -0
- package/dist/mcp/error-result.js.map +1 -0
- package/dist/mcp/intelligence.d.ts +15 -0
- package/dist/mcp/intelligence.d.ts.map +1 -0
- package/dist/mcp/intelligence.js +855 -0
- package/dist/mcp/intelligence.js.map +1 -0
- package/dist/mcp/output-bounds.d.ts +13 -0
- package/dist/mcp/output-bounds.d.ts.map +1 -0
- package/dist/mcp/output-bounds.js +61 -0
- package/dist/mcp/output-bounds.js.map +1 -0
- package/dist/mcp/preview-service.d.ts +54 -0
- package/dist/mcp/preview-service.d.ts.map +1 -0
- package/dist/mcp/preview-service.js +454 -0
- package/dist/mcp/preview-service.js.map +1 -0
- package/dist/mcp/progress.d.ts +18 -0
- package/dist/mcp/progress.d.ts.map +1 -0
- package/dist/mcp/progress.js +28 -0
- package/dist/mcp/progress.js.map +1 -0
- package/dist/mcp/prompts.d.ts +4 -0
- package/dist/mcp/prompts.d.ts.map +1 -0
- package/dist/mcp/prompts.js +124 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/rendered-conversion.d.ts +34 -0
- package/dist/mcp/rendered-conversion.d.ts.map +1 -0
- package/dist/mcp/rendered-conversion.js +364 -0
- package/dist/mcp/rendered-conversion.js.map +1 -0
- package/dist/mcp/server.d.ts +67 -10
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +228 -496
- package/dist/mcp/server.js.map +1 -1
- package/dist/preview-policy.d.ts +8 -0
- package/dist/preview-policy.d.ts.map +1 -0
- package/dist/preview-policy.js +85 -0
- package/dist/preview-policy.js.map +1 -0
- package/dist/render-html.d.ts +17 -0
- package/dist/render-html.d.ts.map +1 -0
- package/dist/render-html.js +85 -0
- package/dist/render-html.js.map +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +104 -0
- package/dist/version.js.map +1 -0
- package/package.json +11 -11
- package/dist/converters/docx-to-md.d.ts +0 -10
- package/dist/converters/docx-to-md.d.ts.map +0 -1
- package/dist/converters/docx-to-md.js +0 -17
- package/dist/converters/docx-to-md.js.map +0 -1
- package/dist/converters/pdf-to-md.d.ts +0 -14
- package/dist/converters/pdf-to-md.d.ts.map +0 -1
- package/dist/converters/pdf-to-md.js +0 -51
- package/dist/converters/pdf-to-md.js.map +0 -1
- package/dist/converters/pptx-to-md.d.ts +0 -13
- package/dist/converters/pptx-to-md.d.ts.map +0 -1
- package/dist/converters/pptx-to-md.js +0 -67
- package/dist/converters/pptx-to-md.js.map +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { completable } from '@modelcontextprotocol/sdk/server/completable.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const MAX_ID_CHARACTERS = 256;
|
|
4
|
+
const MAX_TOPIC_CHARACTERS = 10000;
|
|
5
|
+
/** Artifact-first authoring prompts whose named calls are all current MCP tools. */
|
|
6
|
+
export function registerAuthoringPrompts(server) {
|
|
7
|
+
const style = completable(z.string().max(MAX_ID_CHARACTERS).optional().describe('Preferred transform style id.'), async (prefix) => {
|
|
8
|
+
const { getTransformStyleIds } = await import('@bendyline/squisq/transform');
|
|
9
|
+
return complete(getTransformStyleIds(), prefix);
|
|
10
|
+
});
|
|
11
|
+
const theme = completable(z.string().max(MAX_ID_CHARACTERS).optional().describe('Preferred Squisq theme id.'), async (prefix) => {
|
|
12
|
+
const { getAvailableThemes } = await import('@bendyline/squisq/schemas');
|
|
13
|
+
return complete(getAvailableThemes(), prefix);
|
|
14
|
+
});
|
|
15
|
+
const template = completable(z.string().max(MAX_ID_CHARACTERS).optional().describe('Preferred Squisq template id.'), async (prefix) => {
|
|
16
|
+
const { getAvailableTemplates } = await import('@bendyline/squisq/doc');
|
|
17
|
+
return complete(getAvailableTemplates(), prefix);
|
|
18
|
+
});
|
|
19
|
+
const presentationArgs = z
|
|
20
|
+
.object({
|
|
21
|
+
topic: z.string().max(MAX_TOPIC_CHARACTERS).describe('Presentation topic or subject.'),
|
|
22
|
+
style,
|
|
23
|
+
theme,
|
|
24
|
+
template,
|
|
25
|
+
})
|
|
26
|
+
.strict();
|
|
27
|
+
const presentation = server.registerPrompt('create-presentation', {
|
|
28
|
+
description: 'Create, validate, preview, and export an artifact-first presentation.',
|
|
29
|
+
argsSchema: presentationArgs.shape,
|
|
30
|
+
}, async (args) => ({
|
|
31
|
+
messages: [
|
|
32
|
+
{
|
|
33
|
+
role: 'user',
|
|
34
|
+
content: {
|
|
35
|
+
type: 'text',
|
|
36
|
+
text: presentationPrompt(args.topic, args.style, args.theme, args.template),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}));
|
|
41
|
+
presentation.argsSchema = presentationArgs;
|
|
42
|
+
const videoArgs = z
|
|
43
|
+
.object({
|
|
44
|
+
topic: z.string().max(MAX_TOPIC_CHARACTERS).describe('Video topic or subject.'),
|
|
45
|
+
orientation: z.enum(['landscape', 'portrait']).optional(),
|
|
46
|
+
theme,
|
|
47
|
+
template,
|
|
48
|
+
})
|
|
49
|
+
.strict();
|
|
50
|
+
const video = server.registerPrompt('create-video', {
|
|
51
|
+
description: 'Create, validate, preview, and export an artifact-first MP4 video.',
|
|
52
|
+
argsSchema: videoArgs.shape,
|
|
53
|
+
}, async (args) => ({
|
|
54
|
+
messages: [
|
|
55
|
+
{
|
|
56
|
+
role: 'user',
|
|
57
|
+
content: {
|
|
58
|
+
type: 'text',
|
|
59
|
+
text: videoPrompt(args.topic, args.orientation, args.theme, args.template),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
}));
|
|
64
|
+
video.argsSchema = videoArgs;
|
|
65
|
+
const documentArgs = z
|
|
66
|
+
.object({
|
|
67
|
+
topic: z.string().max(MAX_TOPIC_CHARACTERS).describe('Document topic or subject.'),
|
|
68
|
+
format: z.enum(['docx', 'pdf']).optional(),
|
|
69
|
+
theme,
|
|
70
|
+
template,
|
|
71
|
+
})
|
|
72
|
+
.strict();
|
|
73
|
+
const document = server.registerPrompt('create-document', {
|
|
74
|
+
description: 'Create, validate, preview, and export an artifact-first document.',
|
|
75
|
+
argsSchema: documentArgs.shape,
|
|
76
|
+
}, async (args) => ({
|
|
77
|
+
messages: [
|
|
78
|
+
{
|
|
79
|
+
role: 'user',
|
|
80
|
+
content: {
|
|
81
|
+
type: 'text',
|
|
82
|
+
text: documentPrompt(args.topic, args.format, args.theme, args.template),
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
}));
|
|
87
|
+
document.argsSchema = documentArgs;
|
|
88
|
+
}
|
|
89
|
+
function presentationPrompt(topic, style, theme, template) {
|
|
90
|
+
return `Create a presentation about: ${topic}
|
|
91
|
+
|
|
92
|
+
1. Use list_formats, list_themes, list_transform_styles, and list_templates for current linked-Squisq capabilities.
|
|
93
|
+
2. Author focused Markdown sections with accessible alt text. Prefer style "${style ?? 'choose from list_transform_styles'}", theme "${theme ?? 'choose from list_themes'}", and template "${template ?? 'choose per block'}".
|
|
94
|
+
3. Call validate_document with targetFormat "pptx" and repair actionable diagnostics.
|
|
95
|
+
4. Call convert_document with a pptx target. Choose editable-native for editable Office structures, rendered-fidelity for exact Squisq visuals, or hybrid for rendered visuals plus semantic retention.
|
|
96
|
+
5. Call preview_document and inspect the bounded slide images.
|
|
97
|
+
6. Use get_conversion_report for provenance and save_artifact only when a durable file is required.`;
|
|
98
|
+
}
|
|
99
|
+
function videoPrompt(topic, orientation, theme, template) {
|
|
100
|
+
return `Create a video about: ${topic}
|
|
101
|
+
|
|
102
|
+
1. Use list_formats, list_themes, list_transform_styles, and list_templates for current linked-Squisq capabilities.
|
|
103
|
+
2. Author concise Markdown for a ${orientation ?? 'landscape'} animated sequence using theme "${theme ?? 'choose from list_themes'}" and template "${template ?? 'choose per block'}".
|
|
104
|
+
3. Call validate_document with targetFormat "mp4" and repair actionable diagnostics.
|
|
105
|
+
4. Call preview_document to review representative frames.
|
|
106
|
+
5. Call convert_document with an mp4 target and orientation "${orientation ?? 'landscape'}"; monitor progress and honor cancellation.
|
|
107
|
+
6. Use get_conversion_report for provenance and save_artifact only when a durable file is required.`;
|
|
108
|
+
}
|
|
109
|
+
function documentPrompt(topic, format, theme, template) {
|
|
110
|
+
const target = format ?? 'pdf';
|
|
111
|
+
return `Create a professional document about: ${topic}
|
|
112
|
+
|
|
113
|
+
1. Use list_formats, list_themes, list_transform_styles, and list_templates for current linked-Squisq capabilities.
|
|
114
|
+
2. Author structured Markdown using theme "${theme ?? 'choose from list_themes'}" and template "${template ?? 'choose per block'}".
|
|
115
|
+
3. Call validate_document with targetFormat "${target}" and repair actionable diagnostics.
|
|
116
|
+
4. Call convert_document with a ${target} target to create an immutable artifact.
|
|
117
|
+
5. Call preview_document and review the bounded page images.
|
|
118
|
+
6. Use get_conversion_report for provenance and save_artifact only when a durable file is required.`;
|
|
119
|
+
}
|
|
120
|
+
function complete(values, prefix) {
|
|
121
|
+
const value = prefix ?? '';
|
|
122
|
+
return values.filter((candidate) => candidate.startsWith(value)).slice(0, 100);
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/mcp/prompts.ts"],"names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I,mCAAmC,aAAa,KAAK,IAAI,yBAAyB,oBAAoB,QAAQ,IAAI,kBAAkB;;;;oGAIvH,CAAC;AACrG,CAAC;AAED,SAAS,WAAW,CAClB,KAAa,EACb,WAAiD,EACjD,KAAyB,EACzB,QAA4B;IAE5B,OAAO,yBAAyB,KAAK;;;mCAGJ,WAAW,IAAI,WAAW,mCAAmC,KAAK,IAAI,yBAAyB,mBAAmB,QAAQ,IAAI,kBAAkB;;;+DAGpH,WAAW,IAAI,WAAW;oGACW,CAAC;AACrG,CAAC;AAED,SAAS,cAAc,CACrB,KAAa,EACb,MAAkC,EAClC,KAAyB,EACzB,QAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC;IAC/B,OAAO,yCAAyC,KAAK;;;6CAGV,KAAK,IAAI,yBAAyB,mBAAmB,QAAQ,IAAI,kBAAkB;+CACjF,MAAM;kCACnB,MAAM;;oGAE4D,CAAC;AACrG,CAAC;AAED,SAAS,QAAQ,CAAC,MAAyB,EAAE,MAA0B;IACrE,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;IAC3B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ConversionFidelity } from '@bendyline/docblocks/mcp';
|
|
2
|
+
import type { PreparedDocument } from './document-service.js';
|
|
3
|
+
import { type CapturedPreview, type PreviewProgress } from './preview-service.js';
|
|
4
|
+
export interface RenderedConversionResult {
|
|
5
|
+
bytes: Uint8Array;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
suggestedFilename: string;
|
|
8
|
+
warnings: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface RenderedDocumentOptions {
|
|
11
|
+
themeId?: string;
|
|
12
|
+
transformId?: string;
|
|
13
|
+
autoTemplates?: boolean;
|
|
14
|
+
title?: string;
|
|
15
|
+
}
|
|
16
|
+
export type RenderedFrameCapture = (prepared: PreparedDocument, options: {
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
}, signal?: AbortSignal, progress?: PreviewProgress) => Promise<CapturedPreview[]>;
|
|
20
|
+
export interface PreparedRenderedDocument {
|
|
21
|
+
prepared: PreparedDocument;
|
|
22
|
+
warnings: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
export interface RenderedSerializationHooks {
|
|
25
|
+
onPptxSerializationProgress?: (percent: number) => void;
|
|
26
|
+
onPdfSerializationProgress?: (processedObjects: number) => void;
|
|
27
|
+
}
|
|
28
|
+
/** Produce image-backed PPTX/PDF output from the actual linked Squisq player. */
|
|
29
|
+
export declare function convertRenderedDocument(prepared: PreparedDocument, format: string, fidelity: ConversionFidelity, options: Readonly<Record<string, string | number | boolean | null>>, documentOptions: RenderedDocumentOptions, signal?: AbortSignal, progress?: PreviewProgress, capture?: RenderedFrameCapture): Promise<RenderedConversionResult>;
|
|
30
|
+
/** Apply linked-registry normalization and transforms before the visual renderer sees the Doc. */
|
|
31
|
+
export declare function prepareRenderedDocument(prepared: PreparedDocument, options: RenderedDocumentOptions, signal?: AbortSignal): Promise<PreparedRenderedDocument>;
|
|
32
|
+
export declare function packageRenderedPptx(frames: readonly CapturedPreview[], semanticText: readonly string[], hybrid: boolean, signal?: AbortSignal, title?: string, serializationHooks?: RenderedSerializationHooks): Promise<Uint8Array>;
|
|
33
|
+
export declare function packageRenderedPdf(frames: readonly CapturedPreview[], semanticText: readonly string[], markdownAttachment: string | null, baseName: string, signal?: AbortSignal, title?: string, serializationHooks?: RenderedSerializationHooks): Promise<Uint8Array>;
|
|
34
|
+
//# sourceMappingURL=rendered-conversion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rendered-conversion.d.ts","sourceRoot":"","sources":["../../src/mcp/rendered-conversion.ts"],"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Q,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,EACnE,eAAe,EAAE,uBAAuB,EACxC,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,eAAe,EAC1B,OAAO,GAAE,oBAAoD,GAC5D,OAAO,CAAC,wBAAwB,CAAC,CAyDnC;AAED,kGAAkG;AAClG,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,uBAAuB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,wBAAwB,CAAC,CA+EnC;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,MAAM,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,WAAW,EACpB,KAAK,CAAC,EAAE,MAAM,EACd,kBAAkB,GAAE,0BAA+B,GAClD,OAAO,CAAC,UAAU,CAAC,CAiDrB;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,kBAAkB,EAAE,MAAM,GAAG,IAAI,EACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,EACpB,KAAK,CAAC,EAAE,MAAM,EACd,kBAAkB,GAAE,0BAA+B,GAClD,OAAO,CAAC,UAAU,CAAC,CAwDrB"}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import JSZip from 'jszip';
|
|
2
|
+
import { throwIfAborted } from './document-service.js';
|
|
3
|
+
import { capturePreparedDocumentFrames, } from './preview-service.js';
|
|
4
|
+
const PPTX_REFERENCE_SHORT_EDGE_EMU = 6858000;
|
|
5
|
+
const MAX_HYBRID_TEXT_CHARACTERS = 8000;
|
|
6
|
+
/** Produce image-backed PPTX/PDF output from the actual linked Squisq player. */
|
|
7
|
+
export async function convertRenderedDocument(prepared, format, fidelity, options, documentOptions, signal, progress, capture = capturePreparedDocumentFrames) {
|
|
8
|
+
if (format !== 'pptx' && format !== 'pdf') {
|
|
9
|
+
throw new Error(`${fidelity} conversion is available only for PPTX and PDF`);
|
|
10
|
+
}
|
|
11
|
+
const width = numericOption(options, 'width', 1200);
|
|
12
|
+
const height = numericOption(options, 'height', 900);
|
|
13
|
+
const normalized = await prepareRenderedDocument(prepared, documentOptions, signal);
|
|
14
|
+
const rendered = normalized.prepared;
|
|
15
|
+
const frames = await capture(rendered, { width, height }, signal, progress);
|
|
16
|
+
if (frames.length === 0)
|
|
17
|
+
throw new Error('Rendered-fidelity conversion requires visual content');
|
|
18
|
+
throwIfAborted(signal);
|
|
19
|
+
const semanticText = await semanticTextByFrame(rendered, frames);
|
|
20
|
+
if (format === 'pptx') {
|
|
21
|
+
return {
|
|
22
|
+
bytes: await packageRenderedPptx(frames, semanticText, fidelity === 'hybrid', signal, documentOptions.title),
|
|
23
|
+
mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
24
|
+
suggestedFilename: `${prepared.baseName}.pptx`,
|
|
25
|
+
warnings: fidelity === 'hybrid'
|
|
26
|
+
? [
|
|
27
|
+
...normalized.warnings,
|
|
28
|
+
'Hybrid PPTX stores each Squisq visual as a full-slide image and retains hidden semantic text for editing and extraction.',
|
|
29
|
+
]
|
|
30
|
+
: [
|
|
31
|
+
...normalized.warnings,
|
|
32
|
+
'Rendered-fidelity PPTX preserves Squisq pixels; slide contents are images rather than native editable shapes.',
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
bytes: await packageRenderedPdf(frames, semanticText, fidelity === 'hybrid' ? rendered.markdown : null, prepared.baseName, signal, documentOptions.title),
|
|
38
|
+
mimeType: 'application/pdf',
|
|
39
|
+
suggestedFilename: `${prepared.baseName}.pdf`,
|
|
40
|
+
warnings: fidelity === 'hybrid'
|
|
41
|
+
? [
|
|
42
|
+
...normalized.warnings,
|
|
43
|
+
'Hybrid PDF retains invisible extraction text and an attached Markdown source, but is not a fully tagged accessible PDF.',
|
|
44
|
+
]
|
|
45
|
+
: [
|
|
46
|
+
...normalized.warnings,
|
|
47
|
+
'Rendered-fidelity PDF preserves Squisq pixels; page contents are raster images and are not editable.',
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Apply linked-registry normalization and transforms before the visual renderer sees the Doc. */
|
|
52
|
+
export async function prepareRenderedDocument(prepared, options, signal) {
|
|
53
|
+
throwIfAborted(signal);
|
|
54
|
+
const { convert, createCliRegistry } = await import('@bendyline/squisq-cli/api');
|
|
55
|
+
const registry = createCliRegistry();
|
|
56
|
+
const captureFormat = 'docblocks-render-input';
|
|
57
|
+
let normalized;
|
|
58
|
+
const captureDefinition = {
|
|
59
|
+
id: captureFormat,
|
|
60
|
+
label: 'DocBlocks rendered input',
|
|
61
|
+
mimeType: 'application/x-docblocks-render-input',
|
|
62
|
+
extensions: ['.render-input'],
|
|
63
|
+
async exportDoc(input) {
|
|
64
|
+
normalized = input;
|
|
65
|
+
return {
|
|
66
|
+
bytes: new Uint8Array(0),
|
|
67
|
+
mimeType: 'application/x-docblocks-render-input',
|
|
68
|
+
suggestedFilename: 'render-input',
|
|
69
|
+
warnings: [],
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
registry.register(captureDefinition);
|
|
74
|
+
const result = await convert({
|
|
75
|
+
kind: 'markdown',
|
|
76
|
+
markdown: prepared.markdownDoc,
|
|
77
|
+
container: prepared.container,
|
|
78
|
+
baseName: prepared.baseName,
|
|
79
|
+
}, captureFormat, {
|
|
80
|
+
registry,
|
|
81
|
+
themeId: options.themeId,
|
|
82
|
+
transformStyle: options.transformId,
|
|
83
|
+
autoTemplates: options.autoTemplates,
|
|
84
|
+
title: options.title,
|
|
85
|
+
signal,
|
|
86
|
+
});
|
|
87
|
+
throwIfAborted(signal);
|
|
88
|
+
if (!normalized)
|
|
89
|
+
throw new Error('Linked Squisq did not produce a rendered document input');
|
|
90
|
+
const { docToMarkdown } = await import('@bendyline/squisq/doc');
|
|
91
|
+
const { stringifyMarkdown } = await import('@bendyline/squisq/markdown');
|
|
92
|
+
let markdownDoc = normalized.markdownDoc ?? docToMarkdown(normalized.doc);
|
|
93
|
+
let doc = normalized.doc;
|
|
94
|
+
if (options.title !== undefined || options.themeId !== undefined) {
|
|
95
|
+
const frontmatter = {
|
|
96
|
+
...(markdownDoc.frontmatter ?? {}),
|
|
97
|
+
...(options.title !== undefined ? { title: options.title } : {}),
|
|
98
|
+
...(options.themeId !== undefined ? { 'squisq-theme': options.themeId } : {}),
|
|
99
|
+
};
|
|
100
|
+
markdownDoc = { ...markdownDoc, frontmatter };
|
|
101
|
+
doc = {
|
|
102
|
+
...doc,
|
|
103
|
+
frontmatter: { ...(doc.frontmatter ?? {}), ...frontmatter },
|
|
104
|
+
...(options.title !== undefined
|
|
105
|
+
? {
|
|
106
|
+
startBlock: doc.startBlock
|
|
107
|
+
? { ...doc.startBlock, title: options.title }
|
|
108
|
+
: { title: options.title },
|
|
109
|
+
}
|
|
110
|
+
: {}),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (options.themeId !== undefined && doc.themeId !== options.themeId) {
|
|
114
|
+
doc = { ...doc, themeId: options.themeId };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
prepared: {
|
|
118
|
+
...prepared,
|
|
119
|
+
markdown: stringifyMarkdown(markdownDoc),
|
|
120
|
+
markdownDoc,
|
|
121
|
+
doc,
|
|
122
|
+
container: normalized.container,
|
|
123
|
+
},
|
|
124
|
+
warnings: result.warnings,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export async function packageRenderedPptx(frames, semanticText, hybrid, signal, title, serializationHooks = {}) {
|
|
128
|
+
const { convert } = await import('@bendyline/squisq-cli/api');
|
|
129
|
+
const scaffold = frames
|
|
130
|
+
.map((_frame, index) => `## Rendered slide ${index + 1}\n\nPlaceholder`)
|
|
131
|
+
.join('\n\n');
|
|
132
|
+
const converted = await convert({ kind: 'markdown', markdown: scaffold, baseName: 'rendered' }, 'pptx', { ...(title === undefined ? {} : { title }), signal });
|
|
133
|
+
throwIfAborted(signal);
|
|
134
|
+
const archive = await JSZip.loadAsync(converted.bytes);
|
|
135
|
+
const slideSize = renderedPptxSlideSize(frames[0]);
|
|
136
|
+
const presentationPart = archive.file('ppt/presentation.xml');
|
|
137
|
+
if (!presentationPart)
|
|
138
|
+
throw new Error('Linked PPTX scaffold has no presentation manifest');
|
|
139
|
+
const presentation = await presentationPart.async('string');
|
|
140
|
+
const resizedPresentation = presentation.replace(/<p:sldSz\b[^>]*\/>/u, `<p:sldSz cx="${slideSize.width}" cy="${slideSize.height}" type="custom"/>`);
|
|
141
|
+
if (resizedPresentation === presentation) {
|
|
142
|
+
throw new Error('Linked PPTX scaffold has no slide-size declaration');
|
|
143
|
+
}
|
|
144
|
+
archive.file('ppt/presentation.xml', resizedPresentation);
|
|
145
|
+
const contentTypesPart = archive.file('[Content_Types].xml');
|
|
146
|
+
if (!contentTypesPart)
|
|
147
|
+
throw new Error('Linked PPTX scaffold has no content-types manifest');
|
|
148
|
+
let contentTypes = await contentTypesPart.async('string');
|
|
149
|
+
if (!/Extension="png"/iu.test(contentTypes)) {
|
|
150
|
+
contentTypes = contentTypes.replace('</Types>', '<Default Extension="png" ContentType="image/png"/></Types>');
|
|
151
|
+
archive.file('[Content_Types].xml', contentTypes);
|
|
152
|
+
}
|
|
153
|
+
for (let index = 0; index < frames.length; index += 1) {
|
|
154
|
+
throwIfAborted(signal);
|
|
155
|
+
const frame = frames[index];
|
|
156
|
+
const slideNumber = index + 1;
|
|
157
|
+
archive.file(`ppt/media/rendered${slideNumber}.png`, frame.bytes);
|
|
158
|
+
archive.file(`ppt/slides/slide${slideNumber}.xml`, renderedSlideXml(frame, semanticText[index] ?? '', hybrid, slideSize));
|
|
159
|
+
archive.file(`ppt/slides/_rels/slide${slideNumber}.xml.rels`, slideRelationshipsXml(slideNumber));
|
|
160
|
+
}
|
|
161
|
+
return generatePptxArchive(archive, signal, serializationHooks.onPptxSerializationProgress);
|
|
162
|
+
}
|
|
163
|
+
export async function packageRenderedPdf(frames, semanticText, markdownAttachment, baseName, signal, title, serializationHooks = {}) {
|
|
164
|
+
const { PDFDocument, PDFWriter, StandardFonts } = await import('pdf-lib');
|
|
165
|
+
const pdf = await PDFDocument.create();
|
|
166
|
+
pdf.setTitle(title ?? baseName);
|
|
167
|
+
pdf.setProducer('DocBlocks rendered-fidelity pipeline');
|
|
168
|
+
const invisibleFont = markdownAttachment ? await pdf.embedFont(StandardFonts.Helvetica) : null;
|
|
169
|
+
for (let index = 0; index < frames.length; index += 1) {
|
|
170
|
+
throwIfAborted(signal);
|
|
171
|
+
const frame = frames[index];
|
|
172
|
+
const image = await pdf.embedPng(frame.bytes);
|
|
173
|
+
const pageWidth = 720;
|
|
174
|
+
const pageHeight = pageWidth * (frame.height / frame.width);
|
|
175
|
+
const page = pdf.addPage([pageWidth, pageHeight]);
|
|
176
|
+
page.drawImage(image, { x: 0, y: 0, width: pageWidth, height: pageHeight });
|
|
177
|
+
if (invisibleFont) {
|
|
178
|
+
page.drawText(asWinAnsiText(semanticText[index] ?? ''), {
|
|
179
|
+
x: 1,
|
|
180
|
+
y: 1,
|
|
181
|
+
size: 1,
|
|
182
|
+
font: invisibleFont,
|
|
183
|
+
opacity: 0,
|
|
184
|
+
lineHeight: 1,
|
|
185
|
+
maxWidth: pageWidth - 2,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (markdownAttachment !== null) {
|
|
190
|
+
await pdf.attach(Buffer.from(markdownAttachment, 'utf8'), `${baseName}.md`, {
|
|
191
|
+
mimeType: 'text/markdown',
|
|
192
|
+
description: 'Editable semantic source for this rendered document',
|
|
193
|
+
creationDate: new Date(),
|
|
194
|
+
modificationDate: new Date(),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
throwIfAborted(signal);
|
|
198
|
+
await pdf.flush();
|
|
199
|
+
throwIfAborted(signal);
|
|
200
|
+
let processedObjects = 0;
|
|
201
|
+
class CancellablePdfWriter extends PDFWriter {
|
|
202
|
+
constructor() {
|
|
203
|
+
super(pdf.context, 1);
|
|
204
|
+
this.shouldWaitForTick = (count) => {
|
|
205
|
+
throwIfAborted(signal);
|
|
206
|
+
processedObjects += count;
|
|
207
|
+
serializationHooks.onPdfSerializationProgress?.(processedObjects);
|
|
208
|
+
throwIfAborted(signal);
|
|
209
|
+
return true;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const bytes = await new CancellablePdfWriter().serializeToBuffer();
|
|
214
|
+
throwIfAborted(signal);
|
|
215
|
+
return bytes;
|
|
216
|
+
}
|
|
217
|
+
function generatePptxArchive(archive, signal, onProgress) {
|
|
218
|
+
throwIfAborted(signal);
|
|
219
|
+
const stream = archive.generateInternalStream({ type: 'uint8array', compression: 'DEFLATE' });
|
|
220
|
+
return new Promise((resolve, reject) => {
|
|
221
|
+
const chunks = [];
|
|
222
|
+
let byteLength = 0;
|
|
223
|
+
let settled = false;
|
|
224
|
+
const cleanup = () => signal?.removeEventListener('abort', handleAbort);
|
|
225
|
+
const fail = (reason) => {
|
|
226
|
+
if (settled)
|
|
227
|
+
return;
|
|
228
|
+
settled = true;
|
|
229
|
+
stream.pause();
|
|
230
|
+
cleanup();
|
|
231
|
+
reject(reason);
|
|
232
|
+
};
|
|
233
|
+
const handleAbort = () => {
|
|
234
|
+
try {
|
|
235
|
+
throwIfAborted(signal);
|
|
236
|
+
}
|
|
237
|
+
catch (caught) {
|
|
238
|
+
fail(caught);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
signal?.addEventListener('abort', handleAbort, { once: true });
|
|
242
|
+
if (signal?.aborted) {
|
|
243
|
+
handleAbort();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
stream
|
|
247
|
+
.on('data', (chunk, metadata) => {
|
|
248
|
+
if (settled)
|
|
249
|
+
return;
|
|
250
|
+
try {
|
|
251
|
+
throwIfAborted(signal);
|
|
252
|
+
onProgress?.(metadata.percent);
|
|
253
|
+
throwIfAborted(signal);
|
|
254
|
+
chunks.push(chunk);
|
|
255
|
+
byteLength += chunk.byteLength;
|
|
256
|
+
}
|
|
257
|
+
catch (caught) {
|
|
258
|
+
fail(caught);
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
.on('error', (error) => fail(error))
|
|
262
|
+
.on('end', () => {
|
|
263
|
+
if (settled)
|
|
264
|
+
return;
|
|
265
|
+
try {
|
|
266
|
+
throwIfAborted(signal);
|
|
267
|
+
const bytes = new Uint8Array(byteLength);
|
|
268
|
+
let offset = 0;
|
|
269
|
+
for (const chunk of chunks) {
|
|
270
|
+
bytes.set(chunk, offset);
|
|
271
|
+
offset += chunk.byteLength;
|
|
272
|
+
}
|
|
273
|
+
settled = true;
|
|
274
|
+
cleanup();
|
|
275
|
+
resolve(bytes);
|
|
276
|
+
}
|
|
277
|
+
catch (caught) {
|
|
278
|
+
fail(caught);
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
.resume();
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
async function semanticTextByFrame(prepared, frames) {
|
|
285
|
+
const { analyzeBlocks } = await import('@bendyline/squisq/transform');
|
|
286
|
+
const analyzed = analyzeBlocks(prepared.doc.blocks);
|
|
287
|
+
return frames.map((frame) => {
|
|
288
|
+
const analyzedBlock = analyzed[frame.index];
|
|
289
|
+
return `${frame.label ?? ''}\n${analyzedBlock?.plainText ?? ''}`
|
|
290
|
+
.trim()
|
|
291
|
+
.slice(0, MAX_HYBRID_TEXT_CHARACTERS);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function renderedSlideXml(frame, semanticText, hybrid, slideSize) {
|
|
295
|
+
const description = escapeXml(frame.label ?? `Rendered slide ${frame.index + 1}`);
|
|
296
|
+
const placement = containedImagePlacement(frame, slideSize);
|
|
297
|
+
const hiddenText = hybrid
|
|
298
|
+
? `<p:sp><p:nvSpPr><p:cNvPr id="3" name="Semantic text" hidden="1"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>` +
|
|
299
|
+
`<p:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="1" cy="1"/></a:xfrm><a:noFill/></p:spPr>` +
|
|
300
|
+
`<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" sz="100"/>` +
|
|
301
|
+
`<a:t>${escapeXml(semanticText)}</a:t></a:r><a:endParaRPr lang="en-US"/></a:p></p:txBody></p:sp>`
|
|
302
|
+
: '';
|
|
303
|
+
return ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
304
|
+
'<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" ' +
|
|
305
|
+
'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' +
|
|
306
|
+
'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">' +
|
|
307
|
+
'<p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/>' +
|
|
308
|
+
`<p:pic><p:nvPicPr><p:cNvPr id="2" name="Rendered visual" descr="${description}"/>` +
|
|
309
|
+
'<p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr><p:nvPr/></p:nvPicPr>' +
|
|
310
|
+
'<p:blipFill><a:blip r:embed="rId2"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>' +
|
|
311
|
+
`<p:spPr><a:xfrm><a:off x="${placement.x}" y="${placement.y}"/><a:ext cx="${placement.width}" cy="${placement.height}"/></a:xfrm>` +
|
|
312
|
+
'<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr></p:pic>' +
|
|
313
|
+
`${hiddenText}</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sld>`);
|
|
314
|
+
}
|
|
315
|
+
function renderedPptxSlideSize(frame) {
|
|
316
|
+
if (frame.width < 1 || frame.height < 1) {
|
|
317
|
+
throw new Error('Rendered PPTX frame dimensions must be positive');
|
|
318
|
+
}
|
|
319
|
+
const aspect = frame.width / frame.height;
|
|
320
|
+
return aspect >= 1
|
|
321
|
+
? {
|
|
322
|
+
width: Math.round(PPTX_REFERENCE_SHORT_EDGE_EMU * aspect),
|
|
323
|
+
height: PPTX_REFERENCE_SHORT_EDGE_EMU,
|
|
324
|
+
}
|
|
325
|
+
: {
|
|
326
|
+
width: PPTX_REFERENCE_SHORT_EDGE_EMU,
|
|
327
|
+
height: Math.round(PPTX_REFERENCE_SHORT_EDGE_EMU / aspect),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function containedImagePlacement(frame, slideSize) {
|
|
331
|
+
const scale = Math.min(slideSize.width / frame.width, slideSize.height / frame.height);
|
|
332
|
+
const width = Math.round(frame.width * scale);
|
|
333
|
+
const height = Math.round(frame.height * scale);
|
|
334
|
+
return {
|
|
335
|
+
x: Math.round((slideSize.width - width) / 2),
|
|
336
|
+
y: Math.round((slideSize.height - height) / 2),
|
|
337
|
+
width,
|
|
338
|
+
height,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function slideRelationshipsXml(slideNumber) {
|
|
342
|
+
return ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
343
|
+
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' +
|
|
344
|
+
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>' +
|
|
345
|
+
`<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/rendered${slideNumber}.png"/>` +
|
|
346
|
+
'</Relationships>');
|
|
347
|
+
}
|
|
348
|
+
function escapeXml(value) {
|
|
349
|
+
return value
|
|
350
|
+
.replace(/&/gu, '&')
|
|
351
|
+
.replace(/</gu, '<')
|
|
352
|
+
.replace(/>/gu, '>')
|
|
353
|
+
.replace(/"/gu, '"')
|
|
354
|
+
.replace(/'/gu, ''');
|
|
355
|
+
}
|
|
356
|
+
function numericOption(options, name, fallback) {
|
|
357
|
+
const value = options[name];
|
|
358
|
+
return typeof value === 'number' ? value : fallback;
|
|
359
|
+
}
|
|
360
|
+
function asWinAnsiText(value) {
|
|
361
|
+
const sanitized = value.replace(/[^\x20-\x7e\r\n\t]/gu, '?').slice(0, MAX_HYBRID_TEXT_CHARACTERS);
|
|
362
|
+
return sanitized || ' ';
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=rendered-conversion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rendered-conversion.js","sourceRoot":"","sources":["../../src/mcp/rendered-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,6BAA6B,GAG9B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,6BAA6B,GAAG,OAAS,CAAC;AAChD,MAAM,0BAA0B,GAAG,IAAK,CAAC;AAiCzC,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAA0B,EAC1B,MAAc,EACd,QAA4B,EAC5B,OAAmE,EACnE,eAAwC,EACxC,MAAoB,EACpB,QAA0B,EAC1B,UAAgC,6BAA6B;IAE7D,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,gDAAgD,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAK,CAAC,CAAC;IACrD,MAAM,MAAM,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,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtD,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC;IAClG,OAAO,SAAS,IAAI,GAAG,CAAC;AAC1B,CAAC"}
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -1,12 +1,69 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DocBlocks MCP Server
|
|
3
|
-
*
|
|
4
|
-
* Exposes document conversion, analysis, and transformation tools
|
|
5
|
-
* via the Model Context Protocol (MCP) over stdio.
|
|
6
|
-
*
|
|
7
|
-
* Designed for AI agents: tools accept raw markdown text so agents
|
|
8
|
-
* can write content and immediately export it without temp files.
|
|
9
|
-
*/
|
|
10
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
11
|
-
|
|
2
|
+
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
3
|
+
import type { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { MCP_CONVERSION_TARGET_FORMATS, MCP_FORMAT_CAPABILITIES } from './agentic-tools.js';
|
|
5
|
+
import { type ArtifactStoreOptions } from './artifact-store.js';
|
|
6
|
+
import { type McpFileAuthorityOptions } from './authority.js';
|
|
7
|
+
export interface McpServerOptions extends McpFileAuthorityOptions, ArtifactStoreOptions {
|
|
8
|
+
maxConcurrentOperations?: number;
|
|
9
|
+
operationTimeoutMs?: number;
|
|
10
|
+
/** Bound cleanup latency after shutdown has aborted every active operation. */
|
|
11
|
+
shutdownDrainTimeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Bounds expensive work while preserving the exact caller cancellation reason. */
|
|
14
|
+
export declare class OperationGuard {
|
|
15
|
+
private readonly maximum;
|
|
16
|
+
private readonly timeoutMs;
|
|
17
|
+
private readonly shutdownDrainTimeoutMs;
|
|
18
|
+
private active;
|
|
19
|
+
private accepting;
|
|
20
|
+
private readonly controllers;
|
|
21
|
+
private readonly completions;
|
|
22
|
+
private shutdownPromise;
|
|
23
|
+
constructor(maximum: number, timeoutMs: number, shutdownDrainTimeoutMs?: number);
|
|
24
|
+
run<T>(requestSignal: AbortSignal, work: (operationSignal: AbortSignal) => Promise<T>): Promise<T>;
|
|
25
|
+
/** Stop admission, abort active work, and wait for all operation cleanup before disposal. */
|
|
26
|
+
shutdown(): Promise<void>;
|
|
27
|
+
private drain;
|
|
28
|
+
}
|
|
29
|
+
export declare class OperationTimeoutError extends Error {
|
|
30
|
+
readonly code = "timeout";
|
|
31
|
+
readonly hint: string;
|
|
32
|
+
constructor(timeoutMs: number);
|
|
33
|
+
}
|
|
34
|
+
export declare class OperationBusyError extends Error {
|
|
35
|
+
readonly active: number;
|
|
36
|
+
readonly capacity: number;
|
|
37
|
+
readonly code = "busy";
|
|
38
|
+
readonly hint: string;
|
|
39
|
+
readonly retryable = true;
|
|
40
|
+
constructor(active: number, capacity: number);
|
|
41
|
+
}
|
|
42
|
+
export declare class OperationClosingError extends Error {
|
|
43
|
+
readonly code = "server-closing";
|
|
44
|
+
readonly hint = "Reconnect to a running DocBlocks MCP server before retrying.";
|
|
45
|
+
readonly retryable = true;
|
|
46
|
+
constructor();
|
|
47
|
+
}
|
|
48
|
+
export declare class OperationShutdownError extends Error {
|
|
49
|
+
readonly code = "server-shutdown";
|
|
50
|
+
readonly hint = "Reconnect to a running DocBlocks MCP server before retrying.";
|
|
51
|
+
readonly retryable = true;
|
|
52
|
+
constructor();
|
|
53
|
+
}
|
|
54
|
+
export declare class OperationDrainTimeoutError extends Error {
|
|
55
|
+
readonly code = "shutdown-drain-timeout";
|
|
56
|
+
readonly hint = "Wait for active converter cleanup, then close the server again.";
|
|
57
|
+
readonly retryable = true;
|
|
58
|
+
constructor(timeoutMs: number);
|
|
59
|
+
}
|
|
60
|
+
/** Retains every independent failure encountered while closing the server. */
|
|
61
|
+
export declare class McpServerShutdownError extends Error {
|
|
62
|
+
readonly errors: readonly unknown[];
|
|
63
|
+
readonly cause: unknown;
|
|
64
|
+
constructor(errors: readonly unknown[]);
|
|
65
|
+
}
|
|
66
|
+
export type McpToolRequestExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
67
|
+
export declare function createMcpServer(options?: McpServerOptions): McpServer;
|
|
68
|
+
export { MCP_CONVERSION_TARGET_FORMATS, MCP_FORMAT_CAPABILITIES };
|
|
12
69
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAE5F,OAAO,EAEL,6BAA6B,EAC7B,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAQhF,MAAM,WAAW,gBAAiB,SAAQ,uBAAuB,EAAE,oBAAoB;IACrF,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,m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