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:
@@ -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',
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user