mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-29 14:02:19 +00:00
feat(core): opt-in memory deletion on channel / composio disconnect (#2546)
Co-authored-by: zed <14452662+nidieopq@user.noreply.gitee.com> Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
This commit is contained in:
co-authored by
zed
Steven Enamakel
parent
9a65e8630d
commit
7ac685e628
@@ -191,3 +191,27 @@ describe('listAgentReadyToolkits', () => {
|
||||
expect(out.toolkits).toEqual(['gmail']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteConnection', () => {
|
||||
beforeEach(() => {
|
||||
mockCallCoreRpc.mockReset();
|
||||
});
|
||||
|
||||
it('calls composio_delete_connection with connection_id', async () => {
|
||||
mockCallCoreRpc.mockResolvedValue({ result: { deleted: true }, logs: [] });
|
||||
await deleteConnection('conn-abc');
|
||||
expect(mockCallCoreRpc).toHaveBeenCalledWith({
|
||||
method: 'openhuman.composio_delete_connection',
|
||||
params: { connection_id: 'conn-abc' },
|
||||
});
|
||||
});
|
||||
|
||||
it('forwards clearMemory=true to the RPC', async () => {
|
||||
mockCallCoreRpc.mockResolvedValue({ result: { deleted: true }, logs: [] });
|
||||
await deleteConnection('conn-abc', { clearMemory: true });
|
||||
expect(mockCallCoreRpc).toHaveBeenCalledWith({
|
||||
method: 'openhuman.composio_delete_connection',
|
||||
params: { connection_id: 'conn-abc', clear_memory: true },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { channelConnectionsApi } from './channelConnectionsApi';
|
||||
|
||||
const mockCallCoreRpc = vi.fn();
|
||||
|
||||
vi.mock('../coreRpcClient', () => ({ callCoreRpc: (args: unknown) => mockCallCoreRpc(args) }));
|
||||
|
||||
describe('channelConnectionsApi.disconnectChannel', () => {
|
||||
beforeEach(() => {
|
||||
mockCallCoreRpc.mockReset();
|
||||
});
|
||||
|
||||
it('calls channels_disconnect with channel and authMode', async () => {
|
||||
mockCallCoreRpc.mockResolvedValue({});
|
||||
await channelConnectionsApi.disconnectChannel('telegram', 'bot_token');
|
||||
expect(mockCallCoreRpc).toHaveBeenCalledWith({
|
||||
method: 'openhuman.channels_disconnect',
|
||||
params: { channel: 'telegram', authMode: 'bot_token' },
|
||||
});
|
||||
});
|
||||
|
||||
it('forwards clearMemory=true to the RPC', async () => {
|
||||
mockCallCoreRpc.mockResolvedValue({});
|
||||
await channelConnectionsApi.disconnectChannel('discord', 'bot_token', { clearMemory: true });
|
||||
expect(mockCallCoreRpc).toHaveBeenCalledWith({
|
||||
method: 'openhuman.channels_disconnect',
|
||||
params: { channel: 'discord', authMode: 'bot_token', clearMemory: true },
|
||||
});
|
||||
});
|
||||
|
||||
it('defaults clearMemory to false when omitted', async () => {
|
||||
mockCallCoreRpc.mockResolvedValue({});
|
||||
await channelConnectionsApi.disconnectChannel('telegram', 'oauth');
|
||||
expect(mockCallCoreRpc).toHaveBeenCalledWith({
|
||||
method: 'openhuman.channels_disconnect',
|
||||
params: { channel: 'telegram', authMode: 'oauth' },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user