agentcash 0.8.2 → 0.8.4
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/cjs/run-server.cjs +276 -70
- package/dist/esm/chunk-36HB4WY2.js +7 -0
- package/dist/esm/{chunk-FFYCYLF4.js → chunk-ECZS3TJG.js} +3 -3
- package/dist/esm/{chunk-RD4Y3CJX.js → chunk-F5TWCY6D.js} +2 -2
- package/dist/esm/{chunk-4ALGXM6F.js → chunk-LSDMWRFT.js} +2 -2
- package/dist/esm/chunk-LSDMWRFT.js.map +1 -0
- package/dist/esm/{chunk-3WG74L5Z.js → chunk-P6XPLUQA.js} +16 -4
- package/dist/esm/chunk-P6XPLUQA.js.map +1 -0
- package/dist/esm/{chunk-EQTHURHC.js → chunk-R64IV5GT.js} +2 -2
- package/dist/esm/{commands-ZBVUG2Q5.js → commands-JDEJKVYM.js} +8 -8
- package/dist/esm/{commands-ZBVUG2Q5.js.map → commands-JDEJKVYM.js.map} +1 -1
- package/dist/esm/index.js +23 -26
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{install-LUCT7K6W.js → install-HSBNOB2O.js} +3 -3
- package/dist/esm/{server-EH7FWUSW.js → server-NSKHFPDM.js} +8 -8
- package/dist/esm/{server-EH7FWUSW.js.map → server-NSKHFPDM.js.map} +1 -1
- package/dist/esm/shared/operations/index.js +3 -3
- package/package.json +2 -2
- package/dist/esm/chunk-3WG74L5Z.js.map +0 -1
- package/dist/esm/chunk-4ALGXM6F.js.map +0 -1
- package/dist/esm/chunk-I7DEUXBL.js +0 -7
- /package/dist/esm/{chunk-I7DEUXBL.js.map → chunk-36HB4WY2.js.map} +0 -0
- /package/dist/esm/{chunk-FFYCYLF4.js.map → chunk-ECZS3TJG.js.map} +0 -0
- /package/dist/esm/{chunk-RD4Y3CJX.js.map → chunk-F5TWCY6D.js.map} +0 -0
- /package/dist/esm/{chunk-EQTHURHC.js.map → chunk-R64IV5GT.js.map} +0 -0
- /package/dist/esm/{install-LUCT7K6W.js.map → install-HSBNOB2O.js.map} +0 -0
package/dist/cjs/run-server.cjs
CHANGED
|
@@ -3010,7 +3010,7 @@ var require_compile = __commonJS({
|
|
|
3010
3010
|
}
|
|
3011
3011
|
}
|
|
3012
3012
|
exports2.compileSchema = compileSchema;
|
|
3013
|
-
function
|
|
3013
|
+
function resolveRef2(root, baseId, ref) {
|
|
3014
3014
|
var _a2;
|
|
3015
3015
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
3016
3016
|
const schOrFunc = root.refs[ref];
|
|
@@ -3027,7 +3027,7 @@ var require_compile = __commonJS({
|
|
|
3027
3027
|
return;
|
|
3028
3028
|
return root.refs[ref] = inlineOrCompile.call(this, _sch);
|
|
3029
3029
|
}
|
|
3030
|
-
exports2.resolveRef =
|
|
3030
|
+
exports2.resolveRef = resolveRef2;
|
|
3031
3031
|
function inlineOrCompile(sch) {
|
|
3032
3032
|
if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs))
|
|
3033
3033
|
return sch.schema;
|
|
@@ -64749,6 +64749,195 @@ var require_content_type = __commonJS({
|
|
|
64749
64749
|
}
|
|
64750
64750
|
});
|
|
64751
64751
|
|
|
64752
|
+
// ../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/types.js
|
|
64753
|
+
var require_types3 = __commonJS({
|
|
64754
|
+
"../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/types.js"(exports2) {
|
|
64755
|
+
"use strict";
|
|
64756
|
+
init_cjs_shims();
|
|
64757
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
64758
|
+
value: true
|
|
64759
|
+
});
|
|
64760
|
+
}
|
|
64761
|
+
});
|
|
64762
|
+
|
|
64763
|
+
// ../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/klona.js
|
|
64764
|
+
var require_klona = __commonJS({
|
|
64765
|
+
"../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/klona.js"(exports2) {
|
|
64766
|
+
"use strict";
|
|
64767
|
+
init_cjs_shims();
|
|
64768
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
64769
|
+
value: true
|
|
64770
|
+
});
|
|
64771
|
+
Object.defineProperty(exports2, "klona", {
|
|
64772
|
+
enumerable: true,
|
|
64773
|
+
get: function() {
|
|
64774
|
+
return klona;
|
|
64775
|
+
}
|
|
64776
|
+
});
|
|
64777
|
+
function klona(val, seen) {
|
|
64778
|
+
if (!seen) seen = /* @__PURE__ */ new Map();
|
|
64779
|
+
var index2, out, tmp;
|
|
64780
|
+
if (Array.isArray(val)) {
|
|
64781
|
+
if (seen.has(val)) return seen.get(val);
|
|
64782
|
+
out = Array(index2 = val.length);
|
|
64783
|
+
seen.set(val, out);
|
|
64784
|
+
while (index2--) out[index2] = (tmp = val[index2]) && typeof tmp === "object" ? klona(tmp, seen) : tmp;
|
|
64785
|
+
return out;
|
|
64786
|
+
}
|
|
64787
|
+
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
64788
|
+
if (seen.has(val)) return seen.get(val);
|
|
64789
|
+
out = {};
|
|
64790
|
+
seen.set(val, out);
|
|
64791
|
+
for (index2 in val) {
|
|
64792
|
+
if (index2 === "__proto__") {
|
|
64793
|
+
Object.defineProperty(out, index2, {
|
|
64794
|
+
value: klona(val[index2], seen),
|
|
64795
|
+
configurable: true,
|
|
64796
|
+
enumerable: true,
|
|
64797
|
+
writable: true
|
|
64798
|
+
});
|
|
64799
|
+
} else {
|
|
64800
|
+
out[index2] = (tmp = val[index2]) && typeof tmp === "object" ? klona(tmp, seen) : tmp;
|
|
64801
|
+
}
|
|
64802
|
+
}
|
|
64803
|
+
return out;
|
|
64804
|
+
}
|
|
64805
|
+
return val;
|
|
64806
|
+
}
|
|
64807
|
+
}
|
|
64808
|
+
});
|
|
64809
|
+
|
|
64810
|
+
// ../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/resolveRef.js
|
|
64811
|
+
var require_resolveRef = __commonJS({
|
|
64812
|
+
"../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/resolveRef.js"(exports2) {
|
|
64813
|
+
"use strict";
|
|
64814
|
+
init_cjs_shims();
|
|
64815
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
64816
|
+
value: true
|
|
64817
|
+
});
|
|
64818
|
+
Object.defineProperty(exports2, "resolveRefSync", {
|
|
64819
|
+
enumerable: true,
|
|
64820
|
+
get: function() {
|
|
64821
|
+
return resolveRefSync2;
|
|
64822
|
+
}
|
|
64823
|
+
});
|
|
64824
|
+
var cache = /* @__PURE__ */ new Map();
|
|
64825
|
+
var resolveRefSync2 = function(schema, ref) {
|
|
64826
|
+
if (!cache.has(schema)) {
|
|
64827
|
+
cache.set(schema, /* @__PURE__ */ new Map());
|
|
64828
|
+
}
|
|
64829
|
+
var schemaCache = cache.get(schema);
|
|
64830
|
+
if (schemaCache.has(ref)) {
|
|
64831
|
+
return schemaCache.get(ref);
|
|
64832
|
+
}
|
|
64833
|
+
var path2 = ref.split("/").slice(1);
|
|
64834
|
+
var current = schema;
|
|
64835
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
64836
|
+
try {
|
|
64837
|
+
for (var _iterator = path2[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
64838
|
+
var segment = _step.value;
|
|
64839
|
+
if (!current || typeof current !== "object") {
|
|
64840
|
+
current = null;
|
|
64841
|
+
}
|
|
64842
|
+
var _current_segment;
|
|
64843
|
+
current = (_current_segment = current[segment]) !== null && _current_segment !== void 0 ? _current_segment : null;
|
|
64844
|
+
}
|
|
64845
|
+
} catch (err3) {
|
|
64846
|
+
_didIteratorError = true;
|
|
64847
|
+
_iteratorError = err3;
|
|
64848
|
+
} finally {
|
|
64849
|
+
try {
|
|
64850
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
64851
|
+
_iterator.return();
|
|
64852
|
+
}
|
|
64853
|
+
} finally {
|
|
64854
|
+
if (_didIteratorError) {
|
|
64855
|
+
throw _iteratorError;
|
|
64856
|
+
}
|
|
64857
|
+
}
|
|
64858
|
+
}
|
|
64859
|
+
schemaCache.set(ref, current);
|
|
64860
|
+
return current;
|
|
64861
|
+
};
|
|
64862
|
+
}
|
|
64863
|
+
});
|
|
64864
|
+
|
|
64865
|
+
// ../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/dereference.js
|
|
64866
|
+
var require_dereference = __commonJS({
|
|
64867
|
+
"../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/dereference.js"(exports2) {
|
|
64868
|
+
"use strict";
|
|
64869
|
+
init_cjs_shims();
|
|
64870
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
64871
|
+
value: true
|
|
64872
|
+
});
|
|
64873
|
+
Object.defineProperty(exports2, "dereferenceSync", {
|
|
64874
|
+
enumerable: true,
|
|
64875
|
+
get: function() {
|
|
64876
|
+
return dereferenceSync;
|
|
64877
|
+
}
|
|
64878
|
+
});
|
|
64879
|
+
var _klona = require_klona();
|
|
64880
|
+
var _resolveRef = require_resolveRef();
|
|
64881
|
+
var cache = /* @__PURE__ */ new Map();
|
|
64882
|
+
var dereferenceSync = function(schema) {
|
|
64883
|
+
if (cache.has(schema)) {
|
|
64884
|
+
return cache.get(schema);
|
|
64885
|
+
}
|
|
64886
|
+
var visitedNodes = /* @__PURE__ */ new Set();
|
|
64887
|
+
var cloned = (0, _klona.klona)(schema);
|
|
64888
|
+
var resolve2 = function(current, path2) {
|
|
64889
|
+
if (typeof current === "object" && current !== null) {
|
|
64890
|
+
if (visitedNodes.has(current)) {
|
|
64891
|
+
return current;
|
|
64892
|
+
}
|
|
64893
|
+
visitedNodes.add(current);
|
|
64894
|
+
if (Array.isArray(current)) {
|
|
64895
|
+
for (var index2 = 0; index2 < current.length; index2++) {
|
|
64896
|
+
current[index2] = resolve2(current[index2], "".concat(path2, "/").concat(index2));
|
|
64897
|
+
}
|
|
64898
|
+
} else {
|
|
64899
|
+
if ("$ref" in current && typeof current["$ref"] === "string") {
|
|
64900
|
+
return (0, _resolveRef.resolveRefSync)(cloned, current["$ref"]);
|
|
64901
|
+
}
|
|
64902
|
+
for (var key in current) {
|
|
64903
|
+
current[key] = resolve2(current[key], "".concat(path2, "/").concat(key));
|
|
64904
|
+
}
|
|
64905
|
+
}
|
|
64906
|
+
}
|
|
64907
|
+
return current;
|
|
64908
|
+
};
|
|
64909
|
+
var result = resolve2(cloned, "#");
|
|
64910
|
+
cache.set(schema, result);
|
|
64911
|
+
return result;
|
|
64912
|
+
};
|
|
64913
|
+
}
|
|
64914
|
+
});
|
|
64915
|
+
|
|
64916
|
+
// ../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/index.js
|
|
64917
|
+
var require_dereference_json_schema = __commonJS({
|
|
64918
|
+
"../../../node_modules/.pnpm/dereference-json-schema@0.2.2/node_modules/dereference-json-schema/index.js"(exports2) {
|
|
64919
|
+
"use strict";
|
|
64920
|
+
init_cjs_shims();
|
|
64921
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
64922
|
+
value: true
|
|
64923
|
+
});
|
|
64924
|
+
_exportStar(require_types3(), exports2);
|
|
64925
|
+
_exportStar(require_dereference(), exports2);
|
|
64926
|
+
_exportStar(require_resolveRef(), exports2);
|
|
64927
|
+
function _exportStar(from25, to2) {
|
|
64928
|
+
Object.keys(from25).forEach(function(k) {
|
|
64929
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to2, k)) Object.defineProperty(to2, k, {
|
|
64930
|
+
enumerable: true,
|
|
64931
|
+
get: function() {
|
|
64932
|
+
return from25[k];
|
|
64933
|
+
}
|
|
64934
|
+
});
|
|
64935
|
+
});
|
|
64936
|
+
return from25;
|
|
64937
|
+
}
|
|
64938
|
+
}
|
|
64939
|
+
});
|
|
64940
|
+
|
|
64752
64941
|
// src/run-server.ts
|
|
64753
64942
|
init_cjs_shims();
|
|
64754
64943
|
|
|
@@ -113816,13 +114005,13 @@ var import_path2 = require("path");
|
|
|
113816
114005
|
var import_url = require("url");
|
|
113817
114006
|
function getVersion2() {
|
|
113818
114007
|
if (true) {
|
|
113819
|
-
return "0.8.
|
|
114008
|
+
return "0.8.4";
|
|
113820
114009
|
}
|
|
113821
114010
|
const __dirname3 = (0, import_path2.dirname)((0, import_url.fileURLToPath)(importMetaUrl));
|
|
113822
|
-
const
|
|
114011
|
+
const pkg2 = JSON.parse(
|
|
113823
114012
|
(0, import_fs3.readFileSync)((0, import_path2.join)(__dirname3, "../../package.json"), "utf-8")
|
|
113824
114013
|
);
|
|
113825
|
-
return
|
|
114014
|
+
return pkg2.version;
|
|
113826
114015
|
}
|
|
113827
114016
|
var MCP_VERSION = getVersion2();
|
|
113828
114017
|
var DIST_TAG = MCP_VERSION.includes("-beta") ? "beta" : "latest";
|
|
@@ -113979,7 +114168,7 @@ var TEMPO_TOKEN_ADDRESS = "0x20c0000000000000000000000000000000000000";
|
|
|
113979
114168
|
|
|
113980
114169
|
// src/shared/mpp-enabled.ts
|
|
113981
114170
|
init_cjs_shims();
|
|
113982
|
-
var isMppEnabled = () => "0.8.
|
|
114171
|
+
var isMppEnabled = () => "0.8.4".includes("-mpp");
|
|
113983
114172
|
|
|
113984
114173
|
// src/shared/operations/fetch-with-payment.ts
|
|
113985
114174
|
init_cjs_shims();
|
|
@@ -115009,6 +115198,18 @@ async function handleX402Payment(surface2, response, clonedRequest, client, befo
|
|
|
115009
115198
|
return paymentRequiredResult;
|
|
115010
115199
|
}
|
|
115011
115200
|
const paymentRequired = paymentRequiredResult.value;
|
|
115201
|
+
if (paymentRequired.x402Version === 1) {
|
|
115202
|
+
return x402Err(surface2, {
|
|
115203
|
+
cause: "parse_payment_required",
|
|
115204
|
+
message: "This endpoint uses the x402 v1 format, which is not supported by agentcash. Only x402 v2 servers (with an `accepts` array in the Payment-Required header) are supported."
|
|
115205
|
+
});
|
|
115206
|
+
}
|
|
115207
|
+
if (!paymentRequired.accepts || !Array.isArray(paymentRequired.accepts)) {
|
|
115208
|
+
return x402Err(surface2, {
|
|
115209
|
+
cause: "parse_payment_required",
|
|
115210
|
+
message: "This endpoint has a missing or malformed accepts array in the Payment-Required header."
|
|
115211
|
+
});
|
|
115212
|
+
}
|
|
115012
115213
|
const accept = paymentRequired.accepts[0];
|
|
115013
115214
|
if (accept) {
|
|
115014
115215
|
const amount2 = tokenStringToNumber(accept.amount);
|
|
@@ -115364,7 +115565,7 @@ var ORIGINS = [
|
|
|
115364
115565
|
var ORIGIN_METADATA = {
|
|
115365
115566
|
["https://stableenrich.dev" /* StableEnrich */]: {
|
|
115366
115567
|
title: "StableEnrich",
|
|
115367
|
-
description: "People/org search, Google Maps,
|
|
115568
|
+
description: "People/org search, Google Maps, Exa web search, LinkedIn data, Firecrawl scrape, WhitePages, email enrichment"
|
|
115368
115569
|
},
|
|
115369
115570
|
["https://stablesocial.dev" /* StableSocial */]: {
|
|
115370
115571
|
title: "StableSocial",
|
|
@@ -116057,8 +116258,9 @@ init_cjs_shims();
|
|
|
116057
116258
|
// src/shared/operations/check-endpoint.ts
|
|
116058
116259
|
init_cjs_shims();
|
|
116059
116260
|
|
|
116060
|
-
// ../../../node_modules/.pnpm/@agentcash+discovery@1.0
|
|
116261
|
+
// ../../../node_modules/.pnpm/@agentcash+discovery@1.1.0/node_modules/@agentcash/discovery/dist/index.js
|
|
116061
116262
|
init_cjs_shims();
|
|
116263
|
+
var import_dereference_json_schema = __toESM(require_dereference_json_schema(), 1);
|
|
116062
116264
|
|
|
116063
116265
|
// ../../../node_modules/.pnpm/@x402+core@2.6.0/node_modules/@x402/core/dist/esm/schemas/index.mjs
|
|
116064
116266
|
init_cjs_shims();
|
|
@@ -116136,7 +116338,7 @@ var PaymentPayloadSchema = external_exports4.discriminatedUnion("x402Version", [
|
|
|
116136
116338
|
PaymentPayloadV2Schema
|
|
116137
116339
|
]);
|
|
116138
116340
|
|
|
116139
|
-
// ../../../node_modules/.pnpm/@agentcash+discovery@1.0
|
|
116341
|
+
// ../../../node_modules/.pnpm/@agentcash+discovery@1.1.0/node_modules/@agentcash/discovery/dist/index.js
|
|
116140
116342
|
var OpenApiPaymentInfoSchema = external_exports3.object({
|
|
116141
116343
|
pricingMode: external_exports3.enum(["fixed", "range", "quote"]),
|
|
116142
116344
|
price: external_exports3.string().optional(),
|
|
@@ -116184,6 +116386,7 @@ var OpenApiDocSchema = external_exports3.object({
|
|
|
116184
116386
|
description: external_exports3.string().optional(),
|
|
116185
116387
|
guidance: external_exports3.string().optional()
|
|
116186
116388
|
}),
|
|
116389
|
+
security: external_exports3.array(external_exports3.record(external_exports3.string(), external_exports3.array(external_exports3.string()))).optional(),
|
|
116187
116390
|
servers: external_exports3.array(external_exports3.object({ url: external_exports3.string() })).optional(),
|
|
116188
116391
|
tags: external_exports3.array(external_exports3.object({ name: external_exports3.string() })).optional(),
|
|
116189
116392
|
components: external_exports3.object({ securitySchemes: external_exports3.record(external_exports3.string(), external_exports3.unknown()).optional() }).optional(),
|
|
@@ -116211,20 +116414,31 @@ var WellKnownParsedSchema = external_exports3.object({
|
|
|
116211
116414
|
function isRecord(value) {
|
|
116212
116415
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
116213
116416
|
}
|
|
116214
|
-
function
|
|
116215
|
-
|
|
116216
|
-
|
|
116217
|
-
|
|
116218
|
-
|
|
116417
|
+
function resolveSecurityFlags(requirements, securitySchemes) {
|
|
116418
|
+
let hasApiKey = false;
|
|
116419
|
+
let hasSiwx = false;
|
|
116420
|
+
for (const requirement of requirements) {
|
|
116421
|
+
for (const schemeName of Object.keys(requirement)) {
|
|
116422
|
+
if (schemeName === "siwx") {
|
|
116423
|
+
hasSiwx = true;
|
|
116424
|
+
continue;
|
|
116425
|
+
}
|
|
116426
|
+
if (schemeName === "apiKey") {
|
|
116427
|
+
hasApiKey = true;
|
|
116428
|
+
continue;
|
|
116429
|
+
}
|
|
116430
|
+
const def = securitySchemes[schemeName];
|
|
116431
|
+
if (isRecord(def) && def["type"] === "apiKey") hasApiKey = true;
|
|
116432
|
+
}
|
|
116433
|
+
}
|
|
116434
|
+
return { hasApiKey, hasSiwx };
|
|
116219
116435
|
}
|
|
116220
|
-
function inferAuthMode(operation) {
|
|
116436
|
+
function inferAuthMode(operation, globalSecurity, securitySchemes) {
|
|
116221
116437
|
const hasXPaymentInfo = Boolean(operation["x-payment-info"]);
|
|
116222
|
-
const
|
|
116223
|
-
const hasApiKey =
|
|
116224
|
-
|
|
116225
|
-
if (hasPayment && hasApiKey) return "apiKey+paid";
|
|
116438
|
+
const effectiveSecurity = operation.security !== void 0 && operation.security.length > 0 ? operation.security : globalSecurity ?? [];
|
|
116439
|
+
const { hasApiKey, hasSiwx } = resolveSecurityFlags(effectiveSecurity, securitySchemes ?? {});
|
|
116440
|
+
if (hasXPaymentInfo && hasApiKey) return "apiKey+paid";
|
|
116226
116441
|
if (hasXPaymentInfo) return "paid";
|
|
116227
|
-
if (hasPayment) return hasSiwx ? "siwx" : "paid";
|
|
116228
116442
|
if (hasApiKey) return "apiKey";
|
|
116229
116443
|
if (hasSiwx) return "siwx";
|
|
116230
116444
|
return void 0;
|
|
@@ -116240,10 +116454,12 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
116240
116454
|
"TRACE"
|
|
116241
116455
|
]);
|
|
116242
116456
|
var DEFAULT_MISSING_METHOD = "POST";
|
|
116243
|
-
function
|
|
116457
|
+
function ensureProtocol(target) {
|
|
116244
116458
|
const trimmed = target.trim();
|
|
116245
|
-
|
|
116246
|
-
|
|
116459
|
+
return /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
116460
|
+
}
|
|
116461
|
+
function normalizeOrigin(target) {
|
|
116462
|
+
const url3 = new URL(ensureProtocol(target));
|
|
116247
116463
|
url3.pathname = "";
|
|
116248
116464
|
url3.search = "";
|
|
116249
116465
|
url3.hash = "";
|
|
@@ -116277,22 +116493,20 @@ function toFetchError(err3) {
|
|
|
116277
116493
|
function fetchSafe(url3, init) {
|
|
116278
116494
|
return ResultAsync.fromPromise(fetch(url3, init), toFetchError);
|
|
116279
116495
|
}
|
|
116280
|
-
var isMmmEnabled = () => "1.0
|
|
116496
|
+
var isMmmEnabled = () => "1.1.0".includes("-mmm");
|
|
116281
116497
|
var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
116282
116498
|
const routes = [];
|
|
116283
116499
|
for (const [rawPath, pathItem] of Object.entries(doc.paths)) {
|
|
116284
116500
|
for (const httpMethod of [...HTTP_METHODS]) {
|
|
116285
116501
|
const operation = pathItem[httpMethod.toLowerCase()];
|
|
116286
116502
|
if (!operation) continue;
|
|
116287
|
-
const authMode = inferAuthMode(operation) ?? void 0;
|
|
116503
|
+
const authMode = inferAuthMode(operation, doc.security, doc.components?.securitySchemes) ?? void 0;
|
|
116288
116504
|
if (!authMode) continue;
|
|
116289
116505
|
const p = operation["x-payment-info"];
|
|
116290
116506
|
const protocols = (p?.protocols ?? []).filter(
|
|
116291
116507
|
(proto) => proto !== "mpp" || isMmmEnabled()
|
|
116292
116508
|
);
|
|
116293
|
-
|
|
116294
|
-
if (authMode === "paid" && protocols.length === 0) continue;
|
|
116295
|
-
const pricing = authMode === "paid" && p ? {
|
|
116509
|
+
const pricing = (authMode === "paid" || authMode === "apiKey+paid") && p ? {
|
|
116296
116510
|
pricingMode: p.pricingMode,
|
|
116297
116511
|
...p.price ? { price: p.price } : {},
|
|
116298
116512
|
...p.minPrice ? { minPrice: p.minPrice } : {},
|
|
@@ -116755,53 +116969,29 @@ function extractPaymentOptions4(wwwAuthenticate) {
|
|
|
116755
116969
|
}
|
|
116756
116970
|
return options;
|
|
116757
116971
|
}
|
|
116758
|
-
|
|
116759
|
-
|
|
116760
|
-
|
|
116761
|
-
for (const [specPath, entry] of Object.entries(paths)) {
|
|
116762
|
-
if (!isRecord(entry)) continue;
|
|
116763
|
-
const pattern = specPath.replace(/\{[^}]+\}/g, "[^/]+");
|
|
116764
|
-
const regex = new RegExp(`^${pattern}$`);
|
|
116765
|
-
if (regex.test(targetPath)) {
|
|
116766
|
-
return { matchedPath: specPath, pathItem: entry };
|
|
116767
|
-
}
|
|
116768
|
-
}
|
|
116769
|
-
return null;
|
|
116770
|
-
}
|
|
116771
|
-
function resolveRef2(document2, ref, seen) {
|
|
116772
|
-
if (!ref.startsWith("#/")) return void 0;
|
|
116773
|
-
if (seen.has(ref)) return { $circular: ref };
|
|
116774
|
-
seen.add(ref);
|
|
116775
|
-
const parts = ref.slice(2).split("/");
|
|
116776
|
-
let current = document2;
|
|
116777
|
-
for (const part of parts) {
|
|
116778
|
-
if (!isRecord(current)) return void 0;
|
|
116779
|
-
current = current[part];
|
|
116780
|
-
if (current === void 0) return void 0;
|
|
116781
|
-
}
|
|
116782
|
-
if (isRecord(current)) return resolveRefs(document2, current, seen);
|
|
116783
|
-
return current;
|
|
116972
|
+
var { resolveRefSync } = import_dereference_json_schema.default;
|
|
116973
|
+
function isRecord2(value) {
|
|
116974
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
116784
116975
|
}
|
|
116785
|
-
function
|
|
116786
|
-
if (depth > 4) return obj;
|
|
116976
|
+
function deepResolveRefs(document2, obj) {
|
|
116787
116977
|
const resolved = {};
|
|
116788
116978
|
for (const [key, value] of Object.entries(obj)) {
|
|
116789
116979
|
if (key === "$ref" && typeof value === "string") {
|
|
116790
|
-
const deref =
|
|
116791
|
-
if (
|
|
116792
|
-
Object.assign(resolved, deref);
|
|
116980
|
+
const deref = resolveRefSync(document2, value);
|
|
116981
|
+
if (isRecord2(deref)) {
|
|
116982
|
+
Object.assign(resolved, deepResolveRefs(document2, deref));
|
|
116793
116983
|
} else {
|
|
116794
116984
|
resolved[key] = value;
|
|
116795
116985
|
}
|
|
116796
116986
|
continue;
|
|
116797
116987
|
}
|
|
116798
|
-
if (
|
|
116799
|
-
resolved[key] =
|
|
116988
|
+
if (isRecord2(value)) {
|
|
116989
|
+
resolved[key] = deepResolveRefs(document2, value);
|
|
116800
116990
|
continue;
|
|
116801
116991
|
}
|
|
116802
116992
|
if (Array.isArray(value)) {
|
|
116803
116993
|
resolved[key] = value.map(
|
|
116804
|
-
(item) =>
|
|
116994
|
+
(item) => isRecord2(item) ? deepResolveRefs(document2, item) : item
|
|
116805
116995
|
);
|
|
116806
116996
|
continue;
|
|
116807
116997
|
}
|
|
@@ -116809,6 +116999,22 @@ function resolveRefs(document2, obj, seen, depth = 0) {
|
|
|
116809
116999
|
}
|
|
116810
117000
|
return resolved;
|
|
116811
117001
|
}
|
|
117002
|
+
function resolveRefs(obj, document2) {
|
|
117003
|
+
return deepResolveRefs(document2, obj);
|
|
117004
|
+
}
|
|
117005
|
+
function findMatchingOpenApiPath(paths, targetPath) {
|
|
117006
|
+
const exact = paths[targetPath];
|
|
117007
|
+
if (isRecord(exact)) return { matchedPath: targetPath, pathItem: exact };
|
|
117008
|
+
for (const [specPath, entry] of Object.entries(paths)) {
|
|
117009
|
+
if (!isRecord(entry)) continue;
|
|
117010
|
+
const pattern = specPath.replace(/\{[^}]+\}/g, "[^/]+");
|
|
117011
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
117012
|
+
if (regex.test(targetPath)) {
|
|
117013
|
+
return { matchedPath: specPath, pathItem: entry };
|
|
117014
|
+
}
|
|
117015
|
+
}
|
|
117016
|
+
return null;
|
|
117017
|
+
}
|
|
116812
117018
|
function extractRequestBodySchema(operationSchema) {
|
|
116813
117019
|
const requestBody = operationSchema.requestBody;
|
|
116814
117020
|
if (!isRecord(requestBody)) return void 0;
|
|
@@ -116888,7 +117094,7 @@ function getL3ForOpenAPI(openApi, path2, method) {
|
|
|
116888
117094
|
if (!matched) return null;
|
|
116889
117095
|
const operation = matched.pathItem[method.toLowerCase()];
|
|
116890
117096
|
if (!isRecord(operation)) return null;
|
|
116891
|
-
const resolvedOperation = resolveRefs(
|
|
117097
|
+
const resolvedOperation = resolveRefs(operation, document2);
|
|
116892
117098
|
const summary = typeof resolvedOperation.summary === "string" ? resolvedOperation.summary : typeof resolvedOperation.description === "string" ? resolvedOperation.description : void 0;
|
|
116893
117099
|
return {
|
|
116894
117100
|
source: "openapi",
|
|
@@ -116932,12 +117138,12 @@ function getAdvisoriesForProbe(probe, path2) {
|
|
|
116932
117138
|
});
|
|
116933
117139
|
}
|
|
116934
117140
|
async function checkEndpointSchema(options) {
|
|
116935
|
-
const endpoint = new URL(options.url);
|
|
117141
|
+
const endpoint = new URL(ensureProtocol(options.url));
|
|
116936
117142
|
const origin = normalizeOrigin(endpoint.origin);
|
|
116937
117143
|
const path2 = normalizePath(endpoint.pathname || "/");
|
|
116938
117144
|
if (options.sampleInputBody !== void 0) {
|
|
116939
117145
|
const probeResult2 = await getProbe(
|
|
116940
|
-
|
|
117146
|
+
endpoint.href,
|
|
116941
117147
|
options.headers,
|
|
116942
117148
|
options.signal,
|
|
116943
117149
|
options.sampleInputBody
|
|
@@ -116962,7 +117168,7 @@ async function checkEndpointSchema(options) {
|
|
|
116962
117168
|
if (advisories2.length > 0) return { found: true, origin, path: path2, advisories: advisories2 };
|
|
116963
117169
|
return { found: false, origin, path: path2, cause: "not_found" };
|
|
116964
117170
|
}
|
|
116965
|
-
const probeResult = await getProbe(
|
|
117171
|
+
const probeResult = await getProbe(endpoint.href, options.headers, options.signal);
|
|
116966
117172
|
if (probeResult.isErr()) {
|
|
116967
117173
|
return {
|
|
116968
117174
|
found: false,
|
|
@@ -117811,7 +118017,7 @@ var PROMPT_CONTENT2 = `To start, you should check this resource page: ${"https:/
|
|
|
117811
118017
|
- You should use these paid endpoints to find useful information whenever possible.
|
|
117812
118018
|
- Opt to use the paid endpoints as often as possible, as they speed up your research and provide higher quality information than traditional WebFetch.
|
|
117813
118019
|
|
|
117814
|
-
- **IMPORTANT:** All the API endpoints below (Exa, Firecrawl, Clado, Google Maps, Apollo,
|
|
118020
|
+
- **IMPORTANT:** All the API endpoints below (Exa, Firecrawl, Clado, Google Maps, Apollo, Whitepages, Hunter) are accessed via mcp__x402__fetch. They are NOT separate MCP tools. Call them like: mcp__x402__fetch(url="${"https://stableenrich.dev" /* StableEnrich */}/api/clado/contacts-enrich", method="POST", body={...})
|
|
117815
118021
|
- Use the Exa and Firecrawl endpoints as advanced / better WebFetch. They will often return data that would otherwise return only javascript or blocked content.
|
|
117816
118022
|
- If you get a 403 or error when using WebSearch or WebFetch on a website, try with Exa/Firecrawl endpoints immediately as they likely can get around the blockage.
|
|
117817
118023
|
- Use the Clado endpoints (/api/clado/contacts-enrich, /api/clado/linkedin-scrape) to enrich information about people and find their linkedin or email addresses. If linkedin returns an error code, immediately try with the Clado endpoints.
|
|
@@ -117886,13 +118092,13 @@ var import_path3 = require("path");
|
|
|
117886
118092
|
var import_url2 = require("url");
|
|
117887
118093
|
function getVersion3() {
|
|
117888
118094
|
if (true) {
|
|
117889
|
-
return "0.8.
|
|
118095
|
+
return "0.8.4";
|
|
117890
118096
|
}
|
|
117891
118097
|
const __dirname3 = (0, import_path3.dirname)((0, import_url2.fileURLToPath)(importMetaUrl));
|
|
117892
|
-
const
|
|
118098
|
+
const pkg2 = JSON.parse(
|
|
117893
118099
|
(0, import_fs8.readFileSync)((0, import_path3.join)(__dirname3, "../../../package.json"), "utf-8")
|
|
117894
118100
|
);
|
|
117895
|
-
return
|
|
118101
|
+
return pkg2.version;
|
|
117896
118102
|
}
|
|
117897
118103
|
var MCP_VERSION2 = getVersion3();
|
|
117898
118104
|
var DIST_TAG2 = MCP_VERSION2.includes("-beta") ? "beta" : "latest";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isMppEnabled
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-36HB4WY2.js";
|
|
4
4
|
import {
|
|
5
5
|
MCP_VERSION
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-F5TWCY6D.js";
|
|
7
7
|
import {
|
|
8
8
|
getBalance,
|
|
9
9
|
getBaseUrl,
|
|
@@ -138,4 +138,4 @@ export {
|
|
|
138
138
|
getWalletInfo,
|
|
139
139
|
submitErrorReport
|
|
140
140
|
};
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-ECZS3TJG.js.map
|
|
@@ -4,7 +4,7 @@ import { dirname, join } from "path";
|
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
function getVersion() {
|
|
6
6
|
if (true) {
|
|
7
|
-
return "0.8.
|
|
7
|
+
return "0.8.4";
|
|
8
8
|
}
|
|
9
9
|
const __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
const pkg = JSON.parse(
|
|
@@ -19,4 +19,4 @@ export {
|
|
|
19
19
|
MCP_VERSION,
|
|
20
20
|
DIST_TAG
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-F5TWCY6D.js.map
|
|
@@ -21,7 +21,7 @@ var ORIGINS = [
|
|
|
21
21
|
var ORIGIN_METADATA = {
|
|
22
22
|
["https://stableenrich.dev" /* StableEnrich */]: {
|
|
23
23
|
title: "StableEnrich",
|
|
24
|
-
description: "People/org search, Google Maps,
|
|
24
|
+
description: "People/org search, Google Maps, Exa web search, LinkedIn data, Firecrawl scrape, WhitePages, email enrichment"
|
|
25
25
|
},
|
|
26
26
|
["https://stablesocial.dev" /* StableSocial */]: {
|
|
27
27
|
title: "StableSocial",
|
|
@@ -270,4 +270,4 @@ export {
|
|
|
270
270
|
addUserOrigin,
|
|
271
271
|
removeUserOrigin
|
|
272
272
|
};
|
|
273
|
-
//# sourceMappingURL=chunk-
|
|
273
|
+
//# sourceMappingURL=chunk-LSDMWRFT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared/origins.ts","../../src/shared/descriptions.ts","../../src/shared/user-origins.ts"],"sourcesContent":["/**\n * Known x402-protected API origins.\n * Using const enum so values are inlined at build time.\n */\nexport const enum Origin {\n StableEnrich = 'https://stableenrich.dev',\n StableSocial = 'https://stablesocial.dev',\n StableStudio = 'https://stablestudio.dev',\n StableUpload = 'https://stableupload.dev',\n StableEmail = 'https://stableemail.dev',\n X402Scan = 'https://x402scan.com',\n Shirt = 'https://shirt.sh',\n X402Puppet = 'https://x402puppet.com',\n X402Facilitator = 'https://x402facilitator.com',\n}\n\n/**\n * Array of all known origins for iteration.\n * Const enums are erased at compile time, so we need a regular array for runtime iteration.\n */\nexport const ORIGINS = [\n Origin.StableEnrich,\n Origin.StableSocial,\n Origin.StableStudio,\n Origin.StableUpload,\n Origin.StableEmail,\n Origin.X402Scan,\n Origin.Shirt,\n Origin.X402Puppet,\n] as const;\n","/**\n * Single source of truth for all LLM-facing text in the MCP package.\n *\n * `DESCRIPTIONS` covers every tool with both an `mcp` variant (detailed,\n * AI-audience) and a `cli` variant (concise, human-readable for --help).\n * `serverInstructions` is shared across both surfaces.\n *\n * Additional exports cover parameter/output schema descriptions, origin\n * metadata, and prompt content — all LLM-facing text in one place.\n */\n\nimport { Origin } from './origins';\nimport type { UserOrigin } from './user-origins';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Origin metadata (used for MCP resource registration descriptions)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const ORIGIN_METADATA: Record<\n string,\n { title: string; description: string }\n> = {\n [Origin.StableEnrich]: {\n title: 'StableEnrich',\n description:\n 'People/org search, Google Maps, Exa web search, LinkedIn data, Firecrawl scrape, WhitePages, email enrichment',\n },\n [Origin.StableSocial]: {\n title: 'StableSocial',\n description:\n 'Social media data for Twitter, Instagram, TikTok, YouTube, Facebook, Reddit',\n },\n [Origin.StableStudio]: {\n title: 'StableStudio',\n description: 'Generate and edit images and videos',\n },\n [Origin.StableUpload]: {\n title: 'StableUpload',\n description: 'Pay to upload files, get a permanent download URL.',\n },\n [Origin.StableEmail]: {\n title: 'StableEmail',\n description: 'Send emails',\n },\n [Origin.X402Scan]: {\n title: 'X402 Scan',\n description: 'x402 protocol explorer',\n },\n [Origin.Shirt]: {\n title: 'Shirt',\n description: 'Shirt.sh',\n },\n [Origin.X402Puppet]: {\n title: 'X402 Puppet',\n description: 'Browser automation',\n },\n [Origin.X402Facilitator]: {\n title: 'X402 Facilitator',\n description: 'Payment facilitation',\n },\n};\n\nexport const PRIMARY_ORIGINS = [\n Origin.StableEnrich,\n Origin.StableSocial,\n Origin.StableStudio,\n Origin.StableUpload,\n Origin.StableEmail,\n] as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Tool descriptions — { mcp, cli } per tool + shared serverInstructions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const DESCRIPTIONS = {\n fetch: {\n mcp: `HTTP fetch with automatic x402 payment handling. Makes the request and, if the endpoint returns 402, signs payment and retries with payment headers. Returns response data along with payment details (price, tx hash) if a payment was made.\\n\\nFor endpoints you haven't called before in this session, you MUST call check_endpoint_schema first to confirm the request body schema. Skipping this causes 400 errors from wrong field names.`,\n cli: `HTTP fetch with automatic x402 payment handling. If the endpoint returns 402, signs payment and retries — no manual payment steps needed. Run 'check <url>' first to confirm the request body schema; skipping this causes 400 errors from wrong field names.`,\n epilogue: `Workflow: check <url> → fetch <url> -m POST -b '{\"field\":\"value\"}'\\nUse 'fetch-auth' instead if the endpoint requires identity (SIWX) rather than payment.`,\n },\n\n fetchWithAuth: {\n mcp: `HTTP fetch with automatic SIWX (Sign-In With X) authentication. Sends an authenticated request to a SIWX-protected endpoint. Returns response data gated by the endpoint's authentication requirements.\\n\\nFor endpoints you haven't called before in this session, you MUST call check_endpoint_schema first to confirm the request body schema. Skipping this causes 400 errors from wrong field names.`,\n cli: `HTTP fetch with automatic SIWX (Sign-In With X) authentication for identity-gated endpoints. No payment required — the wallet is used as an identity proof only. Run 'check <url>' first to confirm the request body schema; skipping this causes 400 errors from wrong field names.`,\n epilogue: `Workflow: check <url> → fetch-auth <url> -m POST -b '{\"field\":\"value\"}'\\nUse 'fetch' instead if the endpoint requires payment (x402) rather than identity.`,\n },\n\n getWalletInfo: {\n mcp: `Get wallet address and USDC balance. Auto-creates wallet on first use (~/.agentcash/wallet.json). Returns a deposit link if funding is needed. If onboardingCta is present, show its message to the user — it means they haven't onboarded yet and need to either visit the onboard link or deposit directly.`,\n cli: `Get wallet address, USDC balance, and deposit link. Creates the wallet on first use (~/.agentcash/wallet.json). Check this before making paid API calls — if balance is zero, deposit USDC using the returned link.`,\n },\n\n checkEndpointSchema: {\n mcp: [\n `Get the input/output schema and auth mode (paid or SIWX) for a single endpoint.`,\n `Call this to see exactly what fields the request body expects and what the response contains.`,\n `Returns the schema from the origin's OpenAPI spec. Optionally pass sample_input_body to probe the endpoint live (without payment) for an exact price quote — do this when pricing is range-based or quote-based, or when you're unsure about the input schema.`,\n ].join('\\n\\n'),\n cli: `Get the input/output schema and auth mode (paid or SIWX) for an endpoint. Returns exact field names from the OpenAPI spec — call this before 'fetch' or 'fetch-auth' to avoid 400 errors. Pass --body to probe the endpoint live for an exact price quote when pricing is range-based or unclear.`,\n epilogue: `Auth mode tells you which command to use:\\n paid → agentcash fetch <url>\\n SIWX → agentcash fetch-auth <url>`,\n },\n\n discoverApiEndpoints: {\n mcp: [\n `List available endpoints at an API origin. Returns endpoint URLs with descriptions of what each does and the auth mode for each (paid or SIWX). Works with any origin, not just the registered ones.`,\n `Call this when you need to see what routes are available at an origin — whether it's one of the registered origins or any other origin you've identified as useful.`,\n `The response always indicates whether guidance is available. Guidance is documentation published by the API provider explaining how endpoints work together, edge cases, and usage tips. compact guidance is included automatically; set include_guidance=true to force-include full usage documentation when you need to compose two or more endpoints or need clarification on how the origin works.`,\n ].join('\\n\\n'),\n cli: `List available endpoints at an API origin with descriptions and auth modes (paid or SIWX). Works with any origin, not just registered ones. Add --include-guidance for full provider docs when composing multiple endpoints or when usage is unclear.`,\n epilogue: `Registered origins:\\n${PRIMARY_ORIGINS.flatMap(o => (ORIGIN_METADATA[o] ? [` ${o} — ${ORIGIN_METADATA[o].description}`] : [])).join('\\n')}`,\n },\n\n redeemInvite: {\n mcp: `Redeem an invite code for free USDC on Base. One-time use per code. Returns amount received and transaction hash. Use get_wallet_info after to verify balance.`,\n cli: `Redeem an invite code for free USDC on Base. One-time use per code. Run 'wallet info' after to verify the balance landed.`,\n },\n\n try: {\n cli: `Fetch a new origin for its resources and return a prompt guiding the user through the process of calling the first endpoint.`,\n },\n\n reportError: {\n mcp: `EMERGENCY ONLY. Report critical MCP tool bugs. Do NOT use for normal errors (balance, network, 4xx) — those are recoverable.`,\n cli: `Report a critical bug to the agentcash team (emergency only). Do NOT use for normal errors like low balance, network timeouts, or 4xx responses — those are recoverable without filing a report.`,\n },\n\n updateSettings: {\n mcp: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount — the maximum USD amount allowed per fetch request. If a fetch response requests more than this, the payment is rejected. Returns the current settings after applying changes.`,\n },\n\n getSettings: {\n mcp: `Get current user settings. Returns persisted values from ~/.agentcash/settings.json with defaults applied.`,\n },\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Dynamic server instructions (includes user-added origins at runtime)\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst WORKFLOW = [\n `Workflow:`,\n `1. If you don't already know your balance, call get_wallet_info. You need a balance for paid endpoints — if it's zero, share the deposit link with the user. SIWX endpoints don't require a balance. You don't need to call this every turn, just before your first paid call or whenever you're unsure.`,\n `2. Call discover_api_endpoints() to get the endpoint index — a list of available routes with descriptions and auth modes. The auth mode for each endpoint tells you whether to use fetch (paid) or fetch_with_auth (SIWX).`,\n `3. Call check_endpoint_schema() to get the exact input/output schema and auth mode for the endpoint you want to call, so you know what fields to pass and what the response contains. Both discover_api_endpoints and check_endpoint_schema return the auth mode.`,\n `4. Call fetch (paid) or fetch_with_auth (SIWX) based on the auth mode, and with the correct input schema.`,\n].join('\\n');\n\nexport function buildServerInstructions(\n userOrigins: UserOrigin[] = []\n): string {\n const allOrigins = [\n ...userOrigins.map(o => ` - ${o.url} — ${o.description}`),\n ...PRIMARY_ORIGINS.flatMap(o =>\n ORIGIN_METADATA[o] ? [` - ${o} — ${ORIGIN_METADATA[o].description}`] : []\n ),\n ].join('\\n');\n\n return [\n `AgentCash lets you call protected APIs — handling both x402 micropayments and SIWX authentication seamlessly. It manages a USDC wallet for paid endpoints (fetch) and signs wallet proofs for identity-gated endpoints (fetch_with_auth).`,\n `The user has installed agentcash because they want to use paid and SIWX-protected APIs as their preferred way to accomplish related tasks.`,\n `Paid endpoints require a wallet balance. SIWX endpoints are free — they only require a wallet identity.`,\n `If a task could be accomplished by one of these registered origins, run the workflow below:\\n${allOrigins}`,\n `discover_api_endpoints also works with any origin beyond this list. If you identify another origin that would be useful for a task, you can use it.`,\n WORKFLOW,\n `If you need to compose multiple endpoints in sequence, or anything about the origin's capabilities is unclear, call discover_api_endpoints with include_guidance=true to retrieve the origin's full usage documentation.`,\n ].join('\\n\\n');\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Shared request schema parameter descriptions\n// (used by fetch, fetch_with_auth tools)\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const REQUEST_PARAMS = {\n url: 'The endpoint URL',\n method: 'HTTP method. Defaults to GET for fetch operations.',\n body: 'Request body for POST/PUT/PATCH methods',\n headers: 'Additional headers to include',\n timeout: 'Request timeout in milliseconds',\n} as const;\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Per-tool parameter and output schema descriptions\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const TOOL_PARAMS = {\n fetch: {\n paymentMethod: 'Payment protocol to use. Defaults to auto-detect.',\n maxAmount:\n 'Maximum amount (in USD) to pay per request. Aborts if the endpoint requests more. Defaults to $5. Pass a higher value for known-expensive endpoints.',\n },\n\n checkEndpointSchema: {\n url: 'Full URL of the endpoint to inspect',\n method:\n 'HTTP method to check. If omitted, all methods declared in the spec are returned.',\n sampleInputBody:\n 'Optional. A sample request body to probe the endpoint live (without payment) for exact pricing. Use when pricing is range-based or quote-based, or when you need to verify the input schema. Omit to get the static schema and advisory pricing from the spec.',\n headers: 'Additional headers to include in the probe request',\n },\n\n getWalletInfo: {\n output: {\n address: 'Wallet address (0x...)',\n balance: 'Total USDC balance across all chains',\n chains: 'Balance breakdown by chain',\n isNewWallet: 'Whether the wallet is new and needs to be funded',\n depositLink: 'Link to deposit USDC directly into the wallet',\n onboardingCta:\n 'Present when the user has not yet redeemed an invite code. Show the message to the user — it directs them to onboard or deposit.',\n onboardingCtaOnboardLink: 'Link to the onboarding page',\n onboardingCtaDepositLink: 'Link to deposit USDC directly',\n onboardingCtaMessage: 'Human-readable CTA to show the user',\n message: 'Warning if balance is low',\n chain: 'Chain name',\n chainBalance: 'USDC balance on this chain',\n },\n },\n\n redeemInvite: {\n code: 'The invite code',\n output: {\n amount: 'Amount with unit (e.g., \"5 USDC\")',\n txHash: 'Transaction hash on Base',\n },\n },\n\n discoverApiEndpoints: {\n url: 'The origin URL to discover endpoints on (e.g. https://stableenrich.dev)',\n includeGuidance:\n \"Request the origin's usage guidance. true=always include, false=never include, omit=auto (included when compact). Guidance explains how to compose multiple endpoints and covers edge cases.\",\n },\n\n reportError: {\n tool: 'MCP tool name',\n resource: 'Resource URL',\n summary: '1-2 sentence summary',\n errorMessage: 'Error message',\n stack: 'Stack trace',\n fullReport: 'Detailed report with context, logs, repro steps',\n output: {\n reportId: 'Unique report ID for tracking',\n message: 'Confirmation message',\n },\n },\n} as const;\n","import * as fs from 'fs';\n\nimport z from 'zod';\n\nimport { configFile } from './fs';\nimport { safeParseJson } from './neverthrow/json';\n\nconst ORIGINS_FILE = configFile('origins.json');\n\nconst userOriginSchema = z.object({\n url: z.string(),\n title: z.string(),\n description: z.string(),\n addedAt: z.string(),\n});\n\nconst originsFileSchema = z.object({\n added: z.array(userOriginSchema),\n});\n\nexport type UserOrigin = z.infer<typeof userOriginSchema>;\n\nfunction readOriginsFile(): UserOrigin[] {\n if (!fs.existsSync(ORIGINS_FILE)) return [];\n const raw = fs.readFileSync(ORIGINS_FILE, 'utf-8');\n const json = safeParseJson('user-origins', raw);\n if (!json.isOk()) return [];\n const parsed = originsFileSchema.safeParse(json.value);\n return parsed.success ? parsed.data.added : [];\n}\n\nfunction writeOriginsFile(origins: UserOrigin[]): void {\n fs.writeFileSync(\n ORIGINS_FILE,\n JSON.stringify({ added: origins }, null, 2),\n 'utf-8'\n );\n}\n\nexport function loadUserOrigins(): UserOrigin[] {\n return readOriginsFile();\n}\n\nexport function addUserOrigin(origin: Omit<UserOrigin, 'addedAt'>): UserOrigin {\n const origins = readOriginsFile();\n const entry: UserOrigin = { ...origin, addedAt: new Date().toISOString() };\n const existing = origins.findIndex(o => o.url === origin.url);\n if (existing >= 0) {\n origins[existing] = entry;\n } else {\n origins.push(entry);\n }\n writeOriginsFile(origins);\n return entry;\n}\n\nexport function removeUserOrigin(url: string): { removed: boolean } {\n const origins = readOriginsFile();\n const filtered = origins.filter(o => o.url !== url);\n if (filtered.length === origins.length) return { removed: false };\n writeOriginsFile(filtered);\n return { removed: true };\n}\n"],"mappings":";;;;;;;;AAoBO,IAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACXO,IAAM,kBAGT;AAAA,EACF,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,8CAAoB,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,4CAAmB,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA,sCAAgB,GAAG;AAAA,IACjB,OAAO;AAAA,IACP,aAAa;AAAA,EACf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