forked from co-l/openfox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.ts
More file actions
415 lines (377 loc) · 9.66 KB
/
Copy pathplugin.ts
File metadata and controls
415 lines (377 loc) · 9.66 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
export type LocalizedString = { en: string; fr: string }
export type PluginCapability =
| 'providers'
| 'models'
| 'settings'
| 'tools'
| 'commands'
| 'skills'
| 'ui'
| 'hooks'
| 'notifications'
| 'workflows'
| 'rpc'
| 'assets'
export type PluginSlotName =
| 'header.actions'
| 'session.header.actions'
| 'message.actions'
| 'composer.actions'
| 'session.row.badges'
| 'session.header.badges'
| (string & {})
export type PluginZoneId =
| 'header'
| 'header.brand'
| 'header.nav'
| 'header.actions'
| 'header.status'
| 'sidebar'
| 'sidebar.header'
| 'sidebar.project_selector'
| 'sidebar.nav'
| 'sidebar.sessions_list'
| 'sidebar.footer'
| 'session.header'
| 'session.header.title'
| 'session.header.actions'
| 'session.header.badges'
| 'session.content'
| 'session.messages'
| 'message.bubble'
| 'message.actions'
| 'composer'
| 'composer.toolbar'
| 'composer.actions'
| 'session.footer'
| 'settings.sidebar'
| 'settings.content'
| 'modal.footer'
| (string & {})
export type PluginBadgeTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger'
export type PluginActivation =
| { kind: 'rpc'; method: string; params?: Record<string, unknown> }
| { kind: 'openPanel'; panelId: string }
| { kind: 'openUrl'; url: string }
/**
* Declarative visibility for a contribution. Every field is ANDed; omitted
* fields impose no constraint. Context values come from the slot host
* (e.g. a session row passes sessionId, a message menu passes messageId).
*/
export interface PluginVisibilityCondition {
hasSession?: boolean
hasProject?: boolean
hasMessage?: boolean
}
export interface PluginUiAction {
id: string
pluginId?: string
slot: PluginSlotName
label: LocalizedString
icon?: string
variant?: 'default' | 'primary' | 'danger' | 'ghost'
tooltip?: LocalizedString
visibleWhen?: PluginVisibilityCondition
onActivate: PluginActivation
}
export type PluginUiBadgeAppearance = 'badge' | 'icon'
export type PluginUiBadgeCacheScope = 'context' | 'session' | 'workdir' | 'project'
export interface PluginUiBadgeDynamicState {
visible?: boolean
value?: string | number
label?: LocalizedString
tone?: PluginBadgeTone
tooltip?: LocalizedString
icon?: string
}
export interface PluginUiBadgeRpcSource {
kind: 'rpc'
method: string
/** Optional live refresh interval. Omit for the default cache-only behavior. */
refreshMs?: number
/** Controls RPC de-duplication when the same badge is rendered in many rows. */
cacheScope?: PluginUiBadgeCacheScope
}
export interface PluginUiBadge {
id: string
pluginId?: string
slot: PluginSlotName
label: LocalizedString
tone?: PluginBadgeTone
tooltip?: LocalizedString
icon?: string
/** Compact icon-only rendering for passive status indicators. */
appearance?: PluginUiBadgeAppearance
value?: string
visibleWhen?: PluginVisibilityCondition
source?: PluginUiBadgeRpcSource
}
export type DeclarativeNode =
| { type: 'text'; text: LocalizedString; muted?: boolean; className?: string }
| { type: 'keyValue'; items: { key: LocalizedString; value: string }[] }
| { type: 'table'; columns: LocalizedString[]; rows: string[][] }
| { type: 'progress'; label: LocalizedString; value: number; max: number; tone?: PluginBadgeTone }
| { type: 'badge'; label: LocalizedString; tone?: PluginBadgeTone }
| {
type: 'button'
label: LocalizedString
variant?: 'default' | 'primary' | 'danger' | 'ghost' | 'pill'
icon?: string
onActivate: PluginActivation
}
| { type: 'divider' }
| {
type: 'stack'
direction?: 'row' | 'column'
gap?: 'none' | 'xs' | 'sm' | 'md' | 'lg'
align?: 'start' | 'center' | 'end' | 'stretch'
justify?: 'start' | 'center' | 'end' | 'between'
className?: string
children: DeclarativeNode[]
}
| {
type: 'card'
title?: LocalizedString
subtitle?: LocalizedString
tone?: PluginBadgeTone
className?: string
children: DeclarativeNode[]
}
| {
type: 'callout'
tone?: PluginBadgeTone
title?: LocalizedString
text: LocalizedString
icon?: string
}
| {
type: 'icon'
icon: string
tone?: PluginBadgeTone
className?: string
}
| {
type: 'details'
title: LocalizedString
defaultOpen?: boolean
className?: string
children: DeclarativeNode[]
}
| {
type: 'input'
id: string
placeholder?: LocalizedString
defaultValue?: string
label?: LocalizedString
inputType?: 'text' | 'number' | 'password'
onChange?: PluginActivation
onBlur?: PluginActivation
}
| {
type: 'select'
id: string
label?: LocalizedString
options: { value: string; label: LocalizedString }[]
defaultValue?: string
onChange?: PluginActivation
onBlur?: PluginActivation
}
| {
type: 'iframe'
url: string
height?: string | number
width?: string | number
}
export interface PluginUiComponent {
id: string
pluginId?: string
zone: PluginZoneId
position?: 'before' | 'after' | 'inside'
order?: number
visibleWhen?: PluginVisibilityCondition
component: DeclarativeNode
}
export interface PluginUiOverride {
id: string
pluginId?: string
zone: PluginZoneId
mode: 'hide' | 'replace'
order?: number
visibleWhen?: PluginVisibilityCondition
replacement?: DeclarativeNode
}
export interface PluginUiPanel {
id: string
pluginId?: string
title: LocalizedString
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full'
kind: 'declarative' | 'iframe'
content?: DeclarativeNode[]
url?: string
}
export interface PluginSettingsTab {
id: string
pluginId?: string
label: LocalizedString
icon?: string
order?: number
content: DeclarativeNode[]
}
export interface PluginUiContributions {
actions: PluginUiAction[]
badges: PluginUiBadge[]
panels: PluginUiPanel[]
sections: PluginUiSection[]
components: PluginUiComponent[]
overrides: PluginUiOverride[]
settingsTabs: PluginSettingsTab[]
}
export interface PluginUiSection {
id: string
pluginId: string
title: LocalizedString
schema: PluginSettingsSchema
}
export interface PluginUiStatePayload {
pluginId: string
panelId?: string
key: string
value: unknown
}
export type PluginSettingScope = 'global' | 'project'
export type PluginSettingValue = string | number | boolean
export interface PluginSettingsOption {
value: string
label: LocalizedString
}
export interface PluginSettingsField {
key: string
type: 'text' | 'password' | 'number' | 'boolean' | 'select' | 'textarea' | 'path' | 'button'
label: LocalizedString
buttonLabel?: LocalizedString
rpcMethod?: string
description?: LocalizedString
default?: PluginSettingValue
options?: PluginSettingsOption[]
required?: boolean
secret?: boolean
placeholder?: string
scope?: PluginSettingScope
parentKey?: string
width?: 'full' | 'half'
section?: LocalizedString
}
export interface PluginSettingsSchema {
fields: PluginSettingsField[]
}
export type PluginSettingsValues = Record<string, PluginSettingValue>
export interface PluginModelPopoverRow {
label: LocalizedString
value: string
strikeThroughValue?: string
tone?: PluginBadgeTone
}
export interface PluginModelPopoverView {
title?: LocalizedString
badge?: { label: LocalizedString; tone?: PluginBadgeTone }
rows?: PluginModelPopoverRow[]
footer?: LocalizedString
}
export interface PluginModelSublineItem {
text: string
tone?: PluginBadgeTone
}
export interface PluginModelBadge {
label: LocalizedString
tooltip?: LocalizedString
tone?: PluginBadgeTone
icon?: string
}
export interface PluginModelMetadataView {
contextWindow?: number
vision?: boolean
reasoning?: boolean
nameTone?: PluginBadgeTone
popover?: PluginModelPopoverView
subline?: PluginModelSublineItem[]
bottomSubline?: PluginModelSublineItem[]
badges?: PluginModelBadge[]
extra?: Record<string, unknown>
}
export interface PluginContributionSummary {
presets: number
authAdapters: number
transportAdapters: number
modelMetadataProviders: number
tools: number
commands: number
skillSources: number
hooks: number
rpcMethods: number
transitions: number
settingsFields: number
uiActions: number
uiBadges: number
uiPanels: number
settingsTabs: number
uiComponents: number
uiOverrides: number
}
export interface PluginInfo {
id: string
displayName: string
description?: string
icon?: string
logo?: string
version: string
apiVersion: 1 | 2
source: string
enabled: boolean
loaded: boolean
error?: string
capabilities: PluginCapability[]
contributions: PluginContributionSummary
/** False when the plugin was discovered outside {configDir}/plugins (e.g. node_modules). */
removable: boolean
}
export type PluginNotificationLevel = 'info' | 'success' | 'warning' | 'error'
export interface PluginNotificationAction {
label: LocalizedString
onActivate: PluginActivation
}
export interface PluginNotification {
id: string
pluginId: string
title: LocalizedString
body?: LocalizedString
level: PluginNotificationLevel
actions?: PluginNotificationAction[]
createdAt: string
readAt?: string
}
export interface PluginNotificationPayload {
notification: PluginNotification
}
export interface PluginNotificationDeletedPayload {
id?: string
all?: boolean
}
export const EMPTY_PLUGIN_CONTRIBUTIONS: PluginContributionSummary = {
presets: 0,
authAdapters: 0,
transportAdapters: 0,
modelMetadataProviders: 0,
tools: 0,
commands: 0,
skillSources: 0,
hooks: 0,
rpcMethods: 0,
transitions: 0,
settingsFields: 0,
uiActions: 0,
uiBadges: 0,
uiPanels: 0,
settingsTabs: 0,
uiComponents: 0,
uiOverrides: 0,
}