MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / useExtensionHost

Function useExtensionHost

apps/cli/src/ui/hooks/useExtensionHost.ts:65–239  ·  view source on GitHub ↗
({
	initialPrompt,
	initialTaskId,
	initialSessionId,
	continueSession,
	mode,
	reasoningEffort,
	user,
	provider,
	apiKey,
	model,
	workspacePath,
	extensionPath,
	nonInteractive,
	ephemeral,
	debug,
	exitOnComplete,
	onExtensionMessage,
	createExtensionHost,
}: UseExtensionHostOptions)

Source from the content-addressed store, hash-verified

63 * - Expose methods for sending messages and running tasks
64 */
65export function useExtensionHost({
66 initialPrompt,
67 initialTaskId,
68 initialSessionId,
69 continueSession,
70 mode,
71 reasoningEffort,
72 user,
73 provider,
74 apiKey,
75 model,
76 workspacePath,
77 extensionPath,
78 nonInteractive,
79 ephemeral,
80 debug,
81 exitOnComplete,
82 onExtensionMessage,
83 createExtensionHost,
84}: UseExtensionHostOptions): UseExtensionHostReturn {
85 const { exit } = useApp()
86 const { addMessage, setComplete, setLoading, setHasStartedTask, setError, setCurrentTaskId, setIsResumingTask } =
87 useCLIStore()
88
89 const hostRef = useRef<ExtensionHostInterface | null>(null)
90 const isReadyRef = useRef(false)
91 const pendingInitialTaskIdRef = useRef<string | undefined>(initialTaskId?.trim() || undefined)
92
93 const cleanup = useCallback(async () => {
94 if (hostRef.current) {
95 await hostRef.current.dispose()
96 hostRef.current = null
97 isReadyRef.current = false
98 }
99 }, [])
100
101 useEffect(() => {
102 const init = async () => {
103 try {
104 const requestedSessionId = initialSessionId?.trim()
105 let taskHistorySnapshot: HistoryItem[] = []
106 let hasReceivedTaskHistory = false
107
108 const host = createExtensionHost({
109 mode,
110 user,
111 reasoningEffort,
112 provider,
113 apiKey,
114 model,
115 workspacePath,
116 extensionPath,
117 nonInteractive,
118 ephemeral,
119 debug,
120 exitOnComplete,
121 disableOutput: true,
122 })

Callers 1

AppInnerFunction · 0.85

Calls 6

initFunction · 0.85
rejectMethod · 0.80
disposeMethod · 0.65
sendToExtensionMethod · 0.65
runTaskMethod · 0.65
cleanupFunction · 0.50

Tested by

no test coverage detected