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.
- package/package.json +1 -1
- package/src/agents/codex.ts +16 -10
package/package.json
CHANGED
package/src/agents/codex.ts
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
146
|
-
|
|
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) {
|