@swarmclawai/swarmclaw 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/README.md +12 -15
  2. package/next.config.ts +13 -2
  3. package/package.json +4 -2
  4. package/src/app/api/agents/[id]/thread/route.ts +9 -0
  5. package/src/app/api/agents/route.ts +4 -0
  6. package/src/app/api/agents/thread-route.test.ts +133 -0
  7. package/src/app/api/approvals/route.test.ts +148 -0
  8. package/src/app/api/canvas/[sessionId]/route.ts +3 -1
  9. package/src/app/api/chatrooms/[id]/chat/route.ts +4 -2
  10. package/src/app/api/chats/[id]/devserver/route.ts +48 -7
  11. package/src/app/api/chats/[id]/messages/route.ts +42 -18
  12. package/src/app/api/chats/[id]/route.ts +1 -1
  13. package/src/app/api/chats/[id]/stop/route.ts +5 -4
  14. package/src/app/api/chats/route.ts +22 -2
  15. package/src/app/api/clawhub/install/route.ts +28 -8
  16. package/src/app/api/connectors/[id]/route.ts +26 -1
  17. package/src/app/api/external-agents/route.test.ts +165 -0
  18. package/src/app/api/gateways/[id]/health/route.ts +27 -12
  19. package/src/app/api/gateways/[id]/route.ts +2 -0
  20. package/src/app/api/gateways/health-route.test.ts +135 -0
  21. package/src/app/api/gateways/route.ts +2 -0
  22. package/src/app/api/mcp-servers/route.test.ts +130 -0
  23. package/src/app/api/openclaw/deploy/route.ts +38 -5
  24. package/src/app/api/plugins/install/route.ts +46 -6
  25. package/src/app/api/plugins/marketplace/route.ts +48 -15
  26. package/src/app/api/preview-server/route.ts +26 -11
  27. package/src/app/api/schedules/[id]/run/route.ts +4 -0
  28. package/src/app/api/schedules/route.test.ts +86 -0
  29. package/src/app/api/schedules/route.ts +6 -1
  30. package/src/app/api/setup/check-provider/route.test.ts +19 -0
  31. package/src/app/api/setup/check-provider/route.ts +40 -10
  32. package/src/app/api/skills/[id]/route.ts +12 -0
  33. package/src/app/api/skills/import/route.ts +14 -12
  34. package/src/app/api/skills/route.ts +13 -1
  35. package/src/app/api/tasks/[id]/route.ts +10 -1
  36. package/src/app/api/tasks/import/github/route.test.ts +65 -0
  37. package/src/app/api/tasks/import/github/route.ts +337 -0
  38. package/src/app/api/wallets/[id]/approve/route.ts +17 -3
  39. package/src/app/api/wallets/[id]/route.ts +79 -33
  40. package/src/app/api/wallets/[id]/send/route.ts +19 -33
  41. package/src/app/api/wallets/route.ts +78 -61
  42. package/src/app/api/webhooks/[id]/route.ts +33 -6
  43. package/src/app/api/webhooks/route.test.ts +272 -0
  44. package/src/cli/index.js +1 -0
  45. package/src/cli/spec.js +1 -0
  46. package/src/components/agents/agent-card.tsx +9 -2
  47. package/src/components/agents/agent-chat-list.tsx +18 -2
  48. package/src/components/agents/agent-list.tsx +1 -0
  49. package/src/components/agents/agent-sheet.tsx +73 -24
  50. package/src/components/agents/inspector-panel.tsx +41 -0
  51. package/src/components/canvas/canvas-panel.tsx +236 -65
  52. package/src/components/chat/chat-card.tsx +36 -13
  53. package/src/components/chat/chat-header.tsx +44 -16
  54. package/src/components/chat/chat-list.tsx +28 -4
  55. package/src/components/chat/checkpoint-timeline.tsx +50 -34
  56. package/src/components/chat/message-bubble.tsx +208 -145
  57. package/src/components/chat/message-list.tsx +48 -19
  58. package/src/components/chatrooms/chatroom-message.tsx +2 -2
  59. package/src/components/chatrooms/chatroom-sheet.tsx +16 -2
  60. package/src/components/connectors/connector-health.tsx +1 -1
  61. package/src/components/connectors/connector-list.tsx +7 -2
  62. package/src/components/connectors/connector-sheet.tsx +337 -148
  63. package/src/components/gateways/gateway-sheet.tsx +2 -2
  64. package/src/components/mcp-servers/mcp-server-list.tsx +26 -5
  65. package/src/components/mcp-servers/mcp-server-sheet.tsx +19 -2
  66. package/src/components/openclaw/openclaw-deploy-panel.tsx +269 -21
  67. package/src/components/plugins/plugin-list.tsx +45 -9
  68. package/src/components/plugins/plugin-sheet.tsx +55 -7
  69. package/src/components/providers/provider-list.tsx +2 -1
  70. package/src/components/providers/provider-sheet.tsx +21 -2
  71. package/src/components/schedules/schedule-card.tsx +25 -1
  72. package/src/components/schedules/schedule-sheet.tsx +44 -2
  73. package/src/components/secrets/secret-sheet.tsx +21 -2
  74. package/src/components/shared/agent-switch-dialog.tsx +12 -1
  75. package/src/components/shared/bottom-sheet.tsx +13 -3
  76. package/src/components/shared/command-palette.tsx +8 -1
  77. package/src/components/shared/confirm-dialog.tsx +19 -4
  78. package/src/components/shared/connector-platform-icon.test.ts +28 -0
  79. package/src/components/shared/connector-platform-icon.tsx +39 -6
  80. package/src/components/shared/settings/plugin-manager.tsx +29 -6
  81. package/src/components/shared/settings/section-capability-policy.tsx +7 -3
  82. package/src/components/skills/skill-list.tsx +25 -0
  83. package/src/components/skills/skill-sheet.tsx +84 -12
  84. package/src/components/tasks/approvals-panel.tsx +191 -95
  85. package/src/components/tasks/task-board.tsx +273 -2
  86. package/src/components/tasks/task-card.tsx +38 -9
  87. package/src/components/ui/dialog.tsx +2 -2
  88. package/src/components/wallets/wallet-approval-dialog.tsx +4 -2
  89. package/src/components/wallets/wallet-panel.tsx +435 -90
  90. package/src/components/wallets/wallet-section.tsx +198 -48
  91. package/src/components/webhooks/webhook-sheet.tsx +22 -2
  92. package/src/lib/approval-display.ts +20 -0
  93. package/src/lib/canvas-content.ts +198 -0
  94. package/src/lib/chat-artifact-summary.ts +165 -0
  95. package/src/lib/chat-display.test.ts +91 -0
  96. package/src/lib/chat-display.ts +58 -0
  97. package/src/lib/chat-streaming-state.test.ts +47 -1
  98. package/src/lib/chat-streaming-state.ts +42 -0
  99. package/src/lib/ollama-model.ts +10 -0
  100. package/src/lib/openclaw-endpoint.test.ts +8 -0
  101. package/src/lib/openclaw-endpoint.ts +6 -1
  102. package/src/lib/plugin-install-cors.ts +46 -0
  103. package/src/lib/plugin-sources.test.ts +43 -0
  104. package/src/lib/plugin-sources.ts +77 -0
  105. package/src/lib/providers/ollama.ts +16 -6
  106. package/src/lib/providers/openclaw.test.ts +54 -0
  107. package/src/lib/providers/openclaw.ts +127 -11
  108. package/src/lib/schedule-dedupe-advanced.test.ts +1335 -0
  109. package/src/lib/schedule-dedupe.test.ts +66 -1
  110. package/src/lib/schedule-dedupe.ts +169 -12
  111. package/src/lib/schedule-origin.test.ts +20 -0
  112. package/src/lib/schedule-origin.ts +15 -0
  113. package/src/lib/server/__fixtures__/fake-mcp-stdio-server.mjs +27 -0
  114. package/src/lib/server/agent-availability.ts +16 -0
  115. package/src/lib/server/agent-runtime-config.ts +12 -4
  116. package/src/lib/server/agent-thread-session.test.ts +51 -0
  117. package/src/lib/server/agent-thread-session.ts +7 -0
  118. package/src/lib/server/approval-match.ts +205 -0
  119. package/src/lib/server/approvals-auto-approve.test.ts +538 -1
  120. package/src/lib/server/approvals.ts +214 -1
  121. package/src/lib/server/assistant-control.test.ts +29 -0
  122. package/src/lib/server/assistant-control.ts +23 -0
  123. package/src/lib/server/build-llm.test.ts +79 -0
  124. package/src/lib/server/build-llm.ts +14 -4
  125. package/src/lib/server/canvas-content.test.ts +32 -0
  126. package/src/lib/server/canvas-content.ts +6 -0
  127. package/src/lib/server/capability-router.test.ts +11 -0
  128. package/src/lib/server/capability-router.ts +26 -1
  129. package/src/lib/server/chat-execution-advanced.test.ts +651 -0
  130. package/src/lib/server/chat-execution-disabled.test.ts +94 -0
  131. package/src/lib/server/chat-execution-tool-events.test.ts +157 -0
  132. package/src/lib/server/chat-execution.ts +353 -72
  133. package/src/lib/server/clawhub-client.test.ts +14 -8
  134. package/src/lib/server/connectors/manager.test.ts +1147 -0
  135. package/src/lib/server/connectors/manager.ts +362 -63
  136. package/src/lib/server/connectors/pairing.ts +26 -5
  137. package/src/lib/server/connectors/types.ts +2 -0
  138. package/src/lib/server/connectors/whatsapp.test.ts +134 -0
  139. package/src/lib/server/connectors/whatsapp.ts +271 -47
  140. package/src/lib/server/context-manager.ts +6 -1
  141. package/src/lib/server/daemon-state.ts +1 -1
  142. package/src/lib/server/data-dir.test.ts +37 -0
  143. package/src/lib/server/data-dir.ts +20 -1
  144. package/src/lib/server/delegation-jobs-advanced.test.ts +513 -0
  145. package/src/lib/server/devserver-launch.test.ts +60 -0
  146. package/src/lib/server/devserver-launch.ts +85 -0
  147. package/src/lib/server/elevenlabs.test.ts +189 -1
  148. package/src/lib/server/elevenlabs.ts +147 -43
  149. package/src/lib/server/ethereum.ts +590 -0
  150. package/src/lib/server/eval/agent-regression-advanced.test.ts +302 -0
  151. package/src/lib/server/eval/agent-regression.test.ts +18 -1
  152. package/src/lib/server/eval/agent-regression.ts +383 -11
  153. package/src/lib/server/evm-swap.ts +475 -0
  154. package/src/lib/server/execution-log.ts +1 -0
  155. package/src/lib/server/heartbeat-service-timer.test.ts +173 -0
  156. package/src/lib/server/heartbeat-service.ts +15 -10
  157. package/src/lib/server/heartbeat-wake.test.ts +112 -0
  158. package/src/lib/server/heartbeat-wake.ts +338 -57
  159. package/src/lib/server/main-agent-loop-advanced.test.ts +538 -0
  160. package/src/lib/server/mcp-client.test.ts +16 -0
  161. package/src/lib/server/mcp-client.ts +25 -0
  162. package/src/lib/server/memory-integration.test.ts +719 -0
  163. package/src/lib/server/memory-policy.test.ts +43 -0
  164. package/src/lib/server/memory-policy.ts +132 -0
  165. package/src/lib/server/memory-tiers.test.ts +60 -0
  166. package/src/lib/server/memory-tiers.ts +16 -0
  167. package/src/lib/server/ollama-runtime.ts +58 -0
  168. package/src/lib/server/openclaw-deploy.test.ts +109 -1
  169. package/src/lib/server/openclaw-deploy.ts +557 -81
  170. package/src/lib/server/openclaw-gateway.test.ts +131 -0
  171. package/src/lib/server/openclaw-gateway.ts +10 -4
  172. package/src/lib/server/openclaw-health.test.ts +35 -0
  173. package/src/lib/server/openclaw-health.ts +215 -47
  174. package/src/lib/server/orchestrator-lg.ts +2 -2
  175. package/src/lib/server/plugins-advanced.test.ts +351 -0
  176. package/src/lib/server/plugins.ts +205 -5
  177. package/src/lib/server/queue-advanced.test.ts +528 -0
  178. package/src/lib/server/queue-followups.test.ts +262 -0
  179. package/src/lib/server/queue-reconcile.test.ts +128 -0
  180. package/src/lib/server/queue.ts +293 -61
  181. package/src/lib/server/scheduler.ts +29 -1
  182. package/src/lib/server/session-note.test.ts +36 -0
  183. package/src/lib/server/session-note.ts +42 -0
  184. package/src/lib/server/session-run-manager.ts +52 -4
  185. package/src/lib/server/session-tools/canvas.ts +14 -12
  186. package/src/lib/server/session-tools/connector.test.ts +138 -0
  187. package/src/lib/server/session-tools/connector.ts +348 -61
  188. package/src/lib/server/session-tools/context.ts +12 -3
  189. package/src/lib/server/session-tools/crud.ts +221 -10
  190. package/src/lib/server/session-tools/delegate-fallback.test.ts +103 -0
  191. package/src/lib/server/session-tools/delegate.ts +64 -8
  192. package/src/lib/server/session-tools/discovery-approvals.test.ts +142 -0
  193. package/src/lib/server/session-tools/discovery.ts +80 -12
  194. package/src/lib/server/session-tools/file-normalize.test.ts +36 -0
  195. package/src/lib/server/session-tools/file.ts +43 -4
  196. package/src/lib/server/session-tools/human-loop.ts +35 -5
  197. package/src/lib/server/session-tools/index.ts +44 -9
  198. package/src/lib/server/session-tools/manage-connectors.test.ts +139 -0
  199. package/src/lib/server/session-tools/manage-schedules-advanced.test.ts +564 -0
  200. package/src/lib/server/session-tools/manage-schedules.test.ts +283 -0
  201. package/src/lib/server/session-tools/manage-tasks-advanced.test.ts +852 -0
  202. package/src/lib/server/session-tools/memory.test.ts +93 -0
  203. package/src/lib/server/session-tools/memory.ts +546 -79
  204. package/src/lib/server/session-tools/normalize-tool-args.ts +1 -1
  205. package/src/lib/server/session-tools/plugin-creator.ts +57 -1
  206. package/src/lib/server/session-tools/primitive-tools.test.ts +6 -0
  207. package/src/lib/server/session-tools/schedule.ts +6 -1
  208. package/src/lib/server/session-tools/shell-normalize.test.ts +25 -1
  209. package/src/lib/server/session-tools/shell.ts +22 -3
  210. package/src/lib/server/session-tools/wallet-tool.test.ts +254 -0
  211. package/src/lib/server/session-tools/wallet.ts +1374 -139
  212. package/src/lib/server/session-tools/web-inputs.test.ts +162 -1
  213. package/src/lib/server/session-tools/web.ts +468 -64
  214. package/src/lib/server/skill-discovery.ts +128 -0
  215. package/src/lib/server/skill-eligibility.test.ts +84 -0
  216. package/src/lib/server/skill-eligibility.ts +95 -0
  217. package/src/lib/server/skill-prompt-budget.test.ts +102 -0
  218. package/src/lib/server/skill-prompt-budget.ts +125 -0
  219. package/src/lib/server/skills-normalize.test.ts +54 -0
  220. package/src/lib/server/skills-normalize.ts +372 -26
  221. package/src/lib/server/solana.ts +214 -29
  222. package/src/lib/server/storage.ts +65 -36
  223. package/src/lib/server/stream-agent-chat.test.ts +419 -9
  224. package/src/lib/server/stream-agent-chat.ts +887 -83
  225. package/src/lib/server/system-events.ts +1 -1
  226. package/src/lib/server/tool-capability-policy-advanced.test.ts +502 -0
  227. package/src/lib/server/tool-loop-detection.test.ts +105 -0
  228. package/src/lib/server/tool-loop-detection.ts +260 -0
  229. package/src/lib/server/tool-planning.ts +4 -2
  230. package/src/lib/server/wallet-execution.test.ts +198 -0
  231. package/src/lib/server/wallet-portfolio.test.ts +98 -0
  232. package/src/lib/server/wallet-portfolio.ts +724 -0
  233. package/src/lib/server/wallet-service.test.ts +57 -0
  234. package/src/lib/server/wallet-service.ts +213 -0
  235. package/src/lib/server/watch-jobs-advanced.test.ts +594 -0
  236. package/src/lib/server/watch-jobs.ts +17 -2
  237. package/src/lib/server/workspace-context.ts +111 -0
  238. package/src/lib/skill-save-payload.test.ts +39 -0
  239. package/src/lib/skill-save-payload.ts +37 -0
  240. package/src/lib/tasks.ts +28 -0
  241. package/src/lib/tool-event-summary.test.ts +30 -0
  242. package/src/lib/tool-event-summary.ts +37 -0
  243. package/src/lib/validation/schemas.ts +1 -0
  244. package/src/lib/wallet-transactions.test.ts +75 -0
  245. package/src/lib/wallet-transactions.ts +43 -0
  246. package/src/lib/wallet.test.ts +17 -0
  247. package/src/lib/wallet.ts +183 -0
  248. package/src/proxy.test.ts +31 -0
  249. package/src/proxy.ts +34 -2
  250. package/src/stores/use-chat-store.ts +15 -1
  251. package/src/types/index.ts +210 -14
