@swarmclawai/swarmclaw 0.7.5 → 0.7.7

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 (32) hide show
  1. package/README.md +41 -10
  2. package/package.json +2 -2
  3. package/src/app/api/agents/[id]/route.ts +16 -0
  4. package/src/app/api/agents/route.ts +2 -0
  5. package/src/app/api/chats/[id]/route.ts +21 -1
  6. package/src/app/api/chats/route.ts +12 -1
  7. package/src/app/api/external-agents/[id]/heartbeat/route.ts +3 -0
  8. package/src/app/api/external-agents/[id]/route.ts +38 -6
  9. package/src/app/api/external-agents/route.ts +17 -1
  10. package/src/app/api/gateways/[id]/health/route.ts +8 -0
  11. package/src/app/api/gateways/[id]/route.ts +53 -1
  12. package/src/app/api/gateways/route.ts +53 -0
  13. package/src/app/api/openclaw/deploy/route.ts +240 -0
  14. package/src/cli/index.js +53 -0
  15. package/src/cli/index.test.js +102 -0
  16. package/src/cli/spec.js +79 -0
  17. package/src/components/agents/agent-sheet.tsx +97 -19
  18. package/src/components/auth/setup-wizard.tsx +111 -54
  19. package/src/components/gateways/gateway-sheet.tsx +202 -10
  20. package/src/components/openclaw/openclaw-deploy-panel.tsx +1208 -0
  21. package/src/components/providers/provider-list.tsx +321 -22
  22. package/src/lib/server/agent-runtime-config.ts +142 -7
  23. package/src/lib/server/agent-thread-session.ts +9 -1
  24. package/src/lib/server/chat-execution.ts +8 -2
  25. package/src/lib/server/heartbeat-service.ts +5 -1
  26. package/src/lib/server/openclaw-deploy.test.ts +75 -0
  27. package/src/lib/server/openclaw-deploy.ts +1384 -0
  28. package/src/lib/server/orchestrator.ts +9 -0
  29. package/src/lib/server/queue.ts +45 -2
  30. package/src/lib/setup-defaults.ts +2 -2
  31. package/src/lib/validation/schemas.ts +9 -0
  32. package/src/types/index.ts +65 -0
@@ -26,6 +26,8 @@ function buildThreadSession(agent: Agent, sessionId: string, user: string, creat
26
26
  fallbackCredentialIds: agent.fallbackCredentialIds || [],
27
27
  apiEndpoint: agent.apiEndpoint || null,
28
28
  gatewayProfileId: agent.gatewayProfileId || null,
29
+ routePreferredGatewayTags: existing?.routePreferredGatewayTags || [],
30
+ routePreferredGatewayUseCase: existing?.routePreferredGatewayUseCase || null,
29
31
  claudeSessionId: existing?.claudeSessionId || null,
30
32
  codexThreadId: existing?.codexThreadId || null,
31
33
  opencodeSessionId: existing?.opencodeSessionId || null,
@@ -77,7 +79,13 @@ function buildThreadSession(agent: Agent, sessionId: string, user: string, creat
77
79
  avatar: existing?.avatar,
78
80
  canvasContent: existing?.canvasContent || null,
79
81
  }
80
- return applyResolvedRoute(baseSession, resolvePrimaryAgentRoute(agent))
82
+ return applyResolvedRoute(
83
+ baseSession,
84
+ resolvePrimaryAgentRoute(agent, undefined, {
85
+ preferredGatewayTags: baseSession.routePreferredGatewayTags || [],
86
+ preferredGatewayUseCase: baseSession.routePreferredGatewayUseCase || null,
87
+ }),
88
+ )
81
89
  }
82
90
 
