@swarmclawai/swarmclaw 1.2.8 → 1.2.9

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 (195) hide show
  1. package/README.md +30 -6
  2. package/package.json +2 -2
  3. package/src/app/agents/[id]/page.tsx +1 -18
  4. package/src/app/api/agents/thread-route.test.ts +0 -1
  5. package/src/app/api/approvals/route.test.ts +6 -22
  6. package/src/app/api/connectors/route.ts +2 -2
  7. package/src/app/api/portability/export/route.ts +8 -0
  8. package/src/app/api/portability/import/route.test.ts +80 -0
  9. package/src/app/api/portability/import/route.ts +28 -0
  10. package/src/app/api/settings/route.ts +0 -2
  11. package/src/app/api/wallets/[id]/route.ts +15 -157
  12. package/src/app/api/wallets/generate/route.ts +22 -0
  13. package/src/app/api/wallets/route.test.ts +147 -0
  14. package/src/app/api/wallets/route.ts +13 -95
  15. package/src/app/autonomy/page.tsx +2 -57
  16. package/src/app/protocols/page.tsx +2 -21
  17. package/src/app/settings/page.tsx +0 -9
  18. package/src/app/wallets/page.tsx +105 -5
  19. package/src/cli/index.js +21 -33
  20. package/src/cli/spec.js +19 -30
  21. package/src/components/agents/agent-sheet.tsx +2 -40
  22. package/src/components/agents/inspector-panel.tsx +0 -83
  23. package/src/components/chat/chat-card.tsx +0 -31
  24. package/src/components/chat/message-bubble.tsx +1 -108
  25. package/src/components/connectors/connector-sheet.tsx +25 -1
  26. package/src/components/layout/sidebar-rail.tsx +6 -10
  27. package/src/components/projects/project-detail.tsx +3 -35
  28. package/src/components/projects/tabs/overview-tab.tsx +3 -59
  29. package/src/components/projects/tabs/work-tab.tsx +7 -77
  30. package/src/components/protocols/structured-session-launcher.tsx +1 -22
  31. package/src/components/shared/connector-platform-icon.tsx +1 -0
  32. package/src/components/tasks/task-card.tsx +4 -34
  33. package/src/components/tasks/task-sheet.tsx +6 -36
  34. package/src/components/wallets/wallet-list.tsx +150 -0
  35. package/src/lib/app/navigation.test.ts +0 -13
  36. package/src/lib/app/navigation.ts +2 -7
  37. package/src/lib/app/view-constants.ts +14 -19
  38. package/src/lib/server/agents/agent-thread-session.ts +0 -1
  39. package/src/lib/server/agents/delegation-advisory.test.ts +0 -1
  40. package/src/lib/server/agents/delegation-jobs.test.ts +0 -69
  41. package/src/lib/server/agents/delegation-jobs.ts +0 -25
  42. package/src/lib/server/agents/main-agent-loop.ts +1 -49
  43. package/src/lib/server/agents/subagent-runtime.ts +0 -1
  44. package/src/lib/server/approval-match.ts +0 -85
  45. package/src/lib/server/approvals.test.ts +6 -6
  46. package/src/lib/server/approvals.ts +0 -6
  47. package/src/lib/server/autonomy/supervisor-reflection.test.ts +0 -1
  48. package/src/lib/server/builtin-extensions.ts +0 -2
  49. package/src/lib/server/capability-router.test.ts +0 -2
  50. package/src/lib/server/chat-execution/chat-execution-tool-events.test.ts +14 -14
  51. package/src/lib/server/chat-execution/chat-execution-types.ts +0 -2
  52. package/src/lib/server/chat-execution/chat-execution-utils.ts +0 -2
  53. package/src/lib/server/chat-execution/chat-streaming-utils.ts +2 -30
  54. package/src/lib/server/chat-execution/chat-turn-finalization.ts +1 -36
  55. package/src/lib/server/chat-execution/chat-turn-preparation.ts +2 -22
  56. package/src/lib/server/chat-execution/iteration-event-handler.ts +0 -24
  57. package/src/lib/server/chat-execution/message-classifier.test.ts +0 -45
  58. package/src/lib/server/chat-execution/message-classifier.ts +1 -16
  59. package/src/lib/server/chat-execution/prompt-builder.test.ts +0 -1
  60. package/src/lib/server/chat-execution/prompt-builder.ts +0 -30
  61. package/src/lib/server/chat-execution/prompt-sections.ts +0 -1
  62. package/src/lib/server/chat-execution/situational-awareness.test.ts +2 -73
  63. package/src/lib/server/chat-execution/situational-awareness.ts +4 -38
  64. package/src/lib/server/chat-execution/stream-agent-chat.test.ts +8 -123
  65. package/src/lib/server/chat-execution/stream-agent-chat.ts +1 -5
  66. package/src/lib/server/chat-execution/stream-continuation.test.ts +4 -52
  67. package/src/lib/server/chat-execution/stream-continuation.ts +6 -48
  68. package/src/lib/server/chatrooms/session-mailbox.ts +0 -10
  69. package/src/lib/server/chats/chat-session-service.ts +3 -5
  70. package/src/lib/server/connectors/connector-inbound.ts +0 -1
  71. package/src/lib/server/connectors/connector-lifecycle.ts +19 -3
  72. package/src/lib/server/connectors/connector-service.ts +39 -9
  73. package/src/lib/server/connectors/swarmdock-bidding.ts +74 -0
  74. package/src/lib/server/connectors/swarmdock-payloads.test.ts +85 -0
  75. package/src/lib/server/connectors/swarmdock-secret.test.ts +128 -0
  76. package/src/lib/server/connectors/swarmdock-secret.ts +152 -0
  77. package/src/lib/server/connectors/swarmdock-tasks.ts +119 -0
  78. package/src/lib/server/connectors/swarmdock.ts +255 -0
  79. package/src/lib/server/execution-brief.test.ts +2 -25
  80. package/src/lib/server/execution-brief.ts +12 -35
  81. package/src/lib/server/execution-engine/task-attempt.ts +0 -1
  82. package/src/lib/server/persistence/storage-context.ts +0 -5
  83. package/src/lib/server/portability/export.ts +109 -0
  84. package/src/lib/server/portability/import.ts +159 -0
  85. package/src/lib/server/protocols/protocol-normalization.ts +0 -4
  86. package/src/lib/server/protocols/protocol-queries.ts +0 -6
  87. package/src/lib/server/protocols/protocol-run-lifecycle.ts +4 -32
  88. package/src/lib/server/protocols/protocol-service.ts +0 -1
  89. package/src/lib/server/protocols/protocol-step-helpers.ts +0 -4
  90. package/src/lib/server/protocols/protocol-step-processors.ts +0 -6
  91. package/src/lib/server/protocols/protocol-swarm.ts +0 -2
  92. package/src/lib/server/protocols/protocol-types.ts +0 -2
  93. package/src/lib/server/provider-health.ts +0 -9
  94. package/src/lib/server/runtime/daemon-state/core.ts +0 -9
  95. package/src/lib/server/runtime/daemon-state.test.ts +0 -35
  96. package/src/lib/server/runtime/heartbeat-service.ts +3 -23
  97. package/src/lib/server/runtime/queue/core.ts +11 -33
  98. package/src/lib/server/runtime/runtime-storage-write-paths.test.ts +6 -6
  99. package/src/lib/server/runtime/scheduler.ts +0 -13
  100. package/src/lib/server/runtime/session-run-manager/drain.ts +0 -24
  101. package/src/lib/server/runtime/session-run-manager/enqueue.ts +0 -1
  102. package/src/lib/server/runtime/session-run-manager/queries.ts +0 -1
  103. package/src/lib/server/runtime/session-run-manager/recovery.ts +0 -1
  104. package/src/lib/server/runtime/session-run-manager.test.ts +0 -28
  105. package/src/lib/server/session-tools/crud.ts +0 -14
  106. package/src/lib/server/session-tools/delegate.ts +0 -4
  107. package/src/lib/server/session-tools/index.ts +0 -4
  108. package/src/lib/server/session-tools/team-context.ts +0 -3
  109. package/src/lib/server/storage-normalization.ts +8 -0
  110. package/src/lib/server/storage.ts +18 -45
  111. package/src/lib/server/tasks/task-checkout.ts +59 -0
  112. package/src/lib/server/tasks/task-lifecycle.ts +2 -0
  113. package/src/lib/server/tasks/task-route-service.ts +4 -26
  114. package/src/lib/server/tasks/task-service.ts +0 -7
  115. package/src/lib/server/tool-aliases.ts +0 -1
  116. package/src/lib/server/tool-capability-policy-advanced.test.ts +4 -4
  117. package/src/lib/server/tool-capability-policy.ts +0 -2
  118. package/src/lib/server/tool-planning.ts +0 -12
  119. package/src/lib/server/universal-tool-access.ts +0 -1
  120. package/src/lib/server/wallets/wallet-crypto.ts +33 -0
  121. package/src/lib/server/wallets/wallet-repository.ts +24 -0
  122. package/src/lib/server/wallets/wallet-service.ts +119 -0
  123. package/src/lib/server/working-state/extraction.ts +8 -42
  124. package/src/lib/server/working-state/normalization.ts +10 -103
  125. package/src/lib/server/working-state/service.ts +12 -21
  126. package/src/lib/strip-internal-metadata.test.ts +1 -1
  127. package/src/lib/strip-internal-metadata.ts +1 -1
  128. package/src/lib/tool-definitions.ts +0 -1
  129. package/src/lib/validation/schemas.ts +33 -2
  130. package/src/stores/slices/data-slice.ts +5 -1
  131. package/src/stores/slices/ui-slice.ts +0 -4
  132. package/src/types/agent.ts +0 -84
  133. package/src/types/app-settings.ts +0 -2
  134. package/src/types/approval.ts +0 -2
  135. package/src/types/connector.ts +1 -0
  136. package/src/types/index.ts +1 -1
  137. package/src/types/message.ts +0 -1
  138. package/src/types/misc.ts +0 -2
  139. package/src/types/protocol.ts +0 -2
  140. package/src/types/run.ts +0 -3
  141. package/src/types/session.ts +1 -51
  142. package/src/types/swarmdock.ts +29 -0
  143. package/src/types/task.ts +7 -3
  144. package/src/types/working-state.ts +2 -9
  145. package/src/views/settings/section-runtime-loop.tsx +0 -14
  146. package/src/app/api/canvas/[sessionId]/route.ts +0 -35
  147. package/src/app/api/missions/[id]/actions/route.ts +0 -31
  148. package/src/app/api/missions/[id]/events/route.ts +0 -14
  149. package/src/app/api/missions/[id]/route.ts +0 -10
  150. package/src/app/api/missions/route.test.ts +0 -244
  151. package/src/app/api/missions/route.ts +0 -57
  152. package/src/app/api/wallets/[id]/approve/route.ts +0 -79
  153. package/src/app/api/wallets/[id]/balance-history/route.ts +0 -18
  154. package/src/app/api/wallets/[id]/send/route.ts +0 -113
  155. package/src/app/api/wallets/[id]/transactions/route.ts +0 -18
  156. package/src/app/missions/[id]/page.tsx +0 -3
  157. package/src/app/missions/page.tsx +0 -685
  158. package/src/components/canvas/canvas-panel.tsx +0 -267
  159. package/src/components/wallets/wallet-approval-dialog.tsx +0 -107
  160. package/src/components/wallets/wallet-panel.tsx +0 -1010
  161. package/src/components/wallets/wallet-section.tsx +0 -260
  162. package/src/features/missions/queries.ts +0 -23
  163. package/src/lib/canvas-content.test.ts +0 -360
  164. package/src/lib/canvas-content.ts +0 -198
  165. package/src/lib/server/canvas-content.test.ts +0 -32
  166. package/src/lib/server/canvas-content.ts +0 -6
  167. package/src/lib/server/ethereum.ts +0 -591
  168. package/src/lib/server/evm-swap.ts +0 -476
  169. package/src/lib/server/missions/mission-intent.test.ts +0 -63
  170. package/src/lib/server/missions/mission-intent.ts +0 -569
  171. package/src/lib/server/missions/mission-repository.ts +0 -74
  172. package/src/lib/server/missions/mission-service/actions.ts +0 -6
  173. package/src/lib/server/missions/mission-service/bindings.ts +0 -9
  174. package/src/lib/server/missions/mission-service/context.ts +0 -4
  175. package/src/lib/server/missions/mission-service/core.ts +0 -2271
  176. package/src/lib/server/missions/mission-service/queries.ts +0 -12
  177. package/src/lib/server/missions/mission-service/recovery.ts +0 -5
  178. package/src/lib/server/missions/mission-service/ticks.ts +0 -9
  179. package/src/lib/server/missions/mission-service.test.ts +0 -888
  180. package/src/lib/server/missions/mission-service.ts +0 -6
  181. package/src/lib/server/session-tools/canvas.ts +0 -105
  182. package/src/lib/server/session-tools/wallet-tool.test.ts +0 -150
  183. package/src/lib/server/session-tools/wallet.ts +0 -1287
  184. package/src/lib/server/solana.ts +0 -327
  185. package/src/lib/server/wallet/wallet-execution.test.ts +0 -198
  186. package/src/lib/server/wallet/wallet-portfolio.test.ts +0 -98
  187. package/src/lib/server/wallet/wallet-portfolio.ts +0 -772
  188. package/src/lib/server/wallet/wallet-service.test.ts +0 -81
  189. package/src/lib/server/wallet/wallet-service.ts +0 -225
  190. package/src/lib/wallet/wallet-transactions.test.ts +0 -75
  191. package/src/lib/wallet/wallet-transactions.ts +0 -43
  192. package/src/lib/wallet/wallet.test.ts +0 -333
  193. package/src/lib/wallet/wallet.ts +0 -183
  194. package/src/types/mission.ts +0 -185
  195. package/src/views/settings/section-wallets.tsx +0 -35
