@swarmclawai/swarmclaw 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -22
- package/package.json +1 -1
- package/src/app/api/agents/[id]/route.ts +26 -0
- package/src/app/api/agents/[id]/thread/route.ts +36 -7
- package/src/app/api/agents/route.ts +12 -1
- package/src/app/api/auth/route.ts +76 -7
- package/src/app/api/chatrooms/[id]/chat/route.ts +7 -2
- package/src/app/api/chats/[id]/browser/route.ts +5 -1
- package/src/app/api/chats/[id]/chat/route.ts +7 -3
- package/src/app/api/chats/[id]/main-loop/route.ts +7 -88
- package/src/app/api/chats/[id]/messages/route.ts +19 -13
- package/src/app/api/chats/[id]/route.ts +18 -0
- package/src/app/api/chats/[id]/stop/route.ts +6 -1
- package/src/app/api/chats/route.ts +16 -0
- package/src/app/api/connectors/[id]/doctor/route.ts +26 -0
- package/src/app/api/connectors/doctor/route.ts +13 -0
- package/src/app/api/files/open/route.ts +16 -14
- package/src/app/api/memory/maintenance/route.ts +11 -1
- package/src/app/api/openclaw/agent-files/route.ts +27 -4
- package/src/app/api/openclaw/skills/route.ts +11 -3
- package/src/app/api/plugins/dependencies/route.ts +24 -0
- package/src/app/api/plugins/install/route.ts +15 -92
- package/src/app/api/plugins/route.ts +3 -26
- package/src/app/api/plugins/settings/route.ts +17 -12
- package/src/app/api/plugins/ui/route.ts +1 -0
- package/src/app/api/settings/route.ts +49 -7
- package/src/app/api/tasks/[id]/route.ts +15 -6
- package/src/app/api/tasks/bulk/route.ts +2 -2
- package/src/app/api/tasks/route.ts +9 -4
- package/src/app/api/webhooks/[id]/route.ts +8 -1
- package/src/app/page.tsx +9 -2
- package/src/cli/index.js +4 -0
- package/src/cli/index.ts +3 -10
- package/src/components/agents/agent-card.tsx +15 -12
- package/src/components/agents/agent-chat-list.tsx +101 -1
- package/src/components/agents/agent-list.tsx +46 -9
- package/src/components/agents/agent-sheet.tsx +207 -16
- package/src/components/agents/inspector-panel.tsx +108 -48
- package/src/components/auth/access-key-gate.tsx +36 -97
- package/src/components/chat/chat-area.tsx +29 -13
- package/src/components/chat/chat-card.tsx +4 -20
- package/src/components/chat/chat-header.tsx +255 -353
- package/src/components/chat/chat-list.tsx +7 -9
- package/src/components/chat/checkpoint-timeline.tsx +1 -1
- package/src/components/chat/message-list.tsx +3 -1
- package/src/components/chatrooms/chatroom-view.tsx +347 -205
- package/src/components/connectors/connector-list.tsx +265 -127
- package/src/components/connectors/connector-sheet.tsx +217 -0
- package/src/components/home/home-view.tsx +128 -4
- package/src/components/layout/app-layout.tsx +383 -194
- package/src/components/layout/mobile-header.tsx +26 -8
- package/src/components/plugins/plugin-list.tsx +15 -3
- package/src/components/plugins/plugin-sheet.tsx +118 -9
- package/src/components/projects/project-detail.tsx +183 -0
- package/src/components/shared/agent-picker-list.tsx +2 -2
- package/src/components/shared/command-palette.tsx +111 -24
- package/src/components/shared/settings/plugin-manager.tsx +20 -4
- package/src/components/shared/settings/section-capability-policy.tsx +105 -0
- package/src/components/shared/settings/section-heartbeat.tsx +77 -0
- package/src/components/shared/settings/section-orchestrator.tsx +3 -3
- package/src/components/shared/settings/section-runtime-loop.tsx +5 -5
- package/src/components/shared/settings/section-secrets.tsx +6 -6
- package/src/components/shared/settings/section-user-preferences.tsx +1 -1
- package/src/components/shared/settings/section-voice.tsx +5 -1
- package/src/components/shared/settings/section-web-search.tsx +10 -2
- package/src/components/shared/settings/settings-page.tsx +245 -46
- package/src/components/tasks/approvals-panel.tsx +205 -18
- package/src/components/tasks/task-board.tsx +242 -46
- package/src/components/usage/metrics-dashboard.tsx +74 -1
- package/src/components/wallets/wallet-panel.tsx +17 -5
- package/src/components/webhooks/webhook-sheet.tsx +7 -7
- package/src/lib/auth.ts +17 -0
- package/src/lib/chat-streaming-state.test.ts +108 -0
- package/src/lib/chat-streaming-state.ts +108 -0
- package/src/lib/openclaw-agent-id.test.ts +14 -0
- package/src/lib/openclaw-agent-id.ts +31 -0
- package/src/lib/server/agent-assignment.test.ts +112 -0
- package/src/lib/server/agent-assignment.ts +169 -0
- package/src/lib/server/approval-connector-notify.test.ts +253 -0
- package/src/lib/server/approvals-auto-approve.test.ts +205 -0
- package/src/lib/server/approvals.ts +483 -75
- package/src/lib/server/autonomy-runtime.test.ts +341 -0
- package/src/lib/server/browser-state.test.ts +118 -0
- package/src/lib/server/browser-state.ts +123 -0
- package/src/lib/server/build-llm.test.ts +36 -0
- package/src/lib/server/build-llm.ts +11 -4
- package/src/lib/server/builtin-plugins.ts +34 -0
- package/src/lib/server/chat-execution-heartbeat.test.ts +40 -0
- package/src/lib/server/chat-execution-tool-events.test.ts +134 -0
- package/src/lib/server/chat-execution.ts +250 -61
- package/src/lib/server/chatroom-health.test.ts +26 -0
- package/src/lib/server/chatroom-health.ts +2 -3
- package/src/lib/server/chatroom-helpers.test.ts +67 -2
- package/src/lib/server/chatroom-helpers.ts +45 -5
- package/src/lib/server/connectors/discord.ts +175 -11
- package/src/lib/server/connectors/doctor.test.ts +80 -0
- package/src/lib/server/connectors/doctor.ts +116 -0
- package/src/lib/server/connectors/manager.ts +946 -110
- package/src/lib/server/connectors/policy.test.ts +222 -0
- package/src/lib/server/connectors/policy.ts +452 -0
- package/src/lib/server/connectors/slack.ts +188 -9
- package/src/lib/server/connectors/telegram.ts +65 -15
- package/src/lib/server/connectors/thread-context.test.ts +44 -0
- package/src/lib/server/connectors/thread-context.ts +72 -0
- package/src/lib/server/connectors/types.ts +41 -11
- package/src/lib/server/daemon-state.ts +59 -1
- package/src/lib/server/data-dir.ts +13 -0
- package/src/lib/server/delegation-jobs.test.ts +140 -0
- package/src/lib/server/delegation-jobs.ts +248 -0
- package/src/lib/server/document-utils.test.ts +47 -0
- package/src/lib/server/document-utils.ts +397 -0
- package/src/lib/server/heartbeat-service.ts +13 -39
- package/src/lib/server/heartbeat-source.test.ts +22 -0
- package/src/lib/server/heartbeat-source.ts +7 -0
- package/src/lib/server/identity-continuity.test.ts +77 -0
- package/src/lib/server/identity-continuity.ts +127 -0
- package/src/lib/server/mailbox-utils.ts +347 -0
- package/src/lib/server/main-agent-loop.ts +27 -967
- package/src/lib/server/memory-db.ts +4 -6
- package/src/lib/server/memory-tiers.ts +40 -0
- package/src/lib/server/openclaw-agent-resolver.test.ts +70 -0
- package/src/lib/server/openclaw-agent-resolver.ts +128 -0
- package/src/lib/server/openclaw-exec-config.ts +5 -6
- package/src/lib/server/openclaw-skills-normalize.test.ts +56 -0
- package/src/lib/server/openclaw-skills-normalize.ts +136 -0
- package/src/lib/server/openclaw-sync.ts +3 -2
- package/src/lib/server/orchestrator-lg.ts +17 -6
- package/src/lib/server/orchestrator.ts +2 -2
- package/src/lib/server/playwright-proxy.mjs +27 -3
- package/src/lib/server/plugins.test.ts +207 -0
- package/src/lib/server/plugins.ts +822 -69
- package/src/lib/server/provider-health.ts +33 -3
- package/src/lib/server/queue.ts +3 -20
- package/src/lib/server/scheduler.ts +2 -0
- package/src/lib/server/session-archive-memory.test.ts +85 -0
- package/src/lib/server/session-archive-memory.ts +230 -0
- package/src/lib/server/session-mailbox.ts +8 -18
- package/src/lib/server/session-reset-policy.test.ts +99 -0
- package/src/lib/server/session-reset-policy.ts +311 -0
- package/src/lib/server/session-run-manager.ts +33 -80
- package/src/lib/server/session-tools/autonomy-tools.test.ts +105 -0
- package/src/lib/server/session-tools/calendar.ts +2 -12
- package/src/lib/server/session-tools/connector.ts +109 -8
- package/src/lib/server/session-tools/context.ts +14 -2
- package/src/lib/server/session-tools/crawl.ts +447 -0
- package/src/lib/server/session-tools/crud.ts +70 -32
- package/src/lib/server/session-tools/delegate-fallback.test.ts +219 -0
- package/src/lib/server/session-tools/delegate.ts +406 -20
- package/src/lib/server/session-tools/discovery.ts +22 -4
- package/src/lib/server/session-tools/document.ts +283 -0
- package/src/lib/server/session-tools/email.ts +1 -3
- package/src/lib/server/session-tools/extract.ts +137 -0
- package/src/lib/server/session-tools/file-normalize.test.ts +93 -0
- package/src/lib/server/session-tools/file-send.test.ts +84 -1
- package/src/lib/server/session-tools/file.ts +237 -24
- package/src/lib/server/session-tools/human-loop.ts +227 -0
- package/src/lib/server/session-tools/image-gen.ts +1 -3
- package/src/lib/server/session-tools/index.ts +56 -1
- package/src/lib/server/session-tools/mailbox.ts +276 -0
- package/src/lib/server/session-tools/memory.ts +35 -3
- package/src/lib/server/session-tools/monitor.ts +150 -7
- package/src/lib/server/session-tools/normalize-tool-args.ts +17 -14
- package/src/lib/server/session-tools/platform-normalize.test.ts +142 -0
- package/src/lib/server/session-tools/platform.ts +142 -4
- package/src/lib/server/session-tools/plugin-creator.ts +86 -23
- package/src/lib/server/session-tools/primitive-tools.test.ts +257 -0
- package/src/lib/server/session-tools/replicate.ts +1 -3
- package/src/lib/server/session-tools/schedule.ts +20 -10
- package/src/lib/server/session-tools/session-info.ts +36 -3
- package/src/lib/server/session-tools/session-tools-wiring.test.ts +31 -17
- package/src/lib/server/session-tools/subagent.ts +193 -27
- package/src/lib/server/session-tools/table.ts +587 -0
- package/src/lib/server/session-tools/wallet.ts +13 -10
- package/src/lib/server/session-tools/web-browser-config.test.ts +39 -0
- package/src/lib/server/session-tools/web.ts +896 -100
- package/src/lib/server/storage.ts +226 -7
- package/src/lib/server/stream-agent-chat.ts +46 -21
- package/src/lib/server/structured-extract.test.ts +72 -0
- package/src/lib/server/structured-extract.ts +373 -0
- package/src/lib/server/task-mention.test.ts +16 -2
- package/src/lib/server/task-mention.ts +61 -10
- package/src/lib/server/tool-aliases.ts +44 -7
- package/src/lib/server/tool-capability-policy.ts +6 -0
- package/src/lib/server/tool-retry.ts +2 -0
- package/src/lib/server/watch-jobs.test.ts +173 -0
- package/src/lib/server/watch-jobs.ts +532 -0
- package/src/lib/server/ws-hub.ts +5 -3
- package/src/lib/validation/schemas.test.ts +26 -0
- package/src/lib/validation/schemas.ts +7 -0
- package/src/lib/ws-client.ts +14 -12
- package/src/proxy.ts +5 -5
- package/src/stores/use-app-store.ts +0 -6
- package/src/stores/use-chat-store.ts +31 -2
- package/src/types/index.ts +287 -44
- package/src/components/chat/new-chat-sheet.tsx +0 -253
- package/src/lib/server/main-session.ts +0 -17
- package/src/lib/server/session-run-manager.test.ts +0 -26
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
|
-
import {
|
|
2
|
+
import { active, loadStoredItem, upsertStoredItem } from '@/lib/server/storage'
|
|
3
3
|
import { notFound } from '@/lib/server/collection-helpers'
|
|
4
|
+
import { getSessionRunState } from '@/lib/server/session-run-manager'
|
|
5
|
+
import { pruneStreamingAssistantArtifacts } from '@/lib/chat-streaming-state'
|
|
4
6
|
|
|
5
7
|
export async function GET(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
6
8
|
const { id } = await params
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
9
|
+
const session = loadStoredItem('sessions', id)
|
|
10
|
+
if (!session) return notFound()
|
|
11
|
+
session.messages = Array.isArray(session.messages) ? session.messages : []
|
|
12
|
+
|
|
13
|
+
const run = getSessionRunState(id)
|
|
14
|
+
const hasLiveRun = active.has(id) || !!run.runningRunId
|
|
15
|
+
if (!hasLiveRun && pruneStreamingAssistantArtifacts(session.messages)) {
|
|
16
|
+
upsertStoredItem('sessions', id, session)
|
|
17
|
+
}
|
|
9
18
|
|
|
10
19
|
const url = new URL(req.url)
|
|
11
20
|
const limitParam = url.searchParams.get('limit')
|
|
12
21
|
const beforeParam = url.searchParams.get('before')
|
|
13
22
|
|
|
14
|
-
const allMessages =
|
|
23
|
+
const allMessages = Array.isArray(session.messages) ? session.messages : []
|
|
15
24
|
const total = allMessages.length
|
|
16
25
|
|
|
17
26
|
// If no limit param, return all messages (backward compatible)
|
|
@@ -41,8 +50,7 @@ export async function POST(req: Request, { params }: { params: Promise<{ id: str
|
|
|
41
50
|
if (body.kind !== 'context-clear') {
|
|
42
51
|
return NextResponse.json({ error: 'Only context-clear kind is supported' }, { status: 400 })
|
|
43
52
|
}
|
|
44
|
-
const
|
|
45
|
-
const session = sessions[id]
|
|
53
|
+
const session = loadStoredItem('sessions', id)
|
|
46
54
|
if (!session) return notFound()
|
|
47
55
|
|
|
48
56
|
session.messages.push({
|
|
@@ -51,15 +59,14 @@ export async function POST(req: Request, { params }: { params: Promise<{ id: str
|
|
|
51
59
|
kind: 'context-clear',
|
|
52
60
|
time: Date.now(),
|
|
53
61
|
})
|
|
54
|
-
|
|
62
|
+
upsertStoredItem('sessions', id, session)
|
|
55
63
|
return NextResponse.json({ ok: true })
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
export async function PUT(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
59
67
|
const { id } = await params
|
|
60
68
|
const body = await req.json() as { messageIndex: number; bookmarked: boolean }
|
|
61
|
-
const
|
|
62
|
-
const session = sessions[id]
|
|
69
|
+
const session = loadStoredItem('sessions', id)
|
|
63
70
|
if (!session) return notFound()
|
|
64
71
|
|
|
65
72
|
const { messageIndex, bookmarked } = body
|
|
@@ -68,15 +75,14 @@ export async function PUT(req: Request, { params }: { params: Promise<{ id: stri
|
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
session.messages[messageIndex].bookmarked = bookmarked
|
|
71
|
-
|
|
78
|
+
upsertStoredItem('sessions', id, session)
|
|
72
79
|
return NextResponse.json(session.messages[messageIndex])
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
export async function DELETE(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
76
83
|
const { id } = await params
|
|
77
84
|
const body = await req.json() as { messageIndex: number }
|
|
78
|
-
const
|
|
79
|
-
const session = sessions[id]
|
|
85
|
+
const session = loadStoredItem('sessions', id)
|
|
80
86
|
if (!session) return notFound()
|
|
81
87
|
|
|
82
88
|
const { messageIndex } = body
|
|
@@ -90,6 +96,6 @@ export async function DELETE(req: Request, { params }: { params: Promise<{ id: s
|
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
session.messages.splice(messageIndex, 1)
|
|
93
|
-
|
|
99
|
+
upsertStoredItem('sessions', id, session)
|
|
94
100
|
return NextResponse.json({ ok: true })
|
|
95
101
|
}
|
|
@@ -45,6 +45,24 @@ export async function PUT(req: Request, { params }: { params: Promise<{ id: stri
|
|
|
45
45
|
}
|
|
46
46
|
if (updates.heartbeatEnabled !== undefined) sessions[id].heartbeatEnabled = updates.heartbeatEnabled
|
|
47
47
|
if (updates.heartbeatIntervalSec !== undefined) sessions[id].heartbeatIntervalSec = updates.heartbeatIntervalSec
|
|
48
|
+
if (updates.sessionResetMode !== undefined) sessions[id].sessionResetMode = updates.sessionResetMode
|
|
49
|
+
if (updates.sessionIdleTimeoutSec !== undefined) sessions[id].sessionIdleTimeoutSec = updates.sessionIdleTimeoutSec
|
|
50
|
+
if (updates.sessionMaxAgeSec !== undefined) sessions[id].sessionMaxAgeSec = updates.sessionMaxAgeSec
|
|
51
|
+
if (updates.sessionDailyResetAt !== undefined) sessions[id].sessionDailyResetAt = updates.sessionDailyResetAt
|
|
52
|
+
if (updates.sessionResetTimezone !== undefined) sessions[id].sessionResetTimezone = updates.sessionResetTimezone
|
|
53
|
+
if (updates.thinkingLevel !== undefined) sessions[id].thinkingLevel = updates.thinkingLevel
|
|
54
|
+
if (updates.connectorThinkLevel !== undefined) sessions[id].connectorThinkLevel = updates.connectorThinkLevel
|
|
55
|
+
if (updates.connectorSessionScope !== undefined) sessions[id].connectorSessionScope = updates.connectorSessionScope
|
|
56
|
+
if (updates.connectorReplyMode !== undefined) sessions[id].connectorReplyMode = updates.connectorReplyMode
|
|
57
|
+
if (updates.connectorThreadBinding !== undefined) sessions[id].connectorThreadBinding = updates.connectorThreadBinding
|
|
58
|
+
if (updates.connectorGroupPolicy !== undefined) sessions[id].connectorGroupPolicy = updates.connectorGroupPolicy
|
|
59
|
+
if (updates.connectorIdleTimeoutSec !== undefined) sessions[id].connectorIdleTimeoutSec = updates.connectorIdleTimeoutSec
|
|
60
|
+
if (updates.connectorMaxAgeSec !== undefined) sessions[id].connectorMaxAgeSec = updates.connectorMaxAgeSec
|
|
61
|
+
if (updates.connectorContext !== undefined) sessions[id].connectorContext = updates.connectorContext
|
|
62
|
+
if (updates.identityState !== undefined) sessions[id].identityState = updates.identityState
|
|
63
|
+
if (updates.sessionArchiveState !== undefined) sessions[id].sessionArchiveState = updates.sessionArchiveState
|
|
64
|
+
if (updates.lastSessionResetAt !== undefined) sessions[id].lastSessionResetAt = updates.lastSessionResetAt
|
|
65
|
+
if (updates.lastSessionResetReason !== undefined) sessions[id].lastSessionResetReason = updates.lastSessionResetReason
|
|
48
66
|
if (updates.pinned !== undefined) sessions[id].pinned = !!updates.pinned
|
|
49
67
|
if (updates.claudeSessionId !== undefined) sessions[id].claudeSessionId = updates.claudeSessionId
|
|
50
68
|
if (updates.codexThreadId !== undefined) sessions[id].codexThreadId = updates.codexThreadId
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
|
-
import {
|
|
2
|
+
import { pruneStreamingAssistantArtifacts } from '@/lib/chat-streaming-state'
|
|
3
|
+
import { active, loadStoredItem, upsertStoredItem } from '@/lib/server/storage'
|
|
3
4
|
import { cancelSessionRuns } from '@/lib/server/session-run-manager'
|
|
4
5
|
|
|
5
6
|
export async function POST(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
6
7
|
const { id } = await params
|
|
7
8
|
const cancel = cancelSessionRuns(id, 'Stopped by user')
|
|
9
|
+
const session = loadStoredItem('sessions', id)
|
|
10
|
+
if (session && Array.isArray(session.messages) && pruneStreamingAssistantArtifacts(session.messages)) {
|
|
11
|
+
upsertStoredItem('sessions', id, session)
|
|
12
|
+
}
|
|
8
13
|
if (active.has(id)) {
|
|
9
14
|
try { active.get(id).kill() } catch {}
|
|
10
15
|
active.delete(id)
|
|
@@ -96,6 +96,22 @@ export async function POST(req: Request) {
|
|
|
96
96
|
plugins: resolvedPlugins,
|
|
97
97
|
heartbeatEnabled: body.heartbeatEnabled ?? null,
|
|
98
98
|
heartbeatIntervalSec: body.heartbeatIntervalSec ?? null,
|
|
99
|
+
sessionResetMode: body.sessionResetMode ?? agent?.sessionResetMode ?? null,
|
|
100
|
+
sessionIdleTimeoutSec: body.sessionIdleTimeoutSec ?? agent?.sessionIdleTimeoutSec ?? null,
|
|
101
|
+
sessionMaxAgeSec: body.sessionMaxAgeSec ?? agent?.sessionMaxAgeSec ?? null,
|
|
102
|
+
sessionDailyResetAt: body.sessionDailyResetAt ?? agent?.sessionDailyResetAt ?? null,
|
|
103
|
+
sessionResetTimezone: body.sessionResetTimezone ?? agent?.sessionResetTimezone ?? null,
|
|
104
|
+
thinkingLevel: body.thinkingLevel ?? null,
|
|
105
|
+
connectorThinkLevel: body.connectorThinkLevel ?? null,
|
|
106
|
+
connectorSessionScope: body.connectorSessionScope ?? null,
|
|
107
|
+
connectorReplyMode: body.connectorReplyMode ?? null,
|
|
108
|
+
connectorThreadBinding: body.connectorThreadBinding ?? null,
|
|
109
|
+
connectorGroupPolicy: body.connectorGroupPolicy ?? null,
|
|
110
|
+
connectorIdleTimeoutSec: body.connectorIdleTimeoutSec ?? null,
|
|
111
|
+
connectorMaxAgeSec: body.connectorMaxAgeSec ?? null,
|
|
112
|
+
connectorContext: body.connectorContext ?? null,
|
|
113
|
+
identityState: body.identityState ?? agent?.identityState ?? null,
|
|
114
|
+
sessionArchiveState: body.sessionArchiveState ?? null,
|
|
99
115
|
}
|
|
100
116
|
saveSessions(sessions)
|
|
101
117
|
notify('sessions')
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server'
|
|
2
|
+
import { loadConnectors } from '@/lib/server/storage'
|
|
3
|
+
import { notFound } from '@/lib/server/collection-helpers'
|
|
4
|
+
import { buildConnectorDoctorPreview, buildConnectorDoctorReport, type ConnectorDoctorPreviewInput } from '@/lib/server/connectors/doctor'
|
|
5
|
+
|
|
6
|
+
export const dynamic = 'force-dynamic'
|
|
7
|
+
|
|
8
|
+
export async function GET(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
9
|
+
const { id } = await params
|
|
10
|
+
const connectors = loadConnectors()
|
|
11
|
+
const connector = connectors[id]
|
|
12
|
+
if (!connector) return notFound()
|
|
13
|
+
|
|
14
|
+
return NextResponse.json(buildConnectorDoctorReport(connector, null, { baseConnector: connector }))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
18
|
+
const { id } = await params
|
|
19
|
+
const connectors = loadConnectors()
|
|
20
|
+
const baseConnector = connectors[id]
|
|
21
|
+
if (!baseConnector) return notFound()
|
|
22
|
+
|
|
23
|
+
const body = await req.json().catch(() => ({})) as ConnectorDoctorPreviewInput
|
|
24
|
+
const connector = buildConnectorDoctorPreview({ baseConnector, input: body, fallbackId: id })
|
|
25
|
+
return NextResponse.json(buildConnectorDoctorReport(connector, body.sampleMsg, { baseConnector }))
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server'
|
|
2
|
+
import { buildConnectorDoctorPreview, buildConnectorDoctorReport, type ConnectorDoctorPreviewInput } from '@/lib/server/connectors/doctor'
|
|
3
|
+
import { loadConnectors } from '@/lib/server/storage'
|
|
4
|
+
|
|
5
|
+
export const dynamic = 'force-dynamic'
|
|
6
|
+
|
|
7
|
+
export async function POST(req: Request) {
|
|
8
|
+
const body = await req.json().catch(() => ({})) as ConnectorDoctorPreviewInput
|
|
9
|
+
const connectors = loadConnectors()
|
|
10
|
+
const baseConnector = typeof body.id === 'string' ? connectors[body.id] : null
|
|
11
|
+
const connector = buildConnectorDoctorPreview({ baseConnector, input: body })
|
|
12
|
+
return NextResponse.json(buildConnectorDoctorReport(connector, body.sampleMsg, { baseConnector }))
|
|
13
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
|
-
import {
|
|
2
|
+
import { spawn } from 'child_process'
|
|
3
3
|
import fs from 'fs'
|
|
4
4
|
import path from 'path'
|
|
5
5
|
|
|
@@ -19,25 +19,27 @@ export async function POST(req: Request) {
|
|
|
19
19
|
const isDir = fs.statSync(resolved).isDirectory()
|
|
20
20
|
const platform = process.platform
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
let
|
|
22
|
+
let command: string
|
|
23
|
+
let args: string[]
|
|
24
24
|
if (platform === 'darwin') {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
command = 'open'
|
|
26
|
+
args = isDir ? [resolved] : ['-R', resolved]
|
|
27
27
|
} else if (platform === 'win32') {
|
|
28
|
-
|
|
28
|
+
command = 'explorer'
|
|
29
|
+
args = isDir ? [resolved] : [`/select,${resolved}`]
|
|
29
30
|
} else {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
command = 'xdg-open'
|
|
32
|
+
args = [isDir ? resolved : path.dirname(resolved)]
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
return new Promise<NextResponse>((resolve) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const child = spawn(command, args, { stdio: 'ignore' })
|
|
37
|
+
child.once('error', (err) => {
|
|
38
|
+
resolve(NextResponse.json({ error: err.message }, { status: 500 }))
|
|
39
|
+
})
|
|
40
|
+
child.once('spawn', () => {
|
|
41
|
+
child.unref()
|
|
42
|
+
resolve(NextResponse.json({ ok: true }))
|
|
41
43
|
})
|
|
42
44
|
})
|
|
43
45
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
|
+
import path from 'path'
|
|
2
3
|
import { getMemoryDb } from '@/lib/server/memory-db'
|
|
3
4
|
import { loadSettings } from '@/lib/server/storage'
|
|
5
|
+
import { syncAllSessionArchiveMemories } from '@/lib/server/session-archive-memory'
|
|
6
|
+
import { DATA_DIR } from '@/lib/server/data-dir'
|
|
4
7
|
|
|
5
8
|
function parseBool(value: unknown, fallback: boolean): boolean {
|
|
6
9
|
if (typeof value === 'boolean') return value
|
|
@@ -33,10 +36,13 @@ export async function GET(req: Request) {
|
|
|
33
36
|
24 * 365,
|
|
34
37
|
)
|
|
35
38
|
const analyzed = db.analyzeMaintenance(ttlHours)
|
|
39
|
+
const archiveSync = syncAllSessionArchiveMemories()
|
|
36
40
|
return NextResponse.json({
|
|
37
41
|
ok: true,
|
|
38
42
|
ttlHours,
|
|
39
43
|
analyzed,
|
|
44
|
+
archiveSync,
|
|
45
|
+
archiveExportDir: path.join(DATA_DIR, 'session-archives'),
|
|
40
46
|
})
|
|
41
47
|
}
|
|
42
48
|
|
|
@@ -46,6 +52,9 @@ export async function POST(req: Request) {
|
|
|
46
52
|
const db = getMemoryDb()
|
|
47
53
|
const ttlHours = parseIntBounded(body?.ttlHours ?? settings.memoryWorkingTtlHours, 24, 1, 24 * 365)
|
|
48
54
|
const maxDeletes = parseIntBounded(body?.maxDeletes, 500, 1, 20_000)
|
|
55
|
+
const archiveSync = body?.syncArchives === false
|
|
56
|
+
? { synced: 0, skipped: 0, sessionIds: [] }
|
|
57
|
+
: syncAllSessionArchiveMemories()
|
|
49
58
|
const result = db.maintain({
|
|
50
59
|
ttlHours,
|
|
51
60
|
maxDeletes,
|
|
@@ -57,7 +66,8 @@ export async function POST(req: Request) {
|
|
|
57
66
|
ok: true,
|
|
58
67
|
ttlHours,
|
|
59
68
|
maxDeletes,
|
|
69
|
+
archiveSync,
|
|
70
|
+
archiveExportDir: path.join(DATA_DIR, 'session-archives'),
|
|
60
71
|
...result,
|
|
61
72
|
})
|
|
62
73
|
}
|
|
63
|
-
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { ensureGatewayConnected } from '@/lib/server/openclaw-gateway'
|
|
3
|
+
import { resolveOpenClawGatewayAgentId } from '@/lib/server/openclaw-agent-resolver'
|
|
3
4
|
|
|
4
5
|
const AGENT_FILES = ['SOUL.md', 'IDENTITY.md', 'USER.md', 'TOOLS.md', 'HEARTBEAT.md', 'MEMORY.md', 'AGENTS.md'] as const
|
|
5
6
|
|
|
@@ -16,12 +17,24 @@ export async function GET(req: Request) {
|
|
|
16
17
|
return NextResponse.json({ error: 'OpenClaw gateway not connected' }, { status: 503 })
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
let gatewayAgentId: string
|
|
21
|
+
try {
|
|
22
|
+
gatewayAgentId = await resolveOpenClawGatewayAgentId(agentId, gw)
|
|
23
|
+
} catch (err: unknown) {
|
|
24
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
25
|
+
const status = message.includes('not an OpenClaw agent') ? 400 : 404
|
|
26
|
+
return NextResponse.json({ error: message }, { status })
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
const files: Record<string, { content: string; error?: string }> = {}
|
|
20
30
|
await Promise.all(
|
|
21
31
|
AGENT_FILES.map(async (filename) => {
|
|
22
32
|
try {
|
|
23
|
-
const result = await gw.rpc('agents.files.get', {
|
|
24
|
-
|
|
33
|
+
const result = await gw.rpc('agents.files.get', {
|
|
34
|
+
agentId: gatewayAgentId,
|
|
35
|
+
name: filename,
|
|
36
|
+
}) as { file?: { content?: string } } | undefined
|
|
37
|
+
files[filename] = { content: result?.file?.content ?? '' }
|
|
25
38
|
} catch (err: unknown) {
|
|
26
39
|
files[filename] = { content: '', error: err instanceof Error ? err.message : String(err) }
|
|
27
40
|
}
|
|
@@ -48,10 +61,20 @@ export async function PUT(req: Request) {
|
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
try {
|
|
51
|
-
await
|
|
64
|
+
const gatewayAgentId = await resolveOpenClawGatewayAgentId(agentId, gw)
|
|
65
|
+
await gw.rpc('agents.files.set', {
|
|
66
|
+
agentId: gatewayAgentId,
|
|
67
|
+
name: filename,
|
|
68
|
+
content: content ?? '',
|
|
69
|
+
})
|
|
52
70
|
return NextResponse.json({ ok: true })
|
|
53
71
|
} catch (err: unknown) {
|
|
54
72
|
const message = err instanceof Error ? err.message : String(err)
|
|
55
|
-
|
|
73
|
+
const status = message.includes('not an OpenClaw agent')
|
|
74
|
+
? 400
|
|
75
|
+
: message.includes('not found')
|
|
76
|
+
? 404
|
|
77
|
+
: 502
|
|
78
|
+
return NextResponse.json({ error: message }, { status })
|
|
56
79
|
}
|
|
57
80
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { ensureGatewayConnected } from '@/lib/server/openclaw-gateway'
|
|
3
|
+
import { resolveOpenClawGatewayAgentId } from '@/lib/server/openclaw-agent-resolver'
|
|
4
|
+
import { normalizeOpenClawSkillsPayload } from '@/lib/server/openclaw-skills-normalize'
|
|
3
5
|
import { loadAgents, saveAgents } from '@/lib/server/storage'
|
|
4
6
|
import { notify } from '@/lib/server/ws-hub'
|
|
5
7
|
import type { OpenClawSkillEntry, SkillAllowlistMode } from '@/types'
|
|
@@ -18,11 +20,17 @@ export async function GET(req: Request) {
|
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
try {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
+
const gatewayAgentId = await resolveOpenClawGatewayAgentId(agentId, gw)
|
|
24
|
+
const result = await gw.rpc('skills.status', { agentId: gatewayAgentId }) as unknown
|
|
25
|
+
return NextResponse.json(normalizeOpenClawSkillsPayload(result))
|
|
23
26
|
} catch (err: unknown) {
|
|
24
27
|
const message = err instanceof Error ? err.message : String(err)
|
|
25
|
-
|
|
28
|
+
const status = message.includes('not an OpenClaw agent')
|
|
29
|
+
? 400
|
|
30
|
+
: message.includes('not found')
|
|
31
|
+
? 404
|
|
32
|
+
: 502
|
|
33
|
+
return NextResponse.json({ error: message }, { status })
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server'
|
|
2
|
+
import { getPluginManager } from '@/lib/server/plugins'
|
|
3
|
+
|
|
4
|
+
export async function POST(req: Request) {
|
|
5
|
+
const body = await req.json()
|
|
6
|
+
const filename = typeof body?.filename === 'string' ? body.filename : ''
|
|
7
|
+
const packageManager = typeof body?.packageManager === 'string' ? body.packageManager : undefined
|
|
8
|
+
|
|
9
|
+
if (!filename) {
|
|
10
|
+
return NextResponse.json({ error: 'filename is required' }, { status: 400 })
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const result = await getPluginManager().installPluginDependencies(filename, {
|
|
15
|
+
packageManager: packageManager as import('@/types').PluginPackageManager | undefined,
|
|
16
|
+
})
|
|
17
|
+
return NextResponse.json({ ok: true, dependencyInfo: result })
|
|
18
|
+
} catch (err: unknown) {
|
|
19
|
+
return NextResponse.json(
|
|
20
|
+
{ error: err instanceof Error ? err.message : String(err) },
|
|
21
|
+
{ status: 400 },
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,110 +1,33 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
|
-
import
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import { getPluginManager } from '@/lib/server/plugins'
|
|
5
|
-
|
|
6
|
-
const PLUGINS_DIR = path.join(process.cwd(), 'data', 'plugins')
|
|
7
|
-
|
|
8
|
-
function toRawUrl(url: string): string {
|
|
9
|
-
if (url.includes('github.com') && url.includes('/blob/')) {
|
|
10
|
-
return url.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/')
|
|
11
|
-
}
|
|
12
|
-
if (url.includes('gist.github.com')) {
|
|
13
|
-
return url.endsWith('/raw') ? url : `${url}/raw`
|
|
14
|
-
}
|
|
15
|
-
return url
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function normalizeMarketplaceUrl(url: string): string {
|
|
19
|
-
const trimmed = typeof url === 'string' ? url.trim() : ''
|
|
20
|
-
if (!trimmed) return trimmed
|
|
21
|
-
|
|
22
|
-
let normalized = trimmed
|
|
23
|
-
.replace('github.com/swarmclawai/plugins/', 'github.com/swarmclawai/swarmforge/')
|
|
24
|
-
.replace('raw.githubusercontent.com/swarmclawai/plugins/', 'raw.githubusercontent.com/swarmclawai/swarmforge/')
|
|
25
|
-
|
|
26
|
-
normalized = toRawUrl(normalized)
|
|
27
|
-
|
|
28
|
-
// Legacy registry entries used master and old repo names.
|
|
29
|
-
normalized = normalized
|
|
30
|
-
.replace('/swarmclawai/swarmforge/master/', '/swarmclawai/swarmforge/main/')
|
|
31
|
-
.replace('/swarmclawai/plugins/master/', '/swarmclawai/swarmforge/main/')
|
|
32
|
-
.replace('/swarmclawai/plugins/main/', '/swarmclawai/swarmforge/main/')
|
|
33
|
-
|
|
34
|
-
return normalized
|
|
35
|
-
}
|
|
2
|
+
import { getPluginManager, sanitizePluginFilename } from '@/lib/server/plugins'
|
|
36
3
|
|
|
37
4
|
export async function POST(req: Request) {
|
|
38
5
|
const body = await req.json()
|
|
39
|
-
const
|
|
40
|
-
const
|
|
6
|
+
const url = typeof body?.url === 'string' ? body.url : ''
|
|
7
|
+
const filename = typeof body?.filename === 'string' ? body.filename : ''
|
|
41
8
|
|
|
42
|
-
|
|
43
|
-
if (!url || typeof url !== 'string' || !url.startsWith('https://')) {
|
|
9
|
+
if (!url || !url.startsWith('https://')) {
|
|
44
10
|
return NextResponse.json(
|
|
45
11
|
{ error: 'URL must be a valid HTTPS URL' },
|
|
46
12
|
{ status: 400 },
|
|
47
13
|
)
|
|
48
14
|
}
|
|
49
15
|
|
|
50
|
-
// Validate filename
|
|
51
|
-
if (!filename || typeof filename !== 'string' || !filename.endsWith('.js')) {
|
|
52
|
-
return NextResponse.json(
|
|
53
|
-
{ error: 'Filename must end in .js' },
|
|
54
|
-
{ status: 400 },
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Path traversal protection
|
|
59
|
-
const sanitized = path.basename(filename)
|
|
60
|
-
if (sanitized !== filename || filename.includes('..')) {
|
|
61
|
-
return NextResponse.json(
|
|
62
|
-
{ error: 'Invalid filename' },
|
|
63
|
-
{ status: 400 },
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
16
|
try {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{ error: `Download failed (HTTP ${res.status}) from ${rawUrl}` },
|
|
72
|
-
{ status: 502 },
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
const contentType = res.headers.get('content-type') || ''
|
|
76
|
-
let code = await res.text()
|
|
77
|
-
|
|
78
|
-
// Reject HTML responses (likely a GitHub page, not raw content)
|
|
79
|
-
if (contentType.includes('text/html') && code.includes('<!DOCTYPE')) {
|
|
80
|
-
return NextResponse.json(
|
|
81
|
-
{ error: 'URL returned an HTML page instead of JavaScript. Use a raw/direct link to the .js file.' },
|
|
82
|
-
{ status: 400 },
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Compatibility fix: Strip node-fetch requires if present, as modern Node has global fetch
|
|
87
|
-
code = code.replace(/const\s+fetch\s*=\s*require\(['"]node-fetch['"]\);?/g, '// node-fetch stripped for compatibility')
|
|
88
|
-
code = code.replace(/import\s+fetch\s+from\s+['"]node-fetch['"];?/g, '// node-fetch stripped for compatibility')
|
|
89
|
-
|
|
90
|
-
// Ensure plugins directory exists
|
|
91
|
-
if (!fs.existsSync(PLUGINS_DIR)) {
|
|
92
|
-
fs.mkdirSync(PLUGINS_DIR, { recursive: true })
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const dest = path.join(PLUGINS_DIR, sanitized)
|
|
96
|
-
fs.writeFileSync(dest, code, 'utf8')
|
|
97
|
-
|
|
98
|
-
// Force plugin manager to re-scan so the new plugin appears in listings
|
|
99
|
-
getPluginManager().reload()
|
|
100
|
-
|
|
101
|
-
return NextResponse.json({ ok: true, filename: sanitized })
|
|
17
|
+
const sanitizedFilename = sanitizePluginFilename(filename)
|
|
18
|
+
const installed = await getPluginManager().installPluginFromUrl(url, sanitizedFilename)
|
|
19
|
+
return NextResponse.json({ ok: true, filename: installed.filename, hash: installed.sourceHash })
|
|
102
20
|
} catch (err: unknown) {
|
|
103
21
|
const msg = err instanceof Error ? err.message : String(err)
|
|
104
|
-
const isTimeout =
|
|
22
|
+
const isTimeout = /abort|timeout/i.test(msg)
|
|
23
|
+
const status = /valid HTTPS URL|Filename|Invalid filename|HTML page|too large/i.test(msg)
|
|
24
|
+
? 400
|
|
25
|
+
: isTimeout
|
|
26
|
+
? 504
|
|
27
|
+
: 500
|
|
105
28
|
return NextResponse.json(
|
|
106
|
-
{ error: isTimeout ? 'Download timed out — the plugin URL may be unreachable' :
|
|
107
|
-
{ status
|
|
29
|
+
{ error: isTimeout ? 'Download timed out — the plugin URL may be unreachable' : msg },
|
|
30
|
+
{ status },
|
|
108
31
|
)
|
|
109
32
|
}
|
|
110
33
|
}
|
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { getPluginManager } from '@/lib/server/plugins'
|
|
3
3
|
import { notify } from '@/lib/server/ws-hub'
|
|
4
|
-
|
|
5
|
-
// Ensure all builtin plugins are registered by importing their modules
|
|
6
|
-
import '@/lib/server/session-tools/shell'
|
|
7
|
-
import '@/lib/server/session-tools/file'
|
|
8
|
-
import '@/lib/server/session-tools/edit_file'
|
|
9
|
-
import '@/lib/server/session-tools/web'
|
|
10
|
-
import '@/lib/server/session-tools/memory'
|
|
11
|
-
import '@/lib/server/session-tools/platform'
|
|
12
|
-
import '@/lib/server/session-tools/monitor'
|
|
13
|
-
import '@/lib/server/session-tools/discovery'
|
|
14
|
-
import '@/lib/server/session-tools/sample-ui'
|
|
15
|
-
import '@/lib/server/session-tools/git'
|
|
16
|
-
import '@/lib/server/session-tools/wallet'
|
|
17
|
-
import '@/lib/server/session-tools/connector'
|
|
18
|
-
import '@/lib/server/session-tools/http'
|
|
19
|
-
import '@/lib/server/session-tools/sandbox'
|
|
20
|
-
import '@/lib/server/session-tools/canvas'
|
|
21
|
-
import '@/lib/server/session-tools/chatroom'
|
|
22
|
-
import '@/lib/server/session-tools/delegate'
|
|
23
|
-
import '@/lib/server/session-tools/schedule'
|
|
24
|
-
import '@/lib/server/session-tools/session-info'
|
|
25
|
-
import '@/lib/server/session-tools/openclaw-nodes'
|
|
26
|
-
import '@/lib/server/session-tools/openclaw-workspace'
|
|
27
|
-
import '@/lib/server/session-tools/context-mgmt'
|
|
28
|
-
import '@/lib/server/session-tools/subagent'
|
|
29
|
-
import '@/lib/server/session-tools/plugin-creator'
|
|
4
|
+
import '@/lib/server/builtin-plugins'
|
|
30
5
|
|
|
31
6
|
export const dynamic = 'force-dynamic'
|
|
32
7
|
|
|
@@ -74,11 +49,13 @@ export async function PATCH(req: Request) {
|
|
|
74
49
|
|
|
75
50
|
if (all) {
|
|
76
51
|
await manager.updateAllPlugins()
|
|
52
|
+
notify('plugins')
|
|
77
53
|
return NextResponse.json({ ok: true, message: 'All plugins updated' })
|
|
78
54
|
}
|
|
79
55
|
|
|
80
56
|
if (id) {
|
|
81
57
|
await manager.updatePlugin(id)
|
|
58
|
+
notify('plugins')
|
|
82
59
|
return NextResponse.json({ ok: true, message: `Plugin ${id} updated` })
|
|
83
60
|
}
|
|
84
61
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
|
-
import {
|
|
2
|
+
import { getPluginManager } from '@/lib/server/plugins'
|
|
3
|
+
import '@/lib/server/builtin-plugins'
|
|
3
4
|
|
|
4
5
|
export const dynamic = 'force-dynamic'
|
|
5
6
|
|
|
@@ -11,9 +12,7 @@ export async function GET(req: Request) {
|
|
|
11
12
|
return NextResponse.json({ error: 'pluginId required' }, { status: 400 })
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
const pluginSettings = (settings.pluginSettings as Record<string, Record<string, unknown>> | undefined) ?? {}
|
|
16
|
-
return NextResponse.json(pluginSettings[pluginId] ?? {})
|
|
15
|
+
return NextResponse.json(getPluginManager().getPublicPluginSettings(pluginId))
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/** PUT /api/plugins/settings?pluginId=X — write per-plugin settings */
|
|
@@ -24,12 +23,18 @@ export async function PUT(req: Request) {
|
|
|
24
23
|
return NextResponse.json({ error: 'pluginId required' }, { status: 400 })
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
try {
|
|
27
|
+
const body = await req.json() as Record<string, unknown>
|
|
28
|
+
const saved = getPluginManager().setPluginSettings(pluginId, body)
|
|
29
|
+
return NextResponse.json({
|
|
30
|
+
ok: true,
|
|
31
|
+
values: saved,
|
|
32
|
+
configuredSecretFields: getPluginManager().getPublicPluginSettings(pluginId).configuredSecretFields,
|
|
33
|
+
})
|
|
34
|
+
} catch (err: unknown) {
|
|
35
|
+
return NextResponse.json(
|
|
36
|
+
{ error: err instanceof Error ? err.message : String(err) },
|
|
37
|
+
{ status: 400 },
|
|
38
|
+
)
|
|
39
|
+
}
|
|
35
40
|
}
|