Add smart ACK provider for WeChat MP replies
Replace fixed ackText with a rule-based AckProvider that picks response templates by message type and intent (translate, summary, rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync, zero I/O, auto-falls back to config.ackText on any error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+18
-9
@@ -88,6 +88,7 @@ export async function reconcileAgentSession(
|
||||
if (sessionPolicy?.unrestricted) return;
|
||||
|
||||
const session = await readJson(await apiFetch(`/sessions/${sessionId}`));
|
||||
let needsRestart = false;
|
||||
if (workingDir && !samePath(session?.working_dir, workingDir)) {
|
||||
try {
|
||||
await readJson(
|
||||
@@ -108,7 +109,7 @@ export async function reconcileAgentSession(
|
||||
}
|
||||
}
|
||||
|
||||
if (sessionPolicy?.gooseMode) {
|
||||
if (sessionPolicy?.gooseMode && session?.goose_mode !== sessionPolicy.gooseMode) {
|
||||
await readJson(
|
||||
await apiFetch('/agent/update_session', {
|
||||
method: 'POST',
|
||||
@@ -118,12 +119,14 @@ export async function reconcileAgentSession(
|
||||
}),
|
||||
}),
|
||||
);
|
||||
needsRestart = true;
|
||||
}
|
||||
|
||||
const desired = sessionPolicy?.extensionOverrides ?? [];
|
||||
const allowed = allowedExtensionNames(desired);
|
||||
const currentPayload = await readJson(await apiFetch(`/sessions/${sessionId}/extensions`));
|
||||
const current = currentPayload?.extensions ?? [];
|
||||
let removedAny = false;
|
||||
|
||||
for (const ext of current) {
|
||||
const name = extensionName(ext);
|
||||
@@ -134,10 +137,12 @@ export async function reconcileAgentSession(
|
||||
body: JSON.stringify({ session_id: sessionId, name }),
|
||||
}),
|
||||
);
|
||||
removedAny = true;
|
||||
}
|
||||
|
||||
const refreshedPayload = await readJson(await apiFetch(`/sessions/${sessionId}/extensions`));
|
||||
const refreshed = refreshedPayload?.extensions ?? [];
|
||||
const refreshed = removedAny
|
||||
? ((await readJson(await apiFetch(`/sessions/${sessionId}/extensions`)))?.extensions ?? [])
|
||||
: current;
|
||||
const { toRemove, toAdd } = extensionsNeedingRefresh(refreshed, desired);
|
||||
|
||||
for (const name of toRemove) {
|
||||
@@ -147,6 +152,7 @@ export async function reconcileAgentSession(
|
||||
body: JSON.stringify({ session_id: sessionId, name }),
|
||||
}),
|
||||
);
|
||||
needsRestart = true;
|
||||
}
|
||||
|
||||
for (const config of toAdd) {
|
||||
@@ -156,14 +162,17 @@ export async function reconcileAgentSession(
|
||||
body: JSON.stringify({ session_id: sessionId, config }),
|
||||
}),
|
||||
);
|
||||
needsRestart = true;
|
||||
}
|
||||
|
||||
await readJson(
|
||||
await apiFetch('/agent/restart', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ session_id: sessionId }),
|
||||
}),
|
||||
);
|
||||
if (needsRestart) {
|
||||
await readJson(
|
||||
await apiFetch('/agent/restart', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ session_id: sessionId }),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const sandboxText = sandboxConstraints?.trim()
|
||||
? buildSandboxSessionConstraints({
|
||||
|
||||
Reference in New Issue
Block a user