fix: ensure userVisible metadata on Goosed session replies
Goosed rejects /sessions/:id/reply when user_message.metadata lacks userVisible. Normalize metadata before submit and during agent orchestration so page-generation runs no longer fail before streaming starts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import { createMemoryV2 } from './memory-v2.mjs';
|
||||
async function withFakeGoosedSession(handler) {
|
||||
const workingDir = fs.mkdtempSync(path.join(os.tmpdir(), 'memind-memory-v2-'));
|
||||
const harnessEntries = [];
|
||||
const replyBodies = [];
|
||||
let server;
|
||||
|
||||
try {
|
||||
@@ -52,6 +53,7 @@ async function withFakeGoosedSession(handler) {
|
||||
return;
|
||||
}
|
||||
if (req.method === 'POST' && req.url === '/sessions/session-1/reply') {
|
||||
replyBodies.push(body);
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ ok: true }));
|
||||
return;
|
||||
@@ -77,6 +79,7 @@ async function withFakeGoosedSession(handler) {
|
||||
apiTarget: `http://127.0.0.1:${port}`,
|
||||
workingDir,
|
||||
harnessEntries,
|
||||
replyBodies,
|
||||
});
|
||||
} finally {
|
||||
if (server?.listening) {
|
||||
@@ -538,6 +541,44 @@ test('getRuntimeStatus preserves Memory V2 status contract for release gates', a
|
||||
});
|
||||
});
|
||||
|
||||
test('submitSessionReplyForUser adds goose metadata visibility flags before reply', 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 proxy.submitSessionReplyForUser(
|
||||
'user-1',
|
||||
'session-1',
|
||||
'request-goose-meta',
|
||||
{
|
||||
role: 'user',
|
||||
content: [{ type: 'text', text: '帮我生成一个分享页面' }],
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(replyBodies.length, 1);
|
||||
assert.equal(replyBodies[0]?.user_message?.metadata?.userVisible, true);
|
||||
assert.equal(replyBodies[0]?.user_message?.metadata?.agentVisible, true);
|
||||
});
|
||||
});
|
||||
|
||||
test('submitSessionReplyForUser passes current prompt to Memory V2 resolve before existing reply path', async () => {
|
||||
let resolveInput = null;
|
||||
await withFakeGoosedSession(async ({ apiTarget, workingDir }) => {
|
||||
|
||||
Reference in New Issue
Block a user