la-machina-engine 0.19.0 → 0.19.2
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 +44 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1413,10 +1413,11 @@ var RESERVED_DEFAULT_HEADER_EXACT = /* @__PURE__ */ new Set([
|
|
|
1413
1413
|
"proxy-authorization",
|
|
1414
1414
|
"x-auth-token"
|
|
1415
1415
|
]);
|
|
1416
|
+
var INTEGRATION_BASE_URL_REF_RE = /^\$integration:[a-z][a-z0-9_-]*\.[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
1416
1417
|
var ApiServiceSchema = import_zod.z.object({
|
|
1417
1418
|
name: import_zod.z.string().min(1),
|
|
1418
1419
|
description: import_zod.z.string().optional(),
|
|
1419
|
-
baseUrl: import_zod.z.string().url(),
|
|
1420
|
+
baseUrl: import_zod.z.union([import_zod.z.string().url(), import_zod.z.string().regex(INTEGRATION_BASE_URL_REF_RE)]),
|
|
1420
1421
|
auth: ApiAuthSchema.optional(),
|
|
1421
1422
|
// Allow both strings and RegExp values via z.union — RegExp is
|
|
1422
1423
|
// serialized as its source when cloned, so we accept both.
|
|
@@ -8515,6 +8516,7 @@ function createApiCallTool(opts) {
|
|
|
8515
8516
|
maxResponseBytes,
|
|
8516
8517
|
env: opts.env,
|
|
8517
8518
|
resolveAuth: opts.resolveAuth,
|
|
8519
|
+
resolveBaseUrl: opts.resolveBaseUrl,
|
|
8518
8520
|
onRequest: opts.onRequest,
|
|
8519
8521
|
onResponse: opts.onResponse
|
|
8520
8522
|
});
|
|
@@ -8560,7 +8562,25 @@ function createApiCallTool(opts) {
|
|
|
8560
8562
|
return errResult(`ERR_API_RESOLVER_FAILED: ${truncated}`);
|
|
8561
8563
|
}
|
|
8562
8564
|
const userHeaders = sanitizeHeaders(input.headers ?? {}, authHeaders);
|
|
8563
|
-
|
|
8565
|
+
let effectiveBaseUrl = svc.baseUrl;
|
|
8566
|
+
if (opts.resolveBaseUrl !== void 0) {
|
|
8567
|
+
try {
|
|
8568
|
+
const resolved = await opts.resolveBaseUrl(svc.name, {
|
|
8569
|
+
serviceName: svc.name,
|
|
8570
|
+
method: input.method,
|
|
8571
|
+
path: input.path,
|
|
8572
|
+
...secretHeaderRefs !== void 0 ? { secretHeaderRefs } : {}
|
|
8573
|
+
});
|
|
8574
|
+
if (resolved !== void 0) {
|
|
8575
|
+
effectiveBaseUrl = resolved;
|
|
8576
|
+
}
|
|
8577
|
+
} catch (err) {
|
|
8578
|
+
const raw2 = err instanceof Error ? err.message : String(err);
|
|
8579
|
+
const truncated = raw2.length > 200 ? raw2.slice(0, 200) + "\u2026" : raw2;
|
|
8580
|
+
return errResult(`ERR_API_BASE_URL_RESOLVE_FAILED: ${truncated}`);
|
|
8581
|
+
}
|
|
8582
|
+
}
|
|
8583
|
+
const url = buildUrl(effectiveBaseUrl, input.path, input.query);
|
|
8564
8584
|
await invokeHook(opts.onRequest, {
|
|
8565
8585
|
service: svc.name,
|
|
8566
8586
|
method: input.method,
|
|
@@ -8814,6 +8834,24 @@ async function executeAutoPaginated(args) {
|
|
|
8814
8834
|
return errResult(`ERR_API_RESOLVER_FAILED: ${truncated}`);
|
|
8815
8835
|
}
|
|
8816
8836
|
const userHeaders = sanitizeHeaders(input.headers ?? {}, authHeaders);
|
|
8837
|
+
let effectiveBaseUrl = svc.baseUrl;
|
|
8838
|
+
if (args.resolveBaseUrl !== void 0) {
|
|
8839
|
+
try {
|
|
8840
|
+
const resolved = await args.resolveBaseUrl(svc.name, {
|
|
8841
|
+
serviceName: svc.name,
|
|
8842
|
+
method: input.method,
|
|
8843
|
+
path: input.path,
|
|
8844
|
+
...secretHeaderRefs !== void 0 ? { secretHeaderRefs } : {}
|
|
8845
|
+
});
|
|
8846
|
+
if (resolved !== void 0) {
|
|
8847
|
+
effectiveBaseUrl = resolved;
|
|
8848
|
+
}
|
|
8849
|
+
} catch (err) {
|
|
8850
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
8851
|
+
const truncated = raw.length > 200 ? raw.slice(0, 200) + "\u2026" : raw;
|
|
8852
|
+
return errResult(`ERR_API_BASE_URL_RESOLVE_FAILED: ${truncated}`);
|
|
8853
|
+
}
|
|
8854
|
+
}
|
|
8817
8855
|
const aggregated = [];
|
|
8818
8856
|
let pagesFetched = 0;
|
|
8819
8857
|
let stoppedBy = "unknown";
|
|
@@ -8844,7 +8882,7 @@ async function executeAutoPaginated(args) {
|
|
|
8844
8882
|
} else if (p.mode === "link-header") {
|
|
8845
8883
|
if (nextLink !== null) pageUrl = nextLink;
|
|
8846
8884
|
}
|
|
8847
|
-
const url = pageUrl ?? buildUrl(
|
|
8885
|
+
const url = pageUrl ?? buildUrl(effectiveBaseUrl, input.path, pageQuery);
|
|
8848
8886
|
await invokeHook(args.onRequest, {
|
|
8849
8887
|
service: svc.name,
|
|
8850
8888
|
method: input.method,
|
|
@@ -12432,12 +12470,14 @@ ${inputJson}
|
|
|
12432
12470
|
if (services === void 0 || services.length === 0) return void 0;
|
|
12433
12471
|
const env = override?.env ?? base?.env;
|
|
12434
12472
|
const resolveAuth2 = override?.resolveAuth ?? base?.resolveAuth;
|
|
12473
|
+
const resolveBaseUrl = override?.resolveBaseUrl ?? base?.resolveBaseUrl;
|
|
12435
12474
|
const onRequest = override?.onRequest ?? base?.onRequest;
|
|
12436
12475
|
const onResponse = override?.onResponse ?? base?.onResponse;
|
|
12437
12476
|
return {
|
|
12438
12477
|
services,
|
|
12439
12478
|
...env !== void 0 ? { env } : {},
|
|
12440
12479
|
...resolveAuth2 !== void 0 ? { resolveAuth: resolveAuth2 } : {},
|
|
12480
|
+
...resolveBaseUrl !== void 0 ? { resolveBaseUrl } : {},
|
|
12441
12481
|
...onRequest !== void 0 ? { onRequest } : {},
|
|
12442
12482
|
...onResponse !== void 0 ? { onResponse } : {},
|
|
12443
12483
|
...base?.maxResponseBytes !== void 0 ? { maxResponseBytes: base.maxResponseBytes } : {}
|
|
@@ -12730,6 +12770,7 @@ function buildToolRegistry(options) {
|
|
|
12730
12770
|
...options.fetch !== void 0 ? { fetch: options.fetch } : {},
|
|
12731
12771
|
...options.apiConfig.env !== void 0 ? { env: options.apiConfig.env } : {},
|
|
12732
12772
|
...options.apiConfig.resolveAuth !== void 0 ? { resolveAuth: options.apiConfig.resolveAuth } : {},
|
|
12773
|
+
...options.apiConfig.resolveBaseUrl !== void 0 ? { resolveBaseUrl: options.apiConfig.resolveBaseUrl } : {},
|
|
12733
12774
|
...options.apiConfig.onRequest !== void 0 ? { onRequest: options.apiConfig.onRequest } : {},
|
|
12734
12775
|
...options.apiConfig.onResponse !== void 0 ? { onResponse: options.apiConfig.onResponse } : {},
|
|
12735
12776
|
...options.apiConfig.maxResponseBytes !== void 0 ? { maxResponseBytes: options.apiConfig.maxResponseBytes } : {}
|