cliclaw 1.0.23 → 1.0.25
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 +6 -7
- package/package.json +1 -1
- package/src/agents/codex.ts +2 -2
- package/src/config.ts +6 -12
- package/src/handlers/messages.ts +2 -2
package/bin/cli.js
CHANGED
|
@@ -189,13 +189,12 @@ async function runConfigWizard() {
|
|
|
189
189
|
console.log(`${c.gray} Leave empty to configure later.\n${c.reset}`)
|
|
190
190
|
const forumId = await prompt('FORUM_GROUP_ID (Enter to skip)', existing.FORUM_GROUP_ID || '')
|
|
191
191
|
|
|
192
|
-
console.log(`\n${c.bold}
|
|
193
|
-
console.log(` ${c.bold}1)
|
|
194
|
-
console.log(` ${c.bold}2)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const permMode = permChoice === '2' ? 'session' : permChoice === '3' ? 'ask' : 'auto'
|
|
192
|
+
console.log(`\n${c.bold}Aprovação de comandos${c.reset} ${c.gray}(todos os agentes)${c.reset}`)
|
|
193
|
+
console.log(` ${c.bold}1) ask${c.reset} — pergunta antes de executar cada comando ${c.cyan}(recomendado)${c.reset}`)
|
|
194
|
+
console.log(` ${c.bold}2) allow${c.reset} — executa tudo automaticamente sem perguntar\n`)
|
|
195
|
+
const permChoice = await prompt('Escolha [1/2]',
|
|
196
|
+
(existing.PERMISSION_MODE || existing.CODEX_APPROVAL) === 'allow' ? '2' : '1')
|
|
197
|
+
const permMode = permChoice === '2' ? 'allow' : 'ask'
|
|
199
198
|
ok(`Permission mode: ${permMode}`)
|
|
200
199
|
|
|
201
200
|
const dataDir = existing.DATA_DIR || path.join(USER_DIR, 'data')
|
package/package.json
CHANGED
package/src/agents/codex.ts
CHANGED
|
@@ -14,8 +14,8 @@ const BASE_ENV = {
|
|
|
14
14
|
LANG: 'en_US.UTF-8',
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const SESSION_TTL_MS = 30 * 60 * 1000
|
|
18
|
-
const RESPONSE_TIMEOUT_MS =
|
|
17
|
+
const SESSION_TTL_MS = 30 * 60 * 1000 // kill idle processes after 30 min
|
|
18
|
+
const RESPONSE_TIMEOUT_MS = 10 * 60_000 // 10 min — allows time for user approval clicks
|
|
19
19
|
|
|
20
20
|
interface PendingReq {
|
|
21
21
|
resolve: (r: { text: string; usage?: TokenUsage }) => void
|
package/src/config.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { join } from 'path'
|
|
|
4
4
|
import { homedir } from 'os'
|
|
5
5
|
|
|
6
6
|
export type AgentName = 'claude' | 'codex'
|
|
7
|
-
|
|
8
|
-
export type
|
|
7
|
+
/** ask = ask before each command | allow = auto-approve everything */
|
|
8
|
+
export type PermissionMode = 'ask' | 'allow'
|
|
9
9
|
|
|
10
10
|
export interface Config {
|
|
11
11
|
TELEGRAM_BOT_TOKEN: string
|
|
@@ -13,7 +13,6 @@ export interface Config {
|
|
|
13
13
|
FORUM_GROUP_ID: string
|
|
14
14
|
TELEGRAM_ADMIN_IDS: string[]
|
|
15
15
|
PERMISSION_MODE: PermissionMode
|
|
16
|
-
CODEX_APPROVAL: CodexApproval
|
|
17
16
|
availableAgents: AgentName[]
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -56,13 +55,9 @@ export function loadConfig(): Config {
|
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
rawMode === 'ask' ? 'ask' : 'auto'
|
|
63
|
-
|
|
64
|
-
const rawApproval = (process.env.CODEX_APPROVAL || 'ask').toLowerCase()
|
|
65
|
-
const codexApproval: CodexApproval = rawApproval === 'allow' ? 'allow' : 'ask'
|
|
58
|
+
// Support both PERMISSION_MODE and legacy CODEX_APPROVAL
|
|
59
|
+
const rawMode = (process.env.PERMISSION_MODE || process.env.CODEX_APPROVAL || 'ask').toLowerCase()
|
|
60
|
+
const permMode: PermissionMode = rawMode === 'allow' ? 'allow' : 'ask'
|
|
66
61
|
|
|
67
62
|
const config: Config = {
|
|
68
63
|
TELEGRAM_BOT_TOKEN: process.env.TELEGRAM_BOT_TOKEN || '',
|
|
@@ -71,7 +66,6 @@ export function loadConfig(): Config {
|
|
|
71
66
|
TELEGRAM_ADMIN_IDS: (process.env.TELEGRAM_ADMIN_IDS || '')
|
|
72
67
|
.split(',').map(id => id.trim()).filter(Boolean),
|
|
73
68
|
PERMISSION_MODE: permMode,
|
|
74
|
-
CODEX_APPROVAL: codexApproval,
|
|
75
69
|
availableAgents: checkAgents(),
|
|
76
70
|
}
|
|
77
71
|
|
|
@@ -86,7 +80,7 @@ export function loadConfig(): Config {
|
|
|
86
80
|
if (config.availableAgents.length === 0) {
|
|
87
81
|
console.warn('\n⚠️ No AI CLIs found in PATH. Run /start in Telegram for setup instructions.\n')
|
|
88
82
|
} else {
|
|
89
|
-
console.log(`✅ Available agents: ${config.availableAgents.join(', ')} |
|
|
83
|
+
console.log(`✅ Available agents: ${config.availableAgents.join(', ')} | Approval: ${config.PERMISSION_MODE}`)
|
|
90
84
|
}
|
|
91
85
|
|
|
92
86
|
return config
|
package/src/handlers/messages.ts
CHANGED
|
@@ -102,8 +102,8 @@ export function registerMessageHandler(bot: Bot<Context>, storage: Storage, conf
|
|
|
102
102
|
|
|
103
103
|
storage.addMessage(chatId, session.id, 'user', text)
|
|
104
104
|
|
|
105
|
-
// ── build codex approval handler (only if
|
|
106
|
-
const codexApprovalHandler = (session.model === 'codex' && config.
|
|
105
|
+
// ── build codex approval handler (only if PERMISSION_MODE=ask) ─────────
|
|
106
|
+
const codexApprovalHandler = (session.model === 'codex' && config.PERMISSION_MODE === 'ask')
|
|
107
107
|
? (callId: string, cmdStr: string) => {
|
|
108
108
|
const approvalId = randomUUID()
|
|
109
109
|
ctx.api.sendMessage(chatId,
|