trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
31 lines (29 loc) • 692 B
JavaScript
import {
createTimelineCore
} from "../../chunk-BMZU23AY.js";
import "../../chunk-2ESYSVXG.js";
// src/timeline/react/index.ts
import { useRef, useSyncExternalStore } from "react";
function asTimelineCore(input) {
return "actions" in input ? input : createTimelineCore(input);
}
function useTimeline(input = {}) {
const ref = useRef(null);
if (ref.current === null) {
ref.current = asTimelineCore(input);
}
const timeline = ref.current;
const state = useSyncExternalStore(
timeline.subscribe,
() => timeline.state,
() => timeline.state
);
return {
state,
actions: timeline.actions,
subscribe: timeline.subscribe
};
}
export {
useTimeline
};