mirror of
https://github.com/BradGroux/veritas-kanban.git
synced 2026-12-03 19:27:18 +00:00
Some checks are pending
CI / Lint & Type Check (push) Waiting to run
CI / Changed Tests (push) Waiting to run
CI / Workspace Unit Tests (push) Waiting to run
CI / Build (push) Waiting to run
CI / Security Audit (push) Waiting to run
Desktop Artifacts / Unsigned macOS Artifact (push) Waiting to run
Desktop Artifacts / Unsigned Linux Artifacts (push) Waiting to run
Desktop Artifacts / Unsigned Windows Artifacts (push) Waiting to run
* feat: add run-scoped tool control plane (#857) * test: align provider capability fixtures
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
vi.mock('../utils/api.js', () => ({ api: vi.fn() }));
|
|
|
|
import { api } from '../utils/api.js';
|
|
import { handleToolControlPlaneTool, toolControlPlaneTools } from '../tools/tool-control-plane.js';
|
|
|
|
const apiMock = vi.mocked(api);
|
|
|
|
describe('MCP run-scoped tool control plane', () => {
|
|
beforeEach(() => apiMock.mockReset());
|
|
|
|
it('publishes discovery, catalog, and mediated call tools', () => {
|
|
expect(toolControlPlaneTools.map((tool) => tool.name)).toEqual([
|
|
'list_tool_servers',
|
|
'discover_tool_server',
|
|
'get_run_tool_catalog',
|
|
'call_run_tool',
|
|
]);
|
|
});
|
|
|
|
it('forwards an exact run-bound tool call without changing provenance', async () => {
|
|
apiMock.mockResolvedValue({
|
|
serverId: 'veritas',
|
|
tool: 'get_task',
|
|
operationId: 'operation-1',
|
|
isError: false,
|
|
eventId: 'event-1',
|
|
});
|
|
await handleToolControlPlaneTool('call_run_tool', {
|
|
taskId: 'task-1',
|
|
attemptId: 'attempt-1',
|
|
serverId: 'veritas',
|
|
tool: 'get_task',
|
|
arguments: { id: 'task-2' },
|
|
operationId: 'operation-1',
|
|
approvalId: 'approval-1',
|
|
});
|
|
expect(apiMock).toHaveBeenCalledWith('/api/tool-servers/call', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
taskId: 'task-1',
|
|
attemptId: 'attempt-1',
|
|
serverId: 'veritas',
|
|
tool: 'get_task',
|
|
arguments: { id: 'task-2' },
|
|
operationId: 'operation-1',
|
|
approvalId: 'approval-1',
|
|
}),
|
|
});
|
|
});
|
|
|
|
it('rejects incomplete mediated calls before the API boundary', async () => {
|
|
await expect(
|
|
handleToolControlPlaneTool('call_run_tool', {
|
|
taskId: 'task-1',
|
|
attemptId: 'attempt-1',
|
|
serverId: 'veritas',
|
|
tool: 'get_task',
|
|
})
|
|
).rejects.toThrow();
|
|
expect(apiMock).not.toHaveBeenCalled();
|
|
});
|
|
});
|