Skip to content

Commit e34b3d8

Browse files
committed
fix(mothership): keep a turn's payload shape unless it declares workspace copies
1 parent e7fdc69 commit e34b3d8

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎apps/sim/lib/mothership/application/file-owner-context.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createLogger } from '@sim/logger'
22
import { getErrorMessage } from '@sim/utils/errors'
33
import { generateId } from '@sim/utils/id'
4-
import { omit } from '@sim/utils/object'
4+
import { omit, toArray } from '@sim/utils/object'
55
import { asOrchestrationError } from '@/lib/core/orchestration/types'
66
import { executeCopilotProjectDiscovery } from '@/lib/mothership/application/execute-project-use-case'
77
import {
@@ -35,13 +35,14 @@ export async function withFileOwnerContext(
3535
const clean = omit(payload, ['project', 'fileOwnerCapabilities', 'fileOwnerProtocolVersion'])
3636
if (!['/api/copilot', '/api/mothership'].includes(route)) return clean
3737
const admitted = context.requestMode !== 'assistant' && hasCopilotResourceAdmission(context)
38-
const declared = (Array.isArray(clean.clientCapabilities) ? clean.clientCapabilities : []).filter(
38+
const declared = toArray(clean.clientCapabilities).filter(
3939
(capability) => capability !== WORKSPACE_FILE_COPY_CAPABILITY
4040
)
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 }
4546
if (!admitted || !(await isProjectsEnabled()) || !(await supportsFileOwnerProtocol(baseURL)))
4647
return turn
4748

‎apps/sim/lib/projects/files/__integration__/authorization-product.integration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ describe('Mothership origin navigation and independent Project authority', () =>
419419
workerURL,
420420
'/api/mothership'
421421
)
422-
).toEqual({ message: 'hello', clientCapabilities: [] })
422+
).toEqual({ message: 'hello' })
423423
expect(
424424
await withFileOwnerContext(forged, context(f), workerURL, '/api/tools/resume')
425425
).toEqual({ message: 'hello' })

0 commit comments

Comments
 (0)