128 lines
3.6 KiB
TypeScript
128 lines
3.6 KiB
TypeScript
import type { ExactReference } from "@quixos/camino-react";
|
|
export type Ref = ExactReference;
|
|
export type PageInfo = { hasNextPage: boolean; endCursor: string | null };
|
|
export type Profile = {
|
|
revision: string;
|
|
modelProvider?: string;
|
|
available?: boolean;
|
|
model?: string | null;
|
|
effort?: string | null;
|
|
serviceTier?: string;
|
|
description?: string;
|
|
power?: number;
|
|
speed?: number;
|
|
cost?: number;
|
|
fastProfile?: string;
|
|
standardProfile?: string;
|
|
};
|
|
export type Profiles = Record<string, Profile>;
|
|
export type Connection<T> = { entries: { node: T }[]; pageInfo: PageInfo };
|
|
export type NodeRef = { _camino: { ref: Ref } };
|
|
export type Progress = {
|
|
status: string;
|
|
attempt: string;
|
|
generation: number;
|
|
reason: string;
|
|
result?: string | null;
|
|
rawOutput?: string | null;
|
|
cancelRequested: boolean;
|
|
notificationPending?: boolean;
|
|
startedAt?: string | null;
|
|
endedAt?: string | null;
|
|
usage?: string | null;
|
|
};
|
|
export type Question = NodeRef & {
|
|
data: {
|
|
key: string;
|
|
title: string;
|
|
options: string;
|
|
status: string;
|
|
answer: string | null;
|
|
attempt: string;
|
|
generation: number;
|
|
expiresAt: string;
|
|
};
|
|
};
|
|
export type Request = NodeRef & {
|
|
progress: Progress;
|
|
admission?: {
|
|
text?: string;
|
|
sequence?: string;
|
|
createdAt: string;
|
|
sourceKind: string;
|
|
sourceLabel: string;
|
|
responseKind?: string;
|
|
configuration?: string;
|
|
configurationDigest?: string;
|
|
};
|
|
questions?: Connection<Question>;
|
|
repair?: string;
|
|
pendingGraph?: boolean;
|
|
};
|
|
export type ItemData = {
|
|
key: string;
|
|
kind: string;
|
|
text: string;
|
|
phase: string;
|
|
activity: string | null;
|
|
presentation: string | null;
|
|
sequence: string;
|
|
version: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
control?: { attempt: string; generation: number; status: string; reason: string } | null;
|
|
};
|
|
export type Item = {
|
|
_camino?: { ref: Ref };
|
|
data: ItemData;
|
|
request: Request;
|
|
subject?: NodeRef | null;
|
|
presentationMount?: NodeRef | null;
|
|
live?: boolean;
|
|
};
|
|
export type Agent = NodeRef & {
|
|
data: { name: string; description: string; enabled: boolean; settings: string };
|
|
instructions: string;
|
|
};
|
|
export type Thread = NodeRef & {
|
|
data: { title: string; kind: string; archived: boolean; pending: number; updatedAt?: string };
|
|
agent: NodeRef & { data: { name: string } };
|
|
active?: Request | null;
|
|
requests?: Connection<Request>;
|
|
items?: Connection<Item>;
|
|
};
|
|
export type Cursor = { epoch: string; sequence: number };
|
|
export type ThreadState = {
|
|
thread?: Thread;
|
|
items: Item[];
|
|
requests: Request[];
|
|
cursor?: Cursor;
|
|
pageInfo?: PageInfo;
|
|
maintenance: boolean;
|
|
connected: boolean;
|
|
loading: boolean;
|
|
error: string;
|
|
};
|
|
export type Status = {
|
|
account: { available: boolean; label?: string; plan?: string; error?: string };
|
|
providers?: { cerebras?: { available: boolean } };
|
|
graphReady: boolean;
|
|
login?: { verificationUrl: string; userCode: string };
|
|
error?: string | null;
|
|
seed?: { directory: Ref; agent: Ref; thread: Ref; data: Agent["data"]; instructions: string; confirmedAt: string };
|
|
};
|
|
export const terminal = new Set(["completed", "failed", "cancelled", "uncertain"]);
|
|
export type ThreadController = {
|
|
getSnapshot(): ThreadState;
|
|
subscribe(callback: () => void): () => void;
|
|
submit(
|
|
text: string,
|
|
options?: { profile?: string; response?: unknown; repair?: boolean; retryOf?: string },
|
|
): Promise<void>;
|
|
control(input: Record<string, unknown>): Promise<void>;
|
|
refresh(older?: boolean): Promise<void>;
|
|
details(request: string): Promise<unknown>;
|
|
close(): void;
|
|
};
|
|
export const itemKey = (item: Item) => `${item.request._camino.ref.object}/${item.data.key}`;
|