@bosonprotocol/agentic-commerce 1.0.0-alpha.72 → 1.0.0-alpha.73
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/boson/goat-sdk-plugin/parameters.d.ts +2 -2
- package/dist/boson/mcp-server/external-tools/github.d.ts +473 -0
- package/dist/boson/mcp-server/external-tools/github.d.ts.map +1 -0
- package/dist/boson/mcp-server/external-tools/github.js +137 -0
- package/dist/boson/mcp-server/external-tools/github.js.map +1 -0
- package/dist/boson/mcp-server/external-tools/jsonSchemaValidator.d.ts +21 -0
- package/dist/boson/mcp-server/external-tools/jsonSchemaValidator.d.ts.map +1 -0
- package/dist/boson/mcp-server/external-tools/jsonSchemaValidator.js +102 -0
- package/dist/boson/mcp-server/external-tools/jsonSchemaValidator.js.map +1 -0
- package/dist/boson/mcp-server/external-tools/verify-signature.d.ts +15 -0
- package/dist/boson/mcp-server/external-tools/verify-signature.d.ts.map +1 -0
- package/dist/boson/mcp-server/external-tools/verify-signature.js +40 -0
- package/dist/boson/mcp-server/external-tools/verify-signature.js.map +1 -0
- package/dist/boson/mcp-server/handlers/agentRegistry.d.ts +4 -0
- package/dist/boson/mcp-server/handlers/agentRegistry.d.ts.map +1 -0
- package/dist/boson/mcp-server/handlers/agentRegistry.js +117 -0
- package/dist/boson/mcp-server/handlers/agentRegistry.js.map +1 -0
- package/dist/boson/mcp-server/index.d.ts.map +1 -1
- package/dist/boson/mcp-server/index.js +61 -10
- package/dist/boson/mcp-server/index.js.map +1 -1
- package/dist/boson/mcp-server/resourceParameterTypes.d.ts +86 -0
- package/dist/boson/mcp-server/resourceParameterTypes.d.ts.map +1 -1
- package/dist/boson/mcp-server/resourceParameterTypes.js +14 -1
- package/dist/boson/mcp-server/resourceParameterTypes.js.map +1 -1
- package/dist/boson/mcp-server/validation.d.ts +45 -2
- package/dist/boson/mcp-server/validation.d.ts.map +1 -1
- package/dist/boson/mcp-server/validation.js +2 -1
- package/dist/boson/mcp-server/validation.js.map +1 -1
- package/dist/common/mcp-client/index.d.ts +2 -1
- package/dist/common/mcp-client/index.d.ts.map +1 -1
- package/dist/common/mcp-client/index.js +2 -2
- package/dist/common/mcp-client/index.js.map +1 -1
- package/dist/common/mcp-server/validationUtils.d.ts +1 -0
- package/dist/common/mcp-server/validationUtils.d.ts.map +1 -1
- package/dist/common/mcp-server/validationUtils.js +11 -1
- package/dist/common/mcp-server/validationUtils.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../../../src/boson/mcp-server/external-tools/github.ts"],"names":[],"mappings":";;;AAAA,wEAAmE;AACnE,0FAAmG;AAEnG,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;AAC5D,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,MAAM,eAAe;IACT,YAAY,GAAG,KAAK,CAAC;IACrB,SAAS,GAAyC,IAAI,CAAC;IACvD,GAAG,CAAS;IAEtB;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,iBAAM,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,iDAA6B,CAChD,IAAI,GAAG,CAAC,cAAc,CAAC,EACvB;gBACE,WAAW,EAAE;oBACX,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,UAAU,EAAE,EAAE;iBACnD;aACF,CACF,CAAC;YACF,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACvC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;QAAC,OA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,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAC/B,CAAC;QACD,qCAAqC;QAErC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;YACvB,IAAI,EAAE,uBAAuB;YAC7B,SAAS,EAAE;gBACT,KAAK,EAAE,YAAY;gBACnB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,OAAO;gBACP,MAAM;gBACN,OAAO,EAAE,OAAO,IAAI,eAAe,QAAQ,EAAE;aAC9C;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,EACtB,YAAY,EACZ,UAAU,EACV,MAAM,EACN,KAAK,EACL,IAAI,GAOL;QACC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAC/B,CAAC;QACD,6CAA6C;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC;QACpB,MAAM,qBAAqB,GAAG,KAAK,CAAC;QAEpC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;YACvB,IAAI,EAAE,qBAAqB;YAC3B,SAAS,EAAE;gBACT,KAAK,EAAE,YAAY;gBACnB,IAAI,EAAE,UAAU;gBAChB,KAAK;gBACL,IAAI;gBACJ,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,KAAK;gBACZ,qBAAqB,EAAE,qBAAqB;gBAC5C,MAAM,EAAE,CAAC,oBAAoB,CAAC;aAC/B;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAEY,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ValidationResult {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
errors?: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare class JsonSchemaValidator {
|
|
6
|
+
private ajv;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Fetches a JSON schema from a URL
|
|
10
|
+
*/
|
|
11
|
+
private fetchSchema;
|
|
12
|
+
/**
|
|
13
|
+
* Validates a JSON object against a schema fetched from URL
|
|
14
|
+
*/
|
|
15
|
+
validateAgainstRemoteSchema(jsonData: any, schemaUrl: string): Promise<ValidationResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Validates against a local schema object
|
|
18
|
+
*/
|
|
19
|
+
validateAgainstLocalSchema(jsonData: any, schema: object): ValidationResult;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=jsonSchemaValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSchemaValidator.d.ts","sourceRoot":"","sources":["../../../../src/boson/mcp-server/external-tools/jsonSchemaValidator.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,GAAG,CAAM;;IAcjB;;OAEG;YACW,WAAW;IAmBzB;;OAEG;IACG,2BAA2B,CAE/B,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC;IAiC5B;;OAEG;IAEH,0BAA0B,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB;CA0B5E"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.JsonSchemaValidator = void 0;
|
|
7
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
8
|
+
const ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
9
|
+
class JsonSchemaValidator {
|
|
10
|
+
ajv;
|
|
11
|
+
constructor() {
|
|
12
|
+
// Initialize AJV with additional formats support
|
|
13
|
+
this.ajv = new ajv_1.default({
|
|
14
|
+
allErrors: true, // Collect all errors, not just the first one
|
|
15
|
+
verbose: true, // Include schema path in error messages
|
|
16
|
+
strict: false, // Allow unknown keywords
|
|
17
|
+
});
|
|
18
|
+
// Add format validators (email, date, uuid, etc.)
|
|
19
|
+
(0, ajv_formats_1.default)(this.ajv);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetches a JSON schema from a URL
|
|
23
|
+
*/
|
|
24
|
+
async fetchSchema(schemaUrl) {
|
|
25
|
+
try {
|
|
26
|
+
const response = await fetch(schemaUrl);
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new Error(`Failed to fetch schema: ${response.status} ${response.statusText}`);
|
|
29
|
+
}
|
|
30
|
+
const schema = (await response.json());
|
|
31
|
+
return schema;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
throw new Error(`Error fetching schema from ${schemaUrl}: ${error}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Validates a JSON object against a schema fetched from URL
|
|
39
|
+
*/
|
|
40
|
+
async validateAgainstRemoteSchema(
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
jsonData, schemaUrl) {
|
|
43
|
+
try {
|
|
44
|
+
// Fetch the schema
|
|
45
|
+
const schema = await this.fetchSchema(schemaUrl);
|
|
46
|
+
// Compile the schema
|
|
47
|
+
const validate = this.ajv.compile(schema);
|
|
48
|
+
// Validate the data
|
|
49
|
+
const isValid = validate(jsonData);
|
|
50
|
+
if (isValid) {
|
|
51
|
+
return { isValid: true };
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const errors = validate.errors?.map((error) => {
|
|
55
|
+
const path = error.instancePath || "root";
|
|
56
|
+
return `${path}: ${error.message}`;
|
|
57
|
+
}) || [];
|
|
58
|
+
return {
|
|
59
|
+
isValid: false,
|
|
60
|
+
errors,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
isValid: false,
|
|
67
|
+
errors: [`Validation failed: ${error}`],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validates against a local schema object
|
|
73
|
+
*/
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
validateAgainstLocalSchema(jsonData, schema) {
|
|
76
|
+
try {
|
|
77
|
+
const validate = this.ajv.compile(schema);
|
|
78
|
+
const isValid = validate(jsonData);
|
|
79
|
+
if (isValid) {
|
|
80
|
+
return { isValid: true };
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const errors = validate.errors?.map((error) => {
|
|
84
|
+
const path = error.instancePath || "root";
|
|
85
|
+
return `${path}: ${error.message}`;
|
|
86
|
+
}) || [];
|
|
87
|
+
return {
|
|
88
|
+
isValid: false,
|
|
89
|
+
errors,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return {
|
|
95
|
+
isValid: false,
|
|
96
|
+
errors: [`Validation failed: ${error}`],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.JsonSchemaValidator = JsonSchemaValidator;
|
|
102
|
+
//# sourceMappingURL=jsonSchemaValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSchemaValidator.js","sourceRoot":"","sources":["../../../../src/boson/mcp-server/external-tools/jsonSchemaValidator.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,8DAAqC;AAOrC,MAAa,mBAAmB;IACtB,GAAG,CAAM;IAEjB;Q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BACd,MAAM,EAAE,CAAC,sBAAsB,KAAc,EAAE,CAAC;aACjD,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA3GD,kDA2GC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface VerificationResult {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
recoveredAddress?: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Verifies the signer of an Ethereum message
|
|
8
|
+
* @param message - The original message that was signed
|
|
9
|
+
* @param signature - The signature in hex format (0x...)
|
|
10
|
+
* @param expectedSigner - Optional: the expected signer address to validate against
|
|
11
|
+
* @returns VerificationResult with validation status and recovered address
|
|
12
|
+
*/
|
|
13
|
+
export declare function verifyEthereumSignature(message: string, signature: string, expectedSigner?: string): VerificationResult;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=verify-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-signature.d.ts","sourceRoot":"","sources":["../../../../src/boson/mcp-server/external-tools/verify-signature.ts"],"names":[],"mappings":"AAEA,UAAU,kBAAkB;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,MAAM,GACtB,kBAAkB,CA6BpB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyEthereumSignature = verifyEthereumSignature;
|
|
4
|
+
const ethers_v6_1 = require("ethers-v6");
|
|
5
|
+
/**
|
|
6
|
+
* Verifies the signer of an Ethereum message
|
|
7
|
+
* @param message - The original message that was signed
|
|
8
|
+
* @param signature - The signature in hex format (0x...)
|
|
9
|
+
* @param expectedSigner - Optional: the expected signer address to validate against
|
|
10
|
+
* @returns VerificationResult with validation status and recovered address
|
|
11
|
+
*/
|
|
12
|
+
function verifyEthereumSignature(message, signature, expectedSigner) {
|
|
13
|
+
try {
|
|
14
|
+
// Recover the address from the message and signature
|
|
15
|
+
const recoveredAddress = ethers_v6_1.ethers.verifyMessage(message, signature);
|
|
16
|
+
// If an expected signer is provided, check if it matches
|
|
17
|
+
if (expectedSigner) {
|
|
18
|
+
const isValid = recoveredAddress.toLowerCase() === expectedSigner.toLowerCase();
|
|
19
|
+
return {
|
|
20
|
+
isValid,
|
|
21
|
+
recoveredAddress,
|
|
22
|
+
error: isValid
|
|
23
|
+
? undefined
|
|
24
|
+
: `Expected ${expectedSigner} but recovered ${recoveredAddress}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// If no expected signer provided, just return the recovered address
|
|
28
|
+
return {
|
|
29
|
+
isValid: true,
|
|
30
|
+
recoveredAddress,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
isValid: false,
|
|
36
|
+
error: `Signature verification failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=verify-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-signature.js","sourceRoot":"","sources":["../../../../src/boson/mcp-server/external-tools/verify-signature.ts"],"names":[],"mappings":";;AAeA,0DAiCC;AAhDD,yCAAmC;AAQnC;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,OAAe,EACf,SAAiB,EACjB,cAAuB;IAEvB,IAAI,CAAC;QACH,qDAAqD;QACrD,MAAM,gBAAgB,GAAG,kBAAM,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAElE,yDAAyD;QACzD,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,OAAO,GACX,gBAAgB,CAAC,WAAW,EAAE,KAAK,cAAc,CAAC,WAAW,EAAE,CAAC;YAClE,OAAO;gBACL,OAAO;gBACP,gBAAgB;gBAChB,KAAK,EAAE,OAAO;oBACZ,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,YAAY,cAAc,kBAAkB,gBAAgB,EAAE;aACnE,CAAC;QACJ,CAAC;QAED,oEAAoE;QACpE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,gBAAgB;SACjB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,kCAAkC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;SACpG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentRegistry.d.ts","sourceRoot":"","sources":["../../../../src/boson/mcp-server/handlers/agentRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAQpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AA8ExD,wBAAgB,oBAAoB,KAEhC,iBAAiB,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,KACvD,OAAO,CAAC,MAAM,CAAC,CAwDnB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAgentHandler = registerAgentHandler;
|
|
4
|
+
const common_1 = require("../../../common");
|
|
5
|
+
const configValidation_1 = require("../../../common/mcp-server/configValidation");
|
|
6
|
+
const jsonUtils_1 = require("../../../common/mcp-server/jsonUtils");
|
|
7
|
+
const github_1 = require("../external-tools/github");
|
|
8
|
+
const jsonSchemaValidator_1 = require("../external-tools/jsonSchemaValidator");
|
|
9
|
+
const verify_signature_1 = require("../external-tools/verify-signature");
|
|
10
|
+
const validation_1 = require("../validation");
|
|
11
|
+
const GH_ORGANISATION = process.env.AGENT_REGISTRY_REPO?.split("/")[0];
|
|
12
|
+
const GH_REPOSITORY = process.env.AGENT_REGISTRY_REPO?.split("/")[1];
|
|
13
|
+
const GH_DIRECTORY = process.env.AGENT_REGISTRY_DIRECTORY;
|
|
14
|
+
const SCHEMA_VERSION = "1.0.0";
|
|
15
|
+
const SCHEMA_URL = (version) => `https://raw.githubusercontent.com/bosonprotocol/dACP-agents-registry/refs/heads/main/schemas/v${version}.json`;
|
|
16
|
+
if (!GH_ORGANISATION || !GH_REPOSITORY || !GH_DIRECTORY) {
|
|
17
|
+
throw new Error(`Environment variables GH_ORGANISATION=${GH_ORGANISATION}, GH_REPOSITORY=${GH_REPOSITORY} and GH_DIRECTORY=${GH_DIRECTORY} must be set`);
|
|
18
|
+
}
|
|
19
|
+
if (!GH_DIRECTORY.match(/^agents\/(local|testing|staging|production)+$/)) {
|
|
20
|
+
throw new Error(`Invalid directory name: ${GH_DIRECTORY}. It should match 'agents/local', 'agents/testing', 'agents/staging', or 'agents/production'.`);
|
|
21
|
+
}
|
|
22
|
+
async function validateAgentDefition(agentDefinition, { uuid, schemaVersion }) {
|
|
23
|
+
const parsed = validation_1.registerAgentValidation.safeParse(agentDefinition);
|
|
24
|
+
if (!parsed.success) {
|
|
25
|
+
throw new Error(`Invalid agent definition: ${JSON.stringify(parsed.error.issues)}`);
|
|
26
|
+
}
|
|
27
|
+
// check the JSON file is valid regarding the schema version
|
|
28
|
+
const jsv = new jsonSchemaValidator_1.JsonSchemaValidator();
|
|
29
|
+
const schemaUrl = SCHEMA_URL(schemaVersion);
|
|
30
|
+
const agentDefinitionOutput = {
|
|
31
|
+
uuid,
|
|
32
|
+
schemaVersion,
|
|
33
|
+
name: parsed.data.name,
|
|
34
|
+
description: parsed.data.description,
|
|
35
|
+
entities: parsed.data.entities.map((entity) => ({
|
|
36
|
+
configId: entity.configId,
|
|
37
|
+
role: entity.role,
|
|
38
|
+
entityId: entity.entityId,
|
|
39
|
+
signerAddress: entity.signerAddress,
|
|
40
|
+
// Ensure the signature is removed from the validation
|
|
41
|
+
// as it will be verified separately (NOT in the schema)
|
|
42
|
+
})),
|
|
43
|
+
};
|
|
44
|
+
const { isValid, errors } = await jsv.validateAgainstRemoteSchema(agentDefinitionOutput, schemaUrl);
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
throw new Error(`Agent definition is not valid against the schema at ${schemaUrl}: ${errors.join(", ")}`);
|
|
47
|
+
}
|
|
48
|
+
for (const entity of parsed.data.entities) {
|
|
49
|
+
// check the configId is valid regarding process.env.CONFIG_IDS
|
|
50
|
+
configValidation_1.configIdValidation.parse(entity.configId);
|
|
51
|
+
// verify the signature is matching the signerAddress specified in the entity
|
|
52
|
+
const message = JSON.stringify({
|
|
53
|
+
configId: entity.configId,
|
|
54
|
+
entityId: entity.entityId,
|
|
55
|
+
role: entity.role,
|
|
56
|
+
}); // Use alphabetical order for consistency
|
|
57
|
+
const { isValid } = (0, verify_signature_1.verifyEthereumSignature)(message, entity.signature, entity.signerAddress);
|
|
58
|
+
if (!isValid) {
|
|
59
|
+
throw new Error(`Signature verification failed for entity ${entity.entityId} with message ${message}.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return agentDefinitionOutput;
|
|
63
|
+
}
|
|
64
|
+
function registerAgentHandler() {
|
|
65
|
+
return async function registerAgent(agentDefinition) {
|
|
66
|
+
try {
|
|
67
|
+
const uuid = crypto.randomUUID();
|
|
68
|
+
(0, common_1.log)("Register Agent:", uuid, (0, jsonUtils_1.stringifyWithBigInt)(agentDefinition));
|
|
69
|
+
agentDefinition = await validateAgentDefition(agentDefinition, {
|
|
70
|
+
uuid,
|
|
71
|
+
schemaVersion: SCHEMA_VERSION,
|
|
72
|
+
});
|
|
73
|
+
const pR_title = `Register Agent ${uuid} with name ${agentDefinition.name}`;
|
|
74
|
+
const pR_body = `This PR registers the agent ${uuid} named ${agentDefinition.name} with the dACP MCP server.`;
|
|
75
|
+
const headBranch = `register-agent-${uuid}-${agentDefinition.name.toLowerCase().replace(/\s+/g, "-")}`;
|
|
76
|
+
let ret = await github_1.gitHubMCPClient.createBranch({ branchName: headBranch });
|
|
77
|
+
if (ret.isError) {
|
|
78
|
+
return (0, common_1.logAndThrowError)(ret.content, "Failed to create branch");
|
|
79
|
+
}
|
|
80
|
+
ret = await github_1.gitHubMCPClient.createFile({
|
|
81
|
+
organisation: GH_ORGANISATION,
|
|
82
|
+
repository: GH_REPOSITORY,
|
|
83
|
+
branch: headBranch,
|
|
84
|
+
filePath: `${GH_DIRECTORY}/${uuid}-${agentDefinition.name.toLowerCase().replace(/\s+/g, "-")}.json`,
|
|
85
|
+
content: (0, jsonUtils_1.stringifyWithBigInt)({
|
|
86
|
+
uuid,
|
|
87
|
+
...agentDefinition,
|
|
88
|
+
}, 2),
|
|
89
|
+
});
|
|
90
|
+
if (ret.isError) {
|
|
91
|
+
return (0, common_1.logAndThrowError)(ret.content, "Failed to create agent file");
|
|
92
|
+
}
|
|
93
|
+
ret = await github_1.gitHubMCPClient.createPullRequest({
|
|
94
|
+
organisation: GH_ORGANISATION,
|
|
95
|
+
repository: GH_REPOSITORY,
|
|
96
|
+
branch: headBranch,
|
|
97
|
+
title: pR_title,
|
|
98
|
+
body: pR_body,
|
|
99
|
+
});
|
|
100
|
+
if (ret.isError) {
|
|
101
|
+
return (0, common_1.logAndThrowError)(ret.content, "Failed to create pull request");
|
|
102
|
+
}
|
|
103
|
+
return (0, jsonUtils_1.stringifyWithBigInt)({
|
|
104
|
+
success: true,
|
|
105
|
+
registeringData: {},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.error("Error registering agent:", error);
|
|
110
|
+
return (0, jsonUtils_1.stringifyWithBigInt)({
|
|
111
|
+
success: false,
|
|
112
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=agentRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentRegistry.js","sourceRoot":"","sources":["../../../../src/boson/mcp-server/handlers/agentRegistry.ts"],"names":[],"mappings":";;AAsFA,oDA2DC;AA/ID,4CAAwD;AACxD,kFAAiF;AACjF,oEAA2E;AAC3E,qDAA2D;AAC3D,+EAA4E;AAC5E,yEAA6E;AAC7E,8CAAwD;AAExD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;AAC1D,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,UAAU,GAAG,CAAC,OAAe,EAAU,EAAE,CAC7C,iGAAiG,OAAO,OAAO,CAAC;AAClH,IAAI,CAAC,eAAe,IAAI,CAAC,aAAa,IAAI,CAAC,YAAY,EAAE,CAAC;IACxD,MAAM,IAAI,KAAK,CACb,yCAAyC,eAAe,mBAAmB,aAAa,qBAAqB,YAAY,cAAc,CACxI,CAAC;AACJ,CAAC;AACD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,+CAA+C,CAAC,EAAE,CAAC;IACzE,MAAM,IAAI,KAAK,CACb,2BAA2B,YAAY,+FAA+F,CACvI,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,qBAAqB,CAClC,eAAwD,EACxD,EAAE,IAAI,EAAE,aAAa,EAA2C;IAEhE,MAAM,MAAM,GAAG,oCAAuB,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM,C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,CAAC,eAAe;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/boson/mcp-server/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/boson/mcp-server/index.ts"],"names":[],"mappings":";AAqLA,cAAM,cAAc;;IAKlB,OAAO,CAAC,oBAAoB;IAiE5B,OAAO,CAAC,aAAa;IA2CrB,OAAO,CAAC,iBAAiB;IAuCzB,OAAO,CAAC,qBAAqB;IA4B7B,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,iBAAiB;YAyqCX,UAAU;YAQV,SAAS;IAsMjB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAc3B;AAGD,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -62,6 +62,7 @@ const productsFilter_js_1 = require("./filters/productsFilter.js");
|
|
|
62
62
|
const sellersByAddressFilter_js_1 = require("./filters/sellersByAddressFilter.js");
|
|
63
63
|
const sellersFilter_js_1 = require("./filters/sellersFilter.js");
|
|
64
64
|
const accounts_js_1 = require("./handlers/accounts.js");
|
|
65
|
+
const agentRegistry_js_1 = require("./handlers/agentRegistry.js");
|
|
65
66
|
const disputes_js_1 = require("./handlers/disputes.js");
|
|
66
67
|
const exchanges_js_1 = require("./handlers/exchanges.js");
|
|
67
68
|
const funds_js_1 = require("./handlers/funds.js");
|
|
@@ -121,31 +122,38 @@ class BosonMCPServer {
|
|
|
121
122
|
});
|
|
122
123
|
return { coreSDK, config };
|
|
123
124
|
}
|
|
124
|
-
createHandler(handlerFactory, needsConfig = false, requiresSignerAddress = true) {
|
|
125
|
+
createHandler(handlerFactory, needsConfig = false, requiresSignerAddress = true, needsCoreSDK = true) {
|
|
125
126
|
return async (args) => {
|
|
126
127
|
if (requiresSignerAddress) {
|
|
127
128
|
if (!args.configId || !args.signerAddress) {
|
|
128
129
|
throw new Error(`configId(${args.configId}) and signerAddress(${args.signerAddress}) are required`);
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
|
-
else {
|
|
132
|
+
else if (needsCoreSDK) {
|
|
132
133
|
if (!args.configId) {
|
|
133
134
|
throw new Error(`configId(${args.configId}) is required`);
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
let handler;
|
|
138
|
+
if (needsCoreSDK || needsConfig) {
|
|
139
|
+
const { coreSDK, config } = this.createSDKFromContext(args.configId, args.signerAddress);
|
|
140
|
+
handler = needsConfig
|
|
141
|
+
? handlerFactory(() => coreSDK, () => config)
|
|
142
|
+
: handlerFactory(() => coreSDK);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
handler = handlerFactory();
|
|
146
|
+
}
|
|
140
147
|
return await handler(args);
|
|
141
148
|
};
|
|
142
149
|
}
|
|
143
|
-
createToolHandler(handlerFactory, { needsConfig
|
|
150
|
+
createToolHandler(handlerFactory, { needsConfig, requiresSignerAddress, needsCoreSDK, } = {
|
|
144
151
|
needsConfig: false,
|
|
145
152
|
requiresSignerAddress: true,
|
|
153
|
+
needsCoreSDK: true,
|
|
146
154
|
}) {
|
|
147
155
|
return async (args) => {
|
|
148
|
-
const result = await this.createHandler(handlerFactory, needsConfig, requiresSignerAddress)(args);
|
|
156
|
+
const result = await this.createHandler(handlerFactory, needsConfig, requiresSignerAddress, needsCoreSDK)(args);
|
|
149
157
|
return {
|
|
150
158
|
content: [
|
|
151
159
|
{
|
|
@@ -344,9 +352,7 @@ class BosonMCPServer {
|
|
|
344
352
|
return this.createToolHandler(offers_js_1.createStoreBundleMetadataHandler)(validatedArgs);
|
|
345
353
|
});
|
|
346
354
|
server.tool("store_custom_metadata", "Store custom metadata to IPFS and return metadata URI and hash", validation_js_1.storeCustomMetadataValidation.shape, (args) => {
|
|
347
|
-
console.log("received args:", args);
|
|
348
355
|
const validatedArgs = validation_js_1.storeCustomMetadataValidation.parse(args);
|
|
349
|
-
console.log("Storing custom metadata with args:", validatedArgs, args);
|
|
350
356
|
return this.createToolHandler(offers_js_1.createStoreCustomMetadataHandler)(validatedArgs);
|
|
351
357
|
});
|
|
352
358
|
server.tool("render_contractual_agreement", "Render a contractual agreement using renderContractualAgreement from Boson Protocol SDK", validation_js_1.renderContractualAgreementValidation.shape, (args) => {
|
|
@@ -363,6 +369,51 @@ class BosonMCPServer {
|
|
|
363
369
|
const validatedArgs = validation_js_1.storeBundleItemNftMetadataValidation.parse(args);
|
|
364
370
|
return this.createToolHandler(offers_js_1.createStoreBundleItemNftMetadataHandler)(validatedArgs);
|
|
365
371
|
});
|
|
372
|
+
server.tool("register_agent", "Register a dACP agent with the MCP server", validation_js_1.registerAgentValidation.shape, (args) => {
|
|
373
|
+
const validatedArgs = validation_js_1.registerAgentValidation.parse(args);
|
|
374
|
+
return this.createToolHandler(agentRegistry_js_1.registerAgentHandler, {
|
|
375
|
+
needsCoreSDK: false,
|
|
376
|
+
needsConfig: false,
|
|
377
|
+
requiresSignerAddress: false,
|
|
378
|
+
})(validatedArgs);
|
|
379
|
+
});
|
|
380
|
+
server.tool("get_registered_agents", "Get all dACP agents registered with the MCP server", {}, () => {
|
|
381
|
+
// TODO: TO BE IMPLEMENTED
|
|
382
|
+
// This should return the list of registered agents in a format compatible with dACP
|
|
383
|
+
// For now, we return an empty list
|
|
384
|
+
(0, index_js_1.log)("WARNING: get_registered_agents tool is not implemented yet");
|
|
385
|
+
return {
|
|
386
|
+
content: [
|
|
387
|
+
{
|
|
388
|
+
type: "text",
|
|
389
|
+
text: JSON.stringify({ agents: [] }),
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
};
|
|
393
|
+
});
|
|
394
|
+
server.resource("registered_agents", new mcp_js_1.ResourceTemplate("dACP://agents", {
|
|
395
|
+
list: undefined,
|
|
396
|
+
}), {
|
|
397
|
+
name: "dACP Agents",
|
|
398
|
+
description: "Get the list of dACP agents registered with the MCP server. This resource helps clients discover available agents.",
|
|
399
|
+
mimeType: "application/json",
|
|
400
|
+
}, (url) => {
|
|
401
|
+
// TODO: TO BE IMPLEMENTED
|
|
402
|
+
// This should return the list of registered agents in a format compatible with dACP
|
|
403
|
+
// For now, we return an empty list
|
|
404
|
+
(0, index_js_1.log)("WARNING: registered_agents resource is not implemented yet");
|
|
405
|
+
return {
|
|
406
|
+
contents: [
|
|
407
|
+
{
|
|
408
|
+
uri: url.toString(),
|
|
409
|
+
mimeType: "application/json",
|
|
410
|
+
text: JSON.stringify({
|
|
411
|
+
agents: [],
|
|
412
|
+
}),
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
};
|
|
416
|
+
});
|
|
366
417
|
server.resource("config-ids", new mcp_js_1.ResourceTemplate(configIdsFilter_js_1.configIdsUriTemplate, {
|
|
367
418
|
list: undefined,
|
|
368
419
|
}), {
|