@swarmclawai/swarmclaw 1.2.6 → 1.2.8

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 (112) hide show
  1. package/README.md +24 -17
  2. package/next.config.ts +1 -0
  3. package/package.json +3 -2
  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/api/chats/[id]/messages/route.ts +23 -19
  14. package/src/app/api/chats/messages-route.test.ts +105 -51
  15. package/src/app/api/mcp-servers/[id]/test/route.ts +3 -2
  16. package/src/app/api/openclaw/deploy/route.ts +2 -0
  17. package/src/app/api/setup/doctor/route.ts +4 -4
  18. package/src/components/agents/agent-chat-list.tsx +23 -1
  19. package/src/components/agents/inspector-panel.tsx +165 -48
  20. package/src/components/chat/chat-area.tsx +38 -9
  21. package/src/components/chat/message-list.tsx +33 -19
  22. package/src/components/gateways/gateway-sheet.tsx +5 -2
  23. package/src/lib/agent-execute-defaults.test.ts +24 -0
  24. package/src/lib/agent-execute-defaults.ts +62 -0
  25. package/src/lib/chat/queued-message-queue.test.ts +134 -1
  26. package/src/lib/chat/queued-message-queue.ts +77 -2
  27. package/src/lib/server/agents/agent-service.ts +5 -0
  28. package/src/lib/server/builtin-extensions.ts +1 -0
  29. package/src/lib/server/chat-execution/chat-execution-advanced.test.ts +1 -1
  30. package/src/lib/server/chat-execution/chat-execution-tool-events.test.ts +1 -0
  31. package/src/lib/server/chat-execution/chat-execution-utils.ts +2 -2
  32. package/src/lib/server/chat-execution/chat-turn-preparation.ts +79 -42
  33. package/src/lib/server/chat-execution/chat-turn-stream-execution.ts +4 -0
  34. package/src/lib/server/chat-execution/continuation-evaluator.ts +8 -0
  35. package/src/lib/server/chat-execution/memory-mutation-tools.ts +1 -1
  36. package/src/lib/server/chat-execution/message-classifier.ts +11 -1
  37. package/src/lib/server/chat-execution/prompt-builder.test.ts +28 -0
  38. package/src/lib/server/chat-execution/prompt-builder.ts +14 -1
  39. package/src/lib/server/chat-execution/prompt-mode.test.ts +24 -0
  40. package/src/lib/server/chat-execution/prompt-mode.ts +5 -1
  41. package/src/lib/server/chat-execution/stream-agent-chat.test.ts +6 -4
  42. package/src/lib/server/chat-execution/stream-agent-chat.ts +45 -16
  43. package/src/lib/server/chatrooms/chatroom-routing.test.ts +4 -0
  44. package/src/lib/server/connectors/discord.ts +2 -2
  45. package/src/lib/server/connectors/matrix.ts +3 -2
  46. package/src/lib/server/connectors/signal.ts +5 -4
  47. package/src/lib/server/connectors/slack.ts +10 -9
  48. package/src/lib/server/connectors/teams.ts +3 -2
  49. package/src/lib/server/connectors/telegram.ts +4 -4
  50. package/src/lib/server/connectors/whatsapp.ts +2 -2
  51. package/src/lib/server/daemon/controller.ts +7 -0
  52. package/src/lib/server/gateways/gateway-profile-service.ts +19 -1
  53. package/src/lib/server/messages/message-repository.test.ts +70 -0
  54. package/src/lib/server/messages/message-repository.ts +11 -6
  55. package/src/lib/server/openclaw/deploy.ts +32 -2
  56. package/src/lib/server/plugins-advanced.test.ts +1 -2
  57. package/src/lib/server/provider-health.ts +1 -1
  58. package/src/lib/server/runtime/process-manager.ts +13 -9
  59. package/src/lib/server/runtime/session-run-manager/queries.ts +15 -0
  60. package/src/lib/server/runtime/session-run-manager.test.ts +58 -0
  61. package/src/lib/server/sandbox/session-runtime.test.ts +18 -1
  62. package/src/lib/server/sandbox/session-runtime.ts +40 -28
  63. package/src/lib/server/session-tools/autonomy-tools.test.ts +7 -9
  64. package/src/lib/server/session-tools/context.ts +1 -1
  65. package/src/lib/server/session-tools/credential-env.ts +109 -0
  66. package/src/lib/server/session-tools/crud.ts +3 -3
  67. package/src/lib/server/session-tools/edit_file.ts +3 -2
  68. package/src/lib/server/session-tools/execute.test.ts +58 -0
  69. package/src/lib/server/session-tools/execute.ts +334 -0
  70. package/src/lib/server/session-tools/files-tool.ts +635 -0
  71. package/src/lib/server/session-tools/index.ts +14 -4
  72. package/src/lib/server/session-tools/memory-tool.ts +242 -0
  73. package/src/lib/server/session-tools/memory.ts +1 -1
  74. package/src/lib/server/session-tools/openclaw-nodes.ts +3 -2
  75. package/src/lib/server/session-tools/openclaw-workspace.ts +3 -2
  76. package/src/lib/server/session-tools/platform-tool.ts +617 -0
  77. package/src/lib/server/session-tools/session-info.ts +3 -2
  78. package/src/lib/server/session-tools/session-tools-wiring.test.ts +3 -4
  79. package/src/lib/server/session-tools/shell.ts +7 -122
  80. package/src/lib/server/session-tools/skills-tool.ts +396 -0
  81. package/src/lib/server/session-tools/web.ts +2 -2
  82. package/src/lib/server/storage-normalization.ts +2 -0
  83. package/src/lib/server/tool-aliases.ts +2 -1
  84. package/src/lib/server/tool-capability-policy-advanced.test.ts +9 -2
  85. package/src/lib/server/tool-capability-policy.test.ts +2 -1
  86. package/src/lib/server/tool-capability-policy.ts +60 -33
  87. package/src/lib/server/tool-planning.ts +11 -0
  88. package/src/lib/setup-defaults.ts +5 -0
  89. package/src/lib/tool-definitions.ts +1 -0
  90. package/src/lib/validation/schemas.test.ts +16 -0
  91. package/src/lib/validation/schemas.ts +16 -0
  92. package/src/stores/use-chat-store.test.ts +231 -0
  93. package/src/stores/use-chat-store.ts +62 -13
  94. package/src/types/agent.ts +348 -0
  95. package/src/types/app-settings.ts +175 -0
  96. package/src/types/approval.ts +27 -0
  97. package/src/types/connector.ts +187 -0
  98. package/src/types/extension.ts +386 -0
  99. package/src/types/index.ts +16 -3555
  100. package/src/types/message.ts +57 -0
  101. package/src/types/misc.ts +739 -0
  102. package/src/types/mission.ts +185 -0
  103. package/src/types/protocol.ts +422 -0
  104. package/src/types/provider.ts +52 -0
  105. package/src/types/run.ts +183 -0
  106. package/src/types/schedule.ts +59 -0
  107. package/src/types/session.ts +265 -0
  108. package/src/types/skill.ts +157 -0
  109. package/src/types/task.ts +140 -0
  110. package/src/types/working-state.ts +211 -0
  111. package/src/views/settings/section-heartbeat.tsx +2 -2
  112. package/src/lib/server/session-tools/sandbox.ts +0 -281
