@swarmclawai/swarmclaw 1.2.6 → 1.2.9

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 (269) hide show
  1. package/README.md +54 -23
  2. package/next.config.ts +1 -0
  3. package/package.json +4 -3
  4. package/scripts/easy-setup.mjs +1 -1
  5. package/scripts/postinstall.mjs +1 -1
  6. package/skills/swarmclaw.md +115 -0
  7. package/skills/tools/browser.md +131 -0
  8. package/skills/tools/execute.md +98 -0
  9. package/skills/tools/files.md +98 -0
  10. package/skills/tools/memory.md +104 -0
  11. package/skills/tools/platform.md +144 -0
  12. package/skills/tools/skills.md +83 -0
  13. package/src/app/agents/[id]/page.tsx +1 -18
  14. package/src/app/api/agents/thread-route.test.ts +0 -1
  15. package/src/app/api/approvals/route.test.ts +6 -22
  16. package/src/app/api/chats/[id]/messages/route.ts +23 -19
  17. package/src/app/api/chats/messages-route.test.ts +105 -51
  18. package/src/app/api/connectors/route.ts +2 -2
  19. package/src/app/api/mcp-servers/[id]/test/route.ts +3 -2
  20. package/src/app/api/openclaw/deploy/route.ts +2 -0
  21. package/src/app/api/portability/export/route.ts +8 -0
  22. package/src/app/api/portability/import/route.test.ts +80 -0
  23. package/src/app/api/portability/import/route.ts +28 -0
  24. package/src/app/api/settings/route.ts +0 -2
  25. package/src/app/api/setup/doctor/route.ts +4 -4
  26. package/src/app/api/wallets/[id]/route.ts +15 -157
  27. package/src/app/api/wallets/generate/route.ts +22 -0
  28. package/src/app/api/wallets/route.test.ts +147 -0
  29. package/src/app/api/wallets/route.ts +13 -95
  30. package/src/app/autonomy/page.tsx +2 -57
  31. package/src/app/protocols/page.tsx +2 -21
  32. package/src/app/settings/page.tsx +0 -9
  33. package/src/app/wallets/page.tsx +105 -5
  34. package/src/cli/index.js +21 -33
  35. package/src/cli/spec.js +19 -30
  36. package/src/components/agents/agent-chat-list.tsx +23 -1
  37. package/src/components/agents/agent-sheet.tsx +2 -40
  38. package/src/components/agents/inspector-panel.tsx +165 -131
  39. package/src/components/chat/chat-area.tsx +38 -9
  40. package/src/components/chat/chat-card.tsx +0 -31
  41. package/src/components/chat/message-bubble.tsx +1 -108
  42. package/src/components/chat/message-list.tsx +33 -19
  43. package/src/components/connectors/connector-sheet.tsx +25 -1
  44. package/src/components/gateways/gateway-sheet.tsx +5 -2
  45. package/src/components/layout/sidebar-rail.tsx +6 -10
  46. package/src/components/projects/project-detail.tsx +3 -35
  47. package/src/components/projects/tabs/overview-tab.tsx +3 -59
  48. package/src/components/projects/tabs/work-tab.tsx +7 -77
  49. package/src/components/protocols/structured-session-launcher.tsx +1 -22
  50. package/src/components/shared/connector-platform-icon.tsx +1 -0
  51. package/src/components/tasks/task-card.tsx +4 -34
  52. package/src/components/tasks/task-sheet.tsx +6 -36
  53. package/src/components/wallets/wallet-list.tsx +150 -0
  54. package/src/lib/agent-execute-defaults.test.ts +24 -0
  55. package/src/lib/agent-execute-defaults.ts +62 -0
  56. package/src/lib/app/navigation.test.ts +0 -13
  57. package/src/lib/app/navigation.ts +2 -7
  58. package/src/lib/app/view-constants.ts +14 -19
  59. package/src/lib/chat/queued-message-queue.test.ts +134 -1
  60. package/src/lib/chat/queued-message-queue.ts +77 -2
  61. package/src/lib/server/agents/agent-service.ts +5 -0
  62. package/src/lib/server/agents/agent-thread-session.ts +0 -1
  63. package/src/lib/server/agents/delegation-advisory.test.ts +0 -1
  64. package/src/lib/server/agents/delegation-jobs.test.ts +0 -69
  65. package/src/lib/server/agents/delegation-jobs.ts +0 -25
  66. package/src/lib/server/agents/main-agent-loop.ts +1 -49
  67. package/src/lib/server/agents/subagent-runtime.ts +0 -1
  68. package/src/lib/server/approval-match.ts +0 -85
  69. package/src/lib/server/approvals.test.ts +6 -6
  70. package/src/lib/server/approvals.ts +0 -6
  71. package/src/lib/server/autonomy/supervisor-reflection.test.ts +0 -1
  72. package/src/lib/server/builtin-extensions.ts +1 -2
  73. package/src/lib/server/capability-router.test.ts +0 -2
  74. package/src/lib/server/chat-execution/chat-execution-advanced.test.ts +1 -1
  75. package/src/lib/server/chat-execution/chat-execution-tool-events.test.ts +15 -14
  76. package/src/lib/server/chat-execution/chat-execution-types.ts +0 -2
  77. package/src/lib/server/chat-execution/chat-execution-utils.ts +2 -4
  78. package/src/lib/server/chat-execution/chat-streaming-utils.ts +2 -30
  79. package/src/lib/server/chat-execution/chat-turn-finalization.ts +1 -36
  80. package/src/lib/server/chat-execution/chat-turn-preparation.ts +81 -64
  81. package/src/lib/server/chat-execution/chat-turn-stream-execution.ts +4 -0
  82. package/src/lib/server/chat-execution/continuation-evaluator.ts +8 -0
  83. package/src/lib/server/chat-execution/iteration-event-handler.ts +0 -24
  84. package/src/lib/server/chat-execution/memory-mutation-tools.ts +1 -1
  85. package/src/lib/server/chat-execution/message-classifier.test.ts +0 -45
  86. package/src/lib/server/chat-execution/message-classifier.ts +11 -16
  87. package/src/lib/server/chat-execution/prompt-builder.test.ts +27 -0
  88. package/src/lib/server/chat-execution/prompt-builder.ts +14 -31
  89. package/src/lib/server/chat-execution/prompt-mode.test.ts +24 -0
  90. package/src/lib/server/chat-execution/prompt-mode.ts +5 -1
  91. package/src/lib/server/chat-execution/prompt-sections.ts +0 -1
  92. package/src/lib/server/chat-execution/situational-awareness.test.ts +2 -73
  93. package/src/lib/server/chat-execution/situational-awareness.ts +4 -38
  94. package/src/lib/server/chat-execution/stream-agent-chat.test.ts +13 -126
  95. package/src/lib/server/chat-execution/stream-agent-chat.ts +46 -21
  96. package/src/lib/server/chat-execution/stream-continuation.test.ts +4 -52
  97. package/src/lib/server/chat-execution/stream-continuation.ts +6 -48
  98. package/src/lib/server/chatrooms/chatroom-routing.test.ts +4 -0
  99. package/src/lib/server/chatrooms/session-mailbox.ts +0 -10
  100. package/src/lib/server/chats/chat-session-service.ts +3 -5
  101. package/src/lib/server/connectors/connector-inbound.ts +0 -1
  102. package/src/lib/server/connectors/connector-lifecycle.ts +19 -3
  103. package/src/lib/server/connectors/connector-service.ts +39 -9
  104. package/src/lib/server/connectors/discord.ts +2 -2
  105. package/src/lib/server/connectors/matrix.ts +3 -2
  106. package/src/lib/server/connectors/signal.ts +5 -4
  107. package/src/lib/server/connectors/slack.ts +10 -9
  108. package/src/lib/server/connectors/swarmdock-bidding.ts +74 -0
  109. package/src/lib/server/connectors/swarmdock-payloads.test.ts +85 -0
  110. package/src/lib/server/connectors/swarmdock-secret.test.ts +128 -0
  111. package/src/lib/server/connectors/swarmdock-secret.ts +152 -0
  112. package/src/lib/server/connectors/swarmdock-tasks.ts +119 -0
  113. package/src/lib/server/connectors/swarmdock.ts +255 -0
  114. package/src/lib/server/connectors/teams.ts +3 -2
  115. package/src/lib/server/connectors/telegram.ts +4 -4
  116. package/src/lib/server/connectors/whatsapp.ts +2 -2
  117. package/src/lib/server/daemon/controller.ts +7 -0
  118. package/src/lib/server/execution-brief.test.ts +2 -25
  119. package/src/lib/server/execution-brief.ts +12 -35
  120. package/src/lib/server/execution-engine/task-attempt.ts +0 -1
  121. package/src/lib/server/gateways/gateway-profile-service.ts +19 -1
  122. package/src/lib/server/messages/message-repository.test.ts +70 -0
  123. package/src/lib/server/messages/message-repository.ts +11 -6
  124. package/src/lib/server/openclaw/deploy.ts +32 -2
  125. package/src/lib/server/persistence/storage-context.ts +0 -5
  126. package/src/lib/server/plugins-advanced.test.ts +1 -2
  127. package/src/lib/server/portability/export.ts +109 -0
  128. package/src/lib/server/portability/import.ts +159 -0
  129. package/src/lib/server/protocols/protocol-normalization.ts +0 -4
  130. package/src/lib/server/protocols/protocol-queries.ts +0 -6
  131. package/src/lib/server/protocols/protocol-run-lifecycle.ts +4 -32
  132. package/src/lib/server/protocols/protocol-service.ts +0 -1
  133. package/src/lib/server/protocols/protocol-step-helpers.ts +0 -4
  134. package/src/lib/server/protocols/protocol-step-processors.ts +0 -6
  135. package/src/lib/server/protocols/protocol-swarm.ts +0 -2
  136. package/src/lib/server/protocols/protocol-types.ts +0 -2
  137. package/src/lib/server/provider-health.ts +1 -10
  138. package/src/lib/server/runtime/daemon-state/core.ts +0 -9
  139. package/src/lib/server/runtime/daemon-state.test.ts +0 -35
  140. package/src/lib/server/runtime/heartbeat-service.ts +3 -23
  141. package/src/lib/server/runtime/process-manager.ts +13 -9
  142. package/src/lib/server/runtime/queue/core.ts +11 -33
  143. package/src/lib/server/runtime/runtime-storage-write-paths.test.ts +6 -6
  144. package/src/lib/server/runtime/scheduler.ts +0 -13
  145. package/src/lib/server/runtime/session-run-manager/drain.ts +0 -24
  146. package/src/lib/server/runtime/session-run-manager/enqueue.ts +0 -1
  147. package/src/lib/server/runtime/session-run-manager/queries.ts +15 -1
  148. package/src/lib/server/runtime/session-run-manager/recovery.ts +0 -1
  149. package/src/lib/server/runtime/session-run-manager.test.ts +58 -28
  150. package/src/lib/server/sandbox/session-runtime.test.ts +18 -1
  151. package/src/lib/server/sandbox/session-runtime.ts +40 -28
  152. package/src/lib/server/session-tools/autonomy-tools.test.ts +7 -9
  153. package/src/lib/server/session-tools/context.ts +1 -1
  154. package/src/lib/server/session-tools/credential-env.ts +109 -0
  155. package/src/lib/server/session-tools/crud.ts +3 -17
  156. package/src/lib/server/session-tools/delegate.ts +0 -4
  157. package/src/lib/server/session-tools/edit_file.ts +3 -2
  158. package/src/lib/server/session-tools/execute.test.ts +58 -0
  159. package/src/lib/server/session-tools/execute.ts +334 -0
  160. package/src/lib/server/session-tools/files-tool.ts +635 -0
  161. package/src/lib/server/session-tools/index.ts +14 -8
  162. package/src/lib/server/session-tools/memory-tool.ts +242 -0
  163. package/src/lib/server/session-tools/memory.ts +1 -1
  164. package/src/lib/server/session-tools/openclaw-nodes.ts +3 -2
  165. package/src/lib/server/session-tools/openclaw-workspace.ts +3 -2
  166. package/src/lib/server/session-tools/platform-tool.ts +617 -0
  167. package/src/lib/server/session-tools/session-info.ts +3 -2
  168. package/src/lib/server/session-tools/session-tools-wiring.test.ts +3 -4
  169. package/src/lib/server/session-tools/shell.ts +7 -122
  170. package/src/lib/server/session-tools/skills-tool.ts +396 -0
  171. package/src/lib/server/session-tools/team-context.ts +0 -3
  172. package/src/lib/server/session-tools/web.ts +2 -2
  173. package/src/lib/server/storage-normalization.ts +10 -0
  174. package/src/lib/server/storage.ts +18 -45
  175. package/src/lib/server/tasks/task-checkout.ts +59 -0
  176. package/src/lib/server/tasks/task-lifecycle.ts +2 -0
  177. package/src/lib/server/tasks/task-route-service.ts +4 -26
  178. package/src/lib/server/tasks/task-service.ts +0 -7
  179. package/src/lib/server/tool-aliases.ts +2 -2
  180. package/src/lib/server/tool-capability-policy-advanced.test.ts +13 -6
  181. package/src/lib/server/tool-capability-policy.test.ts +2 -1
  182. package/src/lib/server/tool-capability-policy.ts +60 -35
  183. package/src/lib/server/tool-planning.ts +11 -12
  184. package/src/lib/server/universal-tool-access.ts +0 -1
  185. package/src/lib/server/wallets/wallet-crypto.ts +33 -0
  186. package/src/lib/server/wallets/wallet-repository.ts +24 -0
  187. package/src/lib/server/wallets/wallet-service.ts +119 -0
  188. package/src/lib/server/working-state/extraction.ts +8 -42
  189. package/src/lib/server/working-state/normalization.ts +10 -103
  190. package/src/lib/server/working-state/service.ts +12 -21
  191. package/src/lib/setup-defaults.ts +5 -0
  192. package/src/lib/strip-internal-metadata.test.ts +1 -1
  193. package/src/lib/strip-internal-metadata.ts +1 -1
  194. package/src/lib/tool-definitions.ts +1 -1
  195. package/src/lib/validation/schemas.test.ts +16 -0
  196. package/src/lib/validation/schemas.ts +49 -2
  197. package/src/stores/slices/data-slice.ts +5 -1
  198. package/src/stores/slices/ui-slice.ts +0 -4
  199. package/src/stores/use-chat-store.test.ts +231 -0
  200. package/src/stores/use-chat-store.ts +62 -13
  201. package/src/types/agent.ts +264 -0
  202. package/src/types/app-settings.ts +173 -0
  203. package/src/types/approval.ts +25 -0
  204. package/src/types/connector.ts +188 -0
  205. package/src/types/extension.ts +386 -0
  206. package/src/types/index.ts +16 -3555
  207. package/src/types/message.ts +56 -0
  208. package/src/types/misc.ts +737 -0
  209. package/src/types/protocol.ts +420 -0
  210. package/src/types/provider.ts +52 -0
  211. package/src/types/run.ts +180 -0
  212. package/src/types/schedule.ts +59 -0
  213. package/src/types/session.ts +215 -0
  214. package/src/types/skill.ts +157 -0
  215. package/src/types/swarmdock.ts +29 -0
  216. package/src/types/task.ts +144 -0
  217. package/src/types/working-state.ts +204 -0
  218. package/src/views/settings/section-heartbeat.tsx +2 -2
  219. package/src/views/settings/section-runtime-loop.tsx +0 -14
  220. package/src/app/api/canvas/[sessionId]/route.ts +0 -35
  221. package/src/app/api/missions/[id]/actions/route.ts +0 -31
  222. package/src/app/api/missions/[id]/events/route.ts +0 -14
  223. package/src/app/api/missions/[id]/route.ts +0 -10
  224. package/src/app/api/missions/route.test.ts +0 -244
  225. package/src/app/api/missions/route.ts +0 -57
  226. package/src/app/api/wallets/[id]/approve/route.ts +0 -79
  227. package/src/app/api/wallets/[id]/balance-history/route.ts +0 -18
  228. package/src/app/api/wallets/[id]/send/route.ts +0 -113
  229. package/src/app/api/wallets/[id]/transactions/route.ts +0 -18
  230. package/src/app/missions/[id]/page.tsx +0 -3
  231. package/src/app/missions/page.tsx +0 -685
  232. package/src/components/canvas/canvas-panel.tsx +0 -267
  233. package/src/components/wallets/wallet-approval-dialog.tsx +0 -107
  234. package/src/components/wallets/wallet-panel.tsx +0 -1010
  235. package/src/components/wallets/wallet-section.tsx +0 -260
  236. package/src/features/missions/queries.ts +0 -23
  237. package/src/lib/canvas-content.test.ts +0 -360
  238. package/src/lib/canvas-content.ts +0 -198
  239. package/src/lib/server/canvas-content.test.ts +0 -32
  240. package/src/lib/server/canvas-content.ts +0 -6
  241. package/src/lib/server/ethereum.ts +0 -591
  242. package/src/lib/server/evm-swap.ts +0 -476
  243. package/src/lib/server/missions/mission-intent.test.ts +0 -63
  244. package/src/lib/server/missions/mission-intent.ts +0 -569
  245. package/src/lib/server/missions/mission-repository.ts +0 -74
  246. package/src/lib/server/missions/mission-service/actions.ts +0 -6
  247. package/src/lib/server/missions/mission-service/bindings.ts +0 -9
  248. package/src/lib/server/missions/mission-service/context.ts +0 -4
  249. package/src/lib/server/missions/mission-service/core.ts +0 -2271
  250. package/src/lib/server/missions/mission-service/queries.ts +0 -12
  251. package/src/lib/server/missions/mission-service/recovery.ts +0 -5
  252. package/src/lib/server/missions/mission-service/ticks.ts +0 -9
  253. package/src/lib/server/missions/mission-service.test.ts +0 -888
  254. package/src/lib/server/missions/mission-service.ts +0 -6
  255. package/src/lib/server/session-tools/canvas.ts +0 -105
  256. package/src/lib/server/session-tools/sandbox.ts +0 -281
  257. package/src/lib/server/session-tools/wallet-tool.test.ts +0 -150
  258. package/src/lib/server/session-tools/wallet.ts +0 -1287
  259. package/src/lib/server/solana.ts +0 -327
  260. package/src/lib/server/wallet/wallet-execution.test.ts +0 -198
  261. package/src/lib/server/wallet/wallet-portfolio.test.ts +0 -98
  262. package/src/lib/server/wallet/wallet-portfolio.ts +0 -772
  263. package/src/lib/server/wallet/wallet-service.test.ts +0 -81
  264. package/src/lib/server/wallet/wallet-service.ts +0 -225
  265. package/src/lib/wallet/wallet-transactions.test.ts +0 -75
  266. package/src/lib/wallet/wallet-transactions.ts +0 -43
  267. package/src/lib/wallet/wallet.test.ts +0 -333
  268. package/src/lib/wallet/wallet.ts +0 -183
  269. package/src/views/settings/section-wallets.tsx +0 -35
@@ -1,3555 +1,16 @@
1
- export interface MessageToolEvent {
2
- name: string
3
- input: string
4
- output?: string
5
- error?: boolean
6
- /** Internal correlation token for matching streaming tool calls/results. */
7
- toolCallId?: string
8
- }
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
-
29
- export interface Message {
30
- role: 'user' | 'assistant'
31
- text: string
32
- time: number
33
- /** Client-only render identity used to keep in-progress transcript rows stable. */
34
- clientRenderId?: string
35
- imagePath?: string
36
- imageUrl?: string
37
- attachedFiles?: string[]
38
- toolEvents?: MessageToolEvent[]
39
- thinking?: string
40
- kind?: 'chat' | 'heartbeat' | 'system' | 'context-clear' | 'extension-ui' | 'connector-delivery'
41
- suppressed?: boolean
42
- bookmarked?: boolean
43
- suggestions?: string[]
44
- replyToId?: string
45
- source?: MessageSource
46
- /** Persist in the UI transcript, but exclude from normal model history. */
47
- historyExcluded?: boolean
48
- /** True while the message is still being streamed — cleared on final persist. */
49
- streaming?: boolean
50
- /** Run ID that produced this message — used to scope streaming artifact replacement. */
51
- runId?: string
52
- /** Cached turn semantics used for routing, delegation, and reflection. */
53
- semantics?: MessageSemanticsSummary
54
- }
55
-
56
- export type SessionResetMode = 'idle' | 'daily' | 'isolated'
57
- export type SessionResetType = 'direct' | 'group' | 'thread' | 'main'
58
-
59
- export interface IdentityContinuityState {
60
- selfSummary?: string | null
61
- relationshipSummary?: string | null
62
- personaLabel?: string | null
63
- toneStyle?: string | null
64
- boundaries?: string[]
65
- continuityNotes?: string[]
66
- updatedAt?: number | null
67
- }
68
-
69
- export interface SessionArchiveState {
70
- memoryId?: string | null
71
- lastSyncedAt?: number | null
72
- lastHash?: string | null
73
- messageCount?: number
74
- exportPath?: string | null
75
- }
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
-
287
- export type MissionSource =
288
- | 'chat'
289
- | 'connector'
290
- | 'heartbeat'
291
- | 'main-loop-followup'
292
- | 'task'
293
- | 'schedule'
294
- | 'delegation'
295
- | 'manual'
296
-
297
- export type MissionStatus = 'active' | 'waiting' | 'completed' | 'failed' | 'cancelled'
298
- export type MissionPhase = 'intake' | 'planning' | 'dispatching' | 'executing' | 'verifying' | 'waiting' | 'completed' | 'failed'
299
- export type MissionWaitKind =
300
- | 'human_reply'
301
- | 'approval'
302
- | 'external_dependency'
303
- | 'provider'
304
- | 'blocked_task'
305
- | 'blocked_mission'
306
- | 'scheduled'
307
- | 'other'
308
-
309
- export type MissionPlannerDecision =
310
- | 'dispatch_task'
311
- | 'dispatch_session_turn'
312
- | 'spawn_child_mission'
313
- | 'wait'
314
- | 'verify_now'
315
- | 'complete_candidate'
316
- | 'replan'
317
- | 'fail_terminal'
318
- | 'cancel'
319
-
320
- export type MissionVerificationVerdict =
321
- | 'continue'
322
- | 'waiting'
323
- | 'completed'
324
- | 'failed'
325
- | 'replan'
326
-
327
- export type MissionSourceRef =
328
- | { kind: 'chat'; sessionId: string; messageId?: string | null }
329
- | { kind: 'connector'; sessionId: string; connectorId: string; channelId: string; threadId?: string | null }
330
- | { kind: 'schedule'; scheduleId: string; recurring: boolean }
331
- | { kind: 'task'; taskId: string }
332
- | { kind: 'delegation'; parentMissionId: string; backend?: 'agent' | 'codex' | 'claude' | 'opencode' | 'gemini' | null }
333
- | { kind: 'heartbeat'; sessionId: string }
334
- | { kind: 'manual' }
335
-
336
- export interface MissionWaitState {
337
- kind: MissionWaitKind
338
- reason: string
339
- approvalId?: string | null
340
- untilAt?: number | null
341
- dependencyTaskId?: string | null
342
- dependencyMissionId?: string | null
343
- providerKey?: string | null
344
- }
345
-
346
- export interface MissionControllerState {
347
- leaseId?: string | null
348
- leaseExpiresAt?: number | null
349
- tickRequestedAt?: number | null
350
- tickReason?: string | null
351
- plannerRunId?: string | null
352
- verifierRunId?: string | null
353
- activeRunId?: string | null
354
- currentTaskId?: string | null
355
- currentChildMissionId?: string | null
356
- pendingWakeId?: string | null
357
- attemptCount?: number
358
- lastEvidenceAt?: number | null
359
- }
360
-
361
- export interface MissionPlannerState {
362
- lastDecision?: MissionPlannerDecision | null
363
- lastPlannedAt?: number | null
364
- planSummary?: string | null
365
- }
366
-
367
- export interface MissionVerificationState {
368
- candidate: boolean
369
- requiredTaskIds?: string[]
370
- requiredChildMissionIds?: string[]
371
- requiredArtifacts?: string[]
372
- evidenceSummary?: string | null
373
- lastVerdict?: MissionVerificationVerdict | null
374
- lastVerifiedAt?: number | null
375
- }
376
-
377
- export interface MissionSummary {
378
- id: string
379
- objective: string
380
- status: MissionStatus
381
- phase: MissionPhase
382
- source: MissionSource
383
- currentStep?: string | null
384
- waitingReason?: string | null
385
- sessionId?: string | null
386
- agentId?: string | null
387
- projectId?: string | null
388
- parentMissionId?: string | null
389
- rootMissionId?: string | null
390
- taskIds?: string[]
391
- openTaskCount?: number
392
- completedTaskCount?: number
393
- childCount?: number
394
- sourceRef?: MissionSourceRef
395
- updatedAt: number
396
- }
397
-
398
- export interface Mission {
399
- id: string
400
- source: MissionSource
401
- sourceRef?: MissionSourceRef
402
- objective: string
403
- successCriteria?: string[]
404
- status: MissionStatus
405
- phase: MissionPhase
406
- sessionId?: string | null
407
- agentId?: string | null
408
- projectId?: string | null
409
- rootMissionId?: string | null
410
- parentMissionId?: string | null
411
- childMissionIds?: string[]
412
- dependencyMissionIds?: string[]
413
- dependencyTaskIds?: string[]
414
- taskIds?: string[]
415
- rootTaskId?: string | null
416
- currentStep?: string | null
417
- plannerSummary?: string | null
418
- verifierSummary?: string | null
419
- blockerSummary?: string | null
420
- waitState?: MissionWaitState | null
421
- controllerState?: MissionControllerState
422
- plannerState?: MissionPlannerState
423
- verificationState?: MissionVerificationState
424
- lastRunId?: string | null
425
- sourceRunId?: string | null
426
- sourceMessage?: string | null
427
- createdAt: number
428
- updatedAt: number
429
- lastActiveAt?: number | null
430
- completedAt?: number | null
431
- failedAt?: number | null
432
- cancelledAt?: number | null
433
- }
434
-
435
- export type MissionEventType =
436
- | 'created'
437
- | 'source_triggered'
438
- | 'attached'
439
- | 'planner_decision'
440
- | 'dispatch_started'
441
- | 'task_linked'
442
- | 'task_started'
443
- | 'task_completed'
444
- | 'task_failed'
445
- | 'child_created'
446
- | 'child_completed'
447
- | 'child_failed'
448
- | 'run_result'
449
- | 'verifier_decision'
450
- | 'waiting'
451
- | 'resumed'
452
- | 'replanned'
453
- | 'completed'
454
- | 'failed'
455
- | 'cancelled'
456
- | 'interrupted'
457
- | 'operator_action'
458
- | 'status_change'
459
-
460
- export interface MissionEvent {
461
- id: string
462
- missionId: string
463
- type: MissionEventType
464
- source: MissionSource | 'system'
465
- summary: string
466
- data?: Record<string, unknown> | null
467
- sessionId?: string | null
468
- taskId?: string | null
469
- runId?: string | null
470
- createdAt: number
471
- }
472
-
473
- export interface SessionSkillRuntimeState {
474
- selectedSkillId?: string | null
475
- selectedSkillName?: string | null
476
- selectedAt?: number | null
477
- lastAction?: 'select' | 'load' | 'run' | null
478
- lastRunAt?: number | null
479
- lastRunToolName?: string | null
480
- }
481
-
482
- export interface CanvasMetricItem {
483
- label: string
484
- value: string
485
- detail?: string
486
- tone?: 'default' | 'positive' | 'negative' | 'warning'
487
- }
488
-
489
- export interface CanvasCardItem {
490
- title: string
491
- body?: string
492
- meta?: string
493
- tone?: 'default' | 'positive' | 'negative' | 'warning'
494
- }
495
-
496
- export interface CanvasActionItem {
497
- label: string
498
- href?: string
499
- note?: string
500
- intent?: 'primary' | 'secondary' | 'success' | 'danger'
501
- }
502
-
503
- export interface CanvasTableData {
504
- columns: string[]
505
- rows: Array<Array<string | number | boolean | null>>
506
- caption?: string
507
- }
508
-
509
- export type CanvasBlock =
510
- | { type: 'markdown'; title?: string; markdown: string }
511
- | { type: 'metrics'; title?: string; items: CanvasMetricItem[] }
512
- | { type: 'cards'; title?: string; items: CanvasCardItem[] }
513
- | { type: 'table'; title?: string; table: CanvasTableData }
514
- | { type: 'code'; title?: string; code: string; language?: string }
515
- | { type: 'actions'; title?: string; items: CanvasActionItem[] }
516
-
517
- export interface CanvasDocument {
518
- kind: 'structured'
519
- title?: string
520
- subtitle?: string
521
- theme?: 'slate' | 'sky' | 'emerald' | 'amber' | 'rose'
522
- blocks: CanvasBlock[]
523
- updatedAt?: number | null
524
- }
525
-
526
- export type CanvasContent = string | CanvasDocument | null
527
-
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 & {})
530
-
531
- export interface ProviderInfo {
532
- id: ProviderId
533
- name: string
534
- models: string[]
535
- defaultModels?: string[]
536
- supportsModelDiscovery?: boolean
537
- requiresApiKey: boolean
538
- optionalApiKey?: boolean
539
- requiresEndpoint: boolean
540
- defaultEndpoint?: string
541
- }
542
-
543
- export interface ProviderModelDiscoveryResult {
544
- ok: boolean
545
- providerId: string
546
- providerName?: string
547
- models: string[]
548
- cached: boolean
549
- fetchedAt: number
550
- cacheTtlMs: number
551
- supportsDiscovery: boolean
552
- missingCredential?: boolean
553
- message?: string
554
- }
555
-
556
- export interface Credential {
557
- id: string
558
- provider: string
559
- name: string
560
- createdAt: number
561
- }
562
-
563
- export type Credentials = Record<string, Credential>
564
- export type OllamaMode = 'local' | 'cloud'
565
-
566
- export interface Session {
567
- id: string
568
- name: string
569
- openclawAgentId?: string | null
570
- shortcutForAgentId?: string | null
571
- cwd: string
572
- user: string
573
- provider: ProviderId
574
- model: string
575
- ollamaMode?: OllamaMode | null
576
- credentialId?: string | null
577
- fallbackCredentialIds?: string[]
578
- apiEndpoint?: string | null
579
- gatewayProfileId?: string | null
580
- routePreferredGatewayTags?: string[]
581
- routePreferredGatewayUseCase?: string | null
582
- claudeSessionId: string | null
583
- codexThreadId?: string | null
584
- opencodeSessionId?: string | null
585
- geminiSessionId?: string | null
586
- delegateResumeIds?: {
587
- claudeCode?: string | null
588
- codex?: string | null
589
- opencode?: string | null
590
- gemini?: string | null
591
- }
592
- /** @deprecated Messages are stored in session_messages table. Use message-repository. */
593
- messages: Message[]
594
- /** Pre-computed message count (kept in sync by message-repository). */
595
- messageCount?: number
596
- lastMessageSummary?: Message | null
597
- lastAssistantAt?: number | null
598
- createdAt: number
599
- updatedAt?: number | null
600
- lastActiveAt: number
601
- active?: boolean
602
- sessionType?: SessionType
603
- agentId?: string | null
604
- parentSessionId?: string | null
605
- delegationDepth?: number | null
606
- tools?: string[]
607
- extensions?: string[]
608
- heartbeatEnabled?: boolean | null
609
- heartbeatIntervalSec?: number | null
610
- heartbeatTarget?: 'last' | 'none' | string | null
611
- memoryScopeMode?: 'auto' | 'all' | 'global' | 'agent' | 'session' | 'project' | null
612
- memoryTierPreference?: 'working' | 'durable' | 'archive' | 'blended' | null
613
- projectId?: string | null
614
- sessionResetMode?: SessionResetMode | null
615
- sessionIdleTimeoutSec?: number | null
616
- sessionMaxAgeSec?: number | null
617
- sessionDailyResetAt?: string | null
618
- sessionResetTimezone?: string | null
619
- thinkingLevel?: 'minimal' | 'low' | 'medium' | 'high' | null
620
- browserProfileId?: string | null
621
- connectorThinkLevel?: 'minimal' | 'low' | 'medium' | 'high' | null
622
- connectorSessionScope?: 'main' | 'channel' | 'peer' | 'channel-peer' | 'thread' | null
623
- connectorReplyMode?: 'off' | 'first' | 'all' | null
624
- connectorThreadBinding?: 'off' | 'prefer' | 'strict' | null
625
- connectorGroupPolicy?: 'open' | 'mention' | 'reply-or-mention' | 'disabled' | null
626
- connectorIdleTimeoutSec?: number | null
627
- connectorMaxAgeSec?: number | null
628
- /** Last heartbeat/cron delivery status */
629
- lastDeliveryStatus?: 'ok' | 'error' | null
630
- /** Timestamp of last heartbeat/cron delivery attempt */
631
- lastDeliveredAt?: number | null
632
- /** Error message from last failed delivery */
633
- lastDeliveryError?: string | null
634
- mailbox?: MailboxEnvelope[] | null
635
- connectorContext?: {
636
- connectorId?: string | null
637
- platform?: ConnectorPlatform | null
638
- channelId?: string | null
639
- channelIdAlt?: string | null
640
- senderId?: string | null
641
- senderIdAlt?: string | null
642
- senderName?: string | null
643
- senderAvatarUrl?: string | null
644
- sessionKey?: string | null
645
- peerKey?: string | null
646
- scope?: 'main' | 'channel' | 'peer' | 'channel-peer' | 'thread' | null
647
- replyMode?: 'off' | 'first' | 'all' | null
648
- threadBinding?: 'off' | 'prefer' | 'strict' | null
649
- groupPolicy?: 'open' | 'mention' | 'reply-or-mention' | 'disabled' | null
650
- threadId?: string | null
651
- threadTitle?: string | null
652
- threadPersonaLabel?: string | null
653
- threadParentChannelId?: string | null
654
- threadParentChannelName?: string | null
655
- isGroup?: boolean
656
- isOwnerConversation?: boolean
657
- lastInboundAt?: number | null
658
- lastInboundMessageId?: string | null
659
- lastInboundReplyToMessageId?: string | null
660
- lastInboundThreadId?: string | null
661
- lastOutboundAt?: number | null
662
- lastOutboundMessageId?: string | null
663
- lastResetAt?: number | null
664
- lastResetReason?: string | null
665
- allKnownPeerIds?: string[] | null
666
- }
667
- lastAutoMemoryAt?: number | null
668
- lastHeartbeatText?: string | null
669
- lastHeartbeatSentAt?: number | null
670
- lastSessionResetAt?: number | null
671
- lastSessionResetReason?: string | null
672
- identityState?: IdentityContinuityState | null
673
- sessionArchiveState?: SessionArchiveState | null
674
- missionId?: string | null
675
- missionSummary?: MissionSummary | null
676
- skillRuntimeState?: SessionSkillRuntimeState | null
677
- pinned?: boolean
678
- file?: string | null
679
- queuedCount?: number
680
- currentRunId?: string | null
681
- conversationTone?: string
682
- emoji?: string
683
- creature?: string
684
- vibe?: string
685
- theme?: string
686
- avatar?: string
687
- canvasContent?: CanvasContent
688
- /** Tracks how many times each memory ID has been injected via proactive recall in this session. */
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
706
- }
707
-
708
- export type Sessions = Record<string, Session>
709
-
710
- export type SessionTool =
711
- | 'shell'
712
- | 'files'
713
- | 'claude_code'
714
- | 'codex_cli'
715
- | 'opencode_cli'
716
- | 'web_search'
717
- | 'web_fetch'
718
- | 'edit_file'
719
- | 'process'
720
- | 'spawn_subagent'
721
- | 'canvas'
722
- | 'http_request'
723
- | 'git'
724
- | 'mailbox'
725
- | 'ask_human'
726
- | 'document'
727
- | 'extract'
728
- | 'table'
729
- | 'crawl'
730
-
731
- // --- Approvals ---
732
-
733
- export type ApprovalCategory =
734
- | 'tool_access'
735
- | 'wallet_transfer'
736
- | 'wallet_action'
737
- | 'extension_scaffold'
738
- | 'extension_install'
739
- | 'task_tool'
740
- | 'human_loop'
741
- | 'connector_sender'
742
-
743
- export interface ApprovalRequest {
744
- id: string
745
- category: ApprovalCategory
746
- agentId?: string | null
747
- sessionId?: string | null
748
- taskId?: string | null
749
- title: string
750
- description?: string
751
- data: Record<string, unknown>
752
- createdAt: number
753
- updatedAt: number
754
- status: 'pending' | 'approved' | 'rejected'
755
- }
756
-
757
- export type Approvals = Record<string, ApprovalRequest>
758
-
759
- export type MailboxStatus = 'new' | 'ack'
760
-
761
- export interface MailboxEnvelope {
762
- id: string
763
- type: string
764
- payload: string
765
- fromSessionId?: string | null
766
- fromAgentId?: string | null
767
- toSessionId: string
768
- toAgentId?: string | null
769
- correlationId?: string | null
770
- status: MailboxStatus
771
- createdAt: number
772
- expiresAt?: number | null
773
- ackAt?: number | null
774
- }
775
-
776
- export interface ExtensionInvocationRecord {
777
- extensionId: string
778
- toolName: string
779
- inputTokens: number
780
- outputTokens: number
781
- }
782
-
783
- export interface ExtensionDefinitionCost {
784
- extensionId: string
785
- estimatedTokens: number
786
- }
787
-
788
- export interface UsageRecord {
789
- sessionId: string
790
- messageIndex: number
791
- model: string
792
- provider: string
793
- inputTokens: number
794
- outputTokens: number
795
- totalTokens: number
796
- estimatedCost: number
797
- timestamp: number
798
- durationMs?: number
799
- agentId?: string | null
800
- projectId?: string | null
801
- extensionDefinitionCosts?: ExtensionDefinitionCost[]
802
- extensionInvocations?: ExtensionInvocationRecord[]
803
- }
804
-
805
- // --- Extension System ---
806
-
807
- export interface ExtensionPromptBuildResult {
808
- systemPrompt?: string
809
- prependContext?: string
810
- prependSystemContext?: string
811
- appendSystemContext?: string
812
- }
813
-
814
- export interface ExtensionModelResolveResult {
815
- providerOverride?: ProviderId
816
- modelOverride?: string
817
- apiEndpointOverride?: string | null
818
- }
819
-
820
- export interface ExtensionToolCallResult {
821
- input?: Record<string, unknown> | null
822
- params?: Record<string, unknown>
823
- block?: boolean
824
- blockReason?: string
825
- warning?: string
826
- }
827
-
828
- export interface ExtensionMessagePersistResult {
829
- message?: Message
830
- }
831
-
832
- export interface ExtensionBeforeMessageWriteResult extends ExtensionMessagePersistResult {
833
- block?: boolean
834
- }
835
-
836
- export interface ExtensionSubagentSpawningResult {
837
- status: 'ok' | 'error'
838
- error?: string
839
- }
840
-
841
- export interface ExtensionHooks {
842
- beforeAgentStart?: (ctx: { session: Session; message: string }) => Promise<void> | void
843
- afterAgentComplete?: (ctx: { session: Session; response: string }) => Promise<void> | void
844
- beforeModelResolve?: (ctx: {
845
- session: Session
846
- prompt: string
847
- message: string
848
- provider: ProviderId
849
- model: string
850
- apiEndpoint?: string | null
851
- }) => Promise<ExtensionModelResolveResult | void> | ExtensionModelResolveResult | void
852
- beforeToolExec?: (ctx: { toolName: string; input: Record<string, unknown> | null }) => Promise<Record<string, unknown> | void> | Record<string, unknown> | void
853
- beforePromptBuild?: (ctx: {
854
- session: Session
855
- prompt: string
856
- message: string
857
- history: Message[]
858
- messages: Message[]
859
- }) => Promise<ExtensionPromptBuildResult | void> | ExtensionPromptBuildResult | void
860
- beforeToolCall?: (ctx: {
861
- session: Session
862
- toolName: string
863
- input: Record<string, unknown> | null
864
- runId?: string
865
- toolCallId?: string
866
- }) => Promise<ExtensionToolCallResult | Record<string, unknown> | void> | ExtensionToolCallResult | Record<string, unknown> | void
867
- llmInput?: (ctx: {
868
- session: Session
869
- runId: string
870
- provider: ProviderId
871
- model: string
872
- systemPrompt?: string
873
- prompt: string
874
- historyMessages: Message[]
875
- imagesCount: number
876
- }) => Promise<void> | void
877
- llmOutput?: (ctx: {
878
- session: Session
879
- runId: string
880
- provider: ProviderId
881
- model: string
882
- assistantTexts: string[]
883
- response: string
884
- usage?: {
885
- input?: number
886
- output?: number
887
- total?: number
888
- estimatedCost?: number
889
- }
890
- }) => Promise<void> | void
891
- toolResultPersist?: (ctx: {
892
- session: Session
893
- message: Message
894
- toolName?: string
895
- toolCallId?: string
896
- isSynthetic?: boolean
897
- }) => Promise<ExtensionMessagePersistResult | Message | void> | ExtensionMessagePersistResult | Message | void
898
- beforeMessageWrite?: (ctx: {
899
- session: Session
900
- message: Message
901
- phase?: 'user' | 'system' | 'assistant_partial' | 'assistant_final' | 'heartbeat'
902
- runId?: string
903
- }) => Promise<ExtensionBeforeMessageWriteResult | Message | void> | ExtensionBeforeMessageWriteResult | Message | void
904
- afterToolExec?: (ctx: { session: Session; toolName: string; input: Record<string, unknown> | null; output: string }) => Promise<void> | void
905
- onMessage?: (ctx: { session: Session; message: Message }) => Promise<void> | void
906
- sessionStart?: (ctx: {
907
- session: Session
908
- resumedFrom?: string | null
909
- }) => Promise<void> | void
910
- sessionEnd?: (ctx: {
911
- sessionId: string
912
- session?: Session | null
913
- messageCount: number
914
- durationMs?: number
915
- reason?: string | null
916
- }) => Promise<void> | void
917
- subagentSpawning?: (ctx: {
918
- parentSessionId?: string | null
919
- agentId: string
920
- agentName: string
921
- message: string
922
- cwd: string
923
- mode: 'run' | 'session'
924
- threadRequested: boolean
925
- }) => Promise<ExtensionSubagentSpawningResult | void> | ExtensionSubagentSpawningResult | void
926
- subagentSpawned?: (ctx: {
927
- parentSessionId?: string | null
928
- childSessionId: string
929
- agentId: string
930
- agentName: string
931
- runId: string
932
- mode: 'run' | 'session'
933
- threadRequested: boolean
934
- }) => Promise<void> | void
935
- subagentEnded?: (ctx: {
936
- parentSessionId?: string | null
937
- childSessionId: string
938
- agentId: string
939
- agentName: string
940
- status: 'completed' | 'failed' | 'cancelled' | 'timed_out'
941
- response?: string | null
942
- error?: string | null
943
- durationMs?: number
944
- }) => Promise<void> | void
945
-
946
- // Post-turn hook — fires after a full chat exchange (user message → agent response)
947
- afterChatTurn?: (ctx: {
948
- session: Session
949
- message: string
950
- response: string
951
- source: string
952
- internal: boolean
953
- toolEvents?: MessageToolEvent[]
954
- }) => Promise<void> | void
955
-
956
- // Orchestration & Swarm Hooks
957
- onTaskComplete?: (ctx: { taskId: string; result: unknown }) => Promise<void> | void
958
- onAgentDelegation?: (ctx: { sourceAgentId: string; targetAgentId: string; task: string }) => Promise<void> | void
959
-
960
- // Chat Middleware (Transform messages)
961
- transformInboundMessage?: (ctx: { session: Session; text: string }) => Promise<string> | string
962
- transformOutboundMessage?: (ctx: { session: Session; text: string }) => Promise<string> | string
963
-
964
- // Context injection — return a markdown string to inject into the agent's state modifier, or null/undefined to skip
965
- getAgentContext?: (ctx: { session: Session; enabledExtensions: string[]; message: string; history: Message[] }) => Promise<string | null | undefined> | string | null | undefined
966
-
967
- // Self-description — returns a capability line for the system prompt (e.g., "I can remember things across conversations")
968
- getCapabilityDescription?: () => string | null | undefined
969
-
970
- // Operating guidance — returns operational hints for the agent when this extension is active
971
- getOperatingGuidance?: () => string | string[] | null | undefined
972
-
973
- // Approval guidance — returns approval-scoped instructions when this extension is active
974
- getApprovalGuidance?: (ctx: {
975
- approval: ApprovalRequest
976
- phase: 'request' | 'resume' | 'connector_reminder'
977
- approved?: boolean
978
- }) => string | string[] | null | undefined
979
- }
980
-
981
- export interface ExtensionToolPlanning {
982
- /**
983
- * Capability tags that the harness can use for prompt guidance and tool routing.
984
- * Examples: research.search, research.fetch, browser.capture, artifact.pdf,
985
- * delivery.media, delivery.voice_note.
986
- */
987
- capabilities?: string[]
988
- /**
989
- * Concrete usage guidance that should be injected into the system prompt when
990
- * this tool is enabled.
991
- */
992
- disciplineGuidance?: string[]
993
- }
994
-
995
- export interface ExtensionToolDef {
996
- name: string
997
- description: string
998
- parameters: Record<string, unknown>
999
- planning?: ExtensionToolPlanning
1000
- execute: (args: Record<string, unknown>, ctx: { session: Session; message: string }) => Promise<string | object> | string | object
1001
- }
1002
-
1003
- export interface ExtensionSettingsField {
1004
- key: string
1005
- label: string
1006
- type: 'text' | 'number' | 'boolean' | 'select' | 'secret'
1007
- placeholder?: string
1008
- help?: string
1009
- options?: Array<{ value: string; label: string }>
1010
- defaultValue?: string | number | boolean
1011
- required?: boolean
1012
- }
1013
-
1014
- export interface ExtensionUIDefinition {
1015
- sidebarItems?: Array<{
1016
- id: string
1017
- label: string
1018
- icon?: string
1019
- href: string
1020
- position?: 'top' | 'bottom'
1021
- }>
1022
- headerWidgets?: Array<{
1023
- id: string
1024
- label: string
1025
- icon?: string
1026
- }>
1027
- chatInputActions?: Array<{
1028
- id: string
1029
- label: string
1030
- icon?: string
1031
- tooltip?: string
1032
- action: 'message' | 'link' | 'tool'
1033
- value: string
1034
- }>
1035
- /** Settings fields declared by the extension, rendered in the extension settings panel */
1036
- settingsFields?: ExtensionSettingsField[]
1037
- /** Chat panels the extension provides (e.g., browser view, terminal) */
1038
- chatPanels?: Array<{
1039
- id: string
1040
- label: string
1041
- icon?: string
1042
- /** WS topic to subscribe to for updates (e.g., 'browser:{sessionId}') */
1043
- wsTopic?: string
1044
- }>
1045
- /** Badges to show on agent cards when this extension is enabled */
1046
- agentBadges?: Array<{
1047
- id: string
1048
- label: string
1049
- icon?: string
1050
- }>
1051
- }
1052
-
1053
- export interface ExtensionProviderDefinition {
1054
- id: string
1055
- name: string
1056
- models: string[]
1057
- requiresApiKey: boolean
1058
- requiresEndpoint: boolean
1059
- defaultEndpoint?: string
1060
- streamChat: (opts: {
1061
- session: { id: string } & Record<string, unknown>
1062
- message: string
1063
- imagePath?: string
1064
- imageUrl?: string
1065
- apiKey?: string | null
1066
- systemPrompt?: string
1067
- write: (data: string) => void
1068
- active: Map<string, unknown>
1069
- loadHistory: (sessionId: string) => unknown[]
1070
- onUsage?: (usage: { inputTokens: number; outputTokens: number }) => void
1071
- signal?: AbortSignal
1072
- }) => Promise<string>
1073
- }
1074
-
1075
- export type InboundMediaType = 'image' | 'video' | 'audio' | 'document' | 'file'
1076
-
1077
- export interface InboundThreadHistoryEntry {
1078
- role: 'user' | 'assistant'
1079
- senderName: string
1080
- text: string
1081
- messageId?: string
1082
- }
1083
-
1084
- export interface InboundMedia {
1085
- type: InboundMediaType
1086
- fileName?: string
1087
- mimeType?: string
1088
- sizeBytes?: number
1089
- url?: string
1090
- localPath?: string
1091
- }
1092
-
1093
- export interface InboundMessage {
1094
- platform: string
1095
- channelId: string
1096
- channelIdAlt?: string
1097
- channelName?: string
1098
- senderId: string
1099
- senderIdAlt?: string
1100
- senderName: string
1101
- senderAvatarUrl?: string
1102
- text: string
1103
- isGroup?: boolean
1104
- messageId?: string
1105
- imageUrl?: string
1106
- media?: InboundMedia[]
1107
- replyToMessageId?: string
1108
- threadId?: string
1109
- threadTitle?: string
1110
- threadStarterText?: string
1111
- threadStarterSenderName?: string
1112
- threadPersonaLabel?: string
1113
- threadParentChannelId?: string
1114
- threadParentChannelName?: string
1115
- threadHistory?: InboundThreadHistoryEntry[]
1116
- mentionsBot?: boolean
1117
- agentIdOverride?: string
1118
- isOwnerConversation?: boolean
1119
- }
1120
-
1121
- export interface OutboundSendOptions {
1122
- imageUrl?: string
1123
- fileUrl?: string
1124
- mediaPath?: string
1125
- mimeType?: string
1126
- fileName?: string
1127
- caption?: string
1128
- ptt?: boolean
1129
- replyToMessageId?: string
1130
- threadId?: string
1131
- }
1132
-
1133
- export interface ExtensionConnectorDefinition {
1134
- id: string
1135
- name: string
1136
- description: string
1137
- supportsBinaryMedia?: boolean
1138
- // For sending outbound
1139
- sendMessage?: (
1140
- channelId: string,
1141
- text: string,
1142
- options?: OutboundSendOptions,
1143
- ) => Promise<{ messageId?: string } | void>
1144
- // For polling/listening
1145
- startListener?: (onMessage: (msg: InboundMessage) => void) => Promise<() => void>
1146
- }
1147
-
1148
- export interface Extension {
1149
- name: string
1150
- version?: string
1151
- description?: string
1152
- author?: string
1153
- openclaw?: boolean
1154
- enabledByDefault?: boolean
1155
- hooks?: ExtensionHooks
1156
- tools?: ExtensionToolDef[]
1157
- ui?: ExtensionUIDefinition
1158
- providers?: ExtensionProviderDefinition[]
1159
- connectors?: ExtensionConnectorDefinition[]
1160
- }
1161
-
1162
- export interface ExtensionMeta {
1163
- name: string
1164
- description?: string
1165
- filename: string
1166
- enabled: boolean
1167
- isBuiltin?: boolean
1168
- author?: string
1169
- version?: string
1170
- source?: 'local' | 'manual' | 'marketplace'
1171
- sourceLabel?: ExtensionPublisherSource
1172
- installSource?: ExtensionInstallSource
1173
- sourceUrl?: string
1174
- openclaw?: boolean
1175
- failureCount?: number
1176
- lastFailureAt?: number
1177
- lastFailureStage?: string
1178
- lastFailureError?: string
1179
- autoDisabled?: boolean
1180
- toolCount?: number
1181
- hookCount?: number
1182
- hasUI?: boolean
1183
- providerCount?: number
1184
- connectorCount?: number
1185
- createdByAgentId?: string | null
1186
- settingsFields?: ExtensionSettingsField[]
1187
- hasDependencyManifest?: boolean
1188
- dependencyCount?: number
1189
- devDependencyCount?: number
1190
- packageManager?: ExtensionPackageManager
1191
- dependencyInstallStatus?: ExtensionDependencyInstallStatus
1192
- dependencyInstallError?: string
1193
- dependencyInstalledAt?: number
1194
- }
1195
-
1196
- export type ExtensionPublisherSource =
1197
- | 'builtin'
1198
- | 'local'
1199
- | 'manual'
1200
- | 'swarmclaw'
1201
- | 'swarmforge'
1202
- | 'clawhub'
1203
-
1204
- export type ExtensionCatalogSource =
1205
- | 'swarmclaw'
1206
- | 'swarmclaw-site'
1207
- | 'swarmforge'
1208
- | 'clawhub'
1209
-
1210
- export type ExtensionInstallSource =
1211
- | 'builtin'
1212
- | 'local'
1213
- | 'manual'
1214
- | ExtensionCatalogSource
1215
-
1216
- export type ExtensionPackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'
1217
- export type ExtensionDependencyInstallStatus = 'none' | 'ready' | 'installing' | 'installed' | 'error'
1218
-
1219
- export interface MarketplaceExtension {
1220
- id: string
1221
- name: string
1222
- description: string
1223
- author: string
1224
- version: string
1225
- url: string
1226
- source?: ExtensionPublisherSource
1227
- catalogSource?: ExtensionCatalogSource
1228
- tags?: string[]
1229
- openclaw?: boolean
1230
- downloads?: number
1231
- }
1232
-
1233
- export interface SSEEvent {
1234
- t: 'd' | 'md' | 'r' | 'done' | 'err' | 'tool_call' | 'tool_result' | 'status' | 'thinking' | 'reset' | 'cr_agent_start' | 'cr_agent_done'
1235
- text?: string
1236
- toolName?: string
1237
- toolInput?: string
1238
- toolOutput?: string
1239
- toolCallId?: string
1240
- agentId?: string
1241
- agentName?: string
1242
- }
1243
-
1244
- export interface Directory {
1245
- name: string
1246
- path: string
1247
- }
1248
-
1249
- export interface DevServerStatus {
1250
- running: boolean
1251
- url?: string
1252
- }
1253
-
1254
- export interface DeployResult {
1255
- ok: boolean
1256
- output?: string
1257
- error?: string
1258
- }
1259
-
1260
- export interface UploadResult {
1261
- path: string
1262
- size: number
1263
- url: string
1264
- }
1265
-
1266
- export interface NetworkInfo {
1267
- ip: string
1268
- port: number
1269
- }
1270
-
1271
- // --- Agent / Delegation ---
1272
-
1273
- export type AgentRole = 'worker' | 'coordinator'
1274
- export type DelegationTargetMode = 'all' | 'selected'
1275
-
1276
- export interface AgentOrgChart {
1277
- parentId?: string | null
1278
- teamLabel?: string | null
1279
- teamColor?: string | null
1280
- x?: number | null
1281
- y?: number | null
1282
- }
1283
-
1284
- export interface Agent {
1285
- id: string
1286
- name: string
1287
- openclawAgentId?: string | null
1288
- description: string
1289
- soul?: string
1290
- identityState?: IdentityContinuityState | null
1291
- emoji?: string
1292
- creature?: string
1293
- vibe?: string
1294
- theme?: string
1295
- avatar?: string
1296
- systemPrompt: string
1297
- provider: ProviderId
1298
- model: string
1299
- ollamaMode?: OllamaMode | null
1300
- credentialId?: string | null
1301
- fallbackCredentialIds?: string[]
1302
- apiEndpoint?: string | null
1303
- gatewayProfileId?: string | null
1304
- preferredGatewayTags?: string[]
1305
- preferredGatewayUseCase?: string | null
1306
- routingStrategy?: AgentRoutingStrategy | null
1307
- routingTargets?: AgentRoutingTarget[]
1308
- role?: AgentRole // default 'worker' — coordinators get enhanced delegation prompts
1309
- delegationEnabled?: boolean
1310
- delegationTargetMode?: DelegationTargetMode
1311
- delegationTargetAgentIds?: string[]
1312
- tools?: string[]
1313
- extensions?: string[]
1314
- skills?: string[] // e.g. ['frontend-design'] — pinned Claude Code skills to mention explicitly
1315
- skillIds?: string[] // IDs of pinned managed skills to keep always-on for this agent
1316
- mcpServerIds?: string[] // IDs of configured MCP servers to inject tools from
1317
- mcpDisabledTools?: string[] // MCP tool names disabled for this agent (denylist)
1318
- orgChart?: AgentOrgChart | null
1319
- capabilities?: string[] // e.g. ['frontend', 'screenshots', 'research', 'devops']
1320
- threadSessionId?: string | null // persistent shortcut chat session for agent-centric UI
1321
- heartbeatEnabled?: boolean
1322
- heartbeatIntervalSec?: number | null
1323
- heartbeatInterval?: string | number | null
1324
- heartbeatPrompt?: string | null
1325
- heartbeatModel?: string | null
1326
- heartbeatAckMaxChars?: number | null
1327
- heartbeatShowOk?: boolean | null
1328
- heartbeatShowAlerts?: boolean | null
1329
- heartbeatTarget?: 'last' | 'none' | string | null
1330
- heartbeatGoal?: string | null
1331
- heartbeatNextAction?: string | null
1332
- heartbeatLightContext?: boolean | null
1333
- sessionResetMode?: SessionResetMode | null
1334
- sessionIdleTimeoutSec?: number | null
1335
- sessionMaxAgeSec?: number | null
1336
- sessionDailyResetAt?: string | null
1337
- sessionResetTimezone?: string | null
1338
- thinkingLevel?: 'minimal' | 'low' | 'medium' | 'high'
1339
- memoryScopeMode?: 'auto' | 'all' | 'global' | 'agent' | 'session' | 'project' | null
1340
- memoryTierPreference?: 'working' | 'durable' | 'archive' | 'blended' | null
1341
- elevenLabsVoiceId?: string | null
1342
- projectId?: string
1343
- avatarSeed?: string
1344
- avatarUrl?: string | null
1345
- pinned?: boolean
1346
- lastUsedAt?: number
1347
- totalCost?: number
1348
- disabled?: boolean
1349
- trashedAt?: number
1350
- openclawSkillMode?: SkillAllowlistMode
1351
- openclawAllowedSkills?: string[]
1352
- walletIds?: string[]
1353
- activeWalletId?: string | null
1354
- /** @deprecated Use walletIds + activeWalletId */
1355
- walletId?: string | null
1356
- responseStyle?: 'concise' | 'normal' | 'detailed' | null
1357
- responseMaxChars?: number | null
1358
- monthlyBudget?: number | null
1359
- dailyBudget?: number | null
1360
- hourlyBudget?: number | null
1361
- autoRecovery?: boolean
1362
- proactiveMemory?: boolean
1363
- /** Auto-refresh a reviewed skill draft from meaningful chat turns for this agent. */
1364
- autoDraftSkillSuggestions?: boolean
1365
- /** Controls whether file operations are confined to the workspace or allowed anywhere on the host. Default: 'workspace'. */
1366
- filesystemScope?: 'workspace' | 'machine' | null
1367
- /** Per-agent filesystem restrictions. Globs matched against resolved paths. */
1368
- fileAccessPolicy?: {
1369
- /** If set, only these paths (globs) are writable. Others are blocked. */
1370
- allowedPaths?: string[]
1371
- /** These paths (globs) are always blocked even if allowedPaths matches. */
1372
- blockedPaths?: string[]
1373
- } | null
1374
-
1375
- /** Docker container sandbox for shell command execution. */
1376
- sandboxConfig?: {
1377
- enabled: boolean
1378
- mode?: 'off' | 'non-main' | 'all' // default: 'all' when enabled, modeled after OpenClaw
1379
- scope?: 'session' | 'agent' // default: 'session'
1380
- workspaceAccess?: 'ro' | 'rw' // default: 'rw'
1381
- image?: string // default: 'node:22-slim'
1382
- network?: 'none' | 'bridge' // default: 'none'
1383
- memoryMb?: number // default: 512
1384
- cpus?: number // default: 1.0
1385
- readonlyRoot?: boolean // default: false
1386
- workdir?: string // default: '/workspace'
1387
- containerPrefix?: string // default: 'swarmclaw-sb-'
1388
- pidsLimit?: number // default: 256
1389
- setupCommand?: string
1390
- browser?: {
1391
- enabled?: boolean
1392
- image?: string
1393
- containerPrefix?: string
1394
- network?: 'none' | 'bridge'
1395
- cdpPort?: number
1396
- vncPort?: number
1397
- noVncPort?: number
1398
- headless?: boolean
1399
- enableNoVnc?: boolean
1400
- mountUploads?: boolean
1401
- autoStartTimeoutMs?: number
1402
- } | null
1403
- prune?: {
1404
- idleHours?: number
1405
- maxAgeDays?: number
1406
- } | null
1407
- } | null
1408
-
1409
- budgetAction?: 'warn' | 'block'
1410
- /** Runtime-enriched: current month's spend. Populated by GET /api/agents when monthlyBudget is set. */
1411
- monthlySpend?: number
1412
- /** Runtime-enriched: current day's spend. Populated by GET /api/agents when dailyBudget is set. */
1413
- dailySpend?: number
1414
- /** Runtime-enriched: trailing 1-hour spend. Populated by GET /api/agents when hourlyBudget is set. */
1415
- hourlySpend?: number
1416
- maxFollowupChain?: number
1417
-
1418
- // Orchestrator Mode
1419
- orchestratorEnabled?: boolean
1420
- orchestratorMission?: string
1421
- orchestratorWakeInterval?: string | number | null
1422
- orchestratorGovernance?: 'autonomous' | 'approval-required' | 'notify-only'
1423
- orchestratorMaxCyclesPerDay?: number | null
1424
- orchestratorLastWakeAt?: number | null
1425
- orchestratorCycleCount?: number
1426
-
1427
- createdAt: number
1428
- updatedAt: number
1429
- }
1430
-
1431
- // --- Agent Wallets ---
1432
-
1433
- export type WalletChain = 'solana' | 'ethereum'
1434
-
1435
- export interface AgentWallet {
1436
- id: string
1437
- agentId: string
1438
- chain: WalletChain
1439
- publicKey: string
1440
- encryptedPrivateKey: string // AES-256-GCM via encryptKey()
1441
- label?: string
1442
- spendingLimitAtomic?: string
1443
- dailyLimitAtomic?: string
1444
- /** @deprecated Use spendingLimitAtomic */
1445
- spendingLimitLamports?: number
1446
- /** @deprecated Use dailyLimitAtomic */
1447
- dailyLimitLamports?: number
1448
- requireApproval: boolean // default true; can be globally overridden by app settings
1449
- createdAt: number
1450
- updatedAt: number
1451
- }
1452
-
1453
- export interface WalletAssetBalance {
1454
- id: string
1455
- chain: WalletChain
1456
- networkId: string
1457
- networkLabel: string
1458
- symbol: string
1459
- name?: string
1460
- decimals: number
1461
- balanceAtomic: string
1462
- balanceFormatted?: string
1463
- balanceDisplay?: string
1464
- isNative: boolean
1465
- contractAddress?: string
1466
- tokenMint?: string
1467
- explorerUrl?: string
1468
- }
1469
-
1470
- export interface WalletPortfolioSummary {
1471
- totalAssets: number
1472
- nonZeroAssets: number
1473
- tokenAssets: number
1474
- networkCount: number
1475
- }
1476
-
1477
- export type WalletTransactionType = 'send' | 'receive' | 'swap'
1478
- export type WalletTransactionStatus = 'pending_approval' | 'pending' | 'confirmed' | 'failed' | 'denied'
1479
-
1480
- export interface WalletTransaction {
1481
- id: string
1482
- walletId: string
1483
- agentId: string
1484
- chain: WalletChain
1485
- type: WalletTransactionType
1486
- signature: string
1487
- fromAddress: string
1488
- toAddress: string
1489
- amountAtomic?: string
1490
- feeAtomic?: string
1491
- /** @deprecated Use amountAtomic */
1492
- amountLamports?: number
1493
- /** @deprecated Use feeAtomic */
1494
- feeLamports?: number
1495
- status: WalletTransactionStatus
1496
- memo?: string // agent's reason for tx
1497
- approvedBy?: 'user' | 'auto'
1498
- tokenMint?: string // null = native chain asset
1499
- timestamp: number
1500
- }
1501
-
1502
- export interface WalletBalanceSnapshot {
1503
- id: string
1504
- walletId: string
1505
- balanceAtomic?: string
1506
- /** @deprecated Use balanceAtomic */
1507
- balanceLamports?: number
1508
- timestamp: number
1509
- }
1510
-
1511
- export type AgentTool = 'browser'
1512
-
1513
- export interface ClaudeSkill {
1514
- id: string
1515
- name: string
1516
- description: string
1517
- }
1518
-
1519
- export type ScheduleType = 'cron' | 'interval' | 'once'
1520
- export type ScheduleStatus = 'active' | 'paused' | 'completed' | 'failed' | 'archived'
1521
- export type ScheduleTaskMode = 'task' | 'wake_only' | 'protocol'
1522
-
1523
- export interface Schedule {
1524
- id: string
1525
- name: string
1526
- agentId: string
1527
- projectId?: string
1528
- taskPrompt: string
1529
- /** 'task' creates a board task, 'wake_only' just wakes the agent, and 'protocol' launches a structured session run. */
1530
- taskMode?: ScheduleTaskMode
1531
- /** Wake message sent to agent when taskMode is 'wake_only' */
1532
- message?: string
1533
- /** Structured session template launched when taskMode is 'protocol'. */
1534
- protocolTemplateId?: string | null
1535
- protocolParticipantAgentIds?: string[]
1536
- protocolFacilitatorAgentId?: string | null
1537
- protocolObserverAgentIds?: string[]
1538
- protocolConfig?: Record<string, unknown> | null
1539
- scheduleType: ScheduleType
1540
- action?: string
1541
- path?: string
1542
- command?: string
1543
- description?: string
1544
- frequency?: string
1545
- cron?: string
1546
- /** Natural time expression e.g. "at 09:00" — resolved to cron on creation */
1547
- atTime?: string | null
1548
- intervalMs?: number
1549
- runAt?: number
1550
- lastRunAt?: number
1551
- nextRunAt?: number
1552
- /** IANA timezone for schedule evaluation (default: system local) */
1553
- timezone?: string | null
1554
- /** Random stagger window in seconds added to nextRunAt to avoid thundering herd */
1555
- staggerSec?: number | null
1556
- /** Last delivery status for this schedule */
1557
- lastDeliveryStatus?: 'ok' | 'error' | null
1558
- /** Timestamp of last delivery attempt */
1559
- lastDeliveredAt?: number | null
1560
- /** Error message from last failed delivery */
1561
- lastDeliveryError?: string | null
1562
- status: ScheduleStatus
1563
- archivedAt?: number | null
1564
- archivedFromStatus?: Exclude<ScheduleStatus, 'archived'> | null
1565
- linkedTaskId?: string | null
1566
- linkedMissionId?: string | null
1567
- runNumber?: number
1568
- createdByAgentId?: string | null
1569
- createdInSessionId?: string | null
1570
- followupConnectorId?: string | null
1571
- followupChannelId?: string | null
1572
- followupThreadId?: string | null
1573
- followupSenderId?: string | null
1574
- followupSenderName?: string | null
1575
- createdAt: number
1576
- updatedAt?: number
1577
- }
1578
-
1579
- export type BrowserSessionStatus = 'active' | 'idle' | 'closed' | 'error'
1580
-
1581
- export interface BrowserSessionTab {
1582
- index: number
1583
- title?: string | null
1584
- url?: string | null
1585
- }
1586
-
1587
- export interface BrowserSessionArtifact {
1588
- kind: 'snapshot' | 'screenshot' | 'download' | 'pdf'
1589
- path: string
1590
- url?: string | null
1591
- filename?: string | null
1592
- createdAt: number
1593
- }
1594
-
1595
- export interface BrowserObservationLink {
1596
- text: string
1597
- href: string
1598
- }
1599
-
1600
- export interface BrowserObservationFormField {
1601
- name?: string | null
1602
- label?: string | null
1603
- type: string
1604
- required?: boolean
1605
- }
1606
-
1607
- export interface BrowserObservationForm {
1608
- index: number
1609
- action?: string | null
1610
- method?: string | null
1611
- fields: BrowserObservationFormField[]
1612
- }
1613
-
1614
- export interface BrowserObservationTable {
1615
- index: number
1616
- headers: string[]
1617
- rowCount: number
1618
- rows?: string[][]
1619
- }
1620
-
1621
- export interface BrowserObservation {
1622
- capturedAt: number
1623
- url?: string | null
1624
- title?: string | null
1625
- textPreview?: string | null
1626
- activeTabIndex?: number | null
1627
- tabs?: BrowserSessionTab[]
1628
- links?: BrowserObservationLink[]
1629
- forms?: BrowserObservationForm[]
1630
- tables?: BrowserObservationTable[]
1631
- errors?: string[]
1632
- }
1633
-
1634
- export interface BrowserSandboxRuntimeInfo {
1635
- scopeKey?: string | null
1636
- containerName?: string | null
1637
- cdpEndpoint?: string | null
1638
- cdpPort?: number | null
1639
- noVncPort?: number | null
1640
- bridgeUrl?: string | null
1641
- }
1642
-
1643
- export interface BrowserSessionRecord {
1644
- id: string
1645
- sessionId: string
1646
- profileId: string
1647
- profileDir: string
1648
- status: BrowserSessionStatus
1649
- runtime?: 'host' | 'sandbox-browser' | null
1650
- sandbox?: BrowserSandboxRuntimeInfo | null
1651
- inheritedFromSessionId?: string | null
1652
- currentUrl?: string | null
1653
- pageTitle?: string | null
1654
- activeTabIndex?: number | null
1655
- tabs?: BrowserSessionTab[]
1656
- lastAction?: string | null
1657
- lastError?: string | null
1658
- lastObservation?: BrowserObservation | null
1659
- artifacts?: BrowserSessionArtifact[]
1660
- createdAt: number
1661
- updatedAt: number
1662
- lastUsedAt: number
1663
- }
1664
-
1665
- export type WatchJobType = 'time' | 'http' | 'file' | 'task' | 'webhook' | 'page' | 'email' | 'mailbox' | 'approval'
1666
- export type WatchJobStatus = 'active' | 'triggered' | 'failed' | 'cancelled'
1667
-
1668
- export interface WatchJob {
1669
- id: string
1670
- type: WatchJobType
1671
- status: WatchJobStatus
1672
- description?: string | null
1673
- sessionId?: string | null
1674
- agentId?: string | null
1675
- createdByAgentId?: string | null
1676
- browserProfileId?: string | null
1677
- resumeMessage: string
1678
- target: Record<string, unknown>
1679
- condition: Record<string, unknown>
1680
- runAt?: number | null
1681
- nextCheckAt?: number | null
1682
- intervalMs?: number | null
1683
- timeoutAt?: number | null
1684
- lastCheckedAt?: number | null
1685
- lastTriggeredAt?: number | null
1686
- lastError?: string | null
1687
- result?: Record<string, unknown> | null
1688
- createdAt: number
1689
- updatedAt: number
1690
- }
1691
-
1692
- export type DelegationJobKind = 'subagent' | 'delegate'
1693
- export type DelegationJobStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled'
1694
-
1695
- export interface DelegationJobCheckpoint {
1696
- at: number
1697
- note: string
1698
- status?: DelegationJobStatus
1699
- }
1700
-
1701
- export interface DelegationJobArtifact {
1702
- type: 'text' | 'file' | 'image' | 'link'
1703
- value: string
1704
- label?: string | null
1705
- }
1706
-
1707
- export interface DelegationJobRecord {
1708
- id: string
1709
- kind: DelegationJobKind
1710
- status: DelegationJobStatus
1711
- backend?: 'claude' | 'codex' | 'opencode' | 'gemini' | null
1712
- missionId?: string | null
1713
- parentMissionId?: string | null
1714
- parentSessionId?: string | null
1715
- childSessionId?: string | null
1716
- agentId?: string | null
1717
- agentName?: string | null
1718
- cwd?: string | null
1719
- task: string
1720
- result?: string | null
1721
- resultPreview?: string | null
1722
- error?: string | null
1723
- checkpoints?: DelegationJobCheckpoint[]
1724
- artifacts?: DelegationJobArtifact[]
1725
- resumeId?: string | null
1726
- resumeIds?: {
1727
- claudeCode?: string | null
1728
- codex?: string | null
1729
- opencode?: string | null
1730
- gemini?: string | null
1731
- }
1732
- requesterRunId?: string | null
1733
- childRunId?: string | null
1734
- createdAt: number
1735
- updatedAt: number
1736
- startedAt?: number | null
1737
- completedAt?: number | null
1738
- }
1739
-
1740
- export interface FileReference {
1741
- path: string
1742
- contextSnippet?: string
1743
- kind?: 'file' | 'folder' | 'project'
1744
- projectRoot?: string
1745
- projectName?: string
1746
- exists?: boolean
1747
- timestamp: number
1748
- }
1749
-
1750
- export interface MemoryReference {
1751
- type: 'project' | 'folder' | 'file' | 'task' | 'session' | 'url'
1752
- path?: string
1753
- projectRoot?: string
1754
- projectName?: string
1755
- title?: string
1756
- note?: string
1757
- exists?: boolean
1758
- timestamp: number
1759
- }
1760
-
1761
- export interface MemoryImage {
1762
- path: string
1763
- mimeType?: string
1764
- width?: number
1765
- height?: number
1766
- sizeBytes?: number
1767
- }
1768
-
1769
- export interface MemoryEntry {
1770
- id: string
1771
- agentId?: string | null
1772
- sessionId?: string | null
1773
- category: string
1774
- title: string
1775
- content: string
1776
- metadata?: Record<string, unknown>
1777
- references?: MemoryReference[]
1778
- filePaths?: FileReference[]
1779
- image?: MemoryImage | null
1780
- imagePath?: string | null
1781
- linkedMemoryIds?: string[]
1782
- pinned?: boolean
1783
- sharedWith?: string[]
1784
- accessCount?: number
1785
- lastAccessedAt?: number
1786
- contentHash?: string
1787
- reinforcementCount?: number
1788
- abstract?: string | null
1789
- createdAt: number
1790
- updatedAt: number
1791
- }
1792
-
1793
- export type SessionType = 'human'
1794
- export type AppView = 'home' | 'agents' | 'org_chart' | 'inbox' | 'chatrooms' | 'protocols' | 'schedules' | 'memory' | 'missions' | 'tasks' | 'secrets' | 'providers' | 'skills' | 'connectors' | 'webhooks' | 'mcp_servers' | 'knowledge' | 'extensions' | 'usage' | 'wallets' | 'runs' | 'autonomy' | 'logs' | 'settings' | 'projects' | 'activity'
1795
-
1796
- // --- Chatrooms ---
1797
-
1798
- export interface ChatroomRoutingRule {
1799
- id: string
1800
- type: 'keyword' | 'capability'
1801
- pattern?: string
1802
- keywords?: string[]
1803
- agentId: string
1804
- priority: number
1805
- }
1806
-
1807
- export interface ChatroomMember {
1808
- agentId: string
1809
- role: 'admin' | 'moderator' | 'member'
1810
- mutedUntil?: string
1811
- }
1812
-
1813
- export interface ChatroomReaction {
1814
- emoji: string
1815
- reactorId: string // 'user' or agentId
1816
- time: number
1817
- }
1818
-
1819
- export interface ChatroomMessage {
1820
- id: string
1821
- senderId: string // 'user' or agentId
1822
- senderName: string
1823
- role: 'user' | 'assistant'
1824
- text: string
1825
- mentions: string[] // parsed agentIds
1826
- reactions: ChatroomReaction[]
1827
- toolEvents?: MessageToolEvent[]
1828
- time: number
1829
- attachedFiles?: string[]
1830
- imagePath?: string
1831
- replyToId?: string
1832
- targetAgentId?: string
1833
- source?: MessageSource
1834
- historyExcluded?: boolean
1835
- }
1836
-
1837
- export interface Chatroom {
1838
- id: string
1839
- name: string
1840
- description?: string
1841
- agentIds: string[]
1842
- members?: ChatroomMember[]
1843
- messages: ChatroomMessage[]
1844
- pinnedMessageIds?: string[]
1845
- chatMode?: 'sequential' | 'parallel'
1846
- autoAddress?: boolean
1847
- routingGuidance?: string | null
1848
- /** Legacy deterministic routing config kept only for migration/read compatibility. */
1849
- routingRules?: ChatroomRoutingRule[]
1850
- temporary?: boolean
1851
- topic?: string
1852
- hidden?: boolean
1853
- archivedAt?: number | null
1854
- protocolRunId?: string | null
1855
- parentChatroomId?: string | null
1856
- createdAt: number
1857
- updatedAt: number
1858
- }
1859
-
1860
- // --- Structured Session Runs / Protocols ---
1861
-
1862
- export type ProtocolRunStatus = 'draft' | 'running' | 'waiting' | 'paused' | 'completed' | 'failed' | 'cancelled' | 'archived'
1863
-
1864
- export type ProtocolPhaseKind =
1865
- | 'present'
1866
- | 'collect_independent_inputs'
1867
- | 'round_robin'
1868
- | 'compare'
1869
- | 'decide'
1870
- | 'summarize'
1871
- | 'emit_tasks'
1872
- | 'wait'
1873
- | 'dispatch_task'
1874
- | 'dispatch_delegation'
1875
-
1876
- export interface ProtocolPhaseDefinition {
1877
- id: string
1878
- kind: ProtocolPhaseKind
1879
- label: string
1880
- instructions?: string | null
1881
- turnLimit?: number | null
1882
- completionCriteria?: string | null
1883
- taskConfig?: { agentId?: string; title: string; description: string } | null
1884
- delegationConfig?: { agentId: string; message: string } | null
1885
- }
1886
-
1887
- export type ProtocolConditionDefinition =
1888
- | { type: 'summary_exists' }
1889
- | { type: 'artifact_exists'; artifactKind?: ProtocolRunArtifact['kind'] | null }
1890
- | { type: 'artifact_count_at_least'; count: number; artifactKind?: ProtocolRunArtifact['kind'] | null }
1891
- | { type: 'created_task_count_at_least'; count: number }
1892
- | { type: 'all'; conditions: ProtocolConditionDefinition[] }
1893
- | { type: 'any'; conditions: ProtocolConditionDefinition[] }
1894
-
1895
- export interface ProtocolBranchCase {
1896
- id: string
1897
- label: string
1898
- nextStepId: string
1899
- description?: string | null
1900
- when?: ProtocolConditionDefinition | null
1901
- }
1902
-
1903
- export interface ProtocolRepeatConfig {
1904
- bodyStepId: string
1905
- nextStepId?: string | null
1906
- maxIterations: number
1907
- exitCondition?: ProtocolConditionDefinition | null
1908
- onExhausted?: 'advance' | 'fail'
1909
- }
1910
-
1911
- export interface ProtocolParallelBranchDefinition {
1912
- id: string
1913
- label: string
1914
- steps: ProtocolStepDefinition[]
1915
- entryStepId?: string | null
1916
- participantAgentIds?: string[]
1917
- facilitatorAgentId?: string | null
1918
- observerAgentIds?: string[]
1919
- }
1920
-
1921
- export interface ProtocolParallelConfig {
1922
- branches: ProtocolParallelBranchDefinition[]
1923
- }
1924
-
1925
- export interface ProtocolJoinConfig {
1926
- parallelStepId?: string | null
1927
- }
1928
-
1929
- export type ProtocolStepKind =
1930
- | ProtocolPhaseKind
1931
- | 'branch'
1932
- | 'repeat'
1933
- | 'parallel'
1934
- | 'join'
1935
- | 'complete'
1936
- | 'for_each'
1937
- | 'subflow'
1938
- | 'swarm_claim'
1939
-
1940
- export interface ProtocolStepDefinition {
1941
- id: string
1942
- kind: ProtocolStepKind
1943
- label: string
1944
- instructions?: string | null
1945
- turnLimit?: number | null
1946
- completionCriteria?: string | null
1947
- taskConfig?: { agentId?: string; title: string; description: string } | null
1948
- delegationConfig?: { agentId: string; message: string } | null
1949
- nextStepId?: string | null
1950
- branchCases?: ProtocolBranchCase[]
1951
- defaultNextStepId?: string | null
1952
- repeat?: ProtocolRepeatConfig | null
1953
- parallel?: ProtocolParallelConfig | null
1954
- join?: ProtocolJoinConfig | null
1955
- dependsOnStepIds?: string[]
1956
- outputKey?: string | null
1957
- forEach?: ProtocolForEachConfig | null
1958
- subflow?: ProtocolSubflowConfig | null
1959
- swarm?: ProtocolSwarmConfig | null
1960
- }
1961
-
1962
- export interface ProtocolTemplate {
1963
- id: string
1964
- name: string
1965
- description: string
1966
- builtIn: boolean
1967
- singleAgentAllowed?: boolean
1968
- tags?: string[]
1969
- recommendedOutputs?: string[]
1970
- defaultPhases: ProtocolPhaseDefinition[]
1971
- steps?: ProtocolStepDefinition[]
1972
- entryStepId?: string | null
1973
- createdAt?: number
1974
- updatedAt?: number
1975
- }
1976
-
1977
- export type ProtocolSourceRef =
1978
- | { kind: 'manual' }
1979
- | { kind: 'api' }
1980
- | { kind: 'session'; sessionId: string }
1981
- | { kind: 'chatroom'; chatroomId: string }
1982
- | { kind: 'mission'; missionId: string }
1983
- | { kind: 'task'; taskId: string }
1984
- | { kind: 'schedule'; scheduleId: string }
1985
- | { kind: 'protocol_run'; runId: string; parentRunId?: string | null; stepId?: string | null; branchId?: string | null }
1986
-
1987
- export interface ProtocolRunArtifact {
1988
- id: string
1989
- kind: 'summary' | 'decision' | 'comparison' | 'notes' | 'action_items'
1990
- title: string
1991
- content: string
1992
- phaseId?: string | null
1993
- taskIds?: string[]
1994
- createdAt: number
1995
- }
1996
-
1997
- export interface ProtocolRunPhaseStateResponse {
1998
- agentId: string
1999
- text: string
2000
- toolEvents?: MessageToolEvent[]
2001
- }
2002
-
2003
- export interface ProtocolRunPhaseState {
2004
- phaseId: string
2005
- respondedAgentIds?: string[]
2006
- responses?: ProtocolRunPhaseStateResponse[]
2007
- appendedToTranscript?: boolean
2008
- artifactId?: string | null
2009
- dispatchedTaskId?: string | null
2010
- }
2011
-
2012
- export interface ProtocolRunLoopState {
2013
- stepId: string
2014
- iterationCount: number
2015
- }
2016
-
2017
- export interface ProtocolRunBranchDecision {
2018
- stepId: string
2019
- caseId?: string | null
2020
- nextStepId?: string | null
2021
- decidedAt: number
2022
- }
2023
-
2024
- export interface ProtocolRunParallelBranchState {
2025
- branchId: string
2026
- label: string
2027
- runId: string
2028
- status: ProtocolRunStatus
2029
- participantAgentIds?: string[]
2030
- summary?: string | null
2031
- lastError?: string | null
2032
- updatedAt: number
2033
- }
2034
-
2035
- export interface ProtocolRunParallelStepState {
2036
- stepId: string
2037
- branchRunIds: string[]
2038
- branches: ProtocolRunParallelBranchState[]
2039
- waitingOnBranchIds?: string[]
2040
- joinReady?: boolean
2041
- joinCompletedAt?: number | null
2042
- }
2043
-
2044
- // --- DAG Step State ---
2045
-
2046
- export type ProtocolRunStepStatus = 'pending' | 'ready' | 'running' | 'waiting' | 'completed' | 'failed' | 'skipped'
2047
-
2048
- export interface ProtocolRunStepState {
2049
- stepId: string
2050
- status: ProtocolRunStepStatus
2051
- startedAt?: number | null
2052
- completedAt?: number | null
2053
- error?: string | null
2054
- }
2055
-
2056
- export interface ProtocolRunStepOutput {
2057
- stepId: string
2058
- outputKey?: string | null
2059
- summary?: string | null
2060
- artifactIds?: string[]
2061
- taskIds?: string[]
2062
- childRunIds?: string[]
2063
- structuredData?: Record<string, unknown> | null
2064
- }
2065
-
2066
- // --- For-Each Config ---
2067
-
2068
- export interface ProtocolForEachConfig {
2069
- itemsSource:
2070
- | { type: 'literal'; items: unknown[] }
2071
- | { type: 'step_output'; stepId: string; path?: string | null }
2072
- | { type: 'artifact'; artifactId?: string | null; artifactKind?: string | null }
2073
- | { type: 'llm_extract'; prompt: string }
2074
- itemAlias: string
2075
- branchTemplate: {
2076
- steps: ProtocolStepDefinition[]
2077
- entryStepId?: string | null
2078
- participantAgentIds?: string[]
2079
- facilitatorAgentId?: string | null
2080
- }
2081
- joinMode: 'all'
2082
- maxItems?: number | null
2083
- onEmpty?: 'fail' | 'skip' | 'advance'
2084
- }
2085
-
2086
- export interface ProtocolRunForEachStepState {
2087
- stepId: string
2088
- items: unknown[]
2089
- branchRunIds: string[]
2090
- branches: ProtocolRunParallelBranchState[]
2091
- waitingOnBranchIds?: string[]
2092
- joinReady?: boolean
2093
- joinCompletedAt?: number | null
2094
- }
2095
-
2096
- // --- Subflow Config ---
2097
-
2098
- export interface ProtocolSubflowConfig {
2099
- templateId: string
2100
- templateVersion?: string | null
2101
- participantAgentIds?: string[]
2102
- facilitatorAgentId?: string | null
2103
- inputMapping?: Record<string, string> | null
2104
- outputMapping?: Record<string, string> | null
2105
- onFailure: 'fail_parent' | 'advance_with_warning'
2106
- }
2107
-
2108
- export interface ProtocolRunSubflowState {
2109
- stepId: string
2110
- childRunId: string
2111
- templateId: string
2112
- status: ProtocolRunStatus
2113
- summary?: string | null
2114
- lastError?: string | null
2115
- startedAt?: number | null
2116
- completedAt?: number | null
2117
- }
2118
-
2119
- // --- Swarm Config ---
2120
-
2121
- export interface ProtocolSwarmConfig {
2122
- eligibleAgentIds: string[]
2123
- workItemsSource:
2124
- | { type: 'literal'; items: Array<{ id: string; label: string; description?: string | null }> }
2125
- | { type: 'step_output'; stepId: string; path?: string | null }
2126
- claimLimitPerAgent?: number | null
2127
- selectionMode: 'first_claim' | 'claim_until_empty'
2128
- claimTimeoutSec: number
2129
- onUnclaimed: 'fail' | 'advance' | 'fallback_assign'
2130
- }
2131
-
2132
- export interface ProtocolSwarmClaim {
2133
- id: string
2134
- workItemId: string
2135
- workItemLabel: string
2136
- agentId: string
2137
- childRunId?: string | null
2138
- taskId?: string | null
2139
- status: 'claimed' | 'running' | 'completed' | 'failed'
2140
- claimedAt: number
2141
- completedAt?: number | null
2142
- }
2143
-
2144
- export interface ProtocolRunSwarmState {
2145
- stepId: string
2146
- workItems: Array<{ id: string; label: string; description?: string | null }>
2147
- claims: ProtocolSwarmClaim[]
2148
- unclaimedItemIds: string[]
2149
- eligibleAgentIds: string[]
2150
- claimLimitPerAgent: number
2151
- selectionMode: 'first_claim' | 'claim_until_empty'
2152
- claimTimeoutSec: number
2153
- openedAt: number
2154
- closedAt?: number | null
2155
- timedOut?: boolean
2156
- }
2157
-
2158
- export interface ProtocolRunConfig {
2159
- goal?: string | null
2160
- kickoffMessage?: string | null
2161
- roundLimit?: number | null
2162
- decisionMode?: string | null
2163
- createTranscript?: boolean
2164
- autoEmitTasks?: boolean
2165
- taskProjectId?: string | null
2166
- postSummaryToParent?: boolean
2167
- }
2168
-
2169
- export interface ProtocolRun {
2170
- id: string
2171
- title: string
2172
- templateId: string
2173
- templateName: string
2174
- status: ProtocolRunStatus
2175
- sourceRef: ProtocolSourceRef
2176
- participantAgentIds: string[]
2177
- facilitatorAgentId?: string | null
2178
- observerAgentIds?: string[]
2179
- missionId?: string | null
2180
- taskId?: string | null
2181
- sessionId?: string | null
2182
- parentRunId?: string | null
2183
- parentStepId?: string | null
2184
- branchId?: string | null
2185
- parentChatroomId?: string | null
2186
- transcriptChatroomId?: string | null
2187
- scheduleId?: string | null
2188
- systemOwned?: boolean
2189
- phases: ProtocolPhaseDefinition[]
2190
- steps?: ProtocolStepDefinition[]
2191
- entryStepId?: string | null
2192
- currentStepId?: string | null
2193
- config?: ProtocolRunConfig | null
2194
- currentPhaseIndex: number
2195
- roundNumber?: number
2196
- summary?: string | null
2197
- latestArtifactId?: string | null
2198
- artifacts?: ProtocolRunArtifact[]
2199
- createdTaskIds?: string[]
2200
- waitingReason?: string | null
2201
- pauseReason?: string | null
2202
- lastError?: string | null
2203
- operatorContext?: string[]
2204
- phaseState?: ProtocolRunPhaseState | null
2205
- loopState?: Record<string, ProtocolRunLoopState>
2206
- branchHistory?: ProtocolRunBranchDecision[]
2207
- parallelState?: Record<string, ProtocolRunParallelStepState>
2208
- stepState?: Record<string, ProtocolRunStepState>
2209
- completedStepIds?: string[]
2210
- runningStepIds?: string[]
2211
- readyStepIds?: string[]
2212
- failedStepIds?: string[]
2213
- stepOutputs?: Record<string, ProtocolRunStepOutput>
2214
- forEachState?: Record<string, ProtocolRunForEachStepState>
2215
- subflowState?: Record<string, ProtocolRunSubflowState>
2216
- swarmState?: Record<string, ProtocolRunSwarmState>
2217
- createdAt: number
2218
- updatedAt: number
2219
- startedAt?: number | null
2220
- endedAt?: number | null
2221
- archivedAt?: number | null
2222
- }
2223
-
2224
- export interface ProtocolRunEvent {
2225
- id: string
2226
- runId: string
2227
- type:
2228
- | 'created'
2229
- | 'phase_started'
2230
- | 'phase_completed'
2231
- | 'participant_response'
2232
- | 'artifact_emitted'
2233
- | 'task_emitted'
2234
- | 'waiting'
2235
- | 'paused'
2236
- | 'resumed'
2237
- | 'phase_skipped'
2238
- | 'phase_retried'
2239
- | 'context_injected'
2240
- | 'recovered'
2241
- | 'step_started'
2242
- | 'step_completed'
2243
- | 'branch_taken'
2244
- | 'parallel_started'
2245
- | 'parallel_branch_spawned'
2246
- | 'parallel_branch_completed'
2247
- | 'parallel_branch_failed'
2248
- | 'join_ready'
2249
- | 'join_completed'
2250
- | 'loop_iteration_started'
2251
- | 'loop_iteration_completed'
2252
- | 'loop_exhausted'
2253
- | 'completed'
2254
- | 'failed'
2255
- | 'warning'
2256
- | 'cancelled'
2257
- | 'task_dispatched'
2258
- | 'delegation_dispatched'
2259
- | 'archived'
2260
- | 'summary_posted'
2261
- | 'step_ready'
2262
- | 'step_waiting'
2263
- | 'step_failed'
2264
- | 'for_each_expanded'
2265
- | 'subflow_started'
2266
- | 'subflow_completed'
2267
- | 'subflow_failed'
2268
- | 'swarm_opened'
2269
- | 'swarm_claimed'
2270
- | 'swarm_exhausted'
2271
- summary: string
2272
- phaseId?: string | null
2273
- stepId?: string | null
2274
- agentId?: string | null
2275
- artifactId?: string | null
2276
- taskId?: string | null
2277
- createdAt: number
2278
- data?: Record<string, unknown> | null
2279
- }
2280
-
2281
- // --- Activity / Audit Trail ---
2282
-
2283
- export interface ActivityEntry {
2284
- id: string
2285
- entityType: 'agent' | 'task' | 'connector' | 'session' | 'webhook' | 'schedule' | 'delegation' | 'swarm' | 'chatroom' | 'coordination'
2286
- entityId: string
2287
- action: 'created' | 'updated' | 'deleted' | 'started' | 'stopped' | 'queued' | 'completed' | 'failed' | 'archived' | 'restored' | 'approved' | 'rejected' | 'delegated' | 'queried' | 'spawned' | 'timeout' | 'cancelled' | 'incident' | 'running' | 'claimed'
2288
- actor: 'user' | 'agent' | 'system' | 'daemon'
2289
- actorId?: string
2290
- summary: string
2291
- detail?: Record<string, unknown>
2292
- timestamp: number
2293
- }
2294
-
2295
- // --- Webhook Retry Queue ---
2296
-
2297
- export interface WebhookRetryEntry {
2298
- id: string
2299
- webhookId: string
2300
- event: string
2301
- payload: string
2302
- attempts: number
2303
- maxAttempts: number
2304
- nextRetryAt: number
2305
- deadLettered: boolean
2306
- createdAt: number
2307
- }
2308
-
2309
- export interface Project {
2310
- id: string
2311
- name: string
2312
- description: string
2313
- color?: string
2314
- objective?: string
2315
- audience?: string
2316
- priorities?: string[]
2317
- openObjectives?: string[]
2318
- capabilityHints?: string[]
2319
- credentialRequirements?: string[]
2320
- successMetrics?: string[]
2321
- heartbeatPrompt?: string
2322
- heartbeatIntervalSec?: number
2323
- createdAt: number
2324
- updatedAt: number
2325
- }
2326
-
2327
- // --- Notifications ---
2328
-
2329
- export interface AppNotification {
2330
- id: string
2331
- type: 'info' | 'success' | 'warning' | 'error'
2332
- title: string
2333
- message?: string
2334
- actionLabel?: string
2335
- actionUrl?: string
2336
- entityType?: string
2337
- entityId?: string
2338
- dedupKey?: string
2339
- read: boolean
2340
- createdAt: number
2341
- updatedAt?: number
2342
- occurrenceCount?: number
2343
- }
2344
-
2345
- // --- Session Runs ---
2346
-
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'
2365
-
2366
- export interface SessionRunHeartbeatConfig {
2367
- ackMaxChars: number
2368
- showOk: boolean
2369
- showAlerts: boolean
2370
- target: string | null
2371
- deliveryMode?: 'default' | 'tool_only' | 'silent'
2372
- lightContext?: boolean
2373
- }
2374
-
2375
- export interface SessionRunRecoveryPayload {
2376
- message: string
2377
- imagePath?: string
2378
- imageUrl?: string
2379
- attachedFiles?: string[]
2380
- internal: boolean
2381
- source: string
2382
- mode: string
2383
- maxRuntimeMs?: number
2384
- modelOverride?: string
2385
- heartbeatConfig?: SessionRunHeartbeatConfig
2386
- replyToId?: string
2387
- executionGroupKey?: string
2388
- }
2389
-
2390
- export interface SessionRunRecord {
2391
- id: string
2392
- sessionId: string
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'
2399
- source: string
2400
- internal: boolean
2401
- mode: string
2402
- status: SessionRunStatus
2403
- messagePreview: string
2404
- dedupeKey?: string
2405
- queuedAt: number
2406
- startedAt?: number
2407
- endedAt?: number
2408
- interruptedAt?: number
2409
- interruptedReason?: string
2410
- error?: string
2411
- resultPreview?: string
2412
- recoveredFromRestart?: boolean
2413
- recoveredFromRunId?: string
2414
- recoveryPayload?: SessionRunRecoveryPayload
2415
- totalInputTokens?: number
2416
- totalOutputTokens?: number
2417
- estimatedCost?: number
2418
- }
2419
-
2420
- export interface SessionQueuedTurn {
2421
- runId: string
2422
- sessionId: string
2423
- missionId?: string | null
2424
- text: string
2425
- queuedAt: number
2426
- position: number
2427
- imagePath?: string
2428
- imageUrl?: string
2429
- attachedFiles?: string[]
2430
- replyToId?: string
2431
- source?: string
2432
- }
2433
-
2434
- export interface SessionQueueSnapshot {
2435
- sessionId: string
2436
- activeRunId: string | null
2437
- queueLength: number
2438
- items: SessionQueuedTurn[]
2439
- }
2440
-
2441
- export interface RunEventRecord {
2442
- id: string
2443
- runId: string
2444
- sessionId: string
2445
- kind?: ExecutionKind
2446
- ownerType?: ExecutionOwnerType | null
2447
- ownerId?: string | null
2448
- parentExecutionId?: string | null
2449
- timestamp: number
2450
- phase: 'status' | 'event'
2451
- status?: SessionRunStatus
2452
- summary?: string
2453
- event: SSEEvent
2454
- }
2455
-
2456
- export type RuntimeFailureFamily =
2457
- | 'provider_auth'
2458
- | 'provider_transport'
2459
- | 'gateway_disconnected'
2460
- | 'browser_boot'
2461
- | 'cli_missing'
2462
- | 'rate_limit'
2463
- | 'webhook_delivery'
2464
- | 'connector_delivery'
2465
- | 'workspace_recovery'
2466
-
2467
- export type SupervisorIncidentKind =
2468
- | 'run_error'
2469
- | 'repeated_tool'
2470
- | 'no_progress'
2471
- | 'budget_pressure'
2472
- | 'context_pressure'
2473
- | 'runtime_failure'
2474
-
2475
- export type SupervisorIncidentSeverity = 'low' | 'medium' | 'high'
2476
-
2477
- export interface SupervisorIncident {
2478
- id: string
2479
- runId: string
2480
- sessionId: string
2481
- taskId?: string | null
2482
- agentId?: string | null
2483
- source: string
2484
- kind: SupervisorIncidentKind
2485
- severity: SupervisorIncidentSeverity
2486
- summary: string
2487
- details?: string | null
2488
- toolName?: string | null
2489
- failureFamily?: RuntimeFailureFamily | null
2490
- remediation?: string | null
2491
- repairPrompt?: string | null
2492
- autoAction?: 'replan' | 'compact' | 'block' | 'budget_trim' | null
2493
- createdAt: number
2494
- }
2495
-
2496
- export interface RunReflection {
2497
- id: string
2498
- runId: string
2499
- sessionId: string
2500
- taskId?: string | null
2501
- agentId?: string | null
2502
- source: string
2503
- status: SessionRunStatus | 'completed' | 'failed'
2504
- summary: string
2505
- sourceSnippet?: string | null
2506
- invariantNotes: string[]
2507
- derivedNotes: string[]
2508
- failureNotes: string[]
2509
- lessonNotes: string[]
2510
- communicationNotes?: string[]
2511
- relationshipNotes?: string[]
2512
- significantEventNotes?: string[]
2513
- profileNotes?: string[]
2514
- boundaryNotes?: string[]
2515
- openLoopNotes?: string[]
2516
- incidentIds?: string[]
2517
- autoMemoryIds?: string[]
2518
- learnedSkillIds?: string[]
2519
- learnedSkillNotes?: string[]
2520
- qualityScore?: number | null
2521
- qualityReasoning?: string | null
2522
- createdAt: number
2523
- updatedAt: number
2524
- }
2525
-
2526
- // --- Webhook Logs ---
2527
-
2528
- export interface WebhookLogEntry {
2529
- id: string
2530
- webhookId: string
2531
- event: string
2532
- payload: string
2533
- status: 'success' | 'error'
2534
- sessionId?: string
2535
- runId?: string
2536
- error?: string
2537
- timestamp: number
2538
- }
2539
-
2540
- // --- App Settings ---
2541
- export type LoopMode = 'bounded' | 'ongoing'
2542
- export type AutonomyEstopLevel = 'none' | 'autonomy' | 'all'
2543
-
2544
- export interface GoalContract {
2545
- objective: string
2546
- constraints?: string[]
2547
- budgetUsd?: number | null
2548
- deadlineAt?: number | null
2549
- successMetric?: string | null
2550
- }
2551
-
2552
- export interface AppSettings {
2553
- userPrompt?: string
2554
- userName?: string
2555
- setupCompleted?: boolean
2556
- embeddingProvider?: 'local' | 'openai' | 'ollama' | null
2557
- embeddingModel?: string | null
2558
- embeddingCredentialId?: string | null
2559
- embeddingEndpoint?: string | null
2560
- loopMode?: LoopMode
2561
- agentLoopRecursionLimit?: number
2562
- delegationMaxDepth?: number
2563
- ongoingLoopMaxIterations?: number
2564
- ongoingLoopMaxRuntimeMinutes?: number
2565
- maxFollowupChain?: number
2566
- shellCommandTimeoutSec?: number
2567
- claudeCodeTimeoutSec?: number
2568
- cliProcessTimeoutSec?: number
2569
- streamIdleStallSec?: number
2570
- requiredToolKickoffSec?: number
2571
- userAvatarSeed?: string
2572
- elevenLabsEnabled?: boolean
2573
- elevenLabsApiKey?: string | null
2574
- elevenLabsApiKeyConfigured?: boolean
2575
- elevenLabsVoiceId?: string | null
2576
- speechRecognitionLang?: string | null
2577
- tavilyApiKey?: string | null
2578
- tavilyApiKeyConfigured?: boolean
2579
- braveApiKey?: string | null
2580
- braveApiKeyConfigured?: boolean
2581
- heartbeatPrompt?: string | null
2582
- heartbeatIntervalSec?: number | null
2583
- heartbeatInterval?: string | number | null
2584
- heartbeatModel?: string | null
2585
- heartbeatAckMaxChars?: number | null
2586
- heartbeatShowOk?: boolean | null
2587
- heartbeatShowAlerts?: boolean | null
2588
- heartbeatTarget?: 'last' | 'none' | string | null
2589
- heartbeatActiveStart?: string | null
2590
- heartbeatActiveEnd?: string | null
2591
- heartbeatTimezone?: string | null
2592
- heartbeatLightContext?: boolean | null
2593
- sessionResetMode?: SessionResetMode | null
2594
- sessionIdleTimeoutSec?: number | null
2595
- sessionMaxAgeSec?: number | null
2596
- sessionDailyResetAt?: string | null
2597
- sessionResetTimezone?: string | null
2598
- untrustedContentGuardMode?: 'off' | 'warn' | 'block'
2599
- // Task resiliency and supervision
2600
- defaultTaskMaxAttempts?: number
2601
- taskRetryBackoffSec?: number
2602
- taskStallTimeoutMin?: number
2603
- // Safety rails
2604
- safetyRequireApprovalForOutbound?: boolean
2605
- safetyMaxDailySpendUsd?: number | null
2606
- safetyBlockedTools?: string[]
2607
- walletApprovalsEnabled?: boolean
2608
- capabilityPolicyMode?: 'permissive' | 'balanced' | 'strict'
2609
- capabilityBlockedTools?: string[]
2610
- capabilityBlockedCategories?: string[]
2611
- capabilityAllowedTools?: string[]
2612
- taskManagementEnabled?: boolean
2613
- projectManagementEnabled?: boolean
2614
- // Memory governance
2615
- memoryWorkingTtlHours?: number
2616
- memoryDefaultConfidence?: number
2617
- memoryPruneEnabled?: boolean
2618
- memorySummaryEnabled?: boolean
2619
- // Capability router preferences
2620
- autonomyPreferredDelegates?: Array<'claude' | 'codex' | 'opencode'>
2621
- autonomyPreferToolRouting?: boolean
2622
- // Continuous eval
2623
- autonomyEvalEnabled?: boolean
2624
- autonomyEvalCron?: string | null
2625
- supervisorEnabled?: boolean
2626
- supervisorRuntimeScope?: 'chat' | 'task' | 'both'
2627
- supervisorNoProgressLimit?: number
2628
- supervisorRepeatedToolLimit?: number
2629
- autonomyResumeApprovalsEnabled?: boolean
2630
- missionHumanLoopEnabled?: boolean
2631
- reflectionEnabled?: boolean
2632
- reflectionAutoWriteMemory?: boolean
2633
- memoryReferenceDepth?: number
2634
- maxMemoriesPerLookup?: number
2635
- maxLinkedMemoriesExpanded?: number
2636
- memoryMaxDepth?: number
2637
- memoryMaxPerLookup?: number
2638
- // Chat UX
2639
- suggestionsEnabled?: boolean
2640
- runtimeSkillRetrievalMode?: 'keyword' | 'embedding'
2641
- runtimeSkillTopK?: number
2642
- // Globally approved WhatsApp contacts for connector DMs
2643
- whatsappApprovedContacts?: WhatsAppApprovedContact[]
2644
- // Voice conversation
2645
- voiceAutoSendDelaySec?: number
2646
- // Default agent for main chat on startup
2647
- defaultAgentId?: string | null
2648
- // Theme
2649
- themeHue?: string
2650
- // Web search provider
2651
- webSearchProvider?: 'duckduckgo' | 'google' | 'bing' | 'searxng' | 'tavily' | 'brave'
2652
- searxngUrl?: string
2653
- // Task custom field definitions
2654
- taskCustomFieldDefs?: Array<{ key: string; label: string; type: 'text' | 'number' | 'select'; options?: string[] }>
2655
- // OpenClaw sync settings
2656
- openclawWorkspacePath?: string | null
2657
- openclawAutoSyncMemory?: boolean
2658
- openclawAutoSyncSchedules?: boolean
2659
- // Outbound ops alert webhook
2660
- alertWebhookUrl?: string | null
2661
- alertWebhookType?: 'discord' | 'slack' | 'custom' | null
2662
- alertWebhookEvents?: ('error' | 'warning')[]
2663
- // Deterministic LLM response cache
2664
- responseCacheEnabled?: boolean
2665
- responseCacheTtlSec?: number
2666
- responseCacheMaxEntries?: number
2667
- // Task quality gate defaults
2668
- taskQualityGateEnabled?: boolean
2669
- taskQualityGateMinResultChars?: number
2670
- taskQualityGateMinEvidenceItems?: number
2671
- taskQualityGateRequireVerification?: boolean
2672
- taskQualityGateRequireArtifact?: boolean
2673
- taskQualityGateRequireReport?: boolean
2674
- // Integrity monitor
2675
- integrityMonitorEnabled?: boolean
2676
- // Background daemon
2677
- daemonAutostartEnabled?: boolean
2678
- // Tool loop detection thresholds
2679
- toolLoopFrequencyWarn?: number
2680
- toolLoopFrequencyCritical?: number
2681
- toolLoopCircuitBreaker?: number
2682
- // Per-extension settings (keyed by extensionId)
2683
- extensionSettings?: Record<string, Record<string, unknown>>
2684
- }
2685
-
2686
- export interface WhatsAppApprovedContact {
2687
- id: string
2688
- label: string
2689
- phone: string
2690
- }
2691
-
2692
- // --- Agent Secrets ---
2693
-
2694
- export interface StoredSecret {
2695
- id: string
2696
- name: string
2697
- service: string // e.g. 'gmail', 'ahrefs', 'custom'
2698
- encryptedValue: string
2699
- scope: 'global' | 'agent'
2700
- agentIds: string[] // if scope === 'agent', which agents can use it
2701
- projectId?: string
2702
- createdAt: number
2703
- updatedAt: number
2704
- }
2705
-
2706
- // --- Task Board ---
2707
-
2708
- export type BoardTaskStatus = 'backlog' | 'queued' | 'running' | 'completed' | 'failed' | 'cancelled' | 'archived' | 'deferred'
2709
-
2710
- export interface TaskComment {
2711
- id: string
2712
- author: string // agent name or 'user'
2713
- agentId?: string // if from an agent
2714
- text: string
2715
- createdAt: number
2716
- }
2717
-
2718
- export interface TaskQualityGateConfig {
2719
- enabled?: boolean
2720
- minResultChars?: number
2721
- minEvidenceItems?: number
2722
- requireVerification?: boolean
2723
- requireArtifact?: boolean
2724
- requireReport?: boolean
2725
- }
2726
-
2727
- // --- Custom Providers ---
2728
-
2729
- export interface ProviderConfig {
2730
- id: string
2731
- name: string
2732
- type: 'builtin' | 'custom'
2733
- baseUrl?: string
2734
- models: string[]
2735
- requiresApiKey: boolean
2736
- credentialId?: string | null
2737
- isEnabled: boolean
2738
- createdAt: number
2739
- updatedAt: number
2740
- }
2741
-
2742
- // --- Gateways ---
2743
-
2744
- export type GatewayProvider = 'openclaw'
2745
- export type GatewayHealthState = 'unknown' | 'healthy' | 'degraded' | 'offline' | 'pending'
2746
- export type OpenClawDeploymentMethod = 'local' | 'bundle' | 'ssh' | 'imported'
2747
- export type OpenClawDeploymentProvider =
2748
- | 'local'
2749
- | 'hetzner'
2750
- | 'digitalocean'
2751
- | 'vultr'
2752
- | 'linode'
2753
- | 'lightsail'
2754
- | 'gcp'
2755
- | 'azure'
2756
- | 'oci'
2757
- | 'generic'
2758
- | 'render'
2759
- | 'fly'
2760
- | 'railway'
2761
- export type OpenClawRemoteDeployTarget = 'docker' | 'render' | 'fly' | 'railway'
2762
- export type OpenClawUseCaseTemplate = 'local-dev' | 'single-vps' | 'private-tailnet' | 'browser-heavy' | 'team-control'
2763
- export type OpenClawExposurePreset = 'private-lan' | 'tailscale' | 'caddy' | 'nginx' | 'ssh-tunnel'
2764
-
2765
- export interface OpenClawGatewayStats {
2766
- nodeCount?: number
2767
- connectedNodeCount?: number
2768
- pendingNodePairings?: number
2769
- pairedDeviceCount?: number
2770
- pendingDevicePairings?: number
2771
- externalRuntimeCount?: number
2772
- }
2773
-
2774
- export interface OpenClawDeploymentConfig {
2775
- method?: OpenClawDeploymentMethod | null
2776
- provider?: OpenClawDeploymentProvider | null
2777
- remoteTarget?: OpenClawRemoteDeployTarget | null
2778
- useCase?: OpenClawUseCaseTemplate | null
2779
- exposure?: OpenClawExposurePreset | null
2780
- managedBy?: 'swarmclaw' | 'manual' | null
2781
- localInstanceId?: string | null
2782
- localPort?: number | null
2783
- targetHost?: string | null
2784
- sshHost?: string | null
2785
- sshUser?: string | null
2786
- sshPort?: number | null
2787
- sshKeyPath?: string | null
2788
- sshTargetDir?: string | null
2789
- image?: string | null
2790
- version?: string | null
2791
- lastDeployAt?: number | null
2792
- lastDeployAction?: string | null
2793
- lastDeployProcessId?: string | null
2794
- lastDeploySummary?: string | null
2795
- lastVerifiedAt?: number | null
2796
- lastVerifiedOk?: boolean | null
2797
- lastVerifiedMessage?: string | null
2798
- lastBackupPath?: string | null
2799
- }
2800
-
2801
- export interface GatewayProfile {
2802
- id: string
2803
- name: string
2804
- provider: GatewayProvider
2805
- endpoint: string
2806
- wsUrl?: string | null
2807
- credentialId?: string | null
2808
- status: GatewayHealthState
2809
- notes?: string | null
2810
- tags?: string[]
2811
- lastError?: string | null
2812
- lastCheckedAt?: number | null
2813
- lastModelCount?: number | null
2814
- discoveredHost?: string | null
2815
- discoveredPort?: number | null
2816
- deployment?: OpenClawDeploymentConfig | null
2817
- stats?: OpenClawGatewayStats | null
2818
- isDefault?: boolean
2819
- createdAt: number
2820
- updatedAt: number
2821
- }
2822
-
2823
- export interface OpenClawNode {
2824
- nodeId: string
2825
- displayName?: string
2826
- platform?: string
2827
- version?: string
2828
- coreVersion?: string
2829
- uiVersion?: string
2830
- deviceFamily?: string
2831
- modelIdentifier?: string
2832
- remoteIp?: string
2833
- caps?: string[]
2834
- commands?: string[]
2835
- pathEnv?: string[]
2836
- permissions?: string[]
2837
- connectedAtMs?: number
2838
- paired?: boolean
2839
- connected?: boolean
2840
- }
2841
-
2842
- export interface OpenClawNodePairRequest {
2843
- requestId: string
2844
- nodeId?: string
2845
- displayName?: string
2846
- platform?: string
2847
- remoteIp?: string
2848
- createdAtMs?: number
2849
- }
2850
-
2851
- export interface OpenClawPairedDevice {
2852
- deviceId: string
2853
- displayName?: string
2854
- role?: string
2855
- remoteIp?: string
2856
- platform?: string
2857
- tokens?: Array<{ role?: string; scopes?: string[]; createdAtMs?: number; rotatedAtMs?: number; revokedAtMs?: number }>
2858
- }
2859
-
2860
- export interface OpenClawDevicePairRequest {
2861
- requestId: string
2862
- deviceId?: string
2863
- displayName?: string
2864
- role?: string
2865
- platform?: string
2866
- remoteIp?: string
2867
- createdAtMs?: number
2868
- }
2869
-
2870
- export interface OpenClawPairingSnapshot {
2871
- pending?: OpenClawDevicePairRequest[]
2872
- paired?: OpenClawPairedDevice[]
2873
- }
2874
-
2875
- // --- Agent Routing / Packs ---
2876
-
2877
- export type AgentRoutingStrategy = 'single' | 'balanced' | 'economy' | 'premium' | 'reasoning'
2878
- export type AgentRoutingTargetRole = 'primary' | 'economy' | 'premium' | 'reasoning' | 'backup'
2879
-
2880
- export interface AgentRoutingTarget {
2881
- id: string
2882
- label?: string
2883
- role?: AgentRoutingTargetRole
2884
- provider: ProviderId
2885
- model: string
2886
- ollamaMode?: OllamaMode | null
2887
- credentialId?: string | null
2888
- fallbackCredentialIds?: string[]
2889
- apiEndpoint?: string | null
2890
- gatewayProfileId?: string | null
2891
- preferredGatewayTags?: string[]
2892
- preferredGatewayUseCase?: string | null
2893
- priority?: number
2894
- }
2895
-
2896
- export interface AgentPackEntry {
2897
- id: string
2898
- name: string
2899
- description?: string
2900
- provider: ProviderId
2901
- model: string
2902
- ollamaMode?: OllamaMode | null
2903
- credentialId?: string | null
2904
- fallbackCredentialIds?: string[]
2905
- apiEndpoint?: string | null
2906
- gatewayProfileId?: string | null
2907
- routingStrategy?: AgentRoutingStrategy | null
2908
- routingTargets?: AgentRoutingTarget[]
2909
- tools?: string[]
2910
- extensions?: string[]
2911
- capabilities?: string[]
2912
- elevenLabsVoiceId?: string | null
2913
- soul?: string
2914
- systemPrompt?: string
2915
- }
2916
-
2917
- export interface AgentPackManifest {
2918
- schemaVersion: 1
2919
- kind: 'swarmclaw-agent-pack'
2920
- name: string
2921
- description?: string
2922
- exportedAt: number
2923
- recommendedProviders?: ProviderType[]
2924
- agents: AgentPackEntry[]
2925
- }
2926
-
2927
- // --- External Agents ---
2928
-
2929
- export type ExternalAgentSourceType = 'codex' | 'claude' | 'opencode' | 'openclaw' | 'custom'
2930
- export type ExternalAgentStatus = 'online' | 'idle' | 'offline' | 'stale'
2931
-
2932
- export interface ExternalAgentRuntime {
2933
- id: string
2934
- name: string
2935
- sourceType: ExternalAgentSourceType
2936
- status: ExternalAgentStatus
2937
- provider?: ProviderId | null
2938
- model?: string | null
2939
- workspace?: string | null
2940
- transport?: 'http' | 'ws' | 'cli' | 'gateway' | 'custom' | null
2941
- endpoint?: string | null
2942
- agentId?: string | null
2943
- gatewayProfileId?: string | null
2944
- capabilities?: string[]
2945
- labels?: string[]
2946
- lifecycleState?: 'active' | 'draining' | 'cordoned'
2947
- gatewayTags?: string[]
2948
- gatewayUseCase?: string | null
2949
- version?: string | null
2950
- lastHealthNote?: string | null
2951
- metadata?: Record<string, unknown> | null
2952
- tokenStats?: {
2953
- inputTokens?: number
2954
- outputTokens?: number
2955
- totalTokens?: number
2956
- } | null
2957
- lastHeartbeatAt?: number | null
2958
- lastSeenAt?: number | null
2959
- createdAt: number
2960
- updatedAt: number
2961
- }
2962
-
2963
- // --- Skills ---
2964
-
2965
- export interface Skill {
2966
- id: string
2967
- name: string
2968
- filename: string
2969
- content: string
2970
- projectId?: string
2971
- description?: string
2972
- sourceUrl?: string
2973
- sourceFormat?: 'openclaw' | 'plain'
2974
- author?: string
2975
- tags?: string[]
2976
- version?: string
2977
- homepage?: string
2978
- primaryEnv?: string | null
2979
- skillKey?: string | null
2980
- toolNames?: string[]
2981
- capabilities?: string[]
2982
- always?: boolean
2983
- installOptions?: SkillInstallOption[]
2984
- skillRequirements?: SkillRequirements
2985
- detectedEnvVars?: string[]
2986
- security?: SkillSecuritySummary | null
2987
- invocation?: SkillInvocationConfig | null
2988
- commandDispatch?: SkillCommandDispatch | null
2989
- frontmatter?: Record<string, unknown> | null
2990
- scope?: 'global' | 'agent'
2991
- agentIds?: string[]
2992
- createdAt: number
2993
- updatedAt: number
2994
- }
2995
-
2996
- export type LearnedSkillScope = 'agent' | 'session'
2997
- export type LearnedSkillLifecycle = 'candidate' | 'active' | 'shadow' | 'demoted' | 'review_ready'
2998
- export type LearnedSkillSourceKind = 'success_pattern' | 'failure_repair'
2999
- export type LearnedSkillValidationStatus = 'pending' | 'passed' | 'failed'
3000
- export type LearnedSkillRiskLevel = 'low' | 'medium' | 'high'
3001
-
3002
- export interface LearnedSkill {
3003
- id: string
3004
- parentSkillId?: string | null
3005
- agentId: string
3006
- userId?: string | null
3007
- sessionId?: string | null
3008
- scope: LearnedSkillScope
3009
- lifecycle: LearnedSkillLifecycle
3010
- sourceKind: LearnedSkillSourceKind
3011
- workflowKey: string
3012
- failureFamily?: string | null
3013
- objectiveSummary?: string | null
3014
- name?: string | null
3015
- description?: string | null
3016
- content?: string | null
3017
- tags?: string[]
3018
- rationale?: string | null
3019
- confidence?: number | null
3020
- riskLevel?: LearnedSkillRiskLevel | null
3021
- validationStatus: LearnedSkillValidationStatus
3022
- validationSummary?: string | null
3023
- validationEvidenceCount?: number
3024
- evidenceCount?: number
3025
- activationCount?: number
3026
- successCount?: number
3027
- failureCount?: number
3028
- consecutiveSuccessCount?: number
3029
- consecutiveFailureCount?: number
3030
- lastSourceHash?: string | null
3031
- lastUsedAt?: number | null
3032
- lastSucceededAt?: number | null
3033
- lastFailedAt?: number | null
3034
- demotedAt?: number | null
3035
- demotionReason?: string | null
3036
- retryUnlockedAt?: number | null
3037
- retryUnlockedByReflectionId?: string | null
3038
- retryUnlockedBySkillId?: string | null
3039
- reviewReadyAt?: number | null
3040
- sourceSessionName?: string | null
3041
- sourceSnippet?: string | null
3042
- lastRefinedAt?: number | null
3043
- refinementCount?: number
3044
- createdAt: number
3045
- updatedAt: number
3046
- }
3047
-
3048
- export type SkillSuggestionStatus = 'draft' | 'approved' | 'rejected'
3049
-
3050
- export interface SkillSuggestion {
3051
- id: string
3052
- status: SkillSuggestionStatus
3053
- sourceSessionId: string
3054
- sourceSessionName?: string | null
3055
- sourceAgentId?: string | null
3056
- sourceAgentName?: string | null
3057
- sourceHash?: string | null
3058
- sourceMessageCount?: number | null
3059
- name: string
3060
- description?: string
3061
- content: string
3062
- tags?: string[]
3063
- confidence?: number | null
3064
- rationale?: string | null
3065
- summary?: string | null
3066
- sourceSnippet?: string | null
3067
- createdSkillId?: string | null
3068
- approvedAt?: number | null
3069
- rejectedAt?: number | null
3070
- createdAt: number
3071
- updatedAt: number
3072
- }
3073
-
3074
- export interface SkillInvocationConfig {
3075
- userInvocable?: boolean
3076
- }
3077
-
3078
- export interface SkillCommandDispatch {
3079
- kind: 'tool'
3080
- toolName: string
3081
- argMode?: 'raw'
3082
- }
3083
-
3084
- export interface SkillAuditFinding {
3085
- severity: 'warning' | 'error'
3086
- code: string
3087
- message: string
3088
- path?: string
3089
- }
3090
-
3091
- export interface SkillAuditResult {
3092
- status: 'pass' | 'warn' | 'block'
3093
- findings: SkillAuditFinding[]
3094
- }
3095
-
3096
- export interface SkillSecuritySummary {
3097
- level: 'low' | 'medium' | 'high'
3098
- notes: string[]
3099
- detectedEnvVars?: string[]
3100
- missingDeclarations?: string[]
3101
- installCommands?: string[]
3102
- }
3103
-
3104
- export interface EstopState {
3105
- level: AutonomyEstopLevel
3106
- reason?: string | null
3107
- engagedAt?: number | null
3108
- engagedBy?: string | null
3109
- resumeApprovalId?: string | null
3110
- updatedAt: number
3111
- }
3112
-
3113
- export interface GuardianCheckpoint {
3114
- id: string
3115
- cwd: string
3116
- head: string
3117
- branch?: string | null
3118
- status: string
3119
- createdAt: number
3120
- createdBy: string
3121
- approvalId?: string | null
3122
- restorePreparedAt?: number | null
3123
- restoredAt?: number | null
3124
- }
3125
-
3126
- // --- Connector Health Events ---
3127
-
3128
- export type ConnectorHealthEventType = 'started' | 'stopped' | 'error' | 'reconnected' | 'disconnected'
3129
-
3130
- export interface ConnectorHealthEvent {
3131
- id: string
3132
- connectorId: string
3133
- event: ConnectorHealthEventType
3134
- message?: string
3135
- timestamp: string
3136
- }
3137
-
3138
- // --- Connectors (Chat Platform Bridges) ---
3139
-
3140
- export type ConnectorPlatform =
3141
- | 'discord'
3142
- | 'telegram'
3143
- | 'slack'
3144
- | 'whatsapp'
3145
- | 'openclaw'
3146
- | 'bluebubbles'
3147
- | 'signal'
3148
- | 'teams'
3149
- | 'googlechat'
3150
- | 'matrix'
3151
- | 'email'
3152
- | 'webchat'
3153
- | 'mockmail'
3154
- export type ConnectorStatus = 'stopped' | 'running' | 'error'
3155
-
3156
- export interface MessageSource {
3157
- platform: ConnectorPlatform
3158
- connectorId: string
3159
- connectorName: string
3160
- channelId?: string
3161
- senderId?: string
3162
- senderName?: string
3163
- messageId?: string
3164
- replyToMessageId?: string
3165
- threadId?: string
3166
- deliveryMode?: 'text' | 'voice_note'
3167
- deliveryTranscript?: string | null
3168
- }
3169
-
3170
- export interface Connector {
3171
- id: string
3172
- name: string
3173
- platform: ConnectorPlatform
3174
- agentId?: string | null // which agent handles incoming messages (optional if using chatroomId)
3175
- chatroomId?: string | null // route to a chatroom instead of a single agent
3176
- credentialId?: string | null // bot token stored as encrypted credential
3177
- config: Record<string, string> // platform-specific settings
3178
- isEnabled: boolean
3179
- status: ConnectorStatus
3180
- lastError?: string | null
3181
- /** WhatsApp QR code data URL (runtime only) */
3182
- qrDataUrl?: string | null
3183
- /** WhatsApp authenticated/paired state (runtime only) */
3184
- authenticated?: boolean
3185
- /** WhatsApp has stored credentials from previous pairing (runtime only) */
3186
- hasCredentials?: boolean
3187
- /** Connector presence info (runtime only) */
3188
- presence?: { lastMessageAt?: number | null; channelId?: string | null }
3189
- createdAt: number
3190
- updatedAt: number
3191
- }
3192
-
3193
- export type ConnectorDmAddressingMode = 'open' | 'addressed'
3194
-
3195
- export interface ConnectorAccessSenderStatus {
3196
- senderIds: string[]
3197
- isOwnerOverride: boolean
3198
- isBlocked: boolean
3199
- isApproved: boolean
3200
- isConfigAllowed: boolean
3201
- isStoredAllowed: boolean
3202
- isGlobalAllowed: boolean
3203
- isPending: boolean
3204
- pendingCode?: string | null
3205
- dmAddressingOverride: ConnectorDmAddressingMode | null
3206
- effectiveDmAddressingMode: ConnectorDmAddressingMode
3207
- requiresDirectAddress: boolean
3208
- }
3209
-
3210
- export interface ConnectorAccessSnapshot {
3211
- connectorId: string
3212
- platform: ConnectorPlatform
3213
- dmPolicy: 'open' | 'allowlist' | 'pairing' | 'disabled'
3214
- dmAddressingMode: ConnectorDmAddressingMode
3215
- allowFrom: string[]
3216
- denyFrom: string[]
3217
- ownerSenderId: string | null
3218
- storedAllowedSenderIds: string[]
3219
- senderAddressingOverrides: Array<{
3220
- senderId: string
3221
- dmAddressingMode: ConnectorDmAddressingMode
3222
- }>
3223
- pendingPairingRequests: Array<{
3224
- code: string
3225
- senderId: string
3226
- senderName?: string
3227
- channelId?: string
3228
- createdAt: number
3229
- updatedAt: number
3230
- }>
3231
- globalWhatsAppApprovedContacts: WhatsAppApprovedContact[]
3232
- senderStatus?: ConnectorAccessSenderStatus | null
3233
- }
3234
-
3235
- export type ConnectorAccessMutationAction =
3236
- | 'set_policy'
3237
- | 'set_dm_addressing_mode'
3238
- | 'allow_sender'
3239
- | 'remove_allowed_sender'
3240
- | 'block_sender'
3241
- | 'unblock_sender'
3242
- | 'approve_pairing'
3243
- | 'reject_pairing'
3244
- | 'set_owner'
3245
- | 'clear_owner'
3246
- | 'set_sender_dm_addressing'
3247
- | 'clear_sender_dm_addressing'
3248
-
3249
- export interface ConnectorAccessMutationResponse {
3250
- ok: boolean
3251
- snapshot: ConnectorAccessSnapshot
3252
- }
3253
-
3254
- export interface Webhook {
3255
- id: string
3256
- name: string
3257
- source: string
3258
- events: string[]
3259
- agentId?: string | null
3260
- secret?: string
3261
- isEnabled: boolean
3262
- createdAt: number
3263
- updatedAt: number
3264
- }
3265
-
3266
- export interface DocumentRevision {
3267
- id: string
3268
- documentId: string
3269
- version: number
3270
- content: string
3271
- createdAt: number
3272
- createdBy?: string | null
3273
- }
3274
-
3275
- export interface DocumentEntry {
3276
- id: string
3277
- title: string
3278
- fileName: string
3279
- sourcePath: string
3280
- content: string
3281
- method: string
3282
- textLength: number
3283
- currentVersion?: number
3284
- metadata?: Record<string, unknown>
3285
- createdAt: number
3286
- updatedAt: number
3287
- }
3288
-
3289
- export interface BoardTask {
3290
- id: string
3291
- title: string
3292
- description: string
3293
- status: BoardTaskStatus
3294
- agentId: string
3295
- missionId?: string | null
3296
- protocolRunId?: string | null
3297
- missionSummary?: MissionSummary | null
3298
- projectId?: string
3299
- goalContract?: GoalContract | null
3300
- cwd?: string | null
3301
- file?: string | null
3302
- sessionId?: string | null
3303
- completionReportPath?: string | null
3304
- result?: string | null
3305
- error?: string | null
3306
- outputFiles?: string[]
3307
- artifacts?: Array<{
3308
- url: string
3309
- type: 'image' | 'video' | 'pdf' | 'file'
3310
- filename: string
3311
- }>
3312
- comments?: TaskComment[]
3313
- images?: string[]
3314
- createdByAgentId?: string | null
3315
- createdInSessionId?: string | null
3316
- followupConnectorId?: string | null
3317
- followupChannelId?: string | null
3318
- followupThreadId?: string | null
3319
- followupSenderId?: string | null
3320
- followupSenderName?: string | null
3321
- delegatedByAgentId?: string | null
3322
- delegatedFromTaskId?: string | null
3323
- delegationDepth?: number | null
3324
- createdAt: number
3325
- updatedAt: number
3326
- queuedAt?: number | null
3327
- startedAt?: number | null
3328
- completedAt?: number | null
3329
- archivedAt?: number | null
3330
- attempts?: number
3331
- maxAttempts?: number
3332
- retryBackoffSec?: number
3333
- retryScheduledAt?: number | null
3334
- runNumber?: number
3335
- totalRuns?: number
3336
- totalCompleted?: number
3337
- totalFailed?: number
3338
- sourceType?: 'schedule' | 'delegation' | 'manual' | 'import'
3339
- sourceScheduleId?: string | null
3340
- sourceScheduleName?: string | null
3341
- sourceScheduleKey?: string | null
3342
- externalSource?: {
3343
- source: string
3344
- id?: string | null
3345
- repo?: string | null
3346
- number?: number | null
3347
- state?: string | null
3348
- labels?: string[]
3349
- assignee?: string | null
3350
- url?: string | null
3351
- } | null
3352
- lastActivityAt?: number | null
3353
- deferredReason?: string | null
3354
- deadLetteredAt?: number | null
3355
- cliResumeId?: string | null
3356
- cliProvider?: string | null
3357
- claudeResumeId?: string | null
3358
- codexResumeId?: string | null
3359
- opencodeResumeId?: string | null
3360
- geminiResumeId?: string | null
3361
- checkpoint?: {
3362
- lastRunId?: string | null
3363
- lastSessionId?: string | null
3364
- note?: string | null
3365
- updatedAt: number
3366
- } | null
3367
- validation?: {
3368
- ok: boolean
3369
- reasons: string[]
3370
- checkedAt: number
3371
- } | null
3372
- // Parent/child task hierarchy (user-created subtasks)
3373
- parentTaskId?: string | null
3374
- subtaskIds?: string[]
3375
- // Task dependencies (DAG)
3376
- blockedBy?: string[]
3377
- blocks?: string[]
3378
- // Task tags
3379
- tags?: string[]
3380
- // Due date
3381
- dueAt?: number | null
3382
- // Custom fields
3383
- customFields?: Record<string, string | number | boolean>
3384
- // Priority
3385
- priority?: 'low' | 'medium' | 'high' | 'critical'
3386
- // Dedup fingerprint
3387
- fingerprint?: string
3388
- qualityGate?: TaskQualityGateConfig | null
3389
- // Competitive task claiming (pool mode)
3390
- assignmentMode?: 'direct' | 'pool'
3391
- poolCandidateAgentIds?: string[]
3392
- claimedByAgentId?: string | null
3393
- claimedAt?: number | null
3394
- requiredCapabilities?: string[]
3395
- // Upstream task results (populated by cascadeUnblock when dependencies complete)
3396
- upstreamResults?: Array<{
3397
- taskId: string
3398
- taskTitle: string
3399
- agentId: string | null
3400
- resultPreview: string | null
3401
- }>
3402
- repairRunId?: string | null
3403
- lastRepairAttemptAt?: number | null
3404
- }
3405
-
3406
- // --- MCP Servers ---
3407
-
3408
- export type McpTransport = 'stdio' | 'sse' | 'streamable-http'
3409
-
3410
- export interface McpServerConfig {
3411
- id: string
3412
- name: string
3413
- transport: McpTransport
3414
- command?: string // for stdio transport
3415
- args?: string[] // for stdio transport
3416
- url?: string // for sse/streamable-http transport
3417
- env?: Record<string, string> // environment variables
3418
- headers?: Record<string, string> // HTTP headers for sse/streamable-http
3419
- createdAt: number
3420
- updatedAt: number
3421
- }
3422
-
3423
- // --- ClawHub ---
3424
-
3425
- export interface ClawHubSkill {
3426
- id: string
3427
- name: string
3428
- description: string
3429
- author: string
3430
- tags: string[]
3431
- downloads: number
3432
- stars?: number
3433
- url: string
3434
- version: string
3435
- changelog?: string
3436
- createdAt?: number
3437
- updatedAt?: number
3438
- metadata?: Record<string, unknown> | null
3439
- }
3440
-
3441
- // --- OpenClaw Execution Approvals ---
3442
-
3443
- export interface PendingExecApproval {
3444
- id: string
3445
- agentId: string
3446
- sessionKey: string
3447
- command: string
3448
- cwd?: string
3449
- host?: string
3450
- security?: string
3451
- ask?: string
3452
- createdAtMs: number
3453
- expiresAtMs: number
3454
- resolving?: boolean
3455
- error?: string
3456
- }
3457
-
3458
- export type ExecApprovalDecision = 'allow-once' | 'allow-always' | 'deny'
3459
-
3460
- // --- OpenClaw Skills ---
3461
-
3462
- export interface OpenClawSkillEntry {
3463
- name: string
3464
- description?: string
3465
- source: 'bundled' | 'managed' | 'personal' | 'workspace'
3466
- eligible: boolean
3467
- requirements?: string[]
3468
- missing?: string[]
3469
- disabled?: boolean
3470
- installOptions?: SkillInstallOption[]
3471
- skillRequirements?: SkillRequirements
3472
- configChecks?: { key: string; ok: boolean }[]
3473
- skillKey?: string
3474
- baseDir?: string
3475
- }
3476
-
3477
- export type SkillAllowlistMode = 'all' | 'none' | 'selected'
3478
-
3479
- // --- Fleet Sidebar Filters (F16) ---
3480
- export type FleetFilter = 'all' | 'running' | 'approvals'
3481
-
3482
- // --- Exec Approval Config (F8) ---
3483
- export interface ExecApprovalConfig {
3484
- security: 'deny' | 'allowlist' | 'full'
3485
- askMode: 'off' | 'on-miss' | 'always'
3486
- patterns: string[]
3487
- }
3488
-
3489
- export interface ExecApprovalSnapshot {
3490
- path: string
3491
- exists: boolean
3492
- hash: string
3493
- file: ExecApprovalConfig
3494
- }
3495
-
3496
- // --- Permission Presets (F9) ---
3497
- export type PermissionPreset = 'conservative' | 'collaborative' | 'autonomous'
3498
-
3499
- // --- Personality Builder (F10) ---
3500
- export interface PersonalityDraft {
3501
- identity: { name?: string; creature?: string; vibe?: string; emoji?: string }
3502
- user: { name?: string; callThem?: string; pronouns?: string; timezone?: string; notes?: string; context?: string }
3503
- soul: { coreTruths?: string; boundaries?: string; vibe?: string; continuity?: string }
3504
- }
3505
-
3506
- // --- Skill Lifecycle (F11) ---
3507
- export interface SkillInstallOption {
3508
- kind: 'brew' | 'node' | 'go' | 'uv' | 'download'
3509
- label: string
3510
- bins?: string[]
3511
- }
3512
-
3513
- export interface SkillRequirements {
3514
- bins?: string[]
3515
- anyBins?: string[][]
3516
- env?: string[]
3517
- config?: string[]
3518
- os?: string[]
3519
- }
3520
-
3521
- // --- Cron Jobs (F12) ---
3522
- export interface GatewayCronJob {
3523
- id: string
3524
- name: string
3525
- agentId: string
3526
- enabled: boolean
3527
- schedule: { kind: 'at' | 'every' | 'cron'; value: string; timezone?: string }
3528
- payload: {
3529
- kind: 'systemEvent' | 'agentTurn'
3530
- text?: string
3531
- message?: string
3532
- model?: string
3533
- deliver?: { mode: 'none' | 'announce'; channel?: string }
3534
- }
3535
- sessionTarget: 'main' | 'isolated'
3536
- state?: { nextRun?: string; lastRun?: string; lastStatus?: string }
3537
- }
3538
-
3539
- // --- Rich Chat Traces (F13) ---
3540
- export interface ChatTraceBlock {
3541
- type: 'thinking' | 'tool-call' | 'tool-result'
3542
- content: string
3543
- label?: string
3544
- collapsed?: boolean
3545
- }
3546
-
3547
- // --- Chat History Sync (F18) ---
3548
- export interface GatewaySessionPreview {
3549
- sessionKey: string
3550
- epoch: number
3551
- messages: Array<{ role: string; content: string; ts: number }>
3552
- }
3553
-
3554
- // --- Gateway Reload Mode (F21) ---
3555
- export type GatewayReloadMode = 'hot' | 'hybrid' | 'full'
1
+ export * from './message'
2
+ export * from './session'
3
+ export * from './agent'
4
+ export * from './working-state'
5
+ export * from './extension'
6
+ export * from './connector'
7
+ export * from './provider'
8
+ export * from './task'
9
+ export * from './schedule'
10
+ export * from './protocol'
11
+ export * from './app-settings'
12
+ export * from './skill'
13
+ export * from './run'
14
+ export * from './approval'
15
+ export * from './misc'
16
+ export * from './swarmdock'