Open History to see the last commit
1import type {
2 EnvironmentId,
3 OrchestrationV2ShellSnapshot,
4 ProjectId,
5 ScopedProjectRef,
6 ScopedThreadRef,
7 ThreadId,
8} from "@t3tools/contracts";
9import { isProviderNativeSubagentThread, OrchestrationV2ThreadShell } from "@t3tools/contracts";
10import * as Schema from "effect/Schema";
11import { Atom } from "effect/reactivity";
12
13import type { EnvironmentThreadShell, PendingSubagentRequest } from "./models.ts";
14import { presentThreadShell, threadRuntimeIsActive } from "./models.ts";
15import { type EnvironmentCatalogState, enabledEnvironmentIds } from "./connections.ts";
16import { makeSideChatListingFilter } from "./threadWorkflows.ts";
17import {
18 arrayElementsEqual,
19 parseProjectRefCollectionKey,
20 parseThreadKey,
21 projectRefCollectionKey,
22 threadKey,
23 threadRefsEqual,
24} from "./entities.ts";
25
26const EMPTY_THREADS: ReadonlyArray<OrchestrationV2ThreadShell> = Object.freeze([]);
27const EMPTY_SCOPED_THREAD_REFS: ReadonlyArray<ScopedThreadRef> = Object.freeze([]);
28const EMPTY_THREAD_INDEX: ReadonlyMap<ThreadId, OrchestrationV2ThreadShell> = new Map();
29const EMPTY_SUBAGENT_REQUESTS: ReadonlyMap<ThreadId, PendingSubagentRequest> = new Map();
30const EMPTY_THREAD_REFS_BY_PROJECT: ReadonlyMap<
31 ProjectId,
32 ReadonlyArray<ScopedThreadRef>
33> = new Map();
34
35// An async question outlives the subagent's run, but once that run ends the
36// parent is no longer waiting on the answer, so it stops counting as input.
37// The activity run stays set when a follow-up is queued behind a blocked run;
38// older servers omit it, so fall back to the latest run's status.
39const isChildRunLive = (
40 thread: Pick<OrchestrationV2ThreadShell, "activityRunStatus" | "status">,
41) =>
42 thread.activityRunStatus !== undefined
43 ? thread.activityRunStatus !== null
44 : thread.status === "preparing" ||
45 thread.status === "starting" ||
46 thread.status === "running" ||
47 thread.status === "waiting";
48
49/**
50 * Whether a thread shows under its parent rather than in thread lists: a
51 * subagent, or a task a linked environment delegated here whose parent the
52 * client lists (`delegatedUnderParent`, by thread key). A task whose parent
53 * the client cannot list stays in the lists, so its work is never out of reach.
54 */
55export function isShownUnderParent(
56 ref: ScopedThreadRef,
57 lineage: OrchestrationV2ThreadShell["lineage"],
58 delegatedUnderParent: ReadonlySet<string>,
59): boolean {
60 return lineage.relationshipToParent === "subagent" || delegatedUnderParent.has(threadKey(ref));
61}
62
63/** Provider-native
64 subagents ask on their parent, so they are skipped. */
65function subagentRequest(thread: OrchestrationV2ThreadShell): PendingSubagentRequest | null {
66 const kind = thread.pendingRuntimeRequest?.kind;
67 if (
68 kind === undefined ||
69 kind === "auth_refresh" ||
70 (thread.lineage.relationshipToParent !== "subagent" && thread.delegatedFrom === undefined) ||
71 isProviderNativeSubagentThread(thread) ||
72 !isChildRunLive(thread)
73 ) {
74 return null;
75 }
76 return kind === "user_input" ? "user_input" : "approval";
77}
78
79/**
80 * The threads to flag for a subagent's live approval, up its
81 * subagent chain. `delegated` are tasks this environment's threads delegated
82 * to linked environments, with what each one, or its own subagents, asks.
83 */
84function pendingSubagentRequestsByThread(
85 threads: ReadonlyArray<OrchestrationV2ThreadShell>,
86 delegated: ReadonlyArray<{
87 readonly parentThreadId: ThreadId;
88 readonly request: PendingSubagentRequest;
89 }> = [],
90): ReadonlyMap<ThreadId, PendingSubagentRequest> {
91 const requests = new Map<ThreadId, PendingSubagentRequest>();
92 let byId: ReadonlyMap<ThreadId, OrchestrationV2ThreadShell> | undefined;
93 const flag = (
94 firstParentId: ThreadId | null,
95 request: PendingSubagentRequest,
96 seen: Set<ThreadId>,
97 ) => {
98 // The coordinator answers child questions; only approvals need user attention.
99 if (request === "user_input") return;
100 byId ??= new Map(threads.map((thread) => [thread.id, thread] as const));
101 let parentId = firstParentId;
102 while (parentId !== null && !seen.has(parentId)) {
103 seen.add(parentId);
104 if (requests.get(parentId) !== "approval") requests.set(parentId, request);
105 const parent = byId.get(parentId);
106 parentId =
107 parent?.lineage.relationshipToParent === "subagent" ? parent.lineage.parentThreadId : null;
108 }
109 };
110 for (const child of threads) {
111 if (child.lineage.relationshipToParent !== "subagent") continue;
112 const request = subagentRequest(child);
113 if (request !== null) flag(child.lineage.parentThreadId, request, new Set([child.id]));
114 }
115 for (const task of delegated) flag(task.parentThreadId, task.request, new Set());
116 return requests.size === 0 ? EMPTY_SUBAGENT_REQUESTS : requests;
117}
118
119const sameRequests = (
120 left: ReadonlyMap<ThreadId, PendingSubagentRequest>,
121 right: ReadonlyMap<ThreadId, PendingSubagentRequest>,
122) =>
123 left.size === right.size &&
124 [...right].every(([threadId, request]) => left.get(threadId) === request);
125
126export function childThreadInputsTitle(
127 children: ReadonlyArray<Pick<EnvironmentThreadShell, "hasPendingApprovals">>,
128): string {
129 const approvals = children.filter((child) => child.hasPendingApprovals).length;
130 const need = approvals === 0 ? "input" : approvals === children.length ? "approval" : "you";
131 return children.length === 1
132 ? `Subagent needs ${need}`
133 : `${children.length} subagents need ${need}`;
134}
135
136const sameWireThreadShell = Schema.toEquivalence(OrchestrationV2ThreadShell);
137
138// While a run streams, the server bumps the shell's timestamps, item counts and
139// latest message several times a second. Only the zero crossing of the counts
140// says anything (whether the thread has started). Once the run stops every
141// field counts again, so snooze wakes and failure times read the current value.
142function sameApartFromStreaming(
143 previous: EnvironmentThreadShell,
144 next: EnvironmentThreadShell,
145): boolean {
146 if (
147 previous.environmentId !== next.environmentId ||
148 previous.pendingSubagentRequest !== next.pendingSubagentRequest ||
149 !threadRuntimeIsActive(next.runtime)
150 ) {
151 return false;
152 }
153 const before = previous.source;
154 const after = next.source;
155 return (
156 before.itemCount > 0 === after.itemCount > 0 &&
157 before.visibleItemCount > 0 === after.visibleItemCount > 0 &&
158 sameWireThreadShell(
159 {
160 ...before,
161 updatedAt: after.updatedAt,
162 itemCount: after.itemCount,
163 visibleItemCount: after.visibleItemCount,
164 latestVisibleMessage: after.latestVisibleMessage,
165 },
166 after,
167 )
168 );
169}
170
171export function createEnvironmentThreadShellAtoms(input: {
172 readonly catalogValueAtom: Atom.Atom<EnvironmentCatalogState>;
173 readonly snapshotAtom: (
174 environmentId: EnvironmentId,
175 ) => Atom.Atom<OrchestrationV2ShellSnapshot | null>;
176}) {
177 // Point reads and aggregate lists share values without keeping an atom alive
178 // for every listed thread. Replaced source objects can be collected.
179 const scopedThreads = new WeakMap<
180 OrchestrationV2ThreadShell,
181 Map<string, EnvironmentThreadShell>
182 >();
183 const scopedThread = (
184 environmentId: EnvironmentId,
185 thread: OrchestrationV2ThreadShell,
186 subagentRequests: ReadonlyMap<ThreadId, PendingSubagentRequest>,
187 ) => {
188 let byEnvironment = scopedThreads.get(thread);
189 if (byEnvironment === undefined) {
190 byEnvironment = new Map();
191 scopedThreads.set(thread, byEnvironment);
192 }
193 const request = subagentRequests.get(thread.id) ?? null;
194 const key = request === null ? environmentId : `${environmentId}:${request}`;
195 let value = byEnvironment.get(key);
196 if (value === undefined) {
197 value = presentThreadShell(environmentId, thread, request);
198 byEnvironment.set(key, value);
199 }
200 return value;
201 };
202
203 const environmentThreadsAtom = Atom.family((environmentId: EnvironmentId) =>
204 Atom.make(
205 (get): ReadonlyArray<OrchestrationV2ThreadShell> =>
206 get(input.snapshotAtom(environmentId))?.threads ?? EMPTY_THREADS,
207 ).pipe(Atom.withLabel(`environment-threads:${environmentId}`)),
208 );
209
210 const environmentThreadIndexAtom = Atom.family((environmentId: EnvironmentId) =>
211 Atom.make((get): ReadonlyMap<ThreadId, OrchestrationV2ThreadShell> => {
212 const threads = get(environmentThreadsAtom(environmentId));
213 if (threads.length === 0) {
214 return EMPTY_THREAD_INDEX;
215 }
216 return new Map(threads.map((thread) => [thread.id, thread] as const));
217 }).pipe(Atom.withLabel(`environment-thread-index:${environmentId}`)),
218 );
219
220 // What an environment's own subagents ask. Kept apart from the tasks other
221 // environments run for it, so two environments delegating to each other
222 // never read each other's totals.
223 const localSubagentRequestsAtom = Atom.family((environmentId: EnvironmentId) => {
224 let previous = EMPTY_SUBAGENT_REQUESTS;
225 return Atom.make((get) => {
226 const next = pendingSubagentRequestsByThread(get(environmentThreadsAtom(environmentId)));
227 if (sameRequests(previous, next)) return previous;
228 previous = next;
229 return next;
230 }).pipe(Atom.withLabel(`environment-local-subagent-requests:${environmentId}`));
231 });
232
233 // Flags for environments whose threads delegated tasks, counting what each task
234 // or anything it delegated on asks. Each pass settles one more hop of a chain;
235 // flags only grow, so environments delegating to each other settle too.
236 const delegatedSubagentRequestsAtom = Atom.make((get) => {
237 const tasksByDelegator = new Map<
238 EnvironmentId,
239 Array<{
240 readonly runsIn: EnvironmentId;
241 readonly thread: OrchestrationV2ThreadShell;
242 readonly parentThreadId: ThreadId;
243 }>
244 >();
245 for (const runsIn of enabledEnvironmentIds(get(input.catalogValueAtom))) {
246 for (const thread of get(environmentThreadsAtom(runsIn))) {
247 const from = thread.delegatedFrom;
248 if (from === undefined || from.environmentId === runsIn) continue;
249 const task = { runsIn, thread, parentThreadId: from.threadId };
250 const tasks = tasksByDelegator.get(from.environmentId);
251 if (tasks === undefined) tasksByDelegator.set(from.environmentId, [task]);
252 else tasks.push(task);
253 }
254 }
255 let flags = new Map<EnvironmentId, ReadonlyMap<ThreadId, PendingSubagentRequest>>();
256 const requestsOf = (environmentId: EnvironmentId) =>
257 flags.get(environmentId) ?? get(localSubagentRequestsAtom(environmentId));
258 for (let changed = tasksByDelegator.size > 0; changed;) {
259 changed = false;
260 const next = new Map(flags);
261 for (const [environmentId, tasks] of tasksByDelegator) {
262 const delegated = tasks.flatMap(({ runsIn, thread, parentThreadId }) => {
263 const own = subagentRequest(thread);
264 const nested = requestsOf(runsIn).get(thread.id);
265 const request = own === "approval" ? own : (nested ?? own);
266 return request === null ? [] : [{ parentThreadId, request }];
267 });
268 if (delegated.length === 0) continue;
269 const requests = pendingSubagentRequestsByThread(
270 get(environmentThreadsAtom(environmentId)),
271 delegated,
272 );
273 if (sameRequests(requestsOf(environmentId), requests)) continue;
274 next.set(environmentId, requests);
275 changed = true;
276 }
277 flags = next;
278 }
279 return flags;
280 }).pipe(Atom.withLabel("environment-delegated-subagent-requests"));
281
282 const pendingSubagentRequestsAtom = Atom.family((environmentId: EnvironmentId) => {
283 let previous = EMPTY_SUBAGENT_REQUESTS;
284 return Atom.make((get) => {
285 const next =
286 get(delegatedSubagentRequestsAtom).get(environmentId) ??
287 get(localSubagentRequestsAtom(environmentId));
288 if (sameRequests(previous, next)) return previous;
289 previous = next;
290 return next;
291 }).pipe(Atom.withLabel(`environment-pending-subagent-requests:${environmentId}`));
292 });
293
294 const environmentThreadRefsAtom = Atom.family((environmentId: EnvironmentId) => {
295 let previous: ReadonlyArray<ScopedThreadRef> = [];
296 return Atom.make((get) => {
297 const next = get(environmentThreadsAtom(environmentId)).map((thread) => ({
298 environmentId,
299 threadId: thread.id,
300 }));
301 if (threadRefsEqual(previous, next)) {
302 return previous;
303 }
304 previous = next;
305 return next;
306 }).pipe(Atom.withLabel(`environment-thread-refs:${environmentId}`));
307 });
308
309 const environmentThreadRefsByProjectAtom = Atom.family((environmentId: EnvironmentId) => {
310 let previous: ReadonlyMap<
311 ProjectId,
312 ReadonlyArray<ScopedThreadRef>
313 > = EMPTY_THREAD_REFS_BY_PROJECT;
314 return Atom.make((get) => {
315 const grouped = new Map<ProjectId, ScopedThreadRef[]>();
316 for (const thread of get(environmentThreadsAtom(environmentId))) {
317 const refs = grouped.get(thread.projectId);
318 const ref = { environmentId, threadId: thread.id };
319 if (refs === undefined) {
320 grouped.set(thread.projectId, [ref]);
321 } else {
322 refs.push(ref);
323 }
324 }
325 if (grouped.size === 0) {
326 previous = EMPTY_THREAD_REFS_BY_PROJECT;
327 return previous;
328 }
329 const next = new Map<ProjectId, ReadonlyArray<ScopedThreadRef>>();
330 for (const [projectId, refs] of grouped) {
331 const previousRefs = previous.get(projectId);
332 next.set(
333 projectId,
334 previousRefs !== undefined && threadRefsEqual(previousRefs, refs) ? previousRefs : refs,
335 );
336 }
337 const previousProjectIds = [...previous.keys()];
338 if (
339 next.size === previous.size &&
340 [...next].every(
341 ([projectId, refs], index) =>
342 previousProjectIds[index] === projectId && previous.get(projectId) === refs,
343 )
344 ) {
345 return previous;
346 }
347 previous = next;
348 return previous;
349 }).pipe(Atom.withLabel(`environment-thread-refs-by-project:${environmentId}`));
350 });
351
352 const threadShellAtomFamily = Atom.family((key: string) => {
353 const ref = parseThreadKey(key);
354 return Atom.make((get) => {
355 const source = get(environmentThreadIndexAtom(ref.environmentId)).get(ref.threadId) ?? null;
356 return source === null
357 ? null
358 : scopedThread(
359 ref.environmentId,
360 source,
361 get(pendingSubagentRequestsAtom(ref.environmentId)),
362 );
363 }).pipe(Atom.withLabel(`environment-thread-shell:${key}`));
364 });
365
366 // Keeps the previous shell while only streaming ticks changed. During a run,
367 // its timestamps, item counts and latest message are as of the last kept
368 // change; anything that needs them current reads threadShellAtom.
369 const quietThreadShellAtomFamily = Atom.family((key: string) => {
370 let previous: EnvironmentThreadShell | null = null;
371 return Atom.make((get) => {
372 const next = get(threadShellAtomFamily(key));
373 if (previous !== null && next !== null && sameApartFromStreaming(previous, next)) {
374 return previous;
375 }
376 previous = next;
377 return next;
378 }).pipe(Atom.withLabel(`environment-quiet-thread-shell:${key}`));
379 });
380
381 // Child approvals and questions are hidden with their sidebar rows. Read their
382 // shell summaries, without subscribing to every child transcript. A task
383 // delegated to a linked environment is a child too, with its own subagents.
384 const childThreadInputsAtomFamily = Atom.family((key: string) => {
385 let previous: ReadonlyArray<EnvironmentThreadShell> = [];
386 return Atom.make((get) => {
387 const children = new Map<
388 string,
389 Array<{ environmentId: EnvironmentId; thread: OrchestrationV2ThreadShell }>
390 >();
391 const addChild = (
392 parent: ScopedThreadRef,
393 environmentId: EnvironmentId,
394 thread: OrchestrationV2ThreadShell,
395 ) => {
396 const siblings = children.get(threadKey(parent));
397 if (siblings) siblings.push({ environmentId, thread });
398 else children.set(threadKey(parent), [{ environmentId, thread }]);
399 };
400 for (const environmentId of enabledEnvironmentIds(get(input.catalogValueAtom))) {
401 for (const thread of get(environmentThreadsAtom(environmentId))) {
402 const parent = thread.lineage.parentThreadId;
403 if (parent !== null && thread.lineage.relationshipToParent === "subagent") {
404 addChild({ environmentId, threadId: parent }, environmentId, thread);
405 } else if (thread.delegatedFrom !== undefined) {
406 addChild(thread.delegatedFrom, environmentId, thread);
407 }
408 }
409 }
410 const seen = new Set<string>([key]);
411 const pending = [key];
412 const next: EnvironmentThreadShell[] = [];
413 for (const parent of pending) {
414 for (const { environmentId, thread } of children.get(parent) ?? []) {
415 const childKey = threadKey({ environmentId, threadId: thread.id });
416 if (seen.has(childKey)) continue;
417 seen.add(childKey);
418 pending.push(childKey);
419 if (subagentRequest(thread) !== null) {
420 next.push(
421 scopedThread(environmentId, thread, get(pendingSubagentRequestsAtom(environmentId))),
422 );
423 }
424 }
425 }
426 // Indicators read only ids, titles and the request kind, so other shell
427 // updates keep the old array.
428 if (
429 previous.length === next.length &&
430 previous.every(
431 (thread, index) =>
432 thread.environmentId === next[index]?.environmentId &&
433 thread.id === next[index]?.id &&
434 thread.title === next[index]?.title &&
435 thread.hasPendingApprovals === next[index]?.hasPendingApprovals,
436 )
437 ) {
438 return previous;
439 }
440 previous = next;
441 return next;
442 }).pipe(Atom.withLabel(`environment-child-thread-inputs:${key}`));
443 });
444
445 const threadShellsForProjectRefsAtomFamily = Atom.family((key: string) => {
446 const projectRefs = parseProjectRefCollectionKey(key);
447 let previous: ReadonlyArray<EnvironmentThreadShell> = [];
448 return Atom.make((get) => {
449 const next: EnvironmentThreadShell[] = [];
450 const seen = new Set<string>();
451 for (const projectRef of projectRefs) {
452 const refs =
453 get(environmentThreadRefsByProjectAtom(projectRef.environmentId)).get(
454 projectRef.projectId,
455 ) ?? EMPTY_SCOPED_THREAD_REFS;
456 if (refs.length === 0) continue;
457 const threads = get(environmentThreadIndexAtom(projectRef.environmentId));
458 const subagentRequests = get(pendingSubagentRequestsAtom(projectRef.environmentId));
459 for (const ref of refs) {
460 const key = threadKey(ref);
461 if (seen.has(key)) {
462 continue;
463 }
464 seen.add(key);
465 const thread = threads.get(ref.threadId);
466 if (thread !== undefined) {
467 next.push(scopedThread(ref.environmentId, thread, subagentRequests));
468 }
469 }
470 }
471 if (arrayElementsEqual(previous, next)) {
472 return previous;
473 }
474 previous = next;
475 return previous;
476 }).pipe(Atom.withLabel(`environment-thread-shells-for-projects:${key}`));
477 });
478
479 let previousThreadRefs: ReadonlyArray<ScopedThreadRef> = [];
480 const threadRefsAtom = Atom.make((get) => {
481 const refs: ScopedThreadRef[] = [];
482 for (const environmentId of enabledEnvironmentIds(get(input.catalogValueAtom))) {
483 refs.push(...get(environmentThreadRefsAtom(environmentId)));
484 }
485 if (threadRefsEqual(previousThreadRefs, refs)) {
486 return previousThreadRefs;
487 }
488 previousThreadRefs = refs;
489 return refs;
490 }).pipe(Atom.withLabel("environment-thread-refs"));
491
492 let previousThreadShells: ReadonlyArray<EnvironmentThreadShell> = [];
493 const threadShellsAtom = Atom.make((get) => {
494 const next: EnvironmentThreadShell[] = [];
495 for (const environmentId of enabledEnvironmentIds(get(input.catalogValueAtom))) {
496 const subagentRequests = get(pendingSubagentRequestsAtom(environmentId));
497 for (const thread of get(environmentThreadsAtom(environmentId))) {
498 next.push(scopedThread(environmentId, thread, subagentRequests));
499 }
500 }
501 if (arrayElementsEqual(previousThreadShells, next)) {
502 return previousThreadShells;
503 }
504 previousThreadShells = next;
505 return previousThreadShells;
506 }).pipe(Atom.withLabel("environment-thread-shell-list"));
507
508 // Lists that arrange threads read this, so a running thread's streaming
509 // ticks reach only what reads its live shell.
510 let previousQuietThreadShells: ReadonlyArray<EnvironmentThreadShell> = [];
511 const quietThreadShellsAtom = Atom.make((get) => {
512 const next: EnvironmentThreadShell[] = [];
513 for (const ref of get(threadRefsAtom)) {
514 const shell = get(quietThreadShellAtomFamily(threadKey(ref)));
515 if (shell !== null) next.push(shell);
516 }
517 if (arrayElementsEqual(previousQuietThreadShells, next)) return previousQuietThreadShells;
518 previousQuietThreadShells = next;
519 return next;
520 }).pipe(Atom.withLabel("environment-quiet-thread-shell-list"));
521
522 let previousDelegatedUnderParent: ReadonlySet<string> = new Set();
523 const delegatedUnderParentAtom = Atom.make((get) => {
524 const environmentIds = new Set(enabledEnvironmentIds(get(input.catalogValueAtom)));
525 const next = new Set<string>();
526 for (const environmentId of environmentIds) {
527 for (const thread of get(environmentThreadsAtom(environmentId))) {
528 const parent = thread.delegatedFrom;
529 if (
530 parent !== undefined &&
531 environmentIds.has(parent.environmentId) &&
532 // An archived parent leaves navigation; its task there stays listed on its own.
533 get(environmentThreadIndexAtom(parent.environmentId)).get(parent.threadId)?.archivedAt ===
534 null
535 ) {
536 next.add(threadKey({ environmentId, threadId: thread.id }));
537 }
538 }
539 }
540 if (
541 next.size === previousDelegatedUnderParent.size &&
542 [...next].every((key) => previousDelegatedUnderParent.has(key))
543 ) {
544 return previousDelegatedUnderParent;
545 }
546 previousDelegatedUnderParent = next;
547 return next;
548 }).pipe(Atom.withLabel("environment-delegated-under-parent"));
549
550 let previousNavigationShells: ReadonlyArray<EnvironmentThreadShell> = [];
551 const navigationThreadShellsAtom = Atom.make((get) => {
552 const next: EnvironmentThreadShell[] = [];
553 const underParent = get(delegatedUnderParentAtom);
554 for (const environmentId of enabledEnvironmentIds(get(input.catalogValueAtom))) {
555 const subagentRequests = get(pendingSubagentRequestsAtom(environmentId));
556 const threads = get(environmentThreadsAtom(environmentId)).map((thread) =>
557 scopedThread(environmentId, thread, subagentRequests),
558 );
559 // Side chats live in their parent's side panel, not in thread lists.
560 const listable = makeSideChatListingFilter(threads);
561 for (const thread of threads) {
562 if (
563 thread.archivedAt !== null ||
564 isShownUnderParent({ environmentId, threadId: thread.id }, thread.lineage, underParent) ||
565 !listable(thread)
566 ) {
567 continue;
568 }
569 next.push(thread);
570 }
571 }
572 if (arrayElementsEqual(previousNavigationShells, next)) return previousNavigationShells;
573 previousNavigationShells = next;
574 return next;
575 }).pipe(Atom.withLabel("environment-navigation-thread-shells"));
576
577 return {
578 environmentThreadsAtom,
579 environmentThreadIndexAtom,
580 environmentThreadRefsAtom,
581 environmentThreadRefsByProjectAtom,
582 threadRefsAtom,
583 threadShellsAtom,
584 quietThreadShellsAtom,
585 navigationThreadShellsAtom,
586 delegatedUnderParentAtom,
587 pendingSubagentRequestsAtom,
588 threadShellsForProjectRefsAtom: (refs: ReadonlyArray<ScopedProjectRef>) =>
589 threadShellsForProjectRefsAtomFamily(projectRefCollectionKey(refs)),
590 threadShellAtom: (ref: ScopedThreadRef) => threadShellAtomFamily(threadKey(ref)),
591 quietThreadShellAtom: (ref: ScopedThreadRef) => quietThreadShellAtomFamily(threadKey(ref)),
592 childThreadInputsAtom: (ref: ScopedThreadRef) => childThreadInputsAtomFamily(threadKey(ref)),
593 };
594}