teleton 0.7.2 → 0.7.3
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/{chunk-ND2X5FWB.js → chunk-5PLZ3KSO.js} +16 -3
- package/dist/{chunk-JHKWHGBM.js → chunk-A4GCOHCE.js} +203 -42
- package/dist/{chunk-VSMUAU5X.js → chunk-BU453WX4.js} +416 -612
- package/dist/{chunk-NERLQY2H.js → chunk-DAMCNMYL.js} +64 -6
- package/dist/chunk-JQDLW7IE.js +107 -0
- package/dist/{chunk-LRCPA7SC.js → chunk-RMLQS3X6.js} +15 -3
- package/dist/{chunk-UDD7FYOU.js → chunk-WIKM24GZ.js} +1 -18
- package/dist/cli/index.js +77 -14
- package/dist/{client-3VWE7NC4.js → client-RTNALK7W.js} +3 -2
- package/dist/{get-my-gifts-RI7FAXAL.js → get-my-gifts-TPVUGUWT.js} +1 -1
- package/dist/index.js +7 -8
- package/dist/{server-NPSODUMA.js → server-FOC5P7U6.js} +3 -4
- package/dist/{setup-server-C7ZTPHD5.js → setup-server-BVVD2PR6.js} +83 -14
- package/dist/web/assets/index-By_fs4Jl.js +72 -0
- package/dist/web/assets/{index.es-D81xLR29.js → index.es-7MTSV5SL.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-EHEV7FJ7.js +0 -157
- package/dist/chunk-QUAPFI2N.js +0 -42
- package/dist/endpoint-FLYNEZ2F.js +0 -7
- package/dist/format-transactions-FD74HI5N.js +0 -9
- package/dist/web/assets/index-BqwoDycr.js +0 -72
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
telegramGetMyGiftsExecutor,
|
|
3
3
|
telegramGetMyGiftsTool
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
formatTransactions
|
|
7
|
-
} from "./chunk-EHEV7FJ7.js";
|
|
4
|
+
} from "./chunk-WIKM24GZ.js";
|
|
8
5
|
import {
|
|
9
6
|
Mi,
|
|
10
7
|
Mn,
|
|
@@ -22,6 +19,7 @@ import {
|
|
|
22
19
|
buildSystemPrompt,
|
|
23
20
|
deletePluginSecret,
|
|
24
21
|
ensurePluginDeps,
|
|
22
|
+
formatTransactions,
|
|
25
23
|
getDefaultConfigPath,
|
|
26
24
|
listPluginSecretKeys,
|
|
27
25
|
loadConfig,
|
|
@@ -42,18 +40,17 @@ import {
|
|
|
42
40
|
writePluginSecret,
|
|
43
41
|
writeRawConfig,
|
|
44
42
|
writeSummaryToDailyLog
|
|
45
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-A4GCOHCE.js";
|
|
46
44
|
import {
|
|
45
|
+
getCachedHttpEndpoint,
|
|
46
|
+
getCachedTonClient,
|
|
47
47
|
getKeyPair,
|
|
48
48
|
getTonPrice,
|
|
49
49
|
getWalletAddress,
|
|
50
50
|
getWalletBalance,
|
|
51
51
|
loadTemplate,
|
|
52
52
|
loadWallet
|
|
53
|
-
} from "./chunk-
|
|
54
|
-
import {
|
|
55
|
-
getCachedHttpEndpoint
|
|
56
|
-
} from "./chunk-QUAPFI2N.js";
|
|
53
|
+
} from "./chunk-DAMCNMYL.js";
|
|
57
54
|
import {
|
|
58
55
|
require_BigInteger
|
|
59
56
|
} from "./chunk-TSKJCWQQ.js";
|
|
@@ -66,10 +63,10 @@ import {
|
|
|
66
63
|
getProviderModel,
|
|
67
64
|
getUtilityModel,
|
|
68
65
|
loadContextFromTranscript
|
|
69
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-5PLZ3KSO.js";
|
|
70
67
|
import {
|
|
71
68
|
getProviderMetadata
|
|
72
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-RMLQS3X6.js";
|
|
73
70
|
import {
|
|
74
71
|
appendToTranscript,
|
|
75
72
|
archiveTranscript,
|
|
@@ -254,6 +251,14 @@ function formatMessageEnvelope(params) {
|
|
|
254
251
|
const msgIdHint = params.messageId ? ` msg_id=${params.messageId}` : "";
|
|
255
252
|
body = `[${mediaEmoji} ${params.mediaType}${msgIdHint}] ${body}`;
|
|
256
253
|
}
|
|
254
|
+
if (params.replyContext) {
|
|
255
|
+
const sender = params.replyContext.isAgent ? "agent" : sanitizeForPrompt(params.replyContext.senderName ?? "unknown");
|
|
256
|
+
let quotedText = sanitizeForContext(params.replyContext.text);
|
|
257
|
+
if (quotedText.length > 200) quotedText = quotedText.slice(0, 200) + "...";
|
|
258
|
+
return `${header}
|
|
259
|
+
[\u21A9 reply to ${sender}: "${quotedText}"]
|
|
260
|
+
${body}`;
|
|
261
|
+
}
|
|
257
262
|
return `${header} ${body}`;
|
|
258
263
|
}
|
|
259
264
|
|
|
@@ -1228,7 +1233,7 @@ var AgentRuntime = class {
|
|
|
1228
1233
|
getToolRegistry() {
|
|
1229
1234
|
return this.toolRegistry;
|
|
1230
1235
|
}
|
|
1231
|
-
async processMessage(chatId, userMessage, userName, timestamp, isGroup, pendingContext, toolContext, senderUsername, hasMedia, mediaType, messageId) {
|
|
1236
|
+
async processMessage(chatId, userMessage, userName, timestamp, isGroup, pendingContext, toolContext, senderUsername, hasMedia, mediaType, messageId, replyContext) {
|
|
1232
1237
|
try {
|
|
1233
1238
|
let session = getOrCreateSession(chatId);
|
|
1234
1239
|
const now = timestamp ?? Date.now();
|
|
@@ -1273,7 +1278,8 @@ var AgentRuntime = class {
|
|
|
1273
1278
|
isGroup: isGroup ?? false,
|
|
1274
1279
|
hasMedia,
|
|
1275
1280
|
mediaType,
|
|
1276
|
-
messageId
|
|
1281
|
+
messageId,
|
|
1282
|
+
replyContext
|
|
1277
1283
|
});
|
|
1278
1284
|
if (pendingContext) {
|
|
1279
1285
|
formattedMessage = `${pendingContext}
|
|
@@ -1868,14 +1874,71 @@ var TelegramUserClient = class {
|
|
|
1868
1874
|
await this.client.connect();
|
|
1869
1875
|
} else {
|
|
1870
1876
|
log7.info("Starting authentication flow...");
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1877
|
+
const phone = this.config.phone || await promptInput("Phone number: ");
|
|
1878
|
+
await this.client.connect();
|
|
1879
|
+
const sendResult = await this.client.invoke(
|
|
1880
|
+
new Api.auth.SendCode({
|
|
1881
|
+
phoneNumber: phone,
|
|
1882
|
+
apiId: this.config.apiId,
|
|
1883
|
+
apiHash: this.config.apiHash,
|
|
1884
|
+
settings: new Api.CodeSettings({})
|
|
1885
|
+
})
|
|
1886
|
+
);
|
|
1887
|
+
if (sendResult instanceof Api.auth.SentCodeSuccess) {
|
|
1888
|
+
log7.info("Authenticated (SentCodeSuccess)");
|
|
1889
|
+
this.saveSession();
|
|
1890
|
+
} else {
|
|
1891
|
+
const phoneCodeHash = sendResult.phoneCodeHash;
|
|
1892
|
+
if (sendResult.type instanceof Api.auth.SentCodeTypeFragmentSms) {
|
|
1893
|
+
const url = sendResult.type.url;
|
|
1894
|
+
if (url) {
|
|
1895
|
+
console.log(`
|
|
1896
|
+
Anonymous number \u2014 open this URL to get your code:
|
|
1897
|
+
${url}
|
|
1898
|
+
`);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
let authenticated = false;
|
|
1902
|
+
const maxAttempts = 3;
|
|
1903
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1904
|
+
const code = await promptInput("Verification code: ");
|
|
1905
|
+
try {
|
|
1906
|
+
await this.client.invoke(
|
|
1907
|
+
new Api.auth.SignIn({
|
|
1908
|
+
phoneNumber: phone,
|
|
1909
|
+
phoneCodeHash,
|
|
1910
|
+
phoneCode: code
|
|
1911
|
+
})
|
|
1912
|
+
);
|
|
1913
|
+
authenticated = true;
|
|
1914
|
+
break;
|
|
1915
|
+
} catch (err) {
|
|
1916
|
+
if (err.errorMessage === "PHONE_CODE_INVALID") {
|
|
1917
|
+
const remaining = maxAttempts - attempt - 1;
|
|
1918
|
+
if (remaining > 0) {
|
|
1919
|
+
console.log(`Invalid code. ${remaining} attempt(s) remaining.`);
|
|
1920
|
+
} else {
|
|
1921
|
+
throw new Error("Authentication failed: too many invalid code attempts");
|
|
1922
|
+
}
|
|
1923
|
+
} else if (err.errorMessage === "SESSION_PASSWORD_NEEDED") {
|
|
1924
|
+
const pwd = await promptInput("2FA password: ");
|
|
1925
|
+
const { computeCheck } = await import("telegram/Password.js");
|
|
1926
|
+
const srpResult = await this.client.invoke(new Api.account.GetPassword());
|
|
1927
|
+
const srpCheck = await computeCheck(srpResult, pwd);
|
|
1928
|
+
await this.client.invoke(new Api.auth.CheckPassword({ password: srpCheck }));
|
|
1929
|
+
authenticated = true;
|
|
1930
|
+
break;
|
|
1931
|
+
} else {
|
|
1932
|
+
throw err;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
if (!authenticated) {
|
|
1937
|
+
throw new Error("Authentication failed");
|
|
1938
|
+
}
|
|
1939
|
+
log7.info("Authenticated");
|
|
1940
|
+
this.saveSession();
|
|
1941
|
+
}
|
|
1879
1942
|
}
|
|
1880
1943
|
const me = await this.client.getMe();
|
|
1881
1944
|
this.me = {
|
|
@@ -2223,6 +2286,7 @@ var TelegramBridge = class {
|
|
|
2223
2286
|
else if (msg.voice) mediaType = "voice";
|
|
2224
2287
|
else if (msg.sticker) mediaType = "sticker";
|
|
2225
2288
|
else if (msg.document) mediaType = "document";
|
|
2289
|
+
const replyToMsgId = msg.replyToMsgId;
|
|
2226
2290
|
let text = msg.message ?? "";
|
|
2227
2291
|
if (!text && msg.media) {
|
|
2228
2292
|
if (msg.media.className === "MessageMediaDice") {
|
|
@@ -2256,12 +2320,45 @@ var TelegramBridge = class {
|
|
|
2256
2320
|
_rawPeer: msg.peerId,
|
|
2257
2321
|
hasMedia,
|
|
2258
2322
|
mediaType,
|
|
2259
|
-
|
|
2323
|
+
replyToId: replyToMsgId,
|
|
2324
|
+
_rawMessage: hasMedia || !!replyToMsgId ? msg : void 0
|
|
2260
2325
|
};
|
|
2261
2326
|
}
|
|
2262
2327
|
getPeer(chatId) {
|
|
2263
2328
|
return this.peerCache.get(chatId);
|
|
2264
2329
|
}
|
|
2330
|
+
async fetchReplyContext(rawMsg) {
|
|
2331
|
+
try {
|
|
2332
|
+
const replyMsg = await Promise.race([
|
|
2333
|
+
rawMsg.getReplyMessage(),
|
|
2334
|
+
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 5e3))
|
|
2335
|
+
]);
|
|
2336
|
+
if (!replyMsg) return void 0;
|
|
2337
|
+
let senderName;
|
|
2338
|
+
try {
|
|
2339
|
+
const sender = await Promise.race([
|
|
2340
|
+
replyMsg.getSender(),
|
|
2341
|
+
new Promise((resolve2) => setTimeout(() => resolve2(void 0), 5e3))
|
|
2342
|
+
]);
|
|
2343
|
+
if (sender && "firstName" in sender) {
|
|
2344
|
+
senderName = sender.firstName ?? void 0;
|
|
2345
|
+
}
|
|
2346
|
+
if (sender && "username" in sender && !senderName) {
|
|
2347
|
+
senderName = sender.username ?? void 0;
|
|
2348
|
+
}
|
|
2349
|
+
} catch {
|
|
2350
|
+
}
|
|
2351
|
+
const replyMsgSenderId = replyMsg.senderId ? BigInt(replyMsg.senderId.toString()) : void 0;
|
|
2352
|
+
const isAgent = this.ownUserId !== void 0 && replyMsgSenderId === this.ownUserId;
|
|
2353
|
+
return {
|
|
2354
|
+
text: replyMsg.message || void 0,
|
|
2355
|
+
senderName,
|
|
2356
|
+
isAgent
|
|
2357
|
+
};
|
|
2358
|
+
} catch {
|
|
2359
|
+
return void 0;
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2265
2362
|
getClient() {
|
|
2266
2363
|
return this.client;
|
|
2267
2364
|
}
|
|
@@ -2637,6 +2734,13 @@ var MessageHandler = class {
|
|
|
2637
2734
|
if (message.isGroup) {
|
|
2638
2735
|
pendingContext = this.pendingHistory.getAndClearPending(message.chatId);
|
|
2639
2736
|
}
|
|
2737
|
+
let replyContext;
|
|
2738
|
+
if (message.replyToId && message._rawMessage) {
|
|
2739
|
+
const raw = await this.bridge.fetchReplyContext(message._rawMessage);
|
|
2740
|
+
if (raw?.text) {
|
|
2741
|
+
replyContext = { text: raw.text, senderName: raw.senderName, isAgent: raw.isAgent };
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2640
2744
|
const toolContext = {
|
|
2641
2745
|
bridge: this.bridge,
|
|
2642
2746
|
db: this.db,
|
|
@@ -2655,7 +2759,8 @@ var MessageHandler = class {
|
|
|
2655
2759
|
message.senderUsername,
|
|
2656
2760
|
message.hasMedia,
|
|
2657
2761
|
message.mediaType,
|
|
2658
|
-
message.id
|
|
2762
|
+
message.id,
|
|
2763
|
+
replyContext
|
|
2659
2764
|
);
|
|
2660
2765
|
const hasToolCalls = response.toolCalls && response.toolCalls.length > 0;
|
|
2661
2766
|
const telegramSendCalled = hasToolCalls && response.toolCalls?.some((tc) => TELEGRAM_SEND_TOOLS.has(tc.name));
|
|
@@ -2719,7 +2824,7 @@ var MessageHandler = class {
|
|
|
2719
2824
|
chatId: message.chatId,
|
|
2720
2825
|
senderId: message.senderId?.toString() ?? null,
|
|
2721
2826
|
text: message.text,
|
|
2722
|
-
replyToId:
|
|
2827
|
+
replyToId: message.replyToId?.toString(),
|
|
2723
2828
|
isFromAgent,
|
|
2724
2829
|
hasMedia: message.hasMedia,
|
|
2725
2830
|
mediaType: message.mediaType,
|
|
@@ -3847,7 +3952,7 @@ import { Type } from "@sinclair/typebox";
|
|
|
3847
3952
|
var log14 = createLogger("Tools");
|
|
3848
3953
|
var telegramSendMessageTool = {
|
|
3849
3954
|
name: "telegram_send_message",
|
|
3850
|
-
description: "Send a text message to a Telegram chat.
|
|
3955
|
+
description: "Send a text message to a Telegram chat. For custom keyboards use telegram_reply_keyboard; for media use telegram_send_photo/gif/sticker.",
|
|
3851
3956
|
parameters: Type.Object({
|
|
3852
3957
|
chatId: Type.String({
|
|
3853
3958
|
description: "The chat ID to send the message to"
|
|
@@ -3892,7 +3997,7 @@ import { Type as Type2 } from "@sinclair/typebox";
|
|
|
3892
3997
|
var log15 = createLogger("Tools");
|
|
3893
3998
|
var telegramEditMessageTool = {
|
|
3894
3999
|
name: "telegram_edit_message",
|
|
3895
|
-
description: "Edit a previously sent message
|
|
4000
|
+
description: "Edit a previously sent message. Only your own messages can be edited, within 48h.",
|
|
3896
4001
|
parameters: Type2.Object({
|
|
3897
4002
|
chatId: Type2.String({
|
|
3898
4003
|
description: "The chat ID where the message was sent"
|
|
@@ -3940,7 +4045,7 @@ import { Api as Api3 } from "telegram";
|
|
|
3940
4045
|
var log16 = createLogger("Tools");
|
|
3941
4046
|
var telegramDeleteMessageTool = {
|
|
3942
4047
|
name: "telegram_delete_message",
|
|
3943
|
-
description: "Delete
|
|
4048
|
+
description: "Delete messages from a chat. Own messages in any chat, or any message with admin rights. Deletion is permanent.",
|
|
3944
4049
|
parameters: Type3.Object({
|
|
3945
4050
|
chatId: Type3.String({
|
|
3946
4051
|
description: "The chat ID where the messages are located"
|
|
@@ -4005,7 +4110,7 @@ import { Api as Api4 } from "telegram";
|
|
|
4005
4110
|
var log17 = createLogger("Tools");
|
|
4006
4111
|
var telegramForwardMessageTool = {
|
|
4007
4112
|
name: "telegram_forward_message",
|
|
4008
|
-
description: "Forward one or more messages from one chat to another.
|
|
4113
|
+
description: "Forward one or more messages from one chat to another. Shows original sender attribution.",
|
|
4009
4114
|
parameters: Type4.Object({
|
|
4010
4115
|
fromChatId: Type4.String({
|
|
4011
4116
|
description: "The chat ID where the original message(s) are located"
|
|
@@ -4065,7 +4170,7 @@ import { Api as Api5 } from "telegram";
|
|
|
4065
4170
|
var log18 = createLogger("Tools");
|
|
4066
4171
|
var telegramScheduleMessageTool = {
|
|
4067
4172
|
name: "telegram_schedule_message",
|
|
4068
|
-
description: "Schedule a message to be sent at a
|
|
4173
|
+
description: "Schedule a message to be sent at a future time. scheduleDate must be in the future.",
|
|
4069
4174
|
parameters: Type5.Object({
|
|
4070
4175
|
chatId: Type5.String({
|
|
4071
4176
|
description: "The chat ID to send the scheduled message to"
|
|
@@ -4138,7 +4243,7 @@ import { Api as Api6 } from "telegram";
|
|
|
4138
4243
|
var log19 = createLogger("Tools");
|
|
4139
4244
|
var telegramSearchMessagesTool = {
|
|
4140
4245
|
name: "telegram_search_messages",
|
|
4141
|
-
description: "Search for messages in a
|
|
4246
|
+
description: "Search for messages in a chat by text query. Returns matching messages with content and metadata.",
|
|
4142
4247
|
category: "data-bearing",
|
|
4143
4248
|
parameters: Type6.Object({
|
|
4144
4249
|
chatId: Type6.String({
|
|
@@ -4331,7 +4436,7 @@ import { Api as Api8, helpers } from "telegram";
|
|
|
4331
4436
|
var log21 = createLogger("Tools");
|
|
4332
4437
|
var telegramQuoteReplyTool = {
|
|
4333
4438
|
name: "telegram_quote_reply",
|
|
4334
|
-
description: "Reply to a message while quoting a specific part of it.
|
|
4439
|
+
description: "Reply to a message while quoting a specific part of it. quoteText must match the original exactly.",
|
|
4335
4440
|
parameters: Type8.Object({
|
|
4336
4441
|
chatId: Type8.String({
|
|
4337
4442
|
description: "The chat ID where the message is"
|
|
@@ -4406,7 +4511,7 @@ import { Api as Api9 } from "telegram";
|
|
|
4406
4511
|
var log22 = createLogger("Tools");
|
|
4407
4512
|
var telegramGetRepliesTool = {
|
|
4408
4513
|
name: "telegram_get_replies",
|
|
4409
|
-
description: "Get all replies to a specific message (
|
|
4514
|
+
description: "Get all replies to a specific message (thread/chain). Returns messages oldest-first.",
|
|
4410
4515
|
category: "data-bearing",
|
|
4411
4516
|
parameters: Type9.Object({
|
|
4412
4517
|
chatId: Type9.String({
|
|
@@ -4531,7 +4636,7 @@ import { Type as Type10 } from "@sinclair/typebox";
|
|
|
4531
4636
|
var log23 = createLogger("Tools");
|
|
4532
4637
|
var telegramSendPhotoTool = {
|
|
4533
4638
|
name: "telegram_send_photo",
|
|
4534
|
-
description: "Send a photo
|
|
4639
|
+
description: "Send a photo from a local file path to a Telegram chat. Supports JPG, PNG, WEBP.",
|
|
4535
4640
|
parameters: Type10.Object({
|
|
4536
4641
|
chatId: Type10.String({
|
|
4537
4642
|
description: "The chat ID to send the photo to"
|
|
@@ -4902,30 +5007,7 @@ async function generateElevenLabsTTS(text, voiceId) {
|
|
|
4902
5007
|
var log24 = createLogger("Tools");
|
|
4903
5008
|
var telegramSendVoiceTool = {
|
|
4904
5009
|
name: "telegram_send_voice",
|
|
4905
|
-
description:
|
|
4906
|
-
|
|
4907
|
-
**Two modes:**
|
|
4908
|
-
1. **File mode**: Provide \`voicePath\` to send an existing audio file
|
|
4909
|
-
2. **TTS mode**: Provide \`text\` to generate speech and send as voice note
|
|
4910
|
-
|
|
4911
|
-
**TTS Providers:**
|
|
4912
|
-
- \`piper\` (default): Offline neural TTS with Trump voice
|
|
4913
|
-
- \`edge\`: Free Microsoft Edge TTS - cloud, many voices
|
|
4914
|
-
- \`openai\`: OpenAI TTS API (requires OPENAI_API_KEY)
|
|
4915
|
-
- \`elevenlabs\`: ElevenLabs API (requires ELEVENLABS_API_KEY)
|
|
4916
|
-
|
|
4917
|
-
**Piper voices (default):**
|
|
4918
|
-
- \`trump\`: Trump voice (default, en-US)
|
|
4919
|
-
- \`dmitri\` / \`ru-ru\`: Russian male
|
|
4920
|
-
|
|
4921
|
-
**Edge voices (fallback):**
|
|
4922
|
-
- English: en-us-male, en-us-female, en-gb-male
|
|
4923
|
-
- Russian: ru-ru-male, ru-ru-female
|
|
4924
|
-
|
|
4925
|
-
**Examples:**
|
|
4926
|
-
- Default Trump voice: text="This is tremendous, believe me!"
|
|
4927
|
-
- Russian: text="\u041F\u0440\u0438\u0432\u0435\u0442!", voice="dmitri", ttsProvider="piper"
|
|
4928
|
-
- Edge fallback: text="Hello!", ttsProvider="edge"`,
|
|
5010
|
+
description: "Send a voice message. Either provide voicePath for an existing file, or text for TTS generation. Default TTS: piper (Trump voice). Available providers: piper, edge, openai, elevenlabs.",
|
|
4929
5011
|
parameters: Type11.Object({
|
|
4930
5012
|
chatId: Type11.String({
|
|
4931
5013
|
description: "The chat ID to send the voice message to"
|
|
@@ -5094,7 +5176,7 @@ import { Api as Api11 } from "telegram";
|
|
|
5094
5176
|
var log25 = createLogger("Tools");
|
|
5095
5177
|
var telegramSendStickerTool = {
|
|
5096
5178
|
name: "telegram_send_sticker",
|
|
5097
|
-
description: "Send a sticker
|
|
5179
|
+
description: "Send a sticker via stickerSetShortName+stickerIndex (from telegram_search_stickers) or a local WEBP/TGS file path.",
|
|
5098
5180
|
parameters: Type12.Object({
|
|
5099
5181
|
chatId: Type12.String({
|
|
5100
5182
|
description: "The chat ID to send the sticker to"
|
|
@@ -5218,7 +5300,7 @@ import { Api as Api12 } from "telegram";
|
|
|
5218
5300
|
var log26 = createLogger("Tools");
|
|
5219
5301
|
var telegramSendGifTool = {
|
|
5220
5302
|
name: "telegram_send_gif",
|
|
5221
|
-
description: "Send
|
|
5303
|
+
description: "Send a GIF via queryId+resultId (from telegram_search_gifs) or a local GIF/MP4 file path.",
|
|
5222
5304
|
parameters: Type13.Object({
|
|
5223
5305
|
chatId: Type13.String({
|
|
5224
5306
|
description: "The chat ID to send the GIF to"
|
|
@@ -5322,7 +5404,7 @@ import { extname } from "path";
|
|
|
5322
5404
|
var log27 = createLogger("Tools");
|
|
5323
5405
|
var telegramDownloadMediaTool = {
|
|
5324
5406
|
name: "telegram_download_media",
|
|
5325
|
-
description: "Download media
|
|
5407
|
+
description: "Download media from a Telegram message to ~/.teleton/downloads/. Returns the local file path.",
|
|
5326
5408
|
parameters: Type14.Object({
|
|
5327
5409
|
chatId: Type14.String({
|
|
5328
5410
|
description: "The chat ID where the message with media is located"
|
|
@@ -5469,7 +5551,7 @@ import { extname as extname2 } from "path";
|
|
|
5469
5551
|
var log28 = createLogger("Tools");
|
|
5470
5552
|
var visionAnalyzeTool = {
|
|
5471
5553
|
name: "vision_analyze",
|
|
5472
|
-
description: "Analyze an image using
|
|
5554
|
+
description: "Analyze an image using vision LLM. Provide chatId+messageId for Telegram images or filePath for local files.",
|
|
5473
5555
|
category: "data-bearing",
|
|
5474
5556
|
parameters: Type15.Object({
|
|
5475
5557
|
chatId: Type15.Optional(
|
|
@@ -5686,7 +5768,7 @@ import { Type as Type16 } from "@sinclair/typebox";
|
|
|
5686
5768
|
var log29 = createLogger("Tools");
|
|
5687
5769
|
var telegramGetDialogsTool = {
|
|
5688
5770
|
name: "telegram_get_dialogs",
|
|
5689
|
-
description: "
|
|
5771
|
+
description: "List all conversations (DMs, groups, channels) with unread counts. Use to find chat IDs and check inbox.",
|
|
5690
5772
|
category: "data-bearing",
|
|
5691
5773
|
parameters: Type16.Object({
|
|
5692
5774
|
limit: Type16.Optional(
|
|
@@ -5825,7 +5907,7 @@ import { Api as Api14 } from "telegram";
|
|
|
5825
5907
|
var log31 = createLogger("Tools");
|
|
5826
5908
|
var telegramGetChatInfoTool = {
|
|
5827
5909
|
name: "telegram_get_chat_info",
|
|
5828
|
-
description: "Get detailed
|
|
5910
|
+
description: "Get detailed info about a chat, group, channel, or user. Returns title, description, member count, and metadata.",
|
|
5829
5911
|
category: "data-bearing",
|
|
5830
5912
|
parameters: Type18.Object({
|
|
5831
5913
|
chatId: Type18.String({
|
|
@@ -5933,7 +6015,7 @@ import { Type as Type19 } from "@sinclair/typebox";
|
|
|
5933
6015
|
var log32 = createLogger("Tools");
|
|
5934
6016
|
var telegramMarkAsReadTool = {
|
|
5935
6017
|
name: "telegram_mark_as_read",
|
|
5936
|
-
description: "Mark messages as read in a
|
|
6018
|
+
description: "Mark messages as read in a chat. Can mark up to a specific message or clear all unread.",
|
|
5937
6019
|
parameters: Type19.Object({
|
|
5938
6020
|
chatId: Type19.String({
|
|
5939
6021
|
description: "The chat ID to mark as read"
|
|
@@ -6002,7 +6084,7 @@ function extractInviteHash(input) {
|
|
|
6002
6084
|
}
|
|
6003
6085
|
var telegramJoinChannelTool = {
|
|
6004
6086
|
name: "telegram_join_channel",
|
|
6005
|
-
description: "Join a
|
|
6087
|
+
description: "Join a channel or group. Accepts username, channel ID, or private invite link.",
|
|
6006
6088
|
parameters: Type20.Object({
|
|
6007
6089
|
channel: Type20.String({
|
|
6008
6090
|
description: "Channel username (with or without @), numeric channel ID, or invite link. Examples: '@mychannel', 'mychannel', '-1001234567890', 'https://t.me/+AbCdEf123'"
|
|
@@ -6136,7 +6218,7 @@ import { Api as Api16 } from "telegram";
|
|
|
6136
6218
|
var log34 = createLogger("Tools");
|
|
6137
6219
|
var telegramLeaveChannelTool = {
|
|
6138
6220
|
name: "telegram_leave_channel",
|
|
6139
|
-
description: "Leave a
|
|
6221
|
+
description: "Leave a channel or group you are a member of.",
|
|
6140
6222
|
parameters: Type21.Object({
|
|
6141
6223
|
channel: Type21.String({
|
|
6142
6224
|
description: "Channel username (with or without @) or numeric channel ID to leave. Examples: '@mychannel', 'mychannel', '-1001234567890'"
|
|
@@ -6204,7 +6286,7 @@ import { Api as Api17 } from "telegram";
|
|
|
6204
6286
|
var log35 = createLogger("Tools");
|
|
6205
6287
|
var telegramCreateChannelTool = {
|
|
6206
6288
|
name: "telegram_create_channel",
|
|
6207
|
-
description: "Create a new Telegram channel
|
|
6289
|
+
description: "Create a new Telegram channel (broadcast) or megagroup (chat). Set megagroup=true for group mode.",
|
|
6208
6290
|
parameters: Type22.Object({
|
|
6209
6291
|
title: Type22.String({
|
|
6210
6292
|
description: "Name of the channel/megagroup (max 128 characters)",
|
|
@@ -6260,19 +6342,7 @@ import { Api as Api18 } from "telegram";
|
|
|
6260
6342
|
var log36 = createLogger("Tools");
|
|
6261
6343
|
var telegramEditChannelInfoTool = {
|
|
6262
6344
|
name: "telegram_edit_channel_info",
|
|
6263
|
-
description:
|
|
6264
|
-
|
|
6265
|
-
USAGE:
|
|
6266
|
-
- Pass the channelId and any fields to update
|
|
6267
|
-
- You must be an admin with the appropriate rights
|
|
6268
|
-
|
|
6269
|
-
FIELDS:
|
|
6270
|
-
- title: Channel/group name (1-255 characters)
|
|
6271
|
-
- about: Description/bio (0-255 characters)
|
|
6272
|
-
|
|
6273
|
-
NOTE: To change the photo, use a separate photo upload tool.
|
|
6274
|
-
|
|
6275
|
-
Example: Update your channel @my_channel with a new description.`,
|
|
6345
|
+
description: "Edit a channel or group's title and/or description. Requires admin rights.",
|
|
6276
6346
|
parameters: Type23.Object({
|
|
6277
6347
|
channelId: Type23.String({
|
|
6278
6348
|
description: "Channel or group ID to edit"
|
|
@@ -6366,18 +6436,7 @@ import { Api as Api19 } from "telegram";
|
|
|
6366
6436
|
var log37 = createLogger("Tools");
|
|
6367
6437
|
var telegramInviteToChannelTool = {
|
|
6368
6438
|
name: "telegram_invite_to_channel",
|
|
6369
|
-
description:
|
|
6370
|
-
|
|
6371
|
-
USAGE:
|
|
6372
|
-
- Pass channelId and either userIds or usernames (or both)
|
|
6373
|
-
- You must be an admin with invite rights
|
|
6374
|
-
- Users must allow being added to groups (privacy settings)
|
|
6375
|
-
|
|
6376
|
-
LIMITS:
|
|
6377
|
-
- Can invite up to 200 users at once
|
|
6378
|
-
- Some users may have privacy settings preventing invites
|
|
6379
|
-
|
|
6380
|
-
For public channels, you can also share the invite link instead.`,
|
|
6439
|
+
description: "Invite users to a channel or group by userIds or usernames. Requires admin invite rights.",
|
|
6381
6440
|
parameters: Type24.Object({
|
|
6382
6441
|
channelId: Type24.String({
|
|
6383
6442
|
description: "Channel or group ID to invite users to"
|
|
@@ -6537,7 +6596,7 @@ import { Type as Type25 } from "@sinclair/typebox";
|
|
|
6537
6596
|
var log38 = createLogger("Tools");
|
|
6538
6597
|
var telegramGetMeTool = {
|
|
6539
6598
|
name: "telegram_get_me",
|
|
6540
|
-
description: "Get
|
|
6599
|
+
description: "Get your own Telegram account info (user ID, username, name, phone).",
|
|
6541
6600
|
category: "data-bearing",
|
|
6542
6601
|
parameters: Type25.Object({})
|
|
6543
6602
|
// No parameters needed
|
|
@@ -6576,7 +6635,7 @@ import { Api as Api20 } from "telegram";
|
|
|
6576
6635
|
var log39 = createLogger("Tools");
|
|
6577
6636
|
var telegramGetParticipantsTool = {
|
|
6578
6637
|
name: "telegram_get_participants",
|
|
6579
|
-
description: "Get
|
|
6638
|
+
description: "Get participants of a group or channel. Filterable by all, admins, banned, or bots.",
|
|
6580
6639
|
category: "data-bearing",
|
|
6581
6640
|
parameters: Type26.Object({
|
|
6582
6641
|
chatId: Type26.String({
|
|
@@ -6953,7 +7012,7 @@ import { readFileSync as readFileSync4 } from "fs";
|
|
|
6953
7012
|
var log42 = createLogger("Tools");
|
|
6954
7013
|
var telegramSetChatPhotoTool = {
|
|
6955
7014
|
name: "telegram_set_chat_photo",
|
|
6956
|
-
description: `Set or delete a group/channel profile photo.
|
|
7015
|
+
description: `Set or delete a group/channel profile photo. Requires admin rights with change-info permission.`,
|
|
6957
7016
|
parameters: Type29.Object({
|
|
6958
7017
|
chat_id: Type29.String({
|
|
6959
7018
|
description: "Group/channel ID or username"
|
|
@@ -7098,7 +7157,7 @@ import { Api as Api24 } from "telegram";
|
|
|
7098
7157
|
var log43 = createLogger("Tools");
|
|
7099
7158
|
var telegramCreatePollTool = {
|
|
7100
7159
|
name: "telegram_create_poll",
|
|
7101
|
-
description: "Create a poll in a
|
|
7160
|
+
description: "Create a poll in a chat. For quizzes with a correct answer, use telegram_create_quiz instead.",
|
|
7102
7161
|
parameters: Type30.Object({
|
|
7103
7162
|
chatId: Type30.String({
|
|
7104
7163
|
description: "The chat ID where the poll will be created"
|
|
@@ -7211,7 +7270,7 @@ import { Api as Api25 } from "telegram";
|
|
|
7211
7270
|
var log44 = createLogger("Tools");
|
|
7212
7271
|
var telegramCreateQuizTool = {
|
|
7213
7272
|
name: "telegram_create_quiz",
|
|
7214
|
-
description: "Create a quiz (poll with
|
|
7273
|
+
description: "Create a quiz (poll with one correct answer revealed on vote). For opinion polls, use telegram_create_poll.",
|
|
7215
7274
|
parameters: Type31.Object({
|
|
7216
7275
|
chatId: Type31.String({
|
|
7217
7276
|
description: "The chat ID where the quiz will be created"
|
|
@@ -7324,7 +7383,7 @@ import { Api as Api26 } from "telegram";
|
|
|
7324
7383
|
var log45 = createLogger("Tools");
|
|
7325
7384
|
var telegramReplyKeyboardTool = {
|
|
7326
7385
|
name: "telegram_reply_keyboard",
|
|
7327
|
-
description: "Send a message with a custom reply keyboard
|
|
7386
|
+
description: "Send a message with a custom reply keyboard. Buttons are arranged in rows; each button sends its label as a message.",
|
|
7328
7387
|
parameters: Type32.Object({
|
|
7329
7388
|
chatId: Type32.String({
|
|
7330
7389
|
description: "The chat ID to send the message with keyboard to"
|
|
@@ -7414,7 +7473,7 @@ import { Type as Type33 } from "@sinclair/typebox";
|
|
|
7414
7473
|
var log46 = createLogger("Tools");
|
|
7415
7474
|
var telegramReactTool = {
|
|
7416
7475
|
name: "telegram_react",
|
|
7417
|
-
description: "Add an emoji reaction to a
|
|
7476
|
+
description: "Add an emoji reaction to a message.",
|
|
7418
7477
|
parameters: Type33.Object({
|
|
7419
7478
|
chatId: Type33.String({
|
|
7420
7479
|
description: "The chat ID where the message is located"
|
|
@@ -7454,17 +7513,7 @@ import { Api as Api27 } from "telegram";
|
|
|
7454
7513
|
var log47 = createLogger("Tools");
|
|
7455
7514
|
var telegramSendDiceTool = {
|
|
7456
7515
|
name: "telegram_send_dice",
|
|
7457
|
-
description: `Send an animated dice/game message.
|
|
7458
|
-
|
|
7459
|
-
Available games:
|
|
7460
|
-
- \u{1F3B2} Dice (1-6)
|
|
7461
|
-
- \u{1F3AF} Darts (1-6, 6 = bullseye)
|
|
7462
|
-
- \u{1F3C0} Basketball (1-5, 4-5 = score)
|
|
7463
|
-
- \u26BD Football (1-5, 4-5 = goal)
|
|
7464
|
-
- \u{1F3B0} Slot machine (1-64, 64 = jackpot 777)
|
|
7465
|
-
- \u{1F3B3} Bowling (1-6, 6 = strike)
|
|
7466
|
-
|
|
7467
|
-
Use for games, decisions, or fun interactions.`,
|
|
7516
|
+
description: `Send an animated dice/game message. Result is random, determined by Telegram servers.`,
|
|
7468
7517
|
parameters: Type34.Object({
|
|
7469
7518
|
chat_id: Type34.String({
|
|
7470
7519
|
description: "Chat ID or username to send the dice to"
|
|
@@ -7567,7 +7616,7 @@ import { Api as Api28 } from "telegram";
|
|
|
7567
7616
|
var log48 = createLogger("Tools");
|
|
7568
7617
|
var telegramSearchStickersTool = {
|
|
7569
7618
|
name: "telegram_search_stickers",
|
|
7570
|
-
description: "Search
|
|
7619
|
+
description: "Search sticker packs globally by keyword or emoji. Returns packs with shortName, count, and install status. For installed-only, use telegram_get_my_stickers.",
|
|
7571
7620
|
parameters: Type35.Object({
|
|
7572
7621
|
query: Type35.String({
|
|
7573
7622
|
description: "Search query (sticker pack name, emoji, or keywords). Example: 'pepe', '\u{1F600}', 'cat'"
|
|
@@ -7627,7 +7676,7 @@ import { Api as Api29 } from "telegram";
|
|
|
7627
7676
|
var log49 = createLogger("Tools");
|
|
7628
7677
|
var telegramSearchGifsTool = {
|
|
7629
7678
|
name: "telegram_search_gifs",
|
|
7630
|
-
description: "Search for
|
|
7679
|
+
description: "Search for GIFs via @gif bot. Returns queryId + result IDs needed by telegram_send_gif.",
|
|
7631
7680
|
parameters: Type36.Object({
|
|
7632
7681
|
query: Type36.String({
|
|
7633
7682
|
description: "Search query for GIFs. Example: 'happy', 'dancing', 'thumbs up', 'laughing'"
|
|
@@ -7683,7 +7732,7 @@ import { Api as Api30 } from "telegram";
|
|
|
7683
7732
|
var log50 = createLogger("Tools");
|
|
7684
7733
|
var telegramGetMyStickersTool = {
|
|
7685
7734
|
name: "telegram_get_my_stickers",
|
|
7686
|
-
description: "List all sticker packs
|
|
7735
|
+
description: "List all sticker packs installed on your account. Returns shortName, title, and count per pack.",
|
|
7687
7736
|
category: "data-bearing",
|
|
7688
7737
|
parameters: Type37.Object({
|
|
7689
7738
|
limit: Type37.Optional(
|
|
@@ -7748,7 +7797,7 @@ import { Api as Api31 } from "telegram";
|
|
|
7748
7797
|
var log51 = createLogger("Tools");
|
|
7749
7798
|
var telegramAddStickerSetTool = {
|
|
7750
7799
|
name: "telegram_add_sticker_set",
|
|
7751
|
-
description: "
|
|
7800
|
+
description: "Install a sticker pack to your account by its short name.",
|
|
7752
7801
|
parameters: Type38.Object({
|
|
7753
7802
|
shortName: Type38.String({
|
|
7754
7803
|
description: "Short name of the sticker pack (e.g., 'Animals' from t.me/addstickers/Animals). Obtainable from telegram_search_stickers results."
|
|
@@ -7806,7 +7855,7 @@ import { Api as Api32 } from "telegram";
|
|
|
7806
7855
|
var log52 = createLogger("Tools");
|
|
7807
7856
|
var telegramGetFoldersTool = {
|
|
7808
7857
|
name: "telegram_get_folders",
|
|
7809
|
-
description: "List all your chat folders
|
|
7858
|
+
description: "List all your chat folders with IDs, names, and included chat types.",
|
|
7810
7859
|
category: "data-bearing",
|
|
7811
7860
|
parameters: Type39.Object({})
|
|
7812
7861
|
// No parameters needed
|
|
@@ -7856,7 +7905,7 @@ import { Api as Api33 } from "telegram";
|
|
|
7856
7905
|
var log53 = createLogger("Tools");
|
|
7857
7906
|
var telegramCreateFolderTool = {
|
|
7858
7907
|
name: "telegram_create_folder",
|
|
7859
|
-
description: "Create a new chat folder
|
|
7908
|
+
description: "Create a new chat folder. Can auto-include chat types or add specific chats later with telegram_add_chat_to_folder.",
|
|
7860
7909
|
parameters: Type40.Object({
|
|
7861
7910
|
title: Type40.String({
|
|
7862
7911
|
description: "Name of the folder (e.g., 'Work', 'Family', 'Projects'). Max 12 characters.",
|
|
@@ -7958,7 +8007,7 @@ import { Api as Api34 } from "telegram";
|
|
|
7958
8007
|
var log54 = createLogger("Tools");
|
|
7959
8008
|
var telegramAddChatToFolderTool = {
|
|
7960
8009
|
name: "telegram_add_chat_to_folder",
|
|
7961
|
-
description: "Add a
|
|
8010
|
+
description: "Add a chat to an existing folder. Use telegram_get_folders first to get folder IDs.",
|
|
7962
8011
|
parameters: Type41.Object({
|
|
7963
8012
|
folderId: Type41.Number({
|
|
7964
8013
|
description: "ID of the folder to add the chat to (obtainable from telegram_get_folders). Must be an existing folder."
|
|
@@ -8028,7 +8077,7 @@ import { Api as Api35 } from "telegram";
|
|
|
8028
8077
|
var log55 = createLogger("Tools");
|
|
8029
8078
|
var telegramUpdateProfileTool = {
|
|
8030
8079
|
name: "telegram_update_profile",
|
|
8031
|
-
description: "Update your
|
|
8080
|
+
description: "Update your profile (first name, last name, bio). Omit fields to keep current values.",
|
|
8032
8081
|
parameters: Type42.Object({
|
|
8033
8082
|
firstName: Type42.Optional(
|
|
8034
8083
|
Type42.String({
|
|
@@ -8102,7 +8151,7 @@ import { Api as Api36 } from "telegram";
|
|
|
8102
8151
|
var log56 = createLogger("Tools");
|
|
8103
8152
|
var telegramSetBioTool = {
|
|
8104
8153
|
name: "telegram_set_bio",
|
|
8105
|
-
description: "Set or update your Telegram bio (
|
|
8154
|
+
description: "Set or update your Telegram bio (About section). Max 70 chars. Empty string to remove.",
|
|
8106
8155
|
parameters: Type43.Object({
|
|
8107
8156
|
bio: Type43.String({
|
|
8108
8157
|
description: "Your new bio text (max 70 characters). Examples: 'Software Engineer \u{1F680}', 'Crypto enthusiast', 'Building cool stuff'. Empty string to remove bio.",
|
|
@@ -8141,7 +8190,7 @@ import { Api as Api37 } from "telegram";
|
|
|
8141
8190
|
var log57 = createLogger("Tools");
|
|
8142
8191
|
var telegramSetUsernameTool = {
|
|
8143
8192
|
name: "telegram_set_username",
|
|
8144
|
-
description: "Set or change your Telegram username
|
|
8193
|
+
description: "Set or change your Telegram @username. Must be 5-32 chars, alphanumeric + underscores. Empty string removes it. Warning: breaks existing t.me/ links.",
|
|
8145
8194
|
parameters: Type44.Object({
|
|
8146
8195
|
username: Type44.String({
|
|
8147
8196
|
description: "New username (5-32 chars, letters/numbers/underscores only, no @ symbol). Example: 'cool_user_123'. Empty string '' to remove username.",
|
|
@@ -8209,7 +8258,7 @@ import { Api as Api38 } from "telegram";
|
|
|
8209
8258
|
var log58 = createLogger("Tools");
|
|
8210
8259
|
var telegramGetStarsBalanceTool = {
|
|
8211
8260
|
name: "telegram_get_stars_balance",
|
|
8212
|
-
description: "Get your current Telegram Stars balance.
|
|
8261
|
+
description: "Get your current Telegram Stars balance.",
|
|
8213
8262
|
category: "data-bearing",
|
|
8214
8263
|
parameters: Type45.Object({})
|
|
8215
8264
|
};
|
|
@@ -8246,7 +8295,7 @@ import { Api as Api39 } from "telegram";
|
|
|
8246
8295
|
var log59 = createLogger("Tools");
|
|
8247
8296
|
var telegramGetStarsTransactionsTool = {
|
|
8248
8297
|
name: "telegram_get_stars_transactions",
|
|
8249
|
-
description: "Get your
|
|
8298
|
+
description: "Get your Stars transaction history. Filterable by inbound/outbound.",
|
|
8250
8299
|
category: "data-bearing",
|
|
8251
8300
|
parameters: Type46.Object({
|
|
8252
8301
|
limit: Type46.Optional(
|
|
@@ -8328,7 +8377,7 @@ import { Api as Api40 } from "telegram";
|
|
|
8328
8377
|
var log60 = createLogger("Tools");
|
|
8329
8378
|
var telegramGetAvailableGiftsTool = {
|
|
8330
8379
|
name: "telegram_get_available_gifts",
|
|
8331
|
-
description: "Get
|
|
8380
|
+
description: "Get Star Gifts available for purchase. Filterable by limited/unlimited. Use gift ID with telegram_send_gift.",
|
|
8332
8381
|
category: "data-bearing",
|
|
8333
8382
|
parameters: Type47.Object({
|
|
8334
8383
|
filter: Type47.Optional(
|
|
@@ -8980,7 +9029,7 @@ var GramJSBotClient = class {
|
|
|
8980
9029
|
};
|
|
8981
9030
|
|
|
8982
9031
|
// src/ton/payment-verifier.ts
|
|
8983
|
-
import {
|
|
9032
|
+
import { fromNano } from "@ton/ton";
|
|
8984
9033
|
import { Address } from "@ton/core";
|
|
8985
9034
|
var log62 = createLogger("TON");
|
|
8986
9035
|
var DEFAULT_MAX_PAYMENT_AGE_MINUTES = 10;
|
|
@@ -9015,8 +9064,7 @@ async function verifyPayment(db2, params) {
|
|
|
9015
9064
|
userId,
|
|
9016
9065
|
maxPaymentAgeMinutes = DEFAULT_MAX_PAYMENT_AGE_MINUTES
|
|
9017
9066
|
} = params;
|
|
9018
|
-
const
|
|
9019
|
-
const client = new TonClient({ endpoint });
|
|
9067
|
+
const client = await getCachedTonClient();
|
|
9020
9068
|
const botAddress = Address.parse(botWalletAddress);
|
|
9021
9069
|
const transactions = await withBlockchainRetry(
|
|
9022
9070
|
() => client.getTransactions(botAddress, { limit: 20 }),
|
|
@@ -9309,13 +9357,7 @@ async function executeDeal(dealId, db2, bridge) {
|
|
|
9309
9357
|
comment: `Deal #${dealId} - ${formatAsset2(deal.agent_gives_type, deal.agent_gives_ton_amount, deal.agent_gives_gift_slug)}`
|
|
9310
9358
|
});
|
|
9311
9359
|
if (!txHash) {
|
|
9312
|
-
|
|
9313
|
-
`UPDATE deals SET agent_sent_at = NULL, status = 'failed', notes = 'TON transfer returned no tx hash' WHERE id = ?`
|
|
9314
|
-
).run(dealId);
|
|
9315
|
-
return {
|
|
9316
|
-
success: false,
|
|
9317
|
-
error: "TON transfer failed (no tx hash returned)"
|
|
9318
|
-
};
|
|
9360
|
+
throw new Error("TON transfer failed (wallet not initialized or invalid parameters)");
|
|
9319
9361
|
}
|
|
9320
9362
|
db2.prepare(
|
|
9321
9363
|
`UPDATE deals SET
|
|
@@ -9622,7 +9664,7 @@ var VerificationPoller = class {
|
|
|
9622
9664
|
const me = this.bridge.getClient().getMe();
|
|
9623
9665
|
if (!me) return { verified: false };
|
|
9624
9666
|
const botUserId = Number(me.id);
|
|
9625
|
-
const { telegramGetMyGiftsExecutor: telegramGetMyGiftsExecutor2 } = await import("./get-my-gifts-
|
|
9667
|
+
const { telegramGetMyGiftsExecutor: telegramGetMyGiftsExecutor2 } = await import("./get-my-gifts-TPVUGUWT.js");
|
|
9626
9668
|
const toolContext = {
|
|
9627
9669
|
bridge: this.bridge,
|
|
9628
9670
|
db: this.db,
|
|
@@ -10305,28 +10347,7 @@ function formatStrategyCheckJSON(check) {
|
|
|
10305
10347
|
var log66 = createLogger("Tools");
|
|
10306
10348
|
var dealProposeTool = {
|
|
10307
10349
|
name: "deal_propose",
|
|
10308
|
-
description:
|
|
10309
|
-
|
|
10310
|
-
Automatically sends an inline bot message with buttons in the chat.
|
|
10311
|
-
The user can Accept or Decline directly from the message.
|
|
10312
|
-
|
|
10313
|
-
IMPORTANT - MESSAGE FLOW:
|
|
10314
|
-
- Send your message BEFORE calling this tool (e.g. "I'll create a deal for you")
|
|
10315
|
-
- Do NOT send any message after this tool returns \u2014 the deal card already contains all info
|
|
10316
|
-
- The inline bot message IS the proposal, no need to repeat deal details
|
|
10317
|
-
|
|
10318
|
-
CRITICAL - STRATEGY.md ENFORCEMENT:
|
|
10319
|
-
- When BUYING (you buy their gift): Pay max 80% of floor price
|
|
10320
|
-
- When SELLING (you sell your gift): Charge min 115% of floor price
|
|
10321
|
-
- Gift swaps: Must receive equal or more value
|
|
10322
|
-
- User ALWAYS sends first (TON or gift)
|
|
10323
|
-
|
|
10324
|
-
BEFORE proposing:
|
|
10325
|
-
1. Check gift floor price if market plugin is available
|
|
10326
|
-
2. Calculate values in TON
|
|
10327
|
-
3. This tool will REJECT deals that violate strategy
|
|
10328
|
-
|
|
10329
|
-
Deal expires in 2 minutes if not accepted.`,
|
|
10350
|
+
description: "Create a trade deal with Accept/Decline buttons. Sends an inline bot message \u2014 do NOT send another message after. Strategy compliance is enforced automatically (will reject bad deals). User always sends first. Expires in 2 minutes.",
|
|
10330
10351
|
parameters: Type48.Object({
|
|
10331
10352
|
chatId: Type48.String({ description: "Chat ID where to send proposal" }),
|
|
10332
10353
|
userId: Type48.Number({ description: "Telegram user ID" }),
|
|
@@ -10570,15 +10591,7 @@ var GiftDetector = class {
|
|
|
10570
10591
|
var log68 = createLogger("Tools");
|
|
10571
10592
|
var dealVerifyPaymentTool = {
|
|
10572
10593
|
name: "deal_verify_payment",
|
|
10573
|
-
description:
|
|
10574
|
-
|
|
10575
|
-
For TON payments: Checks blockchain for transaction with memo = dealId
|
|
10576
|
-
For gift transfers: Polls telegram_get_my_gifts for newly received gift
|
|
10577
|
-
|
|
10578
|
-
Updates deal status to 'verified' if successful.
|
|
10579
|
-
Auto-triggers executor after verification.
|
|
10580
|
-
|
|
10581
|
-
IMPORTANT: Only call this for deals with status = 'accepted'.`,
|
|
10594
|
+
description: "Verify payment/gift for an accepted deal. Checks blockchain (TON) or gift inbox. Auto-executes on success. Only for status='accepted'.",
|
|
10582
10595
|
parameters: Type49.Object({
|
|
10583
10596
|
dealId: Type49.String({ description: "Deal ID to verify payment for" })
|
|
10584
10597
|
})
|
|
@@ -10755,15 +10768,7 @@ import { Type as Type50 } from "@sinclair/typebox";
|
|
|
10755
10768
|
var log69 = createLogger("Tools");
|
|
10756
10769
|
var dealStatusTool = {
|
|
10757
10770
|
name: "deal_status",
|
|
10758
|
-
description:
|
|
10759
|
-
|
|
10760
|
-
Shows:
|
|
10761
|
-
- Deal parties (user, agent)
|
|
10762
|
-
- What each side gives/receives
|
|
10763
|
-
- Current status (proposed, accepted, verified, completed, etc.)
|
|
10764
|
-
- Timestamps (created, expires, verified, completed)
|
|
10765
|
-
- Payment/transfer tracking info (TX hashes, msgIds)
|
|
10766
|
-
- Profit calculation`,
|
|
10771
|
+
description: "Get full details of a deal by ID: status, parties, assets, payment tracking, profit.",
|
|
10767
10772
|
category: "data-bearing",
|
|
10768
10773
|
parameters: Type50.Object({
|
|
10769
10774
|
dealId: Type50.String({ description: "Deal ID to check status for" })
|
|
@@ -10889,14 +10894,7 @@ import { Type as Type51 } from "@sinclair/typebox";
|
|
|
10889
10894
|
var log70 = createLogger("Tools");
|
|
10890
10895
|
var dealListTool = {
|
|
10891
10896
|
name: "deal_list",
|
|
10892
|
-
description:
|
|
10893
|
-
|
|
10894
|
-
Filters:
|
|
10895
|
-
- status: Filter by status (proposed, accepted, verified, completed, declined, expired, cancelled, failed)
|
|
10896
|
-
- userId: Filter by user's Telegram ID
|
|
10897
|
-
- limit: Max results (default 20)
|
|
10898
|
-
|
|
10899
|
-
Returns summary of each deal with ID, status, parties, trade details, timestamps.`,
|
|
10897
|
+
description: "List recent deals. Filter by status or user. Non-admins see only their own deals.",
|
|
10900
10898
|
category: "data-bearing",
|
|
10901
10899
|
parameters: Type51.Object({
|
|
10902
10900
|
status: Type51.Optional(
|
|
@@ -11013,19 +11011,7 @@ import { Type as Type52 } from "@sinclair/typebox";
|
|
|
11013
11011
|
var log71 = createLogger("Tools");
|
|
11014
11012
|
var dealCancelTool = {
|
|
11015
11013
|
name: "deal_cancel",
|
|
11016
|
-
description:
|
|
11017
|
-
|
|
11018
|
-
IMPORTANT: Cannot cancel deals that are:
|
|
11019
|
-
- Already verified (payment received)
|
|
11020
|
-
- Already completed
|
|
11021
|
-
- Already declined, expired, or failed
|
|
11022
|
-
|
|
11023
|
-
Use this when:
|
|
11024
|
-
- User explicitly asks to cancel
|
|
11025
|
-
- Deal terms change before verification
|
|
11026
|
-
- External circumstances make deal impossible
|
|
11027
|
-
|
|
11028
|
-
The deal status will be set to 'cancelled' and cannot be resumed.`,
|
|
11014
|
+
description: "Cancel a deal. Only works for 'proposed' or 'accepted' status. Irreversible.",
|
|
11029
11015
|
parameters: Type52.Object({
|
|
11030
11016
|
dealId: Type52.String({ description: "Deal ID to cancel" }),
|
|
11031
11017
|
reason: Type52.Optional(Type52.String({ description: "Reason for cancellation (optional)" }))
|
|
@@ -11202,7 +11188,7 @@ function hasVerifiedDeal(giftId, userId) {
|
|
|
11202
11188
|
var log73 = createLogger("Tools");
|
|
11203
11189
|
var telegramSendGiftTool = {
|
|
11204
11190
|
name: "telegram_send_gift",
|
|
11205
|
-
description: "Send a Star Gift to
|
|
11191
|
+
description: "Send a Star Gift to a user. Costs Stars. Requires a verified deal (use deal_propose first).",
|
|
11206
11192
|
parameters: Type53.Object({
|
|
11207
11193
|
userId: Type53.String({
|
|
11208
11194
|
description: "User ID or @username to send the gift to"
|
|
@@ -11288,13 +11274,7 @@ import { Api as Api46 } from "telegram";
|
|
|
11288
11274
|
var log74 = createLogger("Tools");
|
|
11289
11275
|
var telegramTransferCollectibleTool = {
|
|
11290
11276
|
name: "telegram_transfer_collectible",
|
|
11291
|
-
description:
|
|
11292
|
-
|
|
11293
|
-
IMPORTANT: Some collectibles require a Star fee to transfer (shown as transferStars in telegram_get_my_gifts).
|
|
11294
|
-
- If transferStars is null/0: Transfer is FREE
|
|
11295
|
-
- If transferStars has a value: That amount of Stars will be deducted from your balance
|
|
11296
|
-
|
|
11297
|
-
Use telegram_get_my_gifts to find your collectibles and their msgId.`,
|
|
11277
|
+
description: "Transfer a collectible gift to another user. Requires verified deal. May cost Stars (see transferStars in telegram_get_my_gifts). Collectibles only.",
|
|
11298
11278
|
parameters: Type54.Object({
|
|
11299
11279
|
msgId: Type54.Number({
|
|
11300
11280
|
description: "The msgId of the collectible gift to transfer (from telegram_get_my_gifts). This is the message ID where the gift was received."
|
|
@@ -11406,7 +11386,7 @@ import { Api as Api47 } from "telegram";
|
|
|
11406
11386
|
var log75 = createLogger("Tools");
|
|
11407
11387
|
var telegramSetCollectiblePriceTool = {
|
|
11408
11388
|
name: "telegram_set_collectible_price",
|
|
11409
|
-
description: "List
|
|
11389
|
+
description: "List/unlist a collectible for sale. Set price in Stars to list, omit or 0 to unlist. Collectibles only.",
|
|
11410
11390
|
parameters: Type55.Object({
|
|
11411
11391
|
odayId: Type55.String({
|
|
11412
11392
|
description: "The odayId of the collectible to list/unlist (from telegram_get_my_gifts)"
|
|
@@ -11468,7 +11448,7 @@ import { Api as Api48 } from "telegram";
|
|
|
11468
11448
|
var log76 = createLogger("Tools");
|
|
11469
11449
|
var telegramGetResaleGiftsTool = {
|
|
11470
11450
|
name: "telegram_get_resale_gifts",
|
|
11471
|
-
description: "Browse
|
|
11451
|
+
description: "Browse collectible gifts listed for resale. Filterable by gift type. Use telegram_buy_resale_gift to purchase.",
|
|
11472
11452
|
category: "data-bearing",
|
|
11473
11453
|
parameters: Type56.Object({
|
|
11474
11454
|
giftId: Type56.Optional(
|
|
@@ -11550,7 +11530,7 @@ import { Api as Api49 } from "telegram";
|
|
|
11550
11530
|
var log77 = createLogger("Tools");
|
|
11551
11531
|
var telegramBuyResaleGiftTool = {
|
|
11552
11532
|
name: "telegram_buy_resale_gift",
|
|
11553
|
-
description: "
|
|
11533
|
+
description: "Buy a collectible from the resale marketplace using Stars. Get odayId from telegram_get_resale_gifts.",
|
|
11554
11534
|
parameters: Type57.Object({
|
|
11555
11535
|
odayId: Type57.String({
|
|
11556
11536
|
description: "The odayId of the listing to purchase (from telegram_get_resale_gifts)"
|
|
@@ -11621,18 +11601,7 @@ import { Api as Api50 } from "telegram";
|
|
|
11621
11601
|
var log78 = createLogger("Tools");
|
|
11622
11602
|
var telegramSetGiftStatusTool = {
|
|
11623
11603
|
name: "telegram_set_gift_status",
|
|
11624
|
-
description:
|
|
11625
|
-
|
|
11626
|
-
USAGE:
|
|
11627
|
-
- Set status: telegram_set_gift_status({ collectibleId: "123456789" })
|
|
11628
|
-
- Clear status: telegram_set_gift_status({ clear: true })
|
|
11629
|
-
|
|
11630
|
-
IMPORTANT:
|
|
11631
|
-
- Only COLLECTIBLE gifts (isCollectible: true) can be used as emoji status
|
|
11632
|
-
- Use the "collectibleId" field from telegram_get_my_gifts (NOT the slug!)
|
|
11633
|
-
- collectibleId is a numeric string like "6219780841349758977"
|
|
11634
|
-
|
|
11635
|
-
The emoji status appears next to your name in chats and your profile.`,
|
|
11604
|
+
description: "Set a collectible gift as your emoji status (icon next to your name). Use collectibleId from telegram_get_my_gifts (not slug). Set clear=true to remove.",
|
|
11636
11605
|
parameters: Type58.Object({
|
|
11637
11606
|
collectibleId: Type58.Optional(
|
|
11638
11607
|
Type58.String({
|
|
@@ -11708,7 +11677,7 @@ import { Api as Api51 } from "telegram";
|
|
|
11708
11677
|
var log79 = createLogger("Tools");
|
|
11709
11678
|
var telegramBlockUserTool = {
|
|
11710
11679
|
name: "telegram_block_user",
|
|
11711
|
-
description: "Block a
|
|
11680
|
+
description: "Block a user. They won't be able to message you or add you to groups. Not notified.",
|
|
11712
11681
|
parameters: Type59.Object({
|
|
11713
11682
|
userId: Type59.String({
|
|
11714
11683
|
description: "The user ID or username to block (e.g., '123456789' or '@username')"
|
|
@@ -11747,7 +11716,7 @@ import { Api as Api52 } from "telegram";
|
|
|
11747
11716
|
var log80 = createLogger("Tools");
|
|
11748
11717
|
var telegramGetBlockedTool = {
|
|
11749
11718
|
name: "telegram_get_blocked",
|
|
11750
|
-
description: "Get list of
|
|
11719
|
+
description: "Get your list of blocked users.",
|
|
11751
11720
|
category: "data-bearing",
|
|
11752
11721
|
parameters: Type60.Object({
|
|
11753
11722
|
limit: Type60.Optional(
|
|
@@ -11798,7 +11767,7 @@ import { Api as Api53 } from "telegram";
|
|
|
11798
11767
|
var log81 = createLogger("Tools");
|
|
11799
11768
|
var telegramGetCommonChatsTool = {
|
|
11800
11769
|
name: "telegram_get_common_chats",
|
|
11801
|
-
description: "Find groups and channels
|
|
11770
|
+
description: "Find groups and channels you share with another user.",
|
|
11802
11771
|
category: "data-bearing",
|
|
11803
11772
|
parameters: Type61.Object({
|
|
11804
11773
|
userId: Type61.String({
|
|
@@ -11856,20 +11825,7 @@ import { Api as Api54 } from "telegram";
|
|
|
11856
11825
|
var log82 = createLogger("Tools");
|
|
11857
11826
|
var telegramGetUserInfoTool = {
|
|
11858
11827
|
name: "telegram_get_user_info",
|
|
11859
|
-
description:
|
|
11860
|
-
|
|
11861
|
-
USAGE:
|
|
11862
|
-
- By username: pass username (with or without @)
|
|
11863
|
-
- By ID: pass userId
|
|
11864
|
-
|
|
11865
|
-
RETURNS:
|
|
11866
|
-
- Basic info: id, username, firstName, lastName, phone (if visible)
|
|
11867
|
-
- Status: isBot, isPremium, isVerified, isScam, isFake
|
|
11868
|
-
- Bio/about (if public)
|
|
11869
|
-
- Photo info (if available)
|
|
11870
|
-
- Common chats count
|
|
11871
|
-
|
|
11872
|
-
Use this to learn about traders, verify users, or gather intel.`,
|
|
11828
|
+
description: "Get detailed info about a Telegram user by username or userId. Returns profile, status, bio, and common chats.",
|
|
11873
11829
|
category: "data-bearing",
|
|
11874
11830
|
parameters: Type62.Object({
|
|
11875
11831
|
userId: Type62.Optional(
|
|
@@ -11979,20 +11935,7 @@ import { Api as Api55 } from "telegram";
|
|
|
11979
11935
|
var log83 = createLogger("Tools");
|
|
11980
11936
|
var telegramCheckUsernameTool = {
|
|
11981
11937
|
name: "telegram_check_username",
|
|
11982
|
-
description:
|
|
11983
|
-
|
|
11984
|
-
USAGE:
|
|
11985
|
-
- Pass a username (with or without @)
|
|
11986
|
-
|
|
11987
|
-
RETURNS:
|
|
11988
|
-
- exists: whether the username is taken
|
|
11989
|
-
- type: "user", "channel", "group", or null if not found
|
|
11990
|
-
- Basic info about the entity if it exists
|
|
11991
|
-
|
|
11992
|
-
Use this to:
|
|
11993
|
-
- Check if a trader's username is valid
|
|
11994
|
-
- Verify channel/group names
|
|
11995
|
-
- See if a username is available`,
|
|
11938
|
+
description: "Check if a username exists and get basic info (type, ID). Also reveals if a username is available.",
|
|
11996
11939
|
category: "data-bearing",
|
|
11997
11940
|
parameters: Type63.Object({
|
|
11998
11941
|
username: Type63.String({
|
|
@@ -12113,7 +12056,7 @@ import { basename } from "path";
|
|
|
12113
12056
|
var log84 = createLogger("Tools");
|
|
12114
12057
|
var telegramSendStoryTool = {
|
|
12115
12058
|
name: "telegram_send_story",
|
|
12116
|
-
description: "Post a story (
|
|
12059
|
+
description: "Post a story (photo/video) that disappears after 24h. Supports JPG, PNG, MP4.",
|
|
12117
12060
|
parameters: Type64.Object({
|
|
12118
12061
|
mediaPath: Type64.String({
|
|
12119
12062
|
description: "Local file path to the media (photo or video) for the story (e.g., '/path/to/image.jpg' or '/path/to/video.mp4')"
|
|
@@ -12245,7 +12188,7 @@ function getMemoryLineCount() {
|
|
|
12245
12188
|
}
|
|
12246
12189
|
var memoryWriteTool = {
|
|
12247
12190
|
name: "memory_write",
|
|
12248
|
-
description: "
|
|
12191
|
+
description: "Save to agent memory. Use 'persistent' for long-term facts, preferences, contacts, rules \u2192 MEMORY.md. Use 'daily' for session notes, events, temporary context \u2192 today's log. Disabled in group chats.",
|
|
12249
12192
|
parameters: Type65.Object({
|
|
12250
12193
|
content: Type65.String({
|
|
12251
12194
|
description: "The content to write to memory. Be concise but complete."
|
|
@@ -12372,7 +12315,7 @@ var MEMORY_DIR2 = WORKSPACE_PATHS.MEMORY_DIR;
|
|
|
12372
12315
|
var MEMORY_FILE2 = WORKSPACE_PATHS.MEMORY;
|
|
12373
12316
|
var memoryReadTool = {
|
|
12374
12317
|
name: "memory_read",
|
|
12375
|
-
description: "Read your memory files
|
|
12318
|
+
description: "Read your memory files: persistent (MEMORY.md), daily (today's log), recent (today+yesterday), or list all.",
|
|
12376
12319
|
category: "data-bearing",
|
|
12377
12320
|
parameters: Type66.Object({
|
|
12378
12321
|
target: Type66.String({
|
|
@@ -12510,7 +12453,7 @@ import { Api as Api57 } from "telegram";
|
|
|
12510
12453
|
var log87 = createLogger("Tools");
|
|
12511
12454
|
var telegramCreateScheduledTaskTool = {
|
|
12512
12455
|
name: "telegram_create_scheduled_task",
|
|
12513
|
-
description: "
|
|
12456
|
+
description: "Schedule a task for future execution. Stores in DB and schedules a reminder in Saved Messages. Supports tool_call, agent_task payloads, or simple reminders. Can depend on other tasks.",
|
|
12514
12457
|
parameters: Type67.Object({
|
|
12515
12458
|
description: Type67.String({
|
|
12516
12459
|
description: "What the task is about (e.g., 'Check TON price and alert if > $5')"
|
|
@@ -12745,7 +12688,7 @@ import { Type as Type68 } from "@sinclair/typebox";
|
|
|
12745
12688
|
var log88 = createLogger("Tools");
|
|
12746
12689
|
var tonGetAddressTool = {
|
|
12747
12690
|
name: "ton_get_address",
|
|
12748
|
-
description: "Get your TON wallet address.
|
|
12691
|
+
description: "Get your TON wallet address.",
|
|
12749
12692
|
parameters: Type68.Object({})
|
|
12750
12693
|
};
|
|
12751
12694
|
var tonGetAddressExecutor = async (params, context) => {
|
|
@@ -12778,7 +12721,7 @@ import { Type as Type69 } from "@sinclair/typebox";
|
|
|
12778
12721
|
var log89 = createLogger("Tools");
|
|
12779
12722
|
var tonGetBalanceTool = {
|
|
12780
12723
|
name: "ton_get_balance",
|
|
12781
|
-
description: "Get your current TON wallet balance.
|
|
12724
|
+
description: "Get your current TON wallet balance.",
|
|
12782
12725
|
parameters: Type69.Object({}),
|
|
12783
12726
|
category: "data-bearing"
|
|
12784
12727
|
};
|
|
@@ -12822,7 +12765,7 @@ import { Type as Type70 } from "@sinclair/typebox";
|
|
|
12822
12765
|
var log90 = createLogger("Tools");
|
|
12823
12766
|
var tonPriceTool = {
|
|
12824
12767
|
name: "ton_price",
|
|
12825
|
-
description: "Get current TON
|
|
12768
|
+
description: "Get current TON price in USD.",
|
|
12826
12769
|
category: "data-bearing",
|
|
12827
12770
|
parameters: Type70.Object({})
|
|
12828
12771
|
};
|
|
@@ -12856,12 +12799,10 @@ var tonPriceExecutor = async (params, context) => {
|
|
|
12856
12799
|
|
|
12857
12800
|
// src/agent/tools/ton/send.ts
|
|
12858
12801
|
import { Type as Type71 } from "@sinclair/typebox";
|
|
12859
|
-
import { WalletContractV5R1, TonClient as TonClient2, toNano, internal } from "@ton/ton";
|
|
12860
|
-
import { Address as Address2, SendMode } from "@ton/core";
|
|
12861
12802
|
var log91 = createLogger("Tools");
|
|
12862
12803
|
var tonSendTool = {
|
|
12863
12804
|
name: "ton_send",
|
|
12864
|
-
description: "Send TON
|
|
12805
|
+
description: "Send TON to an address. Amount in TON (not nanoTON). Confirm details before sending.",
|
|
12865
12806
|
parameters: Type71.Object({
|
|
12866
12807
|
to: Type71.String({
|
|
12867
12808
|
description: "Recipient TON address (EQ... or UQ... format)"
|
|
@@ -12877,7 +12818,7 @@ var tonSendTool = {
|
|
|
12877
12818
|
)
|
|
12878
12819
|
})
|
|
12879
12820
|
};
|
|
12880
|
-
var tonSendExecutor = async (params,
|
|
12821
|
+
var tonSendExecutor = async (params, _context) => {
|
|
12881
12822
|
try {
|
|
12882
12823
|
const { to, amount, comment } = params;
|
|
12883
12824
|
const walletData = loadWallet();
|
|
@@ -12887,39 +12828,13 @@ var tonSendExecutor = async (params, context) => {
|
|
|
12887
12828
|
error: "Wallet not initialized. Contact admin to generate wallet."
|
|
12888
12829
|
};
|
|
12889
12830
|
}
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
} catch (e) {
|
|
12831
|
+
const txRef = await sendTon({ toAddress: to, amount, comment });
|
|
12832
|
+
if (!txRef) {
|
|
12893
12833
|
return {
|
|
12894
12834
|
success: false,
|
|
12895
|
-
error:
|
|
12835
|
+
error: "TON transfer failed (wallet not initialized or invalid parameters)"
|
|
12896
12836
|
};
|
|
12897
12837
|
}
|
|
12898
|
-
const keyPair = await getKeyPair();
|
|
12899
|
-
if (!keyPair) {
|
|
12900
|
-
return { success: false, error: "Wallet key derivation failed." };
|
|
12901
|
-
}
|
|
12902
|
-
const wallet = WalletContractV5R1.create({
|
|
12903
|
-
workchain: 0,
|
|
12904
|
-
publicKey: keyPair.publicKey
|
|
12905
|
-
});
|
|
12906
|
-
const endpoint = await getCachedHttpEndpoint();
|
|
12907
|
-
const client = new TonClient2({ endpoint });
|
|
12908
|
-
const contract = client.open(wallet);
|
|
12909
|
-
const seqno = await contract.getSeqno();
|
|
12910
|
-
await contract.sendTransfer({
|
|
12911
|
-
seqno,
|
|
12912
|
-
secretKey: keyPair.secretKey,
|
|
12913
|
-
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
12914
|
-
messages: [
|
|
12915
|
-
internal({
|
|
12916
|
-
to: Address2.parse(to),
|
|
12917
|
-
value: toNano(amount),
|
|
12918
|
-
body: comment || "",
|
|
12919
|
-
bounce: false
|
|
12920
|
-
})
|
|
12921
|
-
]
|
|
12922
|
-
});
|
|
12923
12838
|
return {
|
|
12924
12839
|
success: true,
|
|
12925
12840
|
data: {
|
|
@@ -12941,12 +12856,12 @@ var tonSendExecutor = async (params, context) => {
|
|
|
12941
12856
|
|
|
12942
12857
|
// src/agent/tools/ton/get-transactions.ts
|
|
12943
12858
|
import { Type as Type72 } from "@sinclair/typebox";
|
|
12944
|
-
import { TonClient
|
|
12945
|
-
import { Address as
|
|
12859
|
+
import { TonClient } from "@ton/ton";
|
|
12860
|
+
import { Address as Address2 } from "@ton/core";
|
|
12946
12861
|
var log92 = createLogger("Tools");
|
|
12947
12862
|
var tonGetTransactionsTool = {
|
|
12948
12863
|
name: "ton_get_transactions",
|
|
12949
|
-
description: "Get transaction history for any TON address.
|
|
12864
|
+
description: "Get transaction history for any TON address.",
|
|
12950
12865
|
category: "data-bearing",
|
|
12951
12866
|
parameters: Type72.Object({
|
|
12952
12867
|
address: Type72.String({
|
|
@@ -12966,7 +12881,7 @@ var tonGetTransactionsExecutor = async (params, context) => {
|
|
|
12966
12881
|
const { address: address4, limit = 10 } = params;
|
|
12967
12882
|
let addressObj;
|
|
12968
12883
|
try {
|
|
12969
|
-
addressObj =
|
|
12884
|
+
addressObj = Address2.parse(address4);
|
|
12970
12885
|
} catch (e) {
|
|
12971
12886
|
return {
|
|
12972
12887
|
success: false,
|
|
@@ -12974,7 +12889,7 @@ var tonGetTransactionsExecutor = async (params, context) => {
|
|
|
12974
12889
|
};
|
|
12975
12890
|
}
|
|
12976
12891
|
const endpoint = await getCachedHttpEndpoint();
|
|
12977
|
-
const client = new
|
|
12892
|
+
const client = new TonClient({ endpoint });
|
|
12978
12893
|
const transactions = await client.getTransactions(addressObj, {
|
|
12979
12894
|
limit: Math.min(limit, 50)
|
|
12980
12895
|
});
|
|
@@ -12997,12 +12912,12 @@ var tonGetTransactionsExecutor = async (params, context) => {
|
|
|
12997
12912
|
|
|
12998
12913
|
// src/agent/tools/ton/my-transactions.ts
|
|
12999
12914
|
import { Type as Type73 } from "@sinclair/typebox";
|
|
13000
|
-
import { TonClient as
|
|
13001
|
-
import { Address as
|
|
12915
|
+
import { TonClient as TonClient2 } from "@ton/ton";
|
|
12916
|
+
import { Address as Address3 } from "@ton/core";
|
|
13002
12917
|
var log93 = createLogger("Tools");
|
|
13003
12918
|
var tonMyTransactionsTool = {
|
|
13004
12919
|
name: "ton_my_transactions",
|
|
13005
|
-
description: "Get your own wallet's transaction history.
|
|
12920
|
+
description: "Get your own wallet's transaction history.",
|
|
13006
12921
|
category: "data-bearing",
|
|
13007
12922
|
parameters: Type73.Object({
|
|
13008
12923
|
limit: Type73.Optional(
|
|
@@ -13024,9 +12939,9 @@ var tonMyTransactionsExecutor = async (params, context) => {
|
|
|
13024
12939
|
error: "Wallet not initialized. Contact admin to generate wallet."
|
|
13025
12940
|
};
|
|
13026
12941
|
}
|
|
13027
|
-
const addressObj =
|
|
12942
|
+
const addressObj = Address3.parse(walletData.address);
|
|
13028
12943
|
const endpoint = await getCachedHttpEndpoint();
|
|
13029
|
-
const client = new
|
|
12944
|
+
const client = new TonClient2({ endpoint });
|
|
13030
12945
|
const transactions = await client.getTransactions(addressObj, {
|
|
13031
12946
|
limit: Math.min(limit, 50)
|
|
13032
12947
|
});
|
|
@@ -13052,7 +12967,7 @@ import { Type as Type74 } from "@sinclair/typebox";
|
|
|
13052
12967
|
var log94 = createLogger("Tools");
|
|
13053
12968
|
var tonChartTool = {
|
|
13054
12969
|
name: "ton_chart",
|
|
13055
|
-
description: "Get price history chart for TON or any jetton
|
|
12970
|
+
description: "Get price history chart for TON or any jetton over a configurable time period.",
|
|
13056
12971
|
parameters: Type74.Object({
|
|
13057
12972
|
token: Type74.Optional(
|
|
13058
12973
|
Type74.String({
|
|
@@ -13268,13 +13183,13 @@ var nftListExecutor = async (params, context) => {
|
|
|
13268
13183
|
|
|
13269
13184
|
// src/agent/tools/ton/jetton-send.ts
|
|
13270
13185
|
import { Type as Type76 } from "@sinclair/typebox";
|
|
13271
|
-
import { WalletContractV5R1
|
|
13272
|
-
import { Address as
|
|
13186
|
+
import { WalletContractV5R1, toNano, internal } from "@ton/ton";
|
|
13187
|
+
import { Address as Address4, SendMode, beginCell } from "@ton/core";
|
|
13273
13188
|
var log96 = createLogger("Tools");
|
|
13274
13189
|
var JETTON_TRANSFER_OP = 260734629;
|
|
13275
13190
|
var jettonSendTool = {
|
|
13276
13191
|
name: "jetton_send",
|
|
13277
|
-
description: "Send
|
|
13192
|
+
description: "Send jettons to another address. Amount in human-readable units. Use jetton_balances first to find addresses.",
|
|
13278
13193
|
parameters: Type76.Object({
|
|
13279
13194
|
jetton_address: Type76.String({
|
|
13280
13195
|
description: "Jetton master contract address (EQ... or 0:... format)"
|
|
@@ -13304,14 +13219,16 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
13304
13219
|
};
|
|
13305
13220
|
}
|
|
13306
13221
|
try {
|
|
13307
|
-
|
|
13222
|
+
Address4.parse(to);
|
|
13308
13223
|
} catch {
|
|
13309
13224
|
return {
|
|
13310
13225
|
success: false,
|
|
13311
13226
|
error: `Invalid recipient address: ${to}`
|
|
13312
13227
|
};
|
|
13313
13228
|
}
|
|
13314
|
-
const jettonsResponse = await tonapiFetch(
|
|
13229
|
+
const jettonsResponse = await tonapiFetch(
|
|
13230
|
+
`/accounts/${encodeURIComponent(walletData.address)}/jettons`
|
|
13231
|
+
);
|
|
13315
13232
|
if (!jettonsResponse.ok) {
|
|
13316
13233
|
return {
|
|
13317
13234
|
success: false,
|
|
@@ -13319,9 +13236,14 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
13319
13236
|
};
|
|
13320
13237
|
}
|
|
13321
13238
|
const jettonsData = await jettonsResponse.json();
|
|
13322
|
-
const jettonBalance = jettonsData.balances?.find(
|
|
13323
|
-
(b
|
|
13324
|
-
|
|
13239
|
+
const jettonBalance = jettonsData.balances?.find((b) => {
|
|
13240
|
+
if (b.jetton.address.toLowerCase() === jetton_address.toLowerCase()) return true;
|
|
13241
|
+
try {
|
|
13242
|
+
return Address4.parse(b.jetton.address).toString() === Address4.parse(jetton_address).toString();
|
|
13243
|
+
} catch {
|
|
13244
|
+
return false;
|
|
13245
|
+
}
|
|
13246
|
+
});
|
|
13325
13247
|
if (!jettonBalance) {
|
|
13326
13248
|
return {
|
|
13327
13249
|
success: false,
|
|
@@ -13346,27 +13268,26 @@ var jettonSendExecutor = async (params, context) => {
|
|
|
13346
13268
|
if (comment) {
|
|
13347
13269
|
forwardPayload = beginCell().storeUint(0, 32).storeStringTail(comment).endCell();
|
|
13348
13270
|
}
|
|
13349
|
-
const messageBody = beginCell().storeUint(JETTON_TRANSFER_OP, 32).storeUint(0, 64).storeCoins(amountInUnits).storeAddress(
|
|
13271
|
+
const messageBody = beginCell().storeUint(JETTON_TRANSFER_OP, 32).storeUint(0, 64).storeCoins(amountInUnits).storeAddress(Address4.parse(to)).storeAddress(Address4.parse(walletData.address)).storeBit(false).storeCoins(comment ? toNano("0.01") : BigInt(1)).storeBit(comment ? 1 : 0).storeRef(comment ? forwardPayload : beginCell().endCell()).endCell();
|
|
13350
13272
|
const keyPair = await getKeyPair();
|
|
13351
13273
|
if (!keyPair) {
|
|
13352
13274
|
return { success: false, error: "Wallet key derivation failed." };
|
|
13353
13275
|
}
|
|
13354
|
-
const wallet =
|
|
13276
|
+
const wallet = WalletContractV5R1.create({
|
|
13355
13277
|
workchain: 0,
|
|
13356
13278
|
publicKey: keyPair.publicKey
|
|
13357
13279
|
});
|
|
13358
|
-
const
|
|
13359
|
-
const client = new TonClient5({ endpoint });
|
|
13280
|
+
const client = await getCachedTonClient();
|
|
13360
13281
|
const walletContract = client.open(wallet);
|
|
13361
13282
|
const seqno = await walletContract.getSeqno();
|
|
13362
13283
|
await walletContract.sendTransfer({
|
|
13363
13284
|
seqno,
|
|
13364
13285
|
secretKey: keyPair.secretKey,
|
|
13365
|
-
sendMode:
|
|
13286
|
+
sendMode: SendMode.PAY_GAS_SEPARATELY + SendMode.IGNORE_ERRORS,
|
|
13366
13287
|
messages: [
|
|
13367
|
-
|
|
13368
|
-
to:
|
|
13369
|
-
value:
|
|
13288
|
+
internal({
|
|
13289
|
+
to: Address4.parse(senderJettonWallet),
|
|
13290
|
+
value: toNano("0.05"),
|
|
13370
13291
|
// Gas for jetton transfer
|
|
13371
13292
|
body: messageBody,
|
|
13372
13293
|
bounce: true
|
|
@@ -13400,7 +13321,7 @@ import { Type as Type77 } from "@sinclair/typebox";
|
|
|
13400
13321
|
var log97 = createLogger("Tools");
|
|
13401
13322
|
var jettonBalancesTool = {
|
|
13402
13323
|
name: "jetton_balances",
|
|
13403
|
-
description: "Get all
|
|
13324
|
+
description: "Get all jetton balances owned by the agent. Filters out blacklisted tokens.",
|
|
13404
13325
|
parameters: Type77.Object({}),
|
|
13405
13326
|
category: "data-bearing"
|
|
13406
13327
|
};
|
|
@@ -13506,7 +13427,7 @@ import { Type as Type78 } from "@sinclair/typebox";
|
|
|
13506
13427
|
var log98 = createLogger("Tools");
|
|
13507
13428
|
var jettonInfoTool = {
|
|
13508
13429
|
name: "jetton_info",
|
|
13509
|
-
description: "Get
|
|
13430
|
+
description: "Get jetton metadata: name, symbol, decimals, total supply, holders, verification status.",
|
|
13510
13431
|
category: "data-bearing",
|
|
13511
13432
|
parameters: Type78.Object({
|
|
13512
13433
|
jetton_address: Type78.String({
|
|
@@ -13603,7 +13524,7 @@ import { Type as Type79 } from "@sinclair/typebox";
|
|
|
13603
13524
|
var log99 = createLogger("Tools");
|
|
13604
13525
|
var jettonPriceTool = {
|
|
13605
13526
|
name: "jetton_price",
|
|
13606
|
-
description: "Get
|
|
13527
|
+
description: "Get current jetton price in USD/TON with 24h, 7d, 30d changes.",
|
|
13607
13528
|
category: "data-bearing",
|
|
13608
13529
|
parameters: Type79.Object({
|
|
13609
13530
|
jetton_address: Type79.String({
|
|
@@ -13703,7 +13624,7 @@ import { Type as Type80 } from "@sinclair/typebox";
|
|
|
13703
13624
|
var log100 = createLogger("Tools");
|
|
13704
13625
|
var jettonHoldersTool = {
|
|
13705
13626
|
name: "jetton_holders",
|
|
13706
|
-
description: "Get
|
|
13627
|
+
description: "Get top holders of a jetton with their balances.",
|
|
13707
13628
|
category: "data-bearing",
|
|
13708
13629
|
parameters: Type80.Object({
|
|
13709
13630
|
jetton_address: Type80.String({
|
|
@@ -13799,7 +13720,7 @@ import { Type as Type81 } from "@sinclair/typebox";
|
|
|
13799
13720
|
var log101 = createLogger("Tools");
|
|
13800
13721
|
var jettonHistoryTool = {
|
|
13801
13722
|
name: "jetton_history",
|
|
13802
|
-
description: "Get price history
|
|
13723
|
+
description: "Get jetton price history: 24h/7d/30d changes, volume, FDV, and holder count.",
|
|
13803
13724
|
category: "data-bearing",
|
|
13804
13725
|
parameters: Type81.Object({
|
|
13805
13726
|
jetton_address: Type81.String({
|
|
@@ -13923,8 +13844,8 @@ var jettonHistoryExecutor = async (params, context) => {
|
|
|
13923
13844
|
|
|
13924
13845
|
// src/agent/tools/ton/dex-quote.ts
|
|
13925
13846
|
import { Type as Type82 } from "@sinclair/typebox";
|
|
13926
|
-
import { TonClient as
|
|
13927
|
-
import { Address as
|
|
13847
|
+
import { TonClient as TonClient3 } from "@ton/ton";
|
|
13848
|
+
import { Address as Address5 } from "@ton/core";
|
|
13928
13849
|
|
|
13929
13850
|
// node_modules/ofetch/dist/node.mjs
|
|
13930
13851
|
import http from "http";
|
|
@@ -15359,7 +15280,7 @@ function fromUnits(units, decimals) {
|
|
|
15359
15280
|
var log103 = createLogger("Tools");
|
|
15360
15281
|
var dexQuoteTool = {
|
|
15361
15282
|
name: "dex_quote",
|
|
15362
|
-
description: "
|
|
15283
|
+
description: "Compare swap quotes from STON.fi and DeDust to find the best price. Does not execute.",
|
|
15363
15284
|
category: "data-bearing",
|
|
15364
15285
|
parameters: Type82.Object({
|
|
15365
15286
|
from_asset: Type82.String({
|
|
@@ -15438,10 +15359,10 @@ async function getDedustQuote(fromAsset, toAsset, amount, slippage, tonClient) {
|
|
|
15438
15359
|
const isTonInput = fromAsset.toLowerCase() === "ton";
|
|
15439
15360
|
const isTonOutput = toAsset.toLowerCase() === "ton";
|
|
15440
15361
|
const factory = tonClient.open(
|
|
15441
|
-
Factory.createFromAddress(
|
|
15362
|
+
Factory.createFromAddress(Address5.parse(DEDUST_FACTORY_MAINNET))
|
|
15442
15363
|
);
|
|
15443
|
-
const fromAssetObj = isTonInput ? Asset.native() : Asset.jetton(
|
|
15444
|
-
const toAssetObj = isTonOutput ? Asset.native() : Asset.jetton(
|
|
15364
|
+
const fromAssetObj = isTonInput ? Asset.native() : Asset.jetton(Address5.parse(fromAsset));
|
|
15365
|
+
const toAssetObj = isTonOutput ? Asset.native() : Asset.jetton(Address5.parse(toAsset));
|
|
15445
15366
|
let pool;
|
|
15446
15367
|
let poolType = "volatile";
|
|
15447
15368
|
try {
|
|
@@ -15508,7 +15429,7 @@ var dexQuoteExecutor = async (params, context) => {
|
|
|
15508
15429
|
try {
|
|
15509
15430
|
const { from_asset, to_asset, amount, slippage = 0.01 } = params;
|
|
15510
15431
|
const endpoint = await getCachedHttpEndpoint();
|
|
15511
|
-
const tonClient = new
|
|
15432
|
+
const tonClient = new TonClient3({ endpoint });
|
|
15512
15433
|
const [stonfiQuote, dedustQuote] = await Promise.all([
|
|
15513
15434
|
getStonfiQuote(from_asset, to_asset, amount, slippage),
|
|
15514
15435
|
getDedustQuote(from_asset, to_asset, amount, slippage, tonClient)
|
|
@@ -15638,7 +15559,7 @@ import { Type as Type83 } from "@sinclair/typebox";
|
|
|
15638
15559
|
var log104 = createLogger("Tools");
|
|
15639
15560
|
var dnsCheckTool = {
|
|
15640
15561
|
name: "dns_check",
|
|
15641
|
-
description: "Check
|
|
15562
|
+
description: "Check .ton domain status: available, in auction, or owned.",
|
|
15642
15563
|
category: "data-bearing",
|
|
15643
15564
|
parameters: Type83.Object({
|
|
15644
15565
|
domain: Type83.String({
|
|
@@ -15759,7 +15680,7 @@ import { Type as Type84 } from "@sinclair/typebox";
|
|
|
15759
15680
|
var log105 = createLogger("Tools");
|
|
15760
15681
|
var dnsAuctionsTool = {
|
|
15761
15682
|
name: "dns_auctions",
|
|
15762
|
-
description: "List
|
|
15683
|
+
description: "List active .ton domain auctions with current bids and end times.",
|
|
15763
15684
|
category: "data-bearing",
|
|
15764
15685
|
parameters: Type84.Object({
|
|
15765
15686
|
limit: Type84.Optional(
|
|
@@ -15832,7 +15753,7 @@ import { Type as Type85 } from "@sinclair/typebox";
|
|
|
15832
15753
|
var log106 = createLogger("Tools");
|
|
15833
15754
|
var dnsResolveTool = {
|
|
15834
15755
|
name: "dns_resolve",
|
|
15835
|
-
description: "Resolve a .ton domain to its
|
|
15756
|
+
description: "Resolve a .ton domain to its wallet address. Only works for owned domains.",
|
|
15836
15757
|
category: "data-bearing",
|
|
15837
15758
|
parameters: Type85.Object({
|
|
15838
15759
|
domain: Type85.String({
|
|
@@ -15892,13 +15813,13 @@ var dnsResolveExecutor = async (params, context) => {
|
|
|
15892
15813
|
|
|
15893
15814
|
// src/agent/tools/dns/start-auction.ts
|
|
15894
15815
|
import { Type as Type86 } from "@sinclair/typebox";
|
|
15895
|
-
import { WalletContractV5R1 as
|
|
15896
|
-
import { Address as
|
|
15816
|
+
import { WalletContractV5R1 as WalletContractV5R12, TonClient as TonClient4, toNano as toNano2, internal as internal2, beginCell as beginCell2 } from "@ton/ton";
|
|
15817
|
+
import { Address as Address6, SendMode as SendMode2 } from "@ton/core";
|
|
15897
15818
|
var log107 = createLogger("Tools");
|
|
15898
15819
|
var DNS_COLLECTION = "EQC3dNlesgVD8YbAazcauIrXBPfiVhMMr5YYk2in0Mtsz0Bz";
|
|
15899
15820
|
var dnsStartAuctionTool = {
|
|
15900
15821
|
name: "dns_start_auction",
|
|
15901
|
-
description: "Start an auction for an unminted .ton domain.
|
|
15822
|
+
description: "Start an auction for an unminted .ton domain. Amount must meet minimum price for domain length.",
|
|
15902
15823
|
parameters: Type86.Object({
|
|
15903
15824
|
domain: Type86.String({
|
|
15904
15825
|
description: "Domain name to mint (without .ton extension, 4-126 chars)"
|
|
@@ -15936,23 +15857,23 @@ var dnsStartAuctionExecutor = async (params, context) => {
|
|
|
15936
15857
|
if (!keyPair) {
|
|
15937
15858
|
return { success: false, error: "Wallet key derivation failed." };
|
|
15938
15859
|
}
|
|
15939
|
-
const wallet =
|
|
15860
|
+
const wallet = WalletContractV5R12.create({
|
|
15940
15861
|
workchain: 0,
|
|
15941
15862
|
publicKey: keyPair.publicKey
|
|
15942
15863
|
});
|
|
15943
15864
|
const endpoint = await getCachedHttpEndpoint();
|
|
15944
|
-
const client = new
|
|
15865
|
+
const client = new TonClient4({ endpoint });
|
|
15945
15866
|
const contract = client.open(wallet);
|
|
15946
15867
|
const seqno = await contract.getSeqno();
|
|
15947
15868
|
const body = beginCell2().storeUint(0, 32).storeStringTail(domain).endCell();
|
|
15948
15869
|
await contract.sendTransfer({
|
|
15949
15870
|
seqno,
|
|
15950
15871
|
secretKey: keyPair.secretKey,
|
|
15951
|
-
sendMode:
|
|
15872
|
+
sendMode: SendMode2.PAY_GAS_SEPARATELY + SendMode2.IGNORE_ERRORS,
|
|
15952
15873
|
messages: [
|
|
15953
|
-
|
|
15954
|
-
to:
|
|
15955
|
-
value:
|
|
15874
|
+
internal2({
|
|
15875
|
+
to: Address6.parse(DNS_COLLECTION),
|
|
15876
|
+
value: toNano2(amount),
|
|
15956
15877
|
body,
|
|
15957
15878
|
bounce: true
|
|
15958
15879
|
})
|
|
@@ -15982,12 +15903,12 @@ var dnsStartAuctionExecutor = async (params, context) => {
|
|
|
15982
15903
|
|
|
15983
15904
|
// src/agent/tools/dns/bid.ts
|
|
15984
15905
|
import { Type as Type87 } from "@sinclair/typebox";
|
|
15985
|
-
import { WalletContractV5R1 as
|
|
15986
|
-
import { Address as
|
|
15906
|
+
import { WalletContractV5R1 as WalletContractV5R13, TonClient as TonClient5, toNano as toNano3, internal as internal3 } from "@ton/ton";
|
|
15907
|
+
import { Address as Address7, SendMode as SendMode3 } from "@ton/core";
|
|
15987
15908
|
var log108 = createLogger("Tools");
|
|
15988
15909
|
var dnsBidTool = {
|
|
15989
15910
|
name: "dns_bid",
|
|
15990
|
-
description: "Place a bid on
|
|
15911
|
+
description: "Place a bid on a .ton domain auction. Bid must be >= 105% of current bid. Use dns_check first.",
|
|
15991
15912
|
parameters: Type87.Object({
|
|
15992
15913
|
domain: Type87.String({
|
|
15993
15914
|
description: "Domain name (with or without .ton extension)"
|
|
@@ -16056,22 +15977,22 @@ var dnsBidExecutor = async (params, context) => {
|
|
|
16056
15977
|
if (!keyPair) {
|
|
16057
15978
|
return { success: false, error: "Wallet key derivation failed." };
|
|
16058
15979
|
}
|
|
16059
|
-
const wallet =
|
|
15980
|
+
const wallet = WalletContractV5R13.create({
|
|
16060
15981
|
workchain: 0,
|
|
16061
15982
|
publicKey: keyPair.publicKey
|
|
16062
15983
|
});
|
|
16063
15984
|
const endpoint = await getCachedHttpEndpoint();
|
|
16064
|
-
const client = new
|
|
15985
|
+
const client = new TonClient5({ endpoint });
|
|
16065
15986
|
const contract = client.open(wallet);
|
|
16066
15987
|
const seqno = await contract.getSeqno();
|
|
16067
15988
|
await contract.sendTransfer({
|
|
16068
15989
|
seqno,
|
|
16069
15990
|
secretKey: keyPair.secretKey,
|
|
16070
|
-
sendMode:
|
|
15991
|
+
sendMode: SendMode3.PAY_GAS_SEPARATELY + SendMode3.IGNORE_ERRORS,
|
|
16071
15992
|
messages: [
|
|
16072
|
-
|
|
16073
|
-
to:
|
|
16074
|
-
value:
|
|
15993
|
+
internal3({
|
|
15994
|
+
to: Address7.parse(nftAddress),
|
|
15995
|
+
value: toNano3(amount),
|
|
16075
15996
|
body: "",
|
|
16076
15997
|
// Empty body for bid
|
|
16077
15998
|
bounce: true
|
|
@@ -16102,8 +16023,8 @@ var dnsBidExecutor = async (params, context) => {
|
|
|
16102
16023
|
|
|
16103
16024
|
// src/agent/tools/dns/link.ts
|
|
16104
16025
|
import { Type as Type88 } from "@sinclair/typebox";
|
|
16105
|
-
import { WalletContractV5R1 as
|
|
16106
|
-
import { Address as
|
|
16026
|
+
import { WalletContractV5R1 as WalletContractV5R14, TonClient as TonClient6, toNano as toNano4, internal as internal4, beginCell as beginCell3 } from "@ton/ton";
|
|
16027
|
+
import { Address as Address8, SendMode as SendMode4 } from "@ton/core";
|
|
16107
16028
|
var log109 = createLogger("Tools");
|
|
16108
16029
|
var DNS_CHANGE_RECORD_OP = 1320284409;
|
|
16109
16030
|
var DNS_SMC_ADDRESS_PREFIX = 40915;
|
|
@@ -16112,7 +16033,7 @@ var WALLET_RECORD_KEY = BigInt(
|
|
|
16112
16033
|
);
|
|
16113
16034
|
var dnsLinkTool = {
|
|
16114
16035
|
name: "dns_link",
|
|
16115
|
-
description: "Link a wallet address to a .ton domain you own.
|
|
16036
|
+
description: "Link a wallet address to a .ton domain you own. Defaults to your own wallet.",
|
|
16116
16037
|
parameters: Type88.Object({
|
|
16117
16038
|
domain: Type88.String({
|
|
16118
16039
|
description: "Domain name (with or without .ton extension)"
|
|
@@ -16138,7 +16059,7 @@ var dnsLinkExecutor = async (params, context) => {
|
|
|
16138
16059
|
}
|
|
16139
16060
|
const targetAddress = wallet_address || walletData.address;
|
|
16140
16061
|
try {
|
|
16141
|
-
|
|
16062
|
+
Address8.parse(targetAddress);
|
|
16142
16063
|
} catch {
|
|
16143
16064
|
return {
|
|
16144
16065
|
success: false,
|
|
@@ -16173,8 +16094,8 @@ var dnsLinkExecutor = async (params, context) => {
|
|
|
16173
16094
|
error: `Domain ${fullDomain} has no owner (still in auction?)`
|
|
16174
16095
|
};
|
|
16175
16096
|
}
|
|
16176
|
-
const ownerNormalized =
|
|
16177
|
-
const agentNormalized =
|
|
16097
|
+
const ownerNormalized = Address8.parse(ownerAddress).toString();
|
|
16098
|
+
const agentNormalized = Address8.parse(walletData.address).toString();
|
|
16178
16099
|
if (ownerNormalized !== agentNormalized) {
|
|
16179
16100
|
return {
|
|
16180
16101
|
success: false,
|
|
@@ -16185,24 +16106,24 @@ var dnsLinkExecutor = async (params, context) => {
|
|
|
16185
16106
|
if (!keyPair) {
|
|
16186
16107
|
return { success: false, error: "Wallet key derivation failed." };
|
|
16187
16108
|
}
|
|
16188
|
-
const wallet =
|
|
16109
|
+
const wallet = WalletContractV5R14.create({
|
|
16189
16110
|
workchain: 0,
|
|
16190
16111
|
publicKey: keyPair.publicKey
|
|
16191
16112
|
});
|
|
16192
16113
|
const endpoint = await getCachedHttpEndpoint();
|
|
16193
|
-
const client = new
|
|
16114
|
+
const client = new TonClient6({ endpoint });
|
|
16194
16115
|
const contract = client.open(wallet);
|
|
16195
16116
|
const seqno = await contract.getSeqno();
|
|
16196
|
-
const valueCell = beginCell3().storeUint(DNS_SMC_ADDRESS_PREFIX, 16).storeAddress(
|
|
16117
|
+
const valueCell = beginCell3().storeUint(DNS_SMC_ADDRESS_PREFIX, 16).storeAddress(Address8.parse(targetAddress)).storeUint(0, 8).endCell();
|
|
16197
16118
|
const body = beginCell3().storeUint(DNS_CHANGE_RECORD_OP, 32).storeUint(0, 64).storeUint(WALLET_RECORD_KEY, 256).storeRef(valueCell).endCell();
|
|
16198
16119
|
await contract.sendTransfer({
|
|
16199
16120
|
seqno,
|
|
16200
16121
|
secretKey: keyPair.secretKey,
|
|
16201
|
-
sendMode:
|
|
16122
|
+
sendMode: SendMode4.PAY_GAS_SEPARATELY + SendMode4.IGNORE_ERRORS,
|
|
16202
16123
|
messages: [
|
|
16203
|
-
|
|
16204
|
-
to:
|
|
16205
|
-
value:
|
|
16124
|
+
internal4({
|
|
16125
|
+
to: Address8.parse(nftAddress),
|
|
16126
|
+
value: toNano4("0.05"),
|
|
16206
16127
|
// Gas for DNS record update
|
|
16207
16128
|
body,
|
|
16208
16129
|
bounce: true
|
|
@@ -16232,8 +16153,8 @@ var dnsLinkExecutor = async (params, context) => {
|
|
|
16232
16153
|
|
|
16233
16154
|
// src/agent/tools/dns/unlink.ts
|
|
16234
16155
|
import { Type as Type89 } from "@sinclair/typebox";
|
|
16235
|
-
import { WalletContractV5R1 as
|
|
16236
|
-
import { Address as
|
|
16156
|
+
import { WalletContractV5R1 as WalletContractV5R15, TonClient as TonClient7, toNano as toNano5, internal as internal5, beginCell as beginCell4 } from "@ton/ton";
|
|
16157
|
+
import { Address as Address9, SendMode as SendMode5 } from "@ton/core";
|
|
16237
16158
|
var log110 = createLogger("Tools");
|
|
16238
16159
|
var DNS_CHANGE_RECORD_OP2 = 1320284409;
|
|
16239
16160
|
var WALLET_RECORD_KEY2 = BigInt(
|
|
@@ -16241,7 +16162,7 @@ var WALLET_RECORD_KEY2 = BigInt(
|
|
|
16241
16162
|
);
|
|
16242
16163
|
var dnsUnlinkTool = {
|
|
16243
16164
|
name: "dns_unlink",
|
|
16244
|
-
description: "Remove the wallet link from a .ton domain you own.
|
|
16165
|
+
description: "Remove the wallet link from a .ton domain you own.",
|
|
16245
16166
|
parameters: Type89.Object({
|
|
16246
16167
|
domain: Type89.String({
|
|
16247
16168
|
description: "Domain name (with or without .ton extension)"
|
|
@@ -16288,8 +16209,8 @@ var dnsUnlinkExecutor = async (params, context) => {
|
|
|
16288
16209
|
error: `Domain ${fullDomain} has no owner (still in auction?)`
|
|
16289
16210
|
};
|
|
16290
16211
|
}
|
|
16291
|
-
const ownerNormalized =
|
|
16292
|
-
const agentNormalized =
|
|
16212
|
+
const ownerNormalized = Address9.parse(ownerAddress).toString();
|
|
16213
|
+
const agentNormalized = Address9.parse(walletData.address).toString();
|
|
16293
16214
|
if (ownerNormalized !== agentNormalized) {
|
|
16294
16215
|
return {
|
|
16295
16216
|
success: false,
|
|
@@ -16300,23 +16221,23 @@ var dnsUnlinkExecutor = async (params, context) => {
|
|
|
16300
16221
|
if (!keyPair) {
|
|
16301
16222
|
return { success: false, error: "Wallet key derivation failed." };
|
|
16302
16223
|
}
|
|
16303
|
-
const wallet =
|
|
16224
|
+
const wallet = WalletContractV5R15.create({
|
|
16304
16225
|
workchain: 0,
|
|
16305
16226
|
publicKey: keyPair.publicKey
|
|
16306
16227
|
});
|
|
16307
16228
|
const endpoint = await getCachedHttpEndpoint();
|
|
16308
|
-
const client = new
|
|
16229
|
+
const client = new TonClient7({ endpoint });
|
|
16309
16230
|
const contract = client.open(wallet);
|
|
16310
16231
|
const seqno = await contract.getSeqno();
|
|
16311
16232
|
const body = beginCell4().storeUint(DNS_CHANGE_RECORD_OP2, 32).storeUint(0, 64).storeUint(WALLET_RECORD_KEY2, 256).endCell();
|
|
16312
16233
|
await contract.sendTransfer({
|
|
16313
16234
|
seqno,
|
|
16314
16235
|
secretKey: keyPair.secretKey,
|
|
16315
|
-
sendMode:
|
|
16236
|
+
sendMode: SendMode5.PAY_GAS_SEPARATELY + SendMode5.IGNORE_ERRORS,
|
|
16316
16237
|
messages: [
|
|
16317
|
-
|
|
16318
|
-
to:
|
|
16319
|
-
value:
|
|
16238
|
+
internal5({
|
|
16239
|
+
to: Address9.parse(nftAddress),
|
|
16240
|
+
value: toNano5("0.05"),
|
|
16320
16241
|
// Gas for DNS record update
|
|
16321
16242
|
body,
|
|
16322
16243
|
bounce: true
|
|
@@ -16356,13 +16277,13 @@ var tools17 = [
|
|
|
16356
16277
|
|
|
16357
16278
|
// src/agent/tools/stonfi/swap.ts
|
|
16358
16279
|
import { Type as Type90 } from "@sinclair/typebox";
|
|
16359
|
-
import { WalletContractV5R1 as
|
|
16360
|
-
import { SendMode as
|
|
16280
|
+
import { WalletContractV5R1 as WalletContractV5R16, TonClient as TonClient8, toNano as toNano18, fromNano as fromNano2, internal as internal6 } from "@ton/ton";
|
|
16281
|
+
import { SendMode as SendMode6 } from "@ton/core";
|
|
16361
16282
|
|
|
16362
16283
|
// node_modules/@ston-fi/sdk/dist/chunk-HNMPFVZW.js
|
|
16363
|
-
import { Address as
|
|
16284
|
+
import { Address as Address10, address } from "@ton/ton";
|
|
16364
16285
|
function toAddress(addressValue) {
|
|
16365
|
-
if (addressValue instanceof
|
|
16286
|
+
if (addressValue instanceof Address10) {
|
|
16366
16287
|
return addressValue;
|
|
16367
16288
|
}
|
|
16368
16289
|
return address(addressValue.toString());
|
|
@@ -16491,14 +16412,14 @@ var DEX_TYPE = {
|
|
|
16491
16412
|
// node_modules/@ston-fi/sdk/dist/chunk-ZPXELCC2.js
|
|
16492
16413
|
import {
|
|
16493
16414
|
beginCell as beginCell7,
|
|
16494
|
-
toNano as
|
|
16415
|
+
toNano as toNano6
|
|
16495
16416
|
} from "@ton/ton";
|
|
16496
16417
|
var LpAccountV1 = class _LpAccountV1 extends Contract {
|
|
16497
16418
|
static version = DEX_VERSION.v1;
|
|
16498
16419
|
static gasConstants = {
|
|
16499
|
-
refund:
|
|
16500
|
-
directAddLp:
|
|
16501
|
-
resetGas:
|
|
16420
|
+
refund: toNano6("0.3"),
|
|
16421
|
+
directAddLp: toNano6("0.3"),
|
|
16422
|
+
resetGas: toNano6("0.3")
|
|
16502
16423
|
};
|
|
16503
16424
|
gasConstants;
|
|
16504
16425
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -16600,13 +16521,13 @@ var LpAccountV1 = class _LpAccountV1 extends Contract {
|
|
|
16600
16521
|
// node_modules/@ston-fi/sdk/dist/chunk-OREDCISV.js
|
|
16601
16522
|
import {
|
|
16602
16523
|
beginCell as beginCell8,
|
|
16603
|
-
toNano as
|
|
16524
|
+
toNano as toNano7
|
|
16604
16525
|
} from "@ton/ton";
|
|
16605
16526
|
var PoolV1 = class _PoolV1 extends JettonMinter {
|
|
16606
16527
|
static version = DEX_VERSION.v1;
|
|
16607
16528
|
static gasConstants = {
|
|
16608
|
-
collectFees:
|
|
16609
|
-
burn:
|
|
16529
|
+
collectFees: toNano7("1.1"),
|
|
16530
|
+
burn: toNano7("0.5")
|
|
16610
16531
|
};
|
|
16611
16532
|
gasConstants;
|
|
16612
16533
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -16777,8 +16698,8 @@ var PoolV1 = class _PoolV1 extends JettonMinter {
|
|
|
16777
16698
|
};
|
|
16778
16699
|
|
|
16779
16700
|
// node_modules/@ston-fi/sdk/dist/chunk-BZOLUFTK.js
|
|
16780
|
-
import { Address as
|
|
16781
|
-
var HOLE_ADDRESS =
|
|
16701
|
+
import { Address as Address11 } from "@ton/ton";
|
|
16702
|
+
var HOLE_ADDRESS = Address11.parse(
|
|
16782
16703
|
"0:0000000000000000000000000000000000000000000000000000000000000000"
|
|
16783
16704
|
);
|
|
16784
16705
|
|
|
@@ -16798,29 +16719,29 @@ var UnmatchedPtonVersion = class extends Error {
|
|
|
16798
16719
|
import {
|
|
16799
16720
|
address as address2,
|
|
16800
16721
|
beginCell as beginCell9,
|
|
16801
|
-
toNano as
|
|
16722
|
+
toNano as toNano8
|
|
16802
16723
|
} from "@ton/ton";
|
|
16803
16724
|
var RouterV1 = class _RouterV1 extends Contract {
|
|
16804
16725
|
static version = DEX_VERSION.v1;
|
|
16805
16726
|
static address = address2(ROUTER_ADDRESS);
|
|
16806
16727
|
static gasConstants = {
|
|
16807
16728
|
swapJettonToJetton: {
|
|
16808
|
-
gasAmount:
|
|
16809
|
-
forwardGasAmount:
|
|
16729
|
+
gasAmount: toNano8("0.22"),
|
|
16730
|
+
forwardGasAmount: toNano8("0.175")
|
|
16810
16731
|
},
|
|
16811
16732
|
swapJettonToTon: {
|
|
16812
|
-
gasAmount:
|
|
16813
|
-
forwardGasAmount:
|
|
16733
|
+
gasAmount: toNano8("0.17"),
|
|
16734
|
+
forwardGasAmount: toNano8("0.125")
|
|
16814
16735
|
},
|
|
16815
16736
|
swapTonToJetton: {
|
|
16816
|
-
forwardGasAmount:
|
|
16737
|
+
forwardGasAmount: toNano8("0.185")
|
|
16817
16738
|
},
|
|
16818
16739
|
provideLpJetton: {
|
|
16819
|
-
gasAmount:
|
|
16820
|
-
forwardGasAmount:
|
|
16740
|
+
gasAmount: toNano8("0.3"),
|
|
16741
|
+
forwardGasAmount: toNano8("0.24")
|
|
16821
16742
|
},
|
|
16822
16743
|
provideLpTon: {
|
|
16823
|
-
forwardGasAmount:
|
|
16744
|
+
forwardGasAmount: toNano8("0.26")
|
|
16824
16745
|
}
|
|
16825
16746
|
};
|
|
16826
16747
|
gasConstants;
|
|
@@ -17154,7 +17075,7 @@ var pTON_OP_CODES = {
|
|
|
17154
17075
|
import {
|
|
17155
17076
|
address as address3,
|
|
17156
17077
|
beginCell as beginCell10,
|
|
17157
|
-
toNano as
|
|
17078
|
+
toNano as toNano9
|
|
17158
17079
|
} from "@ton/ton";
|
|
17159
17080
|
var PtonV1 = class _PtonV1 extends JettonMinter {
|
|
17160
17081
|
static version = pTON_VERSION.v1;
|
|
@@ -17162,7 +17083,7 @@ var PtonV1 = class _PtonV1 extends JettonMinter {
|
|
|
17162
17083
|
"EQCM3B12QK1e4yZSf8GtBRT0aLMNyEsBc_DhVfRRtOEffLez"
|
|
17163
17084
|
);
|
|
17164
17085
|
static gasConstants = {
|
|
17165
|
-
deployWallet:
|
|
17086
|
+
deployWallet: toNano9("1.05")
|
|
17166
17087
|
};
|
|
17167
17088
|
version = _PtonV1.version;
|
|
17168
17089
|
gasConstants;
|
|
@@ -17232,12 +17153,12 @@ var TX_DEADLINE = 15 * 60;
|
|
|
17232
17153
|
// node_modules/@ston-fi/sdk/dist/chunk-ZREZXXSX.js
|
|
17233
17154
|
import {
|
|
17234
17155
|
beginCell as beginCell11,
|
|
17235
|
-
toNano as
|
|
17156
|
+
toNano as toNano10
|
|
17236
17157
|
} from "@ton/ton";
|
|
17237
17158
|
var VaultV2_1 = class _VaultV2_1 extends Contract {
|
|
17238
17159
|
static version = DEX_VERSION.v2_1;
|
|
17239
17160
|
static gasConstants = {
|
|
17240
|
-
withdrawFee:
|
|
17161
|
+
withdrawFee: toNano10("0.3")
|
|
17241
17162
|
};
|
|
17242
17163
|
gasConstants;
|
|
17243
17164
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -17296,14 +17217,14 @@ var VaultV2_1 = class _VaultV2_1 extends Contract {
|
|
|
17296
17217
|
// node_modules/@ston-fi/sdk/dist/chunk-NYDP354Z.js
|
|
17297
17218
|
import {
|
|
17298
17219
|
beginCell as beginCell12,
|
|
17299
|
-
toNano as
|
|
17220
|
+
toNano as toNano11
|
|
17300
17221
|
} from "@ton/ton";
|
|
17301
17222
|
var LpAccountV2_1 = class _LpAccountV2_1 extends Contract {
|
|
17302
17223
|
static version = DEX_VERSION.v2_1;
|
|
17303
17224
|
static gasConstants = {
|
|
17304
|
-
refund:
|
|
17305
|
-
directAddLp:
|
|
17306
|
-
resetGas:
|
|
17225
|
+
refund: toNano11("0.8"),
|
|
17226
|
+
directAddLp: toNano11("0.3"),
|
|
17227
|
+
resetGas: toNano11("0.02")
|
|
17307
17228
|
};
|
|
17308
17229
|
gasConstants;
|
|
17309
17230
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -17390,13 +17311,13 @@ var LpAccountV2_1 = class _LpAccountV2_1 extends Contract {
|
|
|
17390
17311
|
// node_modules/@ston-fi/sdk/dist/chunk-DFPKM3LH.js
|
|
17391
17312
|
import {
|
|
17392
17313
|
beginCell as beginCell13,
|
|
17393
|
-
toNano as
|
|
17314
|
+
toNano as toNano12
|
|
17394
17315
|
} from "@ton/ton";
|
|
17395
17316
|
var BasePoolV2_1 = class _BasePoolV2_1 extends JettonMinter {
|
|
17396
17317
|
static version = DEX_VERSION.v2_1;
|
|
17397
17318
|
static gasConstants = {
|
|
17398
|
-
collectFees:
|
|
17399
|
-
burn:
|
|
17319
|
+
collectFees: toNano12("0.4"),
|
|
17320
|
+
burn: toNano12("0.8")
|
|
17400
17321
|
};
|
|
17401
17322
|
gasConstants;
|
|
17402
17323
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -17492,44 +17413,44 @@ var BasePoolV2_1 = class _BasePoolV2_1 extends JettonMinter {
|
|
|
17492
17413
|
|
|
17493
17414
|
// node_modules/@ston-fi/sdk/dist/chunk-YSYMABVC.js
|
|
17494
17415
|
import {
|
|
17495
|
-
Address as
|
|
17416
|
+
Address as Address12,
|
|
17496
17417
|
beginCell as beginCell14,
|
|
17497
|
-
toNano as
|
|
17418
|
+
toNano as toNano13
|
|
17498
17419
|
} from "@ton/ton";
|
|
17499
17420
|
var BaseRouterV2_1 = class _BaseRouterV2_1 extends Contract {
|
|
17500
17421
|
static version = DEX_VERSION.v2_1;
|
|
17501
17422
|
static gasConstants = {
|
|
17502
17423
|
swapJettonToJetton: {
|
|
17503
|
-
gasAmount:
|
|
17504
|
-
forwardGasAmount:
|
|
17424
|
+
gasAmount: toNano13("0.3"),
|
|
17425
|
+
forwardGasAmount: toNano13("0.24")
|
|
17505
17426
|
},
|
|
17506
17427
|
swapJettonToTon: {
|
|
17507
|
-
gasAmount:
|
|
17508
|
-
forwardGasAmount:
|
|
17428
|
+
gasAmount: toNano13("0.3"),
|
|
17429
|
+
forwardGasAmount: toNano13("0.24")
|
|
17509
17430
|
},
|
|
17510
17431
|
swapTonToJetton: {
|
|
17511
|
-
forwardGasAmount:
|
|
17432
|
+
forwardGasAmount: toNano13("0.3")
|
|
17512
17433
|
},
|
|
17513
17434
|
provideLpJetton: {
|
|
17514
|
-
gasAmount:
|
|
17515
|
-
forwardGasAmount:
|
|
17435
|
+
gasAmount: toNano13("0.3"),
|
|
17436
|
+
forwardGasAmount: toNano13("0.235")
|
|
17516
17437
|
},
|
|
17517
17438
|
provideLpTon: {
|
|
17518
|
-
forwardGasAmount:
|
|
17439
|
+
forwardGasAmount: toNano13("0.3")
|
|
17519
17440
|
},
|
|
17520
17441
|
singleSideProvideLpJetton: {
|
|
17521
|
-
gasAmount:
|
|
17522
|
-
forwardGasAmount:
|
|
17442
|
+
gasAmount: toNano13("1"),
|
|
17443
|
+
forwardGasAmount: toNano13("0.8")
|
|
17523
17444
|
},
|
|
17524
17445
|
singleSideProvideLpTon: {
|
|
17525
|
-
forwardGasAmount:
|
|
17446
|
+
forwardGasAmount: toNano13("0.8")
|
|
17526
17447
|
}
|
|
17527
17448
|
};
|
|
17528
17449
|
gasConstants;
|
|
17529
17450
|
txDeadline;
|
|
17530
17451
|
constructor(address4, { gasConstants, txDeadline, ...options } = {}) {
|
|
17531
17452
|
super(address4, options);
|
|
17532
|
-
if (this.address.equals(
|
|
17453
|
+
if (this.address.equals(Address12.parse(ROUTER_ADDRESS))) {
|
|
17533
17454
|
throw Error(
|
|
17534
17455
|
[
|
|
17535
17456
|
"You are trying to create an instance v2.1 Router with a v1 address",
|
|
@@ -17904,21 +17825,21 @@ var StablePoolV2_1 = class extends BasePoolV2_1 {
|
|
|
17904
17825
|
};
|
|
17905
17826
|
|
|
17906
17827
|
// node_modules/@ston-fi/sdk/dist/chunk-VFE4LTGM.js
|
|
17907
|
-
import { toNano as
|
|
17828
|
+
import { toNano as toNano14 } from "@ton/ton";
|
|
17908
17829
|
var StableRouterV2_1 = class _StableRouterV2_1 extends BaseRouterV2_1 {
|
|
17909
17830
|
static dexType = DEX_TYPE.Stable;
|
|
17910
17831
|
static gasConstants = {
|
|
17911
17832
|
...BaseRouterV2_1.gasConstants,
|
|
17912
17833
|
swapJettonToJetton: {
|
|
17913
|
-
gasAmount:
|
|
17914
|
-
forwardGasAmount:
|
|
17834
|
+
gasAmount: toNano14("0.329"),
|
|
17835
|
+
forwardGasAmount: toNano14("0.269")
|
|
17915
17836
|
},
|
|
17916
17837
|
swapJettonToTon: {
|
|
17917
|
-
gasAmount:
|
|
17918
|
-
forwardGasAmount:
|
|
17838
|
+
gasAmount: toNano14("0.329"),
|
|
17839
|
+
forwardGasAmount: toNano14("0.269")
|
|
17919
17840
|
},
|
|
17920
17841
|
swapTonToJetton: {
|
|
17921
|
-
forwardGasAmount:
|
|
17842
|
+
forwardGasAmount: toNano14("0.329")
|
|
17922
17843
|
}
|
|
17923
17844
|
};
|
|
17924
17845
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -17951,21 +17872,21 @@ var WCPIPoolV2_1 = class extends BasePoolV2_1 {
|
|
|
17951
17872
|
};
|
|
17952
17873
|
|
|
17953
17874
|
// node_modules/@ston-fi/sdk/dist/chunk-FU2GQY36.js
|
|
17954
|
-
import { toNano as
|
|
17875
|
+
import { toNano as toNano15 } from "@ton/ton";
|
|
17955
17876
|
var WCPIRouterV2_1 = class _WCPIRouterV2_1 extends BaseRouterV2_1 {
|
|
17956
17877
|
static dexType = DEX_TYPE.WCPI;
|
|
17957
17878
|
static gasConstants = {
|
|
17958
17879
|
...BaseRouterV2_1.gasConstants,
|
|
17959
17880
|
swapJettonToJetton: {
|
|
17960
|
-
gasAmount:
|
|
17961
|
-
forwardGasAmount:
|
|
17881
|
+
gasAmount: toNano15("0.319"),
|
|
17882
|
+
forwardGasAmount: toNano15("0.259")
|
|
17962
17883
|
},
|
|
17963
17884
|
swapJettonToTon: {
|
|
17964
|
-
gasAmount:
|
|
17965
|
-
forwardGasAmount:
|
|
17885
|
+
gasAmount: toNano15("0.319"),
|
|
17886
|
+
forwardGasAmount: toNano15("0.259")
|
|
17966
17887
|
},
|
|
17967
17888
|
swapTonToJetton: {
|
|
17968
|
-
forwardGasAmount:
|
|
17889
|
+
forwardGasAmount: toNano15("0.319")
|
|
17969
17890
|
}
|
|
17970
17891
|
};
|
|
17971
17892
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -18002,21 +17923,21 @@ var WStablePoolV2_1 = class extends BasePoolV2_1 {
|
|
|
18002
17923
|
};
|
|
18003
17924
|
|
|
18004
17925
|
// node_modules/@ston-fi/sdk/dist/chunk-KTS34XTO.js
|
|
18005
|
-
import { toNano as
|
|
17926
|
+
import { toNano as toNano16 } from "@ton/ton";
|
|
18006
17927
|
var WStableRouterV2_1 = class _WStableRouterV2_1 extends BaseRouterV2_1 {
|
|
18007
17928
|
static dexType = DEX_TYPE.WStable;
|
|
18008
17929
|
static gasConstants = {
|
|
18009
17930
|
...BaseRouterV2_1.gasConstants,
|
|
18010
17931
|
swapJettonToJetton: {
|
|
18011
|
-
gasAmount:
|
|
18012
|
-
forwardGasAmount:
|
|
17932
|
+
gasAmount: toNano16("0.479"),
|
|
17933
|
+
forwardGasAmount: toNano16("0.419")
|
|
18013
17934
|
},
|
|
18014
17935
|
swapJettonToTon: {
|
|
18015
|
-
gasAmount:
|
|
18016
|
-
forwardGasAmount:
|
|
17936
|
+
gasAmount: toNano16("0.479"),
|
|
17937
|
+
forwardGasAmount: toNano16("0.419")
|
|
18017
17938
|
},
|
|
18018
17939
|
swapTonToJetton: {
|
|
18019
|
-
forwardGasAmount:
|
|
17940
|
+
forwardGasAmount: toNano16("0.479")
|
|
18020
17941
|
}
|
|
18021
17942
|
};
|
|
18022
17943
|
constructor(address4, { gasConstants, ...options } = {}) {
|
|
@@ -18046,13 +17967,13 @@ var pTON_OP_CODES2 = {
|
|
|
18046
17967
|
// node_modules/@ston-fi/sdk/dist/chunk-4OOOZ56G.js
|
|
18047
17968
|
import {
|
|
18048
17969
|
beginCell as beginCell15,
|
|
18049
|
-
toNano as
|
|
17970
|
+
toNano as toNano17
|
|
18050
17971
|
} from "@ton/ton";
|
|
18051
17972
|
var PtonV2_1 = class _PtonV2_1 extends PtonV1 {
|
|
18052
17973
|
static version = pTON_VERSION.v2_1;
|
|
18053
17974
|
static gasConstants = {
|
|
18054
|
-
tonTransfer:
|
|
18055
|
-
deployWallet:
|
|
17975
|
+
tonTransfer: toNano17("0.01"),
|
|
17976
|
+
deployWallet: toNano17("0.1")
|
|
18056
17977
|
};
|
|
18057
17978
|
version = _PtonV2_1.version;
|
|
18058
17979
|
gasConstants;
|
|
@@ -18326,7 +18247,7 @@ var log111 = createLogger("Tools");
|
|
|
18326
18247
|
var NATIVE_TON_ADDRESS2 = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
18327
18248
|
var stonfiSwapTool = {
|
|
18328
18249
|
name: "stonfi_swap",
|
|
18329
|
-
description: "
|
|
18250
|
+
description: "Execute a token swap on STON.fi. Supports TON<->jetton and jetton<->jetton. Use stonfi_quote first to preview.",
|
|
18330
18251
|
parameters: Type90.Object({
|
|
18331
18252
|
from_asset: Type90.String({
|
|
18332
18253
|
description: "Source asset: 'ton' for TON, or jetton master address (EQ... format)"
|
|
@@ -18373,7 +18294,7 @@ var stonfiSwapExecutor = async (params, context) => {
|
|
|
18373
18294
|
};
|
|
18374
18295
|
}
|
|
18375
18296
|
const endpoint = await getCachedHttpEndpoint();
|
|
18376
|
-
const tonClient = new
|
|
18297
|
+
const tonClient = new TonClient8({ endpoint });
|
|
18377
18298
|
const stonApiClient = new StonApiClient();
|
|
18378
18299
|
const fromAssetInfo = await stonApiClient.getAsset(fromAddress);
|
|
18379
18300
|
const fromDecimals = fromAssetInfo?.decimals ?? 9;
|
|
@@ -18401,7 +18322,7 @@ var stonfiSwapExecutor = async (params, context) => {
|
|
|
18401
18322
|
if (!keyPair) {
|
|
18402
18323
|
return { success: false, error: "Wallet key derivation failed." };
|
|
18403
18324
|
}
|
|
18404
|
-
const wallet =
|
|
18325
|
+
const wallet = WalletContractV5R16.create({
|
|
18405
18326
|
workchain: 0,
|
|
18406
18327
|
publicKey: keyPair.publicKey
|
|
18407
18328
|
});
|
|
@@ -18410,7 +18331,7 @@ var stonfiSwapExecutor = async (params, context) => {
|
|
|
18410
18331
|
let txParams;
|
|
18411
18332
|
if (isTonInput) {
|
|
18412
18333
|
const balance = await tonClient.getBalance(wallet.address);
|
|
18413
|
-
const requiredAmount = BigInt(simulationResult.offerUnits) +
|
|
18334
|
+
const requiredAmount = BigInt(simulationResult.offerUnits) + toNano18("0.3");
|
|
18414
18335
|
if (balance < requiredAmount) {
|
|
18415
18336
|
return {
|
|
18416
18337
|
success: false,
|
|
@@ -18437,9 +18358,9 @@ var stonfiSwapExecutor = async (params, context) => {
|
|
|
18437
18358
|
await walletContract.sendTransfer({
|
|
18438
18359
|
seqno,
|
|
18439
18360
|
secretKey: keyPair.secretKey,
|
|
18440
|
-
sendMode:
|
|
18361
|
+
sendMode: SendMode6.PAY_GAS_SEPARATELY + SendMode6.IGNORE_ERRORS,
|
|
18441
18362
|
messages: [
|
|
18442
|
-
|
|
18363
|
+
internal6({
|
|
18443
18364
|
to: txParams.to,
|
|
18444
18365
|
value: txParams.value,
|
|
18445
18366
|
body: txParams.body,
|
|
@@ -18483,7 +18404,7 @@ var log112 = createLogger("Tools");
|
|
|
18483
18404
|
var NATIVE_TON_ADDRESS3 = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
18484
18405
|
var stonfiQuoteTool = {
|
|
18485
18406
|
name: "stonfi_quote",
|
|
18486
|
-
description: "Get a price quote
|
|
18407
|
+
description: "Get a swap price quote on STON.fi without executing. Use stonfi_swap to execute.",
|
|
18487
18408
|
category: "data-bearing",
|
|
18488
18409
|
parameters: Type91.Object({
|
|
18489
18410
|
from_asset: Type91.String({
|
|
@@ -18594,7 +18515,7 @@ import { Type as Type92 } from "@sinclair/typebox";
|
|
|
18594
18515
|
var log113 = createLogger("Tools");
|
|
18595
18516
|
var stonfiSearchTool = {
|
|
18596
18517
|
name: "stonfi_search",
|
|
18597
|
-
description: "Search for
|
|
18518
|
+
description: "Search for jettons by name or symbol. Returns addresses for use in swap/price tools.",
|
|
18598
18519
|
category: "data-bearing",
|
|
18599
18520
|
parameters: Type92.Object({
|
|
18600
18521
|
query: Type92.String({
|
|
@@ -18715,7 +18636,7 @@ import { Type as Type93 } from "@sinclair/typebox";
|
|
|
18715
18636
|
var log114 = createLogger("Tools");
|
|
18716
18637
|
var stonfiTrendingTool = {
|
|
18717
18638
|
name: "stonfi_trending",
|
|
18718
|
-
description: "Get trending
|
|
18639
|
+
description: "Get trending jettons ranked by popularity on STON.fi.",
|
|
18719
18640
|
category: "data-bearing",
|
|
18720
18641
|
parameters: Type93.Object({
|
|
18721
18642
|
limit: Type93.Optional(
|
|
@@ -18790,7 +18711,7 @@ import { Type as Type94 } from "@sinclair/typebox";
|
|
|
18790
18711
|
var log115 = createLogger("Tools");
|
|
18791
18712
|
var stonfiPoolsTool = {
|
|
18792
18713
|
name: "stonfi_pools",
|
|
18793
|
-
description: "
|
|
18714
|
+
description: "List STON.fi liquidity pools. Filter by jetton or get top pools by volume.",
|
|
18794
18715
|
category: "data-bearing",
|
|
18795
18716
|
parameters: Type94.Object({
|
|
18796
18717
|
jetton_address: Type94.Optional(
|
|
@@ -18910,13 +18831,13 @@ var tools18 = [
|
|
|
18910
18831
|
|
|
18911
18832
|
// src/agent/tools/dedust/quote.ts
|
|
18912
18833
|
import { Type as Type95 } from "@sinclair/typebox";
|
|
18913
|
-
import { TonClient as
|
|
18914
|
-
import { Address as
|
|
18834
|
+
import { TonClient as TonClient9 } from "@ton/ton";
|
|
18835
|
+
import { Address as Address13 } from "@ton/core";
|
|
18915
18836
|
import { Factory as Factory2, Asset as Asset2, PoolType as PoolType2, ReadinessStatus as ReadinessStatus2 } from "@dedust/sdk";
|
|
18916
18837
|
var log116 = createLogger("Tools");
|
|
18917
18838
|
var dedustQuoteTool = {
|
|
18918
18839
|
name: "dedust_quote",
|
|
18919
|
-
description: "Get a price quote for a token swap on DeDust DEX
|
|
18840
|
+
description: "Get a price quote for a token swap on DeDust DEX without executing it. Use 'ton' for TON or jetton master address.",
|
|
18920
18841
|
category: "data-bearing",
|
|
18921
18842
|
parameters: Type95.Object({
|
|
18922
18843
|
from_asset: Type95.String({
|
|
@@ -18952,7 +18873,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
18952
18873
|
let toAssetAddr = to_asset;
|
|
18953
18874
|
if (!isTonInput) {
|
|
18954
18875
|
try {
|
|
18955
|
-
fromAssetAddr =
|
|
18876
|
+
fromAssetAddr = Address13.parse(from_asset).toString();
|
|
18956
18877
|
} catch (error) {
|
|
18957
18878
|
return {
|
|
18958
18879
|
success: false,
|
|
@@ -18962,7 +18883,7 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
18962
18883
|
}
|
|
18963
18884
|
if (!isTonOutput) {
|
|
18964
18885
|
try {
|
|
18965
|
-
toAssetAddr =
|
|
18886
|
+
toAssetAddr = Address13.parse(to_asset).toString();
|
|
18966
18887
|
} catch (error) {
|
|
18967
18888
|
return {
|
|
18968
18889
|
success: false,
|
|
@@ -18971,12 +18892,12 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
18971
18892
|
}
|
|
18972
18893
|
}
|
|
18973
18894
|
const endpoint = await getCachedHttpEndpoint();
|
|
18974
|
-
const tonClient = new
|
|
18895
|
+
const tonClient = new TonClient9({ endpoint });
|
|
18975
18896
|
const factory = tonClient.open(
|
|
18976
|
-
Factory2.createFromAddress(
|
|
18897
|
+
Factory2.createFromAddress(Address13.parse(DEDUST_FACTORY_MAINNET))
|
|
18977
18898
|
);
|
|
18978
|
-
const fromAsset = isTonInput ? Asset2.native() : Asset2.jetton(
|
|
18979
|
-
const toAsset = isTonOutput ? Asset2.native() : Asset2.jetton(
|
|
18899
|
+
const fromAsset = isTonInput ? Asset2.native() : Asset2.jetton(Address13.parse(fromAssetAddr));
|
|
18900
|
+
const toAsset = isTonOutput ? Asset2.native() : Asset2.jetton(Address13.parse(toAssetAddr));
|
|
18980
18901
|
const poolTypeEnum = pool_type === "stable" ? PoolType2.STABLE : PoolType2.VOLATILE;
|
|
18981
18902
|
const pool = tonClient.open(await factory.getPool(poolTypeEnum, [fromAsset, toAsset]));
|
|
18982
18903
|
const readinessStatus = await pool.getReadinessStatus();
|
|
@@ -19053,13 +18974,13 @@ var dedustQuoteExecutor = async (params, context) => {
|
|
|
19053
18974
|
|
|
19054
18975
|
// src/agent/tools/dedust/swap.ts
|
|
19055
18976
|
import { Type as Type96 } from "@sinclair/typebox";
|
|
19056
|
-
import { WalletContractV5R1 as
|
|
19057
|
-
import { Address as
|
|
18977
|
+
import { WalletContractV5R1 as WalletContractV5R17, TonClient as TonClient10, toNano as toNano19, fromNano as fromNano3 } from "@ton/ton";
|
|
18978
|
+
import { Address as Address14 } from "@ton/core";
|
|
19058
18979
|
import { Factory as Factory3, Asset as Asset3, PoolType as PoolType3, ReadinessStatus as ReadinessStatus3, JettonRoot, VaultJetton } from "@dedust/sdk";
|
|
19059
18980
|
var log117 = createLogger("Tools");
|
|
19060
18981
|
var dedustSwapTool = {
|
|
19061
18982
|
name: "dedust_swap",
|
|
19062
|
-
description: "Execute a token swap on DeDust
|
|
18983
|
+
description: "Execute a token swap on DeDust. Supports TON<->jetton and jetton<->jetton. Use dedust_quote first to preview.",
|
|
19063
18984
|
parameters: Type96.Object({
|
|
19064
18985
|
from_asset: Type96.String({
|
|
19065
18986
|
description: "Source asset: 'ton' for TON, or jetton master address (EQ... format)"
|
|
@@ -19101,7 +19022,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
19101
19022
|
let toAssetAddr = to_asset;
|
|
19102
19023
|
if (!isTonInput) {
|
|
19103
19024
|
try {
|
|
19104
|
-
fromAssetAddr =
|
|
19025
|
+
fromAssetAddr = Address14.parse(from_asset).toString();
|
|
19105
19026
|
} catch (error) {
|
|
19106
19027
|
return {
|
|
19107
19028
|
success: false,
|
|
@@ -19111,7 +19032,7 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
19111
19032
|
}
|
|
19112
19033
|
if (!isTonOutput) {
|
|
19113
19034
|
try {
|
|
19114
|
-
toAssetAddr =
|
|
19035
|
+
toAssetAddr = Address14.parse(to_asset).toString();
|
|
19115
19036
|
} catch (error) {
|
|
19116
19037
|
return {
|
|
19117
19038
|
success: false,
|
|
@@ -19120,12 +19041,12 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
19120
19041
|
}
|
|
19121
19042
|
}
|
|
19122
19043
|
const endpoint = await getCachedHttpEndpoint();
|
|
19123
|
-
const tonClient = new
|
|
19044
|
+
const tonClient = new TonClient10({ endpoint });
|
|
19124
19045
|
const factory = tonClient.open(
|
|
19125
|
-
Factory3.createFromAddress(
|
|
19046
|
+
Factory3.createFromAddress(Address14.parse(DEDUST_FACTORY_MAINNET))
|
|
19126
19047
|
);
|
|
19127
|
-
const fromAssetObj = isTonInput ? Asset3.native() : Asset3.jetton(
|
|
19128
|
-
const toAssetObj = isTonOutput ? Asset3.native() : Asset3.jetton(
|
|
19048
|
+
const fromAssetObj = isTonInput ? Asset3.native() : Asset3.jetton(Address14.parse(fromAssetAddr));
|
|
19049
|
+
const toAssetObj = isTonOutput ? Asset3.native() : Asset3.jetton(Address14.parse(toAssetAddr));
|
|
19129
19050
|
const poolTypeEnum = pool_type === "stable" ? PoolType3.STABLE : PoolType3.VOLATILE;
|
|
19130
19051
|
const pool = tonClient.open(await factory.getPool(poolTypeEnum, [fromAssetObj, toAssetObj]));
|
|
19131
19052
|
const readinessStatus = await pool.getReadinessStatus();
|
|
@@ -19147,15 +19068,15 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
19147
19068
|
if (!keyPair) {
|
|
19148
19069
|
return { success: false, error: "Wallet key derivation failed." };
|
|
19149
19070
|
}
|
|
19150
|
-
const wallet =
|
|
19071
|
+
const wallet = WalletContractV5R17.create({
|
|
19151
19072
|
workchain: 0,
|
|
19152
19073
|
publicKey: keyPair.publicKey
|
|
19153
19074
|
});
|
|
19154
19075
|
const walletContract = tonClient.open(wallet);
|
|
19155
19076
|
const sender = walletContract.sender(keyPair.secretKey);
|
|
19156
19077
|
if (isTonInput) {
|
|
19157
|
-
const balance = await tonClient.getBalance(
|
|
19158
|
-
const requiredAmount = amountIn +
|
|
19078
|
+
const balance = await tonClient.getBalance(Address14.parse(walletData.address));
|
|
19079
|
+
const requiredAmount = amountIn + toNano19(DEDUST_GAS.SWAP_TON_TO_JETTON);
|
|
19159
19080
|
if (balance < requiredAmount) {
|
|
19160
19081
|
return {
|
|
19161
19082
|
success: false,
|
|
@@ -19174,10 +19095,10 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
19174
19095
|
poolAddress: pool.address,
|
|
19175
19096
|
amount: amountIn,
|
|
19176
19097
|
limit: minAmountOut,
|
|
19177
|
-
gasAmount:
|
|
19098
|
+
gasAmount: toNano19(DEDUST_GAS.SWAP_TON_TO_JETTON)
|
|
19178
19099
|
});
|
|
19179
19100
|
} else {
|
|
19180
|
-
const jettonAddress =
|
|
19101
|
+
const jettonAddress = Address14.parse(fromAssetAddr);
|
|
19181
19102
|
const jettonVault = tonClient.open(await factory.getJettonVault(jettonAddress));
|
|
19182
19103
|
const vaultStatus = await jettonVault.getReadinessStatus();
|
|
19183
19104
|
if (vaultStatus !== ReadinessStatus3.READY) {
|
|
@@ -19188,17 +19109,17 @@ var dedustSwapExecutor = async (params, context) => {
|
|
|
19188
19109
|
}
|
|
19189
19110
|
const jettonRoot = tonClient.open(JettonRoot.createFromAddress(jettonAddress));
|
|
19190
19111
|
const jettonWallet = tonClient.open(
|
|
19191
|
-
await jettonRoot.getWallet(
|
|
19112
|
+
await jettonRoot.getWallet(Address14.parse(walletData.address))
|
|
19192
19113
|
);
|
|
19193
19114
|
const swapPayload = VaultJetton.createSwapPayload({
|
|
19194
19115
|
poolAddress: pool.address,
|
|
19195
19116
|
limit: minAmountOut
|
|
19196
19117
|
});
|
|
19197
|
-
await jettonWallet.sendTransfer(sender,
|
|
19118
|
+
await jettonWallet.sendTransfer(sender, toNano19(DEDUST_GAS.SWAP_JETTON_TO_ANY), {
|
|
19198
19119
|
destination: jettonVault.address,
|
|
19199
19120
|
amount: amountIn,
|
|
19200
|
-
responseAddress:
|
|
19201
|
-
forwardAmount:
|
|
19121
|
+
responseAddress: Address14.parse(walletData.address),
|
|
19122
|
+
forwardAmount: toNano19(DEDUST_GAS.FORWARD_GAS),
|
|
19202
19123
|
forwardPayload: swapPayload
|
|
19203
19124
|
});
|
|
19204
19125
|
}
|
|
@@ -19240,7 +19161,7 @@ import { Type as Type97 } from "@sinclair/typebox";
|
|
|
19240
19161
|
var log118 = createLogger("Tools");
|
|
19241
19162
|
var dedustPoolsTool = {
|
|
19242
19163
|
name: "dedust_pools",
|
|
19243
|
-
description: "List liquidity pools
|
|
19164
|
+
description: "List DeDust liquidity pools. Filter by jetton address or pool type.",
|
|
19244
19165
|
category: "data-bearing",
|
|
19245
19166
|
parameters: Type97.Object({
|
|
19246
19167
|
jetton_address: Type97.Optional(
|
|
@@ -19369,7 +19290,7 @@ import { Type as Type98 } from "@sinclair/typebox";
|
|
|
19369
19290
|
var log119 = createLogger("Tools");
|
|
19370
19291
|
var dedustPricesTool = {
|
|
19371
19292
|
name: "dedust_prices",
|
|
19372
|
-
description: "Get real-time token prices from DeDust
|
|
19293
|
+
description: "Get real-time token prices from DeDust. Optionally filter by symbol(s).",
|
|
19373
19294
|
category: "data-bearing",
|
|
19374
19295
|
parameters: Type98.Object({
|
|
19375
19296
|
symbols: Type98.Optional(
|
|
@@ -19431,7 +19352,7 @@ import { Type as Type99 } from "@sinclair/typebox";
|
|
|
19431
19352
|
var log120 = createLogger("Tools");
|
|
19432
19353
|
var dedustTokenInfoTool = {
|
|
19433
19354
|
name: "dedust_token_info",
|
|
19434
|
-
description: "Get
|
|
19355
|
+
description: "Get jetton info from DeDust: metadata, top holders, top traders, largest buys. Accepts address or symbol.",
|
|
19435
19356
|
category: "data-bearing",
|
|
19436
19357
|
parameters: Type99.Object({
|
|
19437
19358
|
token: Type99.String({
|
|
@@ -19575,21 +19496,7 @@ var tools19 = [
|
|
|
19575
19496
|
import { Type as Type100 } from "@sinclair/typebox";
|
|
19576
19497
|
var journalLogTool = {
|
|
19577
19498
|
name: "journal_log",
|
|
19578
|
-
description:
|
|
19579
|
-
|
|
19580
|
-
Use this to record:
|
|
19581
|
-
- **trade**: Crypto swaps, buy/sell operations
|
|
19582
|
-
- **gift**: Gift purchases, sales, or exchanges
|
|
19583
|
-
- **middleman**: Escrow services (record both sides if applicable)
|
|
19584
|
-
- **kol**: Posts, moderation, bullposting services
|
|
19585
|
-
|
|
19586
|
-
ALWAYS include 'reasoning' to explain WHY you took this action.
|
|
19587
|
-
|
|
19588
|
-
Examples:
|
|
19589
|
-
- trade: "Bought TON dip (-28% in 72h), community active, narrative fits ecosystem"
|
|
19590
|
-
- gift: "Sold Deluxe Heart at 120% floor - buyer was eager"
|
|
19591
|
-
- middleman: "Escrow for 150 TON gift trade - 3% fee"
|
|
19592
|
-
- kol: "Posted project review in channel - 75 TON fee"`,
|
|
19499
|
+
description: "Log a business operation (trade, gift, middleman, kol) to the journal. Always include reasoning.",
|
|
19593
19500
|
parameters: Type100.Object({
|
|
19594
19501
|
type: Type100.Union(
|
|
19595
19502
|
[Type100.Literal("trade"), Type100.Literal("gift"), Type100.Literal("middleman"), Type100.Literal("kol")],
|
|
@@ -19690,19 +19597,7 @@ var journalLogExecutor = async (params, context) => {
|
|
|
19690
19597
|
import { Type as Type101 } from "@sinclair/typebox";
|
|
19691
19598
|
var journalQueryTool = {
|
|
19692
19599
|
name: "journal_query",
|
|
19693
|
-
description:
|
|
19694
|
-
|
|
19695
|
-
Use this to:
|
|
19696
|
-
- Review recent trades, gifts, or services
|
|
19697
|
-
- Analyze performance (win rate, P&L)
|
|
19698
|
-
- Find specific operations by asset or outcome
|
|
19699
|
-
- Learn from past decisions (read the 'reasoning' field!)
|
|
19700
|
-
|
|
19701
|
-
Examples:
|
|
19702
|
-
- "Show me my last 10 trades"
|
|
19703
|
-
- "What gifts did I sell this week?"
|
|
19704
|
-
- "Show all profitable TON trades"
|
|
19705
|
-
- "What's my win rate on crypto trades?"`,
|
|
19600
|
+
description: "Query the trading journal. Filter by type/asset/outcome/period. Includes P&L summary.",
|
|
19706
19601
|
category: "data-bearing",
|
|
19707
19602
|
parameters: Type101.Object({
|
|
19708
19603
|
type: Type101.Optional(
|
|
@@ -19826,22 +19721,7 @@ var journalQueryExecutor = async (params) => {
|
|
|
19826
19721
|
import { Type as Type102 } from "@sinclair/typebox";
|
|
19827
19722
|
var journalUpdateTool = {
|
|
19828
19723
|
name: "journal_update",
|
|
19829
|
-
description:
|
|
19830
|
-
|
|
19831
|
-
Use this to:
|
|
19832
|
-
- Close pending operations with final results
|
|
19833
|
-
- Record profit/loss after selling or closing a position
|
|
19834
|
-
- Update transaction hash after confirmation
|
|
19835
|
-
- Mark operations as cancelled
|
|
19836
|
-
|
|
19837
|
-
ALWAYS calculate P&L when closing trades:
|
|
19838
|
-
- pnl_ton = final value in TON - initial cost in TON
|
|
19839
|
-
- pnl_pct = (pnl_ton / initial_cost) * 100
|
|
19840
|
-
|
|
19841
|
-
Examples:
|
|
19842
|
-
- "Close trade #42 - sold at profit"
|
|
19843
|
-
- "Mark gift sale #38 as complete"
|
|
19844
|
-
- "Update escrow #55 with tx hash"`,
|
|
19724
|
+
description: "Update a journal entry with outcome, P&L, or tx_hash. Auto-sets closed_at when outcome changes from pending.",
|
|
19845
19725
|
parameters: Type102.Object({
|
|
19846
19726
|
id: Type102.Number({ description: "Journal entry ID to update" }),
|
|
19847
19727
|
outcome: Type102.Optional(
|
|
@@ -19934,16 +19814,7 @@ import { readdirSync as readdirSync2, lstatSync } from "fs";
|
|
|
19934
19814
|
import { join as join7 } from "path";
|
|
19935
19815
|
var workspaceListTool = {
|
|
19936
19816
|
name: "workspace_list",
|
|
19937
|
-
description:
|
|
19938
|
-
|
|
19939
|
-
Your workspace is at ~/.teleton/workspace/ and contains:
|
|
19940
|
-
- SOUL.md, MEMORY.md, IDENTITY.md (config files)
|
|
19941
|
-
- memory/ (daily logs)
|
|
19942
|
-
- downloads/ (downloaded media)
|
|
19943
|
-
- uploads/ (files to send)
|
|
19944
|
-
- temp/ (temporary files)
|
|
19945
|
-
|
|
19946
|
-
You can ONLY access files within this workspace. Files outside (config.yaml, wallet.json, etc.) are protected.`,
|
|
19817
|
+
description: "List files and directories in the workspace.",
|
|
19947
19818
|
category: "data-bearing",
|
|
19948
19819
|
parameters: Type103.Object({
|
|
19949
19820
|
path: Type103.Optional(
|
|
@@ -20033,18 +19904,7 @@ import { Type as Type104 } from "@sinclair/typebox";
|
|
|
20033
19904
|
import { readFileSync as readFileSync8, lstatSync as lstatSync2 } from "fs";
|
|
20034
19905
|
var workspaceReadTool = {
|
|
20035
19906
|
name: "workspace_read",
|
|
20036
|
-
description:
|
|
20037
|
-
|
|
20038
|
-
You can ONLY read files within ~/.teleton/workspace/. Protected files like config.yaml, wallet.json, and telegram_session.txt are NOT accessible.
|
|
20039
|
-
|
|
20040
|
-
Supported files:
|
|
20041
|
-
- Text files (.md, .txt, .json, .csv)
|
|
20042
|
-
- Use encoding="base64" for binary files
|
|
20043
|
-
|
|
20044
|
-
Examples:
|
|
20045
|
-
- Read your memory: path="MEMORY.md"
|
|
20046
|
-
- Read today's log: path="memory/2024-01-15.md"
|
|
20047
|
-
- Read downloaded image info: path="downloads/image.jpg" (will return metadata only)`,
|
|
19907
|
+
description: "Read a file from workspace. Only ~/.teleton/workspace/ is accessible. Use encoding='base64' for binary files.",
|
|
20048
19908
|
category: "data-bearing",
|
|
20049
19909
|
parameters: Type104.Object({
|
|
20050
19910
|
path: Type104.String({
|
|
@@ -20137,18 +19997,7 @@ import { writeFileSync as writeFileSync6, appendFileSync as appendFileSync2, mkd
|
|
|
20137
19997
|
import { dirname as dirname3 } from "path";
|
|
20138
19998
|
var workspaceWriteTool = {
|
|
20139
19999
|
name: "workspace_write",
|
|
20140
|
-
description:
|
|
20141
|
-
|
|
20142
|
-
You can ONLY write files within ~/.teleton/workspace/. This includes:
|
|
20143
|
-
- memory/ - Daily logs and notes
|
|
20144
|
-
- uploads/ - Files to send
|
|
20145
|
-
- temp/ - Temporary files
|
|
20146
|
-
|
|
20147
|
-
You CANNOT write to protected locations like config.yaml, wallet.json, etc.
|
|
20148
|
-
|
|
20149
|
-
Examples:
|
|
20150
|
-
- Save a note: path="memory/note.md", content="..."
|
|
20151
|
-
- Prepare upload: path="uploads/message.txt", content="..."`,
|
|
20000
|
+
description: "Write a file to workspace. Only ~/.teleton/workspace/ is writable. Cannot write to protected locations.",
|
|
20152
20001
|
parameters: Type105.Object({
|
|
20153
20002
|
path: Type105.String({
|
|
20154
20003
|
description: "Path to file (relative to workspace root)"
|
|
@@ -20237,16 +20086,7 @@ var PROTECTED_WORKSPACE_FILES = [
|
|
|
20237
20086
|
];
|
|
20238
20087
|
var workspaceDeleteTool = {
|
|
20239
20088
|
name: "workspace_delete",
|
|
20240
|
-
description:
|
|
20241
|
-
|
|
20242
|
-
PROTECTED FILES (cannot delete):
|
|
20243
|
-
- SOUL.md, MEMORY.md, IDENTITY.md, USER.md
|
|
20244
|
-
|
|
20245
|
-
You CAN delete:
|
|
20246
|
-
- Files in memory/, downloads/, uploads/, temp/
|
|
20247
|
-
- Custom files you've created
|
|
20248
|
-
|
|
20249
|
-
Use recursive=true to delete non-empty directories.`,
|
|
20089
|
+
description: "Delete a file or directory from workspace. Cannot delete SOUL.md, MEMORY.md, IDENTITY.md, USER.md.",
|
|
20250
20090
|
parameters: Type106.Object({
|
|
20251
20091
|
path: Type106.String({
|
|
20252
20092
|
description: "Path to file or directory to delete"
|
|
@@ -20313,13 +20153,7 @@ import { join as join8 } from "path";
|
|
|
20313
20153
|
var MEMES_DIR = WORKSPACE_PATHS.MEMES_DIR;
|
|
20314
20154
|
var workspaceInfoTool = {
|
|
20315
20155
|
name: "workspace_info",
|
|
20316
|
-
description:
|
|
20317
|
-
|
|
20318
|
-
Returns:
|
|
20319
|
-
- Workspace root path
|
|
20320
|
-
- Directory structure
|
|
20321
|
-
- File counts and sizes
|
|
20322
|
-
- Usage limits`,
|
|
20156
|
+
description: "Get workspace structure, file counts, sizes, and usage limits.",
|
|
20323
20157
|
category: "data-bearing",
|
|
20324
20158
|
parameters: Type107.Object({
|
|
20325
20159
|
detailed: Type107.Optional(
|
|
@@ -20428,19 +20262,7 @@ import { dirname as dirname4 } from "path";
|
|
|
20428
20262
|
import { mkdirSync as mkdirSync6 } from "fs";
|
|
20429
20263
|
var workspaceRenameTool = {
|
|
20430
20264
|
name: "workspace_rename",
|
|
20431
|
-
description:
|
|
20432
|
-
|
|
20433
|
-
Use this to:
|
|
20434
|
-
- Give meaningful names to downloaded files
|
|
20435
|
-
- Organize files into subdirectories
|
|
20436
|
-
- Rename Telegram downloads (default names like "123_456_789.jpg" are hard to track)
|
|
20437
|
-
|
|
20438
|
-
Examples:
|
|
20439
|
-
- Rename: from="downloads/123_456_789.jpg", to="downloads/alice_profile.jpg"
|
|
20440
|
-
- Move: from="downloads/photo.jpg", to="uploads/photo.jpg"
|
|
20441
|
-
- Organize: from="downloads/doc.pdf", to="downloads/contracts/2026/lease.pdf"
|
|
20442
|
-
|
|
20443
|
-
CANNOT move/rename files outside workspace or to protected locations.`,
|
|
20265
|
+
description: "Rename or move a file within workspace. Creates parent directories as needed.",
|
|
20444
20266
|
parameters: Type108.Object({
|
|
20445
20267
|
from: Type108.String({
|
|
20446
20268
|
description: "Current path of the file (relative to workspace)"
|
|
@@ -20514,18 +20336,7 @@ import { Type as Type109 } from "@sinclair/typebox";
|
|
|
20514
20336
|
import { tavily } from "@tavily/core";
|
|
20515
20337
|
var webSearchTool = {
|
|
20516
20338
|
name: "web_search",
|
|
20517
|
-
description:
|
|
20518
|
-
|
|
20519
|
-
Use this to find up-to-date information, verify facts, research topics, or get news.
|
|
20520
|
-
|
|
20521
|
-
Parameters:
|
|
20522
|
-
- query: search query string
|
|
20523
|
-
- count: number of results (default 5, max ${WEB_SEARCH_MAX_RESULTS})
|
|
20524
|
-
- topic: "general" (default), "news", or "finance"
|
|
20525
|
-
|
|
20526
|
-
Examples:
|
|
20527
|
-
- query="TON blockchain latest news", topic="news"
|
|
20528
|
-
- query="bitcoin price today", count=3, topic="finance"`,
|
|
20339
|
+
description: "Search the web. Returns results with title, URL, and content snippet.",
|
|
20529
20340
|
category: "data-bearing",
|
|
20530
20341
|
parameters: Type109.Object({
|
|
20531
20342
|
query: Type109.String({ description: "Search query" }),
|
|
@@ -20587,14 +20398,7 @@ import { tavily as tavily2 } from "@tavily/core";
|
|
|
20587
20398
|
var ALLOWED_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
20588
20399
|
var webFetchTool = {
|
|
20589
20400
|
name: "web_fetch",
|
|
20590
|
-
description:
|
|
20591
|
-
|
|
20592
|
-
Returns clean, readable text extracted from the page \u2014 ideal for reading articles, docs, or links shared by users.
|
|
20593
|
-
Only http/https URLs are allowed. Content is truncated to max_length characters.
|
|
20594
|
-
|
|
20595
|
-
Examples:
|
|
20596
|
-
- url="https://docs.ton.org/develop/overview"
|
|
20597
|
-
- url="https://example.com/article", max_length=10000`,
|
|
20401
|
+
description: "Fetch a web page and extract readable text. HTTP/HTTPS only.",
|
|
20598
20402
|
category: "data-bearing",
|
|
20599
20403
|
parameters: Type110.Object({
|
|
20600
20404
|
url: Type110.String({ description: "URL to fetch (http or https only)" }),
|
|
@@ -21398,7 +21202,7 @@ ${blue} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
|
|
|
21398
21202
|
);
|
|
21399
21203
|
if (this.config.webui.enabled) {
|
|
21400
21204
|
try {
|
|
21401
|
-
const { WebUIServer } = await import("./server-
|
|
21205
|
+
const { WebUIServer } = await import("./server-FOC5P7U6.js");
|
|
21402
21206
|
const mcpServers = () => Object.entries(this.config.mcp.servers).map(([name, serverConfig]) => {
|
|
21403
21207
|
const type = serverConfig.command ? "stdio" : serverConfig.url ? "streamable-http" : "sse";
|
|
21404
21208
|
const target = serverConfig.command ?? serverConfig.url ?? "";
|
|
@@ -21544,7 +21348,7 @@ ${blue} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
|
|
|
21544
21348
|
this.agent.initializeContextBuilder(this.memory.embedder, db2.isVectorSearchReady());
|
|
21545
21349
|
if (this.config.agent.provider === "cocoon") {
|
|
21546
21350
|
try {
|
|
21547
|
-
const { registerCocoonModels } = await import("./client-
|
|
21351
|
+
const { registerCocoonModels } = await import("./client-RTNALK7W.js");
|
|
21548
21352
|
const port = this.config.cocoon?.port ?? 1e4;
|
|
21549
21353
|
const models = await registerCocoonModels(port);
|
|
21550
21354
|
if (models.length === 0) {
|
|
@@ -21566,7 +21370,7 @@ ${blue} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u250
|
|
|
21566
21370
|
}
|
|
21567
21371
|
if (this.config.agent.provider === "local" && this.config.agent.base_url) {
|
|
21568
21372
|
try {
|
|
21569
|
-
const { registerLocalModels } = await import("./client-
|
|
21373
|
+
const { registerLocalModels } = await import("./client-RTNALK7W.js");
|
|
21570
21374
|
const models = await registerLocalModels(this.config.agent.base_url);
|
|
21571
21375
|
if (models.length > 0) {
|
|
21572
21376
|
log125.info(`Discovered ${models.length} local model(s): ${models.join(", ")}`);
|