83
91
  export function ensureAgentThreadSession(agentId: string, user = 'default'): Session | null {
@@ -626,7 +626,10 @@ function syncSessionFromAgent(sessionId: string): void {
626
626
  if (!agent) return
627
627
 
628
628
  let changed = false
629
- const route = resolvePrimaryAgentRoute(agent)
629
+ const route = resolvePrimaryAgentRoute(agent, undefined, {
630
+ preferredGatewayTags: session.routePreferredGatewayTags || [],
631
+ preferredGatewayUseCase: session.routePreferredGatewayUseCase || null,
632
+ })
630
633
  if (!session.provider && agent.provider) { session.provider = agent.provider; changed = true }
631
634
  if ((session.model === undefined || session.model === null || session.model === '') && agent.model !== undefined) {
632
635
  session.model = agent.model
@@ -849,7 +852,10 @@ export async function executeSessionChatTurn(input: ExecuteChatTurnInput): Promi
849
852
  ? session
850
853
  : { ...session, plugins: pluginsForRun }
851
854
  if (agentForSession) {
852
- const preferredRoute = resolvePrimaryAgentRoute(agentForSession)
855
+ const preferredRoute = resolvePrimaryAgentRoute(agentForSession, undefined, {
856
+ preferredGatewayTags: session.routePreferredGatewayTags || [],
857
+ preferredGatewayUseCase: session.routePreferredGatewayUseCase || null,
858
+ })
853
859
  if (preferredRoute) {
854
860
  sessionForRun = applyResolvedRoute({ ...sessionForRun }, preferredRoute)
855
861
  }
@@ -127,9 +127,13 @@ export interface HeartbeatConfig {
127
127
  target: string | null
128
128
  }
129
129
 
130
+ interface HeartbeatFileSession {
131
+ cwd?: string | null
132
+ }
133
+
130
134
  const DEFAULT_HEARTBEAT_PROMPT = 'Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.'
131
135
 
132
- function readHeartbeatFile(session: any): string {
136
+ function readHeartbeatFile(session: HeartbeatFileSession): string {
133
137
  try {
134
138
  const filePath = path.join(session.cwd || WORKSPACE_DIR, 'HEARTBEAT.md')
135
139
  if (fs.existsSync(filePath)) {
@@ -0,0 +1,75 @@
1
+ import assert from 'node:assert/strict'
2
+ import { test } from 'node:test'
3
+ import {
4
+ buildOpenClawDeployBundle,
5
+ getOpenClawLocalDeployStatus,
6
+ } from './openclaw-deploy.ts'
7
+
8
+ test('docker smart deploy bundle uses official image and provider-specific metadata', () => {
9
+ const bundle = buildOpenClawDeployBundle({
10
+ template: 'docker',
11
+ provider: 'digitalocean',
12
+ target: 'gateway.example.com',
13
+ token: 'test-token',
14
+ })
15
+
16
+ assert.equal(bundle.template, 'docker')
17
+ assert.equal(bundle.provider, 'digitalocean')
18
+ assert.equal(bundle.providerLabel, 'DigitalOcean')
19
+ assert.equal(bundle.endpoint, 'https://gateway.example.com/v1')
20
+ assert.equal(bundle.wsUrl, 'wss://gateway.example.com')
21
+ assert.equal(bundle.useCase, 'single-vps')
22
+ assert.equal(bundle.exposure, 'caddy')
23
+ assert.match(bundle.summary, /official OpenClaw Docker image/i)
24
+ assert.deepEqual(bundle.files.map((file) => file.name), [
25
+ 'cloud-init.yaml',
26
+ '.env',
27
+ 'docker-compose.yml',
28
+ 'bootstrap.sh',
29
+ 'docker-compose.proxy.yml',
30
+ 'Caddyfile',
31
+ ])
32
+
33
+ const envFile = bundle.files.find((file) => file.name === '.env')
34
+ assert.ok(envFile)
35
+ assert.match(envFile.content, /OPENCLAW_IMAGE=openclaw:latest/)
36
+ assert.match(envFile.content, /OPENCLAW_GATEWAY_TOKEN=test-token/)
37
+
38
+ const cloudInit = bundle.files.find((file) => file.name === 'cloud-init.yaml')
39
+ assert.ok(cloudInit)
40
+ assert.match(cloudInit.content, /docker\.io/)
41
+ assert.match(cloudInit.content, /docker pull "\$\{OPENCLAW_IMAGE:-openclaw:latest\}"/)
42
+ assert.match(cloudInit.content, /\/opt\/openclaw\/docker-compose\.yml/)
43
+
44
+ const caddyfile = bundle.files.find((file) => file.name === 'Caddyfile')
45
+ assert.ok(caddyfile)
46
+ assert.match(caddyfile.content, /gateway\.example\.com/)
47
+ })
48
+
49
+ test('render bundle stays aligned with the official repo flow', () => {
50
+ const bundle = buildOpenClawDeployBundle({
51
+ template: 'render',
52
+ target: 'https://openclaw.onrender.com',
53
+ token: 'render-token',
54
+ })
55
+
56
+ assert.equal(bundle.template, 'render')
57
+ assert.equal(bundle.providerLabel, 'Render')
58
+ assert.equal(bundle.endpoint, 'https://openclaw.onrender.com/v1')
59
+ assert.equal(bundle.token, 'render-token')
60
+ assert.deepEqual(bundle.files.map((file) => file.name), [
61
+ 'render.yaml',
62
+ 'OPENCLAW_GATEWAY_TOKEN.txt',
63
+ ])
64
+ assert.match(bundle.runbook[0] || '', /official OpenClaw GitHub repo/i)
65
+ })
66
+
67
+ test('local deploy status exposes a sensible default endpoint before startup', () => {
68
+ const status = getOpenClawLocalDeployStatus()
69
+
70
+ assert.equal(status.running, false)
71
+ assert.equal(status.port, 18789)
72
+ assert.equal(status.endpoint, 'http://127.0.0.1:18789/v1')
73
+ assert.equal(status.wsUrl, 'ws://127.0.0.1:18789')
74
+ assert.match(status.launchCommand, /npx openclaw gateway run/)
75
+ })