@swarmclawai/swarmclaw 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/README.md +20 -0
  2. package/bin/daemon-cmd.js +169 -0
  3. package/bin/server-cmd.js +3 -0
  4. package/bin/swarmclaw.js +11 -0
  5. package/package.json +17 -16
  6. package/src/app/api/agents/[id]/clone/route.ts +3 -32
  7. package/src/app/api/agents/[id]/route.ts +6 -158
  8. package/src/app/api/agents/[id]/status/route.ts +2 -3
  9. package/src/app/api/agents/[id]/thread/route.ts +4 -17
  10. package/src/app/api/agents/bulk/route.ts +5 -47
  11. package/src/app/api/agents/route.ts +5 -119
  12. package/src/app/api/agents/trash/route.ts +13 -24
  13. package/src/app/api/auth/route.ts +3 -9
  14. package/src/app/api/autonomy/estop/route.ts +5 -5
  15. package/src/app/api/chatrooms/[id]/chat/route.ts +11 -5
  16. package/src/app/api/chatrooms/[id]/route.ts +23 -2
  17. package/src/app/api/chatrooms/route.ts +13 -2
  18. package/src/app/api/chats/[id]/clear/route.ts +2 -13
  19. package/src/app/api/chats/[id]/deploy/route.ts +2 -3
  20. package/src/app/api/chats/[id]/edit-resend/route.ts +7 -13
  21. package/src/app/api/chats/[id]/mailbox/route.ts +6 -8
  22. package/src/app/api/chats/[id]/queue/route.ts +17 -64
  23. package/src/app/api/chats/[id]/retry/route.ts +4 -22
  24. package/src/app/api/chats/[id]/route.ts +10 -138
  25. package/src/app/api/chats/heartbeat/route.ts +2 -1
  26. package/src/app/api/chats/migrate-messages/route.ts +7 -0
  27. package/src/app/api/chats/route.ts +13 -134
  28. package/src/app/api/connectors/[id]/access/route.ts +12 -229
  29. package/src/app/api/connectors/[id]/doctor/route.ts +1 -1
  30. package/src/app/api/connectors/[id]/health/route.ts +12 -39
  31. package/src/app/api/connectors/[id]/route.ts +14 -122
  32. package/src/app/api/connectors/[id]/webhook/route.ts +1 -1
  33. package/src/app/api/connectors/doctor/route.ts +1 -1
  34. package/src/app/api/connectors/route.ts +12 -70
  35. package/src/app/api/credentials/[id]/route.ts +2 -4
  36. package/src/app/api/credentials/route.ts +10 -19
  37. package/src/app/api/daemon/health-check/route.ts +3 -4
  38. package/src/app/api/daemon/route.ts +10 -8
  39. package/src/app/api/documents/route.ts +11 -10
  40. package/src/app/api/external-agents/route.ts +3 -3
  41. package/src/app/api/gateways/[id]/health/route.ts +2 -3
  42. package/src/app/api/gateways/[id]/route.ts +7 -122
  43. package/src/app/api/gateways/route.ts +3 -103
  44. package/src/app/api/mcp-servers/[id]/tools/route.ts +5 -5
  45. package/src/app/api/openclaw/dashboard-url/route.ts +8 -16
  46. package/src/app/api/openclaw/directory/route.ts +2 -2
  47. package/src/app/api/openclaw/history/route.ts +3 -5
  48. package/src/app/api/providers/[id]/models/route.test.ts +60 -0
  49. package/src/app/api/providers/[id]/models/route.ts +33 -1
  50. package/src/app/api/providers/[id]/route.test.ts +49 -0
  51. package/src/app/api/providers/[id]/route.ts +30 -1
  52. package/src/app/api/providers/ollama/route.ts +6 -5
  53. package/src/app/api/schedules/[id]/route.ts +14 -108
  54. package/src/app/api/schedules/[id]/run/route.ts +6 -67
  55. package/src/app/api/schedules/route.ts +9 -51
  56. package/src/app/api/settings/route.ts +4 -3
  57. package/src/app/api/setup/check-provider/route.ts +15 -1
  58. package/src/app/api/setup/openclaw-device/route.ts +2 -2
  59. package/src/app/api/system/status/route.ts +2 -2
  60. package/src/app/api/tasks/[id]/route.ts +16 -202
  61. package/src/app/api/tasks/bulk/route.ts +5 -86
  62. package/src/app/api/tasks/metrics/route.ts +2 -1
  63. package/src/app/api/tasks/route.ts +11 -171
  64. package/src/app/api/upload/route.ts +1 -1
  65. package/src/app/api/uploads/[filename]/route.ts +1 -1
  66. package/src/app/api/uploads/route.ts +1 -1
  67. package/src/app/api/webhooks/[id]/history/route.ts +2 -2
  68. package/src/app/layout.tsx +9 -6
  69. package/src/app/protocols/page.tsx +71 -89
  70. package/src/app/tasks/page.tsx +32 -32
  71. package/src/cli/index.js +1 -0
  72. package/src/cli/spec.js +1 -0
  73. package/src/components/agents/agent-sheet.tsx +51 -25
  74. package/src/components/agents/inspector-panel.tsx +15 -4
  75. package/src/components/auth/setup-wizard/index.tsx +27 -18
  76. package/src/components/auth/setup-wizard/shared.tsx +2 -2
  77. package/src/components/auth/setup-wizard/step-agents.tsx +51 -38
  78. package/src/components/auth/setup-wizard/step-connect.tsx +48 -17
  79. package/src/components/auth/setup-wizard/types.ts +6 -4
  80. package/src/components/auth/setup-wizard/utils.test.ts +38 -8
  81. package/src/components/auth/setup-wizard/utils.ts +14 -8
  82. package/src/components/chatrooms/chatroom-sheet.tsx +16 -276
  83. package/src/components/connectors/connector-list.tsx +26 -40
  84. package/src/components/connectors/connector-sheet.tsx +95 -149
  85. package/src/components/gateways/gateway-sheet.tsx +61 -110
  86. package/src/components/layout/live-query-sync.tsx +121 -0
  87. package/src/components/protocols/structured-session-launcher.tsx +24 -45
  88. package/src/components/providers/app-query-provider.tsx +17 -0
  89. package/src/components/providers/provider-list.tsx +150 -77
  90. package/src/components/providers/provider-sheet.tsx +102 -77
  91. package/src/components/shared/model-combobox.tsx +5 -4
  92. package/src/components/skills/skill-list.tsx +5 -18
  93. package/src/components/skills/skill-sheet.tsx +21 -20
  94. package/src/components/skills/skills-workspace.tsx +48 -87
  95. package/src/components/tasks/task-card.tsx +20 -13
  96. package/src/components/tasks/task-column.tsx +22 -7
  97. package/src/components/tasks/task-list.tsx +8 -11
  98. package/src/components/tasks/task-sheet.tsx +111 -103
  99. package/src/features/agents/queries.ts +20 -0
  100. package/src/features/chatrooms/queries.ts +20 -0
  101. package/src/features/chats/queries.ts +27 -0
  102. package/src/features/connectors/queries.ts +145 -0
  103. package/src/features/credentials/queries.ts +37 -0
  104. package/src/features/extensions/queries.ts +26 -0
  105. package/src/features/external-agents/queries.ts +36 -0
  106. package/src/features/gateways/queries.ts +274 -0
  107. package/src/features/missions/queries.ts +23 -0
  108. package/src/features/projects/queries.ts +20 -0
  109. package/src/features/protocols/queries.ts +149 -0
  110. package/src/features/providers/queries.ts +142 -0
  111. package/src/features/settings/queries.ts +20 -0
  112. package/src/features/skills/queries.ts +182 -0
  113. package/src/features/tasks/queries.ts +189 -0
  114. package/src/hooks/use-ws.ts +3 -2
  115. package/src/lib/agent-provider-options.test.ts +152 -0
  116. package/src/lib/agent-provider-options.ts +84 -0
  117. package/src/lib/app/api-client.ts +2 -2
  118. package/src/lib/providers/index.test.ts +78 -0
  119. package/src/lib/providers/index.ts +13 -10
  120. package/src/lib/query/client.ts +17 -0
  121. package/src/lib/server/agents/agent-runtime-config.ts +6 -6
  122. package/src/lib/server/agents/agent-service.ts +429 -0
  123. package/src/lib/server/agents/agent-thread-session.ts +6 -5
  124. package/src/lib/server/agents/autonomy-contract.ts +1 -4
  125. package/src/lib/server/agents/delegation-advisory.test.ts +206 -0
  126. package/src/lib/server/agents/delegation-advisory.ts +251 -0
  127. package/src/lib/server/agents/main-agent-loop.ts +98 -40
  128. package/src/lib/server/agents/subagent-runtime.ts +12 -0
  129. package/src/lib/server/autonomy/supervisor-reflection.test.ts +20 -1
  130. package/src/lib/server/autonomy/supervisor-reflection.ts +39 -19
  131. package/src/lib/server/build-llm.ts +7 -15
  132. package/src/lib/server/capability-router.test.ts +70 -1
  133. package/src/lib/server/capability-router.ts +24 -99
  134. package/src/lib/server/chat-execution/chat-execution-utils.ts +0 -15
  135. package/src/lib/server/chat-execution/chat-streaming-utils.ts +2 -4
  136. package/src/lib/server/chat-execution/chat-turn-finalization.ts +77 -12
  137. package/src/lib/server/chat-execution/chat-turn-partial-persistence.ts +4 -4
  138. package/src/lib/server/chat-execution/chat-turn-preflight.ts +2 -2
  139. package/src/lib/server/chat-execution/chat-turn-preparation.ts +41 -17
  140. package/src/lib/server/chat-execution/chat-turn-stream-execution.ts +4 -2
  141. package/src/lib/server/chat-execution/chat-turn-tool-routing.test.ts +45 -0
  142. package/src/lib/server/chat-execution/chat-turn-tool-routing.ts +48 -17
  143. package/src/lib/server/chat-execution/continuation-evaluator.ts +4 -1
  144. package/src/lib/server/chat-execution/direct-memory-intent.test.ts +9 -0
  145. package/src/lib/server/chat-execution/direct-memory-intent.ts +12 -2
  146. package/src/lib/server/chat-execution/message-classifier.test.ts +35 -23
  147. package/src/lib/server/chat-execution/message-classifier.ts +74 -32
  148. package/src/lib/server/chat-execution/prompt-builder.test.ts +29 -0
  149. package/src/lib/server/chat-execution/prompt-builder.ts +37 -2
  150. package/src/lib/server/chat-execution/prompt-sections.test.ts +56 -0
  151. package/src/lib/server/chat-execution/prompt-sections.ts +193 -0
  152. package/src/lib/server/chat-execution/stream-agent-chat.ts +63 -7
  153. package/src/lib/server/chat-execution/stream-continuation.test.ts +36 -0
  154. package/src/lib/server/chat-execution/stream-continuation.ts +28 -13
  155. package/src/lib/server/chatrooms/chatroom-agent-signals.ts +26 -18
  156. package/src/lib/server/chatrooms/chatroom-helpers.ts +19 -18
  157. package/src/lib/server/chatrooms/chatroom-repository.ts +16 -0
  158. package/src/lib/server/chatrooms/chatroom-routing.test.ts +96 -0
  159. package/src/lib/server/chatrooms/chatroom-routing.ts +207 -53
  160. package/src/lib/server/chatrooms/mailbox-utils.ts +4 -2
  161. package/src/lib/server/chatrooms/session-mailbox.ts +50 -40
  162. package/src/lib/server/chats/chat-session-service.ts +410 -0
  163. package/src/lib/server/connectors/access.ts +1 -1
  164. package/src/lib/server/connectors/commands.ts +7 -6
  165. package/src/lib/server/connectors/connector-inbound.ts +14 -7
  166. package/src/lib/server/connectors/connector-outbound.ts +16 -11
  167. package/src/lib/server/connectors/connector-service.ts +453 -0
  168. package/src/lib/server/connectors/delivery.ts +17 -12
  169. package/src/lib/server/connectors/inbound-audio-transcription.ts +5 -14
  170. package/src/lib/server/connectors/media.ts +1 -1
  171. package/src/lib/server/connectors/response-media.ts +1 -1
  172. package/src/lib/server/connectors/session-consolidation.ts +11 -7
  173. package/src/lib/server/connectors/session.ts +9 -7
  174. package/src/lib/server/connectors/voice-note.ts +2 -1
  175. package/src/lib/server/context-manager.ts +20 -1
  176. package/src/lib/server/cost.ts +2 -3
  177. package/src/lib/server/credentials/credential-repository.ts +43 -4
  178. package/src/lib/server/credentials/credential-service.ts +112 -0
  179. package/src/lib/server/daemon/admin-metadata.ts +64 -0
  180. package/src/lib/server/daemon/controller.ts +577 -0
  181. package/src/lib/server/daemon/daemon-runtime.ts +352 -0
  182. package/src/lib/server/daemon/daemon-status-repository.ts +63 -0
  183. package/src/lib/server/daemon/types.ts +101 -0
  184. package/src/lib/server/embeddings.ts +3 -9
  185. package/src/lib/server/eval/agent-regression.ts +3 -2
  186. package/src/lib/server/eval/runner.ts +2 -2
  187. package/src/lib/server/execution-brief.test.ts +167 -0
  188. package/src/lib/server/execution-brief.ts +295 -0
  189. package/src/lib/server/execution-engine/chat-turn.ts +9 -0
  190. package/src/lib/server/execution-engine/import-boundary.test.ts +44 -0
  191. package/src/lib/server/execution-engine/index.ts +35 -0
  192. package/src/lib/server/execution-engine/task-attempt.ts +303 -0
  193. package/src/lib/server/execution-engine/types.ts +33 -0
  194. package/src/lib/server/gateways/gateway-profile-repository.ts +47 -3
  195. package/src/lib/server/gateways/gateway-profile-service.ts +200 -0
  196. package/src/lib/server/memory/session-archive-memory.ts +12 -10
  197. package/src/lib/server/messages/message-repository.ts +330 -0
  198. package/src/lib/server/missions/mission-service/core.ts +8 -6
  199. package/src/lib/server/openclaw/agent-resolver.ts +2 -3
  200. package/src/lib/server/openclaw/doctor.ts +1 -1
  201. package/src/lib/server/openclaw/gateway.test.ts +10 -1
  202. package/src/lib/server/openclaw/gateway.ts +5 -14
  203. package/src/lib/server/openclaw/health.ts +3 -11
  204. package/src/lib/server/openclaw/sync.ts +8 -6
  205. package/src/lib/server/persistence/storage-context.ts +3 -0
  206. package/src/lib/server/protocols/protocol-agent-turn.ts +25 -17
  207. package/src/lib/server/protocols/protocol-normalization.ts +1 -1
  208. package/src/lib/server/protocols/protocol-queries.ts +13 -7
  209. package/src/lib/server/protocols/protocol-run-lifecycle.ts +16 -20
  210. package/src/lib/server/protocols/protocol-run-repository.ts +81 -0
  211. package/src/lib/server/protocols/protocol-step-processors.ts +23 -31
  212. package/src/lib/server/protocols/protocol-swarm.ts +8 -8
  213. package/src/lib/server/protocols/protocol-template-repository.ts +42 -0
  214. package/src/lib/server/protocols/protocol-templates.ts +4 -2
  215. package/src/lib/server/protocols/protocol-types.ts +10 -7
  216. package/src/lib/server/provider-endpoint.ts +7 -12
  217. package/src/lib/server/provider-model-discovery.ts +2 -11
  218. package/src/lib/server/query-expansion.ts +5 -6
  219. package/src/lib/server/run-context.test.ts +365 -0
  220. package/src/lib/server/run-context.ts +367 -0
  221. package/src/lib/server/runtime/heartbeat-service.ts +7 -5
  222. package/src/lib/server/runtime/queue/core.ts +61 -190
  223. package/src/lib/server/runtime/run-ledger.ts +8 -0
  224. package/src/lib/server/runtime/session-run-manager/drain.ts +2 -2
  225. package/src/lib/server/runtime/session-run-manager/enqueue.ts +6 -0
  226. package/src/lib/server/runtime/session-run-manager/state.ts +4 -0
  227. package/src/lib/server/schedules/schedule-route-service.ts +230 -0
  228. package/src/lib/server/service-result.ts +16 -0
  229. package/src/lib/server/session-note.ts +2 -3
  230. package/src/lib/server/session-reset-policy.ts +4 -3
  231. package/src/lib/server/session-tools/connector.ts +9 -6
  232. package/src/lib/server/session-tools/context-mgmt.ts +58 -9
  233. package/src/lib/server/session-tools/crud.ts +162 -10
  234. package/src/lib/server/session-tools/delegate.ts +1 -1
  235. package/src/lib/server/session-tools/manage-tasks.test.ts +152 -0
  236. package/src/lib/server/session-tools/memory.ts +6 -4
  237. package/src/lib/server/session-tools/session-info.test.ts +56 -0
  238. package/src/lib/server/session-tools/session-info.ts +119 -12
  239. package/src/lib/server/session-tools/skill-runtime.ts +3 -1
  240. package/src/lib/server/session-tools/skills.ts +15 -15
  241. package/src/lib/server/session-tools/subagent.test.ts +115 -1
  242. package/src/lib/server/session-tools/subagent.ts +125 -7
  243. package/src/lib/server/session-tools/team-context.ts +4 -3
  244. package/src/lib/server/session-tools/wallet.ts +0 -58
  245. package/src/lib/server/sessions/session-lineage.ts +55 -0
  246. package/src/lib/server/sessions/session-repository.ts +2 -2
  247. package/src/lib/server/skills/learned-skills.ts +24 -23
  248. package/src/lib/server/skills/runtime-skill-resolver.ts +2 -1
  249. package/src/lib/server/skills/skill-repository.ts +136 -13
  250. package/src/lib/server/skills/skill-suggestions.ts +25 -28
  251. package/src/lib/server/storage-normalization.test.ts +42 -215
  252. package/src/lib/server/storage-normalization.ts +98 -0
  253. package/src/lib/server/storage.ts +19 -0
  254. package/src/lib/server/structured-extract.ts +3 -14
  255. package/src/lib/server/tasks/task-followups.ts +16 -11
  256. package/src/lib/server/tasks/task-result.test.ts +25 -29
  257. package/src/lib/server/tasks/task-result.ts +5 -9
  258. package/src/lib/server/tasks/task-route-service.ts +449 -0
  259. package/src/lib/server/text-normalization.ts +41 -0
  260. package/src/lib/server/tool-planning.ts +6 -42
  261. package/src/lib/server/upload-path.ts +5 -0
  262. package/src/lib/server/working-state/extraction.ts +614 -0
  263. package/src/lib/server/working-state/normalization.ts +866 -0
  264. package/src/lib/server/working-state/prompt.ts +60 -0
  265. package/src/lib/server/working-state/repository.ts +38 -0
  266. package/src/lib/server/working-state/service.test.ts +253 -0
  267. package/src/lib/server/working-state/service.ts +293 -0
  268. package/src/lib/validation/schemas.ts +1 -0
  269. package/src/lib/ws-client.ts +3 -3
  270. package/src/stores/slices/task-slice.ts +1 -4
  271. package/src/stores/use-chatroom-store.ts +2 -2
  272. package/src/types/index.ts +288 -22
  273. package/src/views/settings/section-providers.tsx +2 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { create } from 'zustand'
