@aparte/plugin-artifacts 0.16.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 +21 -0
- package/README.md +60 -0
- package/dist/binary-file.d.ts +7 -0
- package/dist/binary-file.d.ts.map +1 -0
- package/dist/card.d.ts +6 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/custom-elements.json +1184 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +675 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.d.ts +32 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +30 -0
- package/dist/index.node.js.map +1 -0
- package/dist/kinds.d.ts +19 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/options.d.ts +72 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/preview-document-xP-Ne-F0.js +177 -0
- package/dist/preview-document-xP-Ne-F0.js.map +1 -0
- package/dist/preview-document.d.ts +27 -0
- package/dist/preview-document.d.ts.map +1 -0
- package/dist/segment.d.ts +66 -0
- package/dist/segment.d.ts.map +1 -0
- package/dist/shared.d.ts +29 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/tool.d.ts +31 -0
- package/dist/tool.d.ts.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/binary-file.ts",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "function",
|
|
11
|
+
"name": "resetBinaryArtifacts",
|
|
12
|
+
"return": {
|
|
13
|
+
"type": {
|
|
14
|
+
"text": "void"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"description": "For tests: forget every produced file and every generation in flight."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"kind": "function",
|
|
21
|
+
"name": "renderBinaryFileArtifact",
|
|
22
|
+
"return": {
|
|
23
|
+
"type": {
|
|
24
|
+
"text": "string"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"parameters": [
|
|
28
|
+
{
|
|
29
|
+
"name": "segment",
|
|
30
|
+
"type": {
|
|
31
|
+
"text": "ArtifactSegment"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "kind",
|
|
36
|
+
"type": {
|
|
37
|
+
"text": "string"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"kind": "function",
|
|
44
|
+
"name": "setupBinaryFileArtifact",
|
|
45
|
+
"return": {
|
|
46
|
+
"type": {
|
|
47
|
+
"text": "void"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"parameters": [
|
|
51
|
+
{
|
|
52
|
+
"name": "element",
|
|
53
|
+
"type": {
|
|
54
|
+
"text": "HTMLElement"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "segment",
|
|
59
|
+
"type": {
|
|
60
|
+
"text": "ArtifactSegment"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "kind",
|
|
65
|
+
"type": {
|
|
66
|
+
"text": "string"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"kind": "function",
|
|
73
|
+
"name": "updateBinaryFileArtifact",
|
|
74
|
+
"return": {
|
|
75
|
+
"type": {
|
|
76
|
+
"text": "void"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"parameters": [
|
|
80
|
+
{
|
|
81
|
+
"name": "element",
|
|
82
|
+
"type": {
|
|
83
|
+
"text": "HTMLElement"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "segment",
|
|
88
|
+
"type": {
|
|
89
|
+
"text": "ArtifactSegment"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "isStreaming",
|
|
94
|
+
"type": {
|
|
95
|
+
"text": "boolean"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"exports": [
|
|
102
|
+
{
|
|
103
|
+
"kind": "js",
|
|
104
|
+
"name": "resetBinaryArtifacts",
|
|
105
|
+
"declaration": {
|
|
106
|
+
"name": "resetBinaryArtifacts",
|
|
107
|
+
"module": "src/binary-file.ts"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"kind": "js",
|
|
112
|
+
"name": "renderBinaryFileArtifact",
|
|
113
|
+
"declaration": {
|
|
114
|
+
"name": "renderBinaryFileArtifact",
|
|
115
|
+
"module": "src/binary-file.ts"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"kind": "js",
|
|
120
|
+
"name": "setupBinaryFileArtifact",
|
|
121
|
+
"declaration": {
|
|
122
|
+
"name": "setupBinaryFileArtifact",
|
|
123
|
+
"module": "src/binary-file.ts"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"kind": "js",
|
|
128
|
+
"name": "updateBinaryFileArtifact",
|
|
129
|
+
"declaration": {
|
|
130
|
+
"name": "updateBinaryFileArtifact",
|
|
131
|
+
"module": "src/binary-file.ts"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"kind": "javascript-module",
|
|
138
|
+
"path": "src/card.ts",
|
|
139
|
+
"declarations": [
|
|
140
|
+
{
|
|
141
|
+
"kind": "variable",
|
|
142
|
+
"name": "artifactRenderer",
|
|
143
|
+
"type": {
|
|
144
|
+
"text": "AparteSegmentRenderer<ArtifactSegment>"
|
|
145
|
+
},
|
|
146
|
+
"default": "{ type: ARTIFACT_SEGMENT_TYPE, render: (segment: ArtifactSegment) => { const kind = (segment.artifactType || 'unknown').toLowerCase(); // Binary file kinds (xlsx/pdf/docx) follow a separate track: the generated JS // is implementation noise, so the file card shows progress, then the file. if (BINARY_FILE_KINDS.has(kind)) { return renderBinaryFileArtifact(segment, kind); } const title = segment.title?.trim() || labelForKind(kind); const displayLang = languageForKind(kind); const isStreaming = !!segment.isStreaming; const previewable = PREVIEWABLE_KINDS.has(kind) && previewEnabled(); // `t()`, not `getLocale().x ?? 'X'`: `t()` already falls back to // APARTE_DEFAULT_LOCALE, so the English lives in ONE place instead of being // re-typed at each call site — and `setLocale()` REPLACES rather than merges, // which makes a partial locale the normal case rather than an edge one. // `download` is title AND aria-label: they disagreed on the button next door, // whose title went through `t('copy')` while its aria-label said \"Copy\" in // every language. const cfg = contextConfig(); const downloadLabel = cfg.t('download'); const previewLabel = cfg.t('preview'); const codeLabel = cfg.t('code'); const isBinary = BINARY_FILE_KINDS.has(kind); const cleanContent = stripCodeFences(segment.content || ''); /* * Ids, so the tabs can POINT at their panels. * * The card announced `role=\"tablist\"` with `role=\"tab\"` buttons and shipped none * of the pattern's obligations: no `aria-controls`, no `role=\"tabpanel\"`, no ids * and no arrow keys. A role is a promise about behaviour — declaring tablist and * then behaving like two ordinary buttons tells a screen-reader user to expect a * relationship and a keyboard model that are not there, which is worse than the * plain buttons it actually was. * * Scoped to the segment id because a transcript holds many cards, and duplicate * ids would make `aria-controls` point at whichever one parsed first. * * Escaped HERE rather than inside an id-building helper: `check:attr-escaping` * follows a local produced by an escaper and cannot see through a function, and * teaching it to trust the helper's NAME is precisely the hole that guard was * just tightened to close. */ const cardId = escapeAttr(segment.id); // The card ALWAYS opens on the code tab, and the preview frame is not built // here at all — it is mounted only when the user presses Preview // (`mountPreviewFrame`, called from the tab handler). // // It used to open on Preview for any artifact that was not streaming, i.e. // every render of a completed one — so reloading a persisted conversation // executed the model's JS with no gesture. Defaulting the tab is not enough // on its own either: a `display:none` iframe still loads and still runs // scripts, so the frame has to be ABSENT, not hidden. // // Ratified decision #8, applied to a tier-(c) affordance: content the app // did not produce does not get to act on its own. return ` <div class=\"aparte-segment aparte-card aparte-segment-artifact-card\" data-segment-id=\"${escapeHtml(segment.id)}\" data-artifact-type=\"${escapeHtml(kind)}\" data-streaming=\"${isStreaming ? 'true' : 'false'}\" data-tab=\"code\" data-previewable=\"${previewable ? 'true' : 'false'}\" data-binary=\"${isBinary ? 'true' : 'false'}\"> <header class=\"aparte-art-card__header\"> <div class=\"aparte-art-card__title-block\"> <span class=\"aparte-badge aparte-badge--outline aparte-art-card__kind\" data-kind=\"${escapeHtml(kind)}\">${escapeHtml(displayLang)}</span> <span class=\"aparte-art-card__title\">${escapeHtml(title)}</span> ${isStreaming ? `<span class=\"aparte-dot aparte-art-card__pulse\" role=\"img\" aria-label=\"${escapeAttr(cfg.t('generating'))}\"></span>` : ''} </div> <div class=\"aparte-art-card__actions\"> <button type=\"button\" class=\"aparte-btn aparte-btn--icon aparte-art-card__btn\" data-action=\"copy\" title=\"${escapeAttr(contextConfig().t('copy'))}\" aria-label=\"${escapeAttr(contextConfig().t('copy'))}\"> ${contextConfig().getIcon('copy')} </button> <button type=\"button\" class=\"aparte-btn aparte-btn--icon aparte-art-card__btn\" data-action=\"download\" title=\"${escapeAttr(downloadLabel)}\" aria-label=\"${escapeAttr(downloadLabel)}\" ${isStreaming ? 'disabled' : ''}> ${contextConfig().getIcon('download')} </button> </div> </header> <nav class=\"aparte-tabs aparte-tabs--underline aparte-art-card__tabs\" role=\"tablist\"> <button type=\"button\" class=\"aparte-tabs__tab\" role=\"tab\" id=\"aparte-art-${cardId}-tab-code\" aria-controls=\"aparte-art-${cardId}-pane-code\" aria-selected=\"true\" tabindex=\"0\" data-tab-target=\"code\">${escapeHtml(codeLabel)}</button> ${previewable ? `<button type=\"button\" class=\"aparte-tabs__tab\" role=\"tab\" id=\"aparte-art-${cardId}-tab-preview\" aria-controls=\"aparte-art-${cardId}-pane-preview\" aria-selected=\"false\" tabindex=\"-1\" data-tab-target=\"preview\" ${isStreaming ? 'disabled' : ''}>${escapeHtml(previewLabel)}</button>` : ''} </nav> <div class=\"aparte-art-card__body\"> <div class=\"aparte-art-card__pane\" role=\"tabpanel\" id=\"aparte-art-${cardId}-pane-code\" aria-labelledby=\"aparte-art-${cardId}-tab-code\" tabindex=\"0\" data-pane=\"code\"> <div class=\"aparte-code-content-wrapper\"> <pre><code class=\"language-${escapeHtml(displayLang)}\">${escapeHtml(cleanContent)}</code></pre> </div> </div> ${previewable ? ` <div class=\"aparte-art-card__pane\" role=\"tabpanel\" id=\"aparte-art-${cardId}-pane-preview\" aria-labelledby=\"aparte-art-${cardId}-tab-preview\" tabindex=\"0\" data-pane=\"preview\"> <div class=\"aparte-art-card__pending\">${escapeHtml(cfg.t('previewPending'))}</div> </div> ` : ''} </div> </div> `; }, /** * Every string this card shows: the copy button's tooltip, glyph and accessible * name, the download button's title and label, and the two tab names. They were * all hardcoded literals until they got locale keys — including the copy button's * `aria-label`, which said \"Copy\" while its own `title` one attribute away already * went through `t('copy')`, so a French reader got a French tooltip and an English * announcement. * * Nothing here touches the tab state or the preview pane: a mounted iframe is * running model-authored code, and re-rendering this card is exactly what the * hook exists to avoid. */ relabel: (element: HTMLElement) => { const cfg = contextConfig(); const copyBtn = element.querySelector('.aparte-art-card__btn[data-action=\"copy\"]'); if (copyBtn) { copyBtn.setAttribute('title', cfg.t('copy')); copyBtn.setAttribute('aria-label', cfg.t('copy')); copyBtn.innerHTML = cfg.getIcon('copy'); } const dl = element.querySelector('.aparte-art-card__btn[data-action=\"download\"]'); if (dl) { const label = cfg.t('download'); dl.setAttribute('title', label); dl.setAttribute('aria-label', label); } // Text only, and never `aria-selected` or `data-tab`: which pane is open is // the reader's state, not the locale's. A relabel that touched it would close // a preview somebody had opened. const previewTab = element.querySelector('[data-tab-target=\"preview\"]'); if (previewTab) previewTab.textContent = cfg.t('preview'); const codeTab = element.querySelector('[data-tab-target=\"code\"]'); if (codeTab) codeTab.textContent = cfg.t('code'); }, setup: (element: HTMLElement, segment: AparteArtifactSegment) => { latestSegment.set(element, segment); const kind = (segment.artifactType || '').toLowerCase(); if (BINARY_FILE_KINDS.has(kind)) { setupBinaryFileArtifact(element, segment, kind); return; } // Async highlight on the code pane const wrapper = element.querySelector('.aparte-code-content-wrapper'); if (wrapper) { const displayLang = languageForKind(kind); const cleanContent = stripCodeFences(segment.content || ''); void contextConfig().highlightCode(cleanContent, displayLang).then(html => { wrapper.innerHTML = html; }).catch(() => { /* best-effort: a failed highlight degrades silently */ }); } /* * Tab switching — and, for Preview, the one place the frame is created. * * A `tablist` is a SINGLE tab stop with arrow keys inside it, not N tab stops. * This shipped as two ordinary buttons under a tablist role: Tab landed on each * in turn and the arrows did nothing, so the role promised a keyboard model the * card did not have. The roving `tabindex` and the arrow handling below are that * model; `aria-controls` / `role=\"tabpanel\"` in the markup are the other half. */ const tabs = [...element.querySelectorAll<HTMLButtonElement>('[data-tab-target]')]; const select = (btn: HTMLButtonElement, focus: boolean): void => { const target = btn.getAttribute('data-tab-target'); if (!target || btn.disabled) return; if (target === 'preview') mountPreviewFrame(element, segment); element.setAttribute('data-tab', target); for (const b of tabs) { const on = b === btn; b.setAttribute('aria-selected', on ? 'true' : 'false'); b.tabIndex = on ? 0 : -1; } if (focus) btn.focus(); }; for (const [i, btn] of tabs.entries()) { btn.addEventListener('click', () => select(btn, false)); btn.addEventListener('keydown', (e) => { // Home/End as well as the arrows: both are in the pattern, and on a // two-tab list they are the fastest way to the one you are not on. const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0; let next = -1; if (step) next = (i + step + tabs.length) % tabs.length; else if (e.key === 'Home') next = 0; else if (e.key === 'End') next = tabs.length - 1; if (next < 0) return; e.preventDefault(); // Skip a disabled tab rather than trapping focus on it: Preview is // disabled while the artifact still streams. for (let n = 0; n < tabs.length; n++) { const candidate = tabs[(next + n * (step || 1) + tabs.length) % tabs.length]; if (candidate && !candidate.disabled) { select(candidate, true); return; } } }); } // Copy const copyBtn = element.querySelector<HTMLButtonElement>('[data-action=\"copy\"]'); if (copyBtn) { copyBtn.addEventListener('click', () => { // Late execution (user click) — resolve from the element. const code = stripCodeFences(segment.content || ''); void copyText(code).catch(() => { /* best-effort: a failed clipboard write degrades silently */ }); const original = copyBtn.innerHTML; copyBtn.innerHTML = contextConfig(copyBtn).getIcon('check'); copyBtn.setAttribute('title', contextConfig(copyBtn).t('copied')); setTimeout(() => { copyBtn.innerHTML = original; copyBtn.setAttribute('title', contextConfig(copyBtn).t('copy')); }, 1500); }); } // Download — a text artifact downloads from its own content. (A binary one // never reaches here: its setup returned above, and its file card owns the // button.) The LATEST segment, not the one this closure captured. const dlBtn = element.querySelector<HTMLButtonElement>('[data-action=\"download\"]'); if (dlBtn) { dlBtn.addEventListener('click', () => { if (dlBtn.disabled) return; downloadTextArtifact(latestSegment.get(element) ?? segment); }); } }, update: (element: HTMLElement, segment: AparteArtifactSegment) => { // Keep the click handler's view of the artifact current, and throw away a // frame that is now showing stale content so the next press rebuilds it. const previous = latestSegment.get(element); latestSegment.set(element, segment); if (previous && previous.content !== segment.content) { element.querySelector('.aparte-art-card__pane[data-pane=\"preview\"] iframe')?.remove(); } const isStreaming = !!segment.isStreaming; const kind = (segment.artifactType || '').toLowerCase(); if (BINARY_FILE_KINDS.has(kind)) { updateBinaryFileArtifact(element, segment, isStreaming); return; } const wasStreaming = element.getAttribute('data-streaming') === 'true'; const cleanContent = stripCodeFences(segment.content || ''); // 1. Live-update the code pane during streaming. // // One call owns both halves — the plain tail every token and the coloured // prefix on a throttle. Setting `textContent` here as well is what made the // pane flicker: it erased the highlighter's spans on every token. if (isStreaming) { const segId = element.getAttribute('data-segment-id') ?? segment.id; streamHighlight(element, '.aparte-code-content-wrapper', cleanContent, languageForKind(kind), segId); } else { const codeEl = element.querySelector('.aparte-code-content-wrapper code'); if (codeEl) { codeEl.textContent = cleanContent; } else { const wrapper = element.querySelector('.aparte-code-content-wrapper'); if (wrapper) { const displayLang = languageForKind(kind); wrapper.innerHTML = `<pre><code class=\"language-${escapeHtml(displayLang)}\">${escapeHtml(cleanContent)}</code></pre>`; } } } // 2. On stream-completion: highlight + build preview iframe + auto-switch if (wasStreaming && !isStreaming) { element.setAttribute('data-streaming', 'false'); // The pulse says \"the model is still writing this\". `render()` painted it // and nothing ever took it away, so a finished document kept claiming to be // in flight — forever, at 1.2s a cycle. Unnoticed until the artifact demo // actually streamed: the indicator had never been exercised. element.querySelector('.aparte-art-card__pulse')?.remove(); // Re-run syntax highlight now that content is final const wrapper = element.querySelector('.aparte-code-content-wrapper'); if (wrapper) { const displayLang = languageForKind(kind); void contextConfig().highlightCode(cleanContent, displayLang).then(html => { wrapper.innerHTML = html; }).catch(() => { /* best-effort: a failed highlight degrades silently */ }); } // Enable previously-disabled buttons (download, preview tab) element.querySelectorAll<HTMLButtonElement>('button[disabled]').forEach(b => { b.disabled = false; }); // Nothing to build and nothing to switch: enabling the Preview button // above is the whole of it. The frame is mounted by the tab handler, on // a real user press — see the note at `initialTab`. } }, // The card's sheet, injected once per document by core — the seam a renderer that // is not core's has onto the page. It is a real `.css` file, inlined at build. getStyles: () => artifactStyles, }"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"exports": [
|
|
150
|
+
{
|
|
151
|
+
"kind": "js",
|
|
152
|
+
"name": "artifactRenderer",
|
|
153
|
+
"declaration": {
|
|
154
|
+
"name": "artifactRenderer",
|
|
155
|
+
"module": "src/card.ts"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"kind": "javascript-module",
|
|
162
|
+
"path": "src/highlight.ts",
|
|
163
|
+
"declarations": [
|
|
164
|
+
{
|
|
165
|
+
"kind": "function",
|
|
166
|
+
"name": "markThrottle",
|
|
167
|
+
"return": {
|
|
168
|
+
"type": {
|
|
169
|
+
"text": "void"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"parameters": [
|
|
173
|
+
{
|
|
174
|
+
"name": "map",
|
|
175
|
+
"type": {
|
|
176
|
+
"text": "Map<string, number>"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "id",
|
|
181
|
+
"type": {
|
|
182
|
+
"text": "string"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "at",
|
|
187
|
+
"type": {
|
|
188
|
+
"text": "number"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"description": "Record `id`'s last-seen time in a bounded, insertion-ordered map.\n\nShared with the artifact's event-dispatch throttle, which is why it is generic\nover the map rather than closing over one."
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"kind": "function",
|
|
196
|
+
"name": "streamHighlight",
|
|
197
|
+
"return": {
|
|
198
|
+
"type": {
|
|
199
|
+
"text": "void"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
"parameters": [
|
|
203
|
+
{
|
|
204
|
+
"name": "element",
|
|
205
|
+
"type": {
|
|
206
|
+
"text": "HTMLElement"
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "paneSelector",
|
|
211
|
+
"type": {
|
|
212
|
+
"text": "string"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "content",
|
|
217
|
+
"type": {
|
|
218
|
+
"text": "string"
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "lang",
|
|
223
|
+
"type": {
|
|
224
|
+
"text": "string"
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"name": "segId",
|
|
229
|
+
"type": {
|
|
230
|
+
"text": "string"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
"description": "Paint `content` into `paneSelector` while it streams.\n\nCall it on every token: the cheap half runs every time, the highlight is\nthrottled internally. The caller still runs one final, whole-content highlight\nwhen the segment settles — this function deliberately never colours the last\nline, so the settle pass is what completes it."
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"exports": [
|
|
238
|
+
{
|
|
239
|
+
"kind": "js",
|
|
240
|
+
"name": "markThrottle",
|
|
241
|
+
"declaration": {
|
|
242
|
+
"name": "markThrottle",
|
|
243
|
+
"module": "src/highlight.ts"
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"kind": "js",
|
|
248
|
+
"name": "streamHighlight",
|
|
249
|
+
"declaration": {
|
|
250
|
+
"name": "streamHighlight",
|
|
251
|
+
"module": "src/highlight.ts"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"kind": "javascript-module",
|
|
258
|
+
"path": "src/index.node.ts",
|
|
259
|
+
"declarations": [
|
|
260
|
+
{
|
|
261
|
+
"kind": "function",
|
|
262
|
+
"name": "setupArtifacts",
|
|
263
|
+
"return": {
|
|
264
|
+
"type": {
|
|
265
|
+
"text": "() => void"
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"parameters": [
|
|
269
|
+
{
|
|
270
|
+
"name": "options",
|
|
271
|
+
"default": "{}",
|
|
272
|
+
"type": {
|
|
273
|
+
"text": "ArtifactsSetupOptions"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"name": "config",
|
|
278
|
+
"default": "aparteGlobalConfig",
|
|
279
|
+
"type": {
|
|
280
|
+
"text": "AparteConfig"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
],
|
|
284
|
+
"description": "Register the tool, its handler and the grammar on the server. No renderer: it builds DOM."
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"exports": [
|
|
288
|
+
{
|
|
289
|
+
"kind": "js",
|
|
290
|
+
"name": "setupArtifacts",
|
|
291
|
+
"declaration": {
|
|
292
|
+
"name": "setupArtifacts",
|
|
293
|
+
"module": "src/index.node.ts"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"kind": "js",
|
|
298
|
+
"name": "createArtifactTool",
|
|
299
|
+
"declaration": {
|
|
300
|
+
"name": "createArtifactTool",
|
|
301
|
+
"module": "./tool.js"
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"kind": "js",
|
|
306
|
+
"name": "artifactHandler",
|
|
307
|
+
"declaration": {
|
|
308
|
+
"name": "artifactHandler",
|
|
309
|
+
"module": "./tool.js"
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"kind": "js",
|
|
314
|
+
"name": "ARTIFACT_SYSTEM_PROMPT",
|
|
315
|
+
"declaration": {
|
|
316
|
+
"name": "ARTIFACT_SYSTEM_PROMPT",
|
|
317
|
+
"module": "./tool.js"
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"kind": "js",
|
|
322
|
+
"name": "ArtifactToolOptions",
|
|
323
|
+
"declaration": {
|
|
324
|
+
"name": "ArtifactToolOptions",
|
|
325
|
+
"module": "./tool.js"
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"kind": "js",
|
|
330
|
+
"name": "artifactBlock",
|
|
331
|
+
"declaration": {
|
|
332
|
+
"name": "artifactBlock",
|
|
333
|
+
"module": "./segment.js"
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"kind": "js",
|
|
338
|
+
"name": "artifactSegment",
|
|
339
|
+
"declaration": {
|
|
340
|
+
"name": "artifactSegment",
|
|
341
|
+
"module": "./segment.js"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"kind": "js",
|
|
346
|
+
"name": "artifactFromToolCall",
|
|
347
|
+
"declaration": {
|
|
348
|
+
"name": "artifactFromToolCall",
|
|
349
|
+
"module": "./segment.js"
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"kind": "js",
|
|
354
|
+
"name": "ARTIFACT_TAG",
|
|
355
|
+
"declaration": {
|
|
356
|
+
"name": "ARTIFACT_TAG",
|
|
357
|
+
"module": "./segment.js"
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"kind": "js",
|
|
362
|
+
"name": "ARTIFACT_SEGMENT_TYPE",
|
|
363
|
+
"declaration": {
|
|
364
|
+
"name": "ARTIFACT_SEGMENT_TYPE",
|
|
365
|
+
"module": "./segment.js"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"kind": "js",
|
|
370
|
+
"name": "ArtifactSegment",
|
|
371
|
+
"declaration": {
|
|
372
|
+
"name": "ArtifactSegment",
|
|
373
|
+
"module": "./segment.js"
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"kind": "js",
|
|
378
|
+
"name": "ArtifactInput",
|
|
379
|
+
"declaration": {
|
|
380
|
+
"name": "ArtifactInput",
|
|
381
|
+
"module": "./segment.js"
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"kind": "js",
|
|
386
|
+
"name": "deriveArtifactKind",
|
|
387
|
+
"declaration": {
|
|
388
|
+
"name": "deriveArtifactKind",
|
|
389
|
+
"module": "./kinds.js"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"kind": "js",
|
|
394
|
+
"name": "buildSafePreviewDocument",
|
|
395
|
+
"declaration": {
|
|
396
|
+
"name": "buildSafePreviewDocument",
|
|
397
|
+
"module": "./preview-document.js"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"kind": "js",
|
|
402
|
+
"name": "PREVIEW_CSP",
|
|
403
|
+
"declaration": {
|
|
404
|
+
"name": "PREVIEW_CSP",
|
|
405
|
+
"module": "./preview-document.js"
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"kind": "js",
|
|
410
|
+
"name": "ArtifactRenderOptions",
|
|
411
|
+
"declaration": {
|
|
412
|
+
"name": "ArtifactRenderOptions",
|
|
413
|
+
"module": "./options.js"
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"kind": "js",
|
|
418
|
+
"name": "ArtifactPreviewBuilder",
|
|
419
|
+
"declaration": {
|
|
420
|
+
"name": "ArtifactPreviewBuilder",
|
|
421
|
+
"module": "./options.js"
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"kind": "js",
|
|
426
|
+
"name": "ArtifactBinary",
|
|
427
|
+
"declaration": {
|
|
428
|
+
"name": "ArtifactBinary",
|
|
429
|
+
"module": "./options.js"
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"kind": "js",
|
|
434
|
+
"name": "ArtifactBinaryResolver",
|
|
435
|
+
"declaration": {
|
|
436
|
+
"name": "ArtifactBinaryResolver",
|
|
437
|
+
"module": "./options.js"
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"kind": "js",
|
|
442
|
+
"name": "ArtifactsSetupOptions",
|
|
443
|
+
"declaration": {
|
|
444
|
+
"name": "ArtifactsSetupOptions",
|
|
445
|
+
"module": "./options.js"
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"kind": "js",
|
|
450
|
+
"name": "AparteTool",
|
|
451
|
+
"declaration": {
|
|
452
|
+
"name": "AparteTool",
|
|
453
|
+
"package": "@aparte/core"
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"kind": "js",
|
|
458
|
+
"name": "AparteToolHandler",
|
|
459
|
+
"declaration": {
|
|
460
|
+
"name": "AparteToolHandler",
|
|
461
|
+
"package": "@aparte/core"
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"kind": "js",
|
|
466
|
+
"name": "AparteToolCall",
|
|
467
|
+
"declaration": {
|
|
468
|
+
"name": "AparteToolCall",
|
|
469
|
+
"package": "@aparte/core"
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"kind": "js",
|
|
474
|
+
"name": "AparteToolResult",
|
|
475
|
+
"declaration": {
|
|
476
|
+
"name": "AparteToolResult",
|
|
477
|
+
"package": "@aparte/core"
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
]
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"kind": "javascript-module",
|
|
484
|
+
"path": "src/index.ts",
|
|
485
|
+
"declarations": [
|
|
486
|
+
{
|
|
487
|
+
"kind": "function",
|
|
488
|
+
"name": "setupArtifacts",
|
|
489
|
+
"return": {
|
|
490
|
+
"type": {
|
|
491
|
+
"text": "() => void"
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
"parameters": [
|
|
495
|
+
{
|
|
496
|
+
"name": "options",
|
|
497
|
+
"default": "{}",
|
|
498
|
+
"type": {
|
|
499
|
+
"text": "ArtifactsSetupOptions"
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"name": "config",
|
|
504
|
+
"default": "aparteGlobalConfig",
|
|
505
|
+
"type": {
|
|
506
|
+
"text": "AparteConfig"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
],
|
|
510
|
+
"description": "Register the tool, its renderer, the block grammar and the segment renderer on\n`config` (the global config by default). Call once at application startup;\nreturns a function that unregisters all four."
|
|
511
|
+
}
|
|
512
|
+
],
|
|
513
|
+
"exports": [
|
|
514
|
+
{
|
|
515
|
+
"kind": "js",
|
|
516
|
+
"name": "setupArtifacts",
|
|
517
|
+
"declaration": {
|
|
518
|
+
"name": "setupArtifacts",
|
|
519
|
+
"module": "src/index.ts"
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
"kind": "js",
|
|
524
|
+
"name": "createArtifactTool",
|
|
525
|
+
"declaration": {
|
|
526
|
+
"name": "createArtifactTool",
|
|
527
|
+
"module": "./tool.js"
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
"kind": "js",
|
|
532
|
+
"name": "artifactHandler",
|
|
533
|
+
"declaration": {
|
|
534
|
+
"name": "artifactHandler",
|
|
535
|
+
"module": "./tool.js"
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"kind": "js",
|
|
540
|
+
"name": "ARTIFACT_SYSTEM_PROMPT",
|
|
541
|
+
"declaration": {
|
|
542
|
+
"name": "ARTIFACT_SYSTEM_PROMPT",
|
|
543
|
+
"module": "./tool.js"
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
"kind": "js",
|
|
548
|
+
"name": "ArtifactToolOptions",
|
|
549
|
+
"declaration": {
|
|
550
|
+
"name": "ArtifactToolOptions",
|
|
551
|
+
"module": "./tool.js"
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"kind": "js",
|
|
556
|
+
"name": "artifactRenderer",
|
|
557
|
+
"declaration": {
|
|
558
|
+
"name": "artifactRenderer",
|
|
559
|
+
"module": "./card.js"
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"kind": "js",
|
|
564
|
+
"name": "AparteArtifactSegment",
|
|
565
|
+
"declaration": {
|
|
566
|
+
"name": "AparteArtifactSegment",
|
|
567
|
+
"module": "./card.js"
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
"kind": "js",
|
|
572
|
+
"name": "artifactBlock",
|
|
573
|
+
"declaration": {
|
|
574
|
+
"name": "artifactBlock",
|
|
575
|
+
"module": "./segment.js"
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"kind": "js",
|
|
580
|
+
"name": "artifactSegment",
|
|
581
|
+
"declaration": {
|
|
582
|
+
"name": "artifactSegment",
|
|
583
|
+
"module": "./segment.js"
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
"kind": "js",
|
|
588
|
+
"name": "artifactFromToolCall",
|
|
589
|
+
"declaration": {
|
|
590
|
+
"name": "artifactFromToolCall",
|
|
591
|
+
"module": "./segment.js"
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"kind": "js",
|
|
596
|
+
"name": "ARTIFACT_TAG",
|
|
597
|
+
"declaration": {
|
|
598
|
+
"name": "ARTIFACT_TAG",
|
|
599
|
+
"module": "./segment.js"
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
"kind": "js",
|
|
604
|
+
"name": "ARTIFACT_SEGMENT_TYPE",
|
|
605
|
+
"declaration": {
|
|
606
|
+
"name": "ARTIFACT_SEGMENT_TYPE",
|
|
607
|
+
"module": "./segment.js"
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
"kind": "js",
|
|
612
|
+
"name": "ArtifactSegment",
|
|
613
|
+
"declaration": {
|
|
614
|
+
"name": "ArtifactSegment",
|
|
615
|
+
"module": "./segment.js"
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
"kind": "js",
|
|
620
|
+
"name": "ArtifactInput",
|
|
621
|
+
"declaration": {
|
|
622
|
+
"name": "ArtifactInput",
|
|
623
|
+
"module": "./segment.js"
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
"kind": "js",
|
|
628
|
+
"name": "deriveArtifactKind",
|
|
629
|
+
"declaration": {
|
|
630
|
+
"name": "deriveArtifactKind",
|
|
631
|
+
"module": "./kinds.js"
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"kind": "js",
|
|
636
|
+
"name": "buildSafePreviewDocument",
|
|
637
|
+
"declaration": {
|
|
638
|
+
"name": "buildSafePreviewDocument",
|
|
639
|
+
"module": "./preview-document.js"
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"kind": "js",
|
|
644
|
+
"name": "PREVIEW_CSP",
|
|
645
|
+
"declaration": {
|
|
646
|
+
"name": "PREVIEW_CSP",
|
|
647
|
+
"module": "./preview-document.js"
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
"kind": "js",
|
|
652
|
+
"name": "ArtifactRenderOptions",
|
|
653
|
+
"declaration": {
|
|
654
|
+
"name": "ArtifactRenderOptions",
|
|
655
|
+
"module": "./options.js"
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
"kind": "js",
|
|
660
|
+
"name": "ArtifactPreviewBuilder",
|
|
661
|
+
"declaration": {
|
|
662
|
+
"name": "ArtifactPreviewBuilder",
|
|
663
|
+
"module": "./options.js"
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
"kind": "js",
|
|
668
|
+
"name": "ArtifactBinary",
|
|
669
|
+
"declaration": {
|
|
670
|
+
"name": "ArtifactBinary",
|
|
671
|
+
"module": "./options.js"
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
"kind": "js",
|
|
676
|
+
"name": "ArtifactBinaryResolver",
|
|
677
|
+
"declaration": {
|
|
678
|
+
"name": "ArtifactBinaryResolver",
|
|
679
|
+
"module": "./options.js"
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"kind": "js",
|
|
684
|
+
"name": "ArtifactsSetupOptions",
|
|
685
|
+
"declaration": {
|
|
686
|
+
"name": "ArtifactsSetupOptions",
|
|
687
|
+
"module": "./options.js"
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
"kind": "js",
|
|
692
|
+
"name": "AparteTool",
|
|
693
|
+
"declaration": {
|
|
694
|
+
"name": "AparteTool",
|
|
695
|
+
"package": "@aparte/core"
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
"kind": "js",
|
|
700
|
+
"name": "AparteToolHandler",
|
|
701
|
+
"declaration": {
|
|
702
|
+
"name": "AparteToolHandler",
|
|
703
|
+
"package": "@aparte/core"
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"kind": "js",
|
|
708
|
+
"name": "AparteToolCall",
|
|
709
|
+
"declaration": {
|
|
710
|
+
"name": "AparteToolCall",
|
|
711
|
+
"package": "@aparte/core"
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
"kind": "js",
|
|
716
|
+
"name": "AparteToolResult",
|
|
717
|
+
"declaration": {
|
|
718
|
+
"name": "AparteToolResult",
|
|
719
|
+
"package": "@aparte/core"
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
]
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"kind": "javascript-module",
|
|
726
|
+
"path": "src/kinds.ts",
|
|
727
|
+
"declarations": [
|
|
728
|
+
{
|
|
729
|
+
"kind": "function",
|
|
730
|
+
"name": "deriveArtifactKind",
|
|
731
|
+
"return": {
|
|
732
|
+
"type": {
|
|
733
|
+
"text": "string"
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
"parameters": [
|
|
737
|
+
{
|
|
738
|
+
"name": "mimeType",
|
|
739
|
+
"type": {
|
|
740
|
+
"text": "string"
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
"name": "fallback",
|
|
745
|
+
"default": "'unknown'"
|
|
746
|
+
}
|
|
747
|
+
],
|
|
748
|
+
"description": "Map an artifact MIME type to a renderer kind — `'react'`, `'html'`, `'js'`, `'css'`,\n`'svg'`, `'json'`, `'markdown'`, `'csv'`, `'text'` — or `fallback` (default\n`'unknown'`) for anything else. Anthropic's `application/vnd.ant.*` namespace maps to\nits suffix; exact standard MIMEs are matched first, then a substring rescue for\nparameterised or vendor variants (`text/html; charset=utf-8`, `application/ld+json`).\n\nTHE implementation, and the plugin's: it used to live in `@aparte/engine` and be\nre-exported by `@aparte/core`, because the engine's built-in `create_artifact` and\ncore's parser both needed it. Neither does any more — an artifact is a plugin's\nconvention, so the function that names its kinds is the plugin's too."
|
|
749
|
+
}
|
|
750
|
+
],
|
|
751
|
+
"exports": [
|
|
752
|
+
{
|
|
753
|
+
"kind": "js",
|
|
754
|
+
"name": "deriveArtifactKind",
|
|
755
|
+
"declaration": {
|
|
756
|
+
"name": "deriveArtifactKind",
|
|
757
|
+
"module": "src/kinds.ts"
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
]
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
"kind": "javascript-module",
|
|
764
|
+
"path": "src/options.ts",
|
|
765
|
+
"declarations": [
|
|
766
|
+
{
|
|
767
|
+
"kind": "function",
|
|
768
|
+
"name": "setRenderOptions",
|
|
769
|
+
"return": {
|
|
770
|
+
"type": {
|
|
771
|
+
"text": "void"
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
"parameters": [
|
|
775
|
+
{
|
|
776
|
+
"name": "config",
|
|
777
|
+
"type": {
|
|
778
|
+
"text": "AparteConfig"
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"name": "options",
|
|
783
|
+
"type": {
|
|
784
|
+
"text": "ArtifactRenderOptions"
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
]
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
"kind": "function",
|
|
791
|
+
"name": "renderOptions",
|
|
792
|
+
"return": {
|
|
793
|
+
"type": {
|
|
794
|
+
"text": "ArtifactRenderOptions"
|
|
795
|
+
}
|
|
796
|
+
},
|
|
797
|
+
"parameters": [
|
|
798
|
+
{
|
|
799
|
+
"name": "config",
|
|
800
|
+
"type": {
|
|
801
|
+
"text": "AparteConfig"
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
],
|
|
805
|
+
"description": "The options for this config, else the global config's, else the defaults."
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
"kind": "function",
|
|
809
|
+
"name": "clearRenderOptions",
|
|
810
|
+
"return": {
|
|
811
|
+
"type": {
|
|
812
|
+
"text": "void"
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
"parameters": [
|
|
816
|
+
{
|
|
817
|
+
"name": "config",
|
|
818
|
+
"type": {
|
|
819
|
+
"text": "AparteConfig"
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
],
|
|
823
|
+
"description": "For tests and a teardown: forget what a config was told."
|
|
824
|
+
}
|
|
825
|
+
],
|
|
826
|
+
"exports": [
|
|
827
|
+
{
|
|
828
|
+
"kind": "js",
|
|
829
|
+
"name": "setRenderOptions",
|
|
830
|
+
"declaration": {
|
|
831
|
+
"name": "setRenderOptions",
|
|
832
|
+
"module": "src/options.ts"
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
"kind": "js",
|
|
837
|
+
"name": "renderOptions",
|
|
838
|
+
"declaration": {
|
|
839
|
+
"name": "renderOptions",
|
|
840
|
+
"module": "src/options.ts"
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
"kind": "js",
|
|
845
|
+
"name": "clearRenderOptions",
|
|
846
|
+
"declaration": {
|
|
847
|
+
"name": "clearRenderOptions",
|
|
848
|
+
"module": "src/options.ts"
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
]
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
"kind": "javascript-module",
|
|
855
|
+
"path": "src/preview-document.ts",
|
|
856
|
+
"declarations": [
|
|
857
|
+
{
|
|
858
|
+
"kind": "variable",
|
|
859
|
+
"name": "PREVIEW_CSP",
|
|
860
|
+
"type": {
|
|
861
|
+
"text": "string"
|
|
862
|
+
},
|
|
863
|
+
"default": "\"default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; font-src data:\"",
|
|
864
|
+
"description": "What a previewed artifact is allowed to FETCH. Inline script and style are\npermitted (that IS the preview); no fetch, no XHR, no websocket, no remote image,\nno font. Without this the sandbox still lets injected code beacon out to any\norigin, so the policy does real work — measured blocked in Chromium, Firefox and\nWebKit.\n\nWHAT IT DOES NOT STOP, stated because the sentence here used to claim otherwise:\nthe frame NAVIGATING ITSELF. Assigning `location.href` is a navigation, not a\nfetch, and no directive in this policy governs it — CSP's `navigate-to` was\nremoved from the spec and never shipped, and the parent page's `frame-src` does\nnot apply to a navigation the frame initiates. Reproduced in all three engines;\nin Firefox and WebKit the frame then RENDERS the attacker's page inside the card,\nwhich is a phishing surface as well as an exfiltration channel.\n\nWhat still holds, and is why this is serious rather than fatal: the sandbox has\nno `allow-same-origin`, so the frame's origin is opaque — it cannot read the host\npage, its storage, or the API key — and no `allow-forms` or\n`allow-top-navigation`, so it can neither POST nor move the tab.\n\nThe honest summary for a consumer: a previewed artifact cannot reach your page or\nyour data, and can phone home once. Previewing model-authored HTML is running\nuntrusted content in a box, not running nothing."
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
"kind": "function",
|
|
868
|
+
"name": "buildSafePreviewDocument",
|
|
869
|
+
"return": {
|
|
870
|
+
"type": {
|
|
871
|
+
"text": "string"
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
"parameters": [
|
|
875
|
+
{
|
|
876
|
+
"name": "kind",
|
|
877
|
+
"type": {
|
|
878
|
+
"text": "string"
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
"name": "body",
|
|
883
|
+
"type": {
|
|
884
|
+
"text": "string"
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
"name": "title",
|
|
889
|
+
"type": {
|
|
890
|
+
"text": "string"
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
]
|
|
894
|
+
}
|
|
895
|
+
],
|
|
896
|
+
"exports": [
|
|
897
|
+
{
|
|
898
|
+
"kind": "js",
|
|
899
|
+
"name": "PREVIEW_CSP",
|
|
900
|
+
"declaration": {
|
|
901
|
+
"name": "PREVIEW_CSP",
|
|
902
|
+
"module": "src/preview-document.ts"
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"kind": "js",
|
|
907
|
+
"name": "buildSafePreviewDocument",
|
|
908
|
+
"declaration": {
|
|
909
|
+
"name": "buildSafePreviewDocument",
|
|
910
|
+
"module": "src/preview-document.ts"
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
]
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
"kind": "javascript-module",
|
|
917
|
+
"path": "src/segment.ts",
|
|
918
|
+
"declarations": [
|
|
919
|
+
{
|
|
920
|
+
"kind": "variable",
|
|
921
|
+
"name": "ARTIFACT_SEGMENT_TYPE",
|
|
922
|
+
"type": {
|
|
923
|
+
"text": "'artifact'"
|
|
924
|
+
},
|
|
925
|
+
"default": "'artifact'",
|
|
926
|
+
"description": "Segment type discriminator. Registered by `setupArtifacts()`, not built into core."
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"kind": "variable",
|
|
930
|
+
"name": "ARTIFACT_TAG",
|
|
931
|
+
"type": {
|
|
932
|
+
"text": "string"
|
|
933
|
+
},
|
|
934
|
+
"default": "'artifact'",
|
|
935
|
+
"description": "The default tag the grammar recognises: `<artifact …>…</artifact>`."
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
"kind": "function",
|
|
939
|
+
"name": "artifactSegment",
|
|
940
|
+
"return": {
|
|
941
|
+
"type": {
|
|
942
|
+
"text": "ArtifactSegment"
|
|
943
|
+
}
|
|
944
|
+
},
|
|
945
|
+
"parameters": [
|
|
946
|
+
{
|
|
947
|
+
"name": "id",
|
|
948
|
+
"type": {
|
|
949
|
+
"text": "string"
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
"name": "input",
|
|
954
|
+
"type": {
|
|
955
|
+
"text": "Partial<ArtifactInput>"
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
],
|
|
959
|
+
"description": "Build the segment for a document, from either path."
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"kind": "function",
|
|
963
|
+
"name": "artifactBlock",
|
|
964
|
+
"return": {
|
|
965
|
+
"type": {
|
|
966
|
+
"text": "AparteStreamBlock"
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
"parameters": [
|
|
970
|
+
{
|
|
971
|
+
"name": "tag",
|
|
972
|
+
"default": "ARTIFACT_TAG",
|
|
973
|
+
"type": {
|
|
974
|
+
"text": "string"
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
],
|
|
978
|
+
"description": "The block grammar for `<artifact …>…</artifact>` in the prose.\n\nBoth attribute spellings are read — `type=` (Anthropic's) and `mimeType=` — and\n`mimeType` wins when both are present; `title=` is optional. Everything the parser\ndoes with it (chunk boundaries, the partial closing tag, `finalize()`) is core's."
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
"kind": "function",
|
|
982
|
+
"name": "artifactFromToolCall",
|
|
983
|
+
"return": {
|
|
984
|
+
"type": {
|
|
985
|
+
"text": "ArtifactSegment"
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
"parameters": [
|
|
989
|
+
{
|
|
990
|
+
"name": "segment",
|
|
991
|
+
"type": {
|
|
992
|
+
"text": "AparteToolCallSegment"
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
],
|
|
996
|
+
"description": "The artifact a tool-call segment carries: its structured result once the tool ran,\nelse the model's input while the call is pending — so the card can be drawn before\nthe handler returns, which is instantaneous anyway."
|
|
997
|
+
}
|
|
998
|
+
],
|
|
999
|
+
"exports": [
|
|
1000
|
+
{
|
|
1001
|
+
"kind": "js",
|
|
1002
|
+
"name": "ARTIFACT_SEGMENT_TYPE",
|
|
1003
|
+
"declaration": {
|
|
1004
|
+
"name": "ARTIFACT_SEGMENT_TYPE",
|
|
1005
|
+
"module": "src/segment.ts"
|
|
1006
|
+
}
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
"kind": "js",
|
|
1010
|
+
"name": "ARTIFACT_TAG",
|
|
1011
|
+
"declaration": {
|
|
1012
|
+
"name": "ARTIFACT_TAG",
|
|
1013
|
+
"module": "src/segment.ts"
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
"kind": "js",
|
|
1018
|
+
"name": "artifactSegment",
|
|
1019
|
+
"declaration": {
|
|
1020
|
+
"name": "artifactSegment",
|
|
1021
|
+
"module": "src/segment.ts"
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
"kind": "js",
|
|
1026
|
+
"name": "artifactBlock",
|
|
1027
|
+
"declaration": {
|
|
1028
|
+
"name": "artifactBlock",
|
|
1029
|
+
"module": "src/segment.ts"
|
|
1030
|
+
}
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
"kind": "js",
|
|
1034
|
+
"name": "artifactFromToolCall",
|
|
1035
|
+
"declaration": {
|
|
1036
|
+
"name": "artifactFromToolCall",
|
|
1037
|
+
"module": "src/segment.ts"
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
]
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
"kind": "javascript-module",
|
|
1044
|
+
"path": "src/shared.ts",
|
|
1045
|
+
"declarations": [
|
|
1046
|
+
{
|
|
1047
|
+
"kind": "function",
|
|
1048
|
+
"name": "stripCodeFences",
|
|
1049
|
+
"return": {
|
|
1050
|
+
"type": {
|
|
1051
|
+
"text": "string"
|
|
1052
|
+
}
|
|
1053
|
+
},
|
|
1054
|
+
"parameters": [
|
|
1055
|
+
{
|
|
1056
|
+
"name": "content",
|
|
1057
|
+
"type": {
|
|
1058
|
+
"text": "string"
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
],
|
|
1062
|
+
"description": "Strip leading/trailing markdown code fences (``` or ~~~, optional lang tag).\nAlso strips any content that appears after the closing fence (small models\nfrequently duplicate lines after the closing ``` block).\n\nChar-based scanner — no regex."
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
"kind": "function",
|
|
1066
|
+
"name": "labelForKind",
|
|
1067
|
+
"return": {
|
|
1068
|
+
"type": {
|
|
1069
|
+
"text": "string"
|
|
1070
|
+
}
|
|
1071
|
+
},
|
|
1072
|
+
"parameters": [
|
|
1073
|
+
{
|
|
1074
|
+
"name": "kind",
|
|
1075
|
+
"type": {
|
|
1076
|
+
"text": "string"
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
]
|
|
1080
|
+
}
|
|
1081
|
+
],
|
|
1082
|
+
"exports": [
|
|
1083
|
+
{
|
|
1084
|
+
"kind": "js",
|
|
1085
|
+
"name": "stripCodeFences",
|
|
1086
|
+
"declaration": {
|
|
1087
|
+
"name": "stripCodeFences",
|
|
1088
|
+
"module": "src/shared.ts"
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
"kind": "js",
|
|
1093
|
+
"name": "labelForKind",
|
|
1094
|
+
"declaration": {
|
|
1095
|
+
"name": "labelForKind",
|
|
1096
|
+
"module": "src/shared.ts"
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
]
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
"kind": "javascript-module",
|
|
1103
|
+
"path": "src/tool.ts",
|
|
1104
|
+
"declarations": [
|
|
1105
|
+
{
|
|
1106
|
+
"kind": "variable",
|
|
1107
|
+
"name": "ARTIFACT_SYSTEM_PROMPT",
|
|
1108
|
+
"description": "What the model is told, when the app does not say otherwise."
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
"kind": "function",
|
|
1112
|
+
"name": "createArtifactTool",
|
|
1113
|
+
"return": {
|
|
1114
|
+
"type": {
|
|
1115
|
+
"text": "AparteTool"
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
"parameters": [
|
|
1119
|
+
{
|
|
1120
|
+
"name": "options",
|
|
1121
|
+
"default": "{}",
|
|
1122
|
+
"type": {
|
|
1123
|
+
"text": "ArtifactToolOptions"
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
],
|
|
1127
|
+
"description": "The tool definition — name, description, input schema, system prompt."
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"kind": "function",
|
|
1131
|
+
"name": "artifactHandler",
|
|
1132
|
+
"return": {
|
|
1133
|
+
"type": {
|
|
1134
|
+
"text": "Promise<AparteToolResult>"
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
"parameters": [
|
|
1138
|
+
{
|
|
1139
|
+
"name": "call",
|
|
1140
|
+
"type": {
|
|
1141
|
+
"text": "AparteToolCall"
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
],
|
|
1145
|
+
"description": "The handler: the document IS the result. The prose tells the model what happened;\nthe structured twin carries the artifact for the renderer, verbatim."
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
"kind": "variable",
|
|
1149
|
+
"name": "mimeType"
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
"kind": "variable",
|
|
1153
|
+
"name": "content"
|
|
1154
|
+
}
|
|
1155
|
+
],
|
|
1156
|
+
"exports": [
|
|
1157
|
+
{
|
|
1158
|
+
"kind": "js",
|
|
1159
|
+
"name": "ARTIFACT_SYSTEM_PROMPT",
|
|
1160
|
+
"declaration": {
|
|
1161
|
+
"name": "ARTIFACT_SYSTEM_PROMPT",
|
|
1162
|
+
"module": "src/tool.ts"
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
"kind": "js",
|
|
1167
|
+
"name": "createArtifactTool",
|
|
1168
|
+
"declaration": {
|
|
1169
|
+
"name": "createArtifactTool",
|
|
1170
|
+
"module": "src/tool.ts"
|
|
1171
|
+
}
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
"kind": "js",
|
|
1175
|
+
"name": "artifactHandler",
|
|
1176
|
+
"declaration": {
|
|
1177
|
+
"name": "artifactHandler",
|
|
1178
|
+
"module": "src/tool.ts"
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
]
|
|
1182
|
+
}
|
|
1183
|
+
]
|
|
1184
|
+
}
|