Repository navigation
TB1: the bot on Workers - #2
Merged
Merged
Conversation
ChatGPT-Telegram-Workers v1.10.7 (0d152e5, MIT) as one Cloudflare Worker built in this workspace. The upstream libraries keep their code and layout under packages/ — types, i18n, telegram, plugins, ai, config, agent, web, core — renamed to the @bot/* scope, each built by tsc -b as upstream (the admin page by Vite into its HTML string module), their tests beside them in workerd, linted by upstream's oxlint. The Node/Vercel/Docker server and the mock and browser test packages are not ported: the product runs on Workers only. apps/bot is upstream's Workers entry plus what the port adds: the product's name and repository on its pages (the <title>, the heading, the source and issue links; the documentation link and the credit stay upstream's), GET /health (the KV namespace read through DATABASE, the environment, whether a token is connected), and POST /init/bind, which runs upstream's webhook bind when the caller holds the bot token. The wrangler template binds DATABASE from the cloudflare-kv wiring document and the AI binding; the committed wrangler.jsonc is its fixture render. The build is wrangler's dry run plus upstream's bundle guard: 239 KB, dependency-free ESM. Workers AI is the keyless default: a fresh configuration carries one chat and one image provider on the AI binding, so a new bot answers before its owner has any vendor key; English is the default language. Three upstream tests asserted the empty default and now assert this one. The component runs on cloudflare-worker-turbo: the bot token, the admin id, the admin password and the webhook secret are optional Orun secrets the composition's secrets-live step pushes to the Worker after a deploy, and the smoke first runs scripts/bind-webhook.mjs (the post-deploy binding, a named no-op with no token), then reads /health. tests/bot runs every library's tests and the port's own (health, the routes, the bind's authentication and its Telegram calls, the defaults); change.inputs re-plans both components when a library changes. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ChatGPT-Telegram-Workers v1.10.7 (
0d152e5, MIT) as one Cloudflare Worker built in this workspace (TB-2).The libraries keep their code and layout under
packages/— types, i18n, telegram, plugins, ai, config, agent, web, core — renamed to the@bot/*scope, each built bytsc -bas upstream (the admin page by Vite into its HTML string module), their tests beside them in workerd, linted by upstream's oxlint. The Node/Vercel/Docker server and the mock/browser test packages are not ported (Workers only).apps/bot is upstream's Workers entry plus what the port adds:
<title>, heading, source and issue links; the docs link and the credit stay upstream's);GET /health— the KV namespace read throughDATABASE, the environment, whether a token is connected;POST /init/bind— upstream's webhook bind, for a caller holding the bot token.The wrangler template binds
DATABASEfrom thecloudflare-kvwiring document plus theAIbinding; the committedwrangler.jsoncis its fixture render. Build: wrangler's dry run plus upstream's bundle guard — 239 KB (55 KB gzipped), dependency-free ESM.Workers AI is the keyless default: a fresh configuration carries a chat and an image provider on the
AIbinding, so a new bot answers with no vendor key; English is the default language. Three upstream tests asserted the empty default and now assert this one.The component (
cloudflare-worker-turbo):TELEGRAM_TOKEN,ADMIN_ID,ADMIN_PASSWORD,TELEGRAM_SECRET_TOKENare optional Orun secrets the composition'ssecrets-livestep pushes to the Worker after a deploy; the smoke first runsscripts/bind-webhook.mjs(the post-deploy binding — a named no-op with no token), then reads/health.tests/botruns every library's tests plus the port's own;change.inputsre-plans both components when a library changes.Checked locally:
pnpm typecheck,pnpm lint,pnpm test(215 library tests + 14 port tests) andpnpm buildgreen;wrangler dev --localserves/health, the branded page and/rpc, and refuses/init/bindwithout the token;orun planandorun catalog validate(0 errors) pass; component docs generated.🤖 Generated with Claude Code
https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn