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.js
CHANGED
|
@@ -30965,6 +30965,9 @@ var MoltsPayServer = class {
|
|
|
30965
30965
|
if (url.pathname === "/services" && req.method === "GET") {
|
|
30966
30966
|
return this.handleGetServices(res);
|
|
30967
30967
|
}
|
|
30968
|
+
if (url.pathname === "/.well-known/agent-services.json" && req.method === "GET") {
|
|
30969
|
+
return this.handleAgentServicesDiscovery(res);
|
|
30970
|
+
}
|
|
30968
30971
|
if (url.pathname === "/health" && req.method === "GET") {
|
|
30969
30972
|
return await this.handleHealthCheck(res);
|
|
30970
30973
|
}
|
|
@@ -30988,6 +30991,43 @@ var MoltsPayServer = class {
|
|
|
30988
30991
|
this.sendJson(res, 500, { error: err.message || "Internal error" });
|
|
30989
30992
|
}
|
|
30990
30993
|
}
|
|
30994
|
+
/**
|
|
30995
|
+
* GET /.well-known/agent-services.json - Standard discovery endpoint
|
|
30996
|
+
*/
|
|
30997
|
+
handleAgentServicesDiscovery(res) {
|
|
30998
|
+
const services = this.manifest.services.map((s) => ({
|
|
30999
|
+
id: s.id,
|
|
31000
|
+
name: s.name,
|
|
31001
|
+
description: s.description,
|
|
31002
|
+
price: s.price,
|
|
31003
|
+
currency: s.currency,
|
|
31004
|
+
input: s.input,
|
|
31005
|
+
output: s.output,
|
|
31006
|
+
available: this.skills.has(s.id)
|
|
31007
|
+
}));
|
|
31008
|
+
this.sendJson(res, 200, {
|
|
31009
|
+
version: "1.0",
|
|
31010
|
+
provider: {
|
|
31011
|
+
name: this.manifest.provider.name,
|
|
31012
|
+
description: this.manifest.provider.description,
|
|
31013
|
+
wallet: this.manifest.provider.wallet,
|
|
31014
|
+
chain: this.manifest.provider.chain || "base"
|
|
31015
|
+
},
|
|
31016
|
+
services,
|
|
31017
|
+
endpoints: {
|
|
31018
|
+
services: "/services",
|
|
31019
|
+
execute: "/execute",
|
|
31020
|
+
health: "/health"
|
|
31021
|
+
},
|
|
31022
|
+
payment: {
|
|
31023
|
+
protocol: "x402",
|
|
31024
|
+
version: X402_VERSION2,
|
|
31025
|
+
network: this.networkId,
|
|
31026
|
+
schemes: ["exact"],
|
|
31027
|
+
mainnet: this.useMainnet
|
|
31028
|
+
}
|
|
31029
|
+
});
|
|
31030
|
+
}
|
|
30991
31031
|
/**
|
|
30992
31032
|
* GET /services - List available services
|
|
30993
31033
|
*/
|
|
@@ -31074,10 +31114,16 @@ var MoltsPayServer = class {
|
|
|
31074
31114
|
});
|
|
31075
31115
|
}
|
|
31076
31116
|
console.log(`[MoltsPay] Verified by ${verifyResult.facilitator}`);
|
|
31077
|
-
|
|
31117
|
+
const timeoutSeconds = parseInt(process.env.SKILL_TIMEOUT_SECONDS || "1200");
|
|
31118
|
+
console.log(`[MoltsPay] Executing skill: ${service} (timeout: ${timeoutSeconds}s)`);
|
|
31078
31119
|
let result;
|
|
31079
31120
|
try {
|
|
31080
|
-
result = await
|
|
31121
|
+
result = await Promise.race([
|
|
31122
|
+
skill.handler(params || {}),
|
|
31123
|
+
new Promise(
|
|
31124
|
+
(_, reject) => setTimeout(() => reject(new Error(`Skill timeout after ${timeoutSeconds}s`)), timeoutSeconds * 1e3)
|
|
31125
|
+
)
|
|
31126
|
+
]);
|
|
31081
31127
|
} catch (err) {
|
|
31082
31128
|
console.error("[MoltsPay] Skill execution failed:", err.message);
|
|
31083
31129
|
return this.sendJson(res, 500, {
|
|
@@ -31286,9 +31332,15 @@ var MoltsPayServer = class {
|
|
|
31286
31332
|
error: `Service not found: ${service}`
|
|
31287
31333
|
});
|
|
31288
31334
|
}
|
|
31335
|
+
const timeoutSeconds = parseInt(process.env.SKILL_TIMEOUT_SECONDS || "1200");
|
|
31289
31336
|
let result;
|
|
31290
31337
|
try {
|
|
31291
|
-
result = await
|
|
31338
|
+
result = await Promise.race([
|
|
31339
|
+
skill.handler(params || {}),
|
|
31340
|
+
new Promise(
|
|
31341
|
+
(_, reject) => setTimeout(() => reject(new Error(`Skill timeout after ${timeoutSeconds}s`)), timeoutSeconds * 1e3)
|
|
31342
|
+
)
|
|
31343
|
+
]);
|
|
31292
31344
|
console.log(`[MoltsPay] /proxy: Skill succeeded, now settling payment...`);
|
|
31293
31345
|
} catch (err) {
|
|
31294
31346
|
console.error(`[MoltsPay] /proxy: Skill failed: ${err.message} - NOT settling`);
|