Files
sausage/extensions/subagents/landing.ts
T

14 lines
620 B
TypeScript

/**
* Where a page opens when no conversation is chosen (a first load, a new chapter, a remembered one that is gone):
* the main agent's conversation, once the shared state and the main agents are known; 'create' when the main agent has no
* conversation yet, as on a fresh preview. The root is only its history.
*/
export const landing = (
loaded: boolean,
chosen: unknown,
mainAgent: Readonly<Record<string, number>> | null | undefined,
): number | 'create' | undefined => {
if (!loaded || chosen !== undefined || mainAgent === undefined) return undefined
return mainAgent?.['$main-agent'] ?? 'create'
}