@agledger/mcp-server 1.5.0 → 2.0.1

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 (162) 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/dist/enums.d.ts +0 -110
  21. package/dist/enums.d.ts.map +0 -1
  22. package/dist/enums.js +0 -42
  23. package/dist/enums.js.map +0 -1
  24. package/dist/errors.d.ts +0 -10
  25. package/dist/errors.d.ts.map +0 -1
  26. package/dist/errors.js +0 -49
  27. package/dist/errors.js.map +0 -1
  28. package/dist/resources/contract-types.d.ts +0 -4
  29. package/dist/resources/contract-types.d.ts.map +0 -1
  30. package/dist/resources/contract-types.js +0 -104
  31. package/dist/resources/contract-types.js.map +0 -1
  32. package/dist/tool-scopes.d.ts +0 -11
  33. package/dist/tool-scopes.d.ts.map +0 -1
  34. package/dist/tool-scopes.js +0 -164
  35. package/dist/tool-scopes.js.map +0 -1
  36. package/dist/tools/a2a.d.ts +0 -8
  37. package/dist/tools/a2a.d.ts.map +0 -1
  38. package/dist/tools/a2a.js +0 -360
  39. package/dist/tools/a2a.js.map +0 -1
  40. package/dist/tools/agent-mandates.d.ts +0 -4
  41. package/dist/tools/agent-mandates.d.ts.map +0 -1
  42. package/dist/tools/agent-mandates.js +0 -222
  43. package/dist/tools/agent-mandates.js.map +0 -1
  44. package/dist/tools/agents-refs.d.ts +0 -4
  45. package/dist/tools/agents-refs.d.ts.map +0 -1
  46. package/dist/tools/agents-refs.js +0 -196
  47. package/dist/tools/agents-refs.js.map +0 -1
  48. package/dist/tools/capabilities.d.ts +0 -4
  49. package/dist/tools/capabilities.d.ts.map +0 -1
  50. package/dist/tools/capabilities.js +0 -54
  51. package/dist/tools/capabilities.js.map +0 -1
  52. package/dist/tools/code-mode.d.ts +0 -4
  53. package/dist/tools/code-mode.d.ts.map +0 -1
  54. package/dist/tools/code-mode.js +0 -389
  55. package/dist/tools/code-mode.js.map +0 -1
  56. package/dist/tools/compliance.d.ts +0 -4
  57. package/dist/tools/compliance.d.ts.map +0 -1
  58. package/dist/tools/compliance.js +0 -63
  59. package/dist/tools/compliance.js.map +0 -1
  60. package/dist/tools/dashboard.d.ts +0 -4
  61. package/dist/tools/dashboard.d.ts.map +0 -1
  62. package/dist/tools/dashboard.js +0 -57
  63. package/dist/tools/dashboard.js.map +0 -1
  64. package/dist/tools/disputes.d.ts +0 -4
  65. package/dist/tools/disputes.d.ts.map +0 -1
  66. package/dist/tools/disputes.js +0 -103
  67. package/dist/tools/disputes.js.map +0 -1
  68. package/dist/tools/enterprises.d.ts +0 -4
  69. package/dist/tools/enterprises.d.ts.map +0 -1
  70. package/dist/tools/enterprises.js +0 -173
  71. package/dist/tools/enterprises.js.map +0 -1
  72. package/dist/tools/events.d.ts +0 -4
  73. package/dist/tools/events.d.ts.map +0 -1
  74. package/dist/tools/events.js +0 -28
  75. package/dist/tools/events.js.map +0 -1
  76. package/dist/tools/federation-admin.d.ts +0 -4
  77. package/dist/tools/federation-admin.d.ts.map +0 -1
  78. package/dist/tools/federation-admin.js +0 -567
  79. package/dist/tools/federation-admin.js.map +0 -1
  80. package/dist/tools/federation.d.ts +0 -4
  81. package/dist/tools/federation.d.ts.map +0 -1
  82. package/dist/tools/federation.js +0 -505
  83. package/dist/tools/federation.js.map +0 -1
  84. package/dist/tools/health.d.ts +0 -4
  85. package/dist/tools/health.d.ts.map +0 -1
  86. package/dist/tools/health.js +0 -25
  87. package/dist/tools/health.js.map +0 -1
  88. package/dist/tools/mandates.d.ts +0 -4
  89. package/dist/tools/mandates.d.ts.map +0 -1
  90. package/dist/tools/mandates.js +0 -227
  91. package/dist/tools/mandates.js.map +0 -1
  92. package/dist/tools/openclaw.d.ts +0 -4
  93. package/dist/tools/openclaw.d.ts.map +0 -1
  94. package/dist/tools/openclaw.js +0 -110
  95. package/dist/tools/openclaw.js.map +0 -1
  96. package/dist/tools/receipts.d.ts +0 -8
  97. package/dist/tools/receipts.d.ts.map +0 -1
  98. package/dist/tools/receipts.js +0 -111
  99. package/dist/tools/receipts.js.map +0 -1
  100. package/dist/tools/reputation.d.ts +0 -4
  101. package/dist/tools/reputation.d.ts.map +0 -1
  102. package/dist/tools/reputation.js +0 -62
  103. package/dist/tools/reputation.js.map +0 -1
  104. package/dist/tools/schemas.d.ts +0 -4
  105. package/dist/tools/schemas.d.ts.map +0 -1
  106. package/dist/tools/schemas.js +0 -453
  107. package/dist/tools/schemas.js.map +0 -1
  108. package/dist/tools/verification-keys.d.ts +0 -4
  109. package/dist/tools/verification-keys.d.ts.map +0 -1
  110. package/dist/tools/verification-keys.js +0 -27
  111. package/dist/tools/verification-keys.js.map +0 -1
  112. package/dist/tools/verification.d.ts +0 -4
  113. package/dist/tools/verification.d.ts.map +0 -1
  114. package/dist/tools/verification.js +0 -50
  115. package/dist/tools/verification.js.map +0 -1
  116. package/src/enums.ts +0 -47
  117. package/src/errors.ts +0 -44
  118. package/src/resources/contract-types.ts +0 -130
  119. package/src/tool-scopes.ts +0 -180
  120. package/src/tools/a2a.ts +0 -430
  121. package/src/tools/agent-mandates.ts +0 -259
  122. package/src/tools/agents-refs.ts +0 -232
  123. package/src/tools/capabilities.ts +0 -63
  124. package/src/tools/compliance.ts +0 -70
  125. package/src/tools/dashboard.ts +0 -64
  126. package/src/tools/disputes.ts +0 -121
  127. package/src/tools/enterprises.ts +0 -203
  128. package/src/tools/events.ts +0 -33
  129. package/src/tools/federation-admin.ts +0 -665
  130. package/src/tools/federation.ts +0 -587
  131. package/src/tools/health.ts +0 -30
  132. package/src/tools/mandates.ts +0 -264
  133. package/src/tools/openclaw.ts +0 -122
  134. package/src/tools/receipts.ts +0 -134
  135. package/src/tools/reputation.ts +0 -69
  136. package/src/tools/schemas.ts +0 -535
  137. package/src/tools/verification-keys.ts +0 -33
  138. package/src/tools/verification.ts +0 -59
  139. package/tests/conformance.test.ts +0 -197
  140. package/tests/conformance.ts +0 -65
  141. package/tests/mock-client.ts +0 -71
  142. package/tests/profiles.test.ts +0 -120
  143. package/tests/resources/contract-types.test.ts +0 -82
  144. package/tests/tools/a2a.test.ts +0 -213
  145. package/tests/tools/agent-mandates.test.ts +0 -196
  146. package/tests/tools/agents-refs.test.ts +0 -190
  147. package/tests/tools/capabilities.test.ts +0 -80
  148. package/tests/tools/compliance.test.ts +0 -123
  149. package/tests/tools/dashboard.test.ts +0 -111
  150. package/tests/tools/disputes.test.ts +0 -123
  151. package/tests/tools/enterprises.test.ts +0 -171
  152. package/tests/tools/events.test.ts +0 -56
  153. package/tests/tools/federation-admin.test.ts +0 -468
  154. package/tests/tools/federation.test.ts +0 -522
  155. package/tests/tools/health.test.ts +0 -56
  156. package/tests/tools/mandates.test.ts +0 -143
  157. package/tests/tools/openclaw.test.ts +0 -148
  158. package/tests/tools/receipts.test.ts +0 -157
  159. package/tests/tools/reputation.test.ts +0 -108
  160. package/tests/tools/schemas.test.ts +0 -374
  161. package/tests/tools/verification-keys.test.ts +0 -56
  162. package/tests/tools/verification.test.ts +0 -64