@@ -1,79 +0,0 @@
1
- import { NextResponse } from 'next/server'
2
- import { safeParseBody } from '@/lib/server/safe-parse-body'
3
- import { loadWallets, loadWalletTransactions, upsertWalletTransaction } from '@/lib/server/storage'
4
- import { notify } from '@/lib/server/ws-hub'
5
- import type { AgentWallet, WalletTransaction } from '@/types'
6
- import { getWalletAtomicAmount } from '@/lib/wallet/wallet'
7
- import { sendWalletNativeAsset, validateWalletSendLimits } from '@/lib/server/wallet/wallet-service'
8
- import { errorMessage } from '@/lib/shared-utils'
9
- export const dynamic = 'force-dynamic'
10
-
11
- export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {
12
- const { id } = await params
13
- const wallets = loadWallets() as Record<string, AgentWallet>
14
- const wallet = wallets[id]
15
- if (!wallet) return NextResponse.json({ error: 'Wallet not found' }, { status: 404 })
16
-
17
- const { data: body, error } = await safeParseBody(req)
18
- if (error) return error
19
- const transactionId = typeof body.transactionId === 'string' ? body.transactionId.trim() : ''
20
- const decision = body.decision as 'approve' | 'deny'
21
-
22
- if (!transactionId) {
23
- return NextResponse.json({ error: 'transactionId is required' }, { status: 400 })
24
- }
25
- if (decision !== 'approve' && decision !== 'deny') {
26
- return NextResponse.json({ error: 'decision must be "approve" or "deny"' }, { status: 400 })
27
- }
28
-
29
- const allTxs = loadWalletTransactions() as Record<string, WalletTransaction>
30
- const tx = allTxs[transactionId]
31
- if (!tx || tx.walletId !== id) {
32
- return NextResponse.json({ error: 'Transaction not found' }, { status: 404 })
33
- }
34
- if (tx.status !== 'pending_approval') {
35
- return NextResponse.json({ error: `Transaction is already ${tx.status}` }, { status: 409 })
36
- }
37
-
38
- if (decision === 'deny') {
39
- tx.status = 'denied'
40
- tx.approvedBy = 'user'
41
- upsertWalletTransaction(transactionId, tx)
42
- notify('wallets')
43
- return NextResponse.json({ status: 'denied', transactionId })
44
- }
45
-
46
- // Approve — sign and submit
47
- try {
48
- const limitError = validateWalletSendLimits({ wallet, amountAtomic: getWalletAtomicAmount(tx), excludeTransactionId: transactionId })
49
- if (limitError) {
50
- tx.status = 'failed'
51
- upsertWalletTransaction(transactionId, tx)
52
- notify('wallets')
53
- return NextResponse.json({
54
- error: limitError,
55
- transactionId,
56
- status: 'failed',
57
- }, { status: limitError === 'Amount must be positive' ? 400 : 403 })
58
- }
59
-
60
- const { signature, feeAtomic } = await sendWalletNativeAsset(wallet, tx.toAddress, getWalletAtomicAmount(tx))
61
- tx.status = 'confirmed'
62
- tx.signature = signature
63
- tx.feeAtomic = feeAtomic
64
- tx.feeLamports = wallet.chain === 'solana' && feeAtomic ? Number.parseInt(feeAtomic, 10) : undefined
65
- tx.approvedBy = 'user'
66
- upsertWalletTransaction(transactionId, tx)
67
- notify('wallets')
68
- return NextResponse.json({ status: 'confirmed', transactionId, signature })
69
- } catch (err: unknown) {
70
- tx.status = 'failed'
71
- upsertWalletTransaction(transactionId, tx)
72
- notify('wallets')
73
- return NextResponse.json({
74
- error: errorMessage(err),
75
- transactionId,
76
- status: 'failed',
77
- }, { status: 500 })
78
- }
79
- }
@@ -1,18 +0,0 @@
1
- import { NextResponse } from 'next/server'
2
- import { loadWallets, loadWalletBalanceHistory } from '@/lib/server/storage'
3
- import type { AgentWallet, WalletBalanceSnapshot } from '@/types'
4
- export const dynamic = 'force-dynamic'
5
-
6
- export async function GET(_req: Request, { params }: { params: Promise<{ id: string }> }) {
7
- const { id } = await params
8
- const wallets = loadWallets() as Record<string, AgentWallet>
9
- const wallet = wallets[id]
10
- if (!wallet) return NextResponse.json({ error: 'Wallet not found' }, { status: 404 })
11
-
12
- const allSnapshots = loadWalletBalanceHistory() as Record<string, WalletBalanceSnapshot>
13
- const walletSnapshots = Object.values(allSnapshots)
14
- .filter((s) => s.walletId === id)
15
- .sort((a, b) => a.timestamp - b.timestamp)
16
-
17
- return NextResponse.json(walletSnapshots)
18
- }
@@ -1,113 +0,0 @@
1
- import { NextResponse } from 'next/server'
2
- import { safeParseBody } from '@/lib/server/safe-parse-body'
3
- import { genId } from '@/lib/id'
4
- import { loadSettings, loadWallets, upsertWalletTransaction } from '@/lib/server/storage'
5
- import { notify } from '@/lib/server/ws-hub'
6
- import type { AgentWallet, WalletTransaction } from '@/types'
7
- import {
8
- normalizeAtomicString,
9
- } from '@/lib/wallet/wallet'
10
- import {
11
- isValidWalletAddress,
12
- sendWalletNativeAsset,
13
- validateWalletSendLimits,
14
- walletRequiresApproval,
15
- } from '@/lib/server/wallet/wallet-service'
16
- import { errorMessage } from '@/lib/shared-utils'
17
- export const dynamic = 'force-dynamic'
18
-
19
- export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {
20
- const { id } = await params
21
- const wallets = loadWallets() as Record<string, AgentWallet>
22
- const wallet = wallets[id]
23
- if (!wallet) return NextResponse.json({ error: 'Wallet not found' }, { status: 404 })
24
- const settings = loadSettings()
25
-
26
- const { data: body, error } = await safeParseBody(req)
27
- if (error) return error
28
- const toAddress = typeof body.toAddress === 'string' ? body.toAddress.trim() : ''
29
- const amountAtomic = normalizeAtomicString(body.amountAtomic ?? body.amountLamports, '0')
30
- const memo = typeof body.memo === 'string' ? body.memo.slice(0, 500) : undefined
31
-
32
- if (!toAddress || !isValidWalletAddress(wallet.chain, toAddress)) {
33
- return NextResponse.json({ error: 'Invalid recipient address' }, { status: 400 })
34
- }
35
- const limitError = validateWalletSendLimits({ wallet, amountAtomic })
36
- if (limitError) {
37
- return NextResponse.json({ error: limitError }, { status: limitError === 'Amount must be positive' ? 400 : 403 })
38
- }
39
-
40
- const txId = genId(8)
41
- const now = Date.now()
42
-
43
- // When approvals are enabled globally and for this wallet, create a pending request instead of sending.
44
- if (walletRequiresApproval(wallet, settings)) {
45
- const pendingTx: WalletTransaction = {
46
- id: txId,
47
- walletId: id,
48
- agentId: wallet.agentId,
49
- chain: wallet.chain,
50
- type: 'send',
51
- signature: '',
52
- fromAddress: wallet.publicKey,
53
- toAddress,
54
- amountAtomic,
55
- amountLamports: wallet.chain === 'solana' ? Number.parseInt(amountAtomic, 10) : undefined,
56
- status: 'pending_approval',
57
- memo,
58
- timestamp: now,
59
- }
60
- upsertWalletTransaction(txId, pendingTx)
61
- notify('wallets')
62
- return NextResponse.json({ status: 'pending_approval', transactionId: txId, message: 'Transaction requires user approval' })
63
- }
64
-
65
- // Auto-approved — sign and submit
66
- try {
67
- const { signature, feeAtomic } = await sendWalletNativeAsset(wallet, toAddress, amountAtomic)
68
- const confirmedTx: WalletTransaction = {
69
- id: txId,
70
- walletId: id,
71
- agentId: wallet.agentId,
72
- chain: wallet.chain,
73
- type: 'send',
74
- signature,
75
- fromAddress: wallet.publicKey,
76
- toAddress,
77
- amountAtomic,
78
- amountLamports: wallet.chain === 'solana' ? Number.parseInt(amountAtomic, 10) : undefined,
79
- feeAtomic,
80
- feeLamports: wallet.chain === 'solana' && feeAtomic ? Number.parseInt(feeAtomic, 10) : undefined,
81
- status: 'confirmed',
82
- memo,
83
- approvedBy: 'auto',
84
- timestamp: now,
85
- }
86
- upsertWalletTransaction(txId, confirmedTx)
87
- notify('wallets')
88
- return NextResponse.json({ status: 'confirmed', transactionId: txId, signature })
89
- } catch (err: unknown) {
90
- const failedTx: WalletTransaction = {
91
- id: txId,
92
- walletId: id,
93
- agentId: wallet.agentId,
94
- chain: wallet.chain,
95
- type: 'send',
96
- signature: '',
97
- fromAddress: wallet.publicKey,
98
- toAddress,
99
- amountAtomic,
100
- amountLamports: wallet.chain === 'solana' ? Number.parseInt(amountAtomic, 10) : undefined,
101
- status: 'failed',
102
- memo,
103
- timestamp: now,
104
- }
105
- upsertWalletTransaction(txId, failedTx)
106
- notify('wallets')
107
- return NextResponse.json({
108
- error: errorMessage(err),
109
- transactionId: txId,
110
- status: 'failed',
111
- }, { status: 500 })
112
- }
113
- }
@@ -1,18 +0,0 @@
1
- import { NextResponse } from 'next/server'
2
- import { loadWallets, loadWalletTransactions } from '@/lib/server/storage'
3
- import type { AgentWallet, WalletTransaction } from '@/types'
4
- export const dynamic = 'force-dynamic'
5
-
6
- export async function GET(_req: Request, { params }: { params: Promise<{ id: string }> }) {
7
- const { id } = await params
8
- const wallets = loadWallets() as Record<string, AgentWallet>
9
- const wallet = wallets[id]
10
- if (!wallet) return NextResponse.json({ error: 'Wallet not found' }, { status: 404 })
11
-
12
- const allTxs = loadWalletTransactions() as Record<string, WalletTransaction>
13
- const walletTxs = Object.values(allTxs)
14
- .filter((tx) => tx.walletId === id)
15
- .sort((a, b) => b.timestamp - a.timestamp)
16
-
17
- return NextResponse.json(walletTxs)
18
- }
@@ -1,3 +0,0 @@
1
- 'use client'
2
-
3
- export { default } from '../page'