@ai-gui/core 0.5.0 → 0.6.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/dist/index.cjs +13 -0
- package/dist/index.d.cts +29 -2
- package/dist/index.d.ts +29 -2
- package/dist/index.js +13 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -238,6 +238,18 @@ function sanitizeHtml(html, options = {}) {
|
|
|
238
238
|
}
|
|
239
239
|
return dompurify.default.sanitize(html);
|
|
240
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Sanitize one piece of rendered HTML, respecting a plugin's claim that it built the markup itself.
|
|
243
|
+
*
|
|
244
|
+
* Shared by every framework binding so the three of them cannot drift apart on what "sanitize"
|
|
245
|
+
* means — and so a diagram is not escaped into its own source text in one of them.
|
|
246
|
+
*/
|
|
247
|
+
function sanitizeRenderedHtml(html, sanitize, trusted = false) {
|
|
248
|
+
if (sanitize === false) return html;
|
|
249
|
+
const options = typeof sanitize === "object" ? sanitize : void 0;
|
|
250
|
+
if (trusted && options?.trustPlugins !== false) return html;
|
|
251
|
+
return sanitizeHtml(html, options);
|
|
252
|
+
}
|
|
241
253
|
|
|
242
254
|
//#endregion
|
|
243
255
|
//#region src/debug-events.ts
|
|
@@ -2645,5 +2657,6 @@ exports.readableBytes = readableBytes
|
|
|
2645
2657
|
exports.repairMarkdown = repairMarkdown
|
|
2646
2658
|
exports.safeDebugValue = safeDebugValue
|
|
2647
2659
|
exports.sanitizeHtml = sanitizeHtml
|
|
2660
|
+
exports.sanitizeRenderedHtml = sanitizeRenderedHtml
|
|
2648
2661
|
exports.textLines = textLines
|
|
2649
2662
|
exports.validateJSONSchema = validateJSONSchema
|
package/dist/index.d.cts
CHANGED
|
@@ -36,6 +36,12 @@ interface SanitizeHtmlOptions {
|
|
|
36
36
|
sanitizer?: (html: string) => string;
|
|
37
37
|
/** Bare SSR either escapes all markup (default) or fails explicitly. */
|
|
38
38
|
ssr?: "escape" | "throw";
|
|
39
|
+
/**
|
|
40
|
+
* Whether a plugin may declare its own markup safe, which it does by returning `trusted: true`.
|
|
41
|
+
* On by default: a plugin is code the host installed, and sanitizing the SVG it drew would
|
|
42
|
+
* escape it into text. Set to `false` to sanitize every output whatever its origin.
|
|
43
|
+
*/
|
|
44
|
+
trustPlugins?: boolean;
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
* Sanitize an HTML string, stripping scripts and unsafe attributes.
|
|
@@ -46,6 +52,15 @@ interface SanitizeHtmlOptions {
|
|
|
46
52
|
* markup and never throws.
|
|
47
53
|
*/
|
|
48
54
|
declare function sanitizeHtml(html: string, options?: SanitizeHtmlOptions): string;
|
|
55
|
+
/** What a renderer was told to do about sanitizing: nothing, the default, or these options. */
|
|
56
|
+
type SanitizeSetting = boolean | SanitizeHtmlOptions | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Sanitize one piece of rendered HTML, respecting a plugin's claim that it built the markup itself.
|
|
59
|
+
*
|
|
60
|
+
* Shared by every framework binding so the three of them cannot drift apart on what "sanitize"
|
|
61
|
+
* means — and so a diagram is not escaped into its own source text in one of them.
|
|
62
|
+
*/
|
|
63
|
+
declare function sanitizeRenderedHtml(html: string, sanitize: SanitizeSetting, trusted?: boolean): string;
|
|
49
64
|
|
|
50
65
|
//#endregion
|
|
51
66
|
//#region src/debug-events.d.ts
|
|
@@ -139,9 +154,21 @@ type Patch = {
|
|
|
139
154
|
key: string;
|
|
140
155
|
};
|
|
141
156
|
/** Framework-neutral render descriptor returned by plugin node renderers. */
|
|
142
|
-
type RenderOutput =
|
|
157
|
+
type RenderOutput =
|
|
158
|
+
/**
|
|
159
|
+
* `trusted` marks markup the plugin built itself rather than markup taken from the model.
|
|
160
|
+
*
|
|
161
|
+
* A plugin that renders a diagram returns SVG, and sanitizing SVG escapes it — the reader gets
|
|
162
|
+
* the source text instead of the picture. Hosts worked around that by matching the plugin's
|
|
163
|
+
* internal id prefix with a regular expression, which breaks the moment the plugin renames its
|
|
164
|
+
* ids and lets any model output wearing that prefix through unsanitized. A plugin is code the
|
|
165
|
+
* host chose to install, so it can say so itself; a host that disagrees sets
|
|
166
|
+
* `sanitize: { trustPlugins: false }`.
|
|
167
|
+
*/
|
|
168
|
+
{
|
|
143
169
|
kind: "html";
|
|
144
170
|
html: string;
|
|
171
|
+
trusted?: boolean;
|
|
145
172
|
} | {
|
|
146
173
|
kind: "element";
|
|
147
174
|
tag: string;
|
|
@@ -756,4 +783,4 @@ declare function mockModelStream(events: Iterable<ModelStreamEvent> | AsyncItera
|
|
|
756
783
|
declare function readableBytes(chunks: Iterable<string | Uint8Array> | AsyncIterable<string | Uint8Array>): ReadableStream<Uint8Array>;
|
|
757
784
|
|
|
758
785
|
//#endregion
|
|
759
|
-
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SourceBlock, StreamParseOptions, StreamRouter, Usage, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, textLines, validateJSONSchema };
|
|
786
|
+
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SanitizeSetting, SourceBlock, StreamParseOptions, StreamRouter, Usage, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ interface SanitizeHtmlOptions {
|
|
|
36
36
|
sanitizer?: (html: string) => string;
|
|
37
37
|
/** Bare SSR either escapes all markup (default) or fails explicitly. */
|
|
38
38
|
ssr?: "escape" | "throw";
|
|
39
|
+
/**
|
|
40
|
+
* Whether a plugin may declare its own markup safe, which it does by returning `trusted: true`.
|
|
41
|
+
* On by default: a plugin is code the host installed, and sanitizing the SVG it drew would
|
|
42
|
+
* escape it into text. Set to `false` to sanitize every output whatever its origin.
|
|
43
|
+
*/
|
|
44
|
+
trustPlugins?: boolean;
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
* Sanitize an HTML string, stripping scripts and unsafe attributes.
|
|
@@ -46,6 +52,15 @@ interface SanitizeHtmlOptions {
|
|
|
46
52
|
* markup and never throws.
|
|
47
53
|
*/
|
|
48
54
|
declare function sanitizeHtml(html: string, options?: SanitizeHtmlOptions): string;
|
|
55
|
+
/** What a renderer was told to do about sanitizing: nothing, the default, or these options. */
|
|
56
|
+
type SanitizeSetting = boolean | SanitizeHtmlOptions | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Sanitize one piece of rendered HTML, respecting a plugin's claim that it built the markup itself.
|
|
59
|
+
*
|
|
60
|
+
* Shared by every framework binding so the three of them cannot drift apart on what "sanitize"
|
|
61
|
+
* means — and so a diagram is not escaped into its own source text in one of them.
|
|
62
|
+
*/
|
|
63
|
+
declare function sanitizeRenderedHtml(html: string, sanitize: SanitizeSetting, trusted?: boolean): string;
|
|
49
64
|
|
|
50
65
|
//#endregion
|
|
51
66
|
//#region src/debug-events.d.ts
|
|
@@ -139,9 +154,21 @@ type Patch = {
|
|
|
139
154
|
key: string;
|
|
140
155
|
};
|
|
141
156
|
/** Framework-neutral render descriptor returned by plugin node renderers. */
|
|
142
|
-
type RenderOutput =
|
|
157
|
+
type RenderOutput =
|
|
158
|
+
/**
|
|
159
|
+
* `trusted` marks markup the plugin built itself rather than markup taken from the model.
|
|
160
|
+
*
|
|
161
|
+
* A plugin that renders a diagram returns SVG, and sanitizing SVG escapes it — the reader gets
|
|
162
|
+
* the source text instead of the picture. Hosts worked around that by matching the plugin's
|
|
163
|
+
* internal id prefix with a regular expression, which breaks the moment the plugin renames its
|
|
164
|
+
* ids and lets any model output wearing that prefix through unsanitized. A plugin is code the
|
|
165
|
+
* host chose to install, so it can say so itself; a host that disagrees sets
|
|
166
|
+
* `sanitize: { trustPlugins: false }`.
|
|
167
|
+
*/
|
|
168
|
+
{
|
|
143
169
|
kind: "html";
|
|
144
170
|
html: string;
|
|
171
|
+
trusted?: boolean;
|
|
145
172
|
} | {
|
|
146
173
|
kind: "element";
|
|
147
174
|
tag: string;
|
|
@@ -756,4 +783,4 @@ declare function mockModelStream(events: Iterable<ModelStreamEvent> | AsyncItera
|
|
|
756
783
|
declare function readableBytes(chunks: Iterable<string | Uint8Array> | AsyncIterable<string | Uint8Array>): ReadableStream<Uint8Array>;
|
|
757
784
|
|
|
758
785
|
//#endregion
|
|
759
|
-
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SourceBlock, StreamParseOptions, StreamRouter, Usage, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, textLines, validateJSONSchema };
|
|
786
|
+
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SanitizeSetting, SourceBlock, StreamParseOptions, StreamRouter, Usage, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
package/dist/index.js
CHANGED
|
@@ -214,6 +214,18 @@ function sanitizeHtml(html, options = {}) {
|
|
|
214
214
|
}
|
|
215
215
|
return DOMPurify.sanitize(html);
|
|
216
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Sanitize one piece of rendered HTML, respecting a plugin's claim that it built the markup itself.
|
|
219
|
+
*
|
|
220
|
+
* Shared by every framework binding so the three of them cannot drift apart on what "sanitize"
|
|
221
|
+
* means — and so a diagram is not escaped into its own source text in one of them.
|
|
222
|
+
*/
|
|
223
|
+
function sanitizeRenderedHtml(html, sanitize, trusted = false) {
|
|
224
|
+
if (sanitize === false) return html;
|
|
225
|
+
const options = typeof sanitize === "object" ? sanitize : void 0;
|
|
226
|
+
if (trusted && options?.trustPlugins !== false) return html;
|
|
227
|
+
return sanitizeHtml(html, options);
|
|
228
|
+
}
|
|
217
229
|
|
|
218
230
|
//#endregion
|
|
219
231
|
//#region src/debug-events.ts
|
|
@@ -2570,4 +2582,4 @@ function delay(ms, signal) {
|
|
|
2570
2582
|
}
|
|
2571
2583
|
|
|
2572
2584
|
//#endregion
|
|
2573
|
-
export { ActionAbortedError, ActionAlreadyRegisteredError, ActionDestroyedError, ActionExecutionError, ActionNotFoundError, ActionRegistry, ActionRuntime, ActionRuntimeError, ActionTimeoutError, ActionValidationError, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardJSONError, CardLimitError, CardNotFoundError, CardRegistry, CardRevisionConflictError, CardSnapshotError, CardStore, CardStoreError, CardTypeConflictError, CardValidationError, DebugEmitter, Renderer, StreamRouter, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, textLines, validateJSONSchema };
|
|
2585
|
+
export { ActionAbortedError, ActionAlreadyRegisteredError, ActionDestroyedError, ActionExecutionError, ActionNotFoundError, ActionRegistry, ActionRuntime, ActionRuntimeError, ActionTimeoutError, ActionValidationError, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardJSONError, CardLimitError, CardNotFoundError, CardRegistry, CardRevisionConflictError, CardSnapshotError, CardStore, CardStoreError, CardTypeConflictError, CardValidationError, DebugEmitter, Renderer, StreamRouter, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
package/package.json
CHANGED