Three provider kinds have a browser sign-in, but the add-provider dialog only accepted a pasted key. A per-account login record now runs the adapter's InteractiveLogin on the server, reports the instruction, URL, and code to the dialog, and stores the credential before the browser sees completion. The credential never reaches the client. The dialog gets a sign-in stage for flow kinds, with a link, a copyable code, and retry after failure. Closing the dialog cancels the flow. ChatGPT's callback lands on the server's loopback port, and the instruction names the port to forward.
394 lines
6.9 KiB
TypeScript
394 lines
6.9 KiB
TypeScript
export interface User {
|
|
id: string
|
|
handle: string
|
|
display_name: string
|
|
kind: string
|
|
avatar_updated_at: number | null
|
|
}
|
|
|
|
export interface BootstrapResponse {
|
|
needs_setup: boolean
|
|
user: User | null
|
|
allow_registration: boolean
|
|
public_url: string
|
|
preview_origin: string
|
|
}
|
|
|
|
export interface Message {
|
|
seq: number
|
|
id: string
|
|
author_id: string | null
|
|
author_name: string
|
|
author_kind: 'human' | 'agent' | 'system'
|
|
text: string
|
|
mentions: boolean
|
|
created_at: number
|
|
}
|
|
|
|
export interface MessagePage {
|
|
messages: Message[]
|
|
has_more: boolean
|
|
}
|
|
|
|
export interface SendMessageResponse {
|
|
message: Message
|
|
}
|
|
|
|
export interface RoomSummary {
|
|
id: string
|
|
name: string
|
|
role: string
|
|
member_count: number
|
|
last_at: number | null
|
|
last_text: string | null
|
|
}
|
|
|
|
export interface RoomListResponse {
|
|
rooms: RoomSummary[]
|
|
}
|
|
|
|
export interface Room {
|
|
id: string
|
|
name: string
|
|
owner_id: string
|
|
provider_config_id: string | null
|
|
sandbox_target_id: string | null
|
|
workspace: string
|
|
repo_url: string | null
|
|
model: string | null
|
|
max_turn_steps: number
|
|
created_at: number
|
|
archived_at: number | null
|
|
}
|
|
|
|
export interface Member {
|
|
id: string
|
|
account_id: string
|
|
display_name: string
|
|
role: string
|
|
color: string
|
|
avatar_updated_at: number | null
|
|
online: boolean
|
|
}
|
|
|
|
export interface Me {
|
|
id: string
|
|
display_name: string
|
|
role: string
|
|
color: string
|
|
}
|
|
|
|
export type PreviewTarget =
|
|
| { kind: 'port'; port: number }
|
|
| { kind: 'static'; path: string; root: string; entry: string }
|
|
|
|
export interface RoomDetailResponse {
|
|
room: Room
|
|
members: Member[]
|
|
preview: PreviewTarget | null
|
|
me: Me
|
|
}
|
|
|
|
export interface CreateRoomBody {
|
|
name: string
|
|
provider_config_id: string
|
|
sandbox_target_id: string
|
|
workspace?: string
|
|
repo_url?: string
|
|
model?: string
|
|
}
|
|
|
|
export interface CreateRoomResponse {
|
|
room: Room
|
|
}
|
|
|
|
export interface UpdateRoomBody {
|
|
name?: string
|
|
provider_config_id?: string
|
|
model?: string
|
|
max_turn_steps?: number
|
|
}
|
|
|
|
export interface UpdateRoomResponse {
|
|
room: Room
|
|
}
|
|
|
|
export interface Invite {
|
|
token: string
|
|
url: string
|
|
expires_at: number
|
|
}
|
|
|
|
export interface InvitePreview {
|
|
room_id: string
|
|
room_name: string
|
|
owner: string
|
|
role: string
|
|
expires_at: number
|
|
}
|
|
|
|
export interface JoinResponse {
|
|
user: User
|
|
room_id: string
|
|
member: { id: string; role: string }
|
|
}
|
|
|
|
export interface ProviderConfig {
|
|
id: string
|
|
name: string
|
|
kind: string
|
|
model: string
|
|
base_url: string | null
|
|
}
|
|
|
|
export interface ProviderListResponse {
|
|
providers: ProviderConfig[]
|
|
kinds: string[]
|
|
flow_kinds: string[]
|
|
}
|
|
|
|
export interface LoginInstruction {
|
|
text: string
|
|
url: string | null
|
|
code: string | null
|
|
}
|
|
|
|
export type LoginFlowPhase = 'starting' | 'instruct' | 'waiting' | 'completed' | 'failed'
|
|
|
|
export interface LoginFlowStatus {
|
|
status: LoginFlowPhase
|
|
instruction?: LoginInstruction
|
|
message?: string
|
|
provider_id?: string
|
|
}
|
|
|
|
export interface StartLoginResponse {
|
|
id: string
|
|
}
|
|
|
|
export interface ModelPricing {
|
|
input_per_mtok: number
|
|
output_per_mtok: number
|
|
cached_input_per_mtok: number | null
|
|
}
|
|
|
|
export interface ModelCard {
|
|
id: string
|
|
display_name: string
|
|
description: string
|
|
input_token_limit: number | null
|
|
output_token_limit: number | null
|
|
supports_vision?: boolean | null
|
|
generation_methods: string[]
|
|
pricing?: ModelPricing | null
|
|
family?: string | null
|
|
release_date?: string | null
|
|
}
|
|
|
|
export interface ProviderModelsResponse {
|
|
provider: { id: string; kind: string; model: string }
|
|
models: ModelCard[]
|
|
}
|
|
|
|
export interface CreateProviderBody {
|
|
name: string
|
|
kind: string
|
|
model?: string
|
|
base_url?: string | null
|
|
api_key?: string
|
|
}
|
|
|
|
export interface IdResponse {
|
|
id: string
|
|
}
|
|
|
|
export interface SandboxTarget {
|
|
id: string
|
|
name: string
|
|
host: string
|
|
port: number
|
|
user_name: string
|
|
workspace_root: string
|
|
public_key: string
|
|
host_fingerprint: string | null
|
|
}
|
|
|
|
export interface SandboxListResponse {
|
|
targets: SandboxTarget[]
|
|
}
|
|
|
|
export interface CreateSandboxBody {
|
|
name: string
|
|
host: string
|
|
port?: number
|
|
user_name?: string
|
|
workspace_root?: string
|
|
private_key?: string
|
|
}
|
|
|
|
export interface CreateSandboxResponse {
|
|
id: string
|
|
public_key: string
|
|
}
|
|
|
|
export interface TestSandboxResponse {
|
|
ok: boolean
|
|
detail: string
|
|
}
|
|
|
|
export interface FileEntry {
|
|
name: string
|
|
path: string
|
|
kind: 'dir' | 'file' | 'link'
|
|
size: number
|
|
}
|
|
|
|
export interface FileListResponse {
|
|
path: string
|
|
entries: FileEntry[]
|
|
}
|
|
|
|
export interface FileContentResponse {
|
|
path: string
|
|
content: string
|
|
binary: boolean
|
|
size: number
|
|
truncated: boolean
|
|
}
|
|
|
|
export interface GitSummaryResponse {
|
|
text: string
|
|
code: number | null
|
|
}
|
|
|
|
export interface PreviewResponse {
|
|
url: string
|
|
target: PreviewTarget
|
|
}
|
|
|
|
export interface PresencePeer {
|
|
member_id: string
|
|
display_name: string
|
|
color: string
|
|
state: PresenceState | null
|
|
}
|
|
|
|
export interface PresenceState {
|
|
typing?: boolean
|
|
[key: string]: unknown
|
|
}
|
|
|
|
export interface PresenceEvent {
|
|
type: 'presence'
|
|
peers: PresencePeer[]
|
|
}
|
|
|
|
export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }
|
|
|
|
export interface Envelope {
|
|
seq: number
|
|
kind: string
|
|
data: JsonValue
|
|
}
|
|
|
|
export interface Usage {
|
|
input_tokens: number
|
|
output_tokens: number
|
|
cached_input_tokens: number
|
|
cost_usd: number | null
|
|
}
|
|
|
|
export interface NoticeData {
|
|
level: string
|
|
text: string
|
|
at: number
|
|
}
|
|
|
|
export interface TurnStartData {
|
|
turn_id: string
|
|
by: string
|
|
model: string
|
|
at: number
|
|
}
|
|
|
|
export interface TurnEndData {
|
|
turn_id: string
|
|
status: 'done' | 'error' | 'interrupted' | 'step_limit' | 'max_tokens'
|
|
error?: string
|
|
usage: Usage
|
|
steps: number
|
|
}
|
|
|
|
export interface DeltaData {
|
|
turn_id: string
|
|
delta: string
|
|
}
|
|
|
|
export interface StepStartData {
|
|
turn_id: string
|
|
iteration: number
|
|
}
|
|
|
|
export interface ToolStartData {
|
|
turn_id: string
|
|
call_id: string
|
|
name: string
|
|
}
|
|
|
|
export interface ToolArgsData {
|
|
turn_id: string
|
|
call_id: string
|
|
delta: string
|
|
}
|
|
|
|
export interface ToolOutputData {
|
|
turn_id: string
|
|
call_id: string
|
|
chunk: string
|
|
}
|
|
|
|
export interface ToolResultData {
|
|
turn_id: string
|
|
call_id: string
|
|
name: string
|
|
args: string
|
|
content: string
|
|
is_error: boolean
|
|
code: number | null
|
|
}
|
|
|
|
export interface UsageEventData extends Usage {
|
|
turn_id: string
|
|
}
|
|
|
|
export interface ToolActivity {
|
|
call_id: string
|
|
name: string
|
|
args: string
|
|
output: string
|
|
content: string | null
|
|
isError: boolean | null
|
|
code: number | null
|
|
done: boolean
|
|
}
|
|
|
|
export type TurnStatus = 'running' | 'done' | 'error' | 'interrupted' | 'step_limit' | 'max_tokens'
|
|
|
|
export interface TurnActivity {
|
|
turnId: string
|
|
seq: number
|
|
startedAt: number
|
|
text: string
|
|
thinking: string
|
|
steps: number
|
|
tools: ToolActivity[]
|
|
usage: Usage | null
|
|
status: TurnStatus
|
|
error: string
|
|
}
|
|
|
|
export type TimelineEntry =
|
|
| { kind: 'message'; seq: number; message: Message }
|
|
| { kind: 'notice'; seq: number; level: string; text: string }
|
|
| { kind: 'turn'; seq: number; activity: TurnActivity }
|