-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathupstream-types.ts
More file actions
187 lines (169 loc) · 5.91 KB
/
Copy pathupstream-types.ts
File metadata and controls
187 lines (169 loc) · 5.91 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
/**
* Upstream-compatible type definitions.
*
* These mirror the shapes a client expects from the server API.
*/
// ── Session ───────────────────────────────────────────────────────
export interface SessionInfo {
id: string
slug: string
projectID: string
workspaceID?: string
directory: string
parentID?: string
title: string
version: string
summary?: {
additions: number
deletions: number
files: number
diffs?: unknown[]
}
share?: { url: string }
time: {
created: number
updated: number
compacting?: number
archived?: number
}
permission?: Array<{ permission: string; pattern: string; action: string }>
revert?: {
messageID: string
partID?: string
snapshot?: string
diff?: string
}
}
// ── Config ────────────────────────────────────────────────────────
export interface ConfigInfo {
$schema?: string
agent?: Record<string, AgentConfig>
mode?: Record<string, AgentConfig>
plugin?: unknown[]
command?: Record<string, { template: string; description?: string; agent?: string; model?: string }>
provider?: Record<string, unknown>
mcp?: Record<string, unknown>
permission?: Record<string, unknown>
tools?: Record<string, boolean>
username?: string
disabled_providers?: string[]
enabled_providers?: string[]
model?: string
small_model?: string
default_agent?: string
instructions?: string[]
experimental?: Record<string, unknown>
}
export interface AgentConfig {
model?: string
variant?: string
temperature?: number
prompt?: string
description?: string
mode?: "subagent" | "primary" | "all"
hidden?: boolean
color?: string
steps?: number
permission?: Record<string, unknown>
options?: Record<string, unknown>
tools?: Record<string, boolean>
disable?: boolean
}
// ── Agent (runtime info, returned by GET /agent) ──────────────────
export interface AgentInfo {
name: string
description?: string
mode?: "subagent" | "primary" | "all"
native?: boolean
hidden?: boolean
temperature?: number
color?: string
prompt?: string
options: Record<string, unknown>
permission?: Array<{ permission: string; action: string; pattern: string }>
model?: { modelID: string; providerID: string }
variant?: string
steps?: number
}
// ── Provider ──────────────────────────────────────────────────────
export interface Model {
id: string
providerID: string
name: string
family?: string
api: { id: string; url: string; npm: string }
status: "alpha" | "beta" | "deprecated" | "active"
headers: Record<string, string>
options: Record<string, unknown>
cost: {
input: number
output: number
cache: { read: number; write: number }
}
limit: { context: number; output: number; input?: number }
capabilities: {
temperature: boolean
reasoning: boolean
attachment: boolean
toolcall: boolean
input: { text: boolean; audio: boolean; image: boolean; video: boolean; pdf: boolean }
output: { text: boolean; audio: boolean; image: boolean; video: boolean; pdf: boolean }
interleaved: boolean | { field: string }
}
release_date: string
variants?: Record<string, Record<string, unknown>>
}
export interface Provider {
id: string
name: string
source: "env" | "config" | "custom" | "api"
env: string[]
options: Record<string, unknown>
models: Record<string, Model>
}
export interface ProviderListResponse {
all: Provider[]
default: Record<string, string>
connected: string[]
}
// ── Project ───────────────────────────────────────────────────────
export interface ProjectInfo {
id: string
worktree: string
vcs?: string
name?: string
time: {
created: number
updated: number
initialized?: number
}
sandboxes?: string[]
}
// ── Bus Events ────────────────────────────────────────────────────
export type SessionStatus =
| { type: "idle" }
| { type: "busy" }
| { type: "retry"; attempt: number; message: string; next: number }
export type BusEventPayload =
| { type: "server.connected"; properties: Record<string, never> }
| { type: "server.heartbeat"; properties: Record<string, never> }
| { type: "session.created"; properties: { sessionID: string; info: SessionInfo } }
| { type: "session.updated"; properties: { sessionID: string; info: SessionInfo } }
| { type: "session.deleted"; properties: { sessionID: string; info: SessionInfo } }
| { type: "message.updated"; properties: { sessionID: string; info: unknown } }
| { type: "message.part.updated"; properties: { sessionID: string; part: unknown; time: number } }
| { type: "message.part.delta"; properties: { sessionID: string; messageID: string; partID: string; field: string; delta: string } }
| { type: "session.status"; properties: { sessionID: string; status: SessionStatus } }
| { type: "session.idle"; properties: { sessionID: string } }
| { type: "session.error"; properties: { sessionID?: string; error?: unknown } }
| { type: string; properties: Record<string, unknown> }
// ── Helpers ───────────────────────────────────────────────────────
let _counter = 0
export function generateSlug(title: string): string {
const base = title
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "")
.slice(0, 40)
return `${base}-${(++_counter).toString(36)}`
}