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/cli/index.mjs
CHANGED
|
@@ -984,6 +984,9 @@ var MoltsPayServer = class {
|
|
|
984
984
|
if (url.pathname === "/services" && req.method === "GET") {
|
|
985
985
|
return this.handleGetServices(res);
|
|
986
986
|
}
|
|
987
|
+
if (url.pathname === "/.well-known/agent-services.json" && req.method === "GET") {
|
|
988
|
+
return this.handleAgentServicesDiscovery(res);
|
|
989
|
+
}
|
|
987
990
|
if (url.pathname === "/health" && req.method === "GET") {
|
|
988
991
|
return await this.handleHealthCheck(res);
|
|
989
992
|
}
|
|
@@ -1007,6 +1010,43 @@ var MoltsPayServer = class {
|
|
|
1007
1010
|
this.sendJson(res, 500, { error: err.message || "Internal error" });
|
|
1008
1011
|
}
|
|
1009
1012
|
}
|
|
1013
|
+
/**
|
|
1014
|
+
* GET /.well-known/agent-services.json - Standard discovery endpoint
|
|
1015
|
+
*/
|
|
1016
|
+
handleAgentServicesDiscovery(res) {
|
|
1017
|
+
const services = this.manifest.services.map((s) => ({
|
|
1018
|
+
id: s.id,
|
|
1019
|
+
name: s.name,
|
|
1020
|
+
description: s.description,
|
|
1021
|
+
price: s.price,
|
|
1022
|
+
currency: s.currency,
|
|
1023
|
+
input: s.input,
|
|
1024
|
+
output: s.output,
|
|
1025
|
+
available: this.skills.has(s.id)
|
|
1026
|
+
}));
|
|
1027
|
+
this.sendJson(res, 200, {
|
|
1028
|
+
version: "1.0",
|
|
1029
|
+
provider: {
|
|
1030
|
+
name: this.manifest.provider.name,
|
|
1031
|
+
description: this.manifest.provider.description,
|
|
1032
|
+
wallet: this.manifest.provider.wallet,
|
|
1033
|
+
chain: this.manifest.provider.chain || "base"
|
|
1034
|
+
},
|
|
1035
|
+
services,
|
|
1036
|
+
endpoints: {
|
|
1037
|
+
services: "/services",
|
|
1038
|
+
execute: "/execute",
|
|
1039
|
+
health: "/health"
|
|
1040
|
+
},
|
|
1041
|
+
payment: {
|
|
1042
|
+
protocol: "x402",
|
|
1043
|
+
version: X402_VERSION3,
|
|
1044
|
+
network: this.networkId,
|
|
1045
|
+
schemes: ["exact"],
|
|
1046
|
+
mainnet: this.useMainnet
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1010
1050
|
/**
|
|
1011
1051
|
* GET /services - List available services
|
|
1012
1052
|
*/
|
|
@@ -1093,10 +1133,16 @@ var MoltsPayServer = class {
|
|
|
1093
1133
|
});
|
|
1094
1134
|
}
|
|
1095
1135
|
console.log(`[MoltsPay] Verified by ${verifyResult.facilitator}`);
|
|
1096
|
-
|
|
1136
|
+
const timeoutSeconds = parseInt(process.env.SKILL_TIMEOUT_SECONDS || "1200");
|
|
1137
|
+
console.log(`[MoltsPay] Executing skill: ${service} (timeout: ${timeoutSeconds}s)`);
|
|
1097
1138
|
let result;
|
|
1098
1139
|
try {
|
|
1099
|
-
result = await
|
|
1140
|
+
result = await Promise.race([
|
|
1141
|
+
skill.handler(params || {}),
|
|
1142
|
+
new Promise(
|
|
1143
|
+
(_, reject) => setTimeout(() => reject(new Error(`Skill timeout after ${timeoutSeconds}s`)), timeoutSeconds * 1e3)
|
|
1144
|
+
)
|
|
1145
|
+
]);
|
|
1100
1146
|
} catch (err) {
|
|
1101
1147
|
console.error("[MoltsPay] Skill execution failed:", err.message);
|
|
1102
1148
|
return this.sendJson(res, 500, {
|
|
@@ -1305,9 +1351,15 @@ var MoltsPayServer = class {
|
|
|
1305
1351
|
error: `Service not found: ${service}`
|
|
1306
1352
|
});
|
|
1307
1353
|
}
|
|
1354
|
+
const timeoutSeconds = parseInt(process.env.SKILL_TIMEOUT_SECONDS || "1200");
|
|
1308
1355
|
let result;
|
|
1309
1356
|
try {
|
|
1310
|
-
result = await
|
|
1357
|
+
result = await Promise.race([
|
|
1358
|
+
skill.handler(params || {}),
|
|
1359
|
+
new Promise(
|
|
1360
|
+
(_, reject) => setTimeout(() => reject(new Error(`Skill timeout after ${timeoutSeconds}s`)), timeoutSeconds * 1e3)
|
|
1361
|
+
)
|
|
1362
|
+
]);
|
|
1311
1363
|
console.log(`[MoltsPay] /proxy: Skill succeeded, now settling payment...`);
|
|
1312
1364
|
} catch (err) {
|
|
1313
1365
|
console.error(`[MoltsPay] /proxy: Skill failed: ${err.message} - NOT settling`);
|