feat: remote-control live DSH Web sessions from Telegram

Attach via /sessions picker instead of creating parallel agents; mirror the same session trajectory to phone and Web (Codex-style remote).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
owo
2026-08-14 17:11:13 +08:00
co-authored by Cursor
parent dd72f134fb
commit c2c0db7597
12 changed files with 518 additions and 666 deletions
+20 -2
View File
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
import test from 'node:test'
import { TelegramClient } from '../src/client.ts'
test('getUpdates posts timeout and optional offset', async () => {
test('getUpdates posts timeout and optional offset with callback_query', async () => {
const calls: Array<{ url: string; body: unknown }> = []
const fetchImpl: typeof fetch = async (input, init) => {
calls.push({ url: String(input), body: JSON.parse(String(init?.body)) })
@@ -13,7 +13,7 @@ test('getUpdates posts timeout and optional offset', async () => {
assert.match(calls[0]!.url, /\/botSECRET-TOKEN\/getUpdates$/)
assert.deepEqual(calls[0]!.body, {
timeout: 12,
allowed_updates: ['message'],
allowed_updates: ['message', 'callback_query'],
offset: 9,
})
})
@@ -33,3 +33,21 @@ test('errors redact token', async () => {
test('empty token throws in constructor', () => {
assert.throws(() => new TelegramClient(''), /token/)
})
test('sendMessage can include reply_markup', async () => {
const calls: Array<{ body: Record<string, unknown> }> = []
const fetchImpl: typeof fetch = async (_input, init) => {
calls.push({ body: JSON.parse(String(init?.body)) })
return new Response(JSON.stringify({
ok: true,
result: { message_id: 1, date: 0, chat: { id: 1, type: 'private' }, text: 'x' },
}), { status: 200 })
}
const client = new TelegramClient('TOK', { fetch: fetchImpl })
await client.sendMessage(1, 'pick', undefined, {
inline_keyboard: [[{ text: 'A', callback_data: 'bind:1' }]],
})
assert.deepEqual(calls[0]!.body.reply_markup, {
inline_keyboard: [[{ text: 'A', callback_data: 'bind:1' }]],
})
})