@swarmclawai/swarmclaw 1.2.8 → 1.3.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 (214) hide show
  1. package/README.md +39 -6
  2. package/package.json +2 -2
  3. package/src/app/agents/[id]/page.tsx +1 -18
  4. package/src/app/api/activity/route.ts +9 -23
  5. package/src/app/api/agents/route.ts +17 -1
  6. package/src/app/api/agents/thread-route.test.ts +0 -1
  7. package/src/app/api/approvals/route.test.ts +6 -22
  8. package/src/app/api/approvals/route.ts +13 -5
  9. package/src/app/api/connectors/route.ts +2 -2
  10. package/src/app/api/credentials/[id]/route.ts +2 -0
  11. package/src/app/api/credentials/route.ts +4 -1
  12. package/src/app/api/goals/[id]/route.ts +28 -0
  13. package/src/app/api/goals/route.ts +33 -0
  14. package/src/app/api/portability/export/route.ts +8 -0
  15. package/src/app/api/portability/import/route.test.ts +80 -0
  16. package/src/app/api/portability/import/route.ts +28 -0
  17. package/src/app/api/protocols/templates/[id]/route.ts +2 -1
  18. package/src/app/api/protocols/templates/route.ts +2 -1
  19. package/src/app/api/settings/route.ts +13 -2
  20. package/src/app/api/wallets/[id]/route.ts +15 -157
  21. package/src/app/api/wallets/generate/route.ts +22 -0
  22. package/src/app/api/wallets/route.test.ts +147 -0
  23. package/src/app/api/wallets/route.ts +13 -95
  24. package/src/app/autonomy/page.tsx +2 -57
  25. package/src/app/home/page.tsx +3 -0
  26. package/src/app/protocols/page.tsx +2 -21
  27. package/src/app/settings/page.tsx +0 -9
  28. package/src/app/wallets/page.tsx +105 -5
  29. package/src/cli/index.js +32 -33
  30. package/src/cli/spec.js +26 -27
  31. package/src/components/agents/agent-sheet.tsx +2 -40
  32. package/src/components/agents/inspector-panel.tsx +0 -83
  33. package/src/components/chat/chat-card.tsx +0 -31
  34. package/src/components/chat/message-bubble.tsx +1 -108
  35. package/src/components/connectors/connector-sheet.tsx +25 -1
  36. package/src/components/layout/sidebar-rail.tsx +6 -10
  37. package/src/components/projects/project-detail.tsx +3 -35
  38. package/src/components/projects/tabs/overview-tab.tsx +3 -59
  39. package/src/components/projects/tabs/work-tab.tsx +7 -77
  40. package/src/components/protocols/structured-session-launcher.tsx +1 -22
  41. package/src/components/shared/connector-platform-icon.tsx +1 -0
  42. package/src/components/tasks/task-card.tsx +4 -34
  43. package/src/components/tasks/task-sheet.tsx +6 -36
  44. package/src/components/wallets/wallet-list.tsx +150 -0
  45. package/src/lib/app/navigation.test.ts +0 -13
  46. package/src/lib/app/navigation.ts +2 -7
  47. package/src/lib/app/view-constants.ts +14 -19
  48. package/src/lib/server/activity/activity-log.ts +16 -1
  49. package/src/lib/server/agents/agent-service.ts +24 -11
  50. package/src/lib/server/agents/agent-thread-session.ts +0 -1
  51. package/src/lib/server/agents/delegation-advisory.test.ts +0 -1
  52. package/src/lib/server/agents/delegation-jobs.test.ts +0 -69
  53. package/src/lib/server/agents/delegation-jobs.ts +0 -25
  54. package/src/lib/server/agents/main-agent-loop.ts +1 -49
  55. package/src/lib/server/agents/subagent-runtime.ts +0 -1
  56. package/src/lib/server/approval-match.ts +14 -85
  57. package/src/lib/server/approvals/approval-hooks.ts +81 -0
  58. package/src/lib/server/approvals.test.ts +6 -6
  59. package/src/lib/server/approvals.ts +11 -6
  60. package/src/lib/server/autonomy/supervisor-reflection.test.ts +0 -1
  61. package/src/lib/server/builtin-extensions.ts +0 -2
  62. package/src/lib/server/capability-router.test.ts +0 -2
  63. package/src/lib/server/chat-execution/chat-execution-tool-events.test.ts +14 -14
  64. package/src/lib/server/chat-execution/chat-execution-types.ts +0 -2
  65. package/src/lib/server/chat-execution/chat-execution-utils.ts +0 -2
  66. package/src/lib/server/chat-execution/chat-streaming-utils.ts +2 -30
  67. package/src/lib/server/chat-execution/chat-turn-finalization.ts +1 -36
  68. package/src/lib/server/chat-execution/chat-turn-preparation.ts +2 -22
  69. package/src/lib/server/chat-execution/iteration-event-handler.ts +0 -24
  70. package/src/lib/server/chat-execution/message-classifier.test.ts +0 -45
  71. package/src/lib/server/chat-execution/message-classifier.ts +1 -16
  72. package/src/lib/server/chat-execution/prompt-builder.test.ts +0 -1
  73. package/src/lib/server/chat-execution/prompt-builder.ts +0 -30
  74. package/src/lib/server/chat-execution/prompt-sections.ts +0 -1
  75. package/src/lib/server/chat-execution/situational-awareness.test.ts +2 -73
  76. package/src/lib/server/chat-execution/situational-awareness.ts +4 -38
  77. package/src/lib/server/chat-execution/stream-agent-chat.test.ts +8 -123
  78. package/src/lib/server/chat-execution/stream-agent-chat.ts +1 -5
  79. package/src/lib/server/chat-execution/stream-continuation.test.ts +4 -52
  80. package/src/lib/server/chat-execution/stream-continuation.ts +6 -48
  81. package/src/lib/server/chatrooms/session-mailbox.ts +0 -10
  82. package/src/lib/server/chats/chat-session-service.ts +3 -5
  83. package/src/lib/server/connectors/connector-inbound.ts +0 -1
  84. package/src/lib/server/connectors/connector-lifecycle.ts +19 -3
  85. package/src/lib/server/connectors/connector-service.ts +39 -9
  86. package/src/lib/server/connectors/swarmdock-bidding.ts +74 -0
  87. package/src/lib/server/connectors/swarmdock-payloads.test.ts +85 -0
  88. package/src/lib/server/connectors/swarmdock-secret.test.ts +128 -0
  89. package/src/lib/server/connectors/swarmdock-secret.ts +152 -0
  90. package/src/lib/server/connectors/swarmdock-tasks.ts +127 -0
  91. package/src/lib/server/connectors/swarmdock.ts +285 -0
  92. package/src/lib/server/execution-brief.test.ts +2 -25
  93. package/src/lib/server/execution-brief.ts +30 -35
  94. package/src/lib/server/execution-engine/task-attempt.ts +0 -1
  95. package/src/lib/server/goals/goal-repository.ts +19 -0
  96. package/src/lib/server/goals/goal-service.ts +143 -0
  97. package/src/lib/server/persistence/storage-context.ts +0 -5
  98. package/src/lib/server/portability/export.ts +109 -0
  99. package/src/lib/server/portability/import.ts +159 -0
  100. package/src/lib/server/protocols/protocol-normalization.ts +0 -4
  101. package/src/lib/server/protocols/protocol-queries.ts +0 -6
  102. package/src/lib/server/protocols/protocol-run-lifecycle.ts +4 -32
  103. package/src/lib/server/protocols/protocol-service.ts +0 -1
  104. package/src/lib/server/protocols/protocol-step-helpers.ts +0 -4
  105. package/src/lib/server/protocols/protocol-step-processors.ts +0 -6
  106. package/src/lib/server/protocols/protocol-swarm.ts +0 -2
  107. package/src/lib/server/protocols/protocol-types.ts +0 -2
  108. package/src/lib/server/provider-health.ts +0 -9
  109. package/src/lib/server/runtime/daemon-state/core.ts +0 -9
  110. package/src/lib/server/runtime/daemon-state.test.ts +0 -35
  111. package/src/lib/server/runtime/heartbeat-service.ts +3 -23
  112. package/src/lib/server/runtime/queue/core.ts +11 -33
  113. package/src/lib/server/runtime/runtime-storage-write-paths.test.ts +6 -6
  114. package/src/lib/server/runtime/scheduler.ts +0 -13
  115. package/src/lib/server/runtime/session-run-manager/drain.ts +0 -24
  116. package/src/lib/server/runtime/session-run-manager/enqueue.ts +0 -1
  117. package/src/lib/server/runtime/session-run-manager/queries.ts +0 -1
  118. package/src/lib/server/runtime/session-run-manager/recovery.ts +0 -1
  119. package/src/lib/server/runtime/session-run-manager.test.ts +0 -28
  120. package/src/lib/server/session-tools/crud.ts +0 -14
  121. package/src/lib/server/session-tools/delegate.ts +0 -4
  122. package/src/lib/server/session-tools/index.ts +0 -4
  123. package/src/lib/server/session-tools/team-context.ts +0 -3
  124. package/src/lib/server/storage-normalization.ts +13 -0
  125. package/src/lib/server/storage.ts +75 -45
  126. package/src/lib/server/tasks/task-checkout.ts +59 -0
  127. package/src/lib/server/tasks/task-lifecycle.ts +2 -0
  128. package/src/lib/server/tasks/task-route-service.ts +4 -26
  129. package/src/lib/server/tasks/task-service.ts +0 -7
  130. package/src/lib/server/tool-aliases.ts +0 -1
  131. package/src/lib/server/tool-capability-policy-advanced.test.ts +4 -4
  132. package/src/lib/server/tool-capability-policy.ts +0 -2
  133. package/src/lib/server/tool-planning.ts +0 -12
  134. package/src/lib/server/universal-tool-access.ts +0 -1
  135. package/src/lib/server/usage/cost-rollup.ts +124 -0
  136. package/src/lib/server/usage/usage-repository.ts +6 -0
  137. package/src/lib/server/wallets/wallet-crypto.ts +33 -0
  138. package/src/lib/server/wallets/wallet-repository.ts +24 -0
  139. package/src/lib/server/wallets/wallet-service.ts +119 -0
  140. package/src/lib/server/working-state/extraction.ts +8 -42
  141. package/src/lib/server/working-state/normalization.ts +10 -103
  142. package/src/lib/server/working-state/service.ts +12 -21
  143. package/src/lib/strip-internal-metadata.test.ts +1 -1
  144. package/src/lib/strip-internal-metadata.ts +1 -1
  145. package/src/lib/tool-definitions.ts +0 -1
  146. package/src/lib/validation/schemas.ts +36 -32
  147. package/src/lib/validation/server-schemas.ts +35 -0
  148. package/src/stores/slices/data-slice.ts +5 -1
  149. package/src/stores/slices/ui-slice.ts +0 -4
  150. package/src/types/agent.ts +10 -84
  151. package/src/types/app-settings.ts +6 -2
  152. package/src/types/approval.ts +3 -2
  153. package/src/types/connector.ts +1 -0
  154. package/src/types/goal.ts +30 -0
  155. package/src/types/index.ts +2 -1
  156. package/src/types/message.ts +0 -1
  157. package/src/types/misc.ts +2 -4
  158. package/src/types/protocol.ts +0 -2
  159. package/src/types/run.ts +0 -3
  160. package/src/types/session.ts +1 -51
  161. package/src/types/swarmdock.ts +29 -0
  162. package/src/types/task.ts +9 -3
  163. package/src/types/working-state.ts +2 -9
  164. package/src/views/settings/section-runtime-loop.tsx +0 -14
  165. package/src/app/api/canvas/[sessionId]/route.ts +0 -35
  166. package/src/app/api/missions/[id]/actions/route.ts +0 -31
  167. package/src/app/api/missions/[id]/events/route.ts +0 -14
  168. package/src/app/api/missions/[id]/route.ts +0 -10
  169. package/src/app/api/missions/route.test.ts +0 -244
  170. package/src/app/api/missions/route.ts +0 -57
  171. package/src/app/api/wallets/[id]/approve/route.ts +0 -79
  172. package/src/app/api/wallets/[id]/balance-history/route.ts +0 -18
  173. package/src/app/api/wallets/[id]/send/route.ts +0 -113
  174. package/src/app/api/wallets/[id]/transactions/route.ts +0 -18
  175. package/src/app/missions/[id]/page.tsx +0 -3
  176. package/src/app/missions/page.tsx +0 -685
  177. package/src/components/canvas/canvas-panel.tsx +0 -267
  178. package/src/components/wallets/wallet-approval-dialog.tsx +0 -107
  179. package/src/components/wallets/wallet-panel.tsx +0 -1010
  180. package/src/components/wallets/wallet-section.tsx +0 -260
  181. package/src/features/missions/queries.ts +0 -23
  182. package/src/lib/canvas-content.test.ts +0 -360
  183. package/src/lib/canvas-content.ts +0 -198
  184. package/src/lib/server/canvas-content.test.ts +0 -32
  185. package/src/lib/server/canvas-content.ts +0 -6
  186. package/src/lib/server/ethereum.ts +0 -591
  187. package/src/lib/server/evm-swap.ts +0 -476
  188. package/src/lib/server/missions/mission-intent.test.ts +0 -63
  189. package/src/lib/server/missions/mission-intent.ts +0 -569
  190. package/src/lib/server/missions/mission-repository.ts +0 -74
  191. package/src/lib/server/missions/mission-service/actions.ts +0 -6
  192. package/src/lib/server/missions/mission-service/bindings.ts +0 -9
  193. package/src/lib/server/missions/mission-service/context.ts +0 -4
  194. package/src/lib/server/missions/mission-service/core.ts +0 -2271
  195. package/src/lib/server/missions/mission-service/queries.ts +0 -12
  196. package/src/lib/server/missions/mission-service/recovery.ts +0 -5
  197. package/src/lib/server/missions/mission-service/ticks.ts +0 -9
  198. package/src/lib/server/missions/mission-service.test.ts +0 -888
  199. package/src/lib/server/missions/mission-service.ts +0 -6
  200. package/src/lib/server/session-tools/canvas.ts +0 -105
  201. package/src/lib/server/session-tools/wallet-tool.test.ts +0 -150
  202. package/src/lib/server/session-tools/wallet.ts +0 -1287
  203. package/src/lib/server/solana.ts +0 -327
  204. package/src/lib/server/wallet/wallet-execution.test.ts +0 -198
  205. package/src/lib/server/wallet/wallet-portfolio.test.ts +0 -98
  206. package/src/lib/server/wallet/wallet-portfolio.ts +0 -772
  207. package/src/lib/server/wallet/wallet-service.test.ts +0 -81
  208. package/src/lib/server/wallet/wallet-service.ts +0 -225
  209. package/src/lib/wallet/wallet-transactions.test.ts +0 -75
  210. package/src/lib/wallet/wallet-transactions.ts +0 -43
  211. package/src/lib/wallet/wallet.test.ts +0 -333
  212. package/src/lib/wallet/wallet.ts +0 -183
  213. package/src/types/mission.ts +0 -185
  214. package/src/views/settings/section-wallets.tsx +0 -35
