@frogbotai/piece-telegram-bot 0.21.0 → 0.23.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAElF,eAAO,MAAM,kBAAkB,iHAOrB,CAAC;AACX,eAAO,MAAM,iBAAiB,aAAc,CAAC;AAE7C,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,kBAAkB;IAUzD,oEAAoE;;IAEpE,2FAA2F;;IAE3F,uEAAuE;;IAEvE,gGAAgG;;IAEhG,wFAAwF;;IAExF,uGAAuG;;IAEvG,yEAAyE;;IAEzE,gKAAgK;;IAEhK,yFAAyF;;IAEzF,wIAAwI;;IAExI,kEAAkE;;IAElE,2GAA2G;;IAE3G,gHAAgH;;IAEhH,uGAAuG;;IAEvG,sFAAsF;;IAEtF,kFAAkF;;IAElF,2DAA2D;;IAE3D,uIAAuI;;IAEvI,yHAAyH;;IAEzH,qEAAqE;;EAGxE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuB7B,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG9E,OAAO,EAAwB,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,kBAAkB,+TAoBrB,CAAC;AACX,eAAO,MAAM,mBAAmB,wBAAyB,CAAC;AAC1D,eAAO,MAAM,iBAAiB,aAAc,CAAC;AAgC7C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAgCm8R,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADv+R,CAAC"}
package/dist/index.js CHANGED
@@ -1,64 +1,86 @@
1
- import * as module from '@activepieces/piece-telegram-bot';
2
- import { createActivepiecesPiece } from 'frogbot/pieces';
1
+ import { createTelegramAdapter } from '@chat-adapter/telegram';
2
+ import { definePiece } from 'frogbot/pieces';
3
+ import { answerCallbackQuery, createInviteLink, customApiCall, deleteMessage, editMessageText, forwardMessage, getChat, getChatMember, getFile, pinMessage, sendAudio, sendChatAction, sendDocument, sendLocation, sendMedia, sendMediaGroup, sendPoll, sendTextMessage, unpinMessage, } from './actions/index.js';
4
+ import { createTelegramBotClient } from './client.js';
5
+ import { telegramBotAuth, telegramBotOptions } from './config.js';
6
+ import { newUpdate } from './triggers/newUpdate.js';
7
+ import { parseTelegramWebhook, verifyTelegramWebhook } from './webhook.js';
3
8
  export const telegramBotActions = [
4
- 'send_text_message',
5
- 'send_media',
6
- 'send_document',
7
- 'send_location',
8
- 'edit_message_text',
9
- 'get_chat',
9
+ 'sendTextMessage',
10
+ 'sendMedia',
11
+ 'sendDocument',
12
+ 'sendAudio',
13
+ 'sendLocation',
14
+ 'sendMediaGroup',
15
+ 'sendPoll',
16
+ 'sendChatAction',
17
+ 'editMessageText',
18
+ 'deleteMessage',
19
+ 'forwardMessage',
20
+ 'pinMessage',
21
+ 'unpinMessage',
22
+ 'getChat',
23
+ 'getChatMember',
24
+ 'getFile',
25
+ 'createInviteLink',
26
+ 'answerCallbackQuery',
27
+ 'customApiCall',
10
28
  ];
29
+ export const telegramBotTriggers = ['newUpdate'];
11
30
  export const telegramBotScopes = [];
