@swarmclawai/swarmclaw 0.8.4 → 0.8.7
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 +9 -9
- package/bin/swarmclaw.js +5 -1
- package/bin/worker-cmd.js +73 -0
- package/package.json +2 -1
- package/src/app/api/agents/[id]/route.ts +17 -7
- package/src/app/api/agents/route.ts +21 -8
- package/src/app/api/approvals/route.test.ts +6 -6
- package/src/app/api/approvals/route.ts +2 -1
- package/src/app/api/auth/route.ts +2 -3
- package/src/app/api/chatrooms/[id]/chat/route.test.ts +299 -0
- package/src/app/api/chatrooms/[id]/chat/route.ts +3 -2
- package/src/app/api/chatrooms/[id]/route.ts +7 -6
- package/src/app/api/chats/[id]/chat/route.test.ts +496 -0
- package/src/app/api/chats/[id]/chat/route.ts +7 -3
- package/src/app/api/chats/[id]/clear/route.ts +9 -9
- package/src/app/api/chats/[id]/devserver/route.ts +2 -1
- package/src/app/api/chats/[id]/edit-resend/route.ts +3 -4
- package/src/app/api/chats/[id]/fork/route.ts +3 -5
- package/src/app/api/chats/[id]/restore/route.ts +6 -7
- package/src/app/api/chats/[id]/retry/route.ts +3 -4
- package/src/app/api/chats/[id]/route.ts +61 -62
- package/src/app/api/chats/route.ts +7 -1
- package/src/app/api/connectors/[id]/route.ts +7 -8
- package/src/app/api/connectors/route.ts +5 -4
- package/src/app/api/eval/run/route.ts +2 -1
- package/src/app/api/eval/suite/route.ts +2 -1
- package/src/app/api/external-agents/route.test.ts +1 -1
- package/src/app/api/external-agents/route.ts +2 -2
- package/src/app/api/files/serve/route.ts +1 -1
- package/src/app/api/gateways/[id]/route.ts +7 -5
- package/src/app/api/gateways/route.ts +1 -1
- package/src/app/api/knowledge/upload/route.ts +1 -1
- package/src/app/api/logs/route.ts +5 -7
- package/src/app/api/memory-images/[filename]/route.ts +2 -3
- package/src/app/api/openclaw/agent-files/route.ts +4 -3
- package/src/app/api/openclaw/approvals/route.ts +3 -4
- package/src/app/api/openclaw/config-sync/route.ts +3 -2
- package/src/app/api/openclaw/cron/route.ts +3 -2
- package/src/app/api/openclaw/dotenv-keys/route.ts +2 -1
- package/src/app/api/openclaw/exec-config/route.ts +3 -2
- package/src/app/api/openclaw/gateway/route.ts +5 -4
- package/src/app/api/openclaw/history/route.ts +3 -2
- package/src/app/api/openclaw/media/route.ts +2 -1
- package/src/app/api/openclaw/permissions/route.ts +3 -2
- package/src/app/api/openclaw/sandbox-env/route.ts +3 -2
- package/src/app/api/openclaw/skills/install/route.ts +2 -1
- package/src/app/api/openclaw/skills/remove/route.ts +2 -1
- package/src/app/api/openclaw/skills/route.ts +3 -2
- package/src/app/api/orchestrator/run/route.ts +5 -14
- package/src/app/api/perf/route.ts +43 -0
- package/src/app/api/plugins/dependencies/route.ts +2 -1
- package/src/app/api/plugins/install/route.ts +2 -1
- package/src/app/api/plugins/marketplace/route.ts +3 -2
- package/src/app/api/plugins/settings/route.ts +2 -1
- package/src/app/api/preview-server/route.ts +11 -10
- package/src/app/api/projects/[id]/route.ts +1 -1
- package/src/app/api/schedules/[id]/route.test.ts +128 -0
- package/src/app/api/schedules/[id]/route.ts +43 -43
- package/src/app/api/schedules/[id]/run/route.ts +11 -62
- package/src/app/api/schedules/route.ts +21 -87
- package/src/app/api/settings/route.ts +2 -0
- package/src/app/api/setup/doctor/route.ts +9 -8
- package/src/app/api/tasks/[id]/approve/route.ts +33 -30
- package/src/app/api/tasks/[id]/route.ts +12 -35
- package/src/app/api/tasks/import/github/route.ts +2 -1
- package/src/app/api/tasks/route.ts +79 -91
- package/src/app/api/wallets/[id]/approve/route.ts +2 -1
- package/src/app/api/wallets/[id]/route.ts +13 -19
- package/src/app/api/wallets/[id]/send/route.ts +2 -1
- package/src/app/api/wallets/route.ts +2 -1
- package/src/app/api/webhooks/[id]/route.ts +2 -1
- package/src/app/api/webhooks/route.test.ts +3 -1
- package/src/app/page.tsx +23 -331
- package/src/cli/index.js +19 -0
- package/src/cli/index.ts +38 -7
- package/src/cli/spec.js +9 -0
- package/src/components/activity/activity-feed.tsx +7 -4
- package/src/components/agents/agent-card.tsx +32 -6
- package/src/components/agents/agent-chat-list.tsx +55 -22
- package/src/components/agents/agent-files-editor.tsx +3 -2
- package/src/components/agents/agent-sheet.tsx +123 -22
- package/src/components/agents/inspector-panel.tsx +1 -1
- package/src/components/agents/openclaw-skills-panel.tsx +2 -1
- package/src/components/agents/trash-list.tsx +1 -1
- package/src/components/auth/access-key-gate.tsx +8 -2
- package/src/components/auth/setup-wizard.tsx +10 -9
- package/src/components/auth/user-picker.tsx +3 -2
- package/src/components/chat/chat-area.tsx +20 -1
- package/src/components/chat/chat-card.tsx +18 -3
- package/src/components/chat/chat-header.tsx +24 -4
- package/src/components/chat/chat-list.tsx +2 -11
- package/src/components/chat/heartbeat-history-panel.tsx +2 -1
- package/src/components/chat/message-bubble.tsx +45 -6
- package/src/components/chat/message-list.tsx +280 -145
- package/src/components/chat/streaming-bubble.tsx +217 -60
- package/src/components/chat/swarm-panel.test.ts +274 -0
- package/src/components/chat/swarm-panel.tsx +410 -0
- package/src/components/chat/swarm-status-card.tsx +346 -0
- package/src/components/chat/tool-call-bubble.tsx +48 -23
- package/src/components/chatrooms/chatroom-list.tsx +8 -5
- package/src/components/chatrooms/chatroom-message.tsx +10 -7
- package/src/components/chatrooms/chatroom-view.tsx +12 -9
- package/src/components/connectors/connector-health.tsx +6 -4
- package/src/components/connectors/connector-list.tsx +16 -11
- package/src/components/connectors/connector-sheet.tsx +12 -6
- package/src/components/home/home-view.tsx +38 -24
- package/src/components/input/chat-input.tsx +10 -1
- package/src/components/layout/app-layout.tsx +2 -38
- package/src/components/layout/sheet-layer.tsx +50 -0
- package/src/components/mcp-servers/mcp-server-list.tsx +37 -5
- package/src/components/mcp-servers/mcp-server-sheet.tsx +12 -2
- package/src/components/plugins/plugin-list.tsx +8 -4
- package/src/components/plugins/plugin-sheet.tsx +2 -1
- package/src/components/providers/provider-list.tsx +3 -2
- package/src/components/providers/provider-sheet.tsx +2 -1
- package/src/components/runs/run-list.tsx +11 -7
- package/src/components/schedules/schedule-card.tsx +5 -3
- package/src/components/shared/agent-switch-dialog.tsx +1 -1
- package/src/components/shared/attachment-chip.tsx +19 -3
- package/src/components/shared/notification-center.tsx +6 -3
- package/src/components/shared/settings/plugin-manager.tsx +3 -2
- package/src/components/shared/settings/section-embedding.tsx +2 -1
- package/src/components/shared/settings/section-orchestrator.tsx +2 -1
- package/src/components/shared/settings/section-user-preferences.tsx +107 -0
- package/src/components/shared/settings/settings-page.tsx +13 -9
- package/src/components/skills/clawhub-browser.tsx +15 -4
- package/src/components/skills/skill-list.tsx +15 -4
- package/src/components/tasks/approvals-panel.tsx +2 -1
- package/src/components/tasks/task-board.tsx +35 -37
- package/src/components/tasks/task-sheet.tsx +4 -3
- package/src/components/ui/full-screen-loader.tsx +164 -0
- package/src/components/wallets/wallet-approval-dialog.tsx +2 -1
- package/src/components/wallets/wallet-panel.tsx +6 -5
- package/src/components/wallets/wallet-section.tsx +3 -2
- package/src/components/webhooks/webhook-list.tsx +4 -5
- package/src/components/webhooks/webhook-sheet.tsx +6 -6
- package/src/hooks/use-app-bootstrap.ts +202 -0
- package/src/hooks/use-mounted-ref.ts +14 -0
- package/src/hooks/use-now.ts +31 -0
- package/src/hooks/use-openclaw-gateway.ts +2 -1
- package/src/instrumentation.ts +20 -8
- package/src/lib/agent-default-tools.test.ts +52 -0
- package/src/lib/agent-default-tools.ts +40 -0
- package/src/lib/api-client.test.ts +21 -0
- package/src/lib/api-client.ts +6 -11
- package/src/lib/canvas-content.test.ts +360 -0
- package/src/lib/chat-streaming-state.test.ts +49 -2
- package/src/lib/chat-streaming-state.ts +26 -10
- package/src/lib/fetch-timeout.test.ts +54 -0
- package/src/lib/fetch-timeout.ts +60 -3
- package/src/lib/live-tool-events.test.ts +77 -0
- package/src/lib/live-tool-events.ts +73 -0
- package/src/lib/local-observability.test.ts +2 -2
- package/src/lib/openclaw-endpoint.test.ts +1 -1
- package/src/lib/providers/anthropic.ts +12 -16
- package/src/lib/providers/index.ts +4 -2
- package/src/lib/providers/ollama.ts +9 -6
- package/src/lib/providers/openai.ts +11 -14
- package/src/lib/runtime-env.test.ts +8 -8
- package/src/lib/schedule-dedupe-advanced.test.ts +2 -2
- package/src/lib/schedule-dedupe.test.ts +1 -1
- package/src/lib/schedule-dedupe.ts +3 -2
- package/src/lib/server/agent-thread-session.test.ts +6 -6
- package/src/lib/server/agent-thread-session.ts +6 -9
- package/src/lib/server/alert-dispatch.ts +2 -1
- package/src/lib/server/api-routes.test.ts +6 -6
- package/src/lib/server/approval-connector-notify.test.ts +4 -4
- package/src/lib/server/approvals-auto-approve.test.ts +29 -29
- package/src/lib/server/approvals.test.ts +317 -0
- package/src/lib/server/approvals.ts +5 -4
- package/src/lib/server/autonomy-runtime.test.ts +11 -11
- package/src/lib/server/browser-state.ts +2 -2
- package/src/lib/server/capability-router.test.ts +1 -1
- package/src/lib/server/capability-router.ts +3 -2
- package/src/lib/server/chat-execution-advanced.test.ts +15 -2
- package/src/lib/server/chat-execution-connector-delivery.ts +67 -0
- package/src/lib/server/chat-execution-disabled.test.ts +3 -3
- package/src/lib/server/chat-execution-eval-history.test.ts +3 -3
- package/src/lib/server/chat-execution-heartbeat.test.ts +42 -1
- package/src/lib/server/chat-execution-session-sync.test.ts +119 -0
- package/src/lib/server/chat-execution-tool-events.ts +116 -0
- package/src/lib/server/chat-execution-utils.test.ts +479 -0
- package/src/lib/server/chat-execution-utils.ts +533 -0
- package/src/lib/server/chat-execution.ts +153 -748
- package/src/lib/server/chat-streaming-utils.ts +174 -0
- package/src/lib/server/chat-turn-tool-routing.ts +310 -0
- package/src/lib/server/chatroom-session-persistence.test.ts +2 -2
- package/src/lib/server/clawhub-client.ts +2 -1
- package/src/lib/server/collection-helpers.test.ts +92 -0
- package/src/lib/server/collection-helpers.ts +25 -3
- package/src/lib/server/connectors/access.ts +146 -0
- package/src/lib/server/connectors/bluebubbles.test.ts +1 -1
- package/src/lib/server/connectors/bluebubbles.ts +4 -4
- package/src/lib/server/connectors/commands.ts +367 -0
- package/src/lib/server/connectors/connector-routing.test.ts +4 -4
- package/src/lib/server/connectors/delivery.ts +142 -0
- package/src/lib/server/connectors/discord.ts +37 -40
- package/src/lib/server/connectors/email.ts +11 -10
- package/src/lib/server/connectors/googlechat.ts +4 -4
- package/src/lib/server/connectors/inbound-audio-transcription.ts +2 -1
- package/src/lib/server/connectors/ingress-delivery.ts +23 -0
- package/src/lib/server/connectors/manager-roundtrip.test.ts +300 -0
- package/src/lib/server/connectors/manager.test.ts +352 -77
- package/src/lib/server/connectors/manager.ts +134 -673
- package/src/lib/server/connectors/matrix.ts +4 -4
- package/src/lib/server/connectors/message-sentinel.ts +7 -0
- package/src/lib/server/connectors/openclaw.test.ts +1 -1
- package/src/lib/server/connectors/openclaw.ts +8 -10
- package/src/lib/server/connectors/outbox.test.ts +192 -0
- package/src/lib/server/connectors/outbox.ts +369 -0
- package/src/lib/server/connectors/pairing.test.ts +18 -1
- package/src/lib/server/connectors/pairing.ts +49 -4
- package/src/lib/server/connectors/policy.ts +9 -3
- package/src/lib/server/connectors/reconnect-state.ts +71 -0
- package/src/lib/server/connectors/response-media.ts +256 -0
- package/src/lib/server/connectors/runtime-state.ts +67 -0
- package/src/lib/server/connectors/session.test.ts +357 -0
- package/src/lib/server/connectors/session.ts +422 -0
- package/src/lib/server/connectors/signal.ts +7 -7
- package/src/lib/server/connectors/slack.ts +43 -43
- package/src/lib/server/connectors/teams.ts +4 -4
- package/src/lib/server/connectors/telegram.ts +37 -43
- package/src/lib/server/connectors/types.ts +31 -1
- package/src/lib/server/connectors/whatsapp.test.ts +108 -0
- package/src/lib/server/connectors/whatsapp.ts +106 -34
- package/src/lib/server/context-manager.test.ts +409 -0
- package/src/lib/server/cost.test.ts +1 -1
- package/src/lib/server/daemon-policy.ts +78 -0
- package/src/lib/server/daemon-state-connectors.test.ts +167 -0
- package/src/lib/server/daemon-state.test.ts +283 -55
- package/src/lib/server/daemon-state.ts +106 -109
- package/src/lib/server/data-dir.test.ts +5 -5
- package/src/lib/server/data-dir.ts +4 -0
- package/src/lib/server/delegation-jobs-advanced.test.ts +1 -1
- package/src/lib/server/delegation-jobs.test.ts +87 -0
- package/src/lib/server/delegation-jobs.ts +42 -48
- package/src/lib/server/devserver-launch.ts +1 -1
- package/src/lib/server/document-utils.ts +7 -9
- package/src/lib/server/elevenlabs.ts +2 -1
- package/src/lib/server/embeddings.test.ts +105 -0
- package/src/lib/server/ethereum.ts +3 -2
- package/src/lib/server/eval/agent-regression.ts +3 -2
- package/src/lib/server/eval/runner.ts +2 -1
- package/src/lib/server/eval/scorer.ts +2 -1
- package/src/lib/server/evm-swap.ts +2 -1
- package/src/lib/server/gateway/protocol.test.ts +1 -1
- package/src/lib/server/guardian.ts +2 -1
- package/src/lib/server/heartbeat-blocked-suppression.test.ts +151 -0
- package/src/lib/server/heartbeat-service-timer.test.ts +6 -6
- package/src/lib/server/heartbeat-service.test.ts +406 -0
- package/src/lib/server/heartbeat-service.ts +54 -7
- package/src/lib/server/heartbeat-wake.test.ts +19 -0
- package/src/lib/server/heartbeat-wake.ts +17 -16
- package/src/lib/server/integrity-monitor.test.ts +149 -0
- package/src/lib/server/json-utils.ts +22 -0
- package/src/lib/server/knowledge-db.test.ts +13 -13
- package/src/lib/server/link-understanding.ts +2 -1
- package/src/lib/server/llm-response-cache.test.ts +1 -1
- package/src/lib/server/main-agent-loop-advanced.test.ts +65 -3
- package/src/lib/server/main-agent-loop.test.ts +6 -6
- package/src/lib/server/main-agent-loop.ts +21 -7
- package/src/lib/server/mcp-client.test.ts +1 -1
- package/src/lib/server/mcp-conformance.test.ts +1 -1
- package/src/lib/server/mcp-conformance.ts +3 -2
- package/src/lib/server/memory-consolidation.ts +2 -1
- package/src/lib/server/memory-db.test.ts +485 -0
- package/src/lib/server/memory-db.ts +39 -26
- package/src/lib/server/memory-graph.test.ts +2 -2
- package/src/lib/server/memory-policy.test.ts +7 -7
- package/src/lib/server/memory-retrieval.test.ts +1 -1
- package/src/lib/server/openclaw-config-sync.ts +2 -1
- package/src/lib/server/openclaw-deploy.test.ts +1 -1
- package/src/lib/server/openclaw-deploy.ts +8 -12
- package/src/lib/server/openclaw-exec-config.ts +2 -1
- package/src/lib/server/openclaw-gateway.ts +6 -7
- package/src/lib/server/openclaw-skills-normalize.ts +2 -1
- package/src/lib/server/openclaw-sync.ts +7 -5
- package/src/lib/server/orchestrator-lg-structure.test.ts +17 -0
- package/src/lib/server/orchestrator-lg.ts +199 -327
- package/src/lib/server/path-utils.ts +31 -0
- package/src/lib/server/perf.ts +161 -0
- package/src/lib/server/plugins-approval-guidance.ts +115 -0
- package/src/lib/server/plugins.test.ts +1 -1
- package/src/lib/server/plugins.ts +22 -132
- package/src/lib/server/process-manager.ts +5 -8
- package/src/lib/server/provider-health.test.ts +137 -0
- package/src/lib/server/provider-health.ts +3 -3
- package/src/lib/server/provider-model-discovery.ts +3 -12
- package/src/lib/server/queue-followups.test.ts +9 -9
- package/src/lib/server/queue-reconcile.test.ts +2 -2
- package/src/lib/server/queue-recovery.test.ts +269 -0
- package/src/lib/server/queue.test.ts +570 -0
- package/src/lib/server/queue.ts +62 -455
- package/src/lib/server/resolve-image.ts +30 -0
- package/src/lib/server/runtime-settings.test.ts +4 -4
- package/src/lib/server/runtime-storage-write-paths.test.ts +60 -0
- package/src/lib/server/schedule-normalization.test.ts +279 -0
- package/src/lib/server/schedule-service.ts +263 -0
- package/src/lib/server/scheduler.ts +17 -74
- package/src/lib/server/session-mailbox.test.ts +191 -0
- package/src/lib/server/session-run-manager.test.ts +640 -0
- package/src/lib/server/session-run-manager.ts +59 -15
- package/src/lib/server/session-tools/autonomy-tools.test.ts +20 -20
- package/src/lib/server/session-tools/calendar.ts +2 -1
- package/src/lib/server/session-tools/canvas.ts +2 -1
- package/src/lib/server/session-tools/chatroom.ts +2 -1
- package/src/lib/server/session-tools/connector.ts +26 -28
- package/src/lib/server/session-tools/context-mgmt.ts +3 -2
- package/src/lib/server/session-tools/crawl.ts +4 -3
- package/src/lib/server/session-tools/crud.ts +105 -324
- package/src/lib/server/session-tools/delegate-fallback.test.ts +9 -9
- package/src/lib/server/session-tools/delegate.ts +6 -8
- package/src/lib/server/session-tools/discovery-approvals.test.ts +15 -15
- package/src/lib/server/session-tools/discovery.ts +4 -3
- package/src/lib/server/session-tools/document.ts +2 -1
- package/src/lib/server/session-tools/email.ts +2 -1
- package/src/lib/server/session-tools/extract.ts +2 -1
- package/src/lib/server/session-tools/file.ts +4 -3
- package/src/lib/server/session-tools/http.ts +2 -1
- package/src/lib/server/session-tools/human-loop.ts +2 -1
- package/src/lib/server/session-tools/image-gen.ts +4 -3
- package/src/lib/server/session-tools/index.ts +26 -30
- package/src/lib/server/session-tools/mailbox.ts +2 -1
- package/src/lib/server/session-tools/manage-connectors.test.ts +4 -4
- package/src/lib/server/session-tools/manage-schedules.test.ts +12 -12
- package/src/lib/server/session-tools/manage-tasks-advanced.test.ts +5 -5
- package/src/lib/server/session-tools/manage-tasks.test.ts +2 -2
- package/src/lib/server/session-tools/monitor.ts +2 -1
- package/src/lib/server/session-tools/platform.ts +2 -1
- package/src/lib/server/session-tools/plugin-creator.ts +2 -1
- package/src/lib/server/session-tools/replicate.ts +3 -2
- package/src/lib/server/session-tools/session-tools-wiring.test.ts +6 -6
- package/src/lib/server/session-tools/shell.ts +4 -9
- package/src/lib/server/session-tools/subagent.ts +322 -170
- package/src/lib/server/session-tools/table.ts +6 -5
- package/src/lib/server/session-tools/wallet-tool.test.ts +3 -3
- package/src/lib/server/session-tools/wallet.ts +7 -6
- package/src/lib/server/session-tools/web-browser-config.test.ts +1 -0
- package/src/lib/server/session-tools/web-utils.ts +317 -0
- package/src/lib/server/session-tools/web.ts +62 -328
- package/src/lib/server/skill-prompt-budget.test.ts +1 -1
- package/src/lib/server/skills-normalize.ts +2 -1
- package/src/lib/server/storage-item-access.test.ts +302 -0
- package/src/lib/server/storage.ts +366 -314
- package/src/lib/server/stream-agent-chat.test.ts +82 -3
- package/src/lib/server/stream-agent-chat.ts +146 -510
- package/src/lib/server/stream-continuation.ts +412 -0
- package/src/lib/server/subagent-lineage.test.ts +647 -0
- package/src/lib/server/subagent-lineage.ts +435 -0
- package/src/lib/server/subagent-runtime.test.ts +484 -0
- package/src/lib/server/subagent-runtime.ts +419 -0
- package/src/lib/server/subagent-swarm.test.ts +391 -0
- package/src/lib/server/subagent-swarm.ts +564 -0
- package/src/lib/server/system-events.ts +3 -3
- package/src/lib/server/task-followups.test.ts +491 -0
- package/src/lib/server/task-followups.ts +391 -0
- package/src/lib/server/task-lifecycle.test.ts +205 -0
- package/src/lib/server/task-lifecycle.ts +200 -0
- package/src/lib/server/task-quality-gate.test.ts +1 -1
- package/src/lib/server/task-resume.ts +208 -0
- package/src/lib/server/task-service.test.ts +108 -0
- package/src/lib/server/task-service.ts +264 -0
- package/src/lib/server/task-validation.test.ts +1 -1
- package/src/lib/server/test-utils/run-with-temp-data-dir.ts +42 -0
- package/src/lib/server/tool-capability-policy.test.ts +2 -2
- package/src/lib/server/tool-capability-policy.ts +3 -2
- package/src/lib/server/tool-planning.ts +2 -1
- package/src/lib/server/tool-retry.ts +2 -3
- package/src/lib/server/wake-dispatcher.test.ts +303 -0
- package/src/lib/server/wake-dispatcher.ts +318 -0
- package/src/lib/server/wake-mode.test.ts +161 -0
- package/src/lib/server/wake-mode.ts +174 -0
- package/src/lib/server/wallet-service.ts +8 -9
- package/src/lib/server/watch-jobs.ts +2 -1
- package/src/lib/server/workspace-context.ts +2 -2
- package/src/lib/shared-utils.test.ts +142 -0
- package/src/lib/shared-utils.ts +62 -0
- package/src/lib/tool-event-summary.ts +2 -1
- package/src/lib/view-routes.test.ts +100 -0
- package/src/lib/wallet.test.ts +322 -6
- package/src/proxy.test.ts +4 -4
- package/src/proxy.ts +2 -3
- package/src/stores/set-if-changed.ts +40 -0
- package/src/stores/slices/agent-slice.ts +111 -0
- package/src/stores/slices/auth-slice.ts +25 -0
- package/src/stores/slices/data-slice.ts +301 -0
- package/src/stores/slices/index.ts +7 -0
- package/src/stores/slices/session-slice.ts +112 -0
- package/src/stores/slices/task-slice.ts +63 -0
- package/src/stores/slices/ui-slice.ts +192 -0
- package/src/stores/use-app-store.ts +17 -822
- package/src/stores/use-approval-store.ts +2 -1
- package/src/stores/use-chat-store.ts +8 -1
- package/src/types/index.ts +10 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ensureGatewayConnected } from './openclaw-gateway'
|
|
2
|
+
import { errorMessage } from '@/lib/shared-utils'
|
|
2
3
|
|
|
3
4
|
export interface ConfigIssue {
|
|
4
5
|
id: string
|
|
@@ -98,7 +99,7 @@ export async function repairConfigIssue(issueId: string): Promise<{ ok: boolean;
|
|
|
98
99
|
return { ok: false, error: `Unknown issue: ${issueId}` }
|
|
99
100
|
}
|
|
100
101
|
} catch (err: unknown) {
|
|
101
|
-
const msg =
|
|
102
|
+
const msg = errorMessage(err)
|
|
102
103
|
if (msg.includes('conflict') && attempt < MAX_RETRIES - 1) continue
|
|
103
104
|
return { ok: false, error: msg }
|
|
104
105
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getOpenClawLocalDeployStatus,
|
|
7
7
|
getOpenClawRemoteDeployCollectionStatus,
|
|
8
8
|
getOpenClawRemoteDeployStatus,
|
|
9
|
-
} from './openclaw-deploy
|
|
9
|
+
} from './openclaw-deploy'
|
|
10
10
|
|
|
11
11
|
const GLOBAL_KEY = '__swarmclaw_openclaw_deploy__' as const
|
|
12
12
|
const originalRuntimeState = (globalThis as typeof globalThis & { [GLOBAL_KEY]?: unknown })[GLOBAL_KEY]
|
|
@@ -3,6 +3,7 @@ import { existsSync } from 'node:fs'
|
|
|
3
3
|
import { promises as fs } from 'node:fs'
|
|
4
4
|
import os from 'node:os'
|
|
5
5
|
import path from 'node:path'
|
|
6
|
+
import { hmrSingleton, sleep } from '@/lib/shared-utils'
|
|
6
7
|
import {
|
|
7
8
|
getManagedProcess,
|
|
8
9
|
killManagedProcess,
|
|
@@ -191,7 +192,7 @@ interface ExposureMeta {
|
|
|
191
192
|
|
|
192
193
|
const DEFAULT_LOCAL_PORT = 18789
|
|
193
194
|
const DEFAULT_REMOTE_PORT = 18789
|
|
194
|
-
const
|
|
195
|
+
const OC_DEPLOY_KEY = '__swarmclaw_openclaw_deploy__'
|
|
195
196
|
|
|
196
197
|
const REMOTE_PROVIDER_META: Record<OpenClawRemoteDeployProvider, RemoteProviderMeta> = {
|
|
197
198
|
hetzner: {
|
|
@@ -542,13 +543,11 @@ function normalizeRuntimeState(raw: unknown): DeployRuntimeState {
|
|
|
542
543
|
}
|
|
543
544
|
|
|
544
545
|
function getRuntimeState(): DeployRuntimeState {
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
return globalState[GLOBAL_KEY] || defaultRuntimeState()
|
|
546
|
+
const raw = hmrSingleton<DeployRuntimeState>(OC_DEPLOY_KEY, defaultRuntimeState)
|
|
547
|
+
const normalized = normalizeRuntimeState(raw)
|
|
548
|
+
// Write back the normalized state so subsequent reads see it
|
|
549
|
+
;(globalThis as Record<string, unknown>)[OC_DEPLOY_KEY] = normalized
|
|
550
|
+
return normalized
|
|
552
551
|
}
|
|
553
552
|
|
|
554
553
|
function shellEscape(value: string): string {
|
|
@@ -818,16 +817,13 @@ async function startRemoteCommand(params: {
|
|
|
818
817
|
}
|
|
819
818
|
}
|
|
820
819
|
|
|
821
|
-
function wait(ms: number): Promise<void> {
|
|
822
|
-
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
823
|
-
}
|
|
824
820
|
|
|
825
821
|
async function waitForLocalRuntime(processId: string, attempts = 12): Promise<void> {
|
|
826
822
|
for (let i = 0; i < attempts; i += 1) {
|
|
827
823
|
const process = getManagedProcess(processId)
|
|
828
824
|
if (!process || process.status !== 'running') break
|
|
829
825
|
if ((process.log || '').toLowerCase().includes('listening')) return
|
|
830
|
-
await
|
|
826
|
+
await sleep(500)
|
|
831
827
|
}
|
|
832
828
|
}
|
|
833
829
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExecApprovalConfig, ExecApprovalSnapshot } from '@/types'
|
|
2
2
|
import { ensureGatewayConnected } from './openclaw-gateway'
|
|
3
|
+
import { errorMessage } from '@/lib/shared-utils'
|
|
3
4
|
|
|
4
5
|
const DEFAULT_CONFIG: ExecApprovalConfig = {
|
|
5
6
|
security: 'deny',
|
|
@@ -39,7 +40,7 @@ export async function setExecConfig(
|
|
|
39
40
|
}) as { hash?: string } | undefined
|
|
40
41
|
return { ok: true, hash: result?.hash ?? '' }
|
|
41
42
|
} catch (err: unknown) {
|
|
42
|
-
const msg =
|
|
43
|
+
const msg = errorMessage(err)
|
|
43
44
|
if (msg.includes('conflict') && attempt < 2) {
|
|
44
45
|
// Re-fetch to get fresh hash
|
|
45
46
|
const fresh = await getExecConfig()
|
|
@@ -5,6 +5,7 @@ import { deriveOpenClawWsUrl } from '@/lib/openclaw-endpoint'
|
|
|
5
5
|
import { loadAgents, loadCredentials, decryptKey } from './storage'
|
|
6
6
|
import { notify, notifyWithPayload } from './ws-hub'
|
|
7
7
|
import { getGatewayProfile, getGatewayProfiles, resolvePrimaryAgentRoute } from './agent-runtime-config'
|
|
8
|
+
import { errorMessage, hmrSingleton } from '@/lib/shared-utils'
|
|
8
9
|
|
|
9
10
|
// --- Types ---
|
|
10
11
|
|
|
@@ -18,18 +19,16 @@ type EventHandler = (payload: unknown) => void
|
|
|
18
19
|
|
|
19
20
|
// --- Singleton (HMR-safe) ---
|
|
20
21
|
|
|
21
|
-
const GK = '__swarmclaw_ocgateway__' as const
|
|
22
|
-
|
|
23
22
|
interface GatewayState {
|
|
24
23
|
instances: Map<string, OpenClawGateway>
|
|
25
24
|
activeKey: string | null
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
function getState(): GatewayState {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
return hmrSingleton<GatewayState>('__swarmclaw_ocgateway__', () => ({
|
|
29
|
+
instances: new Map<string, OpenClawGateway>(),
|
|
30
|
+
activeKey: null,
|
|
31
|
+
}))
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
// --- Helper: resolve gateway config from first OpenClaw agent ---
|
|
@@ -190,7 +189,7 @@ export class OpenClawGateway {
|
|
|
190
189
|
|
|
191
190
|
return true
|
|
192
191
|
} catch (err: unknown) {
|
|
193
|
-
console.error('[openclaw-gateway] Connect error:',
|
|
192
|
+
console.error('[openclaw-gateway] Connect error:', errorMessage(err))
|
|
194
193
|
this.scheduleReconnect()
|
|
195
194
|
return false
|
|
196
195
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OpenClawSkillEntry, SkillInstallOption, SkillRequirements } from '@/types'
|
|
2
|
+
import { dedup } from '@/lib/shared-utils'
|
|
2
3
|
|
|
3
4
|
interface GatewayConfigCheck {
|
|
4
5
|
path?: string
|
|
@@ -38,7 +39,7 @@ interface GatewaySkillsStatusPayload {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
function uniq(values: Array<string | undefined | null>): string[] {
|
|
41
|
-
return
|
|
42
|
+
return dedup(values.map((value) => (value ?? '').trim()).filter(Boolean))
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function normalizeSource(source: string | undefined): OpenClawSkillEntry['source'] {
|
|
@@ -3,7 +3,7 @@ import path from 'node:path'
|
|
|
3
3
|
import crypto from 'node:crypto'
|
|
4
4
|
import { DATA_DIR } from './data-dir'
|
|
5
5
|
import { normalizeOpenClawAgentId } from '@/lib/openclaw-agent-id'
|
|
6
|
-
import { loadSettings, loadAgents,
|
|
6
|
+
import { loadSettings, loadAgents, upsertAgent, loadSchedules, upsertSchedules, loadCredentials, decryptKey, encryptKey } from './storage'
|
|
7
7
|
import { getMemoryDb } from './memory-db'
|
|
8
8
|
import type { AppSettings, MemoryEntry, Schedule } from '@/types'
|
|
9
9
|
|
|
@@ -239,8 +239,7 @@ export function pullAgentFromOpenClaw(agentId: string): { updated: string[] } {
|
|
|
239
239
|
|
|
240
240
|
if (updated.length > 0) {
|
|
241
241
|
agent.updatedAt = Date.now()
|
|
242
|
-
|
|
243
|
-
saveAgents(agents)
|
|
242
|
+
upsertAgent(agentId, agent)
|
|
244
243
|
}
|
|
245
244
|
|
|
246
245
|
return { updated }
|
|
@@ -281,6 +280,7 @@ export function pullSchedulesFromOpenClaw(): { imported: number } {
|
|
|
281
280
|
const schedules = loadSchedules() as Record<string, Schedule>
|
|
282
281
|
const existingNames = new Set(Object.values(schedules).map((s) => `${s.name}|${s.cron}`))
|
|
283
282
|
let imported = 0
|
|
283
|
+
const importedEntries: Array<[string, Schedule]> = []
|
|
284
284
|
|
|
285
285
|
for (const job of raw) {
|
|
286
286
|
if (!job.name || !job.cron) continue
|
|
@@ -288,7 +288,7 @@ export function pullSchedulesFromOpenClaw(): { imported: number } {
|
|
|
288
288
|
if (existingNames.has(key)) continue
|
|
289
289
|
|
|
290
290
|
const id = crypto.randomUUID()
|
|
291
|
-
|
|
291
|
+
const schedule = {
|
|
292
292
|
id,
|
|
293
293
|
name: job.name,
|
|
294
294
|
agentId: job.agentId || '',
|
|
@@ -298,11 +298,13 @@ export function pullSchedulesFromOpenClaw(): { imported: number } {
|
|
|
298
298
|
status: 'active',
|
|
299
299
|
createdAt: Date.now(),
|
|
300
300
|
}
|
|
301
|
+
schedules[id] = schedule as any
|
|
302
|
+
importedEntries.push([id, schedule as any])
|
|
301
303
|
existingNames.add(key)
|
|
302
304
|
imported++
|
|
303
305
|
}
|
|
304
306
|
|
|
305
|
-
if (
|
|
307
|
+
if (importedEntries.length > 0) upsertSchedules(importedEntries)
|
|
306
308
|
return { imported }
|
|
307
309
|
}
|
|
308
310
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import test from 'node:test'
|
|
5
|
+
|
|
6
|
+
const serverDir = path.resolve(path.dirname(new URL(import.meta.url).pathname))
|
|
7
|
+
|
|
8
|
+
test('orchestrator runtime shares tool and graph builders between start and resume flows', () => {
|
|
9
|
+
const src = fs.readFileSync(path.join(serverDir, 'orchestrator-lg.ts'), 'utf-8')
|
|
10
|
+
|
|
11
|
+
assert.equal(src.includes('function createOrchestratorTools('), true)
|
|
12
|
+
assert.equal(src.includes('function compileOrchestratorGraph('), true)
|
|
13
|
+
assert.equal((src.match(/createOrchestratorTools\(/g) || []).length >= 3, true)
|
|
14
|
+
assert.equal((src.match(/compileOrchestratorGraph\(/g) || []).length >= 3, true)
|
|
15
|
+
assert.equal((src.match(/const createTaskTool = tool\(/g) || []).length, 1)
|
|
16
|
+
assert.equal((src.match(/const commentOnTaskTool = tool\(/g) || []).length, 1)
|
|
17
|
+
})
|