mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-20 20:43:21 +08:00
merge: integrate upstream v2.0.0 (files, images, i18n) into feishu-card-system
- Resolve conflicts in feishu-cards.mjs / bridge.mjs / control-command.mjs / lib - Keep card-system enhancements: menuCard/settingsCard/presetCard/modelCard, /m newCard, card form submit, model select - Adopt upstream i18n t() wrapping + file/image delivery + inbound files - Add missing English dictionary entries for new feishu card strings - Rebuild lib (package now 2.0.0)
This commit is contained in:
commit
044ab74c28
167 changed files with 22497 additions and 1793 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { t } from './i18n.mjs';
|
||||
|
||||
const CONTROL_COMMAND = /^\/(?:stop|steer)(?=$|\s)/iu;
|
||||
const STOP_COMMAND = /^\/stop(?=$|\s)/iu;
|
||||
const STOP_USAGE = '用法:/stop(不带参数)';
|
||||
|
|
@ -40,35 +42,35 @@ export async function runControlCommand(text, harness, state, key, {
|
|||
const command = text.trim();
|
||||
const stop = STOP_COMMAND.test(command);
|
||||
|
||||
if (hasImages) return commandResult(TEXT_ONLY);
|
||||
if (hasImages) return commandResult(t(TEXT_ONLY));
|
||||
|
||||
if (stop) {
|
||||
if (!/^\/stop$/iu.test(command)) return commandResult(STOP_USAGE);
|
||||
if (!/^\/stop$/iu.test(command)) return commandResult(t(STOP_USAGE));
|
||||
const session = boundSession(harness, state, key);
|
||||
if (!session) return commandResult('当前聊天没有正在运行的任务。');
|
||||
if (!session) return commandResult(t('当前聊天没有正在运行的任务。'));
|
||||
if (typeof session.stopActiveTurn !== 'function') {
|
||||
throw new TypeError('Harness session does not support stopping active turns');
|
||||
}
|
||||
const stopped = await session.stopActiveTurn(control, requestOptions(signal));
|
||||
return stopped
|
||||
? commandResult('已请求停止当前任务。', { stopped: true })
|
||||
: commandResult('当前聊天没有正在运行的任务。');
|
||||
? commandResult(t('已请求停止当前任务。'), { stopped: true })
|
||||
: commandResult(t('当前聊天没有正在运行的任务。'));
|
||||
}
|
||||
|
||||
const match = /^\/steer(?:\s+([\s\S]*))?$/iu.exec(command);
|
||||
const instruction = match?.[1]?.trim() ?? '';
|
||||
if (!instruction) return commandResult(STEER_USAGE);
|
||||
if (!instruction) return commandResult(t(STEER_USAGE));
|
||||
if (pendingInteraction) {
|
||||
return commandResult([
|
||||
'当前任务正在等待你的回答或审批。',
|
||||
t('当前任务正在等待你的回答或审批。'),
|
||||
'',
|
||||
'请先处理当前请求,或者发送 /stop 停止任务。',
|
||||
t('请先处理当前请求,或者发送 /stop 停止任务。'),
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
const session = boundSession(harness, state, key);
|
||||
if (!session) {
|
||||
return commandResult('当前聊天没有绑定会话,无法补充指令。请先绑定会话。');
|
||||
return commandResult(t('当前聊天没有绑定会话,无法补充指令。请先绑定会话。'));
|
||||
}
|
||||
if (typeof session.steerActiveTurn !== 'function') {
|
||||
throw new TypeError('Harness session does not support steering active turns');
|
||||
|
|
@ -79,6 +81,6 @@ export async function runControlCommand(text, harness, state, key, {
|
|||
requestOptions(signal),
|
||||
);
|
||||
return steered
|
||||
? commandResult('已提交补充指令,Agent 会在下一步读取。')
|
||||
: commandResult('任务已结束,没有正在运行的任务,无法补充指令。请直接发送消息开始新任务。');
|
||||
? commandResult(t('已提交补充指令,Agent 会在下一步读取。'))
|
||||
: commandResult(t('任务已结束,没有正在运行的任务,无法补充指令。请直接发送消息开始新任务。'));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue