cliclaw 1.0.7 → 1.0.9
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/bin/cli.js +15 -1
- package/package.json +1 -1
- package/src/agents/claude.ts +7 -2
- package/src/agents/codex.ts +8 -2
- package/src/i18n.ts +2 -2
package/bin/cli.js
CHANGED
|
@@ -355,7 +355,21 @@ const [,, cmd = 'help'] = process.argv
|
|
|
355
355
|
switch (cmd) {
|
|
356
356
|
case 'setup': cmdSetup().catch(e => { err(e.message); process.exit(1) }); break
|
|
357
357
|
case 'config': cmdConfig(); break
|
|
358
|
-
case 'start':
|
|
358
|
+
case 'start': {
|
|
359
|
+
process.chdir(PKG_DIR)
|
|
360
|
+
// If the process exists in PM2 but is broken, restart it; otherwise start fresh
|
|
361
|
+
let exists = false
|
|
362
|
+
try {
|
|
363
|
+
const jlist = JSON.parse(require('child_process').execSync('pm2 jlist', { stdio: 'pipe', encoding: 'utf8' }))
|
|
364
|
+
exists = jlist.some(p => p.name === 'cliclaw')
|
|
365
|
+
} catch {}
|
|
366
|
+
if (exists) {
|
|
367
|
+
spawnSync('pm2', ['restart', 'cliclaw', '--update-env'], { stdio: 'inherit', shell: true })
|
|
368
|
+
} else {
|
|
369
|
+
spawnSync('pm2', ['start', path.join(PKG_DIR, 'ecosystem.config.js')], { stdio: 'inherit', shell: true })
|
|
370
|
+
}
|
|
371
|
+
break
|
|
372
|
+
}
|
|
359
373
|
case 'stop': cmdPm2(['stop', 'cliclaw']); break
|
|
360
374
|
case 'restart': cmdPm2(['restart', 'cliclaw', '--update-env']); break
|
|
361
375
|
case 'status': cmdPm2(['status']); break
|
package/package.json
CHANGED
package/src/agents/claude.ts
CHANGED
|
@@ -10,12 +10,17 @@ export interface TokenUsage {
|
|
|
10
10
|
costUsd?: number
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const HOME = process.env.HOME || '/root'
|
|
13
|
+
const HOME = process.env.HOME || process.env.USERPROFILE || '/root'
|
|
14
|
+
const SEP = process.platform === 'win32' ? ';' : ':'
|
|
14
15
|
|
|
15
16
|
function buildEnv() {
|
|
16
17
|
const e: Record<string, string> = {
|
|
17
18
|
...process.env as any,
|
|
18
|
-
PATH:
|
|
19
|
+
PATH: [
|
|
20
|
+
process.env.PATH || '',
|
|
21
|
+
`${HOME}/.npm-global/bin`,
|
|
22
|
+
'/usr/local/bin', '/usr/bin', '/bin',
|
|
23
|
+
].filter(Boolean).join(SEP),
|
|
19
24
|
HOME,
|
|
20
25
|
LANG: 'en_US.UTF-8',
|
|
21
26
|
}
|
package/src/agents/codex.ts
CHANGED
|
@@ -2,9 +2,15 @@ import { spawn } from 'child_process'
|
|
|
2
2
|
import type { Session } from '../storage'
|
|
3
3
|
import type { TokenUsage } from './claude'
|
|
4
4
|
|
|
5
|
-
const HOME = process.env.HOME || '/root'
|
|
5
|
+
const HOME = process.env.HOME || process.env.USERPROFILE || '/root'
|
|
6
|
+
const SEP = process.platform === 'win32' ? ';' : ':'
|
|
7
|
+
// Keep system PATH (contains npm global bin) and append Linux fallbacks for non-Windows
|
|
6
8
|
const BASE_ENV = {
|
|
7
|
-
PATH:
|
|
9
|
+
PATH: [
|
|
10
|
+
process.env.PATH || '',
|
|
11
|
+
`${HOME}/.npm-global/bin`,
|
|
12
|
+
'/usr/local/bin', '/usr/bin', '/bin',
|
|
13
|
+
].filter(Boolean).join(SEP),
|
|
8
14
|
HOME,
|
|
9
15
|
LANG: 'en_US.UTF-8',
|
|
10
16
|
}
|
package/src/i18n.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { Context } from 'grammy'
|
|
|
2
2
|
|
|
3
3
|
export type Lang = 'pt' | 'en'
|
|
4
4
|
|
|
5
|
-
/** Detect language from Telegram user locale. Defaults to '
|
|
5
|
+
/** Detect language from Telegram user locale. Defaults to 'pt'. */
|
|
6
6
|
export function getLang(ctx: Context): Lang {
|
|
7
7
|
const code = ctx.from?.language_code ?? ''
|
|
8
|
-
return code.startsWith('
|
|
8
|
+
return code.startsWith('en') ? 'en' : 'pt'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const strings = {
|