cliclaw 1.0.37 → 1.0.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cliclaw",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "Telegram bot bridging AI CLIs (Claude Code, Codex) to Forum Topics",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -130,27 +130,19 @@ function handleProtoEvent(ps: ProtoSession, obj: any) {
130
130
 
131
131
  // ── exec approval request ───────────────────────────────────────────────────
132
132
  if (msg?.type === 'exec_approval_request') {
133
- const subId = msg.sub_id ?? msg.call_id ?? msgId
133
+ // effective_approval_id() in Codex uses approval_id ?? call_id
134
+ const approvalId = msg.approval_id ?? msg.call_id ?? msg.sub_id ?? msgId
135
+ const turnId = msg.turn_id as string | undefined
134
136
  const commandStr = formatApprovalCommand(msg.command ?? msg.cmd)
135
- console.log(`[Codex approval] request recebido sub_id=${subId} cmd="${commandStr.slice(0, 80)}"`)
137
+ console.log(`[Codex approval] request: outer_id=${msgId} approval_id=${approvalId} turn_id=${turnId} raw=${JSON.stringify(msg)}`)
136
138
 
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
- }
144
139
  const respond = (decision: string) => {
145
140
  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}`)
141
+ const op: Record<string, unknown> = { type: 'exec_approval', id: approvalId, decision }
142
+ if (turnId) op.turn_id = turnId
143
+ console.log(`[Codex approval] enviando: ${JSON.stringify({ id: '...', op })}`)
148
144
  try {
149
- ps.proc.stdin!.write(JSON.stringify({
150
- jsonrpc: '2.0',
151
- id: msgId,
152
- result: { decision: codexDecision },
153
- }) + '\n')
145
+ ps.proc.stdin!.write(JSON.stringify({ id: randomUUID(), op }) + '\n')
154
146
  console.log(`[Codex approval] enviado ok`)
155
147
  } catch (e: any) {
156
148
  console.error(`[Codex approval] erro ao enviar: ${e.message}`)