@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
@@ -0,0 +1,420 @@
1
+ import type { MessageToolEvent } from './message'
2
+
3
+ // --- Structured Session Runs / Protocols ---
4
+
5
+ export type ProtocolRunStatus = 'draft' | 'running' | 'waiting' | 'paused' | 'completed' | 'failed' | 'cancelled' | 'archived'
6
+
7
+ export type ProtocolPhaseKind =
8
+ | 'present'
9
+ | 'collect_independent_inputs'
10
+ | 'round_robin'
11
+ | 'compare'
12
+ | 'decide'
13
+ | 'summarize'
14
+ | 'emit_tasks'
15
+ | 'wait'
16
+ | 'dispatch_task'
17
+ | 'dispatch_delegation'
18
+
19
+ export interface ProtocolPhaseDefinition {
20
+ id: string
21
+ kind: ProtocolPhaseKind
22
+ label: string
23
+ instructions?: string | null
24
+ turnLimit?: number | null
25
+ completionCriteria?: string | null
26
+ taskConfig?: { agentId?: string; title: string; description: string } | null
27
+ delegationConfig?: { agentId: string; message: string } | null
28
+ }
29
+
30
+ export type ProtocolConditionDefinition =
31
+ | { type: 'summary_exists' }
32
+ | { type: 'artifact_exists'; artifactKind?: ProtocolRunArtifact['kind'] | null }
33
+ | { type: 'artifact_count_at_least'; count: number; artifactKind?: ProtocolRunArtifact['kind'] | null }
34
+ | { type: 'created_task_count_at_least'; count: number }
35
+ | { type: 'all'; conditions: ProtocolConditionDefinition[] }
36
+ | { type: 'any'; conditions: ProtocolConditionDefinition[] }
37
+
38
+ export interface ProtocolBranchCase {
39
+ id: string
40
+ label: string
41
+ nextStepId: string
42
+ description?: string | null
43
+ when?: ProtocolConditionDefinition | null
44
+ }
45
+
46
+ export interface ProtocolRepeatConfig {
47
+ bodyStepId: string
48
+ nextStepId?: string | null
49
+ maxIterations: number
50
+ exitCondition?: ProtocolConditionDefinition | null
51
+ onExhausted?: 'advance' | 'fail'
52
+ }
53
+
54
+ export interface ProtocolParallelBranchDefinition {
55
+ id: string
56
+ label: string
57
+ steps: ProtocolStepDefinition[]
58
+ entryStepId?: string | null
59
+ participantAgentIds?: string[]
60
+ facilitatorAgentId?: string | null
61
+ observerAgentIds?: string[]
62
+ }
63
+
64
+ export interface ProtocolParallelConfig {
65
+ branches: ProtocolParallelBranchDefinition[]
66
+ }
67
+
68
+ export interface ProtocolJoinConfig {
69
+ parallelStepId?: string | null
70
+ }
71
+
72
+ export type ProtocolStepKind =
73
+ | ProtocolPhaseKind
74
+ | 'branch'
75
+ | 'repeat'
76
+ | 'parallel'
77
+ | 'join'
78
+ | 'complete'
79
+ | 'for_each'
80
+ | 'subflow'
81
+ | 'swarm_claim'
82
+
83
+ export interface ProtocolStepDefinition {
84
+ id: string
85
+ kind: ProtocolStepKind
86
+ label: string
87
+ instructions?: string | null
88
+ turnLimit?: number | null
89
+ completionCriteria?: string | null
90
+ taskConfig?: { agentId?: string; title: string; description: string } | null
91
+ delegationConfig?: { agentId: string; message: string } | null
92
+ nextStepId?: string | null
93
+ branchCases?: ProtocolBranchCase[]
94
+ defaultNextStepId?: string | null
95
+ repeat?: ProtocolRepeatConfig | null
96
+ parallel?: ProtocolParallelConfig | null
97
+ join?: ProtocolJoinConfig | null
98
+ dependsOnStepIds?: string[]
99
+ outputKey?: string | null
100
+ forEach?: ProtocolForEachConfig | null
101
+ subflow?: ProtocolSubflowConfig | null
102
+ swarm?: ProtocolSwarmConfig | null
103
+ }
104
+
105
+ export interface ProtocolTemplate {
106
+ id: string
107
+ name: string
108
+ description: string
109
+ builtIn: boolean
110
+ singleAgentAllowed?: boolean
111
+ tags?: string[]
112
+ recommendedOutputs?: string[]
113
+ defaultPhases: ProtocolPhaseDefinition[]
114
+ steps?: ProtocolStepDefinition[]
115
+ entryStepId?: string | null
116
+ createdAt?: number
117
+ updatedAt?: number
118
+ }
119
+
120
+ export type ProtocolSourceRef =
121
+ | { kind: 'manual' }
122
+ | { kind: 'api' }
123
+ | { kind: 'session'; sessionId: string }
124
+ | { kind: 'chatroom'; chatroomId: string }
125
+ | { kind: 'task'; taskId: string }
126
+ | { kind: 'schedule'; scheduleId: string }
127
+ | { kind: 'protocol_run'; runId: string; parentRunId?: string | null; stepId?: string | null; branchId?: string | null }
128
+
129
+ export interface ProtocolRunArtifact {
130
+ id: string
131
+ kind: 'summary' | 'decision' | 'comparison' | 'notes' | 'action_items'
132
+ title: string
133
+ content: string
134
+ phaseId?: string | null
135
+ taskIds?: string[]
136
+ createdAt: number
137
+ }
138
+
139
+ export interface ProtocolRunPhaseStateResponse {
140
+ agentId: string
141
+ text: string
142
+ toolEvents?: MessageToolEvent[]
143
+ }
144
+
145
+ export interface ProtocolRunPhaseState {
146
+ phaseId: string
147
+ respondedAgentIds?: string[]
148
+ responses?: ProtocolRunPhaseStateResponse[]
149
+ appendedToTranscript?: boolean
150
+ artifactId?: string | null
151
+ dispatchedTaskId?: string | null
152
+ }
153
+
154
+ export interface ProtocolRunLoopState {
155
+ stepId: string
156
+ iterationCount: number
157
+ }
158
+
159
+ export interface ProtocolRunBranchDecision {
160
+ stepId: string
161
+ caseId?: string | null
162
+ nextStepId?: string | null
163
+ decidedAt: number
164
+ }
165
+
166
+ export interface ProtocolRunParallelBranchState {
167
+ branchId: string
168
+ label: string
169
+ runId: string
170
+ status: ProtocolRunStatus
171
+ participantAgentIds?: string[]
172
+ summary?: string | null
173
+ lastError?: string | null
174
+ updatedAt: number
175
+ }
176
+
177
+ export interface ProtocolRunParallelStepState {
178
+ stepId: string
179
+ branchRunIds: string[]
180
+ branches: ProtocolRunParallelBranchState[]
181
+ waitingOnBranchIds?: string[]
182
+ joinReady?: boolean
183
+ joinCompletedAt?: number | null
184
+ }
185
+
186
+ // --- DAG Step State ---
187
+
188
+ export type ProtocolRunStepStatus = 'pending' | 'ready' | 'running' | 'waiting' | 'completed' | 'failed' | 'skipped'
189
+
190
+ export interface ProtocolRunStepState {
191
+ stepId: string
192
+ status: ProtocolRunStepStatus
193
+ startedAt?: number | null
194
+ completedAt?: number | null
195
+ error?: string | null
196
+ }
197
+
198
+ export interface ProtocolRunStepOutput {
199
+ stepId: string
200
+ outputKey?: string | null
201
+ summary?: string | null
202
+ artifactIds?: string[]
203
+ taskIds?: string[]
204
+ childRunIds?: string[]
205
+ structuredData?: Record<string, unknown> | null
206
+ }
207
+
208
+ // --- For-Each Config ---
209
+
210
+ export interface ProtocolForEachConfig {
211
+ itemsSource:
212
+ | { type: 'literal'; items: unknown[] }
213
+ | { type: 'step_output'; stepId: string; path?: string | null }
214
+ | { type: 'artifact'; artifactId?: string | null; artifactKind?: string | null }
215
+ | { type: 'llm_extract'; prompt: string }
216
+ itemAlias: string
217
+ branchTemplate: {
218
+ steps: ProtocolStepDefinition[]
219
+ entryStepId?: string | null
220
+ participantAgentIds?: string[]
221
+ facilitatorAgentId?: string | null
222
+ }
223
+ joinMode: 'all'
224
+ maxItems?: number | null
225
+ onEmpty?: 'fail' | 'skip' | 'advance'
226
+ }
227
+
228
+ export interface ProtocolRunForEachStepState {
229
+ stepId: string
230
+ items: unknown[]
231
+ branchRunIds: string[]
232
+ branches: ProtocolRunParallelBranchState[]
233
+ waitingOnBranchIds?: string[]
234
+ joinReady?: boolean
235
+ joinCompletedAt?: number | null
236
+ }
237
+
238
+ // --- Subflow Config ---
239
+
240
+ export interface ProtocolSubflowConfig {
241
+ templateId: string
242
+ templateVersion?: string | null
243
+ participantAgentIds?: string[]
244
+ facilitatorAgentId?: string | null
245
+ inputMapping?: Record<string, string> | null
246
+ outputMapping?: Record<string, string> | null
247
+ onFailure: 'fail_parent' | 'advance_with_warning'
248
+ }
249
+
250
+ export interface ProtocolRunSubflowState {
251
+ stepId: string
252
+ childRunId: string
253
+ templateId: string
254
+ status: ProtocolRunStatus
255
+ summary?: string | null
256
+ lastError?: string | null
257
+ startedAt?: number | null
258
+ completedAt?: number | null
259
+ }
260
+
261
+ // --- Swarm Config ---
262
+
263
+ export interface ProtocolSwarmConfig {
264
+ eligibleAgentIds: string[]
265
+ workItemsSource:
266
+ | { type: 'literal'; items: Array<{ id: string; label: string; description?: string | null }> }
267
+ | { type: 'step_output'; stepId: string; path?: string | null }
268
+ claimLimitPerAgent?: number | null
269
+ selectionMode: 'first_claim' | 'claim_until_empty'
270
+ claimTimeoutSec: number
271
+ onUnclaimed: 'fail' | 'advance' | 'fallback_assign'
272
+ }
273
+
274
+ export interface ProtocolSwarmClaim {
275
+ id: string
276
+ workItemId: string
277
+ workItemLabel: string
278
+ agentId: string
279
+ childRunId?: string | null
280
+ taskId?: string | null
281
+ status: 'claimed' | 'running' | 'completed' | 'failed'
282
+ claimedAt: number
283
+ completedAt?: number | null
284
+ }
285
+
286
+ export interface ProtocolRunSwarmState {
287
+ stepId: string
288
+ workItems: Array<{ id: string; label: string; description?: string | null }>
289
+ claims: ProtocolSwarmClaim[]
290
+ unclaimedItemIds: string[]
291
+ eligibleAgentIds: string[]
292
+ claimLimitPerAgent: number
293
+ selectionMode: 'first_claim' | 'claim_until_empty'
294
+ claimTimeoutSec: number
295
+ openedAt: number
296
+ closedAt?: number | null
297
+ timedOut?: boolean
298
+ }
299
+
300
+ export interface ProtocolRunConfig {
301
+ goal?: string | null
302
+ kickoffMessage?: string | null
303
+ roundLimit?: number | null
304
+ decisionMode?: string | null
305
+ createTranscript?: boolean
306
+ autoEmitTasks?: boolean
307
+ taskProjectId?: string | null
308
+ postSummaryToParent?: boolean
309
+ }
310
+
311
+ export interface ProtocolRun {
312
+ id: string
313
+ title: string
314
+ templateId: string
315
+ templateName: string
316
+ status: ProtocolRunStatus
317
+ sourceRef: ProtocolSourceRef
318
+ participantAgentIds: string[]
319
+ facilitatorAgentId?: string | null
320
+ observerAgentIds?: string[]
321
+ taskId?: string | null
322
+ sessionId?: string | null
323
+ parentRunId?: string | null
324
+ parentStepId?: string | null
325
+ branchId?: string | null
326
+ parentChatroomId?: string | null
327
+ transcriptChatroomId?: string | null
328
+ scheduleId?: string | null
329
+ systemOwned?: boolean
330
+ phases: ProtocolPhaseDefinition[]
331
+ steps?: ProtocolStepDefinition[]
332
+ entryStepId?: string | null
333
+ currentStepId?: string | null
334
+ config?: ProtocolRunConfig | null
335
+ currentPhaseIndex: number
336
+ roundNumber?: number
337
+ summary?: string | null
338
+ latestArtifactId?: string | null
339
+ artifacts?: ProtocolRunArtifact[]
340
+ createdTaskIds?: string[]
341
+ waitingReason?: string | null
342
+ pauseReason?: string | null
343
+ lastError?: string | null
344
+ operatorContext?: string[]
345
+ phaseState?: ProtocolRunPhaseState | null
346
+ loopState?: Record<string, ProtocolRunLoopState>
347
+ branchHistory?: ProtocolRunBranchDecision[]
348
+ parallelState?: Record<string, ProtocolRunParallelStepState>
349
+ stepState?: Record<string, ProtocolRunStepState>
350
+ completedStepIds?: string[]
351
+ runningStepIds?: string[]
352
+ readyStepIds?: string[]
353
+ failedStepIds?: string[]
354
+ stepOutputs?: Record<string, ProtocolRunStepOutput>
355
+ forEachState?: Record<string, ProtocolRunForEachStepState>
356
+ subflowState?: Record<string, ProtocolRunSubflowState>
357
+ swarmState?: Record<string, ProtocolRunSwarmState>
358
+ createdAt: number
359
+ updatedAt: number
360
+ startedAt?: number | null
361
+ endedAt?: number | null
362
+ archivedAt?: number | null
363
+ }
364
+
365
+ export interface ProtocolRunEvent {
366
+ id: string
367
+ runId: string
368
+ type:
369
+ | 'created'
370
+ | 'phase_started'
371
+ | 'phase_completed'
372
+ | 'participant_response'
373
+ | 'artifact_emitted'
374
+ | 'task_emitted'
375
+ | 'waiting'
376
+ | 'paused'
377
+ | 'resumed'
378
+ | 'phase_skipped'
379
+ | 'phase_retried'
380
+ | 'context_injected'
381
+ | 'recovered'
382
+ | 'step_started'
383
+ | 'step_completed'
384
+ | 'branch_taken'
385
+ | 'parallel_started'
386
+ | 'parallel_branch_spawned'
387
+ | 'parallel_branch_completed'
388
+ | 'parallel_branch_failed'
389
+ | 'join_ready'
390
+ | 'join_completed'
391
+ | 'loop_iteration_started'
392
+ | 'loop_iteration_completed'
393
+ | 'loop_exhausted'
394
+ | 'completed'
395
+ | 'failed'
396
+ | 'warning'
397
+ | 'cancelled'
398
+ | 'task_dispatched'
399
+ | 'delegation_dispatched'
400
+ | 'archived'
401
+ | 'summary_posted'
402
+ | 'step_ready'
403
+ | 'step_waiting'
404
+ | 'step_failed'
405
+ | 'for_each_expanded'
406
+ | 'subflow_started'
407
+ | 'subflow_completed'
408
+ | 'subflow_failed'
409
+ | 'swarm_opened'
410
+ | 'swarm_claimed'
411
+ | 'swarm_exhausted'
412
+ summary: string
413
+ phaseId?: string | null
414
+ stepId?: string | null
415
+ agentId?: string | null
416
+ artifactId?: string | null
417
+ taskId?: string | null
418
+ createdAt: number
419
+ data?: Record<string, unknown> | null
420
+ }
@@ -0,0 +1,52 @@
1
+ export type ProviderType = 'claude-cli' | 'codex-cli' | 'opencode-cli' | 'gemini-cli' | 'openai' | 'ollama' | 'anthropic' | 'openclaw' | 'google' | 'deepseek' | 'groq' | 'together' | 'mistral' | 'xai' | 'fireworks' | 'nebius' | 'deepinfra'
2
+ export type ProviderId = ProviderType | (string & {})
3
+
4
+ export interface ProviderInfo {
5
+ id: ProviderId
6
+ name: string
7
+ models: string[]
8
+ defaultModels?: string[]
9
+ supportsModelDiscovery?: boolean
10
+ requiresApiKey: boolean
11
+ optionalApiKey?: boolean
12
+ requiresEndpoint: boolean
13
+ defaultEndpoint?: string
14
+ }
15
+
16
+ export interface ProviderModelDiscoveryResult {
17
+ ok: boolean
18
+ providerId: string
19
+ providerName?: string
20
+ models: string[]
21
+ cached: boolean
22
+ fetchedAt: number
23
+ cacheTtlMs: number
24
+ supportsDiscovery: boolean
25
+ missingCredential?: boolean
26
+ message?: string
27
+ }
28
+
29
+ export interface Credential {
30
+ id: string
31
+ provider: string
32
+ name: string
33
+ createdAt: number
34
+ }
35
+
36
+ export type Credentials = Record<string, Credential>
37
+ export type OllamaMode = 'local' | 'cloud'
38
+
39
+ // --- Custom Providers ---
40
+
41
+ export interface ProviderConfig {
42
+ id: string
43
+ name: string
44
+ type: 'builtin' | 'custom'
45
+ baseUrl?: string
46
+ models: string[]
47
+ requiresApiKey: boolean
48
+ credentialId?: string | null
49
+ isEnabled: boolean
50
+ createdAt: number
51
+ updatedAt: number
52
+ }
@@ -0,0 +1,180 @@
1
+ import type { SSEEvent } from './misc'
2
+
3
+ // --- Session Runs ---
4
+
5
+ export type SessionRunStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled'
6
+ export type ExecutionKind =
7
+ | 'session_turn'
8
+ | 'task_attempt'
9
+ | 'protocol_step'
10
+ | 'heartbeat_tick'
11
+ | 'schedule_wake'
12
+ | 'repair_turn'
13
+ | 'subagent_turn'
14
+
15
+ export type ExecutionOwnerType =
16
+ | 'session'
17
+ | 'task'
18
+ | 'protocol_run'
19
+ | 'schedule'
20
+ | 'agent'
21
+ | 'subagent'
22
+
23
+ export interface SessionRunHeartbeatConfig {
24
+ ackMaxChars: number
25
+ showOk: boolean
26
+ showAlerts: boolean
27
+ target: string | null
28
+ deliveryMode?: 'default' | 'tool_only' | 'silent'
29
+ lightContext?: boolean
30
+ }
31
+
32
+ export interface SessionRunRecoveryPayload {
33
+ message: string
34
+ imagePath?: string
35
+ imageUrl?: string
36
+ attachedFiles?: string[]
37
+ internal: boolean
38
+ source: string
39
+ mode: string
40
+ maxRuntimeMs?: number
41
+ modelOverride?: string
42
+ heartbeatConfig?: SessionRunHeartbeatConfig
43
+ replyToId?: string
44
+ executionGroupKey?: string
45
+ }
46
+
47
+ export interface SessionRunRecord {
48
+ id: string
49
+ sessionId: string
50
+ kind?: ExecutionKind
51
+ ownerType?: ExecutionOwnerType | null
52
+ ownerId?: string | null
53
+ parentExecutionId?: string | null
54
+ recoveryPolicy?: 'restart_recoverable' | 'ephemeral' | 'manual' | 'none'
55
+ source: string
56
+ internal: boolean
57
+ mode: string
58
+ status: SessionRunStatus
59
+ messagePreview: string
60
+ dedupeKey?: string
61
+ queuedAt: number
62
+ startedAt?: number
63
+ endedAt?: number
64
+ interruptedAt?: number
65
+ interruptedReason?: string
66
+ error?: string
67
+ resultPreview?: string
68
+ recoveredFromRestart?: boolean
69
+ recoveredFromRunId?: string
70
+ recoveryPayload?: SessionRunRecoveryPayload
71
+ totalInputTokens?: number
72
+ totalOutputTokens?: number
73
+ estimatedCost?: number
74
+ }
75
+
76
+ export interface SessionQueuedTurn {
77
+ runId: string
78
+ sessionId: string
79
+ text: string
80
+ queuedAt: number
81
+ position: number
82
+ imagePath?: string
83
+ imageUrl?: string
84
+ attachedFiles?: string[]
85
+ replyToId?: string
86
+ source?: string
87
+ }
88
+
89
+ export interface SessionQueueSnapshot {
90
+ sessionId: string
91
+ activeRunId: string | null
92
+ activeTurn?: SessionQueuedTurn | null
93
+ queueLength: number
94
+ items: SessionQueuedTurn[]
95
+ }
96
+
97
+ export interface RunEventRecord {
98
+ id: string
99
+ runId: string
100
+ sessionId: string
101
+ kind?: ExecutionKind
102
+ ownerType?: ExecutionOwnerType | null
103
+ ownerId?: string | null
104
+ parentExecutionId?: string | null
105
+ timestamp: number
106
+ phase: 'status' | 'event'
107
+ status?: SessionRunStatus
108
+ summary?: string
109
+ event: SSEEvent
110
+ }
111
+
112
+ export type RuntimeFailureFamily =
113
+ | 'provider_auth'
114
+ | 'provider_transport'
115
+ | 'gateway_disconnected'
116
+ | 'browser_boot'
117
+ | 'cli_missing'
118
+ | 'rate_limit'
119
+ | 'webhook_delivery'
120
+ | 'connector_delivery'
121
+ | 'workspace_recovery'
122
+
123
+ export type SupervisorIncidentKind =
124
+ | 'run_error'
125
+ | 'repeated_tool'
126
+ | 'no_progress'
127
+ | 'budget_pressure'
128
+ | 'context_pressure'
129
+ | 'runtime_failure'
130
+
131
+ export type SupervisorIncidentSeverity = 'low' | 'medium' | 'high'
132
+
133
+ export interface SupervisorIncident {
134
+ id: string
135
+ runId: string
136
+ sessionId: string
137
+ taskId?: string | null
138
+ agentId?: string | null
139
+ source: string
140
+ kind: SupervisorIncidentKind
141
+ severity: SupervisorIncidentSeverity
142
+ summary: string
143
+ details?: string | null
144
+ toolName?: string | null
145
+ failureFamily?: RuntimeFailureFamily | null
146
+ remediation?: string | null
147
+ repairPrompt?: string | null
148
+ autoAction?: 'replan' | 'compact' | 'block' | 'budget_trim' | null
149
+ createdAt: number
150
+ }
151
+
152
+ export interface RunReflection {
153
+ id: string
154
+ runId: string
155
+ sessionId: string
156
+ taskId?: string | null
157
+ agentId?: string | null
158
+ source: string
159
+ status: SessionRunStatus | 'completed' | 'failed'
160
+ summary: string
161
+ sourceSnippet?: string | null
162
+ invariantNotes: string[]
163
+ derivedNotes: string[]
164
+ failureNotes: string[]
165
+ lessonNotes: string[]
166
+ communicationNotes?: string[]
167
+ relationshipNotes?: string[]
168
+ significantEventNotes?: string[]
169
+ profileNotes?: string[]
170
+ boundaryNotes?: string[]
171
+ openLoopNotes?: string[]
172
+ incidentIds?: string[]
173
+ autoMemoryIds?: string[]
174
+ learnedSkillIds?: string[]
175
+ learnedSkillNotes?: string[]
176
+ qualityScore?: number | null
177
+ qualityReasoning?: string | null
178
+ createdAt: number
179
+ updatedAt: number
180
+ }
@@ -0,0 +1,59 @@
1
+ export type ScheduleType = 'cron' | 'interval' | 'once'
2
+ export type ScheduleStatus = 'active' | 'paused' | 'completed' | 'failed' | 'archived'
3
+ export type ScheduleTaskMode = 'task' | 'wake_only' | 'protocol'
4
+
5
+ export interface Schedule {
6
+ id: string
7
+ name: string
8
+ agentId: string
9
+ projectId?: string
10
+ taskPrompt: string
11
+ /** 'task' creates a board task, 'wake_only' just wakes the agent, and 'protocol' launches a structured session run. */
12
+ taskMode?: ScheduleTaskMode
13
+ /** Wake message sent to agent when taskMode is 'wake_only' */
14
+ message?: string
15
+ /** Structured session template launched when taskMode is 'protocol'. */
16
+ protocolTemplateId?: string | null
17
+ protocolParticipantAgentIds?: string[]
18
+ protocolFacilitatorAgentId?: string | null
19
+ protocolObserverAgentIds?: string[]
20
+ protocolConfig?: Record<string, unknown> | null
21
+ scheduleType: ScheduleType
22
+ action?: string
23
+ path?: string
24
+ command?: string
25
+ description?: string
26
+ frequency?: string
27
+ cron?: string
28
+ /** Natural time expression e.g. "at 09:00" — resolved to cron on creation */
29
+ atTime?: string | null
30
+ intervalMs?: number
31
+ runAt?: number
32
+ lastRunAt?: number
33
+ nextRunAt?: number
34
+ /** IANA timezone for schedule evaluation (default: system local) */
35
+ timezone?: string | null
36
+ /** Random stagger window in seconds added to nextRunAt to avoid thundering herd */
37
+ staggerSec?: number | null
38
+ /** Last delivery status for this schedule */
39
+ lastDeliveryStatus?: 'ok' | 'error' | null
40
+ /** Timestamp of last delivery attempt */
41
+ lastDeliveredAt?: number | null
42
+ /** Error message from last failed delivery */
43
+ lastDeliveryError?: string | null
44
+ status: ScheduleStatus
45
+ archivedAt?: number | null
46
+ archivedFromStatus?: Exclude<ScheduleStatus, 'archived'> | null
47
+ linkedTaskId?: string | null
48
+ linkedMissionId?: string | null
49
+ runNumber?: number
50
+ createdByAgentId?: string | null
51
+ createdInSessionId?: string | null
52
+ followupConnectorId?: string | null
53
+ followupChannelId?: string | null
54
+ followupThreadId?: string | null
55
+ followupSenderId?: string | null
56
+ followupSenderName?: string | null
57
+ createdAt: number
58
+ updatedAt?: number
59
+ }