refactor: extract reply-end config constants / 抽出 reply-end 共用設定常數
This commit is contained in:
24
src/config.ts
Normal file
24
src/config.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { ReplyEndChoice } from "./types.js"
|
||||
|
||||
export const REPLY_END_CALLBACKS = {
|
||||
continue: "rec:continue",
|
||||
stop: "rec:stop",
|
||||
} as const
|
||||
|
||||
export const REPLY_END_LABELS = {
|
||||
continue: "A. 繼續",
|
||||
stop: "B. 就這樣吧,不需要額外處理",
|
||||
} as const
|
||||
|
||||
export const REPLY_END_RESOLVED_LABELS = {
|
||||
continue: "✅ A. 繼續",
|
||||
stop: "⏹ B. 就這樣吧,不需要額外處理",
|
||||
} as const
|
||||
|
||||
export function buildReplyEndAckText(choice: ReplyEndChoice): string {
|
||||
return choice === "continue"
|
||||
? "reply-end-controls: continue received"
|
||||
: "reply-end-controls: stop received"
|
||||
}
|
||||
|
||||
export const STOP_POLICY_TEXT = "[System: The user previously pressed reply-end-controls Stop for this conversation. Treat the previous thread as closed. Unless the user's new message contains a clear new instruction or explicit request for more work, you must NOT proactively continue, must NOT add extra checks, must NOT propose next steps, must NOT extend the task, and should answer briefly and close cleanly.]"
|
||||
@@ -1,30 +1,29 @@
|
||||
import type { ReplyEndChoice, ReplyEndState, TelegramInlineButton } from "../types.js"
|
||||
import { REPLY_END_CALLBACKS, REPLY_END_LABELS, REPLY_END_RESOLVED_LABELS, STOP_POLICY_TEXT, buildReplyEndAckText } from "../config.js"
|
||||
|
||||
export function buildDefaultReplyEndButtons(): TelegramInlineButton[][] {
|
||||
return [[
|
||||
{ text: "A. 繼續", callback_data: "rec:continue" },
|
||||
{ text: "B. 就這樣吧,不需要額外處理", callback_data: "rec:stop" },
|
||||
{ text: REPLY_END_LABELS.continue, callback_data: REPLY_END_CALLBACKS.continue },
|
||||
{ text: REPLY_END_LABELS.stop, callback_data: REPLY_END_CALLBACKS.stop },
|
||||
]]
|
||||
}
|
||||
|
||||
export function buildResolvedReplyEndButtons(choice: ReplyEndChoice): TelegramInlineButton[][] {
|
||||
if (choice === "continue") {
|
||||
return [[
|
||||
{ text: "✅ A. 繼續", callback_data: "rec:continue" },
|
||||
{ text: "B. 就這樣吧,不需要額外處理", callback_data: "rec:stop" },
|
||||
{ text: REPLY_END_RESOLVED_LABELS.continue, callback_data: REPLY_END_CALLBACKS.continue },
|
||||
{ text: REPLY_END_LABELS.stop, callback_data: REPLY_END_CALLBACKS.stop },
|
||||
]]
|
||||
}
|
||||
|
||||
return [[
|
||||
{ text: "A. 繼續", callback_data: "rec:continue" },
|
||||
{ text: "⏹ B. 就這樣吧,不需要額外處理", callback_data: "rec:stop" },
|
||||
{ text: REPLY_END_LABELS.continue, callback_data: REPLY_END_CALLBACKS.continue },
|
||||
{ text: REPLY_END_RESOLVED_LABELS.stop, callback_data: REPLY_END_CALLBACKS.stop },
|
||||
]]
|
||||
}
|
||||
|
||||
export function buildReplyEndAcknowledgement(choice: ReplyEndChoice): string {
|
||||
return choice === "continue"
|
||||
? "reply-end-controls: continue received"
|
||||
: "reply-end-controls: stop received"
|
||||
return buildReplyEndAckText(choice)
|
||||
}
|
||||
|
||||
export function applyStopStateToInboundText(text: string, state: ReplyEndState | null): string {
|
||||
@@ -32,5 +31,5 @@ export function applyStopStateToInboundText(text: string, state: ReplyEndState |
|
||||
return text
|
||||
}
|
||||
|
||||
return `${text}\n\n[System: The user previously pressed reply-end-controls Stop for this conversation. Treat the previous thread as closed. Unless the user's new message contains a clear new instruction or explicit request for more work, you must NOT proactively continue, must NOT add extra checks, must NOT propose next steps, must NOT extend the task, and should answer briefly and close cleanly.]`.trim()
|
||||
return `${text}\n\n${STOP_POLICY_TEXT}`.trim()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user