@utcp/http 1.0.12 → 1.1.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.cts CHANGED
@@ -18,6 +18,7 @@ interface HttpCallTemplate extends CallTemplate {
18
18
  body_field?: string;
19
19
  header_fields?: string[];
20
20
  auth_tools?: Auth | null;
21
+ allowed_communication_protocols?: string[];
21
22
  }
22
23
  /**
23
24
  * HTTP Call Template schema for RESTful HTTP/HTTPS API tools.
@@ -149,6 +150,7 @@ interface StreamableHttpCallTemplate extends CallTemplate {
149
150
  headers?: Record<string, string>;
150
151
  body_field?: string | null;
151
152
  header_fields?: string[] | null;
153
+ allowed_communication_protocols?: string[];
152
154
  }
153
155
  /**
154
156
  * Streamable HTTP Call Template schema.
@@ -245,6 +247,7 @@ interface SseCallTemplate extends CallTemplate {
245
247
  headers?: Record<string, string>;
246
248
  body_field?: string | null;
247
249
  header_fields?: string[] | null;
250
+ allowed_communication_protocols?: string[];
248
251
  }
249
252
  /**
250
253
  * SSE Call Template schema.
@@ -319,6 +322,7 @@ interface OpenApiConverterOptions {
319
322
  specUrl?: string;
320
323
  callTemplateName?: string;
321
324
  authTools?: Auth;
325
+ baseUrl?: string;
322
326
  }
323
327
  /**
324
328
  * REQUIRED
@@ -332,6 +336,7 @@ interface OpenApiConverterOptions {
332
336
  declare class OpenApiConverter {
333
337
  private spec;
334
338
  private spec_url;
339
+ private base_url;
335
340
  private auth_tools;
336
341
  private placeholder_counter;
337
342
  private call_template_name;
@@ -339,10 +344,11 @@ declare class OpenApiConverter {
339
344
  * Initializes the OpenAPI converter.
340
345
  *
341
346
  * @param openapi_spec Parsed OpenAPI specification as a dictionary.
342
- * @param options Optional settings including spec_url, call_template_name, and auth_tools.
347
+ * @param options Optional settings including spec_url, call_template_name, auth_tools, and baseUrl.
343
348
  * - specUrl: URL where the specification was retrieved from.
344
349
  * - callTemplateName: Custom name for the call_template if spec title not provided.
345
350
  * - authTools: Optional auth configuration for generated tools.
351
+ * - baseUrl: Optional base URL override for all API endpoints.
346
352
  */
347
353
  constructor(openapi_spec: Record<string, any>, options?: OpenApiConverterOptions);
348
354
  private _generateUuid;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ interface HttpCallTemplate extends CallTemplate {
18
18
  body_field?: string;
19
19
  header_fields?: string[];
20
20
  auth_tools?: Auth | null;
21
+ allowed_communication_protocols?: string[];
21
22
  }
22
23
  /**
23
24
  * HTTP Call Template schema for RESTful HTTP/HTTPS API tools.
@@ -149,6 +150,7 @@ interface StreamableHttpCallTemplate extends CallTemplate {
149
150
  headers?: Record<string, string>;
150
151
  body_field?: string | null;
151
152
  header_fields?: string[] | null;
153
+ allowed_communication_protocols?: string[];
152
154
  }
153
155
  /**
154
156
  * Streamable HTTP Call Template schema.
@@ -245,6 +247,7 @@ interface SseCallTemplate extends CallTemplate {
245
247
  headers?: Record<string, string>;
246
248
  body_field?: string | null;
247
249
  header_fields?: string[] | null;
250
+ allowed_communication_protocols?: string[];
248
251
  }
249
252
  /**
250
253
  * SSE Call Template schema.
@@ -319,6 +322,7 @@ interface OpenApiConverterOptions {
319
322
  specUrl?: string;
320
323
  callTemplateName?: string;
321
324
  authTools?: Auth;
325
+ baseUrl?: string;
322
326
  }
323
327
  /**
324
328
  * REQUIRED
@@ -332,6 +336,7 @@ interface OpenApiConverterOptions {
332
336
  declare class OpenApiConverter {
333
337
  private spec;
334
338
  private spec_url;
339
+ private base_url;
335
340
  private auth_tools;
336
341
  private placeholder_counter;
337
342
  private call_template_name;
@@ -339,10 +344,11 @@ declare class OpenApiConverter {
339
344
  * Initializes the OpenAPI converter.
340
345
  *
341
346
  * @param openapi_spec Parsed OpenAPI specification as a dictionary.
342
- * @param options Optional settings including spec_url, call_template_name, and auth_tools.
347
+ * @param options Optional settings including spec_url, call_template_name, auth_tools, and baseUrl.
343
348
  * - specUrl: URL where the specification was retrieved from.
344
349
  * - callTemplateName: Custom name for the call_template if spec title not provided.
345
350
  * - authTools: Optional auth configuration for generated tools.
351
+ * - baseUrl: Optional base URL override for all API endpoints.
346
352
  */
