pi-freeflow 1.34.0 → 1.35.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/CHANGELOG.md +30 -0
- package/README.md +65 -33
- package/package.json +1 -1
- package/src/catalog.ts +13 -1
- package/src/cline-accounts.ts +15 -13
- package/src/config.ts +11 -0
- package/src/index.ts +3 -3
- package/src/models.ts +181 -46
- package/src/opencode-fingerprint.ts +143 -16
- package/src/proxy.ts +188 -13
- package/src/tool-translation.ts +112 -33
- package/src/types.ts +162 -162
package/src/types.ts
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core type definitions for pi-freeflow
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export type ProviderApi = "openai-completions" | "openai-responses" | "anthropic-messages";
|
|
6
|
-
export type Upstream = "opencode" | "kilo" | "cline";
|
|
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" | "video";
|
|
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
|
-
/** Shared secret set by /freeflow deploy; proxy sends x-relay-auth only when present. */
|
|
42
|
-
auth?: string;
|
|
43
|
-
}
|
|
44
|
-
export type RelayMode = "auto" | "on" | "off" | "spread";
|
|
45
|
-
|
|
46
|
-
export interface RelayState {
|
|
47
|
-
mode?: RelayMode;
|
|
48
|
-
enabled: boolean;
|
|
49
|
-
url: string;
|
|
50
|
-
relays: KnownRelay[];
|
|
51
|
-
hideWidget?: boolean;
|
|
52
|
-
}
|
|
53
|
-
export type LogLevel = "debug" | "info" | "warn" | "error" | "audit";
|
|
54
|
-
|
|
55
|
-
export interface DebugState {
|
|
56
|
-
debug: boolean;
|
|
57
|
-
level?: LogLevel;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface RawModelItem {
|
|
61
|
-
id: string;
|
|
62
|
-
name?: string;
|
|
63
|
-
context_length?: number;
|
|
64
|
-
max_tokens?: number;
|
|
65
|
-
contextWindow?: number;
|
|
66
|
-
maxTokens?: number;
|
|
67
|
-
reasoning?: boolean;
|
|
68
|
-
[key: string]: unknown;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface CatalogCacheData {
|
|
72
|
-
timestamp: number;
|
|
73
|
-
opencode: string[];
|
|
74
|
-
kilo: string[];
|
|
75
|
-
models?: RegisteredModel[];
|
|
76
|
-
etag?: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ── Extension API & UI Types (compatible with @earendil-works/pi-coding-agent) ──
|
|
80
|
-
|
|
81
|
-
export interface ExtensionUIContext {
|
|
82
|
-
notify(message: string, type?: "info" | "warning" | "error"): void;
|
|
83
|
-
setStatus(key: string, status: string | undefined): void;
|
|
84
|
-
input(prompt: string, placeholder?: string): Promise<string | undefined>;
|
|
85
|
-
select(prompt: string, options: string[]): Promise<string | undefined>;
|
|
86
|
-
confirm?(title: string, message?: string): Promise<boolean>;
|
|
87
|
-
/** Optional status-bar click handler (when host supports clickable widgets) */
|
|
88
|
-
onStatusClick?(handler: () => void | Promise<void>): void | (() => void);
|
|
89
|
-
/** Fallback/alternate names hosts may expose */
|
|
90
|
-
onStatusBarClick?(handler: () => void | Promise<void>): void | (() => void);
|
|
91
|
-
onWidgetClick?(handler: () => void | Promise<void>): void | (() => void);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface ExtensionContext {
|
|
95
|
-
ui: ExtensionUIContext;
|
|
96
|
-
[key: string]: unknown;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface CommandCompletion {
|
|
100
|
-
value: string;
|
|
101
|
-
label?: string;
|
|
102
|
-
description?: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface RegisteredCommand {
|
|
106
|
-
description?: string;
|
|
107
|
-
getArgumentCompletions?: (prefix: string) => CommandCompletion[];
|
|
108
|
-
handler: (args: string, ctx: ExtensionContext) => Promise<void> | void;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface ProviderModelCost {
|
|
112
|
-
input: number;
|
|
113
|
-
output: number;
|
|
114
|
-
cacheRead: number;
|
|
115
|
-
cacheWrite: number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface ProviderModelCompat {
|
|
119
|
-
supportsDeveloperRole?: boolean;
|
|
120
|
-
supportsReasoningEffort?: boolean;
|
|
121
|
-
thinkingFormat?: "openrouter" | string;
|
|
122
|
-
sessionAffinityFormat?: "openai-nosession" | string;
|
|
123
|
-
[key: string]: unknown;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface ProviderModelConfig {
|
|
127
|
-
id: string;
|
|
128
|
-
name: string;
|
|
129
|
-
api?: ProviderApi;
|
|
130
|
-
owned_by?: string;
|
|
131
|
-
reasoning?: boolean;
|
|
132
|
-
thinking?: {
|
|
133
|
-
mode: string;
|
|
134
|
-
efforts?: string[];
|
|
135
|
-
[key: string]: unknown;
|
|
136
|
-
};
|
|
137
|
-
thinkingLevelMap?: ThinkingLevelMap;
|
|
138
|
-
input?: ModelInputType[];
|
|
139
|
-
contextWindow?: number;
|
|
140
|
-
maxTokens?: number;
|
|
141
|
-
cost?: ProviderModelCost;
|
|
142
|
-
compat?: ProviderModelCompat;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface ProviderConfig {
|
|
146
|
-
baseUrl: string;
|
|
147
|
-
apiKey: string;
|
|
148
|
-
api: ProviderApi;
|
|
149
|
-
compat?: {
|
|
150
|
-
supportsDeveloperRole?: boolean;
|
|
151
|
-
[key: string]: unknown;
|
|
152
|
-
};
|
|
153
|
-
models: ProviderModelConfig[];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface ExtensionAPI {
|
|
157
|
-
registerProvider(name: string, config: ProviderConfig): void;
|
|
158
|
-
registerCommand(name: string, spec: RegisteredCommand): void;
|
|
159
|
-
on?(event: string, handler: (event: unknown, ctx: ExtensionContext) => Promise<void> | void): void;
|
|
160
|
-
sendUserMessage?(message: string, options?: { deliverAs?: string }): void;
|
|
161
|
-
[key: string]: unknown;
|
|
162
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for pi-freeflow
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type ProviderApi = "openai-completions" | "openai-responses" | "anthropic-messages";
|
|
6
|
+
export type Upstream = "opencode" | "kilo" | "cline" | "ovh";
|
|
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" | "video";
|
|
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
|
+
/** Shared secret set by /freeflow deploy; proxy sends x-relay-auth only when present. */
|
|
42
|
+
auth?: string;
|
|
43
|
+
}
|
|
44
|
+
export type RelayMode = "auto" | "on" | "off" | "spread";
|
|
45
|
+
|
|
46
|
+
export interface RelayState {
|
|
47
|
+
mode?: RelayMode;
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
url: string;
|
|
50
|
+
relays: KnownRelay[];
|
|
51
|
+
hideWidget?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export type LogLevel = "debug" | "info" | "warn" | "error" | "audit";
|
|
54
|
+
|
|
55
|
+
export interface DebugState {
|
|
56
|
+
debug: boolean;
|
|
57
|
+
level?: LogLevel;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface RawModelItem {
|
|
61
|
+
id: string;
|
|
62
|
+
name?: string;
|
|
63
|
+
context_length?: number;
|
|
64
|
+
max_tokens?: number;
|
|
65
|
+
contextWindow?: number;
|
|
66
|
+
maxTokens?: number;
|
|
67
|
+
reasoning?: boolean;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface CatalogCacheData {
|
|
72
|
+
timestamp: number;
|
|
73
|
+
opencode: string[];
|
|
74
|
+
kilo: string[];
|
|
75
|
+
models?: RegisteredModel[];
|
|
76
|
+
etag?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ── Extension API & UI Types (compatible with @earendil-works/pi-coding-agent) ──
|
|
80
|
+
|
|
81
|
+
export interface ExtensionUIContext {
|
|
82
|
+
notify(message: string, type?: "info" | "warning" | "error"): void;
|
|
83
|
+
setStatus(key: string, status: string | undefined): void;
|
|
84
|
+
input(prompt: string, placeholder?: string): Promise<string | undefined>;
|
|
85
|
+
select(prompt: string, options: string[]): Promise<string | undefined>;
|
|
86
|
+
confirm?(title: string, message?: string): Promise<boolean>;
|
|
87
|
+
/** Optional status-bar click handler (when host supports clickable widgets) */
|
|
88
|
+
onStatusClick?(handler: () => void | Promise<void>): void | (() => void);
|
|
89
|
+
/** Fallback/alternate names hosts may expose */
|
|
90
|
+
onStatusBarClick?(handler: () => void | Promise<void>): void | (() => void);
|
|
91
|
+
onWidgetClick?(handler: () => void | Promise<void>): void | (() => void);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ExtensionContext {
|
|
95
|
+
ui: ExtensionUIContext;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface CommandCompletion {
|
|
100
|
+
value: string;
|
|
101
|
+
label?: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface RegisteredCommand {
|
|
106
|
+
description?: string;
|
|
107
|
+
getArgumentCompletions?: (prefix: string) => CommandCompletion[];
|
|
108
|
+
handler: (args: string, ctx: ExtensionContext) => Promise<void> | void;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ProviderModelCost {
|
|
112
|
+
input: number;
|
|
113
|
+
output: number;
|
|
114
|
+
cacheRead: number;
|
|
115
|
+
cacheWrite: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ProviderModelCompat {
|
|
119
|
+
supportsDeveloperRole?: boolean;
|
|
120
|
+
supportsReasoningEffort?: boolean;
|
|
121
|
+
thinkingFormat?: "openrouter" | string;
|
|
122
|
+
sessionAffinityFormat?: "openai-nosession" | string;
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface ProviderModelConfig {
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
api?: ProviderApi;
|
|
130
|
+
owned_by?: string;
|
|
131
|
+
reasoning?: boolean;
|
|
132
|
+
thinking?: {
|
|
133
|
+
mode: string;
|
|
134
|
+
efforts?: string[];
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
};
|
|
137
|
+
thinkingLevelMap?: ThinkingLevelMap;
|
|
138
|
+
input?: ModelInputType[];
|
|
139
|
+
contextWindow?: number;
|
|
140
|
+
maxTokens?: number;
|
|
141
|
+
cost?: ProviderModelCost;
|
|
142
|
+
compat?: ProviderModelCompat;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface ProviderConfig {
|
|
146
|
+
baseUrl: string;
|
|
147
|
+
apiKey: string;
|
|
148
|
+
api: ProviderApi;
|
|
149
|
+
compat?: {
|
|
150
|
+
supportsDeveloperRole?: boolean;
|
|
151
|
+
[key: string]: unknown;
|
|
152
|
+
};
|
|
153
|
+
models: ProviderModelConfig[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface ExtensionAPI {
|
|
157
|
+
registerProvider(name: string, config: ProviderConfig): void;
|
|
158
|
+
registerCommand(name: string, spec: RegisteredCommand): void;
|
|
159
|
+
on?(event: string, handler: (event: unknown, ctx: ExtensionContext) => Promise<void> | void): void;
|
|
160
|
+
sendUserMessage?(message: string, options?: { deliverAs?: string }): void;
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
}
|