fix(wechat): isolate stale images and page links
Memind CI / Test, build, and release guards (pull_request) Successful in 2m36s

This commit is contained in:
john
2026-07-22 13:30:44 +08:00
parent aea3c1e83e
commit db225b784e
11 changed files with 416 additions and 37 deletions
+59 -1
View File
@@ -13,7 +13,7 @@ import {
} from './tkmind-proxy.mjs';
import { createMemoryV2 } from './memory-v2.mjs';
async function withFakeGoosedSession(handler) {
async function withFakeGoosedSession(handler, { conversation = [] } = {}) {
const workingDir = fs.mkdtempSync(path.join(os.tmpdir(), 'memind-memory-v2-'));
const harnessEntries = [];
const replyBodies = [];
@@ -42,9 +42,15 @@ async function withFakeGoosedSession(handler) {
id: 'session-1',
working_dir: workingDir,
goose_mode: 'chat',
conversation,
}));
return;
}
if (req.method === 'PUT' && req.url === '/sessions/session-1') {
res.writeHead(405, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'method not allowed' }));
return;
}
if (req.method === 'GET' && req.url === '/sessions/session-1/extensions') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
@@ -898,6 +904,58 @@ test('submitSessionReplyForUser adds goose metadata visibility flags before repl
});
});
test('submitSessionReplyForUser fails closed when historical image scrub is unsupported', async () => {
await withFakeGoosedSession(async ({ apiTarget, workingDir, replyBodies }) => {
const proxy = createTkmindProxy({
apiTarget,
apiSecret: 'test-secret',
userAuth: {
...createMemoryTestUserAuth(workingDir),
async ownsSession() {
return true;
},
async canUseChat() {
return { ok: true };
},
async getUserById() {
return { id: 'user-1' };
},
async resolveUserPolicies() {
return { unrestricted: true, policies: {} };
},
},
});
await assert.rejects(
proxy.submitSessionReplyForUser(
'user-1',
'session-1',
'request-after-image',
{
id: 'message-current',
role: 'user',
content: [{ type: 'text', text: '继续分析' }],
},
{ requireHistoricalImageIsolation: true },
),
/historical_image_session_update_unsupported:405/,
);
assert.equal(replyBodies.length, 0);
}, {
conversation: [
{
id: 'message-old-image',
role: 'user',
metadata: { imageUrls: ['https://example.com/old.png'] },
content: [
{ type: 'text', text: '上一张图片' },
{ type: 'image_url', image_url: { url: 'https://example.com/old.png' } },
],
},
],
});
});
test('submitSessionReplyForUser applies the shared Qwen vision preprocessing path', async () => {
await withFakeGoosedSession(async ({ apiTarget, workingDir, replyBodies }) => {
const proxy = createTkmindProxy({