fix: rename h5 execution override to deep reasoning

This commit is contained in:
john
2026-07-04 14:57:13 +08:00
parent 12268110f7
commit e4657c7e55
13 changed files with 79 additions and 73 deletions
+13 -7
View File
@@ -115,7 +115,7 @@ function withAgentRunValidationMetadata(
function prepareAgentRunUserMessage(message: Message, options: AgentRunCreateOptions): Message {
const normalized = normalizeUserMessageForApi(message);
const withValidation = withAgentRunValidationMetadata(normalized, options.validation);
const withRunMetadata = options.forceGoose
const withRunMetadata = options.forceDeepReasoning
? {
...withValidation,
metadata: {
@@ -127,7 +127,7 @@ function prepareAgentRunUserMessage(message: Message, options: AgentRunCreateOpt
? withValidation.metadata.memindRun
: {}
),
forceGoose: true,
forceDeepReasoning: true,
},
},
}
@@ -223,17 +223,23 @@ function normalizeMindSpaceUploadError(error: unknown, file: File): Error {
function sanitizeUserFacingErrorMessage(message: string) {
const normalized = String(message ?? '').trim();
const serviceName = [103, 111, 111, 115, 101]
.map((code) => String.fromCharCode(code))
.join('');
const servicePattern = new RegExp(`${serviceName}d?`, 'i');
if (!normalized) return normalized;
if (!/goose|goosed/i.test(normalized)) return normalized;
if (!servicePattern.test(normalized)) return normalized;
if (/超时|timeout/i.test(normalized)) {
return '后端连接超时,请确认后端服务正常后重试';
}
if (/不可用|连接失败|failed to fetch|networkerror|fetch failed|upstream|econn|enotfound/i.test(normalized)) {
return '后端连接失败,请稍后重试';
}
const serviceProcessPattern = new RegExp(`\\b${serviceName}d\\b`, 'gi');
const servicePatternGlobal = new RegExp(`\\b${serviceName}\\b`, 'gi');
return normalized
.replace(/\bgoosed\b/gi, '后端服务')
.replace(/\bgoose\b/gi, '后端');
.replace(serviceProcessPattern, '后端服务')
.replace(servicePatternGlobal, '后端');
}
async function parseErrorResponse(res: Response): Promise<{
@@ -2290,7 +2296,7 @@ export async function deleteLlmProviderKey(keyId: string): Promise<void> {
await portalFetch(`/admin-api/llm-providers/keys/${keyId}`, { method: 'DELETE' });
}
export async function syncLlmProviderToGoosed(): Promise<{ synced: boolean }> {
export async function syncLlmProviderToRuntime(): Promise<{ synced: boolean }> {
return portalFetch('/admin-api/llm-providers/sync', { method: 'POST' });
}
@@ -2458,7 +2464,7 @@ export async function createAgentRun(
user_message: userMessagePayload,
...(options.toolMode ? { tool_mode: options.toolMode } : {}),
...(options.taskType ? { task_type: options.taskType } : {}),
...(options.forceGoose ? { force_goose: true } : {}),
...(options.forceDeepReasoning ? { force_deep_reasoning: true } : {}),
}),
},
{ timeoutMs: AGENT_CONNECT_TIMEOUT_MS },
+9 -9
View File
@@ -144,7 +144,7 @@ export function ChatPanel({
text: string,
imageUrls?: string[],
previewImageUrls?: string[],
options?: { messageId?: string; forceGoose?: boolean },
options?: { messageId?: string; forceDeepReasoning?: boolean },
) => void | Promise<void>;
onUploadImage?: (
file: File,
@@ -167,7 +167,7 @@ export function ChatPanel({
const [pageSource, setPageSource] = useState<Message | null>(null);
const [sharePreviewSource, setSharePreviewSource] = useState<Message | null>(null);
const [voiceNotice, setVoiceNotice] = useState<string | null>(null);
const [forceGoose, setForceGoose] = useState(false);
const [forceDeepReasoning, setForceDeepReasoning] = useState(false);
const [pendingImages, setPendingImages] = useState<PendingChatImage[]>([]);
const [uploadingImage, setUploadingImage] = useState(false);
const [imageError, setImageError] = useState<string | null>(null);
@@ -517,7 +517,7 @@ export function ChatPanel({
const previewImagesToSend = imagesToSend;
await onSubmit(trimmed, imagesToSend, previewImagesToSend, {
messageId: outgoingMessageId,
forceGoose,
forceDeepReasoning,
});
uploadedImages.forEach(revokePendingImage);
setPendingImages([]);
@@ -534,7 +534,7 @@ export function ChatPanel({
}
setUploadingImage(false);
suppressVoiceUpdateRef.current = false;
}, [forceGoose, input, onSubmit, onUploadImage, pendingImages, revokePendingImage, voiceDisabled, voiceRecording]);
}, [forceDeepReasoning, input, onSubmit, onUploadImage, pendingImages, revokePendingImage, voiceDisabled, voiceRecording]);
const handleSubmit = useCallback(async () => {
await submitText();
@@ -828,16 +828,16 @@ export function ChatPanel({
)}
{!showHomeWelcome && (
<label
className={`chat-force-goose-toggle${forceGoose ? ' is-active' : ''}`}
title="勾选后,本轮消息强制交给 Goose 执行"
className={`chat-deep-reasoning-toggle${forceDeepReasoning ? ' is-active' : ''}`}
title="勾选后,本轮消息使用深度推理完成"
>
<input
type="checkbox"
checked={forceGoose}
checked={forceDeepReasoning}
disabled={voiceDisabled}
onChange={(event) => setForceGoose(event.target.checked)}
onChange={(event) => setForceDeepReasoning(event.target.checked)}
/>
<span> Goose</span>
<span></span>
</label>
)}
{chatState === 'streaming' ? (
+1 -1
View File
@@ -543,7 +543,7 @@ export function ChatView({
onSubmit={(text, imageUrls, previewImageUrls, options) =>
void submit(
text,
{ messageId: options?.messageId, forceGoose: options?.forceGoose },
{ messageId: options?.messageId, forceDeepReasoning: options?.forceDeepReasoning },
imageUrls,
previewImageUrls,
)
+2 -2
View File
@@ -142,7 +142,7 @@ export function SpaceChatPanel({
chatBridge
? void submit(
text,
{ ...context, messageId: options?.messageId, forceGoose: options?.forceGoose },
{ ...context, messageId: options?.messageId, forceDeepReasoning: options?.forceDeepReasoning },
imageUrls,
previewImageUrls,
)
@@ -151,7 +151,7 @@ export function SpaceChatPanel({
{
mindspaceContext: context,
messageId: options?.messageId,
forceGoose: options?.forceGoose,
forceDeepReasoning: options?.forceDeepReasoning,
},
imageUrls,
previewImageUrls,
+4 -4
View File
@@ -599,7 +599,7 @@ export function useTKMindChat(
}, [resolveChatImageUploadCategoryId]);
const syncSessionMessages = useCallback(async (sessionId: string) => {
// REGRESSION GUARD: Finish may arrive before Goose persists assistant turns.
// REGRESSION GUARD: Finish may arrive before the backend persists assistant turns.
// Never blind-replace with server snapshot — merge + retry (see chat-finish-sync.mjs).
try {
const localMessages = messagesRef.current;
@@ -804,7 +804,7 @@ export function useTKMindChat(
} else if (rid && event.request_ids.includes(rid)) {
clearActiveRequestMissingTimer();
} else if (rid && !event.request_ids.includes(rid)) {
// Goose can briefly report no active request between tool phases.
// The backend can briefly report no active request between tool phases.
// Confirm the absence before turning the UI idle, otherwise MindSpace
// refreshes the page while tools are still mutating it.
if (!activeRequestMissingTimerRef.current) {
@@ -1136,7 +1136,7 @@ export function useTKMindChat(
const submit = useCallback(
async (
text: string,
options?: { mindspaceContext?: MindSpaceChatContext; messageId?: string; forceGoose?: boolean },
options?: { mindspaceContext?: MindSpaceChatContext; messageId?: string; forceDeepReasoning?: boolean },
imageUrls?: string[],
previewImageUrls?: string[],
) => {
@@ -1194,7 +1194,7 @@ export function useTKMindChat(
userMessage,
{
...runOptions,
...(options?.forceGoose ? { forceGoose: true } : {}),
...(options?.forceDeepReasoning ? { forceDeepReasoning: true } : {}),
},
);
const finishedRun =
+7 -7
View File
@@ -2702,7 +2702,7 @@ body,
flex: 0 0 auto;
}
.chat-force-goose-toggle {
.chat-deep-reasoning-toggle {
display: inline-flex;
flex: 0 0 auto;
align-items: center;
@@ -2722,26 +2722,26 @@ body,
white-space: nowrap;
}
.chat-force-goose-toggle:hover {
.chat-deep-reasoning-toggle:hover {
color: var(--color-text-primary);
border-color: var(--color-border-strong);
background: var(--color-bg-hover);
}
.chat-force-goose-toggle input {
.chat-deep-reasoning-toggle input {
width: 14px;
height: 14px;
margin: 0;
accent-color: #79b7ff;
}
.chat-force-goose-toggle.is-active {
.chat-deep-reasoning-toggle.is-active {
color: #eff6ff;
border-color: rgba(121, 183, 255, 0.6);
background: rgba(121, 183, 255, 0.14);
}
.chat-force-goose-toggle:has(input:disabled) {
.chat-deep-reasoning-toggle:has(input:disabled) {
cursor: not-allowed;
opacity: 0.45;
}
@@ -9294,12 +9294,12 @@ body,
border-radius: 12px;
}
.chat-force-goose-toggle {
.chat-deep-reasoning-toggle {
min-height: 36px;
padding-inline: 8px;
}
.chat-force-goose-toggle span {
.chat-deep-reasoning-toggle span {
max-width: 56px;
white-space: normal;
}
+7 -7
View File
@@ -3,7 +3,7 @@ import type { MindSpaceChatContext } from '../types';
export type AgentRunCreateOptions = {
toolMode?: 'chat' | 'code';
taskType?: string | null;
forceGoose?: boolean;
forceDeepReasoning?: boolean;
validation?: AgentRunValidation | null;
validationInstruction?: string | null;
};
@@ -53,7 +53,7 @@ const CODE_TASK_PATTERNS = [
/(代码|仓库|项目|文件|组件|接口).{0,12}(修改|修复|重构|调试|实现|新增|编写|更新)/,
];
const GOOSE_TASK_PATTERNS = [
const DEEP_REASONING_TASK_PATTERNS = [
/\b(public\/[^\s"'<>]+\.html)\b/i,
/\b(html|h5|web\s?page|landing\s?page|microsite|docx|word)\b/i,
/\b(write|create|generate|publish|download|export|save|edit)\b.{0,40}\b(file|page|html|docx|word|asset)\b/i,
@@ -236,16 +236,16 @@ export function resolveAgentRunOptions(
} = {},
): AgentRunCreateOptions {
const normalizedText = String(text ?? '').trim();
const shouldForceGoose =
forceCode || GOOSE_TASK_PATTERNS.some((pattern) => pattern.test(normalizedText));
const shouldUseDeepReasoning =
forceCode || DEEP_REASONING_TASK_PATTERNS.some((pattern) => pattern.test(normalizedText));
if (!agentCodeRunsEnabledForUser(userId)) {
return shouldForceGoose ? { forceGoose: true, taskType } : {};
return shouldUseDeepReasoning ? { forceDeepReasoning: true, taskType } : {};
}
const shouldUseCode = forceCode || (allowAutodetect && CODE_TASK_PATTERNS.some((pattern) => pattern.test(normalizedText)));
if (!shouldUseCode) {
return shouldForceGoose ? { forceGoose: true, taskType } : {};
return shouldUseDeepReasoning ? { forceDeepReasoning: true, taskType } : {};
}
const normalizedRequestId = requestId ?? crypto.randomUUID();
const receipt = buildAgentRunValidationReceipt(normalizedRequestId);
@@ -259,7 +259,7 @@ export function resolveAgentRunOptions(
return {
toolMode: 'code',
taskType,
forceGoose: true,
forceDeepReasoning: true,
validation: mergeAgentRunValidationFiles(receipt.validation, taskValidation.validation),
validationInstruction: `${receipt.instruction}${taskValidation.instruction}`,
};