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:
john
2026-06-26 15:19:03 +08:00
parent 9ed4fd48d7
commit 9b4a25799f
162 changed files with 17276 additions and 2054 deletions
+73 -1
View File
@@ -48,7 +48,7 @@ test('extensionsNeedingRefresh adds missing extensions', () => {
assert.equal(toAdd[0].name, 'summon');
});
test('reconcileAgentSession tolerates invalid working directory during resume sync', async () => {
test('reconcileAgentSession tolerates invalid working directory during resume sync without restart', async () => {
const calls = [];
const apiFetch = async (pathname) => {
calls.push(pathname);
@@ -90,7 +90,79 @@ test('reconcileAgentSession tolerates invalid working directory during resume sy
'/sessions/session-1',
'/agent/update_working_dir',
'/sessions/session-1/extensions',
]);
});
test('reconcileAgentSession skips restart when extensions already match', async () => {
const calls = [];
const apiFetch = async (pathname) => {
calls.push(pathname);
if (pathname === '/sessions/session-1') {
return {
ok: true,
text: async () => JSON.stringify({ working_dir: '/valid/workspace' }),
};
}
if (pathname === '/sessions/session-1/extensions') {
return {
ok: true,
text: async () =>
JSON.stringify({
extensions: [{ name: 'skills', available_tools: [] }],
}),
};
}
if (pathname === '/agent/restart') {
return {
ok: true,
text: async () => JSON.stringify({ ok: true }),
};
}
throw new Error(`unexpected path: ${pathname}`);
};
await reconcileAgentSession(apiFetch, 'session-1', {
workingDir: '/valid/workspace',
sessionPolicy: { extensionOverrides: [{ name: 'skills', available_tools: [] }] },
});
assert.deepEqual(calls, ['/sessions/session-1', '/sessions/session-1/extensions']);
});
test('reconcileAgentSession restarts after adding missing extensions', async () => {
const calls = [];
const apiFetch = async (pathname) => {
calls.push(pathname);
if (pathname === '/sessions/session-1') {
return {
ok: true,
text: async () => JSON.stringify({ working_dir: '/valid/workspace' }),
};
}
if (pathname === '/sessions/session-1/extensions') {
return {
ok: true,
text: async () => JSON.stringify({ extensions: [] }),
};
}
if (pathname === '/agent/add_extension' || pathname === '/agent/restart') {
return {
ok: true,
text: async () => JSON.stringify({ ok: true }),
};
}
throw new Error(`unexpected path: ${pathname}`);
};
await reconcileAgentSession(apiFetch, 'session-1', {
workingDir: '/valid/workspace',
sessionPolicy: { extensionOverrides: [{ name: 'skills', available_tools: [] }] },
});
assert.deepEqual(calls, [
'/sessions/session-1',
'/sessions/session-1/extensions',
'/agent/add_extension',
'/agent/restart',
]);
});