diff --git a/README.md b/README.md index 317a50c..113ec09 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ dsh plugin --profile web add D:\path\to\dsh-telegram-channel | `allowAllUsers` | `true` 仅调试 | | `maxMessageLength` | 默认 4096 | | `pollingTimeoutSec` | 默认 30 | -| `rendering` | `rich`(默认,原生 Rich Message)或 `html`(旧 Markdown→HTML 兼容) | +| `rendering` | `html`(默认,兼容所有客户端)或 `rich`(原生 Rich Message) | 若本机用了 HTTP(S)_PROXY 访问 Telegram,插件会自动走代理(无需再设 `NODE_USE_ENV_PROXY`)。 diff --git a/lib/bridge.js b/lib/bridge.js index 177c25f..5c0d3d6 100644 --- a/lib/bridge.js +++ b/lib/bridge.js @@ -61,7 +61,8 @@ export class TelegramBridge { }); this.sleep = options.sleep ?? defaultSleep; this.maxMessageLength = options.maxMessageLength ?? 4096; - this.renderingMode = options.rendering === 'html' ? 'html' : 'rich'; + // HTML is the compatibility default; opt into Rich Messages explicitly. + this.renderingMode = options.rendering === 'rich' ? 'rich' : 'html'; } start() { this.disposeSessionListener?.(); diff --git a/lib/index.d.ts b/lib/index.d.ts index 1636ab1..ac4bdf3 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,7 +1,8 @@ import type { Context } from '@deepseek-ai/cordis'; import Schema from '@deepseek-ai/schemastery'; export declare const name = "dsh-telegram-channel"; -/** agents: followup; apiProxy: workspace/session catalog + /model (Cordis requires inject to read ctx.apiProxy). */ +/** agents: followup; apiProxy is optional and resolved at runtime via ctx.get; + * when absent, catalog helpers degrade to the live-agents view. */ export declare const inject: string[]; export interface TelegramChannelConfig { token?: string; diff --git a/lib/index.js b/lib/index.js index d905698..b92e672 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,15 +1,16 @@ import Schema from '@deepseek-ai/schemastery'; import { TelegramBridge } from './bridge.js'; export const name = 'dsh-telegram-channel'; -/** agents: followup; apiProxy: workspace/session catalog + /model (Cordis requires inject to read ctx.apiProxy). */ -export const inject = ['agents', 'apiProxy']; +/** agents: followup; apiProxy is optional and resolved at runtime via ctx.get; + * when absent, catalog helpers degrade to the live-agents view. */ +export const inject = ['agents']; export const Config = Schema.object({ token: Schema.string().default(''), allowedUserIds: Schema.array(Schema.number()).default([]), allowAllUsers: Schema.boolean().default(false), maxMessageLength: Schema.number().default(4096), pollingTimeoutSec: Schema.number().default(30), - rendering: Schema.string().default('rich'), + rendering: Schema.string().default('html'), }); function resolveAllowedUserIds(config) { if (config.allowedUserIds && config.allowedUserIds.length > 0) { @@ -37,7 +38,7 @@ export function apply(ctx, config) { allowAllUsers: config.allowAllUsers ?? false, maxMessageLength: config.maxMessageLength ?? 4096, pollingTimeoutSec: config.pollingTimeoutSec ?? 30, - rendering: config.rendering === 'html' ? 'html' : 'rich', + rendering: config.rendering === 'rich' ? 'rich' : 'html', }); ctx.effect(() => { bridge.start(); diff --git a/src/bridge.ts b/src/bridge.ts index c835c0f..9f18a2f 100644 --- a/src/bridge.ts +++ b/src/bridge.ts @@ -121,7 +121,8 @@ export class TelegramBridge { }) this.sleep = options.sleep ?? defaultSleep this.maxMessageLength = options.maxMessageLength ?? 4096 - this.renderingMode = options.rendering === 'html' ? 'html' : 'rich' + // HTML is the compatibility default; opt into Rich Messages explicitly. + this.renderingMode = options.rendering === 'rich' ? 'rich' : 'html' } start(): void { diff --git a/src/index.ts b/src/index.ts index c1f4437..5f8afba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,8 +3,9 @@ import Schema from '@deepseek-ai/schemastery' import { TelegramBridge } from './bridge.js' export const name = 'dsh-telegram-channel' -/** agents: followup; apiProxy: workspace/session catalog + /model (Cordis requires inject to read ctx.apiProxy). */ -export const inject = ['agents', 'apiProxy'] +/** agents: followup; apiProxy is optional and resolved at runtime via ctx.get; + * when absent, catalog helpers degrade to the live-agents view. */ +export const inject = ['agents'] export interface TelegramChannelConfig { token?: string @@ -21,7 +22,7 @@ export const Config: Schema = Schema.object({ allowAllUsers: Schema.boolean().default(false), maxMessageLength: Schema.number().default(4096), pollingTimeoutSec: Schema.number().default(30), - rendering: Schema.string().default('rich'), + rendering: Schema.string().default('html'), }) function resolveAllowedUserIds(config: TelegramChannelConfig): number[] { @@ -53,7 +54,7 @@ export function apply(ctx: Context, config: TelegramChannelConfig): void { allowAllUsers: config.allowAllUsers ?? false, maxMessageLength: config.maxMessageLength ?? 4096, pollingTimeoutSec: config.pollingTimeoutSec ?? 30, - rendering: config.rendering === 'html' ? 'html' : 'rich', + rendering: config.rendering === 'rich' ? 'rich' : 'html', }) ctx.effect(() => { bridge.start() diff --git a/tests/apply.test.ts b/tests/apply.test.ts index 3f26bc6..49b6e5c 100644 --- a/tests/apply.test.ts +++ b/tests/apply.test.ts @@ -1,6 +1,10 @@ import assert from 'node:assert/strict' import test from 'node:test' -import { apply } from '../src/index.ts' +import { apply, inject } from '../src/index.ts' + +test('apiProxy is optional and is not a hard Cordis dependency', () => { + assert.deepEqual(inject, ['agents']) +}) test('apply without token does not throw and does not start effect', () => { const effects: string[] = []