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
@@ -24,6 +24,9 @@ const NOT_OPERATOR_SETTINGS: Record<string, string> = {
APP_VERSION: 'set by the image build; the VERSION file wins over it',
TREK_DB_FILE: 'points the Playwright harness at a throwaway database',
TREK_MANAGED: 'managed hosting only, deliberately undocumented for self-hosters',
TREK_MANAGED_ASSISTANT_URL: 'managed hosting only, the operator gateway URL',
TREK_MANAGED_ASSISTANT_TOKEN: 'managed hosting only, the instance credential for the operator gateway',
TREK_MANAGED_ASSISTANT_MODEL: 'managed hosting only, the operator-selected assistant model',
MAPBOX_ACCESS_TOKEN: 'managed hosting only (read with TREK_MANAGED), deliberately undocumented for self-hosters',
CARTO_API_KEY: 'managed hosting only (read with TREK_MANAGED), deliberately undocumented for self-hosters',
PLACES_API_BASE: "managed hosting's egress gateway for the Places calls, deliberately undocumented for self-hosters",
@@ -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 () => {