@peasant-labs/schema 0.49.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import type { TurnDetail } from "./internal/generated/contract/zod.gen.js";
2
+ /**
3
+ * Whether a turn is a conversation turn: depth 0 and its (role, entryType) on
4
+ * the allowed list. A missing or unknown role or entry type does not count.
5
+ */
6
+ export declare function isConversationTurn(turn: Pick<TurnDetail, "role" | "entryType" | "depth">): boolean;
@@ -0,0 +1,18 @@
1
+ import { EntryType, Role } from "./internal/generated/enums.gen.js";
2
+ const conversationTurnKinds = new Set([
3
+ `${Role.User}|${EntryType.Text}`,
4
+ `${Role.User}|${EntryType.Image}`,
5
+ `${Role.Assistant}|${EntryType.Text}`,
6
+ `${Role.Assistant}|${EntryType.Image}`,
7
+ ]);
8
+ /**
9
+ * Whether a turn is a conversation turn: depth 0 and its (role, entryType) on
10
+ * the allowed list. A missing or unknown role or entry type does not count.
11
+ */
12
+ export function isConversationTurn(turn) {
13
+ if (turn.depth !== 0)
14
+ return false;
15
+ if (typeof turn.role !== "string" || typeof turn.entryType !== "string")
16
+ return false;
17
+ return conversationTurnKinds.has(`${turn.role}|${turn.entryType}`);
18
+ }