File size: 994 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
import type { MarkerId, TaskId, TaskRefId } from './ids';
import type { TranscriptTurn } from './turn';

export type MarkerKey = string;

export const KNOWN_MARKERS = [
  'compaction',
  'undo',
  'clear',
  'goal',
  'plan.enter',
  'plan.exit',
  'plan.revision',
  'swarm.enter',
  'swarm.exit',
  'skill',
  'cron.fired',
  'notice',
  'hook',
] as const;

export interface TranscriptMarker {
  readonly kind: 'marker';
  readonly markerId: MarkerId;
  readonly marker: MarkerKey;
  readonly payload?: unknown;
  readonly at?: string;
}

export interface TranscriptTaskRef {
  readonly kind: 'taskref';
  readonly refId: TaskRefId;
  readonly taskId: TaskId;
  readonly at?: string;
}

export type TranscriptItem = TranscriptTurn | TranscriptMarker | TranscriptTaskRef;

export function itemId(item: TranscriptItem): string {
  switch (item.kind) {
    case 'turn':
      return item.turnId;
    case 'marker':
      return item.markerId;
    case 'taskref':
      return item.refId;
  }
}