@swarmclawai/swarmclaw 1.9.35 → 1.9.38
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 +53 -1
- package/package.json +3 -3
- package/src/app/api/chats/[id]/context-status/route.ts +2 -0
- package/src/app/api/chats/context-status-route.test.ts +59 -0
- package/src/app/api/openclaw/history/route.ts +11 -6
- package/src/app/api/preview-server/route.ts +20 -12
- package/src/app/api/search/route.test.ts +63 -0
- package/src/app/api/search/route.ts +3 -2
- package/src/app/api/settings/route.ts +5 -1
- package/src/app/api/settings/settings-route.test.ts +38 -0
- package/src/app/api/setup/check-provider/route.test.ts +12 -0
- package/src/app/api/setup/check-provider/route.ts +6 -0
- package/src/app/api/usage/live/route.ts +2 -2
- package/src/app/globals.css +158 -0
- package/src/app/layout.tsx +12 -9
- package/src/app/protocols/builder/[templateId]/page.tsx +5 -5
- package/src/components/layout/dashboard-shell.tsx +9 -0
- package/src/components/protocols/builder/protocol-builder-canvas.tsx +106 -15
- package/src/components/providers/theme-provider.tsx +16 -0
- package/src/features/protocols/builder/hooks/use-template-sync.ts +5 -0
- package/src/features/protocols/builder/protocol-builder-store.ts +4 -4
- package/src/features/protocols/builder/utils/builder-template-access.test.ts +30 -0
- package/src/features/protocols/builder/utils/builder-template-access.ts +5 -0
- package/src/lib/providers/index.ts +23 -0
- package/src/lib/server/context-manager.ts +4 -0
- package/src/lib/server/messages/message-repository.test.ts +122 -0
- package/src/lib/server/messages/message-repository.ts +67 -11
- package/src/lib/server/openrouter-model-context.test.ts +205 -0
- package/src/lib/server/openrouter-model-context.ts +169 -0
- package/src/lib/server/provider-health.ts +1 -0
- package/src/lib/server/runtime/devserver-launch.ts +7 -4
- package/src/lib/setup-defaults.test.ts +10 -1
- package/src/lib/setup-defaults.ts +20 -0
- package/src/lib/theme-mode.ts +5 -0
- package/src/types/app-settings.ts +2 -0
- package/src/types/provider.ts +1 -1
- package/src/views/settings/section-theme.tsx +41 -1
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ Available for macOS (Apple Silicon & Intel), Windows, and Linux (AppImage + .deb
|
|
|
84
84
|
The release workflow supports Developer ID signing and notarization when Apple
|
|
85
85
|
credentials are configured. If a macOS build is still ad-hoc signed, first
|
|
86
86
|
launch may need one manual approval:
|
|
87
|
-
- **macOS:**
|
|
87
|
+
- **macOS:** signed/notarized releases publish both `.dmg` and `.zip`; unsigned fallback releases publish `.zip` only to avoid the damaged unsigned DMG path. Right-click the app in Finder → **Open** → **Open** to bypass Gatekeeper. If macOS instead reports *"SwarmClaw is damaged and can't be opened"* (common when a downloaded app was quarantined by Safari), strip the quarantine attribute and relaunch:
|
|
88
88
|
```bash
|
|
89
89
|
xattr -dr com.apple.quarantine /Applications/SwarmClaw.app
|
|
90
90
|
```
|
|
@@ -151,6 +151,32 @@ openclaw skills install swarmclaw
|
|
|
151
151
|
|
|
152
152
|
[Browse on ClawHub](https://clawhub.ai/waydelyle/swarmclaw)
|
|
153
153
|
|
|
154
|
+
## v1.9.38 Highlights
|
|
155
|
+
|
|
156
|
+
PR integration release for provider catalog coverage, OpenRouter context meters, and safer unsigned macOS desktop artifacts.
|
|
157
|
+
|
|
158
|
+
- **TokenMix provider.** Added TokenMix as a built-in OpenAI-compatible provider with setup metadata, starter-agent defaults, and provider health checks.
|
|
159
|
+
- **OpenRouter context meters.** Chat context status now uses cached OpenRouter model metadata when available so routed model context windows display accurately.
|
|
160
|
+
- **macOS unsigned artifact fallback.** Desktop releases publish zip-only macOS artifacts when signing/notarization inputs are missing, avoiding the unsigned DMG damaged-app path.
|
|
161
|
+
- **Regression coverage.** Added targeted tests for TokenMix setup, OpenRouter context metadata caching, and macOS target selection.
|
|
162
|
+
|
|
163
|
+
## v1.9.37 Highlights
|
|
164
|
+
|
|
165
|
+
Theme and memory-pressure release for lighter UI preferences and leaner chat history storage.
|
|
166
|
+
|
|
167
|
+
- **Light, dark, and system theme modes.** Settings → Appearance now persists a Light/Dark/System selector while keeping the existing hue presets and custom color picker.
|
|
168
|
+
- **Lean session history storage.** Legacy transcript blobs migrate into the `session_messages` table and are compacted from session records after persistence is verified, reducing page-load memory pressure on lower-RAM devices.
|
|
169
|
+
- **Repo-backed message readers.** Global search, live usage summaries, and OpenClaw history merge now read table-backed messages after transcript compaction.
|
|
170
|
+
- **Regression coverage.** Added tests for theme-mode normalization, legacy transcript compaction, and repo-backed message search.
|
|
171
|
+
|
|
172
|
+
## v1.9.36 Highlights
|
|
173
|
+
|
|
174
|
+
Protocol builder visibility release for built-in Structured Sessions.
|
|
175
|
+
|
|
176
|
+
- **Built-in flow inspector.** Built-in protocol templates now open in a full-size visual builder canvas with a read-only template step panel.
|
|
177
|
+
- **Canvas viewport repair.** Builder routes now claim the full dashboard workspace and refit React Flow after async template loads.
|
|
178
|
+
- **Regression coverage.** Browser smoke now verifies that the built-in facilitated discussion graph renders with visible flow nodes.
|
|
179
|
+
|
|
154
180
|
## v1.9.35 Highlights
|
|
155
181
|
|
|
156
182
|
Installed package build fix for fresh npm-global installs and upgrades.
|
|
@@ -462,6 +488,32 @@ Operational docs: https://swarmclaw.ai/docs/observability
|
|
|
462
488
|
|
|
463
489
|
## Releases
|
|
464
490
|
|
|
491
|
+
### v1.9.38 Highlights
|
|
492
|
+
|
|
493
|
+
PR integration release for provider catalog coverage, OpenRouter context meters, and safer unsigned macOS desktop artifacts.
|
|
494
|
+
|
|
495
|
+
- **TokenMix provider.** Added TokenMix as a built-in OpenAI-compatible provider with setup metadata, starter-agent defaults, and provider health checks.
|
|
496
|
+
- **OpenRouter context meters.** Chat context status now uses cached OpenRouter model metadata when available so routed model context windows display accurately.
|
|
497
|
+
- **macOS unsigned artifact fallback.** Desktop releases publish zip-only macOS artifacts when signing/notarization inputs are missing, avoiding the unsigned DMG damaged-app path.
|
|
498
|
+
- **Regression coverage.** Added targeted tests for TokenMix setup, OpenRouter context metadata caching, and macOS target selection.
|
|
499
|
+
|
|
500
|
+
### v1.9.37 Highlights
|
|
501
|
+
|
|
502
|
+
Theme and memory-pressure release for lighter UI preferences and leaner chat history storage.
|
|
503
|
+
|
|
504
|
+
- **Light, dark, and system theme modes.** Settings → Appearance now persists a Light/Dark/System selector while keeping the existing hue presets and custom color picker.
|
|
505
|
+
- **Lean session history storage.** Legacy transcript blobs migrate into the `session_messages` table and are compacted from session records after persistence is verified, reducing page-load memory pressure on lower-RAM devices.
|
|
506
|
+
- **Repo-backed message readers.** Global search, live usage summaries, and OpenClaw history merge now read table-backed messages after transcript compaction.
|
|
507
|
+
- **Regression coverage.** Added tests for theme-mode normalization, legacy transcript compaction, and repo-backed message search.
|
|
508
|
+
|
|
509
|
+
### v1.9.36 Highlights
|
|
510
|
+
|
|
511
|
+
Protocol builder visibility release for built-in Structured Sessions.
|
|
512
|
+
|
|
513
|
+
- **Built-in flow inspector.** Built-in protocol templates now open in a full-size visual builder canvas with a read-only template step panel.
|
|
514
|
+
- **Canvas viewport repair.** Builder routes now claim the full dashboard workspace and refit React Flow after async template loads.
|
|
515
|
+
- **Regression coverage.** Browser smoke now verifies that the built-in facilitated discussion graph renders with visible flow nodes.
|
|
516
|
+
|
|
465
517
|
### v1.9.35 Highlights
|
|
466
518
|
|
|
467
519
|
Installed package build fix for fresh npm-global installs and upgrades.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swarmclawai/swarmclaw",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.38",
|
|
4
4
|
"description": "Build and run autonomous AI agents with OpenClaw, Hermes, multiple model providers, orchestration, delegation, memory, skills, schedules, and chat connectors.",
|
|
5
5
|
"main": "electron-dist/main.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"test:cli": "node --test src/cli/*.test.js bin/*.test.js scripts/electron-after-pack.test.mjs scripts/electron-signing-config.test.mjs scripts/ensure-sandbox-browser-image.test.mjs scripts/postinstall.test.mjs scripts/run-next-build.test.mjs scripts/run-next-typegen.test.mjs",
|
|
89
89
|
"test:setup": "tsx --test src/app/api/setup/check-provider/route.test.ts src/lib/server/provider-model-discovery.test.ts src/components/auth/setup-wizard/utils.test.ts src/components/auth/setup-wizard/types.test.ts src/hooks/setup-done-detection.test.ts src/lib/setup-defaults.test.ts src/lib/server/storage-auth.test.ts src/lib/server/storage-auth-docker.test.ts",
|
|
90
90
|
"test:openclaw": "tsx --test src/lib/openclaw/openclaw-agent-id.test.ts src/lib/openclaw/openclaw-endpoint.test.ts src/lib/server/agents/agent-runtime-config.test.ts src/lib/server/build-llm.test.ts src/lib/server/connectors/connector-routing.test.ts src/lib/server/connectors/openclaw.test.ts src/lib/server/connectors/swarmdock.test.ts src/lib/server/gateway/protocol.test.ts src/lib/server/gateways/gateway-topology.test.ts src/lib/server/llm-response-cache.test.ts src/lib/server/mcp-conformance.test.ts src/lib/server/openclaw/agent-resolver.test.ts src/lib/server/openclaw/deploy.test.ts src/lib/server/openclaw/skills-normalize.test.ts src/lib/server/session-tools/openclaw-nodes.test.ts src/lib/server/session-tools/swarmdock.test.ts src/lib/server/tasks/task-quality-gate.test.ts src/lib/server/tasks/task-validation.test.ts src/lib/server/tool-capability-policy.test.ts src/lib/providers/openai.test.ts src/lib/providers/openclaw-exports.test.ts src/app/api/gateways/topology-route.test.ts src/app/api/openclaw/dashboard-url/route.test.ts",
|
|
91
|
-
"test:runtime": "tsx --test src/lib/a2a/agent-card.test.ts src/lib/agent-planning-mode.test.ts src/lib/agent-config-history.test.ts src/lib/autonomy/supervisor-settings.test.ts src/lib/strip-internal-metadata.test.ts src/lib/provider-sets.test.ts src/lib/providers/opencode-cli.test.ts src/lib/providers/cli-provider-metadata.test.ts src/lib/providers/cli-utils.test.ts src/lib/providers/generic-cli.test.ts src/lib/server/agents/delegation-advisory.test.ts src/lib/server/agents/agent-runtime-config.test.ts src/lib/server/autonomy/supervisor-reflection.test.ts src/lib/server/cli-provider-readiness.test.ts src/lib/server/provider-health.test.ts src/lib/server/provider-diagnostics.test.ts src/lib/server/mcp-gateway-runtime.test.ts src/lib/server/mcp-connection-pool.test.ts src/lib/server/knowledge-sources.test.ts src/lib/server/memory/dream-service.test.ts src/lib/server/memory/memory-consolidation.test.ts src/lib/server/extension-managed-resources.test.ts src/lib/server/eval/baseline.test.ts src/lib/server/eval/environment-plan.test.ts src/lib/server/chat-execution/chat-execution-grounding.test.ts src/lib/server/chat-execution/chat-turn-preparation.test.ts src/lib/server/chat-execution/compaction-generation-preference.test.ts src/lib/server/chat-execution/iteration-timers.test.ts src/lib/server/chat-execution/post-stream-finalization.test.ts src/lib/server/chat-execution/prompt-sections.planning-mode.test.ts src/lib/server/chat-execution/reasoning-tag-scrubber.test.ts src/lib/server/chats/clear-undo-snapshots.test.ts src/lib/server/chats/session-context-pack.test.ts src/lib/server/connectors/email.test.ts src/lib/server/connectors/slack.test.ts src/lib/server/protocols/protocol-service.test.ts src/lib/server/runtime/run-ledger.test.ts src/lib/server/runtime/queue-retry-policy.test.ts src/lib/server/runs/run-brief.test.ts src/lib/server/runs/run-handoff.test.ts src/lib/server/operations/operation-pulse.test.ts src/lib/server/schedules/schedule-history.test.ts src/lib/server/schedules/schedule-timing.test.ts src/lib/server/schedules/schedule-preview.test.ts src/lib/quality/release-readiness.test.ts src/lib/quality/architecture-health.test.ts src/lib/server/artifacts/artifact-resolver.test.ts src/lib/server/observability/otel-config.test.ts src/lib/server/safe-parse-body.test.ts src/lib/server/missions/mission-templates.test.ts src/lib/server/sharing/share-link-repository.test.ts src/lib/server/sharing/share-resolver.test.ts src/lib/server/tasks/task-execution-workspace.test.ts src/lib/server/tasks/task-execution-policy.test.ts src/lib/server/tasks/task-handoff.test.ts src/lib/server/tasks/task-service.test.ts src/lib/server/session-tools/execute.test.ts src/lib/server/session-tools/manage-tasks.test.ts src/lib/server/session-tools/web-crawl.test.ts src/lib/app/view-constants.test.ts src/lib/quality/quality-summary.test.ts src/app/api/approvals/route.test.ts src/app/api/agents/agents-route.test.ts src/app/api/tasks/tasks-route.test.ts src/app/api/tasks/task-workspace-route.test.ts src/app/api/chats/chat-route.test.ts src/app/api/chats/clear-route.test.ts src/app/api/chats/compact-route.test.ts src/app/api/chats/context-pack-route.test.ts src/app/api/chats/context-status-route.test.ts src/app/api/config-versions/config-versions-route.test.ts src/app/api/runs/run-handoff-route.test.ts src/app/api/connectors/connector-doctor-route.test.ts src/app/api/extensions/managed-resources/route.test.ts src/app/api/gateways/control-route.test.ts src/app/api/healthz/route.test.ts src/app/api/logs/route.test.ts src/app/api/portability/export/route.test.ts src/app/api/portability/import/route.test.ts src/app/api/providers/[id]/route.test.ts src/app/api/schedules/preview/route.test.ts src/app/api/schedules/schedule-history-route.test.ts src/app/api/tts/route.test.ts",
|
|
92
|
-
"test:builder": "tsx --test src/features/protocols/builder/utils/nodes-to-template.test.ts src/features/protocols/builder/utils/template-to-nodes.test.ts src/features/protocols/builder/validators/dag-validator.test.ts",
|
|
91
|
+
"test:runtime": "tsx --test src/lib/a2a/agent-card.test.ts src/lib/agent-planning-mode.test.ts src/lib/agent-config-history.test.ts src/lib/autonomy/supervisor-settings.test.ts src/lib/strip-internal-metadata.test.ts src/lib/provider-sets.test.ts src/lib/providers/opencode-cli.test.ts src/lib/providers/cli-provider-metadata.test.ts src/lib/providers/cli-utils.test.ts src/lib/providers/generic-cli.test.ts src/lib/server/agents/delegation-advisory.test.ts src/lib/server/agents/agent-runtime-config.test.ts src/lib/server/autonomy/supervisor-reflection.test.ts src/lib/server/cli-provider-readiness.test.ts src/lib/server/provider-health.test.ts src/lib/server/provider-diagnostics.test.ts src/lib/server/mcp-gateway-runtime.test.ts src/lib/server/mcp-connection-pool.test.ts src/lib/server/knowledge-sources.test.ts src/lib/server/memory/dream-service.test.ts src/lib/server/memory/memory-consolidation.test.ts src/lib/server/messages/message-repository.test.ts src/lib/server/extension-managed-resources.test.ts src/lib/server/eval/baseline.test.ts src/lib/server/eval/environment-plan.test.ts src/lib/server/chat-execution/chat-execution-grounding.test.ts src/lib/server/chat-execution/chat-turn-preparation.test.ts src/lib/server/chat-execution/compaction-generation-preference.test.ts src/lib/server/chat-execution/iteration-timers.test.ts src/lib/server/chat-execution/post-stream-finalization.test.ts src/lib/server/chat-execution/prompt-sections.planning-mode.test.ts src/lib/server/chat-execution/reasoning-tag-scrubber.test.ts src/lib/server/chats/clear-undo-snapshots.test.ts src/lib/server/chats/session-context-pack.test.ts src/lib/server/connectors/email.test.ts src/lib/server/connectors/slack.test.ts src/lib/server/protocols/protocol-service.test.ts src/lib/server/runtime/run-ledger.test.ts src/lib/server/runtime/queue-retry-policy.test.ts src/lib/server/runs/run-brief.test.ts src/lib/server/runs/run-handoff.test.ts src/lib/server/operations/operation-pulse.test.ts src/lib/server/schedules/schedule-history.test.ts src/lib/server/schedules/schedule-timing.test.ts src/lib/server/schedules/schedule-preview.test.ts src/lib/quality/release-readiness.test.ts src/lib/quality/architecture-health.test.ts src/lib/server/artifacts/artifact-resolver.test.ts src/lib/server/observability/otel-config.test.ts src/lib/server/safe-parse-body.test.ts src/lib/server/missions/mission-templates.test.ts src/lib/server/sharing/share-link-repository.test.ts src/lib/server/sharing/share-resolver.test.ts src/lib/server/tasks/task-execution-workspace.test.ts src/lib/server/tasks/task-execution-policy.test.ts src/lib/server/tasks/task-handoff.test.ts src/lib/server/tasks/task-service.test.ts src/lib/server/session-tools/execute.test.ts src/lib/server/session-tools/manage-tasks.test.ts src/lib/server/session-tools/web-crawl.test.ts src/lib/app/view-constants.test.ts src/lib/quality/quality-summary.test.ts src/app/api/approvals/route.test.ts src/app/api/agents/agents-route.test.ts src/app/api/tasks/tasks-route.test.ts src/app/api/tasks/task-workspace-route.test.ts src/app/api/chats/chat-route.test.ts src/app/api/chats/clear-route.test.ts src/app/api/chats/compact-route.test.ts src/app/api/chats/context-pack-route.test.ts src/app/api/chats/context-status-route.test.ts src/app/api/config-versions/config-versions-route.test.ts src/app/api/runs/run-handoff-route.test.ts src/app/api/search/route.test.ts src/app/api/settings/settings-route.test.ts src/app/api/connectors/connector-doctor-route.test.ts src/app/api/extensions/managed-resources/route.test.ts src/app/api/gateways/control-route.test.ts src/app/api/healthz/route.test.ts src/app/api/logs/route.test.ts src/app/api/portability/export/route.test.ts src/app/api/portability/import/route.test.ts src/app/api/providers/[id]/route.test.ts src/app/api/schedules/preview/route.test.ts src/app/api/schedules/schedule-history-route.test.ts src/app/api/tts/route.test.ts",
|
|
92
|
+
"test:builder": "tsx --test src/features/protocols/builder/utils/builder-template-access.test.ts src/features/protocols/builder/utils/nodes-to-template.test.ts src/features/protocols/builder/utils/template-to-nodes.test.ts src/features/protocols/builder/validators/dag-validator.test.ts",
|
|
93
93
|
"test:e2e": "node --import tsx scripts/browser-e2e-smoke.ts",
|
|
94
94
|
"test:mcp:conformance": "node --import tsx ./scripts/mcp-conformance-check.ts",
|
|
95
95
|
"electron:compile": "tsc -p electron/tsconfig.json",
|
|
@@ -3,6 +3,7 @@ import { getSession } from '@/lib/server/sessions/session-repository'
|
|
|
3
3
|
import { getMessages } from '@/lib/server/messages/message-repository'
|
|
4
4
|
import { getContextStatus } from '@/lib/server/context-manager'
|
|
5
5
|
import { notFound } from '@/lib/server/collection-helpers'
|
|
6
|
+
import { ensureOpenRouterModelContextCache } from '@/lib/server/openrouter-model-context'
|
|
6
7
|
|
|
7
8
|
const SYSTEM_PROMPT_TOKEN_ESTIMATE = 2000
|
|
8
9
|
|
|
@@ -11,6 +12,7 @@ export async function GET(_req: Request, { params }: { params: Promise<{ id: str
|
|
|
11
12
|
const session = getSession(id)
|
|
12
13
|
if (!session) return notFound()
|
|
13
14
|
const messages = getMessages(id)
|
|
15
|
+
await ensureOpenRouterModelContextCache(session.provider as string)
|
|
14
16
|
const status = getContextStatus(
|
|
15
17
|
messages,
|
|
16
18
|
SYSTEM_PROMPT_TOKEN_ESTIMATE,
|
|
@@ -66,3 +66,62 @@ test('GET /api/chats/[id]/context-status returns token usage summary', () => {
|
|
|
66
66
|
assert.ok(['ok', 'warning', 'critical'].includes(output.strategy))
|
|
67
67
|
assert.equal(output.missingStatus, 404)
|
|
68
68
|
})
|
|
69
|
+
|
|
70
|
+
test('GET /api/chats/[id]/context-status uses OpenRouter model metadata context window', () => {
|
|
71
|
+
const output = runWithTempDataDir<{
|
|
72
|
+
status: number
|
|
73
|
+
contextWindow: number
|
|
74
|
+
}>(`
|
|
75
|
+
const fs = await import('node:fs')
|
|
76
|
+
const path = await import('node:path')
|
|
77
|
+
const cachePath = path.join(process.env.DATA_DIR, 'openrouter-model-context.json')
|
|
78
|
+
fs.writeFileSync(cachePath, JSON.stringify({
|
|
79
|
+
loadedAt: Date.now(),
|
|
80
|
+
models: { 'minimax/minimax-m3': 524288 },
|
|
81
|
+
}))
|
|
82
|
+
|
|
83
|
+
globalThis.fetch = async () => {
|
|
84
|
+
throw new Error('route should use seeded OpenRouter model metadata cache')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const storageMod = await import('./src/lib/server/storage')
|
|
88
|
+
const repoMod = await import('@/lib/server/messages/message-repository')
|
|
89
|
+
const routeMod = await import('./src/app/api/chats/[id]/context-status/route')
|
|
90
|
+
const storage = storageMod.default || storageMod
|
|
91
|
+
const repo = repoMod.default || repoMod
|
|
92
|
+
const route = routeMod.default || routeMod
|
|
93
|
+
|
|
94
|
+
const now = Date.now()
|
|
95
|
+
storage.saveSessions({
|
|
96
|
+
sess_ctx_openrouter: {
|
|
97
|
+
id: 'sess_ctx_openrouter',
|
|
98
|
+
name: 'OpenRouter context status test',
|
|
99
|
+
cwd: process.env.WORKSPACE_DIR,
|
|
100
|
+
user: 'tester',
|
|
101
|
+
provider: 'openrouter',
|
|
102
|
+
model: 'minimax/minimax-m3',
|
|
103
|
+
claudeSessionId: null,
|
|
104
|
+
messages: [],
|
|
105
|
+
createdAt: now,
|
|
106
|
+
lastActiveAt: now,
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
repo.appendMessage('sess_ctx_openrouter', { role: 'user', text: 'hello world', time: now })
|
|
111
|
+
|
|
112
|
+
const response = await route.GET(
|
|
113
|
+
new Request('http://local/api/chats/sess_ctx_openrouter/context-status'),
|
|
114
|
+
{ params: Promise.resolve({ id: 'sess_ctx_openrouter' }) },
|
|
115
|
+
)
|
|
116
|
+
const payload = await response.json()
|
|
117
|
+
|
|
118
|
+
console.log(JSON.stringify({
|
|
119
|
+
status: response.status,
|
|
120
|
+
contextWindow: payload.contextWindow,
|
|
121
|
+
}))
|
|
122
|
+
`, { prefix: 'swarmclaw-context-status-route-' })
|
|
123
|
+
|
|
124
|
+
assert.equal(output.status, 200)
|
|
125
|
+
assert.equal(output.contextWindow, 524_288)
|
|
126
|
+
assert.notEqual(output.contextWindow, 8_192)
|
|
127
|
+
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { ensureGatewayConnected } from '@/lib/server/openclaw/gateway'
|
|
3
3
|
import { mergeHistoryMessages, isValidSessionKey } from '@/lib/server/openclaw/history-merge'
|
|
4
|
-
import { getSession,
|
|
4
|
+
import { getSession, patchSession } from '@/lib/server/sessions/session-repository'
|
|
5
|
+
import { getMessages, replaceAllMessages } from '@/lib/server/messages/message-repository'
|
|
5
6
|
import { notify } from '@/lib/server/ws-hub'
|
|
6
7
|
import type { GatewaySessionPreview } from '@/types'
|
|
7
8
|
import { errorMessage } from '@/lib/shared-utils'
|
|
@@ -95,11 +96,15 @@ export async function POST(req: Request) {
|
|
|
95
96
|
return NextResponse.json({ error: 'Local session not found' }, { status: 404 })
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
const currentMessages = getMessages(localSessionId)
|
|
100
|
+
const merged = mergeHistoryMessages(currentMessages, preview)
|
|
101
|
+
const newCount = merged.length - currentMessages.length
|
|
102
|
+
replaceAllMessages(localSessionId, merged)
|
|
103
|
+
patchSession(localSessionId, (current) => {
|
|
104
|
+
if (!current) return null
|
|
105
|
+
current.lastActiveAt = Date.now()
|
|
106
|
+
return current
|
|
107
|
+
})
|
|
103
108
|
notify('sessions')
|
|
104
109
|
|
|
105
110
|
return NextResponse.json({ ok: true, merged: newCount })
|
|
@@ -49,11 +49,13 @@ const servers: Map<string, PreviewServer> =
|
|
|
49
49
|
// ---------------------------------------------------------------------------
|
|
50
50
|
|
|
51
51
|
function resolveServeDir(filePath: string): string {
|
|
52
|
-
const resolved = path.resolve(filePath)
|
|
52
|
+
const resolved = path.resolve(/*turbopackIgnore: true*/ filePath)
|
|
53
53
|
try {
|
|
54
|
-
return fs.statSync(resolved).isDirectory()
|
|
54
|
+
return fs.statSync(/*turbopackIgnore: true*/ resolved).isDirectory()
|
|
55
|
+
? resolved
|
|
56
|
+
: path.dirname(/*turbopackIgnore: true*/ resolved)
|
|
55
57
|
} catch {
|
|
56
|
-
return path.dirname(resolved)
|
|
58
|
+
return path.dirname(/*turbopackIgnore: true*/ resolved)
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -91,13 +93,13 @@ function buildFrameworkArgs(framework: string | undefined, port: number): string
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
function detectProject(dir: string): ProjectInfo {
|
|
94
|
-
const pkgPath = path.join(dir, 'package.json')
|
|
95
|
-
if (!fs.existsSync(pkgPath)) {
|
|
96
|
+
const pkgPath = path.join(/*turbopackIgnore: true*/ dir, 'package.json')
|
|
97
|
+
if (!fs.existsSync(/*turbopackIgnore: true*/ pkgPath)) {
|
|
96
98
|
return { type: 'static' }
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
try {
|
|
100
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
102
|
+
const pkg = JSON.parse(fs.readFileSync(/*turbopackIgnore: true*/ pkgPath, 'utf-8'))
|
|
101
103
|
const scripts = pkg.scripts || {}
|
|
102
104
|
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) }
|
|
103
105
|
|
|
@@ -156,16 +158,22 @@ function createStaticServer(dir: string): http.Server {
|
|
|
156
158
|
]
|
|
157
159
|
|
|
158
160
|
for (const candidate of candidates) {
|
|
159
|
-
if (
|
|
161
|
+
if (
|
|
162
|
+
fs.existsSync(/*turbopackIgnore: true*/ candidate)
|
|
163
|
+
&& fs.statSync(/*turbopackIgnore: true*/ candidate).isFile()
|
|
164
|
+
) {
|
|
160
165
|
const ext = path.extname(candidate).toLowerCase()
|
|
161
166
|
res.writeHead(200, { 'Content-Type': MIME_MAP[ext] || 'application/octet-stream' })
|
|
162
|
-
fs.createReadStream(candidate).pipe(res)
|
|
167
|
+
fs.createReadStream(/*turbopackIgnore: true*/ candidate).pipe(res)
|
|
163
168
|
return
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
|
|
167
|
-
if (
|
|
168
|
-
|
|
172
|
+
if (
|
|
173
|
+
fs.existsSync(/*turbopackIgnore: true*/ normalizedFile)
|
|
174
|
+
&& fs.statSync(/*turbopackIgnore: true*/ normalizedFile).isDirectory()
|
|
175
|
+
) {
|
|
176
|
+
const files = fs.readdirSync(/*turbopackIgnore: true*/ normalizedFile)
|
|
169
177
|
const links = files.map((f) => `<li><a href="${reqPath.replace(/\/$/, '')}/${f}">${f}</a></li>`).join('\n')
|
|
170
178
|
res.writeHead(200, { 'Content-Type': 'text/html' })
|
|
171
179
|
res.end(`<!DOCTYPE html><html><head><title>Index of ${reqPath}</title><style>body{font-family:monospace;padding:20px;background:#1a1a2e;color:#e0e0e0}a{color:#60a5fa}</style></head><body><h2>Index of ${reqPath}</h2><ul>${links}</ul></body></html>`)
|
|
@@ -183,7 +191,7 @@ function createStaticServer(dir: string): http.Server {
|
|
|
183
191
|
|
|
184
192
|
async function startNpmServer(dir: string, command: string[], port: number, framework?: string): Promise<PreviewServer> {
|
|
185
193
|
// Install deps if node_modules missing
|
|
186
|
-
if (!fs.existsSync(path.join(dir, 'node_modules'))) {
|
|
194
|
+
if (!fs.existsSync(/*turbopackIgnore: true*/ path.join(/*turbopackIgnore: true*/ dir, 'node_modules'))) {
|
|
187
195
|
log.info(TAG, `Installing dependencies in ${dir}`)
|
|
188
196
|
await new Promise<void>((resolve, reject) => {
|
|
189
197
|
const install = spawn('npm', ['install'], { cwd: dir, stdio: 'pipe' })
|
|
@@ -290,7 +298,7 @@ export async function POST(req: Request) {
|
|
|
290
298
|
return NextResponse.json(buildResponse(servers.get(key)!))
|
|
291
299
|
}
|
|
292
300
|
|
|
293
|
-
if (!fs.existsSync(dir)) {
|
|
301
|
+
if (!fs.existsSync(/*turbopackIgnore: true*/ dir)) {
|
|
294
302
|
return NextResponse.json({ error: 'Directory not found' }, { status: 404 })
|
|
295
303
|
}
|
|
296
304
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import test from 'node:test'
|
|
3
|
+
|
|
4
|
+
import { runWithTempDataDir } from '@/lib/server/test-utils/run-with-temp-data-dir'
|
|
5
|
+
|
|
6
|
+
test('global search finds repo-backed session messages after blob compaction', () => {
|
|
7
|
+
const output = runWithTempDataDir<{
|
|
8
|
+
messageTitles: string[]
|
|
9
|
+
messageIndexes: number[]
|
|
10
|
+
}>(`
|
|
11
|
+
const storageMod = await import('@/lib/server/storage')
|
|
12
|
+
const repoMod = await import('@/lib/server/messages/message-repository')
|
|
13
|
+
const routeMod = await import('./src/app/api/search/route')
|
|
14
|
+
const storage = storageMod.default || storageMod
|
|
15
|
+
const repo = repoMod.default || repoMod
|
|
16
|
+
const route = routeMod.default || routeMod
|
|
17
|
+
|
|
18
|
+
storage.saveAgents({
|
|
19
|
+
'agent-search': {
|
|
20
|
+
id: 'agent-search',
|
|
21
|
+
name: 'Search Agent',
|
|
22
|
+
description: 'Search fixture',
|
|
23
|
+
provider: 'openai',
|
|
24
|
+
model: 'gpt-5',
|
|
25
|
+
createdAt: Date.now(),
|
|
26
|
+
updatedAt: Date.now(),
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
storage.saveSessions({
|
|
30
|
+
'sess-search': {
|
|
31
|
+
id: 'sess-search',
|
|
32
|
+
name: 'Search Session',
|
|
33
|
+
cwd: process.env.WORKSPACE_DIR,
|
|
34
|
+
user: 'tester',
|
|
35
|
+
provider: 'openai',
|
|
36
|
+
model: 'gpt-5',
|
|
37
|
+
agentId: 'agent-search',
|
|
38
|
+
claudeSessionId: null,
|
|
39
|
+
codexThreadId: null,
|
|
40
|
+
opencodeSessionId: null,
|
|
41
|
+
delegateResumeIds: { claudeCode: null, codex: null, opencode: null, gemini: null },
|
|
42
|
+
messages: [],
|
|
43
|
+
createdAt: Date.now(),
|
|
44
|
+
lastActiveAt: Date.now(),
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
repo.appendMessage('sess-search', { role: 'user', text: 'ordinary setup note', time: 10 })
|
|
49
|
+
repo.appendMessage('sess-search', { role: 'assistant', text: 'needle-backed answer from the message table', time: 20 })
|
|
50
|
+
|
|
51
|
+
const response = await route.GET(new Request('http://local/api/search?q=needle-backed'))
|
|
52
|
+
const payload = await response.json()
|
|
53
|
+
const messageResults = payload.results.filter((result) => result.type === 'message')
|
|
54
|
+
|
|
55
|
+
console.log(JSON.stringify({
|
|
56
|
+
messageTitles: messageResults.map((result) => result.title),
|
|
57
|
+
messageIndexes: messageResults.map((result) => result.messageIndex),
|
|
58
|
+
}))
|
|
59
|
+
`, { prefix: 'swarmclaw-search-repo-messages-' })
|
|
60
|
+
|
|
61
|
+
assert.deepEqual(output.messageTitles, ['needle-backed answer from the message table'])
|
|
62
|
+
assert.deepEqual(output.messageIndexes, [1])
|
|
63
|
+
})
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
loadWebhooks,
|
|
8
8
|
loadSkills,
|
|
9
9
|
} from '@/lib/server/storage'
|
|
10
|
+
import { getMessages } from '@/lib/server/messages/message-repository'
|
|
10
11
|
|
|
11
12
|
interface SearchResult {
|
|
12
13
|
type: 'task' | 'agent' | 'session' | 'schedule' | 'webhook' | 'skill' | 'message'
|
|
@@ -59,8 +60,8 @@ function searchMessages(
|
|
|
59
60
|
const MAX_MSG_RESULTS = 10
|
|
60
61
|
for (const [sessionId, session] of Object.entries(sessions)) {
|
|
61
62
|
if (results.length >= MAX_MSG_RESULTS) break
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
const messages = getMessages(sessionId)
|
|
64
|
+
if (!messages.length) continue
|
|
64
65
|
const agentId = session.agentId as string | undefined
|
|
65
66
|
const agentName = agentId && agents[agentId] ? (agents[agentId].name as string) : undefined
|
|
66
67
|
const sessionName = (session.name as string) || 'Untitled'
|
|
@@ -7,6 +7,7 @@ import { normalizeRuntimeSettingFields } from '@/lib/runtime/runtime-loop'
|
|
|
7
7
|
import { normalizeSupervisorSettings } from '@/lib/autonomy/supervisor-settings'
|
|
8
8
|
import { ensureDaemonProcessRunning } from '@/lib/server/daemon/controller'
|
|
9
9
|
import { logActivity } from '@/lib/server/activity/activity-log'
|
|
10
|
+
import { normalizeThemeMode } from '@/lib/theme-mode'
|
|
10
11
|
export const dynamic = 'force-dynamic'
|
|
11
12
|
|
|
12
13
|
|
|
@@ -55,7 +56,9 @@ function parseGuardMode(value: unknown): 'off' | 'warn' | 'block' {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
export async function GET() {
|
|
58
|
-
|
|
59
|
+
const settings = loadPublicSettings()
|
|
60
|
+
settings.themeMode = normalizeThemeMode(settings.themeMode)
|
|
61
|
+
return NextResponse.json(settings)
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export async function PUT(req: Request) {
|
|
@@ -146,6 +149,7 @@ export async function PUT(req: Request) {
|
|
|
146
149
|
settings.daemonAutostartEnabled = parseBoolSetting(settings.daemonAutostartEnabled, true)
|
|
147
150
|
settings.autonomyResumeApprovalsEnabled = parseBoolSetting(settings.autonomyResumeApprovalsEnabled, false)
|
|
148
151
|
settings.untrustedContentGuardMode = parseGuardMode(settings.untrustedContentGuardMode)
|
|
152
|
+
settings.themeMode = normalizeThemeMode(settings.themeMode)
|
|
149
153
|
settings.sessionResetMode = settings.sessionResetMode === 'daily' ? 'daily' : settings.sessionResetMode === 'idle' ? 'idle' : null
|
|
150
154
|
settings.whatsappApprovedContacts = normalizeWhatsAppApprovedContacts(settings.whatsappApprovedContacts)
|
|
151
155
|
settings.sessionIdleTimeoutSec = parseIntSetting(
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import test from 'node:test'
|
|
3
|
+
|
|
4
|
+
import { runWithTempDataDir } from '@/lib/server/test-utils/run-with-temp-data-dir'
|
|
5
|
+
|
|
6
|
+
test('settings route persists valid theme mode and normalizes invalid values to dark', () => {
|
|
7
|
+
const output = runWithTempDataDir<{
|
|
8
|
+
lightMode: string | null
|
|
9
|
+
invalidMode: string | null
|
|
10
|
+
}>(`
|
|
11
|
+
const routeMod = await import('./src/app/api/settings/route')
|
|
12
|
+
const route = routeMod.default || routeMod
|
|
13
|
+
|
|
14
|
+
await route.PUT(new Request('http://local/api/settings', {
|
|
15
|
+
method: 'PUT',
|
|
16
|
+
headers: { 'content-type': 'application/json' },
|
|
17
|
+
body: JSON.stringify({ themeMode: 'light' }),
|
|
18
|
+
}))
|
|
19
|
+
const lightResponse = await route.GET()
|
|
20
|
+
const lightSettings = await lightResponse.json()
|
|
21
|
+
|
|
22
|
+
await route.PUT(new Request('http://local/api/settings', {
|
|
23
|
+
method: 'PUT',
|
|
24
|
+
headers: { 'content-type': 'application/json' },
|
|
25
|
+
body: JSON.stringify({ themeMode: 'sepia' }),
|
|
26
|
+
}))
|
|
27
|
+
const invalidResponse = await route.GET()
|
|
28
|
+
const invalidSettings = await invalidResponse.json()
|
|
29
|
+
|
|
30
|
+
console.log(JSON.stringify({
|
|
31
|
+
lightMode: lightSettings.themeMode || null,
|
|
32
|
+
invalidMode: invalidSettings.themeMode || null,
|
|
33
|
+
}))
|
|
34
|
+
`, { prefix: 'swarmclaw-settings-theme-mode-' })
|
|
35
|
+
|
|
36
|
+
assert.equal(output.lightMode, 'light')
|
|
37
|
+
assert.equal(output.invalidMode, 'dark')
|
|
38
|
+
})
|
|
@@ -161,3 +161,15 @@ test('POST returns provider diagnostics with normalized LM Studio targets and re
|
|
|
161
161
|
globalThis.fetch = originalFetch
|
|
162
162
|
}
|
|
163
163
|
})
|
|
164
|
+
|
|
165
|
+
test('POST rejects TokenMix setup checks without an API key', async () => {
|
|
166
|
+
const res = await POST(new Request('http://localhost/api/setup/check-provider', {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
body: JSON.stringify({ provider: 'tokenmix' }),
|
|
169
|
+
}))
|
|
170
|
+
const payload = await res.json()
|
|
171
|
+
|
|
172
|
+
assert.equal(res.status, 200)
|
|
173
|
+
assert.equal(payload.ok, false)
|
|
174
|
+
assert.equal(payload.message, 'TokenMix API key is required.')
|
|
175
|
+
})
|
|
@@ -501,6 +501,12 @@ export async function POST(req: Request) {
|
|
|
501
501
|
const result = await checkOpenAiCompatible(info.name, apiKey, endpoint, info.defaultEndpoint, model)
|
|
502
502
|
return NextResponse.json(result)
|
|
503
503
|
}
|
|
504
|
+
case 'tokenmix': {
|
|
505
|
+
if (!apiKey) return NextResponse.json({ ok: false, message: 'TokenMix API key is required.' })
|
|
506
|
+
const info = OPENAI_COMPATIBLE_DEFAULTS.tokenmix
|
|
507
|
+
const result = await checkOpenAiCompatible(info.name, apiKey, endpoint, info.defaultEndpoint, model)
|
|
508
|
+
return NextResponse.json(result)
|
|
509
|
+
}
|
|
504
510
|
case 'anthropic': {
|
|
505
511
|
if (!apiKey) return NextResponse.json({ ok: false, message: 'Anthropic API key is required.' })
|
|
506
512
|
const result = await checkAnthropic(apiKey, endpoint, model)
|
|
@@ -9,7 +9,7 @@ type SessionSnapshot = {
|
|
|
9
9
|
agentId?: string
|
|
10
10
|
createdAt?: number
|
|
11
11
|
lastActiveAt?: number
|
|
12
|
-
|
|
12
|
+
messageCount?: number
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
interface LiveUsage {
|
|
@@ -45,7 +45,7 @@ function summarize(sessionId: string, records: UsageRecord[], session: SessionSn
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const turns =
|
|
48
|
+
const turns = typeof session?.messageCount === 'number' ? session.messageCount : records.length
|
|
49
49
|
const wallStart = session?.createdAt ?? firstAt ?? 0
|
|
50
50
|
const wallEnd = session?.lastActiveAt ?? lastAt ?? Date.now()
|
|
51
51
|
const wallclockMs = wallStart > 0 ? Math.max(0, wallEnd - wallStart) : 0
|