@@ -0,0 +1,185 @@
1
+ export type MissionSource =
2
+ | 'chat'
3
+ | 'connector'
4
+ | 'heartbeat'
5
+ | 'main-loop-followup'
6
+ | 'task'
7
+ | 'schedule'
8
+ | 'delegation'
9
+ | 'manual'
10
+
11
+ export type MissionStatus = 'active' | 'waiting' | 'completed' | 'failed' | 'cancelled'
12
+ export type MissionPhase = 'intake' | 'planning' | 'dispatching' | 'executing' | 'verifying' | 'waiting' | 'completed' | 'failed'
13
+ export type MissionWaitKind =
14
+ | 'human_reply'
15
+ | 'approval'
16
+ | 'external_dependency'
17
+ | 'provider'
18
+ | 'blocked_task'
19
+ | 'blocked_mission'
20
+ | 'scheduled'
21
+ | 'other'
22
+
23
+ export type MissionPlannerDecision =
24
+ | 'dispatch_task'
25
+ | 'dispatch_session_turn'
26
+ | 'spawn_child_mission'
27
+ | 'wait'
28
+ | 'verify_now'
29
+ | 'complete_candidate'
30
+ | 'replan'
31
+ | 'fail_terminal'
32
+ | 'cancel'
33
+
34
+ export type MissionVerificationVerdict =
35
+ | 'continue'
36
+ | 'waiting'
37
+ | 'completed'
38
+ | 'failed'
39
+ | 'replan'
40
+
41
+ export type MissionSourceRef =
42
+ | { kind: 'chat'; sessionId: string; messageId?: string | null }
43
+ | { kind: 'connector'; sessionId: string; connectorId: string; channelId: string; threadId?: string | null }
44
+ | { kind: 'schedule'; scheduleId: string; recurring: boolean }
45
+ | { kind: 'task'; taskId: string }
46
+ | { kind: 'delegation'; parentMissionId: string; backend?: 'agent' | 'codex' | 'claude' | 'opencode' | 'gemini' | null }
47
+ | { kind: 'heartbeat'; sessionId: string }
48
+ | { kind: 'manual' }
49
+
50
+ export interface MissionWaitState {
51
+ kind: MissionWaitKind
52
+ reason: string
53
+ approvalId?: string | null
54
+ untilAt?: number | null
55
+ dependencyTaskId?: string | null
56
+ dependencyMissionId?: string | null
57
+ providerKey?: string | null
58
+ }
59
+
60
+ export interface MissionControllerState {
61
+ leaseId?: string | null
62
+ leaseExpiresAt?: number | null
63
+ tickRequestedAt?: number | null
64
+ tickReason?: string | null
65
+ plannerRunId?: string | null
66
+ verifierRunId?: string | null
67
+ activeRunId?: string | null
68
+ currentTaskId?: string | null
69
+ currentChildMissionId?: string | null
70
+ pendingWakeId?: string | null
71
+ attemptCount?: number
72
+ lastEvidenceAt?: number | null
73
+ }
74
+
75
+ export interface MissionPlannerState {
76
+ lastDecision?: MissionPlannerDecision | null
77
+ lastPlannedAt?: number | null
78
+ planSummary?: string | null
79
+ }
80
+
81
+ export interface MissionVerificationState {
82
+ candidate: boolean
83
+ requiredTaskIds?: string[]
84
+ requiredChildMissionIds?: string[]
85
+ requiredArtifacts?: string[]
86
+ evidenceSummary?: string | null
87
+ lastVerdict?: MissionVerificationVerdict | null
88
+ lastVerifiedAt?: number | null
89
+ }
90
+
91
+ export interface MissionSummary {
92
+ id: string
93
+ objective: string
94
+ status: MissionStatus
95
+ phase: MissionPhase
96
+ source: MissionSource
97
+ currentStep?: string | null
98
+ waitingReason?: string | null
99
+ sessionId?: string | null
100
+ agentId?: string | null
101
+ projectId?: string | null
102
+ parentMissionId?: string | null
103
+ rootMissionId?: string | null
104
+ taskIds?: string[]
105
+ openTaskCount?: number
106
+ completedTaskCount?: number
107
+ childCount?: number
108
+ sourceRef?: MissionSourceRef
109
+ updatedAt: number
110
+ }
111
+
112
+ export interface Mission {
113
+ id: string
114
+ source: MissionSource
115
+ sourceRef?: MissionSourceRef
116
+ objective: string
117
+ successCriteria?: string[]
118
+ status: MissionStatus
119
+ phase: MissionPhase
120
+ sessionId?: string | null
121
+ agentId?: string | null
122
+ projectId?: string | null
123
+ rootMissionId?: string | null
124
+ parentMissionId?: string | null
125
+ childMissionIds?: string[]
126
+ dependencyMissionIds?: string[]
127
+ dependencyTaskIds?: string[]
128
+ taskIds?: string[]
129
+ rootTaskId?: string | null
130
+ currentStep?: string | null
131
+ plannerSummary?: string | null
132
+ verifierSummary?: string | null
133
+ blockerSummary?: string | null
134
+ waitState?: MissionWaitState | null
135
+ controllerState?: MissionControllerState
136
+ plannerState?: MissionPlannerState
137
+ verificationState?: MissionVerificationState
138
+ lastRunId?: string | null
139
+ sourceRunId?: string | null
140
+ sourceMessage?: string | null
141
+ createdAt: number
142
+ updatedAt: number
143
+ lastActiveAt?: number | null
144
+ completedAt?: number | null
145
+ failedAt?: number | null
146
+ cancelledAt?: number | null
147
+ }
148
+
149
+ export type MissionEventType =
150
+ | 'created'
151
+ | 'source_triggered'
152
+ | 'attached'
153
+ | 'planner_decision'
154
+ | 'dispatch_started'
155
+ | 'task_linked'
156
+ | 'task_started'
157
+ | 'task_completed'
158
+ | 'task_failed'
159
+ | 'child_created'
160
+ | 'child_completed'
161
+ | 'child_failed'
162
+ | 'run_result'
163
+ | 'verifier_decision'
164
+ | 'waiting'
165
+ | 'resumed'
166
+ | 'replanned'
167
+ | 'completed'
168
+ | 'failed'
169
+ | 'cancelled'
170
+ | 'interrupted'
171
+ | 'operator_action'
172
+ | 'status_change'
173
+
174
+ export interface MissionEvent {
175
+ id: string
176
+ missionId: string
177
+ type: MissionEventType
178
+ source: MissionSource | 'system'
179
+ summary: string
180
+ data?: Record<string, unknown> | null
181
+ sessionId?: string | null
182
+ taskId?: string | null
183
+ runId?: string | null
184
+ createdAt: number
185
+ }
@@ -0,0 +1,422 @@
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: 'mission'; missionId: string }
126
+ | { kind: 'task'; taskId: string }
127
+ | { kind: 'schedule'; scheduleId: string }
128
+ | { kind: 'protocol_run'; runId: string; parentRunId?: string | null; stepId?: string | null; branchId?: string | null }
129
+
130
+ export interface ProtocolRunArtifact {
131
+ id: string
132
+ kind: 'summary' | 'decision' | 'comparison' | 'notes' | 'action_items'
133
+ title: string
134
+ content: string
135
+ phaseId?: string | null
136
+ taskIds?: string[]
137
+ createdAt: number
138
+ }
139
+
140
+ export interface ProtocolRunPhaseStateResponse {
141
+ agentId: string
142
+ text: string
143
+ toolEvents?: MessageToolEvent[]
144
+ }
145
+
146
+ export interface ProtocolRunPhaseState {
147
+ phaseId: string
148
+ respondedAgentIds?: string[]
149
+ responses?: ProtocolRunPhaseStateResponse[]
150
+ appendedToTranscript?: boolean
151
+ artifactId?: string | null
152
+ dispatchedTaskId?: string | null
153
+ }
154
+
155
+ export interface ProtocolRunLoopState {
156
+ stepId: string
157
+ iterationCount: number
158
+ }
159
+
160
+ export interface ProtocolRunBranchDecision {
161
+ stepId: string
162
+ caseId?: string | null
163
+ nextStepId?: string | null
164
+ decidedAt: number
165
+ }
166
+
167
+ export interface ProtocolRunParallelBranchState {
168
+ branchId: string
169
+ label: string
170
+ runId: string
171
+ status: ProtocolRunStatus
172
+ participantAgentIds?: string[]
173
+ summary?: string | null
174
+ lastError?: string | null
175
+ updatedAt: number
176
+ }
177
+
178
+ export interface ProtocolRunParallelStepState {
179
+ stepId: string
180
+ branchRunIds: string[]
181
+ branches: ProtocolRunParallelBranchState[]
182
+ waitingOnBranchIds?: string[]
183
+ joinReady?: boolean
184
+ joinCompletedAt?: number | null
185
+ }
186
+
187
+ // --- DAG Step State ---
188
+
189
+ export type ProtocolRunStepStatus = 'pending' | 'ready' | 'running' | 'waiting' | 'completed' | 'failed' | 'skipped'
190
+
191
+ export interface ProtocolRunStepState {
192
+ stepId: string
193
+ status: ProtocolRunStepStatus
194
+ startedAt?: number | null
195
+ completedAt?: number | null
196
+ error?: string | null
197
+ }
198
+
199
+ export interface ProtocolRunStepOutput {
200
+ stepId: string
201
+ outputKey?: string | null
202
+ summary?: string | null
203
+ artifactIds?: string[]
204
+ taskIds?: string[]
205
+ childRunIds?: string[]
206
+ structuredData?: Record<string, unknown> | null
207
+ }
208
+
209
+ // --- For-Each Config ---
210
+
211
+ export interface ProtocolForEachConfig {
212
+ itemsSource:
213
+ | { type: 'literal'; items: unknown[] }
214
+ | { type: 'step_output'; stepId: string; path?: string | null }
215
+ | { type: 'artifact'; artifactId?: string | null; artifactKind?: string | null }
216
+ | { type: 'llm_extract'; prompt: string }
217
+ itemAlias: string
218
+ branchTemplate: {
219
+ steps: ProtocolStepDefinition[]
220
+ entryStepId?: string | null
221
+ participantAgentIds?: string[]
222
+ facilitatorAgentId?: string | null
223
+ }
224
+ joinMode: 'all'
225
+ maxItems?: number | null
226
+ onEmpty?: 'fail' | 'skip' | 'advance'
227
+ }
228
+
229
+ export interface ProtocolRunForEachStepState {
230
+ stepId: string
231
+ items: unknown[]
232
+ branchRunIds: string[]
233
+ branches: ProtocolRunParallelBranchState[]
234
+ waitingOnBranchIds?: string[]
235
+ joinReady?: boolean
236
+ joinCompletedAt?: number | null
237
+ }
238
+
239
+ // --- Subflow Config ---
240
+
241
+ export interface ProtocolSubflowConfig {
242
+ templateId: string
243
+ templateVersion?: string | null
244
+ participantAgentIds?: string[]
245
+ facilitatorAgentId?: string | null
246
+ inputMapping?: Record<string, string> | null
247
+ outputMapping?: Record<string, string> | null
248
+ onFailure: 'fail_parent' | 'advance_with_warning'
249
+ }
250
+
251
+ export interface ProtocolRunSubflowState {
252
+ stepId: string
253
+ childRunId: string
254
+ templateId: string
255
+ status: ProtocolRunStatus
256
+ summary?: string | null
257
+ lastError?: string | null
258
+ startedAt?: number | null
259
+ completedAt?: number | null
260
+ }
261
+
262
+ // --- Swarm Config ---
263
+
264
+ export interface ProtocolSwarmConfig {
265
+ eligibleAgentIds: string[]
266
+ workItemsSource:
267
+ | { type: 'literal'; items: Array<{ id: string; label: string; description?: string | null }> }
268
+ | { type: 'step_output'; stepId: string; path?: string | null }
269
+ claimLimitPerAgent?: number | null
270
+ selectionMode: 'first_claim' | 'claim_until_empty'
271
+ claimTimeoutSec: number
272
+ onUnclaimed: 'fail' | 'advance' | 'fallback_assign'
273
+ }
274
+
275
+ export interface ProtocolSwarmClaim {
276
+ id: string
277
+ workItemId: string
278
+ workItemLabel: string
279
+ agentId: string
280
+ childRunId?: string | null
281
+ taskId?: string | null
282
+ status: 'claimed' | 'running' | 'completed' | 'failed'
283
+ claimedAt: number
284
+ completedAt?: number | null
285
+ }
286
+
287
+ export interface ProtocolRunSwarmState {
288
+ stepId: string
289
+ workItems: Array<{ id: string; label: string; description?: string | null }>
290
+ claims: ProtocolSwarmClaim[]
291
+ unclaimedItemIds: string[]
292
+ eligibleAgentIds: string[]
293
+ claimLimitPerAgent: number
294
+ selectionMode: 'first_claim' | 'claim_until_empty'
295
+ claimTimeoutSec: number
296
+ openedAt: number
297
+ closedAt?: number | null
298
+ timedOut?: boolean
299
+ }
300
+
301
+ export interface ProtocolRunConfig {
302
+ goal?: string | null
303
+ kickoffMessage?: string | null
304
+ roundLimit?: number | null
305
+ decisionMode?: string | null
306
+ createTranscript?: boolean
307
+ autoEmitTasks?: boolean
308
+ taskProjectId?: string | null
309
+ postSummaryToParent?: boolean
310
+ }
311
+
312
+ export interface ProtocolRun {
313
+ id: string
314
+ title: string
315
+ templateId: string
316
+ templateName: string
317
+ status: ProtocolRunStatus
318
+ sourceRef: ProtocolSourceRef
319
+ participantAgentIds: string[]
320
+ facilitatorAgentId?: string | null
321
+ observerAgentIds?: string[]
322
+ missionId?: string | null
323
+ taskId?: string | null
324
+ sessionId?: string | null
325
+ parentRunId?: string | null
326
+ parentStepId?: string | null
327
+ branchId?: string | null
328
+ parentChatroomId?: string | null
329
+ transcriptChatroomId?: string | null
330
+ scheduleId?: string | null
331
+ systemOwned?: boolean
332
+ phases: ProtocolPhaseDefinition[]
333
+ steps?: ProtocolStepDefinition[]
334
+ entryStepId?: string | null
335
+ currentStepId?: string | null
336
+ config?: ProtocolRunConfig | null
337
+ currentPhaseIndex: number
338
+ roundNumber?: number
339
+ summary?: string | null
340
+ latestArtifactId?: string | null
341
+ artifacts?: ProtocolRunArtifact[]
342
+ createdTaskIds?: string[]
343
+ waitingReason?: string | null
344
+ pauseReason?: string | null
345
+ lastError?: string | null
346
+ operatorContext?: string[]
347
+ phaseState?: ProtocolRunPhaseState | null
348
+ loopState?: Record<string, ProtocolRunLoopState>
349
+ branchHistory?: ProtocolRunBranchDecision[]
350
+ parallelState?: Record<string, ProtocolRunParallelStepState>
351
+ stepState?: Record<string, ProtocolRunStepState>
352
+ completedStepIds?: string[]
353
+ runningStepIds?: string[]
354
+ readyStepIds?: string[]
355
+ failedStepIds?: string[]
356
+ stepOutputs?: Record<string, ProtocolRunStepOutput>
357
+ forEachState?: Record<string, ProtocolRunForEachStepState>
358
+ subflowState?: Record<string, ProtocolRunSubflowState>
359
+ swarmState?: Record<string, ProtocolRunSwarmState>
360
+ createdAt: number
361
+ updatedAt: number
362
+ startedAt?: number | null
363
+ endedAt?: number | null
364
+ archivedAt?: number | null
365
+ }
366
+
367
+ export interface ProtocolRunEvent {
368
+ id: string
369
+ runId: string
370
+ type:
371
+ | 'created'
372
+ | 'phase_started'
373
+ | 'phase_completed'
374
+ | 'participant_response'
375
+ | 'artifact_emitted'
376
+ | 'task_emitted'
377
+ | 'waiting'
378
+ | 'paused'
379
+ | 'resumed'
380
+ | 'phase_skipped'
381
+ | 'phase_retried'
382
+ | 'context_injected'
383
+ | 'recovered'
384
+ | 'step_started'
385
+ | 'step_completed'
386
+ | 'branch_taken'
387
+ | 'parallel_started'
388
+ | 'parallel_branch_spawned'
389
+ | 'parallel_branch_completed'
390
+ | 'parallel_branch_failed'
391
+ | 'join_ready'
392
+ | 'join_completed'
393
+ | 'loop_iteration_started'
394
+ | 'loop_iteration_completed'
395
+ | 'loop_exhausted'
396
+ | 'completed'
397
+ | 'failed'
398
+ | 'warning'
399
+ | 'cancelled'
400
+ | 'task_dispatched'
401
+ | 'delegation_dispatched'
402
+ | 'archived'
403
+ | 'summary_posted'
404
+ | 'step_ready'
405
+ | 'step_waiting'
406
+ | 'step_failed'
407
+ | 'for_each_expanded'
408
+ | 'subflow_started'
409
+ | 'subflow_completed'
410
+ | 'subflow_failed'
411
+ | 'swarm_opened'
412
+ | 'swarm_claimed'
413
+ | 'swarm_exhausted'
414
+ summary: string
415
+ phaseId?: string | null
416
+ stepId?: string | null
417
+ agentId?: string | null
418
+ artifactId?: string | null
419
+ taskId?: string | null
420
+ createdAt: number
421
+ data?: Record<string, unknown> | null
422
+ }
@@ -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
+ }