@miphamai/cli 0.7.0 → 0.7.2
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/dist/mipham +0 -0
- package/package.json +1 -1
- package/src/core/engine.ts +4 -0
- package/src/core/permission.ts +3 -2
- package/src/providers/anthropic.ts +13 -1
- package/src/providers/openai-compat.ts +7 -8
package/dist/mipham
ADDED
|
Binary file
|
package/package.json
CHANGED
package/src/core/engine.ts
CHANGED
|
@@ -255,9 +255,11 @@ export class QueryEngine {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
// Add tool use + result to context
|
|
258
|
+
// DeepSeek V4 thinking mode requires reasoning_content on every assistant message
|
|
258
259
|
this.context.addMessage({
|
|
259
260
|
role: 'assistant',
|
|
260
261
|
content: [{ type: 'tool_use', id: toolUse.id, name: toolUse.name, input: toolUse.input }],
|
|
262
|
+
reasoning_content: '',
|
|
261
263
|
})
|
|
262
264
|
this.context.addMessage({
|
|
263
265
|
role: 'user',
|
|
@@ -403,9 +405,11 @@ export class QueryEngine {
|
|
|
403
405
|
content: result.content,
|
|
404
406
|
}
|
|
405
407
|
|
|
408
|
+
// DeepSeek V4 thinking mode requires reasoning_content on every assistant message
|
|
406
409
|
this.context.addMessage({
|
|
407
410
|
role: 'assistant',
|
|
408
411
|
content: [{ type: 'tool_use', id: toolUse.id, name: toolUse.name, input: toolUse.input }],
|
|
412
|
+
reasoning_content: '',
|
|
409
413
|
})
|
|
410
414
|
this.context.addMessage({
|
|
411
415
|
role: 'user',
|
package/src/core/permission.ts
CHANGED
|
@@ -170,8 +170,9 @@ export class PermissionSystem {
|
|
|
170
170
|
: 'ask'
|
|
171
171
|
|
|
172
172
|
case 'auto':
|
|
173
|
-
//
|
|
174
|
-
|
|
173
|
+
// Safety checks handled by hook layer (PreToolUse hooks).
|
|
174
|
+
// Bypass the static permission system so hooks are the sole gate.
|
|
175
|
+
return 'bypass'
|
|
175
176
|
|
|
176
177
|
case 'dontAsk':
|
|
177
178
|
// Only allowlisted tools free (already handled above); everything else requires approval
|
|
@@ -221,9 +221,16 @@ export class AnthropicProvider implements ProviderInstance {
|
|
|
221
221
|
if (msg.role === 'system') continue
|
|
222
222
|
|
|
223
223
|
if (typeof msg.content === 'string') {
|
|
224
|
+
const content: unknown[] = [{ type: 'text', text: msg.content }]
|
|
225
|
+
// DeepSeek V4 thinking mode via Anthropic endpoint: every assistant
|
|
226
|
+
// message must contain a thinking block if any message in history does.
|
|
227
|
+
if (msg.role === 'assistant') {
|
|
228
|
+
const thinkingText = (msg as any).reasoning_content || ''
|
|
229
|
+
content.unshift({ type: 'thinking', thinking: thinkingText })
|
|
230
|
+
}
|
|
224
231
|
result.push({
|
|
225
232
|
role: msg.role,
|
|
226
|
-
content
|
|
233
|
+
content,
|
|
227
234
|
})
|
|
228
235
|
} else {
|
|
229
236
|
const blocks = (msg.content as ContentBlock[]).map((block) => {
|
|
@@ -282,6 +289,11 @@ export class AnthropicProvider implements ProviderInstance {
|
|
|
282
289
|
}
|
|
283
290
|
})
|
|
284
291
|
|
|
292
|
+
// DeepSeek V4 thinking mode via Anthropic endpoint: every assistant
|
|
293
|
+
// message must contain a thinking block if any message in history does.
|
|
294
|
+
if (msg.role === 'assistant' && !blocks.some((b: any) => b.type === 'thinking')) {
|
|
295
|
+
blocks.unshift({ type: 'thinking', thinking: '' })
|
|
296
|
+
}
|
|
285
297
|
result.push({ role: msg.role, content: blocks })
|
|
286
298
|
}
|
|
287
299
|
}
|
|
@@ -190,9 +190,8 @@ export class OpenAICompatProvider implements ProviderInstance {
|
|
|
190
190
|
arguments: JSON.stringify(tu.input),
|
|
191
191
|
},
|
|
192
192
|
})),
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
combinedMsg.reasoning_content = msg.reasoning_content
|
|
193
|
+
// DeepSeek V4 thinking mode: every assistant message needs reasoning_content
|
|
194
|
+
reasoning_content: msg.reasoning_content || '',
|
|
196
195
|
}
|
|
197
196
|
result.push(combinedMsg)
|
|
198
197
|
i++ // skip the next message (consumed)
|
|
@@ -200,8 +199,9 @@ export class OpenAICompatProvider implements ProviderInstance {
|
|
|
200
199
|
}
|
|
201
200
|
|
|
202
201
|
const standaloneMsg: Record<string, unknown> = { role: msg.role, content: msg.content }
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
// DeepSeek V4 thinking mode: every assistant message needs reasoning_content
|
|
203
|
+
if (msg.role === 'assistant') {
|
|
204
|
+
standaloneMsg.reasoning_content = msg.reasoning_content || ''
|
|
205
205
|
}
|
|
206
206
|
result.push(standaloneMsg)
|
|
207
207
|
continue
|
|
@@ -232,9 +232,8 @@ export class OpenAICompatProvider implements ProviderInstance {
|
|
|
232
232
|
arguments: JSON.stringify(tu.input),
|
|
233
233
|
},
|
|
234
234
|
})),
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
toolUseMsg.reasoning_content = msg.reasoning_content
|
|
235
|
+
// DeepSeek V4 thinking mode: every assistant message needs reasoning_content
|
|
236
|
+
reasoning_content: msg.reasoning_content || '',
|
|
238
237
|
}
|
|
239
238
|
result.push(toolUseMsg)
|
|
240
239
|
continue
|