Skip to content

Commit 48b77a0

Browse files
committed
fix(computer-use): authorize app commands in the server use case and route contract
1 parent 242e418 commit 48b77a0

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎apps/sim/lib/api/contracts/computer-use.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComputerUseSchema } from '@sim/desktop-bridge/computer-use'
1+
import { ComputerUseWithAppCommandsSchema } from '@sim/desktop-bridge/computer-use'
22
import { z } from 'zod'
33
import { desktopToolCallIdSchema } from '@/lib/api/contracts/desktop-tool-authorization'
44
import { organizationIdSchema, workspaceIdSchema } from '@/lib/api/contracts/primitives'
@@ -8,7 +8,7 @@ const authorizeComputerUseBodySchema = z.object({ toolCallId: desktopToolCallIdS
88
const authorizeComputerUseResponseSchema = z
99
.object({
1010
toolName: z.literal('computer'),
11-
args: ComputerUseSchema,
11+
args: ComputerUseWithAppCommandsSchema,
1212
chatId: z.string().min(1),
1313
})
1414
.strict()

‎apps/sim/lib/computer-use/application/authorize.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ describe('native computer authorization', () => {
7575
chatId: 'chat-1',
7676
})
7777
})
78+
it('returns a claimed app command to the desktop', async () => {
79+
const command = { name: 'create_reminder', title: 'Pay rent' }
80+
mocks.claim.mockResolvedValue({ args: { action: 'app_command', command } })
81+
await expect(authorizeComputerUse.execute({ principal, input })).resolves.toMatchObject({
82+
args: { action: 'app_command', command },
83+
})
84+
})
7885
it('rejects non-session principals before protected loading', async () => {
7986
await expect(
8087
authorizeComputerUse.execute({

‎apps/sim/lib/computer-use/application/authorize.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { SessionPrincipal } from '@sim/auth/principal'
2-
import { ComputerUseSchema } from '@sim/desktop-bridge/computer-use'
2+
import { ComputerUseWithAppCommandsSchema } from '@sim/desktop-bridge/computer-use'
33
import { claimComputerUseTool } from '@/lib/computer-use/repository'
44
import { defineOrganizationOperation } from '@/lib/core/application/organization-operation'
55
import { defineWorkspaceOperation } from '@/lib/core/application/workspace-operation'
@@ -72,7 +72,7 @@ export const authorizeComputerUse = defineAuthorizedChatUseCase({
7272
)
7373
return {
7474
toolName: 'computer' as const,
75-
args: ComputerUseSchema.parse(claimed.args),
75+
args: ComputerUseWithAppCommandsSchema.parse(claimed.args),
7676
chatId: context.chatId,
7777
}
7878
},

0 commit comments

Comments
 (0)