feat(page-data): add validation suggestions, repair path, and thinking fixes
Memind CI / Test, build, and release guards (push) Failing after 3m18s
Memind CI / Test, build, and release guards (push) Failing after 3m18s
Map Page Data failure codes to Chinese remediation hints, trigger one-shot goosed repair for remediable cases, and recover poisoned thinking sessions. Route local DeepSeek through the no-think proxy via host.docker.internal so tool rounds no longer hit reasoning_content 400; document gate and case-study scenarios for event registration repair. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+21
-12
@@ -760,6 +760,18 @@ export async function updateSessionProvider(
|
||||
}
|
||||
}
|
||||
|
||||
function isMissingCustomProviderResponse(status, text) {
|
||||
return status === 404 || /provider not found/i.test(text);
|
||||
}
|
||||
|
||||
function resolveGoosedProviderId(profile, goosedProviderId) {
|
||||
if (goosedProviderId) return goosedProviderId;
|
||||
if (profile.providerKind === 'custom') {
|
||||
return profile.goosedProviderId ?? profile.providerId;
|
||||
}
|
||||
return profile.providerId;
|
||||
}
|
||||
|
||||
async function upsertCustomProviderOnGoosed(apiTarget, apiSecret, profile, fetchImpl) {
|
||||
const headers = profile.relayProvider
|
||||
? { 'X-Provider': profile.relayProvider }
|
||||
@@ -788,9 +800,11 @@ async function upsertCustomProviderOnGoosed(apiTarget, apiSecret, profile, fetch
|
||||
fetchImpl,
|
||||
);
|
||||
if (upstream.ok) return profile.goosedProviderId;
|
||||
// First-time ensure: fixed ids may 404 until created.
|
||||
if (upstream.status !== 404) {
|
||||
const text = await upstream.text().catch(() => '');
|
||||
const text = await upstream.text().catch(() => '');
|
||||
// First-time ensure: older TKMind Agent builds may report a missing fixed id
|
||||
// as 500 with a JSON "Provider not found" message instead of HTTP 404.
|
||||
const providerMissing = isMissingCustomProviderResponse(upstream.status, text);
|
||||
if (!providerMissing) {
|
||||
throw new Error(`更新 TKMind Agent 自定义 provider 失败: ${text || upstream.status}`);
|
||||
}
|
||||
}
|
||||
@@ -863,8 +877,9 @@ async function removeCustomProviderOnGoosed(apiTarget, apiSecret, goosedProvider
|
||||
{ method: 'DELETE' },
|
||||
fetchImpl,
|
||||
);
|
||||
if (!upstream.ok && upstream.status !== 404) {
|
||||
if (!upstream.ok) {
|
||||
const text = await upstream.text().catch(() => '');
|
||||
if (isMissingCustomProviderResponse(upstream.status, text)) return;
|
||||
throw new Error(`删除 TKMind Agent 自定义 provider 失败: ${text || upstream.status}`);
|
||||
}
|
||||
}
|
||||
@@ -1157,10 +1172,7 @@ export function createLlmProviderService(
|
||||
try {
|
||||
const goosedProviderId = await syncRowWithModel(row, binding.model, fetchImpl);
|
||||
const profile = profileFromRow(row, decryptRow);
|
||||
const providerId =
|
||||
profile.providerKind === 'custom'
|
||||
? (goosedProviderId ?? profile.goosedProviderId ?? profile.providerId)
|
||||
: profile.providerId;
|
||||
const providerId = resolveGoosedProviderId(profile, goosedProviderId);
|
||||
return {
|
||||
ok: true,
|
||||
providerId,
|
||||
@@ -1355,10 +1367,7 @@ export function createLlmProviderService(
|
||||
}
|
||||
try {
|
||||
const goosedProviderId = await syncRow(row, fetchImpl);
|
||||
const providerId =
|
||||
profile.providerKind === 'custom'
|
||||
? (goosedProviderId ?? profile.goosedProviderId ?? profile.providerId)
|
||||
: profile.providerId;
|
||||
const providerId = resolveGoosedProviderId(profile, goosedProviderId);
|
||||
return {
|
||||
ok: true,
|
||||
providerId,
|
||||
|
||||
Reference in New Issue
Block a user