workspace.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /** Application-owned identities. Hermes profile/session IDs never identify a chat. */
  2. export interface WorkspaceAgent {
  3. id: string
  4. name: string
  5. avatar: string
  6. instructions: string
  7. /** Explicit account-owner grant; absent on older records means disabled. */
  8. execution?: 'profile' | 'computer'
  9. computer?: 'auto' | 'cloud' | 'vm' | 'local' | 'browser' | 'off'
  10. browserProfile?: 'persistent' | 'temporary'
  11. computerEnvironmentId?:string
  12. computerEnvironmentName?:string
  13. canManageTeam?: boolean
  14. teamAuthorizationVersion?: number
  15. temporaryGoalId?:string
  16. helperActivation?:number
  17. helperRunnerId?:string
  18. retiredAt?:number
  19. cleanupState?:'pending'|'complete'
  20. createdByAgentId?: string
  21. createdFromRunId?: string
  22. nodeId: string
  23. profile: string
  24. remoteAgentId?: string
  25. archived: boolean
  26. revision: number
  27. createdAt: number
  28. updatedAt: number
  29. }
  30. export interface WorkspaceMemberRole {
  31. name: string
  32. description: string
  33. }
  34. export interface WorkspaceConversation {
  35. id: string
  36. kind: 'direct' | 'group'
  37. name: string
  38. avatar: string
  39. memberIds: string[]
  40. memberRoles?: Record<string, WorkspaceMemberRole>
  41. instructions: string
  42. administratorId: string
  43. mode: 'host' | 'free'
  44. autoReplyIds: string[]
  45. maxReplyRounds: number
  46. archived: boolean
  47. pinned: boolean
  48. readSeq: number
  49. lastSeq: number
  50. lastMessageAt?: number
  51. preview: string
  52. previewAgentId?: string
  53. activeRunId?: string
  54. activeAgentId?: string
  55. activeRunStatus?: WorkspaceRun['status']
  56. activeAgentStates?: Record<string, 'running' | 'waiting' | 'uncertain' | 'queued'>
  57. avatarSignals?: Record<string, { id: string; state: 'success' | 'failure'; at: number }>
  58. queuedMessageCount?: number
  59. unread?: boolean
  60. /** Changes when new attention arrives, so an older read cannot clear it. */
  61. unreadVersion?: number
  62. /** Compatibility signal for older clients: always 0 or 1. */
  63. unreadCount?: number
  64. createdAt: number
  65. updatedAt: number
  66. }
  67. export interface WorkspaceTask {
  68. id: string
  69. conversationId: string
  70. title: string
  71. titleSource: 'automatic' | 'user'
  72. messageCount: number
  73. readSeq: number
  74. lastSeq: number
  75. unread?: boolean
  76. unreadVersion?: number
  77. /** Compatibility signal for older clients: always 0 or 1. */
  78. unreadCount: number
  79. activeRunId?: string
  80. activeRunStatus?: WorkspaceRun['status']
  81. lastMessageAt?: number
  82. createdAt: number
  83. updatedAt: number
  84. goal?: import('./agentTasks.js').AgentGoal
  85. }
  86. export function workspaceHasUnread(value: { unread?: boolean; unreadCount?: number; lastSeq: number; readSeq: number }): boolean {
  87. return value.unread ?? (value.unreadCount !== undefined ? value.unreadCount > 0 : value.lastSeq > value.readSeq)
  88. }
  89. export interface WorkspaceFile {
  90. id: string
  91. name: string
  92. mimeType: string
  93. size: number
  94. createdAt: number
  95. sourcePath?: string
  96. conversationId?: string
  97. messageId?: string
  98. profile?: string
  99. sender: 'user' | 'agent'
  100. }
  101. export interface WorkspaceMessage {
  102. execution?:'profile'|'computer'
  103. id: string
  104. conversationId: string
  105. /** User-visible task scope. `taskId` below remains the scheduler turn ID. */
  106. conversationTaskId?: string
  107. seq: number
  108. role: 'user' | 'assistant' | 'system'
  109. taskReference?: { conversationId: string; taskId: string }
  110. agentId?: string
  111. agentName?: string
  112. content: string
  113. reasoning: string
  114. runId?: string
  115. taskId?: string
  116. visible?: boolean
  117. error?: string
  118. status: 'queued' | 'streaming' | 'complete' | 'failed' | 'interrupted' | 'uncertain'
  119. attachments: WorkspaceFile[]
  120. tools: Array<Record<string, unknown>>
  121. createdAt: number
  122. }
  123. export interface WorkspaceRun {
  124. id: string
  125. conversationId: string
  126. conversationTaskId?: string
  127. messageId: string
  128. mentionIds: string[]
  129. activeAgentId?: string
  130. status: 'queued' | 'running' | 'waiting' | 'complete' | 'failed' | 'interrupted' | 'uncertain'
  131. round: number
  132. error?: string
  133. stopRequested?: boolean
  134. assignmentId?: string
  135. /** Structured delivery run; ordinary chat does not carry a goal. */
  136. goalId?: string
  137. targetAgentId?: string
  138. triggerKind?: 'assignment' | 'task_review' | 'task_result'
  139. internalInstruction?: string
  140. authorizationVersion?: number
  141. createdAt: number
  142. updatedAt: number
  143. }
  144. export interface WorkspaceInteraction {
  145. id: string
  146. conversationId: string
  147. conversationTaskId?: string
  148. runId: string
  149. agentId: string
  150. kind: 'approval' | 'clarification'
  151. message: string
  152. choices: string[]
  153. resolved: boolean
  154. }
  155. export interface WorkspaceEvent {
  156. seq: number
  157. type: string
  158. conversationId?: string
  159. data: unknown
  160. }
  161. export interface WorkspaceSource {
  162. nodeId: string
  163. profile: string
  164. name: string
  165. }