moltspay 0.9.3 → 0.9.5
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/.env.example +7 -0
- package/dist/cli/index.js +55 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +55 -3
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.js +55 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -3
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +4 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +55 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +55 -3
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -30923,6 +30923,9 @@ var MoltsPayServer = class {
|
|
|
30923
30923
|
if (url.pathname === "/services" && req.method === "GET") {
|
|
30924
30924
|
return this.handleGetServices(res);
|
|
30925
30925
|
}
|
|
30926
|
+
if (url.pathname === "/.well-known/agent-services.json" && req.method === "GET") {
|
|
30927
|
+
return this.handleAgentServicesDiscovery(res);
|
|
30928
|
+
}
|
|
30926
30929
|
if (url.pathname === "/health" && req.method === "GET") {
|
|
30927
30930
|
return await this.handleHealthCheck(res);
|
|
30928
30931
|
}
|
|
@@ -30946,6 +30949,43 @@ var MoltsPayServer = class {
|
|
|
30946
30949
|
this.sendJson(res, 500, { error: err.message || "Internal error" });
|
|
30947
30950
|
}
|
|
30948
30951
|
}
|
|
30952
|
+
/**
|
|
30953
|
+
* GET /.well-known/agent-services.json - Standard discovery endpoint
|
|
30954
|
+
*/
|
|
30955
|
+
handleAgentServicesDiscovery(res) {
|
|
30956
|
+
const services = this.manifest.services.map((s) => ({
|
|
30957
|
+
id: s.id,
|
|
30958
|
+
name: s.name,
|
|
30959
|
+
description: s.description,
|
|
30960
|
+
price: s.price,
|
|
30961
|
+
currency: s.currency,
|
|
30962
|
+
input: s.input,
|
|
30963
|
+
output: s.output,
|
|
30964
|
+
available: this.skills.has(s.id)
|
|
30965
|
+
}));
|
|
30966
|
+
this.sendJson(res, 200, {
|
|
30967
|
+
version: "1.0",
|
|
30968
|
+
provider: {
|
|
30969
|
+
name: this.manifest.provider.name,
|
|
30970
|
+
description: this.manifest.provider.description,
|
|
30971
|
+
wallet: this.manifest.provider.wallet,
|
|
30972
|
+
chain: this.manifest.provider.chain || "base"
|
|
30973
|
+
},
|
|
30974
|
+
services,
|
|
30975
|
+
endpoints: {
|
|
30976
|
+
services: "/services",
|
|
30977
|
+
execute: "/execute",
|
|
30978
|
+
health: "/health"
|
|
30979
|
+
},
|
|
30980
|
+
payment: {
|
|
30981
|
+
protocol: "x402",
|
|
30982
|
+
version: X402_VERSION2,
|
|
30983
|
+
network: this.networkId,
|
|
30984
|
+
schemes: ["exact"],
|
|
30985
|
+
mainnet: this.useMainnet
|
|
30986
|
+
}
|
|
30987
|
+
});
|
|
30988
|
+
}
|
|
30949
30989
|
/**
|
|
30950
30990
|
* GET /services - List available services
|
|
30951
30991
|
*/
|
|
@@ -31032,10 +31072,16 @@ var MoltsPayServer = class {
|
|
|
31032
31072
|
});
|
|
31033
31073
|
}
|
|
31034
31074
|
console.log(`[MoltsPay] Verified by ${verifyResult.facilitator}`);
|
|
31035
|
-
|
|
31075
|
+
const timeoutSeconds = parseInt(process.env.SKILL_TIMEOUT_SECONDS || "1200");
|
|
31076
|
+
console.log(`[MoltsPay] Executing skill: ${service} (timeout: ${timeoutSeconds}s)`);
|
|
31036
31077
|
let result;
|
|
31037
31078
|
try {
|
|
31038
|
-
result = await
|
|
31079
|
+
result = await Promise.race([
|
|
31080
|
+
skill.handler(params || {}),
|
|
31081
|
+
new Promise(
|
|
31082
|
+
(_, reject) => setTimeout(() => reject(new Error(`Skill timeout after ${timeoutSeconds}s`)), timeoutSeconds * 1e3)
|
|
31083
|
+
)
|
|
31084
|
+
]);
|
|
31039
31085
|
} catch (err) {
|
|
31040
31086
|
console.error("[MoltsPay] Skill execution failed:", err.message);
|
|
31041
31087
|
return this.sendJson(res, 500, {
|
|
@@ -31244,9 +31290,15 @@ var MoltsPayServer = class {
|
|
|
31244
31290
|
error: `Service not found: ${service}`
|
|
31245
31291
|
});
|
|
31246
31292
|
}
|
|
31293
|
+
const timeoutSeconds = parseInt(process.env.SKILL_TIMEOUT_SECONDS || "1200");
|
|
31247
31294
|
let result;
|
|
31248
31295
|
try {
|
|
31249
|
-
result = await
|
|
31296
|
+
result = await Promise.race([
|
|
31297
|
+
skill.handler(params || {}),
|
|
31298
|
+
new Promise(
|
|
31299
|
+
(_, reject) => setTimeout(() => reject(new Error(`Skill timeout after ${timeoutSeconds}s`)), timeoutSeconds * 1e3)
|
|
31300
|
+
)
|
|
31301
|
+
]);
|
|
31250
31302
|
console.log(`[MoltsPay] /proxy: Skill succeeded, now settling payment...`);
|
|
31251
31303
|
} catch (err) {
|
|
31252
31304
|
console.error(`[MoltsPay] /proxy: Skill failed: ${err.message} - NOT settling`);
|