cliclaw 1.0.15 → 1.0.16

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.15",
3
+ "version": "1.0.16",
4
4
  "description": "Telegram bot bridging AI CLIs (Claude Code, Codex) to Forum Topics",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -16,22 +16,21 @@ const BASE_ENV = {
16
16
  }
17
17
 
18
18
  function extractTextFromObj(obj: any): string | null {
19
- // Format 1: item.completed with agent_message
19
+ // New codex format: {"id":"...","msg":{"type":"agent_message","text":"..."}}
20
+ if (obj.msg?.type === 'agent_message' && obj.msg?.text) return obj.msg.text
21
+ // Old format: item.completed with agent_message
20
22
  if (obj.type === 'item.completed' && obj.item?.type === 'agent_message' && obj.item?.text)
21
23
  return obj.item.text
22
- // Format 2: response.output_item.done with message content array
24
+ // OpenAI Responses API: response.output_item.done with message content array
23
25
  if (obj.item?.type === 'message' && Array.isArray(obj.item?.content)) {
24
26
  const parts = obj.item.content
25
27
  .filter((c: any) => c.type === 'output_text' && c.text)
26
28
  .map((c: any) => c.text)
27
29
  if (parts.length > 0) return parts.join('')
28
30
  }
29
- // Format 3: top-level result/output/text
31
+ // Fallback: top-level result/output
30
32
  if (typeof obj.result === 'string' && obj.result) return obj.result
31
33
  if (typeof obj.output === 'string' && obj.output) return obj.output
32
- if (typeof obj.text === 'string' && obj.text && obj.type !== 'thread.started') return obj.text
33
- // Format 4: message with content string
34
- if (obj.type === 'message' && typeof obj.content === 'string' && obj.content) return obj.content
35
34
  return null
36
35
  }
37
36
 
@@ -102,12 +101,10 @@ export async function askCodex(
102
101
  onNewThreadId?: (id: string) => void
103
102
  ): Promise<{ text: string; usage?: TokenUsage }> {
104
103
  try {
105
- const codexThreadId = session.codexThreadId
106
- const args = codexThreadId
107
- ? ['exec', 'resume', codexThreadId, '--dangerously-bypass-approvals-and-sandbox', '--skip-git-repo-check', '--json', userMessage]
108
- : ['exec', '--dangerously-bypass-approvals-and-sandbox', '--skip-git-repo-check', '--json', userMessage]
104
+ // Always start fresh — codex exec resume <id> <message> rejects the message as unexpected arg
105
+ const args = ['exec', '--dangerously-bypass-approvals-and-sandbox', '--skip-git-repo-check', '--json', userMessage]
109
106
  const { text, threadId, usage } = await spawnCodex(args)
110
- if (threadId && !codexThreadId) onNewThreadId?.(threadId)
107
+ if (threadId && !session.codexThreadId) onNewThreadId?.(threadId)
111
108
  return { text, usage }
112
109
  } catch (err: any) {
113
110
  return { text: `❌ Codex error: ${err.message}` }