@vibefield/rosetta-room 0.1.6 → 0.1.8
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 +29 -2
- package/dist/components/Transcript.js +8 -2
- package/dist/components/transcript/Attachments.d.ts +2 -0
- package/dist/components/transcript/Attachments.js +35 -10
- package/dist/components/transcript/AuthoredMessage.js +2 -1
- package/dist/components/transcript/DayPill.d.ts +8 -4
- package/dist/components/transcript/DayPill.js +13 -12
- package/dist/components/transcript/Document.js +8 -2
- package/dist/components/transcript/PromptJump.d.ts +14 -0
- package/dist/components/transcript/PromptJump.js +116 -0
- package/dist/components/transcript/VideoTile.d.ts +28 -0
- package/dist/components/transcript/VideoTile.js +99 -0
- package/dist/components/transcript/attachment-file-source.d.ts +9 -1
- package/dist/components/transcript/attachment-file-source.js +9 -1
- package/dist/components/transcript/document-model.js +6 -4
- package/dist/components/transcript/video-source.d.ts +39 -0
- package/dist/components/transcript/video-source.js +110 -0
- package/dist/components/transcript/viewer-day.d.ts +7 -0
- package/dist/components/transcript/viewer-day.js +44 -0
- package/dist/fixtures/index.d.ts +2 -1
- package/dist/fixtures/index.js +53 -4
- package/dist/lib/image-media.d.ts +5 -0
- package/dist/lib/image-media.js +17 -0
- package/dist/lib/transcript/images.d.ts +6 -2
- package/dist/lib/transcript/images.js +10 -4
- package/dist/lib/transcript/index.d.ts +3 -1
- package/dist/lib/transcript/index.js +2 -1
- package/dist/lib/transcript/prompt-jump.d.ts +30 -0
- package/dist/lib/transcript/prompt-jump.js +65 -0
- package/dist/lib/transcript/sittings.d.ts +26 -0
- package/dist/lib/transcript/sittings.js +46 -1
- package/dist/ports.d.ts +15 -1
- package/dist/styles/attachments.css +13 -0
- package/dist/styles/room.css +18 -0
- package/package.json +2 -2
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { useMemo } from "react";
|
|
10
10
|
import { useReadingSession, useRoom } from "../../room-context.js";
|
|
11
11
|
import { resolveKind } from "../file-viewer/index.js";
|
|
12
|
-
import { isRecordedImageAsset } from "../../lib/image-media.js";
|
|
12
|
+
import { isRecordedImageAsset, isRecordedVideoAsset } from "../../lib/image-media.js";
|
|
13
13
|
const EXTENSION_BY_MEDIA_TYPE = new Map([
|
|
14
14
|
["image/png", "png"],
|
|
15
15
|
["image/jpeg", "jpg"],
|
|
@@ -45,6 +45,8 @@ export function createAttachmentReader(assets, readAsset) {
|
|
|
45
45
|
return null;
|
|
46
46
|
if (fact.kind === "image" && !isRecordedImageAsset(source.asset))
|
|
47
47
|
return null;
|
|
48
|
+
if (fact.kind === "video" && !isRecordedVideoAsset(source.asset))
|
|
49
|
+
return null;
|
|
48
50
|
return assets.attachmentAssetUrl(source.asset);
|
|
49
51
|
}
|
|
50
52
|
function imageResource(fact) {
|
|
@@ -54,6 +56,10 @@ export function createAttachmentReader(assets, readAsset) {
|
|
|
54
56
|
return null;
|
|
55
57
|
return imageOf(assets, asset, fact.ref?.dimensions?.width, fact.ref?.dimensions?.height);
|
|
56
58
|
}
|
|
59
|
+
function videoAsset(fact) {
|
|
60
|
+
const source = fact.ref?.source;
|
|
61
|
+
return fact.kind === "video" && source?.type === "asset" && assetUrl(fact) !== null ? source.asset : null;
|
|
62
|
+
}
|
|
57
63
|
function handleFor(fact) {
|
|
58
64
|
const source = fact.ref?.source;
|
|
59
65
|
const url = assetUrl(fact);
|
|
@@ -84,6 +90,8 @@ export function createAttachmentReader(assets, readAsset) {
|
|
|
84
90
|
return {
|
|
85
91
|
assetUrl,
|
|
86
92
|
imageResource,
|
|
93
|
+
videoAsset,
|
|
94
|
+
mediaAssetUrl: assets.mediaAssetUrl === undefined ? undefined : (asset) => assets.mediaAssetUrl?.(asset) ?? null,
|
|
87
95
|
handleFor,
|
|
88
96
|
canOpen: (fact) => fact.kind === "image" && handleFor(fact) !== null,
|
|
89
97
|
fileSource,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// so a jump is a real absence — D33's data gap, stated rather than
|
|
15
15
|
// silently closed over.
|
|
16
16
|
import { useMemo } from "react";
|
|
17
|
-
import { dayList, documentTurns, sittings } from "../../lib/transcript/index.js";
|
|
17
|
+
import { calendarDayKey, dayList, documentTurns, sittings } from "../../lib/transcript/index.js";
|
|
18
18
|
import { documentPlan } from "./document-plan.js";
|
|
19
19
|
function buildRepresentatives(turns) {
|
|
20
20
|
const map = new Map();
|
|
@@ -91,14 +91,16 @@ export function useTranscriptModel(rows, session, homeDirectory, now, options =
|
|
|
91
91
|
const cwd = session?.cwd ?? null;
|
|
92
92
|
const sharedKey = [...(options.sharedCollaborationSessionIds ?? [])].sort().join("\u0000");
|
|
93
93
|
const cutKey = [...(options.cutBefore ?? [])].sort().join("\u0000");
|
|
94
|
+
const day = calendarDayKey(now);
|
|
94
95
|
return useMemo(() => {
|
|
95
96
|
const sharedCollaborationSessionIds = new Set(sharedKey === "" ? [] : sharedKey.split("\u0000"));
|
|
96
97
|
return transcriptModel(rows, session, homeDirectory, now, {
|
|
97
98
|
...options,
|
|
98
99
|
sharedCollaborationSessionIds,
|
|
99
100
|
});
|
|
100
|
-
// `now` only names the day a stamp falls in
|
|
101
|
-
// document
|
|
101
|
+
// `now` only names the day a stamp falls in, so the memo keys on that day:
|
|
102
|
+
// the document is re-derived when the viewer's day turns (a pill's words
|
|
103
|
+
// are the drawing's) and never on a clock tick.
|
|
102
104
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
-
}, [rows, cwd, homeDirectory, sharedKey, cutKey]);
|
|
105
|
+
}, [rows, cwd, homeDirectory, sharedKey, cutKey, day]);
|
|
104
106
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AssetRef } from "@vibefield/rosetta-protocol";
|
|
2
|
+
import type { AssetUrl } from "../../ports.js";
|
|
3
|
+
export type VideoState = {
|
|
4
|
+
readonly phase: "idle";
|
|
5
|
+
} | {
|
|
6
|
+
readonly phase: "loading";
|
|
7
|
+
}
|
|
8
|
+
/** `from` says whose address plays: the host's, or the bytes read here. */
|
|
9
|
+
| {
|
|
10
|
+
readonly phase: "ready";
|
|
11
|
+
readonly url: string;
|
|
12
|
+
readonly from: "host" | "bytes";
|
|
13
|
+
} | {
|
|
14
|
+
readonly phase: "failed";
|
|
15
|
+
};
|
|
16
|
+
export declare const IDLE_VIDEO: VideoState;
|
|
17
|
+
export interface VideoSourceDoors {
|
|
18
|
+
/** The host's address for a `<video src>`; absent on a host that offers none. */
|
|
19
|
+
readonly mediaAssetUrl?: ((asset: AssetRef) => AssetUrl) | undefined;
|
|
20
|
+
/** The member's bytes, through the reading session's client. */
|
|
21
|
+
readonly readAsset: (asset: AssetRef, signal: AbortSignal) => Promise<Uint8Array>;
|
|
22
|
+
readonly createObjectURL: (bytes: Uint8Array, mediaType: string) => string;
|
|
23
|
+
readonly revokeObjectURL: (url: string) => void;
|
|
24
|
+
/** Every state after the first, in order. Never called after `dispose`. */
|
|
25
|
+
readonly onChange?: ((state: VideoState) => void) | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface VideoSource {
|
|
28
|
+
state(): VideoState;
|
|
29
|
+
/** The reader asked to play, or to try again after a failure. A press while
|
|
30
|
+
* loading or ready is nothing. */
|
|
31
|
+
play(): void;
|
|
32
|
+
/** The element could not load or decode `url`. The host's address falls
|
|
33
|
+
* back to the bytes; the bytes' own failure is the failed face. A report
|
|
34
|
+
* about an address that is no longer the current one is nothing. */
|
|
35
|
+
elementFailed(url: string): void;
|
|
36
|
+
/** Abort a read in flight and revoke any object URL made here. */
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function createVideoSource(asset: AssetRef, doors: VideoSourceDoors): VideoSource;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export const IDLE_VIDEO = { phase: "idle" };
|
|
2
|
+
export function createVideoSource(asset, doors) {
|
|
3
|
+
let state = IDLE_VIDEO;
|
|
4
|
+
let disposed = false;
|
|
5
|
+
// Each press is its own run: an answer that arrives for an older run, or
|
|
6
|
+
// after disposal, is dropped.
|
|
7
|
+
let run = 0;
|
|
8
|
+
let reading = null;
|
|
9
|
+
let objectUrl = null;
|
|
10
|
+
const set = (next) => {
|
|
11
|
+
state = next;
|
|
12
|
+
doors.onChange?.(next);
|
|
13
|
+
};
|
|
14
|
+
const current = (id) => !disposed && id === run;
|
|
15
|
+
const release = () => {
|
|
16
|
+
if (objectUrl === null)
|
|
17
|
+
return;
|
|
18
|
+
const url = objectUrl;
|
|
19
|
+
objectUrl = null;
|
|
20
|
+
doors.revokeObjectURL(url);
|
|
21
|
+
};
|
|
22
|
+
function readBytes(id) {
|
|
23
|
+
const controller = new AbortController();
|
|
24
|
+
reading = controller;
|
|
25
|
+
if (state.phase !== "loading")
|
|
26
|
+
set({ phase: "loading" });
|
|
27
|
+
const settle = () => {
|
|
28
|
+
if (reading === controller)
|
|
29
|
+
reading = null;
|
|
30
|
+
return current(id);
|
|
31
|
+
};
|
|
32
|
+
let read;
|
|
33
|
+
try {
|
|
34
|
+
read = Promise.resolve(doors.readAsset(asset, controller.signal));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
read = Promise.reject(error);
|
|
38
|
+
}
|
|
39
|
+
read.then((bytes) => {
|
|
40
|
+
if (!settle())
|
|
41
|
+
return;
|
|
42
|
+
try {
|
|
43
|
+
objectUrl = doors.createObjectURL(bytes, asset.media_type);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
set({ phase: "failed" });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
set({ phase: "ready", url: objectUrl, from: "bytes" });
|
|
50
|
+
}, () => {
|
|
51
|
+
if (settle())
|
|
52
|
+
set({ phase: "failed" });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
state: () => state,
|
|
57
|
+
play() {
|
|
58
|
+
if (disposed || state.phase === "loading" || state.phase === "ready")
|
|
59
|
+
return;
|
|
60
|
+
const id = (run += 1);
|
|
61
|
+
release();
|
|
62
|
+
let answer = null;
|
|
63
|
+
try {
|
|
64
|
+
if (doors.mediaAssetUrl !== undefined)
|
|
65
|
+
answer = doors.mediaAssetUrl(asset);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
answer = null;
|
|
69
|
+
}
|
|
70
|
+
if (typeof answer === "string" && answer !== "") {
|
|
71
|
+
set({ phase: "ready", url: answer, from: "host" });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (answer === null || typeof answer === "string") {
|
|
75
|
+
readBytes(id);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
set({ phase: "loading" });
|
|
79
|
+
Promise.resolve(answer).then((url) => {
|
|
80
|
+
if (!current(id))
|
|
81
|
+
return;
|
|
82
|
+
if (typeof url === "string" && url !== "")
|
|
83
|
+
set({ phase: "ready", url, from: "host" });
|
|
84
|
+
else
|
|
85
|
+
readBytes(id);
|
|
86
|
+
}, () => {
|
|
87
|
+
if (current(id))
|
|
88
|
+
readBytes(id);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
elementFailed(url) {
|
|
92
|
+
if (disposed || state.phase !== "ready" || state.url !== url)
|
|
93
|
+
return;
|
|
94
|
+
if (state.from === "host") {
|
|
95
|
+
readBytes(run);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
release();
|
|
99
|
+
set({ phase: "failed" });
|
|
100
|
+
},
|
|
101
|
+
dispose() {
|
|
102
|
+
if (disposed)
|
|
103
|
+
return;
|
|
104
|
+
disposed = true;
|
|
105
|
+
reading?.abort();
|
|
106
|
+
reading = null;
|
|
107
|
+
release();
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ViewerDay {
|
|
2
|
+
/** The clock as read when the viewer's current day began for this document. */
|
|
3
|
+
readonly now: number;
|
|
4
|
+
/** `YYYY-MM-DD`, viewer-local: what a memo over the document keys on. */
|
|
5
|
+
readonly dayKey: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useViewerDay(): ViewerDay;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The transcript's clock (§07). A pill's words are made when
|
|
2
|
+
// the document is drawn, by the viewer's own calendar days — so a document left
|
|
3
|
+
// open over midnight is drawn again at midnight, and a pill read today and
|
|
4
|
+
// looked at tomorrow says tomorrow's words.
|
|
5
|
+
//
|
|
6
|
+
// The clock is re-read at the viewer's next midnight (one timer, re-armed each
|
|
7
|
+
// read) and whenever the window comes back (`focus`, `visibilitychange`), in
|
|
8
|
+
// case the timer slept with the machine. The value changes only when the DAY
|
|
9
|
+
// does, so a document keyed by it is re-derived once a day, never per tick.
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import { calendarDayKey, msToNextViewerDay } from "../../lib/transcript/index.js";
|
|
12
|
+
/** A timer this far past midnight reads the new day, not the old one's last instant. */
|
|
13
|
+
const PAST_MIDNIGHT_MS = 1_000;
|
|
14
|
+
function readViewerDay() {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
return { now, dayKey: calendarDayKey(now) };
|
|
17
|
+
}
|
|
18
|
+
export function useViewerDay() {
|
|
19
|
+
const [day, setDay] = useState(readViewerDay);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let timer;
|
|
22
|
+
const refresh = () => {
|
|
23
|
+
const read = readViewerDay();
|
|
24
|
+
setDay((current) => (current.dayKey === read.dayKey ? current : read));
|
|
25
|
+
if (timer !== undefined)
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
timer = setTimeout(refresh, msToNextViewerDay(read.now) + PAST_MIDNIGHT_MS);
|
|
28
|
+
};
|
|
29
|
+
const onVisibility = () => {
|
|
30
|
+
if (document.visibilityState === "visible")
|
|
31
|
+
refresh();
|
|
32
|
+
};
|
|
33
|
+
refresh();
|
|
34
|
+
window.addEventListener("focus", refresh);
|
|
35
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
36
|
+
return () => {
|
|
37
|
+
if (timer !== undefined)
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
window.removeEventListener("focus", refresh);
|
|
40
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
return day;
|
|
44
|
+
}
|
package/dist/fixtures/index.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export interface RoomDemo {
|
|
|
12
12
|
readonly timelines: ReadonlyMap<string, readonly TimelineEntry[]>;
|
|
13
13
|
}
|
|
14
14
|
export declare function createRoomDemo(now?: number): RoomDemo;
|
|
15
|
-
/** The demo's addresses: every stored image is a drawn tile, inline.
|
|
15
|
+
/** The demo's addresses: every stored image is a drawn tile, inline. It
|
|
16
|
+
* offers no `mediaAssetUrl`: a video's bytes are read through the session. */
|
|
16
17
|
export declare function demoAssets(): AssetSource;
|
|
17
18
|
/** Ports over the demo: a catalog, sessions and asset addresses. No host —
|
|
18
19
|
* a host that is a desktop adds its own `HostPort`. */
|
package/dist/fixtures/index.js
CHANGED
|
@@ -74,6 +74,24 @@ function original(id, seed, name, width, height) {
|
|
|
74
74
|
source: { type: "asset", asset }, dimensions: { width, height }, message_ranges: [],
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
+
/** A video an agent sent and ingestion captured: one recorded member, played
|
|
78
|
+
* from its own bytes once the reader asks. No poster, no rendition map. */
|
|
79
|
+
function video(id, seed, name, width, height, byteLen) {
|
|
80
|
+
const digest = digestOf(seed);
|
|
81
|
+
const asset = { url: `/api/assets/${digest}.mp4`, digest, media_type: "video/mp4", byte_len: byteLen };
|
|
82
|
+
return {
|
|
83
|
+
id, kind: "video", label: null, name, media_type: asset.media_type, byte_len: asset.byte_len,
|
|
84
|
+
source: { type: "asset", asset }, dimensions: { width, height }, message_ranges: [],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** A video that was sent but not captured: the record keeps its path, its
|
|
88
|
+
* declared type and its size, and no bytes. */
|
|
89
|
+
function uncapturedVideo(id, path, mediaType, byteLen) {
|
|
90
|
+
return {
|
|
91
|
+
id, kind: "video", label: null, name: path.slice(path.lastIndexOf("/") + 1), media_type: mediaType, byte_len: byteLen,
|
|
92
|
+
source: { type: "reference", reference: { type: "file", path, resolved: true } }, dimensions: null, message_ranges: [],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
77
95
|
function transcript(sessionId, startedAt) {
|
|
78
96
|
const rows = [];
|
|
79
97
|
const add = (body, kind, model = null) => {
|
|
@@ -90,11 +108,11 @@ function transcript(sessionId, startedAt) {
|
|
|
90
108
|
rows,
|
|
91
109
|
user: (text, attachments = []) => add({ type: "user", text: { type: "inline", text }, attachments }, "human_turn"),
|
|
92
110
|
agent: (text) => add({ type: "agent", text: { type: "inline", text }, attachments: [], citations: [] }, "agent_cycle", "claude-opus-5-5"),
|
|
93
|
-
tool: (name, action, status = "succeeded") => add({ type: "tool_use", tool: {
|
|
111
|
+
tool: (name, action, status = "succeeded", attachments = []) => add({ type: "tool_use", tool: {
|
|
94
112
|
correlation: { key: `${sessionId}-k${rows.length + 1}`, derivation: "native_id" },
|
|
95
113
|
native: { id: null, namespace: null, name, provider: null },
|
|
96
114
|
status: { value: status, basis: "native_state" },
|
|
97
|
-
action, attachments
|
|
115
|
+
action, attachments, failure: null, timing: null,
|
|
98
116
|
} }, "agent_cycle"),
|
|
99
117
|
};
|
|
100
118
|
}
|
|
@@ -106,6 +124,10 @@ const shell = (command, finished = true) => ({
|
|
|
106
124
|
type: "shell", command: { type: "inline", text: command }, source_truncated: false, cwd: null, timeout_ms: null,
|
|
107
125
|
background: false, outcome: finished ? { exit_code: 0, signal: null, process_id: null } : null,
|
|
108
126
|
});
|
|
127
|
+
const send = (paths, caption) => ({
|
|
128
|
+
type: "artifact", operation: "send", artifact_kind: "file", name: null, description: { type: "inline", text: caption },
|
|
129
|
+
resources: paths.map((path) => ({ type: "file", path, resolved: true })), media: null,
|
|
130
|
+
});
|
|
109
131
|
/* ── the demo ───────────────────────────────────────────────────────────── */
|
|
110
132
|
export function createRoomDemo(now = Date.now()) {
|
|
111
133
|
const runtimes = RUNTIMES.map(([id, kind]) => ({
|
|
@@ -179,6 +201,14 @@ export function createRoomDemo(now = Date.now()) {
|
|
|
179
201
|
two.user("Extract the room into a package that dials nothing.");
|
|
180
202
|
two.agent("The room reads four ports now: the catalog, one session's body, the desktop and the asset source.");
|
|
181
203
|
two.agent("rosetta's own app is the first host, over its one client.");
|
|
204
|
+
// Two recordings the agent sent: one captured, played in place on a press;
|
|
205
|
+
// one whose file was gone before it could be captured.
|
|
206
|
+
const recordings = ["/Users/demo/Projects/rosetta/work/room-walkthrough.mp4", "/Users/demo/Projects/rosetta/work/before-the-split.mov"];
|
|
207
|
+
two.tool("SendUserFile", send(recordings, "The room over the demo ports, and the app before the split"), "succeeded", [
|
|
208
|
+
video("1", "room-walkthrough", "room-walkthrough.mp4", 1920, 1080, 3_562_144),
|
|
209
|
+
uncapturedVideo("2", recordings[1], "video/quicktime", 11_482_112),
|
|
210
|
+
]);
|
|
211
|
+
two.agent("Two recordings are attached: the room over the demo ports, and the app before the split.");
|
|
182
212
|
timelines.set("s8", two.rows);
|
|
183
213
|
const status = {
|
|
184
214
|
canonicalReady: true, searchReadiness: "ready", searchProgress: null,
|
|
@@ -196,7 +226,25 @@ function placeholderSvg(digest) {
|
|
|
196
226
|
const hue = Number.parseInt(digest.slice(0, 2), 16) * 1.4;
|
|
197
227
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 10"><rect width="16" height="10" fill="hsl(${hue.toFixed(0)} 55% 55%)"/><circle cx="11" cy="3.5" r="1.6" fill="hsl(${hue.toFixed(0)} 60% 85%)"/><path d="M0 10 6 4l4 4 2-2 4 4z" fill="hsl(${hue.toFixed(0)} 45% 35%)"/></svg>`;
|
|
198
228
|
}
|
|
199
|
-
/**
|
|
229
|
+
/** What a video member reads as: the demo commits no encoded video, so this
|
|
230
|
+
* is a header only (an `ftyp` box, then a `free` box of padding). No browser
|
|
231
|
+
* can play it, and a harness that presses play sees the "could not play" face. */
|
|
232
|
+
function headerOnlyMp4() {
|
|
233
|
+
const bytes = new Uint8Array(64);
|
|
234
|
+
const text = (at, value) => { for (let i = 0; i < value.length; i += 1)
|
|
235
|
+
bytes[at + i] = value.charCodeAt(i); };
|
|
236
|
+
bytes[3] = 24;
|
|
237
|
+
text(4, "ftyp");
|
|
238
|
+
text(8, "isom");
|
|
239
|
+
bytes[14] = 2;
|
|
240
|
+
text(16, "isom");
|
|
241
|
+
text(20, "mp41");
|
|
242
|
+
bytes[27] = 40;
|
|
243
|
+
text(28, "free");
|
|
244
|
+
return bytes;
|
|
245
|
+
}
|
|
246
|
+
/** The demo's addresses: every stored image is a drawn tile, inline. It
|
|
247
|
+
* offers no `mediaAssetUrl`: a video's bytes are read through the session. */
|
|
200
248
|
export function demoAssets() {
|
|
201
249
|
return {
|
|
202
250
|
imageAssetUrl: (asset) => `data:image/svg+xml,${encodeURIComponent(placeholderSvg(asset.digest))}`,
|
|
@@ -240,7 +288,8 @@ function demoSessionClient(demo) {
|
|
|
240
288
|
readFileTarget: never,
|
|
241
289
|
readPlan: never,
|
|
242
290
|
readTextAsset: never,
|
|
243
|
-
readAsset: async (asset) =>
|
|
291
|
+
readAsset: async (asset) => asset.media_type.startsWith("video/") ? headerOnlyMp4()
|
|
292
|
+
: new TextEncoder().encode(placeholderSvg(asset.digest)),
|
|
244
293
|
};
|
|
245
294
|
}
|
|
246
295
|
/** The demo's catalog: rows on subscribe, figures by project, and a search
|
|
@@ -14,3 +14,8 @@ export declare function isLegacyImageBundle(asset: AssetRef): boolean;
|
|
|
14
14
|
* WebP renditions (`AssetSource.imageAssetUrl`); the room never draws the
|
|
15
15
|
* recorded bytes themselves. */
|
|
16
16
|
export declare function isRecordedImageAsset(asset: AssetRef): boolean;
|
|
17
|
+
/** A sent video the room may play: one recorded member,
|
|
18
|
+
* `/api/assets/<digest>.mp4` or `.mov`, with no rendition map. The room never
|
|
19
|
+
* draws it as an image and asks no rendition of it; `VideoTile` plays the
|
|
20
|
+
* member's own bytes once the reader asks. */
|
|
21
|
+
export declare function isRecordedVideoAsset(asset: AssetRef): boolean;
|
package/dist/lib/image-media.js
CHANGED
|
@@ -62,3 +62,20 @@ export function isRecordedImageAsset(asset) {
|
|
|
62
62
|
const extension = recordedImageExtension(asset.media_type);
|
|
63
63
|
return extension !== undefined && isMember(asset, asset.media_type, extension);
|
|
64
64
|
}
|
|
65
|
+
/** The two video containers ingestion records, each with the one extension
|
|
66
|
+
* its content-addressed member name carries. */
|
|
67
|
+
const RECORDED_VIDEO_EXTENSION = new Map([
|
|
68
|
+
["video/mp4", "mp4"],
|
|
69
|
+
["video/quicktime", "mov"],
|
|
70
|
+
]);
|
|
71
|
+
/** A sent video the room may play: one recorded member,
|
|
72
|
+
* `/api/assets/<digest>.mp4` or `.mov`, with no rendition map. The room never
|
|
73
|
+
* draws it as an image and asks no rendition of it; `VideoTile` plays the
|
|
74
|
+
* member's own bytes once the reader asks. */
|
|
75
|
+
export function isRecordedVideoAsset(asset) {
|
|
76
|
+
// A malformed row's missing asset is refused, never a render-time throw.
|
|
77
|
+
if (asset == null || asset.image_variants != null)
|
|
78
|
+
return false;
|
|
79
|
+
const extension = RECORDED_VIDEO_EXTENSION.get(asset.media_type);
|
|
80
|
+
return extension !== undefined && isMember(asset, asset.media_type, extension);
|
|
81
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { TimelineEntry } from "@vibefield/rosetta-protocol";
|
|
2
2
|
import type { AttachmentFact, LedgerMember } from "./turns.js";
|
|
3
|
-
/**
|
|
3
|
+
/** What a run's rail gathers: recorded images, and the videos sent beside them. */
|
|
4
|
+
export declare function isRailMedia(fact: Pick<AttachmentFact, "kind">): boolean;
|
|
5
|
+
/** Keep occurrences in transcript order, including repeated reads of one image
|
|
6
|
+
* and the videos among them. */
|
|
4
7
|
export declare function activityImages(members: readonly LedgerMember[]): AttachmentFact[];
|
|
5
8
|
/** Attachment ids belong to a message, not to the whole transcript. */
|
|
6
9
|
export declare function messageAttachments(row: TimelineEntry): AttachmentFact[];
|
|
7
|
-
/** One rail for every image occurrence in the run, regardless of
|
|
10
|
+
/** One rail for every image and video occurrence in the run, regardless of
|
|
11
|
+
* row type. */
|
|
8
12
|
export declare function timelineImages(rows: readonly TimelineEntry[]): AttachmentFact[];
|
|
@@ -2,6 +2,10 @@ import { projectAction } from "./families.js";
|
|
|
2
2
|
import { readAttachments } from "./turns.js";
|
|
3
3
|
import { resourceLabel, splitPath } from "./vocabulary.js";
|
|
4
4
|
import { isRecordedImageAsset } from "../image-media.js";
|
|
5
|
+
/** What a run's rail gathers: recorded images, and the videos sent beside them. */
|
|
6
|
+
export function isRailMedia(fact) {
|
|
7
|
+
return fact.kind === "image" || fact.kind === "video";
|
|
8
|
+
}
|
|
5
9
|
function resourcePath(resource) {
|
|
6
10
|
const label = resourceLabel(resource);
|
|
7
11
|
return { label, ...splitPath(label), resource };
|
|
@@ -10,7 +14,7 @@ function rowImages(row) {
|
|
|
10
14
|
if (row.body.type !== "tool_use")
|
|
11
15
|
return [];
|
|
12
16
|
const { action, native } = row.body.tool;
|
|
13
|
-
const recorded = messageAttachments(row).filter(
|
|
17
|
+
const recorded = messageAttachments(row).filter(isRailMedia);
|
|
14
18
|
if (!["artifact", "workflow", "structured_output", "external"].includes(action.type))
|
|
15
19
|
return recorded;
|
|
16
20
|
const detail = projectAction(action, native, {}, { sessionId: row.session_id, timelineId: row.timeline_id }).detail;
|
|
@@ -33,7 +37,8 @@ function rowImages(row) {
|
|
|
33
37
|
return readAttachments(null, [ref]).attachments;
|
|
34
38
|
})];
|
|
35
39
|
}
|
|
36
|
-
/** Keep occurrences in transcript order, including repeated reads of one image
|
|
40
|
+
/** Keep occurrences in transcript order, including repeated reads of one image
|
|
41
|
+
* and the videos among them. */
|
|
37
42
|
export function activityImages(members) {
|
|
38
43
|
return members.flatMap(member => member.kind === "line" ? member.line.rows.flatMap(rowImages) : []);
|
|
39
44
|
}
|
|
@@ -46,7 +51,8 @@ export function messageAttachments(row) {
|
|
|
46
51
|
...fact, key: `${row.session_id}:${row.timeline_id}:attachment:${fact.key}`,
|
|
47
52
|
}));
|
|
48
53
|
}
|
|
49
|
-
/** One rail for every image occurrence in the run, regardless of
|
|
54
|
+
/** One rail for every image and video occurrence in the run, regardless of
|
|
55
|
+
* row type. */
|
|
50
56
|
export function timelineImages(rows) {
|
|
51
57
|
const seen = new Set();
|
|
52
58
|
return rows.flatMap(row => {
|
|
@@ -55,6 +61,6 @@ export function timelineImages(rows) {
|
|
|
55
61
|
return [];
|
|
56
62
|
seen.add(identity);
|
|
57
63
|
return row.body.type === "tool_use" ? rowImages(row)
|
|
58
|
-
: messageAttachments(row).filter(
|
|
64
|
+
: messageAttachments(row).filter(isRailMedia);
|
|
59
65
|
});
|
|
60
66
|
}
|
|
@@ -7,9 +7,11 @@ export { FOLD_NAME_LIMIT, RUN_FOLD_THRESHOLD, commandName, ledgerLine, ledgerLin
|
|
|
7
7
|
export type { AttachmentFact, DocumentOptions, LedgerMember, LocalSetting, Prompt, ResponseHead, Segment, Turn, } from "./turns.js";
|
|
8
8
|
export { documentTurns, attachmentMentions, localSetting, readAttachments } from "./turns.js";
|
|
9
9
|
export type { DayEntry, Sitting } from "./sittings.js";
|
|
10
|
-
export { PROMPT_CLUSTER_MS, SITTING_PAUSE_MS, calendarDayKey, dayList, sittingCount, sittingDayLabel, sittings, withinPromptCluster, } from "./sittings.js";
|
|
10
|
+
export { PROMPT_CLUSTER_MS, SITTING_PAUSE_MS, calendarDayKey, clockPillLead, dayList, msToNextViewerDay, sittingCount, sittingDayLabel, sittings, viewerDaysBack, withinPromptCluster, } from "./sittings.js";
|
|
11
11
|
export type { CollaborationStamp, CollaborationTimeBasis, RuntimeProfile, RuntimeProfileBasis, TeamMemberOperation, TeamMemberPresentation, TeamParticipantPresentation, TeamReportWork, TeamChronology, WorkerThreadLinks, } from "./collaboration.js";
|
|
12
12
|
export { isWorkflowOwnedSession, standaloneWorkerSessions, } from "./collaboration.js";
|
|
13
13
|
export type { WorkflowAttemptFact, WorkflowAttemptIndex, WorkflowRuntimeFact, } from "./workflow.js";
|
|
14
14
|
export { workflowAttemptIndex, workflowAttemptsFor, workflowRuntime, workflowWorkerState, } from "./workflow.js";
|
|
15
15
|
export { collaborationStamp, interleaveTeamCollaboration, participantPresentation, runtimeProfile, teamMemberPresentations, teamChronology, teamParticipants, taskBoundedReportWork, teamSessionIds, workerThreadLinks, } from "./collaboration.js";
|
|
16
|
+
export type { PromptJumpPlan } from "./prompt-jump.js";
|
|
17
|
+
export { PROMPT_JUMP_EASE_MS, PROMPT_JUMP_LANDING_PX, jumpMotion, jumpScrollTop, previousMessageTarget, promptJumpPlan, promptJumpShown, settleEase, } from "./prompt-jump.js";
|
|
@@ -2,7 +2,8 @@ export { FAMILY_CLASS, FAMILY_GLYPH, FAMILY_NOUN, FOLD_NOUN, attachmentLabel, ba
|
|
|
2
2
|
export { COMMAND_PREVIEW_CHARACTER_LIMIT, TASK_PREVIEW_LIMIT, commandDirectoryContext, commandPreviewText, diffstatText, projectAction, taskDisplayRows, } from "./families.js";
|
|
3
3
|
export { FOLD_NAME_LIMIT, RUN_FOLD_THRESHOLD, commandName, ledgerLine, ledgerLines, linkedChildSessionIds, runSummary, } from "./ledger.js";
|
|
4
4
|
export { documentTurns, attachmentMentions, localSetting, readAttachments } from "./turns.js";
|
|
5
|
-
export { PROMPT_CLUSTER_MS, SITTING_PAUSE_MS, calendarDayKey, dayList, sittingCount, sittingDayLabel, sittings, withinPromptCluster, } from "./sittings.js";
|
|
5
|
+
export { PROMPT_CLUSTER_MS, SITTING_PAUSE_MS, calendarDayKey, clockPillLead, dayList, msToNextViewerDay, sittingCount, sittingDayLabel, sittings, viewerDaysBack, withinPromptCluster, } from "./sittings.js";
|
|
6
6
|
export { isWorkflowOwnedSession, standaloneWorkerSessions, } from "./collaboration.js";
|
|
7
7
|
export { workflowAttemptIndex, workflowAttemptsFor, workflowRuntime, workflowWorkerState, } from "./workflow.js";
|
|
8
8
|
export { collaborationStamp, interleaveTeamCollaboration, participantPresentation, runtimeProfile, teamMemberPresentations, teamChronology, teamParticipants, taskBoundedReportWork, teamSessionIds, workerThreadLinks, } from "./collaboration.js";
|
|
9
|
+
export { PROMPT_JUMP_EASE_MS, PROMPT_JUMP_LANDING_PX, jumpMotion, jumpScrollTop, previousMessageTarget, promptJumpPlan, promptJumpShown, settleEase, } from "./prompt-jump.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EarlierState } from "./head-state.js";
|
|
2
|
+
/** Where a landed message's top stands: this far under the head. */
|
|
3
|
+
export declare const PROMPT_JUMP_LANDING_PX = 12;
|
|
4
|
+
/** The ease a near jump moves on. */
|
|
5
|
+
export declare const PROMPT_JUMP_EASE_MS = 300;
|
|
6
|
+
/**
|
|
7
|
+
* The index of the nearest own message that begins above the view's top, or
|
|
8
|
+
* null. `tops` are in document order; of two at one top, the earlier.
|
|
9
|
+
*/
|
|
10
|
+
export declare function previousMessageTarget(tops: readonly number[], viewTop: number): number | null;
|
|
11
|
+
/** The scroll offset that stands a message's top 12 under the head, never above the document's top. */
|
|
12
|
+
export declare function jumpScrollTop(scrollTop: number, messageTop: number, viewTop: number): number;
|
|
13
|
+
/** At once when more than a screen away or under Reduce Motion; else the 300 ms ease. */
|
|
14
|
+
export declare function jumpMotion(distance: number, viewHeight: number, reduced: boolean): "instant" | "ease";
|
|
15
|
+
/** Shown while an own message begins above the view, or rows above are not yet read. */
|
|
16
|
+
export declare function promptJumpShown(above: boolean, earlier: EarlierState["kind"]): boolean;
|
|
17
|
+
export interface PromptJumpPlan {
|
|
18
|
+
/** The message gone to, by its place in `tops`; null for the document's top. */
|
|
19
|
+
readonly index: number | null;
|
|
20
|
+
readonly scrollTop: number;
|
|
21
|
+
}
|
|
22
|
+
/** What a press does: a message above, else the document's top while rows above are unread, else nothing. */
|
|
23
|
+
export declare function promptJumpPlan(view: {
|
|
24
|
+
readonly tops: readonly number[];
|
|
25
|
+
readonly viewTop: number;
|
|
26
|
+
readonly scrollTop: number;
|
|
27
|
+
readonly earlier: EarlierState["kind"];
|
|
28
|
+
}): PromptJumpPlan | null;
|
|
29
|
+
/** cubic-bezier(0.22, 1, 0.36, 1) at `x` in [0, 1], solved by bisection (monotone in x). */
|
|
30
|
+
export declare function settleEase(x: number): number;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** Where a landed message's top stands: this far under the head. */
|
|
2
|
+
export const PROMPT_JUMP_LANDING_PX = 12;
|
|
3
|
+
/** The ease a near jump moves on. */
|
|
4
|
+
export const PROMPT_JUMP_EASE_MS = 300;
|
|
5
|
+
/** Half a device pixel: a top at the view's top is in the view, not above it. */
|
|
6
|
+
const AT_THE_TOP_PX = 0.5;
|
|
7
|
+
/**
|
|
8
|
+
* The index of the nearest own message that begins above the view's top, or
|
|
9
|
+
* null. `tops` are in document order; of two at one top, the earlier.
|
|
10
|
+
*/
|
|
11
|
+
export function previousMessageTarget(tops, viewTop) {
|
|
12
|
+
let target = null;
|
|
13
|
+
for (let index = 0; index < tops.length; index += 1) {
|
|
14
|
+
const top = tops[index];
|
|
15
|
+
if (top >= viewTop - AT_THE_TOP_PX)
|
|
16
|
+
continue;
|
|
17
|
+
if (target === null || top > tops[target])
|
|
18
|
+
target = index;
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
}
|
|
22
|
+
/** The scroll offset that stands a message's top 12 under the head, never above the document's top. */
|
|
23
|
+
export function jumpScrollTop(scrollTop, messageTop, viewTop) {
|
|
24
|
+
return Math.max(0, scrollTop + messageTop - viewTop - PROMPT_JUMP_LANDING_PX);
|
|
25
|
+
}
|
|
26
|
+
/** At once when more than a screen away or under Reduce Motion; else the 300 ms ease. */
|
|
27
|
+
export function jumpMotion(distance, viewHeight, reduced) {
|
|
28
|
+
return reduced || Math.abs(distance) > viewHeight ? "instant" : "ease";
|
|
29
|
+
}
|
|
30
|
+
/** Shown while an own message begins above the view, or rows above are not yet read. */
|
|
31
|
+
export function promptJumpShown(above, earlier) {
|
|
32
|
+
return above || earlier !== "none";
|
|
33
|
+
}
|
|
34
|
+
/** What a press does: a message above, else the document's top while rows above are unread, else nothing. */
|
|
35
|
+
export function promptJumpPlan(view) {
|
|
36
|
+
const index = previousMessageTarget(view.tops, view.viewTop);
|
|
37
|
+
if (index !== null) {
|
|
38
|
+
return { index, scrollTop: jumpScrollTop(view.scrollTop, view.tops[index], view.viewTop) };
|
|
39
|
+
}
|
|
40
|
+
return view.earlier === "none" ? null : { index: null, scrollTop: 0 };
|
|
41
|
+
}
|
|
42
|
+
// The room's settle curve (`SETTLE_EASING` in lib/motion.ts), as a function of
|
|
43
|
+
// time: a scroll offset cannot ride a CSS transition.
|
|
44
|
+
const X1 = 0.22;
|
|
45
|
+
const Y1 = 1;
|
|
46
|
+
const X2 = 0.36;
|
|
47
|
+
const Y2 = 1;
|
|
48
|
+
const bezier = (t, a, b) => 3 * (1 - t) * (1 - t) * t * a + 3 * (1 - t) * t * t * b + t * t * t;
|
|
49
|
+
/** cubic-bezier(0.22, 1, 0.36, 1) at `x` in [0, 1], solved by bisection (monotone in x). */
|
|
50
|
+
export function settleEase(x) {
|
|
51
|
+
if (x <= 0)
|
|
52
|
+
return 0;
|
|
53
|
+
if (x >= 1)
|
|
54
|
+
return 1;
|
|
55
|
+
let low = 0;
|
|
56
|
+
let high = 1;
|
|
57
|
+
for (let step = 0; step < 32; step += 1) {
|
|
58
|
+
const middle = (low + high) / 2;
|
|
59
|
+
if (bezier(middle, X1, X2) < x)
|
|
60
|
+
low = middle;
|
|
61
|
+
else
|
|
62
|
+
high = middle;
|
|
63
|
+
}
|
|
64
|
+
return bezier((low + high) / 2, Y1, Y2);
|
|
65
|
+
}
|
|
@@ -21,6 +21,29 @@ export declare function calendarDayKey(timestamp: number): string;
|
|
|
21
21
|
* §07's year rule on top of it so the pill and the session list never disagree.
|
|
22
22
|
*/
|
|
23
23
|
export declare function sittingDayLabel(timestamp: number, now: number): string;
|
|
24
|
+
/**
|
|
25
|
+
* How many of the viewer's calendar days `timestamp` lies before `now`'s: 0 for today, 1 for the day before. Counted
|
|
26
|
+
* between the two days' keys, so a 23- or 25-hour day never moves it. Negative for a stamp ahead of `now` (a clock
|
|
27
|
+
* skew between devices).
|
|
28
|
+
*/
|
|
29
|
+
export declare function viewerDaysBack(timestamp: number, now: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* §07 — a pill that carries a clock says how far back it is. By the viewer's own calendar days, counted from
|
|
32
|
+
* today:
|
|
33
|
+
* - today: the clock alone, `20:21`;
|
|
34
|
+
* - one of the six days before today: the weekday and the clock, `Fri · 20:21`;
|
|
35
|
+
* - earlier: the day and the clock, `Fri 6 Nov · 20:21`, and with its year when it is not this one,
|
|
36
|
+
* `6 Nov 2025 · 20:21`.
|
|
37
|
+
* This holds for every pill with a clock, where the day turned and inside a day alike. A stamp ahead of `now`
|
|
38
|
+
* (a clock skew between devices) takes today's form, never a negative distance's. Six days, not seven: a weekday
|
|
39
|
+
* then never names today's own.
|
|
40
|
+
*/
|
|
41
|
+
export declare function clockPillLead(at: number, now: number): string;
|
|
42
|
+
/**
|
|
43
|
+
* How long until the viewer's next calendar day begins, by the wall clock: the room re-reads its clock then, so a
|
|
44
|
+
* pill's words are tomorrow's tomorrow. 23 or 25 hours across a daylight-saving change, as the wall clock has them.
|
|
45
|
+
*/
|
|
46
|
+
export declare function msToNextViewerDay(now: number): number;
|
|
24
47
|
export interface Sitting {
|
|
25
48
|
/** Stable across renders: the first row's `timeline_id`. */
|
|
26
49
|
readonly key: string;
|
|
@@ -31,6 +54,9 @@ export interface Sitting {
|
|
|
31
54
|
/** The pill's time, drawn only when the reader actually came back: null for
|
|
32
55
|
* the first sitting and for a day that turned without a pause. */
|
|
33
56
|
readonly resumedAt: number | null;
|
|
57
|
+
/** That time's words, by how far back its day is (`clockPillLead`): `20:21`, `Fri · 20:21`,
|
|
58
|
+
* `Fri 6 Nov · 20:21`. Null exactly when `resumedAt` is. */
|
|
59
|
+
readonly clockLabel: string | null;
|
|
34
60
|
/** The silence before this sitting. Null when the cut was a day change with
|
|
35
61
|
* no pause of fifteen minutes or more. */
|
|
36
62
|
readonly pauseMs: number | null;
|