Files
t3code/packages/client-runtime/src/state/orchestration.ts
T
2026-08-06 00:32:28 -04:00

38 lines
1.5 KiB
TypeScript

import { ORCHESTRATION_WS_METHODS } from "@t3tools/contracts";
import { Atom } from "effect/unstable/reactivity";
import { createEnvironmentRpcQueryAtomFamily } from "./runtime.ts";
import type { EnvironmentRegistry } from "../connection/registry.ts";
export function createOrchestrationEnvironmentAtoms<R, E>(
runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>,
) {
return {
turnDiff: createEnvironmentRpcQueryAtomFamily(runtime, {
label: "environment-data:orchestration:turn-diff",
tag: ORCHESTRATION_WS_METHODS.getTurnDiff,
}),
workflowScript: createEnvironmentRpcQueryAtomFamily(runtime, {
label: "environment-data:orchestration:workflow-script",
tag: ORCHESTRATION_WS_METHODS.getWorkflowScript,
// Scripts are immutable per run: cache generously.
staleTimeMs: 300_000,
idleTtlMs: 300_000,
}),
fullThreadDiff: createEnvironmentRpcQueryAtomFamily(runtime, {
label: "environment-data:orchestration:full-thread-diff",
tag: ORCHESTRATION_WS_METHODS.getFullThreadDiff,
}),
threadSearch: createEnvironmentRpcQueryAtomFamily(runtime, {
label: "environment-data:orchestration:thread-search",
tag: ORCHESTRATION_WS_METHODS.searchThreads,
staleTimeMs: 30_000,
idleTtlMs: 60_000,
}),
archivedShellSnapshot: createEnvironmentRpcQueryAtomFamily(runtime, {
label: "environment-data:orchestration:archived-shell-snapshot",
tag: ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot,
}),
};
}