Первая версия
This commit is contained in:
35
src/core/ChatClientMock.js
Normal file
35
src/core/ChatClientMock.js
Normal file
@@ -0,0 +1,35 @@
|
||||
export class ChatClientMock {
|
||||
async sendMessage(payload) {
|
||||
const taskId = `task-${Date.now()}`;
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
const text = payload.message.trim();
|
||||
|
||||
if (text.startsWith("/changeset")) {
|
||||
const raw = text.slice("/changeset".length).trim();
|
||||
const parsed = JSON.parse(raw);
|
||||
return { task_id: taskId, status: "done", result_type: "changeset", changeset: parsed.changeset || [] };
|
||||
}
|
||||
|
||||
if (text.startsWith("/demo-update ")) {
|
||||
const path = text.replace("/demo-update ", "").trim();
|
||||
const file = payload.files.find((f) => f.path === path);
|
||||
if (!file) {
|
||||
return { task_id: taskId, status: "done", result_type: "answer", answer: `Файл ${path} не найден.` };
|
||||
}
|
||||
const proposed = `${file.content}\n// demo update from mock agent\n`;
|
||||
return {
|
||||
task_id: taskId,
|
||||
status: "done",
|
||||
result_type: "changeset",
|
||||
changeset: [{ op: "update", path, base_hash: file.content_hash, proposed_content: proposed, reason: "Demo change" }]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
task_id: taskId,
|
||||
status: "done",
|
||||
result_type: "answer",
|
||||
answer: "Mock-агент активен. Используйте /changeset {json} или /demo-update <path>."
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user