teleton 0.7.0 → 0.7.1
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/README.md +11 -8
- package/dist/{chunk-OGIG552S.js → chunk-3YM57ZAV.js} +312 -132
- package/dist/{chunk-TCD4NZDA.js → chunk-HZNZT4TG.js} +66 -58
- package/dist/cli/index.js +4 -4
- package/dist/index.js +4 -4
- package/dist/{memory-RD7ZSTRV.js → memory-5SS3Q5EA.js} +2 -2
- package/dist/{migrate-GO4NOBT7.js → migrate-M7SJMDOL.js} +2 -2
- package/dist/{server-OWVEZTR3.js → server-DS5OARW6.js} +94 -2
- package/dist/web/assets/index-BqwoDycr.js +72 -0
- package/dist/web/assets/index-CRDIf07k.css +1 -0
- package/dist/web/assets/{index.es-oXiZF7Hc.js → index.es-D81xLR29.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-B_FcaX5D.css +0 -1
- package/dist/web/assets/index-CbeAP4_n.js +0 -67
- package/dist/{chunk-N3F7E7DR.js → chunk-RBU6JXD3.js} +3 -3
|
@@ -927,7 +927,7 @@ function createTonSDK(log7, db) {
|
|
|
927
927
|
for (const item of data.balances || []) {
|
|
928
928
|
const { balance, wallet_address, jetton } = item;
|
|
929
929
|
if (jetton.verification === "blacklist") continue;
|
|
930
|
-
const decimals = jetton.decimals
|
|
930
|
+
const decimals = jetton.decimals ?? 9;
|
|
931
931
|
const rawBalance = BigInt(balance);
|
|
932
932
|
const divisor = BigInt(10 ** decimals);
|
|
933
933
|
const wholePart = rawBalance / divisor;
|
|
@@ -994,68 +994,76 @@ function createTonSDK(log7, db) {
|
|
|
994
994
|
} catch {
|
|
995
995
|
throw new PluginSDKError("Invalid recipient address", "INVALID_ADDRESS");
|
|
996
996
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
if (!jettonBalance) {
|
|
1009
|
-
throw new PluginSDKError(
|
|
1010
|
-
`You don't own any of this jetton: ${jettonAddress}`,
|
|
1011
|
-
"OPERATION_FAILED"
|
|
997
|
+
try {
|
|
998
|
+
const jettonsResponse = await tonapiFetch(`/accounts/${walletData.address}/jettons`);
|
|
999
|
+
if (!jettonsResponse.ok) {
|
|
1000
|
+
throw new PluginSDKError(
|
|
1001
|
+
`Failed to fetch jetton balances: ${jettonsResponse.status}`,
|
|
1002
|
+
"OPERATION_FAILED"
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
const jettonsData = await jettonsResponse.json();
|
|
1006
|
+
const jettonBalance = jettonsData.balances?.find(
|
|
1007
|
+
(b) => b.jetton.address.toLowerCase() === jettonAddress.toLowerCase() || Address2.parse(b.jetton.address).toString() === Address2.parse(jettonAddress).toString()
|
|
1012
1008
|
);
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1009
|
+
if (!jettonBalance) {
|
|
1010
|
+
throw new PluginSDKError(
|
|
1011
|
+
`You don't own any of this jetton: ${jettonAddress}`,
|
|
1012
|
+
"OPERATION_FAILED"
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
const senderJettonWallet = jettonBalance.wallet_address.address;
|
|
1016
|
+
const decimals = jettonBalance.jetton.decimals ?? 9;
|
|
1017
|
+
const currentBalance = BigInt(jettonBalance.balance);
|
|
1018
|
+
const amountStr = amount.toFixed(decimals);
|
|
1019
|
+
const [whole, frac = ""] = amountStr.split(".");
|
|
1020
|
+
const amountInUnits = BigInt(whole + (frac + "0".repeat(decimals)).slice(0, decimals));
|
|
1021
|
+
if (amountInUnits > currentBalance) {
|
|
1022
|
+
throw new PluginSDKError(
|
|
1023
|
+
`Insufficient balance. Have ${Number(currentBalance) / 10 ** decimals}, need ${amount}`,
|
|
1024
|
+
"OPERATION_FAILED"
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
const comment = opts?.comment;
|
|
1028
|
+
let forwardPayload = beginCell().endCell();
|
|
1029
|
+
if (comment) {
|
|
1030
|
+
forwardPayload = beginCell().storeUint(0, 32).storeStringTail(comment).endCell();
|
|
1031
|
+
}
|
|
1032
|
+
const JETTON_TRANSFER_OP = 260734629;
|
|
1033
|
+
const messageBody = beginCell().storeUint(JETTON_TRANSFER_OP, 32).storeUint(0, 64).storeCoins(amountInUnits).storeAddress(Address2.parse(to)).storeAddress(Address2.parse(walletData.address)).storeBit(false).storeCoins(comment ? toNano2("0.01") : BigInt(1)).storeBit(comment ? true : false).storeMaybeRef(comment ? forwardPayload : null).endCell();
|
|
1034
|
+
const keyPair = await getKeyPair();
|
|
1035
|
+
if (!keyPair) {
|
|
1036
|
+
throw new PluginSDKError("Wallet key derivation failed", "OPERATION_FAILED");
|
|
1037
|
+
}
|
|
1038
|
+
const wallet = WalletContractV5R12.create({
|
|
1039
|
+
workchain: 0,
|
|
1040
|
+
publicKey: keyPair.publicKey
|
|
1041
|
+
});
|
|
1042
|
+
const endpoint = await getCachedHttpEndpoint2();
|
|
1043
|
+
const client = new TonClient2({ endpoint });
|
|
1044
|
+
const walletContract = client.open(wallet);
|
|
1045
|
+
const seqno = await walletContract.getSeqno();
|
|
1046
|
+
await walletContract.sendTransfer({
|
|
1047
|
+
seqno,
|
|
1048
|
+
secretKey: keyPair.secretKey,
|
|
1049
|
+
sendMode: SendMode2.PAY_GAS_SEPARATELY,
|
|
1050
|
+
messages: [
|
|
1051
|
+
internal2({
|
|
1052
|
+
to: Address2.parse(senderJettonWallet),
|
|
1053
|
+
value: toNano2("0.05"),
|
|
1054
|
+
body: messageBody,
|
|
1055
|
+
bounce: true
|
|
1056
|
+
})
|
|
1057
|
+
]
|
|
1058
|
+
});
|
|
1059
|
+
return { success: true, seqno };
|
|
1060
|
+
} catch (err) {
|
|
1061
|
+
if (err instanceof PluginSDKError) throw err;
|
|
1021
1062
|
throw new PluginSDKError(
|
|
1022
|
-
`
|
|
1063
|
+
`Failed to send jetton: ${err instanceof Error ? err.message : String(err)}`,
|
|
1023
1064
|
"OPERATION_FAILED"
|
|
1024
1065
|
);
|
|
1025
1066
|
}
|
|
1026
|
-
const comment = opts?.comment;
|
|
1027
|
-
let forwardPayload = beginCell().endCell();
|
|
1028
|
-
if (comment) {
|
|
1029
|
-
forwardPayload = beginCell().storeUint(0, 32).storeStringTail(comment).endCell();
|
|
1030
|
-
}
|
|
1031
|
-
const JETTON_TRANSFER_OP = 260734629;
|
|
1032
|
-
const messageBody = beginCell().storeUint(JETTON_TRANSFER_OP, 32).storeUint(0, 64).storeCoins(amountInUnits).storeAddress(Address2.parse(to)).storeAddress(Address2.parse(walletData.address)).storeBit(false).storeCoins(comment ? toNano2("0.01") : BigInt(1)).storeBit(comment ? true : false).storeMaybeRef(comment ? forwardPayload : null).endCell();
|
|
1033
|
-
const keyPair = await getKeyPair();
|
|
1034
|
-
if (!keyPair) {
|
|
1035
|
-
throw new PluginSDKError("Wallet key derivation failed", "OPERATION_FAILED");
|
|
1036
|
-
}
|
|
1037
|
-
const wallet = WalletContractV5R12.create({
|
|
1038
|
-
workchain: 0,
|
|
1039
|
-
publicKey: keyPair.publicKey
|
|
1040
|
-
});
|
|
1041
|
-
const endpoint = await getCachedHttpEndpoint2();
|
|
1042
|
-
const client = new TonClient2({ endpoint });
|
|
1043
|
-
const walletContract = client.open(wallet);
|
|
1044
|
-
const seqno = await walletContract.getSeqno();
|
|
1045
|
-
await walletContract.sendTransfer({
|
|
1046
|
-
seqno,
|
|
1047
|
-
secretKey: keyPair.secretKey,
|
|
1048
|
-
sendMode: SendMode2.PAY_GAS_SEPARATELY + SendMode2.IGNORE_ERRORS,
|
|
1049
|
-
messages: [
|
|
1050
|
-
internal2({
|
|
1051
|
-
to: Address2.parse(senderJettonWallet),
|
|
1052
|
-
value: toNano2("0.05"),
|
|
1053
|
-
body: messageBody,
|
|
1054
|
-
bounce: true
|
|
1055
|
-
})
|
|
1056
|
-
]
|
|
1057
|
-
});
|
|
1058
|
-
return { success: true, seqno };
|
|
1059
1067
|
},
|
|
1060
1068
|
async getJettonWalletAddress(ownerAddress, jettonAddress) {
|
|
1061
1069
|
try {
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TelegramUserClient,
|
|
3
3
|
main
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-3YM57ZAV.js";
|
|
5
5
|
import "../chunk-UDD7FYOU.js";
|
|
6
6
|
import "../chunk-EHEV7FJ7.js";
|
|
7
7
|
import "../chunk-U7FQYCBQ.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
readRawConfig,
|
|
15
15
|
setNestedValue,
|
|
16
16
|
writeRawConfig
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-HZNZT4TG.js";
|
|
18
18
|
import {
|
|
19
19
|
ConfigSchema,
|
|
20
20
|
DealsConfigSchema,
|
|
@@ -38,9 +38,9 @@ import {
|
|
|
38
38
|
validateApiKeyFormat
|
|
39
39
|
} from "../chunk-LRCPA7SC.js";
|
|
40
40
|
import "../chunk-OCLG5GKI.js";
|
|
41
|
-
import "../chunk-
|
|
42
|
-
import "../chunk-FNV5FF35.js";
|
|
41
|
+
import "../chunk-RBU6JXD3.js";
|
|
43
42
|
import "../chunk-UCN6TI25.js";
|
|
43
|
+
import "../chunk-FNV5FF35.js";
|
|
44
44
|
import "../chunk-XBKSS6DM.js";
|
|
45
45
|
import {
|
|
46
46
|
TELEGRAM_MAX_MESSAGE_LENGTH
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TeletonApp,
|
|
3
3
|
main
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3YM57ZAV.js";
|
|
5
5
|
import "./chunk-UDD7FYOU.js";
|
|
6
6
|
import "./chunk-EHEV7FJ7.js";
|
|
7
7
|
import "./chunk-U7FQYCBQ.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-HZNZT4TG.js";
|
|
9
9
|
import "./chunk-NERLQY2H.js";
|
|
10
10
|
import "./chunk-QUAPFI2N.js";
|
|
11
11
|
import "./chunk-TSKJCWQQ.js";
|
|
@@ -13,9 +13,9 @@ import "./chunk-XBE4JB7C.js";
|
|
|
13
13
|
import "./chunk-ND2X5FWB.js";
|
|
14
14
|
import "./chunk-LRCPA7SC.js";
|
|
15
15
|
import "./chunk-OCLG5GKI.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-FNV5FF35.js";
|
|
16
|
+
import "./chunk-RBU6JXD3.js";
|
|
18
17
|
import "./chunk-UCN6TI25.js";
|
|
18
|
+
import "./chunk-FNV5FF35.js";
|
|
19
19
|
import "./chunk-XBKSS6DM.js";
|
|
20
20
|
import "./chunk-RO62LO6Z.js";
|
|
21
21
|
import "./chunk-VAUJSSD3.js";
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
initializeMemory,
|
|
17
17
|
runMigrations,
|
|
18
18
|
setSchemaVersion
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RBU6JXD3.js";
|
|
20
|
+
import "./chunk-UCN6TI25.js";
|
|
20
21
|
import {
|
|
21
22
|
AnthropicEmbeddingProvider,
|
|
22
23
|
CachedEmbeddingProvider,
|
|
@@ -27,7 +28,6 @@ import {
|
|
|
27
28
|
hashText,
|
|
28
29
|
serializeEmbedding
|
|
29
30
|
} from "./chunk-FNV5FF35.js";
|
|
30
|
-
import "./chunk-UCN6TI25.js";
|
|
31
31
|
import "./chunk-XBKSS6DM.js";
|
|
32
32
|
import "./chunk-RO62LO6Z.js";
|
|
33
33
|
import "./chunk-VAUJSSD3.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDatabase
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-FNV5FF35.js";
|
|
3
|
+
} from "./chunk-RBU6JXD3.js";
|
|
5
4
|
import "./chunk-UCN6TI25.js";
|
|
5
|
+
import "./chunk-FNV5FF35.js";
|
|
6
6
|
import "./chunk-XBKSS6DM.js";
|
|
7
7
|
import "./chunk-RO62LO6Z.js";
|
|
8
8
|
import "./chunk-VAUJSSD3.js";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
validateWritePath,
|
|
17
17
|
writePluginSecret,
|
|
18
18
|
writeRawConfig
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HZNZT4TG.js";
|
|
20
20
|
import "./chunk-NERLQY2H.js";
|
|
21
21
|
import "./chunk-QUAPFI2N.js";
|
|
22
22
|
import "./chunk-TSKJCWQQ.js";
|
|
@@ -47,6 +47,7 @@ import "./chunk-QGM4M3NI.js";
|
|
|
47
47
|
import { Hono as Hono12 } from "hono";
|
|
48
48
|
import { serve } from "@hono/node-server";
|
|
49
49
|
import { cors } from "hono/cors";
|
|
50
|
+
import { streamSSE as streamSSE2 } from "hono/streaming";
|
|
50
51
|
import { bodyLimit } from "hono/body-limit";
|
|
51
52
|
import { setCookie, getCookie, deleteCookie } from "hono/cookie";
|
|
52
53
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
@@ -624,9 +625,10 @@ var SAFE_ARG_RE = /^[a-zA-Z0-9._\/:=@-]+$/;
|
|
|
624
625
|
function createMcpRoutes(deps) {
|
|
625
626
|
const app = new Hono7();
|
|
626
627
|
app.get("/", (c) => {
|
|
628
|
+
const servers = typeof deps.mcpServers === "function" ? deps.mcpServers() : deps.mcpServers;
|
|
627
629
|
const response = {
|
|
628
630
|
success: true,
|
|
629
|
-
data:
|
|
631
|
+
data: servers
|
|
630
632
|
};
|
|
631
633
|
return c.json(response);
|
|
632
634
|
});
|
|
@@ -1805,6 +1807,96 @@ var WebUIServer = class {
|
|
|
1805
1807
|
this.app.route("/api/tasks", createTasksRoutes(this.deps));
|
|
1806
1808
|
this.app.route("/api/config", createConfigRoutes(this.deps));
|
|
1807
1809
|
this.app.route("/api/marketplace", createMarketplaceRoutes(this.deps));
|
|
1810
|
+
this.app.post("/api/agent/start", async (c) => {
|
|
1811
|
+
const lifecycle = this.deps.lifecycle;
|
|
1812
|
+
if (!lifecycle) {
|
|
1813
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1814
|
+
}
|
|
1815
|
+
const state = lifecycle.getState();
|
|
1816
|
+
if (state === "running") {
|
|
1817
|
+
return c.json({ state: "running" }, 409);
|
|
1818
|
+
}
|
|
1819
|
+
if (state === "stopping") {
|
|
1820
|
+
return c.json({ error: "Agent is currently stopping, please wait" }, 409);
|
|
1821
|
+
}
|
|
1822
|
+
lifecycle.start().catch((err) => {
|
|
1823
|
+
log2.error({ err }, "Agent start failed");
|
|
1824
|
+
});
|
|
1825
|
+
return c.json({ state: "starting" });
|
|
1826
|
+
});
|
|
1827
|
+
this.app.post("/api/agent/stop", async (c) => {
|
|
1828
|
+
const lifecycle = this.deps.lifecycle;
|
|
1829
|
+
if (!lifecycle) {
|
|
1830
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1831
|
+
}
|
|
1832
|
+
const state = lifecycle.getState();
|
|
1833
|
+
if (state === "stopped") {
|
|
1834
|
+
return c.json({ state: "stopped" }, 409);
|
|
1835
|
+
}
|
|
1836
|
+
if (state === "starting") {
|
|
1837
|
+
return c.json({ error: "Agent is currently starting, please wait" }, 409);
|
|
1838
|
+
}
|
|
1839
|
+
lifecycle.stop().catch((err) => {
|
|
1840
|
+
log2.error({ err }, "Agent stop failed");
|
|
1841
|
+
});
|
|
1842
|
+
return c.json({ state: "stopping" });
|
|
1843
|
+
});
|
|
1844
|
+
this.app.get("/api/agent/status", (c) => {
|
|
1845
|
+
const lifecycle = this.deps.lifecycle;
|
|
1846
|
+
if (!lifecycle) {
|
|
1847
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1848
|
+
}
|
|
1849
|
+
return c.json({
|
|
1850
|
+
state: lifecycle.getState(),
|
|
1851
|
+
uptime: lifecycle.getUptime(),
|
|
1852
|
+
error: lifecycle.getError() ?? null
|
|
1853
|
+
});
|
|
1854
|
+
});
|
|
1855
|
+
this.app.get("/api/agent/events", (c) => {
|
|
1856
|
+
const lifecycle = this.deps.lifecycle;
|
|
1857
|
+
if (!lifecycle) {
|
|
1858
|
+
return c.json({ error: "Agent lifecycle not available" }, 503);
|
|
1859
|
+
}
|
|
1860
|
+
return streamSSE2(c, async (stream) => {
|
|
1861
|
+
let aborted = false;
|
|
1862
|
+
stream.onAbort(() => {
|
|
1863
|
+
aborted = true;
|
|
1864
|
+
});
|
|
1865
|
+
const now = Date.now();
|
|
1866
|
+
await stream.writeSSE({
|
|
1867
|
+
event: "status",
|
|
1868
|
+
id: String(now),
|
|
1869
|
+
data: JSON.stringify({
|
|
1870
|
+
state: lifecycle.getState(),
|
|
1871
|
+
error: lifecycle.getError() ?? null,
|
|
1872
|
+
timestamp: now
|
|
1873
|
+
}),
|
|
1874
|
+
retry: 3e3
|
|
1875
|
+
});
|
|
1876
|
+
const onStateChange = (event) => {
|
|
1877
|
+
if (aborted) return;
|
|
1878
|
+
stream.writeSSE({
|
|
1879
|
+
event: "status",
|
|
1880
|
+
id: String(event.timestamp),
|
|
1881
|
+
data: JSON.stringify({
|
|
1882
|
+
state: event.state,
|
|
1883
|
+
error: event.error ?? null,
|
|
1884
|
+
timestamp: event.timestamp
|
|
1885
|
+
})
|
|
1886
|
+
});
|
|
1887
|
+
};
|
|
1888
|
+
lifecycle.on("stateChange", onStateChange);
|
|
1889
|
+
while (!aborted) {
|
|
1890
|
+
await stream.sleep(3e4);
|
|
1891
|
+
if (aborted) break;
|
|
1892
|
+
await stream.writeSSE({
|
|
1893
|
+
event: "ping",
|
|
1894
|
+
data: ""
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
lifecycle.off("stateChange", onStateChange);
|
|
1898
|
+
});
|
|
1899
|
+
});
|
|
1808
1900
|
const webDist = findWebDist();
|
|
1809
1901
|
if (webDist) {
|
|
1810
1902
|
const indexHtml = readFileSync3(join4(webDist, "index.html"), "utf-8");
|