repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/prune/src/types.ts
RawFile outline
- Message line 7
- role line 8
- content line 9
- toolName line 10
- toolCallId line 11
- isError line 12
- thinking line 13
- redacted line 14
- ContentPart line 17
- type line 18
- text line 19
- name line 20
- arguments line 21
- thinking line 22
- redacted line 23
- mimeType line 24
- BlockKind line 29
- Block line 31
- kind line 32
- text line 33
- sourceIndex line 34
- name line 35
- args line 36
- isError line 37
- ExtractOutput line 42
- goals line 43
- scopeChanges line 44
- files line 45
- context line 50
- preferences line 51
- transcript line 52
- TranscriptEntry line 55
- role line 56
- text line 57
- tool line 58
- cmd line 59
- ref line 60
- count line 61
- PruneOutput line 66
- summary line 67
- stats line 68
- PruneStats line 71
- messagesIn line 72
- messagesOut line 73
- reduction line 74
- elapsedMs line 75
- SearchScope line 80
- SearchInput line 82
- query line 83
- scope line 84
- limit line 85
- expand line 86
- SearchResult line 89
- index line 90
- entry line 91
- role line 92
- score line 93
- context line 94
- PruneSettings line 99
- overrideDefault line 100
- sectionLimit line 101
- transcriptLimit line 102
- toolCapPerTurn line 103
- debug line 104
/**
* prune — types
*/
// ─── Core Types ────────────────────────────────────────────────────────────────
export interface Message {
role: 'user' | 'assistant' | 'tool' | 'toolResult' | 'bashExecution' | 'custom' | 'branchSummary' | 'compactionSummary';
content?: string | ContentPart[];
toolName?: string;
toolCallId?: string;
isError?: boolean;
thinking?: string;
redacted?: boolean;
}
export interface ContentPart {
type: 'text' | 'toolCall' | 'thinking' | 'image';
text?: string;
name?: string;
arguments?: Record<string, unknown>;
thinking?: string;
redacted?: boolean;
mimeType?: string;
}
// ─── Block Types ──────────────────────────────────────────────────────────────
export type BlockKind = 'user' | 'assistant' | 'tool_call' | 'tool_result' | 'thinking';
export interface Block {
kind: BlockKind;
text: string;
sourceIndex: number;
name?: string;
args?: Record<string, unknown>;
isError?: boolean;
}
// ─── Extract Output ───────────────────────────────────────────────────────────
export interface ExtractOutput {
goals: string[];
scopeChanges: string[];
files: {
modified: Set<string>;
created: Set<string>;
read: Set<string>;
};
context: string[];
preferences: string[];
transcript: TranscriptEntry[];
}
export interface TranscriptEntry {
role: 'user' | 'assistant' | 'error';
text: string;
tool?: string;
cmd?: string;
ref?: string;
count?: number;
}
// ─── Prune Output ────────────────────────────────────────────────────────────
export interface PruneOutput {
summary: string;
stats: PruneStats;
}
export interface PruneStats {
messagesIn: number;
messagesOut: number;
reduction: number;
elapsedMs: number;
}
// ─── Search Types ─────────────────────────────────────────────────────────────
export type SearchScope = 'lineage' | 'all';
export interface SearchInput {
query: string | RegExp;
scope?: SearchScope;
limit?: number;
expand?: number[];
}
export interface SearchResult {
index: number;
entry: Message;
role: 'user' | 'assistant' | 'tool';
score: number;
context?: string;
}
// ─── Settings ────────────────────────────────────────────────────────────────
export interface PruneSettings {
overrideDefault?: boolean;
sectionLimit?: number;
transcriptLimit?: number;
toolCapPerTurn?: number;
debug?: boolean;
}