File size: 3,772 Bytes
4e23b01 | 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | import type {
AgentId,
FrameId,
StepId,
TaskId,
TurnId,
} from '../model/ids';
import type { TranscriptAttachment } from '../model/attachment';
import type { TranscriptFrame } from '../model/frame';
import type { TranscriptInteraction } from '../model/interaction';
import type { TranscriptItem, TranscriptMarker, TranscriptTaskRef } from '../model/item';
import type { TranscriptMeta, TranscriptMetaMerge } from '../model/meta';
import type { TranscriptPrompt } from '../model/prompt';
import type { TranscriptTask } from '../model/task';
import type { TranscriptTodo } from '../model/todo';
import type { TranscriptStep, TranscriptTurn } from '../model/turn';
export type TurnHeader = Omit<TranscriptTurn, 'steps'>;
export type StepHeader = Omit<TranscriptStep, 'frames'>;
export interface ResetOp {
readonly op: 'reset';
readonly agentId: AgentId;
readonly snapshot: AgentTranscriptSnapshot;
}
export interface TurnUpsertOp {
readonly op: 'turn.upsert';
readonly turn: TurnHeader;
}
export interface StepUpsertOp {
readonly op: 'step.upsert';
readonly turnId: TurnId;
readonly step: StepHeader;
}
export interface FrameUpsertOp {
readonly op: 'frame.upsert';
readonly turnId: TurnId;
readonly stepId: StepId;
readonly frame: TranscriptFrame;
}
export type AppendTarget =
| { readonly type: 'frame'; readonly turnId: TurnId; readonly stepId: StepId; readonly frameId: FrameId }
| { readonly type: 'task'; readonly taskId: TaskId };
export interface AppendOp {
readonly op: 'append';
readonly target: AppendTarget;
readonly offset: number;
readonly text: string;
}
export interface MarkerUpsertOp {
readonly op: 'marker.upsert';
readonly item: TranscriptMarker;
readonly beforeTurn?: number;
}
export interface TaskRefUpsertOp {
readonly op: 'taskref.upsert';
readonly item: TranscriptTaskRef;
readonly beforeTurn?: number;
}
export interface TaskUpsertOp {
readonly op: 'task.upsert';
readonly task: TranscriptTask;
}
export interface InteractionUpsertOp {
readonly op: 'interaction.upsert';
readonly interaction: TranscriptInteraction;
}
export interface AttachmentUpsertOp {
readonly op: 'attachment.upsert';
readonly attachment: TranscriptAttachment;
}
export interface TodoUpsertOp {
readonly op: 'todo.upsert';
readonly todo: TranscriptTodo;
}
export interface PromptUpsertOp {
readonly op: 'prompt.upsert';
readonly prompt: TranscriptPrompt;
}
export interface MetaMergeOp {
readonly op: 'meta.merge';
readonly meta: TranscriptMetaMerge;
}
export interface ItemsRemoveOp {
readonly op: 'items.remove';
readonly ids: readonly string[];
}
export type TranscriptOperation =
| ResetOp
| TurnUpsertOp
| StepUpsertOp
| FrameUpsertOp
| AppendOp
| MarkerUpsertOp
| TaskRefUpsertOp
| TaskUpsertOp
| InteractionUpsertOp
| AttachmentUpsertOp
| TodoUpsertOp
| PromptUpsertOp
| MetaMergeOp
| ItemsRemoveOp;
export interface TranscriptOpBatch {
readonly agentId: AgentId;
readonly ops: readonly TranscriptOperation[];
}
export interface AgentTranscriptSnapshot {
readonly items: readonly TranscriptItem[];
readonly tasks: readonly TranscriptTask[];
readonly interactions: readonly TranscriptInteraction[];
readonly attachments: readonly TranscriptAttachment[];
readonly todos: readonly TranscriptTodo[];
readonly prompts: readonly TranscriptPrompt[];
readonly meta: TranscriptMeta;
readonly hasMoreOlder?: boolean;
}
export interface AppliedOps {
readonly accepted: readonly TranscriptOperation[];
readonly gap?: { readonly target: AppendTarget; readonly expected: number; readonly got: number };
}
export interface TranscriptChangeEvent {
readonly agentId: AgentId;
readonly ops: readonly TranscriptOperation[];
}
|