clawport-ui 0.4.1 → 0.4.2

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.
@@ -129,10 +129,16 @@ export async function POST(
129
129
  Connection: 'keep-alive',
130
130
  },
131
131
  })
132
- } catch (err) {
132
+ } catch (err: unknown) {
133
133
  console.error('Chat API error:', err)
134
+
135
+ let userMessage = 'Chat failed. Make sure OpenClaw gateway is running.'
136
+ if (err instanceof Error && 'status' in err && (err as { status: number }).status === 405) {
137
+ userMessage = 'Gateway returned 405. Enable the HTTP endpoint: set gateway.http.endpoints.chatCompletions.enabled = true in ~/.openclaw/openclaw.json, then restart the gateway.'
138
+ }
139
+
134
140
  return new Response(
135
- JSON.stringify({ error: 'Chat failed. Make sure OpenClaw gateway is running.' }),
141
+ JSON.stringify({ error: userMessage }),
136
142
  { status: 500, headers: { 'Content-Type': 'application/json' } }
137
143
  )
138
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawport-ui",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Open-source dashboard for managing, monitoring, and chatting with your OpenClaw AI agents.",
5
5
  "homepage": "https://clawport.dev",
6
6
  "repository": {
package/scripts/setup.mjs CHANGED
@@ -64,6 +64,34 @@ function detectGatewayToken() {
64
64
  }
65
65
  }
66
66
 
67
+ function checkHttpEndpointEnabled() {
68
+ const configPath = join(homedir(), '.openclaw', 'openclaw.json')
69
+ if (!existsSync(configPath)) return null // can't check
70
+ try {
71
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'))
72
+ return config?.gateway?.http?.endpoints?.chatCompletions?.enabled === true
73
+ } catch {
74
+ return null
75
+ }
76
+ }
77
+
78
+ function enableHttpEndpoint() {
79
+ const configPath = join(homedir(), '.openclaw', 'openclaw.json')
80
+ if (!existsSync(configPath)) return false
81
+ try {
82
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'))
83
+ if (!config.gateway) config.gateway = {}
84
+ if (!config.gateway.http) config.gateway.http = {}
85
+ if (!config.gateway.http.endpoints) config.gateway.http.endpoints = {}
86
+ if (!config.gateway.http.endpoints.chatCompletions) config.gateway.http.endpoints.chatCompletions = {}
87
+ config.gateway.http.endpoints.chatCompletions.enabled = true
88
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8')
89
+ return true
90
+ } catch {
91
+ return false
92
+ }
93
+ }
94
+
67
95
  async function checkGatewayRunning() {
68
96
  try {
69
97
  const res = await fetch('http://127.0.0.1:18789/', {
@@ -123,6 +151,24 @@ async function main() {
123
151
  console.log(` ${yellow('!')} Gateway not responding at localhost:18789`)
124
152
  console.log(` ${dim('Start it with: openclaw gateway run')}`)
125
153
  }
154
+
155
+ // Check HTTP chat completions endpoint
156
+ const httpEnabled = checkHttpEndpointEnabled()
157
+ if (httpEnabled === true) {
158
+ console.log(` ${green('+')} HTTP chat completions endpoint ${dim('enabled')}`)
159
+ } else if (httpEnabled === false) {
160
+ console.log(` ${yellow('!')} HTTP chat completions endpoint is ${bold('disabled')}`)
161
+ console.log(` ${dim('ClawPort needs this to chat with agents.')}`)
162
+ const enable = await ask(` ${yellow('?')} Enable it in openclaw.json? (Y/n) `)
163
+ if (enable.toLowerCase() !== 'n') {
164
+ if (enableHttpEndpoint()) {
165
+ console.log(` ${green('+')} Enabled! ${dim('Restart the gateway for this to take effect.')}`)
166
+ } else {
167
+ console.log(` ${red('x')} Could not update openclaw.json. Enable it manually:`)
168
+ console.log(` ${dim('Set gateway.http.endpoints.chatCompletions.enabled = true in ~/.openclaw/openclaw.json')}`)
169
+ }
170
+ }
171
+ }
126
172
  console.log()
127
173
 
128
174
  // Handle missing values