teleton 0.2.0 → 0.2.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/README.md +8 -0
- package/dist/chunk-DUW5VBAZ.js +133 -0
- package/dist/{chunk-QVTQORZB.js → chunk-KU4Z3TYC.js} +515 -370
- package/dist/cli/index.js +2 -1
- package/dist/index.js +2 -1
- package/dist/{scraper-3TD27Z2F.js → scraper-DSAYK6QJ.js} +9 -126
- package/package.json +1 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initScraperDb
|
|
3
|
+
} from "./chunk-DUW5VBAZ.js";
|
|
1
4
|
import {
|
|
2
5
|
appendToTranscript,
|
|
3
6
|
archiveTranscript,
|
|
@@ -2124,8 +2127,8 @@ function sanitizeSchema(schema) {
|
|
|
2124
2127
|
}
|
|
2125
2128
|
return result;
|
|
2126
2129
|
}
|
|
2127
|
-
function sanitizeToolsForGemini(
|
|
2128
|
-
return
|
|
2130
|
+
function sanitizeToolsForGemini(tools23) {
|
|
2131
|
+
return tools23.map(
|
|
2129
2132
|
(tool) => ({
|
|
2130
2133
|
...tool,
|
|
2131
2134
|
parameters: sanitizeSchema({ ...tool.parameters })
|
|
@@ -2170,11 +2173,11 @@ function getUtilityModel(provider, overrideModel) {
|
|
|
2170
2173
|
async function chatWithContext(config, options) {
|
|
2171
2174
|
const provider = config.provider || "anthropic";
|
|
2172
2175
|
const model = getProviderModel(provider, config.model);
|
|
2173
|
-
const
|
|
2176
|
+
const tools23 = provider === "google" && options.tools ? sanitizeToolsForGemini(options.tools) : options.tools;
|
|
2174
2177
|
const context = {
|
|
2175
2178
|
...options.context,
|
|
2176
2179
|
systemPrompt: options.systemPrompt || options.context.systemPrompt,
|
|
2177
|
-
tools
|
|
2180
|
+
tools: tools23
|
|
2178
2181
|
};
|
|
2179
2182
|
const response = await complete(model, context, {
|
|
2180
2183
|
apiKey: config.api_key,
|
|
@@ -3405,7 +3408,7 @@ ${statsContext}`;
|
|
|
3405
3408
|
const providerMeta = getProviderMetadata(
|
|
3406
3409
|
this.config.agent.provider || "anthropic"
|
|
3407
3410
|
);
|
|
3408
|
-
const
|
|
3411
|
+
const tools23 = this.toolRegistry?.getForContext(isGroup ?? false, providerMeta.toolLimit);
|
|
3409
3412
|
const maxIterations = this.config.agent.max_agentic_iterations || 5;
|
|
3410
3413
|
let iteration = 0;
|
|
3411
3414
|
let overflowResets = 0;
|
|
@@ -3428,7 +3431,7 @@ ${statsContext}`;
|
|
|
3428
3431
|
context: maskedContext,
|
|
3429
3432
|
sessionId: session.sessionId,
|
|
3430
3433
|
persistTranscript: true,
|
|
3431
|
-
tools
|
|
3434
|
+
tools: tools23
|
|
3432
3435
|
});
|
|
3433
3436
|
const assistantMsg = response2.message;
|
|
3434
3437
|
if (assistantMsg.stopReason === "error") {
|
|
@@ -4043,6 +4046,7 @@ import { Api as Api2 } from "telegram";
|
|
|
4043
4046
|
var TelegramBridge = class {
|
|
4044
4047
|
client;
|
|
4045
4048
|
ownUserId;
|
|
4049
|
+
ownUsername;
|
|
4046
4050
|
peerCache = /* @__PURE__ */ new Map();
|
|
4047
4051
|
constructor(config) {
|
|
4048
4052
|
this.client = new TelegramUserClient(config);
|
|
@@ -4055,6 +4059,7 @@ var TelegramBridge = class {
|
|
|
4055
4059
|
const me = this.client.getMe();
|
|
4056
4060
|
if (me) {
|
|
4057
4061
|
this.ownUserId = me.id;
|
|
4062
|
+
this.ownUsername = me.username?.toLowerCase();
|
|
4058
4063
|
}
|
|
4059
4064
|
try {
|
|
4060
4065
|
await this.getDialogs();
|
|
@@ -4092,7 +4097,8 @@ var TelegramBridge = class {
|
|
|
4092
4097
|
*/
|
|
4093
4098
|
async getMessages(chatId, limit = 50) {
|
|
4094
4099
|
try {
|
|
4095
|
-
const
|
|
4100
|
+
const peer = this.peerCache.get(chatId) || chatId;
|
|
4101
|
+
const messages = await this.client.getMessages(peer, { limit });
|
|
4096
4102
|
return await Promise.all(messages.map((msg) => this.parseMessage(msg)));
|
|
4097
4103
|
} catch (error) {
|
|
4098
4104
|
console.error("Error getting messages:", error);
|
|
@@ -4251,7 +4257,10 @@ var TelegramBridge = class {
|
|
|
4251
4257
|
const chatId = msg.chatId?.toString() ?? msg.peerId?.toString() ?? "unknown";
|
|
4252
4258
|
const senderIdBig = msg.senderId ? BigInt(msg.senderId.toString()) : BigInt(0);
|
|
4253
4259
|
const senderId = Number(senderIdBig);
|
|
4254
|
-
|
|
4260
|
+
let mentionsMe = msg.mentioned ?? false;
|
|
4261
|
+
if (!mentionsMe && this.ownUsername && msg.message) {
|
|
4262
|
+
mentionsMe = msg.message.toLowerCase().includes(`@${this.ownUsername}`);
|
|
4263
|
+
}
|
|
4255
4264
|
const isChannel = msg.post ?? false;
|
|
4256
4265
|
const isGroup = !isChannel && chatId.startsWith("-");
|
|
4257
4266
|
if (msg.peerId) {
|
|
@@ -4321,6 +4330,12 @@ var TelegramBridge = class {
|
|
|
4321
4330
|
// Store raw message only if has media (for download)
|
|
4322
4331
|
};
|
|
4323
4332
|
}
|
|
4333
|
+
/**
|
|
4334
|
+
* Get cached peer entity for a chat ID (if available)
|
|
4335
|
+
*/
|
|
4336
|
+
getPeer(chatId) {
|
|
4337
|
+
return this.peerCache.get(chatId);
|
|
4338
|
+
}
|
|
4324
4339
|
/**
|
|
4325
4340
|
* Get the underlying client
|
|
4326
4341
|
*/
|
|
@@ -4690,6 +4705,11 @@ var MessageHandler = class {
|
|
|
4690
4705
|
}
|
|
4691
4706
|
const releaseLock = await this.chatLock.acquire(message.chatId);
|
|
4692
4707
|
try {
|
|
4708
|
+
const postLockOffset = readOffset(message.chatId) ?? 0;
|
|
4709
|
+
if (message.id <= postLockOffset) {
|
|
4710
|
+
verbose(`Skipping message ${message.id} (already processed after lock)`);
|
|
4711
|
+
return;
|
|
4712
|
+
}
|
|
4693
4713
|
if (this.config.typing_simulation) {
|
|
4694
4714
|
await this.bridge.setTyping(message.chatId);
|
|
4695
4715
|
}
|
|
@@ -6188,6 +6208,20 @@ var telegramGetRepliesExecutor = async (params, context) => {
|
|
|
6188
6208
|
}
|
|
6189
6209
|
};
|
|
6190
6210
|
|
|
6211
|
+
// src/agent/tools/telegram/messaging/index.ts
|
|
6212
|
+
var tools = [
|
|
6213
|
+
{ tool: telegramSendMessageTool, executor: telegramSendMessageExecutor },
|
|
6214
|
+
{ tool: telegramQuoteReplyTool, executor: telegramQuoteReplyExecutor },
|
|
6215
|
+
{ tool: telegramGetRepliesTool, executor: telegramGetRepliesExecutor },
|
|
6216
|
+
{ tool: telegramEditMessageTool, executor: telegramEditMessageExecutor },
|
|
6217
|
+
{ tool: telegramScheduleMessageTool, executor: telegramScheduleMessageExecutor },
|
|
6218
|
+
{ tool: telegramSearchMessagesTool, executor: telegramSearchMessagesExecutor },
|
|
6219
|
+
{ tool: telegramPinMessageTool, executor: telegramPinMessageExecutor },
|
|
6220
|
+
{ tool: telegramUnpinMessageTool, executor: telegramUnpinMessageExecutor },
|
|
6221
|
+
{ tool: telegramForwardMessageTool, executor: telegramForwardMessageExecutor },
|
|
6222
|
+
{ tool: telegramDeleteMessageTool, executor: telegramDeleteMessageExecutor }
|
|
6223
|
+
];
|
|
6224
|
+
|
|
6191
6225
|
// src/agent/tools/telegram/media/send-photo.ts
|
|
6192
6226
|
import { Type as Type10 } from "@sinclair/typebox";
|
|
6193
6227
|
var telegramSendPhotoTool = {
|
|
@@ -7325,6 +7359,16 @@ var visionAnalyzeExecutor = async (params, context) => {
|
|
|
7325
7359
|
}
|
|
7326
7360
|
};
|
|
7327
7361
|
|
|
7362
|
+
// src/agent/tools/telegram/media/index.ts
|
|
7363
|
+
var tools2 = [
|
|
7364
|
+
{ tool: telegramSendPhotoTool, executor: telegramSendPhotoExecutor },
|
|
7365
|
+
{ tool: telegramSendVoiceTool, executor: telegramSendVoiceExecutor },
|
|
7366
|
+
{ tool: telegramSendStickerTool, executor: telegramSendStickerExecutor },
|
|
7367
|
+
{ tool: telegramSendGifTool, executor: telegramSendGifExecutor },
|
|
7368
|
+
{ tool: telegramDownloadMediaTool, executor: telegramDownloadMediaExecutor },
|
|
7369
|
+
{ tool: visionAnalyzeTool, executor: visionAnalyzeExecutor }
|
|
7370
|
+
];
|
|
7371
|
+
|
|
7328
7372
|
// src/agent/tools/telegram/chats/get-dialogs.ts
|
|
7329
7373
|
import { Type as Type16 } from "@sinclair/typebox";
|
|
7330
7374
|
var telegramGetDialogsTool = {
|
|
@@ -7420,7 +7464,8 @@ var telegramGetHistoryExecutor = async (params, context) => {
|
|
|
7420
7464
|
try {
|
|
7421
7465
|
const { chatId, limit = 50, offsetId } = params;
|
|
7422
7466
|
const gramJsClient = context.bridge.getClient().getClient();
|
|
7423
|
-
const
|
|
7467
|
+
const entity = context.bridge.getPeer(chatId) || chatId;
|
|
7468
|
+
const messages = await gramJsClient.getMessages(entity, {
|
|
7424
7469
|
limit,
|
|
7425
7470
|
offsetId
|
|
7426
7471
|
});
|
|
@@ -8062,6 +8107,27 @@ var telegramInviteToChannelExecutor = async (params, context) => {
|
|
|
8062
8107
|
}
|
|
8063
8108
|
};
|
|
8064
8109
|
|
|
8110
|
+
// src/agent/tools/telegram/chats/index.ts
|
|
8111
|
+
var tools3 = [
|
|
8112
|
+
{ tool: telegramGetDialogsTool, executor: telegramGetDialogsExecutor },
|
|
8113
|
+
{ tool: telegramGetHistoryTool, executor: telegramGetHistoryExecutor },
|
|
8114
|
+
{ tool: telegramGetChatInfoTool, executor: telegramGetChatInfoExecutor },
|
|
8115
|
+
{ tool: telegramMarkAsReadTool, executor: telegramMarkAsReadExecutor },
|
|
8116
|
+
{ tool: telegramJoinChannelTool, executor: telegramJoinChannelExecutor, scope: "dm-only" },
|
|
8117
|
+
{ tool: telegramLeaveChannelTool, executor: telegramLeaveChannelExecutor, scope: "dm-only" },
|
|
8118
|
+
{ tool: telegramCreateChannelTool, executor: telegramCreateChannelExecutor, scope: "dm-only" },
|
|
8119
|
+
{
|
|
8120
|
+
tool: telegramEditChannelInfoTool,
|
|
8121
|
+
executor: telegramEditChannelInfoExecutor,
|
|
8122
|
+
scope: "dm-only"
|
|
8123
|
+
},
|
|
8124
|
+
{
|
|
8125
|
+
tool: telegramInviteToChannelTool,
|
|
8126
|
+
executor: telegramInviteToChannelExecutor,
|
|
8127
|
+
scope: "dm-only"
|
|
8128
|
+
}
|
|
8129
|
+
];
|
|
8130
|
+
|
|
8065
8131
|
// src/agent/tools/telegram/groups/get-me.ts
|
|
8066
8132
|
import { Type as Type25 } from "@sinclair/typebox";
|
|
8067
8133
|
var telegramGetMeTool = {
|
|
@@ -8581,6 +8647,17 @@ var CustomFile = class {
|
|
|
8581
8647
|
}
|
|
8582
8648
|
};
|
|
8583
8649
|
|
|
8650
|
+
// src/agent/tools/telegram/groups/index.ts
|
|
8651
|
+
var tools4 = [
|
|
8652
|
+
{ tool: telegramGetMeTool, executor: telegramGetMeExecutor },
|
|
8653
|
+
{ tool: telegramGetParticipantsTool, executor: telegramGetParticipantsExecutor },
|
|
8654
|
+
{ tool: telegramKickUserTool, executor: telegramKickUserExecutor, scope: "group-only" },
|
|
8655
|
+
{ tool: telegramBanUserTool, executor: telegramBanUserExecutor, scope: "group-only" },
|
|
8656
|
+
{ tool: telegramUnbanUserTool, executor: telegramUnbanUserExecutor, scope: "group-only" },
|
|
8657
|
+
{ tool: telegramCreateGroupTool, executor: telegramCreateGroupExecutor, scope: "dm-only" },
|
|
8658
|
+
{ tool: telegramSetChatPhotoTool, executor: telegramSetChatPhotoExecutor, scope: "group-only" }
|
|
8659
|
+
];
|
|
8660
|
+
|
|
8584
8661
|
// src/agent/tools/telegram/interactive/create-poll.ts
|
|
8585
8662
|
import { Type as Type30 } from "@sinclair/typebox";
|
|
8586
8663
|
import { Api as Api23 } from "telegram";
|
|
@@ -9036,6 +9113,15 @@ var telegramSendDiceExecutor = async (params, context) => {
|
|
|
9036
9113
|
}
|
|
9037
9114
|
};
|
|
9038
9115
|
|
|
9116
|
+
// src/agent/tools/telegram/interactive/index.ts
|
|
9117
|
+
var tools5 = [
|
|
9118
|
+
{ tool: telegramCreatePollTool, executor: telegramCreatePollExecutor },
|
|
9119
|
+
{ tool: telegramCreateQuizTool, executor: telegramCreateQuizExecutor },
|
|
9120
|
+
{ tool: telegramReplyKeyboardTool, executor: telegramReplyKeyboardExecutor },
|
|
9121
|
+
{ tool: telegramReactTool, executor: telegramReactExecutor },
|
|
9122
|
+
{ tool: telegramSendDiceTool, executor: telegramSendDiceExecutor }
|
|
9123
|
+
];
|
|
9124
|
+
|
|
9039
9125
|
// src/agent/tools/telegram/stickers/search-stickers.ts
|
|
9040
9126
|
import { Type as Type35 } from "@sinclair/typebox";
|
|
9041
9127
|
import { Api as Api27 } from "telegram";
|
|
@@ -9262,6 +9348,14 @@ var telegramAddStickerSetExecutor = async (params, context) => {
|
|
|
9262
9348
|
}
|
|
9263
9349
|
};
|
|
9264
9350
|
|
|
9351
|
+
// src/agent/tools/telegram/stickers/index.ts
|
|
9352
|
+
var tools6 = [
|
|
9353
|
+
{ tool: telegramSearchStickersTool, executor: telegramSearchStickersExecutor },
|
|
9354
|
+
{ tool: telegramSearchGifsTool, executor: telegramSearchGifsExecutor },
|
|
9355
|
+
{ tool: telegramGetMyStickersTool, executor: telegramGetMyStickersExecutor },
|
|
9356
|
+
{ tool: telegramAddStickerSetTool, executor: telegramAddStickerSetExecutor }
|
|
9357
|
+
];
|
|
9358
|
+
|
|
9265
9359
|
// src/agent/tools/telegram/folders/get-folders.ts
|
|
9266
9360
|
import { Type as Type39 } from "@sinclair/typebox";
|
|
9267
9361
|
import { Api as Api31 } from "telegram";
|
|
@@ -9466,6 +9560,13 @@ var telegramAddChatToFolderExecutor = async (params, context) => {
|
|
|
9466
9560
|
}
|
|
9467
9561
|
};
|
|
9468
9562
|
|
|
9563
|
+
// src/agent/tools/telegram/folders/index.ts
|
|
9564
|
+
var tools7 = [
|
|
9565
|
+
{ tool: telegramGetFoldersTool, executor: telegramGetFoldersExecutor },
|
|
9566
|
+
{ tool: telegramCreateFolderTool, executor: telegramCreateFolderExecutor },
|
|
9567
|
+
{ tool: telegramAddChatToFolderTool, executor: telegramAddChatToFolderExecutor }
|
|
9568
|
+
];
|
|
9569
|
+
|
|
9469
9570
|
// src/agent/tools/telegram/profile/update-profile.ts
|
|
9470
9571
|
import { Type as Type42 } from "@sinclair/typebox";
|
|
9471
9572
|
import { Api as Api34 } from "telegram";
|
|
@@ -9637,6 +9738,13 @@ var telegramSetUsernameExecutor = async (params, context) => {
|
|
|
9637
9738
|
}
|
|
9638
9739
|
};
|
|
9639
9740
|
|
|
9741
|
+
// src/agent/tools/telegram/profile/index.ts
|
|
9742
|
+
var tools8 = [
|
|
9743
|
+
{ tool: telegramUpdateProfileTool, executor: telegramUpdateProfileExecutor, scope: "dm-only" },
|
|
9744
|
+
{ tool: telegramSetBioTool, executor: telegramSetBioExecutor, scope: "dm-only" },
|
|
9745
|
+
{ tool: telegramSetUsernameTool, executor: telegramSetUsernameExecutor, scope: "dm-only" }
|
|
9746
|
+
];
|
|
9747
|
+
|
|
9640
9748
|
// src/agent/tools/telegram/stars/get-balance.ts
|
|
9641
9749
|
import { Type as Type45 } from "@sinclair/typebox";
|
|
9642
9750
|
import { Api as Api37 } from "telegram";
|
|
@@ -9738,6 +9846,20 @@ var telegramGetStarsTransactionsExecutor = async (params, context) => {
|
|
|
9738
9846
|
}
|
|
9739
9847
|
};
|
|
9740
9848
|
|
|
9849
|
+
// src/agent/tools/telegram/stars/index.ts
|
|
9850
|
+
var tools9 = [
|
|
9851
|
+
{
|
|
9852
|
+
tool: telegramGetStarsBalanceTool,
|
|
9853
|
+
executor: telegramGetStarsBalanceExecutor,
|
|
9854
|
+
scope: "dm-only"
|
|
9855
|
+
},
|
|
9856
|
+
{
|
|
9857
|
+
tool: telegramGetStarsTransactionsTool,
|
|
9858
|
+
executor: telegramGetStarsTransactionsExecutor,
|
|
9859
|
+
scope: "dm-only"
|
|
9860
|
+
}
|
|
9861
|
+
];
|
|
9862
|
+
|
|
9741
9863
|
// src/agent/tools/telegram/gifts/get-available-gifts.ts
|
|
9742
9864
|
import { Type as Type47 } from "@sinclair/typebox";
|
|
9743
9865
|
import { Api as Api39 } from "telegram";
|
|
@@ -13303,6 +13425,26 @@ var telegramSetGiftStatusExecutor = async (params, context) => {
|
|
|
13303
13425
|
}
|
|
13304
13426
|
};
|
|
13305
13427
|
|
|
13428
|
+
// src/agent/tools/telegram/gifts/index.ts
|
|
13429
|
+
var tools10 = [
|
|
13430
|
+
{ tool: telegramGetAvailableGiftsTool, executor: telegramGetAvailableGiftsExecutor },
|
|
13431
|
+
{ tool: telegramSendGiftTool, executor: telegramSendGiftExecutor, scope: "dm-only" },
|
|
13432
|
+
{ tool: telegramGetMyGiftsTool, executor: telegramGetMyGiftsExecutor },
|
|
13433
|
+
{
|
|
13434
|
+
tool: telegramTransferCollectibleTool,
|
|
13435
|
+
executor: telegramTransferCollectibleExecutor,
|
|
13436
|
+
scope: "dm-only"
|
|
13437
|
+
},
|
|
13438
|
+
{
|
|
13439
|
+
tool: telegramSetCollectiblePriceTool,
|
|
13440
|
+
executor: telegramSetCollectiblePriceExecutor,
|
|
13441
|
+
scope: "dm-only"
|
|
13442
|
+
},
|
|
13443
|
+
{ tool: telegramGetResaleGiftsTool, executor: telegramGetResaleGiftsExecutor },
|
|
13444
|
+
{ tool: telegramBuyResaleGiftTool, executor: telegramBuyResaleGiftExecutor, scope: "dm-only" },
|
|
13445
|
+
{ tool: telegramSetGiftStatusTool, executor: telegramSetGiftStatusExecutor, scope: "dm-only" }
|
|
13446
|
+
];
|
|
13447
|
+
|
|
13306
13448
|
// src/agent/tools/telegram/contacts/block-user.ts
|
|
13307
13449
|
import { Type as Type59 } from "@sinclair/typebox";
|
|
13308
13450
|
import { Api as Api50 } from "telegram";
|
|
@@ -13687,6 +13829,15 @@ var telegramCheckUsernameExecutor = async (params, context) => {
|
|
|
13687
13829
|
}
|
|
13688
13830
|
};
|
|
13689
13831
|
|
|
13832
|
+
// src/agent/tools/telegram/contacts/index.ts
|
|
13833
|
+
var tools11 = [
|
|
13834
|
+
{ tool: telegramBlockUserTool, executor: telegramBlockUserExecutor, scope: "dm-only" },
|
|
13835
|
+
{ tool: telegramGetBlockedTool, executor: telegramGetBlockedExecutor, scope: "dm-only" },
|
|
13836
|
+
{ tool: telegramGetCommonChatsTool, executor: telegramGetCommonChatsExecutor },
|
|
13837
|
+
{ tool: telegramGetUserInfoTool, executor: telegramGetUserInfoExecutor },
|
|
13838
|
+
{ tool: telegramCheckUsernameTool, executor: telegramCheckUsernameExecutor }
|
|
13839
|
+
];
|
|
13840
|
+
|
|
13690
13841
|
// src/agent/tools/telegram/stories/send-story.ts
|
|
13691
13842
|
var import_big_integer6 = __toESM(require_BigInteger(), 1);
|
|
13692
13843
|
import { Type as Type64 } from "@sinclair/typebox";
|
|
@@ -13808,6 +13959,11 @@ var telegramSendStoryExecutor = async (params, context) => {
|
|
|
13808
13959
|
}
|
|
13809
13960
|
};
|
|
13810
13961
|
|
|
13962
|
+
// src/agent/tools/telegram/stories/index.ts
|
|
13963
|
+
var tools12 = [
|
|
13964
|
+
{ tool: telegramSendStoryTool, executor: telegramSendStoryExecutor, scope: "dm-only" }
|
|
13965
|
+
];
|
|
13966
|
+
|
|
13811
13967
|
// src/agent/tools/telegram/memory/memory-write.ts
|
|
13812
13968
|
import { Type as Type65 } from "@sinclair/typebox";
|
|
13813
13969
|
import { appendFileSync as appendFileSync2, writeFileSync as writeFileSync8, existsSync as existsSync11, mkdirSync as mkdirSync8 } from "fs";
|
|
@@ -14063,19 +14219,243 @@ var memoryReadExecutor = async (params, _context) => {
|
|
|
14063
14219
|
}
|
|
14064
14220
|
};
|
|
14065
14221
|
|
|
14066
|
-
// src/agent/tools/telegram/
|
|
14222
|
+
// src/agent/tools/telegram/memory/index.ts
|
|
14223
|
+
var tools13 = [
|
|
14224
|
+
{ tool: memoryWriteTool, executor: memoryWriteExecutor, scope: "dm-only" },
|
|
14225
|
+
{ tool: memoryReadTool, executor: memoryReadExecutor }
|
|
14226
|
+
];
|
|
14227
|
+
|
|
14228
|
+
// src/agent/tools/telegram/tasks/create-scheduled-task.ts
|
|
14067
14229
|
import { Type as Type67 } from "@sinclair/typebox";
|
|
14230
|
+
import { Api as Api56 } from "telegram";
|
|
14231
|
+
var telegramCreateScheduledTaskTool = {
|
|
14232
|
+
name: "telegram_create_scheduled_task",
|
|
14233
|
+
description: "Create a scheduled task that will be executed at a specific time. The task will be stored in the database and a reminder message will be scheduled in Saved Messages. When the time comes, you'll receive the task context and can execute it with full agent capabilities. Supports both simple tool calls and complex multi-step tasks.",
|
|
14234
|
+
parameters: Type67.Object({
|
|
14235
|
+
description: Type67.String({
|
|
14236
|
+
description: "What the task is about (e.g., 'Check TON price and alert if > $5')"
|
|
14237
|
+
}),
|
|
14238
|
+
scheduleDate: Type67.Optional(
|
|
14239
|
+
Type67.String({
|
|
14240
|
+
description: "When to execute the task (ISO 8601 format, e.g., '2024-12-25T10:00:00Z' or Unix timestamp). Optional if dependsOn is provided - task will execute when dependencies complete."
|
|
14241
|
+
})
|
|
14242
|
+
),
|
|
14243
|
+
payload: Type67.Optional(
|
|
14244
|
+
Type67.String({
|
|
14245
|
+
description: `JSON payload defining task execution. Two types:
|
|
14246
|
+
|
|
14247
|
+
1. Simple tool call (auto-executed, result fed to you):
|
|
14248
|
+
{"type":"tool_call","tool":"ton_get_price","params":{},"condition":"price > 5"}
|
|
14249
|
+
|
|
14250
|
+
2. Complex agent task (you execute step-by-step):
|
|
14251
|
+
{"type":"agent_task","instructions":"1. Check price\\n2. If > $5, swap 50 TON","context":{"chatId":"123"}}
|
|
14252
|
+
|
|
14253
|
+
3. Skip on parent failure (continues even if parent fails):
|
|
14254
|
+
{"type":"agent_task","instructions":"Send daily report","skipOnParentFailure":false}
|
|
14255
|
+
|
|
14256
|
+
If omitted, task is a simple reminder.`
|
|
14257
|
+
})
|
|
14258
|
+
),
|
|
14259
|
+
reason: Type67.Optional(
|
|
14260
|
+
Type67.String({
|
|
14261
|
+
description: "Why you're scheduling this task (helps with context when executing)"
|
|
14262
|
+
})
|
|
14263
|
+
),
|
|
14264
|
+
priority: Type67.Optional(
|
|
14265
|
+
Type67.Number({
|
|
14266
|
+
description: "Task priority (0-10, higher = more important)",
|
|
14267
|
+
minimum: 0,
|
|
14268
|
+
maximum: 10
|
|
14269
|
+
})
|
|
14270
|
+
),
|
|
14271
|
+
dependsOn: Type67.Optional(
|
|
14272
|
+
Type67.Array(Type67.String(), {
|
|
14273
|
+
description: "Array of parent task IDs that must complete before this task executes. When dependencies are provided, task executes automatically when all parents are done (scheduleDate is ignored)."
|
|
14274
|
+
})
|
|
14275
|
+
)
|
|
14276
|
+
})
|
|
14277
|
+
};
|
|
14278
|
+
var telegramCreateScheduledTaskExecutor = async (params, context) => {
|
|
14279
|
+
try {
|
|
14280
|
+
const { description, scheduleDate, payload, reason, priority, dependsOn } = params;
|
|
14281
|
+
if (!scheduleDate && (!dependsOn || dependsOn.length === 0)) {
|
|
14282
|
+
return {
|
|
14283
|
+
success: false,
|
|
14284
|
+
error: "Either scheduleDate or dependsOn must be provided"
|
|
14285
|
+
};
|
|
14286
|
+
}
|
|
14287
|
+
let scheduleTimestamp;
|
|
14288
|
+
if (scheduleDate) {
|
|
14289
|
+
const parsedDate = new Date(scheduleDate);
|
|
14290
|
+
if (!isNaN(parsedDate.getTime())) {
|
|
14291
|
+
scheduleTimestamp = Math.floor(parsedDate.getTime() / 1e3);
|
|
14292
|
+
} else {
|
|
14293
|
+
scheduleTimestamp = parseInt(scheduleDate, 10);
|
|
14294
|
+
if (isNaN(scheduleTimestamp)) {
|
|
14295
|
+
return {
|
|
14296
|
+
success: false,
|
|
14297
|
+
error: "Invalid scheduleDate format"
|
|
14298
|
+
};
|
|
14299
|
+
}
|
|
14300
|
+
}
|
|
14301
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
14302
|
+
if (scheduleTimestamp <= now) {
|
|
14303
|
+
return {
|
|
14304
|
+
success: false,
|
|
14305
|
+
error: "Schedule date must be in the future"
|
|
14306
|
+
};
|
|
14307
|
+
}
|
|
14308
|
+
}
|
|
14309
|
+
if (payload) {
|
|
14310
|
+
try {
|
|
14311
|
+
const parsed = JSON.parse(payload);
|
|
14312
|
+
if (!parsed.type || !["tool_call", "agent_task"].includes(parsed.type)) {
|
|
14313
|
+
return {
|
|
14314
|
+
success: false,
|
|
14315
|
+
error: 'Payload must have type "tool_call" or "agent_task"'
|
|
14316
|
+
};
|
|
14317
|
+
}
|
|
14318
|
+
if (parsed.type === "tool_call") {
|
|
14319
|
+
if (!parsed.tool || typeof parsed.tool !== "string") {
|
|
14320
|
+
return {
|
|
14321
|
+
success: false,
|
|
14322
|
+
error: 'tool_call payload requires "tool" field (string)'
|
|
14323
|
+
};
|
|
14324
|
+
}
|
|
14325
|
+
if (parsed.params !== void 0 && typeof parsed.params !== "object") {
|
|
14326
|
+
return {
|
|
14327
|
+
success: false,
|
|
14328
|
+
error: 'tool_call payload "params" must be an object'
|
|
14329
|
+
};
|
|
14330
|
+
}
|
|
14331
|
+
}
|
|
14332
|
+
if (parsed.type === "agent_task") {
|
|
14333
|
+
if (!parsed.instructions || typeof parsed.instructions !== "string") {
|
|
14334
|
+
return {
|
|
14335
|
+
success: false,
|
|
14336
|
+
error: 'agent_task payload requires "instructions" field (string)'
|
|
14337
|
+
};
|
|
14338
|
+
}
|
|
14339
|
+
if (parsed.instructions.length < 5) {
|
|
14340
|
+
return {
|
|
14341
|
+
success: false,
|
|
14342
|
+
error: "Instructions too short (min 5 characters)"
|
|
14343
|
+
};
|
|
14344
|
+
}
|
|
14345
|
+
if (parsed.context !== void 0 && typeof parsed.context !== "object") {
|
|
14346
|
+
return {
|
|
14347
|
+
success: false,
|
|
14348
|
+
error: 'agent_task payload "context" must be an object'
|
|
14349
|
+
};
|
|
14350
|
+
}
|
|
14351
|
+
}
|
|
14352
|
+
} catch (e) {
|
|
14353
|
+
return {
|
|
14354
|
+
success: false,
|
|
14355
|
+
error: "Invalid JSON payload"
|
|
14356
|
+
};
|
|
14357
|
+
}
|
|
14358
|
+
}
|
|
14359
|
+
if (!context.db) {
|
|
14360
|
+
return {
|
|
14361
|
+
success: false,
|
|
14362
|
+
error: "Database not available"
|
|
14363
|
+
};
|
|
14364
|
+
}
|
|
14365
|
+
const { getTaskStore } = await import("./tasks-M3QDPTGY.js");
|
|
14366
|
+
const taskStore = getTaskStore(context.db);
|
|
14367
|
+
const MAX_DEPENDENTS_PER_TASK = 10;
|
|
14368
|
+
if (dependsOn && dependsOn.length > 0) {
|
|
14369
|
+
for (const parentId of dependsOn) {
|
|
14370
|
+
const existingDependents = taskStore.getDependents(parentId);
|
|
14371
|
+
if (existingDependents.length >= MAX_DEPENDENTS_PER_TASK) {
|
|
14372
|
+
return {
|
|
14373
|
+
success: false,
|
|
14374
|
+
error: `Parent task ${parentId} already has ${existingDependents.length} dependents (max: ${MAX_DEPENDENTS_PER_TASK})`
|
|
14375
|
+
};
|
|
14376
|
+
}
|
|
14377
|
+
}
|
|
14378
|
+
}
|
|
14379
|
+
const task = taskStore.createTask({
|
|
14380
|
+
description,
|
|
14381
|
+
priority: priority ?? 0,
|
|
14382
|
+
createdBy: "agent",
|
|
14383
|
+
scheduledFor: scheduleTimestamp ? new Date(scheduleTimestamp * 1e3) : void 0,
|
|
14384
|
+
payload,
|
|
14385
|
+
reason,
|
|
14386
|
+
dependsOn
|
|
14387
|
+
});
|
|
14388
|
+
let scheduledMessageId;
|
|
14389
|
+
if (dependsOn && dependsOn.length > 0) {
|
|
14390
|
+
return {
|
|
14391
|
+
success: true,
|
|
14392
|
+
data: {
|
|
14393
|
+
taskId: task.id,
|
|
14394
|
+
dependsOn,
|
|
14395
|
+
message: `Task created: "${description}" (will execute when ${dependsOn.length} parent task(s) complete)`
|
|
14396
|
+
}
|
|
14397
|
+
};
|
|
14398
|
+
} else if (scheduleTimestamp) {
|
|
14399
|
+
const gramJsClient = context.bridge.getClient().getClient();
|
|
14400
|
+
const me = await gramJsClient.getMe();
|
|
14401
|
+
const taskMessage = `[TASK:${task.id}] ${description}`;
|
|
14402
|
+
const result = await gramJsClient.invoke(
|
|
14403
|
+
new Api56.messages.SendMessage({
|
|
14404
|
+
peer: me,
|
|
14405
|
+
message: taskMessage,
|
|
14406
|
+
scheduleDate: scheduleTimestamp,
|
|
14407
|
+
randomId: Date.now()
|
|
14408
|
+
})
|
|
14409
|
+
);
|
|
14410
|
+
if (result instanceof Api56.Updates || result instanceof Api56.UpdatesCombined) {
|
|
14411
|
+
for (const update of result.updates) {
|
|
14412
|
+
if (update instanceof Api56.UpdateMessageID) {
|
|
14413
|
+
scheduledMessageId = update.id;
|
|
14414
|
+
break;
|
|
14415
|
+
}
|
|
14416
|
+
}
|
|
14417
|
+
}
|
|
14418
|
+
return {
|
|
14419
|
+
success: true,
|
|
14420
|
+
data: {
|
|
14421
|
+
taskId: task.id,
|
|
14422
|
+
scheduledFor: new Date(scheduleTimestamp * 1e3).toISOString(),
|
|
14423
|
+
scheduledMessageId,
|
|
14424
|
+
message: `Task scheduled: "${description}" at ${new Date(scheduleTimestamp * 1e3).toLocaleString()}`
|
|
14425
|
+
}
|
|
14426
|
+
};
|
|
14427
|
+
}
|
|
14428
|
+
return {
|
|
14429
|
+
success: false,
|
|
14430
|
+
error: "Invalid state: no scheduleDate or dependsOn"
|
|
14431
|
+
};
|
|
14432
|
+
} catch (error) {
|
|
14433
|
+
console.error("Error creating scheduled task:", error);
|
|
14434
|
+
return {
|
|
14435
|
+
success: false,
|
|
14436
|
+
error: error instanceof Error ? error.message : String(error)
|
|
14437
|
+
};
|
|
14438
|
+
}
|
|
14439
|
+
};
|
|
14440
|
+
|
|
14441
|
+
// src/agent/tools/telegram/tasks/index.ts
|
|
14442
|
+
var tools14 = [
|
|
14443
|
+
{ tool: telegramCreateScheduledTaskTool, executor: telegramCreateScheduledTaskExecutor }
|
|
14444
|
+
];
|
|
14445
|
+
|
|
14446
|
+
// src/agent/tools/telegram/market/get-floor.ts
|
|
14447
|
+
import { Type as Type68 } from "@sinclair/typebox";
|
|
14068
14448
|
var marketGetFloorTool = {
|
|
14069
14449
|
name: "market_get_floor",
|
|
14070
14450
|
description: "Get floor price for a Telegram gift collection or specific model from MarketApp.ws. Pass collection name only for collection floor, or both collection and model for specific model floor. Returns floor price in TON, USD (if available), rarity percentage, and cache age. Data is cached for 15 minutes and automatically refreshed every 60 minutes.",
|
|
14071
|
-
parameters:
|
|
14072
|
-
collection:
|
|
14073
|
-
|
|
14451
|
+
parameters: Type68.Object({
|
|
14452
|
+
collection: Type68.Optional(
|
|
14453
|
+
Type68.String({
|
|
14074
14454
|
description: "Collection name (e.g., 'Plush Pepes', 'Heart Lockets')"
|
|
14075
14455
|
})
|
|
14076
14456
|
),
|
|
14077
|
-
model:
|
|
14078
|
-
|
|
14457
|
+
model: Type68.Optional(
|
|
14458
|
+
Type68.String({
|
|
14079
14459
|
description: "Model name (e.g., 'Cozy Galaxy', 'Telegram', 'Resistance')"
|
|
14080
14460
|
})
|
|
14081
14461
|
)
|
|
@@ -14156,16 +14536,16 @@ var marketGetFloorExecutor = async (params, context) => {
|
|
|
14156
14536
|
};
|
|
14157
14537
|
|
|
14158
14538
|
// src/agent/tools/telegram/market/search.ts
|
|
14159
|
-
import { Type as
|
|
14539
|
+
import { Type as Type69 } from "@sinclair/typebox";
|
|
14160
14540
|
var marketSearchTool = {
|
|
14161
14541
|
name: "market_search",
|
|
14162
14542
|
description: "Search for gift models by name (fuzzy search). Searches both collection names and model names with case-insensitive partial matches. Returns up to 'limit' results (default: 10). Examples: 'galaxy' finds Cozy Galaxy models, 'plush' finds all Plush Pepes models.",
|
|
14163
|
-
parameters:
|
|
14164
|
-
query:
|
|
14543
|
+
parameters: Type69.Object({
|
|
14544
|
+
query: Type69.String({
|
|
14165
14545
|
description: "Search query (collection or model name)"
|
|
14166
14546
|
}),
|
|
14167
|
-
limit:
|
|
14168
|
-
|
|
14547
|
+
limit: Type69.Optional(
|
|
14548
|
+
Type69.Number({
|
|
14169
14549
|
description: "Maximum number of results (default: 10, max: 50)",
|
|
14170
14550
|
minimum: 1,
|
|
14171
14551
|
maximum: 50
|
|
@@ -14218,17 +14598,17 @@ var marketSearchExecutor = async (params, context) => {
|
|
|
14218
14598
|
};
|
|
14219
14599
|
|
|
14220
14600
|
// src/agent/tools/telegram/market/cheapest.ts
|
|
14221
|
-
import { Type as
|
|
14601
|
+
import { Type as Type70 } from "@sinclair/typebox";
|
|
14222
14602
|
var marketCheapestTool = {
|
|
14223
14603
|
name: "market_cheapest",
|
|
14224
14604
|
description: "Find the cheapest gift models under a certain TON price. Returns models sorted by floor price (cheapest first) with collection name, floor price in TON, and rarity percentage. Useful for finding affordable gifts.",
|
|
14225
|
-
parameters:
|
|
14226
|
-
maxTon:
|
|
14605
|
+
parameters: Type70.Object({
|
|
14606
|
+
maxTon: Type70.Number({
|
|
14227
14607
|
description: "Maximum TON price",
|
|
14228
14608
|
minimum: 0
|
|
14229
14609
|
}),
|
|
14230
|
-
limit:
|
|
14231
|
-
|
|
14610
|
+
limit: Type70.Optional(
|
|
14611
|
+
Type70.Number({
|
|
14232
14612
|
description: "Maximum number of results (default: 20, max: 100)",
|
|
14233
14613
|
minimum: 1,
|
|
14234
14614
|
maximum: 100
|
|
@@ -14283,19 +14663,19 @@ var marketCheapestExecutor = async (params, context) => {
|
|
|
14283
14663
|
};
|
|
14284
14664
|
|
|
14285
14665
|
// src/agent/tools/telegram/market/price-history.ts
|
|
14286
|
-
import { Type as
|
|
14666
|
+
import { Type as Type71 } from "@sinclair/typebox";
|
|
14287
14667
|
var marketPriceHistoryTool = {
|
|
14288
14668
|
name: "market_price_history",
|
|
14289
14669
|
description: "Get price history for a specific gift model. Requires both collection and model name. Returns historical floor prices with timestamps (most recent first), floor TON and USD values, and trend analysis (rising, falling, or stable).",
|
|
14290
|
-
parameters:
|
|
14291
|
-
collection:
|
|
14670
|
+
parameters: Type71.Object({
|
|
14671
|
+
collection: Type71.String({
|
|
14292
14672
|
description: "Collection name (e.g., 'Plush Pepes')"
|
|
14293
14673
|
}),
|
|
14294
|
-
model:
|
|
14674
|
+
model: Type71.String({
|
|
14295
14675
|
description: "Model name (e.g., 'Cozy Galaxy')"
|
|
14296
14676
|
}),
|
|
14297
|
-
limit:
|
|
14298
|
-
|
|
14677
|
+
limit: Type71.Optional(
|
|
14678
|
+
Type71.Number({
|
|
14299
14679
|
description: "Maximum number of history entries (default: 10, max: 100)",
|
|
14300
14680
|
minimum: 1,
|
|
14301
14681
|
maximum: 100
|
|
@@ -14354,218 +14734,23 @@ var marketPriceHistoryExecutor = async (params, context) => {
|
|
|
14354
14734
|
}
|
|
14355
14735
|
};
|
|
14356
14736
|
|
|
14357
|
-
// src/agent/tools/telegram/
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
description: `JSON payload defining task execution. Two types:
|
|
14375
|
-
|
|
14376
|
-
1. Simple tool call (auto-executed, result fed to you):
|
|
14377
|
-
{"type":"tool_call","tool":"ton_get_price","params":{},"condition":"price > 5"}
|
|
14378
|
-
|
|
14379
|
-
2. Complex agent task (you execute step-by-step):
|
|
14380
|
-
{"type":"agent_task","instructions":"1. Check price\\n2. If > $5, swap 50 TON","context":{"chatId":"123"}}
|
|
14381
|
-
|
|
14382
|
-
3. Skip on parent failure (continues even if parent fails):
|
|
14383
|
-
{"type":"agent_task","instructions":"Send daily report","skipOnParentFailure":false}
|
|
14384
|
-
|
|
14385
|
-
If omitted, task is a simple reminder.`
|
|
14386
|
-
})
|
|
14387
|
-
),
|
|
14388
|
-
reason: Type71.Optional(
|
|
14389
|
-
Type71.String({
|
|
14390
|
-
description: "Why you're scheduling this task (helps with context when executing)"
|
|
14391
|
-
})
|
|
14392
|
-
),
|
|
14393
|
-
priority: Type71.Optional(
|
|
14394
|
-
Type71.Number({
|
|
14395
|
-
description: "Task priority (0-10, higher = more important)",
|
|
14396
|
-
minimum: 0,
|
|
14397
|
-
maximum: 10
|
|
14398
|
-
})
|
|
14399
|
-
),
|
|
14400
|
-
dependsOn: Type71.Optional(
|
|
14401
|
-
Type71.Array(Type71.String(), {
|
|
14402
|
-
description: "Array of parent task IDs that must complete before this task executes. When dependencies are provided, task executes automatically when all parents are done (scheduleDate is ignored)."
|
|
14403
|
-
})
|
|
14404
|
-
)
|
|
14405
|
-
})
|
|
14406
|
-
};
|
|
14407
|
-
var telegramCreateScheduledTaskExecutor = async (params, context) => {
|
|
14408
|
-
try {
|
|
14409
|
-
const { description, scheduleDate, payload, reason, priority, dependsOn } = params;
|
|
14410
|
-
if (!scheduleDate && (!dependsOn || dependsOn.length === 0)) {
|
|
14411
|
-
return {
|
|
14412
|
-
success: false,
|
|
14413
|
-
error: "Either scheduleDate or dependsOn must be provided"
|
|
14414
|
-
};
|
|
14415
|
-
}
|
|
14416
|
-
let scheduleTimestamp;
|
|
14417
|
-
if (scheduleDate) {
|
|
14418
|
-
const parsedDate = new Date(scheduleDate);
|
|
14419
|
-
if (!isNaN(parsedDate.getTime())) {
|
|
14420
|
-
scheduleTimestamp = Math.floor(parsedDate.getTime() / 1e3);
|
|
14421
|
-
} else {
|
|
14422
|
-
scheduleTimestamp = parseInt(scheduleDate, 10);
|
|
14423
|
-
if (isNaN(scheduleTimestamp)) {
|
|
14424
|
-
return {
|
|
14425
|
-
success: false,
|
|
14426
|
-
error: "Invalid scheduleDate format"
|
|
14427
|
-
};
|
|
14428
|
-
}
|
|
14429
|
-
}
|
|
14430
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
14431
|
-
if (scheduleTimestamp <= now) {
|
|
14432
|
-
return {
|
|
14433
|
-
success: false,
|
|
14434
|
-
error: "Schedule date must be in the future"
|
|
14435
|
-
};
|
|
14436
|
-
}
|
|
14437
|
-
}
|
|
14438
|
-
if (payload) {
|
|
14439
|
-
try {
|
|
14440
|
-
const parsed = JSON.parse(payload);
|
|
14441
|
-
if (!parsed.type || !["tool_call", "agent_task"].includes(parsed.type)) {
|
|
14442
|
-
return {
|
|
14443
|
-
success: false,
|
|
14444
|
-
error: 'Payload must have type "tool_call" or "agent_task"'
|
|
14445
|
-
};
|
|
14446
|
-
}
|
|
14447
|
-
if (parsed.type === "tool_call") {
|
|
14448
|
-
if (!parsed.tool || typeof parsed.tool !== "string") {
|
|
14449
|
-
return {
|
|
14450
|
-
success: false,
|
|
14451
|
-
error: 'tool_call payload requires "tool" field (string)'
|
|
14452
|
-
};
|
|
14453
|
-
}
|
|
14454
|
-
if (parsed.params !== void 0 && typeof parsed.params !== "object") {
|
|
14455
|
-
return {
|
|
14456
|
-
success: false,
|
|
14457
|
-
error: 'tool_call payload "params" must be an object'
|
|
14458
|
-
};
|
|
14459
|
-
}
|
|
14460
|
-
}
|
|
14461
|
-
if (parsed.type === "agent_task") {
|
|
14462
|
-
if (!parsed.instructions || typeof parsed.instructions !== "string") {
|
|
14463
|
-
return {
|
|
14464
|
-
success: false,
|
|
14465
|
-
error: 'agent_task payload requires "instructions" field (string)'
|
|
14466
|
-
};
|
|
14467
|
-
}
|
|
14468
|
-
if (parsed.instructions.length < 5) {
|
|
14469
|
-
return {
|
|
14470
|
-
success: false,
|
|
14471
|
-
error: "Instructions too short (min 5 characters)"
|
|
14472
|
-
};
|
|
14473
|
-
}
|
|
14474
|
-
if (parsed.context !== void 0 && typeof parsed.context !== "object") {
|
|
14475
|
-
return {
|
|
14476
|
-
success: false,
|
|
14477
|
-
error: 'agent_task payload "context" must be an object'
|
|
14478
|
-
};
|
|
14479
|
-
}
|
|
14480
|
-
}
|
|
14481
|
-
} catch (e) {
|
|
14482
|
-
return {
|
|
14483
|
-
success: false,
|
|
14484
|
-
error: "Invalid JSON payload"
|
|
14485
|
-
};
|
|
14486
|
-
}
|
|
14487
|
-
}
|
|
14488
|
-
if (!context.db) {
|
|
14489
|
-
return {
|
|
14490
|
-
success: false,
|
|
14491
|
-
error: "Database not available"
|
|
14492
|
-
};
|
|
14493
|
-
}
|
|
14494
|
-
const { getTaskStore } = await import("./tasks-M3QDPTGY.js");
|
|
14495
|
-
const taskStore = getTaskStore(context.db);
|
|
14496
|
-
const MAX_DEPENDENTS_PER_TASK = 10;
|
|
14497
|
-
if (dependsOn && dependsOn.length > 0) {
|
|
14498
|
-
for (const parentId of dependsOn) {
|
|
14499
|
-
const existingDependents = taskStore.getDependents(parentId);
|
|
14500
|
-
if (existingDependents.length >= MAX_DEPENDENTS_PER_TASK) {
|
|
14501
|
-
return {
|
|
14502
|
-
success: false,
|
|
14503
|
-
error: `Parent task ${parentId} already has ${existingDependents.length} dependents (max: ${MAX_DEPENDENTS_PER_TASK})`
|
|
14504
|
-
};
|
|
14505
|
-
}
|
|
14506
|
-
}
|
|
14507
|
-
}
|
|
14508
|
-
const task = taskStore.createTask({
|
|
14509
|
-
description,
|
|
14510
|
-
priority: priority ?? 0,
|
|
14511
|
-
createdBy: "agent",
|
|
14512
|
-
scheduledFor: scheduleTimestamp ? new Date(scheduleTimestamp * 1e3) : void 0,
|
|
14513
|
-
payload,
|
|
14514
|
-
reason,
|
|
14515
|
-
dependsOn
|
|
14516
|
-
});
|
|
14517
|
-
let scheduledMessageId;
|
|
14518
|
-
if (dependsOn && dependsOn.length > 0) {
|
|
14519
|
-
return {
|
|
14520
|
-
success: true,
|
|
14521
|
-
data: {
|
|
14522
|
-
taskId: task.id,
|
|
14523
|
-
dependsOn,
|
|
14524
|
-
message: `Task created: "${description}" (will execute when ${dependsOn.length} parent task(s) complete)`
|
|
14525
|
-
}
|
|
14526
|
-
};
|
|
14527
|
-
} else if (scheduleTimestamp) {
|
|
14528
|
-
const gramJsClient = context.bridge.getClient().getClient();
|
|
14529
|
-
const me = await gramJsClient.getMe();
|
|
14530
|
-
const taskMessage = `[TASK:${task.id}] ${description}`;
|
|
14531
|
-
const result = await gramJsClient.invoke(
|
|
14532
|
-
new Api56.messages.SendMessage({
|
|
14533
|
-
peer: me,
|
|
14534
|
-
message: taskMessage,
|
|
14535
|
-
scheduleDate: scheduleTimestamp,
|
|
14536
|
-
randomId: Date.now()
|
|
14537
|
-
})
|
|
14538
|
-
);
|
|
14539
|
-
if (result instanceof Api56.Updates || result instanceof Api56.UpdatesCombined) {
|
|
14540
|
-
for (const update of result.updates) {
|
|
14541
|
-
if (update instanceof Api56.UpdateMessageID) {
|
|
14542
|
-
scheduledMessageId = update.id;
|
|
14543
|
-
break;
|
|
14544
|
-
}
|
|
14545
|
-
}
|
|
14546
|
-
}
|
|
14547
|
-
return {
|
|
14548
|
-
success: true,
|
|
14549
|
-
data: {
|
|
14550
|
-
taskId: task.id,
|
|
14551
|
-
scheduledFor: new Date(scheduleTimestamp * 1e3).toISOString(),
|
|
14552
|
-
scheduledMessageId,
|
|
14553
|
-
message: `Task scheduled: "${description}" at ${new Date(scheduleTimestamp * 1e3).toLocaleString()}`
|
|
14554
|
-
}
|
|
14555
|
-
};
|
|
14556
|
-
}
|
|
14557
|
-
return {
|
|
14558
|
-
success: false,
|
|
14559
|
-
error: "Invalid state: no scheduleDate or dependsOn"
|
|
14560
|
-
};
|
|
14561
|
-
} catch (error) {
|
|
14562
|
-
console.error("Error creating scheduled task:", error);
|
|
14563
|
-
return {
|
|
14564
|
-
success: false,
|
|
14565
|
-
error: error instanceof Error ? error.message : String(error)
|
|
14566
|
-
};
|
|
14567
|
-
}
|
|
14568
|
-
};
|
|
14737
|
+
// src/agent/tools/telegram/index.ts
|
|
14738
|
+
var tools15 = [
|
|
14739
|
+
...tools,
|
|
14740
|
+
...tools2,
|
|
14741
|
+
...tools3,
|
|
14742
|
+
...tools4,
|
|
14743
|
+
...tools5,
|
|
14744
|
+
...tools6,
|
|
14745
|
+
...tools7,
|
|
14746
|
+
...tools8,
|
|
14747
|
+
...tools9,
|
|
14748
|
+
...tools10,
|
|
14749
|
+
...tools11,
|
|
14750
|
+
...tools12,
|
|
14751
|
+
...tools13,
|
|
14752
|
+
...tools14
|
|
14753
|
+
];
|
|
14569
14754
|
|
|
14570
14755
|
// src/agent/tools/ton/get-address.ts
|
|
14571
14756
|
import { Type as Type72 } from "@sinclair/typebox";
|
|
@@ -15196,6 +15381,16 @@ var tonMyTransactionsExecutor = async (params, context) => {
|
|
|
15196
15381
|
}
|
|
15197
15382
|
};
|
|
15198
15383
|
|
|
15384
|
+
// src/agent/tools/ton/index.ts
|
|
15385
|
+
var tools16 = [
|
|
15386
|
+
{ tool: tonSendTool, executor: tonSendExecutor, scope: "dm-only" },
|
|
15387
|
+
{ tool: tonGetAddressTool, executor: tonGetAddressExecutor },
|
|
15388
|
+
{ tool: tonGetBalanceTool, executor: tonGetBalanceExecutor },
|
|
15389
|
+
{ tool: tonPriceTool, executor: tonPriceExecutor },
|
|
15390
|
+
{ tool: tonGetTransactionsTool, executor: tonGetTransactionsExecutor },
|
|
15391
|
+
{ tool: tonMyTransactionsTool, executor: tonMyTransactionsExecutor }
|
|
15392
|
+
];
|
|
15393
|
+
|
|
15199
15394
|
// src/agent/tools/dns/check.ts
|
|
15200
15395
|
import { Type as Type78 } from "@sinclair/typebox";
|
|
15201
15396
|
var dnsCheckTool = {
|
|
@@ -15892,6 +16087,17 @@ var dnsUnlinkExecutor = async (params, context) => {
|
|
|
15892
16087
|
}
|
|
15893
16088
|
};
|
|
15894
16089
|
|
|
16090
|
+
// src/agent/tools/dns/index.ts
|
|
16091
|
+
var tools17 = [
|
|
16092
|
+
{ tool: dnsStartAuctionTool, executor: dnsStartAuctionExecutor, scope: "dm-only" },
|
|
16093
|
+
{ tool: dnsBidTool, executor: dnsBidExecutor, scope: "dm-only" },
|
|
16094
|
+
{ tool: dnsLinkTool, executor: dnsLinkExecutor, scope: "dm-only" },
|
|
16095
|
+
{ tool: dnsUnlinkTool, executor: dnsUnlinkExecutor, scope: "dm-only" },
|
|
16096
|
+
{ tool: dnsCheckTool, executor: dnsCheckExecutor },
|
|
16097
|
+
{ tool: dnsAuctionsTool, executor: dnsAuctionsExecutor },
|
|
16098
|
+
{ tool: dnsResolveTool, executor: dnsResolveExecutor }
|
|
16099
|
+
];
|
|
16100
|
+
|
|
15895
16101
|
// src/agent/tools/jetton/balances.ts
|
|
15896
16102
|
import { Type as Type85 } from "@sinclair/typebox";
|
|
15897
16103
|
var jettonBalancesTool = {
|
|
@@ -20402,6 +20608,21 @@ var jettonPoolsExecutor = async (params, context) => {
|
|
|
20402
20608
|
}
|
|
20403
20609
|
};
|
|
20404
20610
|
|
|
20611
|
+
// src/agent/tools/jetton/index.ts
|
|
20612
|
+
var tools18 = [
|
|
20613
|
+
{ tool: jettonSwapTool, executor: jettonSwapExecutor, scope: "dm-only" },
|
|
20614
|
+
{ tool: jettonSendTool, executor: jettonSendExecutor, scope: "dm-only" },
|
|
20615
|
+
{ tool: jettonBalancesTool, executor: jettonBalancesExecutor },
|
|
20616
|
+
{ tool: jettonInfoTool, executor: jettonInfoExecutor },
|
|
20617
|
+
{ tool: jettonPriceTool, executor: jettonPriceExecutor },
|
|
20618
|
+
{ tool: jettonSearchTool, executor: jettonSearchExecutor },
|
|
20619
|
+
{ tool: jettonQuoteTool, executor: jettonQuoteExecutor },
|
|
20620
|
+
{ tool: jettonHoldersTool, executor: jettonHoldersExecutor },
|
|
20621
|
+
{ tool: jettonHistoryTool, executor: jettonHistoryExecutor },
|
|
20622
|
+
{ tool: jettonTrendingTool, executor: jettonTrendingExecutor },
|
|
20623
|
+
{ tool: jettonPoolsTool, executor: jettonPoolsExecutor }
|
|
20624
|
+
];
|
|
20625
|
+
|
|
20405
20626
|
// src/agent/tools/dedust/quote.ts
|
|
20406
20627
|
import { Type as Type96 } from "@sinclair/typebox";
|
|
20407
20628
|
import { TonClient as TonClient13, toNano as toNano22, fromNano as fromNano5 } from "@ton/ton";
|
|
@@ -20856,6 +21077,13 @@ var dedustPoolsExecutor = async (params, context) => {
|
|
|
20856
21077
|
}
|
|
20857
21078
|
};
|
|
20858
21079
|
|
|
21080
|
+
// src/agent/tools/dedust/index.ts
|
|
21081
|
+
var tools19 = [
|
|
21082
|
+
{ tool: dedustSwapTool, executor: dedustSwapExecutor, scope: "dm-only" },
|
|
21083
|
+
{ tool: dedustQuoteTool, executor: dedustQuoteExecutor },
|
|
21084
|
+
{ tool: dedustPoolsTool, executor: dedustPoolsExecutor }
|
|
21085
|
+
];
|
|
21086
|
+
|
|
20859
21087
|
// src/agent/tools/dex/smart-quote.ts
|
|
20860
21088
|
import { Type as Type99 } from "@sinclair/typebox";
|
|
20861
21089
|
import { TonClient as TonClient15, toNano as toNano24, fromNano as fromNano7 } from "@ton/ton";
|
|
@@ -21453,6 +21681,12 @@ var dexSwapExecutor = async (params, context) => {
|
|
|
21453
21681
|
}
|
|
21454
21682
|
};
|
|
21455
21683
|
|
|
21684
|
+
// src/agent/tools/dex/index.ts
|
|
21685
|
+
var tools20 = [
|
|
21686
|
+
{ tool: dexSwapTool, executor: dexSwapExecutor, scope: "dm-only" },
|
|
21687
|
+
{ tool: dexQuoteTool, executor: dexQuoteExecutor }
|
|
21688
|
+
];
|
|
21689
|
+
|
|
21456
21690
|
// src/agent/tools/journal/log.ts
|
|
21457
21691
|
import { Type as Type101 } from "@sinclair/typebox";
|
|
21458
21692
|
var journalLogTool = {
|
|
@@ -21802,6 +22036,13 @@ var journalUpdateExecutor = async (params) => {
|
|
|
21802
22036
|
};
|
|
21803
22037
|
};
|
|
21804
22038
|
|
|
22039
|
+
// src/agent/tools/journal/index.ts
|
|
22040
|
+
var tools21 = [
|
|
22041
|
+
{ tool: journalLogTool, executor: journalLogExecutor, scope: "dm-only" },
|
|
22042
|
+
{ tool: journalUpdateTool, executor: journalUpdateExecutor, scope: "dm-only" },
|
|
22043
|
+
{ tool: journalQueryTool, executor: journalQueryExecutor }
|
|
22044
|
+
];
|
|
22045
|
+
|
|
21805
22046
|
// src/agent/tools/workspace/list.ts
|
|
21806
22047
|
import { Type as Type104 } from "@sinclair/typebox";
|
|
21807
22048
|
import { readdirSync as readdirSync3, lstatSync as lstatSync2 } from "fs";
|
|
@@ -22371,124 +22612,33 @@ var workspaceRenameExecutor = async (params, _context) => {
|
|
|
22371
22612
|
}
|
|
22372
22613
|
};
|
|
22373
22614
|
|
|
22615
|
+
// src/agent/tools/workspace/index.ts
|
|
22616
|
+
var tools22 = [
|
|
22617
|
+
{ tool: workspaceWriteTool, executor: workspaceWriteExecutor, scope: "dm-only" },
|
|
22618
|
+
{ tool: workspaceDeleteTool, executor: workspaceDeleteExecutor, scope: "dm-only" },
|
|
22619
|
+
{ tool: workspaceRenameTool, executor: workspaceRenameExecutor, scope: "dm-only" },
|
|
22620
|
+
{ tool: workspaceListTool, executor: workspaceListExecutor },
|
|
22621
|
+
{ tool: workspaceReadTool, executor: workspaceReadExecutor },
|
|
22622
|
+
{ tool: workspaceInfoTool, executor: workspaceInfoExecutor }
|
|
22623
|
+
];
|
|
22624
|
+
|
|
22374
22625
|
// src/agent/tools/register-all.ts
|
|
22375
|
-
|
|
22376
|
-
|
|
22377
|
-
|
|
22378
|
-
|
|
22379
|
-
|
|
22380
|
-
|
|
22381
|
-
|
|
22382
|
-
|
|
22383
|
-
|
|
22384
|
-
|
|
22385
|
-
|
|
22386
|
-
|
|
22387
|
-
|
|
22388
|
-
|
|
22389
|
-
|
|
22390
|
-
|
|
22391
|
-
registry.register(telegramSendGifTool, telegramSendGifExecutor);
|
|
22392
|
-
registry.register(telegramCreatePollTool, telegramCreatePollExecutor);
|
|
22393
|
-
registry.register(telegramCreateQuizTool, telegramCreateQuizExecutor);
|
|
22394
|
-
registry.register(telegramReplyKeyboardTool, telegramReplyKeyboardExecutor);
|
|
22395
|
-
registry.register(telegramSearchStickersTool, telegramSearchStickersExecutor);
|
|
22396
|
-
registry.register(telegramGetMyStickersTool, telegramGetMyStickersExecutor);
|
|
22397
|
-
registry.register(telegramSearchGifsTool, telegramSearchGifsExecutor);
|
|
22398
|
-
registry.register(telegramAddStickerSetTool, telegramAddStickerSetExecutor);
|
|
22399
|
-
registry.register(telegramGetHistoryTool, telegramGetHistoryExecutor);
|
|
22400
|
-
registry.register(telegramGetDialogsTool, telegramGetDialogsExecutor);
|
|
22401
|
-
registry.register(telegramMarkAsReadTool, telegramMarkAsReadExecutor);
|
|
22402
|
-
registry.register(telegramGetChatInfoTool, telegramGetChatInfoExecutor);
|
|
22403
|
-
registry.register(telegramJoinChannelTool, telegramJoinChannelExecutor, "dm-only");
|
|
22404
|
-
registry.register(telegramLeaveChannelTool, telegramLeaveChannelExecutor, "dm-only");
|
|
22405
|
-
registry.register(telegramGetMeTool, telegramGetMeExecutor);
|
|
22406
|
-
registry.register(telegramGetParticipantsTool, telegramGetParticipantsExecutor);
|
|
22407
|
-
registry.register(telegramKickUserTool, telegramKickUserExecutor, "group-only");
|
|
22408
|
-
registry.register(telegramBanUserTool, telegramBanUserExecutor, "group-only");
|
|
22409
|
-
registry.register(telegramUnbanUserTool, telegramUnbanUserExecutor, "group-only");
|
|
22410
|
-
registry.register(telegramCreateGroupTool, telegramCreateGroupExecutor, "dm-only");
|
|
22411
|
-
registry.register(telegramSetChatPhotoTool, telegramSetChatPhotoExecutor, "group-only");
|
|
22412
|
-
registry.register(telegramBlockUserTool, telegramBlockUserExecutor, "dm-only");
|
|
22413
|
-
registry.register(telegramGetBlockedTool, telegramGetBlockedExecutor, "dm-only");
|
|
22414
|
-
registry.register(telegramGetCommonChatsTool, telegramGetCommonChatsExecutor);
|
|
22415
|
-
registry.register(telegramSendStoryTool, telegramSendStoryExecutor, "dm-only");
|
|
22416
|
-
registry.register(telegramGetFoldersTool, telegramGetFoldersExecutor);
|
|
22417
|
-
registry.register(telegramCreateFolderTool, telegramCreateFolderExecutor);
|
|
22418
|
-
registry.register(telegramAddChatToFolderTool, telegramAddChatToFolderExecutor);
|
|
22419
|
-
registry.register(telegramCreateChannelTool, telegramCreateChannelExecutor, "dm-only");
|
|
22420
|
-
registry.register(telegramUpdateProfileTool, telegramUpdateProfileExecutor, "dm-only");
|
|
22421
|
-
registry.register(telegramSetBioTool, telegramSetBioExecutor, "dm-only");
|
|
22422
|
-
registry.register(telegramSetUsernameTool, telegramSetUsernameExecutor, "dm-only");
|
|
22423
|
-
registry.register(telegramDeleteMessageTool, telegramDeleteMessageExecutor);
|
|
22424
|
-
registry.register(telegramDownloadMediaTool, telegramDownloadMediaExecutor);
|
|
22425
|
-
registry.register(visionAnalyzeTool, visionAnalyzeExecutor);
|
|
22426
|
-
registry.register(telegramGetStarsBalanceTool, telegramGetStarsBalanceExecutor, "dm-only");
|
|
22427
|
-
registry.register(
|
|
22428
|
-
telegramGetStarsTransactionsTool,
|
|
22429
|
-
telegramGetStarsTransactionsExecutor,
|
|
22430
|
-
"dm-only"
|
|
22431
|
-
);
|
|
22432
|
-
registry.register(telegramGetAvailableGiftsTool, telegramGetAvailableGiftsExecutor);
|
|
22433
|
-
registry.register(telegramSendGiftTool, telegramSendGiftExecutor, "dm-only");
|
|
22434
|
-
registry.register(telegramGetMyGiftsTool, telegramGetMyGiftsExecutor);
|
|
22435
|
-
registry.register(
|
|
22436
|
-
telegramTransferCollectibleTool,
|
|
22437
|
-
telegramTransferCollectibleExecutor,
|
|
22438
|
-
"dm-only"
|
|
22439
|
-
);
|
|
22440
|
-
registry.register(
|
|
22441
|
-
telegramSetCollectiblePriceTool,
|
|
22442
|
-
telegramSetCollectiblePriceExecutor,
|
|
22443
|
-
"dm-only"
|
|
22444
|
-
);
|
|
22445
|
-
registry.register(telegramGetResaleGiftsTool, telegramGetResaleGiftsExecutor);
|
|
22446
|
-
registry.register(telegramBuyResaleGiftTool, telegramBuyResaleGiftExecutor, "dm-only");
|
|
22447
|
-
registry.register(telegramSetGiftStatusTool, telegramSetGiftStatusExecutor, "dm-only");
|
|
22448
|
-
registry.register(memoryWriteTool, memoryWriteExecutor, "dm-only");
|
|
22449
|
-
registry.register(memoryReadTool, memoryReadExecutor);
|
|
22450
|
-
registry.register(telegramGetUserInfoTool, telegramGetUserInfoExecutor);
|
|
22451
|
-
registry.register(telegramCheckUsernameTool, telegramCheckUsernameExecutor);
|
|
22452
|
-
registry.register(telegramEditChannelInfoTool, telegramEditChannelInfoExecutor, "dm-only");
|
|
22453
|
-
registry.register(telegramInviteToChannelTool, telegramInviteToChannelExecutor, "dm-only");
|
|
22454
|
-
registry.register(tonGetAddressTool, tonGetAddressExecutor);
|
|
22455
|
-
registry.register(tonGetBalanceTool, tonGetBalanceExecutor);
|
|
22456
|
-
registry.register(tonPriceTool, tonPriceExecutor);
|
|
22457
|
-
registry.register(tonSendTool, tonSendExecutor, "dm-only");
|
|
22458
|
-
registry.register(tonGetTransactionsTool, tonGetTransactionsExecutor);
|
|
22459
|
-
registry.register(tonMyTransactionsTool, tonMyTransactionsExecutor);
|
|
22460
|
-
registry.register(jettonBalancesTool, jettonBalancesExecutor);
|
|
22461
|
-
registry.register(jettonSwapTool, jettonSwapExecutor, "dm-only");
|
|
22462
|
-
registry.register(jettonSendTool, jettonSendExecutor, "dm-only");
|
|
22463
|
-
registry.register(jettonInfoTool, jettonInfoExecutor);
|
|
22464
|
-
registry.register(jettonPriceTool, jettonPriceExecutor);
|
|
22465
|
-
registry.register(jettonSearchTool, jettonSearchExecutor);
|
|
22466
|
-
registry.register(jettonQuoteTool, jettonQuoteExecutor);
|
|
22467
|
-
registry.register(jettonHoldersTool, jettonHoldersExecutor);
|
|
22468
|
-
registry.register(jettonHistoryTool, jettonHistoryExecutor);
|
|
22469
|
-
registry.register(jettonTrendingTool, jettonTrendingExecutor);
|
|
22470
|
-
registry.register(jettonPoolsTool, jettonPoolsExecutor);
|
|
22471
|
-
registry.register(dnsCheckTool, dnsCheckExecutor);
|
|
22472
|
-
registry.register(dnsAuctionsTool, dnsAuctionsExecutor);
|
|
22473
|
-
registry.register(dnsResolveTool, dnsResolveExecutor);
|
|
22474
|
-
registry.register(dnsStartAuctionTool, dnsStartAuctionExecutor, "dm-only");
|
|
22475
|
-
registry.register(dnsBidTool, dnsBidExecutor, "dm-only");
|
|
22476
|
-
registry.register(dnsLinkTool, dnsLinkExecutor, "dm-only");
|
|
22477
|
-
registry.register(dnsUnlinkTool, dnsUnlinkExecutor, "dm-only");
|
|
22478
|
-
registry.register(dedustQuoteTool, dedustQuoteExecutor);
|
|
22479
|
-
registry.register(dedustSwapTool, dedustSwapExecutor, "dm-only");
|
|
22480
|
-
registry.register(dedustPoolsTool, dedustPoolsExecutor);
|
|
22481
|
-
registry.register(dexQuoteTool, dexQuoteExecutor);
|
|
22482
|
-
registry.register(dexSwapTool, dexSwapExecutor, "dm-only");
|
|
22483
|
-
registry.register(journalLogTool, journalLogExecutor, "dm-only");
|
|
22484
|
-
registry.register(journalQueryTool, journalQueryExecutor);
|
|
22485
|
-
registry.register(journalUpdateTool, journalUpdateExecutor, "dm-only");
|
|
22486
|
-
registry.register(workspaceListTool, workspaceListExecutor);
|
|
22487
|
-
registry.register(workspaceReadTool, workspaceReadExecutor);
|
|
22488
|
-
registry.register(workspaceWriteTool, workspaceWriteExecutor, "dm-only");
|
|
22489
|
-
registry.register(workspaceDeleteTool, workspaceDeleteExecutor, "dm-only");
|
|
22490
|
-
registry.register(workspaceInfoTool, workspaceInfoExecutor);
|
|
22491
|
-
registry.register(workspaceRenameTool, workspaceRenameExecutor, "dm-only");
|
|
22626
|
+
var ALL_CATEGORIES = [
|
|
22627
|
+
tools15,
|
|
22628
|
+
tools16,
|
|
22629
|
+
tools17,
|
|
22630
|
+
tools18,
|
|
22631
|
+
tools19,
|
|
22632
|
+
tools20,
|
|
22633
|
+
tools21,
|
|
22634
|
+
tools22
|
|
22635
|
+
];
|
|
22636
|
+
function registerAllTools(registry) {
|
|
22637
|
+
for (const category of ALL_CATEGORIES) {
|
|
22638
|
+
for (const { tool, executor, scope } of category) {
|
|
22639
|
+
registry.register(tool, executor, scope);
|
|
22640
|
+
}
|
|
22641
|
+
}
|
|
22492
22642
|
}
|
|
22493
22643
|
|
|
22494
22644
|
// src/agent/tools/plugin-loader.ts
|
|
@@ -23409,11 +23559,6 @@ var module_default2 = casinoModule;
|
|
|
23409
23559
|
import Database from "better-sqlite3";
|
|
23410
23560
|
import { join as join15 } from "path";
|
|
23411
23561
|
var DB_PATH3 = join15(TELETON_ROOT, "gifts.db");
|
|
23412
|
-
function getDb2() {
|
|
23413
|
-
const db3 = new Database(DB_PATH3);
|
|
23414
|
-
db3.pragma("journal_mode = WAL");
|
|
23415
|
-
return db3;
|
|
23416
|
-
}
|
|
23417
23562
|
function getStats(db3) {
|
|
23418
23563
|
const collections = db3.prepare("SELECT COUNT(*) as count FROM gift_collections").get();
|
|
23419
23564
|
const models = db3.prepare("SELECT COUNT(*) as count FROM gift_models").get();
|
|
@@ -23441,7 +23586,7 @@ var MarketScraperService = class {
|
|
|
23441
23586
|
this.isScrapingInProgress = true;
|
|
23442
23587
|
console.log("\u{1F504} Starting full market scrape...");
|
|
23443
23588
|
try {
|
|
23444
|
-
const { runScraper } = await import("./scraper-
|
|
23589
|
+
const { runScraper } = await import("./scraper-DSAYK6QJ.js");
|
|
23445
23590
|
const result = await runScraper({
|
|
23446
23591
|
workers: 4,
|
|
23447
23592
|
limit: 0
|
|
@@ -23510,7 +23655,7 @@ var MarketPriceService = class {
|
|
|
23510
23655
|
return;
|
|
23511
23656
|
}
|
|
23512
23657
|
try {
|
|
23513
|
-
this.db =
|
|
23658
|
+
this.db = initScraperDb();
|
|
23514
23659
|
const stats = getStats(this.db);
|
|
23515
23660
|
let dataAgeMs = Infinity;
|
|
23516
23661
|
let timeUntilNextRefresh = this.fullRefreshIntervalMs;
|
|
@@ -23773,8 +23918,8 @@ function loadModules(registry, config, db3) {
|
|
|
23773
23918
|
try {
|
|
23774
23919
|
mod.configure?.(config);
|
|
23775
23920
|
mod.migrate?.(db3);
|
|
23776
|
-
const
|
|
23777
|
-
for (const { tool, executor, scope } of
|
|
23921
|
+
const tools23 = mod.tools(config);
|
|
23922
|
+
for (const { tool, executor, scope } of tools23) {
|
|
23778
23923
|
registry.register(tool, executor, scope);
|
|
23779
23924
|
}
|
|
23780
23925
|
loaded.push(mod);
|
|
@@ -23805,7 +23950,7 @@ var TonnetApp = class {
|
|
|
23805
23950
|
}
|
|
23806
23951
|
const soul = loadSoul();
|
|
23807
23952
|
this.toolRegistry = new ToolRegistry();
|
|
23808
|
-
registerAllTools(this.toolRegistry
|
|
23953
|
+
registerAllTools(this.toolRegistry);
|
|
23809
23954
|
this.agent = new AgentRuntime(this.config, soul, this.toolRegistry);
|
|
23810
23955
|
this.bridge = new TelegramBridge({
|
|
23811
23956
|
apiId: this.config.telegram.api_id,
|