@agents24/chat-react 0.2.0 → 0.3.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Agents24 Chat React
2
2
 
3
- Last Updated: 2026-07-13
3
+ Last Updated: 2026-07-15
4
4
 
5
5
  Headless React primitives for Agents24 chat surfaces.
6
6
 
@@ -22,16 +22,20 @@ The package owns thread hydration, older-page pagination, stream/reattach state,
22
22
  - `appendStableStreamingTurn(messages, userMessage, assistantMessage)`
23
23
  - `upsertStableAssistantMessage(messages, input)`
24
24
  - normalized chat message, part, transport, and storage types
25
+ - typed V2 `pendingHitl`, `isResolvingHitl`, and `resumeHitl(...)` controller state/actions in package `0.3.0`
26
+ - strict HITL response-block parsing and `waitForMcpOauthComplete(...)` for validated host-owned OAuth popup completion
25
27
  - `partsFromResponseBlocks(blocks, fallbackText)`
26
28
  - `renderChatPart(part, message, renderOptions)`
27
29
  - `@agents24/chat-react/ui` for shared shadcn-derived `Message`, `Bubble`, `Attachment`, `Marker`, `MessageResponse`, `AgentChatMessage`, `AgentChatComposer`, `McpConnectRequiredCard`, and Agents24 message/attachment adapters
28
30
  - `@agents24/chat-react/templates` for the slot-based `AgentChatShell` starter shell
29
31
 
30
- `useAgents24ChatController` exposes reactive `threads`, `activeThreadId`, `activeThread`, `activeRunId`, `isRefreshingThreads`, `loadThreadById(threadId)`, `attachRun(runId, threadId)`, and `startNewThread()` in addition to message and stream state. It hydrates selected threads, detects active runs from `active_run`/`last_run_status`, attaches through the host transport, detaches local SSE streams on navigation, and refreshes history after terminal events.
32
+ `useAgents24ChatController` exposes reactive `threads`, `activeThreadId`, `activeThread`, `activeRunId`, `pendingHitl`, `isResolvingHitl`, `isRefreshingThreads`, `resumeHitl(...)`, `loadThreadById(threadId)`, `attachRun(runId, threadId)`, and `startNewThread()` in addition to message and stream state. It hydrates selected threads, detects active runs from `active_run`/`last_run_status`, attaches through the host transport, detaches local SSE streams on navigation, and refreshes history after terminal events. V2 resume always reattaches after successful or idempotent resolution so the backend snapshot remains authoritative.
31
33
 
32
34
  Hosts can pass `onRuntimeEvent(event, context)` and `onThreadDetailLoaded(detail)` to layer product-specific runtime UI, trace panels, analytics, or metadata over the shared chat lifecycle without forking stream handling. That surface is enough for running-history badges and read-only live thread inspectors without a separate host-owned reattach state machine.
33
35
 
34
- `ChatMessage.parts` is the only render model. Backend `response_blocks` are normalized into ordered parts such as `text`, `tool-get_meteo`, `ui-blocks`, `reasoning`, `approval`, `error`, and `data`. Tool UI is client-owned through `renderPart`, `toolRenderers`, and `fallbackToolRenderer`; the package does not infer English tool labels or group tool rows.
36
+ `ChatMessage.parts` is the only render model. Backend `response_blocks` are normalized into ordered parts such as `text`, `tool-get_meteo`, `ui-blocks`, `reasoning`, `hitl`, `error`, and `data`. The shared HITL action strip renders a neutral, borderless pending state and a compact terminal outcome for Tool review, MCP authentication, User Approval, and app-data permission. Tool review exposes only **Allow once** and **Don't allow**; verbose risk metadata, argument details, Edit, and Respond are not part of the chat presentation. Tool UI is client-owned through `renderPart`, `toolRenderers`, and `fallbackToolRenderer`; the package does not infer English tool labels or group tool rows.
37
+
38
+ MCP OAuth remains a host side effect. `startMcpAuth(...)` returns both `authorization_url` and the authoritative `callback_origin`; hosts open the popup and pass both values to `waitForMcpOauthComplete(...)` before calling `resumeHitl(...)`. The utility verifies popup identity, callback origin, server identity, and connection UUID and owns timeout/close cleanup.
35
39
 
36
40
  `useStreamingText` owns reusable visual pacing for active assistant text. It returns `displayedText`, `isAnimating`, `mode`, and `parseIncompleteMarkdown` so host renderers can pass those values into their markdown component without the package depending on any markdown/UI library. The package only chooses text timing, cache behavior, reduced-motion handling, and active text-part helpers.
