mirror of
https://github.com/musistudio/claude-code-router.git
synced 2026-02-19 15:10:49 +08:00
fix image agent error
This commit is contained in:
@@ -102,21 +102,30 @@ export class ImageAgent implements IAgent {
|
|||||||
"required": ["imageId", "task"]
|
"required": ["imageId", "task"]
|
||||||
},
|
},
|
||||||
handler: async (args, context) => {
|
handler: async (args, context) => {
|
||||||
console.log('args', JSON.stringify(args, null, 2))
|
|
||||||
const imageMessages = [];
|
const imageMessages = [];
|
||||||
let imageId;
|
let imageId;
|
||||||
|
|
||||||
// Create image messages from cached images
|
// Create image messages from cached images
|
||||||
if (args.imageId && Array.isArray(args.imageId)) {
|
if (args.imageId) {
|
||||||
args.imageId.forEach((imgId: string) => {
|
if (Array.isArray(args.imageId)) {
|
||||||
const image = imageCache.getImage(`${context.req.id}_Image#${imgId}`);
|
args.imageId.forEach((imgId: string) => {
|
||||||
|
const image = imageCache.getImage(`${context.req.id}_Image#${imgId}`);
|
||||||
|
if (image) {
|
||||||
|
imageMessages.push({
|
||||||
|
type: "image",
|
||||||
|
source: image,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const image = imageCache.getImage(`${context.req.id}_Image#${args.imageId}`);
|
||||||
if (image) {
|
if (image) {
|
||||||
imageMessages.push({
|
imageMessages.push({
|
||||||
type: "image",
|
type: "image",
|
||||||
source: image,
|
source: image,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
imageId = args.imageId;
|
imageId = args.imageId;
|
||||||
delete args.imageId;
|
delete args.imageId;
|
||||||
}
|
}
|
||||||
@@ -155,7 +164,6 @@ Always ensure that your response reflects a clear, accurate interpretation of th
|
|||||||
}).then(res => res.json()).catch(err => {
|
}).then(res => res.json()).catch(err => {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
console.log(agentResponse.content);
|
|
||||||
if (!agentResponse || !agentResponse.content) {
|
if (!agentResponse || !agentResponse.content) {
|
||||||
return 'analyzeImage Error';
|
return 'analyzeImage Error';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ async function run(options: RunOptions = {}) {
|
|||||||
req,
|
req,
|
||||||
config
|
config
|
||||||
});
|
});
|
||||||
console.log('result', toolResult)
|
|
||||||
toolMessages.push({
|
toolMessages.push({
|
||||||
"tool_use_id": currentToolId,
|
"tool_use_id": currentToolId,
|
||||||
"type": "tool_result",
|
"type": "tool_result",
|
||||||
@@ -318,7 +317,6 @@ async function run(options: RunOptions = {}) {
|
|||||||
|
|
||||||
// 处理流提前关闭的错误
|
// 处理流提前关闭的错误
|
||||||
if (error.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
if (error.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||||
console.log('Stream prematurely closed, aborting operations');
|
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -368,7 +366,6 @@ async function run(options: RunOptions = {}) {
|
|||||||
done(null, payload)
|
done(null, payload)
|
||||||
});
|
});
|
||||||
server.addHook("onSend", async (req, reply, payload) => {
|
server.addHook("onSend", async (req, reply, payload) => {
|
||||||
console.log('主应用onSend')
|
|
||||||
event.emit('onSend', req, reply, payload);
|
event.emit('onSend', req, reply, payload);
|
||||||
return payload;
|
return payload;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -502,7 +502,6 @@ export function LogViewer({ open, onOpenChange, showToast }: LogViewerProps) {
|
|||||||
// 如果在分组模式且选中了具体请求,显示该请求的日志
|
// 如果在分组模式且选中了具体请求,显示该请求的日志
|
||||||
if (groupByReqId && groupedLogs && selectedReqId && groupedLogs.groups[selectedReqId]) {
|
if (groupByReqId && groupedLogs && selectedReqId && groupedLogs.groups[selectedReqId]) {
|
||||||
const requestLogs = groupedLogs.groups[selectedReqId];
|
const requestLogs = groupedLogs.groups[selectedReqId];
|
||||||
console.log(requestLogs)
|
|
||||||
// 提取原始JSON字符串并每行一个
|
// 提取原始JSON字符串并每行一个
|
||||||
return requestLogs.map(log => JSON.stringify(log)).join('\n');
|
return requestLogs.map(log => JSON.stringify(log)).join('\n');
|
||||||
}
|
}
|
||||||
@@ -552,7 +551,7 @@ export function LogViewer({ open, onOpenChange, showToast }: LogViewerProps) {
|
|||||||
const handleDebugClick = (lineNumber: number) => {
|
const handleDebugClick = (lineNumber: number) => {
|
||||||
console.log('handleDebugClick called with lineNumber:', lineNumber);
|
console.log('handleDebugClick called with lineNumber:', lineNumber);
|
||||||
console.log('Current state:', { groupByReqId, selectedReqId, logsLength: logs.length });
|
console.log('Current state:', { groupByReqId, selectedReqId, logsLength: logs.length });
|
||||||
|
|
||||||
let logData = null;
|
let logData = null;
|
||||||
|
|
||||||
if (groupByReqId && groupedLogs && selectedReqId && groupedLogs.groups[selectedReqId]) {
|
if (groupByReqId && groupedLogs && selectedReqId && groupedLogs.groups[selectedReqId]) {
|
||||||
@@ -631,16 +630,16 @@ export function LogViewer({ open, onOpenChange, showToast }: LogViewerProps) {
|
|||||||
glyphMarginLeft: e.target.detail?.glyphMarginLeft,
|
glyphMarginLeft: e.target.detail?.glyphMarginLeft,
|
||||||
glyphMarginWidth: e.target.detail?.glyphMarginWidth
|
glyphMarginWidth: e.target.detail?.glyphMarginWidth
|
||||||
});
|
});
|
||||||
|
|
||||||
// 检查是否点击在glyph margin区域
|
// 检查是否点击在glyph margin区域
|
||||||
const isGlyphMarginClick = e.target.detail &&
|
const isGlyphMarginClick = e.target.detail &&
|
||||||
e.target.detail.glyphMarginLane !== undefined &&
|
e.target.detail.glyphMarginLane !== undefined &&
|
||||||
e.target.detail.offsetX !== undefined &&
|
e.target.detail.offsetX !== undefined &&
|
||||||
e.target.detail.offsetX <= e.target.detail.glyphMarginLeft + e.target.detail.glyphMarginWidth;
|
e.target.detail.offsetX <= e.target.detail.glyphMarginLeft + e.target.detail.glyphMarginWidth;
|
||||||
|
|
||||||
console.log('Is glyph margin click:', isGlyphMarginClick);
|
console.log('Is glyph margin click:', isGlyphMarginClick);
|
||||||
|
|
||||||
if (e.target.position && isGlyphMarginClick) {
|
if (e.target.position && isGlyphMarginClick) {
|
||||||
const finalRequestLines = getFinalRequestLines();
|
const finalRequestLines = getFinalRequestLines();
|
||||||
console.log('Final request lines:', finalRequestLines);
|
console.log('Final request lines:', finalRequestLines);
|
||||||
console.log('Clicked line number:', e.target.position.lineNumber);
|
console.log('Clicked line number:', e.target.position.lineNumber);
|
||||||
|
|||||||
Reference in New Issue
Block a user