@swarmclawai/swarmclaw 1.2.1 → 1.2.3
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.
- package/README.md +16 -85
- package/bin/server-cmd.js +64 -1
- package/package.json +2 -2
- package/skills/coding-agent/SKILL.md +111 -0
- package/skills/github/SKILL.md +140 -0
- package/skills/nano-banana-pro/SKILL.md +62 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +235 -0
- package/skills/nano-pdf/SKILL.md +53 -0
- package/skills/openai-image-gen/SKILL.md +78 -0
- package/skills/openai-image-gen/scripts/gen.py +328 -0
- package/skills/resourceful-problem-solving/SKILL.md +49 -0
- package/skills/skill-creator/SKILL.md +147 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/quick_validate.py +159 -0
- package/skills/summarize/SKILL.md +77 -0
- package/src/app/api/auth/route.ts +20 -5
- package/src/app/api/chats/[id]/devserver/route.ts +13 -19
- package/src/app/api/chats/[id]/messages/route.ts +13 -15
- package/src/app/api/chats/[id]/route.ts +9 -10
- package/src/app/api/chats/[id]/stop/route.ts +5 -7
- package/src/app/api/chats/messages-route.test.ts +8 -6
- package/src/app/api/chats/route.ts +9 -10
- package/src/app/api/ip/route.ts +2 -2
- package/src/app/api/preview-server/route.ts +1 -1
- package/src/app/api/projects/[id]/route.ts +7 -46
- package/src/cli/server-cmd.test.js +74 -0
- package/src/components/chat/chat-area.tsx +45 -23
- package/src/components/chat/message-bubble.test.ts +35 -0
- package/src/components/chat/message-bubble.tsx +19 -9
- package/src/components/chat/message-list.tsx +37 -3
- package/src/components/input/chat-input.tsx +34 -14
- package/src/components/openclaw/openclaw-deploy-panel.tsx +4 -0
- package/src/instrumentation.ts +1 -1
- package/src/lib/chat/assistant-render-id.ts +3 -0
- package/src/lib/chat/chat-streaming-state.test.ts +42 -3
- package/src/lib/chat/chat-streaming-state.ts +20 -8
- package/src/lib/chat/queued-message-queue.test.ts +23 -1
- package/src/lib/chat/queued-message-queue.ts +11 -2
- package/src/lib/providers/cli-utils.test.ts +124 -0
- package/src/lib/server/activity/activity-log.ts +21 -0
- package/src/lib/server/agents/agent-availability.test.ts +10 -5
- package/src/lib/server/agents/agent-cascade.ts +79 -59
- package/src/lib/server/agents/agent-registry.ts +3 -1
- package/src/lib/server/agents/agent-repository.ts +90 -0
- package/src/lib/server/agents/delegation-job-repository.ts +53 -0
- package/src/lib/server/agents/delegation-jobs.ts +11 -4
- package/src/lib/server/agents/guardian-checkpoint-repository.ts +35 -0
- package/src/lib/server/agents/guardian.ts +2 -2
- package/src/lib/server/agents/main-agent-loop.ts +10 -3
- package/src/lib/server/agents/main-loop-state-repository.ts +38 -0
- package/src/lib/server/agents/subagent-runtime.ts +9 -6
- package/src/lib/server/agents/subagent-swarm.ts +3 -2
- package/src/lib/server/agents/task-session.ts +3 -4
- package/src/lib/server/approvals/approval-repository.ts +30 -0
- package/src/lib/server/autonomy/supervisor-incident-repository.ts +42 -0
- package/src/lib/server/chat-execution/chat-execution-types.ts +38 -0
- package/src/lib/server/chat-execution/chat-execution-utils.ts +1 -1
- package/src/lib/server/chat-execution/chat-execution.ts +84 -1926
- package/src/lib/server/chat-execution/chat-turn-finalization.ts +620 -0
- package/src/lib/server/chat-execution/chat-turn-partial-persistence.ts +221 -0
- package/src/lib/server/chat-execution/chat-turn-preflight.ts +133 -0
- package/src/lib/server/chat-execution/chat-turn-preparation.ts +817 -0
- package/src/lib/server/chat-execution/chat-turn-stream-execution.ts +296 -0
- package/src/lib/server/chat-execution/chat-turn-tool-routing.ts +5 -5
- package/src/lib/server/chat-execution/message-classifier.test.ts +329 -0
- package/src/lib/server/chat-execution/post-stream-finalization.ts +1 -1
- package/src/lib/server/chat-execution/prompt-builder.ts +11 -0
- package/src/lib/server/chat-execution/prompt-sections.ts +5 -6
- package/src/lib/server/chat-execution/situational-awareness.ts +12 -7
- package/src/lib/server/chat-execution/stream-agent-chat.ts +16 -13
- package/src/lib/server/chatrooms/chatroom-repository.ts +32 -0
- package/src/lib/server/connectors/connector-repository.ts +58 -0
- package/src/lib/server/connectors/runtime-state.test.ts +117 -0
- package/src/lib/server/credentials/credential-repository.ts +7 -0
- package/src/lib/server/gateways/gateway-profile-repository.ts +4 -0
- package/src/lib/server/memory/memory-abstract.test.ts +59 -0
- package/src/lib/server/missions/mission-repository.ts +74 -0
- package/src/lib/server/missions/mission-service/actions.ts +6 -0
- package/src/lib/server/missions/mission-service/bindings.ts +9 -0
- package/src/lib/server/missions/mission-service/context.ts +4 -0
- package/src/lib/server/missions/mission-service/core.ts +2269 -0
- package/src/lib/server/missions/mission-service/queries.ts +12 -0
- package/src/lib/server/missions/mission-service/recovery.ts +5 -0
- package/src/lib/server/missions/mission-service/ticks.ts +9 -0
- package/src/lib/server/missions/mission-service.test.ts +9 -2
- package/src/lib/server/missions/mission-service.ts +6 -2266
- package/src/lib/server/openclaw/deploy.test.ts +42 -3
- package/src/lib/server/openclaw/deploy.ts +26 -12
- package/src/lib/server/persistence/repository-utils.ts +154 -0
- package/src/lib/server/persistence/storage-context.ts +51 -0
- package/src/lib/server/persistence/transaction.ts +1 -0
- package/src/lib/server/projects/project-repository.ts +36 -0
- package/src/lib/server/projects/project-service.ts +79 -0
- package/src/lib/server/protocols/protocol-normalization.test.ts +6 -4
- package/src/lib/server/runtime/alert-dispatch.ts +1 -1
- package/src/lib/server/runtime/daemon-policy.ts +1 -1
- package/src/lib/server/runtime/daemon-state/core.ts +1570 -0
- package/src/lib/server/runtime/daemon-state/health.ts +6 -0
- package/src/lib/server/runtime/daemon-state/policy.ts +7 -0
- package/src/lib/server/runtime/daemon-state/supervisor.ts +6 -0
- package/src/lib/server/runtime/daemon-state.test.ts +48 -0
- package/src/lib/server/runtime/daemon-state.ts +3 -1470
- package/src/lib/server/runtime/estop-repository.ts +4 -0
- package/src/lib/server/runtime/estop.ts +3 -1
- package/src/lib/server/runtime/heartbeat-service.test.ts +2 -2
- package/src/lib/server/runtime/heartbeat-service.ts +55 -34
- package/src/lib/server/runtime/heartbeat-wake.ts +6 -4
- package/src/lib/server/runtime/idle-window.ts +2 -2
- package/src/lib/server/runtime/network.ts +11 -0
- package/src/lib/server/runtime/orchestrator-events.ts +2 -2
- package/src/lib/server/runtime/queue/claims.ts +4 -0
- package/src/lib/server/runtime/queue/core.ts +2079 -0
- package/src/lib/server/runtime/queue/execution.ts +7 -0
- package/src/lib/server/runtime/queue/followups.ts +4 -0
- package/src/lib/server/runtime/queue/queries.ts +12 -0
- package/src/lib/server/runtime/queue/recovery.ts +7 -0
- package/src/lib/server/runtime/queue-recovery.test.ts +48 -13
- package/src/lib/server/runtime/queue-repository.ts +17 -0
- package/src/lib/server/runtime/queue.ts +5 -2061
- package/src/lib/server/runtime/run-ledger.ts +6 -5
- package/src/lib/server/runtime/run-repository.ts +73 -0
- package/src/lib/server/runtime/runtime-lock-repository.ts +8 -0
- package/src/lib/server/runtime/runtime-settings.ts +1 -1
- package/src/lib/server/runtime/runtime-state.ts +99 -0
- package/src/lib/server/runtime/scheduler.ts +4 -2
- package/src/lib/server/runtime/session-run-manager/cancellation.ts +157 -0
- package/src/lib/server/runtime/session-run-manager/drain.ts +246 -0
- package/src/lib/server/runtime/session-run-manager/enqueue.ts +287 -0
- package/src/lib/server/runtime/session-run-manager/queries.ts +117 -0
- package/src/lib/server/runtime/session-run-manager/recovery.ts +238 -0
- package/src/lib/server/runtime/session-run-manager/state.ts +441 -0
- package/src/lib/server/runtime/session-run-manager/types.ts +74 -0
- package/src/lib/server/runtime/session-run-manager.ts +72 -1377
- package/src/lib/server/runtime/watch-job-repository.ts +35 -0
- package/src/lib/server/runtime/watch-jobs.ts +3 -1
- package/src/lib/server/schedules/schedule-repository.ts +42 -0
- package/src/lib/server/sessions/session-repository.ts +85 -0
- package/src/lib/server/settings/settings-repository.ts +25 -0
- package/src/lib/server/skills/skill-discovery.test.ts +2 -2
- package/src/lib/server/skills/skill-discovery.ts +2 -2
- package/src/lib/server/skills/skill-repository.ts +14 -0
- package/src/lib/server/storage.ts +13 -24
- package/src/lib/server/tasks/task-repository.ts +54 -0
- package/src/lib/server/usage/usage-repository.ts +30 -0
- package/src/lib/server/webhooks/webhook-repository.ts +10 -0
- package/src/lib/strip-internal-metadata.test.ts +42 -41
- package/src/stores/use-chat-store.test.ts +54 -0
- package/src/stores/use-chat-store.ts +21 -5
- /package/{bundled-skills → skills}/google-workspace/SKILL.md +0 -0
|
@@ -196,6 +196,60 @@ describe('useChatStore control-token hygiene', () => {
|
|
|
196
196
|
assert.equal(assistantMessage?.clientRenderId, state.assistantRenderId)
|
|
197
197
|
})
|
|
198
198
|
|
|
199
|
+
it('marks the session idle locally as soon as a direct stream finishes', async () => {
|
|
200
|
+
const session = makeSession({ active: true, currentRunId: 'run-1' } as Partial<Session>)
|
|
201
|
+
useAppStore.setState({
|
|
202
|
+
agents: { 'agent-1': makeAgent() },
|
|
203
|
+
sessions: { [session.id]: session },
|
|
204
|
+
currentAgentId: 'agent-1',
|
|
205
|
+
})
|
|
206
|
+
useChatStore.setState({
|
|
207
|
+
messages: [],
|
|
208
|
+
pendingFiles: [],
|
|
209
|
+
replyingTo: null,
|
|
210
|
+
toolEvents: [],
|
|
211
|
+
streamText: '',
|
|
212
|
+
displayText: '',
|
|
213
|
+
streaming: false,
|
|
214
|
+
streamingSessionId: null,
|
|
215
|
+
streamSource: null,
|
|
216
|
+
assistantRenderId: null,
|
|
217
|
+
streamPhase: 'thinking',
|
|
218
|
+
streamToolName: '',
|
|
219
|
+
thinkingText: '',
|
|
220
|
+
thinkingStartTime: 0,
|
|
221
|
+
queuedMessages: [],
|
|
222
|
+
agentStatus: null,
|
|
223
|
+
lastUsage: null,
|
|
224
|
+
hasMoreMessages: false,
|
|
225
|
+
loadingMore: false,
|
|
226
|
+
totalMessages: 0,
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
global.fetch = (async (input: RequestInfo | URL) => {
|
|
230
|
+
const url = String(input)
|
|
231
|
+
if (url === '/api/chats/session-1/chat') {
|
|
232
|
+
return sseResponse([
|
|
233
|
+
{ t: 'r', text: 'Done' },
|
|
234
|
+
{ t: 'done' },
|
|
235
|
+
])
|
|
236
|
+
}
|
|
237
|
+
if (url === '/api/chats/session-1') {
|
|
238
|
+
return new Response(JSON.stringify({ ...session, active: false, currentRunId: null }), {
|
|
239
|
+
status: 200,
|
|
240
|
+
headers: { 'content-type': 'application/json' },
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
throw new Error(`Unexpected fetch: ${url}`)
|
|
244
|
+
}) as unknown as typeof fetch
|
|
245
|
+
|
|
246
|
+
await useChatStore.getState().sendMessage('Hello', { sessionId: 'session-1' })
|
|
247
|
+
|
|
248
|
+
const refreshedSession = useAppStore.getState().sessions['session-1']
|
|
249
|
+
assert.equal(refreshedSession?.active, false)
|
|
250
|
+
assert.equal(refreshedSession?.currentRunId, null)
|
|
251
|
+
})
|
|
252
|
+
|
|
199
253
|
it('replaces optimistic queued items with the backend queue snapshot', async () => {
|
|
200
254
|
const session = makeSession()
|
|
201
255
|
useAppStore.setState({
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
removeQueuedSessionMessage,
|
|
11
11
|
} from '@/lib/chat/chats'
|
|
12
12
|
import { mergeCompletedAssistantMessage, reconcileClientMessageMetadata } from '@/lib/chat/chat-streaming-state'
|
|
13
|
+
import { createAssistantRenderId } from '@/lib/chat/assistant-render-id'
|
|
13
14
|
import { stripAllInternalMetadata } from '@/lib/strip-internal-metadata'
|
|
14
15
|
import {
|
|
15
16
|
clearQueuedMessagesForSession,
|
|
@@ -152,10 +153,6 @@ function stripHiddenControlTokens(text: string): string {
|
|
|
152
153
|
return cleaned.replace(/\n{3,}/g, '\n\n').trim()
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
function nextAssistantRenderId(): string {
|
|
156
|
-
return `assistant-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`
|
|
157
|
-
}
|
|
158
|
-
|
|
159
156
|
function reconcileMessagesForState(
|
|
160
157
|
nextMessages: Message[],
|
|
161
158
|
currentMessages: Message[],
|
|
@@ -184,6 +181,17 @@ function syncSessionQueueState(sessionId: string, params: {
|
|
|
184
181
|
})
|
|
185
182
|
}
|
|
186
183
|
|
|
184
|
+
function markSessionRunIdle(sessionId: string): void {
|
|
185
|
+
const appState = useAppStore.getState()
|
|
186
|
+
const session = appState.sessions[sessionId]
|
|
187
|
+
if (!session) return
|
|
188
|
+
appState.updateSessionInStore({
|
|
189
|
+
...session,
|
|
190
|
+
active: false,
|
|
191
|
+
currentRunId: null,
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
187
195
|
export const useChatStore = create<ChatState>((set, get) => ({
|
|
188
196
|
streaming: false,
|
|
189
197
|
streamingSessionId: null,
|
|
@@ -239,6 +247,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
239
247
|
s.queuedMessages,
|
|
240
248
|
sessionId,
|
|
241
249
|
snapshotToQueuedMessages(snapshot),
|
|
250
|
+
{ activeRunId: snapshot.activeRunId },
|
|
242
251
|
)
|
|
243
252
|
// Clear "sending" items whose text has already appeared in chat messages
|
|
244
253
|
const messages = s.messages
|
|
@@ -285,6 +294,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
285
294
|
removeQueuedMessageById(s.queuedMessages, optimistic.runId),
|
|
286
295
|
sessionId,
|
|
287
296
|
snapshotToQueuedMessages(response.snapshot),
|
|
297
|
+
{ activeRunId: response.snapshot.activeRunId },
|
|
288
298
|
),
|
|
289
299
|
}))
|
|
290
300
|
syncSessionQueueState(sessionId, {
|
|
@@ -314,6 +324,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
314
324
|
s.queuedMessages,
|
|
315
325
|
sessionId,
|
|
316
326
|
snapshotToQueuedMessages(response.snapshot),
|
|
327
|
+
{ activeRunId: response.snapshot.activeRunId },
|
|
317
328
|
),
|
|
318
329
|
}))
|
|
319
330
|
syncSessionQueueState(sessionId, {
|
|
@@ -331,6 +342,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
331
342
|
s.queuedMessages,
|
|
332
343
|
sessionId,
|
|
333
344
|
snapshotToQueuedMessages(response.snapshot),
|
|
345
|
+
{ activeRunId: response.snapshot.activeRunId },
|
|
334
346
|
),
|
|
335
347
|
}))
|
|
336
348
|
syncSessionQueueState(sessionId, {
|
|
@@ -388,7 +400,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
388
400
|
attachedFiles,
|
|
389
401
|
...(replyToId ? { replyToId } : {}),
|
|
390
402
|
}
|
|
391
|
-
const assistantRenderId =
|
|
403
|
+
const assistantRenderId = createAssistantRenderId()
|
|
392
404
|
set((s) => ({
|
|
393
405
|
streaming: true,
|
|
394
406
|
streamingSessionId: sessionId,
|
|
@@ -603,6 +615,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
603
615
|
thinkingText: '',
|
|
604
616
|
thinkingStartTime: 0,
|
|
605
617
|
}))
|
|
618
|
+
markSessionRunIdle(sessionId)
|
|
606
619
|
if (get().ttsEnabled && !get().voiceConversationActive) speak(visibleFinalText)
|
|
607
620
|
} else {
|
|
608
621
|
set({
|
|
@@ -617,6 +630,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
617
630
|
thinkingText: '',
|
|
618
631
|
thinkingStartTime: 0,
|
|
619
632
|
})
|
|
633
|
+
markSessionRunIdle(sessionId)
|
|
620
634
|
}
|
|
621
635
|
|
|
622
636
|
void useAppStore.getState().refreshSession(sessionId)
|
|
@@ -635,6 +649,7 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
635
649
|
thinkingText: '',
|
|
636
650
|
thinkingStartTime: 0,
|
|
637
651
|
})
|
|
652
|
+
markSessionRunIdle(sessionId)
|
|
638
653
|
}
|
|
639
654
|
}
|
|
640
655
|
},
|
|
@@ -865,5 +880,6 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|
|
865
880
|
toolEvents: [],
|
|
866
881
|
agentStatus: null,
|
|
867
882
|
})
|
|
883
|
+
if (sessionId) markSessionRunIdle(sessionId)
|
|
868
884
|
},
|
|
869
885
|
}))
|
|
File without changes
|