@miadi/companion-ui 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Miadi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,104 @@
1
- # Temporary Holding Version
1
+ # @miadi/companion-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An episode's companion seat, as React: the conversation a person held with the seat, and
4
+ the opener that plans and opens the seat for an episode.
5
+
6
+ In the Miadi stack, a companion seat is an agent session bound to one Chronicle episode.
7
+ The person speaks a take on the phone page, the seat answers, and the answer is voiced.
8
+ This package shows that conversation in order (the person's takes, the seat's replies, each
9
+ with its playback) and lets a page open the seat without going to the cockpit.
10
+
11
+ ```bash
12
+ npm i @miadi/companion-ui
13
+ ```
14
+
15
+ ## The conversation
16
+
17
+ ```tsx
18
+ import { buildCompanionThread, CompanionDialogue, CompanionCard } from "@miadi/companion-ui"
19
+
20
+ const thread = buildCompanionThread({ takes, replies, voices })
21
+
22
+ <CompanionDialogue thread={thread} takeSpeaker="William" takeAudioUrl={(take) => urlOf(take.audioPath)} />
23
+ <CompanionCard thread={thread} conversationHref="/chronicle/ep/companion" links={[...]} />
24
+ ```
25
+
26
+ - **takes**: `{ id, at, text, audioPath?, purpose? }`, one per recorded take. A take with
27
+ `purpose: "labelling"` belongs to something else and is left out.
28
+ - **replies**: `{ id, take, text, seat, session?, at, related?, feedback? }`, one per reply.
29
+ - **voices**: voice-ledger records reduced to `{ id, at, text, persona, source, src, session? }`.
30
+
31
+ A reply is voiced in parts of at most 900 characters, each its own ledger record.
32
+ `buildCompanionThread` finds each part in the text of the reply it was cut from and plays
33
+ them in text order. A voice whose `source` is `phone-capture` is a companion reply
34
+ (`isCompanionVoice`); a host lists every other voice as the episode's recordings. A
35
+ companion voice that no reply record holds becomes a reply of its own, so a host without
36
+ the reply records still shows what the seat said.
37
+
38
+ `CompanionDialogue` shows the latest turns (`initialTurns`, default 12) and offers the
39
+ earlier ones. Each turn plays from one audio element per surface; a reply plays its parts
40
+ one after another. `CompanionCard` is the short form: the latest exchange, a link to the
41
+ whole conversation, the host's links, and a slot for the opener.
42
+
43
+ ## The opener
44
+
45
+ ```tsx
46
+ import { CompanionOpener, httpCompanionTransport } from "@miadi/companion-ui"
47
+
48
+ <CompanionOpener transport={httpCompanionTransport("/api/tide/companion")} episode="120" seats={["mia"]} />
49
+ ```
50
+
51
+ It asks for the plan first (`tide companion open --format json`), says it in words, and
52
+ carries out that plan only when the gold button is pressed. Without `episode` it shows a
53
+ number field. With more than one seat it offers a choice. The transport receives
54
+ `{ episode, seat?, archive?, run? }` and answers tide's plan, or a refusal with `status` and
55
+ `error`.
56
+
57
+ `CompanionGlyphBar` draws one glyph per agent that holds a seat (🧠 for Mia), and the host
58
+ shows the opener of the one pressed, so the opener takes no room until it is wanted:
59
+
60
+ ```tsx
61
+ <CompanionGlyphBar agents={agents} open={seat} onToggle={(key) => setSeat((s) => (s === key ? null : key))} />
62
+ {seat && <CompanionOpener transport={transport} seats={[seat]} />}
63
+ ```
64
+
65
+ `agents` is `{ key, name, glyph, role?, seat }[]`; Miadi serves it at `/api/factory/agents`.
66
+ Ref: jgwill/Miadi#817.
67
+
68
+ ## Reading the files: `@miadi/companion-ui/node`
69
+
70
+ ```ts
71
+ import { readCompanionTakes, readCompanionReplies, readCompanionForks, companionRepliesDir } from "@miadi/companion-ui/node"
72
+
73
+ readCompanionTakes(episodeDir) // captures/<12-digit take>/capture.json + its English transcript
74
+ readCompanionReplies(companionRepliesDir(), episode) // <state>/replies/<episode>.jsonl + feedback/<episode>.jsonl
75
+ readCompanionForks(episodeDir) // branches/<name>/ folders that hold a brief
76
+ ```
77
+
78
+ Only the descriptor and transcript of a take are read, never its audio. A reply's origin
79
+ (user, host, pane, working directory) and its loop record stay on the host.
80
+ `companionRepliesDir` follows the phone page's own order: `MIADI_PHONE_CAPTURE_STATE_DIR`,
81
+ `$XDG_STATE_HOME/miadi-phone-capture`, `~/.local/state/miadi-phone-capture`.
82
+
83
+ ## Entry points
84
+
85
+ | import | holds | React |
86
+ |---|---|---|
87
+ | `@miadi/companion-ui` | everything below, and the components | yes (client modules) |
88
+ | `@miadi/companion-ui/thread` | `buildCompanionThread`, `isCompanionVoice`, the types | no |
89
+ | `@miadi/companion-ui/seat` | the plan types, `sayPlan`, `httpCompanionTransport`, `COMPANION_SEATS` | no |
90
+ | `@miadi/companion-ui/node` | the file readers | no (Node) |
91
+
92
+ A server component imports from `./thread` and `./seat`.
93
+
94
+ ## The contract
95
+
96
+ No component fetches, holds a URL or a token, or knows a chronicle root. The host decides
97
+ who hears a take (`takeAudioUrl` answers null) and who may open a seat (it renders the
98
+ opener or not), and passes the transport.
99
+
100
+ ## Test
101
+
102
+ ```bash
103
+ npm test
104
+ ```
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The conversation with a companion seat, as React: the person's takes and the seat's
3
+ * replies in the order they happened, each with its playback, and the card an episode
4
+ * room shows for it.
5
+ *
6
+ * Data in, intent out. The host builds the thread (`buildCompanionThread`), decides who
7
+ * hears a take (`takeAudioUrl` answers null for a reader who may not), and says where a
8
+ * related card leads (`relatedHref`). No component fetches, holds a URL or knows a root.
9
+ */
10
+ import { type ReactNode } from "react";
11
+ import { type CompanionTakeTurn, type CompanionThread, type CompanionTurn } from "./thread.js";
12
+ /** The fields `@miadi/episode-ui`'s `EpisodeUITheme` carries, so `CHRONICLE_THEME` fits as it is. */
13
+ export interface CompanionTheme {
14
+ background: string;
15
+ card: string;
16
+ text: string;
17
+ textDim: string;
18
+ muted: string;
19
+ accent: string;
20
+ border: string;
21
+ success: string;
22
+ warning: string;
23
+ mono: string;
24
+ }
25
+ /** The Chronicle's surface (the values of `@miadi/episode-ui/chronicle-theme`), every text colour at 4.5:1 or better. */
26
+ export declare const COMPANION_THEME: CompanionTheme;
27
+ export interface CompanionTurnOptions {
28
+ /** A take's audio URL, or null when this reader does not hear takes. */
29
+ takeAudioUrl?: (take: CompanionTakeTurn) => string | null;
30
+ /** The name a take is shown under. */
31
+ takeSpeaker?: string;
32
+ /** Where a related card leads; the card's own href when absent, text when it answers null. */
33
+ relatedHref?: (href: string) => string | null;
34
+ /** False when the host could not read the voices, so a reply without one is not called unvoiced. */
35
+ voicesRead?: boolean;
36
+ theme?: Partial<CompanionTheme>;
37
+ }
38
+ interface Playing {
39
+ turn: string;
40
+ part: number;
41
+ parts: number;
42
+ paused: boolean;
43
+ }
44
+ export interface CompanionTurnViewProps extends CompanionTurnOptions {
45
+ turn: CompanionTurn;
46
+ /** The take this reply answers, when it is not the turn just before. */
47
+ answers?: CompanionTakeTurn;
48
+ playing?: Playing | null;
49
+ onPlay?: (turn: CompanionTurn, srcs: string[]) => void;
50
+ /** Show the whole text at once. */
51
+ open?: boolean;
52
+ anchorPrefix?: string;
53
+ }
54
+ export declare function CompanionTurnView({ turn, answers, playing, onPlay, open, anchorPrefix, ...options }: CompanionTurnViewProps): import("react").JSX.Element;
55
+ export interface CompanionDialogueProps extends CompanionTurnOptions {
56
+ thread: CompanionThread;
57
+ /** How many of the latest turns show before "show earlier". Default 12; 0 shows all. */
58
+ initialTurns?: number;
59
+ /** A line above the turns, for instance why the takes are not shown to this reader. */
60
+ note?: ReactNode;
61
+ anchorPrefix?: string;
62
+ }
63
+ export declare function CompanionDialogue({ thread, initialTurns, note, anchorPrefix, ...options }: CompanionDialogueProps): import("react").JSX.Element;
64
+ export interface CompanionLink {
65
+ label: string;
66
+ href: string;
67
+ /** Opens in a new tab. */
68
+ external?: boolean;
69
+ }
70
+ export interface CompanionCardProps extends CompanionTurnOptions {
71
+ thread: CompanionThread;
72
+ /** The page that shows the whole conversation. */
73
+ conversationHref?: string;
74
+ /** Other places the reader may go: the seat's pane, the page that records a take. */
75
+ links?: CompanionLink[];
76
+ /** Shown under the links, for instance `<CompanionOpener>` for a person who may open a seat. */
77
+ children?: ReactNode;
78
+ /** How many of the latest turns the card shows. Default 2. */
79
+ latest?: number;
80
+ title?: string;
81
+ }
82
+ export declare function CompanionCard({ thread, conversationHref, links, children, latest, title, ...options }: CompanionCardProps): import("react").JSX.Element;
83
+ export {};
84
+ //# sourceMappingURL=dialogue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialogue.d.ts","sourceRoot":"","sources":["../src/dialogue.tsx"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,EAAwC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC5E,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAA;AAEpB,qGAAqG;AACrG,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,I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AAE,MAAM,EAAE,IAAY,EAAE,YAAsB,EAAE,GAAG,OAAO,EAAE,EAAE,sBAAsB,+BAoG7I;AAID,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,MAAM,EAAE,eAAe,CAAA;IACvB,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uFAAuF;IACvF,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,YAAiB,EAAE,IAAI,EAAE,YAAsB,EAAE,GAAG,OAAO,EAAE,EAAE,sBAAsB,+BAwChI;AAID,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,MAAM,EAAE,eAAe,CAAA;IACvB,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qFAAqF;IACrF,KAAK,CAAC,EAAE,aAAa,EAAE,CAAA;IACvB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAU,EAAE,QAAQ,EAAE,MAAU,EAAE,KAAmB,EAAE,GAAG,OAAO,EAAE,EAAE,kBAAkB,+BAyDhJ"}
@@ -0,0 +1,137 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * The conversation with a companion seat, as React: the person's takes and the seat's
5
+ * replies in the order they happened, each with its playback, and the card an episode
6
+ * room shows for it.
7
+ *
8
+ * Data in, intent out. The host builds the thread (`buildCompanionThread`), decides who
9
+ * hears a take (`takeAudioUrl` answers null for a reader who may not), and says where a
10
+ * related card leads (`relatedHref`). No component fetches, holds a URL or knows a root.
11
+ */
12
+ import { useRef, useState } from "react";
13
+ import { personaLabel, stampOf, } from "./thread.js";
14
+ /** The Chronicle's surface (the values of `@miadi/episode-ui/chronicle-theme`), every text colour at 4.5:1 or better. */
15
+ export const COMPANION_THEME = {
16
+ background: "#151515",
17
+ card: "#242424",
18
+ text: "#f9f9f9",
19
+ textDim: "#c8c8c8",
20
+ muted: "#959595",
21
+ accent: "#d4a843",
22
+ border: "#404040",
23
+ success: "#5ac37d",
24
+ warning: "#e0a458",
25
+ mono: "'JetBrains Mono', ui-monospace, monospace",
26
+ };
27
+ /** One audio element per surface; a reply plays its voices one after another. */
28
+ function usePlayer() {
29
+ const audio = useRef(null);
30
+ const queue = useRef([]);
31
+ const [playing, setPlaying] = useState(null);
32
+ const start = (turn, srcs, part = 0) => {
33
+ const a = audio.current;
34
+ const src = srcs[part];
35
+ if (!a || !src)
36
+ return;
37
+ queue.current = srcs;
38
+ setPlaying({ turn, part, parts: srcs.length, paused: false });
39
+ a.src = src;
40
+ a.play().catch(() => { });
41
+ };
42
+ const play = (turn, srcs) => {
43
+ const a = audio.current;
44
+ if (playing?.turn === turn && a) {
45
+ if (a.paused)
46
+ a.play().catch(() => { });
47
+ else
48
+ a.pause();
49
+ return;
50
+ }
51
+ start(turn, srcs);
52
+ };
53
+ const onEnded = () => {
54
+ if (!playing)
55
+ return;
56
+ if (playing.part + 1 < queue.current.length)
57
+ start(playing.turn, queue.current, playing.part + 1);
58
+ else
59
+ setPlaying(null);
60
+ };
61
+ const onPause = () => setPlaying((p) => (p && !p.paused ? { ...p, paused: true } : p));
62
+ const onResume = () => setPlaying((p) => (p && p.paused ? { ...p, paused: false } : p));
63
+ return { audio, playing, play, events: { onEnded, onPause, onPlay: onResume } };
64
+ }
65
+ function sourcesOf(turn, options) {
66
+ if (turn.kind === "take") {
67
+ const url = options.takeAudioUrl?.(turn);
68
+ return url ? [url] : [];
69
+ }
70
+ return turn.audio.map((v) => v.src).filter((src) => Boolean(src));
71
+ }
72
+ // ---------- text ----------
73
+ /** Paragraphs, with `**bold**` kept as emphasis and every other character as written. */
74
+ function Prose({ text, color }) {
75
+ const paragraphs = text.split(/\n{2,}/).map((p) => p.trim()).filter(Boolean);
76
+ return (_jsx(_Fragment, { children: paragraphs.map((p, i) => (_jsx("p", { style: { margin: i === 0 ? 0 : "8px 0 0", whiteSpace: "pre-wrap", overflowWrap: "anywhere", color }, children: p.split(/(\*\*[^*]+\*\*)/g).map((piece, j) => /^\*\*[^*]+\*\*$/.test(piece) ? _jsx("strong", { children: piece.slice(2, -2) }, j) : _jsx("span", { children: piece }, j)) }, i))) }));
77
+ }
78
+ const LONG = 520;
79
+ export function CompanionTurnView({ turn, answers, playing, onPlay, open = false, anchorPrefix = "turn-", ...options }) {
80
+ const t = { ...COMPANION_THEME, ...options.theme };
81
+ const [expanded, setExpanded] = useState(open);
82
+ const take = turn.kind === "take";
83
+ const srcs = sourcesOf(turn, options);
84
+ const on = playing?.turn === turn.id;
85
+ const sounding = on && !playing?.paused;
86
+ const long = turn.text.length > LONG;
87
+ const who = take ? (options.takeSpeaker ?? "Take") : personaLabel(turn.persona);
88
+ const bubble = {
89
+ alignSelf: take ? "flex-end" : "flex-start",
90
+ width: "min(100%, 680px)",
91
+ boxSizing: "border-box",
92
+ background: t.card,
93
+ border: `1px solid ${on ? t.accent : take ? `${t.accent}55` : t.border}`,
94
+ borderRadius: take ? "12px 12px 4px 12px" : "12px 12px 12px 4px",
95
+ padding: "10px 12px",
96
+ display: "flex",
97
+ flexDirection: "column",
98
+ gap: 6,
99
+ };
100
+ return (_jsxs("article", { id: `${anchorPrefix}${turn.id}`, "data-turn": turn.kind, "data-turn-id": turn.id, style: bubble, children: [_jsxs("header", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "4px 10px", fontSize: 12 }, children: [srcs.length > 0 && (_jsx("button", { type: "button", onClick: () => onPlay?.(turn, srcs), "aria-label": `${sounding ? "Pause" : "Play"} ${who} ${stampOf(turn.at)}`, style: {
101
+ width: 26, height: 26, flex: "none", borderRadius: 999, border: "none", cursor: "pointer",
102
+ background: on ? t.accent : t.muted, color: t.background, fontSize: 11, display: "flex", alignItems: "center", justifyContent: "center",
103
+ }, children: sounding ? "❚❚" : "▶" })), _jsx("strong", { style: { color: take ? t.accent : t.text }, children: who }), _jsx("span", { style: { color: t.muted, fontFamily: t.mono, fontSize: 11 }, children: stampOf(turn.at) }), on && playing && playing.parts > 1 && (_jsxs("span", { style: { color: t.accent, fontFamily: t.mono, fontSize: 11 }, children: ["part ", playing.part + 1, " of ", playing.parts] })), !take && answers && (_jsxs("a", { href: `#${anchorPrefix}${answers.id}`, style: { color: t.textDim, fontSize: 11 }, children: ["answers the take of ", stampOf(answers.at)] })), !take && turn.feedback && (_jsx("span", { title: turn.feedback === "up" ? "marked as working" : "marked as not working", style: { fontSize: 12 }, children: turn.feedback === "up" ? "👍" : "👎" }))] }), turn.text ? (_jsx("div", { style: {
104
+ fontSize: 13.5, lineHeight: 1.55,
105
+ ...(long && !expanded ? { maxHeight: "9.5em", overflow: "hidden", WebkitMaskImage: "linear-gradient(#000 70%, transparent)", maskImage: "linear-gradient(#000 70%, transparent)" } : {}),
106
+ }, children: _jsx(Prose, { text: turn.text, color: t.text }) })) : (_jsx("div", { style: { fontSize: 12.5, fontStyle: "italic", color: t.textDim }, children: take ? "No transcript yet." : "No text." })), long && (_jsx("button", { type: "button", onClick: () => setExpanded(!expanded), style: { alignSelf: "flex-start", background: "none", border: "none", padding: 0, cursor: "pointer", color: t.accent, fontSize: 12, fontFamily: "inherit" }, children: expanded ? "Show less" : "Read all" })), !take && turn.related?.length ? (_jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, children: turn.related.map((card) => {
107
+ const href = options.relatedHref ? options.relatedHref(card.href) : card.href;
108
+ const chip = { fontSize: 11.5, padding: "3px 8px", borderRadius: 999, border: `1px solid ${t.border}`, color: t.textDim, textDecoration: "none" };
109
+ return href ? (_jsx("a", { href: href, style: { ...chip, color: t.accent }, title: card.href, children: card.label }, `${card.label}-${card.href}`)) : (_jsx("span", { style: chip, title: card.href, children: card.label }, `${card.label}-${card.href}`));
110
+ }) })) : null, !take && turn.fromVoices && (_jsx("div", { style: { fontSize: 11, color: t.muted }, children: "Shown from its voice: the reply's own record is not on this host." })), !take && srcs.length === 0 && !turn.fromVoices && (_jsx("div", { style: { fontSize: 11, color: t.muted }, children: options.voicesRead === false ? "Its voice could not be read just now." : "Not voiced." }))] }));
111
+ }
112
+ export function CompanionDialogue({ thread, initialTurns = 12, note, anchorPrefix = "turn-", ...options }) {
113
+ const t = { ...COMPANION_THEME, ...options.theme };
114
+ const { audio, playing, play, events } = usePlayer();
115
+ const [shown, setShown] = useState(initialTurns > 0 ? initialTurns : thread.turns.length);
116
+ const from = Math.max(0, thread.turns.length - shown);
117
+ const turns = thread.turns.slice(from);
118
+ return (_jsxs("section", { "data-companion-dialogue": thread.turns.length, style: { display: "flex", flexDirection: "column", gap: 10 }, children: [_jsx("audio", { ref: audio, ...events, controls: true, preload: "none", style: { width: "100%", height: 36, display: playing ? "block" : "none" } }), note ? _jsx("div", { style: { fontSize: 12.5, color: t.textDim }, children: note }) : null, thread.turns.length === 0 && _jsx("div", { style: { fontSize: 13, color: t.textDim, fontStyle: "italic" }, children: "No conversation with a companion yet." }), from > 0 && (_jsxs("button", { type: "button", onClick: () => setShown(thread.turns.length), style: { alignSelf: "center", background: "transparent", border: `1px solid ${t.border}`, borderRadius: 999, color: t.accent, padding: "6px 14px", cursor: "pointer", fontSize: 12.5, fontFamily: "inherit" }, children: ["Show ", from, " earlier turn", from === 1 ? "" : "s"] })), turns.map((turn, i) => {
119
+ const before = i > 0 ? turns[i - 1] : from > 0 ? thread.turns[from - 1] : undefined;
120
+ const answers = turn.kind === "reply" && turn.take && !(before?.kind === "take" && before.id === turn.take)
121
+ ? thread.turns.find((x) => x.kind === "take" && x.id === turn.take)
122
+ : undefined;
123
+ return (_jsx(CompanionTurnView, { turn: turn, answers: answers, playing: playing, onPlay: (x, srcs) => play(x.id, srcs), anchorPrefix: anchorPrefix, ...options }, `${turn.kind}-${turn.id}`));
124
+ })] }));
125
+ }
126
+ export function CompanionCard({ thread, conversationHref, links = [], children, latest = 2, title = "Companion", ...options }) {
127
+ const t = { ...COMPANION_THEME, ...options.theme };
128
+ const { audio, playing, play, events } = usePlayer();
129
+ const personas = [...new Set(thread.turns.flatMap((x) => (x.kind === "reply" ? [personaLabel(x.persona)] : [])))];
130
+ const turns = thread.turns.slice(-latest);
131
+ const counts = [
132
+ thread.takes ? `${thread.takes} take${thread.takes === 1 ? "" : "s"}` : "",
133
+ thread.replies ? `${thread.replies} repl${thread.replies === 1 ? "y" : "ies"}` : "",
134
+ ].filter(Boolean).join(" · ");
135
+ return (_jsxs("section", { "data-companion-card": thread.turns.length, style: { background: t.card, border: `1px solid ${t.border}`, borderRadius: 10, padding: 15, display: "flex", flexDirection: "column", gap: 10 }, children: [_jsxs("div", { style: { display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: 8, flexWrap: "wrap" }, children: [_jsx("div", { style: { fontSize: 11.5, fontWeight: 800, textTransform: "uppercase", letterSpacing: "0.06em", color: t.muted }, children: title }), (personas.length > 0 || counts) && (_jsx("div", { style: { fontSize: 11.5, color: t.textDim }, children: [personas.join(", "), counts].filter(Boolean).join(" · ") }))] }), _jsx("audio", { ref: audio, ...events, controls: true, preload: "none", style: { width: "100%", height: 32, display: playing ? "block" : "none" } }), turns.length === 0 ? (_jsx("div", { style: { fontSize: 12.5, color: t.textDim, fontStyle: "italic" }, children: "No conversation with a companion yet." })) : (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: turns.map((turn) => (_jsx(CompanionTurnView, { turn: turn, playing: playing, onPlay: (x, srcs) => play(x.id, srcs), anchorPrefix: "companion-card-", ...options }, `${turn.kind}-${turn.id}`))) })), (conversationHref || links.length > 0) && (_jsxs("nav", { style: { display: "flex", flexDirection: "column", gap: 6, fontSize: 13 }, children: [conversationHref && thread.turns.length > 0 && (_jsx("a", { href: conversationHref, style: { color: t.accent, fontWeight: 700, textDecoration: "none" }, children: "Open the whole conversation \u2192" })), links.map((link) => (_jsxs("a", { href: link.href, ...(link.external ? { target: "_blank", rel: "noreferrer" } : {}), style: { color: t.accent, textDecoration: "none" }, children: [link.label, link.external ? " ↗" : " →"] }, link.href)))] })), children] }));
136
+ }
137
+ //# sourceMappingURL=dialogue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialogue.js","sourceRoot":"","sources":["../src/dialogue.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAA;AAC5E,OAAO,EACL,YAAY,EACZ,OAAO,GAKR,MAAM,aAAa,CAAA;AAgBpB,yHAAyH;AACzH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,UAAU,EAAE,SAAS;IACrB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,2CAA2C;CAClD,CAAA;AAuBD,iFAAiF;AACjF,SAAS,SAAS;IAChB,MAAM,KAAK,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAA;IAC5C,MAAM,KAAK,GAAG,MAAM,CAAW,EAAE,CAAC,CAAA;IAClC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAiB,IAAI,CAAC,CAAA;IAE5D,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,IAAc,EAAE,IAAI,GAAG,CA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CAAC,EAClE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAEjD,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KALnC,IAAI,CAAC,IAAI,CAMZ,CACL,CAAC,IACE,CACP,EACA,QAAQ,IACD,CACX,CAAA;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The companions a page can open, as a row of glyphs: 🧠 for Mia, then each agent
3
+ * that holds a companion seat. Pressing a glyph asks the host to show (or hide) that
4
+ * agent's opener, so the opener takes no room until someone wants it (Guillaume's
5
+ * screenwalk of the cockpit, review a425d070, jgwill/Miadi#817).
6
+ *
7
+ * The agents come from the host: the factory serves them at /api/factory/agents,
8
+ * built from ~/.agents/agents and data/GlyphMap.json. Only agents with a seat are
9
+ * drawn, because only they can be opened.
10
+ */
11
+ import type { CSSProperties } from "react";
12
+ import { type CompanionOpenerTheme } from "./opener.js";
13
+ export interface CompanionAgent {
14
+ key: string;
15
+ name: string;
16
+ glyph: string;
17
+ role?: string | null;
18
+ /** True when tide can open a companion seat for this agent. */
19
+ seat: boolean;
20
+ }
21
+ export interface CompanionGlyphBarProps {
22
+ agents: readonly CompanionAgent[];
23
+ /** The agent whose opener is shown, or null when all are collapsed. */
24
+ open: string | null;
25
+ onToggle(key: string): void;
26
+ theme?: Partial<CompanionOpenerTheme>;
27
+ style?: CSSProperties;
28
+ }
29
+ /** The agents the bar draws: seat holders, in the order the host gave them. */
30
+ export declare function seatAgents(agents: readonly CompanionAgent[]): CompanionAgent[];
31
+ export declare function CompanionGlyphBar({ agents, open, onToggle, theme, style }: CompanionGlyphBarProps): import("react").JSX.Element | null;
32
+ //# sourceMappingURL=glyphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glyphs.d.ts","sourceRoot":"","sources":["../src/glyphs.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAgB,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAErE,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,+DAA+D;IAC/D,IAAI,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAA;IACjC,uEAAuE;IACvE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACrC,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,cAAc,EAAE,CAE9E;AAED,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,sBAAsB,sCA+BjG"}
package/dist/glyphs.js ADDED
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { OPENER_THEME } from "./opener.js";
4
+ /** The agents the bar draws: seat holders, in the order the host gave them. */
5
+ export function seatAgents(agents) {
6
+ return agents.filter((a) => a.seat && a.glyph);
7
+ }
8
+ export function CompanionGlyphBar({ agents, open, onToggle, theme, style }) {
9
+ const t = { ...OPENER_THEME, ...theme };
10
+ const shown = seatAgents(agents);
11
+ if (shown.length === 0)
12
+ return null;
13
+ return (_jsx("div", { role: "group", "aria-label": "companions", "data-companion-glyphs": "", style: { display: "inline-flex", gap: 4, ...style }, children: shown.map((a) => {
14
+ const pressed = open === a.key;
15
+ return (_jsx("button", { type: "button", "aria-pressed": pressed, "aria-label": `${pressed ? "Hide" : "Open"} ${a.name}`, title: `${a.name}${a.role ? ` · ${a.role}` : ""}`, "data-companion-glyph": a.key, onClick: () => onToggle(a.key), style: {
16
+ minWidth: 36, minHeight: 36, padding: "0 6px", borderRadius: 999, cursor: "pointer",
17
+ fontSize: 18, lineHeight: 1, fontFamily: t.mono,
18
+ background: pressed ? `${t.accent}26` : "transparent",
19
+ border: `1px solid ${pressed ? t.accent : `${t.accent}55`}`,
20
+ color: t.text,
21
+ }, children: _jsx("span", { "aria-hidden": "true", children: a.glyph }) }, a.key));
22
+ }) }));
23
+ }
24
+ //# sourceMappingURL=glyphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glyphs.js","sourceRoot":"","sources":["../src/glyphs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAcZ,OAAO,EAAE,YAAY,EAA6B,MAAM,aAAa,CAAA;AAoBrE,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,MAAiC;IAC1D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAA0B;IAChG,MAAM,CAAC,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,EAAE,CAAA;IACvC,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IAChC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACnC,OAAO,CACL,cAAK,IAAI,EAAC,OAAO,gBAAY,YAAY,2BAAuB,EAAE,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,aA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i/companion-ui — an episode's companion seat, as React.
3
+ *
4
+ * - The conversation: `buildCompanionThread` joins the person's takes, the seat's
5
+ * replies and the voices cut from them; `CompanionDialogue` shows it with each
6
+ * turn's playback; `CompanionCard` is the short form an episode room shows.
7
+ * - The seat: `CompanionOpener` plans and opens a seat for an episode through a
8
+ * transport the host gives it (`httpCompanionTransport`). `CompanionGlyphBar`
9
+ * draws one glyph per agent with a seat, and the host shows the opener of the
10
+ * one pressed.
11
+ *
12
+ * Data and a transport in, intent out. No component holds a URL, a token or a
13
+ * chronicle root, and none decides who may hear a take or open a seat: the host
14
+ * decides, and passes or withholds. `@miadi/companion-ui/node` reads the files.
15
+ *
16
+ * The React modules are client modules. A server component imports the data from
17
+ * `@miadi/companion-ui/thread` and `@miadi/companion-ui/seat`, which hold no React.
18
+ */
19
+ export { COMPANION_VOICE_SOURCE, buildCompanionThread, isCompanionVoice, personaLabel, seatOfSession, speakable, stampOf, takeOf, type CompanionFeedback, type CompanionRelated, type CompanionReply, type CompanionReplyTurn, type CompanionTake, type CompanionTakeTurn, type CompanionThread, type CompanionTurn, type CompanionVoice, } from "./thread.js";
20
+ export { COMPANION_SEATS, LISTENING, NOTHING_TO_RUN, companionSessionName, httpCompanionTransport, sayFault, sayPlan, seatLabel, type CompanionAnswer, type CompanionOpenRequest, type CompanionPlan, type CompanionTransport, } from "./seat.js";
21
+ export { COMPANION_THEME, CompanionCard, CompanionDialogue, CompanionTurnView, type CompanionCardProps, type CompanionDialogueProps, type CompanionLink, type CompanionTheme, type CompanionTurnOptions, type CompanionTurnViewProps, } from "./dialogue.js";
22
+ export { CompanionOpener, OPENER_THEME, type CompanionOpenerProps, type CompanionOpenerTheme } from "./opener.js";
23
+ export { CompanionGlyphBar, seatAgents, type CompanionAgent, type CompanionGlyphBarProps } from "./glyphs.js";
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,eAAe,EACf,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACjH,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @miadi/companion-ui — an episode's companion seat, as React.
3
+ *
4
+ * - The conversation: `buildCompanionThread` joins the person's takes, the seat's
5
+ * replies and the voices cut from them; `CompanionDialogue` shows it with each
6
+ * turn's playback; `CompanionCard` is the short form an episode room shows.
7
+ * - The seat: `CompanionOpener` plans and opens a seat for an episode through a
8
+ * transport the host gives it (`httpCompanionTransport`). `CompanionGlyphBar`
9
+ * draws one glyph per agent with a seat, and the host shows the opener of the
10
+ * one pressed.
11
+ *
12
+ * Data and a transport in, intent out. No component holds a URL, a token or a
13
+ * chronicle root, and none decides who may hear a take or open a seat: the host
14
+ * decides, and passes or withholds. `@miadi/companion-ui/node` reads the files.
15
+ *
16
+ * The React modules are client modules. A server component imports the data from
17
+ * `@miadi/companion-ui/thread` and `@miadi/companion-ui/seat`, which hold no React.
18
+ */
19
+ export { COMPANION_VOICE_SOURCE, buildCompanionThread, isCompanionVoice, personaLabel, seatOfSession, speakable, stampOf, takeOf, } from "./thread.js";
20
+ export { COMPANION_SEATS, LISTENING, NOTHING_TO_RUN, companionSessionName, httpCompanionTransport, sayFault, sayPlan, seatLabel, } from "./seat.js";
21
+ export { COMPANION_THEME, CompanionCard, CompanionDialogue, CompanionTurnView, } from "./dialogue.js";
22
+ export { CompanionOpener, OPENER_THEME } from "./opener.js";
23
+ export { CompanionGlyphBar, seatAgents } from "./glyphs.js";
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,OAAO,EACP,MAAM,GAUP,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,eAAe,EACf,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,QAAQ,EACR,OAAO,EACP,SAAS,GAKV,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAOlB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAwD,MAAM,aAAa,CAAA;AACjH,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAoD,MAAM,aAAa,CAAA"}
package/dist/node.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `@miadi/companion-ui/node` — reads what the companion wrote, on the host that holds it.
3
+ *
4
+ * - Takes are capture bundles in the episode folder: `captures/<take>/capture.json`
5
+ * (`miadi.episode-capture.v1`) and `transcription_<take>_EN.txt` beside it. Only the
6
+ * descriptor and the transcript are read, never the audio and never a digest, so a
7
+ * room with twenty takes of twenty megabytes stays quick.
8
+ * - Replies are the companion phone page's records, one JSON line per reply in
9
+ * `<state>/replies/<episode>.jsonl`, with the person's thumbs in
10
+ * `<state>/replies/feedback/<episode>.jsonl` (jgwill/miadi-orchestration-kit,
11
+ * `claude/mia-episode-companion/phone-capture`). Only id, take, text, seat, session,
12
+ * time, related cards and the thumb leave this module. The reply's origin (user, host,
13
+ * pane, cwd) and its loop record stay on the host.
14
+ * - Forks are the episode's `branches/<name>/` folders that hold a brief: the trunk
15
+ * seat writes the brief when it forks a session to work a branch.
16
+ *
17
+ * Every reader answers an empty list when its folder or file is absent or unreadable.
18
+ */
19
+ import type { CompanionReply, CompanionTake } from "./thread.js";
20
+ /** The takes filed in one episode folder, oldest first. */
21
+ export declare function readCompanionTakes(episodeDir: string): CompanionTake[];
22
+ /**
23
+ * Where the companion phone page keeps its replies: `MIADI_PHONE_CAPTURE_STATE_DIR`,
24
+ * else `$XDG_STATE_HOME/miadi-phone-capture`, else `~/.local/state/miadi-phone-capture`,
25
+ * the same order the page itself reads, plus `/replies`.
26
+ */
27
+ export declare function companionRepliesDir(env?: NodeJS.ProcessEnv, home?: string): string;
28
+ /** One episode's replies with the person's latest thumb on each, oldest first. */
29
+ export declare function readCompanionReplies(repliesDir: string, episode: string): CompanionReply[];
30
+ export interface CompanionFork {
31
+ /** The branch folder's name: `plot-threads`. */
32
+ name: string;
33
+ /** Its files, relative to the episode folder, the brief first. */
34
+ brief: string;
35
+ /** The latest report, when the fork returned one. */
36
+ report?: string;
37
+ }
38
+ /** The forks the companion drove, read from the episode's `branches/<name>/` folders that hold a brief. */
39
+ export declare function readCompanionForks(episodeDir: string): CompanionFork[];
40
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,KAAK,EAAuC,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAkBrG,2DAA2D;AAC3D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,EAAE,CA4CtE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAI1G;AA+BD,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CA8B1F;AAED,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAA;IACb,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,2GAA2G;AAC3G,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,EAAE,CA+BtE"}