Import apps/android/src/types.ts
This commit is contained in:
parent
8cba6510ca
commit
91c7d276d4
|
|
@ -0,0 +1,516 @@
|
||||||
|
import type { TransportStats } from '@dsh-remote/protocol'
|
||||||
|
import type { AdaptiveConnectionDetails } from '@dsh-remote/webrtc'
|
||||||
|
import { strings as zhCN } from './locales/i18n'
|
||||||
|
|
||||||
|
export type AgentBackend = 'harness' | 'codex' | 'cursor' | 'antigravity' | 'pi' | 'opencode' | 'claude' | 'hermes'
|
||||||
|
|
||||||
|
export type ConnectionPhase =
|
||||||
|
| 'disconnected'
|
||||||
|
| 'connecting'
|
||||||
|
| 'connected'
|
||||||
|
| 'reconnecting'
|
||||||
|
| 'offline'
|
||||||
|
|
||||||
|
export type ConnectionStage =
|
||||||
|
| 'authenticating'
|
||||||
|
| 'transport'
|
||||||
|
| 'secure'
|
||||||
|
| 'loading'
|
||||||
|
| 'ready'
|
||||||
|
|
||||||
|
export type ConnectionProbeTransport = 'lan' | 'p2p' | 'turn' | 'relay'
|
||||||
|
|
||||||
|
export type LoginMethod = 'oauth' | 'github-oauth' | 'google-oauth' | 'password'
|
||||||
|
|
||||||
|
export type RedirectLoginMethod = Exclude<LoginMethod, 'password'>
|
||||||
|
|
||||||
|
export interface ServerConfig {
|
||||||
|
baseUrl: string
|
||||||
|
account?: string
|
||||||
|
loginMethod?: LoginMethod
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeviceIdentity {
|
||||||
|
deviceId: string
|
||||||
|
name: string
|
||||||
|
platform: 'android'
|
||||||
|
publicKey: string
|
||||||
|
privateKey: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeviceCredentials {
|
||||||
|
serverUrl: string
|
||||||
|
deviceId: string
|
||||||
|
authorizationMethod: 'account' | 'owned_device'
|
||||||
|
account?: string
|
||||||
|
accessToken: string
|
||||||
|
accessTokenExpiresAt: number
|
||||||
|
refreshToken: string
|
||||||
|
refreshTokenExpiresAt: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A Host visible through same-account membership, with its pinned identity key. */
|
||||||
|
export interface RemoteDevice {
|
||||||
|
deviceId: string
|
||||||
|
name: string
|
||||||
|
platform: string
|
||||||
|
/** Pinned Noise static X25519 public key; never replaced by a Server response. */
|
||||||
|
identityKey: string
|
||||||
|
membershipId: string
|
||||||
|
online: boolean
|
||||||
|
role?: 'host' | 'client'
|
||||||
|
clientVersion?: string
|
||||||
|
harnessVersion?: string
|
||||||
|
lastSeenAt?: number
|
||||||
|
fingerprint?: string
|
||||||
|
trusted: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DevicePresence {
|
||||||
|
deviceId: string
|
||||||
|
online: boolean
|
||||||
|
lastSeenAt?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HostDescriptor {
|
||||||
|
version: string
|
||||||
|
cwd: string
|
||||||
|
provider?: string
|
||||||
|
model?: string
|
||||||
|
attachedSessions: number
|
||||||
|
canOpenPath: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorkspaceView {
|
||||||
|
workspaceId: string
|
||||||
|
backend?: AgentBackend
|
||||||
|
nativeId?: string
|
||||||
|
path: string
|
||||||
|
title: string
|
||||||
|
sessionIds: string[]
|
||||||
|
createdAt: string
|
||||||
|
updatedAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorkspaceList {
|
||||||
|
items: WorkspaceView[]
|
||||||
|
archivedSessionIds: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Locally remembered workspace shortcut: a favorite, or a recently visited workspace. */
|
||||||
|
export interface WorkspaceShortcut {
|
||||||
|
deviceId: string
|
||||||
|
/** Host name snapshot so the link still renders while the device is offline. */
|
||||||
|
deviceName: string
|
||||||
|
/** Durable identity from `workspaceStableKey`; survives CodeX project id changes. */
|
||||||
|
key: string
|
||||||
|
workspaceId: string
|
||||||
|
backend: AgentBackend
|
||||||
|
title: string
|
||||||
|
path: string
|
||||||
|
/** When this shortcut was recorded: favorited time, or last visit for recent items. */
|
||||||
|
addedAt: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DirectoryEntry {
|
||||||
|
name: string
|
||||||
|
path: string
|
||||||
|
hidden: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DirectoryListing {
|
||||||
|
path: string
|
||||||
|
home: string
|
||||||
|
crumbs: DirectoryEntry[]
|
||||||
|
entries: DirectoryEntry[]
|
||||||
|
truncated: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelSelection {
|
||||||
|
provider: string
|
||||||
|
model: string
|
||||||
|
reasoningEffort?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelReasoningEffort {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelReasoning {
|
||||||
|
efforts: ModelReasoningEffort[]
|
||||||
|
defaultEffort?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelCatalogModel {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
description?: string
|
||||||
|
reasoning?: ModelReasoning
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelProviderGroup {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
models: ModelCatalogModel[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModelCatalogFailure {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SessionModels {
|
||||||
|
current: ModelSelection
|
||||||
|
routable: boolean
|
||||||
|
groups: ModelProviderGroup[]
|
||||||
|
failures: ModelCatalogFailure[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Native Harness session row projection. */
|
||||||
|
/** One durable roster row from the session's `agentTeam` projection. */
|
||||||
|
export interface TeamMemberSnapshot {
|
||||||
|
id: string
|
||||||
|
/** Present on wire rows for real members; the Lead pseudo-row may omit it. */
|
||||||
|
name?: string
|
||||||
|
/** Role description shown as the member's identity in the team list. */
|
||||||
|
description?: string
|
||||||
|
provider?: string
|
||||||
|
context?: 'fresh' | 'fork'
|
||||||
|
phase?: 'provisioning' | 'active' | 'failed'
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One durable task row from the session's `agentTeam` projection. */
|
||||||
|
export interface TeamTaskSnapshot {
|
||||||
|
id: string
|
||||||
|
revision: number
|
||||||
|
subject: string
|
||||||
|
description: string
|
||||||
|
status: 'pending' | 'in_progress' | 'completed' | 'deleted'
|
||||||
|
/** Owning member's session id; absent = unassigned. */
|
||||||
|
ownerId?: string
|
||||||
|
blockedBy: string[]
|
||||||
|
writeScopes: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Team state published through the `agentTeam` session projection. */
|
||||||
|
export interface AgentTeamState {
|
||||||
|
id: string
|
||||||
|
members: TeamMemberSnapshot[]
|
||||||
|
tasks: TeamTaskSnapshot[]
|
||||||
|
failure?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RemoteSession {
|
||||||
|
sessionId: string
|
||||||
|
backend?: AgentBackend
|
||||||
|
nativeId?: string
|
||||||
|
updatedAt: number
|
||||||
|
running: boolean
|
||||||
|
blank: boolean
|
||||||
|
title?: string
|
||||||
|
parentSessionId?: string
|
||||||
|
origin?: 'subagent'
|
||||||
|
cwd?: string
|
||||||
|
agentPreset?: string
|
||||||
|
projections?: {
|
||||||
|
values?: Record<string, unknown>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PermissionPresetOption {
|
||||||
|
value: string
|
||||||
|
name: string
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One agent-preset (mode) roster row from the Host. */
|
||||||
|
export interface AgentPresetOption {
|
||||||
|
id: string
|
||||||
|
isDefault: boolean
|
||||||
|
name?: string
|
||||||
|
description?: string
|
||||||
|
broken?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PermissionSelect {
|
||||||
|
currentValue: string
|
||||||
|
options: PermissionPresetOption[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CodexPermissionPreset = 'workspace-write' | 'danger-full-access'
|
||||||
|
|
||||||
|
/** Shared presets supported by both Harness and CodeX; default preserves backend behavior. */
|
||||||
|
export type DefaultPermissionPreset = 'default' | CodexPermissionPreset
|
||||||
|
|
||||||
|
export interface HistoryEntry {
|
||||||
|
event: NativeSessionEvent
|
||||||
|
view?: { for: 'call' | 'result'; view: unknown }
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SessionHistoryPage {
|
||||||
|
events: HistoryEntry[]
|
||||||
|
hasMore: boolean
|
||||||
|
activeTurnId?: string
|
||||||
|
throughSeq?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatItemBase {
|
||||||
|
id: string
|
||||||
|
sessionId: string
|
||||||
|
createdAt: number
|
||||||
|
/** Authoritative event coordinates; absent on optimistic/non-timestamped frames. */
|
||||||
|
nativeSeq?: number
|
||||||
|
nativeTime?: number
|
||||||
|
/** First event position, retained when a tool result updates the same row. */
|
||||||
|
nativeOrderSeq?: number
|
||||||
|
/** Latest update, including the carrier's fractional transient chunk positions. */
|
||||||
|
nativeRevisionSeq?: number
|
||||||
|
turn?: string
|
||||||
|
/** Authoritative turn/end evidence; no reply sequence is replaced by this event. */
|
||||||
|
turnEnd?: { reason: 'completed' | 'stopped' | 'failed'; time: number; detail?: string }
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatMessage extends ChatItemBase {
|
||||||
|
kind: 'message'
|
||||||
|
role: 'user' | 'assistant' | 'system'
|
||||||
|
text: string
|
||||||
|
/** Native turn identifier used to merge multiple reasoning segments in one reply. */
|
||||||
|
replyGroup?: string
|
||||||
|
reasoning?: string
|
||||||
|
images?: ChatImage[]
|
||||||
|
streaming?: boolean
|
||||||
|
streamingPhase?: 'reasoning' | 'text'
|
||||||
|
/** Native session.prompt rpcId used to reconcile an optimistic user message. */
|
||||||
|
requestRpcId?: string
|
||||||
|
/**
|
||||||
|
* Delivery state of a local optimistic user message.
|
||||||
|
* `queued`: the Host accepted the prompt into its queue (authoritative via
|
||||||
|
* the `inbox` projection) — hidden from the timeline and shown in the queue
|
||||||
|
* dock until an inbox update releases it or a `user/message` echo replaces it.
|
||||||
|
* `failed`: the Host rejected the prompt — kept with a retry affordance.
|
||||||
|
* `unconfirmed`: timeout/disconnect, or leaving the inbox without an echo,
|
||||||
|
* left the outcome unknown — visible until a
|
||||||
|
* history/inbox reconciliation decides its fate (never judged by timers).
|
||||||
|
* `canceled`: reconciliation found the queued prompt neither echoed nor in
|
||||||
|
* the inbox (removed remotely); kept quiet in the timeline, and a late echo
|
||||||
|
* still replaces it.
|
||||||
|
*/
|
||||||
|
sendState?: 'queued' | 'failed' | 'unconfirmed' | 'canceled'
|
||||||
|
/** Human-readable delivery failure reason kept on the row (single error surface). */
|
||||||
|
sendError?: string
|
||||||
|
/** The Host inbox adopted this local prompt — it must never re-enter the local queue fallback. */
|
||||||
|
queuedAdopted?: boolean
|
||||||
|
/** Original prompt image payloads kept for retries (the row's `images` are display-only). */
|
||||||
|
promptImages?: PromptImage[]
|
||||||
|
context?: boolean
|
||||||
|
feedback?: 'positive' | 'negative'
|
||||||
|
usage?: { inputTokens: number; outputTokens: number; totalTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number; reasoningTokens?: number }
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outcome of one send attempt.
|
||||||
|
* `sent`: the Host accepted the prompt (or the command ran).
|
||||||
|
* `kept`: delivery failed but the message row (and its retry material) is kept
|
||||||
|
* in the timeline with an inline state — the caller must not restore the draft.
|
||||||
|
* `rejected`: nothing was persisted (command failure / empty input) — the
|
||||||
|
* caller should restore the draft.
|
||||||
|
*/
|
||||||
|
export type SendMessageResult = 'sent' | 'kept' | 'rejected'
|
||||||
|
|
||||||
|
/** Temporary image bytes carried only in one native session.prompt request. */
|
||||||
|
export interface PromptImage {
|
||||||
|
uri: string
|
||||||
|
mediaType: ImageMediaType
|
||||||
|
data: string
|
||||||
|
bytes: number
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
name?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Image presentation; durable references remain bound to their owning session. */
|
||||||
|
export interface ChatImage {
|
||||||
|
attachmentId?: string
|
||||||
|
sessionId?: string
|
||||||
|
uri?: string
|
||||||
|
name?: string
|
||||||
|
mediaType?: string
|
||||||
|
/** Encoded byte length of a durable Host attachment, required by the 0.2.2 read contract. */
|
||||||
|
bytes?: number
|
||||||
|
width?: number
|
||||||
|
height?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ImageAttachmentLimits {
|
||||||
|
maxImageBytes: number
|
||||||
|
maxImagesPerMessage: number
|
||||||
|
maxMessageImageBytes: number
|
||||||
|
maxImagePixels: number
|
||||||
|
maxImageDimension: number
|
||||||
|
mediaTypes: readonly ImageMediaType[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ToolActivity extends ChatItemBase {
|
||||||
|
remoteDetail?: {threadId: string; detailId: string}
|
||||||
|
kind: 'tool'
|
||||||
|
toolName: string
|
||||||
|
/** Original official tool name, separate from its localized display title. */
|
||||||
|
toolKey?: string
|
||||||
|
images?: ChatImage[]
|
||||||
|
arguments?: string
|
||||||
|
summary?: string
|
||||||
|
callDetail?: ToolDisplayDetail
|
||||||
|
resultDetail?: ToolDisplayDetail
|
||||||
|
/** Complete native tool-result metadata; never truncated into ToolDisplayDetail. */
|
||||||
|
uiResultMeta?: unknown
|
||||||
|
state: 'running' | 'finished' | 'failed'
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ToolDisplayDetail {
|
||||||
|
text: string
|
||||||
|
format: 'code' | 'markdown'
|
||||||
|
truncated?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApprovalActivity extends ChatItemBase {
|
||||||
|
kind: 'approval'
|
||||||
|
approvalId: string
|
||||||
|
toolName: string
|
||||||
|
callId?: string
|
||||||
|
reason?: string
|
||||||
|
frameRpcId?: string
|
||||||
|
outcome?: ApprovalOutcome
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable'
|
||||||
|
|
||||||
|
export interface QuestionActivity extends ChatItemBase {
|
||||||
|
kind: 'question'
|
||||||
|
callId?: string
|
||||||
|
questionState?: 'open' | 'continued'
|
||||||
|
deadline?: number
|
||||||
|
frameRpcId?: string
|
||||||
|
questions: AskUserQuestionItem[]
|
||||||
|
outcome?: 'answered' | 'cancelled' | 'queued'
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ChatItem = ChatMessage | ToolActivity | ApprovalActivity | QuestionActivity
|
||||||
|
|
||||||
|
/** Wire-safe question surface (mirrors @deepseek-ai/dsh-user-questions/types). */
|
||||||
|
export interface AskUserQuestionOption {
|
||||||
|
label: string
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AskUserQuestionItem {
|
||||||
|
id: string
|
||||||
|
question: string
|
||||||
|
detail?: string
|
||||||
|
header?: string
|
||||||
|
options?: AskUserQuestionOption[]
|
||||||
|
multiSelect?: boolean
|
||||||
|
intent?: { kind: 'plan-review'; approve: string }
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AskUserQuestionAnswer {
|
||||||
|
answers: Array<{ id: string; selected: string[]; custom?: string }>
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Structural mirror of @deepseek-ai/dsh-session SessionEvent (wire subset used by chat). */
|
||||||
|
export interface NativeSessionEvent {
|
||||||
|
type: string
|
||||||
|
seq: number
|
||||||
|
time: number
|
||||||
|
data: Record<string, unknown>
|
||||||
|
sourceEventSeqs?: number[]
|
||||||
|
surfaceOp?: 'append'
|
||||||
|
| { op: 'replace'; start: number; end: number }
|
||||||
|
| { op: 'replace'; startSeq: number; endSeq: number }
|
||||||
|
ignorable?: true
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MuxFrame {
|
||||||
|
type: string
|
||||||
|
sessionId?: string
|
||||||
|
turn?: string | number
|
||||||
|
key?: string
|
||||||
|
value?: unknown
|
||||||
|
seq?: number
|
||||||
|
event?: NativeSessionEvent
|
||||||
|
view?: unknown
|
||||||
|
lastSeq?: number
|
||||||
|
approvalId?: string
|
||||||
|
toolName?: string
|
||||||
|
callId?: string
|
||||||
|
reason?: string
|
||||||
|
outcome?: string
|
||||||
|
questions?: AskUserQuestionItem[]
|
||||||
|
questionState?: 'open' | 'continued'
|
||||||
|
deadline?: number
|
||||||
|
questionRpcId?: string
|
||||||
|
error?: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One mux stream frame with its native rpcId (needed to answer approvals/questions). */
|
||||||
|
export interface MuxStreamFrame {
|
||||||
|
rpcId: string
|
||||||
|
payload: MuxFrame
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HarnessApiFrame {
|
||||||
|
streamId: string
|
||||||
|
frame: { rpcId: string; payload: MuxFrame }
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConnectionSnapshot {
|
||||||
|
phase: ConnectionPhase
|
||||||
|
stats: TransportStats
|
||||||
|
error?: string
|
||||||
|
errorCode?: string
|
||||||
|
/** False for protocol/security refusals or a replaced connection. */
|
||||||
|
retryable?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Diagnostics for the currently selected network path. Kept in memory only. */
|
||||||
|
export type ConnectionNetworkDetails = AdaptiveConnectionDetails
|
||||||
|
|
||||||
|
export interface PairLink {
|
||||||
|
server?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Client-side transport routing preference (mirrors the Web Remote console). */
|
||||||
|
export type TransportPreference = 'auto' | 'turn' | 'relay'
|
||||||
|
|
||||||
|
export interface TransportPreferenceOption {
|
||||||
|
value: TransportPreference
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function transportPreferenceOptions(): TransportPreferenceOption[] {
|
||||||
|
return [
|
||||||
|
{ value: 'auto', name: zhCN.transport.auto, description: zhCN.transport.autoDescription },
|
||||||
|
{ value: 'turn', name: zhCN.transport.turn, description: zhCN.transport.turnDescription },
|
||||||
|
{ value: 'relay', name: zhCN.transport.relay, description: zhCN.transport.relayDescription },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type {
|
||||||
|
ScheduleCatalogEntry,
|
||||||
|
ScheduleCreateRequest,
|
||||||
|
ScheduleDeleteResult,
|
||||||
|
ScheduleDeliveryHistoryResult,
|
||||||
|
ScheduleDeliveryReceipt,
|
||||||
|
ScheduleDeliveryRecord,
|
||||||
|
ScheduleKind,
|
||||||
|
ScheduleRecord,
|
||||||
|
ScheduleTimingChange,
|
||||||
|
ScheduleUpdateRequest,
|
||||||
|
ScheduleUpdateResult,
|
||||||
|
} from '@dsh-remote/client-core'
|
||||||
Loading…
Reference in New Issue