@swarmclawai/swarmclaw 0.7.0 → 0.7.2
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 +85 -139
- package/package.json +1 -1
- package/src/app/api/agents/[id]/thread/route.ts +1 -2
- package/src/app/api/agents/route.ts +1 -1
- package/src/app/api/{sessions → chats}/[id]/checkpoints/route.ts +1 -1
- package/src/app/api/{sessions → chats}/[id]/main-loop/route.ts +2 -2
- package/src/app/api/{sessions → chats}/[id]/restore/route.ts +1 -1
- package/src/app/api/{sessions → chats}/[id]/route.ts +4 -52
- package/src/app/api/{sessions → chats}/route.ts +5 -7
- package/src/app/api/plugins/route.ts +3 -0
- package/src/app/api/plugins/settings/route.ts +35 -0
- package/src/app/api/usage/route.ts +30 -0
- package/src/cli/index.js +35 -33
- package/src/cli/index.ts +40 -39
- package/src/cli/spec.js +29 -27
- package/src/components/agents/agent-card.tsx +1 -1
- package/src/components/agents/agent-chat-list.tsx +3 -3
- package/src/components/agents/agent-list.tsx +8 -13
- package/src/components/agents/agent-sheet.tsx +2 -2
- package/src/components/agents/cron-job-form.tsx +3 -3
- package/src/components/agents/inspector-panel.tsx +2 -2
- package/src/components/auth/setup-wizard.tsx +5 -38
- package/src/components/chat/chat-area.tsx +10 -14
- package/src/components/{sessions/session-card.tsx → chat/chat-card.tsx} +3 -3
- package/src/components/chat/chat-header.tsx +156 -73
- package/src/components/{sessions/session-list.tsx → chat/chat-list.tsx} +4 -5
- package/src/components/chat/chat-tool-toggles.tsx +26 -17
- package/src/components/chat/checkpoint-timeline.tsx +4 -4
- package/src/components/chat/message-bubble.tsx +4 -1
- package/src/components/chat/message-list.tsx +2 -2
- package/src/components/{sessions/new-session-sheet.tsx → chat/new-chat-sheet.tsx} +6 -6
- package/src/components/chat/session-debug-panel.tsx +1 -1
- package/src/components/chat/tool-request-banner.tsx +3 -3
- package/src/components/chatrooms/agent-hover-card.tsx +3 -3
- package/src/components/chatrooms/chatroom-tool-request-banner.tsx +2 -2
- package/src/components/connectors/connector-sheet.tsx +1 -1
- package/src/components/home/home-view.tsx +1 -1
- package/src/components/layout/app-layout.tsx +23 -2
- package/src/components/plugins/plugin-list.tsx +475 -254
- package/src/components/plugins/plugin-sheet.tsx +124 -10
- package/src/components/settings/gateway-connection-panel.tsx +1 -1
- package/src/components/shared/command-palette.tsx +0 -1
- package/src/components/shared/settings/section-heartbeat.tsx +1 -1
- package/src/components/shared/settings/section-providers.tsx +1 -1
- package/src/components/shared/settings/settings-page.tsx +1 -12
- package/src/components/usage/metrics-dashboard.tsx +73 -0
- package/src/components/webhooks/webhook-sheet.tsx +1 -1
- package/src/lib/chat.ts +1 -1
- package/src/lib/{sessions.ts → chats.ts} +28 -18
- package/src/lib/providers/claude-cli.ts +1 -1
- package/src/lib/server/approvals.ts +4 -4
- package/src/lib/server/capability-router.ts +10 -8
- package/src/lib/server/chat-execution.ts +36 -105
- package/src/lib/server/chatroom-helpers.ts +3 -3
- package/src/lib/server/connectors/manager.ts +4 -4
- package/src/lib/server/cost.ts +34 -1
- package/src/lib/server/daemon-state.ts +2 -2
- package/src/lib/server/heartbeat-service.ts +1 -1
- package/src/lib/server/main-agent-loop.ts +25 -160
- package/src/lib/server/main-session.ts +6 -13
- package/src/lib/server/orchestrator-lg.ts +3 -3
- package/src/lib/server/orchestrator.ts +5 -5
- package/src/lib/server/plugins.ts +112 -4
- package/src/lib/server/provider-health.ts +5 -3
- package/src/lib/server/queue.ts +12 -10
- package/src/lib/server/session-run-manager.test.ts +9 -6
- package/src/lib/server/session-run-manager.ts +1 -3
- package/src/lib/server/session-tools/calendar.ts +376 -0
- package/src/lib/server/session-tools/canvas.ts +1 -1
- package/src/lib/server/session-tools/chatroom.ts +4 -2
- package/src/lib/server/session-tools/connector.ts +5 -2
- package/src/lib/server/session-tools/context.ts +7 -3
- package/src/lib/server/session-tools/crud.ts +14 -6
- package/src/lib/server/session-tools/delegate.ts +95 -8
- package/src/lib/server/session-tools/discovery.ts +2 -2
- package/src/lib/server/session-tools/edit_file.ts +4 -2
- package/src/lib/server/session-tools/email.ts +322 -0
- package/src/lib/server/session-tools/file.ts +5 -2
- package/src/lib/server/session-tools/git.ts +1 -1
- package/src/lib/server/session-tools/http.ts +1 -1
- package/src/lib/server/session-tools/image-gen.ts +382 -0
- package/src/lib/server/session-tools/index.ts +74 -49
- package/src/lib/server/session-tools/memory.ts +139 -2
- package/src/lib/server/session-tools/monitor.ts +1 -1
- package/src/lib/server/session-tools/openclaw-nodes.ts +1 -1
- package/src/lib/server/session-tools/openclaw-workspace.ts +1 -1
- package/src/lib/server/session-tools/platform.ts +6 -3
- package/src/lib/server/session-tools/plugin-creator.ts +3 -3
- package/src/lib/server/session-tools/replicate.ts +303 -0
- package/src/lib/server/session-tools/sample-ui.ts +1 -1
- package/src/lib/server/session-tools/sandbox.ts +4 -2
- package/src/lib/server/session-tools/schedule.ts +4 -2
- package/src/lib/server/session-tools/session-info.ts +7 -4
- package/src/lib/server/session-tools/shell.ts +5 -2
- package/src/lib/server/session-tools/subagent.ts +2 -2
- package/src/lib/server/session-tools/wallet.ts +29 -2
- package/src/lib/server/session-tools/web.ts +51 -6
- package/src/lib/server/storage.ts +29 -9
- package/src/lib/server/stream-agent-chat.ts +72 -249
- package/src/lib/server/tool-aliases.ts +26 -15
- package/src/lib/server/tool-capability-policy.test.ts +9 -9
- package/src/lib/server/tool-capability-policy.ts +32 -27
- package/src/lib/tool-definitions.ts +4 -0
- package/src/lib/validation/schemas.ts +3 -1
- package/src/stores/use-app-store.ts +5 -5
- package/src/stores/use-chat-store.ts +7 -7
- package/src/types/index.ts +65 -3
- /package/src/app/api/{sessions → chats}/[id]/browser/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/chat/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/clear/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/deploy/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/devserver/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/edit-resend/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/fork/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/mailbox/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/messages/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/retry/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/[id]/stop/route.ts +0 -0
- /package/src/app/api/{sessions → chats}/heartbeat/route.ts +0 -0
package/README.md
CHANGED
|
@@ -14,6 +14,19 @@ Inspired by [OpenClaw](https://github.com/openclaw).
|
|
|
14
14
|
|
|
15
15
|
**[Documentation](https://swarmclaw.ai/docs)** | **[Plugin Tutorial](https://swarmclaw.ai/docs/plugin-tutorial)** | **[Website](https://swarmclaw.ai)**
|
|
16
16
|
|
|
17
|
+
## Documentation Map
|
|
18
|
+
|
|
19
|
+
- [Getting Started](https://swarmclaw.ai/docs/getting-started) - install and first-run setup
|
|
20
|
+
- [Providers](https://swarmclaw.ai/docs/providers) - provider setup and failover options
|
|
21
|
+
- [Agents](https://swarmclaw.ai/docs/agents) - agent configuration, tools, and platform capabilities
|
|
22
|
+
- [Tools](https://swarmclaw.ai/docs/tools) - built-in tool reference and guardrails
|
|
23
|
+
- [Orchestration](https://swarmclaw.ai/docs/orchestration) - multi-agent flows, checkpoints, and restore
|
|
24
|
+
- [Chatrooms](https://swarmclaw.ai/docs/chatrooms) - multi-agent rooms and routing
|
|
25
|
+
- [Connectors](https://swarmclaw.ai/docs/connectors) - Discord/Slack/Telegram/WhatsApp and more
|
|
26
|
+
- [Plugins](https://swarmclaw.ai/docs/plugins) - plugin architecture and extension points
|
|
27
|
+
- [CLI Reference](https://swarmclaw.ai/docs/cli) - complete command reference
|
|
28
|
+
- [Deployment](https://swarmclaw.ai/docs/deployment) - VPS, Docker, and production setup
|
|
29
|
+
|
|
17
30
|

|
|
18
31
|

|
|
19
32
|

|
|
@@ -46,7 +59,7 @@ URLs without a protocol are auto-prefixed with `http://`. For remote gateways wi
|
|
|
46
59
|
|
|
47
60
|
## SwarmClaw ClawHub Skill
|
|
48
61
|
|
|
49
|
-
Use the `swarmclaw` ClawHub skill when you want an OpenClaw agent to operate your SwarmClaw control plane directly from chat: list agents, dispatch tasks, check
|
|
62
|
+
Use the `swarmclaw` ClawHub skill when you want an OpenClaw agent to operate your SwarmClaw control plane directly from chat: list agents, dispatch tasks, check chats, run diagnostics, and coordinate multi-agent work.
|
|
50
63
|
|
|
51
64
|
Install it from ClawHub:
|
|
52
65
|
|
|
@@ -68,6 +81,7 @@ Skill source and runbook: [`swarmclaw/SKILL.md`](swarmclaw/SKILL.md).
|
|
|
68
81
|
- **Claude Code CLI** (optional, for `claude-cli` provider) — [Install](https://docs.anthropic.com/en/docs/claude-code/overview)
|
|
69
82
|
- **OpenAI Codex CLI** (optional, for `codex-cli` provider) — [Install](https://github.com/openai/codex)
|
|
70
83
|
- **OpenCode CLI** (optional, for `opencode-cli` provider) — [Install](https://github.com/opencode-ai/opencode)
|
|
84
|
+
- **Gemini CLI** (optional, for `delegate` backend `gemini`) — install and authenticate `gemini` on your host
|
|
71
85
|
|
|
72
86
|
## Quick Start
|
|
73
87
|
|
|
@@ -85,7 +99,7 @@ curl -fsSL https://raw.githubusercontent.com/swarmclawai/swarmclaw/main/install.
|
|
|
85
99
|
```
|
|
86
100
|
|
|
87
101
|
The installer resolves the latest stable release tag and installs that version by default.
|
|
88
|
-
To pin a version: `SWARMCLAW_VERSION=v0.7.
|
|
102
|
+
To pin a version: `SWARMCLAW_VERSION=v0.7.2 curl ... | bash`
|
|
89
103
|
|
|
90
104
|
Or run locally from the repo (friendly for non-technical users):
|
|
91
105
|
|
|
@@ -149,52 +163,23 @@ Notes:
|
|
|
149
163
|
|
|
150
164
|
## Features
|
|
151
165
|
|
|
152
|
-
- **15
|
|
153
|
-
- **OpenClaw
|
|
154
|
-
- **
|
|
155
|
-
- **
|
|
156
|
-
- **
|
|
157
|
-
- **
|
|
158
|
-
- **
|
|
159
|
-
- **
|
|
160
|
-
- **
|
|
161
|
-
- **
|
|
162
|
-
- **
|
|
163
|
-
- **
|
|
164
|
-
- **
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
- **Session Run Queue** — Per-session queued runs with followup/steer/collect modes, collect coalescing for bursty inputs, and run-state APIs
|
|
170
|
-
- **Chat Iteration Workflow** — Edit-and-resend user turns, fork a new session from any message, bookmark key messages, use contextual follow-up suggestion chips, and auto-continue after tool access grants
|
|
171
|
-
- **Agent Chatrooms** — Multi-agent room conversations with `@mention` routing, chained agent replies, reactions, file/image-aware context, health-aware member filtering, and persistent context compaction for long-lived rooms
|
|
172
|
-
- **Live Chat Telemetry** — Thinking/tool/responding stream phases, live main-loop status badges, connector activity presence, tone indicator, and optional sound notifications
|
|
173
|
-
- **Global Search Palette** — `Cmd/Ctrl+K` search across agents, tasks, sessions, schedules, webhooks, and skills from anywhere in the app
|
|
174
|
-
- **Notification Center** — Real-time in-app notifications for task/schedule/daemon events with unread tracking, mark-all/clear-read controls, and optional action links
|
|
175
|
-
- **Preview-Rich Chat UI** — Side preview panel for tool outputs (image/browser/html/code), inline code/PDF previews for attachments, and image lightbox support
|
|
176
|
-
- **Voice Settings** — Per-instance ElevenLabs API key + voice ID for TTS replies, plus configurable speech recognition language for chat input
|
|
177
|
-
- **Chat Connectors** — Bridge agents to Discord, Slack, Telegram, WhatsApp, BlueBubbles (iMessage), Signal, Microsoft Teams, Google Chat, Matrix, and OpenClaw with media-aware inbound handling, inbound voice-note transcription (ElevenLabs/OpenAI fallback), and WhatsApp-friendly plain-text formatting
|
|
178
|
-
- **Skills System** — Discover local skills, import skills from URL, and load OpenClaw `SKILL.md` files (frontmatter-compatible)
|
|
179
|
-
- **Execution Logging** — Structured audit trail for triggers, tool calls, file ops, commits, and errors in a dedicated `logs.db`
|
|
180
|
-
- **Context Management** — Auto-compaction of conversation history when approaching context limits, with manual `context_status` and `context_summarize` tools for agents
|
|
181
|
-
- **Memory** — Per-agent and per-session memory with hybrid FTS5 + vector embeddings search, query expansion (LLM-generated semantic variants), MMR diversity ranking, cross-agent search (`scope: all`), pinned memories (always preloaded), memory sharing between agents, linked memory graph with interactive visualization, image attachments, and periodic auto-journaling for durable execution context
|
|
182
|
-
- **Knowledge Base** — Shared knowledge store (`knowledge_store` / `knowledge_search` actions) with tags, source tracking, and provenance URLs — separate from per-agent memories
|
|
183
|
-
- **Memory Graph Visualization** — Interactive force-directed graph view of linked memories with node details and relationship exploration
|
|
184
|
-
- **Cost Tracking** — Per-message token counting and cost estimation displayed in the chat header, with per-agent monthly budget caps (`warn` or `block` enforcement)
|
|
185
|
-
- **Provider Health Metrics** — Usage dashboard surfaces provider request volume, success rates, average latency, models used, and last-used timestamps
|
|
186
|
-
- **Model Failover** — Automatic key rotation on rate limits and auth errors with configurable fallback credentials
|
|
187
|
-
- **Plugin System** — Extend agent behavior with JS plugins (hooks: beforeAgentStart, afterAgentComplete, beforeToolExec, afterToolExec, onMessage, onTaskComplete, onAgentDelegation). Plugins can also define custom tools that agents can use
|
|
188
|
-
- **Secrets Vault** — Encrypted storage for API keys and service tokens
|
|
189
|
-
- **Custom Providers** — Add any OpenAI-compatible API as a provider
|
|
190
|
-
- **MCP Servers** — Connect agents to any Model Context Protocol server. Per-agent server selection with tool discovery and per-tool disable toggles
|
|
191
|
-
- **Sandboxed Code Execution** — Agents can write and run JS/TS (Deno) or Python scripts in an isolated sandbox with network access, scoped filesystem, and artifact output
|
|
192
|
-
- **Eval Framework** — Built-in agent evaluation with scenario-based testing across categories (coding, research, companionship, multi-step, memory, planning, tool-usage), weighted scoring criteria, and LLM judge support
|
|
193
|
-
- **Guardian Auto-Recovery** — Automatic workspace recovery when agents fail critically, rolling back to the last known good state via git reset
|
|
194
|
-
- **Soul Library** — Browse and apply pre-built personality templates (archetypes) to agents, or create custom souls for reuse across your swarm
|
|
195
|
-
- **Context Degradation Warnings** — Proactive alerts when context usage exceeds 85%, with strategy recommendations (save to memory, summarize, checkpoint)
|
|
196
|
-
- **Real-Time Sync** — WebSocket push notifications for instant UI updates across tabs and devices (fallback to polling when WS is unavailable)
|
|
197
|
-
- **Mobile-First UI** — Responsive glass-themed dark interface, works on phone and desktop
|
|
166
|
+
- **15 providers out of the box** - CLI providers + major hosted APIs + OpenAI-compatible custom endpoints
|
|
167
|
+
- **OpenClaw-native control plane** - per-agent gateway mapping, reload modes, sync, and approval flows
|
|
168
|
+
- **Agent builder + inspector** - personality/system tuning, skill management, and OpenClaw file editing
|
|
169
|
+
- **Rich toolset** - shell, files, browser, git, sandbox execution, memory, MCP, and delegation
|
|
170
|
+
- **Platform automation** - agents can manage tasks, schedules, chats, connectors, secrets, and more
|
|
171
|
+
- **LangGraph orchestration** - routing to sub-agents with checkpoint timeline and restore
|
|
172
|
+
- **Task board + daemon + scheduler** - long-running autonomous workflows with heartbeat safety
|
|
173
|
+
- **Chat UX** - edit/resend, fork, bookmarks, previews, telemetry, notifications, and search palette
|
|
174
|
+
- **Multi-agent chatrooms** - room routing with mentions, reactions, and persistent context compaction
|
|
175
|
+
- **Connector bridge** - Discord, Slack, Telegram, WhatsApp, Teams, Matrix, OpenClaw, and others
|
|
176
|
+
- **Memory + knowledge** - hybrid search, memory graph, shared knowledge store, and auto-journaling
|
|
177
|
+
- **Operational guardrails** - capability policy, cost tracking, provider health, and credential failover
|
|
178
|
+
- **Extensibility** - plugin hooks/tools/UI extensions plus reusable skills
|
|
179
|
+
|
|
180
|
+
For the full feature matrix and per-capability details, see:
|
|
181
|
+
- https://swarmclaw.ai/docs
|
|
182
|
+
- https://swarmclaw.ai/docs/release-notes
|
|
198
183
|
|
|
199
184
|
## Configuration
|
|
200
185
|
|
|
@@ -206,7 +191,7 @@ CREDENTIAL_SECRET=<auto-generated> # AES-256 encryption key for stored
|
|
|
206
191
|
SWARMCLAW_PLUGIN_FAILURE_THRESHOLD=3 # Consecutive failures before auto-disabling a plugin
|
|
207
192
|
```
|
|
208
193
|
|
|
209
|
-
Data is stored in `data/swarmclaw.db` (SQLite with WAL mode), `data/memory.db` (agent memory with FTS5 + vector embeddings), `data/logs.db` (execution audit trail), and `data/langgraph-checkpoints.db` (orchestrator checkpoints). Back the `data/` directory up if you care about your
|
|
194
|
+
Data is stored in `data/swarmclaw.db` (SQLite with WAL mode), `data/memory.db` (agent memory with FTS5 + vector embeddings), `data/logs.db` (execution audit trail), and `data/langgraph-checkpoints.db` (orchestrator checkpoints). Back the `data/` directory up if you care about your chats, agents, and credentials. Existing JSON file data is auto-migrated to SQLite on first run.
|
|
210
195
|
Agent wallet private keys are stored encrypted (AES-256 via `CREDENTIAL_SECRET`) in `data/swarmclaw.db` and are never returned by wallet API responses; keep `data/` out of version control.
|
|
211
196
|
|
|
212
197
|
The app listens on two ports: `PORT` (default 3456) for the HTTP/SSE API, and `PORT + 1` (default 3457) for WebSocket push notifications. The WS port can be customized with `--ws-port`.
|
|
@@ -289,7 +274,7 @@ Bridge any agent to a chat platform:
|
|
|
289
274
|
| Matrix | matrix-bot-sdk | Homeserver URL + access token |
|
|
290
275
|
| OpenClaw | gateway protocol | OpenClaw connector credentials |
|
|
291
276
|
|
|
292
|
-
Connector
|
|
277
|
+
Connector chats preserve attachment visibility in chat context:
|
|
293
278
|
- WhatsApp media is decoded and persisted to `/api/uploads/...` when possible
|
|
294
279
|
- Telegram and Slack attachments are downloaded to uploads when possible
|
|
295
280
|
- Discord attachments are captured as media metadata/URLs
|
|
@@ -309,21 +294,24 @@ Agents can use the following tools when enabled:
|
|
|
309
294
|
|
|
310
295
|
| Tool | Description |
|
|
311
296
|
|-|-|
|
|
312
|
-
| Shell | Execute commands in the
|
|
297
|
+
| Shell | Execute commands in the chat working directory |
|
|
313
298
|
| Process | Control long-running shell commands (`process_tool`) |
|
|
314
299
|
| Files | Read, write, list, and send files |
|
|
315
|
-
| Copy/Move/Delete File | Optional file ops (`copy_file`, `move_file`, `delete_file`) configurable per agent/
|
|
300
|
+
| Copy/Move/Delete File | Optional file ops (`copy_file`, `move_file`, `delete_file`) configurable per agent/chat (`delete_file` is off by default) |
|
|
316
301
|
| Edit File | Search-and-replace editing (exact match required) |
|
|
317
302
|
| Web Search | Search the web via DuckDuckGo HTML scraping |
|
|
318
303
|
| Web Fetch | Fetch and extract text content from URLs (uses cheerio) |
|
|
319
|
-
| CLI Delegation | Delegate complex tasks to Claude Code, Codex CLI, or
|
|
304
|
+
| CLI Delegation | Delegate complex tasks to Claude Code, Codex CLI, OpenCode CLI, or Gemini CLI |
|
|
320
305
|
| Spawn Subagent | Delegate a sub-task to another agent and capture its response in the current run |
|
|
321
306
|
| Browser | Playwright-powered web browsing via MCP (navigate, click, type, screenshot, PDF) |
|
|
322
|
-
| Canvas | Present/hide/snapshot live HTML content in a
|
|
307
|
+
| Canvas | Present/hide/snapshot live HTML content in a chat canvas panel |
|
|
323
308
|
| HTTP Request | Make direct API calls with method, headers, body, redirect control, and timeout |
|
|
324
309
|
| Git | Run structured git subcommands (`status`, `diff`, `log`, `add`, `commit`, `push`, etc.) with repo safety checks |
|
|
325
310
|
| Memory | Store and retrieve long-term memories with FTS5 + vector search, file references, image attachments, and linked memory graph traversal |
|
|
326
311
|
| Wallet | Manage an agent-linked Solana wallet (`wallet_tool`) to check balance/address, send SOL (limits + approval), and review transaction history |
|
|
312
|
+
| Image Generation | Generate images from prompts (`generate_image`) via OpenAI, Stability, Replicate, fal.ai, Together, Fireworks, BFL, or custom endpoints; saved to uploads |
|
|
313
|
+
| Email | Send outbound email via SMTP (`email`) with `send`/`status` actions |
|
|
314
|
+
| Calendar | Manage Google/Outlook events (`calendar`) with list/create/update/delete/status actions |
|
|
327
315
|
| Sandbox | Run JS/TS (Deno) or Python code in an isolated sandbox. Created files are returned as downloadable artifacts |
|
|
328
316
|
| MCP Servers | Connect to external Model Context Protocol servers. Tools from MCP servers are injected as first-class agent tools |
|
|
329
317
|
|
|
@@ -339,13 +327,13 @@ Agents with platform tools enabled can manage the SwarmClaw instance:
|
|
|
339
327
|
| Reminders | Schedule a conversational wake event in the current chat (`schedule_wake`) |
|
|
340
328
|
| Manage Skills | List, create, update reusable skill definitions |
|
|
341
329
|
| Manage Documents | Upload/search/get/delete indexed docs for lightweight RAG workflows |
|
|
342
|
-
| Manage Webhooks | Register external webhook endpoints that trigger agent
|
|
330
|
+
| Manage Webhooks | Register external webhook endpoints that trigger agent chats |
|
|
343
331
|
| Manage Connectors | Manage chat platform bridges |
|
|
344
332
|
| Manage Chatrooms | Create/list/update chatrooms, manage members, and post room messages for multi-agent collaboration |
|
|
345
|
-
| Manage
|
|
333
|
+
| Manage Chats | Enable `sessions_tool` for list/history/status/send/spawn/stop across chats, plus `context_status` and `context_summarize` for context window management |
|
|
346
334
|
| Manage Secrets | Store and retrieve encrypted reusable secrets |
|
|
347
335
|
|
|
348
|
-
Enable tools per-
|
|
336
|
+
Enable tools per-chat or per-agent in the UI. CLI providers (Claude Code, Codex, OpenCode) handle tools natively through their own CLI.
|
|
349
337
|
OpenClaw provider capabilities are also managed remotely in OpenClaw itself, so local Tools/Platform toggles are hidden for OpenClaw agents.
|
|
350
338
|
|
|
351
339
|
## Starter Skills (URL Import)
|
|
@@ -359,7 +347,7 @@ Import these directly in **Skills → Import via URL**:
|
|
|
359
347
|
|
|
360
348
|
Token usage and estimated costs are tracked per message for API-based providers (Anthropic, OpenAI). After each response, a badge in the chat header shows token count and estimated cost.
|
|
361
349
|
|
|
362
|
-
- **API endpoint:** `GET /api/usage` — returns usage summary by
|
|
350
|
+
- **API endpoint:** `GET /api/usage` — returns usage summary by agent/provider plus plugin-level token rollups (`byPlugin`)
|
|
363
351
|
- **Data:** Stored in `data/swarmclaw.db` (usage table)
|
|
364
352
|
- Cost estimates use published model pricing (updated manually in `src/lib/server/cost.ts`)
|
|
365
353
|
|
|
@@ -372,7 +360,7 @@ Task analytics are available via API for dashboarding and release-readiness chec
|
|
|
372
360
|
|
|
373
361
|
## Background Daemon
|
|
374
362
|
|
|
375
|
-
The daemon auto-processes queued tasks from the scheduler on a 30-second interval. It also runs recurring health checks that detect stale heartbeat
|
|
363
|
+
The daemon auto-processes queued tasks from the scheduler on a 30-second interval. It also runs recurring health checks that detect stale heartbeat chats and can send proactive WhatsApp alerts when issues are detected. Toggle the daemon from the sidebar indicator or via API.
|
|
376
364
|
|
|
377
365
|
Daemon runtime also triggers memory consolidation (daily summary generation plus recurring dedupe/prune maintenance).
|
|
378
366
|
|
|
@@ -381,7 +369,7 @@ Daemon runtime also triggers memory consolidation (daily summary generation plus
|
|
|
381
369
|
|
|
382
370
|
## Main Agent Loop
|
|
383
371
|
|
|
384
|
-
For autonomous long-running missions, enable the **Main Loop** on
|
|
372
|
+
For autonomous long-running missions, enable the **Main Loop** on an agent-thread or orchestrated chat. This lets an agent pursue a goal continuously with heartbeat-driven progress checks and automatic followups.
|
|
385
373
|
|
|
386
374
|
- **Heartbeat prompts:** `SWARM_MAIN_MISSION_TICK` triggers on each heartbeat, giving the agent its goal, status, and pending events
|
|
387
375
|
- **Auto-followup:** When an agent returns `[MAIN_LOOP_META] {"follow_up":true}`, the loop schedules another tick after `delay_sec`
|
|
@@ -389,8 +377,8 @@ For autonomous long-running missions, enable the **Main Loop** on a session. Thi
|
|
|
389
377
|
- **Autonomy modes:**
|
|
390
378
|
- `autonomous`: Agent executes safe actions without confirmation, only asks when blocked by permissions/credentials
|
|
391
379
|
- `assist`: Agent asks before irreversible external actions (sending messages, purchases, account mutations)
|
|
392
|
-
- **API:** `POST /api/
|
|
393
|
-
- **CLI:** `swarmclaw
|
|
380
|
+
- **API:** `POST /api/chats/[id]/main-loop` with `{"tick":true}` to trigger a mission tick
|
|
381
|
+
- **CLI:** `swarmclaw chats main-loop <id>` to inspect loop state, or `swarmclaw chats main-loop-action <id> --data '{"action":"nudge"}'` to control it
|
|
394
382
|
|
|
395
383
|
Use this for background agents that should "keep working" on a goal until blocked or complete.
|
|
396
384
|
|
|
@@ -412,7 +400,7 @@ Configure this in **Settings → Capability Policy** to centrally govern tool ac
|
|
|
412
400
|
- **Blocked tools:** specific tool families or concrete tool names
|
|
413
401
|
- **Allowed tools:** explicit overrides when running stricter modes
|
|
414
402
|
|
|
415
|
-
Policy is enforced in both
|
|
403
|
+
Policy is enforced in both chat tool construction and direct forced tool invocations, so auto-routing and explicit tool requests use the same guardrails.
|
|
416
404
|
|
|
417
405
|
## CLI Troubleshooting
|
|
418
406
|
|
|
@@ -430,11 +418,11 @@ Policy is enforced in both session tool construction and direct forced tool invo
|
|
|
430
418
|
Configure these in **Settings**:
|
|
431
419
|
|
|
432
420
|
- **Voice** — set `ElevenLabs API Key`, `ElevenLabs Voice ID`, and `Speech Recognition Language`
|
|
433
|
-
- **Heartbeat** — set `Heartbeat Interval (Seconds)` and `Heartbeat Prompt` for ongoing
|
|
434
|
-
- **Global heartbeat safety** — use `Stop All
|
|
421
|
+
- **Heartbeat** — set `Heartbeat Interval (Seconds)` and `Heartbeat Prompt` for ongoing chat pings
|
|
422
|
+
- **Global heartbeat safety** — use `Stop All Heartbeats` to disable heartbeat across all chats and cancel in-flight heartbeat runs.
|
|
435
423
|
|
|
436
|
-
Heartbeat pings are internal checks for ongoing
|
|
437
|
-
The daemon health monitor also auto-disables heartbeat on
|
|
424
|
+
Heartbeat pings are internal checks for ongoing chats. If there's no new status, the assistant returns `HEARTBEAT_OK`; otherwise it returns a concise progress update and next step. In chat UI, heartbeat entries render as compact expandable cards and consecutive heartbeat streaks are collapsed to the latest item.
|
|
425
|
+
The daemon health monitor also auto-disables heartbeat on chats that remain stale for an extended period.
|
|
438
426
|
|
|
439
427
|
## Embeddings & Hybrid Memory Search
|
|
440
428
|
|
|
@@ -448,7 +436,7 @@ When enabled, new memories get vector embeddings. Search uses both FTS5 keyword
|
|
|
448
436
|
|
|
449
437
|
## Model Failover
|
|
450
438
|
|
|
451
|
-
Agents and
|
|
439
|
+
Agents and chats can have **fallback credentials**. If the primary API key gets a 401, 429, or 500 error, SwarmClaw automatically retries with the next credential. Configure fallback keys in the agent builder UI.
|
|
452
440
|
|
|
453
441
|
## Plugin System
|
|
454
442
|
|
|
@@ -612,8 +600,8 @@ npm run update:easy # safe update helper for local installs
|
|
|
612
600
|
SwarmClaw uses tag-based releases (`vX.Y.Z`) as the stable channel.
|
|
613
601
|
|
|
614
602
|
```bash
|
|
615
|
-
# example
|
|
616
|
-
npm version
|
|
603
|
+
# example patch release (v0.7.2 style)
|
|
604
|
+
npm version patch
|
|
617
605
|
git push origin main --follow-tags
|
|
618
606
|
```
|
|
619
607
|
|
|
@@ -622,19 +610,20 @@ On `v*` tags, GitHub Actions will:
|
|
|
622
610
|
2. Create a GitHub Release
|
|
623
611
|
3. Build and publish Docker images to `ghcr.io/swarmclawai/swarmclaw` (`:vX.Y.Z`, `:latest`, `:sha-*`)
|
|
624
612
|
|
|
625
|
-
#### v0.7.
|
|
613
|
+
#### v0.7.2 Release Readiness Notes
|
|
626
614
|
|
|
627
|
-
Before shipping `v0.7.
|
|
615
|
+
Before shipping `v0.7.2`, confirm the following user-facing changes are reflected in docs:
|
|
628
616
|
|
|
629
|
-
1.
|
|
630
|
-
2.
|
|
631
|
-
3.
|
|
632
|
-
4.
|
|
633
|
-
5.
|
|
617
|
+
1. `sessions` → `chats` naming is consistent in README, site docs, and CLI/API examples.
|
|
618
|
+
2. New built-in plugins/tools are documented (`image_gen`, `email`, `calendar`) including settings expectations.
|
|
619
|
+
3. Plugin settings support is documented (`settingsFields`, `/api/plugins/settings` read/write endpoints).
|
|
620
|
+
4. Usage telemetry docs include plugin rollups (`byPlugin`) and plugin token usage dashboard context.
|
|
621
|
+
5. Gemini CLI delegation support and `geminiResumeId` task metadata are documented where CLI sessions are described.
|
|
622
|
+
6. Site release notes include a `v0.7.2` section and docs index points to the current release notes version.
|
|
634
623
|
|
|
635
624
|
## CLI
|
|
636
625
|
|
|
637
|
-
SwarmClaw ships a built-in CLI for
|
|
626
|
+
SwarmClaw ships a built-in CLI for setup and day-to-day operations.
|
|
638
627
|
|
|
639
628
|
```bash
|
|
640
629
|
# show command help
|
|
@@ -644,80 +633,37 @@ npm run cli -- --help
|
|
|
644
633
|
node ./bin/swarmclaw.js --help
|
|
645
634
|
```
|
|
646
635
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
636
|
+
Primary groups:
|
|
637
|
+
- `chats` (canonical)
|
|
638
|
+
- `tasks`
|
|
639
|
+
- `schedules`
|
|
640
|
+
- `chatrooms`
|
|
641
|
+
- `connectors`
|
|
642
|
+
- `memory`
|
|
643
|
+
- `setup`
|
|
654
644
|
|
|
655
|
-
|
|
656
|
-
|-|-|
|
|
657
|
-
| `--base-url <url>` | API base URL (default: `http://localhost:3456`) |
|
|
658
|
-
| `--access-key <key>` | Access key override (else `SWARMCLAW_API_KEY` or `platform-api-key.txt`) |
|
|
659
|
-
| `--data <json\|@file\|->` | Request JSON body |
|
|
660
|
-
| `--query key=value` | Query parameter (repeatable) |
|
|
661
|
-
| `--header key=value` | Extra HTTP header (repeatable) |
|
|
662
|
-
| `--json` | Compact JSON output |
|
|
663
|
-
| `--wait` | Wait for run/task completion when IDs are returned |
|
|
664
|
-
| `--timeout-ms <ms>` | Request/wait timeout (default `300000`) |
|
|
665
|
-
| `--interval-ms <ms>` | Poll interval for `--wait` (default `2000`) |
|
|
666
|
-
| `--out <file>` | Write binary response to file |
|
|
667
|
-
|
|
668
|
-
Routing note: `swarmclaw` uses a hybrid router. Some legacy rich commands still support `-u/--url`, `-k/--key`, and `--raw`; mapped API commands use the options above.
|
|
669
|
-
|
|
670
|
-
### Command Groups
|
|
645
|
+
Legacy note: some compatibility paths still accept `sessions`, but `chats` is the canonical command group.
|
|
671
646
|
|
|
672
|
-
|
|
673
|
-
Notable setup/operations groups include:
|
|
674
|
-
|
|
675
|
-
| Group | Purpose |
|
|
676
|
-
|-|-|
|
|
677
|
-
| `setup` | Setup helpers like provider checks and `doctor` diagnostics |
|
|
678
|
-
| `version` | Version status and update helpers |
|
|
679
|
-
| `sessions` | Session lifecycle, chat, browser/devserver controls, mailbox |
|
|
680
|
-
| `chatrooms` | Multi-agent chatrooms (members, reactions, streamed room chat) |
|
|
681
|
-
| `memory` | Memory CRUD and maintenance utilities |
|
|
682
|
-
| `notifications` | In-app notification listing and read-state controls |
|
|
683
|
-
|
|
684
|
-
### Examples
|
|
647
|
+
Quick examples:
|
|
685
648
|
|
|
686
649
|
```bash
|
|
687
650
|
# list agents
|
|
688
651
|
swarmclaw agents list
|
|
689
652
|
|
|
690
|
-
#
|
|
691
|
-
swarmclaw
|
|
653
|
+
# create and inspect a chat
|
|
654
|
+
swarmclaw chats create --name "Main Ops" --agent-id <agentId>
|
|
655
|
+
swarmclaw chats list
|
|
692
656
|
|
|
693
|
-
#
|
|
694
|
-
swarmclaw
|
|
657
|
+
# run a main loop action
|
|
658
|
+
swarmclaw chats main-loop-action <chatId> --data '{"action":"nudge"}'
|
|
695
659
|
|
|
696
660
|
# run setup diagnostics
|
|
697
661
|
swarmclaw setup doctor
|
|
698
|
-
|
|
699
|
-
# interactive setup (walks through provider selection, supports multiple providers)
|
|
700
|
-
swarmclaw setup init
|
|
701
|
-
|
|
702
|
-
# or non-interactive setup with flags
|
|
703
|
-
swarmclaw setup init --provider openai --api-key "$OPENAI_API_KEY"
|
|
704
|
-
|
|
705
|
-
# run memory maintenance analysis
|
|
706
|
-
swarmclaw memory maintenance
|
|
707
|
-
|
|
708
|
-
# list chatrooms
|
|
709
|
-
swarmclaw chatrooms list
|
|
710
|
-
|
|
711
|
-
# send a room message and stream agent replies
|
|
712
|
-
swarmclaw chatrooms chat <chatroomId> --data '{"text":"@all status update?"}'
|
|
713
|
-
|
|
714
|
-
# react to a room message
|
|
715
|
-
swarmclaw chatrooms react <chatroomId> --data '{"messageId":"<messageId>","emoji":"👍"}'
|
|
716
|
-
|
|
717
|
-
# pin/unpin a room message
|
|
718
|
-
swarmclaw chatrooms pin <chatroomId> --data '{"messageId":"<messageId>"}'
|
|
719
662
|
```
|
|
720
663
|
|
|
664
|
+
Full reference (groups, commands, and options):
|
|
665
|
+
- https://swarmclaw.ai/docs/cli
|
|
666
|
+
|
|
721
667
|
## Credits
|
|
722
668
|
|
|
723
669
|
- Inspired by [OpenClaw](https://github.com/openclaw)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swarmclawai/swarmclaw",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Self-hosted AI agent orchestration dashboard — manage LLM providers, orchestrate agent swarms, schedule tasks, and bridge agents to chat platforms.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -49,10 +49,9 @@ export async function POST(req: Request, { params }: { params: Promise<{ id: str
|
|
|
49
49
|
createdAt: now,
|
|
50
50
|
lastActiveAt: now,
|
|
51
51
|
active: false,
|
|
52
|
-
mainSession: true,
|
|
53
52
|
sessionType: 'human' as const,
|
|
54
53
|
agentId,
|
|
55
|
-
|
|
54
|
+
plugins: agent.plugins || agent.tools || [],
|
|
56
55
|
heartbeatEnabled: agent.heartbeatEnabled || false,
|
|
57
56
|
heartbeatIntervalSec: agent.heartbeatIntervalSec || null,
|
|
58
57
|
}
|
|
@@ -59,7 +59,7 @@ export async function POST(req: Request) {
|
|
|
59
59
|
apiEndpoint: normalizeProviderEndpoint(body.provider, body.apiEndpoint || null),
|
|
60
60
|
isOrchestrator: body.isOrchestrator,
|
|
61
61
|
subAgentIds: body.subAgentIds,
|
|
62
|
-
|
|
62
|
+
plugins: body.plugins?.length ? body.plugins : (body.tools || []),
|
|
63
63
|
capabilities: body.capabilities,
|
|
64
64
|
thinkingLevel: body.thinkingLevel || undefined,
|
|
65
65
|
autoRecovery: body.autoRecovery || false,
|
|
@@ -3,7 +3,7 @@ import { getCheckpointSaver } from '@/lib/server/langgraph-checkpoint'
|
|
|
3
3
|
|
|
4
4
|
export const dynamic = 'force-dynamic'
|
|
5
5
|
|
|
6
|
-
/** GET /api/
|
|
6
|
+
/** GET /api/chats/[id]/checkpoints — returns checkpoint history for a thread */
|
|
7
7
|
export async function GET(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
8
8
|
const { id: threadId } = await params
|
|
9
9
|
if (!threadId) return NextResponse.json({ error: 'Thread ID is required' }, { status: 400 })
|
|
@@ -14,7 +14,7 @@ export async function GET(_req: Request, { params }: { params: Promise<{ id: str
|
|
|
14
14
|
const sessions = loadSessions()
|
|
15
15
|
const session = sessions[id]
|
|
16
16
|
if (!session) return new NextResponse('Session not found', { status: 404 })
|
|
17
|
-
if (!isMainSession(session)) return new NextResponse('Main-loop controls only apply to
|
|
17
|
+
if (!isMainSession(session)) return new NextResponse('Main-loop controls only apply to agent thread sessions', { status: 400 })
|
|
18
18
|
const state = getMainLoopStateForSession(id)
|
|
19
19
|
return NextResponse.json({ sessionId: id, state })
|
|
20
20
|
}
|
|
@@ -27,7 +27,7 @@ export async function POST(req: Request, { params }: { params: Promise<{ id: str
|
|
|
27
27
|
const sessions = loadSessions()
|
|
28
28
|
const session = sessions[id]
|
|
29
29
|
if (!session) return new NextResponse('Session not found', { status: 404 })
|
|
30
|
-
if (!isMainSession(session)) return new NextResponse('Main-loop controls only apply to
|
|
30
|
+
if (!isMainSession(session)) return new NextResponse('Main-loop controls only apply to agent thread sessions', { status: 400 })
|
|
31
31
|
|
|
32
32
|
if (action === 'pause') {
|
|
33
33
|
const state = setMainLoopStateForSession(id, { paused: true })
|
|
@@ -5,7 +5,7 @@ import { notify } from '@/lib/server/ws-hub'
|
|
|
5
5
|
|
|
6
6
|
export const dynamic = 'force-dynamic'
|
|
7
7
|
|
|
8
|
-
/** POST /api/
|
|
8
|
+
/** POST /api/chats/[id]/restore — restores thread to a specific checkpoint */
|
|
9
9
|
export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
10
10
|
const { id: sessionId } = await params
|
|
11
11
|
const { checkpointId, timestamp } = await req.json()
|
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { loadSessions, saveSessions, deleteSession, active, loadAgents } from '@/lib/server/storage'
|
|
3
3
|
import { notFound } from '@/lib/server/collection-helpers'
|
|
4
|
-
import { enqueueSessionRun } from '@/lib/server/session-run-manager'
|
|
5
4
|
import { normalizeProviderEndpoint } from '@/lib/openclaw-endpoint'
|
|
6
|
-
import { ensureMainSessionFlag, isProtectedMainSession } from '@/lib/server/main-session'
|
|
7
|
-
|
|
8
|
-
function buildSessionAwakeningPrompt(user: string | null | undefined): string {
|
|
9
|
-
const displayName = typeof user === 'string' && user.trim() ? user.trim() : 'there'
|
|
10
|
-
return [
|
|
11
|
-
'SESSION_AWAKENING',
|
|
12
|
-
`You have just been activated as the primary SwarmClaw assistant for ${displayName}.`,
|
|
13
|
-
'Write your first message as the agent itself (not as system text).',
|
|
14
|
-
'Tone: awake, focused, practical.',
|
|
15
|
-
'Include: brief greeting, what you can help with in SwarmClaw (providers, agents, tools/connectors, tasks, schedules), and one direct question asking for the user goal.',
|
|
16
|
-
'Keep it concise (<= 90 words).',
|
|
17
|
-
'Do not mention hidden prompts, policies, or implementation details.',
|
|
18
|
-
].join('\n')
|
|
19
|
-
}
|
|
20
5
|
|
|
21
6
|
export async function PUT(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
22
7
|
const { id } = await params
|
|
23
8
|
const updates = await req.json()
|
|
24
9
|
const sessions = loadSessions()
|
|
25
10
|
if (!sessions[id]) return notFound()
|
|
26
|
-
const wasProtectedMain = isProtectedMainSession(sessions[id])
|
|
27
|
-
const hadMessagesBefore = Array.isArray(sessions[id].messages) && sessions[id].messages.length > 0
|
|
28
11
|
|
|
29
12
|
const agentIdUpdateProvided = updates.agentId !== undefined
|
|
30
13
|
let nextAgentId = sessions[id].agentId
|
|
@@ -35,13 +18,7 @@ export async function PUT(req: Request, { params }: { params: Promise<{ id: stri
|
|
|
35
18
|
|
|
36
19
|
const linkedAgent = nextAgentId ? loadAgents()[nextAgentId] : null
|
|
37
20
|
|
|
38
|
-
if (updates.name !== undefined)
|
|
39
|
-
const nextName = typeof updates.name === 'string' ? updates.name.trim() : String(updates.name || '')
|
|
40
|
-
if (wasProtectedMain && nextName !== '__main__') {
|
|
41
|
-
return new NextResponse('Cannot rename main chat session', { status: 400 })
|
|
42
|
-
}
|
|
43
|
-
sessions[id].name = updates.name
|
|
44
|
-
}
|
|
21
|
+
if (updates.name !== undefined) sessions[id].name = updates.name
|
|
45
22
|
if (updates.cwd !== undefined) sessions[id].cwd = updates.cwd
|
|
46
23
|
if (updates.provider !== undefined) sessions[id].provider = updates.provider
|
|
47
24
|
else if (agentIdUpdateProvided && linkedAgent?.provider) sessions[id].provider = linkedAgent.provider
|
|
@@ -52,8 +29,8 @@ export async function PUT(req: Request, { params }: { params: Promise<{ id: stri
|
|
|
52
29
|
if (updates.credentialId !== undefined) sessions[id].credentialId = updates.credentialId
|
|
53
30
|
else if (agentIdUpdateProvided && linkedAgent) sessions[id].credentialId = linkedAgent.credentialId ?? null
|
|
54
31
|
|
|
55
|
-
if (updates.
|
|
56
|
-
else if (agentIdUpdateProvided && linkedAgent) sessions[id].
|
|
32
|
+
if (updates.plugins !== undefined) sessions[id].plugins = updates.plugins
|
|
33
|
+
else if (agentIdUpdateProvided && linkedAgent) sessions[id].plugins = Array.isArray(linkedAgent.plugins) ? linkedAgent.plugins : []
|
|
57
34
|
|
|
58
35
|
if (updates.apiEndpoint !== undefined) {
|
|
59
36
|
sessions[id].apiEndpoint = normalizeProviderEndpoint(
|
|
@@ -74,40 +51,15 @@ export async function PUT(req: Request, { params }: { params: Promise<{ id: stri
|
|
|
74
51
|
if (updates.opencodeSessionId !== undefined) sessions[id].opencodeSessionId = updates.opencodeSessionId
|
|
75
52
|
if (updates.delegateResumeIds !== undefined) sessions[id].delegateResumeIds = updates.delegateResumeIds
|
|
76
53
|
if (!Array.isArray(sessions[id].messages)) sessions[id].messages = []
|
|
77
|
-
ensureMainSessionFlag(sessions[id])
|
|
78
|
-
|
|
79
|
-
const shouldKickoffAwakening = isProtectedMainSession(sessions[id])
|
|
80
|
-
&& agentIdUpdateProvided
|
|
81
|
-
&& !!sessions[id].agentId
|
|
82
|
-
&& !hadMessagesBefore
|
|
83
|
-
&& sessions[id].messages.length === 0
|
|
84
54
|
|
|
85
55
|
saveSessions(sessions)
|
|
86
|
-
|
|
87
|
-
if (shouldKickoffAwakening) {
|
|
88
|
-
try {
|
|
89
|
-
enqueueSessionRun({
|
|
90
|
-
sessionId: id,
|
|
91
|
-
message: buildSessionAwakeningPrompt(sessions[id].user),
|
|
92
|
-
internal: true,
|
|
93
|
-
source: 'session-awakening',
|
|
94
|
-
mode: 'steer',
|
|
95
|
-
dedupeKey: `session-awakening:${id}`,
|
|
96
|
-
})
|
|
97
|
-
} catch {
|
|
98
|
-
// Best-effort kickoff only.
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
56
|
return NextResponse.json(sessions[id])
|
|
103
57
|
}
|
|
104
58
|
|
|
105
59
|
export async function DELETE(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
106
60
|
const { id } = await params
|
|
107
61
|
const sessions = loadSessions()
|
|
108
|
-
if (
|
|
109
|
-
return new NextResponse('Cannot delete main chat session', { status: 403 })
|
|
110
|
-
}
|
|
62
|
+
if (!sessions[id]) return notFound()
|
|
111
63
|
if (active.has(id)) {
|
|
112
64
|
try { active.get(id).kill() } catch {}
|
|
113
65
|
active.delete(id)
|
|
@@ -7,7 +7,6 @@ import { WORKSPACE_DIR } from '@/lib/server/data-dir'
|
|
|
7
7
|
import { notify } from '@/lib/server/ws-hub'
|
|
8
8
|
import { getSessionRunState } from '@/lib/server/session-run-manager'
|
|
9
9
|
import { normalizeProviderEndpoint } from '@/lib/openclaw-endpoint'
|
|
10
|
-
import { ensureMainSessionFlag, isProtectedMainSession } from '@/lib/server/main-session'
|
|
11
10
|
export const dynamic = 'force-dynamic'
|
|
12
11
|
|
|
13
12
|
|
|
@@ -39,7 +38,7 @@ export async function DELETE(req: Request) {
|
|
|
39
38
|
const sessions = loadSessions()
|
|
40
39
|
let deleted = 0
|
|
41
40
|
for (const id of ids) {
|
|
42
|
-
if (
|
|
41
|
+
if (!sessions[id]) continue
|
|
43
42
|
if (active.has(id)) {
|
|
44
43
|
try { active.get(id).kill() } catch {}
|
|
45
44
|
active.delete(id)
|
|
@@ -61,15 +60,15 @@ export async function POST(req: Request) {
|
|
|
61
60
|
const id = body.id || genId()
|
|
62
61
|
const sessions = loadSessions()
|
|
63
62
|
const agent = body.agentId ? loadAgents()[body.agentId] : null
|
|
64
|
-
const
|
|
65
|
-
const
|
|
63
|
+
const requestedPlugins = Array.isArray(body.plugins) ? body.plugins : (Array.isArray(body.tools) ? body.tools : null)
|
|
64
|
+
const resolvedPlugins = requestedPlugins ?? (Array.isArray(agent?.plugins) ? agent.plugins : (Array.isArray(agent?.tools) ? agent.tools : []))
|
|
66
65
|
|
|
67
66
|
// If session with this ID already exists, return it as-is
|
|
68
67
|
if (body.id && sessions[id]) {
|
|
69
68
|
return NextResponse.json(sessions[id])
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
const sessionName = body.name || 'New
|
|
71
|
+
const sessionName = body.name || 'New Chat'
|
|
73
72
|
|
|
74
73
|
sessions[id] = {
|
|
75
74
|
id, name: sessionName, cwd,
|
|
@@ -94,11 +93,10 @@ export async function POST(req: Request) {
|
|
|
94
93
|
sessionType: body.sessionType || 'human',
|
|
95
94
|
agentId: body.agentId || null,
|
|
96
95
|
parentSessionId: body.parentSessionId || null,
|
|
97
|
-
|
|
96
|
+
plugins: resolvedPlugins,
|
|
98
97
|
heartbeatEnabled: body.heartbeatEnabled ?? null,
|
|
99
98
|
heartbeatIntervalSec: body.heartbeatIntervalSec ?? null,
|
|
100
99
|
}
|
|
101
|
-
ensureMainSessionFlag(sessions[id])
|
|
102
100
|
saveSessions(sessions)
|
|
103
101
|
notify('sessions')
|
|
104
102
|
return NextResponse.json(sessions[id])
|