pi-freeflow 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Core type definitions for pi-freeflow
3
+ */
4
+
5
+ export type ProviderApi = "openai-completions" | "openai-responses";
6
+ export type Upstream = "opencode" | "kilo";
7
+
8
+ export type ThinkingLevel =
9
+ | "off"
10
+ | "minimal"
11
+ | "low"
12
+ | "medium"
13
+ | "high"
14
+ | "xhigh"
15
+ | "max";
16
+
17
+ export type ThinkingLevelMap = Partial<Record<ThinkingLevel, string | null>>;
18
+
19
+ export type ModelInputType = "text" | "image";
20
+
21
+ export interface ModelDef {
22
+ id: string;
23
+ name: string;
24
+ reasoning: boolean;
25
+ contextWindow: number;
26
+ maxTokens: number;
27
+ api?: ProviderApi;
28
+ input?: ModelInputType[];
29
+ thinkingFormat?: "openrouter";
30
+ thinkingLevelMap?: ThinkingLevelMap;
31
+ }
32
+
33
+ export type RegisteredModel = ModelDef & {
34
+ source: Upstream;
35
+ };
36
+
37
+ export interface KnownRelay {
38
+ url: string;
39
+ label?: string;
40
+ addedAt?: string;
41
+ }
42
+
43
+ export interface RelayState {
44
+ enabled: boolean;
45
+ url: string;
46
+ relays: KnownRelay[];
47
+ }
48
+
49
+ export type LogLevel = "debug" | "info" | "warn" | "error" | "audit";
50
+
51
+ export interface DebugState {
52
+ debug: boolean;
53
+ level?: LogLevel;
54
+ }
55
+
56
+ export interface RawModelItem {
57
+ id: string;
58
+ name?: string;
59
+ context_length?: number;
60
+ max_tokens?: number;
61
+ contextWindow?: number;
62
+ maxTokens?: number;
63
+ reasoning?: boolean;
64
+ [key: string]: unknown;
65
+ }
66
+
67
+ export interface CatalogCacheData {
68
+ timestamp: number;
69
+ opencode: string[];
70
+ kilo: string[];
71
+ models?: RegisteredModel[];
72
+ }
73
+
74
+ export interface RateLimitEntry {
75
+ count: number;
76
+ resetAt: number;
77
+ }
78
+
79
+ export interface RateLimitStatus {
80
+ allowed: boolean;
81
+ remaining: number;
82
+ resetAt: number;
83
+ limit: number;
84
+ count: number;
85
+ }
86
+
87
+ // ── Extension API & UI Types (compatible with @earendil-works/pi-coding-agent) ──
88
+
89
+ export interface ExtensionUIContext {
90
+ notify(message: string, type?: "info" | "warning" | "error"): void;
91
+ setStatus(key: string, status: string | undefined): void;
92
+ input(prompt: string, defaultValue?: string): Promise<string | undefined>;
93
+ select(prompt: string, options: string[]): Promise<string | undefined>;
94
+ confirm?(prompt: string): Promise<boolean>;
95
+ }
96
+
97
+ export interface ExtensionContext {
98
+ ui: ExtensionUIContext;
99
+ [key: string]: unknown;
100
+ }
101
+
102
+ export interface CommandCompletion {
103
+ value: string;
104
+ label?: string;
105
+ description?: string;
106
+ }
107
+
108
+ export interface RegisteredCommand {
109
+ description?: string;
110
+ getArgumentCompletions?: (prefix: string) => CommandCompletion[];
111
+ handler: (args: string, ctx: ExtensionContext) => Promise<void> | void;
112
+ }
113
+
114
+ export interface ProviderModelCost {
115
+ input: number;
116
+ output: number;
117
+ cacheRead: number;
118
+ cacheWrite: number;
119
+ }
120
+
121
+ export interface ProviderModelCompat {
122
+ supportsDeveloperRole?: boolean;
123
+ supportsReasoningEffort?: boolean;
124
+ thinkingFormat?: "openrouter" | string;
125
+ sessionAffinityFormat?: "openai-nosession" | string;
126
+ [key: string]: unknown;
127
+ }
128
+
129
+ export interface ProviderModelConfig {
130
+ id: string;
131
+ name: string;
132
+ api?: ProviderApi;
133
+ reasoning?: boolean;
134
+ thinking?: {
135
+ mode: string;
136
+ efforts?: string[];
137
+ [key: string]: unknown;
138
+ };
139
+ thinkingLevelMap?: ThinkingLevelMap;
140
+ input?: ModelInputType[];
141
+ contextWindow?: number;
142
+ maxTokens?: number;
143
+ cost?: ProviderModelCost;
144
+ compat?: ProviderModelCompat;
145
+ }
146
+
147
+ export interface ProviderConfig {
148
+ baseUrl: string;
149
+ apiKey: string;
150
+ api: ProviderApi;
151
+ compat?: {
152
+ supportsDeveloperRole?: boolean;
153
+ [key: string]: unknown;
154
+ };
155
+ models: ProviderModelConfig[];
156
+ }
157
+
158
+ export interface ExtensionAPI {
159
+ registerProvider(name: string, config: ProviderConfig): void;
160
+ registerCommand(name: string, spec: RegisteredCommand): void;
161
+ on?(event: string, handler: (event: unknown, ctx: ExtensionContext) => Promise<void> | void): void;
162
+ sendUserMessage?(message: string, options?: { deliverAs?: string }): void;
163
+ [key: string]: unknown;
164
+ }