fix: make optional services non-blocking
This commit is contained in:
+19
-1
@@ -1345,7 +1345,25 @@ export class TelegramBridge {
|
||||
}
|
||||
// ── ask_user_question: TG answering via dual-path race with the UI ──
|
||||
userQuestions() {
|
||||
return this.ctx.userQuestions;
|
||||
const ctx = this.ctx;
|
||||
if (typeof ctx.get === 'function') {
|
||||
try {
|
||||
const service = ctx.get('userQuestions');
|
||||
if (service)
|
||||
return service;
|
||||
}
|
||||
catch {
|
||||
// Continue to the plain-object fallback used by tests and simple hosts.
|
||||
}
|
||||
}
|
||||
try {
|
||||
return Object.prototype.hasOwnProperty.call(ctx, 'userQuestions')
|
||||
? ctx.userQuestions
|
||||
: undefined;
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Wrap the UI provider's ask() so Telegram gets a parallel answer path.
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
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; userQuestions: TG answer hook (Cordis requires inject). */
|
||||
/** agents: followup; apiProxy and userQuestions are optional runtime services. */
|
||||
export declare const inject: string[];
|
||||
export interface TelegramChannelConfig {
|
||||
token?: string;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import Schema from '@deepseek-ai/schemastery';
|
||||
import { TelegramBridge } from './bridge.js';
|
||||
export const name = 'dsh-telegram-channel';
|
||||
/** agents: followup; apiProxy: workspace/session catalog + /model; userQuestions: TG answer hook (Cordis requires inject). */
|
||||
export const inject = ['agents', 'apiProxy', 'userQuestions'];
|
||||
/** agents: followup; apiProxy and userQuestions are optional runtime services. */
|
||||
export const inject = ['agents'];
|
||||
export const Config = Schema.object({
|
||||
token: Schema.string().default(''),
|
||||
allowedUserIds: Schema.array(Schema.number()).default([]),
|
||||
|
||||
Reference in New Issue
Block a user