@@ -1,522 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerFederationTools } from '../../src/tools/federation.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- const EXPECTED_TOOLS = [
7
- 'federation_broadcast_revocations',
8
- 'federation_catch_up',
9
- 'federation_confirm_schema_publish',
10
- 'federation_contribute_reputation',
11
- 'federation_get_agent_reputation',
12
- 'federation_get_contract_type',
13
- 'federation_get_mandate_criteria',
14
- 'federation_heartbeat',
15
- 'federation_list_agents',
16
- 'federation_list_contract_types',
17
- 'federation_publish_schema',
18
- 'federation_register',
19
- 'federation_register_agent',
20
- 'federation_relay_signal',
21
- 'federation_revoke',
22
- 'federation_rotate_key',
23
- 'federation_stream',
24
- 'federation_submit_mandate_criteria',
25
- 'federation_submit_transition',
26
- 'federation_sync_agent_directory',
27
- ];
28
-
29
- describe('federation tools', () => {
30
- let harness: TestHarness;
31
-
32
- beforeAll(async () => {
33
- harness = await createTestHarness({
34
- registerFns: [registerFederationTools],
35
- mockOverrides: {
36
- federation: {
37
- register: vi.fn().mockResolvedValue({
38
- gatewayId: 'gw-1',
39
- organizationId: 'org-1',
40
- status: 'active',
41
- bearerToken: 'tok-abc',
42
- bearerTokenExpiresAt: '2026-05-01T00:00:00Z',
43
- }),
44
- heartbeat: vi.fn().mockResolvedValue({
45
- gatewayId: 'gw-1',
46
- token: 'tok-refreshed',
47
- expiresAt: '2026-05-01T00:00:00Z',
48
- bearerTokenExpiresAt: '2026-05-01T00:00:00Z',
49
- revocations: [],
50
- }),
51
- registerAgent: vi.fn().mockResolvedValue({
52
- agentId: 'agent-1',
53
- registered: true,
54
- contractTypes: ['ACH-PROC-v1'],
55
- }),
56
- listAgents: vi.fn().mockResolvedValue({
57
- data: [{ agentId: 'agent-1', contractTypes: ['ACH-PROC-v1'] }],
58
- hasMore: false,
59
- agents: [{ agentId: 'agent-1', gatewayId: 'gw-1', contractTypes: ['ACH-PROC-v1'], displayName: 'Agent 1' }],
60
- }),
61
- submitStateTransition: vi.fn().mockResolvedValue({
62
- mandateId: 'mnd-1',
63
- state: 'ACTIVE',
64
- seq: 1,
65
- hubState: 'ACTIVE',
66
- subStatus: 'none',
67
- hubTimestamp: '2026-04-13T00:00:00Z',
68
- }),
69
- relaySignal: vi.fn().mockResolvedValue({
70
- mandateId: 'mnd-1',
71
- signal: 'SETTLE',
72
- signalSeq: 1,
73
- relayed: true,
74
- targetGatewayId: 'gw-2',
75
- hubTimestamp: '2026-04-13T00:00:00Z',
76
- }),
77
- rotateKey: vi.fn().mockResolvedValue({
78
- gatewayId: 'gw-1',
79
- rotated: true,
80
- rotatedAt: '2026-04-13T00:00:00Z',
81
- }),
82
- revoke: vi.fn().mockResolvedValue({
83
- gatewayId: 'gw-1',
84
- reason: 'key_compromise',
85
- revoked: true,
86
- revokedAt: '2026-04-13T00:00:00Z',
87
- }),
88
- catchUp: vi.fn().mockResolvedValue({
89
- data: [{ mandateId: 'mnd-1', state: 'ACTIVE', seq: 1 }],
90
- hasMore: false,
91
- nextPosition: 1,
92
- }),
93
- stream: vi.fn().mockResolvedValue({
94
- events: [{ type: 'transition', timestamp: '2026-04-13T00:00:00Z' }],
95
- }),
96
- publishSchema: vi.fn().mockResolvedValue({
97
- contractType: 'ACH-PROC-v1',
98
- status: 'pending',
99
- confirmationToken: 'tok-confirm',
100
- }),
101
- confirmSchemaPublish: vi.fn().mockResolvedValue({
102
- contractType: 'ACH-PROC-v1',
103
- confirmed: true,
104
- }),
105
- listContractTypes: vi.fn().mockResolvedValue([
106
- { contractType: 'ACH-PROC-v1', version: '1.0', status: 'active' },
107
- ]),
108
- getContractType: vi.fn().mockResolvedValue({
109
- contractType: 'ACH-PROC-v1',
110
- version: '1.0',
111
- status: 'active',
112
- schema: {},
113
- }),
114
- getMandateCriteria: vi.fn().mockResolvedValue({
115
- mandateId: 'mnd-1',
116
- submittedBy: 'gw-1',
117
- criteria: { item: 'widget' },
118
- }),
119
- submitMandateCriteria: vi.fn().mockResolvedValue({
120
- mandateId: 'mnd-1',
121
- submittedBy: 'gw-1',
122
- submittedAt: '2026-04-13T00:00:00Z',
123
- status: 'submitted',
124
- }),
125
- contributeReputation: vi.fn().mockResolvedValue({
126
- agentId: 'agent-1',
127
- recorded: true,
128
- }),
129
- getAgentReputation: vi.fn().mockResolvedValue({
130
- agentId: 'agent-1',
131
- overallScore: 95,
132
- score: 95,
133
- totalMandates: 20,
134
- contributions: 12,
135
- }),
136
- broadcastRevocations: vi.fn().mockResolvedValue({
137
- gatewayId: 'gw-1',
138
- broadcast: true,
139
- peersNotified: 3,
140
- }),
141
- syncAgentDirectory: vi.fn().mockResolvedValue({
142
- synced: 2,
143
- }),
144
- },
145
- },
146
- });
147
- });
148
-
149
- afterAll(async () => { await harness.cleanup(); });
150
-
151
- it('registers exactly 20 tools', async () => {
152
- const { tools } = await harness.client.listTools();
153
- expect(tools.map((t: any) => t.name).sort()).toEqual(EXPECTED_TOOLS);
154
- });
155
-
156
- // --- Top 5 tools: happy path + error ---
157
-
158
- describe('federation_register', () => {
159
- it('registers a gateway', async () => {
160
- const result = await harness.client.callTool({
161
- name: 'federation_register',
162
- arguments: {
163
- registrationToken: 'tok-123',
164
- organizationId: 'org-1',
165
- signingPublicKey: 'key-sign',
166
- encryptionPublicKey: 'key-enc',
167
- endpointUrl: 'https://gw.example.com',
168
- revocationSecret: 'secret',
169
- timestamp: '2026-04-13T00:00:00Z',
170
- nonce: 'nonce-1',
171
- signature: 'sig-1',
172
- },
173
- });
174
- assertSuccessResult(result as any);
175
- });
176
-
177
- it('returns error on failure', async () => {
178
- (harness.mockSdk.federation as any).register.mockRejectedValueOnce(new Error('Token expired'));
179
- const result = await harness.client.callTool({
180
- name: 'federation_register',
181
- arguments: {
182
- registrationToken: 'bad-tok',
183
- organizationId: 'org-1',
184
- signingPublicKey: 'key-sign',
185
- encryptionPublicKey: 'key-enc',
186
- endpointUrl: 'https://gw.example.com',
187
- revocationSecret: 'secret',
188
- timestamp: '2026-04-13T00:00:00Z',
189
- nonce: 'nonce-1',
190
- signature: 'sig-1',
191
- },
192
- });
193
- assertErrorResult(result as any);
194
- });
195
- });
196
-
197
- describe('federation_heartbeat', () => {
198
- it('sends heartbeat successfully', async () => {
199
- const result = await harness.client.callTool({
200
- name: 'federation_heartbeat',
201
- arguments: {
202
- gatewayId: 'gw-1',
203
- agentCount: 5,
204
- mandateCount: 10,
205
- timestamp: '2026-04-13T00:00:00Z',
206
- },
207
- });
208
- assertSuccessResult(result as any);
209
- });
210
-
211
- it('returns error on failure', async () => {
212
- (harness.mockSdk.federation as any).heartbeat.mockRejectedValueOnce(new Error('Gateway not found'));
213
- const result = await harness.client.callTool({
214
- name: 'federation_heartbeat',
215
- arguments: {
216
- gatewayId: 'bad-gw',
217
- agentCount: 0,
218
- mandateCount: 0,
219
- timestamp: '2026-04-13T00:00:00Z',
220
- },
221
- });
222
- assertErrorResult(result as any);
223
- });
224
- });
225
-
226
- describe('federation_submit_transition', () => {
227
- it('submits a state transition', async () => {
228
- const result = await harness.client.callTool({
229
- name: 'federation_submit_transition',
230
- arguments: {
231
- mandateId: 'mnd-1',
232
- gatewayId: 'gw-1',
233
- state: 'ACTIVE',
234
- contractType: 'ACH-PROC-v1',
235
- criteriaHash: 'hash-abc',
236
- role: 'principal',
237
- seq: 1,
238
- idempotencyKey: 'idem-1',
239
- timestamp: '2026-04-13T00:00:00Z',
240
- nonce: 'nonce-1',
241
- signature: 'sig-1',
242
- },
243
- });
244
- assertSuccessResult(result as any);
245
- });
246
-
247
- it('returns error on failure', async () => {
248
- (harness.mockSdk.federation as any).submitStateTransition.mockRejectedValueOnce(new Error('Sequence conflict'));
249
- const result = await harness.client.callTool({
250
- name: 'federation_submit_transition',
251
- arguments: {
252
- mandateId: 'mnd-1',
253
- gatewayId: 'gw-1',
254
- state: 'ACTIVE',
255
- contractType: 'ACH-PROC-v1',
256
- criteriaHash: 'hash-abc',
257
- role: 'principal',
258
- seq: 99,
259
- idempotencyKey: 'idem-bad',
260
- timestamp: '2026-04-13T00:00:00Z',
261
- nonce: 'nonce-1',
262
- signature: 'sig-1',
263
- },
264
- });
265
- assertErrorResult(result as any);
266
- });
267
- });
268
-
269
- describe('federation_relay_signal', () => {
270
- it('relays a settlement signal', async () => {
271
- const result = await harness.client.callTool({
272
- name: 'federation_relay_signal',
273
- arguments: {
274
- mandateId: 'mnd-1',
275
- signal: 'SETTLE',
276
- outcomeHash: 'hash-out',
277
- signalSeq: 1,
278
- validUntil: '2026-05-01T00:00:00Z',
279
- performerGatewayId: 'gw-2',
280
- timestamp: '2026-04-13T00:00:00Z',
281
- nonce: 'nonce-1',
282
- performerSignature: 'sig-perf',
283
- },
284
- });
285
- assertSuccessResult(result as any);
286
- });
287
-
288
- it('returns error on failure', async () => {
289
- (harness.mockSdk.federation as any).relaySignal.mockRejectedValueOnce(new Error('Invalid signal'));
290
- const result = await harness.client.callTool({
291
- name: 'federation_relay_signal',
292
- arguments: {
293
- mandateId: 'mnd-1',
294
- signal: 'SETTLE',
295
- outcomeHash: 'hash-out',
296
- signalSeq: 1,
297
- validUntil: '2026-05-01T00:00:00Z',
298
- performerGatewayId: 'gw-2',
299
- timestamp: '2026-04-13T00:00:00Z',
300
- nonce: 'nonce-1',
301
- performerSignature: 'sig-perf',
302
- },
303
- });
304
- assertErrorResult(result as any);
305
- });
306
- });
307
-
308
- describe('federation_register_agent', () => {
309
- it('registers a federated agent', async () => {
310
- const result = await harness.client.callTool({
311
- name: 'federation_register_agent',
312
- arguments: {
313
- agentId: 'agent-1',
314
- contractTypes: ['ACH-PROC-v1'],
315
- displayName: 'Test Agent',
316
- },
317
- });
318
- assertSuccessResult(result as any);
319
- });
320
-
321
- it('returns error on failure', async () => {
322
- (harness.mockSdk.federation as any).registerAgent.mockRejectedValueOnce(new Error('Agent already registered'));
323
- const result = await harness.client.callTool({
324
- name: 'federation_register_agent',
325
- arguments: {
326
- agentId: 'agent-dup',
327
- contractTypes: ['ACH-PROC-v1'],
328
- },
329
- });
330
- assertErrorResult(result as any);
331
- });
332
- });
333
-
334
- // --- Remaining tools: happy path only ---
335
-
336
- describe('federation_list_agents', () => {
337
- it('lists federated agents', async () => {
338
- const result = await harness.client.callTool({
339
- name: 'federation_list_agents',
340
- arguments: {},
341
- });
342
- assertSuccessResult(result as any);
343
- });
344
- });
345
-
346
- describe('federation_rotate_key', () => {
347
- it('rotates gateway keys', async () => {
348
- const result = await harness.client.callTool({
349
- name: 'federation_rotate_key',
350
- arguments: {
351
- gatewayId: 'gw-1',
352
- newSigningPublicKey: 'new-sign-key',
353
- newEncryptionPublicKey: 'new-enc-key',
354
- signatureOldKey: 'sig-old',
355
- signatureNewKey: 'sig-new',
356
- timestamp: '2026-04-13T00:00:00Z',
357
- nonce: 'nonce-rot',
358
- },
359
- });
360
- assertSuccessResult(result as any);
361
- expect((harness.mockSdk.federation as any).rotateKey).toHaveBeenCalledWith('gw-1', expect.objectContaining({
362
- newSigningPublicKey: 'new-sign-key',
363
- }));
364
- });
365
- });
366
-
367
- describe('federation_revoke', () => {
368
- it('revokes a gateway', async () => {
369
- const result = await harness.client.callTool({
370
- name: 'federation_revoke',
371
- arguments: {
372
- gatewayId: 'gw-1',
373
- revocationSecret: 'secret',
374
- reason: 'key_compromise',
375
- },
376
- });
377
- assertSuccessResult(result as any);
378
- });
379
- });
380
-
381
- describe('federation_catch_up', () => {
382
- it('catches up missed transitions', async () => {
383
- const result = await harness.client.callTool({
384
- name: 'federation_catch_up',
385
- arguments: { sincePosition: 0 },
386
- });
387
- assertSuccessResult(result as any);
388
- });
389
- });
390
-
391
- describe('federation_stream', () => {
392
- it('streams federation events', async () => {
393
- const result = await harness.client.callTool({
394
- name: 'federation_stream',
395
- arguments: { since: '2026-04-12T00:00:00Z' },
396
- });
397
- assertSuccessResult(result as any);
398
- });
399
- });
400
-
401
- describe('federation_publish_schema', () => {
402
- it('publishes a schema', async () => {
403
- const result = await harness.client.callTool({
404
- name: 'federation_publish_schema',
405
- arguments: {
406
- contractType: 'ACH-PROC-v1',
407
- schema: { type: 'object' },
408
- },
409
- });
410
- assertSuccessResult(result as any);
411
- });
412
- });
413
-
414
- describe('federation_confirm_schema_publish', () => {
415
- it('confirms a schema publication', async () => {
416
- const result = await harness.client.callTool({
417
- name: 'federation_confirm_schema_publish',
418
- arguments: {
419
- contractType: 'ACH-PROC-v1',
420
- confirmationToken: 'tok-confirm',
421
- },
422
- });
423
- assertSuccessResult(result as any);
424
- });
425
- });
426
-
427
- describe('federation_list_contract_types', () => {
428
- it('lists contract types', async () => {
429
- const result = await harness.client.callTool({
430
- name: 'federation_list_contract_types',
431
- arguments: {},
432
- });
433
- assertSuccessResult(result as any);
434
- });
435
- });
436
-
437
- describe('federation_get_contract_type', () => {
438
- it('gets a contract type', async () => {
439
- const result = await harness.client.callTool({
440
- name: 'federation_get_contract_type',
441
- arguments: { contractType: 'ACH-PROC-v1' },
442
- });
443
- assertSuccessResult(result as any);
444
- });
445
- });
446
-
447
- describe('federation_get_mandate_criteria', () => {
448
- it('gets mandate criteria', async () => {
449
- const result = await harness.client.callTool({
450
- name: 'federation_get_mandate_criteria',
451
- arguments: { mandateId: 'mnd-1' },
452
- });
453
- assertSuccessResult(result as any);
454
- });
455
- });
456
-
457
- describe('federation_submit_mandate_criteria', () => {
458
- it('submits mandate criteria', async () => {
459
- const result = await harness.client.callTool({
460
- name: 'federation_submit_mandate_criteria',
461
- arguments: {
462
- mandateId: 'mnd-1',
463
- criteria: { item: 'widget', quantity: 10 },
464
- },
465
- });
466
- assertSuccessResult(result as any);
467
- });
468
- });
469
-
470
- describe('federation_contribute_reputation', () => {
471
- it('contributes reputation data', async () => {
472
- const result = await harness.client.callTool({
473
- name: 'federation_contribute_reputation',
474
- arguments: {
475
- agentId: 'agent-1',
476
- contractType: 'ACH-PROC-v1',
477
- outcome: 'PASS',
478
- },
479
- });
480
- assertSuccessResult(result as any);
481
- });
482
- });
483
-
484
- describe('federation_get_agent_reputation', () => {
485
- it('gets agent reputation', async () => {
486
- const result = await harness.client.callTool({
487
- name: 'federation_get_agent_reputation',
488
- arguments: { agentId: 'agent-1' },
489
- });
490
- assertSuccessResult(result as any);
491
- });
492
- });
493
-
494
- describe('federation_broadcast_revocations', () => {
495
- it('broadcasts revocations', async () => {
496
- const result = await harness.client.callTool({
497
- name: 'federation_broadcast_revocations',
498
- arguments: {
499
- gatewayId: 'gw-1',
500
- reason: 'compromised',
501
- revokedAt: '2026-04-13T00:00:00Z',
502
- },
503
- });
504
- assertSuccessResult(result as any);
505
- });
506
- });
507
-
508
- describe('federation_sync_agent_directory', () => {
509
- it('syncs agent directory', async () => {
510
- const result = await harness.client.callTool({
511
- name: 'federation_sync_agent_directory',
512
- arguments: {
513
- agents: [
514
- { agentId: 'agent-1', contractTypes: ['ACH-PROC-v1'] },
515
- { agentId: 'agent-2', contractTypes: ['ACH-DLVR-v1'] },
516
- ],
517
- },
518
- });
519
- assertSuccessResult(result as any);
520
- });
521
- });
522
- });
@@ -1,56 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerHealthTools } from '../../src/tools/health.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertToolMetadata, assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- describe('health tools', () => {
7
- let harness: TestHarness;
8
-
9
- beforeAll(async () => {
10
- harness = await createTestHarness({
11
- registerFns: [registerHealthTools],
12
- mockOverrides: {
13
- health: {
14
- check: vi.fn().mockResolvedValue({
15
- status: 'ok',
16
- version: '0.15.6',
17
- uptime: 12345,
18
- database: 'connected',
19
- timestamp: '2026-04-13T00:00:00Z',
20
- }),
21
- },
22
- },
23
- });
24
- });
25
-
26
- afterAll(async () => {
27
- await harness.cleanup();
28
- });
29
-
30
- describe('tool registration', () => {
31
- it('registers exactly 1 tool: check_api_health', async () => {
32
- const { tools } = await harness.client.listTools();
33
- expect(tools.map(t => t.name)).toEqual(['check_api_health']);
34
- });
35
-
36
- it('has valid metadata', async () => {
37
- const { tools } = await harness.client.listTools();
38
- assertToolMetadata(tools[0]);
39
- });
40
- });
41
-
42
- describe('check_api_health', () => {
43
- it('returns health status on success', async () => {
44
- const result = await harness.client.callTool({ name: 'check_api_health', arguments: {} });
45
- assertSuccessResult(result as any);
46
- expect((harness.mockSdk.health as any).check).toHaveBeenCalledOnce();
47
- });
48
-
49
- it('returns error when API is unreachable', async () => {
50
- (harness.mockSdk.health as any).check.mockRejectedValueOnce(new Error('Connection refused'));
51
-
52
- const result = await harness.client.callTool({ name: 'check_api_health', arguments: {} });
53
- assertErrorResult(result as any);
54
- });
55
- });
56
- });