forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat-first-capability.ts
More file actions
40 lines (36 loc) · 1.31 KB
/
Copy pathchat-first-capability.ts
File metadata and controls
40 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* The chat-first rollout is sampled by Swift once per app session from the
* server-owned workflow-control response. This module deliberately contains
* no persistence: process restart, owner replacement, an absent projection,
* and every non-main surface are all capability-off.
*/
export interface ChatFirstCapabilityProjection {
chatFirstUi: boolean;
controlGeneration: number;
}
export interface ChatFirstProjectionContext {
surfaceKind?: string;
chatFirstUi?: boolean;
controlGeneration?: number | null;
}
export interface EffectiveChatFirstCapability {
chatFirstUi: boolean;
controlGeneration: number | null;
}
export function effectiveChatFirstCapability(
projection: ChatFirstProjectionContext | undefined,
): EffectiveChatFirstCapability {
const generation = projection?.controlGeneration;
const enabled = projection?.chatFirstUi === true
&& projection?.surfaceKind === "main_chat"
&& Number.isSafeInteger(generation)
&& (generation ?? -1) >= 0;
return {
chatFirstUi: enabled,
controlGeneration: enabled ? generation! : null,
};
}
/** One predicate shared by snapshots, run admission, and the MCP child. */
export function isChatFirstMainChat(projection: ChatFirstProjectionContext | undefined): boolean {
return effectiveChatFirstCapability(projection).chatFirstUi;
}