@agledger/mcp-server 1.5.0 → 2.0.0

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.
Files changed (66) hide show
  1. package/dist/api-client.d.ts +16 -0
  2. package/dist/api-client.d.ts.map +1 -0
  3. package/dist/api-client.js +52 -0
  4. package/dist/api-client.js.map +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +17 -58
  7. package/dist/index.js.map +1 -1
  8. package/dist/server.d.ts +2 -13
  9. package/dist/server.d.ts.map +1 -1
  10. package/dist/server.js +113 -109
  11. package/dist/server.js.map +1 -1
  12. package/package.json +2 -3
  13. package/src/api-client.ts +72 -0
  14. package/src/index.ts +27 -60
  15. package/src/server.ts +136 -120
  16. package/tests/api-client.test.ts +147 -0
  17. package/tests/harness.ts +8 -35
  18. package/tests/integration.test.ts +373 -0
  19. package/tests/server.test.ts +286 -0
  20. package/src/enums.ts +0 -47
  21. package/src/errors.ts +0 -44
  22. package/src/resources/contract-types.ts +0 -130
  23. package/src/tool-scopes.ts +0 -180
  24. package/src/tools/a2a.ts +0 -430
  25. package/src/tools/agent-mandates.ts +0 -259
  26. package/src/tools/agents-refs.ts +0 -232
  27. package/src/tools/capabilities.ts +0 -63
  28. package/src/tools/compliance.ts +0 -70
  29. package/src/tools/dashboard.ts +0 -64
  30. package/src/tools/disputes.ts +0 -121
  31. package/src/tools/enterprises.ts +0 -203
  32. package/src/tools/events.ts +0 -33
  33. package/src/tools/federation-admin.ts +0 -665
  34. package/src/tools/federation.ts +0 -587
  35. package/src/tools/health.ts +0 -30
  36. package/src/tools/mandates.ts +0 -264
  37. package/src/tools/openclaw.ts +0 -122
  38. package/src/tools/receipts.ts +0 -134
  39. package/src/tools/reputation.ts +0 -69
  40. package/src/tools/schemas.ts +0 -535
  41. package/src/tools/verification-keys.ts +0 -33
  42. package/src/tools/verification.ts +0 -59
  43. package/tests/conformance.test.ts +0 -197
  44. package/tests/conformance.ts +0 -65
  45. package/tests/mock-client.ts +0 -71
  46. package/tests/profiles.test.ts +0 -120
  47. package/tests/resources/contract-types.test.ts +0 -82
  48. package/tests/tools/a2a.test.ts +0 -213
  49. package/tests/tools/agent-mandates.test.ts +0 -196
  50. package/tests/tools/agents-refs.test.ts +0 -190
  51. package/tests/tools/capabilities.test.ts +0 -80
  52. package/tests/tools/compliance.test.ts +0 -123
  53. package/tests/tools/dashboard.test.ts +0 -111
  54. package/tests/tools/disputes.test.ts +0 -123
  55. package/tests/tools/enterprises.test.ts +0 -171
  56. package/tests/tools/events.test.ts +0 -56
  57. package/tests/tools/federation-admin.test.ts +0 -468
  58. package/tests/tools/federation.test.ts +0 -522
  59. package/tests/tools/health.test.ts +0 -56
  60. package/tests/tools/mandates.test.ts +0 -143
  61. package/tests/tools/openclaw.test.ts +0 -148
  62. package/tests/tools/receipts.test.ts +0 -157
  63. package/tests/tools/reputation.test.ts +0 -108
  64. package/tests/tools/schemas.test.ts +0 -374
  65. package/tests/tools/verification-keys.test.ts +0 -56
  66. package/tests/tools/verification.test.ts +0 -64
