@aintela/chat 0.12.0 → 0.12.1
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/components.js +2210 -2253
- package/dist/components.js.map +1 -1
- package/dist/src/components/LlmResponseRender/LiveJsxBlock.d.ts +8 -0
- package/dist/src/components/LlmResponseRender/LlmResponseRender.d.ts +10 -5
- package/dist/src/components/LlmResponseRender/noInPageEval.test.d.ts +1 -0
- package/dist/src/components/LlmResponseRender/parseBlocks.d.ts +19 -21
- package/package.json +1 -1
|
@@ -51,5 +51,13 @@ export declare class JsxErrorBoundary extends React.Component<{
|
|
|
51
51
|
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
52
52
|
render(): React.ReactNode;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Runs `code` with `new Function` in the window that mounts it, and renders the component it returns.
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ `code` is model-written. Mount this ONLY inside a sandboxed, opaque-origin frame (`<iframe sandbox="allow-scripts">`
|
|
58
|
+
* without `allow-same-origin`) — never in a page that holds a session, where the code could read the token and post it
|
|
59
|
+
* anywhere (AIA-Travel/AIA Issues 1604 and 1752). The obtapp does exactly that for `present_tsx`. Nothing in this
|
|
60
|
+
* library mounts it: assistant markdown renders code fences as code.
|
|
61
|
+
*/
|
|
54
62
|
declare const LiveJsxBlock: React.FC<LiveJsxBlockProps>;
|
|
55
63
|
export default LiveJsxBlock;
|
|
@@ -2,11 +2,11 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { Interaction } from '../../models/Interaction';
|
|
3
3
|
import { EventBusService } from '../../services/eventBusService';
|
|
4
4
|
interface LlmResponseRenderProps {
|
|
5
|
-
/** Full LLM response in markdown
|
|
5
|
+
/** Full LLM response in markdown. Code fences of any language render as code, never live. */
|
|
6
6
|
content: string;
|
|
7
7
|
sessionId: string;
|
|
8
8
|
partial: boolean;
|
|
9
|
-
/**
|
|
9
|
+
/** @deprecated Ignored: nothing in the message is evaluated, so there is no scope to extend. */
|
|
10
10
|
scope?: Record<string, unknown>;
|
|
11
11
|
eventBusService?: EventBusService;
|
|
12
12
|
onLinkClicked: (link: string, content: string | null) => void;
|
|
@@ -17,10 +17,15 @@ interface LlmResponseRenderProps {
|
|
|
17
17
|
friendlyMode?: boolean;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Renders an LLM markdown response
|
|
20
|
+
* Renders an LLM markdown response.
|
|
21
21
|
*
|
|
22
|
-
* Regular markdown
|
|
23
|
-
*
|
|
22
|
+
* Regular markdown, and every fenced code block → MarkdownExtended (sanitized, syntax-highlighted)
|
|
23
|
+
* `{{Component:<slotId>}}` lines → the matching UI tool part, placed here
|
|
24
|
+
*
|
|
25
|
+
* A ```tsx / ```jsx / ```livetsx fence is shown as CODE. Nothing in an assistant message is ever evaluated in this
|
|
26
|
+
* window: it is model output, and the host page holds the user's session (AIA-Travel/AIA Issue 1752). Model-written
|
|
27
|
+
* UI reaches the screen only as a UI tool, and a host that runs such code does so in a sandboxed frame of its own
|
|
28
|
+
* (`LiveJsxBlock` evaluates in whatever window mounts it — mount it only inside one).
|
|
24
29
|
*
|
|
25
30
|
* Usage:
|
|
26
31
|
* <LlmResponseRender content={llmResponse} sessionId={sessionId} />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
export type ContentBlock = {
|
|
2
|
+
/**
|
|
3
|
+
* `markdown` and `slot` are the only kinds emitted. `liveTsx` is kept in the union for source compatibility and
|
|
4
|
+
* is never produced: a ```tsx / ```jsx / ```livetsx fence is model output, and the chat renders it as CODE, never
|
|
5
|
+
* as a live component in the host page (AIA-Travel/AIA Issue 1752). A host that wants model-written UI renders it
|
|
6
|
+
* from a UI tool (`present_tsx`) in a sandboxed, opaque-origin frame of its own.
|
|
7
|
+
*/
|
|
2
8
|
type: 'liveTsx' | 'markdown' | 'slot';
|
|
3
9
|
content?: string;
|
|
10
|
+
/** @deprecated Only ever set on `liveTsx` blocks, which are no longer emitted. */
|
|
4
11
|
code?: string;
|
|
5
12
|
/** For `slot` blocks: the SlotId from a UI tool's result, matched to a
|
|
6
13
|
* `{{Component:<slotId>}}` token in the assistant text. */
|
|
7
14
|
slotId?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Per-block lifecycle state. False once a closed liveTsx fence has
|
|
10
|
-
* been parsed out of the chat text (the sidecar's build succeeded
|
|
11
|
-
* and the compiled JS is safe to mount). True for a "loading"
|
|
12
|
-
* marker without a paired closing fence, and for the trailing
|
|
13
|
-
* unclosed fence at the end of streaming text.
|
|
14
|
-
*/
|
|
15
|
+
/** @deprecated Only ever set on `liveTsx` blocks, which are no longer emitted. */
|
|
15
16
|
partial?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* 0..1 progress hint for partial liveTsx blocks. Derived from the
|
|
18
|
-
* count of <i data-lt-tick></i> markers the server emits into the
|
|
19
|
-
* chat text every `STRIDE` chars of TSX body received (see
|
|
20
|
-
* `LiveTsxProgressStride` in JsxLiveStreamProcessor.cs). Mapped to
|
|
21
|
-
* `MAX_CHARS_FOR_FULL` and clamped to 1. Consumed by
|
|
22
|
-
* `GeneratingVisualization` to fill the placeholder's bar buckets.
|
|
23
|
-
*/
|
|
17
|
+
/** @deprecated Only ever set on `liveTsx` blocks, which are no longer emitted. */
|
|
24
18
|
progress?: number;
|
|
19
|
+
/** @deprecated Only ever set on `liveTsx` blocks, which are no longer emitted. */
|
|
25
20
|
bytes?: number;
|
|
26
21
|
};
|
|
22
|
+
/** Kept for source compatibility with hosts that pass it to `parseContentBlocks`; nothing reads it any more. */
|
|
27
23
|
export declare const DEFAULT_MAX_CHARS_FOR_FULL = 2000;
|
|
28
24
|
/**
|
|
29
25
|
* Splits a markdown string into sequential content blocks:
|
|
30
|
-
* - 'markdown' — regular content
|
|
31
|
-
*
|
|
26
|
+
* - 'markdown' — regular content: prose, headings, and EVERY fenced code block, ```tsx / ```jsx / ```livetsx
|
|
27
|
+
* included (they render as highlighted code; see `ContentBlock.type`)
|
|
28
|
+
* - 'slot' — a `{{Component:<slotId>}}` line, where the matching UI tool part is placed
|
|
29
|
+
*
|
|
30
|
+
* A fence still streaming (no closing ``` yet) is left to remark, which runs an unclosed fence to the end of the
|
|
31
|
+
* text: the code typed so far shows as code, and nothing of it is evaluated.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
* the partial code is still emitted as a 'liveTsx' block so it goes through
|
|
35
|
-
* LiveJsxBlock (and skeleton detection) instead of the markdown renderer.
|
|
33
|
+
* `options` is accepted for source compatibility and ignored.
|
|
36
34
|
*/
|
|
37
|
-
export declare function parseContentBlocks(text: string,
|
|
35
|
+
export declare function parseContentBlocks(text: string, _options?: {
|
|
38
36
|
maxCharsForFull?: number;
|
|
39
37
|
}): ContentBlock[];
|