fix: align WeChat channel modes
This commit is contained in:
@@ -226,5 +226,5 @@ export function startEnvironmentChannels(
|
||||
export function isReadOnlyChannelMessage(
|
||||
message: ChannelInboundText
|
||||
): boolean {
|
||||
return message.workMode === 'ask' || message.workMode === 'plan'
|
||||
return message.workMode === 'ask'
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ async function waitForSent(
|
||||
}
|
||||
|
||||
describe('channel contracts', () => {
|
||||
it('normalizes text, defaults to ask, and strictly refuses execute mode', () => {
|
||||
it('normalizes text, defaults to ask, and refuses non-ask modes', () => {
|
||||
expect(
|
||||
channelInboundTextSchema.parse({
|
||||
channel: ' fake ',
|
||||
@@ -98,6 +98,12 @@ describe('channel contracts', () => {
|
||||
workMode: 'execute'
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
channelInboundTextSchema.safeParse({
|
||||
...inbound(),
|
||||
workMode: 'plan'
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
channelInboundTextSchema.parse({
|
||||
channel: 'fake',
|
||||
|
||||
@@ -13,8 +13,8 @@ describe('parseRemoteChannelPrompt', () => {
|
||||
workMode: 'execute',
|
||||
prompt: '请整理下载目录'
|
||||
})
|
||||
expect(parseRemoteChannelPrompt('总结进展', 'plan')).toEqual({
|
||||
workMode: 'plan',
|
||||
expect(parseRemoteChannelPrompt('总结进展', 'ask')).toEqual({
|
||||
workMode: 'ask',
|
||||
prompt: '总结进展'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { WorkMode } from '../../shared/assistant-contracts'
|
||||
import type { InteractiveWorkMode } from '../../shared/assistant-contracts'
|
||||
|
||||
const COMMAND_PATTERN =
|
||||
/^\/(?<command>ask|execute|exec)(?=$|[\s::])[\s::]*/iu
|
||||
@@ -7,9 +7,9 @@ const CHINESE_PATTERN =
|
||||
|
||||
export function parseRemoteChannelPrompt(
|
||||
text: string,
|
||||
defaultWorkMode: WorkMode
|
||||
defaultWorkMode: InteractiveWorkMode
|
||||
): {
|
||||
workMode: WorkMode
|
||||
workMode: InteractiveWorkMode
|
||||
prompt: string
|
||||
} {
|
||||
const value = text.trim()
|
||||
|
||||
Reference in New Issue
Block a user