kill-switch-mcp 1.2.11 → 1.2.13
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/server.js +46 -11
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -3855,13 +3855,19 @@ import {
|
|
|
3855
3855
|
stringToHex,
|
|
3856
3856
|
pad
|
|
3857
3857
|
} from "viem";
|
|
3858
|
-
import { Account } from "viem/tempo";
|
|
3858
|
+
import { Account, Transaction, withFeePayer } from "viem/tempo";
|
|
3859
3859
|
import { tempoModerato, tempo } from "viem/chains";
|
|
3860
3860
|
var TEMPO_BIN = join2(homedir2(), ".tempo", "bin", "tempo");
|
|
3861
3861
|
var TEMPO_CHAIN_ID = parseInt(process.env.TEMPO_CHAIN_ID || "4217");
|
|
3862
|
-
var
|
|
3863
|
-
var TEMPO_NETWORK =
|
|
3864
|
-
var USDC_ADDRESS = process.env.USDC_ADDRESS || "0x20c000000000000000000000b9537d11c60e8b50";
|
|
3862
|
+
var isMainnet = TEMPO_CHAIN_ID === 4217;
|
|
3863
|
+
var TEMPO_NETWORK = isMainnet ? "mainnet" : "testnet";
|
|
3864
|
+
var USDC_ADDRESS = process.env.USDC_ADDRESS || (isMainnet ? "0x20c000000000000000000000b9537d11c60e8b50" : "0x20c0000000000000000000000000000000000000");
|
|
3865
|
+
var feePayerUrl = null;
|
|
3866
|
+
function setFeePayerUrl(url) {
|
|
3867
|
+
feePayerUrl = url;
|
|
3868
|
+
}
|
|
3869
|
+
var baseChain = isMainnet ? tempo : tempoModerato;
|
|
3870
|
+
var tempoChain = { ...baseChain, feeToken: USDC_ADDRESS };
|
|
3865
3871
|
function runTempo(...args) {
|
|
3866
3872
|
return new Promise((resolve, reject) => {
|
|
3867
3873
|
execFile(TEMPO_BIN, args, { timeout: 30000 }, (error, stdout, stderr) => {
|
|
@@ -3978,12 +3984,31 @@ async function tempoFund() {
|
|
|
3978
3984
|
async function tempoRefresh() {
|
|
3979
3985
|
await runTempoInteractive("wallet", "refresh", "-n", TEMPO_NETWORK);
|
|
3980
3986
|
}
|
|
3987
|
+
function readKeyAuthorization() {
|
|
3988
|
+
const tomlPath = join2(homedir2(), ".tempo", "wallet", "keys.toml");
|
|
3989
|
+
if (!existsSync2(tomlPath))
|
|
3990
|
+
return null;
|
|
3991
|
+
try {
|
|
3992
|
+
const content = readFileSync(tomlPath, "utf-8");
|
|
3993
|
+
const match = content.match(/key_authorization\s*=\s*"(0x[0-9a-fA-F]+)"/);
|
|
3994
|
+
if (!match)
|
|
3995
|
+
return null;
|
|
3996
|
+
const KA = Transaction.z_KeyAuthorization;
|
|
3997
|
+
if (KA?.deserialize) {
|
|
3998
|
+
return KA.deserialize(match[1]);
|
|
3999
|
+
}
|
|
4000
|
+
return match[1];
|
|
4001
|
+
} catch {
|
|
4002
|
+
return null;
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
3981
4005
|
function getWalletClient(privateKey, parentAddress) {
|
|
3982
4006
|
const account = Account.fromSecp256k1(privateKey, { access: parentAddress });
|
|
4007
|
+
const transport = feePayerUrl ? withFeePayer(http(), http(feePayerUrl), { policy: "sign-and-broadcast" }) : http();
|
|
3983
4008
|
return createWalletClient({
|
|
3984
4009
|
account,
|
|
3985
4010
|
chain: tempoChain,
|
|
3986
|
-
transport
|
|
4011
|
+
transport
|
|
3987
4012
|
});
|
|
3988
4013
|
}
|
|
3989
4014
|
function getPublicClient() {
|
|
@@ -4070,11 +4095,15 @@ async function joinTournament(tournamentAddress, username) {
|
|
|
4070
4095
|
if (remaining < buyInUsd) {
|
|
4071
4096
|
throw new Error(`Spending limit too low. Need $${buyInUsd.toFixed(2)}, limit remaining: $${remaining.toFixed(2)}. ` + "Run `tempo wallet refresh` to reset your spending limit.");
|
|
4072
4097
|
}
|
|
4098
|
+
const keyAuth = readKeyAuthorization();
|
|
4099
|
+
const sponsorOpts = feePayerUrl ? { feePayer: true } : {};
|
|
4073
4100
|
const approveHash = await walletClient.writeContract({
|
|
4074
4101
|
address: USDC_ADDRESS,
|
|
4075
4102
|
abi: ERC20_ABI,
|
|
4076
4103
|
functionName: "approve",
|
|
4077
|
-
args: [tournamentAddress, buyIn]
|
|
4104
|
+
args: [tournamentAddress, buyIn],
|
|
4105
|
+
...keyAuth ? { keyAuthorization: keyAuth } : {},
|
|
4106
|
+
...sponsorOpts
|
|
4078
4107
|
});
|
|
4079
4108
|
await pub.waitForTransactionReceipt({ hash: approveHash });
|
|
4080
4109
|
const usernameBytes = pad(stringToHex(username), { size: 32 });
|
|
@@ -4082,7 +4111,9 @@ async function joinTournament(tournamentAddress, username) {
|
|
|
4082
4111
|
address: tournamentAddress,
|
|
4083
4112
|
abi: TOURNAMENT_ABI,
|
|
4084
4113
|
functionName: "deposit",
|
|
4085
|
-
args: [usernameBytes]
|
|
4114
|
+
args: [usernameBytes],
|
|
4115
|
+
...keyAuth ? { keyAuthorization: keyAuth } : {},
|
|
4116
|
+
...sponsorOpts
|
|
4086
4117
|
});
|
|
4087
4118
|
await pub.waitForTransactionReceipt({ hash: depositHash });
|
|
4088
4119
|
return {
|
|
@@ -4099,6 +4130,10 @@ var SERVER_URL = (() => {
|
|
|
4099
4130
|
return process.env.KILL_SWITCH_SERVER || "localhost";
|
|
4100
4131
|
})();
|
|
4101
4132
|
console.error(`[Kill Switch MCP] Server: ${SERVER_URL}`);
|
|
4133
|
+
var isLocal = SERVER_URL === "localhost" || SERVER_URL === "127.0.0.1";
|
|
4134
|
+
var FEE_PAYER_URL = `${isLocal ? "http://localhost:8888" : `https://${SERVER_URL}`}/api/fee-payer`;
|
|
4135
|
+
setFeePayerUrl(FEE_PAYER_URL);
|
|
4136
|
+
console.error(`[Kill Switch MCP] Fee payer relay: ${FEE_PAYER_URL}`);
|
|
4102
4137
|
var KILLSWITCH_HOME = join3(homedir3(), ".killswitch");
|
|
4103
4138
|
var BOTS_DIR = join3(KILLSWITCH_HOME, "bots");
|
|
4104
4139
|
var GUIDE = `# Kill Switch — Player Guide
|
|
@@ -4784,8 +4819,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
|
4784
4819
|
}
|
|
4785
4820
|
}
|
|
4786
4821
|
try {
|
|
4787
|
-
const
|
|
4788
|
-
const webBase =
|
|
4822
|
+
const isLocal2 = SERVER_URL === "localhost" || SERVER_URL === "127.0.0.1";
|
|
4823
|
+
const webBase = isLocal2 ? `http://localhost:8888` : `https://${SERVER_URL}`;
|
|
4789
4824
|
const aliveRes = await fetch(`${webBase}/api/agent-alive?username=${encodeURIComponent(username.toLowerCase())}`);
|
|
4790
4825
|
const aliveData = await aliveRes.json();
|
|
4791
4826
|
if (aliveData.alive === false) {
|
|
@@ -5031,8 +5066,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
|
5031
5066
|
if (!connection) {
|
|
5032
5067
|
return errorResponse("Not connected. Call login first.");
|
|
5033
5068
|
}
|
|
5034
|
-
const
|
|
5035
|
-
const webBase =
|
|
5069
|
+
const isLocal2 = SERVER_URL === "localhost" || SERVER_URL === "127.0.0.1";
|
|
5070
|
+
const webBase = isLocal2 ? `http://localhost:8888` : `https://${SERVER_URL}`;
|
|
5036
5071
|
const availRes = await fetch(`${webBase}/api/game/available`);
|
|
5037
5072
|
const available = await availRes.json();
|
|
5038
5073
|
if (available.status === "active") {
|