@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.
- package/dist/api-client.d.ts +16 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +52 -0
- package/dist/api-client.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -58
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +2 -13
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +113 -109
- package/dist/server.js.map +1 -1
- package/package.json +2 -3
- package/src/api-client.ts +72 -0
- package/src/index.ts +27 -60
- package/src/server.ts +136 -120
- package/tests/api-client.test.ts +147 -0
- package/tests/harness.ts +8 -35
- package/tests/integration.test.ts +373 -0
- package/tests/server.test.ts +286 -0
- package/src/enums.ts +0 -47
- package/src/errors.ts +0 -44
- package/src/resources/contract-types.ts +0 -130
- package/src/tool-scopes.ts +0 -180
- package/src/tools/a2a.ts +0 -430
- package/src/tools/agent-mandates.ts +0 -259
- package/src/tools/agents-refs.ts +0 -232
- package/src/tools/capabilities.ts +0 -63
- package/src/tools/compliance.ts +0 -70
- package/src/tools/dashboard.ts +0 -64
- package/src/tools/disputes.ts +0 -121
- package/src/tools/enterprises.ts +0 -203
- package/src/tools/events.ts +0 -33
- package/src/tools/federation-admin.ts +0 -665
- package/src/tools/federation.ts +0 -587
- package/src/tools/health.ts +0 -30
- package/src/tools/mandates.ts +0 -264
- package/src/tools/openclaw.ts +0 -122
- package/src/tools/receipts.ts +0 -134
- package/src/tools/reputation.ts +0 -69
- package/src/tools/schemas.ts +0 -535
- package/src/tools/verification-keys.ts +0 -33
- package/src/tools/verification.ts +0 -59
- package/tests/conformance.test.ts +0 -197
- package/tests/conformance.ts +0 -65
- package/tests/mock-client.ts +0 -71
- package/tests/profiles.test.ts +0 -120
- package/tests/resources/contract-types.test.ts +0 -82
- package/tests/tools/a2a.test.ts +0 -213
- package/tests/tools/agent-mandates.test.ts +0 -196
- package/tests/tools/agents-refs.test.ts +0 -190
- package/tests/tools/capabilities.test.ts +0 -80
- package/tests/tools/compliance.test.ts +0 -123
- package/tests/tools/dashboard.test.ts +0 -111
- package/tests/tools/disputes.test.ts +0 -123
- package/tests/tools/enterprises.test.ts +0 -171
- package/tests/tools/events.test.ts +0 -56
- package/tests/tools/federation-admin.test.ts +0 -468
- package/tests/tools/federation.test.ts +0 -522
- package/tests/tools/health.test.ts +0 -56
- package/tests/tools/mandates.test.ts +0 -143
- package/tests/tools/openclaw.test.ts +0 -148
- package/tests/tools/receipts.test.ts +0 -157
- package/tests/tools/reputation.test.ts +0 -108
- package/tests/tools/schemas.test.ts +0 -374
- package/tests/tools/verification-keys.test.ts +0 -56
- 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
|
-
});
|