@ai-matrx/rich-content 0.0.0 → 0.2.2
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/CHANGELOG.md +72 -0
- package/LICENSE +1 -1
- package/README.md +58 -3
- package/dist/display/blocks/csv/CsvBlock.d.ts +10 -0
- package/dist/display/blocks/csv/CsvBlock.js +245 -0
- package/dist/display/blocks/table/parseMarkdownTable.d.ts +20 -0
- package/dist/display/blocks/table/parseMarkdownTable.js +35 -0
- package/dist/display/chat-markdown/citations/remarkMatrxCite.d.ts +33 -0
- package/dist/display/chat-markdown/citations/remarkMatrxCite.js +71 -0
- package/dist/display/chat-markdown/matrx-variables/remarkMatrxVariable.d.ts +29 -0
- package/dist/display/chat-markdown/matrx-variables/remarkMatrxVariable.js +71 -0
- package/dist/display/chat-markdown/page-break/remarkMatrxPageBreak.d.ts +55 -0
- package/dist/display/chat-markdown/page-break/remarkMatrxPageBreak.js +108 -0
- package/dist/display/chat-markdown/rehypeSafeRawHtml.d.ts +59 -0
- package/dist/display/chat-markdown/rehypeSafeRawHtml.js +140 -0
- package/dist/display/markdown-classification/processors/bock-processors/parse-markdown-table.d.ts +14 -0
- package/dist/display/markdown-classification/processors/bock-processors/parse-markdown-table.js +171 -0
- package/dist/display/markdown-classification/processors/types.d.ts +120 -0
- package/dist/display/markdown-classification/processors/types.js +10 -0
- package/dist/display/markdown-classification/processors/utils/client-blocks.d.ts +169 -0
- package/dist/display/markdown-classification/processors/utils/client-blocks.js +0 -0
- package/dist/display/markdown-classification/processors/utils/content-splitter-core.d.ts +223 -0
- package/dist/display/markdown-classification/processors/utils/content-splitter-core.js +1791 -0
- package/dist/display/markdown-classification/processors/utils/content-splitter-v2.d.ts +15 -0
- package/dist/display/markdown-classification/processors/utils/content-splitter-v2.js +19 -0
- package/dist/display/markdown-classification/processors/utils/expand-text-blocks.d.ts +9 -0
- package/dist/display/markdown-classification/processors/utils/expand-text-blocks.js +36 -0
- package/dist/display/markdown-classification/processors/utils/gfm-table-lines.d.ts +5 -0
- package/dist/display/markdown-classification/processors/utils/gfm-table-lines.js +40 -0
- package/dist/display/markdown-classification/processors/utils/gfm-table-vector-inputs.d.ts +16 -0
- package/dist/display/markdown-classification/processors/utils/gfm-table-vector-inputs.js +385 -0
- package/dist/display/markdown-classification/processors/utils/gfm-table-vectors.d.ts +43 -0
- package/dist/display/markdown-classification/processors/utils/gfm-table-vectors.js +33 -0
- package/dist/display/markdown-classification/processors/utils/table-data-parser.d.ts +9 -0
- package/dist/display/markdown-classification/processors/utils/table-data-parser.js +30 -0
- package/dist/display/markdown-classification/processors/utils/thinking-parser.d.ts +7 -0
- package/dist/display/markdown-classification/processors/utils/thinking-parser.js +70 -0
- package/dist/display/render-block.d.ts +23 -0
- package/dist/display/render-block.js +0 -0
- package/dist/display/themes.d.ts +1023 -0
- package/dist/display/themes.js +1105 -0
- package/dist/display/types.d.ts +32 -0
- package/dist/display/types.js +0 -0
- package/dist/host/ContentIrHostBoundary.d.ts +8 -0
- package/dist/host/ContentIrHostBoundary.js +15 -0
- package/dist/host/ErrorActions.d.ts +4 -0
- package/dist/host/ErrorActions.js +11 -0
- package/dist/host/NestedContent.d.ts +3 -0
- package/dist/host/NestedContent.js +12 -0
- package/dist/host/ResourcePeek.d.ts +6 -0
- package/dist/host/ResourcePeek.js +14 -0
- package/dist/host/component-registry.d.ts +2 -0
- package/dist/host/component-registry.js +25 -0
- package/dist/host/diagnostics.d.ts +2 -0
- package/dist/host/diagnostics.js +15 -0
- package/dist/host/index.d.ts +3 -0
- package/dist/host/index.js +18 -0
- package/dist/host/kind-incident.d.ts +3 -0
- package/dist/host/kind-incident.js +12 -0
- package/dist/host/kind-registry.d.ts +2 -0
- package/dist/host/kind-registry.js +35 -0
- package/dist/host/people.d.ts +3 -0
- package/dist/host/people.js +12 -0
- package/dist/host/registry.d.ts +27 -0
- package/dist/host/registry.js +55 -0
- package/dist/host/splitter-envelopes.d.ts +2 -0
- package/dist/host/splitter-envelopes.js +7 -0
- package/dist/host/tables.d.ts +6 -0
- package/dist/host/tables.js +8 -0
- package/dist/host/toast.d.ts +2 -0
- package/dist/host/toast.js +57 -0
- package/dist/host/types.d.ts +157 -0
- package/dist/host/types.js +0 -0
- package/dist/host/wikilinks.d.ts +15 -0
- package/dist/host/wikilinks.js +23 -0
- package/dist/kinds/host/route-env.d.ts +33 -0
- package/dist/kinds/host/route-env.js +16 -0
- package/dist/kinds/react/KindEscapedNotice.d.ts +14 -0
- package/dist/kinds/react/KindEscapedNotice.js +72 -0
- package/dist/kinds/react/ProvisionalKindBoundary.d.ts +19 -0
- package/dist/kinds/react/ProvisionalKindBoundary.js +17 -0
- package/dist/kinds/react/ensure-kind-renderable.d.ts +14 -0
- package/dist/kinds/react/ensure-kind-renderable.js +45 -0
- package/dist/kinds/react/kind-problems.d.ts +62 -0
- package/dist/kinds/react/kind-problems.js +134 -0
- package/dist/kinds/react/kind-route.d.ts +23 -0
- package/dist/kinds/react/kind-route.js +24 -0
- package/dist/kinds/react/loading/infer-loading-slug.d.ts +58 -0
- package/dist/kinds/react/loading/infer-loading-slug.js +100 -0
- package/dist/kinds/react/loading/kind-loading-components.d.ts +48 -0
- package/dist/kinds/react/loading/kind-loading-components.js +447 -0
- package/dist/kinds/react/loading/kind-loading-registry.d.ts +21 -0
- package/dist/kinds/react/loading/kind-loading-registry.js +62 -0
- package/dist/kinds/react/loading/kind-loading-slugs.d.ts +18 -0
- package/dist/kinds/react/loading/kind-loading-slugs.js +34 -0
- package/dist/kinds/react/loading/kind-loading.types.d.ts +79 -0
- package/dist/kinds/react/loading/kind-loading.types.js +31 -0
- package/dist/kinds/react/loading/resolve-loading-slug.d.ts +29 -0
- package/dist/kinds/react/loading/resolve-loading-slug.js +51 -0
- package/dist/kinds/react/partial-kind-route.d.ts +32 -0
- package/dist/kinds/react/partial-kind-route.js +27 -0
- package/dist/kinds/react/registry-versioned.d.ts +54 -0
- package/dist/kinds/react/registry-versioned.js +18 -0
- package/dist/kinds/react/route-at-version.d.ts +38 -0
- package/dist/kinds/react/route-at-version.js +78 -0
- package/dist/kinds/react/slot/KindSlot.d.ts +87 -0
- package/dist/kinds/react/slot/KindSlot.js +65 -0
- package/dist/kinds/react/use-registry-repaint.d.ts +6 -0
- package/dist/kinds/react/use-registry-repaint.js +36 -0
- package/dist/kinds/react/useIrNode.d.ts +9 -0
- package/dist/kinds/react/useIrNode.js +46 -0
- package/dist/kinds/react/useLiveJsonRegion.d.ts +15 -0
- package/dist/kinds/react/useLiveJsonRegion.js +84 -0
- package/dist/kinds/redux/render-block-envelope.d.ts +14 -0
- package/dist/kinds/redux/render-block-envelope.js +26 -0
- package/dist/kinds/registry/kind-correctors.d.ts +63 -0
- package/dist/kinds/registry/kind-correctors.js +94 -0
- package/dist/kinds/registry/legacy-quiz-envelope.d.ts +1 -0
- package/dist/kinds/registry/legacy-quiz-envelope.js +1 -0
- package/dist/kinds/registry/region-envelope-memo.d.ts +45 -0
- package/dist/kinds/registry/region-envelope-memo.js +94 -0
- package/dist/kinds/registry/registry-debug.d.ts +38 -0
- package/dist/kinds/registry/registry-debug.js +39 -0
- package/dist/markdown-core/MarkdownCore.d.ts +6 -0
- package/dist/markdown-core/MarkdownCore.js +32 -0
- package/dist/markdown-core/MarkdownCoreImpl.d.ts +3 -0
- package/dist/markdown-core/MarkdownCoreImpl.js +27 -0
- package/dist/markdown-core/MarkdownCoreServer.d.ts +4 -0
- package/dist/markdown-core/MarkdownCoreServer.js +26 -0
- package/dist/markdown-core/heading-anchors-context.d.ts +2 -0
- package/dist/markdown-core/heading-anchors-context.js +11 -0
- package/dist/markdown-core/heading-anchors-props.d.ts +2 -0
- package/dist/markdown-core/heading-anchors-props.js +6 -0
- package/dist/markdown-core/markdown-core-html.d.ts +3 -0
- package/dist/markdown-core/markdown-core-html.js +33 -0
- package/dist/markdown-core/markdown-core-presets.d.ts +22 -0
- package/dist/markdown-core/markdown-core-presets.js +118 -0
- package/dist/markdown-core/markdown-core-types.d.ts +43 -0
- package/dist/markdown-core/markdown-core-types.js +0 -0
- package/dist/markdown-core/math/vendor/micromark-math-math-flow.d.ts +15 -0
- package/dist/markdown-core/math/vendor/micromark-math-math-flow.js +143 -0
- package/dist/markdown-core/math/vendor/micromark-math-math-text.d.ts +24 -0
- package/dist/markdown-core/math/vendor/micromark-math-math-text.js +127 -0
- package/dist/markdown-core/math/vendor/micromark-math-syntax.d.ts +30 -0
- package/dist/markdown-core/math/vendor/micromark-math-syntax.js +15 -0
- package/dist/markdown-core/math/vendor/rehype-katex.d.ts +15 -0
- package/dist/markdown-core/math/vendor/rehype-katex.js +83 -0
- package/dist/markdown-core/math/vendor/remark-math.d.ts +9 -0
- package/dist/markdown-core/math/vendor/remark-math.js +20 -0
- package/dist/markdown-core/math-normalizer.d.ts +57 -0
- package/dist/markdown-core/math-normalizer.js +315 -0
- package/dist/markdown-core/plain-title.d.ts +2 -0
- package/dist/markdown-core/plain-title.js +1 -0
- package/dist/markdown-core/stream-heal.d.ts +2 -0
- package/dist/markdown-core/stream-heal.js +184 -0
- package/dist/markdown-core/streaming-context.d.ts +2 -0
- package/dist/markdown-core/streaming-context.js +11 -0
- package/dist/markdown-core/syntax/callout-types.d.ts +9 -0
- package/dist/markdown-core/syntax/callout-types.js +101 -0
- package/dist/markdown-core/syntax/containers.d.ts +17 -0
- package/dist/markdown-core/syntax/containers.js +353 -0
- package/dist/markdown-core/syntax/document-numbering.d.ts +52 -0
- package/dist/markdown-core/syntax/document-numbering.js +184 -0
- package/dist/markdown-core/syntax/elements/CalloutIcon.d.ts +3 -0
- package/dist/markdown-core/syntax/elements/CalloutIcon.js +41 -0
- package/dist/markdown-core/syntax/elements/CrossRef.d.ts +12 -0
- package/dist/markdown-core/syntax/elements/CrossRef.js +57 -0
- package/dist/markdown-core/syntax/elements/CsvFence.d.ts +4 -0
- package/dist/markdown-core/syntax/elements/CsvFence.js +18 -0
- package/dist/markdown-core/syntax/elements/DetailsElements.d.ts +12 -0
- package/dist/markdown-core/syntax/elements/DetailsElements.js +38 -0
- package/dist/markdown-core/syntax/elements/DocumentNumbering.d.ts +20 -0
- package/dist/markdown-core/syntax/elements/DocumentNumbering.js +37 -0
- package/dist/markdown-core/syntax/elements/DocumentPropertiesPanel.d.ts +4 -0
- package/dist/markdown-core/syntax/elements/DocumentPropertiesPanel.js +46 -0
- package/dist/markdown-core/syntax/elements/InDocAnchor.d.ts +11 -0
- package/dist/markdown-core/syntax/elements/InDocAnchor.js +87 -0
- package/dist/markdown-core/syntax/elements/MarkdownSourceEdit.d.ts +24 -0
- package/dist/markdown-core/syntax/elements/MarkdownSourceEdit.js +28 -0
- package/dist/markdown-core/syntax/elements/MatrxTabs.d.ts +10 -0
- package/dist/markdown-core/syntax/elements/MatrxTabs.js +59 -0
- package/dist/markdown-core/syntax/elements/MentionChip.d.ts +7 -0
- package/dist/markdown-core/syntax/elements/MentionChip.js +69 -0
- package/dist/markdown-core/syntax/elements/NestedBody.d.ts +3 -0
- package/dist/markdown-core/syntax/elements/NestedBody.js +13 -0
- package/dist/markdown-core/syntax/elements/TableOfContents.d.ts +5 -0
- package/dist/markdown-core/syntax/elements/TableOfContents.js +44 -0
- package/dist/markdown-core/syntax/elements/TaskCheckbox.d.ts +7 -0
- package/dist/markdown-core/syntax/elements/TaskCheckbox.js +63 -0
- package/dist/markdown-core/syntax/elements/WikiEmbed.d.ts +7 -0
- package/dist/markdown-core/syntax/elements/WikiEmbed.js +68 -0
- package/dist/markdown-core/syntax/elements/WikiLink.d.ts +10 -0
- package/dist/markdown-core/syntax/elements/WikiLink.js +114 -0
- package/dist/markdown-core/syntax/elements/core-syntax-elements.d.ts +22 -0
- package/dist/markdown-core/syntax/elements/core-syntax-elements.js +70 -0
- package/dist/markdown-core/syntax/elements/find-in-document.d.ts +3 -0
- package/dist/markdown-core/syntax/elements/find-in-document.js +20 -0
- package/dist/markdown-core/syntax/elements/wiki-target.d.ts +5 -0
- package/dist/markdown-core/syntax/elements/wiki-target.js +8 -0
- package/dist/markdown-core/syntax/frontmatter.d.ts +26 -0
- package/dist/markdown-core/syntax/frontmatter.js +72 -0
- package/dist/markdown-core/syntax/gfm-cell-pipes.d.ts +11 -0
- package/dist/markdown-core/syntax/gfm-cell-pipes.js +4 -0
- package/dist/markdown-core/syntax/inline-syntax.d.ts +26 -0
- package/dist/markdown-core/syntax/inline-syntax.js +163 -0
- package/dist/markdown-core/syntax/linear-scan.d.ts +46 -0
- package/dist/markdown-core/syntax/linear-scan.js +129 -0
- package/dist/markdown-core/syntax/mdast-helpers.d.ts +48 -0
- package/dist/markdown-core/syntax/mdast-helpers.js +48 -0
- package/dist/markdown-core/syntax/mentions.d.ts +2 -0
- package/dist/markdown-core/syntax/mentions.js +42 -0
- package/dist/markdown-core/syntax/names.d.ts +6 -0
- package/dist/markdown-core/syntax/names.js +18 -0
- package/dist/markdown-core/syntax/prepare-syntax-source.d.ts +1 -0
- package/dist/markdown-core/syntax/prepare-syntax-source.js +78 -0
- package/dist/markdown-core/syntax/rehype-matrx-syntax.d.ts +9 -0
- package/dist/markdown-core/syntax/rehype-matrx-syntax.js +180 -0
- package/dist/markdown-core/syntax/remark-inline-only.d.ts +23 -0
- package/dist/markdown-core/syntax/remark-inline-only.js +25 -0
- package/dist/markdown-core/syntax/remark-matrx-syntax.d.ts +7 -0
- package/dist/markdown-core/syntax/remark-matrx-syntax.js +351 -0
- package/dist/markdown-core/syntax/remark-table-code-pipes.d.ts +7 -0
- package/dist/markdown-core/syntax/remark-table-code-pipes.js +23 -0
- package/dist/markdown-core/syntax/stream-heal-syntax.d.ts +2 -0
- package/dist/markdown-core/syntax/stream-heal-syntax.js +108 -0
- package/dist/markdown-core/syntax/task-source.d.ts +10 -0
- package/dist/markdown-core/syntax/task-source.js +34 -0
- package/dist/markdown-core/syntax/useDocumentProperties.d.ts +3 -0
- package/dist/markdown-core/syntax/useDocumentProperties.js +8 -0
- package/dist/styles.css +0 -0
- package/dist/utils/addressWithoutNavigating.d.ts +68 -0
- package/dist/utils/addressWithoutNavigating.js +60 -0
- package/dist/utils/client-lazy.d.ts +13 -0
- package/dist/utils/client-lazy.js +24 -0
- package/dist/utils/decision-options.d.ts +21 -0
- package/dist/utils/decision-options.js +32 -0
- package/dist/utils/gfm-lexer.d.ts +5 -0
- package/dist/utils/gfm-lexer.js +10 -0
- package/dist/utils/json.d.ts +63 -0
- package/dist/utils/json.js +22 -0
- package/dist/utils/plain-title.d.ts +25 -0
- package/dist/utils/plain-title.js +51 -0
- package/dist/utils/table-source.d.ts +62 -0
- package/dist/utils/table-source.js +191 -0
- package/dist/utils/youtube.d.ts +52 -0
- package/dist/utils/youtube.js +137 -0
- package/package.json +132 -5
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client-blocks.ts — the CLIENT-ONLY render-block vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* OWNER: the markdown splitter (content-splitter-v2.ts, this directory).
|
|
5
|
+
* These block types are produced ONLY by the frontend splitter from streamed/
|
|
6
|
+
* persisted markdown — Python never emits them. If Python ever needs to send
|
|
7
|
+
* one, add it to the server vocabulary
|
|
8
|
+
* (aidream `matrx_connect/context/data_render_blocks.py` or
|
|
9
|
+
* `render_blocks.py`), regenerate stream-events.ts, and delete it here.
|
|
10
|
+
*
|
|
11
|
+
* This file is deliberately hand-maintained (there is no server source to
|
|
12
|
+
* generate it from) but it is NOT free-form: every type token here is
|
|
13
|
+
* classified by the content-vocab crosswalk
|
|
14
|
+
* (scripts/shape/content-vocab-crosswalk.json — regenerate with
|
|
15
|
+
* `pnpm check:shapes:crosswalk:refresh`). Adding a type without a crosswalk
|
|
16
|
+
* classification rule fails `pnpm check:shapes:crosswalk`.
|
|
17
|
+
*
|
|
18
|
+
* The server-synthesized twin vocabulary (audio_output, function_result, …)
|
|
19
|
+
* is GENERATED into @ai-matrx/agents/generated/stream-events
|
|
20
|
+
* (ServerOnlyRenderBlock / ServerOnlyBlockType) — both replaced the retired
|
|
21
|
+
* hand-maintained @ai-matrx/agents/generated/missing-types drift patch.
|
|
22
|
+
*/
|
|
23
|
+
/** A directory/file tree rendered from box-drawing or ASCII connectors. */
|
|
24
|
+
export interface TreeRenderBlock {
|
|
25
|
+
type: "tree";
|
|
26
|
+
content: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/** A styled accent divider (*** pattern). */
|
|
30
|
+
export interface AccentDividerRenderBlock {
|
|
31
|
+
type: "accent-divider";
|
|
32
|
+
content: string;
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
/** A styled heavy divider (#=== pattern). */
|
|
36
|
+
export interface HeavyDividerRenderBlock {
|
|
37
|
+
type: "heavy-divider";
|
|
38
|
+
content: string;
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* An audio player parsed from a markdown audio link in streamed/persisted text
|
|
43
|
+
* (e.g. `[Audio URL: …]` or a standalone `….mp3` link). Mirrors the typed
|
|
44
|
+
* `image`/`video` render blocks: the URL travels on the splitter block's `src`
|
|
45
|
+
* field, not here. This is the streaming-text twin of the server-side
|
|
46
|
+
* `audio_output` block — see content-splitter-v2.ts `detectAudioMarkdown`.
|
|
47
|
+
*/
|
|
48
|
+
export interface AudioRenderBlock {
|
|
49
|
+
type: "audio";
|
|
50
|
+
content: string;
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A raw SVG illustration emitted by an agent in a ```svg fence — rendered
|
|
55
|
+
* sandboxed (no scripts) and responsively from its viewBox. Client-only for
|
|
56
|
+
* now; promote to Python's stream-events.ts when the server emits a typed svg
|
|
57
|
+
* block. See components/mardown-display/blocks/svg/SvgBlock.tsx.
|
|
58
|
+
*/
|
|
59
|
+
export interface SvgRenderBlock {
|
|
60
|
+
type: "svg";
|
|
61
|
+
content: string;
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A data chart emitted by an agent in a ```chart fence — a small JSON spec
|
|
66
|
+
* (type + data) rendered with recharts (loaded via next/dynamic ssr:false).
|
|
67
|
+
* Client-only for now. See components/mardown-display/blocks/chart/ChartBlock.tsx.
|
|
68
|
+
*/
|
|
69
|
+
export interface ChartRenderBlock {
|
|
70
|
+
type: "chart";
|
|
71
|
+
content: string;
|
|
72
|
+
metadata?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
/** Interactive Leaflet map from a ```map JSON spec (markers/places). Client-only. */
|
|
75
|
+
export interface MapRenderBlock {
|
|
76
|
+
type: "map";
|
|
77
|
+
content: string;
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
/** KPI / headline-metric cards from a ```stats JSON spec. Client-only. */
|
|
81
|
+
export interface StatsRenderBlock {
|
|
82
|
+
type: "stats";
|
|
83
|
+
content: string;
|
|
84
|
+
metadata?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
/** Before/after diff from a ```diff JSON spec ({old,new}). Client-only. */
|
|
87
|
+
export interface DiffRenderBlock {
|
|
88
|
+
type: "diff";
|
|
89
|
+
content: string;
|
|
90
|
+
metadata?: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A clickable reference to a platform entity (agent, note, task, file, etc.).
|
|
94
|
+
* Emitted by an agent as a ```json fence keyed by `item_presentation`:
|
|
95
|
+
* { "item_presentation": { "id": "...", "type": "agent", "name": "...", "about": "..." } }
|
|
96
|
+
* Client-only for now (detected by the splitter's JSON_BLOCK_PATTERNS). The
|
|
97
|
+
* renderer auto-enriches recognized types from the DB and opens the matching
|
|
98
|
+
* window panel on click. See features/item-presentation/.
|
|
99
|
+
*/
|
|
100
|
+
export interface ItemPresentationRenderBlock {
|
|
101
|
+
type: "item_presentation";
|
|
102
|
+
content: string;
|
|
103
|
+
metadata?: Record<string, unknown>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A playable YouTube embed parsed from a YouTube link in streamed/persisted
|
|
107
|
+
* text — a linked thumbnail `[](yt-url)`, a plain `[text](yt-url)`
|
|
108
|
+
* link, or a bare YouTube URL on its own line. The splitter extracts the video
|
|
109
|
+
* id + start offset onto `metadata` (videoId/start/title/poster) and keeps the
|
|
110
|
+
* original line on `content` so it survives the DB round-trip. The server twin
|
|
111
|
+
* is the `media_block(kind: "youtube")` render block — both render through the
|
|
112
|
+
* single `features/files/blocks/youtube/YouTubeEmbed` component. See
|
|
113
|
+
* content-splitter-v2.ts `detectYoutubeMarkdown`.
|
|
114
|
+
*/
|
|
115
|
+
export interface YoutubeRenderBlock {
|
|
116
|
+
type: "youtube";
|
|
117
|
+
content: string;
|
|
118
|
+
src?: string;
|
|
119
|
+
metadata?: Record<string, unknown>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A Matrx Envelope embedded in content via a ```matrx fence. The `content`
|
|
123
|
+
* is the raw envelope JSON `{ matrx_version, kind, type, items: [...] }`.
|
|
124
|
+
* In-content position only resolves `reference` / `secret` kinds (an action in
|
|
125
|
+
* prose is shown, never executed). Rendered by features/matrx-envelope/
|
|
126
|
+
* MatrxEnvelopeBlock — chips for references, a muted card otherwise.
|
|
127
|
+
* See docs/protocol/MATRX_ENVELOPE.md + MATRX_REFERENCES.md.
|
|
128
|
+
*/
|
|
129
|
+
export interface MatrxEnvelopeRenderBlock {
|
|
130
|
+
type: "matrx";
|
|
131
|
+
content: string;
|
|
132
|
+
metadata?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* An output-schema proposal emitted by the "JSON Schema Generator" agent as a
|
|
136
|
+
* ```json fence: `{ name: string, schema: object, strict?: boolean }`. The FE
|
|
137
|
+
* recognizes it (see content-splitter-v2 JSON_BLOCK_PATTERNS) and offers
|
|
138
|
+
* "Apply to an agent" (writes agx_agent.output_schema). Client-only.
|
|
139
|
+
* Classified PROTOCOL in the crosswalk (drives a side-effecting apply flow).
|
|
140
|
+
* See features/agents/components/schema-proposal/.
|
|
141
|
+
*/
|
|
142
|
+
export interface SchemaProposalRenderBlock {
|
|
143
|
+
type: "schema_proposal";
|
|
144
|
+
content: string;
|
|
145
|
+
metadata?: Record<string, unknown>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A reference to one of OUR OWN files (a cld_files-backed signed S3 URL, a
|
|
149
|
+
* public CDN URL or a share-link byte endpoint)
|
|
150
|
+
* found as a plain markdown link / bare URL in streamed/persisted text. Unlike
|
|
151
|
+
* `image`/`audio`/`video` blocks this carries NO declared type — the renderer
|
|
152
|
+
* recovers a `file_id` (or other `FileSource`) via `recognizeOurFileUrl`,
|
|
153
|
+
* discovers the real file type (sniffed from the URL or by hydrating the
|
|
154
|
+
* cld_files row), and renders the universal inline previewer. Signed URLs
|
|
155
|
+
* auto-re-mint through the file handler. On any failure it degrades to the
|
|
156
|
+
* original markdown link. The original line stays on `content` so it survives
|
|
157
|
+
* the DB round-trip and re-detects on reload. Client-only — see
|
|
158
|
+
* content-splitter-v2.ts `detectMatrxFileMarkdown` +
|
|
159
|
+
* components/mardown-display/blocks/matrx-file/MatrxFileBlock.tsx.
|
|
160
|
+
*/
|
|
161
|
+
export interface MatrxFileRenderBlock {
|
|
162
|
+
type: "matrx_file";
|
|
163
|
+
content: string;
|
|
164
|
+
src?: string;
|
|
165
|
+
alt?: string;
|
|
166
|
+
metadata?: Record<string, unknown>;
|
|
167
|
+
}
|
|
168
|
+
export type ClientOnlyRenderBlock = TreeRenderBlock | AccentDividerRenderBlock | HeavyDividerRenderBlock | AudioRenderBlock | SvgRenderBlock | ChartRenderBlock | MapRenderBlock | StatsRenderBlock | DiffRenderBlock | ItemPresentationRenderBlock | YoutubeRenderBlock | MatrxEnvelopeRenderBlock | SchemaProposalRenderBlock | MatrxFileRenderBlock;
|
|
169
|
+
export type ClientOnlyBlockType = ClientOnlyRenderBlock["type"];
|
|
File without changes
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Splitter V2 - PRODUCTION Parser
|
|
3
|
+
*
|
|
4
|
+
* A streamlined, registry-based markdown parser optimized for streaming content.
|
|
5
|
+
* This is the current production parser used by MarkdownStream.
|
|
6
|
+
*
|
|
7
|
+
* Key improvements over V1:
|
|
8
|
+
* - Registry-based architecture for block types (easy to extend)
|
|
9
|
+
* - Clear separation: detection → extraction → validation
|
|
10
|
+
* - Organized by content type (JSON, XML, Markdown)
|
|
11
|
+
* - 38% code reduction (1253 → 781 lines)
|
|
12
|
+
* - Maintains all streaming logic and caching from V1
|
|
13
|
+
*
|
|
14
|
+
* Parsing order (deterministic):
|
|
15
|
+
* 1. MATRX patterns
|
|
16
|
+
* 2. Code blocks (with JSON special types)
|
|
17
|
+
* 3. XML tag blocks
|
|
18
|
+
* 4. Images
|
|
19
|
+
* 5. Videos
|
|
20
|
+
* 6. Tables
|
|
21
|
+
* 7. Text (fallback)
|
|
22
|
+
*
|
|
23
|
+
* Legacy V1 parser available in content-splitter.ts for rollback if needed.
|
|
24
|
+
*
|
|
25
|
+
* THIS module is the environment-neutral core (RC-B2b, 2026-09-24): it never
|
|
26
|
+
* imports the kind/component registries — those arrive as SplitterEnvelopes.
|
|
27
|
+
* Client code imports content-splitter-v2.ts (hooks bound); the server
|
|
28
|
+
* rich-content level calls splitContentIntoBlocksWith(src, NO_SPLITTER_ENVELOPES).
|
|
29
|
+
*/
|
|
30
|
+
import type { TypedRenderBlock, ServerOnlyBlockType } from "@ai-matrx/agents/generated/stream-events";
|
|
31
|
+
import type { ClientOnlyBlockType } from "./client-blocks.js";
|
|
32
|
+
import { type CanonicalBlockIR } from "@ai-matrx/content-ir";
|
|
33
|
+
/**
|
|
34
|
+
* All block type strings this splitter can emit — the union of:
|
|
35
|
+
* - TypedRenderBlock["type"] : render_block wire types (generated stream-events.ts)
|
|
36
|
+
* - ClientOnlyBlockType : splitter-only types (client-blocks.ts, this directory)
|
|
37
|
+
* - ServerOnlyBlockType : FE-synthesized data-event wrappers (generated
|
|
38
|
+
* stream-events.ts ServerOnlyRenderBlock)
|
|
39
|
+
*/
|
|
40
|
+
type SplitterBlockType = TypedRenderBlock["type"] | ClientOnlyBlockType | ServerOnlyBlockType;
|
|
41
|
+
/**
|
|
42
|
+
* The three kind-envelope hooks the splitter calls. They attach the canonical
|
|
43
|
+
* content-IR envelope to a COMPLETED region's `metadata` — they never change a
|
|
44
|
+
* block's type, boundaries or content. The client entry
|
|
45
|
+
* (content-splitter-v2.ts) binds the registry-backed hooks; the server
|
|
46
|
+
* rich-content level passes NO_SPLITTER_ENVELOPES, so this module's graph
|
|
47
|
+
* stays free of the kind/component registries (which create React contexts
|
|
48
|
+
* at module scope and cannot load in a React Server Component).
|
|
49
|
+
*/
|
|
50
|
+
export interface SplitterEnvelopes {
|
|
51
|
+
withIrEnvelope(source: string, metadata: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
52
|
+
fenceRegion(language: string, regionText: string): CanonicalBlockIR | null;
|
|
53
|
+
xmlRegion(tag: string, regionText: string): CanonicalBlockIR | null;
|
|
54
|
+
}
|
|
55
|
+
/** No envelopes: identical blocks, no kind metadata (server rendering). */
|
|
56
|
+
export declare const NO_SPLITTER_ENVELOPES: SplitterEnvelopes;
|
|
57
|
+
/**
|
|
58
|
+
* SplitterBlock — the output type of splitContentIntoBlocksWith / splitContentIntoBlocksV2.
|
|
59
|
+
*
|
|
60
|
+
* Structurally aligned with TypedRenderBlock so that the same type
|
|
61
|
+
* discriminant works across the splitter, Redux, server events, and renderer.
|
|
62
|
+
* Omits blockId/blockIndex/status/data (server/Redux concerns) and adds
|
|
63
|
+
* language/src/alt which are needed by BlockRenderer for code/image/video blocks.
|
|
64
|
+
*
|
|
65
|
+
* The bridge field `serverData` is NOT defined here — BlockRenderer adds it
|
|
66
|
+
* via its local `BlockWithServerData` extension when merging server-processed blocks.
|
|
67
|
+
*/
|
|
68
|
+
export interface SplitterBlock {
|
|
69
|
+
type: SplitterBlockType;
|
|
70
|
+
content: string;
|
|
71
|
+
language?: string;
|
|
72
|
+
src?: string;
|
|
73
|
+
alt?: string;
|
|
74
|
+
metadata?: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use SplitterBlock instead.
|
|
78
|
+
* Kept as an alias so existing imports continue to compile during migration.
|
|
79
|
+
*/
|
|
80
|
+
export type ContentBlock = SplitterBlock;
|
|
81
|
+
/**
|
|
82
|
+
* Detection is recursive across arrival containers: a complete object that
|
|
83
|
+
* directly declares `__kind` becomes its own JSON/Content-IR block even when
|
|
84
|
+
* Markdown first captured it inside prose, a non-JSON fence, or XML. Every
|
|
85
|
+
* byte around recovered objects stays in document order as its original block
|
|
86
|
+
* type. Artifact wrappers already carry their body envelope for selectors and
|
|
87
|
+
* retain their identity/chrome; they are the one container that must not be
|
|
88
|
+
* exploded into anonymous fragments.
|
|
89
|
+
*/
|
|
90
|
+
export declare function recoverEmbeddedKindJsonBlocksWith(input: SplitterBlock[], envelopes: SplitterEnvelopes): SplitterBlock[];
|
|
91
|
+
/**
|
|
92
|
+
* Code-fence languages that promote to a first-class block type (the fence
|
|
93
|
+
* language becomes the block type). Mirrors SPECIAL_CODE_LANGUAGES in
|
|
94
|
+
* aidream block_detector.py — keep the two in lockstep.
|
|
95
|
+
*/
|
|
96
|
+
export declare const SPECIAL_CODE_LANGUAGES: string[];
|
|
97
|
+
/**
|
|
98
|
+
* Fence-language aliases that normalize to a canonical special language
|
|
99
|
+
* (e.g. ```mmd → mermaid). Mirrors CODE_LANGUAGE_ALIASES in block_detector.py.
|
|
100
|
+
*/
|
|
101
|
+
export declare const CODE_LANGUAGE_ALIASES: Record<string, string>;
|
|
102
|
+
export declare function normalizeCodeLanguage(language: string | undefined): string | undefined;
|
|
103
|
+
declare const JSON_BLOCK_PATTERNS: {
|
|
104
|
+
readonly quiz: {
|
|
105
|
+
readonly rootKey: "quiz_title";
|
|
106
|
+
readonly validate: (parsed: unknown) => "" | 0 | boolean | null | undefined;
|
|
107
|
+
};
|
|
108
|
+
readonly presentation: {
|
|
109
|
+
readonly rootKey: "presentation";
|
|
110
|
+
readonly validate: (parsed: unknown) => boolean;
|
|
111
|
+
};
|
|
112
|
+
readonly decision_tree: {
|
|
113
|
+
readonly rootKey: "decision_tree";
|
|
114
|
+
readonly validate: (parsed: unknown) => import("../../../../utils/json.js").JsonValue | undefined;
|
|
115
|
+
};
|
|
116
|
+
readonly comparison_table: {
|
|
117
|
+
readonly rootKey: "comparison";
|
|
118
|
+
readonly validate: (parsed: unknown) => "" | 0 | boolean | null | undefined;
|
|
119
|
+
};
|
|
120
|
+
readonly diagram: {
|
|
121
|
+
readonly rootKey: "diagram";
|
|
122
|
+
readonly validate: (parsed: unknown) => "" | 0 | boolean | null | undefined;
|
|
123
|
+
};
|
|
124
|
+
readonly math_problem: {
|
|
125
|
+
readonly rootKey: "math_problem";
|
|
126
|
+
readonly validate: (parsed: unknown) => "" | 0 | boolean | null | undefined;
|
|
127
|
+
};
|
|
128
|
+
readonly item_presentation: {
|
|
129
|
+
readonly rootKey: "item_presentation";
|
|
130
|
+
readonly validate: (parsed: unknown) => boolean;
|
|
131
|
+
};
|
|
132
|
+
readonly schema_proposal: {
|
|
133
|
+
readonly rootKey: "name";
|
|
134
|
+
readonly validate: (parsed: unknown) => boolean;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
export type DetectedJsonBlockType = keyof typeof JSON_BLOCK_PATTERNS | "matrx";
|
|
138
|
+
export declare function detectJsonBlockType(content: string): DetectedJsonBlockType | null;
|
|
139
|
+
/** Extracts key="value" pairs from an XML opening tag string. */
|
|
140
|
+
export declare function parseXmlAttributes(openingTag: string): Record<string, string>;
|
|
141
|
+
/**
|
|
142
|
+
* Extracts a complete, unrecognized XML element so it can reuse the same
|
|
143
|
+
* enhanced XML renderer as a fenced ```xml block.
|
|
144
|
+
*
|
|
145
|
+
* This deliberately runs after every recognized XML detector. It also requires
|
|
146
|
+
* a line-leading, balanced root element (or a self-closing element), which keeps
|
|
147
|
+
* inline angle-bracket prose and incomplete streaming text on the markdown path.
|
|
148
|
+
* Curated raw HTML remains on its existing sanitized HTML path.
|
|
149
|
+
*/
|
|
150
|
+
export interface UnrecognizedXmlContainerTracker {
|
|
151
|
+
readonly rootTag: string;
|
|
152
|
+
consumeLine(line: string, startOffset?: number): number | null;
|
|
153
|
+
}
|
|
154
|
+
interface UnrecognizedXmlStart {
|
|
155
|
+
tracker: UnrecognizedXmlContainerTracker;
|
|
156
|
+
rootStart: number;
|
|
157
|
+
}
|
|
158
|
+
/** Protect tag attributes while an opening tag is still arriving. */
|
|
159
|
+
export declare function isUnclosedGenericXmlOpening(source: string): boolean;
|
|
160
|
+
/** Starts a line-leading generic XML container, after known/raw-HTML ownership. */
|
|
161
|
+
export declare function startUnrecognizedXmlContainer(line: string): UnrecognizedXmlStart | null;
|
|
162
|
+
/** Redux parity hook: classify a whole text block before kind recovery splits it. */
|
|
163
|
+
export declare function isCompleteUnrecognizedXmlContainer(source: string): boolean;
|
|
164
|
+
export declare function detectImageMarkdown(line: string): {
|
|
165
|
+
isImage: boolean;
|
|
166
|
+
src?: string;
|
|
167
|
+
alt?: string;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Count standalone (http/https) markdown images on a single line.
|
|
171
|
+
*
|
|
172
|
+
* Drives the standalone-block-vs-inline-flow decision: a line with exactly ONE
|
|
173
|
+
* image becomes a full-width `image` block (the deliberate "big incoming image"
|
|
174
|
+
* treatment); a line with 2+ images is intentionally LEFT as text so
|
|
175
|
+
* react-markdown renders them side by side. The rule is "respect line breaks" —
|
|
176
|
+
* no line break between images means the author wants them inline, a line break
|
|
177
|
+
* means stacked. Only the `` form is counted; the single custom
|
|
178
|
+
* `[Image URL: …]` form never yields more than one.
|
|
179
|
+
*/
|
|
180
|
+
export declare function countInlineImages(line: string): number;
|
|
181
|
+
export declare function detectVideoMarkdown(line: string): {
|
|
182
|
+
isVideo: boolean;
|
|
183
|
+
src?: string;
|
|
184
|
+
alt?: string;
|
|
185
|
+
};
|
|
186
|
+
export declare const AUDIO_URL_EXT: RegExp;
|
|
187
|
+
/**
|
|
188
|
+
* Extracts the audio URL + label from a single line that is an audio link, or
|
|
189
|
+
* returns null. Shared by the splitter, the streaming block accumulator, and
|
|
190
|
+
* the content prefilter so all three agree on what counts as an audio link.
|
|
191
|
+
* Three accepted shapes, all line-scoped:
|
|
192
|
+
* 1. `[Audio URL: https://…]` — backend custom format, symmetric with
|
|
193
|
+
* `[Image URL: …]` / `[Video URL: …]`.
|
|
194
|
+
* 2. `[label](https://…/clip.mp3)` or `` — a standard markdown
|
|
195
|
+
* link whose URL is an audio file AND which is the entire line (so inline
|
|
196
|
+
* links inside a sentence are left as ordinary links).
|
|
197
|
+
* 3. A bare audio URL on its own line.
|
|
198
|
+
*/
|
|
199
|
+
export declare function extractAudioLink(line: string): {
|
|
200
|
+
src: string;
|
|
201
|
+
alt: string;
|
|
202
|
+
} | null;
|
|
203
|
+
/**
|
|
204
|
+
* Detect a link (or bare URL) to one of OUR OWN files anywhere in a line.
|
|
205
|
+
*
|
|
206
|
+
* Unlike image/video/audio detection, the URL carries no declared type — we
|
|
207
|
+
* only assert "this is ours" via `recognizeOurFileUrl`. The match can sit
|
|
208
|
+
* mid-line; we return the text BEFORE (`pre`) and AFTER (`post`) the file token
|
|
209
|
+
* so the renderer can render `markdown(pre) → inline file → markdown(post)` and
|
|
210
|
+
* handle the inline case gracefully without shattering the paragraph.
|
|
211
|
+
*
|
|
212
|
+
* Accepts both `[label](our-url)` (optionally `!`-prefixed) and a bare
|
|
213
|
+
* `our-url`. Returns the FIRST our-file match on the line.
|
|
214
|
+
*/
|
|
215
|
+
export declare function detectMatrxFileMarkdown(line: string): {
|
|
216
|
+
isMatrxFile: boolean;
|
|
217
|
+
url?: string;
|
|
218
|
+
label?: string;
|
|
219
|
+
pre?: string;
|
|
220
|
+
post?: string;
|
|
221
|
+
};
|
|
222
|
+
export declare const splitContentIntoBlocksWith: (mdContent: string, envelopes: SplitterEnvelopes) => SplitterBlock[];
|
|
223
|
+
export {};
|