@vibefield/rosetta-room 0.1.2 → 0.1.3
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 +82 -4
- package/dist/HistoryRoom.d.ts +15 -2
- package/dist/HistoryRoom.js +82 -25
- package/dist/TranscriptReader.d.ts +7 -0
- package/dist/TranscriptReader.js +4 -4
- package/dist/components/ColdStart.js +1 -1
- package/dist/components/IngestStatus.d.ts +13 -0
- package/dist/components/IngestStatus.js +39 -3
- package/dist/components/ListActivityNotice.d.ts +9 -1
- package/dist/components/ListActivityNotice.js +9 -2
- package/dist/components/SummaryPanels.d.ts +5 -0
- package/dist/components/SummaryPanels.js +16 -5
- package/dist/components/Transcript.d.ts +5 -0
- package/dist/components/Transcript.js +20 -5
- package/dist/components/artifacts/ArtifactLibrary.d.ts +14 -0
- package/dist/components/artifacts/ArtifactLibrary.js +156 -0
- package/dist/components/artifacts/content.d.ts +8 -0
- package/dist/components/artifacts/content.js +27 -0
- package/dist/components/artifacts/load-all.d.ts +5 -0
- package/dist/components/artifacts/load-all.js +31 -0
- package/dist/components/artifacts/preview.d.ts +4 -0
- package/dist/components/artifacts/preview.js +37 -0
- package/dist/components/artifacts/thumbnails.d.ts +13 -0
- package/dist/components/artifacts/thumbnails.js +43 -0
- package/dist/components/projects/ProjectList.d.ts +9 -3
- package/dist/components/projects/ProjectList.js +3 -3
- package/dist/components/projects/ProjectListItem.d.ts +9 -3
- package/dist/components/projects/ProjectListItem.js +18 -12
- package/dist/components/projects/ProjectsColumn.d.ts +4 -1
- package/dist/components/projects/ProjectsColumn.js +23 -9
- package/dist/components/search/SearchSheet.d.ts +39 -2
- package/dist/components/search/SearchSheet.js +81 -17
- package/dist/components/sessions/SessionList.d.ts +6 -1
- package/dist/components/sessions/SessionList.js +50 -20
- package/dist/components/sessions/SessionListItem.d.ts +3 -1
- package/dist/components/sessions/SessionListItem.js +17 -7
- package/dist/components/sessions/SessionsColumn.d.ts +3 -1
- package/dist/components/sessions/SessionsColumn.js +2 -2
- package/dist/components/sessions/session-display.d.ts +4 -1
- package/dist/components/sessions/session-display.js +13 -2
- package/dist/components/transcript/Attachments.js +6 -1
- package/dist/components/transcript/Document.d.ts +6 -1
- package/dist/components/transcript/Document.js +19 -6
- package/dist/components/transcript/ImportState.d.ts +35 -0
- package/dist/components/transcript/ImportState.js +86 -0
- package/dist/components/transcript/TranscriptLoading.js +15 -5
- package/dist/components/transcript/attachment-file-source.d.ts +2 -0
- package/dist/components/transcript/attachment-file-source.js +6 -6
- package/dist/components/transcript/attachment-gallery.d.ts +2 -1
- package/dist/components/transcript/attachment-gallery.js +2 -1
- package/dist/components/transcript/detail-parts.js +7 -6
- package/dist/components/transcript/timeline-meta-file-source.d.ts +2 -1
- package/dist/components/transcript/timeline-meta-file-source.js +45 -5
- package/dist/components/ui/EmptyState.d.ts +5 -1
- package/dist/components/ui/EmptyState.js +2 -2
- package/dist/components/ui/Meter.d.ts +8 -0
- package/dist/components/ui/Meter.js +9 -0
- package/dist/components/ui/SegmentedControl.d.ts +2 -0
- package/dist/components/ui/SegmentedControl.js +1 -1
- package/dist/components/ui/Veil.d.ts +2 -1
- package/dist/components/ui/Veil.js +9 -2
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/fixtures/cold-import-corpus.d.ts +76 -0
- package/dist/fixtures/cold-import-corpus.js +349 -0
- package/dist/fixtures/cold-import-daemon.d.ts +25 -0
- package/dist/fixtures/cold-import-daemon.js +82 -0
- package/dist/fixtures/cold-import-schedule.d.ts +74 -0
- package/dist/fixtures/cold-import-schedule.js +191 -0
- package/dist/fixtures/cold-import.d.ts +151 -0
- package/dist/fixtures/cold-import.js +786 -0
- package/dist/fixtures/index.d.ts +2 -0
- package/dist/fixtures/index.js +21 -2
- package/dist/lib/activity-order.d.ts +15 -0
- package/dist/lib/activity-order.js +24 -1
- package/dist/lib/conversation-readiness.d.ts +48 -0
- package/dist/lib/conversation-readiness.js +149 -0
- package/dist/lib/figure-order.d.ts +35 -0
- package/dist/lib/figure-order.js +68 -0
- package/dist/lib/hooks.d.ts +32 -10
- package/dist/lib/hooks.js +118 -54
- package/dist/lib/image-media.d.ts +12 -2
- package/dist/lib/image-media.js +40 -6
- package/dist/lib/import-state.d.ts +98 -0
- package/dist/lib/import-state.js +129 -0
- package/dist/lib/ingest-activity.d.ts +51 -0
- package/dist/lib/ingest-activity.js +109 -10
- package/dist/lib/model.d.ts +16 -0
- package/dist/lib/model.js +27 -1
- package/dist/lib/search-sheet.d.ts +43 -0
- package/dist/lib/search-sheet.js +56 -7
- package/dist/lib/session-activity.d.ts +4 -1
- package/dist/lib/session-activity.js +4 -1
- package/dist/lib/title-search.d.ts +82 -0
- package/dist/lib/title-search.js +194 -0
- package/dist/lib/transcript/images.js +2 -2
- package/dist/lib/use-deferred-list-order.d.ts +6 -0
- package/dist/lib/use-deferred-list-order.js +8 -1
- package/dist/lib/use-ingest-activity.d.ts +5 -1
- package/dist/lib/use-ingest-activity.js +54 -18
- package/dist/ports.d.ts +15 -2
- package/dist/styles/artifacts.css +66 -0
- package/dist/styles/history-room.css +1 -0
- package/dist/styles/ingest.css +26 -3
- package/dist/styles/room.css +15 -0
- package/dist/styles/search.css +17 -0
- package/package.json +2 -2
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
// Lazy timeline_meta resources through the room's shared file viewer.
|
|
2
2
|
// The metadata frame carries only safe canonical references; bytes are read
|
|
3
3
|
// after the reader presses a plan or artifact row and then ride on the handle
|
|
4
|
-
// so the viewer never repeats a mutable filesystem read.
|
|
4
|
+
// so the viewer never repeats a mutable filesystem read. A recorded image
|
|
5
|
+
// member is the exception: it is drawn through the host's renditions, as a
|
|
6
|
+
// transcript image is, and its recorded bytes are never read for display.
|
|
7
|
+
import { isRecordedImageAsset, recordedImageExtension } from "../../lib/image-media.js";
|
|
5
8
|
import { resolveKind } from "../file-viewer/index.js";
|
|
9
|
+
import { imageOf } from "./attachment-file-source.js";
|
|
6
10
|
const EXTENSION_BY_MEDIA_TYPE = new Map([
|
|
7
11
|
["image/png", "png"],
|
|
8
12
|
["image/jpeg", "jpg"],
|
|
9
13
|
["image/gif", "gif"],
|
|
10
14
|
["image/webp", "webp"],
|
|
15
|
+
["image/bmp", "bmp"],
|
|
16
|
+
["image/x-icon", "ico"],
|
|
11
17
|
["image/avif", "avif"],
|
|
12
18
|
["image/svg+xml", "svg"],
|
|
13
19
|
["application/json", "json"],
|
|
14
20
|
["text/markdown", "md"],
|
|
15
21
|
["text/plain", "txt"],
|
|
22
|
+
["text/html", "html"],
|
|
16
23
|
]);
|
|
17
24
|
function nameWithType(name, mediaType) {
|
|
18
25
|
if (resolveKind(name).viewer.id !== "binary" || mediaType === null)
|
|
19
26
|
return name;
|
|
20
|
-
const extension = EXTENSION_BY_MEDIA_TYPE.get(mediaType.toLowerCase());
|
|
27
|
+
const extension = EXTENSION_BY_MEDIA_TYPE.get(mediaType.toLowerCase().split(";")[0].trim());
|
|
21
28
|
return extension === undefined ? name : `${name}.${extension}`;
|
|
22
29
|
}
|
|
23
30
|
function handle(key, name, path, bytes) {
|
|
@@ -33,16 +40,49 @@ export async function handleForTimelineMetaPlan(sessions, sessionId, plan) {
|
|
|
33
40
|
const bytes = await sessions.run(sessionId, (client) => client.readPlan(sessionId, plan.source));
|
|
34
41
|
return handle(`timeline-meta:plan:${sessionId}:${plan.id}`, plan.name, null, bytes);
|
|
35
42
|
}
|
|
36
|
-
|
|
43
|
+
/** A recorded image member by its renditions: the name carries the image's
|
|
44
|
+
* own extension so the viewer opens it as an image, and nothing is read. */
|
|
45
|
+
function imageHandle(key, name, asset, extension, assets) {
|
|
46
|
+
return {
|
|
47
|
+
key,
|
|
48
|
+
name: resolveKind(name).viewer.id === "image" ? name : `${name}.${extension}`,
|
|
49
|
+
path: null,
|
|
50
|
+
size: asset.byte_len,
|
|
51
|
+
ref: { type: "timeline-meta-image", image: imageOf(assets, asset) },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export async function handleForTimelineMetaArtifact(sessions, assets, sessionId, artifact) {
|
|
37
55
|
const source = artifact.source;
|
|
56
|
+
if (source.type === "html_publication") {
|
|
57
|
+
if (source.availability !== "captured")
|
|
58
|
+
throw new Error("This artifact's HTML was not captured. Its publication remains in the session.");
|
|
59
|
+
const bytes = await sessions.run(sessionId, (client) => {
|
|
60
|
+
if (!client.readArtifact)
|
|
61
|
+
throw new Error("This host cannot read captured artifacts");
|
|
62
|
+
return client.readArtifact(sessionId, source.publication_id);
|
|
63
|
+
});
|
|
64
|
+
return handle(`html-artifact:${source.publication_id}`, source.filename, null, bytes);
|
|
65
|
+
}
|
|
38
66
|
if (source.type === "timeline_file") {
|
|
39
67
|
const bytes = await sessions.run(sessionId, (client) => client.readFileTarget(sessionId, source.timeline_id, source.target_index));
|
|
40
|
-
return handle(`timeline-meta:artifact:${sessionId}:${artifact.id}`, nameWithType(artifact.name, artifact.media_type), source.path, bytes);
|
|
68
|
+
return handle(`timeline-meta:artifact:${sessionId}:${artifact.id}`, source.path.split(/[\\/]/).at(-1) || nameWithType(artifact.name, artifact.media_type), source.path, bytes);
|
|
69
|
+
}
|
|
70
|
+
const key = `timeline-meta:artifact:${sessionId}:${artifact.id}`;
|
|
71
|
+
const extension = recordedImageExtension(source.asset.media_type);
|
|
72
|
+
if (extension !== undefined) {
|
|
73
|
+
// Recorded image bytes are opened or saved, never drawn.
|
|
74
|
+
if (!isRecordedImageAsset(source.asset))
|
|
75
|
+
throw new Error("This artifact's image is not a recorded member");
|
|
76
|
+
return imageHandle(key, artifact.name, source.asset, extension, assets);
|
|
41
77
|
}
|
|
42
78
|
const bytes = await sessions.run(sessionId, (client) => client.readAsset(source.asset));
|
|
43
|
-
return handle(
|
|
79
|
+
return handle(key, nameWithType(artifact.name, artifact.media_type ?? source.asset.media_type), null, bytes);
|
|
44
80
|
}
|
|
45
81
|
export const timelineMetaFileSource = {
|
|
82
|
+
image(file) {
|
|
83
|
+
const payload = file.ref;
|
|
84
|
+
return payload?.type === "timeline-meta-image" && payload.image ? payload.image : null;
|
|
85
|
+
},
|
|
46
86
|
async read(file, signal) {
|
|
47
87
|
if (signal.aborted)
|
|
48
88
|
throw new DOMException("the file open was cancelled", "AbortError");
|
|
@@ -5,6 +5,10 @@ export interface EmptyStateProps {
|
|
|
5
5
|
readonly children?: ReactNode;
|
|
6
6
|
readonly className?: string;
|
|
7
7
|
readonly style?: CSSProperties;
|
|
8
|
+
/** Inert hooks drawn on the root, such as the face it is
|
|
9
|
+
* (`data-face`, `data-import-face`); see the DOM contract in
|
|
10
|
+
* clients/app/test/dom-contract.test.mjs. */
|
|
11
|
+
readonly [data: `data-${string}`]: string | undefined;
|
|
8
12
|
}
|
|
9
13
|
/** Consistent empty-state copy and spacing for room columns and lists. */
|
|
10
|
-
export declare function EmptyState({ title, description, children, className, style, }: EmptyStateProps): import("react").JSX.Element;
|
|
14
|
+
export declare function EmptyState({ title, description, children, className, style, ...data }: EmptyStateProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/** Consistent empty-state copy and spacing for room columns and lists. */
|
|
3
|
-
export function EmptyState({ title, description, children, className, style, }) {
|
|
3
|
+
export function EmptyState({ title, description, children, className, style, ...data }) {
|
|
4
4
|
const classes = className ? `ah-empty ${className}` : "ah-empty";
|
|
5
|
-
return (_jsxs("div", { className: classes, style: style, children: [children, _jsx("strong", { children: title }), _jsx("p", { children: description })] }));
|
|
5
|
+
return (_jsxs("div", { className: classes, style: style, ...data, children: [children, _jsx("strong", { children: title }), _jsx("p", { children: description })] }));
|
|
6
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface MeterProps {
|
|
2
|
+
/** 0..1 fills the meter (a sliver stays visible); null sweeps. */
|
|
3
|
+
readonly fraction: number | null;
|
|
4
|
+
}
|
|
5
|
+
/** The width a known fraction draws: clamped, and never less than a sliver
|
|
6
|
+
* once something is known, so a started step is never drawn as empty. */
|
|
7
|
+
export declare function meterWidth(fraction: number): string;
|
|
8
|
+
export declare function Meter({ fraction }: MeterProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** The width a known fraction draws: clamped, and never less than a sliver
|
|
3
|
+
* once something is known, so a started step is never drawn as empty. */
|
|
4
|
+
export function meterWidth(fraction) {
|
|
5
|
+
return `${Math.min(100, Math.max(2, fraction * 100)).toFixed(1)}%`;
|
|
6
|
+
}
|
|
7
|
+
export function Meter({ fraction }) {
|
|
8
|
+
return fraction === null ? (_jsx("div", { className: "ah-meter", "data-indeterminate": "", "aria-hidden": "true", children: _jsx("i", {}) })) : (_jsx("div", { className: "ah-meter", "aria-hidden": "true", children: _jsx("i", { style: { width: meterWidth(fraction) } }) }));
|
|
9
|
+
}
|
|
@@ -4,6 +4,8 @@ export interface SegmentedControlOption<Value extends string> {
|
|
|
4
4
|
readonly label: ReactNode;
|
|
5
5
|
readonly accessibleLabel?: string;
|
|
6
6
|
readonly disabled?: boolean;
|
|
7
|
+
/** Why a disabled option waits, as its tooltip. */
|
|
8
|
+
readonly title?: string;
|
|
7
9
|
}
|
|
8
10
|
export interface SegmentedControlProps<Value extends string> {
|
|
9
11
|
readonly value: Value;
|
|
@@ -4,6 +4,6 @@ export function SegmentedControl({ value, options, accessibleLabel, onValueChang
|
|
|
4
4
|
const classes = className ? `ah-seg ${className}` : "ah-seg";
|
|
5
5
|
return (_jsx("div", { className: classes, role: "group", "aria-label": accessibleLabel, children: options.map((option) => {
|
|
6
6
|
const isSelected = option.value === value;
|
|
7
|
-
return (_jsx("button", { type: "button", className: isSelected ? "is-on" : "", "aria-label": option.accessibleLabel, "aria-pressed": isSelected, disabled: option.disabled, onClick: () => onValueChange(option.value), children: option.label }, option.value));
|
|
7
|
+
return (_jsx("button", { type: "button", className: isSelected ? "is-on" : "", "aria-label": option.accessibleLabel, "aria-pressed": isSelected, disabled: option.disabled, title: option.title, onClick: () => onValueChange(option.value), children: option.label }, option.value));
|
|
8
8
|
}) }));
|
|
9
9
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export interface VeilProps {
|
|
2
2
|
/** One label line, e.g. "preparing · 2,314 of 5,912 sessions". */
|
|
3
3
|
readonly label: string;
|
|
4
|
-
/** 0..1 fills the meter; null
|
|
4
|
+
/** 0..1 fills the meter; null sweeps it — an unknown amount is never
|
|
5
|
+
* drawn as a fixed sliver of progress. */
|
|
5
6
|
readonly progress: number | null;
|
|
6
7
|
}
|
|
7
8
|
export declare function Veil({ label, progress }: VeilProps): import("react").JSX.Element;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The veil — what pending looks like. A section that cannot yet vouch for
|
|
3
|
+
// its content frosts over while the content keeps rendering and updating
|
|
4
|
+
// beneath: the motion under the frost IS the progress animation, and the
|
|
5
|
+
// meter is just the caption. Laws (design record, "The Cold Start"):
|
|
6
|
+
// readiness is data, never a timer; only the ready may claim emptiness; a
|
|
7
|
+
// veil overlays and never changes geometry (H-2); and a veil never descends
|
|
8
|
+
// on a scope that has already been ready.
|
|
9
|
+
import { Meter } from "./Meter.js";
|
|
2
10
|
export function Veil({ label, progress }) {
|
|
3
|
-
|
|
4
|
-
return (_jsxs("div", { className: "ah-veil", role: "status", "aria-label": label, children: [_jsx("div", { className: "ah-meter", children: _jsx("i", { style: { width } }) }), _jsx("span", { className: "ah-veil__label", children: label })] }));
|
|
11
|
+
return (_jsxs("div", { className: "ah-veil", role: "status", "aria-label": label, children: [_jsx(Meter, { fraction: progress }), _jsx("span", { className: "ah-veil__label", children: label })] }));
|
|
5
12
|
}
|
|
@@ -10,6 +10,8 @@ export { ListSummaryHeader } from "./ListSummaryHeader.js";
|
|
|
10
10
|
export type { ListSummaryHeaderProps } from "./ListSummaryHeader.js";
|
|
11
11
|
export { ListToolbar } from "./ListToolbar.js";
|
|
12
12
|
export type { ListToolbarProps } from "./ListToolbar.js";
|
|
13
|
+
export { Meter, meterWidth } from "./Meter.js";
|
|
14
|
+
export type { MeterProps } from "./Meter.js";
|
|
13
15
|
export { SummaryMetric } from "./SummaryMetric.js";
|
|
14
16
|
export type { SummaryMetricProps } from "./SummaryMetric.js";
|
|
15
17
|
export { ResultGroupHeader } from "./ResultGroupHeader.js";
|
|
@@ -4,6 +4,7 @@ export { DialogShell } from "./DialogShell.js";
|
|
|
4
4
|
export { EmptyState } from "./EmptyState.js";
|
|
5
5
|
export { ListSummaryHeader } from "./ListSummaryHeader.js";
|
|
6
6
|
export { ListToolbar } from "./ListToolbar.js";
|
|
7
|
+
export { Meter, meterWidth } from "./Meter.js";
|
|
7
8
|
export { SummaryMetric } from "./SummaryMetric.js";
|
|
8
9
|
export { ResultGroupHeader } from "./ResultGroupHeader.js";
|
|
9
10
|
export { SegmentedControl } from "./SegmentedControl.js";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ProjectRow, RuntimeRow, SessionActivity, SessionRow } from "@vibefield/rosetta-protocol";
|
|
2
|
+
/** A tree whose largest source is over this walks the big lane
|
|
3
|
+
* (crates/pipeline/src/closed/walk_order.rs:38). */
|
|
4
|
+
export declare const BIG_SOURCE_BYTES: number;
|
|
5
|
+
export interface ColdCorpusOptions {
|
|
6
|
+
/** The import clock's zero, epoch ms. Every source is older. */
|
|
7
|
+
readonly now: number;
|
|
8
|
+
/** 1 is the MacBook shape; a smaller scale keeps every kind of row. */
|
|
9
|
+
readonly scale?: number;
|
|
10
|
+
readonly seed?: number;
|
|
11
|
+
}
|
|
12
|
+
/** What a session is to the import. */
|
|
13
|
+
export type SessionKind =
|
|
14
|
+
/** A top-level conversation with a transcript: flips with its tree. */
|
|
15
|
+
"root"
|
|
16
|
+
/** A subagent transcript under a root: flips with its tree. */
|
|
17
|
+
| "child"
|
|
18
|
+
/** A metadata-only parent (meta.rs:776): Pending forever, with children. */
|
|
19
|
+
| "placeholder"
|
|
20
|
+
/** Metadata named it, but no streamable source ever rosters it. */
|
|
21
|
+
| "never-rostered-root" | "never-rostered-child";
|
|
22
|
+
/** One root tree as the walk plan sees it (crates/pipeline/src/closed/trees.rs). */
|
|
23
|
+
export interface ColdTree {
|
|
24
|
+
/** The tree's root session id, which is also its key. */
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly runtimeId: string;
|
|
27
|
+
/** The rostered sessions that flip together, root first (unless the root
|
|
28
|
+
* is a placeholder, which no tree flip touches). */
|
|
29
|
+
readonly members: readonly string[];
|
|
30
|
+
/** Streamable bytes, the walk's work. */
|
|
31
|
+
readonly bytes: number;
|
|
32
|
+
/** Its largest source exceeds BIG_SOURCE_BYTES: the big lane. */
|
|
33
|
+
readonly big: boolean;
|
|
34
|
+
/** The recency key: the newest member's mtime (trees.rs:193). */
|
|
35
|
+
readonly recency: number;
|
|
36
|
+
/** A bound or tainted tree: admitted at its producer's close, not on its
|
|
37
|
+
* own (CLAUDE.md, "Bound and tainted trees … are admitted at the
|
|
38
|
+
* producer's close"). */
|
|
39
|
+
readonly bound: boolean;
|
|
40
|
+
/** Its root's source was unclean at capture (missing, unstable or a
|
|
41
|
+
* malformed record): the flip makes the root Streaming, not Indexed
|
|
42
|
+
* (crates/pipeline/src/streamed/trees.rs:226-232, `stream_state(clean)`). */
|
|
43
|
+
readonly dirty: boolean;
|
|
44
|
+
readonly placeholderRoot: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface ColdCorpus {
|
|
47
|
+
readonly now: number;
|
|
48
|
+
readonly scale: number;
|
|
49
|
+
readonly seed: number;
|
|
50
|
+
/** Registry order: claude-code, then codex. */
|
|
51
|
+
readonly runtimes: readonly RuntimeRow[];
|
|
52
|
+
readonly projects: readonly ProjectRow[];
|
|
53
|
+
/** Identity rows as the metadata pass publishes them: Pending, no activity. */
|
|
54
|
+
readonly sessions: readonly SessionRow[];
|
|
55
|
+
readonly kind: ReadonlyMap<string, SessionKind>;
|
|
56
|
+
/** A rostered session's own recorded bounds, public once its tree flips. */
|
|
57
|
+
readonly own: ReadonlyMap<string, SessionActivity>;
|
|
58
|
+
/** Direct children by parent id. */
|
|
59
|
+
readonly children: ReadonlyMap<string, readonly string[]>;
|
|
60
|
+
/** Newest first. */
|
|
61
|
+
readonly trees: readonly ColdTree[];
|
|
62
|
+
/** Rostered session → its tree. */
|
|
63
|
+
readonly treeOf: ReadonlyMap<string, ColdTree>;
|
|
64
|
+
/** Each rostered session's share of its tree's bytes. */
|
|
65
|
+
readonly bytesOf: ReadonlyMap<string, number>;
|
|
66
|
+
/** The topic word every root title starts with. */
|
|
67
|
+
readonly topics: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
/** A 64-hex id, the shape of a rosetta id (a blake3 digest): four rounds of
|
|
70
|
+
* a well-mixed 64-bit string hash (cyrb53's mixing). Like the daemon's
|
|
71
|
+
* digests, ordering by it is unrelated to recency or creation order. */
|
|
72
|
+
export declare function hexId(seed: string): string;
|
|
73
|
+
/** Build the archive. Deterministic in (now, scale, seed); `now` only
|
|
74
|
+
* anchors the times, so every id, count and order is the same in any
|
|
75
|
+
* timezone and on any day. */
|
|
76
|
+
export declare function createColdCorpus(options: ColdCorpusOptions): ColdCorpus;
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
const MINUTE = 60_000;
|
|
2
|
+
const HOUR = 60 * MINUTE;
|
|
3
|
+
const DAY = 24 * HOUR;
|
|
4
|
+
const MB = 1_000_000;
|
|
5
|
+
const MIB = 1024 * 1024;
|
|
6
|
+
/** A tree whose largest source is over this walks the big lane
|
|
7
|
+
* (crates/pipeline/src/closed/walk_order.rs:38). */
|
|
8
|
+
export const BIG_SOURCE_BYTES = 64 * MIB;
|
|
9
|
+
/* ── seeded helpers ─────────────────────────────────────────────────────── */
|
|
10
|
+
/** mulberry32: a small, fast, seeded PRNG. Nothing here reads a clock. */
|
|
11
|
+
function random(seed) {
|
|
12
|
+
let state = seed >>> 0;
|
|
13
|
+
return () => {
|
|
14
|
+
state = (state + 0x6d2b79f5) >>> 0;
|
|
15
|
+
let t = state;
|
|
16
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
17
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
18
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4_294_967_296;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** A 64-hex id, the shape of a rosetta id (a blake3 digest): four rounds of
|
|
22
|
+
* a well-mixed 64-bit string hash (cyrb53's mixing). Like the daemon's
|
|
23
|
+
* digests, ordering by it is unrelated to recency or creation order. */
|
|
24
|
+
export function hexId(seed) {
|
|
25
|
+
let hex = "";
|
|
26
|
+
for (let round = 0; round < 4; round += 1) {
|
|
27
|
+
let h1 = 0xdeadbeef ^ Math.imul(round + 1, 0x9e3779b1);
|
|
28
|
+
let h2 = 0x41c6ce57 ^ Math.imul(round + 1, 0x85ebca6b);
|
|
29
|
+
for (let i = 0; i < seed.length; i += 1) {
|
|
30
|
+
const ch = seed.charCodeAt(i);
|
|
31
|
+
h1 = Math.imul(h1 ^ ch, 2_654_435_761);
|
|
32
|
+
h2 = Math.imul(h2 ^ ch, 1_597_334_677);
|
|
33
|
+
}
|
|
34
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2_246_822_507) ^ Math.imul(h2 ^ (h2 >>> 13), 3_266_489_909);
|
|
35
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2_246_822_507) ^ Math.imul(h1 ^ (h1 >>> 13), 3_266_489_909);
|
|
36
|
+
hex += (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
|
|
37
|
+
}
|
|
38
|
+
return hex;
|
|
39
|
+
}
|
|
40
|
+
function uuidOf(seed) {
|
|
41
|
+
const h = hexId(`native:${seed}`);
|
|
42
|
+
return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20, 32)}`;
|
|
43
|
+
}
|
|
44
|
+
/** A standard normal draw (Box–Muller). */
|
|
45
|
+
function normal(rnd) {
|
|
46
|
+
return Math.sqrt(-2 * Math.log(1 - rnd())) * Math.cos(2 * Math.PI * rnd());
|
|
47
|
+
}
|
|
48
|
+
/** Split `total` over `weights` exactly (largest remainder). */
|
|
49
|
+
function apportion(total, weights) {
|
|
50
|
+
const sum = weights.reduce((a, b) => a + b, 0) || 1;
|
|
51
|
+
const raw = weights.map((w) => (total * w) / sum);
|
|
52
|
+
const out = raw.map(Math.floor);
|
|
53
|
+
let left = total - out.reduce((a, b) => a + b, 0);
|
|
54
|
+
const order = raw.map((r, i) => [r - Math.floor(r), i]).sort((a, b) => b[0] - a[0] || a[1] - b[1]);
|
|
55
|
+
for (let k = 0; left > 0; k = (k + 1) % order.length, left -= 1)
|
|
56
|
+
out[order[k][1]] += 1;
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
const TOPICS = [
|
|
60
|
+
"parser", "ledger", "walker", "sidebar", "charts", "search", "renderer", "importer",
|
|
61
|
+
"schema", "deploy", "billing", "theme", "auth", "cache", "worker", "router",
|
|
62
|
+
"fixtures", "metrics", "layout", "sync", "queue", "export", "budget", "lanes",
|
|
63
|
+
];
|
|
64
|
+
const ACTS = [
|
|
65
|
+
"tidy the walk", "fix the flaky test", "review the diff", "split the module", "trace the stall",
|
|
66
|
+
"draft the plan", "port the screen", "measure the cost", "rename the seam", "check the copy",
|
|
67
|
+
];
|
|
68
|
+
const PROJECT_WORDS = [
|
|
69
|
+
"rosetta", "vibe-field", "puppeteer", "canvas", "ghosttea", "truffle", "atlas", "mille",
|
|
70
|
+
"harbor", "quill", "lantern", "orbit", "pebble", "meadow", "forge", "signal",
|
|
71
|
+
];
|
|
72
|
+
/** Build the archive. Deterministic in (now, scale, seed); `now` only
|
|
73
|
+
* anchors the times, so every id, count and order is the same in any
|
|
74
|
+
* timezone and on any day. */
|
|
75
|
+
export function createColdCorpus(options) {
|
|
76
|
+
const scale = Math.min(1, Math.max(0.01, options.scale ?? 1));
|
|
77
|
+
const seed = options.seed ?? 1;
|
|
78
|
+
const now = options.now;
|
|
79
|
+
const rnd = random(seed * 2_654_435_761);
|
|
80
|
+
const n = (count, least) => Math.max(least, Math.round(count * scale));
|
|
81
|
+
// The trace's counts, scaled (its census line: roots=1139 sessions=8062
|
|
82
|
+
// big=40; its metadata line: sessions=8612 projects=119).
|
|
83
|
+
const treeCount = n(1139, 12);
|
|
84
|
+
const projectCount = n(119, 4);
|
|
85
|
+
const bigCount = n(40, 2);
|
|
86
|
+
const placeholderTrees = n(25, 1);
|
|
87
|
+
const neverRosteredRoots = n(60, 2);
|
|
88
|
+
const boundTrees = n(8, 1);
|
|
89
|
+
const dirtyTrees = n(5, 1);
|
|
90
|
+
const rostered = Math.max(treeCount + 4, n(8062, 0));
|
|
91
|
+
const metadata = Math.max(rostered + placeholderTrees + neverRosteredRoots, n(8612, 0));
|
|
92
|
+
const neverRosteredChildren = metadata - rostered - placeholderTrees - neverRosteredRoots;
|
|
93
|
+
const codexTrees = Math.max(1, Math.round(treeCount * 0.06));
|
|
94
|
+
const runtimes = ["claude-code", "codex"].map((kind) => ({
|
|
95
|
+
id: hexId(`runtime:${seed}:${kind}`), kind, data_root: kind === "codex" ? "~/.codex" : "~/.claude",
|
|
96
|
+
enabled: true, account: null, config: null, skills: null, versions_seen: null, discovered_at: now - 2 * HOUR,
|
|
97
|
+
}));
|
|
98
|
+
// Tree ages: a few trees within a day of the newest, a few more within a
|
|
99
|
+
// week, then a long tail over the year (the trace's census ages).
|
|
100
|
+
const recent = n(13, 3);
|
|
101
|
+
const week = n(14, 2);
|
|
102
|
+
const ages = [];
|
|
103
|
+
for (let i = 0; i < recent; i += 1)
|
|
104
|
+
ages.push(2 * MINUTE + (i / recent) ** 1.6 * 20 * HOUR + rnd() * 10 * MINUTE);
|
|
105
|
+
for (let i = 0; i < week; i += 1)
|
|
106
|
+
ages.push(DAY + ((i + rnd()) / week) * 6 * DAY);
|
|
107
|
+
for (let i = recent + week; i < treeCount; i += 1)
|
|
108
|
+
ages.push(7 * DAY * Math.exp(rnd() * Math.log(60)));
|
|
109
|
+
ages.sort((a, b) => a - b);
|
|
110
|
+
const drafts = ages.map((age, i) => ({
|
|
111
|
+
id: hexId(`tree:${seed}:${i}`), runtime: 0, age, big: false, bytes: 0, project: null,
|
|
112
|
+
children: 0, bound: false, dirty: false, placeholderRoot: false,
|
|
113
|
+
}));
|
|
114
|
+
const pick = (from, to, ok) => {
|
|
115
|
+
for (let tries = 0; tries < 400; tries += 1) {
|
|
116
|
+
const d = drafts[from + Math.floor(rnd() * Math.max(1, to - from))];
|
|
117
|
+
if (d !== undefined && ok(d))
|
|
118
|
+
return d;
|
|
119
|
+
}
|
|
120
|
+
return drafts.slice(from, to).find(ok) ?? null;
|
|
121
|
+
};
|
|
122
|
+
// Big trees: the newest is the giant; the recent ones are mostly big
|
|
123
|
+
// (le1h holds 2.5 GB in 23 files); the rest scatter over the tail.
|
|
124
|
+
drafts[0].big = true;
|
|
125
|
+
const recentBig = Math.min(recent - 2, n(4, 1));
|
|
126
|
+
const weekBig = Math.min(week - 1, n(6, 1));
|
|
127
|
+
for (let k = 0; k < recentBig; k += 1)
|
|
128
|
+
pick(1, recent, (d) => !d.big).big = true;
|
|
129
|
+
for (let k = 0; k < weekBig; k += 1)
|
|
130
|
+
pick(recent, recent + week, (d) => !d.big).big = true;
|
|
131
|
+
for (let k = 1 + recentBig + weekBig; k < bigCount; k += 1)
|
|
132
|
+
pick(recent + week, treeCount, (d) => !d.big).big = true;
|
|
133
|
+
// Codex trees: a few small ones among claude-code's, never the newest.
|
|
134
|
+
for (let k = 0; k < codexTrees; k += 1)
|
|
135
|
+
pick(1, treeCount, (d) => d.runtime === 0 && !d.big).runtime = 1;
|
|
136
|
+
// Bytes: the giant is the trace's 668 MB newest giant; big trees run
|
|
137
|
+
// 70 MB to 1.7 GB; small trees are log-normal around 45 KB (root_p50).
|
|
138
|
+
for (const d of drafts) {
|
|
139
|
+
d.bytes = d.big
|
|
140
|
+
? Math.round(70 * MB * Math.exp(rnd() ** 1.8 * Math.log(24)))
|
|
141
|
+
: Math.round(Math.min(60 * MB, Math.max(1_500, 45_000 * Math.exp(2.4 * normal(rnd)))));
|
|
142
|
+
}
|
|
143
|
+
drafts[0].bytes = 668_350_304;
|
|
144
|
+
// Projects: the newest work concentrates in a few projects; every
|
|
145
|
+
// project owns at least one tree; ~2% of trees have no proven owner.
|
|
146
|
+
const projectWeight = (p) => 1 / (p + 1) ** 0.9;
|
|
147
|
+
const zipf = (limit) => {
|
|
148
|
+
const total = Array.from({ length: limit }, (_, p) => projectWeight(p)).reduce((a, b) => a + b, 0);
|
|
149
|
+
let x = rnd() * total;
|
|
150
|
+
for (let p = 0; p < limit; p += 1) {
|
|
151
|
+
x -= projectWeight(p);
|
|
152
|
+
if (x <= 0)
|
|
153
|
+
return p;
|
|
154
|
+
}
|
|
155
|
+
return limit - 1;
|
|
156
|
+
};
|
|
157
|
+
drafts.forEach((d, i) => {
|
|
158
|
+
d.project = i === 0 ? 0 : i < recent ? zipf(Math.min(3, projectCount)) : i < recent + week ? zipf(Math.min(10, projectCount)) : zipf(projectCount);
|
|
159
|
+
});
|
|
160
|
+
// The newest project keeps a readable morning beside its giant: its small
|
|
161
|
+
// trees today and this week, whatever the draw gave.
|
|
162
|
+
for (const at of [1, 2, recent]) {
|
|
163
|
+
const d = drafts[at];
|
|
164
|
+
if (d !== undefined && !d.big && d.runtime === 0)
|
|
165
|
+
d.project = 0;
|
|
166
|
+
}
|
|
167
|
+
const owned = (p) => drafts.reduce((count, d) => count + (d.project === p ? 1 : 0), 0);
|
|
168
|
+
const tail = drafts.slice(recent + week);
|
|
169
|
+
for (let p = 0; p < projectCount; p += 1) {
|
|
170
|
+
if (owned(p) > 0)
|
|
171
|
+
continue;
|
|
172
|
+
const d = tail.find((t) => t.project !== 0 && owned(t.project) > 2) ?? tail[p % tail.length];
|
|
173
|
+
d.project = p;
|
|
174
|
+
}
|
|
175
|
+
for (let k = 0; k < Math.max(1, Math.round(treeCount * 0.02)); k += 1) {
|
|
176
|
+
const d = pick(recent + week, treeCount, (t) => t.project !== null && owned(t.project) > 2);
|
|
177
|
+
if (d !== null)
|
|
178
|
+
d.project = null;
|
|
179
|
+
}
|
|
180
|
+
// Bound trees: admitted only at the producer's close. One sits in the
|
|
181
|
+
// newest project, so a reader can open a not-imported row whose tree
|
|
182
|
+
// waits for the close.
|
|
183
|
+
const ownBound = drafts.find((d, i) => i > 2 && d.project === 0 && !d.big && d.runtime === 0);
|
|
184
|
+
if (ownBound !== undefined)
|
|
185
|
+
ownBound.bound = true;
|
|
186
|
+
for (let k = ownBound === undefined ? 0 : 1; k < boundTrees; k += 1) {
|
|
187
|
+
const d = pick(recent + week, treeCount, (t) => !t.big && !t.bound && t.runtime === 0);
|
|
188
|
+
if (d !== null)
|
|
189
|
+
d.bound = true;
|
|
190
|
+
}
|
|
191
|
+
// Placeholder roots: claude-code trees whose root transcript is gone. The
|
|
192
|
+
// first is the newest such tree outside the newest project: its family's
|
|
193
|
+
// activity is newer than any unassigned tree's, so publication's reveal
|
|
194
|
+
// (which shows it) moves the unassigned bucket at every scale. The rest
|
|
195
|
+
// are older.
|
|
196
|
+
const placeholderOk = (t) => !t.big && !t.bound && !t.placeholderRoot && t.runtime === 0 && t.project !== null && t.project !== 0;
|
|
197
|
+
for (let k = 0; k < placeholderTrees; k += 1) {
|
|
198
|
+
const d = (k === 0 ? drafts.slice(1).find(placeholderOk) ?? null : null) ?? pick(recent + week, treeCount, placeholderOk);
|
|
199
|
+
if (d !== null)
|
|
200
|
+
d.placeholderRoot = true;
|
|
201
|
+
}
|
|
202
|
+
// Dirty trees: the newest project's second-newest small tree (it flips
|
|
203
|
+
// long before the giant, so its Streaming row sits beside the
|
|
204
|
+
// not-imported ones), the rest scattered over the tail.
|
|
205
|
+
const ownDirty = [drafts[2], drafts[1]].find((d) => d !== undefined && !d.big && !d.bound && d.runtime === 0 && d.project === 0);
|
|
206
|
+
if (ownDirty !== undefined)
|
|
207
|
+
ownDirty.dirty = true;
|
|
208
|
+
for (let k = ownDirty === undefined ? 0 : 1; k < dirtyTrees; k += 1) {
|
|
209
|
+
const d = pick(recent + week, treeCount, (t) => !t.big && !t.bound && !t.dirty && !t.placeholderRoot);
|
|
210
|
+
if (d !== null)
|
|
211
|
+
d.dirty = true;
|
|
212
|
+
}
|
|
213
|
+
// Children: big trees carry the subagent swarms (one flip of 201 sessions
|
|
214
|
+
// in the trace), small trees a few or none; a placeholder needs one.
|
|
215
|
+
const childTotal = rostered - drafts.filter((d) => !d.placeholderRoot).length;
|
|
216
|
+
const weights = drafts.map((d) => d.big ? 40 + rnd() * 160 : d.runtime === 1 ? 0 : rnd() < 0.5 ? 0 : rnd() < 0.9 ? 1 + rnd() * 3 : 8 + rnd() * 30);
|
|
217
|
+
const counts = apportion(childTotal - placeholderTrees, weights);
|
|
218
|
+
drafts.forEach((d, i) => {
|
|
219
|
+
d.children = Math.min(500, counts[i] + (d.placeholderRoot ? 1 : 0));
|
|
220
|
+
});
|
|
221
|
+
// What the cap clipped goes to the oldest claude-code trees with room.
|
|
222
|
+
let spill = childTotal - drafts.reduce((a, d) => a + d.children, 0);
|
|
223
|
+
for (let pass = 0; spill > 0 && pass < 500; pass += 1) {
|
|
224
|
+
for (let i = drafts.length - 1; i >= 0 && spill > 0; i -= 1) {
|
|
225
|
+
const d = drafts[i];
|
|
226
|
+
if (d.children < 500 && d.runtime === 0) {
|
|
227
|
+
d.children += 1;
|
|
228
|
+
spill -= 1;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const projectRows = Array.from({ length: projectCount }, (_, p) => {
|
|
233
|
+
const name = `${PROJECT_WORDS[p % PROJECT_WORDS.length]}${p < PROJECT_WORDS.length ? "" : `-${Math.floor(p / PROJECT_WORDS.length) + 1}`}`;
|
|
234
|
+
return { id: hexId(`project:${seed}:${p}`), name, root_paths: [`/Users/demo/Projects/${name}`], git_repo: p % 3 === 0 ? null : `github.com/demo/${name}` };
|
|
235
|
+
});
|
|
236
|
+
const sessions = [];
|
|
237
|
+
const kind = new Map();
|
|
238
|
+
const own = new Map();
|
|
239
|
+
const children = new Map();
|
|
240
|
+
const trees = [];
|
|
241
|
+
const treeOf = new Map();
|
|
242
|
+
const bytesOf = new Map();
|
|
243
|
+
const adopt = (parent, child) => {
|
|
244
|
+
const list = children.get(parent);
|
|
245
|
+
if (list === undefined)
|
|
246
|
+
children.set(parent, [child]);
|
|
247
|
+
else
|
|
248
|
+
list.push(child);
|
|
249
|
+
};
|
|
250
|
+
/** Recorded bounds a little before the source's mtime. */
|
|
251
|
+
const bounds = (mtime) => {
|
|
252
|
+
const last = mtime - Math.round(rnd() * 50_000) - 1_000;
|
|
253
|
+
return { first_at: last - Math.round(MINUTE + rnd() ** 2 * 6 * HOUR), last_at: last };
|
|
254
|
+
};
|
|
255
|
+
const projectOf = (p) => (p === null ? null : projectRows[p]);
|
|
256
|
+
const cwdOf = (p, i) => projectOf(p)?.root_paths[0] ?? `/Users/demo/scratch/run-${i % 40}`;
|
|
257
|
+
drafts.forEach((d, i) => {
|
|
258
|
+
const runtime = runtimes[d.runtime];
|
|
259
|
+
const recency = now - Math.round(d.age);
|
|
260
|
+
const project = projectOf(d.project);
|
|
261
|
+
const cwd = cwdOf(d.project, i);
|
|
262
|
+
const topic = TOPICS[Math.floor(rnd() * TOPICS.length)];
|
|
263
|
+
const members = [];
|
|
264
|
+
const memberBytes = [];
|
|
265
|
+
if (d.placeholderRoot) {
|
|
266
|
+
// The parent row the child's skim made: unassigned, unnamed, Pending.
|
|
267
|
+
sessions.push({
|
|
268
|
+
id: d.id, native_session_id: uuidOf(d.id), runtime_id: runtime.id, project_id: null, cwd: null,
|
|
269
|
+
parent_session_id: null, delegation: null, root_session_id: d.id, role: "main", title: null, summary: null,
|
|
270
|
+
started_at: recency - HOUR, updated_at: recency, activity: null, stream_state: "pending",
|
|
271
|
+
});
|
|
272
|
+
kind.set(d.id, "placeholder");
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
const activity = bounds(recency);
|
|
276
|
+
sessions.push({
|
|
277
|
+
id: d.id, native_session_id: uuidOf(d.id), runtime_id: runtime.id, project_id: project?.id ?? null, cwd,
|
|
278
|
+
parent_session_id: null, delegation: null, root_session_id: d.id, role: "main",
|
|
279
|
+
title: `${topic}: ${ACTS[Math.floor(rnd() * ACTS.length)]} #${i}`, summary: null,
|
|
280
|
+
started_at: activity.first_at, updated_at: recency, activity: null, stream_state: "pending",
|
|
281
|
+
});
|
|
282
|
+
kind.set(d.id, "root");
|
|
283
|
+
own.set(d.id, activity);
|
|
284
|
+
members.push(d.id);
|
|
285
|
+
memberBytes.push(1 + rnd());
|
|
286
|
+
}
|
|
287
|
+
// Subagents: most under the root, some one level deeper; each wrote a
|
|
288
|
+
// little before the tree's newest file.
|
|
289
|
+
const made = [];
|
|
290
|
+
for (let c = 0; c < d.children; c += 1) {
|
|
291
|
+
const id = hexId(`child:${seed}:${i}:${c}`);
|
|
292
|
+
const parent = made.length > 0 && rnd() < 0.15 ? made[Math.floor(rnd() * made.length)] : d.id;
|
|
293
|
+
const mtime = recency - Math.round(rnd() * Math.min(d.age / 3, 6 * HOUR));
|
|
294
|
+
const activity = bounds(mtime);
|
|
295
|
+
sessions.push({
|
|
296
|
+
id, native_session_id: uuidOf(id), runtime_id: runtime.id, project_id: project?.id ?? null, cwd,
|
|
297
|
+
parent_session_id: parent, delegation: null, root_session_id: d.id, role: "subagent",
|
|
298
|
+
title: rnd() < 0.7 ? `${topic} subtask ${c + 1}` : null, summary: null,
|
|
299
|
+
started_at: activity.first_at, updated_at: mtime, activity: null, stream_state: "pending",
|
|
300
|
+
});
|
|
301
|
+
kind.set(id, "child");
|
|
302
|
+
own.set(id, activity);
|
|
303
|
+
adopt(parent, id);
|
|
304
|
+
made.push(id);
|
|
305
|
+
members.push(id);
|
|
306
|
+
memberBytes.push(rnd());
|
|
307
|
+
}
|
|
308
|
+
const tree = {
|
|
309
|
+
id: d.id, runtimeId: runtime.id, members, bytes: d.bytes, big: d.big, recency, bound: d.bound,
|
|
310
|
+
dirty: d.dirty && !d.placeholderRoot, placeholderRoot: d.placeholderRoot,
|
|
311
|
+
};
|
|
312
|
+
apportion(d.bytes, memberBytes).forEach((bytes, m) => {
|
|
313
|
+
bytesOf.set(members[m], bytes);
|
|
314
|
+
treeOf.set(members[m], tree);
|
|
315
|
+
});
|
|
316
|
+
trees.push(tree);
|
|
317
|
+
});
|
|
318
|
+
// Rows no source rosters: roots spread over the year (one of them in the
|
|
319
|
+
// newest project, this morning) and leaf children under flipping trees.
|
|
320
|
+
for (let k = 0; k < neverRosteredRoots; k += 1) {
|
|
321
|
+
const id = hexId(`unrostered:${seed}:${k}`);
|
|
322
|
+
const p = k === 0 ? 0 : zipf(projectCount);
|
|
323
|
+
const updated = now - Math.round(k === 0 ? 3 * HOUR : 2 * DAY * Math.exp(rnd() * Math.log(150)));
|
|
324
|
+
sessions.push({
|
|
325
|
+
id, native_session_id: uuidOf(id), runtime_id: runtimes[0].id, project_id: projectOf(p).id, cwd: cwdOf(p, k),
|
|
326
|
+
parent_session_id: null, delegation: null, root_session_id: id, role: "main",
|
|
327
|
+
title: `${TOPICS[k % TOPICS.length]}: an unrostered thread #${k}`, summary: null,
|
|
328
|
+
started_at: updated - HOUR, updated_at: updated, activity: null, stream_state: "pending",
|
|
329
|
+
});
|
|
330
|
+
kind.set(id, "never-rostered-root");
|
|
331
|
+
}
|
|
332
|
+
const hosts = trees.filter((t) => !t.placeholderRoot && t.runtimeId === runtimes[0].id);
|
|
333
|
+
const rootRow = new Map(sessions.map((row) => [row.id, row]));
|
|
334
|
+
for (let k = 0; k < neverRosteredChildren; k += 1) {
|
|
335
|
+
const host = hosts[Math.floor(rnd() * hosts.length)];
|
|
336
|
+
const id = hexId(`unrostered-child:${seed}:${k}`);
|
|
337
|
+
const root = rootRow.get(host.id);
|
|
338
|
+
sessions.push({
|
|
339
|
+
...root, id, native_session_id: uuidOf(id), parent_session_id: host.id, role: "subagent",
|
|
340
|
+
title: null, summary: null, updated_at: host.recency - HOUR, started_at: host.recency - 2 * HOUR,
|
|
341
|
+
});
|
|
342
|
+
kind.set(id, "never-rostered-child");
|
|
343
|
+
adopt(host.id, id);
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
now, scale, seed, runtimes, projects: projectRows, sessions, kind, own, children, trees, treeOf, bytesOf,
|
|
347
|
+
topics: TOPICS,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ArtifactPage, BoostResponse, ContributionResponse, DayUsageResponse, DiscoveriesResponse, EnableResponse, ErrorCode, HeatmapResponse, SearchResponse, StatusResponse, UsageResponse } from "@vibefield/rosetta-protocol";
|
|
2
|
+
import type { CatalogSearch } from "../ports.js";
|
|
3
|
+
/** A refusal, as the daemon words it (`ApiError`). */
|
|
4
|
+
export declare class ColdWireError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly code: ErrorCode;
|
|
7
|
+
constructor(status: number, code: ErrorCode, message: string);
|
|
8
|
+
}
|
|
9
|
+
/** What the simulated daemon answers, route by route. */
|
|
10
|
+
export interface ColdWire {
|
|
11
|
+
/** May be held by the controller; rejects with an AbortError on abort. */
|
|
12
|
+
status(signal?: AbortSignal): Promise<StatusResponse>;
|
|
13
|
+
discoveries(): DiscoveriesResponse;
|
|
14
|
+
enableRuntimes(kinds: readonly string[]): EnableResponse;
|
|
15
|
+
heatmap(projectId: string): HeatmapResponse;
|
|
16
|
+
contribution(projectId: string): ContributionResponse;
|
|
17
|
+
usage(projectId: string): UsageResponse;
|
|
18
|
+
dayUsage(projectId: string, day: string): DayUsageResponse;
|
|
19
|
+
search(request: CatalogSearch, signal?: AbortSignal): SearchResponse;
|
|
20
|
+
boost(sessionId: string): BoostResponse;
|
|
21
|
+
artifacts(): ArtifactPage;
|
|
22
|
+
}
|
|
23
|
+
export declare const aborted: () => DOMException;
|
|
24
|
+
/** The routes the SDK asks (clients/ts/client.ts), answered over `wire`. */
|
|
25
|
+
export declare function fetchOver(wire: ColdWire): typeof fetch;
|