@@ -1,6 +1,4 @@
1
1
  import { z } from 'zod'
2
- import type { ProtocolStepDefinition } from '@/types'
3
- import { validateStepDag, validateStepRefs } from '@/lib/server/protocols/step-dag-validation'
4
2
 
5
3
  const OllamaModeSchema = z.enum(['local', 'cloud']).nullable().optional().default(null)
6
4
 
@@ -137,7 +135,7 @@ export const ConnectorCreateSchema = z.object({
137
135
  name: z.string().min(1, 'Connector name is required').optional(),
138
136
  platform: z.enum([
139
137
  'discord', 'telegram', 'slack', 'whatsapp', 'openclaw',
140
- 'bluebubbles', 'signal', 'teams', 'googlechat', 'matrix', 'email',
138
+ 'bluebubbles', 'signal', 'teams', 'googlechat', 'matrix', 'email', 'swarmdock',
141
139
  ]),
142
140
  agentId: z.string().nullable().optional().default(null),
143
141
  chatroomId: z.string().nullable().optional().default(null),
@@ -396,7 +394,6 @@ export const ProtocolRunCreateSchema = z.object({
396
394
  participantAgentIds: z.array(z.string()).min(1, 'Select at least one participant').default([]),
397
395
  facilitatorAgentId: z.string().nullable().optional().default(null),
398
396
  observerAgentIds: z.array(z.string()).optional().default([]),
399
- missionId: z.string().nullable().optional().default(null),
400
397
  taskId: z.string().nullable().optional().default(null),
401
398
  sessionId: z.string().nullable().optional().default(null),
402
399
  parentChatroomId: z.string().nullable().optional().default(null),
@@ -425,7 +422,9 @@ export const ProtocolRunCreateSchema = z.object({
425
422
  entryStepId: z.string().nullable().optional().default(null),
426
423
  })
427
424
 
428
- export const ProtocolTemplateUpsertSchema = z.object({
425
+ /** Base protocol template schema without server-side DAG validation.
426
+ * Use ProtocolTemplateUpsertSchema from '@/lib/validation/server-schemas' for full server-side validation. */
427
+ export const ProtocolTemplateUpsertBaseSchema = z.object({
429
428
  name: z.string().min(1, 'A template name is required'),
430
429
  description: z.string().min(1, 'A template description is required'),
431
430
  singleAgentAllowed: z.boolean().optional().default(true),
@@ -434,33 +433,6 @@ export const ProtocolTemplateUpsertSchema = z.object({
434
433
  defaultPhases: z.array(ProtocolPhaseDefinitionSchema).optional().default([]),
435
434
  steps: z.array(ProtocolStepDefinitionSchema).optional().default([]),
436
435
  entryStepId: z.string().nullable().optional().default(null),
437
- }).superRefine((value, ctx) => {
438
- if (value.defaultPhases.length === 0 && value.steps.length === 0) {
439
- ctx.addIssue({
440
- code: z.ZodIssueCode.custom,
441
- path: ['steps'],
442
- message: 'Provide at least one phase or one step.',
443
- })
444
- }
445
- if (value.steps.length > 0) {
446
- const steps = value.steps as ProtocolStepDefinition[]
447
- const dagResult = validateStepDag(steps)
448
- if (!dagResult.valid) {
449
- ctx.addIssue({
450
- code: z.ZodIssueCode.custom,
451
- path: ['steps'],
452
- message: `Cycle detected in step dependencies: ${dagResult.cycle?.join(' → ')}`,
453
- })
454
- }
455
- const invalidRefs = validateStepRefs(steps)
456
- for (const ref of invalidRefs) {
457
- ctx.addIssue({
458
- code: z.ZodIssueCode.custom,
459
- path: ['steps'],
460
- message: `Step references unknown step ID: "${ref}"`,
461
- })
462
- }
463
- }
464
436
  })
465
437
 
466
438
  export const ProtocolRunActionSchema = z.object({
@@ -473,6 +445,38 @@ export const ProtocolRunActionSchema = z.object({
473
445
  workItemId: z.string().nullable().optional().default(null),
474
446
  })
475
447
 
448
+ const PortableAgentSchema = z.object({
449
+ originalId: z.string().min(1),
450
+ name: z.string().min(1),
451
+ description: z.string(),
452
+ systemPrompt: z.string(),
453
+ provider: z.string().min(1),
454
+ model: z.string().min(1),
455
+ createdAt: z.number().optional(),
456
+ updatedAt: z.number().optional(),
457
+ skillIds: z.array(z.string()).optional(),
458
+ }).passthrough()
459
+
460
+ const PortableSkillSchema = z.object({
461
+ originalId: z.string().min(1),
462
+ name: z.string().min(1),
463
+ content: z.string(),
464
+ }).passthrough()
465
+
466
+ const PortableScheduleSchema = z.object({
467
+ originalId: z.string().min(1),
468
+ originalAgentId: z.string().min(1),
469
+ name: z.string().min(1),
470
+ }).passthrough()
471
+
472
+ export const PortableManifestSchema = z.object({
473
+ formatVersion: z.number().int().nonnegative(),
474
+ exportedAt: z.string().optional(),
475
+ agents: z.array(PortableAgentSchema),
476
+ skills: z.array(PortableSkillSchema),
477
+ schedules: z.array(PortableScheduleSchema),
478
+ })
479
+
476
480
  /** Format ZodError into a 400-friendly payload */
477
481
  export function formatZodError(err: z.ZodError) {
478
482
  return { error: 'Validation failed', issues: err.issues.map((i) => ({ path: i.path.join('.'), message: i.message })) }
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod'
2
+ import type { ProtocolStepDefinition } from '@/types'
3
+ import { validateStepDag, validateStepRefs } from '@/lib/server/protocols/step-dag-validation'
4
+ import { ProtocolTemplateUpsertBaseSchema } from './schemas'
5
+
6
+ /** Full protocol template upsert schema with server-side DAG validation.
7
+ * For client-side use (without server deps), use ProtocolTemplateUpsertBaseSchema from './schemas'. */
8
+ export const ProtocolTemplateUpsertSchema = ProtocolTemplateUpsertBaseSchema.superRefine((value, ctx) => {
9
+ if (value.defaultPhases.length === 0 && value.steps.length === 0) {
10
+ ctx.addIssue({
11
+ code: z.ZodIssueCode.custom,
12
+ path: ['steps'],
13
+ message: 'Provide at least one phase or one step.',
14
+ })
15
+ }
16
+ if (value.steps.length > 0) {
17
+ const steps = value.steps as ProtocolStepDefinition[]
18
+ const dagResult = validateStepDag(steps)
19
+ if (!dagResult.valid) {
20
+ ctx.addIssue({
21
+ code: z.ZodIssueCode.custom,
22
+ path: ['steps'],
23
+ message: `Cycle detected in step dependencies: ${dagResult.cycle?.join(' → ')}`,
24
+ })
25
+ }
26
+ const invalidRefs = validateStepRefs(steps)
27
+ for (const ref of invalidRefs) {
28
+ ctx.addIssue({
29
+ code: z.ZodIssueCode.custom,
30
+ path: ['steps'],
31
+ message: `Step references unknown step ID: "${ref}"`,
32
+ })
33
+ }
34
+ }
35
+ })
@@ -1,6 +1,6 @@
1
1
  import { StateCreator } from 'zustand'
2
2
  import type { AppState } from '../use-app-store'
3
- import type { NetworkInfo, Directory, ProviderInfo, Credentials, Schedule, AppSettings, StoredSecret, ProviderConfig, Skill, Connector, Webhook, McpServerConfig, ExtensionMeta, Project, ActivityEntry, AppNotification, GatewayProfile } from '../../types'
3
+ import type { NetworkInfo, Directory, ProviderInfo, Credentials, Schedule, AppSettings, StoredSecret, ProviderConfig, Skill, Connector, Webhook, McpServerConfig, ExtensionMeta, Project, ActivityEntry, AppNotification, GatewayProfile, SafeWallet } from '../../types'
4
4
  import { api } from '@/lib/app/api-client'
5
5
  import { safeStorageGetJson, safeStorageSet } from '@/lib/app/safe-storage'
6
6
  import { fetchDirs, fetchProviders, fetchCredentials } from '@/lib/chat/chats'
@@ -24,6 +24,8 @@ export interface DataSlice {
24
24
  updateSettings: (patch: Partial<AppSettings>) => Promise<void>
25
25
  secrets: Record<string, StoredSecret>
26
26
  loadSecrets: () => Promise<void>
27
+ wallets: Record<string, SafeWallet>
28
+ loadWallets: () => Promise<void>
27
29
  providerConfigs: ProviderConfig[]
28
30
  loadProviderConfigs: () => Promise<void>
29
31
  gatewayProfiles: GatewayProfile[]
@@ -78,6 +80,8 @@ export const createDataSlice: StateCreator<AppState, [], [], DataSlice> = (set,
78
80
  },
79
81
  secrets: {},
80
82
  loadSecrets: createLoader<AppState>(set, 'secrets', () => api<Record<string, StoredSecret>>('GET', '/secrets'), {}),
83
+ wallets: {},
84
+ loadWallets: createLoader<AppState>(set, 'wallets', () => api<Record<string, SafeWallet>>('GET', '/wallets'), {}),
81
85
  providerConfigs: [],
82
86
  loadProviderConfigs: createLoader<AppState>(set, 'providerConfigs', () => api<ProviderConfig[]>('GET', '/providers/configs'), []),
83
87
  gatewayProfiles: [],
@@ -95,8 +95,6 @@ export interface UiSlice {
95
95
  setFleetFilter: (filter: FleetFilter) => void
96
96
  chatFilter: 'all' | 'active' | 'recent'
97
97
  setChatFilter: (filter: 'all' | 'active' | 'recent') => void
98
- walletPanelAgentId: string | null
99
- setWalletPanelAgentId: (id: string | null) => void
100
98
  heartbeatHistoryOpen: boolean
101
99
  setHeartbeatHistoryOpen: (open: boolean) => void
102
100
  agentPrefill: Partial<Agent> | null
@@ -195,8 +193,6 @@ export const createUiSlice: StateCreator<AppState, [], [], UiSlice> = (set, get)
195
193
  setFleetFilter: (filter) => { safeStorageSet('sc_fleet_filter', filter); set({ fleetFilter: filter }) },
196
194
  chatFilter: 'all' as const,
197
195
  setChatFilter: (filter) => set({ chatFilter: filter }),
198
- walletPanelAgentId: null,
199
- setWalletPanelAgentId: (id) => set({ walletPanelAgentId: id }),
200
196
  heartbeatHistoryOpen: false,
201
197
  setHeartbeatHistoryOpen: (open) => set({ heartbeatHistoryOpen: open }),
202
198
  agentPrefill: null,
@@ -83,15 +83,13 @@ export interface Agent {
83
83
  trashedAt?: number
84
84
  openclawSkillMode?: SkillAllowlistMode
85
85
  openclawAllowedSkills?: string[]
86
- walletIds?: string[]
87
- activeWalletId?: string | null
88
- /** @deprecated Use walletIds + activeWalletId */
89
- walletId?: string | null
90
86
  responseStyle?: 'concise' | 'normal' | 'detailed' | null
91
87
  responseMaxChars?: number | null
92
88
  monthlyBudget?: number | null
93
89
  dailyBudget?: number | null
94
90
  hourlyBudget?: number | null
91
+ /** Reference to a Goal in the goal hierarchy. */
92
+ goalId?: string | null
95
93
  autoRecovery?: boolean
96
94
  proactiveMemory?: boolean
97
95
  /** Auto-refresh a reviewed skill draft from meaningful chat turns for this agent. */
@@ -156,6 +154,14 @@ export interface Agent {
156
154
  dailySpend?: number
157
155
  /** Runtime-enriched: trailing 1-hour spend. Populated by GET /api/agents when hourlyBudget is set. */
158
156
  hourlySpend?: number
157
+ /** Persisted: accumulated spend in current monthly window (USD). Updated on each usage event. */
158
+ spentMonthlyCents?: number
159
+ /** Persisted: accumulated spend in current daily window (USD). Updated on each usage event. */
160
+ spentDailyCents?: number
161
+ /** Persisted: accumulated spend in current hourly window (USD). Updated on each usage event. */
162
+ spentHourlyCents?: number
163
+ /** Timestamp of last spend rollup; used to detect window resets. */
164
+ lastSpendRollupAt?: number
159
165
  maxFollowupChain?: number
160
166
 
161
167
  // Orchestrator Mode
@@ -171,86 +177,6 @@ export interface Agent {
171
177
  updatedAt: number
172
178
  }
173
179
 
174
- // --- Agent Wallets ---
175
-
176
- export type WalletChain = 'solana' | 'ethereum'
177
-
178
- export interface AgentWallet {
179
- id: string
180
- agentId: string
181
- chain: WalletChain
182
- publicKey: string
183
- encryptedPrivateKey: string // AES-256-GCM via encryptKey()
184
- label?: string
185
- spendingLimitAtomic?: string
186
- dailyLimitAtomic?: string
187
- /** @deprecated Use spendingLimitAtomic */
188
- spendingLimitLamports?: number
189
- /** @deprecated Use dailyLimitAtomic */
190
- dailyLimitLamports?: number
191
- requireApproval: boolean // default true; can be globally overridden by app settings
192
- createdAt: number
193
- updatedAt: number
194
- }
195
-
196
- export interface WalletAssetBalance {
197
- id: string
198
- chain: WalletChain
199
- networkId: string
200
- networkLabel: string
201
- symbol: string
202
- name?: string
203
- decimals: number
204
- balanceAtomic: string
205
- balanceFormatted?: string
206
- balanceDisplay?: string
207
- isNative: boolean
208
- contractAddress?: string
209
- tokenMint?: string
210
- explorerUrl?: string
211
- }
212
-
213
- export interface WalletPortfolioSummary {
214
- totalAssets: number
215
- nonZeroAssets: number
216
- tokenAssets: number
217
- networkCount: number
218
- }
219
-
220
- export type WalletTransactionType = 'send' | 'receive' | 'swap'
221
- export type WalletTransactionStatus = 'pending_approval' | 'pending' | 'confirmed' | 'failed' | 'denied'
222
-
223
- export interface WalletTransaction {
224
- id: string
225
- walletId: string
226
- agentId: string
227
- chain: WalletChain
228
- type: WalletTransactionType
229
- signature: string
230
- fromAddress: string
231
- toAddress: string
232
- amountAtomic?: string
233
- feeAtomic?: string
234
- /** @deprecated Use amountAtomic */
235
- amountLamports?: number
236
- /** @deprecated Use feeAtomic */
237
- feeLamports?: number
238
- status: WalletTransactionStatus
239
- memo?: string // agent's reason for tx
240
- approvedBy?: 'user' | 'auto'
241
- tokenMint?: string // null = native chain asset
242
- timestamp: number
243
- }
244
-
245
- export interface WalletBalanceSnapshot {
246
- id: string
247
- walletId: string
248
- balanceAtomic?: string
249
- /** @deprecated Use balanceAtomic */
250
- balanceLamports?: number
251
- timestamp: number
252
- }
253
-
254
180
  export type AgentTool = 'browser'
255
181
 
256
182
  export interface ClaudeSkill {
@@ -73,7 +73,6 @@ export interface AppSettings {
73
73
  safetyRequireApprovalForOutbound?: boolean
74
74
  safetyMaxDailySpendUsd?: number | null
75
75
  safetyBlockedTools?: string[]
76
- walletApprovalsEnabled?: boolean
77
76
  capabilityPolicyMode?: 'permissive' | 'balanced' | 'strict'
78
77
  capabilityBlockedTools?: string[]
79
78
  capabilityBlockedCategories?: string[]
@@ -96,7 +95,6 @@ export interface AppSettings {
96
95
  supervisorNoProgressLimit?: number
97
96
  supervisorRepeatedToolLimit?: number
98
97
  autonomyResumeApprovalsEnabled?: boolean
99
- missionHumanLoopEnabled?: boolean
100
98
  reflectionEnabled?: boolean
101
99
  reflectionAutoWriteMemory?: boolean
102
100
  memoryReferenceDepth?: number
@@ -150,6 +148,12 @@ export interface AppSettings {
150
148
  toolLoopCircuitBreaker?: number
151
149
  // Per-extension settings (keyed by extensionId)
152
150
  extensionSettings?: Record<string, Record<string, unknown>>
151
+ // Approval policies — opt-in governance gates for sensitive operations
152
+ approvalPolicies?: {
153
+ requireApprovalForAgentCreate?: boolean
154
+ requireApprovalForBudgetChange?: boolean
155
+ requireApprovalForDelegationEnable?: boolean
156
+ }
153
157
  }
154
158
 
155
159
  export interface EstopState {
@@ -2,13 +2,14 @@
2
2
 
3
3
  export type ApprovalCategory =
4
4
  | 'tool_access'
5
- | 'wallet_transfer'
6
- | 'wallet_action'
7
5
  | 'extension_scaffold'
8
6
  | 'extension_install'
9
7
  | 'task_tool'
10
8
  | 'human_loop'
11
9
  | 'connector_sender'
10
+ | 'agent_create'
11
+ | 'budget_change'
12
+ | 'delegation_enable'
12
13
 
13
14
  export interface ApprovalRequest {
14
15
  id: string
@@ -28,6 +28,7 @@ export type ConnectorPlatform =
28
28
  | 'email'
29
29
  | 'webchat'
30
30
  | 'mockmail'
31
+ | 'swarmdock'
31
32
  export type ConnectorStatus = 'stopped' | 'running' | 'error'
32
33
 
33
34
  export interface MessageSource {
@@ -0,0 +1,30 @@
1
+ export type GoalLevel = 'organization' | 'team' | 'project' | 'agent' | 'task'
2
+
3
+ export type GoalStatus = 'active' | 'achieved' | 'abandoned'
4
+
5
+ export interface Goal {
6
+ id: string
7
+ title: string
8
+ description?: string
9
+ level: GoalLevel
10
+ parentGoalId?: string | null
11
+ /** Link to a project (for project-level goals). */
12
+ projectId?: string | null
13
+ /** Link to an agent (for agent-level goals). */
14
+ agentId?: string | null
15
+ /** Link to a task (for task-level goals). */
16
+ taskId?: string | null
17
+ /** The concrete objective this goal achieves. */
18
+ objective: string
19
+ /** Constraints or guardrails on how the goal should be pursued. */
20
+ constraints?: string[]
21
+ /** How success is measured. */
22
+ successMetric?: string | null
23
+ /** Optional budget cap for this goal (USD). */
24
+ budgetUsd?: number | null
25
+ /** Optional deadline. */
26
+ deadlineAt?: number | null
27
+ status: GoalStatus
28
+ createdAt: number
29
+ updatedAt: number
30
+ }
@@ -2,7 +2,6 @@ export * from './message'
2
2
  export * from './session'
3
3
  export * from './agent'
4
4
  export * from './working-state'
5
- export * from './mission'
6
5
  export * from './extension'
7
6
  export * from './connector'
8
7
  export * from './provider'
@@ -14,3 +13,5 @@ export * from './skill'
14
13
  export * from './run'
15
14
  export * from './approval'
16
15
  export * from './misc'
16
+ export * from './goal'
17
+ export * from './swarmdock'
@@ -15,7 +15,6 @@ export type MessageWorkType = 'coding' | 'research' | 'writing' | 'review' | 'op
15
15
  export interface MessageSemanticsSummary {
16
16
  taskIntent: MessageTaskIntent
17
17
  workType: MessageWorkType
18
- walletIntent: 'none' | 'read_only' | 'transactional'
19
18
  isDeliverableTask: boolean
20
19
  isBroadGoal: boolean
21
20
  isResearchSynthesis: boolean
package/src/types/misc.ts CHANGED
@@ -126,9 +126,9 @@ export interface Chatroom {
126
126
 
127
127
  export interface ActivityEntry {
128
128
  id: string
129
- entityType: 'agent' | 'task' | 'connector' | 'session' | 'webhook' | 'schedule' | 'delegation' | 'swarm' | 'chatroom' | 'coordination'
129
+ entityType: 'agent' | 'task' | 'connector' | 'session' | 'webhook' | 'schedule' | 'delegation' | 'swarm' | 'chatroom' | 'coordination' | 'approval' | 'settings' | 'budget' | 'credential'
130
130
  entityId: string
131
- action: 'created' | 'updated' | 'deleted' | 'started' | 'stopped' | 'queued' | 'completed' | 'failed' | 'archived' | 'restored' | 'approved' | 'rejected' | 'delegated' | 'queried' | 'spawned' | 'timeout' | 'cancelled' | 'incident' | 'running' | 'claimed'
131
+ action: 'created' | 'updated' | 'deleted' | 'started' | 'stopped' | 'queued' | 'completed' | 'failed' | 'archived' | 'restored' | 'approved' | 'rejected' | 'delegated' | 'queried' | 'spawned' | 'timeout' | 'cancelled' | 'incident' | 'running' | 'claimed' | 'configured' | 'budget_exceeded' | 'budget_warning'
132
132
  actor: 'user' | 'agent' | 'system' | 'daemon'
133
133
  actorId?: string
134
134
  summary: string
@@ -388,8 +388,6 @@ export interface DelegationJobRecord {
388
388
  kind: DelegationJobKind
389
389
  status: DelegationJobStatus
390
390
  backend?: 'claude' | 'codex' | 'opencode' | 'gemini' | null
391
- missionId?: string | null
392
- parentMissionId?: string | null
393
391
  parentSessionId?: string | null
394
392
  childSessionId?: string | null
395
393
  agentId?: string | null
@@ -122,7 +122,6 @@ export type ProtocolSourceRef =
122
122
  | { kind: 'api' }
123
123
  | { kind: 'session'; sessionId: string }
124
124
  | { kind: 'chatroom'; chatroomId: string }
125
- | { kind: 'mission'; missionId: string }
126
125
  | { kind: 'task'; taskId: string }
127
126
  | { kind: 'schedule'; scheduleId: string }
128
127
  | { kind: 'protocol_run'; runId: string; parentRunId?: string | null; stepId?: string | null; branchId?: string | null }
@@ -319,7 +318,6 @@ export interface ProtocolRun {
319
318
  participantAgentIds: string[]
320
319
  facilitatorAgentId?: string | null
321
320
  observerAgentIds?: string[]
322
- missionId?: string | null
323
321
  taskId?: string | null
324
322
  sessionId?: string | null
325
323
  parentRunId?: string | null
package/src/types/run.ts CHANGED
@@ -17,7 +17,6 @@ export type ExecutionOwnerType =
17
17
  | 'task'
18
18
  | 'protocol_run'
19
19
  | 'schedule'
20
- | 'mission'
21
20
  | 'agent'
22
21
  | 'subagent'
23
22
 
@@ -48,7 +47,6 @@ export interface SessionRunRecoveryPayload {
48
47
  export interface SessionRunRecord {
49
48
  id: string
50
49
  sessionId: string
51
- missionId?: string | null
52
50
  kind?: ExecutionKind
53
51
  ownerType?: ExecutionOwnerType | null
54
52
  ownerId?: string | null
@@ -78,7 +76,6 @@ export interface SessionRunRecord {
78
76
  export interface SessionQueuedTurn {
79
77
  runId: string
80
78
  sessionId: string
81
- missionId?: string | null
82
79
  text: string
83
80
  queuedAt: number
84
81
  position: number
@@ -1,7 +1,6 @@
1
1
  import type { ProviderId, OllamaMode } from './provider'
2
2
  import type { ConnectorPlatform } from './connector'
3
3
  import type { Message } from './message'
4
- import type { MissionSummary } from './mission'
5
4
 
6
5
  export type SessionResetMode = 'idle' | 'daily' | 'isolated'
7
6
  export type SessionResetType = 'direct' | 'group' | 'thread' | 'main'
@@ -33,51 +32,6 @@ export interface SessionSkillRuntimeState {
33
32
  lastRunToolName?: string | null
34
33
  }
35
34
 
36
- export interface CanvasMetricItem {
37
- label: string
38
- value: string
39
- detail?: string
40
- tone?: 'default' | 'positive' | 'negative' | 'warning'
41
- }
42
-
43
- export interface CanvasCardItem {
44
- title: string
45
- body?: string
46
- meta?: string
47
- tone?: 'default' | 'positive' | 'negative' | 'warning'
48
- }
49
-
50
- export interface CanvasActionItem {
51
- label: string
52
- href?: string
53
- note?: string
54
- intent?: 'primary' | 'secondary' | 'success' | 'danger'
55
- }
56
-
57
- export interface CanvasTableData {
58
- columns: string[]
59
- rows: Array<Array<string | number | boolean | null>>
60
- caption?: string
61
- }
62
-
63
- export type CanvasBlock =
64
- | { type: 'markdown'; title?: string; markdown: string }
65
- | { type: 'metrics'; title?: string; items: CanvasMetricItem[] }
66
- | { type: 'cards'; title?: string; items: CanvasCardItem[] }
67
- | { type: 'table'; title?: string; table: CanvasTableData }
68
- | { type: 'code'; title?: string; code: string; language?: string }
69
- | { type: 'actions'; title?: string; items: CanvasActionItem[] }
70
-
71
- export interface CanvasDocument {
72
- kind: 'structured'
73
- title?: string
74
- subtitle?: string
75
- theme?: 'slate' | 'sky' | 'emerald' | 'amber' | 'rose'
76
- blocks: CanvasBlock[]
77
- updatedAt?: number | null
78
- }
79
-
80
- export type CanvasContent = string | CanvasDocument | null
81
35
 
82
36
  export interface MailboxEnvelope {
83
37
  id: string
@@ -204,8 +158,6 @@ export interface Session {
204
158
  lastSessionResetReason?: string | null
205
159
  identityState?: IdentityContinuityState | null
206
160
  sessionArchiveState?: SessionArchiveState | null
207
- missionId?: string | null
208
- missionSummary?: MissionSummary | null
209
161
  skillRuntimeState?: SessionSkillRuntimeState | null
210
162
  pinned?: boolean
211
163
  file?: string | null
@@ -217,7 +169,6 @@ export interface Session {
217
169
  vibe?: string
218
170
  theme?: string
219
171
  avatar?: string
220
- canvasContent?: CanvasContent
221
172
  /** Tracks how many times each memory ID has been injected via proactive recall in this session. */
222
173
  injectedMemoryIds?: Record<string, number>
223
174
  /** Structured working memory that survives compaction and flows through delegation. */
@@ -251,7 +202,6 @@ export type SessionTool =
251
202
  | 'edit_file'
252
203
  | 'process'
253
204
  | 'spawn_subagent'
254
- | 'canvas'
255
205
  | 'http_request'
256
206
  | 'git'
257
207
  | 'mailbox'
@@ -262,4 +212,4 @@ export type SessionTool =
262
212
  | 'crawl'
263
213
 
264
214
  export type SessionType = 'human'
265
- export type AppView = 'home' | 'agents' | 'org_chart' | 'inbox' | 'chatrooms' | 'protocols' | 'schedules' | 'memory' | 'missions' | 'tasks' | 'secrets' | 'providers' | 'skills' | 'connectors' | 'webhooks' | 'mcp_servers' | 'knowledge' | 'extensions' | 'usage' | 'wallets' | 'runs' | 'autonomy' | 'logs' | 'settings' | 'projects' | 'activity'
215
+ export type AppView = 'home' | 'agents' | 'org_chart' | 'inbox' | 'chatrooms' | 'protocols' | 'schedules' | 'memory' | 'tasks' | 'secrets' | 'wallets' | 'providers' | 'skills' | 'connectors' | 'webhooks' | 'mcp_servers' | 'knowledge' | 'extensions' | 'usage' | 'runs' | 'autonomy' | 'logs' | 'settings' | 'projects' | 'activity'
@@ -0,0 +1,29 @@
1
+ // --- SwarmDock Marketplace Types ---
2
+
3
+ export interface AgentWallet {
4
+ id: string
5
+ agentId: string
6
+ walletAddress: string
7
+ chain: 'base'
8
+ label?: string
9
+ encryptedPrivateKey?: string | null
10
+ spendingLimitUsdc?: string | null
11
+ dailyLimitUsdc?: string | null
12
+ requireApproval?: boolean
13
+ swarmdockAgentId?: string | null
14
+ swarmdockDid?: string | null
15
+ createdAt: number
16
+ }
17
+
18
+ export type SafeWallet = Omit<AgentWallet, 'encryptedPrivateKey'>
19
+
20
+ export interface WalletTransaction {
21
+ id: string
22
+ walletId: string
23
+ swarmdockTaskId?: string | null
24
+ amount: string
25
+ direction: 'in' | 'out'
26
+ txHash?: string | null
27
+ status: 'pending' | 'confirmed' | 'failed'
28
+ createdAt: number
29
+ }
package/src/types/task.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { MissionSummary } from './mission'
2
1
  import type { GoalContract } from './app-settings'
3
2
 
4
3
  // --- Task Board ---
@@ -28,11 +27,16 @@ export interface BoardTask {
28
27
  description: string
29
28
  status: BoardTaskStatus
30
29
  agentId: string
31
- missionId?: string | null
32
30
  protocolRunId?: string | null
33
- missionSummary?: MissionSummary | null
31
+ // Objective tracking (absorbed from missions)
32
+ objective?: string | null
33
+ successCriteria?: string[] | null
34
+ verificationSummary?: string | null
35
+ rootTaskId?: string | null
34
36
  projectId?: string
35
37
  goalContract?: GoalContract | null
38
+ /** Reference to a Goal in the goal hierarchy. Takes precedence over goalContract when set. */
39
+ goalId?: string | null
36
40
  cwd?: string | null
37
41
  file?: string | null
38
42
  sessionId?: string | null
@@ -137,4 +141,6 @@ export interface BoardTask {
137
141
  }>
138
142
  repairRunId?: string | null
139
143
  lastRepairAttemptAt?: number | null
144
+ // Atomic checkout — prevents two runners from starting the same task
145
+ checkoutRunId?: string | null
140
146
  }