@spexcode/transcript-ui 0.7.0-next.6 → 0.7.0-next.7
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/TranscriptView.d.ts +3 -0
- package/dist/TranscriptView.js +8 -1
- package/dist/context.d.ts +2 -0
- package/dist/context.js +2 -0
- package/dist/envelope.d.ts +10 -0
- package/dist/envelope.js +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
package/dist/TranscriptView.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export declare function TurnBody({ turn, openIds, onToggle, live, fold }: {
|
|
|
8
8
|
live: boolean;
|
|
9
9
|
fold?: boolean;
|
|
10
10
|
} & Disclosure): import("react").JSX.Element;
|
|
11
|
+
export declare function QuotedTurn({ turn }: {
|
|
12
|
+
turn: AnyTurn;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
11
14
|
export declare function WorkSegmentView({ segment, openIds, onToggle, live }: {
|
|
12
15
|
segment: Work;
|
|
13
16
|
live: boolean;
|
package/dist/TranscriptView.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { useTranscriptUi } from './context.js';
|
|
3
3
|
import { Caret } from './icons.js';
|
|
4
4
|
import { Quote } from './Quote.js';
|
|
5
|
+
import { parseEnvelope } from './envelope.js';
|
|
5
6
|
import { segments } from './segments.js';
|
|
6
7
|
import { ToolRun } from './ToolLine.js';
|
|
7
8
|
import { useDisclosure } from './useDisclosure.js';
|
|
@@ -11,6 +12,12 @@ export function TurnBody({ turn, openIds, onToggle, live, fold = true }) {
|
|
|
11
12
|
const { renderText } = useTranscriptUi();
|
|
12
13
|
return _jsxs("div", { className: "tx-say", children: [turn.text && _jsx("div", { className: "tx-say-text", children: renderText(turn.text) }), _jsx(ToolRun, { tools: turn.tools, openIds: openIds, onToggle: onToggle, live: live, fold: fold })] });
|
|
13
14
|
}
|
|
15
|
+
// a quoted turn is read through the envelope rows: the sender it names, the body it carried
|
|
16
|
+
export function QuotedTurn({ turn }) {
|
|
17
|
+
const { envelopes } = useTranscriptUi();
|
|
18
|
+
const envelope = parseEnvelope(turn.text || '', envelopes);
|
|
19
|
+
return _jsx(Quote, { who: envelope.who, ts: envelope.at ?? turn.at, text: envelope.body, className: "tx-quote-nested" });
|
|
20
|
+
}
|
|
14
21
|
export function WorkSegmentView({ segment, openIds, onToggle, live }) {
|
|
15
22
|
const { labels, vocabulary } = useTranscriptUi();
|
|
16
23
|
const id = `seg:${segment.work[0]?.id || segment.answer?.id}`;
|
|
@@ -25,7 +32,7 @@ export function WorkSegmentView({ segment, openIds, onToggle, live }) {
|
|
|
25
32
|
}
|
|
26
33
|
export function SegmentView({ segment, ...rest }) {
|
|
27
34
|
if (segment.kind === 'quote')
|
|
28
|
-
return _jsx(
|
|
35
|
+
return _jsx(QuotedTurn, { turn: segment.turn });
|
|
29
36
|
return _jsx(WorkSegmentView, { segment: segment, ...rest });
|
|
30
37
|
}
|
|
31
38
|
// THE TURNS, in the grammar: quotes where the host wants them, work segments folded behind their answers
|
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type Vocabulary } from './vocabulary.js';
|
|
3
3
|
import type { FoldPolicy, UserTurnPolicy } from './segments.js';
|
|
4
|
+
import { type EnvelopeParser } from './envelope.js';
|
|
4
5
|
export type ToolOutputResult = {
|
|
5
6
|
ok: true;
|
|
6
7
|
output: string | null;
|
|
@@ -30,6 +31,7 @@ export type TranscriptUiOptions = Readonly<{
|
|
|
30
31
|
loadToolOutput: ((toolId: string) => Promise<ToolOutputResult>) | null;
|
|
31
32
|
labels: Labels;
|
|
32
33
|
vocabulary: Vocabulary;
|
|
34
|
+
envelopes: readonly EnvelopeParser[];
|
|
33
35
|
fold: FoldPolicy;
|
|
34
36
|
runMin: number;
|
|
35
37
|
userTurns: UserTurnPolicy;
|
package/dist/context.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext } from 'react';
|
|
3
3
|
import { defaultVocabulary } from './vocabulary.js';
|
|
4
|
+
import { defaultEnvelopes } from './envelope.js';
|
|
4
5
|
export const defaultLabels = {
|
|
5
6
|
loading: 'loading…',
|
|
6
7
|
running: 'running',
|
|
@@ -23,6 +24,7 @@ export const defaultOptions = {
|
|
|
23
24
|
loadToolOutput: null,
|
|
24
25
|
labels: defaultLabels,
|
|
25
26
|
vocabulary: defaultVocabulary,
|
|
27
|
+
envelopes: defaultEnvelopes,
|
|
26
28
|
fold: 'segments',
|
|
27
29
|
runMin: 3,
|
|
28
30
|
userTurns: 'boundary',
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Envelope = Readonly<{
|
|
2
|
+
who: string | null;
|
|
3
|
+
id?: string | null;
|
|
4
|
+
at?: number | null;
|
|
5
|
+
body: string;
|
|
6
|
+
}>;
|
|
7
|
+
export type EnvelopeParser = (text: string) => Envelope | null;
|
|
8
|
+
export declare const spexEnvelope: EnvelopeParser;
|
|
9
|
+
export declare const defaultEnvelopes: readonly EnvelopeParser[];
|
|
10
|
+
export declare function parseEnvelope(text: string, parsers?: readonly EnvelopeParser[]): Envelope;
|
package/dist/envelope.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// `— from session "label" (id) on machine m. To reply: spex session send [--ssh addr] id "<your reply>"`
|
|
2
|
+
const SPEX_FOOTER = /\n*— from session (?:"(.*?)" \(([^\s)]+)\)|(\S+))(?: on machine \S+)?\. To reply: spex session send (?:--ssh \S+ )?\S+ "<your reply>"\s*$/;
|
|
3
|
+
export const spexEnvelope = (text) => {
|
|
4
|
+
const m = SPEX_FOOTER.exec(text || '');
|
|
5
|
+
if (!m)
|
|
6
|
+
return null;
|
|
7
|
+
const id = m[2] || m[3] || null;
|
|
8
|
+
return { who: m[1] || id, id, body: text.slice(0, m.index) };
|
|
9
|
+
};
|
|
10
|
+
export const defaultEnvelopes = [spexEnvelope];
|
|
11
|
+
export function parseEnvelope(text, parsers = defaultEnvelopes) {
|
|
12
|
+
for (const parse of parsers) {
|
|
13
|
+
const envelope = parse(text);
|
|
14
|
+
if (envelope)
|
|
15
|
+
return envelope;
|
|
16
|
+
}
|
|
17
|
+
return { who: null, body: text };
|
|
18
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spexcode/transcript-ui",
|
|
3
|
-
"version": "0.7.0-next.
|
|
3
|
+
"version": "0.7.0-next.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React components that draw a normalized agent transcript — the person quoted, the agent as the page, a tool call as a sentence, the work folded behind its answer — with the fold, the prose renderer, the tool vocabulary, the labels and the design tokens all tunable.",
|
|
6
6
|
"files": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test": "npm run build && tsx --test src/*.test.tsx"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@spexcode/transcript": "0.7.0-next.
|
|
27
|
+
"@spexcode/transcript": "0.7.0-next.7"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^18.2.0 || ^19.0.0"
|