@@ -1,123 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerComplianceTools } from '../../src/tools/compliance.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- describe('compliance tools', () => {
7
- let harness: TestHarness;
8
-
9
- beforeAll(async () => {
10
- harness = await createTestHarness({
11
- registerFns: [registerComplianceTools],
12
- mockOverrides: {
13
- compliance: {
14
- createRecord: vi.fn().mockResolvedValue({
15
- id: 'cr-001',
16
- mandateId: 'm-001',
17
- recordType: 'workplace_notification',
18
- attestedBy: 'compliance-officer',
19
- }),
20
- listRecords: vi.fn().mockResolvedValue({
21
- data: [
22
- { id: 'cr-001', recordType: 'workplace_notification' },
23
- { id: 'cr-002', recordType: 'affected_persons' },
24
- ],
25
- }),
26
- getEuAiActReport: vi.fn().mockResolvedValue({
27
- summary: {
28
- highRiskCount: 3,
29
- auditedCount: 2,
30
- },
31
- }),
32
- },
33
- },
34
- });
35
- });
36
-
37
- afterAll(async () => {
38
- await harness.cleanup();
39
- });
40
-
41
- it('registers exactly 3 tools', async () => {
42
- const { tools } = await harness.client.listTools();
43
- expect(tools.map((t: any) => t.name).sort()).toEqual([
44
- 'create_compliance_record',
45
- 'get_eu_ai_act_report',
46
- 'list_compliance_records',
47
- ]);
48
- });
49
-
50
- describe('create_compliance_record', () => {
51
- it('creates a compliance record on success', async () => {
52
- const result = await harness.client.callTool({
53
- name: 'create_compliance_record',
54
- arguments: {
55
- mandateId: 'm-001',
56
- recordType: 'workplace_notification',
57
- attestation: { notified: true },
58
- attestedBy: 'compliance-officer',
59
- },
60
- });
61
- assertSuccessResult(result as any);
62
- expect((harness.mockSdk.compliance as any).createRecord).toHaveBeenCalledWith('m-001', {
63
- recordType: 'workplace_notification',
64
- attestation: { notified: true },
65
- attestedBy: 'compliance-officer',
66
- });
67
- });
68
-
69
- it('returns error on failure', async () => {
70
- (harness.mockSdk.compliance as any).createRecord.mockRejectedValueOnce(new Error('Mandate not found'));
71
- const result = await harness.client.callTool({
72
- name: 'create_compliance_record',
73
- arguments: {
74
- mandateId: 'm-missing',
75
- recordType: 'workplace_notification',
76
- attestation: {},
77
- attestedBy: 'test',
78
- },
79
- });
80
- assertErrorResult(result as any);
81
- });
82
- });
83
-
84
- describe('list_compliance_records', () => {
85
- it('lists records on success', async () => {
86
- const result = await harness.client.callTool({
87
- name: 'list_compliance_records',
88
- arguments: { mandateId: 'm-001' },
89
- });
90
- assertSuccessResult(result as any);
91
- expect((harness.mockSdk.compliance as any).listRecords).toHaveBeenCalledWith('m-001', { limit: undefined });
92
- });
93
-
94
- it('returns error on failure', async () => {
95
- (harness.mockSdk.compliance as any).listRecords.mockRejectedValueOnce(new Error('Forbidden'));
96
- const result = await harness.client.callTool({
97
- name: 'list_compliance_records',
98
- arguments: { mandateId: 'm-001' },
99
- });
100
- assertErrorResult(result as any);
101
- });
102
- });
103
-
104
- describe('get_eu_ai_act_report', () => {
105
- it('returns EU AI Act report on success', async () => {
106
- const result = await harness.client.callTool({
107
- name: 'get_eu_ai_act_report',
108
- arguments: {},
109
- });
110
- assertSuccessResult(result as any);
111
- expect((harness.mockSdk.compliance as any).getEuAiActReport).toHaveBeenCalledOnce();
112
- });
113
-
114
- it('returns error on failure', async () => {
115
- (harness.mockSdk.compliance as any).getEuAiActReport.mockRejectedValueOnce(new Error('Service unavailable'));
116
- const result = await harness.client.callTool({
117
- name: 'get_eu_ai_act_report',
118
- arguments: {},
119
- });
120
- assertErrorResult(result as any);
121
- });
122
- });
123
- });
@@ -1,111 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerDashboardTools } from '../../src/tools/dashboard.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- describe('dashboard tools', () => {
7
- let harness: TestHarness;
8
-
9
- beforeAll(async () => {
10
- harness = await createTestHarness({
11
- registerFns: [registerDashboardTools],
12
- mockOverrides: {
13
- dashboard: {
14
- getSummary: vi.fn().mockResolvedValue({
15
- totalMandates: 150,
16
- activeCount: 42,
17
- fulfilledCount: 98,
18
- }),
19
- getMetrics: vi.fn().mockResolvedValue({
20
- series: [
21
- { date: '2026-04-01', mandates: 10 },
22
- { date: '2026-04-02', mandates: 15 },
23
- ],
24
- }),
25
- getAlerts: vi.fn().mockResolvedValue({
26
- data: [
27
- { type: 'overdue', mandateId: 'm-001' },
28
- ],
29
- }),
30
- },
31
- },
32
- });
33
- });
34
-
35
- afterAll(async () => {
36
- await harness.cleanup();
37
- });
38
-
39
- it('registers exactly 3 tools', async () => {
40
- const { tools } = await harness.client.listTools();
41
- expect(tools.map((t: any) => t.name).sort()).toEqual([
42
- 'get_dashboard_alerts',
43
- 'get_dashboard_metrics',
44
- 'get_dashboard_summary',
45
- ]);
46
- });
47
-
48
- describe('get_dashboard_summary', () => {
49
- it('returns summary on success', async () => {
50
- const result = await harness.client.callTool({
51
- name: 'get_dashboard_summary',
52
- arguments: {},
53
- });
54
- assertSuccessResult(result as any);
55
- expect((harness.mockSdk.dashboard as any).getSummary).toHaveBeenCalledOnce();
56
- });
57
-
58
- it('returns error on failure', async () => {
59
- (harness.mockSdk.dashboard as any).getSummary.mockRejectedValueOnce(new Error('Unauthorized'));
60
- const result = await harness.client.callTool({
61
- name: 'get_dashboard_summary',
62
- arguments: {},
63
- });
64
- assertErrorResult(result as any);
65
- });
66
- });
67
-
68
- describe('get_dashboard_metrics', () => {
69
- it('returns metrics on success', async () => {
70
- const result = await harness.client.callTool({
71
- name: 'get_dashboard_metrics',
72
- arguments: { from: '2026-04-01', to: '2026-04-07', granularity: 'daily' },
73
- });
74
- assertSuccessResult(result as any);
75
- expect((harness.mockSdk.dashboard as any).getMetrics).toHaveBeenCalledWith({
76
- from: '2026-04-01',
77
- to: '2026-04-07',
78
- granularity: 'daily',
79
- });
80
- });
81
-
82
- it('returns error on failure', async () => {
83
- (harness.mockSdk.dashboard as any).getMetrics.mockRejectedValueOnce(new Error('Bad date range'));
84
- const result = await harness.client.callTool({
85
- name: 'get_dashboard_metrics',
86
- arguments: {},
87
- });
88
- assertErrorResult(result as any);
89
- });
90
- });
91
-
92
- describe('get_dashboard_alerts', () => {
93
- it('returns alerts on success', async () => {
94
- const result = await harness.client.callTool({
95
- name: 'get_dashboard_alerts',
96
- arguments: {},
97
- });
98
- assertSuccessResult(result as any);
99
- expect((harness.mockSdk.dashboard as any).getAlerts).toHaveBeenCalled();
100
- });
101
-
102
- it('returns error on failure', async () => {
103
- (harness.mockSdk.dashboard as any).getAlerts.mockRejectedValueOnce(new Error('Internal error'));
104
- const result = await harness.client.callTool({
105
- name: 'get_dashboard_alerts',
106
- arguments: {},
107
- });
108
- assertErrorResult(result as any);
109
- });
110
- });
111
- });
@@ -1,123 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerDisputeTools } from '../../src/tools/disputes.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- const MOCK_DISPUTE = {
7
- id: 'd-1',
8
- mandateId: 'm-1',
9
- receiptId: 'r-1',
10
- status: 'OPENED',
11
- reason: 'pricing_dispute',
12
- grounds: 'pricing_dispute',
13
- evidence: null,
14
- currentTier: 1,
15
- tierHistory: null,
16
- resolution: null,
17
- amount: null,
18
- createdAt: '2026-04-13T00:00:00Z',
19
- updatedAt: null,
20
- resolvedAt: null,
21
- };
22
-
23
- describe('dispute tools', () => {
24
- let harness: TestHarness;
25
-
26
- const EXPECTED_TOOLS = [
27
- 'create_dispute', 'escalate_dispute', 'get_dispute', 'submit_dispute_evidence',
28
- ];
29
-
30
- beforeAll(async () => {
31
- harness = await createTestHarness({
32
- registerFns: [registerDisputeTools],
33
- mockOverrides: {
34
- disputes: {
35
- create: vi.fn().mockResolvedValue(MOCK_DISPUTE),
36
- get: vi.fn().mockResolvedValue({ dispute: MOCK_DISPUTE, evidence: [] }),
37
- escalate: vi.fn().mockResolvedValue({ ...MOCK_DISPUTE, currentTier: 2, status: 'TIER_2_REVIEW' }),
38
- submitEvidence: vi.fn().mockResolvedValue({ id: 'ev-1', evidenceType: 'document' }),
39
- },
40
- },
41
- });
42
- });
43
-
44
- afterAll(async () => { await harness.cleanup(); });
45
-
46
- it('registers exactly 4 tools', async () => {
47
- const { tools } = await harness.client.listTools();
48
- expect(tools.map((t: any) => t.name).sort()).toEqual(EXPECTED_TOOLS);
49
- });
50
-
51
- describe('create_dispute', () => {
52
- it('opens a dispute', async () => {
53
- const result = await harness.client.callTool({
54
- name: 'create_dispute',
55
- arguments: { mandateId: 'm-1', grounds: 'pricing_dispute' },
56
- });
57
- assertSuccessResult(result as any);
58
- });
59
-
60
- it('returns error on failure', async () => {
61
- (harness.mockSdk.disputes as any).create.mockRejectedValueOnce(new Error('No receipt'));
62
- const result = await harness.client.callTool({
63
- name: 'create_dispute',
64
- arguments: { mandateId: 'bad', grounds: 'pricing_dispute' },
65
- });
66
- assertErrorResult(result as any);
67
- });
68
- });
69
-
70
- describe('get_dispute', () => {
71
- it('returns dispute details', async () => {
72
- const result = await harness.client.callTool({ name: 'get_dispute', arguments: { mandateId: 'm-1' } });
73
- assertSuccessResult(result as any);
74
- expect((harness.mockSdk.disputes as any).get).toHaveBeenCalledWith('m-1');
75
- });
76
-
77
- it('returns error on failure', async () => {
78
- (harness.mockSdk.disputes as any).get.mockRejectedValueOnce(new Error('Not found'));
79
- const result = await harness.client.callTool({ name: 'get_dispute', arguments: { mandateId: 'bad' } });
80
- assertErrorResult(result as any);
81
- });
82
- });
83
-
84
- describe('escalate_dispute', () => {
85
- it('escalates to next tier', async () => {
86
- const result = await harness.client.callTool({ name: 'escalate_dispute', arguments: { mandateId: 'm-1' } });
87
- assertSuccessResult(result as any);
88
- });
89
-
90
- it('returns error on failure', async () => {
91
- (harness.mockSdk.disputes as any).escalate.mockRejectedValueOnce(new Error('Already at max tier'));
92
- const result = await harness.client.callTool({ name: 'escalate_dispute', arguments: { mandateId: 'bad' } });
93
- assertErrorResult(result as any);
94
- });
95
- });
96
-
97
- describe('submit_dispute_evidence', () => {
98
- it('submits evidence', async () => {
99
- const result = await harness.client.callTool({
100
- name: 'submit_dispute_evidence',
101
- arguments: {
102
- mandateId: 'm-1',
103
- evidenceType: 'document',
104
- payload: { url: 'https://example.com/doc.pdf' },
105
- },
106
- });
107
- assertSuccessResult(result as any);
108
- });
109
-
110
- it('returns error on failure', async () => {
111
- (harness.mockSdk.disputes as any).submitEvidence.mockRejectedValueOnce(new Error('Dispute closed'));
112
- const result = await harness.client.callTool({
113
- name: 'submit_dispute_evidence',
114
- arguments: {
115
- mandateId: 'bad',
116
- evidenceType: 'screenshot',
117
- payload: {},
118
- },
119
- });
120
- assertErrorResult(result as any);
121
- });
122
- });
123
- });
@@ -1,171 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerEnterpriseTools } from '../../src/tools/enterprises.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- const MOCK_ENTERPRISE = {
7
- id: 'ent-1',
8
- name: 'Acme Corp',
9
- slug: 'acme-corp',
10
- trustLevel: 'active',
11
- createdAt: '2026-04-13T00:00:00Z',
12
- };
13
-
14
- const MOCK_AGENT = {
15
- id: 'agent-1',
16
- displayName: 'Data Processor',
17
- slug: 'data-processor',
18
- trustLevel: 'sandbox',
19
- createdAt: '2026-04-13T00:00:00Z',
20
- };
21
-
22
- describe('enterprise tools', () => {
23
- let harness: TestHarness;
24
-
25
- const EXPECTED_TOOLS = [
26
- 'approve_enterprise_agent', 'create_agent', 'create_enterprise',
27
- 'list_enterprise_agents', 'revoke_enterprise_agent', 'set_enterprise_config',
28
- ];
29
-
30
- beforeAll(async () => {
31
- harness = await createTestHarness({
32
- registerFns: [registerEnterpriseTools],
33
- mockOverrides: {
34
- enterprises: {
35
- approveAgent: vi.fn().mockResolvedValue({ agentId: 'agent-1', enterpriseId: 'e-1', status: 'approved' }),
36
- revokeAgent: vi.fn().mockResolvedValue(undefined),
37
- listAgents: vi.fn().mockResolvedValue({ data: [{ agentId: 'agent-1', status: 'approved' }] }),
38
- },
39
- admin: {
40
- createEnterprise: vi.fn().mockResolvedValue(MOCK_ENTERPRISE),
41
- createAgent: vi.fn().mockResolvedValue(MOCK_AGENT),
42
- setEnterpriseConfig: vi.fn().mockResolvedValue({ enterpriseId: 'ent-1', config: {} }),
43
- },
44
- },
45
- });
46
- });
47
-
48
- afterAll(async () => { await harness.cleanup(); });
49
-
50
- it('registers exactly 6 tools', async () => {
51
- const { tools } = await harness.client.listTools();
52
- expect(tools.map((t: any) => t.name).sort()).toEqual(EXPECTED_TOOLS);
53
- });
54
-
55
- describe('approve_enterprise_agent', () => {
56
- it('approves an agent', async () => {
57
- const result = await harness.client.callTool({
58
- name: 'approve_enterprise_agent',
59
- arguments: { enterpriseId: 'ent-1', agentId: 'agent-1' },
60
- });
61
- assertSuccessResult(result as any);
62
- });
63
-
64
- it('returns error on failure', async () => {
65
- (harness.mockSdk.enterprises as any).approveAgent.mockRejectedValueOnce(new Error('Not found'));
66
- const result = await harness.client.callTool({
67
- name: 'approve_enterprise_agent',
68
- arguments: { enterpriseId: 'bad', agentId: 'bad' },
69
- });
70
- assertErrorResult(result as any);
71
- });
72
- });
73
-
74
- describe('revoke_enterprise_agent', () => {
75
- it('revokes an agent', async () => {
76
- const result = await harness.client.callTool({
77
- name: 'revoke_enterprise_agent',
78
- arguments: { enterpriseId: 'ent-1', agentId: 'agent-1', reason: 'No longer needed' },
79
- });
80
- assertSuccessResult(result as any);
81
- });
82
-
83
- it('returns error on failure', async () => {
84
- (harness.mockSdk.enterprises as any).revokeAgent.mockRejectedValueOnce(new Error('Not found'));
85
- const result = await harness.client.callTool({
86
- name: 'revoke_enterprise_agent',
87
- arguments: { enterpriseId: 'bad', agentId: 'bad' },
88
- });
89
- assertErrorResult(result as any);
90
- });
91
- });
92
-
93
- describe('list_enterprise_agents', () => {
94
- it('returns agent list', async () => {
95
- const result = await harness.client.callTool({
96
- name: 'list_enterprise_agents',
97
- arguments: { enterpriseId: 'ent-1' },
98
- });
99
- assertSuccessResult(result as any);
100
- });
101
-
102
- it('returns error on failure', async () => {
103
- (harness.mockSdk.enterprises as any).listAgents.mockRejectedValueOnce(new Error('Unauthorized'));
104
- const result = await harness.client.callTool({
105
- name: 'list_enterprise_agents',
106
- arguments: { enterpriseId: 'bad' },
107
- });
108
- assertErrorResult(result as any);
109
- });
110
- });
111
-
112
- describe('create_enterprise', () => {
113
- it('creates an enterprise', async () => {
114
- const result = await harness.client.callTool({
115
- name: 'create_enterprise',
116
- arguments: { name: 'Acme Corp' },
117
- });
118
- assertSuccessResult(result as any);
119
- });
120
-
121
- it('returns error on failure', async () => {
122
- (harness.mockSdk.admin as any).createEnterprise.mockRejectedValueOnce(new Error('Conflict'));
123
- const result = await harness.client.callTool({
124
- name: 'create_enterprise',
125
- arguments: { name: 'Duplicate' },
126
- });
127
- assertErrorResult(result as any);
128
- });
129
- });
130
-
131
- describe('create_agent', () => {
132
- it('creates an agent', async () => {
133
- const result = await harness.client.callTool({
134
- name: 'create_agent',
135
- arguments: { name: 'Data Processor', enterpriseId: 'ent-1' },
136
- });
137
- assertSuccessResult(result as any);
138
- });
139
-
140
- it('returns error on failure', async () => {
141
- (harness.mockSdk.admin as any).createAgent.mockRejectedValueOnce(new Error('Bad request'));
142
- const result = await harness.client.callTool({
143
- name: 'create_agent',
144
- arguments: { name: '' },
145
- });
146
- assertErrorResult(result as any);
147
- });
148
- });
149
-
150
- describe('set_enterprise_config', () => {
151
- it('replaces enterprise config', async () => {
152
- const result = await harness.client.callTool({
153
- name: 'set_enterprise_config',
154
- arguments: {
155
- enterpriseId: 'ent-1',
156
- config: { agentApprovalRequired: true, defaultScopes: ['mandates:read'] },
157
- },
158
- });
159
- assertSuccessResult(result as any);
160
- });
161
-
162
- it('returns error on failure', async () => {
163
- (harness.mockSdk.admin as any).setEnterpriseConfig.mockRejectedValueOnce(new Error('Not found'));
164
- const result = await harness.client.callTool({
165
- name: 'set_enterprise_config',
166
- arguments: { enterpriseId: 'bad', config: {} },
167
- });
168
- assertErrorResult(result as any);
169
- });
170
- });
171
- });
@@ -1,56 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerEventTools } from '../../src/tools/events.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- describe('event tools', () => {
7
- let harness: TestHarness;
8
-
9
- beforeAll(async () => {
10
- harness = await createTestHarness({
11
- registerFns: [registerEventTools],
12
- mockOverrides: {
13
- events: {
14
- getAuditChain: vi.fn().mockResolvedValue({
15
- mandateId: 'm-001',
16
- chainStart: '2026-04-01T00:00:00Z',
17
- entries: [
18
- { index: 0, hash: 'abc123', previousHash: null, event: 'CREATED', actor: 'agent-1', timestamp: '2026-04-01T00:00:00Z' },
19
- { index: 1, hash: 'def456', previousHash: 'abc123', event: 'ACTIVATED', actor: 'agent-1', timestamp: '2026-04-01T00:01:00Z' },
20
- ],
21
- isValid: true,
22
- }),
23
- },
24
- },
25
- });
26
- });
27
-
28
- afterAll(async () => {
29
- await harness.cleanup();
30
- });
31
-
32
- it('registers exactly 1 tool: get_audit_trail', async () => {
33
- const { tools } = await harness.client.listTools();
34
- expect(tools.map((t: any) => t.name)).toEqual(['get_audit_trail']);
35
- });
36
-
37
- describe('get_audit_trail', () => {
38
- it('returns audit trail on success', async () => {
39
- const result = await harness.client.callTool({
40
- name: 'get_audit_trail',
41
- arguments: { mandateId: 'm-001' },
42
- });
43
- assertSuccessResult(result as any);
44
- expect((harness.mockSdk.events as any).getAuditChain).toHaveBeenCalledWith('m-001');
45
- });
46
-
47
- it('returns error on failure', async () => {
48
- (harness.mockSdk.events as any).getAuditChain.mockRejectedValueOnce(new Error('Mandate not found'));
49
- const result = await harness.client.callTool({
50
- name: 'get_audit_trail',
51
- arguments: { mandateId: 'm-missing' },
52
- });
53
- assertErrorResult(result as any);
54
- });
55
- });
56
- });