@rnsk/toolkits 0.0.10 → 0.0.11
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 +12 -2
- package/dist/index.d.ts +11 -1
- package/dist/index.js +21 -1
- package/dist/toolkits/bitbucket/tools/index.d.ts +5 -5
- package/dist/toolkits/bitbucket/tools/reports.d.ts +5 -5
- package/dist/toolkits/cloudflare/tools/create-list.d.ts +1 -1
- package/dist/toolkits/cloudflare/tools/create-zone.d.ts +1 -1
- package/dist/toolkits/cloudflare/tools/index.d.ts +4 -4
- package/dist/toolkits/cloudflare/tools/list-pools.d.ts +1 -1
- package/dist/toolkits/cloudflare/tools/list-zones.d.ts +1 -1
- package/dist/toolkits/convex/icon.d.ts +5 -0
- package/dist/toolkits/convex/icon.js +10 -0
- package/dist/toolkits/convex/manifest.d.ts +3 -0
- package/dist/toolkits/convex/manifest.js +33 -0
- package/dist/toolkits/convex/tools/client.d.ts +28 -0
- package/dist/toolkits/convex/tools/client.js +85 -0
- package/dist/toolkits/convex/tools/deploy-keys.d.ts +10 -0
- package/dist/toolkits/convex/tools/deploy-keys.js +46 -0
- package/dist/toolkits/convex/tools/deployments.d.ts +35 -0
- package/dist/toolkits/convex/tools/deployments.js +126 -0
- package/dist/toolkits/convex/tools/domains.d.ts +7 -0
- package/dist/toolkits/convex/tools/domains.js +29 -0
- package/dist/toolkits/convex/tools/functions.d.ts +14 -0
- package/dist/toolkits/convex/tools/functions.js +49 -0
- package/dist/toolkits/convex/tools/index.d.ts +176 -0
- package/dist/toolkits/convex/tools/index.js +145 -0
- package/dist/toolkits/convex/tools/logging.d.ts +5 -0
- package/dist/toolkits/convex/tools/logging.js +25 -0
- package/dist/toolkits/convex/tools/projects.d.ts +31 -0
- package/dist/toolkits/convex/tools/projects.js +111 -0
- package/dist/toolkits/convex/tools/teams.d.ts +12 -0
- package/dist/toolkits/convex/tools/teams.js +62 -0
- package/dist/toolkits/datadog/icon.d.ts +5 -0
- package/dist/toolkits/datadog/icon.js +6 -0
- package/dist/toolkits/datadog/manifest.d.ts +3 -0
- package/dist/toolkits/datadog/manifest.js +44 -0
- package/dist/toolkits/datadog/tools/api-keys.d.ts +21 -0
- package/dist/toolkits/datadog/tools/api-keys.js +42 -0
- package/dist/toolkits/datadog/tools/apm.d.ts +51 -0
- package/dist/toolkits/datadog/tools/apm.js +106 -0
- package/dist/toolkits/datadog/tools/client.d.ts +19 -0
- package/dist/toolkits/datadog/tools/client.js +81 -0
- package/dist/toolkits/datadog/tools/dashboards.d.ts +93 -0
- package/dist/toolkits/datadog/tools/dashboards.js +127 -0
- package/dist/toolkits/datadog/tools/events.d.ts +35 -0
- package/dist/toolkits/datadog/tools/events.js +56 -0
- package/dist/toolkits/datadog/tools/hosts.d.ts +49 -0
- package/dist/toolkits/datadog/tools/hosts.js +87 -0
- package/dist/toolkits/datadog/tools/incidents.d.ts +18 -0
- package/dist/toolkits/datadog/tools/incidents.js +34 -0
- package/dist/toolkits/datadog/tools/index.d.ts +999 -0
- package/dist/toolkits/datadog/tools/index.js +450 -0
- package/dist/toolkits/datadog/tools/integrations.d.ts +32 -0
- package/dist/toolkits/datadog/tools/integrations.js +47 -0
- package/dist/toolkits/datadog/tools/logs.d.ts +39 -0
- package/dist/toolkits/datadog/tools/logs.js +121 -0
- package/dist/toolkits/datadog/tools/metrics.d.ts +27 -0
- package/dist/toolkits/datadog/tools/metrics.js +83 -0
- package/dist/toolkits/datadog/tools/monitors.d.ts +95 -0
- package/dist/toolkits/datadog/tools/monitors.js +190 -0
- package/dist/toolkits/datadog/tools/oncall-notifications.d.ts +61 -0
- package/dist/toolkits/datadog/tools/oncall-notifications.js +155 -0
- package/dist/toolkits/datadog/tools/oncall-policies.d.ts +28 -0
- package/dist/toolkits/datadog/tools/oncall-policies.js +72 -0
- package/dist/toolkits/datadog/tools/oncall-schedules.d.ts +31 -0
- package/dist/toolkits/datadog/tools/oncall-schedules.js +87 -0
- package/dist/toolkits/datadog/tools/oncall-teams.d.ts +14 -0
- package/dist/toolkits/datadog/tools/oncall-teams.js +54 -0
- package/dist/toolkits/datadog/tools/slos.d.ts +43 -0
- package/dist/toolkits/datadog/tools/slos.js +62 -0
- package/dist/toolkits/datadog/tools/synthetics.d.ts +58 -0
- package/dist/toolkits/datadog/tools/synthetics.js +90 -0
- package/dist/toolkits/datadog/tools/usage.d.ts +7 -0
- package/dist/toolkits/datadog/tools/usage.js +25 -0
- package/dist/toolkits/datadog/tools/users.d.ts +35 -0
- package/dist/toolkits/datadog/tools/users.js +66 -0
- package/dist/toolkits/dev-to/icon.d.ts +5 -0
- package/dist/toolkits/dev-to/icon.js +10 -0
- package/dist/toolkits/dev-to/manifest.d.ts +3 -0
- package/dist/toolkits/dev-to/manifest.js +34 -0
- package/dist/toolkits/dev-to/tools/articles.d.ts +78 -0
- package/dist/toolkits/dev-to/tools/articles.js +262 -0
- package/dist/toolkits/dev-to/tools/client.d.ts +25 -0
- package/dist/toolkits/dev-to/tools/client.js +65 -0
- package/dist/toolkits/dev-to/tools/community.d.ts +61 -0
- package/dist/toolkits/dev-to/tools/community.js +244 -0
- package/dist/toolkits/dev-to/tools/index.d.ts +202 -0
- package/dist/toolkits/dev-to/tools/index.js +37 -0
- package/dist/toolkits/dev-to/tools/listings.d.ts +26 -0
- package/dist/toolkits/dev-to/tools/listings.js +92 -0
- package/dist/toolkits/discord/tools/applications.d.ts +5 -5
- package/dist/toolkits/discord/tools/index.d.ts +5 -5
- package/dist/toolkits/figma/tools/create-modify-delete-variables.d.ts +1 -1
- package/dist/toolkits/figma/tools/get-file-nodes.d.ts +1 -1
- package/dist/toolkits/figma/tools/index.d.ts +3 -3
- package/dist/toolkits/figma/tools/render-images-of-file-nodes.d.ts +1 -1
- package/dist/toolkits/google-analytics/tools/reports.d.ts +9 -9
- package/dist/toolkits/google-classroom/tools/index.d.ts +7 -7
- package/dist/toolkits/google-classroom/tools/invitations.d.ts +2 -2
- package/dist/toolkits/google-classroom/tools/misc.d.ts +1 -1
- package/dist/toolkits/google-classroom/tools/roster.d.ts +5 -5
- package/dist/toolkits/google-search-console/tools/index.d.ts +2 -2
- package/dist/toolkits/google-search-console/tools/search-analytics-query.d.ts +2 -2
- package/dist/toolkits/hostinger/tools/index.d.ts +1 -1
- package/dist/toolkits/hostinger/tools/whois.d.ts +1 -1
- package/dist/toolkits/hugging-face/tools/datasets-viewer.d.ts +1 -1
- package/dist/toolkits/hugging-face/tools/datasets.d.ts +1 -1
- package/dist/toolkits/hugging-face/tools/index.d.ts +1 -1
- package/dist/toolkits/hugging-face/tools/models.d.ts +1 -1
- package/dist/toolkits/hugging-face/tools/repos.d.ts +1 -1
- package/dist/toolkits/hugging-face/tools/spaces.d.ts +1 -1
- package/dist/toolkits/jira/tools/index.d.ts +4 -4
- package/dist/toolkits/jira/tools/meta.d.ts +2 -2
- package/dist/toolkits/jira/tools/users.d.ts +3 -3
- package/dist/toolkits/kaggle/icon.d.ts +5 -0
- package/dist/toolkits/kaggle/icon.js +6 -0
- package/dist/toolkits/kaggle/manifest.d.ts +3 -0
- package/dist/toolkits/kaggle/manifest.js +32 -0
- package/dist/toolkits/kaggle/tools/client.d.ts +10 -0
- package/dist/toolkits/kaggle/tools/client.js +94 -0
- package/dist/toolkits/kaggle/tools/competitions.d.ts +48 -0
- package/dist/toolkits/kaggle/tools/competitions.js +109 -0
- package/dist/toolkits/kaggle/tools/config.d.ts +110 -0
- package/dist/toolkits/kaggle/tools/config.js +256 -0
- package/dist/toolkits/kaggle/tools/datasets.d.ts +88 -0
- package/dist/toolkits/kaggle/tools/datasets.js +161 -0
- package/dist/toolkits/kaggle/tools/index.d.ts +482 -0
- package/dist/toolkits/kaggle/tools/index.js +53 -0
- package/dist/toolkits/kaggle/tools/kernels.d.ts +62 -0
- package/dist/toolkits/kaggle/tools/kernels.js +121 -0
- package/dist/toolkits/kaggle/tools/model_instance_files.d.ts +11 -0
- package/dist/toolkits/kaggle/tools/model_instance_files.js +23 -0
- package/dist/toolkits/kaggle/tools/model_instances.d.ts +8 -0
- package/dist/toolkits/kaggle/tools/model_instances.js +20 -0
- package/dist/toolkits/kaggle/tools/models.d.ts +14 -0
- package/dist/toolkits/kaggle/tools/models.js +33 -0
- package/dist/toolkits/nasa/icon.d.ts +5 -0
- package/dist/toolkits/nasa/icon.js +56 -0
- package/dist/toolkits/nasa/manifest.d.ts +3 -0
- package/dist/toolkits/nasa/manifest.js +49 -0
- package/dist/toolkits/nasa/tools/agage.d.ts +60 -0
- package/dist/toolkits/nasa/tools/agage.js +176 -0
- package/dist/toolkits/nasa/tools/client.d.ts +95 -0
- package/dist/toolkits/nasa/tools/client.js +337 -0
- package/dist/toolkits/nasa/tools/cmr.d.ts +268 -0
- package/dist/toolkits/nasa/tools/cmr.js +984 -0
- package/dist/toolkits/nasa/tools/donki.d.ts +63 -0
- package/dist/toolkits/nasa/tools/donki.js +301 -0
- package/dist/toolkits/nasa/tools/eonet.d.ts +74 -0
- package/dist/toolkits/nasa/tools/eonet.js +279 -0
- package/dist/toolkits/nasa/tools/icesat2.d.ts +25 -0
- package/dist/toolkits/nasa/tools/icesat2.js +97 -0
- package/dist/toolkits/nasa/tools/imagery.d.ts +36 -0
- package/dist/toolkits/nasa/tools/imagery.js +138 -0
- package/dist/toolkits/nasa/tools/index.d.ts +1063 -0
- package/dist/toolkits/nasa/tools/index.js +865 -0
- package/dist/toolkits/nasa/tools/neo.d.ts +15 -0
- package/dist/toolkits/nasa/tools/neo.js +75 -0
- package/dist/toolkits/nasa/tools/ntrs.d.ts +152 -0
- package/dist/toolkits/nasa/tools/ntrs.js +292 -0
- package/dist/toolkits/nasa/tools/osdr.d.ts +72 -0
- package/dist/toolkits/nasa/tools/osdr.js +290 -0
- package/dist/toolkits/nasa/tools/planetary.d.ts +58 -0
- package/dist/toolkits/nasa/tools/planetary.js +312 -0
- package/dist/toolkits/nasa/tools/power.d.ts +52 -0
- package/dist/toolkits/nasa/tools/power.js +213 -0
- package/dist/toolkits/nasa/tools/ssc.d.ts +44 -0
- package/dist/toolkits/nasa/tools/ssc.js +92 -0
- package/dist/toolkits/nasa/tools/tolnet.d.ts +84 -0
- package/dist/toolkits/nasa/tools/tolnet.js +254 -0
- package/dist/toolkits/neo4j/tools/analytics.d.ts +1 -1
- package/dist/toolkits/neo4j/tools/index.d.ts +3 -3
- package/dist/toolkits/neo4j/tools/instances.d.ts +2 -2
- package/dist/toolkits/neon/tools/auth.d.ts +4 -4
- package/dist/toolkits/neon/tools/dataapi.d.ts +1 -1
- package/dist/toolkits/neon/tools/index.d.ts +7 -7
- package/dist/toolkits/neon/tools/projects.d.ts +2 -2
- package/dist/toolkits/new-relic/icon.d.ts +5 -0
- package/dist/toolkits/new-relic/icon.js +6 -0
- package/dist/toolkits/new-relic/manifest.d.ts +3 -0
- package/dist/toolkits/new-relic/manifest.js +41 -0
- package/dist/toolkits/new-relic/tools/admin.d.ts +310 -0
- package/dist/toolkits/new-relic/tools/admin.js +282 -0
- package/dist/toolkits/new-relic/tools/alert-policies.d.ts +74 -0
- package/dist/toolkits/new-relic/tools/alert-policies.js +136 -0
- package/dist/toolkits/new-relic/tools/apm.d.ts +129 -0
- package/dist/toolkits/new-relic/tools/apm.js +228 -0
- package/dist/toolkits/new-relic/tools/client.d.ts +62 -0
- package/dist/toolkits/new-relic/tools/client.js +167 -0
- package/dist/toolkits/new-relic/tools/conditions.d.ts +190 -0
- package/dist/toolkits/new-relic/tools/conditions.js +265 -0
- package/dist/toolkits/new-relic/tools/config.d.ts +73 -0
- package/dist/toolkits/new-relic/tools/config.js +131 -0
- package/dist/toolkits/new-relic/tools/dashboards.d.ts +204 -0
- package/dist/toolkits/new-relic/tools/dashboards.js +159 -0
- package/dist/toolkits/new-relic/tools/entities.d.ts +160 -0
- package/dist/toolkits/new-relic/tools/entities.js +218 -0
- package/dist/toolkits/new-relic/tools/index.d.ts +23 -0
- package/dist/toolkits/new-relic/tools/index.js +179 -0
- package/dist/toolkits/new-relic/tools/ingest.d.ts +31 -0
- package/dist/toolkits/new-relic/tools/ingest.js +80 -0
- package/dist/toolkits/new-relic/tools/notifications.d.ts +186 -0
- package/dist/toolkits/new-relic/tools/notifications.js +232 -0
- package/dist/toolkits/new-relic/tools/nrql-conditions.d.ts +105 -0
- package/dist/toolkits/new-relic/tools/nrql-conditions.js +136 -0
- package/dist/toolkits/new-relic/tools/nrql.d.ts +38 -0
- package/dist/toolkits/new-relic/tools/nrql.js +99 -0
- package/dist/toolkits/new-relic/tools/synthetics.d.ts +176 -0
- package/dist/toolkits/new-relic/tools/synthetics.js +246 -0
- package/dist/toolkits/notebook-lm/icon.d.ts +5 -0
- package/dist/toolkits/notebook-lm/icon.js +6 -0
- package/dist/toolkits/notebook-lm/manifest.d.ts +3 -0
- package/dist/toolkits/notebook-lm/manifest.js +44 -0
- package/dist/toolkits/notebook-lm/tools/add-text-sources.d.ts +36 -0
- package/dist/toolkits/notebook-lm/tools/add-text-sources.js +51 -0
- package/dist/toolkits/notebook-lm/tools/create-audio-overview.d.ts +47 -0
- package/dist/toolkits/notebook-lm/tools/create-audio-overview.js +55 -0
- package/dist/toolkits/notebook-lm/tools/create-notebook.d.ts +52 -0
- package/dist/toolkits/notebook-lm/tools/create-notebook.js +49 -0
- package/dist/toolkits/notebook-lm/tools/delete-audio-overview.d.ts +33 -0
- package/dist/toolkits/notebook-lm/tools/delete-audio-overview.js +46 -0
- package/dist/toolkits/notebook-lm/tools/delete-notebooks.d.ts +32 -0
- package/dist/toolkits/notebook-lm/tools/delete-notebooks.js +46 -0
- package/dist/toolkits/notebook-lm/tools/delete-sources.d.ts +33 -0
- package/dist/toolkits/notebook-lm/tools/delete-sources.js +47 -0
- package/dist/toolkits/notebook-lm/tools/get-notebook.d.ts +52 -0
- package/dist/toolkits/notebook-lm/tools/get-notebook.js +45 -0
- package/dist/toolkits/notebook-lm/tools/get-source.d.ts +53 -0
- package/dist/toolkits/notebook-lm/tools/get-source.js +47 -0
- package/dist/toolkits/notebook-lm/tools/index.d.ts +516 -0
- package/dist/toolkits/notebook-lm/tools/index.js +93 -0
- package/dist/toolkits/notebook-lm/tools/list-recent-notebooks.d.ts +32 -0
- package/dist/toolkits/notebook-lm/tools/list-recent-notebooks.js +41 -0
- package/dist/toolkits/notebook-lm/tools/share-notebook.d.ts +48 -0
- package/dist/toolkits/notebook-lm/tools/share-notebook.js +57 -0
- package/dist/toolkits/notebook-lm/tools/upload-source-file.d.ts +40 -0
- package/dist/toolkits/notebook-lm/tools/upload-source-file.js +62 -0
- package/dist/toolkits/notebook-lm/tools/utils.d.ts +15 -0
- package/dist/toolkits/notebook-lm/tools/utils.js +46 -0
- package/dist/toolkits/npm/icon.d.ts +5 -0
- package/dist/toolkits/npm/icon.js +11 -0
- package/dist/toolkits/npm/manifest.d.ts +3 -0
- package/dist/toolkits/npm/manifest.js +35 -0
- package/dist/toolkits/npm/tools/client.d.ts +19 -0
- package/dist/toolkits/npm/tools/client.js +64 -0
- package/dist/toolkits/npm/tools/downloads.d.ts +19 -0
- package/dist/toolkits/npm/tools/downloads.js +39 -0
- package/dist/toolkits/npm/tools/index.d.ts +14 -0
- package/dist/toolkits/npm/tools/index.js +24 -0
- package/dist/toolkits/npm/tools/registry.d.ts +24 -0
- package/dist/toolkits/npm/tools/registry.js +58 -0
- package/dist/toolkits/npm/tools/security.d.ts +9 -0
- package/dist/toolkits/npm/tools/security.js +29 -0
- package/dist/toolkits/slack/tools/admin-users.d.ts +1 -1
- package/dist/toolkits/slack/tools/slack-lists.d.ts +3 -3
- package/dist/toolkits/snowflake/icon.d.ts +5 -0
- package/dist/toolkits/snowflake/icon.js +6 -0
- package/dist/toolkits/snowflake/manifest.d.ts +3 -0
- package/dist/toolkits/snowflake/manifest.js +32 -0
- package/dist/toolkits/snowflake/tools/catalog.d.ts +56 -0
- package/dist/toolkits/snowflake/tools/catalog.js +123 -0
- package/dist/toolkits/snowflake/tools/client.d.ts +53 -0
- package/dist/toolkits/snowflake/tools/client.js +145 -0
- package/dist/toolkits/snowflake/tools/index.d.ts +14 -0
- package/dist/toolkits/snowflake/tools/index.js +28 -0
- package/dist/toolkits/snowflake/tools/statements.d.ts +27 -0
- package/dist/toolkits/snowflake/tools/statements.js +84 -0
- package/dist/toolkits/snowflake/tools/status.d.ts +22 -0
- package/dist/toolkits/snowflake/tools/status.js +54 -0
- package/dist/toolkits/telegram/icon.d.ts +5 -0
- package/dist/toolkits/telegram/icon.js +6 -0
- package/dist/toolkits/telegram/manifest.d.ts +3 -0
- package/dist/toolkits/telegram/manifest.js +34 -0
- package/dist/toolkits/telegram/tools/bot.d.ts +13 -0
- package/dist/toolkits/telegram/tools/bot.js +23 -0
- package/dist/toolkits/telegram/tools/chats.d.ts +22 -0
- package/dist/toolkits/telegram/tools/chats.js +46 -0
- package/dist/toolkits/telegram/tools/client.d.ts +12 -0
- package/dist/toolkits/telegram/tools/client.js +46 -0
- package/dist/toolkits/telegram/tools/index.d.ts +15 -0
- package/dist/toolkits/telegram/tools/index.js +31 -0
- package/dist/toolkits/telegram/tools/messages.d.ts +86 -0
- package/dist/toolkits/telegram/tools/messages.js +134 -0
- package/dist/toolkits/telegram/tools/updates.d.ts +23 -0
- package/dist/toolkits/telegram/tools/updates.js +54 -0
- package/dist/toolkits/youtube/tools/get-channel-activities.d.ts +1 -1
- package/dist/toolkits/youtube/tools/index.d.ts +5 -5
- package/dist/toolkits/youtube/tools/list-channel-sections.d.ts +1 -1
- package/dist/toolkits/youtube/tools/post-comment.d.ts +1 -1
- package/dist/toolkits/youtube/tools/subscribe-channel.d.ts +1 -1
- package/dist/toolkits/youtube/tools/unsubscribe-channel.d.ts +1 -1
- package/package.json +2 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { snowflakeCredentialsField, statusPage } from './client.js';
|
|
5
|
+
/** Statuspage is public; the optional field keeps the schema non-empty and is ignored. */
|
|
6
|
+
const publicInput = {
|
|
7
|
+
snowflakeCredentials: snowflakeCredentialsField.describe('Optional (ignored — the status page is public)'),
|
|
8
|
+
};
|
|
9
|
+
export const getStatusSummary = tool({
|
|
10
|
+
description: 'Reads the public status summary (overall indicator plus regional components, unresolved incidents, upcoming maintenance). Public — no credentials.',
|
|
11
|
+
inputSchema: z.object({ ...publicInput }),
|
|
12
|
+
execute: async () => statusPage('/summary.json', 'get status summary'),
|
|
13
|
+
});
|
|
14
|
+
export const getStatusRollup = tool({
|
|
15
|
+
description: 'Reads the page rollup (blended indicator + human-readable description). Public — no credentials.',
|
|
16
|
+
inputSchema: z.object({ ...publicInput }),
|
|
17
|
+
execute: async () => statusPage('/status.json', 'get status rollup'),
|
|
18
|
+
});
|
|
19
|
+
export const getComponentStatus = tool({
|
|
20
|
+
description: 'Lists per-component status (AWS/Azure/GCP regions). Limit is applied locally. Public — no credentials.',
|
|
21
|
+
inputSchema: z.object({
|
|
22
|
+
limit: z.number().int().min(1).optional().describe('Max components to return'),
|
|
23
|
+
}),
|
|
24
|
+
execute: async ({ limit }) => {
|
|
25
|
+
const data = await statusPage('/components.json', 'get component status');
|
|
26
|
+
if (data?.error)
|
|
27
|
+
return data;
|
|
28
|
+
if (limit !== undefined && Array.isArray(data?.components)) {
|
|
29
|
+
return { ...data, components: data.components.slice(0, limit) };
|
|
30
|
+
}
|
|
31
|
+
return data;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
export const getUnresolvedIncidents = tool({
|
|
35
|
+
description: 'Lists unresolved incidents (Investigating/Identified/Monitoring); empty when all clear. Public — no credentials.',
|
|
36
|
+
inputSchema: z.object({ ...publicInput }),
|
|
37
|
+
execute: async () => statusPage('/incidents/unresolved.json', 'get unresolved incidents'),
|
|
38
|
+
});
|
|
39
|
+
export const getActiveScheduledMaintenances = tool({
|
|
40
|
+
description: "Lists maintenances In Progress or Verifying. Public — no credentials.",
|
|
41
|
+
inputSchema: z.object({ ...publicInput }),
|
|
42
|
+
execute: async () => statusPage('/scheduled-maintenances/active.json', 'get active scheduled maintenances'),
|
|
43
|
+
});
|
|
44
|
+
export const getUpcomingScheduledMaintenances = tool({
|
|
45
|
+
description: "Lists maintenances still Scheduled (not started). Public — no credentials.",
|
|
46
|
+
inputSchema: z.object({ ...publicInput }),
|
|
47
|
+
execute: async () => statusPage('/scheduled-maintenances/upcoming.json', 'get upcoming scheduled maintenances'),
|
|
48
|
+
});
|
|
49
|
+
export const getAllScheduledMaintenances = tool({
|
|
50
|
+
description: 'Lists the 50 most recent maintenances including Completed. Public — no credentials.',
|
|
51
|
+
inputSchema: z.object({ ...publicInput }),
|
|
52
|
+
execute: async () => statusPage('/scheduled-maintenances.json', 'get all scheduled maintenances'),
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const SVG = `<svg id="Livello_1" data-name="Livello 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 240 240"><defs><linearGradient id="linear-gradient" x1="120" y1="240" x2="120" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#1d93d2"/><stop offset="1" stop-color="#38b0e3"/></linearGradient></defs><title>Telegram_logo</title><circle cx="120" cy="120" r="120" fill="url(#linear-gradient)"/><path d="M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z" fill="#c8daea"/><path d="M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763" fill="#a9c6d8"/><path d="M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z" fill="#fff"/></svg>`;
|
|
2
|
+
export const TELEGRAM_ICON = {
|
|
3
|
+
kind: 'svg',
|
|
4
|
+
dataUri: `data:image/svg+xml;base64,${Buffer.from(SVG).toString('base64')}`,
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=icon.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineToolkit, defineTool } from '../../core/define.js';
|
|
2
|
+
import { inferToolScope } from '../../core/scope.js';
|
|
3
|
+
import { TELEGRAM_ICON } from './icon.js';
|
|
4
|
+
import { telegramTools } from './tools/index.js';
|
|
5
|
+
export default defineToolkit({
|
|
6
|
+
id: 'telegram',
|
|
7
|
+
displayName: 'Telegram',
|
|
8
|
+
shortDescription: 'Send messages and media, manage chats, and read updates via the Bot API.',
|
|
9
|
+
category: 'Collaboration & Communication',
|
|
10
|
+
icon: TELEGRAM_ICON,
|
|
11
|
+
auth: {
|
|
12
|
+
type: 'api_key',
|
|
13
|
+
tokenField: 'telegramBotToken',
|
|
14
|
+
provider: {
|
|
15
|
+
in: 'header',
|
|
16
|
+
name: 'Authorization',
|
|
17
|
+
connectDescription: 'Connect Telegram with a bot token from @BotFather (format 123456:ABC-DEF...). The token is embedded in the Bot API request URL path (https://api.telegram.org/bot<token>/<method>), not sent as a header.',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
allowedHosts: ['api.telegram.org'],
|
|
21
|
+
tools: telegramTools.map((entry) => defineTool({
|
|
22
|
+
name: entry.name,
|
|
23
|
+
description: entry.description,
|
|
24
|
+
tool: entry.tool,
|
|
25
|
+
requiredAuth: entry.requiredAuth,
|
|
26
|
+
scope: entry.scope ?? inferToolScope(entry.name),
|
|
27
|
+
})),
|
|
28
|
+
meta: {
|
|
29
|
+
since: '0.0.10',
|
|
30
|
+
homepage: 'https://telegram.org',
|
|
31
|
+
docsUrl: 'https://core.telegram.org/bots/api',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const getMe: import("ai").Tool<{
|
|
2
|
+
telegramBotToken?: string | undefined;
|
|
3
|
+
}, any>;
|
|
4
|
+
export declare const setMyCommands: import("ai").Tool<{
|
|
5
|
+
commands: {
|
|
6
|
+
description: string;
|
|
7
|
+
command: string;
|
|
8
|
+
}[];
|
|
9
|
+
scope?: string | Record<string, any> | undefined;
|
|
10
|
+
languageCode?: string | undefined;
|
|
11
|
+
telegramBotToken?: string | undefined;
|
|
12
|
+
}, any>;
|
|
13
|
+
//# sourceMappingURL=bot.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { telegramBotTokenField, telegramCall } from './client.js';
|
|
5
|
+
export const getMe = tool({
|
|
6
|
+
description: 'Returns bot identity (id, username, capabilities) and validates the token — ok=false means invalid/revoked token, fix before other calls. Name/bio are BotFather-only.',
|
|
7
|
+
inputSchema: z.object({ telegramBotToken: telegramBotTokenField }),
|
|
8
|
+
execute: async ({ telegramBotToken }) => telegramCall(telegramBotToken, 'getMe', undefined, 'get bot info'),
|
|
9
|
+
});
|
|
10
|
+
export const setMyCommands = tool({
|
|
11
|
+
description: "Replaces the bot command menu (max 100; names 1-32 lowercase/digits/underscores, descriptions 1-256 chars). Scoped commands override globals for matching users; omit scope for the global list.",
|
|
12
|
+
inputSchema: z.object({
|
|
13
|
+
telegramBotToken: telegramBotTokenField,
|
|
14
|
+
commands: z.array(z.object({
|
|
15
|
+
command: z.string().min(1).max(32).describe("Name, e.g. 'start' (lowercase, digits, underscores)"),
|
|
16
|
+
description: z.string().min(1).max(256).describe("Description, e.g. 'Start the bot'"),
|
|
17
|
+
})).max(100).describe('Command list (max 100)'),
|
|
18
|
+
scope: z.union([z.string(), z.record(z.any())]).optional().describe('JSON scope object (default: all users); serialized automatically'),
|
|
19
|
+
languageCode: z.string().optional().describe("ISO 639-1 code, e.g. 'en' (omit for all languages)"),
|
|
20
|
+
}),
|
|
21
|
+
execute: async ({ telegramBotToken, languageCode, ...rest }) => telegramCall(telegramBotToken, 'setMyCommands', { language_code: languageCode, ...rest }, 'set bot commands'),
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=bot.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const getChat: import("ai").Tool<{
|
|
2
|
+
chatId: string | number;
|
|
3
|
+
telegramBotToken?: string | undefined;
|
|
4
|
+
}, any>;
|
|
5
|
+
export declare const getChatAdministrators: import("ai").Tool<{
|
|
6
|
+
chatId: string | number;
|
|
7
|
+
telegramBotToken?: string | undefined;
|
|
8
|
+
}, any>;
|
|
9
|
+
export declare const getChatMember: import("ai").Tool<{
|
|
10
|
+
userId: number;
|
|
11
|
+
chatId: string | number;
|
|
12
|
+
telegramBotToken?: string | undefined;
|
|
13
|
+
}, any>;
|
|
14
|
+
export declare const getChatMembersCount: import("ai").Tool<{
|
|
15
|
+
chatId: string | number;
|
|
16
|
+
telegramBotToken?: string | undefined;
|
|
17
|
+
}, any>;
|
|
18
|
+
export declare const createChatInviteLink: import("ai").Tool<{
|
|
19
|
+
chatId: string | number;
|
|
20
|
+
telegramBotToken?: string | undefined;
|
|
21
|
+
}, any>;
|
|
22
|
+
//# sourceMappingURL=chats.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { chatIdField, telegramBotTokenField, telegramCall } from './client.js';
|
|
5
|
+
export const getChat = tool({
|
|
6
|
+
description: "Reads current chat info (name, username, type, permissions). Bot must be a member; fails if never added/removed/blocked. Use getUpdates to discover reliable chat IDs.",
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
telegramBotToken: telegramBotTokenField,
|
|
9
|
+
chatId: chatIdField.describe("Chat ID (groups/channels are negative) or '@username' (plain names/URLs won't resolve)"),
|
|
10
|
+
}),
|
|
11
|
+
execute: async ({ telegramBotToken, chatId }) => telegramCall(telegramBotToken, 'getChat', { chat_id: chatId }, 'get chat'),
|
|
12
|
+
});
|
|
13
|
+
export const getChatAdministrators = tool({
|
|
14
|
+
description: 'Lists chat admins (except other bots) with privilege flags. Meaningful for supergroups/channels. Includes the bot itself when admin — use to verify rights before moderation.',
|
|
15
|
+
inputSchema: z.object({
|
|
16
|
+
telegramBotToken: telegramBotTokenField,
|
|
17
|
+
chatId: chatIdField,
|
|
18
|
+
}),
|
|
19
|
+
execute: async ({ telegramBotToken, chatId }) => telegramCall(telegramBotToken, 'getChatAdministrators', { chat_id: chatId }, 'get chat administrators'),
|
|
20
|
+
});
|
|
21
|
+
export const getChatMember = tool({
|
|
22
|
+
description: 'Reads one member status/role (creator/administrator/member/restricted/left/kicked). Query the bot itself to preflight membership and troubleshoot 403s.',
|
|
23
|
+
inputSchema: z.object({
|
|
24
|
+
telegramBotToken: telegramBotTokenField,
|
|
25
|
+
chatId: chatIdField,
|
|
26
|
+
userId: z.number().int().describe('Target user ID'),
|
|
27
|
+
}),
|
|
28
|
+
execute: async ({ telegramBotToken, chatId, userId }) => telegramCall(telegramBotToken, 'getChatMember', { chat_id: chatId, user_id: userId }, 'get chat member'),
|
|
29
|
+
});
|
|
30
|
+
export const getChatMembersCount = tool({
|
|
31
|
+
description: 'Returns the member count. Bot must be an admin — permission failures surface as auth errors, not zero.',
|
|
32
|
+
inputSchema: z.object({
|
|
33
|
+
telegramBotToken: telegramBotTokenField,
|
|
34
|
+
chatId: chatIdField.describe("Chat ID or '@username' (must start with '@')"),
|
|
35
|
+
}),
|
|
36
|
+
execute: async ({ telegramBotToken, chatId }) => telegramCall(telegramBotToken, 'getChatMemberCount', { chat_id: chatId }, 'get chat members count'),
|
|
37
|
+
});
|
|
38
|
+
export const createChatInviteLink = tool({
|
|
39
|
+
description: 'Generates a new primary invite link (revokes the previous primary link). Bot must be admin with invite rights.',
|
|
40
|
+
inputSchema: z.object({
|
|
41
|
+
telegramBotToken: telegramBotTokenField,
|
|
42
|
+
chatId: chatIdField.describe('Target chat or @supergroup/@channel username'),
|
|
43
|
+
}),
|
|
44
|
+
execute: async ({ telegramBotToken, chatId }) => telegramCall(telegramBotToken, 'exportChatInviteLink', { chat_id: chatId }, 'export chat invite link'),
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=chats.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const TELEGRAM_API_BASE = "https://api.telegram.org";
|
|
3
|
+
export declare const telegramBotTokenField: z.ZodOptional<z.ZodString>;
|
|
4
|
+
export declare function missingToken(): {
|
|
5
|
+
error: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const chatIdField: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
8
|
+
export declare const parseModeField: z.ZodOptional<z.ZodEnum<["Markdown", "MarkdownV2", "HTML"]>>;
|
|
9
|
+
export declare const replyMarkupField: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
|
|
10
|
+
/** Call a Bot API method. Token goes in the URL path: POST /bot<token>/<method>. */
|
|
11
|
+
export declare function telegramCall(botToken: string | undefined, method: string, params?: Record<string, unknown>, action?: string): Promise<any>;
|
|
12
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const TELEGRAM_API_BASE = 'https://api.telegram.org';
|
|
4
|
+
export const telegramBotTokenField = z
|
|
5
|
+
.string()
|
|
6
|
+
.optional()
|
|
7
|
+
.describe('Telegram bot token from @BotFather (format 123456:ABC-DEF...). Injected at runtime.');
|
|
8
|
+
export function missingToken() {
|
|
9
|
+
return { error: 'Telegram bot token is required. Connect Telegram first.' };
|
|
10
|
+
}
|
|
11
|
+
export const chatIdField = z.union([z.number(), z.string()]).describe("Chat ID (numeric, negative for groups/channels) or @username, e.g. 123456789 or '@mychannel'");
|
|
12
|
+
export const parseModeField = z.enum(['Markdown', 'MarkdownV2', 'HTML']).optional().describe("Entity parse mode ('MarkdownV2'/'HTML' preferred; omit for plain text)");
|
|
13
|
+
export const replyMarkupField = z.union([z.string(), z.record(z.any())]).optional().describe('Inline keyboard as JSON string or object (will be serialized)');
|
|
14
|
+
function normalizeParams(params) {
|
|
15
|
+
const out = {};
|
|
16
|
+
for (const [k, v] of Object.entries(params)) {
|
|
17
|
+
if (v === undefined)
|
|
18
|
+
continue;
|
|
19
|
+
if ((k === 'reply_markup' || k === 'scope') && typeof v === 'object')
|
|
20
|
+
out[k] = JSON.stringify(v);
|
|
21
|
+
else
|
|
22
|
+
out[k] = v;
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
/** Call a Bot API method. Token goes in the URL path: POST /bot<token>/<method>. */
|
|
27
|
+
export async function telegramCall(botToken, method, params, action = 'call Telegram Bot API') {
|
|
28
|
+
if (!botToken)
|
|
29
|
+
return missingToken();
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(`${TELEGRAM_API_BASE}/bot${botToken}/${method}`, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'Content-Type': 'application/json' },
|
|
34
|
+
body: JSON.stringify(normalizeParams(params ?? {})),
|
|
35
|
+
});
|
|
36
|
+
const data = await response.json().catch(() => ({}));
|
|
37
|
+
if (!response.ok || data?.ok === false) {
|
|
38
|
+
return { error: `Failed to ${action}`, details: data };
|
|
39
|
+
}
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return { error: `Error while trying to ${action}`, message: error instanceof Error ? error.message : 'Unknown error' };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createChatInviteLink, getChat, getChatAdministrators, getChatMember, getChatMembersCount } from './chats.js';
|
|
2
|
+
import { getMe, setMyCommands } from './bot.js';
|
|
3
|
+
import { deleteMessage, editMessage, forwardMessage, sendDocument, sendLocation, sendMessage, sendPhoto, sendPoll } from './messages.js';
|
|
4
|
+
import { answerCallbackQuery, getChatHistory, getUpdates } from './updates.js';
|
|
5
|
+
export { sendMessage, forwardMessage, editMessage, deleteMessage, sendPhoto, sendDocument, sendLocation, sendPoll, getChat, getChatAdministrators, getChatMember, getChatMembersCount, createChatInviteLink, getUpdates, getChatHistory, answerCallbackQuery, getMe, setMyCommands, };
|
|
6
|
+
declare const auth: "telegramBotToken";
|
|
7
|
+
type Scope = 'read' | 'write' | 'delete';
|
|
8
|
+
export declare const telegramTools: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
tool: any;
|
|
12
|
+
requiredAuth: typeof auth;
|
|
13
|
+
scope: Scope;
|
|
14
|
+
}[];
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { createChatInviteLink, getChat, getChatAdministrators, getChatMember, getChatMembersCount, } from './chats.js';
|
|
3
|
+
import { getMe, setMyCommands } from './bot.js';
|
|
4
|
+
import { deleteMessage, editMessage, forwardMessage, sendDocument, sendLocation, sendMessage, sendPhoto, sendPoll, } from './messages.js';
|
|
5
|
+
import { answerCallbackQuery, getChatHistory, getUpdates } from './updates.js';
|
|
6
|
+
export { sendMessage, forwardMessage, editMessage, deleteMessage, sendPhoto, sendDocument, sendLocation, sendPoll, getChat, getChatAdministrators, getChatMember, getChatMembersCount, createChatInviteLink, getUpdates, getChatHistory, answerCallbackQuery, getMe, setMyCommands, };
|
|
7
|
+
const auth = 'telegramBotToken';
|
|
8
|
+
function entry(name, description, toolRef, scope) {
|
|
9
|
+
return { name, description, tool: toolRef, requiredAuth: auth, scope };
|
|
10
|
+
}
|
|
11
|
+
export const telegramTools = [
|
|
12
|
+
entry('telegramSendMessage', 'Sends a text message to a chat.', sendMessage, 'write'),
|
|
13
|
+
entry('telegramForwardMessage', 'Forwards a message to another chat.', forwardMessage, 'write'),
|
|
14
|
+
entry('telegramEditMessage', 'Edits a bot-authored text message.', editMessage, 'write'),
|
|
15
|
+
entry('telegramDeleteMessage', 'Deletes a message.', deleteMessage, 'delete'),
|
|
16
|
+
entry('telegramSendPhoto', 'Sends a photo by file_id or public URL.', sendPhoto, 'write'),
|
|
17
|
+
entry('telegramSendDocument', 'Sends a file preserving original format.', sendDocument, 'write'),
|
|
18
|
+
entry('telegramSendLocation', 'Sends a map point (static or live).', sendLocation, 'write'),
|
|
19
|
+
entry('telegramSendPoll', 'Sends a native poll (regular or quiz).', sendPoll, 'write'),
|
|
20
|
+
entry('telegramGetChat', 'Reads current chat info.', getChat, 'read'),
|
|
21
|
+
entry('telegramGetChatAdministrators', 'Lists chat admins with privilege flags.', getChatAdministrators, 'read'),
|
|
22
|
+
entry('telegramGetChatMember', 'Reads one member status/role.', getChatMember, 'read'),
|
|
23
|
+
entry('telegramGetChatMembersCount', 'Returns the member count (admin required).', getChatMembersCount, 'read'),
|
|
24
|
+
entry('telegramCreateChatInviteLink', 'Generates a new primary invite link.', createChatInviteLink, 'write'),
|
|
25
|
+
entry('telegramGetUpdates', 'Long-polls incoming updates.', getUpdates, 'read'),
|
|
26
|
+
entry('telegramGetChatHistory', 'Reads recent chat messages via the updates queue (composite).', getChatHistory, 'read'),
|
|
27
|
+
entry('telegramAnswerCallbackQuery', 'Answers an inline-keyboard callback query.', answerCallbackQuery, 'write'),
|
|
28
|
+
entry('telegramGetMe', 'Returns bot identity and validates the token.', getMe, 'read'),
|
|
29
|
+
entry('telegramSetMyCommands', 'Replaces the bot command menu.', setMyCommands, 'write'),
|
|
30
|
+
];
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export declare const sendMessage: import("ai").Tool<{
|
|
2
|
+
text: string;
|
|
3
|
+
chatId: string | number;
|
|
4
|
+
telegramBotToken?: string | undefined;
|
|
5
|
+
parseMode?: "Markdown" | "MarkdownV2" | "HTML" | undefined;
|
|
6
|
+
replyMarkup?: string | Record<string, any> | undefined;
|
|
7
|
+
replyToMessageId?: number | undefined;
|
|
8
|
+
disableNotification?: boolean | undefined;
|
|
9
|
+
disableWebPagePreview?: boolean | undefined;
|
|
10
|
+
}, any>;
|
|
11
|
+
export declare const forwardMessage: import("ai").Tool<{
|
|
12
|
+
messageId: number;
|
|
13
|
+
chatId: string | number;
|
|
14
|
+
fromChatId: string | number;
|
|
15
|
+
telegramBotToken?: string | undefined;
|
|
16
|
+
disableNotification?: boolean | undefined;
|
|
17
|
+
}, any>;
|
|
18
|
+
export declare const editMessage: import("ai").Tool<{
|
|
19
|
+
text: string;
|
|
20
|
+
messageId?: number | undefined;
|
|
21
|
+
telegramBotToken?: string | undefined;
|
|
22
|
+
chatId?: string | number | undefined;
|
|
23
|
+
parseMode?: "Markdown" | "MarkdownV2" | "HTML" | undefined;
|
|
24
|
+
replyMarkup?: string | Record<string, any> | undefined;
|
|
25
|
+
disableWebPagePreview?: boolean | undefined;
|
|
26
|
+
inlineMessageId?: string | undefined;
|
|
27
|
+
}, any>;
|
|
28
|
+
export declare const deleteMessage: import("ai").Tool<{
|
|
29
|
+
messageId: number;
|
|
30
|
+
chatId: string | number;
|
|
31
|
+
telegramBotToken?: string | undefined;
|
|
32
|
+
}, any>;
|
|
33
|
+
export declare const sendPhoto: import("ai").Tool<{
|
|
34
|
+
photo: string;
|
|
35
|
+
chatId: string | number;
|
|
36
|
+
telegramBotToken?: string | undefined;
|
|
37
|
+
parseMode?: "Markdown" | "MarkdownV2" | "HTML" | undefined;
|
|
38
|
+
replyMarkup?: string | Record<string, any> | undefined;
|
|
39
|
+
replyToMessageId?: number | undefined;
|
|
40
|
+
disableNotification?: boolean | undefined;
|
|
41
|
+
caption?: string | undefined;
|
|
42
|
+
}, any>;
|
|
43
|
+
export declare const sendDocument: import("ai").Tool<{
|
|
44
|
+
chatId: string | number;
|
|
45
|
+
document: string;
|
|
46
|
+
telegramBotToken?: string | undefined;
|
|
47
|
+
parseMode?: "Markdown" | "MarkdownV2" | "HTML" | undefined;
|
|
48
|
+
replyMarkup?: string | Record<string, any> | undefined;
|
|
49
|
+
replyToMessageId?: number | undefined;
|
|
50
|
+
disableNotification?: boolean | undefined;
|
|
51
|
+
caption?: string | undefined;
|
|
52
|
+
thumbnail?: string | undefined;
|
|
53
|
+
disableContentTypeDetection?: boolean | undefined;
|
|
54
|
+
}, any>;
|
|
55
|
+
export declare const sendLocation: import("ai").Tool<{
|
|
56
|
+
latitude: number;
|
|
57
|
+
longitude: number;
|
|
58
|
+
chatId: string | number;
|
|
59
|
+
telegramBotToken?: string | undefined;
|
|
60
|
+
replyMarkup?: string | Record<string, any> | undefined;
|
|
61
|
+
replyToMessageId?: number | undefined;
|
|
62
|
+
disableNotification?: boolean | undefined;
|
|
63
|
+
livePeriod?: number | undefined;
|
|
64
|
+
heading?: number | undefined;
|
|
65
|
+
horizontalAccuracy?: number | undefined;
|
|
66
|
+
proximityAlertRadius?: number | undefined;
|
|
67
|
+
}, any>;
|
|
68
|
+
export declare const sendPoll: import("ai").Tool<{
|
|
69
|
+
options: string[];
|
|
70
|
+
chatId: string | number;
|
|
71
|
+
question: string;
|
|
72
|
+
type?: "regular" | "quiz" | undefined;
|
|
73
|
+
telegramBotToken?: string | undefined;
|
|
74
|
+
replyMarkup?: string | Record<string, any> | undefined;
|
|
75
|
+
replyToMessageId?: number | undefined;
|
|
76
|
+
disableNotification?: boolean | undefined;
|
|
77
|
+
isAnonymous?: boolean | undefined;
|
|
78
|
+
allowsMultipleAnswers?: boolean | undefined;
|
|
79
|
+
correctOptionId?: number | undefined;
|
|
80
|
+
explanation?: string | undefined;
|
|
81
|
+
explanationParseMode?: "Markdown" | "MarkdownV2" | "HTML" | undefined;
|
|
82
|
+
openPeriod?: number | undefined;
|
|
83
|
+
closeDate?: number | undefined;
|
|
84
|
+
isClosed?: boolean | undefined;
|
|
85
|
+
}, any>;
|
|
86
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { chatIdField, parseModeField, replyMarkupField, telegramBotTokenField, telegramCall } from './client.js';
|
|
5
|
+
const silentField = z.boolean().optional().describe('Silent send (no sound)');
|
|
6
|
+
const replyToField = z.number().int().optional().describe('Reply to this message ID');
|
|
7
|
+
export const sendMessage = tool({
|
|
8
|
+
description: 'Sends a text message (1-4096 chars; split longer text). Bot must be a member with post rights; cannot DM users who never messaged first. ~1 msg/sec per chat, ~30/sec globally — honor 429 retry_after.',
|
|
9
|
+
inputSchema: z.object({
|
|
10
|
+
telegramBotToken: telegramBotTokenField,
|
|
11
|
+
chatId: chatIdField,
|
|
12
|
+
text: z.string().min(1).max(4096).describe('Message text, 1-4096 chars after parsing'),
|
|
13
|
+
parseMode: parseModeField,
|
|
14
|
+
replyMarkup: replyMarkupField,
|
|
15
|
+
replyToMessageId: replyToField,
|
|
16
|
+
disableNotification: silentField,
|
|
17
|
+
disableWebPagePreview: z.boolean().optional().describe('Disable link previews'),
|
|
18
|
+
}),
|
|
19
|
+
execute: async ({ telegramBotToken, chatId, ...rest }) => telegramCall(telegramBotToken, 'sendMessage', { chat_id: chatId, ...rest }, 'send message'),
|
|
20
|
+
});
|
|
21
|
+
export const forwardMessage = tool({
|
|
22
|
+
description: "Forwards any message kind to another chat. Service messages can't be forwarded.",
|
|
23
|
+
inputSchema: z.object({
|
|
24
|
+
telegramBotToken: telegramBotTokenField,
|
|
25
|
+
chatId: chatIdField.describe('Target chat'),
|
|
26
|
+
fromChatId: z.union([z.number(), z.string()]).describe('Source chat (ID or @channelusername)'),
|
|
27
|
+
messageId: z.number().int().describe('Message ID in the source chat'),
|
|
28
|
+
disableNotification: silentField,
|
|
29
|
+
}),
|
|
30
|
+
execute: async ({ telegramBotToken, chatId, fromChatId, messageId, disableNotification }) => telegramCall(telegramBotToken, 'forwardMessage', { chat_id: chatId, from_chat_id: fromChatId, message_id: messageId, disable_notification: disableNotification }, 'forward message'),
|
|
31
|
+
});
|
|
32
|
+
export const editMessage = tool({
|
|
33
|
+
description: 'Edits a bot-authored text message (1-4096 chars). Provide chat_id + message_id, or inline_message_id for inline messages.',
|
|
34
|
+
inputSchema: z.object({
|
|
35
|
+
telegramBotToken: telegramBotTokenField,
|
|
36
|
+
text: z.string().min(1).max(4096).describe('New message text'),
|
|
37
|
+
chatId: chatIdField.optional().describe('Required unless inline_message_id is given'),
|
|
38
|
+
messageId: z.number().int().optional().describe('Required unless inline_message_id is given'),
|
|
39
|
+
inlineMessageId: z.string().optional().describe('Inline message ID (alternative to chat+message IDs)'),
|
|
40
|
+
parseMode: parseModeField,
|
|
41
|
+
replyMarkup: replyMarkupField,
|
|
42
|
+
disableWebPagePreview: z.boolean().optional(),
|
|
43
|
+
}),
|
|
44
|
+
execute: async ({ telegramBotToken, chatId, messageId, inlineMessageId, ...rest }) => {
|
|
45
|
+
if (!inlineMessageId && (chatId === undefined || messageId === undefined)) {
|
|
46
|
+
return { error: 'Provide chatId + messageId, or inlineMessageId' };
|
|
47
|
+
}
|
|
48
|
+
return telegramCall(telegramBotToken, 'editMessageText', { chat_id: chatId, message_id: messageId, inline_message_id: inlineMessageId, ...rest }, 'edit message');
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
export const deleteMessage = tool({
|
|
52
|
+
description: "Deletes a message (bot must have delete rights; groups: only bot-authored, <48h). Linked channel/discussion pairs need separate calls per chat. Honor 429 retry_after.",
|
|
53
|
+
inputSchema: z.object({
|
|
54
|
+
telegramBotToken: telegramBotTokenField,
|
|
55
|
+
chatId: chatIdField,
|
|
56
|
+
messageId: z.number().int().describe('Message ID to delete'),
|
|
57
|
+
}),
|
|
58
|
+
execute: async ({ telegramBotToken, chatId, messageId }) => telegramCall(telegramBotToken, 'deleteMessage', { chat_id: chatId, message_id: messageId }, 'delete message'),
|
|
59
|
+
});
|
|
60
|
+
export const sendPhoto = tool({
|
|
61
|
+
description: 'Sends a photo by file_id (preferred) or public HTTPS URL (Telegram-compressed; use sendDocument to preserve quality). No album support — one post per call.',
|
|
62
|
+
inputSchema: z.object({
|
|
63
|
+
telegramBotToken: telegramBotTokenField,
|
|
64
|
+
chatId: chatIdField,
|
|
65
|
+
photo: z.string().describe('file_id or public HTTPS URL (no auth/signed links, no base64)'),
|
|
66
|
+
caption: z.string().max(1024).optional().describe('Caption, 0-1024 chars'),
|
|
67
|
+
parseMode: parseModeField.describe('Caption parse mode'),
|
|
68
|
+
replyMarkup: replyMarkupField,
|
|
69
|
+
replyToMessageId: replyToField,
|
|
70
|
+
disableNotification: silentField,
|
|
71
|
+
}),
|
|
72
|
+
execute: async ({ telegramBotToken, chatId, ...rest }) => telegramCall(telegramBotToken, 'sendPhoto', { chat_id: chatId, ...rest }, 'send photo'),
|
|
73
|
+
});
|
|
74
|
+
export const sendDocument = tool({
|
|
75
|
+
description: 'Sends a file by file_id (preferred) or public URL. Preserves original format/resolution unlike sendPhoto. ~1 msg/sec per chat; honor 429 retry_after.',
|
|
76
|
+
inputSchema: z.object({
|
|
77
|
+
telegramBotToken: telegramBotTokenField,
|
|
78
|
+
chatId: chatIdField,
|
|
79
|
+
document: z.string().describe('file_id or HTTP URL for Telegram to fetch'),
|
|
80
|
+
caption: z.string().max(1024).optional().describe('Caption, 0-1024 chars'),
|
|
81
|
+
parseMode: parseModeField.describe('Caption parse mode'),
|
|
82
|
+
thumbnail: z.string().optional().describe('Thumbnail file_id/URL (skipped if server-side generation works)'),
|
|
83
|
+
replyMarkup: replyMarkupField,
|
|
84
|
+
replyToMessageId: replyToField,
|
|
85
|
+
disableNotification: silentField,
|
|
86
|
+
disableContentTypeDetection: z.boolean().optional().describe('Disable server-side content-type detection'),
|
|
87
|
+
}),
|
|
88
|
+
execute: async ({ telegramBotToken, chatId, ...rest }) => telegramCall(telegramBotToken, 'sendDocument', { chat_id: chatId, ...rest }, 'send document'),
|
|
89
|
+
});
|
|
90
|
+
export const sendLocation = tool({
|
|
91
|
+
description: 'Sends a map point (static or live location with update period and proximity alerts).',
|
|
92
|
+
inputSchema: z.object({
|
|
93
|
+
telegramBotToken: telegramBotTokenField,
|
|
94
|
+
chatId: chatIdField,
|
|
95
|
+
latitude: z.number().min(-90).max(90),
|
|
96
|
+
longitude: z.number().min(-180).max(180),
|
|
97
|
+
livePeriod: z.number().int().min(60).max(86400).optional().describe('Live-update seconds (60-86400)'),
|
|
98
|
+
heading: z.number().int().min(1).max(360).optional().describe('Live-location movement direction degrees'),
|
|
99
|
+
horizontalAccuracy: z.number().min(0).max(1500).optional().describe('Uncertainty radius meters (0-1500)'),
|
|
100
|
+
proximityAlertRadius: z.number().int().min(1).max(100000).optional().describe('Live-location proximity alert meters'),
|
|
101
|
+
replyMarkup: replyMarkupField,
|
|
102
|
+
replyToMessageId: replyToField,
|
|
103
|
+
disableNotification: silentField,
|
|
104
|
+
}),
|
|
105
|
+
execute: async ({ telegramBotToken, chatId, livePeriod, proximityAlertRadius, horizontalAccuracy, ...rest }) => telegramCall(telegramBotToken, 'sendLocation', { chat_id: chatId, live_period: livePeriod, proximity_alert_radius: proximityAlertRadius, horizontal_accuracy: horizontalAccuracy, ...rest }, 'send location'),
|
|
106
|
+
});
|
|
107
|
+
export const sendPoll = tool({
|
|
108
|
+
description: "Sends a native poll (regular or quiz). 2-10 options of 1-100 chars; question 1-300 chars. Quiz mode needs correct_option_id. open_period and close_date are mutually exclusive.",
|
|
109
|
+
inputSchema: z.object({
|
|
110
|
+
telegramBotToken: telegramBotTokenField,
|
|
111
|
+
chatId: chatIdField,
|
|
112
|
+
question: z.string().min(1).max(300).describe('Poll question'),
|
|
113
|
+
options: z.array(z.string().min(1).max(100)).min(2).max(10).describe('2-10 answer options'),
|
|
114
|
+
type: z.enum(['regular', 'quiz']).optional().describe("Poll type (default 'regular')"),
|
|
115
|
+
isAnonymous: z.boolean().optional().describe('Anonymous voting (default true)'),
|
|
116
|
+
allowsMultipleAnswers: z.boolean().optional().describe('Multi-select (regular polls only)'),
|
|
117
|
+
correctOptionId: z.number().int().min(0).optional().describe('0-based correct option (quiz mode required)'),
|
|
118
|
+
explanation: z.string().max(200).optional().describe('Quiz explanation shown on wrong answers (max 2 line feeds)'),
|
|
119
|
+
explanationParseMode: z.enum(['Markdown', 'MarkdownV2', 'HTML']).optional(),
|
|
120
|
+
openPeriod: z.number().int().min(5).max(600).optional().describe('Auto-close seconds after creation (5-600)'),
|
|
121
|
+
closeDate: z.number().int().optional().describe('Auto-close Unix timestamp (5-600s in future)'),
|
|
122
|
+
isClosed: z.boolean().optional().describe('Close immediately (preview)'),
|
|
123
|
+
replyMarkup: replyMarkupField,
|
|
124
|
+
replyToMessageId: replyToField,
|
|
125
|
+
disableNotification: silentField,
|
|
126
|
+
}),
|
|
127
|
+
execute: async ({ telegramBotToken, chatId, isAnonymous, allowsMultipleAnswers, correctOptionId, explanationParseMode, openPeriod, closeDate, isClosed, ...rest }) => {
|
|
128
|
+
if (openPeriod !== undefined && closeDate !== undefined) {
|
|
129
|
+
return { error: 'openPeriod and closeDate are mutually exclusive' };
|
|
130
|
+
}
|
|
131
|
+
return telegramCall(telegramBotToken, 'sendPoll', { chat_id: chatId, is_anonymous: isAnonymous, allows_multiple_answers: allowsMultipleAnswers, correct_option_id: correctOptionId, explanation_parse_mode: explanationParseMode, open_period: openPeriod, close_date: closeDate, is_closed: isClosed, ...rest }, 'send poll');
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const getUpdates: import("ai").Tool<{
|
|
2
|
+
limit?: number | undefined;
|
|
3
|
+
timeout?: number | undefined;
|
|
4
|
+
offset?: number | undefined;
|
|
5
|
+
telegramBotToken?: string | undefined;
|
|
6
|
+
allowedUpdates?: string[] | undefined;
|
|
7
|
+
}, any>;
|
|
8
|
+
export declare const getChatHistory: import("ai").Tool<{
|
|
9
|
+
chatId: string | number;
|
|
10
|
+
messageId?: number | undefined;
|
|
11
|
+
limit?: number | undefined;
|
|
12
|
+
offset?: number | undefined;
|
|
13
|
+
telegramBotToken?: string | undefined;
|
|
14
|
+
}, any>;
|
|
15
|
+
export declare const answerCallbackQuery: import("ai").Tool<{
|
|
16
|
+
callbackQueryId: string;
|
|
17
|
+
url?: string | undefined;
|
|
18
|
+
text?: string | undefined;
|
|
19
|
+
telegramBotToken?: string | undefined;
|
|
20
|
+
showAlert?: boolean | undefined;
|
|
21
|
+
cacheTime?: number | undefined;
|
|
22
|
+
}, any>;
|
|
23
|
+
//# sourceMappingURL=updates.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { chatIdField, telegramBotTokenField, telegramCall } from './client.js';
|
|
5
|
+
export const getUpdates = tool({
|
|
6
|
+
description: 'Long-polls incoming updates (messages, edits, callbacks). Mutually exclusive with webhooks — 409 means delete the webhook first. Empty result is valid (no new updates). Poll ~1/sec; honor 429 retry_after.',
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
telegramBotToken: telegramBotTokenField,
|
|
9
|
+
offset: z.number().int().optional().describe('First update ID (last seen + 1) to avoid duplicates'),
|
|
10
|
+
limit: z.number().int().min(1).max(100).optional().describe('Max updates (1-100, default 100)'),
|
|
11
|
+
timeout: z.number().int().min(0).optional().describe('Long-poll seconds (0 = short poll)'),
|
|
12
|
+
allowedUpdates: z.array(z.string()).optional().describe("Types to receive, e.g. ['message','callback_query'] (empty = all except chat_member)"),
|
|
13
|
+
}),
|
|
14
|
+
execute: async ({ telegramBotToken, ...rest }) => telegramCall(telegramBotToken, 'getUpdates', rest, 'get updates'),
|
|
15
|
+
});
|
|
16
|
+
function updateChatId(update) {
|
|
17
|
+
const msg = update?.message ?? update?.edited_message ?? update?.channel_post ?? update?.edited_channel_post ?? update?.callback_query?.message;
|
|
18
|
+
return msg?.chat?.id;
|
|
19
|
+
}
|
|
20
|
+
export const getChatHistory = tool({
|
|
21
|
+
description: 'Reads recent chat messages via the getUpdates queue filtered to one chat. Only unacknowledged updates from the last ~24h are visible (nothing before the bot joined); empty result means no accessible messages, not failure. No webhook may be active (409 otherwise).',
|
|
22
|
+
inputSchema: z.object({
|
|
23
|
+
telegramBotToken: telegramBotTokenField,
|
|
24
|
+
chatId: chatIdField,
|
|
25
|
+
limit: z.number().int().min(1).max(100).optional().describe('Max messages (1-100, default 100)'),
|
|
26
|
+
offset: z.number().int().optional().describe('Skip this many filtered messages (pagination)'),
|
|
27
|
+
messageId: z.number().int().optional().describe('Start from this message ID in the chat'),
|
|
28
|
+
}),
|
|
29
|
+
execute: async ({ telegramBotToken, chatId, limit, offset, messageId }) => {
|
|
30
|
+
const fetched = await telegramCall(telegramBotToken, 'getUpdates', { limit: 100 }, 'get updates');
|
|
31
|
+
if (fetched?.error)
|
|
32
|
+
return fetched;
|
|
33
|
+
const updates = (fetched?.result ?? []).filter((u) => String(updateChatId(u)) === String(chatId));
|
|
34
|
+
const messages = updates
|
|
35
|
+
.map((u) => u.message ?? u.edited_message ?? u.channel_post ?? u.edited_channel_post ?? u.callback_query?.message)
|
|
36
|
+
.filter((m) => m && (messageId === undefined || m.message_id >= messageId));
|
|
37
|
+
const start = offset && offset > 0 ? offset : 0;
|
|
38
|
+
const sliced = messages.slice(start, start + (limit ?? 100));
|
|
39
|
+
return { ok: true, result: sliced };
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
export const answerCallbackQuery = tool({
|
|
43
|
+
description: 'Answers an inline-keyboard callback query (notification toast or alert popup). Answer promptly — IDs expire quickly and delays leave stuck spinners.',
|
|
44
|
+
inputSchema: z.object({
|
|
45
|
+
telegramBotToken: telegramBotTokenField,
|
|
46
|
+
callbackQueryId: z.string().describe('Callback query ID from the update'),
|
|
47
|
+
text: z.string().max(200).optional().describe('Notification text, 0-200 chars (omit for silent ack)'),
|
|
48
|
+
showAlert: z.boolean().optional().describe('Alert dialog instead of top toast (default false)'),
|
|
49
|
+
url: z.string().optional().describe('Game URL (callback_game buttons from @BotFather games only)'),
|
|
50
|
+
cacheTime: z.number().int().min(0).optional().describe('Client-side cache seconds (default 0)'),
|
|
51
|
+
}),
|
|
52
|
+
execute: async ({ telegramBotToken, callbackQueryId, showAlert, cacheTime, ...rest }) => telegramCall(telegramBotToken, 'answerCallbackQuery', { callback_query_id: callbackQueryId, show_alert: showAlert, cache_time: cacheTime, ...rest }, 'answer callback query'),
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=updates.js.map
|