The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
/*
* Copyright 2026 BoxLite AI
* SPDX-License-Identifier: AGPL-3.0
*/
import { queryKeys } from '@/hooks/queries/queryKeys'
import { useApi } from '@/hooks/useApi'
import { useSelectedOrganization } from '@/hooks/useSelectedOrganization'
import { NetworkMode } from '@boxlite-ai/api-client'
import { useMutation, useQueryClient } from '@tanstack/react-query'
interface UpdateBoxInboundVariables {
boxId: string
mode: NetworkMode
signal?: AbortSignal
}
/**
* Enables or disables inbound access: whether the services a box exposes are
* reachable through the proxy under each tunnel's access policy (public
* tunnels need no sign-in; private ones need their token or membership).
*
* Invalidating the box detail query is the point: `network` lives on the box
* record, so the detail sheet has to re-read it before it can show the new
* mode. Kept here with the other box mutations rather than inline in the
* network section, so cache invalidation is defined once per resource.
*/
export const useUpdateBoxInboundMutation = () => {
const api = useApi()
const { selectedOrganization } = useSelectedOrganization()
const queryClient = useQueryClient()
return useMutation({
mutationFn: async ({ boxId, mode, signal }: UpdateBoxInboundVariables) => {
if (!selectedOrganization?.id) throw new Error('Missing organization')
await api.setBoxInboundMode(selectedOrganization.id, boxId, mode, signal)
},
onSuccess: (_, { boxId }) => {
queryClient.invalidateQueries({
queryKey: queryKeys.boxes.detail(selectedOrganization?.id ?? '', boxId),
})
},
})
}