12
- export function createTelegramBot(config) {
13
- const piece = createActivepiecesPiece({
14
- module: module,
15
- service: 'telegram_bot',
16
- credentialType: 'secret_text',
17
- defaultActions: telegramBotActions,
18
- scopes: telegramBotScopes,
19
- config,
20
- });
21
- return Object.assign(piece, {
22
- /** Send Text Message: Send a text message through a Telegram bot */
23
- sendTextMessage: piece.tool('send_text_message'),
24
- /** Send Media: Send a media message (photo, video, sticker, GIF) through a Telegram bot */
25
- sendMedia: piece.tool('send_media'),
26
- /** Send Document: Send a generic file (document) to a Telegram chat */
27
- sendDocument: piece.tool('send_document'),
28
- /** Send Audio: Send an audio file to a Telegram chat (.MP3/.M4A — shown in the music player) */
29
- sendAudio: piece.tool('send_audio'),
30
- /** Send Location: Send a geographic location (latitude/longitude) to a Telegram chat */
31
- sendLocation: piece.tool('send_location'),
32
- /** Send Media Group: Send a group of 2–10 photos, videos, documents or audios as an album to a chat */
33
- sendMediaGroup: piece.tool('send_media_group'),
34
- /** Send Poll: Send a native Telegram poll (regular or quiz) to a chat */
35
- sendPoll: piece.tool('send_poll'),
36
- /** Send Chat Action: Show a status (typing, uploading photo, recording voice, etc.) on behalf of the bot in a chat. The status is shown for up to 5 seconds. */
37
- sendChatAction: piece.tool('send_chat_action'),
38
- /** Edit Message Text: Edit the text of a previously sent message or an inline message */
39
- editMessageText: piece.tool('edit_message_text'),
40
- /** Delete Message: Delete a message sent in a chat. Bots can delete their own messages and messages in groups where they are admins. */
41
- deleteMessage: piece.tool('delete_message'),
42
- /** Forward Message: Forward a message from one chat to another */
43
- forwardMessage: piece.tool('forward_message'),
44
- /** Pin Message: Pin a message in a chat. The bot must be an administrator in the chat for this to work. */
45
- pinMessage: piece.tool('pin_message'),
46
- /** Unpin Message: Unpin a message in a chat. Leave Message Id empty to unpin the most recent pinned message. */
47
- unpinMessage: piece.tool('unpin_message'),
48
- /** Get Chat: Get up-to-date information about a chat (name, description, photo, member count, etc.) */
49
- getChat: piece.tool('get_chat'),
50
- /** Get Chat Member: Get member info (or null) for the provided chat id and user id */
51
- getChatMember: piece.tool('get_chat_member'),
52
- /** Get File: Get file information and optionally download a file from Telegram */
53
- getFile: piece.tool('get_file'),
54
- /** Create Invite Link: Create an invite link for a chat */
55
- createInviteLink: piece.tool('create_invite_link'),
56
- /** Answer Callback Query: Respond to a callback query sent by an inline keyboard button. Shows a notification or alert to the user. */
57
- answerCallbackQuery: piece.tool('answer_callback_query'),
58
- /** Request Approval Message: Send an approval message to a chat and wait until the message is approved or disapproved */
59
- requestApprovalMessage: piece.tool('request_approval_message'),
60
- /** Custom API Call: Make a custom API call to a specific endpoint */
61
- customApiCall: piece.tool('custom_api_call'),
62
- });
63
- }
31
+ const telegramBotWebhook = {
32
+ verify: verifyTelegramWebhook,
33
+ parse() {
34
+ return parseTelegramWebhook();
35
+ },
36
+ };
37
+ const telegramBotChannel = {
38
+ adapter({ auth, options }) {
39
+ if (!options.webhookSecret) {
40
+ throw new Error('Telegram channels require a webhookSecret option.');
41
+ }
42
+ return createTelegramAdapter({
43
+ botToken: auth.botToken,
44
+ secretToken: options.webhookSecret,
45
+ userName: options.botUsername,
46
+ allowedUserIds: options.allowedUserIds,
47
+ mode: 'webhook',
48
+ });
49
+ },
50
+ async identity() {
51
+ return null;
52
+ },
53
+ };
54
+ export const createTelegramBot = definePiece({
55
+ slug: 'telegramBot',
56
+ label: 'Telegram Bot',
57
+ admin: { description: 'Build chatbots and respond to Telegram updates', group: 'Communication' },
58
+ auth: telegramBotAuth,
59
+ options: telegramBotOptions,
60
+ client: createTelegramBotClient,
61
+ webhook: telegramBotWebhook,
62
+ channel: telegramBotChannel,
63
+ actions: [
64
+ sendTextMessage,
65
+ sendMedia,
66
+ sendDocument,
67
+ sendAudio,
68
+ sendLocation,
69
+ sendMediaGroup,
70
+ sendPoll,
71
+ sendChatAction,
72
+ editMessageText,
73
+ deleteMessage,
74
+ forwardMessage,
75
+ pinMessage,
76
+ unpinMessage,
77
+ getChat,
78
+ getChatMember,
79
+ getFile,
80
+ createInviteLink,
81
+ answerCallbackQuery,
82
+ customApiCall,
83
+ ],
84
+ triggers: [newUpdate],
85
+ });
64
86
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAA2B,MAAM,gBAAgB,CAAC;AAElF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,mBAAmB;IACnB,YAAY;IACZ,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,UAAU;CACF,CAAC;AACX,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAW,CAAC;AAE7C,MAAM,UAAU,iBAAiB,CAAC,MAA2B;IAC3D,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACpC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,cAAc;QACvB,cAAc,EAAE,aAAa;QAC7B,cAAc,EAAE,kBAAkB;QAClC,MAAM,EAAE,iBAAiB;QACzB,MAAM;KACP,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;QAC1B,oEAAoE;QACpE,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC;QAChD,2FAA2F;QAC3F,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;QACnC,uEAAuE;QACvE,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;QACzC,gGAAgG;QAChG,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;QACnC,wFAAwF;QACxF,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;QACzC,uGAAuG;QACvG,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAC9C,yEAAyE;QACzE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW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C,WAAW;YAC7B,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,QAAQ;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;CAKF,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;IAC3C,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,cAAc;IACrB,KAAK,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,KAAK,EAAE,eAAe,EAAE;IAChG,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,uBAAuB;IAC/B,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE;QACP,eAAe;QACf,SAAS;QACT,YAAY;QACZ,SAAS;QACT,YAAY;QACZ,cAAc;QACd,QAAQ;QACR,cAAc;QACd,eAAe;QACf,aAAa;QACb,cAAc;QACd,UAAU;QACV,YAAY;QACZ,OAAO;QACP,aAAa;QACb,OAAO;QACP,gBAAgB;QAChB,mBAAmB;QACnB,aAAa;KACd;IACD,QAAQ,EAAE,CAAC,SAAS,CAAC;CACtB,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { PieceAppTrigger, PieceJSON } from 'frogbot/pieces';
2
+ import { z } from 'zod';
3
+ import type { TelegramBotClient } from '../client.js';
4
+ declare const input: z.ZodObject<{
5
+ updateTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
6
+ message: "message";
7
+ edited_message: "edited_message";
8
+ channel_post: "channel_post";
9
+ edited_channel_post: "edited_channel_post";
10
+ callback_query: "callback_query";
11
+ inline_query: "inline_query";
12
+ chosen_inline_result: "chosen_inline_result";
13
+ poll: "poll";
14
+ poll_answer: "poll_answer";
15
+ my_chat_member: "my_chat_member";
16
+ chat_member: "chat_member";
17
+ chat_join_request: "chat_join_request";
18
+ }>>>;
19
+ }, z.core.$strip>;
20
+ declare const update: z.ZodObject<{
21
+ update_id: z.ZodOptional<z.ZodNumber>;
22
+ }, z.core.$catchall<z.ZodType<PieceJSON, unknown, z.core.$ZodTypeInternals<PieceJSON, unknown>>>>;
23
+ export declare const newUpdate: PieceAppTrigger<typeof input, typeof update, object, TelegramBotClient>;
24
+ export {};
25
+ //# sourceMappingURL=newUpdate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"newUpdate.d.ts","sourceRoot":"","sources":["../../src/triggers/newUpdate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAgBtD,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;iBAA8D,CAAC;AAW1E,QAAA,MAAM,MAAM;;iGAAqE,CAAC;AAElF,eAAO,MAAM,SAAS,EAAE,eAAe,CAAC,OAAO,KAAK,EAAE,OAAO,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAyB7F,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { z } from 'zod';
3
+ const updateTypes = z.enum([
4
+ 'message',
5
+ 'edited_message',
6
+ 'channel_post',
7
+ 'edited_channel_post',
8
+ 'callback_query',
9
+ 'inline_query',
10
+ 'chosen_inline_result',
11
+ 'poll',
12
+ 'poll_answer',
13
+ 'my_chat_member',
14
+ 'chat_member',
15
+ 'chat_join_request',
16
+ ]);
17
+ const input = z.object({ updateTypes: z.array(updateTypes).default([]) });
18
+ const jsonValue = z.lazy(() => z.union([
19
+ z.string(),
20
+ z.number(),
21
+ z.boolean(),
22
+ z.null(),
23
+ z.array(jsonValue),
24
+ z.record(z.string(), jsonValue),
25
+ ]));
26
+ const update = z.object({ update_id: z.number().optional() }).catchall(jsonValue);
27
+ export const newUpdate = {
28
+ slug: 'newUpdate',
29
+ description: 'Trigger when the bot receives a selected Telegram update.',
30
+ type: 'app',
31
+ event: 'update',
32
+ input,
33
+ output: update,
34
+ sample: {
35
+ update_id: 351114420,
36
+ message: { message_id: 21, text: 'Hello world', chat: { id: 55169542059, type: 'private' } },
37
+ },
38
+ async run({ input, req }) {
39
+ const delivery = update.parse(req.data);
40
+ const selected = input.updateTypes;
41
+ const matches = selected.length === 0 || selected.some((type) => type in delivery);
42
+ if (!matches)
43
+ return [];
44
+ const dedupeKey = delivery.update_id === undefined
45
+ ? createHash('sha256').update(JSON.stringify(delivery)).digest('hex')
46
+ : String(delivery.update_id);
47
+ return [{ dedupeKey, data: delivery }];
48
+ },
49
+ };
50
+ //# sourceMappingURL=newUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"newUpdate.js","sourceRoot":"","sources":["../../src/triggers/newUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC;IACzB,SAAS;IACT,gBAAgB;IAChB,cAAc;IACd,qBAAqB;IACrB,gBAAgB;IAChB,cAAc;IACd,sBAAsB;IACtB,MAAM;IACN,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,mBAAmB;CACpB,CAAC,CAAC;AACH,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC1E,MAAM,SAAS,GAAyB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAClD,CAAC,CAAC,KAAK,CAAC;IACN,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,OAAO,EAAE;IACX,CAAC,CAAC,IAAI,EA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;YACrE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAEjC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzC,CAAC;CACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { FrogbotRequest } from 'frogbot';
2
+ export declare function verifyTelegramWebhook({ req, options, }: {
3
+ req: FrogbotRequest;
4
+ options: {
5
+ webhookSecret?: string;
6
+ };
7
+ }): Promise<boolean>;
8
+ export declare function parseTelegramWebhook(): {
9
+ event: string;
10
+ };
11
+ //# sourceMappingURL=webhook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../src/webhook.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAsB,qBAAqB,CAAC,EAC1C,GAAG,EACH,OAAO,GACR,EAAE;IACD,GAAG,EAAE,cAAc,CAAC;IACpB,OAAO,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC,oBAaA;AAED,wBAAgB,oBAAoB;;EAEnC"}
@@ -0,0 +1,15 @@
1
+ import { timingSafeEqual } from 'node:crypto';
2
+ export async function verifyTelegramWebhook({ req, options, }) {
3
+ if (!options.webhookSecret)
4
+ return false;
5
+ const supplied = req.headers.get('x-telegram-bot-api-secret-token');
6
+ if (!supplied)
7
+ return false;
8
+ const suppliedBytes = Buffer.from(supplied);
9
+ const expectedBytes = Buffer.from(options.webhookSecret);
10
+ return (suppliedBytes.length === expectedBytes.length && timingSafeEqual(suppliedBytes, expectedBytes));
11
+ }
12
+ export function parseTelegramWebhook() {
13
+ return { event: 'update' };
14
+ }
15
+ //# sourceMappingURL=webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../src/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAC1C,GAAG,EACH,OAAO,GAIR;IACC,IAAI,CAAC,OAAO,CAAC,aAAa;QAAE,OAAO,KAAK,CAAC;IAEzC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAEpE,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5B,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEzD,OAAO,CACL,aAAa,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,IAAI,eAAe,CAAC,aAAa,EAAE,aAAa,CAAC,CAC/F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frogbotai/piece-telegram-bot",
3
- "version": "0.21.0",
4
- "description": "Telegram Bot tools for FrogBot.",
3
+ "version": "0.23.0",
4
+ "description": "telegram-bot tools for FrogBot.",
5
5
  "license": "MIT",
6
6
  "author": "Colby Gilbert",
7
7
  "type": "module",
@@ -19,14 +19,15 @@
19
19
  ],
20
20
  "sideEffects": false,
21
21
  "dependencies": {
22
- "@activepieces/piece-telegram-bot": "0.6.5"
22
+ "@chat-adapter/telegram": "^4.40.0",
23
+ "zod": "^4.3.6"
23
24
  },
24
25
  "peerDependencies": {
25
- "frogbot": "0.21.0"
26
+ "frogbot": "0.23.0"
26
27
  },
27
28
  "devDependencies": {
28
29
  "typescript": "5.6.2",
29
- "frogbot": "0.21.0"
30
+ "frogbot": "0.23.0"
30
31
  },
31
32
  "publishConfig": {
32
33
  "access": "public"