Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

orchestration.ts

62 lines2.4 KB

1import { ORCHESTRATION_V2_WS_METHODS } from "@t3tools/contracts";
2import { Atom } from "effect/unstable/reactivity";
3​
4import {
5 createEnvironmentRpcCommand,
6 createEnvironmentRpcQueryAtomFamily,
7 createEnvironmentRpcSubscriptionAtomFamily,
8} from "./runtime.ts";
9import type { EnvironmentRegistry } from "../connection/registry.ts";
10​
11export function createOrchestrationEnvironmentAtoms<R, E>(
12 runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>,
13) {
14 return {
15 v2: {
16 dispatchCommand: createEnvironmentRpcCommand(runtime, {
17 label: "environment-data:orchestration-v2:dispatch-command",
18 tag: ORCHESTRATION_V2_WS_METHODS.dispatchCommand,
19 }),
20 threadProjection: createEnvironmentRpcQueryAtomFamily(runtime, {
21 label: "environment-data:orchestration-v2:thread-projection",
22 tag: ORCHESTRATION_V2_WS_METHODS.getThreadProjection,
23 staleTimeMs: 0,
24 idleTtlMs: 0,
25 }),
26 shell: createEnvironmentRpcSubscriptionAtomFamily(runtime, {
27 label: "environment-data:orchestration-v2:shell",
28 tag: ORCHESTRATION_V2_WS_METHODS.subscribeShell,
29 }),
30 thread: createEnvironmentRpcSubscriptionAtomFamily(runtime, {
31 label: "environment-data:orchestration-v2:thread",
32 tag: ORCHESTRATION_V2_WS_METHODS.subscribeThread,
33 idleTtlMs: 0,
34 }),
35 },
36 turnDiff: createEnvironmentRpcQueryAtomFamily(runtime, {
37 label: "environment-data:orchestration:turn-diff",
38 tag: ORCHESTRATION_V2_WS_METHODS.getTurnDiff,
39 }),
40 workflowScript: createEnvironmentRpcQueryAtomFamily(runtime, {
41 label: "environment-data:orchestration:workflow-script",
42 tag: ORCHESTRATION_V2_WS_METHODS.getWorkflowScript,
43 // Scripts are immutable per run: cache generously.
44 staleTimeMs: 300_000,
45 idleTtlMs: 300_000,
46 }),
47 fullThreadDiff: createEnvironmentRpcQueryAtomFamily(runtime, {
48 label: "environment-data:orchestration:full-thread-diff",
49 tag: ORCHESTRATION_V2_WS_METHODS.getFullThreadDiff,
50 }),
51 threadSearch: createEnvironmentRpcQueryAtomFamily(runtime, {
52 label: "environment-data:orchestration:thread-search",
53 tag: ORCHESTRATION_V2_WS_METHODS.searchThreads,
54 staleTimeMs: 30_000,
55 idleTtlMs: 60_000,
56 }),
57 archivedShellSnapshot: createEnvironmentRpcQueryAtomFamily(runtime, {
58 label: "environment-data:orchestration:archived-shell-snapshot",
59 tag: ORCHESTRATION_V2_WS_METHODS.getArchivedShellSnapshot,
60 }),
61 };