@usetheo/ui 0.26.0 → 0.27.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/components/composites/annotation-summary-group/annotation-summary-group.d.ts +28 -0
- package/dist/components/composites/annotation-summary-group/index.d.ts +1 -0
- package/dist/components/composites/chat-message-card/chat-message-card.d.ts +14 -0
- package/dist/components/composites/chat-message-card/index.d.ts +1 -0
- package/dist/components/composites/comment-thread/comment-thread.d.ts +24 -0
- package/dist/components/composites/comment-thread/index.d.ts +2 -0
- package/dist/components/composites/dataset-item-diff/dataset-item-diff.d.ts +19 -0
- package/dist/components/composites/dataset-item-diff/index.d.ts +4 -0
- package/dist/components/composites/dataset-item-diff/to-diff-text.d.ts +22 -0
- package/dist/components/composites/diff-view/diff-section.d.ts +19 -0
- package/dist/components/composites/diff-view/diff-view.d.ts +39 -0
- package/dist/components/composites/diff-view/index.d.ts +2 -0
- package/dist/components/composites/evaluator-form/evaluator-form.d.ts +25 -0
- package/dist/components/composites/evaluator-form/index.d.ts +3 -0
- package/dist/components/composites/evaluator-form/types.d.ts +41 -0
- package/dist/components/composites/message-branch-selector/index.d.ts +1 -0
- package/dist/components/composites/message-branch-selector/message-branch-selector.d.ts +27 -0
- package/dist/components/composites/price-breakdown/index.d.ts +2 -0
- package/dist/components/composites/price-breakdown/price-breakdown.d.ts +21 -0
- package/dist/components/composites/prompt-template-editor/extract-vars.d.ts +1 -0
- package/dist/components/composites/prompt-template-editor/index.d.ts +2 -0
- package/dist/components/composites/prompt-template-editor/prompt-template-editor.d.ts +24 -0
- package/dist/components/composites/prompt-version-diff/index.d.ts +4 -0
- package/dist/components/composites/prompt-version-diff/prompt-version-diff.d.ts +20 -0
- package/dist/components/composites/prompt-version-diff/to-diff-text.d.ts +26 -0
- package/dist/components/composites/severity-badge/index.d.ts +2 -0
- package/dist/components/composites/severity-badge/severity-badge.d.ts +33 -0
- package/dist/components/composites/tag-input/index.d.ts +2 -0
- package/dist/components/composites/tag-input/tag-input.d.ts +32 -0
- package/dist/components/composites/token-cost-breakdown/index.d.ts +2 -0
- package/dist/components/composites/token-cost-breakdown/token-cost-breakdown.d.ts +26 -0
- package/dist/index.d.ts +32 -9
- package/dist/index.js +920 -1
- package/dist/lib/diff/diff-lines.d.ts +23 -0
- package/dist/lib/diff/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AnnotationConfig } from "../annotation-input/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* AnnotationSummaryGroup — a collapsible group showing AGGREGATE stats over a
|
|
4
|
+
* list of annotation values for one `AnnotationConfig` (M18). Reuses the M12
|
|
5
|
+
* `AnnotationConfig` contract (DRY, ADR D2) and dispatches on `config.type`:
|
|
6
|
+
* - continuous → mean of the finite numeric values + count.
|
|
7
|
+
* - categorical → count per option label + total count.
|
|
8
|
+
* - freeform → count of non-empty values.
|
|
9
|
+
*
|
|
10
|
+
* Controlled and pure — the consumer owns `values` (fixture or backend store);
|
|
11
|
+
* this component only summarizes. Uses a native `<details>`/`<summary>` for
|
|
12
|
+
* zero-JS collapsibility; composes `Card`/`Badge`. Zero new dependency.
|
|
13
|
+
*
|
|
14
|
+
* <AnnotationSummaryGroup config={cfg} values={vals} label="Quality" />
|
|
15
|
+
*/
|
|
16
|
+
export interface AnnotationSummaryGroupProps {
|
|
17
|
+
/** The annotation config the values were collected against (reused from M12). */
|
|
18
|
+
config: AnnotationConfig;
|
|
19
|
+
/** The collected annotation values to aggregate. */
|
|
20
|
+
values: (string | number)[];
|
|
21
|
+
/** Group heading; falls back to the config type when omitted. */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Whether the group starts expanded. */
|
|
24
|
+
defaultOpen?: boolean;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
declare const AnnotationSummaryGroup: import("react").ForwardRefExoticComponent<AnnotationSummaryGroupProps & import("react").RefAttributes<HTMLDetailsElement>>;
|
|
28
|
+
export { AnnotationSummaryGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AnnotationSummaryGroup, type AnnotationSummaryGroupProps, } from "./annotation-summary-group.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
import type { ToolCall } from "../../../lib/trace/types.js";
|
|
3
|
+
export interface ChatMessageCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** ChatML role — user / assistant / tool / system (or any string). */
|
|
5
|
+
role: string;
|
|
6
|
+
/** Text body of the message. */
|
|
7
|
+
content?: string;
|
|
8
|
+
/** Structured tool calls attached to the message (assistant turns). */
|
|
9
|
+
toolCalls?: ToolCall[];
|
|
10
|
+
/** Structured tool results (tool turns). Serialized to JSON for display. */
|
|
11
|
+
toolResults?: unknown[];
|
|
12
|
+
}
|
|
13
|
+
declare const ChatMessageCard: import("react").ForwardRefExoticComponent<ChatMessageCardProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export { ChatMessageCard };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChatMessageCard, type ChatMessageCardProps } from "./chat-message-card.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single comment in a {@link CommentThread}. The `id` keys the list; the
|
|
3
|
+
* consumer owns id assignment (backend or fixture).
|
|
4
|
+
*/
|
|
5
|
+
export interface Comment {
|
|
6
|
+
id: string;
|
|
7
|
+
author: string;
|
|
8
|
+
body: string;
|
|
9
|
+
/** ISO string OR Unix **ms** (Timestamp contract) — NOT seconds. */
|
|
10
|
+
createdAt: string | number;
|
|
11
|
+
avatarUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CommentThreadProps {
|
|
14
|
+
/** The rendered thread (controlled — the consumer brings/persists it). */
|
|
15
|
+
comments: Comment[];
|
|
16
|
+
/** Called with the trimmed draft when the composer submits a non-empty body. */
|
|
17
|
+
onSubmit: (body: string) => void;
|
|
18
|
+
/** Name of the person composing — surfaced as the composer avatar/context. */
|
|
19
|
+
currentUser?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
declare const CommentThread: import("react").ForwardRefExoticComponent<CommentThreadProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
24
|
+
export { CommentThread };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
import { type DiffSectionCommon } from "../diff-view/diff-section.js";
|
|
3
|
+
import { type DatasetItemSnapshot } from "./to-diff-text.js";
|
|
4
|
+
/**
|
|
5
|
+
* DatasetItemDiff — diffs two dataset-item versions (M14 ADR D3). Stringifies
|
|
6
|
+
* each field (input / expectedOutput / metadata) and composes a labeled
|
|
7
|
+
* `DiffView` per field. Zero new dependency — reuses the DS diff primitive.
|
|
8
|
+
*
|
|
9
|
+
* A field absent in BOTH items is omitted honestly (no empty "No changes"
|
|
10
|
+
* table); a field present on either side is rendered so an add/remove shows.
|
|
11
|
+
*
|
|
12
|
+
* <DatasetItemDiff oldItem={v1} newItem={v2} />
|
|
13
|
+
*/
|
|
14
|
+
export type DatasetItemDiffProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & DiffSectionCommon & {
|
|
15
|
+
oldItem: DatasetItemSnapshot;
|
|
16
|
+
newItem: DatasetItemSnapshot;
|
|
17
|
+
};
|
|
18
|
+
declare function DatasetItemDiff(props: DatasetItemDiffProps): import("react").JSX.Element;
|
|
19
|
+
export { DatasetItemDiff };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure normalizers for dataset-item snapshots (M14 ADR D3). Turns each field
|
|
3
|
+
* (input / expectedOutput / metadata), whose value is `unknown`, into the plain
|
|
4
|
+
* text a `DiffView` diffs. No React, no I/O; total and deterministic.
|
|
5
|
+
*/
|
|
6
|
+
/** A dataset item version. Fields are optional so absent ones can be omitted. */
|
|
7
|
+
export interface DatasetItemSnapshot {
|
|
8
|
+
input: unknown;
|
|
9
|
+
expectedOutput?: unknown;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Stringify a field value for diffing: a string passes through unchanged;
|
|
14
|
+
* `undefined`/`null` become ""; anything else is pretty-printed JSON. Keeping
|
|
15
|
+
* strings raw avoids wrapping user text in quotes/escapes in the diff.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fieldToText(value: unknown): string;
|
|
18
|
+
/**
|
|
19
|
+
* True when a field is present on either side — the caller renders a section
|
|
20
|
+
* only for present fields, omitting one absent in BOTH items honestly.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fieldPresent(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type DiffViewMode } from "./diff-view.js";
|
|
2
|
+
/**
|
|
3
|
+
* DiffSection — a labeled `DiffView` (a heading + the diff table). Shared by the
|
|
4
|
+
* domain composites (PromptVersionDiff, DatasetItemDiff) so each labeled diff is
|
|
5
|
+
* a single call instead of a repeated heading+DiffView block (DRY).
|
|
6
|
+
*/
|
|
7
|
+
/** The DiffView pass-through props the composites forward to every section. */
|
|
8
|
+
export interface DiffSectionCommon {
|
|
9
|
+
/** Layout mode, forwarded to DiffView. */
|
|
10
|
+
mode?: DiffViewMode;
|
|
11
|
+
oldLabel?: string;
|
|
12
|
+
newLabel?: string;
|
|
13
|
+
}
|
|
14
|
+
export type DiffSectionProps = DiffSectionCommon & {
|
|
15
|
+
title: string;
|
|
16
|
+
oldText: string;
|
|
17
|
+
newText: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function DiffSection({ title, oldText, newText, ...rest }: DiffSectionProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* DiffView — a controlled, line-level text diff rendered as a semantic table
|
|
4
|
+
* (M14 ADR D2). Runs the pure `diffLines` LCS over `oldText`/`newText`; zero
|
|
5
|
+
* new dependency (registry stays copy-pasteable — M14 ADR D1).
|
|
6
|
+
*
|
|
7
|
+
* `mode="split"` (default) shows two columns — old on the left, new on the
|
|
8
|
+
* right, aligning `del` rows on the left and `add` rows on the right; `eq` on
|
|
9
|
+
* both. `mode="unified"` shows a single inline column with `+`/`-` prefixes.
|
|
10
|
+
*
|
|
11
|
+
* A11y is not color-alone: every changed row carries a TEXTUAL marker
|
|
12
|
+
* (`+`/`-`/` `) plus `data-diff`, and the whole thing is a `<table>` with an
|
|
13
|
+
* sr-only `<caption>` so screen readers announce a data table. Identical input
|
|
14
|
+
* reads as an honest "No changes" state, never an empty table.
|
|
15
|
+
*
|
|
16
|
+
* <DiffView oldText={v1} newText={v2} oldLabel="v1" newLabel="v2" />
|
|
17
|
+
*/
|
|
18
|
+
export type DiffViewMode = "split" | "unified";
|
|
19
|
+
export type DiffViewProps = Omit<HTMLAttributes<HTMLTableElement>, "children"> & {
|
|
20
|
+
oldText: string;
|
|
21
|
+
newText: string;
|
|
22
|
+
/** Layout: two-column split (default) or inline unified. */
|
|
23
|
+
mode?: DiffViewMode;
|
|
24
|
+
/** Column header for the old text (split) / caption context. */
|
|
25
|
+
oldLabel?: string;
|
|
26
|
+
/** Column header for the new text (split) / caption context. */
|
|
27
|
+
newLabel?: string;
|
|
28
|
+
};
|
|
29
|
+
declare const DiffView: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLTableElement>, "children"> & {
|
|
30
|
+
oldText: string;
|
|
31
|
+
newText: string;
|
|
32
|
+
/** Layout: two-column split (default) or inline unified. */
|
|
33
|
+
mode?: DiffViewMode;
|
|
34
|
+
/** Column header for the old text (split) / caption context. */
|
|
35
|
+
oldLabel?: string;
|
|
36
|
+
/** Column header for the new text (split) / caption context. */
|
|
37
|
+
newLabel?: string;
|
|
38
|
+
} & import("react").RefAttributes<HTMLTableElement>>;
|
|
39
|
+
export { DiffView };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type EvaluatorConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* EvaluatorForm — a controlled, config-driven builder for a built-in evaluator
|
|
4
|
+
* (M18). Dispatches on `value.type` (Phoenix's code-evaluator model): a
|
|
5
|
+
* `<select>` switches the evaluator type; the fields below it edit the config
|
|
6
|
+
* for the current type — exact_match/contains → a target string; regex →
|
|
7
|
+
* pattern + optional flags; levenshtein/json_distance → a numeric threshold.
|
|
8
|
+
* Switching type emits a FRESH config of that type with sensible defaults.
|
|
9
|
+
*
|
|
10
|
+
* Fully controlled (`value` + `onChange`); the consumer owns the config and its
|
|
11
|
+
* persistence. The form only EDITS — execution/sandboxing of the evaluator is a
|
|
12
|
+
* platform concern (ADR D3). Composes DS primitives; zero new dependency.
|
|
13
|
+
*
|
|
14
|
+
* <EvaluatorForm value={cfg} onChange={setCfg} />
|
|
15
|
+
*/
|
|
16
|
+
export interface EvaluatorFormProps {
|
|
17
|
+
/** The evaluator config being edited (discriminated by `type`). */
|
|
18
|
+
value: EvaluatorConfig;
|
|
19
|
+
/** Emitted with the new config on any edit — always fully typed. */
|
|
20
|
+
onChange: (value: EvaluatorConfig) => void;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const EvaluatorForm: import("react").ForwardRefExoticComponent<EvaluatorFormProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
|
+
export { EvaluatorForm };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { EvaluatorForm, type EvaluatorFormProps } from "./evaluator-form.js";
|
|
2
|
+
export type { EvaluatorConfig, EvaluatorType, ExactMatchEvaluatorConfig, ContainsEvaluatorConfig, RegexEvaluatorConfig, LevenshteinEvaluatorConfig, JsonDistanceEvaluatorConfig, } from "./types.js";
|
|
3
|
+
export { defaultEvaluatorConfig, isTargetEvaluator, isRegexEvaluator, isThresholdEvaluator, } from "./types.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluator config types — the discriminated-union contract for EvaluatorForm
|
|
3
|
+
* (M18). Follows Phoenix's built-in code-evaluator model: each evaluator has a
|
|
4
|
+
* `type` discriminant plus the fields that type needs. The config is a plain
|
|
5
|
+
* descriptor the consumer owns (fixture or backend store) — EvaluatorForm only
|
|
6
|
+
* EDITS it; execution/sandboxing of the evaluator is a platform concern (ADR
|
|
7
|
+
* D3). Same union + Extract narrowing pattern as AnnotationInput (M12), which
|
|
8
|
+
* side-steps the TS#30581 correlated-union limitation.
|
|
9
|
+
*/
|
|
10
|
+
/** A string-target evaluator: the produced output is matched against `target`. */
|
|
11
|
+
export interface ExactMatchEvaluatorConfig {
|
|
12
|
+
type: "exact_match";
|
|
13
|
+
target: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ContainsEvaluatorConfig {
|
|
16
|
+
type: "contains";
|
|
17
|
+
target: string;
|
|
18
|
+
}
|
|
19
|
+
/** A regex evaluator: `pattern` is the source, `flags` the optional RegExp flags. */
|
|
20
|
+
export interface RegexEvaluatorConfig {
|
|
21
|
+
type: "regex";
|
|
22
|
+
pattern: string;
|
|
23
|
+
flags?: string;
|
|
24
|
+
}
|
|
25
|
+
/** A Levenshtein-distance evaluator: passes when distance ≤ `threshold`. */
|
|
26
|
+
export interface LevenshteinEvaluatorConfig {
|
|
27
|
+
type: "levenshtein";
|
|
28
|
+
threshold: number;
|
|
29
|
+
}
|
|
30
|
+
/** A JSON-structural-distance evaluator: passes when distance ≤ `threshold`. */
|
|
31
|
+
export interface JsonDistanceEvaluatorConfig {
|
|
32
|
+
type: "json_distance";
|
|
33
|
+
threshold: number;
|
|
34
|
+
}
|
|
35
|
+
export type EvaluatorType = EvaluatorConfig["type"];
|
|
36
|
+
export type EvaluatorConfig = ExactMatchEvaluatorConfig | ContainsEvaluatorConfig | RegexEvaluatorConfig | LevenshteinEvaluatorConfig | JsonDistanceEvaluatorConfig;
|
|
37
|
+
export declare function isTargetEvaluator(c: EvaluatorConfig): c is ExactMatchEvaluatorConfig | ContainsEvaluatorConfig;
|
|
38
|
+
export declare function isRegexEvaluator(c: EvaluatorConfig): c is RegexEvaluatorConfig;
|
|
39
|
+
export declare function isThresholdEvaluator(c: EvaluatorConfig): c is LevenshteinEvaluatorConfig | JsonDistanceEvaluatorConfig;
|
|
40
|
+
/** A fresh config of `type` with sensible defaults — emitted on a type switch. */
|
|
41
|
+
export declare function defaultEvaluatorConfig(type: EvaluatorType): EvaluatorConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MessageBranchSelector, type MessageBranchSelectorProps, } from "./message-branch-selector.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* MessageBranchSelector — controlled navigator across alternative message
|
|
4
|
+
* branches (e.g. regenerated responses): "‹ 2 / 5 ›" with prev/next buttons.
|
|
5
|
+
*
|
|
6
|
+
* Fully controlled (M19 ADR D3): the consumer owns `index` and reacts to
|
|
7
|
+
* `onPrev` / `onNext`; regenerate / streaming is a platform concern, not the DS.
|
|
8
|
+
* Prev is disabled at the first branch, next at the last. With a single branch
|
|
9
|
+
* (`count <= 1`) there is nothing to navigate, so it renders nothing.
|
|
10
|
+
*
|
|
11
|
+
* <MessageBranchSelector index={i} count={branches.length}
|
|
12
|
+
* onPrev={() => setI(i - 1)} onNext={() => setI(i + 1)} />
|
|
13
|
+
*/
|
|
14
|
+
export interface MessageBranchSelectorProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
15
|
+
/** Zero-based index of the active branch. */
|
|
16
|
+
index: number;
|
|
17
|
+
/** Total number of branches. */
|
|
18
|
+
count: number;
|
|
19
|
+
/** Navigate to the previous branch. */
|
|
20
|
+
onPrev: () => void;
|
|
21
|
+
/** Navigate to the next branch. */
|
|
22
|
+
onNext: () => void;
|
|
23
|
+
/** Disable both controls (e.g. while a branch is loading). */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
declare const MessageBranchSelector: import("react").ForwardRefExoticComponent<MessageBranchSelectorProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
export { MessageBranchSelector };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* PriceBreakdown — a `<table>` of unit prices scaled to per-unit, per-1K, and
|
|
4
|
+
* per-1M columns. Controlled and pure — the consumer supplies a `prices` map of
|
|
5
|
+
* usage-type label → price per unit; each scale is a plain multiplication
|
|
6
|
+
* (`price`, `price × 1000`, `price × 1_000_000`).
|
|
7
|
+
*
|
|
8
|
+
* An empty `prices` map renders an honest empty state, not an empty table. A
|
|
9
|
+
* visually-hidden caption gives screen readers the table's purpose.
|
|
10
|
+
*
|
|
11
|
+
* <PriceBreakdown prices={{ input: 0.000003, output: 0.000015 }} unit="token" />
|
|
12
|
+
*/
|
|
13
|
+
export interface PriceBreakdownProps extends HTMLAttributes<HTMLTableElement> {
|
|
14
|
+
/** Usage-type label → price per unit. */
|
|
15
|
+
prices: Record<string, number>;
|
|
16
|
+
/** The unit each price is quoted per. Default `"token"`. */
|
|
17
|
+
unit?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
declare const PriceBreakdown: import("react").ForwardRefExoticComponent<PriceBreakdownProps & import("react").RefAttributes<HTMLTableElement>>;
|
|
21
|
+
export { PriceBreakdown };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractVars(template: string): string[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* PromptTemplateEditor — a controlled template editor: a `Textarea` plus a
|
|
4
|
+
* simple hint area listing available variables and which are used vs missing.
|
|
5
|
+
*
|
|
6
|
+
* The hint is a lightweight overlay over the plain textarea (M19 ADR D1 —
|
|
7
|
+
* parsimony rung 5): variable detection uses the pure `extractVars` helper;
|
|
8
|
+
* NO CodeMirror / editor library. "Used" = the variable appears in the current
|
|
9
|
+
* value; "missing" = it is used in the value but not declared in `variables`.
|
|
10
|
+
*
|
|
11
|
+
* <PromptTemplateEditor value={t} onChange={setT} variables={["name","city"]} />
|
|
12
|
+
*/
|
|
13
|
+
export interface PromptTemplateEditorProps extends Omit<HTMLAttributes<HTMLTextAreaElement>, "onChange"> {
|
|
14
|
+
/** The template text. */
|
|
15
|
+
value: string;
|
|
16
|
+
/** Emits the new template text on each edit. */
|
|
17
|
+
onChange: (value: string) => void;
|
|
18
|
+
/** Variables the caller declares available to this template. */
|
|
19
|
+
variables?: string[];
|
|
20
|
+
/** Disable editing. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const PromptTemplateEditor: import("react").ForwardRefExoticComponent<PromptTemplateEditorProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
24
|
+
export { PromptTemplateEditor };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { PromptVersionDiff } from "./prompt-version-diff.js";
|
|
2
|
+
export type { PromptVersionDiffProps } from "./prompt-version-diff.js";
|
|
3
|
+
export type { PromptSnapshot, ChatMessage } from "./to-diff-text.js";
|
|
4
|
+
export { templateToText, configToText } from "./to-diff-text.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
import { type DiffSectionCommon } from "../diff-view/diff-section.js";
|
|
3
|
+
import { type PromptSnapshot } from "./to-diff-text.js";
|
|
4
|
+
/**
|
|
5
|
+
* PromptVersionDiff — diffs two prompt versions (M14 ADR D3). Normalizes each
|
|
6
|
+
* snapshot's template (string passthrough; chat array → `role: content` text)
|
|
7
|
+
* and config (pretty JSON) to plain text, then composes `DiffView` for content
|
|
8
|
+
* and, when present, config. Zero new dependency — reuses the DS diff primitive.
|
|
9
|
+
*
|
|
10
|
+
* The config diff is omitted honestly when both versions have no config, rather
|
|
11
|
+
* than rendering an empty "No changes" table nobody asked for.
|
|
12
|
+
*
|
|
13
|
+
* <PromptVersionDiff oldPrompt={v1} newPrompt={v2} />
|
|
14
|
+
*/
|
|
15
|
+
export type PromptVersionDiffProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & DiffSectionCommon & {
|
|
16
|
+
oldPrompt: PromptSnapshot;
|
|
17
|
+
newPrompt: PromptSnapshot;
|
|
18
|
+
};
|
|
19
|
+
declare function PromptVersionDiff(props: PromptVersionDiffProps): import("react").JSX.Element;
|
|
20
|
+
export { PromptVersionDiff };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure normalizers that turn a prompt snapshot's domain shape into the plain
|
|
3
|
+
* text `DiffView` diffs (M14 ADR D3 — composites normalize, DiffView diffs).
|
|
4
|
+
* No React, no I/O; total and deterministic.
|
|
5
|
+
*/
|
|
6
|
+
/** A single chat message in an array-shaped (ChatML-style) template. */
|
|
7
|
+
export interface ChatMessage {
|
|
8
|
+
role: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
/** A prompt version: either a raw string template or a chat-message array. */
|
|
12
|
+
export interface PromptSnapshot {
|
|
13
|
+
template: string | ChatMessage[];
|
|
14
|
+
config?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Normalize a template to readable text. A string passes through unchanged; a
|
|
18
|
+
* chat array becomes one `role: content` line per message (blank line between
|
|
19
|
+
* messages so multi-line contents stay legible in the diff).
|
|
20
|
+
*/
|
|
21
|
+
export declare function templateToText(template: string | ChatMessage[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* Pretty-print a config object to JSON. Absent/empty → "" (the caller omits the
|
|
24
|
+
* config diff entirely when both sides are empty).
|
|
25
|
+
*/
|
|
26
|
+
export declare function configToText(config?: Record<string, unknown>): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
import { type BadgeProps } from "../../primitives/badge/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* SeverityBadge — labeled, multi-level severity indicator (composite).
|
|
5
|
+
*
|
|
6
|
+
* Composes the `Badge` primitive: maps a `Severity` level (langfuse's
|
|
7
|
+
* MonitorSeverity vocabulary, lowercased) to a Badge `variant`, rendering a
|
|
8
|
+
* human-readable label.
|
|
9
|
+
*
|
|
10
|
+
* NOT a duplicate of `StatusIndicator`: StatusIndicator is a small colored
|
|
11
|
+
* *status dot* (online/offline/degraded/info) conveying component liveness.
|
|
12
|
+
* SeverityBadge is a *labeled Badge* conveying a multi-level severity grade
|
|
13
|
+
* (ok/warning/alert/no_data/unknown/paused) — different semantics, different
|
|
14
|
+
* surface (bordered pill with text, not a dot). See plan ADR D2.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <SeverityBadge severity="alert" /> // "Alert", destructive
|
|
18
|
+
* <SeverityBadge severity="ok" label="Healthy" /> // custom label
|
|
19
|
+
* <SeverityBadge severity="warning" variantMap={{ warning: "accent" }} />
|
|
20
|
+
*/
|
|
21
|
+
/** Severity level. langfuse MonitorSeverity vocabulary, lowercased. */
|
|
22
|
+
export type Severity = "ok" | "warning" | "alert" | "no_data" | "unknown" | "paused";
|
|
23
|
+
/** A Badge visual variant (derived from the Badge primitive). */
|
|
24
|
+
export type BadgeVariant = NonNullable<BadgeProps["variant"]>;
|
|
25
|
+
export interface SeverityBadgeProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
26
|
+
/** Severity level to convey. */
|
|
27
|
+
severity: Severity;
|
|
28
|
+
/** Overrides the default human-readable label derived from the severity. */
|
|
29
|
+
label?: string;
|
|
30
|
+
/** Per-severity overrides of the default severity → Badge variant map. */
|
|
31
|
+
variantMap?: Partial<Record<Severity, BadgeVariant>>;
|
|
32
|
+
}
|
|
33
|
+
export declare const SeverityBadge: import("react").ForwardRefExoticComponent<SeverityBadgeProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TagInput — controlled multi-value tag editor (M17).
|
|
3
|
+
*
|
|
4
|
+
* Renders one removable chip per tag (`Badge` + a per-tag "×" button) plus a
|
|
5
|
+
* text input to add a new tag on Enter. Fully controlled: the consumer owns
|
|
6
|
+
* `value: string[]` and handles `onChange`. Adding calls
|
|
7
|
+
* `onChange([...value, tag])`; removing calls `onChange` without that tag.
|
|
8
|
+
* Dedup is built-in — adding an existing (trimmed) tag is a no-op, and so is
|
|
9
|
+
* an empty/whitespace tag. `disabled` blocks both add and remove.
|
|
10
|
+
*
|
|
11
|
+
* Design (ADR D2 + parsimony ladder rung 5): composes `Input` + `Badge` with
|
|
12
|
+
* Enter-to-add rather than the single-select `Combobox`. `Combobox` is a
|
|
13
|
+
* typeahead that selects ONE value from a fixed list and closes its own
|
|
14
|
+
* listbox on select — it has no "create arbitrary tag" affordance, so a plain
|
|
15
|
+
* input is both simpler and a better fit for free-text multi-value tags.
|
|
16
|
+
* `suggestions` power a native `<datalist>` (zero-dep autocomplete).
|
|
17
|
+
*
|
|
18
|
+
* <TagInput value={tags} onChange={setTags} suggestions={["bug", "feat"]} />
|
|
19
|
+
*/
|
|
20
|
+
export interface TagInputProps {
|
|
21
|
+
/** Current tags (controlled). */
|
|
22
|
+
value: string[];
|
|
23
|
+
/** Called with the next tag list on add/remove. */
|
|
24
|
+
onChange: (value: string[]) => void;
|
|
25
|
+
/** Optional autocomplete suggestions surfaced via a native datalist. */
|
|
26
|
+
suggestions?: string[];
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
declare const TagInput: import("react").ForwardRefExoticComponent<TagInputProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
|
+
export { TagInput };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* TokenCostBreakdown — a `<dl>` breakdown of a request's/span's/trace's token
|
|
4
|
+
* usage and USD cost: input, output, cache tokens, total, and cost. Controlled
|
|
5
|
+
* and pure — the consumer supplies the numbers; nothing is fetched.
|
|
6
|
+
*
|
|
7
|
+
* Honest zeros (M9 SessionSummary convention): a real `0` renders `0` /
|
|
8
|
+
* `$0.0000`; an ABSENT (undefined) field renders `—` (em-dash) — it is never
|
|
9
|
+
* fabricated as a zero. When EVERY field is absent, an honest empty state
|
|
10
|
+
* renders instead of a table of em-dashes.
|
|
11
|
+
*
|
|
12
|
+
* <TokenCostBreakdown inputTokens={1200} outputTokens={340}
|
|
13
|
+
* cacheTokens={80} totalTokens={1620} costUsd={0.0234} />
|
|
14
|
+
*/
|
|
15
|
+
export interface TokenCostBreakdownProps extends HTMLAttributes<HTMLDListElement> {
|
|
16
|
+
inputTokens?: number;
|
|
17
|
+
outputTokens?: number;
|
|
18
|
+
cacheTokens?: number;
|
|
19
|
+
totalTokens?: number;
|
|
20
|
+
costUsd?: number;
|
|
21
|
+
/** USD cost formatter. Default `$0.0000`. */
|
|
22
|
+
formatCostUsd?: (usd: number) => string;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
declare const TokenCostBreakdown: import("react").ForwardRefExoticComponent<TokenCostBreakdownProps & import("react").RefAttributes<HTMLDListElement>>;
|
|
26
|
+
export { TokenCostBreakdown };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ export { aggregateCost, asChat, contentText, isRedactedThinking, buildLayeredGra
|
|
|
3
3
|
export type { AlignDelta, AlignRow, AttributeGroup, AxisTick, BarLayout, ChatMessage, FlatSpan, GraphEdge, GraphNode, LayeredGraph, SpanKind, SpanStatus, ToolCall, TraceSpan, TranscriptRow, TranscriptRowStats, } from "./lib/trace/index.js";
|
|
4
4
|
export { Button, buttonVariants, type ButtonProps } from "./components/primitives/button/index.js";
|
|
5
5
|
export { Badge, badgeVariants, type BadgeProps } from "./components/primitives/badge/index.js";
|
|
6
|
-
export { Breadcrumb, type BreadcrumbLinkProps
|
|
7
|
-
export { DescriptionList, type DescriptionListProps
|
|
6
|
+
export { Breadcrumb, type BreadcrumbLinkProps } from "./components/primitives/breadcrumb/index.js";
|
|
7
|
+
export { DescriptionList, type DescriptionListProps } from "./components/primitives/description-list/index.js";
|
|
8
8
|
export { JsonViewer, type JsonViewerProps } from "./components/primitives/json-viewer/index.js";
|
|
9
9
|
export { Combobox, type ComboboxContentProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxProps, } from "./components/primitives/combobox/index.js";
|
|
10
|
-
export { Slider, type SliderMark, type SliderProps
|
|
11
|
-
export { UpdateBanner, type UpdateBannerProps
|
|
10
|
+
export { Slider, type SliderMark, type SliderProps } from "./components/primitives/slider/index.js";
|
|
11
|
+
export { UpdateBanner, type UpdateBannerProps } from "./components/primitives/update-banner/index.js";
|
|
12
12
|
export { Card } from "./components/primitives/card/index.js";
|
|
13
13
|
export { Input, type InputProps } from "./components/primitives/input/index.js";
|
|
14
14
|
export { Dialog } from "./components/primitives/dialog/index.js";
|
|
@@ -33,14 +33,15 @@ export { Progress, type ProgressProps } from "./components/primitives/progress/i
|
|
|
33
33
|
export { PlanBadge, type PlanBadgeProps, type PlanTier, } from "./components/primitives/plan-badge/index.js";
|
|
34
34
|
export { AccountMenu, type AccountMenuProps, } from "./components/composites/account-menu/index.js";
|
|
35
35
|
export { Table, type TableProps, type TableCellProps, type TableHeaderCellProps, } from "./components/primitives/table/index.js";
|
|
36
|
-
export { StatusDot, type StatusDotProps, type StatusKind
|
|
36
|
+
export { StatusDot, type StatusDotProps, type StatusKind } from "./components/primitives/status-dot/index.js";
|
|
37
37
|
export { CopyButton, type CopyButtonProps, } from "./components/primitives/copy-button/index.js";
|
|
38
38
|
export { Timestamp, type TimestampProps } from "./components/primitives/timestamp/index.js";
|
|
39
39
|
export { StatTile, type StatTileProps } from "./components/primitives/stat-tile/index.js";
|
|
40
40
|
export { DangerZone, type DangerZoneProps, type DangerZoneActionProps, } from "./components/primitives/danger-zone/index.js";
|
|
41
41
|
export { ConfirmDialog, type ConfirmDialogProps, } from "./components/composites/confirm-dialog/index.js";
|
|
42
42
|
export { CodeBlock, type CodeBlockProps } from "./components/composites/code-block/index.js";
|
|
43
|
-
export { StatusIndicator
|
|
43
|
+
export { StatusIndicator } from "./components/composites/status-indicator/index.js";
|
|
44
|
+
export type { StatusIndicatorKind, StatusIndicatorProps, StatusIndicatorSize } from "./components/composites/status-indicator/index.js";
|
|
44
45
|
export { MetricCard, type MetricCardDelta, type MetricCardProps, type MetricCardTrend, } from "./components/composites/metric-card/index.js";
|
|
45
46
|
export { Alert, type AlertProps, type AlertIntent } from "./components/primitives/alert/index.js";
|
|
46
47
|
export { Pagination, computePageRange, type PaginationProps, } from "./components/primitives/pagination/index.js";
|
|
@@ -85,9 +86,31 @@ export { SessionTimeline } from "./components/composites/session-timeline/index.
|
|
|
85
86
|
export type { SessionTimelineProps } from "./components/composites/session-timeline/index.js";
|
|
86
87
|
export { computeHistogram } from "./lib/chart/index.js";
|
|
87
88
|
export type { HistogramBin } from "./lib/chart/index.js";
|
|
89
|
+
export { diffLines } from "./lib/diff/index.js";
|
|
90
|
+
export type { DiffRow, DiffRowKind } from "./lib/diff/index.js";
|
|
91
|
+
export { DiffView } from "./components/composites/diff-view/index.js";
|
|
92
|
+
export type { DiffViewProps, DiffViewMode } from "./components/composites/diff-view/index.js";
|
|
93
|
+
export { PromptVersionDiff, templateToText, configToText } from "./components/composites/prompt-version-diff/index.js";
|
|
94
|
+
export type { PromptVersionDiffProps, PromptSnapshot } from "./components/composites/prompt-version-diff/index.js";
|
|
95
|
+
export { DatasetItemDiff, fieldToText, fieldPresent } from "./components/composites/dataset-item-diff/index.js";
|
|
96
|
+
export type { DatasetItemDiffProps, DatasetItemSnapshot } from "./components/composites/dataset-item-diff/index.js";
|
|
88
97
|
export { Histogram } from "./components/composites/histogram/index.js";
|
|
89
98
|
export type { HistogramProps } from "./components/composites/histogram/index.js";
|
|
90
99
|
export { PercentileChart } from "./components/composites/percentile-chart/index.js";
|
|
91
|
-
export type { PercentileBucket, PercentileChartProps
|
|
92
|
-
export { AnnotationInput, isCategoricalConfig, isContinuousConfig, isFreeformConfig
|
|
93
|
-
export type { AnnotationInputProps, CategoricalOption, AnnotationCategoricalConfig, AnnotationContinuousConfig, AnnotationFreeformConfig, AnnotationConfig
|
|
100
|
+
export type { PercentileBucket, PercentileChartProps } from "./components/composites/percentile-chart/index.js";
|
|
101
|
+
export { AnnotationInput, isCategoricalConfig, isContinuousConfig, isFreeformConfig } from "./components/composites/annotation-input/index.js";
|
|
102
|
+
export type { AnnotationInputProps, CategoricalOption, AnnotationCategoricalConfig, AnnotationContinuousConfig, AnnotationFreeformConfig, AnnotationConfig } from "./components/composites/annotation-input/index.js";
|
|
103
|
+
export { EvaluatorForm, defaultEvaluatorConfig, isTargetEvaluator, isRegexEvaluator, isThresholdEvaluator } from "./components/composites/evaluator-form/index.js";
|
|
104
|
+
export type { EvaluatorFormProps, EvaluatorConfig, EvaluatorType, ExactMatchEvaluatorConfig, ContainsEvaluatorConfig, RegexEvaluatorConfig, LevenshteinEvaluatorConfig, JsonDistanceEvaluatorConfig } from "./components/composites/evaluator-form/index.js";
|
|
105
|
+
export { AnnotationSummaryGroup, type AnnotationSummaryGroupProps } from "./components/composites/annotation-summary-group/index.js";
|
|
106
|
+
export { TokenCostBreakdown } from "./components/composites/token-cost-breakdown/index.js";
|
|
107
|
+
export type { TokenCostBreakdownProps } from "./components/composites/token-cost-breakdown/index.js";
|
|
108
|
+
export { PriceBreakdown } from "./components/composites/price-breakdown/index.js";
|
|
109
|
+
export type { PriceBreakdownProps } from "./components/composites/price-breakdown/index.js";
|
|
110
|
+
export { SeverityBadge } from "./components/composites/severity-badge/index.js";
|
|
111
|
+
export type { Severity, BadgeVariant, SeverityBadgeProps } from "./components/composites/severity-badge/index.js";
|
|
112
|
+
export { TagInput, type TagInputProps } from "./components/composites/tag-input/index.js";
|
|
113
|
+
export { CommentThread, type Comment, type CommentThreadProps } from "./components/composites/comment-thread/index.js";
|
|
114
|
+
export { ChatMessageCard, type ChatMessageCardProps } from "./components/composites/chat-message-card/index.js";
|
|
115
|
+
export { MessageBranchSelector, type MessageBranchSelectorProps } from "./components/composites/message-branch-selector/index.js";
|
|
116
|
+
export { PromptTemplateEditor, extractVars, type PromptTemplateEditorProps } from "./components/composites/prompt-template-editor/index.js";
|