mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
* test: define Grok Build integration behavior * feat: add Grok Build agent integration * test: cover Grok permissions and resume paths * docs: add Grok Build setup guide * fix: scope Grok ACP discovery to session cwd * fix: align Grok permission UI semantics * docs: clarify Grok runner setup * test: require Grok create model and effort options * feat: add Grok create model and effort pickers * test: define Grok runtime parity behavior * feat: add Grok runtime ACP controls and discovery * fix: tighten Grok runtime controls * fix: suppress nonfatal Grok title quota errors * feat: support Grok Auto permission mode * feat: forward ACP native session titles for Grok * fix: guard Grok Windows shell arguments
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
import type { AgentFlavor, PermissionMode } from '@hapi/protocol'
|
|
import type { ApiClient } from '@/api/client'
|
|
import type { SpawnResponse } from '@/types/api'
|
|
import { queryKeys } from '@/lib/query-keys'
|
|
|
|
type SpawnInput = {
|
|
machineId: string
|
|
directory: string
|
|
agent?: AgentFlavor
|
|
model?: string
|
|
effort?: string
|
|
modelReasoningEffort?: string
|
|
yolo?: boolean
|
|
permissionMode?: PermissionMode
|
|
sessionType?: 'simple' | 'worktree'
|
|
worktreeName?: string
|
|
}
|
|
|
|
export function useSpawnSession(api: ApiClient | null): {
|
|
spawnSession: (input: SpawnInput) => Promise<SpawnResponse>
|
|
isPending: boolean
|
|
error: string | null
|
|
} {
|
|
const queryClient = useQueryClient()
|
|
|
|
const mutation = useMutation({
|
|
mutationFn: async (input: SpawnInput) => {
|
|
if (!api) {
|
|
throw new Error('API unavailable')
|
|
}
|
|
return await api.spawnSession(
|
|
input.machineId,
|
|
input.directory,
|
|
input.agent,
|
|
input.model,
|
|
input.modelReasoningEffort,
|
|
input.yolo,
|
|
input.sessionType,
|
|
input.worktreeName,
|
|
input.effort,
|
|
input.permissionMode
|
|
)
|
|
},
|
|
onSuccess: () => {
|
|
void queryClient.invalidateQueries({ queryKey: queryKeys.sessions })
|
|
},
|
|
})
|
|
|
|
return {
|
|
spawnSession: mutation.mutateAsync,
|
|
isPending: mutation.isPending,
|
|
error: mutation.error instanceof Error ? mutation.error.message : mutation.error ? 'Failed to spawn session' : null,
|
|
}
|
|
}
|