clawport-ui 0.6.3 → 0.6.5
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 +3 -3
- package/bin/clawport.mjs +45 -7
- package/next.config.mjs +1 -0
- package/package.json +1 -1
- package/scripts/setup.mjs +31 -5
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ All AI calls -- chat, vision, TTS, transcription -- route through the gateway. O
|
|
|
122
122
|
|
|
123
123
|
| Variable | Description | How to find it |
|
|
124
124
|
|----------|-------------|----------------|
|
|
125
|
-
| `WORKSPACE_PATH` | Path to your OpenClaw workspace | Default: `~/.openclaw/workspace` |
|
|
125
|
+
| `WORKSPACE_PATH` | Path to your OpenClaw workspace | Default: `~/.openclaw/agents/main/workspace` (or legacy `~/.openclaw/workspace`) |
|
|
126
126
|
| `OPENCLAW_BIN` | Path to the `openclaw` binary | Run `which openclaw` |
|
|
127
127
|
| `OPENCLAW_GATEWAY_TOKEN` | Gateway auth token | Run `openclaw gateway status` |
|
|
128
128
|
|
|
@@ -132,7 +132,7 @@ All AI calls -- chat, vision, TTS, transcription -- route through the gateway. O
|
|
|
132
132
|
|----------|-------------|
|
|
133
133
|
| `ELEVENLABS_API_KEY` | ElevenLabs API key for voice indicators on agent profiles |
|
|
134
134
|
|
|
135
|
-
Running `clawport setup` auto-detects all required values and writes `.env.local`. See [SETUP.md](SETUP.md) for manual configuration, agent customization, and troubleshooting.
|
|
135
|
+
Running `clawport setup` auto-detects all required values and writes `.env.local`. When installed globally, if the package directory isn't writable, setup writes to `~/.config/clawport-ui/.env.local` instead. See [SETUP.md](SETUP.md) for manual configuration, agent customization, and troubleshooting.
|
|
136
136
|
|
|
137
137
|
---
|
|
138
138
|
|
|
@@ -171,7 +171,7 @@ clawport help # Show usage
|
|
|
171
171
|
## Testing
|
|
172
172
|
|
|
173
173
|
```bash
|
|
174
|
-
npm test #
|
|
174
|
+
npm test # 536 tests across 24 suites (Vitest)
|
|
175
175
|
npx tsc --noEmit # Type-check (zero errors)
|
|
176
176
|
npx next build # Production build
|
|
177
177
|
```
|
package/bin/clawport.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import { dirname, resolve } from 'node:path'
|
|
4
|
+
import { dirname, resolve, join } from 'node:path'
|
|
5
5
|
import { spawn } from 'node:child_process'
|
|
6
6
|
import { existsSync, readFileSync, accessSync, constants } from 'node:fs'
|
|
7
|
+
import { homedir } from 'node:os'
|
|
7
8
|
import { execSync } from 'node:child_process'
|
|
8
9
|
import { createServer } from 'node:net'
|
|
9
10
|
|
|
@@ -26,6 +27,40 @@ if (major < 22) {
|
|
|
26
27
|
const __filename = fileURLToPath(import.meta.url)
|
|
27
28
|
const PKG_ROOT = resolve(dirname(__filename), '..')
|
|
28
29
|
|
|
30
|
+
const USER_CONFIG_DIR = join(homedir(), '.config', 'clawport-ui')
|
|
31
|
+
const ENV_LOCAL_FILENAME = '.env.local'
|
|
32
|
+
|
|
33
|
+
/** Path to .env.local: package root (preferred) or user config dir (for global installs). */
|
|
34
|
+
function getEnvLocalPath() {
|
|
35
|
+
const pkgEnv = resolve(PKG_ROOT, ENV_LOCAL_FILENAME)
|
|
36
|
+
if (existsSync(pkgEnv)) return pkgEnv
|
|
37
|
+
const userEnv = resolve(USER_CONFIG_DIR, ENV_LOCAL_FILENAME)
|
|
38
|
+
if (existsSync(userEnv)) return userEnv
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Load .env.local into process.env so Next.js and status/doctor see the vars. */
|
|
43
|
+
function loadEnvLocal() {
|
|
44
|
+
const path = getEnvLocalPath()
|
|
45
|
+
if (!path) return
|
|
46
|
+
try {
|
|
47
|
+
const content = readFileSync(path, 'utf-8')
|
|
48
|
+
for (const line of content.split('\n')) {
|
|
49
|
+
const trimmed = line.trim()
|
|
50
|
+
if (trimmed && !trimmed.startsWith('#')) {
|
|
51
|
+
const eq = trimmed.indexOf('=')
|
|
52
|
+
if (eq > 0) {
|
|
53
|
+
const key = trimmed.slice(0, eq).trim()
|
|
54
|
+
const value = trimmed.slice(eq + 1).trim()
|
|
55
|
+
if (key) process.env[key] = value
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (_) {}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
loadEnvLocal()
|
|
63
|
+
|
|
29
64
|
// ---------------------------------------------------------------------------
|
|
30
65
|
// Helpers
|
|
31
66
|
// ---------------------------------------------------------------------------
|
|
@@ -153,10 +188,10 @@ async function cmdStatus() {
|
|
|
153
188
|
console.log(` ${dim('Start it with: openclaw gateway run')}`)
|
|
154
189
|
}
|
|
155
190
|
|
|
156
|
-
// Check .env.local
|
|
157
|
-
const envPath =
|
|
191
|
+
// Check .env.local (package root or ~/.config/clawport-ui)
|
|
192
|
+
const envPath = getEnvLocalPath()
|
|
158
193
|
console.log()
|
|
159
|
-
if (existsSync(envPath)) {
|
|
194
|
+
if (envPath && existsSync(envPath)) {
|
|
160
195
|
console.log(` ${green('+')} .env.local found`)
|
|
161
196
|
const content = readFileSync(envPath, 'utf-8')
|
|
162
197
|
const lines = content.split('\n').filter((l) => l && !l.startsWith('#'))
|
|
@@ -175,6 +210,9 @@ async function cmdStatus() {
|
|
|
175
210
|
}
|
|
176
211
|
|
|
177
212
|
console.log()
|
|
213
|
+
if (envPath) {
|
|
214
|
+
console.log(` ${dim(`Config: ${envPath}`)}`)
|
|
215
|
+
}
|
|
178
216
|
console.log(` ${dim(`Package root: ${PKG_ROOT}`)}`)
|
|
179
217
|
console.log()
|
|
180
218
|
}
|
|
@@ -212,12 +250,12 @@ async function cmdDoctor() {
|
|
|
212
250
|
const gatewayUp = await checkGateway()
|
|
213
251
|
check(gatewayUp, 'Gateway reachable at localhost:18789', 'Start it with: openclaw gateway run')
|
|
214
252
|
|
|
215
|
-
// 5. Configuration -- .env.local with required vars
|
|
216
|
-
const envPath =
|
|
253
|
+
// 5. Configuration -- .env.local with required vars (package root or ~/.config/clawport-ui)
|
|
254
|
+
const envPath = getEnvLocalPath()
|
|
217
255
|
const requiredVars = ['WORKSPACE_PATH', 'OPENCLAW_BIN', 'OPENCLAW_GATEWAY_TOKEN']
|
|
218
256
|
let envOk = false
|
|
219
257
|
let envFix = 'Run: clawport setup'
|
|
220
|
-
if (existsSync(envPath)) {
|
|
258
|
+
if (envPath && existsSync(envPath)) {
|
|
221
259
|
const content = readFileSync(envPath, 'utf-8')
|
|
222
260
|
const missing = requiredVars.filter((v) => !content.includes(`${v}=`))
|
|
223
261
|
if (missing.length === 0) {
|
package/next.config.mjs
CHANGED
package/package.json
CHANGED
package/scripts/setup.mjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// Usage: npm run setup
|
|
5
5
|
|
|
6
6
|
import { execSync } from 'node:child_process'
|
|
7
|
-
import { readFileSync, writeFileSync, existsSync } from 'node:fs'
|
|
7
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, accessSync } from 'node:fs'
|
|
8
|
+
import { constants } from 'node:fs'
|
|
8
9
|
import { resolve, join } from 'node:path'
|
|
9
10
|
import { createInterface } from 'node:readline'
|
|
10
11
|
import { homedir } from 'node:os'
|
|
@@ -42,8 +43,12 @@ function exec(cmd) {
|
|
|
42
43
|
// ---------------------------------------------------------------------------
|
|
43
44
|
|
|
44
45
|
function detectWorkspacePath() {
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
// Current OpenClaw layout: ~/.openclaw/agents/main/workspace
|
|
47
|
+
const agentPath = join(homedir(), '.openclaw', 'agents', 'main', 'workspace')
|
|
48
|
+
if (existsSync(agentPath)) return agentPath
|
|
49
|
+
// Legacy layout: ~/.openclaw/workspace
|
|
50
|
+
const legacyPath = join(homedir(), '.openclaw', 'workspace')
|
|
51
|
+
if (existsSync(legacyPath)) return legacyPath
|
|
47
52
|
return null
|
|
48
53
|
}
|
|
49
54
|
|
|
@@ -210,7 +215,28 @@ async function main() {
|
|
|
210
215
|
|
|
211
216
|
// Support --cwd flag for CLI usage (clawport setup writes .env.local into the package dir)
|
|
212
217
|
const cwdFlag = process.argv.find((a) => a.startsWith('--cwd='))
|
|
213
|
-
|
|
218
|
+
let targetDir = cwdFlag ? cwdFlag.split('=')[1] : process.cwd()
|
|
219
|
+
|
|
220
|
+
// When installed globally (e.g. /usr/lib/node_modules/clawport-ui), targetDir may not be writable.
|
|
221
|
+
// Use ~/.config/clawport-ui/.env.local in that case so setup works without sudo.
|
|
222
|
+
function canWriteToDir(dir) {
|
|
223
|
+
try {
|
|
224
|
+
accessSync(dir, constants.W_OK)
|
|
225
|
+
return true
|
|
226
|
+
} catch {
|
|
227
|
+
return false
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (!canWriteToDir(targetDir)) {
|
|
232
|
+
const userConfigDir = join(homedir(), '.config', 'clawport-ui')
|
|
233
|
+
if (!existsSync(userConfigDir)) {
|
|
234
|
+
mkdirSync(userConfigDir, { recursive: true })
|
|
235
|
+
}
|
|
236
|
+
targetDir = userConfigDir
|
|
237
|
+
console.log(` ${yellow('!')} Package directory is not writable; using ${dim(targetDir)} for .env.local`)
|
|
238
|
+
console.log()
|
|
239
|
+
}
|
|
214
240
|
|
|
215
241
|
// Check if .env.local already exists
|
|
216
242
|
const envPath = resolve(targetDir, '.env.local')
|
|
@@ -254,7 +280,7 @@ async function main() {
|
|
|
254
280
|
writeFileSync(envPath, content, 'utf-8')
|
|
255
281
|
|
|
256
282
|
console.log()
|
|
257
|
-
console.log(` ${green('Done!')} .env.local written.`)
|
|
283
|
+
console.log(` ${green('Done!')} .env.local written${targetDir !== (cwdFlag ? cwdFlag.split('=')[1] : process.cwd()) ? ` to ${dim(targetDir)}` : ''}.`)
|
|
258
284
|
console.log()
|
|
259
285
|
const startCmd = cwdFlag ? 'clawport dev' : 'npm run dev'
|
|
260
286
|
console.log(` Next steps:`)
|