package/src/proxy.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { NextResponse } from 'next/server'
2
2
  import type { NextRequest } from 'next/server'
3
3
  import { AUTH_COOKIE_NAME } from '@/lib/auth'
4
+ import {
5
+ buildPluginInstallCorsHeaders,
6
+ isPluginInstallCorsPath,
7
+ resolvePluginInstallCorsOrigin,
8
+ } from '@/lib/plugin-install-cors'
4
9
 
5
10
  /* ------------------------------------------------------------------ */
6
11
  /* Rate-limit state — HMR-safe via globalThis */
@@ -40,6 +45,16 @@ function getClientIp(request: NextRequest): string {
40
45
  return (request as unknown as { ip?: string }).ip ?? 'unknown'
41
46
  }
42
47
 
48
+ function withPluginInstallCorsHeaders(pathname: string, origin: string | null, headers?: HeadersInit): Headers {
49
+ const merged = new Headers(headers)
50
+ if (!isPluginInstallCorsPath(pathname)) return merged
51
+ const corsHeaders = buildPluginInstallCorsHeaders(origin)
52
+ new Headers(corsHeaders).forEach((value, key) => {
53
+ merged.set(key, value)
54
+ })
55
+ return merged
56
+ }
57
+
43
58
  /* ------------------------------------------------------------------ */
