cliclaw 1.0.38 → 1.0.40

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.38",
3
+ "version": "1.0.40",
4
4
  "description": "Telegram bot bridging AI CLIs (Claude Code, Codex) to Forum Topics",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -130,18 +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
139
  const respond = (decision: string) => {
138
140
  if (decision === 'approved_for_session') ps.sessionApproved = true
139
- console.log(`[Codex approval] enviando exec_approval sub_id=${subId} decision=${decision}`)
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 })}`)
140
144
  try {
141
- ps.proc.stdin!.write(JSON.stringify({
142
- id: randomUUID(),
143
- op: { type: 'exec_approval', id: subId, decision },
144
- }) + '\n')
145
+ ps.proc.stdin!.write(JSON.stringify({ id: randomUUID(), op }) + '\n')
145
146
  console.log(`[Codex approval] enviado ok`)
146
147
  } catch (e: any) {
147
148
  console.error(`[Codex approval] erro ao enviar: ${e.message}`)
@@ -157,7 +158,7 @@ function handleProtoEvent(ps: ProtoSession, obj: any) {
157
158
 
158
159
  if (ps.approvalHandler) {
159
160
  console.log(`[Codex approval] aguardando usuário via Telegram...`)
160
- ps.approvalHandler(subId, commandStr)
161
+ ps.approvalHandler(approvalId, commandStr)
161
162
  .then(respond)
162
163
  .catch((e: any) => {
163
164
  console.error(`[Codex approval] handler error: ${e?.message} — negando`)