opencode-visual-cache 1.7.0-beta.2 → 1.7.0-beta.4
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/dist/_version.d.ts +1 -1
- package/dist/_version.js +1 -1
- package/dist/balance-providers.js +27 -1
- package/dist/index.js +4 -1
- package/dist/server.d.ts +1 -4
- package/dist/server.js +0 -4
- package/dist/tui.js +31 -2
- package/dist/v2/index.d.ts +3 -1
- package/dist/v2/index.js +3 -0
- package/dist/v2.js +27 -3
- package/package.json +3 -2
- package/src/_version.ts +1 -1
- package/src/balance-providers.ts +25 -1
- package/src/core/color.ts +108 -108
- package/src/core/currency.ts +46 -46
- package/src/core/estimate.ts +36 -36
- package/src/core/format.ts +81 -81
- package/src/core/index.ts +5 -5
- package/src/core/types.ts +17 -17
- package/src/index.tsx +3 -0
- package/src/panel/panel-api.ts +104 -104
- package/src/server.ts +1 -5
- package/src/v2/data.ts +112 -112
- package/src/v2/index.tsx +187 -184
- package/src/v2/sidebar.tsx +69 -69
- package/src/v2/status.tsx +96 -96
- package/src/v2/theme.ts +19 -19
- package/src/v2/types.ts +159 -159
- package/src/v2/v2-panel-api.ts +177 -177
- package/tui/index.js +12 -0
package/src/v2/types.ts
CHANGED
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V2 (opencode2) TUI plugin API — 最小本地类型(实验版)。
|
|
3
|
-
* 运行时由 opencode2 提供,此处仅用于本地类型检查;
|
|
4
|
-
* 结构对应 v2 分支 packages/plugin/src/tui/context.ts。
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export interface App {
|
|
8
|
-
readonly version: string
|
|
9
|
-
readonly channel: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface Theme {
|
|
13
|
-
readonly hue: {
|
|
14
|
-
/** V1 primary 的 V2 等价(v1-migrate.ts:interactive = hues.byToken.primary)。
|
|
15
|
-
* 取 300:更亮(暗背景下 400/500 偏深)。 */
|
|
16
|
-
readonly interactive: { readonly 300: string }
|
|
17
|
-
/** 主题强调色别名。 */
|
|
18
|
-
readonly accent: { readonly 500: string }
|
|
19
|
-
}
|
|
20
|
-
readonly text: {
|
|
21
|
-
readonly default: string
|
|
22
|
-
readonly subdued: string
|
|
23
|
-
readonly feedback: {
|
|
24
|
-
readonly success: { readonly default: string }
|
|
25
|
-
readonly error: { readonly default: string }
|
|
26
|
-
readonly warning: { readonly default: string }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** token 用量:结构与 V1 的 message.tokens 同构,字段以运行时实际数据为准。 */
|
|
32
|
-
export interface TokenUsage {
|
|
33
|
-
input?: number
|
|
34
|
-
output?: number
|
|
35
|
-
reasoning?: number
|
|
36
|
-
cache?: { read?: number; write?: number }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface MessageInfo {
|
|
40
|
-
readonly id: string
|
|
41
|
-
readonly type: string
|
|
42
|
-
readonly agent?: string
|
|
43
|
-
readonly model?: string
|
|
44
|
-
readonly time: { readonly created: number; readonly completed?: number }
|
|
45
|
-
readonly cost?: unknown
|
|
46
|
-
readonly tokens?: TokenUsage
|
|
47
|
-
readonly content?: unknown[]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SessionInfo {
|
|
51
|
-
readonly id: string
|
|
52
|
-
readonly title?: string
|
|
53
|
-
readonly time?: { readonly created: number; readonly updated: number }
|
|
54
|
-
readonly model?: string
|
|
55
|
-
readonly agent?: string
|
|
56
|
-
readonly parentID?: string
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface Data {
|
|
60
|
-
readonly session: {
|
|
61
|
-
get(sessionID: string): SessionInfo | undefined
|
|
62
|
-
list(): SessionInfo[]
|
|
63
|
-
cost(sessionID: string): number
|
|
64
|
-
status(sessionID: string): string
|
|
65
|
-
readonly message: {
|
|
66
|
-
list(sessionID: string): MessageInfo[]
|
|
67
|
-
sync(sessionID: string): Promise<void>
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
readonly location: {
|
|
71
|
-
readonly provider: { list(location?: unknown): unknown[] }
|
|
72
|
-
readonly model: { list(location?: unknown): unknown[] }
|
|
73
|
-
readonly mcp: { readonly server: { list(location?: unknown): unknown[] } }
|
|
74
|
-
}
|
|
75
|
-
readonly on: (type: string, handler: (event: unknown) => void) => () => void
|
|
76
|
-
readonly listen: (handler: (event: unknown) => void) => () => void
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface Storage {
|
|
80
|
-
store<Value extends object>(
|
|
81
|
-
key: string,
|
|
82
|
-
options: { readonly initial: Value },
|
|
83
|
-
): readonly [Value, (mutation: (draft: Value) => void) => Promise<void>]
|
|
84
|
-
memory<Value extends object>(
|
|
85
|
-
key: string,
|
|
86
|
-
options: { readonly initial: Value },
|
|
87
|
-
): readonly [Value, (mutation: (draft: Value) => void) => void]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type SlotClaim = {
|
|
91
|
-
readonly render: (input: Record<string, any>) => unknown
|
|
92
|
-
} & (
|
|
93
|
-
| { readonly append: string; readonly prepend?: never; readonly before?: never; readonly after?: never; readonly replace?: never }
|
|
94
|
-
| { readonly prepend: string; readonly append?: never; readonly before?: never; readonly after?: never; readonly replace?: never }
|
|
95
|
-
| { readonly before: string; readonly append?: never; readonly prepend?: never; readonly after?: never; readonly replace?: never }
|
|
96
|
-
| { readonly after: string; readonly append?: never; readonly prepend?: never; readonly before?: never; readonly replace?: never }
|
|
97
|
-
| { readonly replace: string; readonly append?: never; readonly prepend?: never; readonly before?: never; readonly after?: never }
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
export interface KeymapCommand {
|
|
101
|
-
readonly id?: string
|
|
102
|
-
readonly title?: string
|
|
103
|
-
readonly description?: string
|
|
104
|
-
readonly group?: string
|
|
105
|
-
readonly palette?: true
|
|
106
|
-
readonly slash?: { readonly name: string; readonly aliases?: string[]; readonly arguments?: true }
|
|
107
|
-
/** 旧字段(opencode-dcp 兼容写法:palette 可见性 + slash 补全依赖它们) */
|
|
108
|
-
readonly namespace?: string
|
|
109
|
-
readonly name?: string
|
|
110
|
-
readonly desc?: string
|
|
111
|
-
readonly category?: string
|
|
112
|
-
readonly slashName?: string
|
|
113
|
-
readonly slashAliases?: string[]
|
|
114
|
-
readonly run: (input?: string) => void | false | Promise<void>
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface Context {
|
|
118
|
-
readonly app: App
|
|
119
|
-
readonly options: Record<string, any>
|
|
120
|
-
readonly location: { readonly directory?: string } | undefined
|
|
121
|
-
readonly renderer: { readonly terminalWidth: number }
|
|
122
|
-
readonly theme: Theme
|
|
123
|
-
readonly data: Data
|
|
124
|
-
readonly storage: Storage
|
|
125
|
-
readonly ui: {
|
|
126
|
-
slot(claim: SlotClaim): () => void
|
|
127
|
-
readonly toast: {
|
|
128
|
-
show(options: { readonly message: string; readonly title?: string; readonly variant?: string }): void
|
|
129
|
-
}
|
|
130
|
-
readonly dialog: {
|
|
131
|
-
prompt(options: { readonly title: string; readonly message?: string; readonly placeholder?: string }): Promise<string | undefined>
|
|
132
|
-
select<Value>(options: {
|
|
133
|
-
readonly title: string
|
|
134
|
-
readonly placeholder?: string
|
|
135
|
-
readonly options: readonly {
|
|
136
|
-
readonly title: string
|
|
137
|
-
readonly value: Value
|
|
138
|
-
readonly description?: string
|
|
139
|
-
readonly category?: string
|
|
140
|
-
readonly disabled?: boolean
|
|
141
|
-
}[]
|
|
142
|
-
readonly current?: Value
|
|
143
|
-
}): Promise<Value | undefined>
|
|
144
|
-
}
|
|
145
|
-
/** 当前路由:命令需要当前会话 ID(V2 Route = { type: "session", sessionID })。 */
|
|
146
|
-
readonly router: {
|
|
147
|
-
current(): { readonly type?: string; readonly sessionID?: string; readonly params?: Record<string, unknown> }
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
readonly keymap: {
|
|
151
|
-
layer(input: () => { readonly commands?: readonly KeymapCommand[] }): void
|
|
152
|
-
shortcuts(id: string): readonly string[]
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export type PluginModule = {
|
|
157
|
-
readonly id: string
|
|
158
|
-
readonly setup: (context: Context) => void | (() => void | Promise<void>) | Promise<void | (() => void | Promise<void>)>
|
|
159
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* V2 (opencode2) TUI plugin API — 最小本地类型(实验版)。
|
|
3
|
+
* 运行时由 opencode2 提供,此处仅用于本地类型检查;
|
|
4
|
+
* 结构对应 v2 分支 packages/plugin/src/tui/context.ts。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface App {
|
|
8
|
+
readonly version: string
|
|
9
|
+
readonly channel: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Theme {
|
|
13
|
+
readonly hue: {
|
|
14
|
+
/** V1 primary 的 V2 等价(v1-migrate.ts:interactive = hues.byToken.primary)。
|
|
15
|
+
* 取 300:更亮(暗背景下 400/500 偏深)。 */
|
|
16
|
+
readonly interactive: { readonly 300: string }
|
|
17
|
+
/** 主题强调色别名。 */
|
|
18
|
+
readonly accent: { readonly 500: string }
|
|
19
|
+
}
|
|
20
|
+
readonly text: {
|
|
21
|
+
readonly default: string
|
|
22
|
+
readonly subdued: string
|
|
23
|
+
readonly feedback: {
|
|
24
|
+
readonly success: { readonly default: string }
|
|
25
|
+
readonly error: { readonly default: string }
|
|
26
|
+
readonly warning: { readonly default: string }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** token 用量:结构与 V1 的 message.tokens 同构,字段以运行时实际数据为准。 */
|
|
32
|
+
export interface TokenUsage {
|
|
33
|
+
input?: number
|
|
34
|
+
output?: number
|
|
35
|
+
reasoning?: number
|
|
36
|
+
cache?: { read?: number; write?: number }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface MessageInfo {
|
|
40
|
+
readonly id: string
|
|
41
|
+
readonly type: string
|
|
42
|
+
readonly agent?: string
|
|
43
|
+
readonly model?: string
|
|
44
|
+
readonly time: { readonly created: number; readonly completed?: number }
|
|
45
|
+
readonly cost?: unknown
|
|
46
|
+
readonly tokens?: TokenUsage
|
|
47
|
+
readonly content?: unknown[]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface SessionInfo {
|
|
51
|
+
readonly id: string
|
|
52
|
+
readonly title?: string
|
|
53
|
+
readonly time?: { readonly created: number; readonly updated: number }
|
|
54
|
+
readonly model?: string
|
|
55
|
+
readonly agent?: string
|
|
56
|
+
readonly parentID?: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface Data {
|
|
60
|
+
readonly session: {
|
|
61
|
+
get(sessionID: string): SessionInfo | undefined
|
|
62
|
+
list(): SessionInfo[]
|
|
63
|
+
cost(sessionID: string): number
|
|
64
|
+
status(sessionID: string): string
|
|
65
|
+
readonly message: {
|
|
66
|
+
list(sessionID: string): MessageInfo[]
|
|
67
|
+
sync(sessionID: string): Promise<void>
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
readonly location: {
|
|
71
|
+
readonly provider: { list(location?: unknown): unknown[] }
|
|
72
|
+
readonly model: { list(location?: unknown): unknown[] }
|
|
73
|
+
readonly mcp: { readonly server: { list(location?: unknown): unknown[] } }
|
|
74
|
+
}
|
|
75
|
+
readonly on: (type: string, handler: (event: unknown) => void) => () => void
|
|
76
|
+
readonly listen: (handler: (event: unknown) => void) => () => void
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface Storage {
|
|
80
|
+
store<Value extends object>(
|
|
81
|
+
key: string,
|
|
82
|
+
options: { readonly initial: Value },
|
|
83
|
+
): readonly [Value, (mutation: (draft: Value) => void) => Promise<void>]
|
|
84
|
+
memory<Value extends object>(
|
|
85
|
+
key: string,
|
|
86
|
+
options: { readonly initial: Value },
|
|
87
|
+
): readonly [Value, (mutation: (draft: Value) => void) => void]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type SlotClaim = {
|
|
91
|
+
readonly render: (input: Record<string, any>) => unknown
|
|
92
|
+
} & (
|
|
93
|
+
| { readonly append: string; readonly prepend?: never; readonly before?: never; readonly after?: never; readonly replace?: never }
|
|
94
|
+
| { readonly prepend: string; readonly append?: never; readonly before?: never; readonly after?: never; readonly replace?: never }
|
|
95
|
+
| { readonly before: string; readonly append?: never; readonly prepend?: never; readonly after?: never; readonly replace?: never }
|
|
96
|
+
| { readonly after: string; readonly append?: never; readonly prepend?: never; readonly before?: never; readonly replace?: never }
|
|
97
|
+
| { readonly replace: string; readonly append?: never; readonly prepend?: never; readonly before?: never; readonly after?: never }
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
export interface KeymapCommand {
|
|
101
|
+
readonly id?: string
|
|
102
|
+
readonly title?: string
|
|
103
|
+
readonly description?: string
|
|
104
|
+
readonly group?: string
|
|
105
|
+
readonly palette?: true
|
|
106
|
+
readonly slash?: { readonly name: string; readonly aliases?: string[]; readonly arguments?: true }
|
|
107
|
+
/** 旧字段(opencode-dcp 兼容写法:palette 可见性 + slash 补全依赖它们) */
|
|
108
|
+
readonly namespace?: string
|
|
109
|
+
readonly name?: string
|
|
110
|
+
readonly desc?: string
|
|
111
|
+
readonly category?: string
|
|
112
|
+
readonly slashName?: string
|
|
113
|
+
readonly slashAliases?: string[]
|
|
114
|
+
readonly run: (input?: string) => void | false | Promise<void>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface Context {
|
|
118
|
+
readonly app: App
|
|
119
|
+
readonly options: Record<string, any>
|
|
120
|
+
readonly location: { readonly directory?: string } | undefined
|
|
121
|
+
readonly renderer: { readonly terminalWidth: number }
|
|
122
|
+
readonly theme: Theme
|
|
123
|
+
readonly data: Data
|
|
124
|
+
readonly storage: Storage
|
|
125
|
+
readonly ui: {
|
|
126
|
+
slot(claim: SlotClaim): () => void
|
|
127
|
+
readonly toast: {
|
|
128
|
+
show(options: { readonly message: string; readonly title?: string; readonly variant?: string }): void
|
|
129
|
+
}
|
|
130
|
+
readonly dialog: {
|
|
131
|
+
prompt(options: { readonly title: string; readonly message?: string; readonly placeholder?: string }): Promise<string | undefined>
|
|
132
|
+
select<Value>(options: {
|
|
133
|
+
readonly title: string
|
|
134
|
+
readonly placeholder?: string
|
|
135
|
+
readonly options: readonly {
|
|
136
|
+
readonly title: string
|
|
137
|
+
readonly value: Value
|
|
138
|
+
readonly description?: string
|
|
139
|
+
readonly category?: string
|
|
140
|
+
readonly disabled?: boolean
|
|
141
|
+
}[]
|
|
142
|
+
readonly current?: Value
|
|
143
|
+
}): Promise<Value | undefined>
|
|
144
|
+
}
|
|
145
|
+
/** 当前路由:命令需要当前会话 ID(V2 Route = { type: "session", sessionID })。 */
|
|
146
|
+
readonly router: {
|
|
147
|
+
current(): { readonly type?: string; readonly sessionID?: string; readonly params?: Record<string, unknown> }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
readonly keymap: {
|
|
151
|
+
layer(input: () => { readonly commands?: readonly KeymapCommand[] }): void
|
|
152
|
+
shortcuts(id: string): readonly string[]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export type PluginModule = {
|
|
157
|
+
readonly id: string
|
|
158
|
+
readonly setup: (context: Context) => void | (() => void | Promise<void>) | Promise<void | (() => void | Promise<void>)>
|
|
159
|
+
}
|