@attentionform/astra-mcp-server 0.0.0-stage → 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/LICENSE +206 -0
- package/NOTICE +12 -0
- package/README.md +488 -2
- package/dist/index.d.ts +63 -0
- package/dist/index.js +41004 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/mcp/descriptions.d.ts +12 -0
- package/dist/lib/mcp/diff.d.ts +220 -0
- package/dist/lib/mcp/errors.d.ts +45 -0
- package/dist/lib/mcp/handlers/export-audit.d.ts +34 -0
- package/dist/lib/mcp/handlers/history.d.ts +93 -0
- package/dist/lib/mcp/handlers/open-inspect.d.ts +69 -0
- package/dist/lib/mcp/handlers/parity.d.ts +112 -0
- package/dist/lib/mcp/handlers/save-close.d.ts +76 -0
- package/dist/lib/mcp/handlers/search-batch.d.ts +55 -0
- package/dist/lib/mcp/normalize-read.d.ts +11 -0
- package/dist/lib/mcp/registry.d.ts +12 -0
- package/dist/lib/mcp/schema-dump.d.ts +24 -0
- package/dist/lib/mcp/schemas.d.ts +948 -0
- package/dist/lib/mcp/tool-names.d.ts +15 -0
- package/dist/lib/mcp-tool-adapter.d.ts +12 -0
- package/dist/lib/session-store.d.ts +422 -0
- package/dist/tools/compose-document.d.ts +124 -0
- package/dist/tools/export.d.ts +43 -0
- package/dist/tools/new-document.d.ts +53 -0
- package/dist/tools/visual.d.ts +161 -0
- package/package.json +69 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type StyleWarning } from '@attentionform/astra-engine';
|
|
2
|
+
import type { McpSessionStore } from '../../session-store';
|
|
3
|
+
import type { McpErrorShape } from '../errors';
|
|
4
|
+
import type { ChangedValue } from '../diff';
|
|
5
|
+
/**
|
|
6
|
+
* Validating save — throwing core.
|
|
7
|
+
* M2 contract (consistent, tested):
|
|
8
|
+
* - executeSaveDocument THROWS on every failure (invalid input E_VALIDATION,
|
|
9
|
+
* unknown/expired session E_SESSION, sandbox escape E_SANDBOX, invalid
|
|
10
|
+
* package E_VALIDATION, write failure E_IO). All throws carry {code,remedy}.
|
|
11
|
+
* - handleSaveDocument NEVER throws: it wraps this core and maps every throw
|
|
12
|
+
* to the {ok:false,code,remedy} return contract. Tool transport MUST go
|
|
13
|
+
* through handleSaveDocument (single source of truth).
|
|
14
|
+
* Never writes corruption: OOXML validation gates the write, and the save
|
|
15
|
+
* target is jailed (M3) before any mkdir/write.
|
|
16
|
+
*/
|
|
17
|
+
export declare function executeSaveDocument(store: McpSessionStore, input: unknown): Promise<{
|
|
18
|
+
ok: true;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
path: string;
|
|
21
|
+
revision: number;
|
|
22
|
+
commitOid: string;
|
|
23
|
+
commitMessage: string;
|
|
24
|
+
/** R-1: pending tracked revisions (w:ins + w:del) in the saved package. */
|
|
25
|
+
revisionsPending: number;
|
|
26
|
+
/** R-1: accept remedy, present only when revisionsPending > 0. */
|
|
27
|
+
revisionsRemedy?: string;
|
|
28
|
+
/** Advisory old→new value summaries (saved baseline -> live just saved; bounded, see CHANGED_VALUES_MAX). */
|
|
29
|
+
changedValues: ChangedValue[];
|
|
30
|
+
/** True when the count or per-string cap truncated changedValues. */
|
|
31
|
+
changedValuesTruncated: boolean;
|
|
32
|
+
/** Present when no baseline was computable (new target / unreadable bytes). */
|
|
33
|
+
changedValuesReason?: string;
|
|
34
|
+
/** Normalizer rewrites applied by this save (display-only core log). */
|
|
35
|
+
normalized: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Advisory style findings under the session guide (never blocking).
|
|
38
|
+
* Absent when no guide is attached (guide-less saves stay byte-identical).
|
|
39
|
+
*/
|
|
40
|
+
styleWarnings?: StyleWarning[];
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* M2: return-contract wrapper — NEVER throws.
|
|
44
|
+
* Maps every executeSaveDocument throw to {ok:false,code,remedy} so tool
|
|
45
|
+
* transport sees a single consistent shape. Tested: invalid input, sandbox
|
|
46
|
+
* escape, unknown session, and validation failure all return (never throw).
|
|
47
|
+
*/
|
|
48
|
+
export declare function handleSaveDocument(store: McpSessionStore, input: unknown): Promise<{
|
|
49
|
+
ok: true;
|
|
50
|
+
sessionId: string;
|
|
51
|
+
path: string;
|
|
52
|
+
revision: number;
|
|
53
|
+
commitOid: string;
|
|
54
|
+
commitMessage: string;
|
|
55
|
+
/** R-1: pending tracked revisions (w:ins + w:del) in the saved package. */
|
|
56
|
+
revisionsPending: number;
|
|
57
|
+
/** R-1: accept remedy, present only when revisionsPending > 0. */
|
|
58
|
+
revisionsRemedy?: string;
|
|
59
|
+
/** Advisory old→new value summaries (saved baseline -> live just saved; bounded). */
|
|
60
|
+
changedValues: ChangedValue[];
|
|
61
|
+
/** True when the count or per-string cap truncated changedValues. */
|
|
62
|
+
changedValuesTruncated: boolean;
|
|
63
|
+
/** Present when no baseline was computable. */
|
|
64
|
+
changedValuesReason?: string;
|
|
65
|
+
/** Normalizer rewrites applied by this save (display-only core log). */
|
|
66
|
+
normalized: string[];
|
|
67
|
+
/** Advisory style findings under the session guide (absent without a guide). */
|
|
68
|
+
styleWarnings?: StyleWarning[];
|
|
69
|
+
} | McpErrorShape>;
|
|
70
|
+
export declare function handleCloseDocument(store: McpSessionStore, input: unknown): Promise<{
|
|
71
|
+
ok: true;
|
|
72
|
+
sessionId: string;
|
|
73
|
+
dirty: boolean;
|
|
74
|
+
discardedRevisions: number;
|
|
75
|
+
warning?: string;
|
|
76
|
+
} | McpErrorShape>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type McpSessionStore } from '../../session-store';
|
|
2
|
+
import type { McpErrorShape } from '../errors';
|
|
3
|
+
import type { BatchOpCreatedIds } from '../diff';
|
|
4
|
+
/**
|
|
5
|
+
* Phase C-3 bounds: regex patterns longer than this are rejected
|
|
6
|
+
* fail-closed (the base query cap is 500; regex gets a tighter bound).
|
|
7
|
+
*/
|
|
8
|
+
export declare const SEARCH_REGEX_MAX_PATTERN = 200;
|
|
9
|
+
/** Phase C-3: wall-clock budget for one regex evaluation pass over the AST. */
|
|
10
|
+
export declare const SEARCH_REGEX_TIME_BUDGET_MS = 500;
|
|
11
|
+
/** Generic remedy for regex search failures (no pattern echo, no hit hint). */
|
|
12
|
+
export declare const SEARCH_REGEX_GENERIC_REMEDY = "Fix the regular-expression syntax and retry, or omit regex:true for a literal substring search.";
|
|
13
|
+
export declare function handleSearchContent(store: McpSessionStore, input: unknown): Promise<{
|
|
14
|
+
ok: true;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
matches: Array<{
|
|
17
|
+
id: string;
|
|
18
|
+
preview: string;
|
|
19
|
+
cells?: string[];
|
|
20
|
+
}>;
|
|
21
|
+
results: Array<{
|
|
22
|
+
id: string;
|
|
23
|
+
preview: string;
|
|
24
|
+
cells?: string[];
|
|
25
|
+
}>;
|
|
26
|
+
hint?: string;
|
|
27
|
+
} | McpErrorShape>;
|
|
28
|
+
export declare function handleExecuteBatch(store: McpSessionStore, input: unknown): Promise<{
|
|
29
|
+
ok: true;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
appliedCount: number;
|
|
32
|
+
revision: number;
|
|
33
|
+
skippedIds: string[];
|
|
34
|
+
/** Advisory table warnings (additive, never a failure). */
|
|
35
|
+
warnings: string[];
|
|
36
|
+
/** New node ids created by this batch, in post-batch document order. */
|
|
37
|
+
createdNodeIds: string[];
|
|
38
|
+
/** Per-op attribution (client `id` claims are exact; remainder best-effort). */
|
|
39
|
+
results: BatchOpCreatedIds[];
|
|
40
|
+
/** R-1: pending tracked revisions (w:ins + w:del) remaining after the batch. */
|
|
41
|
+
revisionsPending: number;
|
|
42
|
+
/** R-1: accept remedy, present only when revisionsPending > 0. */
|
|
43
|
+
revisionsRemedy?: string;
|
|
44
|
+
/** R-14: advisory chart stale body refs (same shape [{nodeId, preview}]). Additive, never a failure. */
|
|
45
|
+
possiblyStaleBodyRefs: {
|
|
46
|
+
nodeId: string;
|
|
47
|
+
preview: string;
|
|
48
|
+
}[];
|
|
49
|
+
/** Normalizer rewrites reported for this batch (display-only core log). */
|
|
50
|
+
normalized: string[];
|
|
51
|
+
/** True only when this batch dropped a non-empty redo stack (absent otherwise). */
|
|
52
|
+
redoCleared?: boolean;
|
|
53
|
+
/** Names the dropped redo depth (present only when redoCleared). */
|
|
54
|
+
redoClearedWarning?: string;
|
|
55
|
+
} | McpErrorShape>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type NormalizedRewrite = string;
|
|
2
|
+
/** Display-only read of an engine result's `normalized` report ([] when absent). */
|
|
3
|
+
export declare function readEngineNormalized(res: unknown): NormalizedRewrite[];
|
|
4
|
+
/** Display-only read of the core's own normalizer log ([] when absent). */
|
|
5
|
+
export declare function readParserNormalizations(parser: unknown): NormalizedRewrite[];
|
|
6
|
+
/**
|
|
7
|
+
* Merge core logs across the rezips one save performs (gate rezip + save
|
|
8
|
+
* rezip), dropping exact duplicates. The gate's internal rezip already heals
|
|
9
|
+
* and logs, so reading only the final rezip would report a dishonest zero.
|
|
10
|
+
*/
|
|
11
|
+
export declare function mergeNormalized(...lists: string[][]): string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { handleOpenDocument, handleInspectDocument } from './handlers/open-inspect';
|
|
2
|
+
import { handleSearchContent, handleExecuteBatch } from './handlers/search-batch';
|
|
3
|
+
import { handleSaveDocument, handleCloseDocument } from './handlers/save-close';
|
|
4
|
+
/** Lean-6 dispatch table (handlers above; research intentionally absent). */
|
|
5
|
+
export declare const LEAN6_HANDLERS: {
|
|
6
|
+
readonly open_document: typeof handleOpenDocument;
|
|
7
|
+
readonly inspect_document: typeof handleInspectDocument;
|
|
8
|
+
readonly search_content: typeof handleSearchContent;
|
|
9
|
+
readonly execute_batch: typeof handleExecuteBatch;
|
|
10
|
+
readonly save_document: typeof handleSaveDocument;
|
|
11
|
+
readonly close_document: typeof handleCloseDocument;
|
|
12
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const SCHEMA_STAMP_KEY = "x-generated-from";
|
|
2
|
+
export declare function getServerVersion(): string;
|
|
3
|
+
export interface ToolDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare function getToolDefinitions(): ToolDefinition[];
|
|
9
|
+
export declare function buildStamp(version: string): string;
|
|
10
|
+
export declare function generateSchemasToDir(targetDir: string, version?: string): {
|
|
11
|
+
written: string[];
|
|
12
|
+
count: number;
|
|
13
|
+
};
|
|
14
|
+
export interface SchemaMismatch {
|
|
15
|
+
file: string;
|
|
16
|
+
stamped: string;
|
|
17
|
+
expected: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function checkSchemasInDir(dir: string, expectedVersion?: string): {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
mismatches: SchemaMismatch[];
|
|
22
|
+
checked: number;
|
|
23
|
+
};
|
|
24
|
+
export declare function formatMismatchWarning(mismatches: SchemaMismatch[]): string;
|