fix(assistant): preserve managed status gating

Only request managed status for the assistant addon. Cover the configured attachment path and keep operator-only gateway configuration out of the self-hosted environment reference.
This commit is contained in:
Maurice
2026-12-01 00:40:57 +01:00
parent 00e98b8711
commit f511fe4fcf
5 changed files with 30 additions and 13 deletions
@@ -48,13 +48,16 @@ class FakeResponse extends EventEmitter {
}
}
function make(opts: { addon?: boolean; managed?: boolean; trip?: boolean } = {}) {
function make(opts: { addon?: boolean; managed?: boolean; managedAssistant?: boolean; trip?: boolean } = {}) {
const service = {
attach: vi.fn(async (_u: number, _t: number, _b: unknown, _f: unknown, _c: TurnChannel) => undefined),
};
const trips = { findAccessible: vi.fn(async () => (opts.trip === false ? undefined : { id: 5, user_id: 7 })) };
const addons = { isAddonEnabled: vi.fn(async () => opts.addon !== false) };
const env = { isManaged: () => opts.managed === true };
const env = {
isManaged: () => opts.managed === true,
env: () => ({ managed: { assistant: opts.managedAssistant ? { model: 'test-model' } : undefined } }),
};
const controller = new AssistantAttachmentsController(
service as unknown as AssistantService,
trips as unknown as TripAccessService,
@@ -105,6 +108,10 @@ describe('AssistantAttachmentsController', () => {
});
expect(stranger.trips.findAccessible).toHaveBeenCalledWith('5', 7);
for (const t of [off, managed, stranger]) expect(t.service.attach).not.toHaveBeenCalled();
const managedWithAssistant = make({ managed: true, managedAssistant: true });
await managedWithAssistant.controller.attach(user, '5', file('a.pdf'), BODY, res);
expect(managedWithAssistant.service.attach).toHaveBeenCalledOnce();
});
it('ASTATT-003: a missing, too large or unknown file is refused before the turn', async () => {