Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/ephemlets/src/types.ts

Raw
/** How a human answer reaches the agent: read on demand, next turn, or right away. */
export type Delivery = "ambient" | "next" | "now";
type FieldBase = { id: string; label?: string; delivery?: Delivery };
export type ChecklistItem = { id: string; label: string; checked?: boolean };
export type ChecklistField = FieldBase & {
	type: "checklist";
	items: ChecklistItem[];
};
export type ChoiceField = FieldBase & {
	type: "choice";
	options: { id: string; label: string }[];
	multiple?: boolean;
};
export type ConfirmField = FieldBase & { type: "confirm"; label: string };
export type TextField = FieldBase & {
	type: "text";
	label: string;
	placeholder?: string;
};
export type Field = ChecklistField | ChoiceField | ConfirmField | TextField;
/** A selectable row of any field; confirm fields expose yes/no options. */
export type FieldOption = { id: string; label: string; checked?: boolean };
/** Human selections keyed by field then option; they override agent defaults. */
export type Answers = Record<string, Record<string, boolean>>;

export type Ephemlet = {
	id: string;
	title: string;
	purpose: string;
	revision: number;
	source: string;
	fields: Field[];
	answers: Answers;
	/** Human free-text answers keyed by text field. */
	texts: Record<string, string>;
	/** Increments on every human answer; the agent has read up to seenRevision. */
	answerRevision: number;
	seenRevision: number;
};