347
353
  constructor(openapi_spec: Record<string, any>, options?: OpenApiConverterOptions);
348
354
  private _generateUuid;
package/dist/index.js CHANGED
@@ -4067,7 +4067,8 @@ var HttpCallTemplateSchema = external_exports.object({
4067
4067
  return new AuthSerializer().validateDict(val);
4068
4068
  }
4069
4069
  return val;
4070
- }).describe("Authentication configuration for generated tools")
4070
+ }).describe("Authentication configuration for generated tools"),
4071
+ allowed_communication_protocols: external_exports.array(external_exports.string()).optional().describe("Optional list of allowed communication protocol types for tools within this manual.")
4071
4072
  });
4072
4073
  var HttpCallTemplateSerializer = class extends Serializer {
4073
4074
  toDict(obj) {
@@ -4081,7 +4082,8 @@ var HttpCallTemplateSerializer = class extends Serializer {
4081
4082
  auth_tools: obj.auth_tools ? new AuthSerializer().toDict(obj.auth_tools) : null,
4082
4083
  headers: obj.headers,
4083
4084
  body_field: obj.body_field,
4084
- header_fields: obj.header_fields
4085
+ header_fields: obj.header_fields,
4086
+ allowed_communication_protocols: obj.allowed_communication_protocols
4085
4087
  };
4086
4088
  }
4087
4089
  validateDict(obj) {
@@ -4108,7 +4110,8 @@ var StreamableHttpCallTemplateSchema = external_exports.object({
4108
4110
  auth: AuthSchema2.optional().describe("Optional authentication configuration."),
4109
4111
  headers: external_exports.record(external_exports.string(), external_exports.string()).optional().describe("Optional static headers to include in requests."),
4110
4112
  body_field: external_exports.string().nullable().optional().describe("The name of the single input field to be sent as the request body."),
4111
- header_fields: external_exports.array(external_exports.string()).nullable().optional().describe("List of input fields to be sent as request headers.")
4113
+ header_fields: external_exports.array(external_exports.string()).nullable().optional().describe("List of input fields to be sent as request headers."),
4114
+ allowed_communication_protocols: external_exports.array(external_exports.string()).optional().describe("Optional list of allowed communication protocol types for tools within this manual.")
4112
4115
  });
4113
4116
  var StreamableHttpCallTemplateSerializer = class extends Serializer2 {
4114
4117
  /**
@@ -4127,7 +4130,8 @@ var StreamableHttpCallTemplateSerializer = class extends Serializer2 {
4127
4130
  auth: obj.auth,
4128
4131
  headers: obj.headers,
4129
4132
  body_field: obj.body_field,
4130
- header_fields: obj.header_fields
4133
+ header_fields: obj.header_fields,
4134
+ allowed_communication_protocols: obj.allowed_communication_protocols
4131
4135
  };
4132
4136
  }
4133
4137
  /**
@@ -4157,7 +4161,8 @@ var SseCallTemplateSchema = external_exports.object({
4157
4161
  auth: AuthSchema3.optional().describe("Optional authentication configuration."),
4158
4162
  headers: external_exports.record(external_exports.string(), external_exports.string()).optional().describe("Optional static headers for the initial connection."),
4159
4163
  body_field: external_exports.string().nullable().optional().describe("The name of the single input field to be sent as the request body."),
4160
- header_fields: external_exports.array(external_exports.string()).nullable().optional().describe("List of input fields to be sent as request headers for the initial connection.")
4164
+ header_fields: external_exports.array(external_exports.string()).nullable().optional().describe("List of input fields to be sent as request headers for the initial connection."),
4165
+ allowed_communication_protocols: external_exports.array(external_exports.string()).optional().describe("Optional list of allowed communication protocol types for tools within this manual.")
4161
4166
  });
4162
4167
  var SseCallTemplateSerializer = class extends Serializer3 {
4163
4168
  /**
@@ -4175,7 +4180,8 @@ var SseCallTemplateSerializer = class extends Serializer3 {
4175
4180
  auth: obj.auth,
4176
4181
  headers: obj.headers,
4177
4182
  body_field: obj.body_field,
4178
- header_fields: obj.header_fields
4183
+ header_fields: obj.header_fields,
4184
+ allowed_communication_protocols: obj.allowed_communication_protocols
4179
4185
  };
4180
4186
  }
4181
4187
  /**
@@ -4203,6 +4209,7 @@ import { UtcpManualSerializer } from "@utcp/sdk";
4203
4209
  var OpenApiConverter = class {
4204
4210
  spec;
4205
4211
  spec_url;
4212
+ base_url;
4206
4213
  auth_tools;
4207
4214
  placeholder_counter = 0;
4208
4215
  call_template_name;
@@ -4210,14 +4217,16 @@ var OpenApiConverter = class {
4210
4217
  * Initializes the OpenAPI converter.
4211
4218
  *
4212
4219
  * @param openapi_spec Parsed OpenAPI specification as a dictionary.
4213
- * @param options Optional settings including spec_url, call_template_name, and auth_tools.
4220
+ * @param options Optional settings including spec_url, call_template_name, auth_tools, and baseUrl.
4214
4221
  * - specUrl: URL where the specification was retrieved from.
4215
4222
  * - callTemplateName: Custom name for the call_template if spec title not provided.
4216
4223
  * - authTools: Optional auth configuration for generated tools.
4224
+ * - baseUrl: Optional base URL override for all API endpoints.
4217
4225
  */
4218
4226
  constructor(openapi_spec, options) {
4219
4227
  this.spec = openapi_spec;
4220
4228
  this.spec_url = options?.specUrl;
4229
+ this.base_url = options?.baseUrl;
4221
4230
  this.auth_tools = options?.authTools;
4222
4231
  this.placeholder_counter = 0;
4223
4232
  let callTemplateName = options?.callTemplateName;
@@ -4252,10 +4261,15 @@ var OpenApiConverter = class {
4252
4261
  this.placeholder_counter = 0;
4253
4262
  const tools = [];
4254
4263
  let baseUrl = "/";
4255
- const servers = this.spec.servers;
4256
- if (servers && Array.isArray(servers) && servers.length > 0 && servers[0].url) {
4257
- baseUrl = servers[0].url;
4258
- } else if (this.spec_url) {
4264
+ if (this.base_url) {
4265
+ baseUrl = this.base_url;
4266
+ } else if (this.spec.servers && Array.isArray(this.spec.servers) && this.spec.servers.length > 0 && this.spec.servers[0].url) {
4267
+ baseUrl = this.spec.servers[0].url;
4268
+ } else if (this.spec.host) {
4269
+ const scheme = this.spec.schemes?.[0] || "https";
4270
+ const basePath = this.spec.basePath || "";
4271
+ baseUrl = `${scheme}://${this.spec.host}${basePath}`;
4272
+ } else if (this.spec_url && (this.spec_url.startsWith("http://") || this.spec_url.startsWith("https://"))) {
4259
4273
  try {
4260
4274
  const parsedUrl = new URL(this.spec_url);
4261
4275
  baseUrl = `${parsedUrl.protocol}//${parsedUrl.host}`;
@@ -4263,7 +4277,7 @@ var OpenApiConverter = class {
4263
4277
  console.error(`[OpenApiConverter] Invalid spec_url provided: ${this.spec_url}`);
4264
4278
  }
4265
4279
  } else {
4266
- console.warn("[OpenApiConverter] No server info or spec URL provided. Using fallback base URL: '/'");
4280
+ console.warn("[OpenApiConverter] No server info found in OpenAPI spec. Using fallback base URL: '/'. Tools may not work correctly without a valid base URL.");
4267
4281
  }
4268
4282
  const paths = this.spec.paths || {};
4269
4283
  for (const [path, pathItem] of Object.entries(paths)) {
@@ -4833,11 +4847,12 @@ var HttpCommunicationProtocol = class {
4833
4847
  if (!apiKeyAuth.api_key) {
4834
4848
  throw new Error("API key for ApiKeyAuth is empty.");
4835
4849
  }
4836
- if (apiKeyAuth.location === "header") {
4850
+ const location = apiKeyAuth.location || "header";
4851
+ if (location === "header") {
4837
4852
  requestConfig.headers = { ...requestConfig.headers, [apiKeyAuth.var_name]: apiKeyAuth.api_key };
4838
- } else if (apiKeyAuth.location === "query") {
4853
+ } else if (location === "query") {
4839
4854
  requestConfig.params = { ...requestConfig.params, [apiKeyAuth.var_name]: apiKeyAuth.api_key };
4840
- } else if (apiKeyAuth.location === "cookie") {
4855
+ } else if (location === "cookie") {
4841
4856
  cookies[apiKeyAuth.var_name] = apiKeyAuth.api_key;
4842
4857
  }
4843
4858
  } else if (httpCallTemplate.auth.auth_type === "basic") {
@@ -4978,11 +4993,12 @@ var StreamableHttpCommunicationProtocol = class {
4978
4993
  if ("api_key" in provider.auth) {
4979
4994
  const apiKeyAuth = provider.auth;
4980
4995
  if (apiKeyAuth.api_key) {
4981
- if (apiKeyAuth.location === "header") {
4996
+ const location = apiKeyAuth.location || "header";
4997
+ if (location === "header") {
4982
4998
  headers[apiKeyAuth.var_name] = apiKeyAuth.api_key;
4983
- } else if (apiKeyAuth.location === "query") {
4999
+ } else if (location === "query") {
4984
5000
  queryParams[apiKeyAuth.var_name] = apiKeyAuth.api_key;
4985
- } else if (apiKeyAuth.location === "cookie") {
5001
+ } else if (location === "cookie") {
4986
5002
  cookies[apiKeyAuth.var_name] = apiKeyAuth.api_key;
4987
5003
  }
4988
5004
  } else {
@@ -5109,11 +5125,12 @@ var SseCommunicationProtocol = class {
5109
5125
  if ("api_key" in provider.auth) {
5110
5126
  const apiKeyAuth = provider.auth;
5111
5127
  if (apiKeyAuth.api_key) {
5112
- if (apiKeyAuth.location === "header") {
5128
+ const location = apiKeyAuth.location || "header";
5129
+ if (location === "header") {
5113
5130
  headers[apiKeyAuth.var_name] = apiKeyAuth.api_key;
5114
- } else if (apiKeyAuth.location === "query") {
5131
+ } else if (location === "query") {
5115
5132
  queryParams[apiKeyAuth.var_name] = apiKeyAuth.api_key;
5116
- } else if (apiKeyAuth.location === "cookie") {
5133
+ } else if (location === "cookie") {
5117
5134
  cookies[apiKeyAuth.var_name] = apiKeyAuth.api_key;
5118
5135
  }
5119
5136
  } else {