@agents24/chat-react 0.5.46 → 0.5.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -1
- package/dist/{chunk-YRUYJFPJ.js → chunk-3UKX2RRE.js} +2 -5
- package/dist/chunk-3UKX2RRE.js.map +1 -0
- package/dist/generated/run-usage.d.ts +2 -0
- package/dist/index.cjs +1 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/registry/agents24-chat.json +16 -16
- package/dist/runtime/index.cjs +7 -1
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.js +7 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/use-agent-chat-runtime.d.ts +7 -0
- package/dist/scaffold/app.d.ts +5 -3
- package/dist/scaffold/components/chat/chat-composer.d.ts +4 -2
- package/dist/scaffold/components/chat/chat-message.d.ts +3 -2
- package/dist/scaffold/components/chat/chat-shell.d.ts +3 -2
- package/dist/scaffold/components/chat/message-parts.d.ts +3 -2
- package/dist/scaffold/index.cjs +284 -384
- package/dist/scaffold/index.cjs.map +1 -1
- package/dist/scaffold/index.d.ts +1 -1
- package/dist/scaffold/index.js +267 -366
- package/dist/scaffold/index.js.map +1 -1
- package/dist/styles.css +41 -5
- package/dist/ui/agent-chat-composer.d.ts +4 -1
- package/dist/ui/agent-chat-message.d.ts +3 -1
- package/dist/ui/agent-response-timeline.d.ts +3 -2
- package/dist/ui/attachment-text.d.ts +14 -0
- package/dist/ui/bubble.d.ts +1 -1
- package/dist/ui/completed-tool-activity.d.ts +36 -0
- package/dist/ui/composer-attachments.d.ts +2 -0
- package/dist/ui/index.cjs +2412 -1439
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +2340 -1371
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/message-response.d.ts +1 -1
- package/dist/ui/microphone-input.d.ts +24 -0
- package/dist/ui/pcm-capture.d.ts +14 -0
- package/dist/ui/realtime-dictation.d.ts +30 -0
- package/dist/ui/tool-sessions.d.ts +18 -2
- package/dist/ui/use-agent-chat-composer.d.ts +7 -2
- package/dist/ui/use-agent-chat-dictation.d.ts +65 -0
- package/dist/ui/voice-dictation.d.ts +32 -0
- package/package.json +5 -4
- package/scaffold/src/app.tsx +13 -4
- package/scaffold/src/chat.css +0 -1
- package/scaffold/src/components/chat/chat-composer.tsx +29 -25
- package/scaffold/src/components/chat/chat-message.tsx +4 -1
- package/scaffold/src/components/chat/chat-shell.tsx +8 -3
- package/scaffold/src/components/chat/external-link-dialog.tsx +30 -20
- package/scaffold/src/components/chat/message-parts.tsx +4 -1
- package/scaffold/src/index.tsx +1 -0
- package/dist/chunk-YRUYJFPJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/use-agent-chat-runtime.ts","../../src/runtime/use-agent-chat-hitl.ts","../../src/runtime/use-delegation-tasks.ts"],"sourcesContent":["import type {\n AgentClient,\n Agents24ClientError,\n ClientBootstrap,\n EffectiveResourcePolicy,\n HitlResponse,\n PortableUpload,\n} from \"@agents24/client\";\nimport type { ContextCompression, ContextWindow } from \"@agents24/client/protocol\";\nimport {\n type AgentChatController,\n type ChatAttachment,\n type ChatHitlPart,\n type HitlSubmissionOptions,\n type HitlSubmissionState,\n useAgentAttachments,\n useAgentChat,\n} from \"@agents24/react\";\nimport * as React from \"react\";\n\nimport { useAgentChatHitl } from \"./use-agent-chat-hitl\";\nimport type { ChatMcpOauthCompletion } from \"../types\";\nimport { validateAgentChatSubmission } from \"./input-contract\";\n\nexport type AgentChatRuntimeAgent = {\n name: string;\n description?: string | null;\n handle?: string | null;\n avatarUrl?: string | null;\n};\n\nexport type AgentChatRuntimeModel = {\n id: string;\n label: string;\n};\n\nexport type AgentChatRuntimeAgentOption = { id: string; label: string };\n\nexport type AgentChatRuntimeViewState =\n | \"ready\"\n | \"loading\"\n | \"uploading\"\n | \"streaming\"\n | \"reconnecting\"\n | \"paused\"\n | \"cancelling\"\n | \"cancelled\"\n | \"offline\"\n | \"denied\"\n | \"quota\"\n | \"failed\"\n | \"expired\";\n\nexport type AgentChatRuntimeConnectionState =\n | \"connected\"\n | \"connecting\"\n | \"reconnecting\"\n | \"offline\"\n | \"expired\";\n\nexport type AgentChatThreadChangeReason = \"created\" | \"opened\" | \"new\" | \"deleted\";\n\nexport type AgentChatActiveThreadChange = {\n threadId: string | null;\n reason: AgentChatThreadChangeReason;\n};\n\nexport type AgentChatActiveThreadChangeHandler = (\n change: AgentChatActiveThreadChange,\n) => void;\n\nexport type AgentChatMcpAuthorizationCompletion = (input: {\n completion: ChatMcpOauthCompletion;\n codeVerifier: string;\n serverId: string;\n}) => Promise<void>;\n\nexport type AgentChatRuntimeSubmit = {\n text: string;\n files?: readonly PortableUpload[];\n attachments?: ChatAttachment[];\n attachmentIds?: readonly string[];\n};\n\nexport type AgentChatRuntimeHitlActionState = Omit<HitlSubmissionState, \"status\"> & {\n status: HitlSubmissionState[\"status\"] | \"connecting\" | \"resuming\";\n};\n\nexport type UseAgentChatRuntimeOptions = {\n activeThreadId?: string | null;\n agent?: AgentChatRuntimeAgent;\n client: AgentClient;\n completeMcpAuthorization?: AgentChatMcpAuthorizationCompletion;\n mcpRedirectUri?: string;\n modelId?: string | null;\n onActiveThreadIdChange?: AgentChatActiveThreadChangeHandler;\n onModelChange?: (modelId: string) => void;\n};\n\nexport type AgentChatRuntime = {\n agent: AgentChatRuntimeAgent;\n inputContract: ClientBootstrap[\"features\"][\"inputs\"] | null;\n allowFeedback: boolean;\n isReadOnly: boolean;\n backgroundError: unknown;\n bootstrap: ClientBootstrap | null;\n capabilities: readonly string[];\n agentId: string | null;\n agents: AgentChatRuntimeAgentOption[];\n changeAgent(agentId: string): Promise<void>;\n changeModel(modelId: string): void;\n clearOperationError(): void;\n connectionState: AgentChatRuntimeConnectionState;\n contextWindow: ContextWindow | null;\n contextCompression: ContextCompression | null;\n controller: AgentChatController;\n deleteThread(threadId: string): Promise<void>;\n errorMessage: string | null;\n fatalError: unknown;\n getHitlActionState(part: ChatHitlPart): AgentChatRuntimeHitlActionState | undefined;\n isBootstrapping: boolean;\n isChangingAgent: boolean;\n isSubmitting: boolean;\n isUploading: boolean;\n modelId: string | null;\n models: AgentChatRuntimeModel[];\n newThread(): void;\n onHitlAction(part: ChatHitlPart, response: HitlResponse, options?: HitlSubmissionOptions): Promise<void>;\n openThread(threadId: string): Promise<void>;\n operationError: unknown;\n retryBootstrap(): Promise<void>;\n resolveAttachmentContent(\n attachment: ChatAttachment,\n signal: AbortSignal,\n ): Promise<{ url: string; validUntil: string | null }>;\n state: AgentChatRuntimeViewState;\n submit(input: AgentChatRuntimeSubmit): Promise<void>;\n};\n\ntype PendingThreadTransition = {\n reason: \"opened\" | \"deleted\";\n value: string | null;\n};\n\nexport function agentChatRuntimeStateFromError(error: unknown): AgentChatRuntimeViewState {\n const typed = error as Partial<Agents24ClientError> | null;\n if (typed?.kind === \"authentication\") return \"expired\";\n if (typed?.kind === \"authorization\") return \"denied\";\n if (typed?.kind === \"quota\" || typed?.kind === \"rate_limit\") return \"quota\";\n if (typed?.kind === \"network\") return \"offline\";\n return \"failed\";\n}\n\nexport function agentChatRuntimeErrorMessage(error: unknown): string | null {\n if (!error) return null;\n return error instanceof Error ? error.message : String(error);\n}\n\nexport function canChangeAgentRuntime(\n runState: AgentChatController[\"runState\"],\n activeRunId: string | null,\n): boolean {\n return !activeRunId && ![\"uploading\", \"streaming\", \"reconnecting\", \"paused\", \"cancelling\"].includes(runState);\n}\n\nexport function agentIdFromBootstrap(\n bootstrap: ClientBootstrap,\n requestedAgentId: string | null,\n): string | null {\n const feature = bootstrap.features.agents;\n if (!feature) return null;\n return feature.options.some((item) => item.id === requestedAgentId)\n ? requestedAgentId\n : feature.default_id || null;\n}\n\nexport function modelsFromAgentChatBootstrap(bootstrap: ClientBootstrap): {\n defaultModelId: string | null;\n models: AgentChatRuntimeModel[];\n} {\n const modelFeatures = bootstrap.features.models;\n const selectable = bootstrap.capabilities.includes(\"models.select\") && modelFeatures?.selectable === true;\n if (!selectable) return { defaultModelId: null, models: [] };\n const models = Array.isArray(modelFeatures.options)\n ? modelFeatures.options.flatMap((option) => (\n typeof option?.id === \"string\" && option.id.trim()\n ? [{ id: option.id, label: typeof option.label === \"string\" && option.label.trim() ? option.label : option.id }]\n : []\n ))\n : [];\n const configuredDefault = models.some((model) => model.id === modelFeatures.default_id)\n ? modelFeatures.default_id\n : null;\n return {\n defaultModelId: configuredDefault,\n models,\n };\n}\n\nfunction modelsFromEffectivePolicy(policy: EffectiveResourcePolicy): {\n defaultModelId: string | null;\n models: AgentChatRuntimeModel[];\n} {\n const models = policy.model_selection.selectable\n ? policy.model_selection.options.map((option) => ({ id: option.id, label: option.label }))\n : [];\n return {\n defaultModelId: models.some((model) => model.id === policy.model_selection.default_id)\n ? policy.model_selection.default_id\n : null,\n models,\n };\n}\n\nexport function useAgentChatRuntime(options: UseAgentChatRuntimeOptions): AgentChatRuntime {\n const {\n activeThreadId,\n agent: agentOverride,\n client,\n completeMcpAuthorization,\n mcpRedirectUri,\n modelId,\n onActiveThreadIdChange,\n onModelChange,\n } = options;\n const controller = useAgentChat(\n activeThreadId === undefined ? { client } : { activeThreadId, client },\n );\n const attachments = useAgentAttachments();\n const bootstrapOwnerRef = React.useRef<AgentClient | null>(null);\n const [bootstrapState, setBootstrap] = React.useState<ClientBootstrap | null>(null);\n const bootstrap = bootstrapOwnerRef.current === client ? bootstrapState : null;\n const bootstrapRef = React.useRef<ClientBootstrap | null>(bootstrap);\n bootstrapRef.current = bootstrap;\n const [effectivePolicyState, setEffectivePolicy] = React.useState<EffectiveResourcePolicy | null>(null);\n const effectivePolicy = bootstrapOwnerRef.current === client ? effectivePolicyState : null;\n const [isBootstrapping, setIsBootstrapping] = React.useState(true);\n const [bootstrapError, setBootstrapError] = React.useState<unknown>(null);\n const [localOperationError, setLocalOperationError] = React.useState<unknown>(null);\n const [selectedModelId, setSelectedModelId] = React.useState<string | null>(modelId ?? null);\n const selectedModelIdRef = React.useRef<string | null>(selectedModelId);\n selectedModelIdRef.current = selectedModelId;\n const [selectedAgentId, setSelectedAgentId] = React.useState<string | null>(null);\n const selectedAgentIdRef = React.useRef<string | null>(null);\n selectedAgentIdRef.current = selectedAgentId;\n const [isChangingAgent, setIsChangingAgent] = React.useState(false);\n const agentChangePromiseRef = React.useRef<Promise<void> | null>(null);\n const [isSubmitting, setIsSubmitting] = React.useState(false);\n const submitPromiseRef = React.useRef<Promise<void> | null>(null);\n\n const mountedRef = React.useRef(true);\n const clientRef = React.useRef(client);\n clientRef.current = client;\n const bootstrapRetryRef = React.useRef(0);\n const bootstrapPromiseRef = React.useRef<{ client: AgentClient; promise: Promise<void> } | null>(null);\n React.useEffect(() => {\n mountedRef.current = true;\n return () => { mountedRef.current = false; };\n }, []);\n\n const previousControlledThreadRef = React.useRef(activeThreadId);\n const threadSelectionGenerationRef = React.useRef(0);\n const controlledSyncTargetRef = React.useRef<{ value: string | null } | null>(null);\n const previousControllerThreadRef = React.useRef(controller.activeThreadId);\n const pendingThreadTransitionRef = React.useRef<PendingThreadTransition | null>(null);\n const lastReportedThreadRef = React.useRef<string | null>(activeThreadId ?? controller.activeThreadId);\n if (activeThreadId !== previousControlledThreadRef.current) {\n threadSelectionGenerationRef.current += 1;\n previousControlledThreadRef.current = activeThreadId;\n if (activeThreadId !== undefined) {\n controlledSyncTargetRef.current = { value: activeThreadId };\n lastReportedThreadRef.current = activeThreadId;\n }\n }\n\n const reportActiveThread = React.useCallback((\n threadId: string | null,\n reason: AgentChatThreadChangeReason,\n ) => {\n if (lastReportedThreadRef.current === threadId) return;\n lastReportedThreadRef.current = threadId;\n onActiveThreadIdChange?.({ threadId, reason });\n }, [onActiveThreadIdChange]);\n\n const retryBootstrap = React.useCallback((): Promise<void> => {\n if (bootstrapPromiseRef.current?.client === client) return bootstrapPromiseRef.current.promise;\n const requestClient = client;\n const request = (async () => {\n if (mountedRef.current) {\n const identityChanged = bootstrapOwnerRef.current !== requestClient;\n setIsBootstrapping(identityChanged || !bootstrapRef.current);\n setBootstrapError(null);\n if (identityChanged) {\n setBootstrap(null);\n setEffectivePolicy(null);\n setSelectedAgentId(null);\n setSelectedModelId(null);\n }\n }\n try {\n const requestedAgentId = selectedAgentIdRef.current;\n const result = await requestClient.bootstrap({ agentId: requestedAgentId || undefined });\n if (!mountedRef.current || clientRef.current !== requestClient) return;\n bootstrapOwnerRef.current = requestClient;\n bootstrapRetryRef.current = 0;\n setBootstrap(result);\n const agentFeature = result.features.agents;\n const resolvedAgentId = agentIdFromBootstrap(result, requestedAgentId);\n setSelectedAgentId(resolvedAgentId);\n const entitlement = agentFeature ? null : await requestClient.resourcePolicies.getEffective();\n if (!mountedRef.current || clientRef.current !== requestClient) return;\n setEffectivePolicy(entitlement);\n const availableModels = entitlement ? modelsFromEffectivePolicy(entitlement) : modelsFromAgentChatBootstrap(result);\n if (modelId === undefined) {\n setSelectedModelId((current) => availableModels.models.some((item) => item.id === current)\n ? current\n : availableModels.defaultModelId);\n }\n void controller.refreshThreads().catch(() => undefined);\n } catch (error) {\n if (mountedRef.current && clientRef.current === requestClient) {\n const status = (error as Agents24ClientError)?.status;\n if (status === 401 || status === 403 || status === 404) {\n setBootstrap(null);\n setEffectivePolicy(null);\n bootstrapOwnerRef.current = null;\n }\n setBootstrapError(error);\n }\n } finally {\n if (mountedRef.current && clientRef.current === requestClient) setIsBootstrapping(false);\n }\n })();\n bootstrapPromiseRef.current = { client: requestClient, promise: request };\n void request.finally(() => {\n if (bootstrapPromiseRef.current?.promise === request) bootstrapPromiseRef.current = null;\n });\n return request;\n }, [client, controller.refreshThreads, modelId]);\n\n React.useEffect(() => {\n if (!bootstrapError || bootstrapRetryRef.current >= 4) return;\n const error = bootstrapError as Agents24ClientError;\n if (!(error.retryable || error.kind === \"network\" || (error.status || 0) >= 500)) return;\n const attempt = bootstrapRetryRef.current++;\n const hint = error.retryAfterMs;\n const delay = Math.max(500 * 2 ** attempt + Math.random() * 250,\n typeof hint === \"number\" && Number.isFinite(hint) && hint >= 0 ? Math.min(hint, 60_000) : 0);\n const timer = setTimeout(() => { void retryBootstrap(); }, delay);\n return () => clearTimeout(timer);\n }, [bootstrapError, retryBootstrap]);\n\n const refreshEffectivePolicy = React.useCallback(async () => {\n if (bootstrap?.features.agents) {\n const refreshed = await client.bootstrap({ agentId: selectedAgentIdRef.current || undefined });\n if (!mountedRef.current || clientRef.current !== client) return;\n setBootstrap(refreshed);\n const available = modelsFromAgentChatBootstrap(refreshed);\n setSelectedModelId((current) => available.models.some((item) => item.id === current)\n ? current\n : available.defaultModelId);\n return;\n }\n const entitlement = await client.resourcePolicies.getEffective();\n if (!mountedRef.current || clientRef.current !== client) return;\n setEffectivePolicy(entitlement);\n if (modelId === undefined) {\n const available = modelsFromEffectivePolicy(entitlement);\n setSelectedModelId((current) => available.models.some((item) => item.id === current)\n ? current\n : available.defaultModelId);\n }\n }, [bootstrap, client, modelId]);\n\n React.useEffect(() => {\n void retryBootstrap();\n }, [retryBootstrap]);\n\n React.useEffect(() => {\n if (modelId !== undefined) setSelectedModelId(modelId);\n }, [modelId]);\n\n React.useEffect(() => {\n if (controlledSyncTargetRef.current?.value === null && controller.activeThreadId) {\n controller.startNewThread();\n }\n }, [activeThreadId, controller.activeThreadId, controller.startNewThread]);\n\n React.useEffect(() => {\n const previous = previousControllerThreadRef.current;\n const current = controller.activeThreadId;\n previousControllerThreadRef.current = current;\n const controlledTarget = controlledSyncTargetRef.current;\n if (controlledTarget) {\n if (current === controlledTarget.value) controlledSyncTargetRef.current = null;\n return;\n }\n const pendingTransition = pendingThreadTransitionRef.current;\n if (pendingTransition && current === pendingTransition.value) return;\n if (previous === null && current !== null) reportActiveThread(current, \"created\");\n }, [activeThreadId, controller.activeThreadId, reportActiveThread]);\n\n const clearOperationError = React.useCallback(() => {\n setLocalOperationError(null);\n controller.clearOperationError();\n }, [controller.clearOperationError]);\n\n const submit = React.useCallback((input: AgentChatRuntimeSubmit): Promise<void> => {\n if (submitPromiseRef.current) return submitPromiseRef.current;\n clearOperationError();\n setIsSubmitting(true);\n const request = (async () => {\n try {\n if(controller.activeThread?.read_only)throw new Error(\"This conversation is read-only. Start a new chat.\");\n await agentChangePromiseRef.current;\n const activeBootstrap = bootstrapRef.current;\n if (!activeBootstrap) throw new Error(\"The agent input contract is unavailable.\");\n const retained = (input.attachments || []).filter((attachment) => input.attachmentIds?.includes(attachment.id || \"\"));\n const inputError = validateAgentChatSubmission(activeBootstrap.features.inputs, input.text, [\n ...(input.files || []),\n ...retained.map((attachment) => ({ data: new Uint8Array(), mediaType: attachment.mediaType || \"application/octet-stream\" })),\n ]);\n if (inputError) throw new Error(inputError);\n await controller.submit({\n text: input.text,\n attachments: input.attachments,\n uploads: input.files,\n attachmentIds: input.attachmentIds,\n requestedModelId: selectedModelIdRef.current || undefined,\n requestedAgentId: selectedAgentIdRef.current || undefined,\n });\n } catch (error) {\n setLocalOperationError(error);\n const typed = error as Partial<Agents24ClientError>;\n if (typed.kind === \"quota\" || typed.kind === \"authorization\") {\n await refreshEffectivePolicy().catch(() => undefined);\n }\n throw error;\n } finally {\n setIsSubmitting(false);\n }\n })();\n submitPromiseRef.current = request;\n const clearRequest = () => {\n if (submitPromiseRef.current === request) submitPromiseRef.current = null;\n };\n void request.then(clearRequest, clearRequest);\n return request;\n }, [bootstrap, clearOperationError, controller.activeThreadId, controller.activeThread?.read_only, controller.submit, refreshEffectivePolicy]);\n\n const { onHitlAction, getHitlActionState } = useAgentChatHitl({\n client, bootstrap, controller, selectionGeneration: threadSelectionGenerationRef,\n completeMcpAuthorization, mcpRedirectUri, clearOperationError, onError: setLocalOperationError,\n });\n\n const newThread = React.useCallback(() => {\n threadSelectionGenerationRef.current += 1;\n clearOperationError();\n pendingThreadTransitionRef.current = null;\n reportActiveThread(null, \"new\");\n controller.startNewThread();\n }, [clearOperationError, controller.startNewThread, reportActiveThread]);\n\n const openThread = React.useCallback(async (threadId: string) => {\n const requestGeneration = ++threadSelectionGenerationRef.current;\n clearOperationError();\n pendingThreadTransitionRef.current = { reason: \"opened\", value: threadId };\n try {\n const detail = await client.threads.get({ threadId });\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n const preferredAgentId = detail.runtime_selection?.agent_alias || detail.runtime_selection?.agent_id || null;\n if (preferredAgentId && !detail.read_only) {\n const result = await client.bootstrap({ agentId: preferredAgentId });\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n const resolvedAgentId = agentIdFromBootstrap(result, preferredAgentId);\n setBootstrap(result);\n setEffectivePolicy(null);\n setSelectedAgentId(resolvedAgentId);\n const available = modelsFromAgentChatBootstrap(result);\n const preferredModelId = detail.runtime_selection?.model_id || null;\n setSelectedModelId(available.models.some((item) => item.id === preferredModelId)\n ? preferredModelId\n : available.defaultModelId);\n }\n await controller.openThread(threadId);\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n reportActiveThread(threadId, \"opened\");\n } catch (error) {\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n setLocalOperationError(error);\n throw error;\n } finally {\n if (requestGeneration === threadSelectionGenerationRef.current) pendingThreadTransitionRef.current = null;\n }\n }, [clearOperationError, client, controller.openThread, reportActiveThread]);\n\n const deleteThread = React.useCallback(async (threadId: string) => {\n clearOperationError();\n const wasActive = controller.activeThreadId === threadId;\n if (wasActive) threadSelectionGenerationRef.current += 1;\n if (wasActive) pendingThreadTransitionRef.current = { reason: \"deleted\", value: null };\n try {\n await controller.deleteThread(threadId);\n if (wasActive) reportActiveThread(null, \"deleted\");\n } catch (error) {\n setLocalOperationError(error);\n throw error;\n } finally {\n if (wasActive && pendingThreadTransitionRef.current?.reason === \"deleted\") {\n pendingThreadTransitionRef.current = null;\n }\n }\n }, [clearOperationError, controller.activeThreadId, controller.deleteThread, reportActiveThread]);\n\n const changeModel = React.useCallback((nextModelId: string) => {\n if (modelId === undefined) setSelectedModelId(nextModelId);\n onModelChange?.(nextModelId);\n if (controller.activeThreadId && selectedAgentId && client.threads.setRuntimeSelection) {\n void client.threads.setRuntimeSelection({\n threadId: controller.activeThreadId,\n preferredAgentId: selectedAgentId,\n preferredModelId: nextModelId,\n }).catch(setLocalOperationError);\n }\n }, [client.threads, controller.activeThreadId, modelId, onModelChange, selectedAgentId]);\n\n const resolveAttachmentContent = React.useCallback(async (\n attachment: ChatAttachment,\n signal: AbortSignal,\n ) => {\n const attachmentId = typeof attachment.id === \"string\" ? attachment.id.trim() : \"\";\n if (!attachmentId) throw new Error(\"Attachment content identity is unavailable.\");\n const access = await attachments.createContentAccess({\n attachmentId,\n disposition: \"inline\",\n signal,\n });\n return { url: access.url, validUntil: access.valid_until || null };\n }, [attachments.createContentAccess]);\n\n const changeAgent = React.useCallback((nextAgentId: string): Promise<void> => {\n if (agentChangePromiseRef.current) return agentChangePromiseRef.current;\n if (\n nextAgentId === selectedAgentIdRef.current\n || !canChangeAgentRuntime(controller.runState, controller.activeRunId)\n ) return Promise.resolve();\n clearOperationError();\n setIsChangingAgent(true);\n const request = (async () => {\n try {\n const result = await client.bootstrap({ agentId: nextAgentId });\n const resolvedAgentId = agentIdFromBootstrap(result, nextAgentId);\n if (!resolvedAgentId) throw new Error(\"The requested Agent is no longer available.\");\n const available = modelsFromAgentChatBootstrap(result);\n const currentModelId = selectedModelIdRef.current;\n const nextModelId = available.models.some((item) => item.id === currentModelId)\n ? currentModelId\n : available.defaultModelId;\n if (controller.activeThreadId && client.threads.setRuntimeSelection) {\n const persisted = await client.threads.setRuntimeSelection({\n threadId: controller.activeThreadId,\n preferredAgentId: resolvedAgentId,\n preferredModelId: nextModelId,\n });\n selectedModelIdRef.current = persisted.runtime_selection.model_id;\n setSelectedModelId(persisted.runtime_selection.model_id);\n } else {\n selectedModelIdRef.current = nextModelId;\n setSelectedModelId(nextModelId);\n }\n selectedAgentIdRef.current = resolvedAgentId;\n bootstrapRef.current = result;\n setSelectedAgentId(resolvedAgentId);\n setBootstrap(result);\n setEffectivePolicy(null);\n } catch (error) {\n setLocalOperationError(error);\n throw error;\n }\n })();\n agentChangePromiseRef.current = request;\n const clearRequest = () => {\n if (agentChangePromiseRef.current === request) agentChangePromiseRef.current = null;\n if (mountedRef.current) setIsChangingAgent(false);\n };\n void request.then(clearRequest, clearRequest);\n return request;\n }, [clearOperationError, client, controller.activeRunId, controller.activeThreadId, controller.runState]);\n\n const modelOptions = effectivePolicy\n ? modelsFromEffectivePolicy(effectivePolicy).models\n : bootstrap\n ? modelsFromAgentChatBootstrap(bootstrap).models\n : [];\n const fatalError = (!bootstrap ? bootstrapError : null) || controller.error;\n const operationError = localOperationError || controller.operationError?.cause;\n const state: AgentChatRuntimeViewState = isBootstrapping\n ? \"loading\"\n : fatalError\n ? agentChatRuntimeStateFromError(fatalError)\n : controller.runState === \"uploading\"\n ? \"uploading\"\n : controller.runState === \"streaming\"\n ? \"streaming\"\n : controller.runState === \"reconnecting\"\n ? \"reconnecting\"\n : controller.runState === \"paused\"\n ? \"paused\"\n : controller.runState === \"cancelling\"\n ? \"cancelling\"\n : controller.runState === \"cancelled\"\n ? \"cancelled\"\n : \"ready\";\n const connectionState: AgentChatRuntimeConnectionState = bootstrapError && bootstrap ? \"reconnecting\" : state === \"offline\"\n ? \"offline\"\n : state === \"expired\"\n ? \"expired\"\n : state === \"reconnecting\"\n ? \"reconnecting\"\n : isBootstrapping\n ? \"connecting\"\n : \"connected\";\n return {\n agent: agentOverride || { name: bootstrap?.deployment.name || \"Agent\" },\n inputContract: bootstrap?.features.inputs || null,\n allowFeedback: Boolean(bootstrap?.capabilities.includes(\"feedback.write\")) && !controller.activeThread?.read_only,\n isReadOnly:controller.activeThread?.read_only===true,\n backgroundError: (bootstrap && bootstrapError) || controller.backgroundError?.cause || null,\n bootstrap,\n capabilities: bootstrap?.capabilities || [],\n agentId: bootstrap ? selectedAgentId : null,\n agents: bootstrap?.features.agents?.options.map((item) => ({ id: item.id, label: item.label })) || [],\n changeAgent,\n changeModel,\n clearOperationError,\n connectionState,\n contextWindow: controller.contextWindow,\n contextCompression: controller.contextCompression,\n controller,\n deleteThread,\n errorMessage: agentChatRuntimeErrorMessage(fatalError || operationError),\n fatalError,\n getHitlActionState,\n isBootstrapping,\n isChangingAgent,\n isSubmitting: isSubmitting || controller.isSubmitting,\n isUploading: attachments.isUploading || controller.runState === \"uploading\",\n modelId: bootstrap ? selectedModelId : null,\n models: modelOptions,\n newThread,\n onHitlAction,\n openThread,\n operationError,\n retryBootstrap,\n resolveAttachmentContent,\n state,\n submit,\n };\n}\n","import type { AgentClient, ClientBootstrap, HitlResponse } from \"@agents24/client\";\nimport { type AgentChatController, type ChatHitlPart, type HitlSubmissionOptions, useAgentMcp } from \"@agents24/react\";\nimport * as React from \"react\";\nimport { browserChatCrypto, createMcpPkceProof, validateMcpCallbackResult, waitForMcpOauthComplete } from \"../mcp-oauth\";\nimport type { AgentChatMcpAuthorizationCompletion, AgentChatRuntimeHitlActionState } from \"./use-agent-chat-runtime\";\n\ntype HitlOptions = {\n client: AgentClient;\n bootstrap: ClientBootstrap | null;\n controller: AgentChatController;\n selectionGeneration: React.MutableRefObject<number>;\n completeMcpAuthorization?: AgentChatMcpAuthorizationCompletion;\n mcpRedirectUri?: string;\n clearOperationError(): void;\n onError(error: unknown): void;\n};\n\ntype HitlOperation = {\n abort: AbortController;\n isCurrent(): boolean;\n phase: \"connecting\" | \"resuming\";\n popup?: Window;\n};\n\nfunction detach(operation: HitlOperation) {\n operation.abort.abort();\n operation.popup?.close();\n}\n\nexport function useAgentChatHitl(options: HitlOptions) {\n const mcp = useAgentMcp();\n const latest = React.useRef(options);\n latest.current = options;\n const mounted = React.useRef(true);\n const operations = React.useRef(new Map<string, HitlOperation>());\n const [states, setStates] = React.useState<Record<string, AgentChatRuntimeHitlActionState>>({});\n\n React.useEffect(() => {\n mounted.current = true;\n const active = operations.current;\n return () => {\n mounted.current = false;\n for (const operation of active.values()) detach(operation);\n active.clear();\n };\n }, []);\n React.useEffect(() => {\n for (const [key, operation] of operations.current) {\n if (operation.isCurrent()) continue;\n detach(operation);\n operations.current.delete(key);\n setStates((current) => {\n const next = { ...current };\n delete next[key];\n return next;\n });\n }\n });\n React.useEffect(() => { setStates({}); }, [options.client, options.controller.activeThreadId]);\n\n const onHitlAction = React.useCallback(async (part: ChatHitlPart, response: HitlResponse, submission?: HitlSubmissionOptions) => {\n const captured = latest.current;\n const { controller, client, bootstrap, selectionGeneration } = captured;\n const generation = selectionGeneration.current;\n const threadId = controller.activeThreadId;\n const runId = part.runId || controller.messages.find((message) => message.parts.some(candidate => candidate.id === part.id))?.runId || controller.activeRunId;\n const key = `${generation}:${threadId}:${runId}:${part.interruptId || part.id}`;\n if (part.hitlKind !== \"mcp_auth\" || response.action !== \"connect\") {\n captured.clearOperationError();\n // All normal decisions, including host preparation, have one headless owner.\n return controller.resumeHitl(part, response, submission).catch(error => {\n const current = latest.current;\n if (mounted.current && current.client === client && current.selectionGeneration.current === generation\n && current.controller.activeThreadId === threadId) captured.onError(error);\n throw error;\n });\n }\n const previous = operations.current.get(key);\n if (previous?.isCurrent()) return;\n if (previous) { detach(previous); operations.current.delete(key); }\n const operation: HitlOperation = {\n abort: new AbortController(),\n phase: part.hitlKind === \"mcp_auth\" && response.action === \"connect\" ? \"connecting\" : \"resuming\",\n isCurrent() {\n const current = latest.current;\n return mounted.current && !operation.abort.signal.aborted\n && current.client === client && current.selectionGeneration.current === generation\n && current.controller.activeThreadId === threadId\n && (!current.controller.activeRunId || current.controller.activeRunId === runId)\n && ![\"cancelling\", \"cancelled\", \"failed\", \"completed\"].includes(current.controller.runState)\n && (operation.phase === \"resuming\" || current.controller.messages.some((message) =>\n message.runId === runId && message.parts.some((candidate) => candidate.type === \"hitl\"\n && candidate.interruptId === part.interruptId && candidate.status === \"pending\")));\n },\n };\n if (!operation.isCurrent()) return;\n captured.clearOperationError();\n operations.current.set(key, operation);\n setStates((current) => ({ ...current, [key]: { action: response.action, status: operation.phase } }));\n try {\n if (operation.phase === \"connecting\") {\n if (!runId) throw new Error(\"MCP authorization is missing its paused run.\");\n if (!bootstrap) throw new Error(\"MCP authorization requires runtime bootstrap.\");\n if (!captured.mcpRedirectUri) throw new Error(\"mcpRedirectUri is required for MCP Connect.\");\n const serverId = String(part.presentation.server_id || \"\").trim();\n if (!serverId) throw new Error(\"MCP authorization is missing its server identity.\");\n const serverEmbed = bootstrap.authentication.modes.includes(\"server_embed\");\n const popupNonce = browserChatCrypto().randomUUID();\n // Open within the click before awaiting crypto or the network.\n const popup = window.open(\"about:blank\", \"agents24-mcp\", \"popup,width=560,height=720\");\n if (!popup) throw new Error(\"Allow popups to connect this MCP account.\");\n operation.popup = popup;\n popup.document.title = \"Connecting to MCP\";\n popup.document.body.textContent = \"Opening secure connection…\";\n const proof = await createMcpPkceProof();\n if (!operation.isCurrent()) return;\n const started = await mcp.startAuthorization({\n runId, serverId, interruptId: part.interruptId, redirectUri: captured.mcpRedirectUri,\n popupNonce, codeChallenge: proof.challenge, signal: operation.abort.signal,\n });\n if (!operation.isCurrent()) return;\n if (!started.callback_origin) throw new Error(\"MCP authorization did not return a callback origin.\");\n const completionPromise = waitForMcpOauthComplete({\n popup, callbackOrigin: started.callback_origin, popupNonce, serverId,\n runId, interruptId: part.interruptId, signal: operation.abort.signal,\n requireConnectionId: serverEmbed || Boolean(captured.completeMcpAuthorization),\n });\n // Ensure a navigation exception cannot leave a rejected waiter unobserved.\n void completionPromise.catch(() => undefined);\n popup.location.replace(started.authorization_url);\n const completion = await completionPromise;\n if (!operation.isCurrent()) return;\n if (captured.completeMcpAuthorization) {\n await captured.completeMcpAuthorization({ completion, codeVerifier: proof.verifier, serverId });\n } else if (serverEmbed) {\n validateMcpCallbackResult({ server_id: completion.serverId, connection_id: completion.connectionId || \"\" }, serverId);\n } else {\n const redeemed = await mcp.redeemCallback({\n code: completion.code, codeVerifier: proof.verifier, signal: operation.abort.signal,\n });\n if (!operation.isCurrent()) return;\n validateMcpCallbackResult(redeemed, serverId);\n }\n popup.close();\n }\n if (!operation.isCurrent()) return;\n operation.phase = \"resuming\";\n setStates((current) => ({ ...current, [key]: { action: response.action, status: \"resuming\" } }));\n await controller.resumeHitl(part, response, submission);\n } catch (error) {\n if (!operation.isCurrent()) return;\n captured.onError(error);\n setStates((current) => ({ ...current, [key]: {\n action: response.action, status: \"error\", error: error instanceof Error ? error.message : String(error),\n } }));\n throw error;\n } finally {\n const ownsState = operation.isCurrent();\n // Abort the waiter and any in-flight transport, and always release the popup.\n detach(operation);\n if (operations.current.get(key) === operation) {\n operations.current.delete(key);\n if (ownsState) setStates((current) => {\n if (current[key]?.status === \"error\") return current;\n const next = { ...current };\n delete next[key];\n return next;\n });\n }\n }\n }, [mcp]);\n\n return { onHitlAction, getHitlActionState: (part: ChatHitlPart) => {\n const { controller, selectionGeneration } = latest.current;\n const runId = part.runId || controller.messages.find(message => message.parts.some(candidate => candidate.id === part.id))?.runId || controller.activeRunId;\n return controller.getHitlSubmissionState(part)\n || states[`${selectionGeneration.current}:${controller.activeThreadId}:${runId}:${part.interruptId || part.id}`];\n } };\n}\n","import * as React from \"react\";\nimport type { DelegationEvents, DelegationTask } from \"../generated/delegation-types\";\n\nexport type DelegationTaskSource = {\n events(input: { threadId: string; after: number; signal: AbortSignal }): Promise<DelegationEvents>;\n};\n\n/** Authoritative snapshots keep task discovery alive after the run stream ends. */\nexport function useDelegationTasks({ threadId, source, pollIntervalMs = 2000 }: {\n threadId: string | null;\n source: DelegationTaskSource;\n pollIntervalMs?: number;\n}) {\n const [state, setState] = React.useState<{\n threadId: string | null; tasks: DelegationTask[]; error: unknown; loading: boolean;\n }>({ threadId: null, tasks: [], error: null, loading: false });\n const [revision, refresh] = React.useReducer((value: number) => value + 1, 0);\n React.useEffect(() => {\n if (!threadId) {\n setState({ threadId: null, tasks: [], error: null, loading: false });\n return;\n }\n const controller = new AbortController();\n let cursor = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let failures = 0;\n setState((previous) => ({ threadId, tasks: previous.threadId === threadId ? previous.tasks : [],\n error: null, loading: true }));\n const poll = async () => {\n try {\n const result = await source.events({ threadId, after: cursor, signal: controller.signal });\n if (controller.signal.aborted) return;\n cursor = result.cursor;\n failures = 0;\n setState({ threadId, tasks: result.snapshot, error: null, loading: false });\n } catch (error) {\n if (controller.signal.aborted) return;\n failures += 1;\n setState((previous) => ({ ...previous, error, loading: false }));\n }\n if (!controller.signal.aborted) {\n timer = setTimeout(poll, Math.min(30000, Math.max(250, pollIntervalMs) * 2 ** Math.min(failures, 4)));\n }\n };\n void poll();\n return () => {\n controller.abort();\n if (timer) clearTimeout(timer);\n };\n }, [threadId, source, pollIntervalMs, revision]);\n return { tasks: state.threadId === threadId ? state.tasks : [],\n error: state.threadId === threadId ? state.error : null,\n loading: Boolean(threadId) && (state.threadId !== threadId || state.loading), refresh };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA;AAAA,EAME;AAAA,EACA;AAAA,OACK;AACP,YAAYA,YAAW;;;ACjBvB,SAAkF,mBAAmB;AACrG,YAAY,WAAW;AAsBvB,SAAS,OAAO,WAA0B;AACxC,YAAU,MAAM,MAAM;AACtB,YAAU,OAAO,MAAM;AACzB;AAEO,SAAS,iBAAiB,SAAsB;AACrD,QAAM,MAAM,YAAY;AACxB,QAAM,SAAe,aAAO,OAAO;AACnC,SAAO,UAAU;AACjB,QAAM,UAAgB,aAAO,IAAI;AACjC,QAAM,aAAmB,aAAO,oBAAI,IAA2B,CAAC;AAChE,QAAM,CAAC,QAAQ,SAAS,IAAU,eAA0D,CAAC,CAAC;AAE9F,EAAM,gBAAU,MAAM;AACpB,YAAQ,UAAU;AAClB,UAAM,SAAS,WAAW;AAC1B,WAAO,MAAM;AACX,cAAQ,UAAU;AAClB,iBAAW,aAAa,OAAO,OAAO,EAAG,QAAO,SAAS;AACzD,aAAO,MAAM;AAAA,IACf;AAAA,EACF,GAAG,CAAC,CAAC;AACL,EAAM,gBAAU,MAAM;AACpB,eAAW,CAAC,KAAK,SAAS,KAAK,WAAW,SAAS;AACjD,UAAI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c;AAAA,MAAE;AAAA,MAAU,OAAO,SAAS,aAAa,WAAW,SAAS,QAAQ,CAAC;AAAA,MAC5F,OAAO;AAAA,MAAM,SAAS;AAAA,IAAK,EAAE;AAC/B,UAAM,OAAO,YAAY;AACvB,UAAI;AACF,cAAM,SAAS,MAAM,OAAO,OAAO,EAAE,UAAU,OAAO,QAAQ,QAAQ,WAAW,OAAO,CAAC;AACzF,YAAI,WAAW,OAAO,QAAS;AAC/B,iBAAS,OAAO;AAChB,mBAAW;AACX,iBAAS,EAAE,UAAU,OAAO,OAAO,UAAU,OAAO,MAAM,SAAS,MAAM,CAAC;AAAA,MAC5E,SAAS,OAAO;AACd,YAAI,WAAW,OAAO,QAAS;AAC/B,oBAAY;AACZ,iBAAS,CAAC,cAAc,EAAE,GAAG,UAAU,OAAO,SAAS,MAAM,EAAE;AAAA,MACjE;AACA,UAAI,CAAC,WAAW,OAAO,SAAS;AAC9B,gBAAQ,WAAW,MAAM,KAAK,IAAI,KAAO,KAAK,IAAI,KAAK,cAAc,IAAI,KAAK,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC;AAAA,MACtG;AAAA,IACF;AACA,SAAK,KAAK;AACV,WAAO,MAAM;AACX,iBAAW,MAAM;AACjB,UAAI,MAAO,cAAa,KAAK;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,UAAU,QAAQ,gBAAgB,QAAQ,CAAC;AAC/C,SAAO;AAAA,IAAE,OAAO,MAAM,aAAa,WAAW,MAAM,QAAQ,CAAC;AAAA,IAC3D,OAAO,MAAM,aAAa,WAAW,MAAM,QAAQ;AAAA,IACnD,SAAS,QAAQ,QAAQ,MAAM,MAAM,aAAa,YAAY,MAAM;AAAA,IAAU;AAAA,EAAQ;AAC1F;","names":["React","React"]}
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/use-agent-chat-runtime.ts","../../src/runtime/use-agent-chat-hitl.ts","../../src/runtime/use-delegation-tasks.ts"],"sourcesContent":["import type {\n AgentClient,\n Agents24ClientError,\n ClientBootstrap,\n EffectiveResourcePolicy,\n HitlResponse,\n PortableUpload,\n} from \"@agents24/client\";\nimport type { ContextCompression, ContextWindow } from \"@agents24/client/protocol\";\nimport {\n type AgentChatController,\n type ChatAttachment,\n type ChatHitlPart,\n type HitlSubmissionOptions,\n type HitlSubmissionState,\n useAgentAttachments,\n useAgentChat,\n} from \"@agents24/react\";\nimport * as React from \"react\";\n\nimport { useAgentChatHitl } from \"./use-agent-chat-hitl\";\nimport type { ChatMcpOauthCompletion } from \"../types\";\nimport { validateAgentChatSubmission } from \"./input-contract\";\n\nexport type AgentChatRuntimeAgent = {\n name: string;\n description?: string | null;\n handle?: string | null;\n avatarUrl?: string | null;\n};\n\nexport type AgentChatRuntimeModel = {\n id: string;\n label: string;\n};\n\nexport type AgentChatRuntimeAgentOption = { id: string; label: string };\n\nexport type AgentChatRuntimeViewState =\n | \"ready\"\n | \"loading\"\n | \"uploading\"\n | \"streaming\"\n | \"reconnecting\"\n | \"paused\"\n | \"cancelling\"\n | \"cancelled\"\n | \"offline\"\n | \"denied\"\n | \"quota\"\n | \"failed\"\n | \"expired\";\n\nexport type AgentChatRuntimeConnectionState =\n | \"connected\"\n | \"connecting\"\n | \"reconnecting\"\n | \"offline\"\n | \"expired\";\n\nexport type AgentChatThreadChangeReason = \"created\" | \"opened\" | \"new\" | \"deleted\";\n\nexport type AgentChatActiveThreadChange = {\n threadId: string | null;\n reason: AgentChatThreadChangeReason;\n};\n\nexport type AgentChatActiveThreadChangeHandler = (\n change: AgentChatActiveThreadChange,\n) => void;\n\nexport type AgentChatMcpAuthorizationCompletion = (input: {\n completion: ChatMcpOauthCompletion;\n codeVerifier: string;\n serverId: string;\n}) => Promise<void>;\n\nexport type AgentChatRuntimeSubmit = {\n dictationSessionId?: string;\n text: string;\n files?: readonly PortableUpload[];\n attachments?: ChatAttachment[];\n attachmentIds?: readonly string[];\n};\n\nexport type AgentChatRuntimeHitlActionState = Omit<HitlSubmissionState, \"status\"> & {\n status: HitlSubmissionState[\"status\"] | \"connecting\" | \"resuming\";\n};\n\nexport type UseAgentChatRuntimeOptions = {\n attachmentTextOutputs?: readonly string[];\n activeThreadId?: string | null;\n agent?: AgentChatRuntimeAgent;\n client: AgentClient;\n completeMcpAuthorization?: AgentChatMcpAuthorizationCompletion;\n mcpRedirectUri?: string;\n modelId?: string | null;\n onActiveThreadIdChange?: AgentChatActiveThreadChangeHandler;\n onModelChange?: (modelId: string) => void;\n};\n\nexport type AgentChatRuntime = {\n dictation?: { agentId?: string; client: AgentClient; feature: import(\"@agents24/client\").DictationFeature };\n agent: AgentChatRuntimeAgent;\n inputContract: ClientBootstrap[\"features\"][\"inputs\"] | null;\n allowFeedback: boolean;\n isReadOnly: boolean;\n backgroundError: unknown;\n bootstrap: ClientBootstrap | null;\n capabilities: readonly string[];\n agentId: string | null;\n agents: AgentChatRuntimeAgentOption[];\n changeAgent(agentId: string): Promise<void>;\n changeModel(modelId: string): void;\n clearOperationError(): void;\n connectionState: AgentChatRuntimeConnectionState;\n contextWindow: ContextWindow | null;\n contextCompression: ContextCompression | null;\n controller: AgentChatController;\n deleteThread(threadId: string): Promise<void>;\n errorMessage: string | null;\n fatalError: unknown;\n getHitlActionState(part: ChatHitlPart): AgentChatRuntimeHitlActionState | undefined;\n isBootstrapping: boolean;\n isChangingAgent: boolean;\n isSubmitting: boolean;\n isUploading: boolean;\n modelId: string | null;\n models: AgentChatRuntimeModel[];\n newThread(): void;\n onHitlAction(part: ChatHitlPart, response: HitlResponse, options?: HitlSubmissionOptions): Promise<void>;\n openThread(threadId: string): Promise<void>;\n operationError: unknown;\n retryBootstrap(): Promise<void>;\n resolveAttachmentContent(\n attachment: ChatAttachment,\n signal: AbortSignal,\n ): Promise<{ url: string; validUntil: string | null }>;\n state: AgentChatRuntimeViewState;\n submit(input: AgentChatRuntimeSubmit): Promise<void>;\n};\n\ntype PendingThreadTransition = {\n reason: \"opened\" | \"deleted\";\n value: string | null;\n};\n\nexport function agentChatRuntimeStateFromError(error: unknown): AgentChatRuntimeViewState {\n const typed = error as Partial<Agents24ClientError> | null;\n if (typed?.kind === \"authentication\") return \"expired\";\n if (typed?.kind === \"authorization\") return \"denied\";\n if (typed?.kind === \"quota\" || typed?.kind === \"rate_limit\") return \"quota\";\n if (typed?.kind === \"network\") return \"offline\";\n return \"failed\";\n}\n\nexport function agentChatRuntimeErrorMessage(error: unknown): string | null {\n if (!error) return null;\n return error instanceof Error ? error.message : String(error);\n}\n\nexport function canChangeAgentRuntime(\n runState: AgentChatController[\"runState\"],\n activeRunId: string | null,\n): boolean {\n return !activeRunId && ![\"uploading\", \"streaming\", \"reconnecting\", \"paused\", \"cancelling\"].includes(runState);\n}\n\nexport function agentIdFromBootstrap(\n bootstrap: ClientBootstrap,\n requestedAgentId: string | null,\n): string | null {\n const feature = bootstrap.features.agents;\n if (!feature) return null;\n return feature.options.some((item) => item.id === requestedAgentId)\n ? requestedAgentId\n : feature.default_id || null;\n}\n\nexport function modelsFromAgentChatBootstrap(bootstrap: ClientBootstrap): {\n defaultModelId: string | null;\n models: AgentChatRuntimeModel[];\n} {\n const modelFeatures = bootstrap.features.models;\n const selectable = bootstrap.capabilities.includes(\"models.select\") && modelFeatures?.selectable === true;\n if (!selectable) return { defaultModelId: null, models: [] };\n const models = Array.isArray(modelFeatures.options)\n ? modelFeatures.options.flatMap((option) => (\n typeof option?.id === \"string\" && option.id.trim()\n ? [{ id: option.id, label: typeof option.label === \"string\" && option.label.trim() ? option.label : option.id }]\n : []\n ))\n : [];\n const configuredDefault = models.some((model) => model.id === modelFeatures.default_id)\n ? modelFeatures.default_id\n : null;\n return {\n defaultModelId: configuredDefault,\n models,\n };\n}\n\nfunction modelsFromEffectivePolicy(policy: EffectiveResourcePolicy): {\n defaultModelId: string | null;\n models: AgentChatRuntimeModel[];\n} {\n const models = policy.model_selection.selectable\n ? policy.model_selection.options.map((option) => ({ id: option.id, label: option.label }))\n : [];\n return {\n defaultModelId: models.some((model) => model.id === policy.model_selection.default_id)\n ? policy.model_selection.default_id\n : null,\n models,\n };\n}\n\nexport function useAgentChatRuntime(options: UseAgentChatRuntimeOptions): AgentChatRuntime {\n const {\n activeThreadId,\n agent: agentOverride,\n client,\n completeMcpAuthorization,\n mcpRedirectUri,\n modelId,\n onActiveThreadIdChange,\n onModelChange,\n } = options;\n const controller = useAgentChat(\n { client, ...(activeThreadId === undefined ? {} : { activeThreadId }),\n attachmentTextOutputs: options.attachmentTextOutputs },\n );\n const attachments = useAgentAttachments();\n const bootstrapOwnerRef = React.useRef<AgentClient | null>(null);\n const [bootstrapState, setBootstrap] = React.useState<ClientBootstrap | null>(null);\n const bootstrap = bootstrapOwnerRef.current === client ? bootstrapState : null;\n const bootstrapRef = React.useRef<ClientBootstrap | null>(bootstrap);\n bootstrapRef.current = bootstrap;\n const [effectivePolicyState, setEffectivePolicy] = React.useState<EffectiveResourcePolicy | null>(null);\n const effectivePolicy = bootstrapOwnerRef.current === client ? effectivePolicyState : null;\n const [isBootstrapping, setIsBootstrapping] = React.useState(true);\n const [bootstrapError, setBootstrapError] = React.useState<unknown>(null);\n const [localOperationError, setLocalOperationError] = React.useState<unknown>(null);\n const [selectedModelId, setSelectedModelId] = React.useState<string | null>(modelId ?? null);\n const selectedModelIdRef = React.useRef<string | null>(selectedModelId);\n selectedModelIdRef.current = selectedModelId;\n const [selectedAgentId, setSelectedAgentId] = React.useState<string | null>(null);\n const selectedAgentIdRef = React.useRef<string | null>(null);\n selectedAgentIdRef.current = selectedAgentId;\n const [isChangingAgent, setIsChangingAgent] = React.useState(false);\n const agentChangePromiseRef = React.useRef<Promise<void> | null>(null);\n const [isSubmitting, setIsSubmitting] = React.useState(false);\n const submitPromiseRef = React.useRef<Promise<void> | null>(null);\n\n const mountedRef = React.useRef(true);\n const clientRef = React.useRef(client);\n clientRef.current = client;\n const bootstrapRetryRef = React.useRef(0);\n const bootstrapPromiseRef = React.useRef<{ client: AgentClient; promise: Promise<void> } | null>(null);\n React.useEffect(() => {\n mountedRef.current = true;\n return () => { mountedRef.current = false; };\n }, []);\n\n const previousControlledThreadRef = React.useRef(activeThreadId);\n const threadSelectionGenerationRef = React.useRef(0);\n const controlledSyncTargetRef = React.useRef<{ value: string | null } | null>(null);\n const previousControllerThreadRef = React.useRef(controller.activeThreadId);\n const pendingThreadTransitionRef = React.useRef<PendingThreadTransition | null>(null);\n const lastReportedThreadRef = React.useRef<string | null>(activeThreadId ?? controller.activeThreadId);\n if (activeThreadId !== previousControlledThreadRef.current) {\n threadSelectionGenerationRef.current += 1;\n previousControlledThreadRef.current = activeThreadId;\n if (activeThreadId !== undefined) {\n controlledSyncTargetRef.current = { value: activeThreadId };\n lastReportedThreadRef.current = activeThreadId;\n }\n }\n\n const reportActiveThread = React.useCallback((\n threadId: string | null,\n reason: AgentChatThreadChangeReason,\n ) => {\n if (lastReportedThreadRef.current === threadId) return;\n lastReportedThreadRef.current = threadId;\n onActiveThreadIdChange?.({ threadId, reason });\n }, [onActiveThreadIdChange]);\n\n const retryBootstrap = React.useCallback((): Promise<void> => {\n if (bootstrapPromiseRef.current?.client === client) return bootstrapPromiseRef.current.promise;\n const requestClient = client;\n const request = (async () => {\n if (mountedRef.current) {\n const identityChanged = bootstrapOwnerRef.current !== requestClient;\n setIsBootstrapping(identityChanged || !bootstrapRef.current);\n setBootstrapError(null);\n if (identityChanged) {\n setBootstrap(null);\n setEffectivePolicy(null);\n setSelectedAgentId(null);\n setSelectedModelId(null);\n }\n }\n try {\n const requestedAgentId = selectedAgentIdRef.current;\n const result = await requestClient.bootstrap({ agentId: requestedAgentId || undefined });\n if (!mountedRef.current || clientRef.current !== requestClient) return;\n bootstrapOwnerRef.current = requestClient;\n bootstrapRetryRef.current = 0;\n setBootstrap(result);\n const agentFeature = result.features.agents;\n const resolvedAgentId = agentIdFromBootstrap(result, requestedAgentId);\n setSelectedAgentId(resolvedAgentId);\n const entitlement = agentFeature ? null : await requestClient.resourcePolicies.getEffective();\n if (!mountedRef.current || clientRef.current !== requestClient) return;\n setEffectivePolicy(entitlement);\n const availableModels = entitlement ? modelsFromEffectivePolicy(entitlement) : modelsFromAgentChatBootstrap(result);\n if (modelId === undefined) {\n setSelectedModelId((current) => availableModels.models.some((item) => item.id === current)\n ? current\n : availableModels.defaultModelId);\n }\n void controller.refreshThreads().catch(() => undefined);\n } catch (error) {\n if (mountedRef.current && clientRef.current === requestClient) {\n const status = (error as Agents24ClientError)?.status;\n if (status === 401 || status === 403 || status === 404) {\n setBootstrap(null);\n setEffectivePolicy(null);\n bootstrapOwnerRef.current = null;\n }\n setBootstrapError(error);\n }\n } finally {\n if (mountedRef.current && clientRef.current === requestClient) setIsBootstrapping(false);\n }\n })();\n bootstrapPromiseRef.current = { client: requestClient, promise: request };\n void request.finally(() => {\n if (bootstrapPromiseRef.current?.promise === request) bootstrapPromiseRef.current = null;\n });\n return request;\n }, [client, controller.refreshThreads, modelId]);\n\n React.useEffect(() => {\n if (!bootstrapError || bootstrapRetryRef.current >= 4) return;\n const error = bootstrapError as Agents24ClientError;\n if (!(error.retryable || error.kind === \"network\" || (error.status || 0) >= 500)) return;\n const attempt = bootstrapRetryRef.current++;\n const hint = error.retryAfterMs;\n const delay = Math.max(500 * 2 ** attempt + Math.random() * 250,\n typeof hint === \"number\" && Number.isFinite(hint) && hint >= 0 ? Math.min(hint, 60_000) : 0);\n const timer = setTimeout(() => { void retryBootstrap(); }, delay);\n return () => clearTimeout(timer);\n }, [bootstrapError, retryBootstrap]);\n\n const refreshEffectivePolicy = React.useCallback(async () => {\n if (bootstrap?.features.agents) {\n const refreshed = await client.bootstrap({ agentId: selectedAgentIdRef.current || undefined });\n if (!mountedRef.current || clientRef.current !== client) return;\n setBootstrap(refreshed);\n const available = modelsFromAgentChatBootstrap(refreshed);\n setSelectedModelId((current) => available.models.some((item) => item.id === current)\n ? current\n : available.defaultModelId);\n return;\n }\n const entitlement = await client.resourcePolicies.getEffective();\n if (!mountedRef.current || clientRef.current !== client) return;\n setEffectivePolicy(entitlement);\n if (modelId === undefined) {\n const available = modelsFromEffectivePolicy(entitlement);\n setSelectedModelId((current) => available.models.some((item) => item.id === current)\n ? current\n : available.defaultModelId);\n }\n }, [bootstrap, client, modelId]);\n\n React.useEffect(() => {\n void retryBootstrap();\n }, [retryBootstrap]);\n\n React.useEffect(() => {\n if (modelId !== undefined) setSelectedModelId(modelId);\n }, [modelId]);\n\n React.useEffect(() => {\n if (controlledSyncTargetRef.current?.value === null && controller.activeThreadId) {\n controller.startNewThread();\n }\n }, [activeThreadId, controller.activeThreadId, controller.startNewThread]);\n\n React.useEffect(() => {\n const previous = previousControllerThreadRef.current;\n const current = controller.activeThreadId;\n previousControllerThreadRef.current = current;\n const controlledTarget = controlledSyncTargetRef.current;\n if (controlledTarget) {\n if (current === controlledTarget.value) controlledSyncTargetRef.current = null;\n return;\n }\n const pendingTransition = pendingThreadTransitionRef.current;\n if (pendingTransition && current === pendingTransition.value) return;\n if (previous === null && current !== null) reportActiveThread(current, \"created\");\n }, [activeThreadId, controller.activeThreadId, reportActiveThread]);\n\n const clearOperationError = React.useCallback(() => {\n setLocalOperationError(null);\n controller.clearOperationError();\n }, [controller.clearOperationError]);\n\n const submit = React.useCallback((input: AgentChatRuntimeSubmit): Promise<void> => {\n if (submitPromiseRef.current) return submitPromiseRef.current;\n clearOperationError();\n setIsSubmitting(true);\n const request = (async () => {\n try {\n if(controller.activeThread?.read_only)throw new Error(\"This conversation is read-only. Start a new chat.\");\n await agentChangePromiseRef.current;\n const activeBootstrap = bootstrapRef.current;\n if (!activeBootstrap) throw new Error(\"The agent input contract is unavailable.\");\n const retained = (input.attachments || []).filter((attachment) => input.attachmentIds?.includes(attachment.id || \"\"));\n const inputError = validateAgentChatSubmission(activeBootstrap.features.inputs, input.text, [\n ...(input.files || []),\n ...retained.map((attachment) => ({ data: new Uint8Array(), mediaType: attachment.mediaType || \"application/octet-stream\" })),\n ]);\n if (inputError) throw new Error(inputError);\n await controller.submit({\n text: input.text,\n dictationSessionId: input.dictationSessionId,\n attachments: input.attachments,\n uploads: input.files,\n attachmentIds: input.attachmentIds,\n requestedModelId: selectedModelIdRef.current || undefined,\n requestedAgentId: selectedAgentIdRef.current || undefined,\n });\n } catch (error) {\n setLocalOperationError(error);\n const typed = error as Partial<Agents24ClientError>;\n if (typed.kind === \"quota\" || typed.kind === \"authorization\") {\n await refreshEffectivePolicy().catch(() => undefined);\n }\n throw error;\n } finally {\n setIsSubmitting(false);\n }\n })();\n submitPromiseRef.current = request;\n const clearRequest = () => {\n if (submitPromiseRef.current === request) submitPromiseRef.current = null;\n };\n void request.then(clearRequest, clearRequest);\n return request;\n }, [bootstrap, clearOperationError, controller.activeThreadId, controller.activeThread?.read_only, controller.submit, refreshEffectivePolicy]);\n\n const { onHitlAction, getHitlActionState } = useAgentChatHitl({\n client, bootstrap, controller, selectionGeneration: threadSelectionGenerationRef,\n completeMcpAuthorization, mcpRedirectUri, clearOperationError, onError: setLocalOperationError,\n });\n\n const newThread = React.useCallback(() => {\n threadSelectionGenerationRef.current += 1;\n clearOperationError();\n pendingThreadTransitionRef.current = null;\n reportActiveThread(null, \"new\");\n controller.startNewThread();\n }, [clearOperationError, controller.startNewThread, reportActiveThread]);\n\n const openThread = React.useCallback(async (threadId: string) => {\n const requestGeneration = ++threadSelectionGenerationRef.current;\n clearOperationError();\n pendingThreadTransitionRef.current = { reason: \"opened\", value: threadId };\n try {\n const detail = await client.threads.get({ threadId });\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n const preferredAgentId = detail.runtime_selection?.agent_alias || detail.runtime_selection?.agent_id || null;\n if (preferredAgentId && !detail.read_only) {\n const result = await client.bootstrap({ agentId: preferredAgentId });\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n const resolvedAgentId = agentIdFromBootstrap(result, preferredAgentId);\n setBootstrap(result);\n setEffectivePolicy(null);\n setSelectedAgentId(resolvedAgentId);\n const available = modelsFromAgentChatBootstrap(result);\n const preferredModelId = detail.runtime_selection?.model_id || null;\n setSelectedModelId(available.models.some((item) => item.id === preferredModelId)\n ? preferredModelId\n : available.defaultModelId);\n }\n await controller.openThread(threadId);\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n reportActiveThread(threadId, \"opened\");\n } catch (error) {\n if (requestGeneration !== threadSelectionGenerationRef.current) return;\n setLocalOperationError(error);\n throw error;\n } finally {\n if (requestGeneration === threadSelectionGenerationRef.current) pendingThreadTransitionRef.current = null;\n }\n }, [clearOperationError, client, controller.openThread, reportActiveThread]);\n\n const deleteThread = React.useCallback(async (threadId: string) => {\n clearOperationError();\n const wasActive = controller.activeThreadId === threadId;\n if (wasActive) threadSelectionGenerationRef.current += 1;\n if (wasActive) pendingThreadTransitionRef.current = { reason: \"deleted\", value: null };\n try {\n await controller.deleteThread(threadId);\n if (wasActive) reportActiveThread(null, \"deleted\");\n } catch (error) {\n setLocalOperationError(error);\n throw error;\n } finally {\n if (wasActive && pendingThreadTransitionRef.current?.reason === \"deleted\") {\n pendingThreadTransitionRef.current = null;\n }\n }\n }, [clearOperationError, controller.activeThreadId, controller.deleteThread, reportActiveThread]);\n\n const changeModel = React.useCallback((nextModelId: string) => {\n if (modelId === undefined) setSelectedModelId(nextModelId);\n onModelChange?.(nextModelId);\n if (controller.activeThreadId && selectedAgentId && client.threads.setRuntimeSelection) {\n void client.threads.setRuntimeSelection({\n threadId: controller.activeThreadId,\n preferredAgentId: selectedAgentId,\n preferredModelId: nextModelId,\n }).catch(setLocalOperationError);\n }\n }, [client.threads, controller.activeThreadId, modelId, onModelChange, selectedAgentId]);\n\n const resolveAttachmentContent = React.useCallback(async (\n attachment: ChatAttachment,\n signal: AbortSignal,\n ) => {\n const attachmentId = typeof attachment.id === \"string\" ? attachment.id.trim() : \"\";\n if (!attachmentId) throw new Error(\"Attachment content identity is unavailable.\");\n const access = await attachments.createContentAccess({\n attachmentId,\n disposition: \"inline\",\n signal,\n });\n return { url: access.url, validUntil: access.valid_until || null };\n }, [attachments.createContentAccess]);\n\n const changeAgent = React.useCallback((nextAgentId: string): Promise<void> => {\n if (agentChangePromiseRef.current) return agentChangePromiseRef.current;\n if (\n nextAgentId === selectedAgentIdRef.current\n || !canChangeAgentRuntime(controller.runState, controller.activeRunId)\n ) return Promise.resolve();\n clearOperationError();\n setIsChangingAgent(true);\n const request = (async () => {\n try {\n const result = await client.bootstrap({ agentId: nextAgentId });\n const resolvedAgentId = agentIdFromBootstrap(result, nextAgentId);\n if (!resolvedAgentId) throw new Error(\"The requested Agent is no longer available.\");\n const available = modelsFromAgentChatBootstrap(result);\n const currentModelId = selectedModelIdRef.current;\n const nextModelId = available.models.some((item) => item.id === currentModelId)\n ? currentModelId\n : available.defaultModelId;\n if (controller.activeThreadId && client.threads.setRuntimeSelection) {\n const persisted = await client.threads.setRuntimeSelection({\n threadId: controller.activeThreadId,\n preferredAgentId: resolvedAgentId,\n preferredModelId: nextModelId,\n });\n selectedModelIdRef.current = persisted.runtime_selection.model_id;\n setSelectedModelId(persisted.runtime_selection.model_id);\n } else {\n selectedModelIdRef.current = nextModelId;\n setSelectedModelId(nextModelId);\n }\n selectedAgentIdRef.current = resolvedAgentId;\n bootstrapRef.current = result;\n setSelectedAgentId(resolvedAgentId);\n setBootstrap(result);\n setEffectivePolicy(null);\n } catch (error) {\n setLocalOperationError(error);\n throw error;\n }\n })();\n agentChangePromiseRef.current = request;\n const clearRequest = () => {\n if (agentChangePromiseRef.current === request) agentChangePromiseRef.current = null;\n if (mountedRef.current) setIsChangingAgent(false);\n };\n void request.then(clearRequest, clearRequest);\n return request;\n }, [clearOperationError, client, controller.activeRunId, controller.activeThreadId, controller.runState]);\n\n const modelOptions = effectivePolicy\n ? modelsFromEffectivePolicy(effectivePolicy).models\n : bootstrap\n ? modelsFromAgentChatBootstrap(bootstrap).models\n : [];\n const fatalError = (!bootstrap ? bootstrapError : null) || controller.error;\n const operationError = localOperationError || controller.operationError?.cause;\n const state: AgentChatRuntimeViewState = isBootstrapping\n ? \"loading\"\n : fatalError\n ? agentChatRuntimeStateFromError(fatalError)\n : controller.runState === \"uploading\"\n ? \"uploading\"\n : controller.runState === \"streaming\"\n ? \"streaming\"\n : controller.runState === \"reconnecting\"\n ? \"reconnecting\"\n : controller.runState === \"paused\"\n ? \"paused\"\n : controller.runState === \"cancelling\"\n ? \"cancelling\"\n : controller.runState === \"cancelled\"\n ? \"cancelled\"\n : \"ready\";\n const connectionState: AgentChatRuntimeConnectionState = bootstrapError && bootstrap ? \"reconnecting\" : state === \"offline\"\n ? \"offline\"\n : state === \"expired\"\n ? \"expired\"\n : state === \"reconnecting\"\n ? \"reconnecting\"\n : isBootstrapping\n ? \"connecting\"\n : \"connected\";\n return {\n agent: agentOverride || { name: bootstrap?.deployment.name || \"Agent\" },\n inputContract: bootstrap?.features.inputs || null,\n dictation: bootstrap?.features.dictation && (bootstrap.features.dictation.enabled || bootstrap.features.dictation.reason)\n ? { client, agentId: selectedAgentId || undefined, feature: bootstrap.features.dictation } : undefined,\n allowFeedback: Boolean(bootstrap?.capabilities.includes(\"feedback.write\")) && !controller.activeThread?.read_only,\n isReadOnly:controller.activeThread?.read_only===true,\n backgroundError: (bootstrap && bootstrapError) || controller.backgroundError?.cause || null,\n bootstrap,\n capabilities: bootstrap?.capabilities || [],\n agentId: bootstrap ? selectedAgentId : null,\n agents: bootstrap?.features.agents?.options.map((item) => ({ id: item.id, label: item.label })) || [],\n changeAgent,\n changeModel,\n clearOperationError,\n connectionState,\n contextWindow: controller.contextWindow,\n contextCompression: controller.contextCompression,\n controller,\n deleteThread,\n errorMessage: agentChatRuntimeErrorMessage(fatalError || operationError),\n fatalError,\n getHitlActionState,\n isBootstrapping,\n isChangingAgent,\n isSubmitting: isSubmitting || controller.isSubmitting,\n isUploading: attachments.isUploading || controller.runState === \"uploading\",\n modelId: bootstrap ? selectedModelId : null,\n models: modelOptions,\n newThread,\n onHitlAction,\n openThread,\n operationError,\n retryBootstrap,\n resolveAttachmentContent,\n state,\n submit,\n };\n}\n","import type { AgentClient, ClientBootstrap, HitlResponse } from \"@agents24/client\";\nimport { type AgentChatController, type ChatHitlPart, type HitlSubmissionOptions, useAgentMcp } from \"@agents24/react\";\nimport * as React from \"react\";\nimport { browserChatCrypto, createMcpPkceProof, validateMcpCallbackResult, waitForMcpOauthComplete } from \"../mcp-oauth\";\nimport type { AgentChatMcpAuthorizationCompletion, AgentChatRuntimeHitlActionState } from \"./use-agent-chat-runtime\";\n\ntype HitlOptions = {\n client: AgentClient;\n bootstrap: ClientBootstrap | null;\n controller: AgentChatController;\n selectionGeneration: React.MutableRefObject<number>;\n completeMcpAuthorization?: AgentChatMcpAuthorizationCompletion;\n mcpRedirectUri?: string;\n clearOperationError(): void;\n onError(error: unknown): void;\n};\n\ntype HitlOperation = {\n abort: AbortController;\n isCurrent(): boolean;\n phase: \"connecting\" | \"resuming\";\n popup?: Window;\n};\n\nfunction detach(operation: HitlOperation) {\n operation.abort.abort();\n operation.popup?.close();\n}\n\nexport function useAgentChatHitl(options: HitlOptions) {\n const mcp = useAgentMcp();\n const latest = React.useRef(options);\n latest.current = options;\n const mounted = React.useRef(true);\n const operations = React.useRef(new Map<string, HitlOperation>());\n const [states, setStates] = React.useState<Record<string, AgentChatRuntimeHitlActionState>>({});\n\n React.useEffect(() => {\n mounted.current = true;\n const active = operations.current;\n return () => {\n mounted.current = false;\n for (const operation of active.values()) detach(operation);\n active.clear();\n };\n }, []);\n React.useEffect(() => {\n for (const [key, operation] of operations.current) {\n if (operation.isCurrent()) continue;\n detach(operation);\n operations.current.delete(key);\n setStates((current) => {\n const next = { ...current };\n delete next[key];\n return next;\n });\n }\n });\n React.useEffect(() => { setStates({}); }, [options.client, options.controller.activeThreadId]);\n\n const onHitlAction = React.useCallback(async (part: ChatHitlPart, response: HitlResponse, submission?: HitlSubmissionOptions) => {\n const captured = latest.current;\n const { controller, client, bootstrap, selectionGeneration } = captured;\n const generation = selectionGeneration.current;\n const threadId = controller.activeThreadId;\n const runId = part.runId || controller.messages.find((message) => message.parts.some(candidate => candidate.id === part.id))?.runId || controller.activeRunId;\n const key = `${generation}:${threadId}:${runId}:${part.interruptId || part.id}`;\n if (part.hitlKind !== \"mcp_auth\" || response.action !== \"connect\") {\n captured.clearOperationError();\n // All normal decisions, including host preparation, have one headless owner.\n return controller.resumeHitl(part, response, submission).catch(error => {\n const current = latest.current;\n if (mounted.current && current.client === client && current.selectionGeneration.current === generation\n && current.controller.activeThreadId === threadId) captured.onError(error);\n throw error;\n });\n }\n const previous = operations.current.get(key);\n if (previous?.isCurrent()) return;\n if (previous) { detach(previous); operations.current.delete(key); }\n const operation: HitlOperation = {\n abort: new AbortController(),\n phase: part.hitlKind === \"mcp_auth\" && response.action === \"connect\" ? \"connecting\" : \"resuming\",\n isCurrent() {\n const current = latest.current;\n return mounted.current && !operation.abort.signal.aborted\n && current.client === client && current.selectionGeneration.current === generation\n && current.controller.activeThreadId === threadId\n && (!current.controller.activeRunId || current.controller.activeRunId === runId)\n && ![\"cancelling\", \"cancelled\", \"failed\", \"completed\"].includes(current.controller.runState)\n && (operation.phase === \"resuming\" || current.controller.messages.some((message) =>\n message.runId === runId && message.parts.some((candidate) => candidate.type === \"hitl\"\n && candidate.interruptId === part.interruptId && candidate.status === \"pending\")));\n },\n };\n if (!operation.isCurrent()) return;\n captured.clearOperationError();\n operations.current.set(key, operation);\n setStates((current) => ({ ...current, [key]: { action: response.action, status: operation.phase } }));\n try {\n if (operation.phase === \"connecting\") {\n if (!runId) throw new Error(\"MCP authorization is missing its paused run.\");\n if (!bootstrap) throw new Error(\"MCP authorization requires runtime bootstrap.\");\n if (!captured.mcpRedirectUri) throw new Error(\"mcpRedirectUri is required for MCP Connect.\");\n const serverId = String(part.presentation.server_id || \"\").trim();\n if (!serverId) throw new Error(\"MCP authorization is missing its server identity.\");\n const serverEmbed = bootstrap.authentication.modes.includes(\"server_embed\");\n const popupNonce = browserChatCrypto().randomUUID();\n // Open within the click before awaiting crypto or the network.\n const popup = window.open(\"about:blank\", \"agents24-mcp\", \"popup,width=560,height=720\");\n if (!popup) throw new Error(\"Allow popups to connect this MCP account.\");\n operation.popup = popup;\n popup.document.title = \"Connecting to MCP\";\n popup.document.body.textContent = \"Opening secure connection…\";\n const proof = await createMcpPkceProof();\n if (!operation.isCurrent()) return;\n const started = await mcp.startAuthorization({\n runId, serverId, interruptId: part.interruptId, redirectUri: captured.mcpRedirectUri,\n popupNonce, codeChallenge: proof.challenge, signal: operation.abort.signal,\n });\n if (!operation.isCurrent()) return;\n if (!started.callback_origin) throw new Error(\"MCP authorization did not return a callback origin.\");\n const completionPromise = waitForMcpOauthComplete({\n popup, callbackOrigin: started.callback_origin, popupNonce, serverId,\n runId, interruptId: part.interruptId, signal: operation.abort.signal,\n requireConnectionId: serverEmbed || Boolean(captured.completeMcpAuthorization),\n });\n // Ensure a navigation exception cannot leave a rejected waiter unobserved.\n void completionPromise.catch(() => undefined);\n popup.location.replace(started.authorization_url);\n const completion = await completionPromise;\n if (!operation.isCurrent()) return;\n if (captured.completeMcpAuthorization) {\n await captured.completeMcpAuthorization({ completion, codeVerifier: proof.verifier, serverId });\n } else if (serverEmbed) {\n validateMcpCallbackResult({ server_id: completion.serverId, connection_id: completion.connectionId || \"\" }, serverId);\n } else {\n const redeemed = await mcp.redeemCallback({\n code: completion.code, codeVerifier: proof.verifier, signal: operation.abort.signal,\n });\n if (!operation.isCurrent()) return;\n validateMcpCallbackResult(redeemed, serverId);\n }\n popup.close();\n }\n if (!operation.isCurrent()) return;\n operation.phase = \"resuming\";\n setStates((current) => ({ ...current, [key]: { action: response.action, status: \"resuming\" } }));\n await controller.resumeHitl(part, response, submission);\n } catch (error) {\n if (!operation.isCurrent()) return;\n captured.onError(error);\n setStates((current) => ({ ...current, [key]: {\n action: response.action, status: \"error\", error: error instanceof Error ? error.message : String(error),\n } }));\n throw error;\n } finally {\n const ownsState = operation.isCurrent();\n // Abort the waiter and any in-flight transport, and always release the popup.\n detach(operation);\n if (operations.current.get(key) === operation) {\n operations.current.delete(key);\n if (ownsState) setStates((current) => {\n if (current[key]?.status === \"error\") return current;\n const next = { ...current };\n delete next[key];\n return next;\n });\n }\n }\n }, [mcp]);\n\n return { onHitlAction, getHitlActionState: (part: ChatHitlPart) => {\n const { controller, selectionGeneration } = latest.current;\n const runId = part.runId || controller.messages.find(message => message.parts.some(candidate => candidate.id === part.id))?.runId || controller.activeRunId;\n return controller.getHitlSubmissionState(part)\n || states[`${selectionGeneration.current}:${controller.activeThreadId}:${runId}:${part.interruptId || part.id}`];\n } };\n}\n","import * as React from \"react\";\nimport type { DelegationEvents, DelegationTask } from \"../generated/delegation-types\";\n\nexport type DelegationTaskSource = {\n events(input: { threadId: string; after: number; signal: AbortSignal }): Promise<DelegationEvents>;\n};\n\n/** Authoritative snapshots keep task discovery alive after the run stream ends. */\nexport function useDelegationTasks({ threadId, source, pollIntervalMs = 2000 }: {\n threadId: string | null;\n source: DelegationTaskSource;\n pollIntervalMs?: number;\n}) {\n const [state, setState] = React.useState<{\n threadId: string | null; tasks: DelegationTask[]; error: unknown; loading: boolean;\n }>({ threadId: null, tasks: [], error: null, loading: false });\n const [revision, refresh] = React.useReducer((value: number) => value + 1, 0);\n React.useEffect(() => {\n if (!threadId) {\n setState({ threadId: null, tasks: [], error: null, loading: false });\n return;\n }\n const controller = new AbortController();\n let cursor = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let failures = 0;\n setState((previous) => ({ threadId, tasks: previous.threadId === threadId ? previous.tasks : [],\n error: null, loading: true }));\n const poll = async () => {\n try {\n const result = await source.events({ threadId, after: cursor, signal: controller.signal });\n if (controller.signal.aborted) return;\n cursor = result.cursor;\n failures = 0;\n setState({ threadId, tasks: result.snapshot, error: null, loading: false });\n } catch (error) {\n if (controller.signal.aborted) return;\n failures += 1;\n setState((previous) => ({ ...previous, error, loading: false }));\n }\n if (!controller.signal.aborted) {\n timer = setTimeout(poll, Math.min(30000, Math.max(250, pollIntervalMs) * 2 ** Math.min(failures, 4)));\n }\n };\n void poll();\n return () => {\n controller.abort();\n if (timer) clearTimeout(timer);\n };\n }, [threadId, source, pollIntervalMs, revision]);\n return { tasks: state.threadId === threadId ? state.tasks : [],\n error: state.threadId === threadId ? state.error : null,\n loading: Boolean(threadId) && (state.threadId !== threadId || state.loading), refresh };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA;AAAA,EAME;AAAA,EACA;AAAA,OACK;AACP,YAAYA,YAAW;;;ACjBvB,SAAkF,mBAAmB;AACrG,YAAY,WAAW;AAsBvB,SAAS,OAAO,WAA0B;AACxC,YAAU,MAAM,MAAM;AACtB,YAAU,OAAO,MAAM;AACzB;AAEO,SAAS,iBAAiB,SAAsB;AACrD,QAAM,MAAM,YAAY;AACxB,QAAM,SAAe,aAAO,OAAO;AACnC,SAAO,UAAU;AACjB,QAAM,UAAgB,aAAO,IAAI;AACjC,QAAM,aAAmB,aAAO,oBAAI,IAA2B,CAAC;AAChE,QAAM,CAAC,QAAQ,SAAS,IAAU,eAA0D,CAAC,CAAC;AAE9F,EAAM,gBAAU,MAAM;AACpB,YAAQ,UAAU;AAClB,UAAM,SAAS,WAAW;AAC1B,WAAO,MAAM;AACX,cAAQ,UAAU;AAClB,iBAAW,aAAa,OAAO,OAAO,EAAG,QAAO,SAAS;AACzD,aAAO,MAAM;AAAA,IACf;AAAA,EACF,GAAG,CAAC,CAAC;AACL,EAAM,gBAAU,MAAM;AACpB,eAAW,CAAC,KAAK,SAAS,KAAK,WAAW,SAAS;AACjD,UAAI,UAAU,UAAU,EAAG;AAC3B,aAAO,SAAS;AAChB,iBAAW,QAAQ,OAAO,GAAG;AAC7B,gBAAU,CAAC,YAAY;AACrB,cAAM,OAAO,EAAE,GAAG,QAAQ;AAC1B,eAAO,KAAK,GAAG;AACf,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,EAAM,gBAAU,MAAM;AAAE,cAAU,CAAC,CAAC;AAAA,EAAG,GAAG,CAAC,QAAQ,QAAQ,QAAQ,WAAW,cAAc,CAAC;AAE7F,QAAM,eAAqB,kBAAY,OAAO,MAAoB,UAAwB,eA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AO,YAAY;AACvB,UAAI;AACF,cAAM,SAAS,MAAM,OAAO,OAAO,EAAE,UAAU,OAAO,QAAQ,QAAQ,WAAW,OAAO,CAAC;AACzF,YAAI,WAAW,OAAO,QAAS;AAC/B,iBAAS,OAAO;AAChB,mBAAW;AACX,iBAAS,EAAE,UAAU,OAAO,OAAO,UAAU,OAAO,MAAM,SAAS,MAAM,CAAC;AAAA,MAC5E,SAAS,OAAO;AACd,YAAI,WAAW,OAAO,QAAS;AAC/B,oBAAY;AACZ,iBAAS,CAAC,cAAc,EAAE,GAAG,UAAU,OAAO,SAAS,MAAM,EAAE;AAAA,MACjE;AACA,UAAI,CAAC,WAAW,OAAO,SAAS;AAC9B,gBAAQ,WAAW,MAAM,KAAK,IAAI,KAAO,KAAK,IAAI,KAAK,cAAc,IAAI,KAAK,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC;AAAA,MACtG;AAAA,IACF;AACA,SAAK,KAAK;AACV,WAAO,MAAM;AACX,iBAAW,MAAM;AACjB,UAAI,MAAO,cAAa,KAAK;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,UAAU,QAAQ,gBAAgB,QAAQ,CAAC;AAC/C,SAAO;AAAA,IAAE,OAAO,MAAM,aAAa,WAAW,MAAM,QAAQ,CAAC;AAAA,IAC3D,OAAO,MAAM,aAAa,WAAW,MAAM,QAAQ;AAAA,IACnD,SAAS,QAAQ,QAAQ,MAAM,MAAM,aAAa,YAAY,MAAM;AAAA,IAAU;AAAA,EAAQ;AAC1F;","names":["React","React"]}
|
|
@@ -30,6 +30,7 @@ export type AgentChatMcpAuthorizationCompletion = (input: {
|
|
|
30
30
|
serverId: string;
|
|
31
31
|
}) => Promise<void>;
|
|
32
32
|
export type AgentChatRuntimeSubmit = {
|
|
33
|
+
dictationSessionId?: string;
|
|
33
34
|
text: string;
|
|
34
35
|
files?: readonly PortableUpload[];
|
|
35
36
|
attachments?: ChatAttachment[];
|
|
@@ -39,6 +40,7 @@ export type AgentChatRuntimeHitlActionState = Omit<HitlSubmissionState, "status"
|
|
|
39
40
|
status: HitlSubmissionState["status"] | "connecting" | "resuming";
|
|
40
41
|
};
|
|
41
42
|
export type UseAgentChatRuntimeOptions = {
|
|
43
|
+
attachmentTextOutputs?: readonly string[];
|
|
42
44
|
activeThreadId?: string | null;
|
|
43
45
|
agent?: AgentChatRuntimeAgent;
|
|
44
46
|
client: AgentClient;
|
|
@@ -49,6 +51,11 @@ export type UseAgentChatRuntimeOptions = {
|
|
|
49
51
|
onModelChange?: (modelId: string) => void;
|
|
50
52
|
};
|
|
51
53
|
export type AgentChatRuntime = {
|
|
54
|
+
dictation?: {
|
|
55
|
+
agentId?: string;
|
|
56
|
+
client: AgentClient;
|
|
57
|
+
feature: import("@agents24/client").DictationFeature;
|
|
58
|
+
};
|
|
52
59
|
agent: AgentChatRuntimeAgent;
|
|
53
60
|
inputContract: ClientBootstrap["features"]["inputs"] | null;
|
|
54
61
|
allowFeedback: boolean;
|
package/dist/scaffold/app.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { AgentClient, HitlResponse } from "@agents24/client";
|
|
2
2
|
import { type AgentChatActiveThreadChangeHandler, type AgentChatMcpAuthorizationCompletion, type AgentChatRuntimeAgent } from "@agents24/chat-react/runtime";
|
|
3
|
-
import type { HitlActionState } from "@agents24/chat-react/ui";
|
|
3
|
+
import type { AgentResponseTimelineProps, HitlActionState } from "@agents24/chat-react/ui";
|
|
4
4
|
import { type ChatHitlPart, type HitlSubmissionOptions, type ChatMessage, type ChatPart } from "@agents24/react";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import type { Agents24ChatComposerProps } from "./components/chat/chat-composer";
|
|
7
7
|
import { type Agents24ChatIdentity } from "./identity";
|
|
8
|
-
export type
|
|
8
|
+
export type Agents24ChatTimelineOptions = Pick<AgentResponseTimelineProps, "nodeActivityMode" | "renderUiBlocks" | "toolLabelMode" | "toolSlots" | "toolViewMode">;
|
|
9
|
+
export type Agents24ChatAppProps = Agents24ChatTimelineOptions & {
|
|
10
|
+
attachmentTextOutputs?: readonly string[];
|
|
9
11
|
activeThreadId?: string | null;
|
|
10
12
|
agent?: AgentChatRuntimeAgent;
|
|
11
13
|
client: AgentClient;
|
|
@@ -24,7 +26,7 @@ export type Agents24ChatScaffoldComponents = {
|
|
|
24
26
|
Timeline?: React.ComponentType<Agents24ChatTimelineSlotProps>;
|
|
25
27
|
};
|
|
26
28
|
export type ChatHitlResponse = HitlResponse;
|
|
27
|
-
export type Agents24ChatTimelineSlotProps = {
|
|
29
|
+
export type Agents24ChatTimelineSlotProps = Agents24ChatTimelineOptions & {
|
|
28
30
|
message: ChatMessage;
|
|
29
31
|
parts: readonly ChatPart[];
|
|
30
32
|
isLoading: boolean;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { RealtimeDictationOptions, AgentChatSubmissionContext } from "@agents24/chat-react/ui";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { type AgentChatComposerFile } from "@agents24/chat-react/ui";
|
|
3
4
|
import { type AgentChatInputContract } from "@agents24/chat-react/runtime";
|
|
4
5
|
import type { ContextWindow } from "@agents24/client/protocol";
|
|
5
6
|
export type Agents24ChatComposerProps = {
|
|
7
|
+
realtimeDictation?: RealtimeDictationOptions;
|
|
6
8
|
queue?: React.ReactNode;
|
|
7
9
|
onRecordingStreamChange?: (stream: MediaStream | null) => void;
|
|
8
10
|
inputContract: AgentChatInputContract;
|
|
@@ -26,7 +28,7 @@ export type Agents24ChatComposerProps = {
|
|
|
26
28
|
onModelChange: (modelId: string) => void;
|
|
27
29
|
onAgentChange: (agentId: string) => void;
|
|
28
30
|
onStop: () => void;
|
|
29
|
-
onSubmit: (text: string, files: AgentChatComposerFile[]) => Promise<void>;
|
|
31
|
+
onSubmit: (text: string, files: AgentChatComposerFile[], context?: AgentChatSubmissionContext) => Promise<void>;
|
|
30
32
|
restoredDraft?: {
|
|
31
33
|
revision: number;
|
|
32
34
|
text: string;
|
|
@@ -34,4 +36,4 @@ export type Agents24ChatComposerProps = {
|
|
|
34
36
|
} | null;
|
|
35
37
|
utilityRow?: "inline" | "below";
|
|
36
38
|
};
|
|
37
|
-
export declare function ChatComposer({ inputContract, queue, onRecordingStreamChange, disabled, contextWindow, focusKey, scopeKey, forceExpanded, isCancelling, isRunning, agentId, agents, modelId, models, onModelChange, onAgentChange, onStop, onSubmit, restoredDraft, utilityRow, }: Agents24ChatComposerProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function ChatComposer({ inputContract, realtimeDictation, queue, onRecordingStreamChange, disabled, contextWindow, focusKey, scopeKey, forceExpanded, isCancelling, isRunning, agentId, agents, modelId, models, onModelChange, onAgentChange, onStop, onSubmit, restoredDraft, utilityRow, }: Agents24ChatComposerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,12 +3,13 @@ import type { FeedbackReason, HitlResponse } from "@agents24/client";
|
|
|
3
3
|
import type { AgentChatRuntimeHitlActionState } from "@agents24/chat-react/runtime";
|
|
4
4
|
import { type ChatAttachmentContentResolver } from "@agents24/chat-react/ui";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import type { Agents24ChatTimelineSlotProps } from "../../app";
|
|
6
|
+
import type { Agents24ChatTimelineSlotProps, Agents24ChatTimelineOptions } from "../../app";
|
|
7
7
|
type Props = {
|
|
8
8
|
animateCompletion: boolean;
|
|
9
9
|
message: ChatMessageModel;
|
|
10
10
|
getHitlActionState: (part: ChatHitlPart) => AgentChatRuntimeHitlActionState | undefined;
|
|
11
11
|
isLoading: boolean;
|
|
12
|
+
timelineOptions?: Agents24ChatTimelineOptions;
|
|
12
13
|
onHitlAction: (part: ChatHitlPart, response: HitlResponse, options?: HitlSubmissionOptions) => Promise<void>;
|
|
13
14
|
onRegenerate: () => Promise<void>;
|
|
14
15
|
allowFeedback: boolean;
|
|
@@ -20,5 +21,5 @@ type Props = {
|
|
|
20
21
|
Timeline?: React.ComponentType<Agents24ChatTimelineSlotProps>;
|
|
21
22
|
resolveAttachmentContent?: ChatAttachmentContentResolver;
|
|
22
23
|
};
|
|
23
|
-
export declare function ChatMessage({ animateCompletion, allowFeedback, getHitlActionState, isLoading, message, onHitlAction, onRegenerate, onSetFeedback, resolveAttachmentContent, Timeline, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function ChatMessage({ animateCompletion, allowFeedback, getHitlActionState, isLoading, timelineOptions, message, onHitlAction, onRegenerate, onSetFeedback, resolveAttachmentContent, Timeline, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
24
25
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type AgentChatRuntime } from "@agents24/chat-react/runtime";
|
|
2
|
-
import type { Agents24ChatScaffoldComponents } from "../../app";
|
|
2
|
+
import type { Agents24ChatScaffoldComponents, Agents24ChatTimelineOptions } from "../../app";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import type { Agents24ChatIdentity } from "../../identity";
|
|
5
|
-
export declare function ChatShell({ components, identity, runtime, sidebar, }: {
|
|
5
|
+
export declare function ChatShell({ components, identity, runtime, sidebar, timelineOptions, }: {
|
|
6
6
|
components?: Agents24ChatScaffoldComponents;
|
|
7
7
|
identity: Agents24ChatIdentity;
|
|
8
8
|
runtime: AgentChatRuntime;
|
|
9
9
|
sidebar?: React.ReactNode;
|
|
10
|
+
timelineOptions?: Agents24ChatTimelineOptions;
|
|
10
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,11 +2,12 @@ import type { ChatHitlPart, HitlSubmissionOptions, ChatMessage } from "@agents24
|
|
|
2
2
|
import type { HitlResponse } from "@agents24/client";
|
|
3
3
|
import type { AgentChatRuntimeHitlActionState } from "@agents24/chat-react/runtime";
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
import type { Agents24ChatTimelineSlotProps } from "../../app";
|
|
6
|
-
export declare function MessageParts({ message, getHitlActionState, isLoading, onHitlAction, Timeline, }: {
|
|
5
|
+
import type { Agents24ChatTimelineSlotProps, Agents24ChatTimelineOptions } from "../../app";
|
|
6
|
+
export declare function MessageParts({ message, getHitlActionState, isLoading, timelineOptions, onHitlAction, Timeline, }: {
|
|
7
7
|
message: ChatMessage;
|
|
8
8
|
getHitlActionState: (part: ChatHitlPart) => AgentChatRuntimeHitlActionState | undefined;
|
|
9
9
|
isLoading: boolean;
|
|
10
|
+
timelineOptions?: Agents24ChatTimelineOptions;
|
|
10
11
|
onHitlAction: (part: ChatHitlPart, response: HitlResponse, options?: HitlSubmissionOptions) => Promise<void>;
|
|
11
12
|
Timeline?: React.ComponentType<Agents24ChatTimelineSlotProps>;
|
|
12
13
|
}): import("react/jsx-runtime").JSX.Element;
|