agentcash 0.8.1 → 0.8.3
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 +426 -102
- package/dist/esm/{chunk-YQFK4U62.js → chunk-36KCO2CQ.js} +2 -2
- package/dist/esm/{chunk-W7DAJMFQ.js → chunk-4ALGXM6F.js} +11 -4
- package/dist/esm/chunk-4ALGXM6F.js.map +1 -0
- package/dist/esm/{chunk-ZDDDU5O2.js → chunk-5GVHLIVV.js} +2 -2
- package/dist/esm/{chunk-TQ4SMW3W.js → chunk-AFAWW7YZ.js} +2 -2
- package/dist/esm/{chunk-7ZEXMJYJ.js → chunk-B2JUF6FK.js} +3 -3
- package/dist/esm/{chunk-AUDGOEEE.js → chunk-BDGWC3Y4.js} +4 -4
- package/dist/esm/{chunk-6PU3XK6I.js → chunk-CM4BCEDY.js} +2 -2
- package/dist/esm/{chunk-6PU3XK6I.js.map → chunk-CM4BCEDY.js.map} +1 -1
- package/dist/esm/chunk-DKMBMJQA.js +7 -0
- package/dist/esm/{chunk-UN3PRLTL.js → chunk-DXPPE7QC.js} +5 -5
- package/dist/esm/{chunk-4R52CY5Q.js → chunk-LKZJ456N.js} +2 -2
- package/dist/esm/{chunk-OHA3LLUQ.js → chunk-NCBPOUV6.js} +3 -3
- package/dist/esm/{chunk-C36IAW7R.js → chunk-NPZ6POPF.js} +3 -3
- package/dist/esm/{chunk-AVLTYWSD.js → chunk-S5HW6SFM.js} +6 -6
- package/dist/esm/{chunk-X4YQNM7D.js → chunk-W65V5DL2.js} +86 -17
- package/dist/esm/chunk-W65V5DL2.js.map +1 -0
- package/dist/esm/{commands-B5TNSXYH.js → commands-D4LB6MQN.js} +60 -17
- package/dist/esm/commands-D4LB6MQN.js.map +1 -0
- package/dist/esm/{fund-PRV53MDA.js → fund-IZ2RYDXT.js} +7 -7
- package/dist/esm/index.js +61 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{install-JQKZJ656.js → install-3EASO5YD.js} +9 -9
- package/dist/esm/lib.js +4 -4
- package/dist/esm/{server-HVKLQ3C3.js → server-P5FI6GYD.js} +88 -27
- package/dist/esm/server-P5FI6GYD.js.map +1 -0
- package/dist/esm/shared/operations/index.js +7 -7
- package/package.json +4 -4
- package/dist/esm/chunk-W7DAJMFQ.js.map +0 -1
- package/dist/esm/chunk-X4YQNM7D.js.map +0 -1
- package/dist/esm/chunk-YK5LKPBE.js +0 -7
- package/dist/esm/commands-B5TNSXYH.js.map +0 -1
- package/dist/esm/server-HVKLQ3C3.js.map +0 -1
- /package/dist/esm/{chunk-YQFK4U62.js.map → chunk-36KCO2CQ.js.map} +0 -0
- /package/dist/esm/{chunk-ZDDDU5O2.js.map → chunk-5GVHLIVV.js.map} +0 -0
- /package/dist/esm/{chunk-TQ4SMW3W.js.map → chunk-AFAWW7YZ.js.map} +0 -0
- /package/dist/esm/{chunk-7ZEXMJYJ.js.map → chunk-B2JUF6FK.js.map} +0 -0
- /package/dist/esm/{chunk-AUDGOEEE.js.map → chunk-BDGWC3Y4.js.map} +0 -0
- /package/dist/esm/{chunk-YK5LKPBE.js.map → chunk-DKMBMJQA.js.map} +0 -0
- /package/dist/esm/{chunk-UN3PRLTL.js.map → chunk-DXPPE7QC.js.map} +0 -0
- /package/dist/esm/{chunk-4R52CY5Q.js.map → chunk-LKZJ456N.js.map} +0 -0
- /package/dist/esm/{chunk-OHA3LLUQ.js.map → chunk-NCBPOUV6.js.map} +0 -0
- /package/dist/esm/{chunk-C36IAW7R.js.map → chunk-NPZ6POPF.js.map} +0 -0
- /package/dist/esm/{chunk-AVLTYWSD.js.map → chunk-S5HW6SFM.js.map} +0 -0
- /package/dist/esm/{fund-PRV53MDA.js.map → fund-IZ2RYDXT.js.map} +0 -0
- /package/dist/esm/{install-JQKZJ656.js.map → install-3EASO5YD.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;
|
|
@@ -6860,12 +6860,12 @@ var require_dist = __commonJS({
|
|
|
6860
6860
|
throw new Error(`Unknown format "${name}"`);
|
|
6861
6861
|
return f;
|
|
6862
6862
|
};
|
|
6863
|
-
function addFormats(ajv, list2,
|
|
6863
|
+
function addFormats(ajv, list2, fs11, exportName) {
|
|
6864
6864
|
var _a2;
|
|
6865
6865
|
var _b;
|
|
6866
6866
|
(_a2 = (_b = ajv.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6867
6867
|
for (const f of list2)
|
|
6868
|
-
ajv.addFormat(f,
|
|
6868
|
+
ajv.addFormat(f, fs11[f]);
|
|
6869
6869
|
}
|
|
6870
6870
|
module2.exports = exports2 = formatsPlugin;
|
|
6871
6871
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -47364,7 +47364,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
47364
47364
|
"../../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js"(exports2, module2) {
|
|
47365
47365
|
"use strict";
|
|
47366
47366
|
init_cjs_shims();
|
|
47367
|
-
var
|
|
47367
|
+
var fs11 = require("fs");
|
|
47368
47368
|
var path2 = require("path");
|
|
47369
47369
|
var os2 = require("os");
|
|
47370
47370
|
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
@@ -47425,7 +47425,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
47425
47425
|
};
|
|
47426
47426
|
function readdirSync2(dir) {
|
|
47427
47427
|
try {
|
|
47428
|
-
return
|
|
47428
|
+
return fs11.readdirSync(dir);
|
|
47429
47429
|
} catch (err3) {
|
|
47430
47430
|
return [];
|
|
47431
47431
|
}
|
|
@@ -47519,7 +47519,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
47519
47519
|
return typeof window !== "undefined" && window.process && window.process.type === "renderer";
|
|
47520
47520
|
}
|
|
47521
47521
|
function isAlpine(platform3) {
|
|
47522
|
-
return platform3 === "linux" &&
|
|
47522
|
+
return platform3 === "linux" && fs11.existsSync("/etc/alpine-release");
|
|
47523
47523
|
}
|
|
47524
47524
|
load.parseTags = parseTags;
|
|
47525
47525
|
load.matchTags = matchTags;
|
|
@@ -64749,13 +64749,202 @@ 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
|
|
|
64755
64944
|
// src/shared/log.ts
|
|
64756
64945
|
init_cjs_shims();
|
|
64757
64946
|
|
|
64758
|
-
// ../../internal/neverthrow/
|
|
64947
|
+
// ../../internal/neverthrow/src/index.ts
|
|
64759
64948
|
init_cjs_shims();
|
|
64760
64949
|
|
|
64761
64950
|
// ../../../node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.es.js
|
|
@@ -65238,7 +65427,7 @@ var Err = class {
|
|
|
65238
65427
|
};
|
|
65239
65428
|
var fromThrowable = Result.fromThrowable;
|
|
65240
65429
|
|
|
65241
|
-
// ../../internal/neverthrow/
|
|
65430
|
+
// ../../internal/neverthrow/src/index.ts
|
|
65242
65431
|
function resultFromPromise(type4, surface2, promise3, error48) {
|
|
65243
65432
|
return ResultAsync.fromPromise(promise3, (e) => ({
|
|
65244
65433
|
...error48(e),
|
|
@@ -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.3";
|
|
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.3".includes("-mpp");
|
|
113983
114172
|
|
|
113984
114173
|
// src/shared/operations/fetch-with-payment.ts
|
|
113985
114174
|
init_cjs_shims();
|
|
@@ -114848,9 +115037,35 @@ async function getTempoBalance({
|
|
|
114848
115037
|
};
|
|
114849
115038
|
}
|
|
114850
115039
|
|
|
115040
|
+
// src/shared/settings.ts
|
|
115041
|
+
init_cjs_shims();
|
|
115042
|
+
var import_fs4 = __toESM(require("fs"), 1);
|
|
115043
|
+
var SETTINGS_FILE = configFile("settings.json");
|
|
115044
|
+
var settingsSchema = zod_default.looseObject({
|
|
115045
|
+
maxAmount: zod_default.number().positive()
|
|
115046
|
+
}).partial();
|
|
115047
|
+
var getSettings = () => {
|
|
115048
|
+
if (!import_fs4.default.existsSync(SETTINGS_FILE)) {
|
|
115049
|
+
return {};
|
|
115050
|
+
}
|
|
115051
|
+
const content = import_fs4.default.readFileSync(SETTINGS_FILE, "utf-8");
|
|
115052
|
+
const result = settingsSchema.safeParse(JSON.parse(content));
|
|
115053
|
+
if (!result.success) {
|
|
115054
|
+
return {};
|
|
115055
|
+
}
|
|
115056
|
+
return result.data;
|
|
115057
|
+
};
|
|
115058
|
+
var setSettings = (settings) => {
|
|
115059
|
+
const existing = getSettings();
|
|
115060
|
+
const newSettings = settingsSchema.parse({ ...existing, ...settings });
|
|
115061
|
+
import_fs4.default.writeFileSync(SETTINGS_FILE, JSON.stringify(newSettings, null, 2));
|
|
115062
|
+
};
|
|
115063
|
+
|
|
114851
115064
|
// src/shared/operations/fetch-with-payment.ts
|
|
115065
|
+
var DEFAULT_MAX_AMOUNT = 5;
|
|
114852
115066
|
function createFetchWithPayment(options) {
|
|
114853
|
-
const { surface: surface2, clients, paymentMethod, beforePayment, timeout } = options;
|
|
115067
|
+
const { surface: surface2, clients, paymentMethod, beforePayment, timeout, maxAmount } = options;
|
|
115068
|
+
const effectiveMaxAmount = maxAmount ?? getSettings().maxAmount ?? DEFAULT_MAX_AMOUNT;
|
|
114854
115069
|
return async (request) => {
|
|
114855
115070
|
const clonedRequest = request.clone();
|
|
114856
115071
|
const fallbackRequest = request.clone();
|
|
@@ -114866,7 +115081,13 @@ function createFetchWithPayment(options) {
|
|
|
114866
115081
|
const response = probeResult.value;
|
|
114867
115082
|
if (paymentMethod !== "auto") {
|
|
114868
115083
|
if (paymentMethod === "mpp") {
|
|
114869
|
-
return handleMppPayment(
|
|
115084
|
+
return handleMppPayment(
|
|
115085
|
+
surface2,
|
|
115086
|
+
response,
|
|
115087
|
+
clonedRequest,
|
|
115088
|
+
options,
|
|
115089
|
+
effectiveMaxAmount
|
|
115090
|
+
);
|
|
114870
115091
|
}
|
|
114871
115092
|
return handleX402Payment(
|
|
114872
115093
|
surface2,
|
|
@@ -114874,7 +115095,8 @@ function createFetchWithPayment(options) {
|
|
|
114874
115095
|
clonedRequest,
|
|
114875
115096
|
clients.x402,
|
|
114876
115097
|
beforePayment,
|
|
114877
|
-
timeout
|
|
115098
|
+
timeout,
|
|
115099
|
+
effectiveMaxAmount
|
|
114878
115100
|
);
|
|
114879
115101
|
}
|
|
114880
115102
|
const available = detectPaymentProtocols(response);
|
|
@@ -114885,22 +115107,36 @@ function createFetchWithPayment(options) {
|
|
|
114885
115107
|
preferred = await pickByBalance(surface2, response, options);
|
|
114886
115108
|
}
|
|
114887
115109
|
const fallback = available.length > 1 ? preferred === "mpp" ? "x402" : "mpp" : null;
|
|
114888
|
-
const result = preferred === "mpp" ? await handleMppPayment(
|
|
115110
|
+
const result = preferred === "mpp" ? await handleMppPayment(
|
|
115111
|
+
surface2,
|
|
115112
|
+
response,
|
|
115113
|
+
clonedRequest,
|
|
115114
|
+
options,
|
|
115115
|
+
effectiveMaxAmount
|
|
115116
|
+
) : await handleX402Payment(
|
|
114889
115117
|
surface2,
|
|
114890
115118
|
response,
|
|
114891
115119
|
clonedRequest,
|
|
114892
115120
|
clients.x402,
|
|
114893
115121
|
beforePayment,
|
|
114894
|
-
timeout
|
|
115122
|
+
timeout,
|
|
115123
|
+
effectiveMaxAmount
|
|
114895
115124
|
);
|
|
114896
115125
|
if (result.isErr() && fallback) {
|
|
114897
|
-
return fallback === "mpp" ? handleMppPayment(
|
|
115126
|
+
return fallback === "mpp" ? handleMppPayment(
|
|
115127
|
+
surface2,
|
|
115128
|
+
response,
|
|
115129
|
+
fallbackRequest,
|
|
115130
|
+
options,
|
|
115131
|
+
effectiveMaxAmount
|
|
115132
|
+
) : handleX402Payment(
|
|
114898
115133
|
surface2,
|
|
114899
115134
|
response,
|
|
114900
115135
|
fallbackRequest,
|
|
114901
115136
|
clients.x402,
|
|
114902
115137
|
beforePayment,
|
|
114903
|
-
timeout
|
|
115138
|
+
timeout,
|
|
115139
|
+
effectiveMaxAmount
|
|
114904
115140
|
);
|
|
114905
115141
|
}
|
|
114906
115142
|
return result;
|
|
@@ -114952,7 +115188,7 @@ async function pickByBalance(surface2, response, options) {
|
|
|
114952
115188
|
log.info(`Protocol selection \u2014 x402: $${x402Balance}, mpp: $${mppBalance}`);
|
|
114953
115189
|
return x402Balance >= mppBalance ? "x402" : "mpp";
|
|
114954
115190
|
}
|
|
114955
|
-
async function handleX402Payment(surface2, response, clonedRequest, client, beforePayment, timeout) {
|
|
115191
|
+
async function handleX402Payment(surface2, response, clonedRequest, client, beforePayment, timeout, maxAmount) {
|
|
114956
115192
|
const paymentRequiredResult = await safeGetPaymentRequired(
|
|
114957
115193
|
surface2,
|
|
114958
115194
|
client,
|
|
@@ -114962,8 +115198,17 @@ async function handleX402Payment(surface2, response, clonedRequest, client, befo
|
|
|
114962
115198
|
return paymentRequiredResult;
|
|
114963
115199
|
}
|
|
114964
115200
|
const paymentRequired = paymentRequiredResult.value;
|
|
115201
|
+
const accept = paymentRequired.accepts[0];
|
|
115202
|
+
if (accept) {
|
|
115203
|
+
const amount2 = tokenStringToNumber(accept.amount);
|
|
115204
|
+
if (amount2 > maxAmount) {
|
|
115205
|
+
return x402Err(surface2, {
|
|
115206
|
+
cause: "payment_already_attempted",
|
|
115207
|
+
message: `Endpoint requested $${amount2} which exceeds the maximum allowed amount of $${maxAmount}. Pass a higher maxAmount on this call, or use update_settings to raise the default permanently.`
|
|
115208
|
+
});
|
|
115209
|
+
}
|
|
115210
|
+
}
|
|
114965
115211
|
if (beforePayment) {
|
|
114966
|
-
const accept = paymentRequired.accepts[0];
|
|
114967
115212
|
if (accept) {
|
|
114968
115213
|
const amount2 = tokenStringToNumber(accept.amount);
|
|
114969
115214
|
const hookResult = await resultFromPromise(
|
|
@@ -115036,7 +115281,7 @@ async function handleX402Payment(surface2, response, clonedRequest, client, befo
|
|
|
115036
115281
|
}
|
|
115037
115282
|
);
|
|
115038
115283
|
}
|
|
115039
|
-
async function handleMppPayment(surface2, response, clonedRequest, options) {
|
|
115284
|
+
async function handleMppPayment(surface2, response, clonedRequest, options, maxAmount) {
|
|
115040
115285
|
const { clients, beforePayment, timeout } = options;
|
|
115041
115286
|
const mppxClient = clients.mpp;
|
|
115042
115287
|
if (clonedRequest.headers.has("Authorization")) {
|
|
@@ -115053,6 +115298,15 @@ async function handleMppPayment(surface2, response, clonedRequest, options) {
|
|
|
115053
115298
|
const amount2 = challenge2.request.amount;
|
|
115054
115299
|
const decimals2 = challenge2.request.decimals ?? 6;
|
|
115055
115300
|
const currency2 = challenge2.request.currency;
|
|
115301
|
+
if (amount2) {
|
|
115302
|
+
const numericAmount = Number(formatUnits(BigInt(amount2), decimals2));
|
|
115303
|
+
if (numericAmount > maxAmount) {
|
|
115304
|
+
return mppErr(surface2, {
|
|
115305
|
+
cause: "mpp_payment_already_attempted",
|
|
115306
|
+
message: `Endpoint requested $${numericAmount} which exceeds the maximum allowed amount of $${maxAmount}. Pass a higher maxAmount on this call, or use update_settings to raise the default permanently.`
|
|
115307
|
+
});
|
|
115308
|
+
}
|
|
115309
|
+
}
|
|
115056
115310
|
if (beforePayment && amount2 && currency2) {
|
|
115057
115311
|
const numericAmount = Number(formatUnits(BigInt(amount2), decimals2));
|
|
115058
115312
|
const hookResult = await resultFromPromise(
|
|
@@ -115393,6 +115647,12 @@ ${PRIMARY_ORIGINS.flatMap((o) => ORIGIN_METADATA[o] ? [` ${o} \u2014 ${ORIGIN_M
|
|
|
115393
115647
|
reportError: {
|
|
115394
115648
|
mcp: `EMERGENCY ONLY. Report critical MCP tool bugs. Do NOT use for normal errors (balance, network, 4xx) \u2014 those are recoverable.`,
|
|
115395
115649
|
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 \u2014 those are recoverable without filing a report.`
|
|
115650
|
+
},
|
|
115651
|
+
updateSettings: {
|
|
115652
|
+
mcp: `Update user settings (persisted to ~/.agentcash/settings.json). Currently supports maxAmount \u2014 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.`
|
|
115653
|
+
},
|
|
115654
|
+
getSettings: {
|
|
115655
|
+
mcp: `Get current user settings. Returns persisted values from ~/.agentcash/settings.json with defaults applied.`
|
|
115396
115656
|
}
|
|
115397
115657
|
};
|
|
115398
115658
|
var WORKFLOW = [
|
|
@@ -115429,7 +115689,8 @@ var REQUEST_PARAMS = {
|
|
|
115429
115689
|
};
|
|
115430
115690
|
var TOOL_PARAMS = {
|
|
115431
115691
|
fetch: {
|
|
115432
|
-
paymentMethod: "Payment protocol to use. Defaults to auto-detect."
|
|
115692
|
+
paymentMethod: "Payment protocol to use. Defaults to auto-detect.",
|
|
115693
|
+
maxAmount: "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."
|
|
115433
115694
|
},
|
|
115434
115695
|
checkEndpointSchema: {
|
|
115435
115696
|
url: "Full URL of the endpoint to inspect",
|
|
@@ -115594,7 +115855,8 @@ Insufficient Tempo balance for this payment.`
|
|
|
115594
115855
|
var toolName = "fetch";
|
|
115595
115856
|
var paymentMethodEnum = isMppEnabled() ? external_exports3.enum(["x402", "mpp", "auto"]) : external_exports3.enum(["x402", "auto"]);
|
|
115596
115857
|
var fetchInputSchema = requestSchema.extend({
|
|
115597
|
-
paymentMethod: paymentMethodEnum.default("auto").optional().describe(TOOL_PARAMS.fetch.paymentMethod)
|
|
115858
|
+
paymentMethod: paymentMethodEnum.default("auto").optional().describe(TOOL_PARAMS.fetch.paymentMethod),
|
|
115859
|
+
maxAmount: external_exports3.number().positive().optional().describe(TOOL_PARAMS.fetch.maxAmount)
|
|
115598
115860
|
});
|
|
115599
115861
|
var registerFetchTool = ({
|
|
115600
115862
|
server,
|
|
@@ -115682,7 +115944,8 @@ var registerFetchTool = ({
|
|
|
115682
115944
|
account,
|
|
115683
115945
|
flags,
|
|
115684
115946
|
beforePayment,
|
|
115685
|
-
timeout: input.timeout ?? DEFAULT_USER_FETCH_TIMEOUT
|
|
115947
|
+
timeout: input.timeout ?? DEFAULT_USER_FETCH_TIMEOUT,
|
|
115948
|
+
maxAmount: input.maxAmount
|
|
115686
115949
|
})(request);
|
|
115687
115950
|
if (fetchResult.isErr()) {
|
|
115688
115951
|
return mcpError(fetchResult);
|
|
@@ -115845,18 +116108,18 @@ init_cjs_shims();
|
|
|
115845
116108
|
|
|
115846
116109
|
// src/shared/state.ts
|
|
115847
116110
|
init_cjs_shims();
|
|
115848
|
-
var
|
|
116111
|
+
var import_fs6 = __toESM(require("fs"), 1);
|
|
115849
116112
|
var STATE_FILE = configFile("state.json");
|
|
115850
116113
|
var stateSchema = zod_default.looseObject({
|
|
115851
116114
|
redeemedCodes: zod_default.array(zod_default.string())
|
|
115852
116115
|
}).partial();
|
|
115853
116116
|
var getState = () => {
|
|
115854
|
-
const stateFileExists =
|
|
116117
|
+
const stateFileExists = import_fs6.default.existsSync(STATE_FILE);
|
|
115855
116118
|
if (!stateFileExists) {
|
|
115856
|
-
|
|
116119
|
+
import_fs6.default.writeFileSync(STATE_FILE, "{}");
|
|
115857
116120
|
return {};
|
|
115858
116121
|
}
|
|
115859
|
-
const stateFileContent =
|
|
116122
|
+
const stateFileContent = import_fs6.default.readFileSync(STATE_FILE, "utf-8");
|
|
115860
116123
|
const result = stateSchema.safeParse(JSON.parse(stateFileContent));
|
|
115861
116124
|
if (!result.success) {
|
|
115862
116125
|
return {};
|
|
@@ -115866,7 +116129,7 @@ var getState = () => {
|
|
|
115866
116129
|
var setState = (state) => {
|
|
115867
116130
|
const existing = getState();
|
|
115868
116131
|
const newState = stateSchema.parse({ ...existing, ...state });
|
|
115869
|
-
|
|
116132
|
+
import_fs6.default.writeFileSync(STATE_FILE, JSON.stringify(newState, null, 2));
|
|
115870
116133
|
};
|
|
115871
116134
|
|
|
115872
116135
|
// src/shared/operations/onboarding-cta.ts
|
|
@@ -115983,8 +116246,9 @@ init_cjs_shims();
|
|
|
115983
116246
|
// src/shared/operations/check-endpoint.ts
|
|
115984
116247
|
init_cjs_shims();
|
|
115985
116248
|
|
|
115986
|
-
// ../../../node_modules/.pnpm/@agentcash+discovery@1.0
|
|
116249
|
+
// ../../../node_modules/.pnpm/@agentcash+discovery@1.1.0/node_modules/@agentcash/discovery/dist/index.js
|
|
115987
116250
|
init_cjs_shims();
|
|
116251
|
+
var import_dereference_json_schema = __toESM(require_dereference_json_schema(), 1);
|
|
115988
116252
|
|
|
115989
116253
|
// ../../../node_modules/.pnpm/@x402+core@2.6.0/node_modules/@x402/core/dist/esm/schemas/index.mjs
|
|
115990
116254
|
init_cjs_shims();
|
|
@@ -116062,7 +116326,7 @@ var PaymentPayloadSchema = external_exports4.discriminatedUnion("x402Version", [
|
|
|
116062
116326
|
PaymentPayloadV2Schema
|
|
116063
116327
|
]);
|
|
116064
116328
|
|
|
116065
|
-
// ../../../node_modules/.pnpm/@agentcash+discovery@1.0
|
|
116329
|
+
// ../../../node_modules/.pnpm/@agentcash+discovery@1.1.0/node_modules/@agentcash/discovery/dist/index.js
|
|
116066
116330
|
var OpenApiPaymentInfoSchema = external_exports3.object({
|
|
116067
116331
|
pricingMode: external_exports3.enum(["fixed", "range", "quote"]),
|
|
116068
116332
|
price: external_exports3.string().optional(),
|
|
@@ -116110,6 +116374,7 @@ var OpenApiDocSchema = external_exports3.object({
|
|
|
116110
116374
|
description: external_exports3.string().optional(),
|
|
116111
116375
|
guidance: external_exports3.string().optional()
|
|
116112
116376
|
}),
|
|
116377
|
+
security: external_exports3.array(external_exports3.record(external_exports3.string(), external_exports3.array(external_exports3.string()))).optional(),
|
|
116113
116378
|
servers: external_exports3.array(external_exports3.object({ url: external_exports3.string() })).optional(),
|
|
116114
116379
|
tags: external_exports3.array(external_exports3.object({ name: external_exports3.string() })).optional(),
|
|
116115
116380
|
components: external_exports3.object({ securitySchemes: external_exports3.record(external_exports3.string(), external_exports3.unknown()).optional() }).optional(),
|
|
@@ -116137,20 +116402,31 @@ var WellKnownParsedSchema = external_exports3.object({
|
|
|
116137
116402
|
function isRecord(value) {
|
|
116138
116403
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
116139
116404
|
}
|
|
116140
|
-
function
|
|
116141
|
-
|
|
116142
|
-
|
|
116143
|
-
|
|
116144
|
-
|
|
116405
|
+
function resolveSecurityFlags(requirements, securitySchemes) {
|
|
116406
|
+
let hasApiKey = false;
|
|
116407
|
+
let hasSiwx = false;
|
|
116408
|
+
for (const requirement of requirements) {
|
|
116409
|
+
for (const schemeName of Object.keys(requirement)) {
|
|
116410
|
+
if (schemeName === "siwx") {
|
|
116411
|
+
hasSiwx = true;
|
|
116412
|
+
continue;
|
|
116413
|
+
}
|
|
116414
|
+
if (schemeName === "apiKey") {
|
|
116415
|
+
hasApiKey = true;
|
|
116416
|
+
continue;
|
|
116417
|
+
}
|
|
116418
|
+
const def = securitySchemes[schemeName];
|
|
116419
|
+
if (isRecord(def) && def["type"] === "apiKey") hasApiKey = true;
|
|
116420
|
+
}
|
|
116421
|
+
}
|
|
116422
|
+
return { hasApiKey, hasSiwx };
|
|
116145
116423
|
}
|
|
116146
|
-
function inferAuthMode(operation) {
|
|
116424
|
+
function inferAuthMode(operation, globalSecurity, securitySchemes) {
|
|
116147
116425
|
const hasXPaymentInfo = Boolean(operation["x-payment-info"]);
|
|
116148
|
-
const
|
|
116149
|
-
const hasApiKey =
|
|
116150
|
-
|
|
116151
|
-
if (hasPayment && hasApiKey) return "apiKey+paid";
|
|
116426
|
+
const effectiveSecurity = operation.security !== void 0 && operation.security.length > 0 ? operation.security : globalSecurity ?? [];
|
|
116427
|
+
const { hasApiKey, hasSiwx } = resolveSecurityFlags(effectiveSecurity, securitySchemes ?? {});
|
|
116428
|
+
if (hasXPaymentInfo && hasApiKey) return "apiKey+paid";
|
|
116152
116429
|
if (hasXPaymentInfo) return "paid";
|
|
116153
|
-
if (hasPayment) return hasSiwx ? "siwx" : "paid";
|
|
116154
116430
|
if (hasApiKey) return "apiKey";
|
|
116155
116431
|
if (hasSiwx) return "siwx";
|
|
116156
116432
|
return void 0;
|
|
@@ -116166,10 +116442,12 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
116166
116442
|
"TRACE"
|
|
116167
116443
|
]);
|
|
116168
116444
|
var DEFAULT_MISSING_METHOD = "POST";
|
|
116169
|
-
function
|
|
116445
|
+
function ensureProtocol(target) {
|
|
116170
116446
|
const trimmed = target.trim();
|
|
116171
|
-
|
|
116172
|
-
|
|
116447
|
+
return /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
116448
|
+
}
|
|
116449
|
+
function normalizeOrigin(target) {
|
|
116450
|
+
const url3 = new URL(ensureProtocol(target));
|
|
116173
116451
|
url3.pathname = "";
|
|
116174
116452
|
url3.search = "";
|
|
116175
116453
|
url3.hash = "";
|
|
@@ -116203,22 +116481,20 @@ function toFetchError(err3) {
|
|
|
116203
116481
|
function fetchSafe(url3, init) {
|
|
116204
116482
|
return ResultAsync.fromPromise(fetch(url3, init), toFetchError);
|
|
116205
116483
|
}
|
|
116206
|
-
var isMmmEnabled = () => "1.0
|
|
116484
|
+
var isMmmEnabled = () => "1.1.0".includes("-mmm");
|
|
116207
116485
|
var OpenApiParsedSchema = OpenApiDocSchema.transform((doc) => {
|
|
116208
116486
|
const routes = [];
|
|
116209
116487
|
for (const [rawPath, pathItem] of Object.entries(doc.paths)) {
|
|
116210
116488
|
for (const httpMethod of [...HTTP_METHODS]) {
|
|
116211
116489
|
const operation = pathItem[httpMethod.toLowerCase()];
|
|
116212
116490
|
if (!operation) continue;
|
|
116213
|
-
const authMode = inferAuthMode(operation) ?? void 0;
|
|
116491
|
+
const authMode = inferAuthMode(operation, doc.security, doc.components?.securitySchemes) ?? void 0;
|
|
116214
116492
|
if (!authMode) continue;
|
|
116215
116493
|
const p = operation["x-payment-info"];
|
|
116216
116494
|
const protocols = (p?.protocols ?? []).filter(
|
|
116217
116495
|
(proto) => proto !== "mpp" || isMmmEnabled()
|
|
116218
116496
|
);
|
|
116219
|
-
|
|
116220
|
-
if (authMode === "paid" && protocols.length === 0) continue;
|
|
116221
|
-
const pricing = authMode === "paid" && p ? {
|
|
116497
|
+
const pricing = (authMode === "paid" || authMode === "apiKey+paid") && p ? {
|
|
116222
116498
|
pricingMode: p.pricingMode,
|
|
116223
116499
|
...p.price ? { price: p.price } : {},
|
|
116224
116500
|
...p.minPrice ? { minPrice: p.minPrice } : {},
|
|
@@ -116681,53 +116957,29 @@ function extractPaymentOptions4(wwwAuthenticate) {
|
|
|
116681
116957
|
}
|
|
116682
116958
|
return options;
|
|
116683
116959
|
}
|
|
116684
|
-
|
|
116685
|
-
|
|
116686
|
-
|
|
116687
|
-
for (const [specPath, entry] of Object.entries(paths)) {
|
|
116688
|
-
if (!isRecord(entry)) continue;
|
|
116689
|
-
const pattern = specPath.replace(/\{[^}]+\}/g, "[^/]+");
|
|
116690
|
-
const regex = new RegExp(`^${pattern}$`);
|
|
116691
|
-
if (regex.test(targetPath)) {
|
|
116692
|
-
return { matchedPath: specPath, pathItem: entry };
|
|
116693
|
-
}
|
|
116694
|
-
}
|
|
116695
|
-
return null;
|
|
116696
|
-
}
|
|
116697
|
-
function resolveRef2(document2, ref, seen) {
|
|
116698
|
-
if (!ref.startsWith("#/")) return void 0;
|
|
116699
|
-
if (seen.has(ref)) return { $circular: ref };
|
|
116700
|
-
seen.add(ref);
|
|
116701
|
-
const parts = ref.slice(2).split("/");
|
|
116702
|
-
let current = document2;
|
|
116703
|
-
for (const part of parts) {
|
|
116704
|
-
if (!isRecord(current)) return void 0;
|
|
116705
|
-
current = current[part];
|
|
116706
|
-
if (current === void 0) return void 0;
|
|
116707
|
-
}
|
|
116708
|
-
if (isRecord(current)) return resolveRefs(document2, current, seen);
|
|
116709
|
-
return current;
|
|
116960
|
+
var { resolveRefSync } = import_dereference_json_schema.default;
|
|
116961
|
+
function isRecord2(value) {
|
|
116962
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
116710
116963
|
}
|
|
116711
|
-
function
|
|
116712
|
-
if (depth > 4) return obj;
|
|
116964
|
+
function deepResolveRefs(document2, obj) {
|
|
116713
116965
|
const resolved = {};
|
|
116714
116966
|
for (const [key, value] of Object.entries(obj)) {
|
|
116715
116967
|
if (key === "$ref" && typeof value === "string") {
|
|
116716
|
-
const deref =
|
|
116717
|
-
if (
|
|
116718
|
-
Object.assign(resolved, deref);
|
|
116968
|
+
const deref = resolveRefSync(document2, value);
|
|
116969
|
+
if (isRecord2(deref)) {
|
|
116970
|
+
Object.assign(resolved, deepResolveRefs(document2, deref));
|
|
116719
116971
|
} else {
|
|
116720
116972
|
resolved[key] = value;
|
|
116721
116973
|
}
|
|
116722
116974
|
continue;
|
|
116723
116975
|
}
|
|
116724
|
-
if (
|
|
116725
|
-
resolved[key] =
|
|
116976
|
+
if (isRecord2(value)) {
|
|
116977
|
+
resolved[key] = deepResolveRefs(document2, value);
|
|
116726
116978
|
continue;
|
|
116727
116979
|
}
|
|
116728
116980
|
if (Array.isArray(value)) {
|
|
116729
116981
|
resolved[key] = value.map(
|
|
116730
|
-
(item) =>
|
|
116982
|
+
(item) => isRecord2(item) ? deepResolveRefs(document2, item) : item
|
|
116731
116983
|
);
|
|
116732
116984
|
continue;
|
|
116733
116985
|
}
|
|
@@ -116735,6 +116987,22 @@ function resolveRefs(document2, obj, seen, depth = 0) {
|
|
|
116735
116987
|
}
|
|
116736
116988
|
return resolved;
|
|
116737
116989
|
}
|
|
116990
|
+
function resolveRefs(obj, document2) {
|
|
116991
|
+
return deepResolveRefs(document2, obj);
|
|
116992
|
+
}
|
|
116993
|
+
function findMatchingOpenApiPath(paths, targetPath) {
|
|
116994
|
+
const exact = paths[targetPath];
|
|
116995
|
+
if (isRecord(exact)) return { matchedPath: targetPath, pathItem: exact };
|
|
116996
|
+
for (const [specPath, entry] of Object.entries(paths)) {
|
|
116997
|
+
if (!isRecord(entry)) continue;
|
|
116998
|
+
const pattern = specPath.replace(/\{[^}]+\}/g, "[^/]+");
|
|
116999
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
117000
|
+
if (regex.test(targetPath)) {
|
|
117001
|
+
return { matchedPath: specPath, pathItem: entry };
|
|
117002
|
+
}
|
|
117003
|
+
}
|
|
117004
|
+
return null;
|
|
117005
|
+
}
|
|
116738
117006
|
function extractRequestBodySchema(operationSchema) {
|
|
116739
117007
|
const requestBody = operationSchema.requestBody;
|
|
116740
117008
|
if (!isRecord(requestBody)) return void 0;
|
|
@@ -116814,7 +117082,7 @@ function getL3ForOpenAPI(openApi, path2, method) {
|
|
|
116814
117082
|
if (!matched) return null;
|
|
116815
117083
|
const operation = matched.pathItem[method.toLowerCase()];
|
|
116816
117084
|
if (!isRecord(operation)) return null;
|
|
116817
|
-
const resolvedOperation = resolveRefs(
|
|
117085
|
+
const resolvedOperation = resolveRefs(operation, document2);
|
|
116818
117086
|
const summary = typeof resolvedOperation.summary === "string" ? resolvedOperation.summary : typeof resolvedOperation.description === "string" ? resolvedOperation.description : void 0;
|
|
116819
117087
|
return {
|
|
116820
117088
|
source: "openapi",
|
|
@@ -116858,12 +117126,12 @@ function getAdvisoriesForProbe(probe, path2) {
|
|
|
116858
117126
|
});
|
|
116859
117127
|
}
|
|
116860
117128
|
async function checkEndpointSchema(options) {
|
|
116861
|
-
const endpoint = new URL(options.url);
|
|
117129
|
+
const endpoint = new URL(ensureProtocol(options.url));
|
|
116862
117130
|
const origin = normalizeOrigin(endpoint.origin);
|
|
116863
117131
|
const path2 = normalizePath(endpoint.pathname || "/");
|
|
116864
117132
|
if (options.sampleInputBody !== void 0) {
|
|
116865
117133
|
const probeResult2 = await getProbe(
|
|
116866
|
-
|
|
117134
|
+
endpoint.href,
|
|
116867
117135
|
options.headers,
|
|
116868
117136
|
options.signal,
|
|
116869
117137
|
options.sampleInputBody
|
|
@@ -116888,7 +117156,7 @@ async function checkEndpointSchema(options) {
|
|
|
116888
117156
|
if (advisories2.length > 0) return { found: true, origin, path: path2, advisories: advisories2 };
|
|
116889
117157
|
return { found: false, origin, path: path2, cause: "not_found" };
|
|
116890
117158
|
}
|
|
116891
|
-
const probeResult = await getProbe(
|
|
117159
|
+
const probeResult = await getProbe(endpoint.href, options.headers, options.signal);
|
|
116892
117160
|
if (probeResult.isErr()) {
|
|
116893
117161
|
return {
|
|
116894
117162
|
found: false,
|
|
@@ -117313,6 +117581,61 @@ function registerDiscoveryTools(server) {
|
|
|
117313
117581
|
);
|
|
117314
117582
|
}
|
|
117315
117583
|
|
|
117584
|
+
// src/server/tools/settings.ts
|
|
117585
|
+
init_cjs_shims();
|
|
117586
|
+
var registerSettingsTools = ({ server }) => {
|
|
117587
|
+
server.registerTool(
|
|
117588
|
+
"update_settings",
|
|
117589
|
+
{
|
|
117590
|
+
title: "Update Settings",
|
|
117591
|
+
description: DESCRIPTIONS.updateSettings.mcp,
|
|
117592
|
+
inputSchema: external_exports3.object({
|
|
117593
|
+
maxAmount: external_exports3.number().positive().optional().describe(
|
|
117594
|
+
`Maximum amount (USD) to pay per fetch request. Current default: $${DEFAULT_MAX_AMOUNT}.`
|
|
117595
|
+
)
|
|
117596
|
+
}),
|
|
117597
|
+
annotations: {
|
|
117598
|
+
readOnlyHint: false,
|
|
117599
|
+
destructiveHint: false,
|
|
117600
|
+
idempotentHint: true,
|
|
117601
|
+
openWorldHint: false
|
|
117602
|
+
}
|
|
117603
|
+
},
|
|
117604
|
+
safeHandler((input) => {
|
|
117605
|
+
if (input.maxAmount !== void 0) {
|
|
117606
|
+
setSettings({ maxAmount: input.maxAmount });
|
|
117607
|
+
}
|
|
117608
|
+
const settings = getSettings();
|
|
117609
|
+
return Promise.resolve(
|
|
117610
|
+
mcpSuccessStructuredJson({
|
|
117611
|
+
maxAmount: settings.maxAmount ?? DEFAULT_MAX_AMOUNT
|
|
117612
|
+
})
|
|
117613
|
+
);
|
|
117614
|
+
})
|
|
117615
|
+
);
|
|
117616
|
+
server.registerTool(
|
|
117617
|
+
"get_settings",
|
|
117618
|
+
{
|
|
117619
|
+
title: "Get Settings",
|
|
117620
|
+
description: DESCRIPTIONS.getSettings.mcp,
|
|
117621
|
+
annotations: {
|
|
117622
|
+
readOnlyHint: true,
|
|
117623
|
+
destructiveHint: false,
|
|
117624
|
+
idempotentHint: true,
|
|
117625
|
+
openWorldHint: false
|
|
117626
|
+
}
|
|
117627
|
+
},
|
|
117628
|
+
safeHandler(() => {
|
|
117629
|
+
const settings = getSettings();
|
|
117630
|
+
return Promise.resolve(
|
|
117631
|
+
mcpSuccessStructuredJson({
|
|
117632
|
+
maxAmount: settings.maxAmount ?? DEFAULT_MAX_AMOUNT
|
|
117633
|
+
})
|
|
117634
|
+
);
|
|
117635
|
+
})
|
|
117636
|
+
);
|
|
117637
|
+
};
|
|
117638
|
+
|
|
117316
117639
|
// src/server/resources/origins.ts
|
|
117317
117640
|
init_cjs_shims();
|
|
117318
117641
|
var surface = "registerOrigins";
|
|
@@ -117752,25 +118075,25 @@ var registerPrompts = (props) => {
|
|
|
117752
118075
|
|
|
117753
118076
|
// src/server/lib/version.ts
|
|
117754
118077
|
init_cjs_shims();
|
|
117755
|
-
var
|
|
118078
|
+
var import_fs8 = require("fs");
|
|
117756
118079
|
var import_path3 = require("path");
|
|
117757
118080
|
var import_url2 = require("url");
|
|
117758
118081
|
function getVersion3() {
|
|
117759
118082
|
if (true) {
|
|
117760
|
-
return "0.8.
|
|
118083
|
+
return "0.8.3";
|
|
117761
118084
|
}
|
|
117762
118085
|
const __dirname3 = (0, import_path3.dirname)((0, import_url2.fileURLToPath)(importMetaUrl));
|
|
117763
|
-
const
|
|
117764
|
-
(0,
|
|
118086
|
+
const pkg2 = JSON.parse(
|
|
118087
|
+
(0, import_fs8.readFileSync)((0, import_path3.join)(__dirname3, "../../../package.json"), "utf-8")
|
|
117765
118088
|
);
|
|
117766
|
-
return
|
|
118089
|
+
return pkg2.version;
|
|
117767
118090
|
}
|
|
117768
118091
|
var MCP_VERSION2 = getVersion3();
|
|
117769
118092
|
var DIST_TAG2 = MCP_VERSION2.includes("-beta") ? "beta" : "latest";
|
|
117770
118093
|
|
|
117771
118094
|
// src/shared/wallet.ts
|
|
117772
118095
|
init_cjs_shims();
|
|
117773
|
-
var
|
|
118096
|
+
var import_fs9 = require("fs");
|
|
117774
118097
|
var import_path4 = require("path");
|
|
117775
118098
|
var WALLET_FILE = configFile("wallet.json");
|
|
117776
118099
|
var storedWalletSchema = zod_default.object({
|
|
@@ -117783,14 +118106,14 @@ var LEGACY_WALLET = (0, import_path4.join)(LEGACY_DIRECTORY, "wallet.json");
|
|
|
117783
118106
|
var reconcileSurface = "wallet-reconcile";
|
|
117784
118107
|
async function reconcileLegacyWallet(current, isNew) {
|
|
117785
118108
|
const noChange = { account: current, isNew };
|
|
117786
|
-
if (!(0,
|
|
118109
|
+
if (!(0, import_fs9.existsSync)(LEGACY_WALLET)) {
|
|
117787
118110
|
return noChange;
|
|
117788
118111
|
}
|
|
117789
118112
|
const legacyResult = resultFromThrowable(
|
|
117790
118113
|
"wallet",
|
|
117791
118114
|
reconcileSurface,
|
|
117792
118115
|
() => {
|
|
117793
|
-
const raw = (0,
|
|
118116
|
+
const raw = (0, import_fs9.readFileSync)(LEGACY_WALLET, "utf-8");
|
|
117794
118117
|
return storedWalletSchema.parse(JSON.parse(raw));
|
|
117795
118118
|
},
|
|
117796
118119
|
() => ({
|
|
@@ -117874,7 +118197,7 @@ async function getWallet() {
|
|
|
117874
118197
|
}
|
|
117875
118198
|
const readFileResult = await safeReadFile(walletSurface, WALLET_FILE);
|
|
117876
118199
|
if (!readFileResult.isOk()) {
|
|
117877
|
-
const fileExistsResult = (0,
|
|
118200
|
+
const fileExistsResult = (0, import_fs9.existsSync)(WALLET_FILE);
|
|
117878
118201
|
if (fileExistsResult) {
|
|
117879
118202
|
return fsErr(walletSurface, {
|
|
117880
118203
|
cause: "file_not_readable",
|
|
@@ -117927,7 +118250,7 @@ async function getWallet() {
|
|
|
117927
118250
|
|
|
117928
118251
|
// src/shared/user-origins.ts
|
|
117929
118252
|
init_cjs_shims();
|
|
117930
|
-
var
|
|
118253
|
+
var fs10 = __toESM(require("fs"), 1);
|
|
117931
118254
|
var ORIGINS_FILE = configFile("origins.json");
|
|
117932
118255
|
var userOriginSchema = zod_default.object({
|
|
117933
118256
|
url: zod_default.string(),
|
|
@@ -117939,8 +118262,8 @@ var originsFileSchema = zod_default.object({
|
|
|
117939
118262
|
added: zod_default.array(userOriginSchema)
|
|
117940
118263
|
});
|
|
117941
118264
|
function readOriginsFile() {
|
|
117942
|
-
if (!
|
|
117943
|
-
const raw =
|
|
118265
|
+
if (!fs10.existsSync(ORIGINS_FILE)) return [];
|
|
118266
|
+
const raw = fs10.readFileSync(ORIGINS_FILE, "utf-8");
|
|
117944
118267
|
const json3 = safeParseJson("user-origins", raw);
|
|
117945
118268
|
if (!json3.isOk()) return [];
|
|
117946
118269
|
const parsed = originsFileSchema.safeParse(json3.value);
|
|
@@ -118007,6 +118330,7 @@ var startServer = async (flags) => {
|
|
|
118007
118330
|
registerRedeemInviteTool(props);
|
|
118008
118331
|
registerDiscoveryTools(server);
|
|
118009
118332
|
registerTelemetryTools(props);
|
|
118333
|
+
registerSettingsTools(props);
|
|
118010
118334
|
registerPrompts(props);
|
|
118011
118335
|
await registerOrigins({ server, flags });
|
|
118012
118336
|
const transport = new StdioServerTransport();
|