4
4
  import { api, getStoredAccessKey } from '@/lib/app/api-client'
5
- import type { Chatroom, ChatroomMessage, ChatroomRoutingRule, SSEEvent } from '@/types'
5
+ import type { Chatroom, ChatroomMessage, SSEEvent } from '@/types'
6
6
  import type { PendingFile } from '@/stores/use-chat-store'
7
7
 
8
8
  interface ToolEvent {
@@ -59,7 +59,7 @@ interface ChatroomState {
59
59
 
60
60
  loadChatrooms: () => Promise<void>
61
61
  loadChatroomById: (id: string) => Promise<Chatroom | null>
62
- createChatroom: (data: { name: string; description?: string; agentIds?: string[]; chatMode?: 'sequential' | 'parallel'; autoAddress?: boolean; routingRules?: ChatroomRoutingRule[] }) => Promise<Chatroom>
62
+ createChatroom: (data: { name: string; description?: string; agentIds?: string[]; chatMode?: 'sequential' | 'parallel'; autoAddress?: boolean; routingGuidance?: string | null }) => Promise<Chatroom>
63
63
  updateChatroom: (id: string, data: Partial<Chatroom>) => Promise<void>
64
64
  deleteChatroom: (id: string) => Promise<void>
65
65
  setCurrentChatroom: (id: string | null) => void
@@ -7,6 +7,25 @@ export interface MessageToolEvent {
7
7
  toolCallId?: string
8
8
  }
9
9
 
10
+ export type MessageTaskIntent = 'coding' | 'research' | 'browsing' | 'outreach' | 'scheduling' | 'general'
11
+ export type MessageWorkType = 'coding' | 'research' | 'writing' | 'review' | 'operations' | 'general'
12
+
13
+ export interface MessageSemanticsSummary {
14
+ taskIntent: MessageTaskIntent
15
+ workType: MessageWorkType
16
+ walletIntent: 'none' | 'read_only' | 'transactional'
17
+ isDeliverableTask: boolean
18
+ isBroadGoal: boolean
19
+ isResearchSynthesis: boolean
20
+ hasHumanSignals: boolean
21
+ hasSignificantEvent: boolean
22
+ wantsScreenshots?: boolean
23
+ wantsOutboundDelivery?: boolean
24
+ wantsVoiceDelivery?: boolean
25
+ explicitToolRequests: string[]
26
+ confidence: number
27
+ }
28
+
10
29
  export interface Message {
11
30
  role: 'user' | 'assistant'
12
31
  text: string
@@ -30,6 +49,8 @@ export interface Message {
30
49
  streaming?: boolean
31
50
  /** Run ID that produced this message — used to scope streaming artifact replacement. */
32
51
  runId?: string
52
+ /** Cached turn semantics used for routing, delegation, and reflection. */
53
+ semantics?: MessageSemanticsSummary
33
54
  }
34
55
 
35
56
  export type SessionResetMode = 'idle' | 'daily' | 'isolated'
@@ -53,6 +74,216 @@ export interface SessionArchiveState {
53
74
  exportPath?: string | null
54
75
  }
55
76
 
77
+ export type WorkingStateStatus = 'idle' | 'progress' | 'blocked' | 'waiting' | 'completed'
78
+ export type WorkingStateItemStatus = 'active' | 'resolved' | 'superseded'
79
+
80
+ export interface EvidenceRef {
81
+ id: string
82
+ type: 'tool' | 'message' | 'mission' | 'task' | 'artifact' | 'error' | 'approval'
83
+ summary: string
84
+ value?: string | null
85
+ toolName?: string | null
86
+ toolCallId?: string | null
87
+ runId?: string | null
88
+ sessionId?: string | null
89
+ missionId?: string | null
90
+ taskId?: string | null
91
+ createdAt: number
92
+ }
93
+
94
+ export interface WorkingPlanStep {
95
+ id: string
96
+ text: string
97
+ status: WorkingStateItemStatus
98
+ createdAt: number
99
+ updatedAt: number
100
+ }
101
+
102
+ export interface WorkingFact {
103
+ id: string
104
+ statement: string
105
+ source: 'user' | 'tool' | 'assistant' | 'mission' | 'system'
106
+ status: WorkingStateItemStatus
107
+ evidenceIds?: string[]
108
+ createdAt: number
109
+ updatedAt: number
110
+ }
111
+
112
+ export interface WorkingArtifact {
113
+ id: string
114
+ label: string
115
+ kind: 'file' | 'url' | 'approval' | 'message' | 'other'
116
+ path?: string | null
117
+ url?: string | null
118
+ sourceTool?: string | null
119
+ status: WorkingStateItemStatus
120
+ evidenceIds?: string[]
121
+ createdAt: number
122
+ updatedAt: number
123
+ }
124
+
125
+ export interface WorkingDecision {
126
+ id: string
127
+ summary: string
128
+ rationale?: string | null
129
+ status: WorkingStateItemStatus
130
+ evidenceIds?: string[]
131
+ createdAt: number
132
+ updatedAt: number
133
+ }
134
+
135
+ export interface WorkingBlocker {
136
+ id: string
137
+ summary: string
138
+ kind?: 'approval' | 'credential' | 'human_input' | 'external_dependency' | 'error' | 'other' | null
139
+ nextAction?: string | null
140
+ status: WorkingStateItemStatus
141
+ evidenceIds?: string[]
142
+ createdAt: number
143
+ updatedAt: number
144
+ }
145
+
146
+ export interface WorkingQuestion {
147
+ id: string
148
+ question: string
149
+ status: WorkingStateItemStatus
150
+ evidenceIds?: string[]
151
+ createdAt: number
152
+ updatedAt: number
153
+ }
154
+
155
+ export interface WorkingHypothesis {
156
+ id: string
157
+ statement: string
158
+ confidence?: 'low' | 'medium' | 'high' | null
159
+ status: WorkingStateItemStatus
160
+ evidenceIds?: string[]
161
+ createdAt: number
162
+ updatedAt: number
163
+ }
164
+
165
+ export interface WorkingPlanStepPatch {
166
+ id?: string | null
167
+ text: string
168
+ status?: WorkingStateItemStatus | null
169
+ }
170
+
171
+ export interface WorkingFactPatch {
172
+ id?: string | null
173
+ statement: string
174
+ source?: WorkingFact['source'] | null
175
+ status?: WorkingStateItemStatus | null
176
+ evidenceIds?: string[]
177
+ }
178
+
179
+ export interface WorkingArtifactPatch {
180
+ id?: string | null
181
+ label: string
182
+ kind?: WorkingArtifact['kind'] | null
183
+ path?: string | null
184
+ url?: string | null
185
+ sourceTool?: string | null
186
+ status?: WorkingStateItemStatus | null
187
+ evidenceIds?: string[]
188
+ }
189
+
190
+ export interface WorkingDecisionPatch {
191
+ id?: string | null
192
+ summary: string
193
+ rationale?: string | null
194
+ status?: WorkingStateItemStatus | null
195
+ evidenceIds?: string[]
196
+ }
197
+
198
+ export interface WorkingBlockerPatch {
199
+ id?: string | null
200
+ summary: string
201
+ kind?: WorkingBlocker['kind']
202
+ nextAction?: string | null
203
+ status?: WorkingStateItemStatus | null
204
+ evidenceIds?: string[]
205
+ }
206
+
207
+ export interface WorkingQuestionPatch {
208
+ id?: string | null
209
+ question: string
210
+ status?: WorkingStateItemStatus | null
211
+ evidenceIds?: string[]
212
+ }
213
+
214
+ export interface WorkingHypothesisPatch {
215
+ id?: string | null
216
+ statement: string
217
+ confidence?: WorkingHypothesis['confidence']
218
+ status?: WorkingStateItemStatus | null
219
+ evidenceIds?: string[]
220
+ }
221
+
222
+ export interface WorkingStatePatch {
223
+ objective?: string | null
224
+ summary?: string | null
225
+ constraints?: string[]
226
+ successCriteria?: string[]
227
+ status?: WorkingStateStatus | null
228
+ nextAction?: string | null
229
+ planSteps?: WorkingPlanStepPatch[]
230
+ factsUpsert?: WorkingFactPatch[]
231
+ artifactsUpsert?: WorkingArtifactPatch[]
232
+ decisionsAppend?: WorkingDecisionPatch[]
233
+ blockersUpsert?: WorkingBlockerPatch[]
234
+ questionsUpsert?: WorkingQuestionPatch[]
235
+ hypothesesUpsert?: WorkingHypothesisPatch[]
236
+ evidenceAppend?: EvidenceRef[]
237
+ supersedeIds?: string[]
238
+ }
239
+
240
+ export interface SessionWorkingState {
241
+ sessionId: string
242
+ missionId?: string | null
243
+ objective?: string | null
244
+ summary?: string | null
245
+ constraints: string[]
246
+ successCriteria: string[]
247
+ status: WorkingStateStatus
248
+ nextAction?: string | null
249
+ planSteps: WorkingPlanStep[]
250
+ confirmedFacts: WorkingFact[]
251
+ artifacts: WorkingArtifact[]
252
+ decisions: WorkingDecision[]
253
+ blockers: WorkingBlocker[]
254
+ openQuestions: WorkingQuestion[]
255
+ hypotheses: WorkingHypothesis[]
256
+ evidenceRefs: EvidenceRef[]
257
+ createdAt: number
258
+ updatedAt: number
259
+ lastCompactedAt?: number | null
260
+ }
261
+
262
+ export interface ExecutionBriefPlanStep {
263
+ text: string
264
+ status: WorkingStateItemStatus
265
+ }
266
+
267
+ export interface ExecutionBrief {
268
+ sessionId?: string | null
269
+ missionId?: string | null
270
+ objective: string | null
271
+ summary: string | null
272
+ status: WorkingStateStatus
273
+ nextAction: string | null
274
+ plan: ExecutionBriefPlanStep[]
275
+ blockers: string[]
276
+ facts: string[]
277
+ artifacts: string[]
278
+ constraints: string[]
279
+ successCriteria: string[]
280
+ missionStatus?: MissionStatus | null
281
+ missionPhase?: MissionPhase | null
282
+ waitState?: MissionWaitState | null
283
+ evidenceRefs: EvidenceRef[]
284
+ parentContext: string | null
285
+ }
286
+
56
287
  export type MissionSource =
57
288
  | 'chat'
58
289
  | 'connector'
@@ -295,9 +526,10 @@ export interface CanvasDocument {
295
526
  export type CanvasContent = string | CanvasDocument | null
296
527
 
297
528
  export type ProviderType = 'claude-cli' | 'codex-cli' | 'opencode-cli' | 'gemini-cli' | 'openai' | 'ollama' | 'anthropic' | 'openclaw' | 'google' | 'deepseek' | 'groq' | 'together' | 'mistral' | 'xai' | 'fireworks' | 'nebius' | 'deepinfra'
529
+ export type ProviderId = ProviderType | (string & {})
298
530
 
299
531
  export interface ProviderInfo {
300
- id: ProviderType
532
+ id: ProviderId
301
533
  name: string
302
534
  models: string[]
303
535
  defaultModels?: string[]
@@ -338,7 +570,7 @@ export interface Session {
338
570
  shortcutForAgentId?: string | null
339
571
  cwd: string
340
572
  user: string
341
- provider: ProviderType
573
+ provider: ProviderId
342
574
  model: string
343
575
  ollamaMode?: OllamaMode | null
344
576
  credentialId?: string | null
@@ -357,8 +589,9 @@ export interface Session {
357
589
  opencode?: string | null
358
590
  gemini?: string | null
359
591
  }
592
+ /** @deprecated Messages are stored in session_messages table. Use message-repository. */
360
593
  messages: Message[]
361
- /** Lightweight summary fields used by list/index APIs to avoid shipping full transcripts. */
594
+ /** Pre-computed message count (kept in sync by message-repository). */
362
595
  messageCount?: number
363
596
  lastMessageSummary?: Message | null
364
597
  lastAssistantAt?: number | null
@@ -454,6 +687,22 @@ export interface Session {
454
687
  canvasContent?: CanvasContent
455
688
  /** Tracks how many times each memory ID has been injected via proactive recall in this session. */
456
689
  injectedMemoryIds?: Record<string, number>
690
+ /** Structured working memory that survives compaction and flows through delegation. */
691
+ runContext?: RunContext | null
692
+ }
693
+
694
+ export interface RunContext {
695
+ objective: string | null
696
+ constraints: string[]
697
+ keyFacts: string[]
698
+ discoveries: string[]
699
+ failedApproaches: string[]
700
+ currentPlan: string[]
701
+ completedSteps: string[]
702
+ blockers: string[]
703
+ parentContext: string | null
704
+ updatedAt: number
705
+ version: number
457
706
  }
458
707
 
459
708
  export type Sessions = Record<string, Session>
@@ -563,7 +812,7 @@ export interface ExtensionPromptBuildResult {
563
812
  }
564
813
 
565
814
  export interface ExtensionModelResolveResult {
566
- providerOverride?: ProviderType
815
+ providerOverride?: ProviderId
567
816
  modelOverride?: string
568
817
  apiEndpointOverride?: string | null
569
818
  }
@@ -596,7 +845,7 @@ export interface ExtensionHooks {
596
845
  session: Session
597
846
  prompt: string
598
847
  message: string
599
- provider: ProviderType
848
+ provider: ProviderId
600
849
  model: string
601
850
  apiEndpoint?: string | null
602
851
  }) => Promise<ExtensionModelResolveResult | void> | ExtensionModelResolveResult | void
@@ -618,7 +867,7 @@ export interface ExtensionHooks {
618
867
  llmInput?: (ctx: {
619
868
  session: Session
620
869
  runId: string
621
- provider: ProviderType
870
+ provider: ProviderId
622
871
  model: string
623
872
  systemPrompt?: string
624
873
  prompt: string
@@ -628,7 +877,7 @@ export interface ExtensionHooks {
628
877
  llmOutput?: (ctx: {
629
878
  session: Session
630
879
  runId: string
631
- provider: ProviderType
880
+ provider: ProviderId
632
881
  model: string
633
882
  assistantTexts: string[]
634
883
  response: string
@@ -741,17 +990,6 @@ export interface ExtensionToolPlanning {
741
990
  * this tool is enabled.
742
991
  */
743
992
  disciplineGuidance?: string[]
744
- /**
745
- * Optional natural-language cues that indicate when this tool should be
746
- * preferred or explicitly invoked. These are declarative hints so the harness
747
- * does not need to hard-code every extension-specific workflow centrally.
748
- */
749
- requestMatchers?: Array<{
750
- capability?: string
751
- patterns?: string[]
752
- requireLiteralUrl?: boolean
753
- forbidLiteralUrl?: boolean
754
- }>
755
993
  }
756
994
 
757
995
  export interface ExtensionToolDef {
@@ -1056,7 +1294,7 @@ export interface Agent {
1056
1294
  theme?: string
1057
1295
  avatar?: string
1058
1296
  systemPrompt: string
1059
- provider: ProviderType
1297
+ provider: ProviderId
1060
1298
  model: string
1061
1299
  ollamaMode?: OllamaMode | null
1062
1300
  credentialId?: string | null
@@ -1606,6 +1844,8 @@ export interface Chatroom {
1606
1844
  pinnedMessageIds?: string[]
1607
1845
  chatMode?: 'sequential' | 'parallel'
1608
1846
  autoAddress?: boolean
1847
+ routingGuidance?: string | null
1848
+ /** Legacy deterministic routing config kept only for migration/read compatibility. */
1609
1849
  routingRules?: ChatroomRoutingRule[]
1610
1850
  temporary?: boolean
1611
1851
  topic?: string
@@ -2105,6 +2345,23 @@ export interface AppNotification {
2105
2345
  // --- Session Runs ---
2106
2346
 
2107
2347
  export type SessionRunStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled'
2348
+ export type ExecutionKind =
2349
+ | 'session_turn'
2350
+ | 'task_attempt'
2351
+ | 'protocol_step'
2352
+ | 'heartbeat_tick'
2353
+ | 'schedule_wake'
2354
+ | 'repair_turn'
2355
+ | 'subagent_turn'
2356
+
2357
+ export type ExecutionOwnerType =
2358
+ | 'session'
2359
+ | 'task'
2360
+ | 'protocol_run'
2361
+ | 'schedule'
2362
+ | 'mission'
2363
+ | 'agent'
2364
+ | 'subagent'
2108
2365
 
2109
2366
  export interface SessionRunHeartbeatConfig {
2110
2367
  ackMaxChars: number
@@ -2134,6 +2391,11 @@ export interface SessionRunRecord {
2134
2391
  id: string
2135
2392
  sessionId: string
2136
2393
  missionId?: string | null
2394
+ kind?: ExecutionKind
2395
+ ownerType?: ExecutionOwnerType | null
2396
+ ownerId?: string | null
2397
+ parentExecutionId?: string | null
2398
+ recoveryPolicy?: 'restart_recoverable' | 'ephemeral' | 'manual' | 'none'
2137
2399
  source: string
2138
2400
  internal: boolean
2139
2401
  mode: string
@@ -2180,6 +2442,10 @@ export interface RunEventRecord {
2180
2442
  id: string
2181
2443
  runId: string
2182
2444
  sessionId: string
2445
+ kind?: ExecutionKind
2446
+ ownerType?: ExecutionOwnerType | null
2447
+ ownerId?: string | null
2448
+ parentExecutionId?: string | null
2183
2449
  timestamp: number
2184
2450
  phase: 'status' | 'event'
2185
2451
  status?: SessionRunStatus
@@ -2615,7 +2881,7 @@ export interface AgentRoutingTarget {
2615
2881
  id: string
2616
2882
  label?: string
2617
2883
  role?: AgentRoutingTargetRole
2618
- provider: ProviderType
2884
+ provider: ProviderId
2619
2885
  model: string
2620
2886
  ollamaMode?: OllamaMode | null
2621
2887
  credentialId?: string | null
@@ -2631,7 +2897,7 @@ export interface AgentPackEntry {
2631
2897
  id: string
2632
2898
  name: string
2633
2899
  description?: string
2634
- provider: ProviderType
2900
+ provider: ProviderId
2635
2901
  model: string
2636
2902
  ollamaMode?: OllamaMode | null
2637
2903
  credentialId?: string | null
@@ -2668,7 +2934,7 @@ export interface ExternalAgentRuntime {
2668
2934
  name: string
2669
2935
  sourceType: ExternalAgentSourceType
2670
2936
  status: ExternalAgentStatus
2671
- provider?: ProviderType | null
2937
+ provider?: ProviderId | null
2672
2938
  model?: string | null
2673
2939
  workspace?: string | null
2674
2940
  transport?: 'http' | 'ws' | 'cli' | 'gateway' | 'custom' | null
@@ -4,7 +4,7 @@ import { useState } from 'react'
4
4
  import { useAppStore } from '@/stores/use-app-store'
5
5
  import { createCredential, deleteCredential } from '@/lib/chat/chats'
6
6
  import { toast } from 'sonner'
7
- import type { ProviderType } from '@/types'
7
+ import type { ProviderId } from '@/types'
8
8
  import type { SettingsSectionProps } from './types'
9
9
 
10
10
  export function ProvidersSection({ inputClass }: SettingsSectionProps) {
@@ -14,7 +14,7 @@ export function ProvidersSection({ inputClass }: SettingsSectionProps) {
14
14
 
15
15
  const credList = Object.values(credentials)
16
16
 
17
- const [addProvider, setAddProvider] = useState<ProviderType | null>(null)
17
+ const [addProvider, setAddProvider] = useState<ProviderId | null>(null)
18
18
  const [newName, setNewName] = useState('')
19
19
  const [newKey, setNewKey] = useState('')
20
20
  const [deleting, setDeleting] = useState<string | null>(null)