@agledger/mcp-server 1.4.3 → 1.5.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/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -3
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.d.ts.map +1 -1
- package/dist/tool-scopes.js +0 -3
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/a2a.d.ts.map +1 -1
- package/dist/tools/a2a.js +20 -220
- package/dist/tools/a2a.js.map +1 -1
- package/dist/tools/agent-mandates.d.ts.map +1 -1
- package/dist/tools/agent-mandates.js +10 -74
- package/dist/tools/agent-mandates.js.map +1 -1
- package/dist/tools/agents-refs.d.ts.map +1 -1
- package/dist/tools/agents-refs.js +9 -61
- package/dist/tools/agents-refs.js.map +1 -1
- package/dist/tools/capabilities.d.ts.map +1 -1
- package/dist/tools/capabilities.js +2 -14
- package/dist/tools/capabilities.js.map +1 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +4 -35
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/compliance.d.ts.map +1 -1
- package/dist/tools/compliance.js +3 -37
- package/dist/tools/compliance.js.map +1 -1
- package/dist/tools/dashboard.d.ts.map +1 -1
- package/dist/tools/dashboard.js +3 -37
- package/dist/tools/dashboard.js.map +1 -1
- package/dist/tools/disputes.d.ts.map +1 -1
- package/dist/tools/disputes.js +4 -41
- package/dist/tools/disputes.js.map +1 -1
- package/dist/tools/enterprises.d.ts.map +1 -1
- package/dist/tools/enterprises.js +6 -62
- package/dist/tools/enterprises.js.map +1 -1
- package/dist/tools/events.d.ts.map +1 -1
- package/dist/tools/events.js +1 -19
- package/dist/tools/events.js.map +1 -1
- package/dist/tools/federation-admin.d.ts.map +1 -1
- package/dist/tools/federation-admin.js +24 -256
- package/dist/tools/federation-admin.js.map +1 -1
- package/dist/tools/federation.d.ts.map +1 -1
- package/dist/tools/federation.js +20 -197
- package/dist/tools/federation.js.map +1 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +1 -13
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/mandates.d.ts.map +1 -1
- package/dist/tools/mandates.js +10 -93
- package/dist/tools/mandates.js.map +1 -1
- package/dist/tools/openclaw.d.ts.map +1 -1
- package/dist/tools/openclaw.js +5 -32
- package/dist/tools/openclaw.js.map +1 -1
- package/dist/tools/receipts.d.ts.map +1 -1
- package/dist/tools/receipts.js +4 -94
- package/dist/tools/receipts.js.map +1 -1
- package/dist/tools/reputation.d.ts.map +1 -1
- package/dist/tools/reputation.js +3 -33
- package/dist/tools/reputation.js.map +1 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +16 -186
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/verification-keys.d.ts.map +1 -1
- package/dist/tools/verification-keys.js +1 -22
- package/dist/tools/verification-keys.js.map +1 -1
- package/dist/tools/verification.d.ts.map +1 -1
- package/dist/tools/verification.js +2 -27
- package/dist/tools/verification.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -3
- package/src/server.ts +3 -5
- package/src/tool-scopes.ts +0 -4
- package/src/tools/a2a.ts +20 -233
- package/src/tools/agent-mandates.ts +10 -76
- package/src/tools/agents-refs.ts +9 -65
- package/src/tools/capabilities.ts +2 -15
- package/src/tools/compliance.ts +3 -37
- package/src/tools/dashboard.ts +3 -37
- package/src/tools/disputes.ts +4 -42
- package/src/tools/enterprises.ts +6 -62
- package/src/tools/events.ts +1 -20
- package/src/tools/federation-admin.ts +24 -281
- package/src/tools/federation.ts +20 -217
- package/src/tools/health.ts +1 -14
- package/src/tools/mandates.ts +10 -95
- package/src/tools/openclaw.ts +5 -51
- package/src/tools/receipts.ts +4 -95
- package/src/tools/reputation.ts +3 -34
- package/src/tools/schemas.ts +16 -194
- package/src/tools/verification-keys.ts +1 -24
- package/src/tools/verification.ts +2 -29
- package/tests/conformance.test.ts +4 -26
- package/tests/conformance.ts +3 -13
- package/tests/profiles.test.ts +2 -17
- package/tests/tools/a2a.test.ts +0 -28
- package/tests/tools/agent-mandates.test.ts +0 -10
- package/tests/tools/agents-refs.test.ts +0 -9
- package/tests/tools/capabilities.test.ts +0 -6
- package/tests/tools/compliance.test.ts +0 -8
- package/tests/tools/dashboard.test.ts +0 -9
- package/tests/tools/disputes.test.ts +0 -8
- package/tests/tools/enterprises.test.ts +0 -10
- package/tests/tools/events.test.ts +0 -5
- package/tests/tools/federation-admin.test.ts +0 -41
- package/tests/tools/federation.test.ts +0 -34
- package/tests/tools/health.test.ts +1 -12
- package/tests/tools/mandates.test.ts +0 -12
- package/tests/tools/openclaw.test.ts +0 -12
- package/tests/tools/receipts.test.ts +1 -14
- package/tests/tools/reputation.test.ts +0 -9
- package/tests/tools/schemas.test.ts +0 -23
- package/tests/tools/verification-keys.test.ts +0 -6
- package/tests/tools/verification.test.ts +1 -11
- package/src/tools/code-mode.ts +0 -461
- package/tests/drift/code-mode-manifest.test.ts +0 -144
- package/tests/integration/output-schema-validation.test.ts +0 -167
- package/tests/tools/code-mode.test.ts +0 -168
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { apiErrorResult, toStructuredContent } from '../errors.js';
|
|
3
|
-
import { VerificationOutcomeEnum } from '../enums.js';
|
|
4
3
|
import { toolMeta } from '../tool-scopes.js';
|
|
5
|
-
const VerificationResultOutputSchema = z.object({
|
|
6
|
-
mandateId: z.string().describe('Mandate UUID that was verified'),
|
|
7
|
-
receipts: z.array(z.object({
|
|
8
|
-
receiptId: z.string().describe('Receipt UUID'),
|
|
9
|
-
phase1Result: z.record(z.string(), z.unknown()).optional().describe('Phase 1 (sync) verification result'),
|
|
10
|
-
phase2Result: z.record(z.string(), z.unknown()).optional().describe('Phase 2 (async) verification result'),
|
|
11
|
-
})).describe('Per-receipt verification results'),
|
|
12
|
-
overallStatus: VerificationOutcomeEnum.describe('Overall verification outcome: PASS, FAIL, or REVIEW_REQUIRED'),
|
|
13
|
-
}).passthrough().describe('Mandate verification result');
|
|
14
|
-
const VerificationStatusOutputSchema = z.object({
|
|
15
|
-
mandateId: z.string().describe('Mandate UUID'),
|
|
16
|
-
phase1Status: z.string().describe('Phase 1 (sync rules) verification status'),
|
|
17
|
-
phase2Status: z.string().describe('Phase 2 (async rules) verification status'),
|
|
18
|
-
lastVerifiedAt: z.string().nullable().optional().describe('ISO 8601 timestamp of last verification'),
|
|
19
|
-
pendingRules: z.array(z.string()).nullable().optional().describe('Rule IDs still pending verification'),
|
|
20
|
-
}).passthrough().describe('Current verification status for a mandate');
|
|
21
4
|
export function registerVerificationTools(mcp, client) {
|
|
22
5
|
mcp.registerTool('verify_mandate', {
|
|
23
6
|
title: 'Verify Mandate',
|
|
@@ -25,7 +8,6 @@ export function registerVerificationTools(mcp, client) {
|
|
|
25
8
|
inputSchema: {
|
|
26
9
|
mandateId: z.string().describe('UUID of the mandate to verify'),
|
|
27
10
|
},
|
|
28
|
-
outputSchema: VerificationResultOutputSchema,
|
|
29
11
|
annotations: {
|
|
30
12
|
readOnlyHint: false,
|
|
31
13
|
destructiveHint: false,
|
|
@@ -36,10 +18,7 @@ export function registerVerificationTools(mcp, client) {
|
|
|
36
18
|
}, async (args) => {
|
|
37
19
|
try {
|
|
38
20
|
const result = await client.verification.verify(args.mandateId);
|
|
39
|
-
return {
|
|
40
|
-
content: [{ type: 'text', text: `Verification for mandate ${result.mandateId}: ${result.overallStatus}. ${result.receipts.length} receipt(s) evaluated.` }],
|
|
41
|
-
structuredContent: toStructuredContent(result),
|
|
42
|
-
};
|
|
21
|
+
return { content: [], structuredContent: toStructuredContent(result) };
|
|
43
22
|
}
|
|
44
23
|
catch (err) {
|
|
45
24
|
return apiErrorResult(err);
|
|
@@ -51,7 +30,6 @@ export function registerVerificationTools(mcp, client) {
|
|
|
51
30
|
inputSchema: {
|
|
52
31
|
mandateId: z.string().describe('UUID of the mandate to check verification status for'),
|
|
53
32
|
},
|
|
54
|
-
outputSchema: VerificationStatusOutputSchema,
|
|
55
33
|
annotations: {
|
|
56
34
|
readOnlyHint: true,
|
|
57
35
|
destructiveHint: false,
|
|
@@ -62,10 +40,7 @@ export function registerVerificationTools(mcp, client) {
|
|
|
62
40
|
}, async (args) => {
|
|
63
41
|
try {
|
|
64
42
|
const status = await client.verification.getStatus(args.mandateId);
|
|
65
|
-
return {
|
|
66
|
-
content: [{ type: 'text', text: `Verification status for ${status.mandateId}: phase1=${status.phase1Status}, phase2=${status.phase2Status}.` }],
|
|
67
|
-
structuredContent: toStructuredContent(status),
|
|
68
|
-
};
|
|
43
|
+
return { content: [], structuredContent: toStructuredContent(status) };
|
|
69
44
|
}
|
|
70
45
|
catch (err) {
|
|
71
46
|
return apiErrorResult(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../src/tools/verification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../src/tools/verification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,UAAU,yBAAyB,CAAC,GAAc,EAAE,MAAsB;IAC9E,GAAG,CAAC,YAAY,CACd,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,+GAA+G;QAC5H,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;SAChE;QACD,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB;QACD,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC;KAClC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAChE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACzE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CACF,CAAC;IAEF,GAAG,CAAC,YAAY,CACd,yBAAyB,EACzB;QACE,KAAK,EAAE,yBAAyB;QAChC,WAAW,EAAE,oGAAoG;QACjH,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;SACvF;QACD,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB;QACD,KAAK,EAAE,QAAQ,CAAC,yBAAyB,CAAC;KAC3C,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACnE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACzE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -48,7 +48,6 @@ Profiles:
|
|
|
48
48
|
audit Compliance monitoring: mandates, receipts, events, verification, disputes, dashboard
|
|
49
49
|
schema-dev Custom contract type authoring with workflow guidance
|
|
50
50
|
openclaw Lightweight notarization for agent-to-agent agreements (5 tools)
|
|
51
|
-
code Power-user mode: execute SDK code directly via sdk_execute (2 tools)
|
|
52
51
|
federation Federation gateway operations + admin
|
|
53
52
|
full All tools (development/debugging only)
|
|
54
53
|
|
|
@@ -73,7 +72,6 @@ Choose a profile to control which tools are available:
|
|
|
73
72
|
audit Compliance monitoring — mandates, events, verification, disputes, dashboard
|
|
74
73
|
schema-dev Custom contract type authoring
|
|
75
74
|
openclaw Lightweight notarization (5 tools)
|
|
76
|
-
code SDK code execution (2 tools)
|
|
77
75
|
federation Federation gateway operations + admin
|
|
78
76
|
full All tools (development/debugging only)
|
|
79
77
|
|
|
@@ -81,7 +79,7 @@ Example: agledger-mcp --api-key <key> --profile agent
|
|
|
81
79
|
`);
|
|
82
80
|
process.exit(1);
|
|
83
81
|
}
|
|
84
|
-
const profile = profileRaw as 'full' | 'agent' | 'openclaw' | 'schema-dev' | 'admin' | 'audit' | '
|
|
82
|
+
const profile = profileRaw as 'full' | 'agent' | 'openclaw' | 'schema-dev' | 'admin' | 'audit' | 'federation';
|
|
85
83
|
const enterpriseId = values['enterprise-id'] ?? process.env.AGLEDGER_ENTERPRISE_ID;
|
|
86
84
|
|
|
87
85
|
if (!apiKey) {
|
package/src/server.ts
CHANGED
|
@@ -19,16 +19,15 @@ import { registerComplianceTools } from './tools/compliance.js';
|
|
|
19
19
|
import { registerFederationTools } from './tools/federation.js';
|
|
20
20
|
import { registerFederationAdminTools } from './tools/federation-admin.js';
|
|
21
21
|
import { registerAgentsRefsTools } from './tools/agents-refs.js';
|
|
22
|
-
import { registerCodeModeTools } from './tools/code-mode.js';
|
|
23
22
|
import { registerVerificationKeysTools } from './tools/verification-keys.js';
|
|
24
23
|
import { registerContractTypeResources } from './resources/contract-types.js';
|
|
25
24
|
|
|
26
|
-
export type ToolProfile = 'full' | '
|
|
25
|
+
export type ToolProfile = 'full' | 'agent' | 'openclaw' | 'schema-dev' | 'admin' | 'audit' | 'federation';
|
|
27
26
|
|
|
28
27
|
export interface AgledgerMcpServerOptions {
|
|
29
28
|
apiKey: string;
|
|
30
29
|
apiUrl?: string;
|
|
31
|
-
/** Tool profile: "
|
|
30
|
+
/** Tool profile: "agent", "openclaw", "schema-dev", "admin", "audit", "federation", or "full" (legacy, all individual tools). */
|
|
32
31
|
profile?: ToolProfile;
|
|
33
32
|
/** Enterprise ID for A2A search queries. Falls back to AGLEDGER_ENTERPRISE_ID env var. */
|
|
34
33
|
enterpriseId?: string;
|
|
@@ -38,7 +37,6 @@ type RegisterFn = (mcp: McpServer, client: AgledgerClient) => void;
|
|
|
38
37
|
|
|
39
38
|
function buildProfileRegistry(enterpriseId?: string): Record<ToolProfile, RegisterFn[]> {
|
|
40
39
|
return {
|
|
41
|
-
code: [registerCodeModeTools],
|
|
42
40
|
openclaw: [registerOpenClawTools],
|
|
43
41
|
agent: [
|
|
44
42
|
(mcp, client) => registerA2aTools(mcp, client, { enterpriseId }),
|
|
@@ -118,7 +116,7 @@ export class AgledgerMcpServer {
|
|
|
118
116
|
this.mcp = new McpServer(
|
|
119
117
|
{
|
|
120
118
|
name: 'agledger-mcp-server',
|
|
121
|
-
version: '1.
|
|
119
|
+
version: '1.5.0',
|
|
122
120
|
},
|
|
123
121
|
{
|
|
124
122
|
capabilities: {
|
package/src/tool-scopes.ts
CHANGED
|
@@ -161,10 +161,6 @@ export const TOOL_SCOPES: Record<string, string[]> = {
|
|
|
161
161
|
federation_reset_reputation: ['admin:system'],
|
|
162
162
|
federation_get_mandate_criteria_status: ['admin:system'],
|
|
163
163
|
|
|
164
|
-
// Code mode
|
|
165
|
-
sdk_execute: [],
|
|
166
|
-
sdk_describe: [],
|
|
167
|
-
|
|
168
164
|
// OpenClaw
|
|
169
165
|
agledger_notarize: ['mandates:write', 'receipts:write'],
|
|
170
166
|
agledger_receipt: ['receipts:write'],
|
package/src/tools/a2a.ts
CHANGED
|
@@ -10,56 +10,6 @@ export interface A2aToolsConfig {
|
|
|
10
10
|
enterpriseId?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const A2aMandateOutputSchema = z
|
|
14
|
-
.object({
|
|
15
|
-
id: z.string().describe('Mandate ID'),
|
|
16
|
-
status: z.string().describe('Mandate lifecycle status'),
|
|
17
|
-
contractType: z.string().describe('Contract type identifier'),
|
|
18
|
-
principalAgentId: z.string().optional().describe('Agent who proposed the work'),
|
|
19
|
-
agentId: z.string().optional().describe('Agent assigned to do the work'),
|
|
20
|
-
})
|
|
21
|
-
.passthrough()
|
|
22
|
-
.describe('Mandate details');
|
|
23
|
-
|
|
24
|
-
const ProposalsOutputSchema = z
|
|
25
|
-
.object({
|
|
26
|
-
proposals: z.array(A2aMandateOutputSchema).describe('Pending proposals'),
|
|
27
|
-
active: z.array(A2aMandateOutputSchema).describe('Active mandates needing receipts'),
|
|
28
|
-
verified: z.array(A2aMandateOutputSchema).describe('Mandates ready to settle'),
|
|
29
|
-
})
|
|
30
|
-
.describe('Current proposals and obligations');
|
|
31
|
-
|
|
32
|
-
const ReceiptResultOutputSchema = z
|
|
33
|
-
.object({
|
|
34
|
-
receipt: z
|
|
35
|
-
.object({
|
|
36
|
-
id: z.string().describe('Receipt ID'),
|
|
37
|
-
status: z.string().describe('Receipt status'),
|
|
38
|
-
})
|
|
39
|
-
.passthrough()
|
|
40
|
-
.describe('Submitted receipt'),
|
|
41
|
-
mandateStatus: z.string().describe('Mandate status after receipt submission'),
|
|
42
|
-
})
|
|
43
|
-
.describe('Receipt submission result');
|
|
44
|
-
|
|
45
|
-
const MandateListOutputSchema = z
|
|
46
|
-
.object({
|
|
47
|
-
mandates: z.array(A2aMandateOutputSchema).describe('All mandates'),
|
|
48
|
-
byStatus: z
|
|
49
|
-
.record(z.string(), z.array(A2aMandateOutputSchema))
|
|
50
|
-
.describe('Mandates grouped by status'),
|
|
51
|
-
})
|
|
52
|
-
.describe('Mandate list grouped by status');
|
|
53
|
-
|
|
54
|
-
const ReputationOutputSchema = z
|
|
55
|
-
.object({
|
|
56
|
-
agentId: z.string().describe('Agent ID'),
|
|
57
|
-
score: z.number().optional().describe('Reputation score'),
|
|
58
|
-
fulfillmentRate: z.number().optional().describe('Fulfillment rate'),
|
|
59
|
-
})
|
|
60
|
-
.passthrough()
|
|
61
|
-
.describe('Agent reputation details');
|
|
62
|
-
|
|
63
13
|
function getEnterpriseId(config: A2aToolsConfig): string {
|
|
64
14
|
return config.enterpriseId ?? process.env.AGLEDGER_ENTERPRISE_ID ?? '';
|
|
65
15
|
}
|
|
@@ -74,7 +24,7 @@ export function registerA2aTools(
|
|
|
74
24
|
{
|
|
75
25
|
title: 'Create Mandate',
|
|
76
26
|
description:
|
|
77
|
-
'Create a mandate for work you will do. Your identity is inferred from your API key. The mandate is auto-activated so you can submit a receipt immediately. Use propose_mandate instead when delegating to another agent.',
|
|
27
|
+
'Create a mandate for work you will do. Your identity is inferred from your API key. The mandate is auto-activated so you can submit a receipt immediately. Use propose_mandate instead when delegating to another agent. Criteria describe WHAT must be done (e.g. {"task": "generate report", "format": "PDF"}). Do NOT put receipt evidence fields (item_description, total_cost, etc.) in criteria — those go in submit_receipt evidence.',
|
|
78
28
|
inputSchema: {
|
|
79
29
|
contractType: ContractTypeEnum,
|
|
80
30
|
criteria: z
|
|
@@ -84,7 +34,6 @@ export function registerA2aTools(
|
|
|
84
34
|
projectRef: z.string().optional().describe('Project grouping ID'),
|
|
85
35
|
deadline: z.string().optional().describe('ISO 8601 future deadline'),
|
|
86
36
|
},
|
|
87
|
-
outputSchema: A2aMandateOutputSchema,
|
|
88
37
|
annotations: {
|
|
89
38
|
readOnlyHint: false,
|
|
90
39
|
destructiveHint: false,
|
|
@@ -115,15 +64,7 @@ export function registerA2aTools(
|
|
|
115
64
|
deadline,
|
|
116
65
|
autoActivate: true,
|
|
117
66
|
});
|
|
118
|
-
return {
|
|
119
|
-
content: [
|
|
120
|
-
{
|
|
121
|
-
type: 'text',
|
|
122
|
-
text: `Mandate ${mandate.id} created and activated (${mandate.contractType}). Status: ${mandate.status}. Do the work, then call submit_receipt with mandateId="${mandate.id}" and evidence of completion. This is REQUIRED to close the accountability loop.`,
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
structuredContent: toStructuredContent(mandate),
|
|
126
|
-
};
|
|
67
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
127
68
|
} catch (err) {
|
|
128
69
|
return apiErrorResult(err);
|
|
129
70
|
}
|
|
@@ -146,7 +87,6 @@ export function registerA2aTools(
|
|
|
146
87
|
parentMandateId: z.string().optional().describe('Parent mandate if delegating'),
|
|
147
88
|
deadline: z.string().optional().describe('ISO 8601 future deadline'),
|
|
148
89
|
},
|
|
149
|
-
outputSchema: A2aMandateOutputSchema,
|
|
150
90
|
annotations: {
|
|
151
91
|
readOnlyHint: false,
|
|
152
92
|
destructiveHint: false,
|
|
@@ -177,15 +117,7 @@ export function registerA2aTools(
|
|
|
177
117
|
parentMandateId: args.parentMandateId,
|
|
178
118
|
deadline,
|
|
179
119
|
});
|
|
180
|
-
return {
|
|
181
|
-
content: [
|
|
182
|
-
{
|
|
183
|
-
type: 'text',
|
|
184
|
-
text: `Mandate ${mandate.id} proposed (${mandate.contractType}). Status: ${mandate.status}. The performer must call accept_mandate to begin. CRITICAL: after work is done, call submit_receipt — this is REQUIRED to close the accountability loop. A mandate without a receipt is an unfulfilled commitment.`,
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
structuredContent: toStructuredContent(mandate),
|
|
188
|
-
};
|
|
120
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
189
121
|
} catch (err) {
|
|
190
122
|
return apiErrorResult(err);
|
|
191
123
|
}
|
|
@@ -201,7 +133,6 @@ export function registerA2aTools(
|
|
|
201
133
|
inputSchema: {
|
|
202
134
|
mandateId: z.string().describe('Mandate ID to accept'),
|
|
203
135
|
},
|
|
204
|
-
outputSchema: A2aMandateOutputSchema,
|
|
205
136
|
annotations: {
|
|
206
137
|
readOnlyHint: false,
|
|
207
138
|
destructiveHint: false,
|
|
@@ -223,37 +154,7 @@ export function registerA2aTools(
|
|
|
223
154
|
}
|
|
224
155
|
}
|
|
225
156
|
|
|
226
|
-
|
|
227
|
-
const evidenceTemplates: Record<string, string> = {
|
|
228
|
-
'ACH-ANALYZE-v1':
|
|
229
|
-
'{"deliverable": "your analysis text", "deliverable_type": "report", "summary": "key findings"}',
|
|
230
|
-
'ACH-COORD-v1':
|
|
231
|
-
'{"deliverable": "coordination outcome", "deliverable_type": "report", "summary": "what was coordinated"}',
|
|
232
|
-
'ACH-DATA-v1': '{"deliverable": "data results", "deliverable_type": "report"}',
|
|
233
|
-
'ACH-DLVR-v1': '{"deliverable": "artifact content", "deliverable_type": "document"}',
|
|
234
|
-
'ACH-PROC-v1':
|
|
235
|
-
'{"item_description": "item name", "quantity": 1, "total_cost": {"amount": 100, "currency": "USD"}, "supplier": {"id": "S1", "name": "Supplier"}, "confirmation_ref": "REF-1"}',
|
|
236
|
-
'ACH-TXN-v1':
|
|
237
|
-
'{"confirmations": [{"ref": "T1", "type": "payment", "provider": "provider", "cost": {"amount": 100, "currency": "USD"}}]}',
|
|
238
|
-
'ACH-COMM-v1': '{"deliverable": "communication sent", "deliverable_type": "report"}',
|
|
239
|
-
'ACH-AUTH-v1': '{"deliverable": "auth action completed", "deliverable_type": "report"}',
|
|
240
|
-
'ACH-INFRA-v1': '{"deliverable": "infrastructure change", "deliverable_type": "report"}',
|
|
241
|
-
'ACH-DEL-v1': '{"deliverable": "deletion completed", "deliverable_type": "report"}',
|
|
242
|
-
'ACH-ORCH-v1': '{"deliverable": "orchestration result", "deliverable_type": "report"}',
|
|
243
|
-
};
|
|
244
|
-
const ct = (mandate as any).contractType as string;
|
|
245
|
-
const template =
|
|
246
|
-
evidenceTemplates[ct] || '{"deliverable": "work result", "deliverable_type": "report"}';
|
|
247
|
-
|
|
248
|
-
return {
|
|
249
|
-
content: [
|
|
250
|
-
{
|
|
251
|
-
type: 'text',
|
|
252
|
-
text: `Mandate ${mandate.id} accepted and activated (${ct}). Status: ${mandate.status}.\n\nNEXT STEP: Do the work, then call submit_receipt with mandateId="${mandate.id}" and evidence=${template}\n\nThis is REQUIRED — do NOT skip the receipt.`,
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
structuredContent: toStructuredContent(mandate),
|
|
256
|
-
};
|
|
157
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
257
158
|
} catch (err) {
|
|
258
159
|
return apiErrorResult(err);
|
|
259
160
|
}
|
|
@@ -268,7 +169,6 @@ export function registerA2aTools(
|
|
|
268
169
|
inputSchema: {
|
|
269
170
|
agentId: z.string().optional().describe('Your agent ID'),
|
|
270
171
|
},
|
|
271
|
-
outputSchema: ProposalsOutputSchema,
|
|
272
172
|
annotations: {
|
|
273
173
|
readOnlyHint: true,
|
|
274
174
|
destructiveHint: false,
|
|
@@ -279,71 +179,34 @@ export function registerA2aTools(
|
|
|
279
179
|
},
|
|
280
180
|
async (args) => {
|
|
281
181
|
try {
|
|
282
|
-
// Agent keys automatically scope to their mandates — don't pass enterpriseId
|
|
283
|
-
// Enterprise keys need enterpriseId for scoping
|
|
284
182
|
const enterpriseId = getEnterpriseId(config);
|
|
285
183
|
|
|
286
|
-
// Search mandates — agent key auto-scopes, enterprise key needs enterpriseId
|
|
287
184
|
const searchParams: Record<string, unknown> = { limit: 100 };
|
|
288
185
|
if (enterpriseId) searchParams.enterpriseId = enterpriseId;
|
|
289
186
|
|
|
290
187
|
const results = await client.mandates.search(searchParams as any);
|
|
291
|
-
|
|
292
188
|
const allMandates = results.data || [];
|
|
293
189
|
|
|
294
190
|
// Client-side status filtering (backend status param unreliable)
|
|
295
|
-
let
|
|
296
|
-
let
|
|
297
|
-
let
|
|
191
|
+
let proposals = allMandates.filter((m: any) => m.status === 'PROPOSED');
|
|
192
|
+
let active = allMandates.filter((m: any) => m.status === 'ACTIVE');
|
|
193
|
+
let verified = allMandates.filter((m: any) => m.status === 'PROCESSING');
|
|
298
194
|
|
|
299
195
|
// Filter to this agent if ID provided
|
|
300
196
|
if (args.agentId) {
|
|
301
197
|
const id = args.agentId;
|
|
302
|
-
|
|
198
|
+
proposals = proposals.filter(
|
|
303
199
|
(m: any) => m.agentId === id || m.principalAgentId === id,
|
|
304
200
|
);
|
|
305
|
-
|
|
306
|
-
|
|
201
|
+
active = active.filter((m: any) => m.agentId === id || m.principalAgentId === id);
|
|
202
|
+
verified = verified.filter(
|
|
307
203
|
(m: any) => m.agentId === id || m.principalAgentId === id,
|
|
308
204
|
);
|
|
309
205
|
}
|
|
310
206
|
|
|
311
|
-
let text = ` ${allProposals.length} pending proposal(s)`;
|
|
312
|
-
if (allProposals.length > 0) {
|
|
313
|
-
text +=
|
|
314
|
-
':\n' +
|
|
315
|
-
allProposals
|
|
316
|
-
.map(
|
|
317
|
-
(m: any) =>
|
|
318
|
-
` • ${m.id} (${m.contractType}) from ${m.principalAgentId?.slice(0, 8)}... — ${JSON.stringify(m.criteria).slice(0, 100)}`,
|
|
319
|
-
)
|
|
320
|
-
.join('\n');
|
|
321
|
-
text += '\n\n→ Call accept_mandate with the mandate ID to accept.';
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (allActive.length > 0) {
|
|
325
|
-
text += `\n\n ${allActive.length} ACTIVE mandate(s) need receipts:`;
|
|
326
|
-
for (const m of allActive.slice(0, 5)) {
|
|
327
|
-
text += `\n • ${m.id} (${(m as any).contractType})`;
|
|
328
|
-
}
|
|
329
|
-
text += '\n→ Call submit_receipt with evidence of completed work!';
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (allVerified.length > 0) {
|
|
333
|
-
text += `\n\n ${allVerified.length} mandate(s) ready to settle:`;
|
|
334
|
-
for (const m of allVerified.slice(0, 5)) {
|
|
335
|
-
text += `\n • ${m.id} (${(m as any).contractType})`;
|
|
336
|
-
}
|
|
337
|
-
text += '\n→ These should auto-settle soon, or call settle_mandate to close manually.';
|
|
338
|
-
}
|
|
339
|
-
|
|
340
207
|
return {
|
|
341
|
-
content: [
|
|
342
|
-
structuredContent: toStructuredContent({
|
|
343
|
-
proposals: allProposals,
|
|
344
|
-
active: allActive,
|
|
345
|
-
verified: allVerified,
|
|
346
|
-
}),
|
|
208
|
+
content: [],
|
|
209
|
+
structuredContent: toStructuredContent({ proposals, active, verified }),
|
|
347
210
|
};
|
|
348
211
|
} catch (err) {
|
|
349
212
|
return apiErrorResult(err);
|
|
@@ -356,12 +219,11 @@ export function registerA2aTools(
|
|
|
356
219
|
{
|
|
357
220
|
title: 'Submit Receipt',
|
|
358
221
|
description:
|
|
359
|
-
'Submit evidence of completed work. REQUIRED to close the accountability loop. Evidence: {"deliverable": "result", "deliverable_type": "report"}
|
|
222
|
+
'Submit evidence of completed work. REQUIRED to close the accountability loop. Evidence documents WHAT WAS DONE (not what was asked — that goes in mandate criteria). Common evidence: {"deliverable": "result", "deliverable_type": "report"}. PROC evidence: {"item_description": "...", "quantity": N, "total_cost": N, "supplier": "...", "confirmation_ref": "..."}.',
|
|
360
223
|
inputSchema: {
|
|
361
224
|
mandateId: z.string().describe('Mandate ID'),
|
|
362
225
|
evidence: z.record(z.string(), z.unknown()).describe('Evidence of completion'),
|
|
363
226
|
},
|
|
364
|
-
outputSchema: ReceiptResultOutputSchema,
|
|
365
227
|
annotations: {
|
|
366
228
|
readOnlyHint: false,
|
|
367
229
|
destructiveHint: false,
|
|
@@ -374,31 +236,7 @@ export function registerA2aTools(
|
|
|
374
236
|
try {
|
|
375
237
|
const { mandateId, ...submitParams } = args;
|
|
376
238
|
const receipt = await client.receipts.submit(mandateId, submitParams);
|
|
377
|
-
|
|
378
|
-
let mandateStatus = '';
|
|
379
|
-
try {
|
|
380
|
-
const mandate = await client.mandates.get(mandateId);
|
|
381
|
-
mandateStatus = mandate.status;
|
|
382
|
-
} catch {
|
|
383
|
-
/* best effort */
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
let text = `Receipt ${receipt.id} submitted for mandate ${mandateId}. Validation: ${receipt.structuralValidation}.`;
|
|
387
|
-
if (mandateStatus) {
|
|
388
|
-
text += `Mandate is now: ${mandateStatus}.`;
|
|
389
|
-
}
|
|
390
|
-
if (mandateStatus === 'FULFILLED') {
|
|
391
|
-
text += `\n\nMandate auto-settled to FULFILLED! Accountability loop closed.`;
|
|
392
|
-
} else if (mandateStatus === 'PROCESSING' || mandateStatus === 'PROCESSING') {
|
|
393
|
-
text += `\n\nCall settle_mandate("${mandateId}") to close this mandate (or wait for auto-settle).`;
|
|
394
|
-
} else if (mandateStatus === 'ACTIVE') {
|
|
395
|
-
text += `Evidence is being verified.`;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return {
|
|
399
|
-
content: [{ type: 'text', text }],
|
|
400
|
-
structuredContent: toStructuredContent({ receipt, mandateStatus }),
|
|
401
|
-
};
|
|
239
|
+
return { content: [], structuredContent: toStructuredContent(receipt) };
|
|
402
240
|
} catch (err) {
|
|
403
241
|
return apiErrorResult(err);
|
|
404
242
|
}
|
|
@@ -415,7 +253,6 @@ export function registerA2aTools(
|
|
|
415
253
|
mandateId: z.string().describe('Mandate ID'),
|
|
416
254
|
reason: z.string().optional().describe('Settlement reason'),
|
|
417
255
|
},
|
|
418
|
-
outputSchema: A2aMandateOutputSchema,
|
|
419
256
|
annotations: {
|
|
420
257
|
readOnlyHint: false,
|
|
421
258
|
destructiveHint: false,
|
|
@@ -427,15 +264,7 @@ export function registerA2aTools(
|
|
|
427
264
|
async (args) => {
|
|
428
265
|
try {
|
|
429
266
|
const mandate = await client.mandates.transition(args.mandateId, 'settle', args.reason);
|
|
430
|
-
return {
|
|
431
|
-
content: [
|
|
432
|
-
{
|
|
433
|
-
type: 'text',
|
|
434
|
-
text: `Mandate ${mandate.id} settled. Status: ${mandate.status}. Accountability loop closed.`,
|
|
435
|
-
},
|
|
436
|
-
],
|
|
437
|
-
structuredContent: toStructuredContent(mandate),
|
|
438
|
-
};
|
|
267
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
439
268
|
} catch (err) {
|
|
440
269
|
return apiErrorResult(err);
|
|
441
270
|
}
|
|
@@ -450,7 +279,6 @@ export function registerA2aTools(
|
|
|
450
279
|
inputSchema: {
|
|
451
280
|
mandateId: z.string().describe('Mandate ID'),
|
|
452
281
|
},
|
|
453
|
-
outputSchema: A2aMandateOutputSchema,
|
|
454
282
|
annotations: {
|
|
455
283
|
readOnlyHint: true,
|
|
456
284
|
destructiveHint: false,
|
|
@@ -462,16 +290,7 @@ export function registerA2aTools(
|
|
|
462
290
|
async (args) => {
|
|
463
291
|
try {
|
|
464
292
|
const mandate = await client.mandates.get(args.mandateId);
|
|
465
|
-
|
|
466
|
-
if (mandate.status === 'ACTIVE')
|
|
467
|
-
text += '\n This mandate needs a receipt — call submit_receipt!';
|
|
468
|
-
if (mandate.status === 'PROCESSING')
|
|
469
|
-
text += '\n Should auto-settle to FULFILLED soon. Call settle_mandate if stuck.';
|
|
470
|
-
if (mandate.status === 'FULFILLED') text += '\n Accountability loop closed.';
|
|
471
|
-
return {
|
|
472
|
-
content: [{ type: 'text', text }],
|
|
473
|
-
structuredContent: toStructuredContent(mandate),
|
|
474
|
-
};
|
|
293
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
475
294
|
} catch (err) {
|
|
476
295
|
return apiErrorResult(err);
|
|
477
296
|
}
|
|
@@ -487,7 +306,6 @@ export function registerA2aTools(
|
|
|
487
306
|
mandateId: z.string().describe('Mandate ID'),
|
|
488
307
|
reason: z.string().describe('Rejection reason'),
|
|
489
308
|
},
|
|
490
|
-
outputSchema: A2aMandateOutputSchema,
|
|
491
309
|
annotations: {
|
|
492
310
|
readOnlyHint: false,
|
|
493
311
|
destructiveHint: true,
|
|
@@ -499,12 +317,7 @@ export function registerA2aTools(
|
|
|
499
317
|
async (args) => {
|
|
500
318
|
try {
|
|
501
319
|
const mandate = await client.mandates.reject(args.mandateId, args.reason);
|
|
502
|
-
return {
|
|
503
|
-
content: [
|
|
504
|
-
{ type: 'text', text: `Mandate ${mandate.id} rejected. Reason: ${args.reason}` },
|
|
505
|
-
],
|
|
506
|
-
structuredContent: toStructuredContent(mandate),
|
|
507
|
-
};
|
|
320
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
508
321
|
} catch (err) {
|
|
509
322
|
return apiErrorResult(err);
|
|
510
323
|
}
|
|
@@ -519,7 +332,6 @@ export function registerA2aTools(
|
|
|
519
332
|
inputSchema: {
|
|
520
333
|
agentId: z.string().optional().describe('Your agent ID'),
|
|
521
334
|
},
|
|
522
|
-
outputSchema: MandateListOutputSchema,
|
|
523
335
|
annotations: {
|
|
524
336
|
readOnlyHint: true,
|
|
525
337
|
destructiveHint: false,
|
|
@@ -532,7 +344,6 @@ export function registerA2aTools(
|
|
|
532
344
|
try {
|
|
533
345
|
const enterpriseId = getEnterpriseId(config);
|
|
534
346
|
|
|
535
|
-
// Agent keys auto-scope — don't require enterpriseId
|
|
536
347
|
const searchParams: Record<string, unknown> = { limit: 100 };
|
|
537
348
|
if (enterpriseId) searchParams.enterpriseId = enterpriseId;
|
|
538
349
|
|
|
@@ -554,20 +365,8 @@ export function registerA2aTools(
|
|
|
554
365
|
byStatus[s].push(m);
|
|
555
366
|
}
|
|
556
367
|
|
|
557
|
-
let text = ` ${filtered.length} mandate(s) total:`;
|
|
558
|
-
for (const [status, mandates] of Object.entries(byStatus)) {
|
|
559
|
-
text += `\n ${status}: ${mandates.length}`;
|
|
560
|
-
if (status === 'ACTIVE') text += ' need receipts!';
|
|
561
|
-
if (status === 'PROCESSING') text += ' ready to settle!';
|
|
562
|
-
if (status === 'PROPOSED') text += ' — awaiting response';
|
|
563
|
-
for (const m of mandates.slice(0, 3)) {
|
|
564
|
-
text += `\n • ${m.id.slice(0, 8)}... (${m.contractType})`;
|
|
565
|
-
}
|
|
566
|
-
if (mandates.length > 3) text += `\n ... and ${mandates.length - 3} more`;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
368
|
return {
|
|
570
|
-
content: [
|
|
369
|
+
content: [],
|
|
571
370
|
structuredContent: toStructuredContent({ mandates: filtered, byStatus }),
|
|
572
371
|
};
|
|
573
372
|
} catch (err) {
|
|
@@ -585,7 +384,6 @@ export function registerA2aTools(
|
|
|
585
384
|
mandateId: z.string().describe('Mandate ID'),
|
|
586
385
|
reason: z.string().describe('Cancellation reason'),
|
|
587
386
|
},
|
|
588
|
-
outputSchema: A2aMandateOutputSchema,
|
|
589
387
|
annotations: {
|
|
590
388
|
readOnlyHint: false,
|
|
591
389
|
destructiveHint: true,
|
|
@@ -597,12 +395,7 @@ export function registerA2aTools(
|
|
|
597
395
|
async (args) => {
|
|
598
396
|
try {
|
|
599
397
|
const mandate = await client.mandates.cancel(args.mandateId, args.reason);
|
|
600
|
-
return {
|
|
601
|
-
content: [
|
|
602
|
-
{ type: 'text', text: `Mandate ${mandate.id} cancelled. Reason: ${args.reason}` },
|
|
603
|
-
],
|
|
604
|
-
structuredContent: toStructuredContent(mandate),
|
|
605
|
-
};
|
|
398
|
+
return { content: [], structuredContent: toStructuredContent(mandate) };
|
|
606
399
|
} catch (err) {
|
|
607
400
|
return apiErrorResult(err);
|
|
608
401
|
}
|
|
@@ -617,7 +410,6 @@ export function registerA2aTools(
|
|
|
617
410
|
inputSchema: {
|
|
618
411
|
agentId: z.string().describe('Agent ID'),
|
|
619
412
|
},
|
|
620
|
-
outputSchema: ReputationOutputSchema,
|
|
621
413
|
annotations: {
|
|
622
414
|
readOnlyHint: true,
|
|
623
415
|
destructiveHint: false,
|
|
@@ -629,12 +421,7 @@ export function registerA2aTools(
|
|
|
629
421
|
async (args) => {
|
|
630
422
|
try {
|
|
631
423
|
const rep = await client.reputation.getAgent(args.agentId);
|
|
632
|
-
return {
|
|
633
|
-
content: [
|
|
634
|
-
{ type: 'text', text: `Agent ${args.agentId} reputation: ${JSON.stringify(rep)}` },
|
|
635
|
-
],
|
|
636
|
-
structuredContent: toStructuredContent(rep),
|
|
637
|
-
};
|
|
424
|
+
return { content: [], structuredContent: toStructuredContent(rep) };
|
|
638
425
|
} catch (err) {
|
|
639
426
|
return apiErrorResult(err);
|
|
640
427
|
}
|