la-machina-engine 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -8515,6 +8515,7 @@ function createApiCallTool(opts) {
8515
8515
  maxResponseBytes,
8516
8516
  env: opts.env,
8517
8517
  resolveAuth: opts.resolveAuth,
8518
+ resolveBaseUrl: opts.resolveBaseUrl,
8518
8519
  onRequest: opts.onRequest,
8519
8520
  onResponse: opts.onResponse
8520
8521
  });
@@ -8560,7 +8561,25 @@ function createApiCallTool(opts) {
8560
8561
  return errResult(`ERR_API_RESOLVER_FAILED: ${truncated}`);
8561
8562
  }
8562
8563
  const userHeaders = sanitizeHeaders(input.headers ?? {}, authHeaders);
8563
- const url = buildUrl(svc.baseUrl, input.path, input.query);
8564
+ let effectiveBaseUrl = svc.baseUrl;
8565
+ if (opts.resolveBaseUrl !== void 0) {
8566
+ try {
8567
+ const resolved = await opts.resolveBaseUrl(svc.name, {
8568
+ serviceName: svc.name,
8569
+ method: input.method,
8570
+ path: input.path,
8571
+ ...secretHeaderRefs !== void 0 ? { secretHeaderRefs } : {}
8572
+ });
8573
+ if (resolved !== void 0) {
8574
+ effectiveBaseUrl = resolved;
8575
+ }
8576
+ } catch (err) {
8577
+ const raw2 = err instanceof Error ? err.message : String(err);
8578
+ const truncated = raw2.length > 200 ? raw2.slice(0, 200) + "\u2026" : raw2;
8579
+ return errResult(`ERR_API_BASE_URL_RESOLVE_FAILED: ${truncated}`);
8580
+ }
8581
+ }
8582
+ const url = buildUrl(effectiveBaseUrl, input.path, input.query);
8564
8583
  await invokeHook(opts.onRequest, {
8565
8584
  service: svc.name,
8566
8585
  method: input.method,
@@ -8814,6 +8833,24 @@ async function executeAutoPaginated(args) {
8814
8833
  return errResult(`ERR_API_RESOLVER_FAILED: ${truncated}`);
8815
8834
  }
8816
8835
  const userHeaders = sanitizeHeaders(input.headers ?? {}, authHeaders);
8836
+ let effectiveBaseUrl = svc.baseUrl;
8837
+ if (args.resolveBaseUrl !== void 0) {
8838
+ try {
8839
+ const resolved = await args.resolveBaseUrl(svc.name, {
8840
+ serviceName: svc.name,
8841
+ method: input.method,
8842
+ path: input.path,
8843
+ ...secretHeaderRefs !== void 0 ? { secretHeaderRefs } : {}
8844
+ });
8845
+ if (resolved !== void 0) {
8846
+ effectiveBaseUrl = resolved;
8847
+ }
8848
+ } catch (err) {
8849
+ const raw = err instanceof Error ? err.message : String(err);
8850
+ const truncated = raw.length > 200 ? raw.slice(0, 200) + "\u2026" : raw;
8851
+ return errResult(`ERR_API_BASE_URL_RESOLVE_FAILED: ${truncated}`);
8852
+ }
8853
+ }
8817
8854
  const aggregated = [];
8818
8855
  let pagesFetched = 0;
8819
8856
  let stoppedBy = "unknown";
@@ -8844,7 +8881,7 @@ async function executeAutoPaginated(args) {
8844
8881
  } else if (p.mode === "link-header") {
8845
8882
  if (nextLink !== null) pageUrl = nextLink;
8846
8883
  }
8847
- const url = pageUrl ?? buildUrl(svc.baseUrl, input.path, pageQuery);
8884
+ const url = pageUrl ?? buildUrl(effectiveBaseUrl, input.path, pageQuery);
8848
8885
  await invokeHook(args.onRequest, {
8849
8886
  service: svc.name,
8850
8887
  method: input.method,
@@ -12432,12 +12469,14 @@ ${inputJson}
12432
12469
  if (services === void 0 || services.length === 0) return void 0;
12433
12470
  const env = override?.env ?? base?.env;
12434
12471
  const resolveAuth2 = override?.resolveAuth ?? base?.resolveAuth;
12472
+ const resolveBaseUrl = override?.resolveBaseUrl ?? base?.resolveBaseUrl;
12435
12473
  const onRequest = override?.onRequest ?? base?.onRequest;
12436
12474
  const onResponse = override?.onResponse ?? base?.onResponse;
12437
12475
  return {
12438
12476
  services,
12439
12477
  ...env !== void 0 ? { env } : {},
12440
12478
  ...resolveAuth2 !== void 0 ? { resolveAuth: resolveAuth2 } : {},
12479
+ ...resolveBaseUrl !== void 0 ? { resolveBaseUrl } : {},
12441
12480
  ...onRequest !== void 0 ? { onRequest } : {},
12442
12481
  ...onResponse !== void 0 ? { onResponse } : {},
12443
12482
  ...base?.maxResponseBytes !== void 0 ? { maxResponseBytes: base.maxResponseBytes } : {}
@@ -12730,6 +12769,7 @@ function buildToolRegistry(options) {
12730
12769
  ...options.fetch !== void 0 ? { fetch: options.fetch } : {},
12731
12770
  ...options.apiConfig.env !== void 0 ? { env: options.apiConfig.env } : {},
12732
12771
  ...options.apiConfig.resolveAuth !== void 0 ? { resolveAuth: options.apiConfig.resolveAuth } : {},
12772
+ ...options.apiConfig.resolveBaseUrl !== void 0 ? { resolveBaseUrl: options.apiConfig.resolveBaseUrl } : {},
12733
12773
  ...options.apiConfig.onRequest !== void 0 ? { onRequest: options.apiConfig.onRequest } : {},
12734
12774
  ...options.apiConfig.onResponse !== void 0 ? { onResponse: options.apiConfig.onResponse } : {},
12735
12775
  ...options.apiConfig.maxResponseBytes !== void 0 ? { maxResponseBytes: options.apiConfig.maxResponseBytes } : {}