cliclaw 1.0.36 → 1.0.37

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/agents/codex.ts +16 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cliclaw",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Telegram bot bridging AI CLIs (Claude Code, Codex) to Forum Topics",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -86,7 +86,9 @@ function startProto(appSessionId: string): ProtoSession {
86
86
  try {
87
87
  const obj = JSON.parse(line)
88
88
  handleProtoEvent(ps, obj)
89
- } catch {}
89
+ } catch (e: any) {
90
+ console.error('[Codex proto] parse error:', e?.message, '| line:', line.slice(0, 120))
91
+ }
90
92
  }
91
93
  })
92
94
 
@@ -132,18 +134,22 @@ function handleProtoEvent(ps: ProtoSession, obj: any) {
132
134
  const commandStr = formatApprovalCommand(msg.command ?? msg.cmd)
133
135
  console.log(`[Codex approval] request recebido sub_id=${subId} cmd="${commandStr.slice(0, 80)}"`)
134
136
 
135
- // Respond using the original message id so Codex can correlate the reply
137
+ // Codex uses JSON-RPC 2.0 with its own decision strings
138
+ const DECISION_MAP: Record<string, string> = {
139
+ approved: 'accept',
140
+ approved_for_session: 'acceptForSession',
141
+ denied: 'decline',
142
+ abort: 'cancel',
143
+ }
136
144
  const respond = (decision: string) => {
137
- // Handle app-level session approval Codex only understands 'approved'/'denied'/'abort'
138
- if (decision === 'approved_for_session') {
139
- ps.sessionApproved = true
140
- decision = 'approved'
141
- }
142
- console.log(`[Codex approval] enviando exec_approval sub_id=${subId} decision=${decision}`)
145
+ if (decision === 'approved_for_session') ps.sessionApproved = true
146
+ const codexDecision = DECISION_MAP[decision] ?? 'decline'
147
+ console.log(`[Codex approval] enviando exec_approval id=${msgId} decision=${codexDecision}`)
143
148
  try {
144
149
  ps.proc.stdin!.write(JSON.stringify({
145
- id: msgId, // use original event id, not a new UUID
146
- op: { type: 'exec_approval', sub_id: subId, decision },
150
+ jsonrpc: '2.0',
151
+ id: msgId,
152
+ result: { decision: codexDecision },
147
153
  }) + '\n')
148
154
  console.log(`[Codex approval] enviado ok`)
149
155
  } catch (e: any) {