@attentionform/astra-mcp-server 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -5
- package/dist/index.js +4594 -1709
- package/dist/lib/mcp/baseline-gate.d.ts +71 -0
- package/dist/lib/mcp/handlers/open-inspect.d.ts +2 -0
- package/dist/lib/mcp/handlers/parity.d.ts +16 -1
- package/dist/lib/mcp/handlers/save-close.d.ts +20 -0
- package/dist/lib/mcp/schemas.d.ts +5 -0
- package/dist/lib/session-store.d.ts +11 -1
- package/dist/tools/export.d.ts +10 -0
- package/package.json +3 -3
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type BaselineVerdict, type ValidationBaseline, type ValidationResult } from '@attentionform/astra-engine';
|
|
2
|
+
import type { DocHandle } from '../session-store';
|
|
3
|
+
/** Set by the `--strict-validation` flag. */
|
|
4
|
+
export declare function setStrictValidationDefault(value: boolean): void;
|
|
5
|
+
/** True when a save refuses every validator error, whether or not the file had it before. */
|
|
6
|
+
export declare function strictValidationDefault(): boolean;
|
|
7
|
+
/** Set by the `--open-validation-timeout` flag. */
|
|
8
|
+
export declare function setOpenValidationTimeoutMs(value: number): void;
|
|
9
|
+
/** How long open_document waits for the validator, in milliseconds. 0 skips the check. */
|
|
10
|
+
export declare function openValidationTimeoutMs(): number;
|
|
11
|
+
export declare function sha256Hex(bytes: Buffer): string;
|
|
12
|
+
/** Validates a package with the full error list, so the result can be compared. */
|
|
13
|
+
export declare function validateForBaseline(bytes: Buffer): Promise<ValidationResult>;
|
|
14
|
+
/** Stores the baseline of a package the session now holds as its saved state. */
|
|
15
|
+
export declare function adoptBaseline(handle: DocHandle, result: ValidationResult): void;
|
|
16
|
+
/**
|
|
17
|
+
* The baseline of a session. When the open did not produce one (timed out or skipped), the file on
|
|
18
|
+
* disk is validated, but only when it is still the file that was opened. Otherwise null, and the
|
|
19
|
+
* save is judged as not comparable.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveBaseline(handle: DocHandle): Promise<ValidationBaseline | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Verdict for a package that revert_document or redo_document restores. Such a state was saved before,
|
|
24
|
+
* so it is allowed to carry the errors the file had when it was opened, as well as the errors of the
|
|
25
|
+
* saved state of the session. Anything beyond both is refused.
|
|
26
|
+
*/
|
|
27
|
+
export declare function judgeRestoredPackage(handle: DocHandle, result: ValidationResult): Promise<BaselineVerdict>;
|
|
28
|
+
/** The first `limit` descriptions of a result, cut to a readable length. */
|
|
29
|
+
export declare function firstMessages(result: ValidationResult, limit?: number): string[];
|
|
30
|
+
/** The error a save or normalize raises when the edit adds validator errors. */
|
|
31
|
+
export declare function introducedError(toolName: string, verdict: Extract<BaselineVerdict, {
|
|
32
|
+
kind: 'introduced';
|
|
33
|
+
}>): Error;
|
|
34
|
+
/** The `validation` field of an answer for a result that was judged. */
|
|
35
|
+
export declare function validationField(result: ValidationResult, verdict: BaselineVerdict): {
|
|
36
|
+
ok: false;
|
|
37
|
+
tolerated: true;
|
|
38
|
+
preExistingErrors: number;
|
|
39
|
+
introducedErrors: 0;
|
|
40
|
+
messages: string[];
|
|
41
|
+
} | {
|
|
42
|
+
ok: true;
|
|
43
|
+
tolerated?: undefined;
|
|
44
|
+
preExistingErrors?: undefined;
|
|
45
|
+
introducedErrors?: undefined;
|
|
46
|
+
messages?: undefined;
|
|
47
|
+
};
|
|
48
|
+
/** Adds the note about existing errors to a commit message; the message is cut, the note never. */
|
|
49
|
+
export declare function withToleratedNote(message: string, preExisting: number): string;
|
|
50
|
+
export type OpenValidationField = {
|
|
51
|
+
status: 'valid';
|
|
52
|
+
} | {
|
|
53
|
+
status: 'invalid';
|
|
54
|
+
preExistingErrors: number;
|
|
55
|
+
baselineComparable: boolean;
|
|
56
|
+
messages: string[];
|
|
57
|
+
degraded: true;
|
|
58
|
+
note: string;
|
|
59
|
+
} | {
|
|
60
|
+
status: 'timed-out';
|
|
61
|
+
degraded: 'unknown';
|
|
62
|
+
note: string;
|
|
63
|
+
} | {
|
|
64
|
+
status: 'skipped';
|
|
65
|
+
note?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Validates the file that was just opened and stores its baseline on the handle. The open itself is
|
|
69
|
+
* never refused for these reasons, and nothing is reported as valid unless the validator said so.
|
|
70
|
+
*/
|
|
71
|
+
export declare function validateAtOpen(handle: DocHandle, timeoutMs: number): Promise<OpenValidationField>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocxParser, type StyleGuideSummary } from '@attentionform/astra-engine';
|
|
2
2
|
import type { McpSessionStore } from '../../session-store';
|
|
3
3
|
import type { McpErrorShape } from '../errors';
|
|
4
|
+
import { type OpenValidationField } from '../baseline-gate';
|
|
4
5
|
export interface StylePalette {
|
|
5
6
|
availableStyles: string[];
|
|
6
7
|
brandColors: string[];
|
|
@@ -15,6 +16,7 @@ export declare function handleOpenDocument(store: McpSessionStore, input: unknow
|
|
|
15
16
|
summary: unknown;
|
|
16
17
|
evicted: string[];
|
|
17
18
|
pendingNormalizations: string[];
|
|
19
|
+
validation: OpenValidationField;
|
|
18
20
|
} | McpErrorShape>;
|
|
19
21
|
/**
|
|
20
22
|
* Phase C-2: docs rendering under ~2000 tokens return the full TOON
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PII_COVERAGE } from '@attentionform/astra-engine';
|
|
1
2
|
import { type McpSessionStore } from '../../session-store';
|
|
2
3
|
import { handleComposeDocument } from '../../../tools/compose-document';
|
|
3
4
|
import type { McpErrorShape } from '../errors';
|
|
@@ -23,6 +24,8 @@ export declare function handleValidateDocument(store: McpSessionStore, input: un
|
|
|
23
24
|
validation: AuditValidation;
|
|
24
25
|
/** Repairs a save would make (e.g. children put in schema order); absent when none. */
|
|
25
26
|
pendingNormalizations?: string[];
|
|
27
|
+
/** Advice when normalize_document can repair errors in the document. */
|
|
28
|
+
normalizeHint?: string;
|
|
26
29
|
} | McpErrorShape>;
|
|
27
30
|
/**
|
|
28
31
|
* get_stats: token-cheap census over the live AST (pure read: no revision
|
|
@@ -51,6 +54,8 @@ export interface SanitizeDocumentOk {
|
|
|
51
54
|
strippedExifBytes: number;
|
|
52
55
|
purgedPII: number;
|
|
53
56
|
bodyPII: number;
|
|
57
|
+
piiCoverage: typeof PII_COVERAGE;
|
|
58
|
+
piiNote: string;
|
|
54
59
|
acceptedRevisions: number;
|
|
55
60
|
strippedComments: number;
|
|
56
61
|
strippedMacros: string[];
|
|
@@ -86,7 +91,17 @@ export declare function handleNormalizeDocument(store: McpSessionStore, input: u
|
|
|
86
91
|
revision: number;
|
|
87
92
|
dirty: boolean;
|
|
88
93
|
normalized: string[];
|
|
89
|
-
|
|
94
|
+
preStateCommit?: string;
|
|
95
|
+
remaining: number;
|
|
96
|
+
rolledBack: {
|
|
97
|
+
rule: string;
|
|
98
|
+
reason: string;
|
|
99
|
+
}[];
|
|
100
|
+
validation: AuditValidation & {
|
|
101
|
+
tolerated?: true;
|
|
102
|
+
preExistingErrors?: number;
|
|
103
|
+
introducedErrors?: 0;
|
|
104
|
+
};
|
|
90
105
|
revisionsPending: number;
|
|
91
106
|
revisionsRemedy?: string;
|
|
92
107
|
redoCleared?: boolean;
|
|
@@ -21,6 +21,16 @@ export declare function executeSaveDocument(store: McpSessionStore, input: unkno
|
|
|
21
21
|
revision: number;
|
|
22
22
|
commitOid: string;
|
|
23
23
|
commitMessage: string;
|
|
24
|
+
/** Result of the validator gate: clean, or tolerated with the number of errors the file already had. */
|
|
25
|
+
validation: {
|
|
26
|
+
ok: true;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
tolerated: true;
|
|
30
|
+
preExistingErrors: number;
|
|
31
|
+
introducedErrors: 0;
|
|
32
|
+
messages: string[];
|
|
33
|
+
};
|
|
24
34
|
/** R-1: pending tracked revisions (w:ins + w:del) in the saved package. */
|
|
25
35
|
revisionsPending: number;
|
|
26
36
|
/** R-1: accept remedy, present only when revisionsPending > 0. */
|
|
@@ -52,6 +62,16 @@ export declare function handleSaveDocument(store: McpSessionStore, input: unknow
|
|
|
52
62
|
revision: number;
|
|
53
63
|
commitOid: string;
|
|
54
64
|
commitMessage: string;
|
|
65
|
+
/** Result of the validator gate: clean, or tolerated with the number of errors the file already had. */
|
|
66
|
+
validation: {
|
|
67
|
+
ok: true;
|
|
68
|
+
} | {
|
|
69
|
+
ok: false;
|
|
70
|
+
tolerated: true;
|
|
71
|
+
preExistingErrors: number;
|
|
72
|
+
introducedErrors: 0;
|
|
73
|
+
messages: string[];
|
|
74
|
+
};
|
|
55
75
|
/** R-1: pending tracked revisions (w:ins + w:del) in the saved package. */
|
|
56
76
|
revisionsPending: number;
|
|
57
77
|
/** R-1: accept remedy, present only when revisionsPending > 0. */
|
|
@@ -6,6 +6,7 @@ export declare const OpenDocumentSchema: z.ZodObject<{
|
|
|
6
6
|
allowMacros: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
stripMacros: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
author: z.ZodOptional<z.ZodString>;
|
|
9
|
+
validationTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
9
10
|
}, z.core.$strict>;
|
|
10
11
|
export declare const InspectDocumentSchema: z.ZodObject<{
|
|
11
12
|
sessionId: z.ZodString;
|
|
@@ -345,6 +346,7 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
|
|
|
345
346
|
col: z.ZodOptional<z.ZodNumber>;
|
|
346
347
|
columnIndex: z.ZodOptional<z.ZodNumber>;
|
|
347
348
|
text: z.ZodOptional<z.ZodString>;
|
|
349
|
+
cells: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
348
350
|
afterIndex: z.ZodOptional<z.ZodNumber>;
|
|
349
351
|
index: z.ZodOptional<z.ZodNumber>;
|
|
350
352
|
fill: z.ZodOptional<z.ZodString>;
|
|
@@ -738,6 +740,7 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
|
|
|
738
740
|
anchor: z.ZodString;
|
|
739
741
|
text: z.ZodString;
|
|
740
742
|
id: z.ZodOptional<z.ZodString>;
|
|
743
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
741
744
|
expectedVersion: z.ZodOptional<z.ZodNumber>;
|
|
742
745
|
}, z.core.$strict>, z.ZodObject<{
|
|
743
746
|
action: z.ZodLiteral<"endnote">;
|
|
@@ -747,6 +750,7 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
|
|
|
747
750
|
anchor: z.ZodString;
|
|
748
751
|
text: z.ZodString;
|
|
749
752
|
id: z.ZodOptional<z.ZodString>;
|
|
753
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
750
754
|
expectedVersion: z.ZodOptional<z.ZodNumber>;
|
|
751
755
|
}, z.core.$strict>, z.ZodObject<{
|
|
752
756
|
action: z.ZodLiteral<"watermark">;
|
|
@@ -862,6 +866,7 @@ export declare const SaveDocumentSchema: z.ZodObject<{
|
|
|
862
866
|
author: z.ZodOptional<z.ZodString>;
|
|
863
867
|
allowMacros: z.ZodOptional<z.ZodBoolean>;
|
|
864
868
|
stripMacros: z.ZodOptional<z.ZodBoolean>;
|
|
869
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
865
870
|
}, z.core.$strict>;
|
|
866
871
|
export declare const CloseDocumentSchema: z.ZodObject<{
|
|
867
872
|
sessionId: z.ZodString;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DocumentAST, type DocxParserMacroOptions, DocxParser, OperationEngine, ToonGenerator, canonicalizeForAsset as canonicalizeForMcp, type StyleGuideConfig } from '@attentionform/astra-engine';
|
|
1
|
+
import { type DocumentAST, type DocxParserMacroOptions, DocxParser, OperationEngine, ToonGenerator, canonicalizeForAsset as canonicalizeForMcp, type StyleGuideConfig, type ValidationBaseline } from '@attentionform/astra-engine';
|
|
2
2
|
/**
|
|
3
3
|
* Sprint-2 Muse session store (MCP Lean-6 backing).
|
|
4
4
|
*
|
|
@@ -136,6 +136,16 @@ export interface DocHandle {
|
|
|
136
136
|
styleGuide?: StyleGuideConfig;
|
|
137
137
|
/** Raw guide ref the session guide was resolved from (name or file path). */
|
|
138
138
|
styleGuideRef?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Validator errors the saved state of the session already has, by signature. `undefined` means the
|
|
141
|
+
* open did not finish a check (timed out or skipped); `null` means a check ran but its result
|
|
142
|
+
* cannot be compared (cut short, or an exception).
|
|
143
|
+
*/
|
|
144
|
+
validationBaseline?: ValidationBaseline | null;
|
|
145
|
+
/** The baseline at open, kept when a save replaces `validationBaseline`: a revert may return to a state with these errors. */
|
|
146
|
+
openBaseline?: ValidationBaseline | null;
|
|
147
|
+
/** sha256 of the file bytes read at open, to tell whether the file on disk is still the opened one. */
|
|
148
|
+
openSha256?: string;
|
|
139
149
|
}
|
|
140
150
|
/**
|
|
141
151
|
* Per-commit audit metadata recorded alongside each history commit.
|
package/dist/tools/export.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ export declare const ExportDocumentSchema: z.ZodObject<{
|
|
|
10
10
|
pdf: "pdf";
|
|
11
11
|
}>;
|
|
12
12
|
outPath: z.ZodOptional<z.ZodString>;
|
|
13
|
+
imageMode: z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
file: "file";
|
|
15
|
+
embed: "embed";
|
|
16
|
+
}>>;
|
|
17
|
+
assetPrefix: z.ZodOptional<z.ZodString>;
|
|
13
18
|
tagged_pdf: z.ZodOptional<z.ZodBoolean>;
|
|
14
19
|
tagged: z.ZodOptional<z.ZodBoolean>;
|
|
15
20
|
strict: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -27,6 +32,7 @@ export declare function mapExportError(err: unknown): {
|
|
|
27
32
|
remedy: string;
|
|
28
33
|
};
|
|
29
34
|
export declare function validateExportTarget(rawPath: unknown, expectedFormat: 'html' | 'markdown' | 'md' | 'pdf'): string;
|
|
35
|
+
export declare function validateAssetTarget(rawPath: unknown): string;
|
|
30
36
|
export declare function handleExportDocument(store: McpSessionStore, rawArgs: unknown): Promise<{
|
|
31
37
|
ok: boolean;
|
|
32
38
|
format?: string;
|
|
@@ -35,6 +41,10 @@ export declare function handleExportDocument(store: McpSessionStore, rawArgs: un
|
|
|
35
41
|
content?: string;
|
|
36
42
|
dirty?: boolean;
|
|
37
43
|
revision?: number;
|
|
44
|
+
imageMode?: 'file' | 'embed';
|
|
45
|
+
assetPrefix?: string;
|
|
46
|
+
assets?: string[];
|
|
47
|
+
assetCount?: number;
|
|
38
48
|
warnings?: PreflightIssue[];
|
|
39
49
|
blockers?: PreflightIssue[];
|
|
40
50
|
message?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attentionform/astra-mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official Model Context Protocol (MCP) server for ASTra document IDE",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"adm-zip-gate": "node ../../scripts/check-adm-zip-imports.mjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@attentionform/astra-engine": "^0.
|
|
45
|
-
"@attentionform/ooxml-validator": "^0.
|
|
44
|
+
"@attentionform/astra-engine": "^0.2.0",
|
|
45
|
+
"@attentionform/ooxml-validator": "^0.2.0",
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
47
47
|
"@xmldom/xmldom": "0.8.15",
|
|
48
48
|
"adm-zip": "0.6.1",
|