|
1 | 1 | import { createLogger } from '@sim/logger' |
2 | 2 | import { getErrorMessage } from '@sim/utils/errors' |
3 | 3 | import { generateId } from '@sim/utils/id' |
4 | | -import { omit } from '@sim/utils/object' |
| 4 | +import { omit, toArray } from '@sim/utils/object' |
5 | 5 | import { asOrchestrationError } from '@/lib/core/orchestration/types' |
6 | 6 | import { executeCopilotProjectDiscovery } from '@/lib/mothership/application/execute-project-use-case' |
7 | 7 | import { |
@@ -35,13 +35,14 @@ export async function withFileOwnerContext( |
35 | 35 | const clean = omit(payload, ['project', 'fileOwnerCapabilities', 'fileOwnerProtocolVersion']) |
36 | 36 | if (!['/api/copilot', '/api/mothership'].includes(route)) return clean |
37 | 37 | const admitted = context.requestMode !== 'assistant' && hasCopilotResourceAdmission(context) |
38 | | - const declared = (Array.isArray(clean.clientCapabilities) ? clean.clientCapabilities : []).filter( |
| 38 | + const declared = toArray(clean.clientCapabilities).filter( |
39 | 39 | (capability) => capability !== WORKSPACE_FILE_COPY_CAPABILITY |
40 | 40 | ) |
41 | | - const turn = { |
42 | | - ...clean, |
43 | | - clientCapabilities: admitted ? [...declared, WORKSPACE_FILE_COPY_CAPABILITY] : declared, |
44 | | - } |
| 41 | + const turn = admitted |
| 42 | + ? { ...clean, clientCapabilities: [...declared, WORKSPACE_FILE_COPY_CAPABILITY] } |
| 43 | + : clean.clientCapabilities === undefined |
| 44 | + ? clean |
| 45 | + : { ...clean, clientCapabilities: declared } |
45 | 46 | if (!admitted || !(await isProjectsEnabled()) || !(await supportsFileOwnerProtocol(baseURL))) |
46 | 47 | return turn |
47 | 48 |
|
|
0 commit comments