44
59
  /* Proxy */
45
60
  /* ------------------------------------------------------------------ */
@@ -51,11 +66,22 @@ function getClientIp(request: NextRequest): string {
51
66
  */
52
67
  export function proxy(request: NextRequest) {
53
68
  const { pathname } = request.nextUrl
69
+ const corsOrigin = resolvePluginInstallCorsOrigin(request.headers.get('origin'))
54
70
  const isWebhookTrigger = request.method === 'POST'
55
71
  && /^\/api\/webhooks\/[^/]+\/?$/.test(pathname)
56
72
  const isConnectorWebhook = request.method === 'POST'
57
73
  && /^\/api\/connectors\/[^/]+\/webhook\/?$/.test(pathname)
58
74
 
75
+ if (request.method === 'OPTIONS' && isPluginInstallCorsPath(pathname)) {
76
+ if (!corsOrigin) {
77
+ return NextResponse.json({ error: 'Origin not allowed' }, { status: 403 })
78
+ }
79
+ return new NextResponse(null, {
80
+ status: 204,
81
+ headers: buildPluginInstallCorsHeaders(corsOrigin),
82
+ })
83
+ }
84
+
59
85
  // Only protect API routes (not auth or inbound webhooks)
60
86
  if (
61
87
  !pathname.startsWith('/api/')
@@ -83,7 +109,10 @@ export function proxy(request: NextRequest) {
83
109
  const retryAfter = Math.ceil((entry.lockedUntil - Date.now()) / 1000)
84
110
  return NextResponse.json(
85
111
  { error: 'Too many failed attempts. Try again later.', retryAfter },
86
- { status: 429, headers: { 'Retry-After': String(retryAfter) } },
112
+ {
113
+ status: 429,
114
+ headers: withPluginInstallCorsHeaders(pathname, corsOrigin, { 'Retry-After': String(retryAfter) }),
115
+ },
87
116
  )
88
117
  }
89
118
 
@@ -106,7 +135,10 @@ export function proxy(request: NextRequest) {
106
135
  const remaining = Math.max(0, MAX_ATTEMPTS - current.count)
107
136
  return NextResponse.json(
108
137
  { error: 'Unauthorized' },
109
- { status: 401, headers: { 'X-RateLimit-Remaining': String(remaining) } },
138
+ {
139
+ status: 401,
140
+ headers: withPluginInstallCorsHeaders(pathname, corsOrigin, { 'X-RateLimit-Remaining': String(remaining) }),
141
+ },
110
142
  )
111
143
  }
112
144
 
@@ -36,7 +36,7 @@ interface ChatState {
36
36
  streamText: string
37
37
 
38
38
  // Task 1: Rich status indicator
39
- streamPhase: 'thinking' | 'tool' | 'responding'
39
+ streamPhase: 'thinking' | 'tool' | 'responding' | 'connecting'
40
40
  streamToolName: string
41
41
 
42
42
  // Task 2: Typing cadence simulation
@@ -359,6 +359,16 @@ export const useChatStore = create<ChatState>((set, get) => ({
359
359
  }
360
360
  return { toolEvents: events }
361
361
  })
362
+ } else if (event.t === 'reset') {
363
+ // Server rolled back state after a transient error — clear accumulated
364
+ // text and tool events so the retry starts with a clean slate.
365
+ fullText = event.text || ''
366
+ toolCallCounter = 0
367
+ soundFiredStart = false
368
+ if (_cadenceInterval) clearCadence()
369
+ _cadencePos = 0
370
+ _cadenceBuffer = ''
371
+ set({ streamText: fullText, displayText: fullText, toolEvents: [], streamPhase: 'connecting' })
362
372
  } else if (event.t === 'err') {
363
373
  const errText = event.text || 'Unknown'
364
374
  if (!shouldIgnoreTransientError(errText)) {
@@ -510,6 +520,10 @@ export const useChatStore = create<ChatState>((set, get) => ({
510
520
  (event: SSEEvent) => {
511
521
  if (event.t === 'd' || event.t === 'r') {
512
522
  fullText += event.text || ''
523
+ } else if (event.t === 'reset') {
524
+ fullText = event.text || ''
525
+ heartbeatToolEvents.length = 0
526
+ toolCallCounter = 0
513
527
  } else if (event.t === 'md') {
514
528
  // metadata only
515
529
  } else if (event.t === 'tool_call') {
@@ -3,6 +3,8 @@ export interface MessageToolEvent {
3
3
  input: string
4
4
  output?: string
5
5
  error?: boolean
6
+ /** Internal correlation token for matching streaming tool calls/results. */
7
+ toolCallId?: string
6
8
  }
7
9
 
8
10
  export interface Message {
@@ -20,6 +22,8 @@ export interface Message {
20
22
  suggestions?: string[]
21
23
  replyToId?: string
22
24
  source?: MessageSource
25
+ /** Persist in the UI transcript, but exclude from normal model history. */
26
+ historyExcluded?: boolean
23
27
  /** True while the message is still being streamed — cleared on final persist. */
24
28
  streaming?: boolean
25
29
  }
@@ -45,6 +49,52 @@ export interface SessionArchiveState {
45
49
  exportPath?: string | null
46
50
  }
47
51
 
52
+ export interface CanvasMetricItem {
53
+ label: string
54
+ value: string
55
+ detail?: string
56
+ tone?: 'default' | 'positive' | 'negative' | 'warning'
57
+ }
58
+
59
+ export interface CanvasCardItem {
60
+ title: string
61
+ body?: string
62
+ meta?: string
63
+ tone?: 'default' | 'positive' | 'negative' | 'warning'
64
+ }
65
+
66
+ export interface CanvasActionItem {
67
+ label: string
68
+ href?: string
69
+ note?: string
70
+ intent?: 'primary' | 'secondary' | 'success' | 'danger'
71
+ }
72
+
73
+ export interface CanvasTableData {
74
+ columns: string[]
75
+ rows: Array<Array<string | number | boolean | null>>
76
+ caption?: string
77
+ }
78
+
79
+ export type CanvasBlock =
80
+ | { type: 'markdown'; title?: string; markdown: string }
81
+ | { type: 'metrics'; title?: string; items: CanvasMetricItem[] }
82
+ | { type: 'cards'; title?: string; items: CanvasCardItem[] }
83
+ | { type: 'table'; title?: string; table: CanvasTableData }
84
+ | { type: 'code'; title?: string; code: string; language?: string }
85
+ | { type: 'actions'; title?: string; items: CanvasActionItem[] }
86
+
87
+ export interface CanvasDocument {
88
+ kind: 'structured'
89
+ title?: string
90
+ subtitle?: string
91
+ theme?: 'slate' | 'sky' | 'emerald' | 'amber' | 'rose'
92
+ blocks: CanvasBlock[]
93
+ updatedAt?: number | null
94
+ }
95
+
96
+ export type CanvasContent = string | CanvasDocument | null
97
+
48
98
  export type ProviderType = 'claude-cli' | 'codex-cli' | 'opencode-cli' | 'openai' | 'ollama' | 'anthropic' | 'openclaw' | 'google' | 'deepseek' | 'groq' | 'together' | 'mistral' | 'xai' | 'fireworks'
49
99
 
50
100
  export interface ProviderInfo {
@@ -106,6 +156,7 @@ export interface Session {
106
156
  }
107
157
  messages: Message[]
108
158
  createdAt: number
159
+ updatedAt?: number | null
109
160
  lastActiveAt: number
110
161
  active?: boolean
111
162
  sessionType?: SessionType
@@ -117,6 +168,9 @@ export interface Session {
117
168
  heartbeatEnabled?: boolean | null
118
169
  heartbeatIntervalSec?: number | null
119
170
  heartbeatTarget?: 'last' | 'none' | string | null
171
+ memoryScopeMode?: 'auto' | 'all' | 'global' | 'agent' | 'session' | 'project' | null
172
+ memoryTierPreference?: 'working' | 'durable' | 'archive' | 'blended' | null
173
+ projectId?: string | null
120
174
  sessionResetMode?: SessionResetMode | null
121
175
  sessionIdleTimeoutSec?: number | null
122
176
  sessionMaxAgeSec?: number | null
@@ -176,7 +230,7 @@ export interface Session {
176
230
  vibe?: string
177
231
  theme?: string
178
232
  avatar?: string
179
- canvasContent?: string | null
233
+ canvasContent?: CanvasContent
180
234
  }
181
235
 
182
236
  export type Sessions = Record<string, Session>
@@ -204,7 +258,15 @@ export type SessionTool =
204
258
 
205
259
  // --- Approvals ---
206
260
 
207
- export type ApprovalCategory = 'tool_access' | 'wallet_transfer' | 'plugin_scaffold' | 'plugin_install' | 'task_tool' | 'human_loop'
261
+ export type ApprovalCategory =
262
+ | 'tool_access'
263
+ | 'wallet_transfer'
264
+ | 'wallet_action'
265
+ | 'plugin_scaffold'
266
+ | 'plugin_install'
267
+ | 'task_tool'
268
+ | 'human_loop'
269
+ | 'connector_sender'
208
270
 
209
271
  export interface ApprovalRequest {
210
272
  id: string
@@ -285,7 +347,14 @@ export interface PluginHooks {
285
347
  onMessage?: (ctx: { session: Session; message: Message }) => Promise<void> | void
286
348
 
287
349
  // Post-turn hook — fires after a full chat exchange (user message → agent response)
288
- afterChatTurn?: (ctx: { session: Session; message: string; response: string; source: string; internal: boolean }) => Promise<void> | void
350
+ afterChatTurn?: (ctx: {
351
+ session: Session
352
+ message: string
353
+ response: string
354
+ source: string
355
+ internal: boolean
356
+ toolEvents?: MessageToolEvent[]
357
+ }) => Promise<void> | void
289
358
 
290
359
  // Orchestration & Swarm Hooks
291
360
  onTaskComplete?: (ctx: { taskId: string; result: unknown }) => Promise<void> | void
@@ -303,6 +372,13 @@ export interface PluginHooks {
303
372
 
304
373
  // Operating guidance — returns operational hints for the agent when this plugin is active
305
374
  getOperatingGuidance?: () => string | string[] | null | undefined
375
+
376
+ // Approval guidance — returns approval-scoped instructions when this plugin is active
377
+ getApprovalGuidance?: (ctx: {
378
+ approval: ApprovalRequest
379
+ phase: 'request' | 'resume' | 'connector_reminder'
380
+ approved?: boolean
381
+ }) => string | string[] | null | undefined
306
382
  }
307
383
 
308
384
  export interface PluginToolPlanning {
@@ -430,7 +506,10 @@ export interface PluginMeta {
430
506
  isBuiltin?: boolean
431
507
  author?: string
432
508
  version?: string
433
- source?: 'local' | 'marketplace'
509
+ source?: 'local' | 'manual' | 'marketplace'
510
+ sourceLabel?: PluginPublisherSource
511
+ installSource?: PluginInstallSource
512
+ sourceUrl?: string
434
513
  openclaw?: boolean
435
514
  failureCount?: number
436
515
  lastFailureAt?: number
@@ -453,6 +532,26 @@ export interface PluginMeta {
453
532
  dependencyInstalledAt?: number
454
533
  }
455
534
 
535
+ export type PluginPublisherSource =
536
+ | 'builtin'
537
+ | 'local'
538
+ | 'manual'
539
+ | 'swarmclaw'
540
+ | 'swarmforge'
541
+ | 'clawhub'
542
+
543
+ export type PluginCatalogSource =
544
+ | 'swarmclaw'
545
+ | 'swarmclaw-site'
546
+ | 'swarmforge'
547
+ | 'clawhub'
548
+
549
+ export type PluginInstallSource =
550
+ | 'builtin'
551
+ | 'local'
552
+ | 'manual'
553
+ | PluginCatalogSource
554
+
456
555
  export type PluginPackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'
457
556
  export type PluginDependencyInstallStatus = 'none' | 'ready' | 'installing' | 'installed' | 'error'
458
557
 
@@ -463,18 +562,20 @@ export interface MarketplacePlugin {
463
562
  author: string
464
563
  version: string
465
564
  url: string
466
- source?: 'swarmclaw' | 'clawhub'
565
+ source?: PluginPublisherSource
566
+ catalogSource?: PluginCatalogSource
467
567
  tags?: string[]
468
568
  openclaw?: boolean
469
569
  downloads?: number
470
570
  }
471
571
 
472
572
  export interface SSEEvent {
473
- t: 'd' | 'md' | 'r' | 'done' | 'err' | 'tool_call' | 'tool_result' | 'status' | 'thinking' | 'cr_agent_start' | 'cr_agent_done'
573
+ t: 'd' | 'md' | 'r' | 'done' | 'err' | 'tool_call' | 'tool_result' | 'status' | 'thinking' | 'reset' | 'cr_agent_start' | 'cr_agent_done'
474
574
  text?: string
475
575
  toolName?: string
476
576
  toolInput?: string
477
577
  toolOutput?: string
578
+ toolCallId?: string
478
579
  agentId?: string
479
580
  agentName?: string
480
581
  }
@@ -568,10 +669,16 @@ export interface Agent {
568
669
  pinned?: boolean
569
670
  lastUsedAt?: number
570
671
  totalCost?: number
672
+ disabled?: boolean
571
673
  trashedAt?: number
572
674
  openclawSkillMode?: SkillAllowlistMode
573
675
  openclawAllowedSkills?: string[]
676
+ walletIds?: string[]
677
+ activeWalletId?: string | null
678
+ /** @deprecated Use walletIds + activeWalletId */
574
679
  walletId?: string | null
680
+ responseStyle?: 'concise' | 'normal' | 'detailed' | null
681
+ responseMaxChars?: number | null
575
682
  monthlyBudget?: number | null
576
683
  dailyBudget?: number | null
577
684
  hourlyBudget?: number | null
@@ -591,7 +698,7 @@ export interface Agent {
591
698
 
592
699
  // --- Agent Wallets ---
593
700
 
594
- export type WalletChain = 'solana'
701
+ export type WalletChain = 'solana' | 'ethereum'
595
702
 
596
703
  export interface AgentWallet {
597
704
  id: string
@@ -600,13 +707,41 @@ export interface AgentWallet {
600
707
  publicKey: string
601
708
  encryptedPrivateKey: string // AES-256-GCM via encryptKey()
602
709
  label?: string
603
- spendingLimitLamports?: number // per-tx cap (default 0.1 SOL = 100_000_000)
604
- dailyLimitLamports?: number // 24h rolling cap (default 1 SOL = 1_000_000_000)
710
+ spendingLimitAtomic?: string
711
+ dailyLimitAtomic?: string
712
+ /** @deprecated Use spendingLimitAtomic */
713
+ spendingLimitLamports?: number
714
+ /** @deprecated Use dailyLimitAtomic */
715
+ dailyLimitLamports?: number
605
716
  requireApproval: boolean // default true
606
717
  createdAt: number
607
718
  updatedAt: number
608
719
  }
609
720
 
721
+ export interface WalletAssetBalance {
722
+ id: string
723
+ chain: WalletChain
724
+ networkId: string
725
+ networkLabel: string
726
+ symbol: string
727
+ name?: string
728
+ decimals: number
729
+ balanceAtomic: string
730
+ balanceFormatted?: string
731
+ balanceDisplay?: string
732
+ isNative: boolean
733
+ contractAddress?: string
734
+ tokenMint?: string
735
+ explorerUrl?: string
736
+ }
737
+
738
+ export interface WalletPortfolioSummary {
739
+ totalAssets: number
740
+ nonZeroAssets: number
741
+ tokenAssets: number
742
+ networkCount: number
743
+ }
744
+
610
745
  export type WalletTransactionType = 'send' | 'receive' | 'swap'
611
746
  export type WalletTransactionStatus = 'pending_approval' | 'pending' | 'confirmed' | 'failed' | 'denied'
612
747
 
@@ -619,19 +754,25 @@ export interface WalletTransaction {
619
754
  signature: string
620
755
  fromAddress: string
621
756
  toAddress: string
622
- amountLamports: number
757
+ amountAtomic?: string
758
+ feeAtomic?: string
759
+ /** @deprecated Use amountAtomic */
760
+ amountLamports?: number
761
+ /** @deprecated Use feeAtomic */
623
762
  feeLamports?: number
624
763
  status: WalletTransactionStatus
625
764
  memo?: string // agent's reason for tx
626
765
  approvedBy?: 'user' | 'auto'
627
- tokenMint?: string // null = native SOL
766
+ tokenMint?: string // null = native chain asset
628
767
  timestamp: number
629
768
  }
630
769
 
631
770
  export interface WalletBalanceSnapshot {
632
771
  id: string
633
772
  walletId: string
634
- balanceLamports: number
773
+ balanceAtomic?: string
774
+ /** @deprecated Use balanceAtomic */
775
+ balanceLamports?: number
635
776
  timestamp: number
636
777
  }
637
778
 
@@ -668,6 +809,11 @@ export interface Schedule {
668
809
  runNumber?: number
669
810
  createdByAgentId?: string | null
670
811
  createdInSessionId?: string | null
812
+ followupConnectorId?: string | null
813
+ followupChannelId?: string | null
814
+ followupThreadId?: string | null
815
+ followupSenderId?: string | null
816
+ followupSenderName?: string | null
671
817
  createdAt: number
672
818
  updatedAt?: number
673
819
  }
@@ -1245,6 +1391,8 @@ export interface OpenClawDeploymentConfig {
1245
1391
  useCase?: OpenClawUseCaseTemplate | null
1246
1392
  exposure?: OpenClawExposurePreset | null
1247
1393
  managedBy?: 'swarmclaw' | 'manual' | null
1394
+ localInstanceId?: string | null
1395
+ localPort?: number | null
1248
1396
  targetHost?: string | null
1249
1397
  sshHost?: string | null
1250
1398
  sshUser?: string | null
@@ -1434,12 +1582,32 @@ export interface Skill {
1434
1582
  description?: string
1435
1583
  sourceUrl?: string
1436
1584
  sourceFormat?: 'openclaw' | 'plain'
1585
+ author?: string
1586
+ tags?: string[]
1587
+ version?: string
1588
+ homepage?: string
1589
+ primaryEnv?: string | null
1590
+ skillKey?: string | null
1591
+ always?: boolean
1592
+ installOptions?: SkillInstallOption[]
1593
+ skillRequirements?: SkillRequirements
1594
+ detectedEnvVars?: string[]
1595
+ security?: SkillSecuritySummary | null
1596
+ frontmatter?: Record<string, unknown> | null
1437
1597
  scope?: 'global' | 'agent'
1438
1598
  agentIds?: string[]
1439
1599
  createdAt: number
1440
1600
  updatedAt: number
1441
1601
  }
1442
1602
 
1603
+ export interface SkillSecuritySummary {
1604
+ level: 'low' | 'medium' | 'high'
1605
+ notes: string[]
1606
+ detectedEnvVars?: string[]
1607
+ missingDeclarations?: string[]
1608
+ installCommands?: string[]
1609
+ }
1610
+
1443
1611
  // --- Connector Health Events ---
1444
1612
 
1445
1613
  export type ConnectorHealthEventType = 'started' | 'stopped' | 'error' | 'reconnected' | 'disconnected'
@@ -1454,7 +1622,20 @@ export interface ConnectorHealthEvent {
1454
1622
 
1455
1623
  // --- Connectors (Chat Platform Bridges) ---
1456
1624
 
1457
- export type ConnectorPlatform = 'discord' | 'telegram' | 'slack' | 'whatsapp' | 'openclaw' | 'bluebubbles' | 'signal' | 'teams' | 'googlechat' | 'matrix' | 'email'
1625
+ export type ConnectorPlatform =
1626
+ | 'discord'
1627
+ | 'telegram'
1628
+ | 'slack'
1629
+ | 'whatsapp'
1630
+ | 'openclaw'
1631
+ | 'bluebubbles'
1632
+ | 'signal'
1633
+ | 'teams'
1634
+ | 'googlechat'
1635
+ | 'matrix'
1636
+ | 'email'
1637
+ | 'webchat'
1638
+ | 'mockmail'
1458
1639
  export type ConnectorStatus = 'stopped' | 'running' | 'error'
1459
1640
 
1460
1641
  export interface MessageSource {
@@ -1541,6 +1722,11 @@ export interface BoardTask {
1541
1722
  images?: string[]
1542
1723
  createdByAgentId?: string | null
1543
1724
  createdInSessionId?: string | null
1725
+ followupConnectorId?: string | null
1726
+ followupChannelId?: string | null
1727
+ followupThreadId?: string | null
1728
+ followupSenderId?: string | null
1729
+ followupSenderName?: string | null
1544
1730
  delegatedByAgentId?: string | null
1545
1731
  delegatedFromTaskId?: string | null
1546
1732
  delegationDepth?: number | null
@@ -1558,10 +1744,20 @@ export interface BoardTask {
1558
1744
  totalRuns?: number
1559
1745
  totalCompleted?: number
1560
1746
  totalFailed?: number
1561
- sourceType?: 'schedule' | 'delegation' | 'manual'
1747
+ sourceType?: 'schedule' | 'delegation' | 'manual' | 'import'
1562
1748
  sourceScheduleId?: string | null
1563
1749
  sourceScheduleName?: string | null
1564
1750
  sourceScheduleKey?: string | null
1751
+ externalSource?: {
1752
+ source: string
1753
+ id?: string | null
1754
+ repo?: string | null
1755
+ number?: number | null
1756
+ state?: string | null
1757
+ labels?: string[]
1758
+ assignee?: string | null
1759
+ url?: string | null
1760
+ } | null
1565
1761
  deadLetteredAt?: number | null
1566
1762
  cliResumeId?: string | null
1567
1763
  cliProvider?: string | null