mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
feat(channels): add config validation, instructions, and sessionScope support
- Validate required fields (type, token) with clear error messages - Prepend channel instructions to first prompt of each session - SessionRouter respects sessionScope (user/thread/single) for routing keys
This commit is contained in:
parent
2985201317
commit
615ccd08f2
3 changed files with 67 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { SessionTarget } from './types.js';
|
||||
import type { SessionScope, SessionTarget } from './types.js';
|
||||
import type { AcpBridge } from './AcpBridge.js';
|
||||
|
||||
export class SessionRouter {
|
||||
|
|
@ -7,10 +7,29 @@ export class SessionRouter {
|
|||
|
||||
private bridge: AcpBridge;
|
||||
private cwd: string;
|
||||
private scope: SessionScope;
|
||||
|
||||
constructor(bridge: AcpBridge, cwd: string) {
|
||||
constructor(bridge: AcpBridge, cwd: string, scope: SessionScope = 'user') {
|
||||
this.bridge = bridge;
|
||||
this.cwd = cwd;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
private routingKey(
|
||||
channelName: string,
|
||||
senderId: string,
|
||||
chatId: string,
|
||||
threadId?: string,
|
||||
): string {
|
||||
switch (this.scope) {
|
||||
case 'thread':
|
||||
return `${channelName}:${threadId || chatId}`;
|
||||
case 'single':
|
||||
return `${channelName}:__single__`;
|
||||
case 'user':
|
||||
default:
|
||||
return `${channelName}:${senderId}`;
|
||||
}
|
||||
}
|
||||
|
||||
async resolve(
|
||||
|
|
@ -19,7 +38,7 @@ export class SessionRouter {
|
|||
chatId: string,
|
||||
threadId?: string,
|
||||
): Promise<string> {
|
||||
const key = `${channelName}:${senderId}`;
|
||||
const key = this.routingKey(channelName, senderId, chatId, threadId);
|
||||
const existing = this.toSession.get(key);
|
||||
if (existing) {
|
||||
return existing;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue