FEAT - OPS MCP: инструмент редактирования комментариев
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import type { AgentsRepository, AgentSessionRecord } from "../repositories/agents.js";
|
||||
import { TaskerClient } from "../tasker/client.js";
|
||||
import { executeMcpTool, getToolsForSession } from "./tool-runtime.js";
|
||||
|
||||
const session: AgentSessionRecord = {
|
||||
agent: {
|
||||
id: "agent-1",
|
||||
ownerUserId: "owner-1",
|
||||
ownerEmail: "owner@example.test",
|
||||
displayName: "Codex Agent",
|
||||
avatarUrl: null,
|
||||
status: "active",
|
||||
createdAt: "2026-08-06T00:00:00.000Z",
|
||||
updatedAt: "2026-08-06T00:00:00.000Z",
|
||||
},
|
||||
token: {
|
||||
id: "token-1",
|
||||
agentId: "agent-1",
|
||||
name: "test",
|
||||
status: "active",
|
||||
grantScope: "agent",
|
||||
tokenSuffix: "test",
|
||||
expiresAt: null,
|
||||
lastUsedAt: null,
|
||||
createdAt: "2026-08-06T00:00:00.000Z",
|
||||
},
|
||||
grants: [
|
||||
{
|
||||
id: "grant-1",
|
||||
agentId: "agent-1",
|
||||
workspaceSlug: "nodedc",
|
||||
projectId: "project-1",
|
||||
scopes: ["issue:comment"],
|
||||
mode: "voluntary",
|
||||
createdByUserId: "owner-1",
|
||||
createdAt: "2026-08-06T00:00:00.000Z",
|
||||
updatedAt: "2026-08-06T00:00:00.000Z",
|
||||
},
|
||||
],
|
||||
grantSource: "agent",
|
||||
};
|
||||
|
||||
test("tasker_update_comment is exposed and forwards the owned comment identity", async () => {
|
||||
const tool = getToolsForSession(session).find((candidate) => candidate.name === "tasker_update_comment");
|
||||
assert.ok(tool);
|
||||
assert.deepEqual(tool.inputSchema.required, ["issue_id", "project_id", "comment_id", "body"]);
|
||||
|
||||
const forwarded: unknown[] = [];
|
||||
const taskerClient = new TaskerClient({ baseUrl: "http://tasker.test", internalAccessToken: "test" });
|
||||
taskerClient.updateComment = async (...args) => {
|
||||
forwarded.push(args);
|
||||
return { ok: true, comment: { id: "comment-1", body: "updated" } };
|
||||
};
|
||||
|
||||
const agentsRepository = {
|
||||
claimIdempotencyKey: async () => ({ status: "claimed" as const }),
|
||||
completeIdempotencyKey: async () => undefined,
|
||||
releaseIdempotencyKey: async () => undefined,
|
||||
createAuditEvent: async () => undefined,
|
||||
} as unknown as AgentsRepository;
|
||||
|
||||
const result = await executeMcpTool(
|
||||
session,
|
||||
"tasker_update_comment",
|
||||
{
|
||||
issue_id: "issue-1",
|
||||
project_id: "project-1",
|
||||
workspace_slug: "nodedc",
|
||||
comment_id: "comment-1",
|
||||
body: "updated",
|
||||
idempotency_key: "comment-update-test-1",
|
||||
},
|
||||
{ agentsRepository, taskerClient }
|
||||
);
|
||||
|
||||
assert.deepEqual(forwarded, [
|
||||
[
|
||||
session,
|
||||
"issue-1",
|
||||
"comment-1",
|
||||
{ project_id: "project-1", workspace_slug: "nodedc", body: "updated" },
|
||||
],
|
||||
]);
|
||||
assert.deepEqual(result.structuredContent, { ok: true, comment: { id: "comment-1", body: "updated" } });
|
||||
});
|
||||
Reference in New Issue
Block a user