| 1 | import type { WireStreamAttempt, WireCompaction, WireSessionOperation } from "./transcriptEventTypes"; |
| 2 | export type { WireStreamAttempt, WireCompaction, WireSessionOperation } from "./transcriptEventTypes"; |
| 3 | import type { HistoryToolCall } from "./historyToolTypes"; |
| 4 | export type { HistoryToolCall } from "./historyToolTypes"; |
| 5 | export type { ProjectNode } from "./projectNodeTypes"; |
| 6 | import type { TranscriptTurnMetadata } from "./transcriptProtocol"; |
| 7 | import type { ConnectionAuthentication } from "./authenticationTypes"; |
| 8 | import type { HistorySwitchPhases } from "./sessionDiagnostics"; |
| 9 | import type { ProviderCatalog } from "./providerCatalogTypes"; |
| 10 | export type { SettingsView } from "./settingsViewTypes"; |
| 11 | export type { ProviderProtocolEndpoint, ProviderCatalog, ProviderPresetView } from "./providerCatalogTypes"; |
| 12 | import type { WireReadStatus } from "./readStatus"; |
| 13 | export type { WireReadStatus } from "./readStatus"; |
| 14 | import type { RecoveryEventFields } from "./recoveryStatus"; |
| 15 | // Wire contract: one discriminated event channel mirrors desktop/wire.go and internal/serve/wire.go. |
| 16 | import type { HistoryServerSearch } from "./searchSources"; |
| 17 | import type { Todo } from "./tools"; |
| 18 | import type { ContextBudgetInfo, ContextMaintenanceInfo, WireContextMaintenance } from "./contextMaintenanceTypes"; |
| 19 | import type { WireApproval } from "./approvalTypes"; |
| 20 | import type { RemoteSessionMetaFields, RemoteTabMetaFields } from "./remoteTypes"; |
| 21 | import type { PinnedFileInfo } from "./pinnedContextBridge"; |
| 22 | import type { RecoveryLineageView } from "./sessionRecoveryTypes"; |
| 23 | import type { SessionRef, SessionRuntimeIssue } from "./sessionRef"; |
| 24 | export * from "./remoteTypes"; |
| 25 | export type { ContextBudgetInfo, ContextMaintenanceInfo, ContextMaintenanceReceipt, WireContextMaintenance } from "./contextMaintenanceTypes"; |
| 26 | export type { HistoryContentChunk, HistoryContentRef, HistoryEntry, HistorySlice, HistorySliceRequest, HistoryWindowPageView, HistoryWindowRequestView, HistoryWindowStatus, MessageFieldView, SessionClearResult } from "./historyTypes"; |
| 27 | export type { ProjectGroupsSnapshot, ProjectRuntimeTopic, ProjectTopicKey, ProjectTopicPage, ProjectTopicPageRequest, ProjectTreeChangedV2, ProjectTreeOrganizationBindings, ProjectTreeRuntimeSnapshot, ProjectTreeSnapshot, SessionCatalogBindings, SessionCatalogStatus, SessionGroup, SessionReference } from "./sessionCatalogTypes"; |
| 28 | export type { SessionRef, SessionRuntimeIssue } from "./sessionRef"; |
| 29 | export type EventKind = |
| 30 | | "user_message" |
| 31 | | "turn_started" |
| 32 | | "reasoning" |
| 33 | | "text" |
| 34 | | "message" |
| 35 | | "tool_dispatch" |
| 36 | | "tool_started" |
| 37 | | "tool_result" |
| 38 | | "tool_result_preview" |
| 39 | | "turn_status" |
| 40 | | "prompt_answered" | "session_changed" |
| 41 | | "mcp_interaction" |
| 42 | | "tool_progress" |
| 43 | | "usage" |
| 44 | | "notice" |
| 45 | | "phase" |
| 46 | | "approval_request" |
| 47 | | "ask_request" |
| 48 | | "turn_done" |
| 49 | | "compaction_started" |
| 50 | | "compaction_done" |
| 51 | | "mcp_surface_ready" |
| 52 | | "retrying" |
| 53 | | "steer" |
| 54 | | "guardian_assessment" |
| 55 | | "extension_surface" |
| 56 | | "extension_status" |
| 57 | | "stream_attempt" |
| 58 | | "context_maintenance" |
| 59 | | "workspace_changed" |
| 60 | | "turn_phase" |
| 61 | | "completion_summary" |
| 62 | | "read_status" |
| 63 | | "session_operation" |
| 64 | | "provider_unreachable"; |
| 65 | export type StreamAttemptAction = "begin" | "discard" | "commit"; |
| 66 | export type TurnStatus = "queued" | "in_progress" | "waiting_user" | "cancelling" | "completed" | "interrupted" | "failed" | "protocol_failed" | "recovery_required"; |
| 67 | export interface TurnEventEnvelope { |
| 68 | sessionId?: string; |
| 69 | turnId: string; |
| 70 | seq: number; |
| 71 | status: TurnStatus | string; |
| 72 | runtimeEpoch?: string; |
| 73 | submissionId?: string; |
| 74 | transcriptRevision?: number; |
| 75 | transcriptDigest?: string; |
| 76 | event: WireEvent; |
| 77 | } |
| 78 | export interface TurnEventReplayView { |
| 79 | events: TurnEventEnvelope[]; |
| 80 | floorSeq: number; |
| 81 | latestSeq: number; |
| 82 | nextAfterSeq: number; |
| 83 | hasMore: boolean; |
| 84 | resetRequired: boolean; |
| 85 | transcriptRevision?: number; |
| 86 | transcriptDigest?: string; |
| 87 | runtimeEpoch?: string; |
| 88 | } |
| 89 | export interface WireProfile { |
| 90 | model?: string; |
| 91 | effort?: string; |
| 92 | } |
| 93 | |
| 94 | export interface WireShellExecution { |
| 95 | kind?: string; |
| 96 | shell?: string; |
| 97 | shellVersion?: string; |
| 98 | platform?: string; |
| 99 | supportsAndAnd?: boolean; |
| 100 | state?: string; |
| 101 | failurePhase?: string; |
| 102 | exitCode?: number; |
| 103 | outputTail?: string; |
| 104 | mutationRisk?: string; |
| 105 | verification?: string; |
| 106 | durationMs?: number; |
| 107 | } |
| 108 | |
| 109 | export interface WireTool { |
| 110 | diagnostic?: import("./readStatus").OperationDiagnostic; |
| 111 | verifying?: boolean; |
| 112 | id?: string; |
| 113 | name: string; |
| 114 | args?: string; |
| 115 | todos?: Todo[]; |
| 116 | todoWritten?: boolean; |
| 117 | resolvedName?: string; |
| 118 | capabilityId?: string; |
| 119 | output?: string; |
| 120 | err?: string; |
| 121 | readOnly: boolean; |
| 122 | truncated?: boolean; |
| 123 | durationMs?: number; |
| 124 | partial?: boolean; // an early dispatch (name only) — a full one with args follows |
| 125 | argChars?: number; // partial only: cumulative argument chars streamed so far |
| 126 | refreshed?: boolean; // same-ID full dispatch with a preview recomputed after an earlier write |
| 127 | parentId?: string; // set on a sub-agent's calls — the parent `task` call's id |
| 128 | /** Host-local stream_attempt id for speculative parent partials only. */ |
| 129 | attemptId?: string; |
| 130 | diff?: string; |
| 131 | added?: number; |
| 132 | removed?: number; subagentRef?: string; subagentStatus?: string; subagentErrorCode?: string; subagentRetryable?: boolean; |
| 133 | profile?: WireProfile; // subagent model/effort resolved for this call |
| 134 | execution?: WireShellExecution; // local shell metadata; never provider-visible |
| 135 | presentedFiles?: PresentedFile[]; // trusted host-only deliverables from built-in present |
| 136 | } |
| 137 | |
| 138 | export interface PresentedFile { |
| 139 | path: string; |
| 140 | description?: string; |
| 141 | } |
| 142 | |
| 143 | export interface WireCacheDiagnostics { |
| 144 | prefixHash: string; |
| 145 | prefixChanged: boolean; |
| 146 | prefixChangeReasons?: string[]; |
| 147 | systemHash: string; |
| 148 | toolsHash: string; |
| 149 | logRewriteVersion: number; |
| 150 | toolSchemaTokens: number; |
| 151 | cacheMissTokens: number; |
| 152 | cacheHitTokens: number; |
| 153 | sessionContext?: import("./sessionContextTypes").WireSessionContextDiagnostics; |
| 154 | } |
| 155 | export interface WireUsage { |
| 156 | promptTokens: number; |
| 157 | completionTokens: number; |
| 158 | totalTokens: number; |
| 159 | cacheHitTokens: number; |
| 160 | cacheMissTokens: number; |
| 161 | reasoningTokens?: number; |
| 162 | estimated?: boolean; |
| 163 | source?: string; |
| 164 | cacheDiagnostics?: WireCacheDiagnostics; |
| 165 | // Session-cumulative cache tokens — the status bar shows the aggregate |
| 166 | // hit-rate (Σhit/Σ(hit+miss)), steadier than the single-turn cacheHitTokens. |
| 167 | sessionCacheHitTokens: number; |
| 168 | sessionCacheMissTokens: number; |
| 169 | /** Latest single-request shape for context gauges; omit → use billable totals. */ |
| 170 | contextPromptTokens?: number; |
| 171 | contextCompletionTokens?: number; |
| 172 | contextReasoningTokens?: number; |
| 173 | contextCacheHitTokens?: number; |
| 174 | contextCacheMissTokens?: number; |
| 175 | cost?: number; |
| 176 | currency?: string; |
| 177 | currencyCode?: string; |
| 178 | // Deprecated compatibility alias. Prefer cost + currencyCode / costQuote. |
| 179 | costUsd?: number; |
| 180 | costComplete?: boolean; |
| 181 | displayComplete?: boolean; |
| 182 | displayStatus?: string; |
| 183 | aggregateMode?: string; |
| 184 | originalTotals?: Money[]; |
| 185 | /** Host-side structured quote; prefer over cost/currency aliases. */ |
| 186 | costQuote?: CostQuote; |
| 187 | } |
| 188 | |
| 189 | /** Display-only aggregate for one completed chat turn. */ |
| 190 | export interface TurnUsage { |
| 191 | uncachedInputTokens: number; |
| 192 | outputTokens: number; |
| 193 | totalTokens: number; |
| 194 | cacheReadTokens?: number; |
| 195 | reasoningTokens?: number; |
| 196 | routes?: string[]; |
| 197 | } |
| 198 | |
| 199 | export interface Money { |
| 200 | amount: string; |
| 201 | currency: string; |
| 202 | } |
| 203 | |
| 204 | export interface CostQuote { |
| 205 | original: Money; |
| 206 | originalTotals?: Money[]; |
| 207 | valuations?: Record<string, { |
| 208 | money: Money; |
| 209 | basis: string; |
| 210 | source: string; |
| 211 | asOf: string; |
| 212 | rateSnapshot?: { base: string; quote: string; rate: number; source: string; asOf: string; stale?: boolean }; |
| 213 | stale?: boolean; |
| 214 | }>; |
| 215 | selected?: Money; |
| 216 | billingMode?: string; |
| 217 | estimated: boolean; |
| 218 | costComplete?: boolean; |
| 219 | displayComplete?: boolean; |
| 220 | complete: boolean; |
| 221 | displayStatus?: "matched" | "fallback_original" | "bucketed" | "unavailable" | string; |
| 222 | aggregateMode?: "single_currency" | "common_valuation" | "currency_buckets" | string; |
| 223 | modelRef?: string; |
| 224 | usageSource?: string; |
| 225 | pricingFingerprint?: string; |
| 226 | rateDate?: string; |
| 227 | rateBand?: "peak" | "off_peak" | "mixed" | string; |
| 228 | ratedAt?: string; |
| 229 | incompleteReason?: string; |
| 230 | legacyEstimate?: boolean; |
| 231 | catalogSource?: string; |
| 232 | } |
| 233 | |
| 234 | export interface WireRecoveryApproval { |
| 235 | source_agent?: string; |
| 236 | failed_tool?: string; |
| 237 | failed_summary?: string; |
| 238 | diagnosis?: string; |
| 239 | next_tool?: string; |
| 240 | next_action?: string; |
| 241 | change_kind?: string; |
| 242 | change_rationale?: string; |
| 243 | review_rationale?: string; |
| 244 | plan_before?: string; |
| 245 | plan_after?: string; |
| 246 | can_grant_task?: boolean; |
| 247 | task_grant_scope?: string; |
| 248 | } |
| 249 | |
| 250 | export type { WireApproval, WireWriteAccessApproval } from "./approvalTypes"; |
| 251 | |
| 252 | export interface WireGuardian { |
| 253 | id: string; |
| 254 | tool: string; |
| 255 | subject: string; |
| 256 | outcome: string; |
| 257 | risk_level?: string; |
| 258 | user_authorization?: string; |
| 259 | rationale?: string; |
| 260 | duration_ms?: number; |
| 261 | usage?: WireUsage; |
| 262 | } |
| 263 | |
| 264 | export interface WireDecisionReceipt { |
| 265 | id: string; |
| 266 | kind: string; |
| 267 | tool?: string; |
| 268 | subject?: string; |
| 269 | outcome: string; |
| 270 | } |
| 271 | |
| 272 | export interface WireAskOption { |
| 273 | label: string; |
| 274 | description?: string; |
| 275 | } |
| 276 | |
| 277 | export type PromptKind = "ask" | "approval" | "plan" | "recovery" | "mcp"; |
| 278 | export interface PromptIdentity { |
| 279 | promptId: string; |
| 280 | turnId?: string; |
| 281 | runtimeEpoch?: string; |
| 282 | kind: PromptKind; |
| 283 | } |
| 284 | export type PromptLifecycle = "pending" | "submitting" | "resolved" | "expired"; |
| 285 | export interface DecisionCardState { |
| 286 | identity: PromptIdentity; |
| 287 | lifecycle: PromptLifecycle; |
| 288 | failureNoticeShown?: boolean; |
| 289 | } |
| 290 | |
| 291 | export interface WireAskQuestion { |
| 292 | id: string; |
| 293 | header?: string; |
| 294 | prompt: string; |
| 295 | options: WireAskOption[]; |
| 296 | multi?: boolean; |
| 297 | } |
| 298 | |
| 299 | export interface WireAsk { |
| 300 | id: string; |
| 301 | questions: WireAskQuestion[]; |
| 302 | turnId?: string; |
| 303 | runtimeEpoch?: string; |
| 304 | } |
| 305 | |
| 306 | export type { MCPAppInstanceView, MCPAppPresentation } from "./mcpAppProtocol"; |
| 307 | |
| 308 | // One server-initiated MCP elicitation awaiting accept/decline/cancel. Form |
| 309 | // mode carries a flat primitive JSON schema; url mode a credential-free target. |
| 310 | export interface WireMCPInteraction { |
| 311 | id: string; |
| 312 | server: string; |
| 313 | mode: "form" | "url"; |
| 314 | message: string; |
| 315 | requestedSchema?: unknown; |
| 316 | url?: string; |
| 317 | elicitationId?: string; |
| 318 | turnId?: string; |
| 319 | runtimeEpoch?: string; |
| 320 | } |
| 321 | |
| 322 | // Extension UI surfaces (stage 8a) — structured-only documents published by |
| 323 | // extension sidecars through the host UI hub. Exactly one sub-struct is set, |
| 324 | // selected by `kind`. |
| 325 | export interface WireExtensionStatus { |
| 326 | label: string; |
| 327 | detail?: string; |
| 328 | severity?: string; // "info" | "warn" | "error" |
| 329 | progress?: number; |
| 330 | } |
| 331 | |
| 332 | export interface WireExtensionKeyValue { |
| 333 | key: string; |
| 334 | value: string; |
| 335 | } |
| 336 | |
| 337 | export interface WireExtensionActionRef { |
| 338 | actionId: string; |
| 339 | label: string; |
| 340 | } |
| 341 | |
| 342 | export interface WireExtensionCard { |
| 343 | title?: string; |
| 344 | markdown?: string; |
| 345 | text?: string; |
| 346 | fields?: WireExtensionKeyValue[]; |
| 347 | progress?: number; |
| 348 | actions?: WireExtensionActionRef[]; |
| 349 | } |
| 350 | |
| 351 | export interface WireExtensionFormField { |
| 352 | key: string; |
| 353 | label?: string; |
| 354 | kind?: string; // "confirm" | "input" | "select" | "multiselect" |
| 355 | options?: string[]; |
| 356 | default?: unknown; |
| 357 | required?: boolean; |
| 358 | } |
| 359 | |
| 360 | export interface WireExtensionForm { |
| 361 | title?: string; |
| 362 | message?: string; |
| 363 | fields: WireExtensionFormField[]; |
| 364 | } |
| 365 | |
| 366 | export interface WireExtensionNotification { |
| 367 | title: string; |
| 368 | body?: string; |
| 369 | severity?: string; // "info" | "warn" | "error" |
| 370 | } |
| 371 | |
| 372 | export interface WireExtensionSurface { |
| 373 | pluginId: string; |
| 374 | surfaceId: string; |
| 375 | sessionId?: string; |
| 376 | generation?: number; |
| 377 | formInstanceId?: string; |
| 378 | kind: string; // "status" | "card" | "form" | "notification" |
| 379 | status?: WireExtensionStatus; |
| 380 | card?: WireExtensionCard; |
| 381 | form?: WireExtensionForm; |
| 382 | notification?: WireExtensionNotification; |
| 383 | } |
| 384 | |
| 385 | // ExtensionActionView is one handshake-declared extension UI action, the JSON |
| 386 | // twin of desktop's ExtensionActionView (stage 8b2). Slash is the public |
| 387 | // invocation name, "/<plugin>:<action>". |
| 388 | export interface ExtensionActionView { |
| 389 | plugin: string; |
| 390 | action: string; |
| 391 | slash: string; |
| 392 | description?: string; |
| 393 | } |
| 394 | |
| 395 | // QuestionAnswer is the reply for one question, sent back via AnswerQuestion. |
| 396 | export interface QuestionAnswer { |
| 397 | questionId: string; |
| 398 | selected: string[]; |
| 399 | } |
| 400 | |
| 401 | export interface MemoryCitation { |
| 402 | id?: string; |
| 403 | source: string; |
| 404 | lineStart?: number; |
| 405 | lineEnd?: number; |
| 406 | note?: string; |
| 407 | kind?: string; |
| 408 | } |
| 409 | |
| 410 | export interface WireEvent extends RecoveryEventFields { |
| 411 | sessionId?: string; |
| 412 | source?: string; |
| 413 | messageId?: string; |
| 414 | attemptId?: string; |
| 415 | receipt?: WireCompletionReceipt; |
| 416 | readPause?: import("./readPause").WireReadPause; |
| 417 | readCompletion?: import("../generated/desktopContract.generated").ReadCompletion; |
| 418 | kind: EventKind; |
| 419 | readStatus?: WireReadStatus; |
| 420 | /** session_changed: the transcript was replaced under the same path (head switch, clear). */ |
| 421 | sessionReset?: boolean; |
| 422 | promptId?: string; |
| 423 | promptKind?: "ask" | "approval" | "plan" | "recovery" | "mcp" | string; |
| 424 | promptLegacy?: boolean; |
| 425 | turnId?: string; |
| 426 | seq?: number; |
| 427 | status?: TurnStatus; |
| 428 | text?: string; |
| 429 | detail?: string; |
| 430 | // Stable notice id for localization; empty/absent = localize by text match. |
| 431 | code?: string; |
| 432 | reasoning?: string; |
| 433 | memoryCitations?: MemoryCitation[]; |
| 434 | level?: "info" | "warn"; |
| 435 | tool?: WireTool; |
| 436 | usage?: WireUsage; |
| 437 | approval?: WireApproval; |
| 438 | ask?: WireAsk; |
| 439 | mcpInteraction?: WireMCPInteraction; |
| 440 | compaction?: WireCompaction; |
| 441 | sessionOperation?: WireSessionOperation; |
| 442 | maintenance?: WireContextMaintenance; |
| 443 | guardian?: WireGuardian; |
| 444 | decisionReceipt?: WireDecisionReceipt; |
| 445 | extension?: WireExtensionSurface; |
| 446 | err?: string; |
| 447 | checkpointTurn?: number; // Authoritative TurnDone rewind target; zero is valid. |
| 448 | submissionId?: string; // Opaque correlation for the exact optimistic user submission. |
| 449 | outcome?: "completed" | "partial" | "blocked" | "final_readiness" | "recovery_paused" | "completion_uncertain" | "incomplete_read"; |
| 450 | readiness?: WireFinalReadiness; |
| 451 | protocolRecovery?: { id: string }; |
| 452 | diagnostic?: { kind: string; status?: number; traceId?: string; providerId?: string; providerDisplayName?: string; protocol?: string; requestPath?: string; transportCode?: string }; |
| 453 | /** Optional: "headers" | "stream". Older clients ignore unknown fields. */ |
| 454 | retryScope?: "headers" | "stream" | "protocol"; |
| 455 | streamAttempt?: WireStreamAttempt; |
| 456 | /** Durable session-inbox item id for steer / TurnDone correlation. */ |
| 457 | itemId?: string; |
| 458 | sessionPath?: string; // Serve multi-session routing tag; absent locally. |
| 459 | workspace?: WireWorkspaceChanged; |
| 460 | /** turn_phase: working | checking | verifying | reviewing */ |
| 461 | phase?: string; |
| 462 | /** completion_summary: content-free quality summary for role settings */ |
| 463 | completion?: WireCompletionSummary; |
| 464 | tabId?: string; // Go's tabEventSink tags events for the correct per-tab reducer. |
| 465 | runtimeEpoch?: string; sessionGeneration?: number; |
| 466 | /** Unix milliseconds recorded by the desktop host when this turn began. */ |
| 467 | turnStartedAt?: number; |
| 468 | sessionHitTokens?: number; |
| 469 | sessionMissTokens?: number; |
| 470 | sessionCost?: number; |
| 471 | sessionCurrency?: string; |
| 472 | // Deprecated compatibility alias. Prefer sessionCost + sessionCurrency. |
| 473 | sessionCostUsd?: number; |
| 474 | } |
| 475 | |
| 476 | export interface WireCompletionSummary { |
| 477 | /** Local projection fields, preserved with the historical result card. */ |
| 478 | receipt?: WireCompletionReceipt; |
| 479 | turnId?: string; |
| 480 | checkpointTurn?: number; |
| 481 | checking?: boolean; |
| 482 | liveChecks?: { toolCallId: string; command: string; output?: string }[]; |
| 483 | preset: string; |
| 484 | verdict: string; |
| 485 | mutations: number; |
| 486 | changed_files?: number; |
| 487 | checks_passed: number; |
| 488 | checks_failed: number; |
| 489 | checks_suppressed: number; |
| 490 | review: string; |
| 491 | gap_kinds?: string[]; |
| 492 | constraint_degraded: boolean; |
| 493 | /** Turn-time policy floor. Missing on historical events. */ |
| 494 | floor?: "standard" | "delivery" | string; |
| 495 | /** Backend decision; authoritative when floor is present. */ |
| 496 | attention?: boolean; |
| 497 | } |
| 498 | |
| 499 | export type { TurnFileChange, TurnChanges, WireCompletionReceipt } from "./turnResultTypes"; |
| 500 | import type { WireCompletionReceipt } from "./turnResultTypes"; |
| 501 | |
| 502 | export type WorkspaceWatchState = "active" | "degraded" | "unavailable"; |
| 503 | export type WorkspaceChangeOp = "create" | "write" | "remove" | "rename" | "unknown"; |
| 504 | |
| 505 | export interface WorkspaceRevisions { |
| 506 | content: number; |
| 507 | tree: number; |
| 508 | workingTree: number; |
| 509 | gitMeta: number; |
| 510 | session: number; |
| 511 | } |
| 512 | |
| 513 | export interface WorkspacePathChange { |
| 514 | path: string; |
| 515 | oldPath?: string; |
| 516 | op: WorkspaceChangeOp; |
| 517 | } |
| 518 | |
| 519 | export interface WireWorkspaceChanged { |
| 520 | revisions: WorkspaceRevisions; |
| 521 | changes: WorkspacePathChange[]; |
| 522 | allPaths: boolean; |
| 523 | source: "agent" | "filesystem" | "git" | "mixed" | "reconcile"; |
| 524 | watchState: WorkspaceWatchState; |
| 525 | } |
| 526 | |
| 527 | export type SessionRuntimePhase = "starting" | "ready" | "lease_blocked" | "failed" | "closing"; |
| 528 | |
| 529 | export interface SessionRuntimeView { |
| 530 | phase: SessionRuntimePhase; |
| 531 | epoch: string; |
| 532 | issue?: SessionRuntimeIssue; |
| 533 | } |
| 534 | |
| 535 | /** Occupancy report for a session a local serve holds; drives the takeover dialog. */ |
| 536 | export interface SessionTakeoverView { |
| 537 | available: boolean; |
| 538 | reason?: string; |
| 539 | sessionPath?: string; |
| 540 | holder?: "serve" | "external" | "other" | "free"; |
| 541 | remoteAttached?: boolean; |
| 542 | running?: boolean; |
| 543 | mirrored?: boolean; |
| 544 | holderPid?: number; |
| 545 | holderHost?: string; |
| 546 | } |
| 547 | |
| 548 | export interface WireFinalReadiness { |
| 549 | attempts?: number; |
| 550 | missing?: string[]; |
| 551 | } |
| 552 | |
| 553 | // Tab management types (desktop/tabs.go). |
| 554 | export interface TabMeta extends RemoteTabMetaFields { |
| 555 | historicalSource?: import("../generated/desktopContract.generated").SessionSourceRef; |
| 556 | id: string; |
| 557 | tabType?: "session" | "file"; |
| 558 | scope: string; |
| 559 | workspaceRoot: string; |
| 560 | workspaceId?: string; |
| 561 | workspaceName: string; |
| 562 | workspacePath?: string; |
| 563 | gitBranch?: string; |
| 564 | isolatedWorktree?: boolean; |
| 565 | topicId: string; |
| 566 | topicTitle: string; |
| 567 | sessionPath?: string; |
| 568 | sessionId?: string; session?: SessionRef | null; |
| 569 | sessionRevision?: number; |
| 570 | sessionDigest?: string; |
| 571 | sessionGeneration?: number; |
| 572 | readOnly?: boolean; |
| 573 | /** Remote tab whose session a local runtime on the serve host took over. */ |
| 574 | takenOver?: boolean; |
| 575 | filePath?: string; |
| 576 | projectColor?: string; |
| 577 | label: string; |
| 578 | ready: boolean; |
| 579 | runtime?: SessionRuntimeView; |
| 580 | running: boolean; |
| 581 | /** Unix milliseconds for the currently active foreground turn. */ |
| 582 | turnStartedAt?: number; |
| 583 | pendingPrompt?: boolean; |
| 584 | backgroundJobs?: number; |
| 585 | cancelRequested?: boolean; |
| 586 | cancellable?: boolean; |
| 587 | turnId?: string; |
| 588 | turnStatus?: TurnStatus; |
| 589 | turnEventSeq?: number; |
| 590 | turnReplayAfterSeq?: number; |
| 591 | mode: Mode; |
| 592 | collaborationMode?: CollaborationMode; |
| 593 | toolApprovalMode?: ToolApprovalMode; |
| 594 | tokenMode?: TokenMode; |
| 595 | agentPreset?: AgentPreset; // retired compatibility field; current hosts emit standard |
| 596 | qualityFloor?: QualityFloor; // retired compatibility field; current hosts emit standard |
| 597 | floorInferred?: boolean; // retired compatibility field; current hosts emit false |
| 598 | goal?: string; |
| 599 | goalStatus?: GoalStatus; |
| 600 | goalView?: GoalLifecycleView; |
| 601 | recovered?: boolean; |
| 602 | recoveryReason?: string; |
| 603 | recoveryDigest?: string; |
| 604 | recoveryParentId?: string; |
| 605 | versionKind?: "normal" | "recovery" | "subagent" | string; |
| 606 | versionState?: "active" | "pending" | "resolved" | "trashed" | string; |
| 607 | parentVersionId?: string; |
| 608 | startupErr?: string; |
| 609 | authentication?: ConnectionAuthentication; |
| 610 | modelSettingsPending?: boolean; |
| 611 | active: boolean; |
| 612 | cwd: string; |
| 613 | } |
| 614 | |
| 615 | export interface TerminalSessionView { |
| 616 | id: string; |
| 617 | title: string; |
| 618 | shell: string; |
| 619 | cwd: string; |
| 620 | createdAt: number; |
| 621 | exitCode?: number; |
| 622 | running: boolean; |
| 623 | } |
| 624 | |
| 625 | export interface TerminalShellView { |
| 626 | id: string; |
| 627 | label: string; |
| 628 | } |
| 629 | |
| 630 | export interface TerminalWorkspaceView { |
| 631 | available: boolean; |
| 632 | readOnly: boolean; |
| 633 | reason?: string; |
| 634 | sessions: TerminalSessionView[]; |
| 635 | shells: TerminalShellView[]; |
| 636 | } |
| 637 | |
| 638 | |
| 639 | |
| 640 | export type { RecoveryLineageMember, RecoveryLineageView } from "./sessionRecoveryTypes"; |
| 641 | |
| 642 | export interface RecoveryCleanupRequest { |
| 643 | scope: string; |
| 644 | workspaceRoot?: string; |
| 645 | topicId: string; |
| 646 | apply: boolean; |
| 647 | } |
| 648 | |
| 649 | export interface RecoveryPreferenceRequest { |
| 650 | scope: string; |
| 651 | workspaceRoot?: string; |
| 652 | topicId: string; |
| 653 | path: string; |
| 654 | /** Head inside a schema-2 log; empty for file-based recovery versions. */ |
| 655 | headId?: string; |
| 656 | } |
| 657 | |
| 658 | export interface RecoveryCleanupItem { |
| 659 | path: string; |
| 660 | status: "eligible" | "moved" | "busy" | "kept" | string; |
| 661 | error?: string; |
| 662 | } |
| 663 | |
| 664 | export interface RecoveryCleanupResult { |
| 665 | eligible: number; |
| 666 | moved: number; |
| 667 | busy: number; |
| 668 | kept: number; |
| 669 | dryRun: boolean; |
| 670 | items: RecoveryCleanupItem[]; |
| 671 | } |
| 672 | |
| 673 | export interface DeliveryWorktreeAvailability { |
| 674 | available: boolean; |
| 675 | reason?: string; |
| 676 | repoRoot?: string; |
| 677 | branch?: string; |
| 678 | sourceDirty?: boolean; |
| 679 | } |
| 680 | |
| 681 | export interface DeliveryWorktreeOpenResult { |
| 682 | workspaceRoot: string; |
| 683 | worktreeRoot: string; |
| 684 | sourceRoot: string; |
| 685 | branch: string; |
| 686 | sourceDirty: boolean; |
| 687 | sourceRevision?: string; |
| 688 | taskId?: string; |
| 689 | conversationId?: string; |
| 690 | tab: TabMeta; |
| 691 | } |
| 692 | |
| 693 | export * from "./worktreeMergeTypes"; |
| 694 | |
| 695 | export type ProjectTopicStatus = "thinking" | "streaming" | "finishing" | "cancelling" | "unknown" | "waiting_confirmation" | "background_job" | "paused" | "awaiting_delivery" | "error" | "diverged_recovery"; |
| 696 | |
| 697 | export interface TopicMeta { |
| 698 | id: string; |
| 699 | title: string; |
| 700 | createdAt: number; |
| 701 | } |
| 702 | |
| 703 | export interface SessionRecoveryEvent { |
| 704 | conversationId?: string; |
| 705 | activeVersionId?: string; |
| 706 | recoveryVersionId?: string; |
| 707 | originalPath?: string; |
| 708 | recoveryPath: string; |
| 709 | scope?: string; |
| 710 | workspaceRoot?: string; |
| 711 | topicId?: string; |
| 712 | topicTitle?: string; |
| 713 | recoveryReason?: string; |
| 714 | recoveryDigest?: string; |
| 715 | recoveryParentId?: string; |
| 716 | existing?: boolean; |
| 717 | baseRevision?: number; |
| 718 | diskRevision?: number; |
| 719 | canContinue?: boolean; |
| 720 | requiresChoice?: boolean; |
| 721 | } |
| 722 | |
| 723 | export interface SessionVersionStateView { |
| 724 | conversationId?: string; |
| 725 | activeVersionId?: string; |
| 726 | activePath?: string; |
| 727 | recoveryVersionId?: string; |
| 728 | canContinue: boolean; |
| 729 | requiresChoice: boolean; |
| 730 | lineage: RecoveryLineageView; |
| 731 | } |
| 732 | |
| 733 | export interface SessionRecoveryFailedEvent { |
| 734 | reason?: "lease_held" | "lease_unavailable" | string; |
| 735 | conversationId?: string; |
| 736 | topicId?: string; |
| 737 | canContinue?: boolean; |
| 738 | recoveryPending?: boolean; |
| 739 | recoveryPath?: string; |
| 740 | workspaceRoot?: string; |
| 741 | } |
| 742 | |
| 743 | export interface ContextPanelInfo { |
| 744 | usedTokens: number; |
| 745 | windowTokens: number; |
| 746 | promptTokens: number; |
| 747 | completionTokens: number; |
| 748 | totalTokens: number; |
| 749 | reasoningTokens: number; |
| 750 | cacheHitTokens: number; |
| 751 | cacheMissTokens: number; |
| 752 | estimated?: boolean; |
| 753 | sessionCacheHitTokens: number; |
| 754 | sessionCacheMissTokens: number; |
| 755 | sessionCompletionTokens: number; |
| 756 | sessionEstimated?: boolean; |
| 757 | requestCount?: number; |
| 758 | elapsedMs?: number; |
| 759 | activeTurnStartedAt?: number; |
| 760 | sessionCost?: number; |
| 761 | sessionCurrency?: string; |
| 762 | // Deprecated compatibility alias. Prefer sessionCost + sessionCurrency. |
| 763 | sessionCostUsd?: number; |
| 764 | sessionCostComplete?: boolean; |
| 765 | sessionCostEstimated?: boolean; |
| 766 | sessionBillingMode?: string; |
| 767 | sessionCostQuote?: CostQuote; |
| 768 | sources?: Record<string, UsageSourceStats>; |
| 769 | mock?: boolean; |
| 770 | readFiles: ReadFileRecord[]; |
| 771 | changedFiles: ChangedFileInfo[]; |
| 772 | contextBudget?: ContextBudgetInfo; |
| 773 | } |
| 774 | |
| 775 | export interface UsageSourceStats { |
| 776 | promptTokens: number; |
| 777 | completionTokens: number; |
| 778 | totalTokens: number; |
| 779 | reasoningTokens: number; |
| 780 | cacheHitTokens: number; |
| 781 | cacheMissTokens: number; |
| 782 | estimated?: boolean; |
| 783 | requestCount: number; |
| 784 | sessionCost?: number; |
| 785 | sessionCurrency?: string; |
| 786 | sessionCostUsd?: number; |
| 787 | } |
| 788 | |
| 789 | export interface ReadFileRecord { |
| 790 | path: string; |
| 791 | turn: number; |
| 792 | time: number; |
| 793 | offset?: number; |
| 794 | limit?: number; |
| 795 | truncated?: boolean; |
| 796 | } |
| 797 | |
| 798 | export interface ChangedFileInfo { |
| 799 | path: string; |
| 800 | oldPath?: string; |
| 801 | sources: string[]; |
| 802 | gitStatus?: string; |
| 803 | turns: number[]; |
| 804 | latestPrompt?: string; |
| 805 | latestTime?: number; |
| 806 | } |
| 807 | |
| 808 | // Bound-method payloads (desktop/app.go). |
| 809 | export interface HistoryMessage extends TranscriptTurnMetadata { |
| 810 | historyTurn?: number; |
| 811 | recordId?: string; |
| 812 | attemptId?: string; |
| 813 | submissionId?: string; |
| 814 | source?: string; |
| 815 | messageId?: string; |
| 816 | completionReceipt?: WireCompletionReceipt; |
| 817 | completionSummary?: WireCompletionSummary; |
| 818 | readCompletion?: import("../generated/desktopContract.generated").ReadCompletion; |
| 819 | turnId?: string; |
| 820 | readPause?: import("./readPause").WireReadPause; |
| 821 | role: string; |
| 822 | content: string; |
| 823 | detail?: string; |
| 824 | code?: string; |
| 825 | submitText?: string; |
| 826 | checkpointTurn?: number; |
| 827 | createdAt?: number; |
| 828 | reasoning?: string; |
| 829 | workDurationMs?: number; |
| 830 | turnDurationMs?: number; |
| 831 | turnUsage?: TurnUsage; |
| 832 | memoryCitations?: MemoryCitation[]; |
| 833 | level?: "info" | "warn"; |
| 834 | toolCalls?: HistoryToolCall[]; |
| 835 | toolCallId?: string; |
| 836 | toolName?: string; |
| 837 | toolResultArchived?: boolean; |
| 838 | toolResultError?: string; |
| 839 | execution?: WireShellExecution; |
| 840 | presentedFiles?: PresentedFile[]; |
| 841 | pending?: boolean; |
| 842 | trigger?: string; |
| 843 | messages?: number; |
| 844 | summary?: string; |
| 845 | archive?: string; |
| 846 | operationId?: string; |
| 847 | operationKind?: string; |
| 848 | operationStatus?: string; |
| 849 | operationActivity?: string; |
| 850 | operationRevision?: number; |
| 851 | runtimeEpoch?: string; |
| 852 | errorCode?: string; |
| 853 | applied?: boolean; |
| 854 | inputTokens?: number; |
| 855 | resultTokens?: number; |
| 856 | decisionReceipt?: WireDecisionReceipt; |
| 857 | readiness?: WireFinalReadiness; |
| 858 | protocolRecovery?: { id: string }; |
| 859 | diagnostic?: { kind: string; status?: number; traceId?: string; providerId?: string; providerDisplayName?: string; protocol?: string; requestPath?: string; transportCode?: string }; |
| 860 | serverSearch?: HistoryServerSearch[]; |
| 861 | attachments?: Array<{ kind?: string; digest?: string; name?: string; mime?: string; width?: number; height?: number; bytes?: number }>; |
| 862 | } |
| 863 | |
| 864 | export interface HistoryPage { |
| 865 | messages: HistoryMessage[]; |
| 866 | startTurn: number; |
| 867 | endTurn: number; |
| 868 | totalTurns: number; |
| 869 | hasOlder: boolean; |
| 870 | revision?: number; |
| 871 | digest?: string; |
| 872 | /** Present only on a page a session switch built; carries the switch's |
| 873 | * content-free phase breakdown. */ |
| 874 | switch?: HistorySwitchPhases | null; |
| 875 | } |
| 876 | |
| 877 | // ── Two-phase topic activation (desktop/topic_activation.go) ──────────────── |
| 878 | |
| 879 | export interface TopicActivationRequest { |
| 880 | selector?: import("../generated/desktopContract.generated").SessionSelector; |
| 881 | scope: string; |
| 882 | workspaceRoot: string; |
| 883 | topicId: string; |
| 884 | sessionPath: string; |
| 885 | requestId?: string; |
| 886 | } |
| 887 | |
| 888 | export interface TopicActivationTicket { |
| 889 | requestId: string; |
| 890 | tabId: string; |
| 891 | meta: TabMeta; |
| 892 | } |
| 893 | |
| 894 | export type TopicActivationPhase = "starting" | "ready" | "failed" | "cancelled"; |
| 895 | |
| 896 | export interface TopicActivationEvent { |
| 897 | requestId: string; |
| 898 | tabId: string; |
| 899 | phase: TopicActivationPhase; |
| 900 | error?: string; |
| 901 | } |
| 902 | |
| 903 | // tab:meta channel: a full refreshed Meta pushed after the background refresh |
| 904 | // of the expensive MetaForTab fields (git branch, image-input capability). |
| 905 | export interface TabMetaRefreshEvent { |
| 906 | tabId: string; |
| 907 | meta: Meta; |
| 908 | } |
| 909 | |
| 910 | export interface PromptHistoryEntry { |
| 911 | text: string; |
| 912 | at: number; // unix ms |
| 913 | sessionPath: string; |
| 914 | turn: number; |
| 915 | } |
| 916 | |
| 917 | export interface PromptHistoryResult { |
| 918 | entries: PromptHistoryEntry[] | null; |
| 919 | nonce: string; |
| 920 | olderCursor?: string; |
| 921 | hasOlder?: boolean; |
| 922 | } |
| 923 | |
| 924 | // CheckpointMeta is one rewind point (a user turn) for the rewind UI. |
| 925 | export interface CheckpointMeta { |
| 926 | turn: number; |
| 927 | prompt: string; |
| 928 | files: string[]; |
| 929 | fileCount?: number; |
| 930 | filesTruncated?: boolean; |
| 931 | turnFileCount?: number; |
| 932 | time: number; // unix ms |
| 933 | canCode?: boolean; |
| 934 | canConversation?: boolean; |
| 935 | coverage?: string; |
| 936 | coverageGaps?: string[]; |
| 937 | expiredFilePayload?: boolean; |
| 938 | activeWriters?: number; |
| 939 | legacy?: boolean; |
| 940 | canUndoFiles?: boolean; |
| 941 | disabledReason?: string; |
| 942 | } |
| 943 | |
| 944 | export type { RewindPlanView } from "./rewindTypes"; |
| 945 | |
| 946 | export interface RewindResultView { |
| 947 | ok?: boolean; |
| 948 | transactionId?: string; |
| 949 | undoAvailable?: boolean; |
| 950 | written?: string[]; |
| 951 | deleted?: string[]; |
| 952 | conversationOk?: boolean; |
| 953 | conversationForked?: boolean; |
| 954 | operationId?: string; |
| 955 | branch?: string; |
| 956 | partial?: boolean; |
| 957 | tabId?: string; |
| 958 | tab?: TabMeta; |
| 959 | error?: string; |
| 960 | conflicts?: string[]; |
| 961 | coverage?: string; |
| 962 | } |
| 963 | |
| 964 | export type { SessionMeta } from "./sessionMetaTypes"; |
| 965 | |
| 966 | export type { HistoryIndexStatus, HistorySearchContextLine, HistorySearchContextRequest, HistorySearchHit, HistorySearchPage, HistorySearchRequest, HistorySessionPage, HistorySessionPageRequest } from "./historyCatalogTypes"; |
| 967 | |
| 968 | export interface WorkspaceView { |
| 969 | path: string; |
| 970 | name: string; |
| 971 | current: boolean; |
| 972 | } |
| 973 | |
| 974 | export interface ContextInfo { |
| 975 | used: number; |
| 976 | window: number; |
| 977 | sessionTokens: number; |
| 978 | compactRatio?: number; |
| 979 | sessionCost?: number; |
| 980 | sessionCurrency?: string; |
| 981 | cacheHitTokens?: number; |
| 982 | cacheMissTokens?: number; |
| 983 | estimated?: boolean; |
| 984 | sessionCostComplete?: boolean; |
| 985 | sessionCostQuote?: CostQuote; |
| 986 | sources?: Record<string, UsageSourceStats>; |
| 987 | maintenance?: ContextMaintenanceInfo; |
| 988 | contextBudget?: ContextBudgetInfo; |
| 989 | } |
| 990 | |
| 991 | export interface Meta extends RemoteSessionMetaFields { |
| 992 | label: string; |
| 993 | ready: boolean; |
| 994 | runtime?: SessionRuntimeView; |
| 995 | startupErr?: string; |
| 996 | historicalSource?: import("../generated/desktopContract.generated").SessionSourceRef; |
| 997 | eventChannel: string; |
| 998 | sessionPath?: string; |
| 999 | sessionId?: string; session?: SessionRef | null; |
| 1000 | sessionRevision?: number; |
| 1001 | sessionDigest?: string; |
| 1002 | sessionGeneration?: number; |
| 1003 | runtimeStateSnapshot?: import("./runtimeStateStore").RuntimeState; |
| 1004 | cwd: string; |
| 1005 | workspaceRoot?: string; |
| 1006 | workspaceName?: string; |
| 1007 | workspacePath?: string; |
| 1008 | gitBranch?: string; |
| 1009 | imageInputEnabled?: boolean; |
| 1010 | visionFallbackEnabled?: boolean; |
| 1011 | autoApproveTools?: boolean; |
| 1012 | bypass?: boolean; // legacy JSON key for YOLO/full-access tool auto-approval |
| 1013 | collaborationMode?: CollaborationMode; |
| 1014 | toolApprovalMode?: ToolApprovalMode; |
| 1015 | tokenMode?: TokenMode; |
| 1016 | agentPreset?: AgentPreset; // retired compatibility field; current hosts emit standard |
| 1017 | qualityFloor?: QualityFloor; // retired compatibility field; current hosts emit standard |
| 1018 | floorInferred?: boolean; // retired compatibility field; current hosts emit false |
| 1019 | goal?: string; |
| 1020 | goalStatus?: GoalStatus; |
| 1021 | goalView?: GoalLifecycleView; |
| 1022 | goalRuntime?: GoalRuntime; |
| 1023 | canonicalTodos?: Todo[]; pinnedFiles?: PinnedFileInfo[]; |
| 1024 | } |
| 1025 | export type CollaborationMode = "normal" | "plan" | "goal"; |
| 1026 | export type PermissionPreset = "read-only" | "workspace-write" | "danger-full-access"; |
| 1027 | export type LegacyToolApprovalMode = "ask" | "auto" | "yolo"; |
| 1028 | // Legacy values remain in the input union for old hosts and persisted fixtures; |
| 1029 | // normalizeToolApprovalMode is the only path into current UI/runtime state. |
| 1030 | export type ToolApprovalMode = PermissionPreset | LegacyToolApprovalMode; |
| 1031 | export interface SessionGrantSummary { |
| 1032 | scope: "tool" | "directory" | "command-prefix" | string; |
| 1033 | target: string; |
| 1034 | } |
| 1035 | export interface PermissionCapabilities { |
| 1036 | backend: string; |
| 1037 | enforcement: "full" | "partial" | "unavailable" | string; |
| 1038 | supportedPresets: PermissionPreset[]; |
| 1039 | unavailableReason?: string; |
| 1040 | writeIsolation?: string; |
| 1041 | readIsolation?: string; |
| 1042 | networkIsolation?: string; |
| 1043 | } |
| 1044 | export interface PermissionSnapshot { |
| 1045 | sessionId: string; |
| 1046 | generation: number; |
| 1047 | revision: number; |
| 1048 | preset: PermissionPreset; |
| 1049 | workspaceRoot: string; |
| 1050 | grants: SessionGrantSummary[]; |
| 1051 | capabilities: PermissionCapabilities; |
| 1052 | } |
| 1053 | // Retired wire vocabularies remain accepted so old sessions and remote hosts |
| 1054 | // can be decoded. Current local hosts emit full/balanced/standard. |
| 1055 | export type TokenMode = "full" | "economy" | "delivery" | "light" | "balanced"; |
| 1056 | export type AgentPreset = "standard" | "light" | "balanced" | "delivery"; |
| 1057 | export type QualityFloor = "standard" | "delivery"; |
| 1058 | export type GoalStatus = "running" | "complete" | "blocked" | "stopped"; |
| 1059 | export type GoalPhase = "active" | "paused" | "blocked" | "complete"; |
| 1060 | export type GoalActivation = "armed" | "disarmed"; |
| 1061 | export interface GoalLifecycleView { |
| 1062 | id: string; |
| 1063 | revision: number; |
| 1064 | objective: string; |
| 1065 | phase: GoalPhase; |
| 1066 | maxGoalRounds: number | null; |
| 1067 | roundsStarted: number; |
| 1068 | blockedReason?: { code: string; message: string }; |
| 1069 | createdAt: string; |
| 1070 | updatedAt: string; |
| 1071 | activation: GoalActivation; |
| 1072 | stopReason?: string; |
| 1073 | } |
| 1074 | // Optional Goal runtime summary; absent for old hosts or when no goal is active. |
| 1075 | export interface GoalRuntime { |
| 1076 | turnsUsed: number; |
| 1077 | turnsLimit: number; // Deprecated: Goal exposes no turn limit and returns 0. |
| 1078 | tokensUsed: number; |
| 1079 | requestsUsed?: number; |
| 1080 | workDurationMs?: number; |
| 1081 | /** @deprecated Goal has no hard token limit; retained as 0 for old hosts/clients. */ |
| 1082 | tokensLimit: number; |
| 1083 | noProgressTurns: number; |
| 1084 | /** @deprecated No longer enforced; retained for old hosts/clients. */ |
| 1085 | noProgressLimit: number; |
| 1086 | lastReason?: string; |
| 1087 | stopCause?: string; |
| 1088 | budgetExtensions: number; // Deprecated: resumes no longer extend a numeric quota. |
| 1089 | } |
| 1090 | export function normalizeCollaborationMode(mode?: string, goal?: string, legacyMode?: Mode): CollaborationMode { |
| 1091 | if (mode === "plan" || mode === "goal" || mode === "normal") return mode; |
| 1092 | if (legacyMode && modeHasPlan(legacyMode)) return "plan"; |
| 1093 | if ((goal ?? "").trim()) return "goal"; |
| 1094 | return "normal"; |
| 1095 | } |
| 1096 | |
| 1097 | export function normalizeToolApprovalMode( |
| 1098 | mode?: string, |
| 1099 | legacyMode?: Mode, |
| 1100 | legacyAutoApproveTools?: boolean, |
| 1101 | fallbackMode?: ToolApprovalMode, |
| 1102 | ): PermissionPreset { |
| 1103 | const normalized = typeof mode === "string" ? mode.trim().toLowerCase() : ""; |
| 1104 | if (normalized === "read-only" || normalized === "workspace-write" || normalized === "danger-full-access") return normalized as PermissionPreset; |
| 1105 | if (normalized === "ask") return "read-only"; |
| 1106 | if (normalized === "auto" || normalized === "yolo") return "workspace-write"; |
| 1107 | if (legacyAutoApproveTools || (legacyMode && modeHasAutoApproveTools(legacyMode))) return "workspace-write"; |
| 1108 | if (fallbackMode && normalized === "") return normalizeToolApprovalMode(fallbackMode); |
| 1109 | return "read-only"; |
| 1110 | } |
| 1111 | |
| 1112 | export function normalizeTokenMode(mode?: string): TokenMode { |
| 1113 | void mode; |
| 1114 | return "full"; |
| 1115 | } |
| 1116 | |
| 1117 | /** Normalize the retired role vocabulary to the fixed compatibility value. */ |
| 1118 | export function normalizeAgentPreset(mode?: string): AgentPreset { |
| 1119 | void mode; |
| 1120 | return "standard"; |
| 1121 | } |
| 1122 | |
| 1123 | export function tokenModeFromAgentPreset(preset: AgentPreset): TokenMode { |
| 1124 | void preset; |
| 1125 | return "full"; |
| 1126 | } |
| 1127 | |
| 1128 | // Mode is a compatibility string from older hosts. New permission state is |
| 1129 | // carried only by PermissionPreset and never derived from this display axis. |
| 1130 | export type Mode = "normal" | "plan" | "yolo" | "plan-yolo"; |
| 1131 | |
| 1132 | export function normalizeMode(mode?: string): Mode { |
| 1133 | if (mode === "plan" || mode === "yolo" || mode === "plan-yolo" || mode === "yolo-plan") { |
| 1134 | return mode === "yolo-plan" ? "plan-yolo" : mode; |
| 1135 | } |
| 1136 | return "normal"; |
| 1137 | } |
| 1138 | |
| 1139 | export function modeHasPlan(mode: Mode): boolean { |
| 1140 | return mode === "plan" || mode === "plan-yolo"; |
| 1141 | } |
| 1142 | |
| 1143 | export function modeHasAutoApproveTools(mode: Mode): boolean { |
| 1144 | return mode === "yolo" || mode === "plan-yolo"; |
| 1145 | } |
| 1146 | |
| 1147 | export function modeFromAxes(plan: boolean, autoApproveTools: boolean): Mode { |
| 1148 | if (plan && autoApproveTools) return "plan-yolo"; |
| 1149 | if (plan) return "plan"; |
| 1150 | if (autoApproveTools) return "yolo"; |
| 1151 | return "normal"; |
| 1152 | } |
| 1153 | |
| 1154 | export function modeWithPlan(mode: Mode, plan: boolean): Mode { |
| 1155 | return modeFromAxes(plan, modeHasAutoApproveTools(mode)); |
| 1156 | } |
| 1157 | |
| 1158 | export function modeWithAutoApproveTools(mode: Mode, autoApproveTools: boolean): Mode { |
| 1159 | return modeFromAxes(modeHasPlan(mode), autoApproveTools); |
| 1160 | } |
| 1161 | |
| 1162 | export interface CommandInfo { |
| 1163 | name: string; // without the leading slash |
| 1164 | description: string; |
| 1165 | hint?: string; |
| 1166 | kind: "builtin" | "custom" | "mcp" | "skill" | "subagent"; |
| 1167 | group?: "actions" | "management" | "subagents" | "skills" | "integrations"; |
| 1168 | plugin?: string; |
| 1169 | color?: string; |
| 1170 | draftBehavior?: "submit" | "setting" | "direct" | "unavailable"; |
| 1171 | } |
| 1172 | |
| 1173 | export interface DirEntry { |
| 1174 | name: string; |
| 1175 | path?: string; |
| 1176 | isDir: boolean; |
| 1177 | displayName?: string; |
| 1178 | displayPath?: string; |
| 1179 | } |
| 1180 | |
| 1181 | export interface DroppedItem { |
| 1182 | kind: "workspace" | "attachment"; |
| 1183 | path: string; |
| 1184 | isDir?: boolean; |
| 1185 | displayPath?: string; |
| 1186 | previewUrl?: string; |
| 1187 | } |
| 1188 | |
| 1189 | export interface FilePreview { |
| 1190 | path: string; |
| 1191 | body: string; |
| 1192 | size: number; |
| 1193 | truncated: boolean; |
| 1194 | binary: boolean; |
| 1195 | version?: string; |
| 1196 | nextOffset?: number; |
| 1197 | kind?: "image" | "pdf" | "html" | "audio" | "video"; |
| 1198 | mime?: string; |
| 1199 | url?: string; |
| 1200 | err?: string; |
| 1201 | } |
| 1202 | |
| 1203 | export interface PresentedTextPage { |
| 1204 | path: string; |
| 1205 | body: string; |
| 1206 | offset: number; |
| 1207 | nextOffset: number; |
| 1208 | size: number; |
| 1209 | hasMore: boolean; |
| 1210 | version: string; |
| 1211 | } |
| 1212 | |
| 1213 | export interface WorkspaceChangeView { |
| 1214 | path: string; |
| 1215 | oldPath?: string; |
| 1216 | sources: string[]; |
| 1217 | gitStatus?: string; |
| 1218 | turns?: number[]; |
| 1219 | latestPrompt?: string; |
| 1220 | latestTime?: number; |
| 1221 | canSessionRevert?: boolean; |
| 1222 | } |
| 1223 | |
| 1224 | export interface WorkspaceChangesView { |
| 1225 | files: WorkspaceChangeView[]; |
| 1226 | gitAvailable: boolean; |
| 1227 | gitErr?: string; |
| 1228 | gitBranch?: string; |
| 1229 | added?: number; |
| 1230 | removed?: number; |
| 1231 | incomplete?: boolean; |
| 1232 | } |
| 1233 | |
| 1234 | export interface WorkspaceChangeDetailView { |
| 1235 | diff?: string; |
| 1236 | source?: "git" | "session"; |
| 1237 | added?: number; |
| 1238 | removed?: number; |
| 1239 | binary?: boolean; |
| 1240 | truncated?: boolean; |
| 1241 | } |
| 1242 | |
| 1243 | export interface GitCommitView { |
| 1244 | hash: string; |
| 1245 | author: string; |
| 1246 | date: string; |
| 1247 | message: string; |
| 1248 | } |
| 1249 | |
| 1250 | export interface GitCommitDetailView { |
| 1251 | diff?: string; |
| 1252 | files?: string[]; |
| 1253 | } |
| 1254 | |
| 1255 | export interface ComposerInsertRequest { |
| 1256 | id: number; |
| 1257 | text: string; |
| 1258 | mode?: "insert" | "replace" | "prefix"; |
| 1259 | } |
| 1260 | |
| 1261 | // MCP & Skills drawer (desktop/app.go Capabilities) — the GUI counterpart to |
| 1262 | // /mcp + /skill: connected/failed servers and discoverable skills. |
| 1263 | export interface ServerView { |
| 1264 | name: string; |
| 1265 | transport: string; |
| 1266 | status: "connected" | "deferred" | "failed" | "initializing" | "disabled"; |
| 1267 | /** @deprecated derived from enabled */ |
| 1268 | startIntent?: "off" | "automatic" | string; |
| 1269 | runtimeState?: "idle" | "connecting" | "ready" | "issue" | string; |
| 1270 | protocolVersion?: string; |
| 1271 | sessionState?: "connecting" | "listening" | "ready" | "reconnecting" | "failed" | "closed" | string; |
| 1272 | reconnectAttempts?: number; |
| 1273 | errorKind?: "auth_required" | "session_missing" | "stream_closed" | "timeout" | "protocol" | "transport" | string; |
| 1274 | /** Product availability: available_on_demand | starting | connected | auth_required | project_auth_changed | start_failed | disabled */ |
| 1275 | availability?: string; |
| 1276 | enabled?: boolean; |
| 1277 | installed?: boolean; |
| 1278 | action?: "none" | "authenticate" | "authorize" | "retry" | string; |
| 1279 | source?: "project" | "user" | "plugin" | "builtin" | string; |
| 1280 | configSource?: string; |
| 1281 | builtIn?: boolean; |
| 1282 | configured?: boolean; |
| 1283 | /** @deprecated same as enabled */ |
| 1284 | autoStart: boolean; |
| 1285 | /** @deprecated ignored by runtime */ |
| 1286 | tier?: "background" | "eager" | string; |
| 1287 | command?: string; |
| 1288 | args?: string[]; |
| 1289 | url?: string; |
| 1290 | envKeys?: string[]; |
| 1291 | headerKeys?: string[]; |
| 1292 | tools: number; |
| 1293 | toolCount?: number; |
| 1294 | prompts: number; |
| 1295 | resources: number; |
| 1296 | hasTools?: boolean; |
| 1297 | error?: string; |
| 1298 | toolList?: MCPToolView[]; |
| 1299 | callTimeoutSeconds?: number; |
| 1300 | toolTimeoutSeconds?: Record<string, number>; |
| 1301 | requiresLaunchApproval?: boolean; |
| 1302 | authStatus?: "none" | "possible" | "required" | string; |
| 1303 | authUrl?: string; |
| 1304 | authConfigured?: boolean; |
| 1305 | managedByPlugin?: string; |
| 1306 | } |
| 1307 | export interface MCPToolView { |
| 1308 | name: string; |
| 1309 | description: string; |
| 1310 | readOnlyHint?: boolean; |
| 1311 | destructiveHint?: boolean; |
| 1312 | schemaError?: string; |
| 1313 | } |
| 1314 | export interface SkillView { |
| 1315 | name: string; |
| 1316 | description: string; |
| 1317 | scope: string; |
| 1318 | sourceDir?: string; |
| 1319 | runAs: string; |
| 1320 | enabled: boolean; |
| 1321 | plugin?: string; |
| 1322 | model?: string; |
| 1323 | effort?: string; |
| 1324 | allowedTools?: string[]; |
| 1325 | readOnly?: boolean; |
| 1326 | color?: string; |
| 1327 | invocation?: string; |
| 1328 | invocationMode?: string; |
| 1329 | body?: string; |
| 1330 | configuredModel?: string; |
| 1331 | configuredEffort?: string; |
| 1332 | } |
| 1333 | export interface SkillRootSkillView { |
| 1334 | name: string; |
| 1335 | description: string; |
| 1336 | scope: string; |
| 1337 | runAs: string; |
| 1338 | plugin?: string; |
| 1339 | model?: string; |
| 1340 | effort?: string; |
| 1341 | allowedTools?: string[]; |
| 1342 | color?: string; |
| 1343 | invocation?: string; |
| 1344 | } |
| 1345 | export interface SkillRootView { |
| 1346 | dir: string; |
| 1347 | scope: string; |
| 1348 | priority: number; |
| 1349 | status: string; |
| 1350 | enabled: boolean; |
| 1351 | configured: boolean; |
| 1352 | removable: boolean; |
| 1353 | skills: number; |
| 1354 | skillItems?: SkillRootSkillView[]; |
| 1355 | warning?: string; |
| 1356 | } |
| 1357 | export interface CapabilitiesView { |
| 1358 | servers: ServerView[]; |
| 1359 | skills: SkillView[]; |
| 1360 | skillRoots: SkillRootView[]; |
| 1361 | plugins: PluginView[]; |
| 1362 | allowImplicitInvocation?: boolean; |
| 1363 | } |
| 1364 | export interface SkillsSettingsView { |
| 1365 | skills: SkillView[]; |
| 1366 | skillRoots: SkillRootView[]; |
| 1367 | allowImplicitInvocation?: boolean; |
| 1368 | } |
| 1369 | export interface SubagentProfileInput { |
| 1370 | name: string; |
| 1371 | description: string; |
| 1372 | systemPrompt: string; |
| 1373 | color?: string; |
| 1374 | model?: string; |
| 1375 | effort?: string; |
| 1376 | allowedTools?: string[]; |
| 1377 | readOnly?: boolean; |
| 1378 | scope?: "project" | "global"; |
| 1379 | } |
| 1380 | export interface PluginView { |
| 1381 | name: string; |
| 1382 | version?: string; |
| 1383 | description?: string; |
| 1384 | source?: string; |
| 1385 | root: string; |
| 1386 | manifestKind?: string; |
| 1387 | enabled: boolean; |
| 1388 | skills: number; |
| 1389 | commands?: number; |
| 1390 | hooks: number; |
| 1391 | mcpServers: number; |
| 1392 | agents?: number; |
| 1393 | compatibility?: "full" | "partial" | "none" | string; |
| 1394 | mappedCapabilities?: string[]; |
| 1395 | skippedCapabilities?: PluginCompatibilityIssue[]; |
| 1396 | skillDetails?: PluginSkillView[]; |
| 1397 | agentDetails?: PluginAgentView[]; |
| 1398 | commandDetails?: PluginCommandView[]; |
| 1399 | hookDetails?: PluginHookView[]; |
| 1400 | mcpServerDetails?: PluginMCPServerView[]; |
| 1401 | warnings?: string[]; |
| 1402 | error?: string; |
| 1403 | } |
| 1404 | export interface PluginCompatibilityIssue { |
| 1405 | capability: string; |
| 1406 | path?: string; |
| 1407 | reason: string; |
| 1408 | } |
| 1409 | export interface PluginAgentView { |
| 1410 | name: string; |
| 1411 | description?: string; |
| 1412 | path?: string; |
| 1413 | invocation?: string; |
| 1414 | model?: string; |
| 1415 | allowedTools?: string[]; |
| 1416 | } |
| 1417 | export interface PluginSkillView { |
| 1418 | name: string; |
| 1419 | description?: string; |
| 1420 | path?: string; |
| 1421 | invocation?: string; |
| 1422 | runAs?: string; |
| 1423 | } |
| 1424 | export interface PluginCommandView { |
| 1425 | name: string; |
| 1426 | description?: string; |
| 1427 | argHint?: string; |
| 1428 | path?: string; |
| 1429 | invocation?: string; |
| 1430 | shadowed?: boolean; |
| 1431 | shadowedByPlugin?: string; |
| 1432 | } |
| 1433 | export interface PluginHookView { |
| 1434 | event: string; |
| 1435 | match?: string; |
| 1436 | command?: string; |
| 1437 | contextFile?: string; |
| 1438 | description?: string; |
| 1439 | } |
| 1440 | export interface PluginMCPServerView { |
| 1441 | name: string; |
| 1442 | displayName?: string; |
| 1443 | description?: string; |
| 1444 | transport?: string; |
| 1445 | command?: string; |
| 1446 | url?: string; |
| 1447 | autoStart?: boolean; |
| 1448 | } |
| 1449 | export interface PluginInstallOptions { |
| 1450 | dryRun?: boolean; |
| 1451 | link?: boolean; |
| 1452 | replace?: boolean; |
| 1453 | name?: string; |
| 1454 | } |
| 1455 | export interface MCPServerInput { |
| 1456 | name: string; |
| 1457 | transport: string; // stdio | http | sse |
| 1458 | command: string; |
| 1459 | args: string[]; |
| 1460 | url: string; |
| 1461 | env?: Record<string, string> | null; |
| 1462 | headers?: Record<string, string> | null; |
| 1463 | autoStart?: boolean | null; |
| 1464 | callTimeoutSeconds?: number | null; |
| 1465 | toolTimeoutSeconds?: Record<string, number> | null; |
| 1466 | } |
| 1467 | |
| 1468 | export interface MCPInstallResult { |
| 1469 | name: string; |
| 1470 | state: "ready" | "action_required" | "issue"; |
| 1471 | toolCount: number; |
| 1472 | action: "none" | "authenticate" | "authorize" | "retry"; |
| 1473 | message: string; |
| 1474 | } |
| 1475 | |
| 1476 | export interface MCPMarketplaceEntry { |
| 1477 | name: string; |
| 1478 | suggestedName: string; |
| 1479 | title?: string; |
| 1480 | description?: string; |
| 1481 | version?: string; |
| 1482 | repositoryUrl?: string; |
| 1483 | installable: boolean; |
| 1484 | unavailableReason?: string; |
| 1485 | transport?: "stdio" | "http" | "sse" | string; |
| 1486 | command?: string; |
| 1487 | args: string[]; |
| 1488 | url?: string; |
| 1489 | } |
| 1490 | |
| 1491 | export interface MCPMarketplaceView { |
| 1492 | servers: MCPMarketplaceEntry[]; |
| 1493 | cached: boolean; |
| 1494 | warning?: string; |
| 1495 | } |
| 1496 | |
| 1497 | export interface ModelInfo { |
| 1498 | displayName?: string; |
| 1499 | ref: string; // "provider/model" — pass to SetModel |
| 1500 | provider: string; |
| 1501 | model: string; |
| 1502 | current: boolean; |
| 1503 | contextWindow?: number; |
| 1504 | vision?: boolean; |
| 1505 | } |
| 1506 | |
| 1507 | export interface EffortInfo { |
| 1508 | options?: { id: string; name: string; description?: string }[]; |
| 1509 | supported: boolean; |
| 1510 | current: string; // adapter-owned ID; "auto" inherits the configured default |
| 1511 | default: string; |
| 1512 | levels: string[]; |
| 1513 | } |
| 1514 | |
| 1515 | // Slash sub-command / argument completion (desktop/app.go SlashArgs). Mirrors the |
| 1516 | // CLI's arg hints so the composer can suggest e.g. /skill → list/show/new/paths. |
| 1517 | export interface SlashArgItem { |
| 1518 | label: string; |
| 1519 | insert: string; // token to place at the current position |
| 1520 | hint: string; |
| 1521 | descend: boolean; // re-open the menu one level deeper after accepting |
| 1522 | } |
| 1523 | export interface SlashArgsResult { |
| 1524 | items: SlashArgItem[]; |
| 1525 | from: number; // byte offset where the current token begins |
| 1526 | } |
| 1527 | |
| 1528 | // Memory panel payloads (desktop/app.go MemoryView). |
| 1529 | export interface MemoryDoc { |
| 1530 | path: string; |
| 1531 | scope: string; // "user" | "ancestor" | "project" | "local" |
| 1532 | directory?: string; |
| 1533 | body: string; |
| 1534 | imports: Array<{ path: string; sourcePath: string }>; |
| 1535 | depth: number; |
| 1536 | order: number; |
| 1537 | precedence: number; |
| 1538 | } |
| 1539 | |
| 1540 | export interface InstructionDiagnostic { |
| 1541 | code: string; |
| 1542 | path: string; |
| 1543 | sourcePath?: string; |
| 1544 | line?: number; |
| 1545 | message: string; |
| 1546 | } |
| 1547 | |
| 1548 | export interface MemoryFact { |
| 1549 | id?: string; |
| 1550 | revision?: number; |
| 1551 | createdAt?: string; |
| 1552 | updatedAt?: string; |
| 1553 | name: string; |
| 1554 | title?: string; |
| 1555 | description: string; |
| 1556 | type: string; // "user" | "feedback" | "project" | "reference" |
| 1557 | scope: string; // "project" | "global" |
| 1558 | body: string; |
| 1559 | freshness: string; // "fresh" | "current" | "stale" |
| 1560 | } |
| 1561 | |
| 1562 | export interface MemoryConflict { |
| 1563 | key: string; |
| 1564 | projectId: string; |
| 1565 | projectName: string; |
| 1566 | globalId: string; |
| 1567 | globalName: string; |
| 1568 | resolution: "project_over_global"; |
| 1569 | } |
| 1570 | |
| 1571 | export interface MemoryRecallHit { |
| 1572 | id: string; |
| 1573 | revision: number; |
| 1574 | name: string; |
| 1575 | title?: string; |
| 1576 | type: string; |
| 1577 | scope: string; |
| 1578 | score: number; |
| 1579 | freshness: string; |
| 1580 | reason: string; |
| 1581 | snippet: string; |
| 1582 | } |
| 1583 | |
| 1584 | export interface MemoryRecallTrace { |
| 1585 | query: string; |
| 1586 | hits: MemoryRecallHit[]; |
| 1587 | omitted: number; |
| 1588 | charBudget: number; |
| 1589 | usedChars: number; |
| 1590 | suppressed?: string; |
| 1591 | } |
| 1592 | |
| 1593 | export interface MemoryArchive extends MemoryFact { |
| 1594 | path: string; |
| 1595 | archivedAt?: string; |
| 1596 | } |
| 1597 | |
| 1598 | export interface MemoryScope { |
| 1599 | scope: string; // "user" | "project" | "local" |
| 1600 | path: string; |
| 1601 | } |
| 1602 | |
| 1603 | export interface MemorySuggestion { |
| 1604 | id: string; |
| 1605 | name: string; |
| 1606 | title: string; |
| 1607 | description: string; |
| 1608 | type: string; |
| 1609 | scope: string; // "project" | "global" |
| 1610 | body: string; |
| 1611 | reason: string; |
| 1612 | evidence: string[]; |
| 1613 | } |
| 1614 | |
| 1615 | export interface SkillSuggestion { |
| 1616 | id: string; |
| 1617 | name: string; |
| 1618 | description: string; |
| 1619 | scope: string; |
| 1620 | body: string; |
| 1621 | reason: string; |
| 1622 | evidence: string[]; |
| 1623 | } |
| 1624 | |
| 1625 | export interface MemorySuggestionsView { |
| 1626 | memories: MemorySuggestion[]; |
| 1627 | skills: SkillSuggestion[]; |
| 1628 | generatedAt: string; |
| 1629 | available: boolean; |
| 1630 | source: string; |
| 1631 | } |
| 1632 | |
| 1633 | export interface MemoryView { |
| 1634 | docs: MemoryDoc[]; |
| 1635 | facts: MemoryFact[]; |
| 1636 | archives: MemoryArchive[]; |
| 1637 | scopes: MemoryScope[]; |
| 1638 | instructionDiagnostics: InstructionDiagnostic[]; |
| 1639 | conflicts: MemoryConflict[]; |
| 1640 | lastRecall: MemoryRecallTrace; |
| 1641 | storeDir: string; |
| 1642 | storeGlobalDir?: string; |
| 1643 | available: boolean; |
| 1644 | } |
| 1645 | |
| 1646 | // SettingsTab is the top-level navigation item in the Settings Centre modal. |
| 1647 | export type SettingsTab = "general" | "models" | "model-stats" | "providers" | "bots" | "mcp" | "remote" | "skills" | "subagents" | "plugins" | "memory" | "hooks" | "diagnostics" | "shortcuts" | "permissions" | "sandbox" | "network" | "browser" | "appearance" | "storage" | "updates"; |
| 1648 | |
| 1649 | export type { RuntimeDoctorReport } from "./runtimeDoctorTypes"; |
| 1650 | |
| 1651 | /** Capability diagnostics report from App.CapabilityDiagnostics (capdiag.Report). */ |
| 1652 | export interface CapabilityDiagnosticsReport { |
| 1653 | schema_version: number; |
| 1654 | root: string; |
| 1655 | live: boolean; |
| 1656 | summary: { |
| 1657 | errors: number; |
| 1658 | warnings: number; |
| 1659 | infos: number; |
| 1660 | instructions: number; |
| 1661 | skills: number; |
| 1662 | commands: number; |
| 1663 | hooks: number; |
| 1664 | plugins: number; |
| 1665 | mcp_servers: number; |
| 1666 | }; |
| 1667 | instructions: { docs: Array<{ path: string; scope: string; directory?: string; depth: number; order: number }> }; |
| 1668 | skills: CapabilityAssetReport; |
| 1669 | commands: CapabilityAssetReport; |
| 1670 | hooks: { |
| 1671 | trusted_project: boolean; |
| 1672 | project_defines_hooks: boolean; |
| 1673 | sources: Array<{ scope: string; path: string; status: string; hook_count: number; parse_error?: string }>; |
| 1674 | entries: Array<{ |
| 1675 | event: string; |
| 1676 | match?: string; |
| 1677 | command?: string; |
| 1678 | context_file?: string; |
| 1679 | description?: string; |
| 1680 | timeout_ms?: number; |
| 1681 | scope: string; |
| 1682 | source: string; |
| 1683 | blocking: boolean; |
| 1684 | }>; |
| 1685 | }; |
| 1686 | plugins: { |
| 1687 | state_path?: string; |
| 1688 | packages: Array<{ |
| 1689 | name: string; |
| 1690 | enabled: boolean; |
| 1691 | version?: string; |
| 1692 | root: string; |
| 1693 | manifest_kind?: string; |
| 1694 | skills: number; |
| 1695 | commands: number; |
| 1696 | hooks: number; |
| 1697 | mcp_servers: number; |
| 1698 | warnings?: string[]; |
| 1699 | status: string; |
| 1700 | }>; |
| 1701 | }; |
| 1702 | mcp: { |
| 1703 | servers: Array<{ |
| 1704 | name: string; |
| 1705 | source?: string; |
| 1706 | package_owner?: string; |
| 1707 | transport: string; |
| 1708 | start_intent: string; |
| 1709 | command?: string; |
| 1710 | url_host?: string; |
| 1711 | env_keys?: string[]; |
| 1712 | header_keys?: string[]; |
| 1713 | runtime_status?: string; |
| 1714 | tool_count?: number; |
| 1715 | tools?: Array<{ name: string; read_only_hint?: boolean }>; |
| 1716 | error?: string; |
| 1717 | }>; |
| 1718 | }; |
| 1719 | issues: CapabilityIssue[]; |
| 1720 | } |
| 1721 | |
| 1722 | export interface CredentialDiagnosticReport { |
| 1723 | home: string; |
| 1724 | credentialPath: string; |
| 1725 | pendingTransactions: number; |
| 1726 | checks: Array<{ id: string; status: "passed" | "failed" | "unknown" | "not_checked" | string; path?: string; message?: string }>; |
| 1727 | actions: string[]; |
| 1728 | } |
| 1729 | |
| 1730 | export interface CapabilityAssetReport { |
| 1731 | roots: Array<{ path: string; scope?: string; status: string }>; |
| 1732 | entries: Array<{ |
| 1733 | name: string; |
| 1734 | description?: string; |
| 1735 | scope?: string; |
| 1736 | path: string; |
| 1737 | status: string; |
| 1738 | winner_path?: string; |
| 1739 | error?: string; |
| 1740 | run_as?: string; |
| 1741 | }>; |
| 1742 | winners: number; |
| 1743 | shadowed: number; |
| 1744 | disabled?: number; |
| 1745 | parse_errors?: number; |
| 1746 | } |
| 1747 | |
| 1748 | export interface CapabilityIssue { |
| 1749 | severity: "error" | "warning" | "info" | string; |
| 1750 | code: string; |
| 1751 | subsystem: string; |
| 1752 | name?: string; |
| 1753 | source?: string; |
| 1754 | message: string; |
| 1755 | remediation?: string; |
| 1756 | settings_tab?: string; |
| 1757 | } |
| 1758 | // Settings panel payloads (desktop/settings_app.go). |
| 1759 | export interface ProviderView { |
| 1760 | displayName?: string; |
| 1761 | name: string; |
| 1762 | presetId?: string; // stable curated identity; read-only in the connection editor |
| 1763 | catalog?: ProviderCatalog; // protocol routes for this installed connection, including hidden legacy presets |
| 1764 | builtIn: boolean; |
| 1765 | added: boolean; |
| 1766 | kind: string; |
| 1767 | baseUrl: string; |
| 1768 | chatUrl?: string; // legacy OpenAI chat endpoint override; preserved for old-config compatibility |
| 1769 | requestUrl?: string; // exact provider request URL written by the current settings UI |
| 1770 | models: string[]; |
| 1771 | visionModels: string[]; // legacy subset; new UI derives capability from modelOverrides |
| 1772 | visionModelsConfigured: boolean; // legacy explicit-list marker retained for old configs |
| 1773 | visionCapability?: "configurable" | "unsupported"; // backend authority; absent on older desktop payloads |
| 1774 | modelsUrl: string; // optional override for model discovery; empty derives from baseUrl |
| 1775 | default: string; |
| 1776 | apiKeyEnv: string; |
| 1777 | headers?: Record<string, string> | null; // optional extra request headers for compatible gateways |
| 1778 | extraBody?: Record<string, unknown> | null; // optional extra top-level request body fields for compatible gateways |
| 1779 | authHeader?: boolean; // Anthropic-compatible: send Authorization: Bearer instead of x-api-key |
| 1780 | noProxy?: boolean; // reach this provider's endpoint directly, bypassing the configured/system proxy |
| 1781 | keySet: boolean; // the env var currently resolves to a value |
| 1782 | requiresKey?: boolean; // false for explicit no-auth providers |
| 1783 | configured?: boolean; // selectable: key is set or no key is required |
| 1784 | keySource?: string; |
| 1785 | keySourcePath?: string; |
| 1786 | balanceUrl: string; // optional wallet-balance endpoint; "" disables the readout |
| 1787 | contextWindow: number; |
| 1788 | reasoningProtocol: string; // auto|deepseek|glm|kimi-k3|openai|none; empty = auto/model registry |
| 1789 | thinking: string; // provider-specific thinking override: ""|enabled|disabled|adaptive |
| 1790 | webSearch?: boolean; // expose a provider-executed web search tool when supported |
| 1791 | serverWebSearchCapability?: boolean; // backend-verified provider capability; absent on older desktop payloads |
| 1792 | supportedEfforts: string[]; // custom /effort levels; empty = use built-in Kind/BaseURL default |
| 1793 | defaultEffort: string; // /effort level when user picks "auto" or unset; "" = supportedEfforts[0] |
| 1794 | modelOverrides?: ProviderModelOverrideView[] | null; |
| 1795 | modelCapabilities?: ProviderModelCapabilityView[] | null; |
| 1796 | recommendedUpgradeAvailable?: boolean; // official legacy OpenAI entry can switch to recommended Anthropic access |
| 1797 | modelCatalogFingerprint?: string; // opaque compare-and-apply token for background model discovery |
| 1798 | } |
| 1799 | |
| 1800 | export interface ProviderModelCatalogUpdate { |
| 1801 | name: string; |
| 1802 | expectedFingerprint: string; |
| 1803 | models: string[]; |
| 1804 | default: string; |
| 1805 | visionModels: string[]; |
| 1806 | modelCapabilities?: ProviderModelCapabilityUpdate[]; |
| 1807 | } |
| 1808 | |
| 1809 | import type { ProviderModelCapabilityView } from "./providerModelCapability"; |
| 1810 | export type { ProviderModelCapabilityView } from "./providerModelCapability"; |
| 1811 | |
| 1812 | export interface ProviderModelCapabilityUpdate { |
| 1813 | model: string; |
| 1814 | inputModalities: string[]; |
| 1815 | } |
| 1816 | |
| 1817 | |
| 1818 | |
| 1819 | export interface ProviderModelOverrideView { |
| 1820 | model: string; |
| 1821 | reasoningProtocol: string; |
| 1822 | supportedEfforts: string[]; |
| 1823 | defaultEffort: string; |
| 1824 | vision?: boolean | null; |
| 1825 | contextWindow?: number; |
| 1826 | maxOutputTokens?: number; |
| 1827 | } |
| 1828 | |
| 1829 | // BalanceInfo is the wallet-balance readout (desktop/app.go Balance). available |
| 1830 | // is false when the provider declares no balanceUrl or a fetch failed; display is |
| 1831 | // the formatted amount in an original wallet currency; no implicit FX conversion. |
| 1832 | export interface BalanceInfo { |
| 1833 | available: boolean; |
| 1834 | display: string; |
| 1835 | detail?: string; |
| 1836 | complete?: boolean; |
| 1837 | rateDate?: string; |
| 1838 | approx?: boolean; |
| 1839 | currencies?: string[]; |
| 1840 | primaryCurrency?: string; |
| 1841 | costDisplayCurrency?: string; |
| 1842 | multiCurrency?: boolean; |
| 1843 | err?: string; |
| 1844 | } |
| 1845 | |
| 1846 | // ── Usage statistics (desktop/stats_app.go) ──────────────────────────────── |
| 1847 | |
| 1848 | // UsageStatsRequest selects the aggregation range and optional entry-point |
| 1849 | // filter for the usage statistics panel. Range is "7" | "14" | "30" | "90" | |
| 1850 | // "custom"; custom requires from/to as "2006-01-02" (inclusive, local dates). |
| 1851 | // Source "" or "all" aggregates every entry point; "desktop" | "cli" | "serve" |
| 1852 | // | "bot" | "remote" filters to that source's records. |
| 1853 | export interface UsageStatsRequest { |
| 1854 | range: string; |
| 1855 | from?: string; |
| 1856 | to?: string; |
| 1857 | source?: string; |
| 1858 | } |
| 1859 | |
| 1860 | // DailyTokenUsage is one day's token total, per-model split and turn count in |
| 1861 | // the daily trend series. |
| 1862 | export interface DailyTokenUsage { |
| 1863 | day: string; // "2006-01-02" |
| 1864 | total: number; |
| 1865 | byModel: Record<string, number>; // model ref -> tokens |
| 1866 | byProvider: Record<string, number>; // provider name -> tokens |
| 1867 | requests: number; // API calls that day |
| 1868 | turns: number; |
| 1869 | cacheHit: number; // cached input tokens that day |
| 1870 | cacheMiss: number; // uncached input tokens that day |
| 1871 | } |
| 1872 | |
| 1873 | // ModelTokenUsage is one model's aggregate within the range. |
| 1874 | export interface ModelTokenUsage { |
| 1875 | model: string; // canonical "provider/model" |
| 1876 | provider: string; |
| 1877 | tokens: number; |
| 1878 | percent: number; // 0..100 |
| 1879 | } |
| 1880 | |
| 1881 | // ProviderTokenUsage is one provider's aggregate within the range. |
| 1882 | export interface ProviderTokenUsage { |
| 1883 | provider: string; |
| 1884 | tokens: number; |
| 1885 | percent: number; |
| 1886 | } |
| 1887 | |
| 1888 | // UsageStatsRange is the full aggregate the settings panel renders. |
| 1889 | export interface UsageStatsRange { |
| 1890 | from: string; |
| 1891 | to: string; |
| 1892 | tokens: number; |
| 1893 | requests: number; // API calls |
| 1894 | turns: number; // completed turns |
| 1895 | cacheHit: number; |
| 1896 | cacheMiss: number; |
| 1897 | activeDays: number; |
| 1898 | topModel: string; |
| 1899 | topProvider: string; |
| 1900 | daily: DailyTokenUsage[]; |
| 1901 | models: ModelTokenUsage[]; |
| 1902 | providers: ProviderTokenUsage[]; |
| 1903 | } |
| 1904 | |
| 1905 | // JobView is one running background job (desktop/app.go Jobs) for the status bar. |
| 1906 | export interface JobView { |
| 1907 | id: string; |
| 1908 | kind: string; // "bash" | "task" |
| 1909 | label: string; |
| 1910 | status: string; // "running" |
| 1911 | startedAt: number; // unix milliseconds |
| 1912 | } |
| 1913 | |
| 1914 | export interface ActiveWorkView { |
| 1915 | running: boolean; |
| 1916 | pendingPrompt: boolean; |
| 1917 | cancellable: boolean; |
| 1918 | jobs: JobView[]; |
| 1919 | } |
| 1920 | |
| 1921 | export interface JobCancelBatchView { |
| 1922 | cancelled: string[]; |
| 1923 | notRunning: string[]; |
| 1924 | } |
| 1925 | |
| 1926 | export interface BackgroundRuntimeView { |
| 1927 | tabId: string; |
| 1928 | title: string; |
| 1929 | detached: boolean; |
| 1930 | running: boolean; |
| 1931 | pendingPrompt: boolean; |
| 1932 | jobs: JobView[]; |
| 1933 | } |
| 1934 | |
| 1935 | export interface WorkspaceConflictView { |
| 1936 | state: "none" | "local" | "external"; |
| 1937 | ownerTabId?: string; ownerTitle?: string; |
| 1938 | ownerScope?: string; ownerLabel?: string; |
| 1939 | ownerWork: ActiveWorkView; |
| 1940 | canReveal: boolean; |
| 1941 | canCreateWorktree: boolean; |
| 1942 | } |
| 1943 | |
| 1944 | export interface PermissionsView { |
| 1945 | mode: string; // "ask" | "allow" | "deny" |
| 1946 | allow: string[]; |
| 1947 | ask: string[]; |
| 1948 | deny: string[]; |
| 1949 | } |
| 1950 | |
| 1951 | export interface SandboxView { |
| 1952 | bash: string; // "enforce" | "off" |
| 1953 | network: boolean; |
| 1954 | workspaceRoot: string; |
| 1955 | allowWrite: string[]; |
| 1956 | effectiveWorkspaceRoot: string; |
| 1957 | effectiveWriteRoots: string[]; |
| 1958 | shell: string; // "auto" | "bash" | "powershell" | "pwsh" |
| 1959 | effectiveShell?: string; // bound shell: "bash" | "zsh" | "sh" | "git-bash" | "powershell" | "pwsh" |
| 1960 | resolvedShell?: string; // shell a reload would pick now |
| 1961 | shellReloadRequired?: boolean; |
| 1962 | shellCapabilities: ShellCapabilityView[]; |
| 1963 | gitCapability?: ShellCapabilityView | null; |
| 1964 | shellInstallAction?: ShellInstallActionView | null; |
| 1965 | shellRepairGuidance?: { manager: string; command?: string } | null; |
| 1966 | gitRepairGuidance?: { manager: string; command?: string } | null; |
| 1967 | } |
| 1968 | // One discovered interpreter: usable on this host, where, and why not. |
| 1969 | export interface ShellCapabilityView { |
| 1970 | id: string; // "bash" | "zsh" | "sh" | "git-bash" | "powershell" | "pwsh" |
| 1971 | variant?: string; |
| 1972 | available: boolean; |
| 1973 | path?: string; |
| 1974 | source?: string; |
| 1975 | reason?: string; |
| 1976 | } |
| 1977 | // Optional manual repair action the sandbox section may offer (Windows only). |
| 1978 | export interface ShellInstallActionView { |
| 1979 | id: string; // "git-for-windows" |
| 1980 | mode: string; // "manual" |
| 1981 | available: boolean; |
| 1982 | manualUrl?: string; |
| 1983 | } |
| 1984 | // Structured outcome of InstallShellSupport. |
| 1985 | export interface ShellInstallResult { |
| 1986 | status: string; // "manual_required" | "unsupported_platform" |
| 1987 | path?: string; |
| 1988 | reason?: string; |
| 1989 | manualUrl?: string; |
| 1990 | } |
| 1991 | |
| 1992 | export interface NetworkProxyView { |
| 1993 | type: string; |
| 1994 | server: string; |
| 1995 | port: number; |
| 1996 | username: string; |
| 1997 | password: string; |
| 1998 | } |
| 1999 | |
| 2000 | export interface NetworkView { |
| 2001 | proxyMode: string; // "auto" | "custom" | "off" (backend may still return legacy "env") |
| 2002 | proxyUrl: string; |
| 2003 | noProxy: string; |
| 2004 | proxy: NetworkProxyView; |
| 2005 | } |
| 2006 | |
| 2007 | export interface AgentView { |
| 2008 | temperature: number; |
| 2009 | maxSteps: number; |
| 2010 | plannerMaxSteps: number; |
| 2011 | maxSubagentDepth: number; |
| 2012 | maxSubagentConcurrency: number; |
| 2013 | maxParallelWriters: number; |
| 2014 | systemPrompt: string; |
| 2015 | reasoningLanguage: string; // "auto" | "zh" | "en" |
| 2016 | compactRatio?: number; // Advanced global default; older backends omit it. |
| 2017 | effectiveCompactRatio?: number; // Active local session after project overrides. |
| 2018 | compactRatioOverridden?: boolean; |
| 2019 | } |
| 2020 | |
| 2021 | export interface BotAllowlistView { |
| 2022 | enabled: boolean; |
| 2023 | allowAll: boolean; |
| 2024 | qqUsers: string[]; |
| 2025 | feishuUsers: string[]; |
| 2026 | weixinUsers: string[]; |
| 2027 | qqApprovers: string[]; |
| 2028 | feishuApprovers: string[]; |
| 2029 | weixinApprovers: string[]; |
| 2030 | qqAdmins: string[]; |
| 2031 | feishuAdmins: string[]; |
| 2032 | weixinAdmins: string[]; |
| 2033 | qqGroups: string[]; |
| 2034 | feishuGroups: string[]; |
| 2035 | weixinGroups: string[]; |
| 2036 | dingtalkUsers: string[]; |
| 2037 | dingtalkApprovers: string[]; |
| 2038 | dingtalkAdmins: string[]; |
| 2039 | dingtalkGroups: string[]; |
| 2040 | } |
| 2041 | |
| 2042 | export interface BotAccessView { |
| 2043 | enabled: boolean; |
| 2044 | allowAll: boolean; |
| 2045 | pairingEnabled: boolean; |
| 2046 | users: string[]; |
| 2047 | groups: string[]; |
| 2048 | approvers: string[]; |
| 2049 | admins: string[]; |
| 2050 | } |
| 2051 | |
| 2052 | export interface BotSelfUserIDsView { |
| 2053 | qq: string[]; |
| 2054 | feishu: string[]; |
| 2055 | weixin: string[]; |
| 2056 | dingtalk: string[]; |
| 2057 | } |
| 2058 | |
| 2059 | export interface BotPairingView { |
| 2060 | enabled: boolean; |
| 2061 | requestTtlMinutes: number; |
| 2062 | maxPendingPerPlatform: number; |
| 2063 | } |
| 2064 | |
| 2065 | export interface BotControlView { |
| 2066 | enabled: boolean; |
| 2067 | addr: string; |
| 2068 | tokenEnv: string; |
| 2069 | } |
| 2070 | |
| 2071 | export interface BotRouteView { |
| 2072 | connectionId: string; |
| 2073 | platform: string; |
| 2074 | chatType: string; |
| 2075 | chatId: string; |
| 2076 | userId: string; |
| 2077 | threadId: string; |
| 2078 | model: string; |
| 2079 | toolApprovalMode: ToolApprovalMode | "" | string; |
| 2080 | workspaceRoot: string; |
| 2081 | } |
| 2082 | |
| 2083 | export interface QQBotView { |
| 2084 | enabled: boolean; |
| 2085 | appId: string; |
| 2086 | appSecretEnv: string; |
| 2087 | secretSet: boolean; |
| 2088 | sandbox: boolean; |
| 2089 | model: string; |
| 2090 | toolApprovalMode: ToolApprovalMode | "" | string; |
| 2091 | workspaceRoot: string; |
| 2092 | access: BotAccessView; |
| 2093 | } |
| 2094 | |
| 2095 | export interface FeishuBotView { |
| 2096 | enabled: boolean; |
| 2097 | domain: string; |
| 2098 | appId: string; |
| 2099 | appSecretEnv: string; |
| 2100 | secretSet: boolean; |
| 2101 | verificationToken: string; |
| 2102 | mode: string; |
| 2103 | webhookPort: number; |
| 2104 | requireMention: boolean; |
| 2105 | } |
| 2106 | |
| 2107 | export interface WeixinBotView { |
| 2108 | enabled: boolean; |
| 2109 | accountId: string; |
| 2110 | tokenEnv: string; |
| 2111 | tokenSet: boolean; |
| 2112 | apiBase: string; |
| 2113 | } |
| 2114 | |
| 2115 | export interface DingtalkBotView { |
| 2116 | enabled: boolean; |
| 2117 | clientId: string; |
| 2118 | clientSecretEnv: string; |
| 2119 | secretSet: boolean; |
| 2120 | botName: string; |
| 2121 | requireMention: boolean; |
| 2122 | model: string; |
| 2123 | toolApprovalMode: string; |
| 2124 | workspaceRoot: string; |
| 2125 | access: BotAccessView; |
| 2126 | } |
| 2127 | |
| 2128 | export interface BotConnectionCredentialView { |
| 2129 | appId: string; |
| 2130 | appSecretEnv: string; |
| 2131 | accountId: string; |
| 2132 | tokenEnv: string; |
| 2133 | secretSet: boolean; |
| 2134 | } |
| 2135 | |
| 2136 | export interface BotConnectionSessionMappingView { |
| 2137 | remoteId: string; |
| 2138 | sessionId: string; |
| 2139 | sessionSource: string; |
| 2140 | chatType: string; |
| 2141 | userId: string; |
| 2142 | threadId: string; |
| 2143 | scope: "global" | "project" | string; |
| 2144 | workspaceRoot: string; |
| 2145 | updatedAt: string; |
| 2146 | } |
| 2147 | |
| 2148 | export interface BotConnectionView { |
| 2149 | id: string; |
| 2150 | provider: "qq" | "feishu" | "weixin" | string; |
| 2151 | domain: "qq" | "feishu" | "lark" | "weixin" | string; |
| 2152 | label: string; |
| 2153 | enabled: boolean; |
| 2154 | status: "disconnected" | "pending" | "connected" | "error" | string; |
| 2155 | model: string; |
| 2156 | toolApprovalMode: ToolApprovalMode | "" | string; |
| 2157 | workspaceRoot: string; |
| 2158 | access: BotAccessView; |
| 2159 | credential: BotConnectionCredentialView; |
| 2160 | sessionMappings: BotConnectionSessionMappingView[]; |
| 2161 | lastError: string; |
| 2162 | createdAt: string; |
| 2163 | updatedAt: string; |
| 2164 | } |
| 2165 | |
| 2166 | export interface BotSettingsView { |
| 2167 | enabled: boolean; |
| 2168 | model: string; |
| 2169 | toolApprovalMode: ToolApprovalMode | "" | string; |
| 2170 | maxSteps: number; |
| 2171 | debounceMs: number; |
| 2172 | queueMode: string; |
| 2173 | queueCap: number; |
| 2174 | queueDrop: string; |
| 2175 | ignoreSelfMessages: boolean; |
| 2176 | selfUserIds: BotSelfUserIDsView; |
| 2177 | control: BotControlView; |
| 2178 | pairing: BotPairingView; |
| 2179 | routes: BotRouteView[]; |
| 2180 | allowlist: BotAllowlistView; |
| 2181 | qq: QQBotView; |
| 2182 | feishu: FeishuBotView; |
| 2183 | weixin: WeixinBotView; |
| 2184 | dingtalk: DingtalkBotView; |
| 2185 | connections: BotConnectionView[]; |
| 2186 | } |
| 2187 | |
| 2188 | export interface BotRuntimeStatusView { |
| 2189 | running: boolean; |
| 2190 | status: string; |
| 2191 | message: string; |
| 2192 | connections: number; |
| 2193 | startedAt: string; |
| 2194 | platforms: Record<string, string>; |
| 2195 | } |
| 2196 | |
| 2197 | export interface BotInstallStartResult { |
| 2198 | ok: boolean; |
| 2199 | provider: string; |
| 2200 | domain: string; |
| 2201 | installId: string; |
| 2202 | url: string; |
| 2203 | deviceCode: string; |
| 2204 | userCode: string; |
| 2205 | interval: number; |
| 2206 | expireIn: number; |
| 2207 | message: string; |
| 2208 | } |
| 2209 | |
| 2210 | export interface BotInstallPollResult { |
| 2211 | done: boolean; |
| 2212 | connection: BotConnectionView; |
| 2213 | status: string; |
| 2214 | message: string; |
| 2215 | error: string; |
| 2216 | } |
| 2217 | |
| 2218 | export interface HookConfigView { |
| 2219 | event: string; |
| 2220 | match?: string; |
| 2221 | command: string; |
| 2222 | description?: string; |
| 2223 | timeout?: number; |
| 2224 | cwd?: string; |
| 2225 | } |
| 2226 | |
| 2227 | export interface HooksSettingsView { |
| 2228 | scope: string; |
| 2229 | path: string; |
| 2230 | projectRoot: string; |
| 2231 | trusted: boolean; |
| 2232 | hooks: HookConfigView[]; |
| 2233 | events: string[]; |
| 2234 | } |
| 2235 | |
| 2236 | export interface BotConnectionDiagnostic { |
| 2237 | id: string; |
| 2238 | label: string; |
| 2239 | status: string; |
| 2240 | message: string; |
| 2241 | messageId: string; |
| 2242 | phase: string; |
| 2243 | code: string; |
| 2244 | reportKind: string; |
| 2245 | reportDetail: string; |
| 2246 | occurredAt: string; |
| 2247 | } |
| 2248 | |
| 2249 | export type { ModelSettingsChange, ModelSettingsResult } from "./modelSettingsTypes"; |
| 2250 | |
| 2251 | export interface DesktopStartupSettingsView { |
| 2252 | bot: BotSettingsView; |
| 2253 | desktopLanguage: string; // "" | "en" | "zh"; empty = auto |
| 2254 | desktopTheme: string; // "auto" | "dark" | "light" |
| 2255 | desktopThemeStyle: string; |
| 2256 | desktopTerminalTheme: string; // "auto" follows app | "dark" | "light" |
| 2257 | displayMode: string; sessionExperience?: "standard" | "deep"; reasoningDisplayMode: string; reasoningDisplayModeExplicit?: boolean; |
| 2258 | statusBarStyle: string; // "icon" | "text" |
| 2259 | statusBarItems: string[]; // ordered visible status bar item ids |
| 2260 | checkUpdates: boolean; // check for new versions on startup |
| 2261 | updaterEnabled?: boolean; // build capability; absent/unknown is disabled |
| 2262 | updateChannel: string; // compatibility field; always "stable" |
| 2263 | conversationWidth?: string; // "standard" | "full"; absent from older desktop payloads |
| 2264 | configWarnings?: string[]; configWarningsRevision?: number; // load recovery notices and async delivery barrier |
| 2265 | configPath?: string; |
| 2266 | } |
| 2267 | |
| 2268 | export type ExternalOpenerKind = "file-manager" | "editor" | "terminal"; |
| 2269 | |
| 2270 | export interface ExternalOpenerView { |
| 2271 | id: string; |
| 2272 | name: string; |
| 2273 | kind: ExternalOpenerKind; |
| 2274 | iconDataUrl?: string; |
| 2275 | } |
| 2276 | |
| 2277 | export interface ExternalOpenersView { |
| 2278 | openers: ExternalOpenerView[]; |
| 2279 | preferred: string; workspaceOpenable?: boolean; |
| 2280 | } |
| 2281 | |
| 2282 | // Auto-updater payloads (desktop/updater.go). UpdateInfo drives the update banner; |
| 2283 | // UpdateProgress streams on the "updater:progress" event during download/install. |
| 2284 | export interface UpdateInfo { |
| 2285 | available: boolean; |
| 2286 | current: string; |
| 2287 | latest: string; |
| 2288 | notes: string; |
| 2289 | channel: string; |
| 2290 | canSelfUpdate: boolean; // macOS true only for signed/notarized builds |
| 2291 | manualOnly?: boolean; |
| 2292 | manualReason?: string; |
| 2293 | installMode?: "portable" | "deb" | "manual" | string; |
| 2294 | requiresElevation?: boolean; |
| 2295 | downloaded: boolean; |
| 2296 | downloadUrl: string; // human-facing releases page (macOS path / fallback link) |
| 2297 | assetSize: number; // running platform's artifact size, for the progress bar |
| 2298 | err?: string; // set when the check itself failed (both endpoints down) |
| 2299 | } |
| 2300 | |
| 2301 | export interface UpdateDownloadResult { |
| 2302 | requestId: string; |
| 2303 | version: string; |
| 2304 | channel: string; |
| 2305 | path: string; |
| 2306 | size: number; |
| 2307 | sha256: string; |
| 2308 | } |
| 2309 | |
| 2310 | export interface UpdateProgress { |
| 2311 | requestId: string; |
| 2312 | version: string; |
| 2313 | channel: "stable" | "preview" | string; |
| 2314 | phase: "downloading" | "verifying" | "downloaded" | "authorizing" | "recovering" | "installing" | "relaunching" | "done" | "error"; |
| 2315 | received: number; |
| 2316 | total: number; |
| 2317 | err?: string; |
| 2318 | } |
| 2319 | |
| 2320 | // Task Monitor panel types (internal/taskmonitor). |
| 2321 | |
| 2322 | export type TaskState = |
| 2323 | | "queued" |
| 2324 | | "running" |
| 2325 | | "waiting" |
| 2326 | | "succeeded" |
| 2327 | | "failed" |
| 2328 | | "cancelled" |
| 2329 | | "stale" |
| 2330 | | string; // forward-compat |
| 2331 | |
| 2332 | export type RuntimeState = "unknown" | "alive" | "exited" | string; |
| 2333 | |
| 2334 | export interface TaskSnapshot { |
| 2335 | schema_version: number; |
| 2336 | task_id: string; |
| 2337 | job_id?: string; // jobs.Manager-local runtime identifier |
| 2338 | session_id: string; |
| 2339 | state: TaskState; |
| 2340 | runtime_state?: RuntimeState; // absent in snapshots written before this field existed |
| 2341 | version: number; |
| 2342 | created_at: string; // ISO 8601 |
| 2343 | updated_at: string; // ISO 8601 |
| 2344 | error_code?: string; |
| 2345 | error_summary?: string; |
| 2346 | } |
| 2347 | |
| 2348 | export type { TaskActionRequest, TaskCatalogItem, TaskCatalogStatus, TaskEventPage, TaskEventPageRequest, TaskPage, TaskPageRequest } from "./taskCatalogTypes"; |
| 2349 | |
| 2350 | export interface ControlResult { |
| 2351 | schema_version: number; |
| 2352 | command: string; |
| 2353 | task_id: string; |
| 2354 | session_id?: string; |
| 2355 | state?: TaskState; |
| 2356 | runtime_state?: RuntimeState; |
| 2357 | version?: number; |
| 2358 | accepted: boolean; |
| 2359 | idempotent: boolean; |
| 2360 | error?: { code: string; message: string }; |
| 2361 | } |
| 2362 | |
| 2363 | export interface TaskEvent { |
| 2364 | sequence: number; |
| 2365 | timestamp: string; // ISO 8601 |
| 2366 | event_type: string; |
| 2367 | task_id: string; |
| 2368 | session_id: string; |
| 2369 | state: TaskState; |
| 2370 | runtime_state?: RuntimeState; |
| 2371 | error_code?: string; |
| 2372 | error_summary?: string; |
| 2373 | } |
| 2374 |