@seclai/react 0.0.17 → 0.0.19
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/README.md +149 -24
- package/dist/chunk-OFKVHNZ6.js +117 -0
- package/dist/chunk-VRNPDCWI.js +134 -0
- package/dist/extensions-D2MHwNt1.d.ts +49 -0
- package/dist/html.d.ts +22 -0
- package/dist/html.js +11 -0
- package/dist/index.d.ts +79 -29
- package/dist/index.js +773 -297
- package/dist/math.d.ts +22 -0
- package/dist/math.js +106 -0
- package/dist/mermaid.d.ts +30 -0
- package/dist/mermaid.js +126 -0
- package/dist/styles.css +274 -15
- package/package.json +46 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { M as MarkdownExtension } from './extensions-D2MHwNt1.js';
|
|
4
|
+
export { S as SeclaiMarkdownProvider, a as SeclaiMarkdownProviderProps } from './extensions-D2MHwNt1.js';
|
|
5
|
+
import 'react-markdown';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* The handlers' wire format, declared here rather than imported from
|
|
@@ -348,42 +351,56 @@ type MediaAspectRatio = number | string;
|
|
|
348
351
|
interface MediaPreviewProps {
|
|
349
352
|
attachment: AgentAttachment;
|
|
350
353
|
/**
|
|
351
|
-
* The image frame's aspect ratio. Without it the frame takes the
|
|
352
|
-
* ratio once it loads, and `--seclai-media-aspect-ratio` (square
|
|
353
|
-
* until then.
|
|
354
|
+
* The image or video frame's aspect ratio. Without it the frame takes the
|
|
355
|
+
* file's own ratio once it loads, and `--seclai-media-aspect-ratio` (square
|
|
356
|
+
* by default) until then. Audio and PDF cards don't use it.
|
|
354
357
|
*/
|
|
355
358
|
aspectRatio?: MediaAspectRatio;
|
|
356
|
-
/** A badge on the
|
|
359
|
+
/** A badge on the card, matching the agent's numbered list ("1.", "2."). */
|
|
357
360
|
number?: number;
|
|
358
361
|
/** App-specific buttons, shown after the download link. A function gets the attachment. */
|
|
359
362
|
actions?: ReactNode | ((attachment: AgentAttachment) => ReactNode);
|
|
360
|
-
/** Makes
|
|
363
|
+
/** Makes an image a button, for opening a full-size viewer. Other files ignore it. */
|
|
361
364
|
onOpen?(): void;
|
|
362
365
|
}
|
|
363
366
|
/**
|
|
364
|
-
* Shows a file from a run
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
+
* Shows a file from a run, by its mime type (ignoring case and parameters):
|
|
368
|
+
*
|
|
369
|
+
* - an image in a fixed-ratio frame, which can open a full-size viewer;
|
|
370
|
+
* - audio with the browser's own controls;
|
|
371
|
+
* - video with the browser's own controls, in a frame like an image's;
|
|
372
|
+
* - a PDF in the browser's PDF viewer, or a download link where there isn't one;
|
|
373
|
+
* - anything else as a download link.
|
|
374
|
+
*
|
|
375
|
+
* Every card has a download link, an optional number badge and an `actions`
|
|
376
|
+
* slot. A file that fails to load says so, and keeps its download link.
|
|
367
377
|
*/
|
|
368
378
|
declare function MediaPreview({ attachment, aspectRatio, number, actions, onOpen }: MediaPreviewProps): react.JSX.Element;
|
|
369
379
|
|
|
370
380
|
interface MediaGalleryProps {
|
|
371
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* A run's attachments. Images, audio, video and PDFs become cards, numbered in
|
|
383
|
+
* this order; other files follow as download links.
|
|
384
|
+
*/
|
|
372
385
|
attachments: AgentAttachment[];
|
|
373
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* Every image and video card's aspect ratio. Without it each takes its file's
|
|
388
|
+
* own ratio. Audio and PDF cards keep their own shape.
|
|
389
|
+
*/
|
|
374
390
|
aspectRatio?: MediaAspectRatio;
|
|
375
391
|
/**
|
|
376
|
-
* Skeleton cards to show after the
|
|
377
|
-
* They're numbered on from the last
|
|
392
|
+
* Skeleton cards to show after the cards, for images still being generated.
|
|
393
|
+
* They're numbered on from the last card.
|
|
378
394
|
*/
|
|
379
395
|
pending?: number;
|
|
380
396
|
/** App-specific buttons for each card. Gets the attachment and its 1-based number. */
|
|
381
397
|
actions?(attachment: AgentAttachment, number: number): ReactNode;
|
|
382
398
|
}
|
|
383
399
|
/**
|
|
384
|
-
* Lays out a run's images
|
|
385
|
-
*
|
|
386
|
-
*
|
|
400
|
+
* Lays out a run's images, audio, video and PDFs as numbered cards, in the
|
|
401
|
+
* attachments' order, so the numbers match the agent's numbered list. Images
|
|
402
|
+
* open a full-size viewer. "Download all" saves every card's file when there's
|
|
403
|
+
* more than one. Other files follow the cards as download links.
|
|
387
404
|
*/
|
|
388
405
|
declare function MediaGallery({ attachments, aspectRatio, pending, actions, }: MediaGalleryProps): react.JSX.Element;
|
|
389
406
|
|
|
@@ -403,8 +420,14 @@ interface MediaSkeletonProps {
|
|
|
403
420
|
declare function MediaSkeleton({ aspectRatio, number, label }: MediaSkeletonProps): react.JSX.Element;
|
|
404
421
|
|
|
405
422
|
interface MediaViewerProps {
|
|
406
|
-
/** The images to page through, in order. Image `i` is numbered `i + 1
|
|
423
|
+
/** The images to page through, in order. Image `i` is numbered `i + 1`, unless `numbers` says otherwise. */
|
|
407
424
|
attachments: AgentAttachment[];
|
|
425
|
+
/**
|
|
426
|
+
* Each image's number, as on its card, for its name and filename. A gallery
|
|
427
|
+
* with audio, video or PDF cards between its images passes these, so image 3
|
|
428
|
+
* isn't called "Image 2" because it's the second image.
|
|
429
|
+
*/
|
|
430
|
+
numbers?: readonly number[];
|
|
408
431
|
/** The image showing, or `null` when the viewer is closed. */
|
|
409
432
|
index: number | null;
|
|
410
433
|
/** Called with the new index when the user goes to the previous or next image. */
|
|
@@ -418,11 +441,12 @@ interface MediaViewerProps {
|
|
|
418
441
|
* show, and `null` to close it. Focus moves into the viewer when it opens and
|
|
419
442
|
* back to where it was when it closes.
|
|
420
443
|
*/
|
|
421
|
-
declare function MediaViewer({ attachments, index, onIndexChange, onClose }: MediaViewerProps): react.JSX.Element;
|
|
444
|
+
declare function MediaViewer({ attachments, numbers, index, onIndexChange, onClose }: MediaViewerProps): react.JSX.Element;
|
|
422
445
|
|
|
423
446
|
/**
|
|
424
|
-
* The filename to save an attachment as: its own name, or else
|
|
425
|
-
* (
|
|
447
|
+
* The filename to save an attachment as: its own name, or else its kind and
|
|
448
|
+
* number (`image-2`, `audio-3`, `video-1`, `pdf-4`, or `file-5` for anything
|
|
449
|
+
* else), or its id without a number, with an extension from its mime type.
|
|
426
450
|
*/
|
|
427
451
|
declare function attachmentFileName(attachment: AgentAttachment, number?: number): string;
|
|
428
452
|
/**
|
|
@@ -457,18 +481,44 @@ interface SaveFilesOptions {
|
|
|
457
481
|
declare function saveFiles(files: readonly SaveFilesEntry[], { delayMs, signal }?: SaveFilesOptions): Promise<void>;
|
|
458
482
|
|
|
459
483
|
interface MarkdownContentProps {
|
|
484
|
+
/** The Markdown to show. */
|
|
460
485
|
content: string;
|
|
486
|
+
/**
|
|
487
|
+
* The text is still streaming in. An unfinished last line that could still
|
|
488
|
+
* become something else, such as a bare `-` or `2.`, is held back until more
|
|
489
|
+
* arrives. Leave it off for finished text.
|
|
490
|
+
*/
|
|
491
|
+
streaming?: boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Extensions, such as `math()` and `mermaid()`. When set, they replace the
|
|
494
|
+
* ones from `SeclaiMarkdownProvider`.
|
|
495
|
+
*/
|
|
496
|
+
extensions?: readonly MarkdownExtension[];
|
|
461
497
|
}
|
|
462
498
|
/**
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
499
|
+
* Renders Markdown, such as an agent's reply, including while it streams in.
|
|
500
|
+
* `AgentRunForm` and `AgentChat` use it for the agent's output and the user's
|
|
501
|
+
* messages.
|
|
502
|
+
*
|
|
503
|
+
* It renders GitHub Flavored Markdown: headings, emphasis, links (and bare
|
|
504
|
+
* URLs), inline code and code blocks, block quotes, lists (nested, and with
|
|
505
|
+
* block content in items), tables, task lists, strikethrough, footnotes and
|
|
506
|
+
* rules. Numbered items keep the number the agent wrote, shown in a badge that
|
|
507
|
+
* matches `MediaPreview`'s. A single newline is a line break, `<br>` is one
|
|
508
|
+
* too, and `•` works as a bullet.
|
|
509
|
+
*
|
|
510
|
+
* Agent output is untrusted: links are limited to http, https, mailto and
|
|
511
|
+
* relative URLs, and external ones open in a new tab; images show as links
|
|
512
|
+
* rather than loading; other HTML shows as text.
|
|
513
|
+
*
|
|
514
|
+
* HTML (sanitized), maths and Mermaid diagrams are opt-in extensions:
|
|
515
|
+
* `html()`, `math()` and `mermaid()` from `@seclai/react/html`,
|
|
516
|
+
* `@seclai/react/math` and `@seclai/react/mermaid`. Pass them in `extensions`,
|
|
517
|
+
* or to every `MarkdownContent` at once with `SeclaiMarkdownProvider`.
|
|
518
|
+
*
|
|
519
|
+
* While the text streams in, it's split into blocks and only the last one is
|
|
520
|
+
* parsed again as tokens arrive. Pass `streaming` until it's complete.
|
|
471
521
|
*/
|
|
472
|
-
declare
|
|
522
|
+
declare const MarkdownContent: react.NamedExoticComponent<MarkdownContentProps>;
|
|
473
523
|
|
|
474
|
-
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatAttachment, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentChatTurn, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, RunProgress, type RunProgressProps, type RunProgressRun, type SaveFilesEntry, type SaveFilesOptions, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadFileOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, saveFile, saveFiles, uploadFile, useAgentRun, useElapsed };
|
|
524
|
+
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatAttachment, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentChatTurn, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, MarkdownExtension, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, RunProgress, type RunProgressProps, type RunProgressRun, type SaveFilesEntry, type SaveFilesOptions, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadFileOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, saveFile, saveFiles, uploadFile, useAgentRun, useElapsed };
|