37
41
 
@@ -0,0 +1,22 @@
1
+ import { type MutableRefObject } from "react";
2
+ import type { ChatHitlPart, ChatHitlResumeInput, ChatHitlResumeResult, ChatMessage, ChatTransport } from "./types";
3
+ type RunStream = (input: {
4
+ mode: "attach";
5
+ threadId: string;
6
+ runId: string;
7
+ }) => Promise<void>;
8
+ export declare function useControllerHitl({ messages, transport, activeRunId, activeRunIdRef, activeThreadIdRef, runStream, }: {
9
+ messages: ChatMessage[];
10
+ transport: ChatTransport;
11
+ activeRunId: string | null;
12
+ activeRunIdRef: MutableRefObject<string | null>;
13
+ activeThreadIdRef: MutableRefObject<string | null>;
14
+ runStream: RunStream;
15
+ }): {
16
+ pendingHitl: ChatHitlPart | null;
17
+ isResolvingHitl: boolean;
18
+ resumeHitl: (input: Omit<ChatHitlResumeInput, "runId"> & {
19
+ runId?: string;
20
+ }) => Promise<ChatHitlResumeResult>;
21
+ };
22
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { ChatRuntimeEventContext } from "./controller-helpers";
2
+ import type { ChatMessage, ChatRuntimeEvent, ChatStorageAdapter, ChatTransport } from "./types";
3
+ export type UseAgents24ChatControllerOptions = {
4
+ transport: ChatTransport;
5
+ storage: ChatStorageAdapter;
6
+ activeThreadId?: string | null;
7
+ pageSize?: number;
8
+ storageKey?: unknown;
9
+ createId?: () => string;
10
+ onActiveThreadIdChange?: (threadId: string | null) => void;
11
+ onSourceClick?: (citations: ChatMessage["citations"]) => void;
12
+ onStreamErrorMessage?: (error: unknown) => string;
13
+ onRuntimeEvent?: (event: ChatRuntimeEvent, context: ChatRuntimeEventContext) => void | Promise<void>;
14
+ onThreadDetailLoaded?: (detail: unknown) => void | Promise<void>;
15
+ };
@@ -0,0 +1,7 @@
1
+ import type { ChatStorageAdapter, ChatTransport, StoredChatThread } from "./types";
2
+ export declare function useControllerThreadEvents({ transport, storage, refresh, setThreads, }: {
3
+ transport: ChatTransport;
4
+ storage: ChatStorageAdapter;
5
+ refresh: () => Promise<void>;
6
+ setThreads: (threads: StoredChatThread[]) => void;
7
+ }): void;
@@ -1,17 +1,5 @@
1
- import { type ChatRuntimeEventContext } from "./controller-helpers";
2
- import type { ChatController, ChatMessage, ChatRuntimeEvent, ChatStorageAdapter, ChatTransport } from "./types";
1
+ import type { UseAgents24ChatControllerOptions } from "./controller-options";
2
+ import type { ChatController } from "./types";
3
3
  export { mergeStoredThreadsForRefresh } from "./controller-helpers";
4
- export type UseAgents24ChatControllerOptions = {
5
- transport: ChatTransport;
6
- storage: ChatStorageAdapter;
7
- activeThreadId?: string | null;
8
- pageSize?: number;
9
- storageKey?: unknown;
10
- createId?: () => string;
11
- onActiveThreadIdChange?: (threadId: string | null) => void;
12
- onSourceClick?: (citations: ChatMessage["citations"]) => void;
13
- onStreamErrorMessage?: (error: unknown) => string;
14
- onRuntimeEvent?: (event: ChatRuntimeEvent, context: ChatRuntimeEventContext) => void | Promise<void>;
15
- onThreadDetailLoaded?: (detail: unknown) => void | Promise<void>;
16
- };
17
- export declare function useAgents24ChatController({ transport, storage, activeThreadId: controlledActiveThreadId, pageSize, storageKey, createId, onActiveThreadIdChange, onSourceClick, onStreamErrorMessage, onRuntimeEvent, onThreadDetailLoaded, }: UseAgents24ChatControllerOptions): ChatController;
4
+ export type { UseAgents24ChatControllerOptions } from "./controller-options";
5
+ export declare function useAgents24ChatController(options: UseAgents24ChatControllerOptions): ChatController;