@agents24/chat-react 0.2.0 → 0.3.0
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 +4 -3
- package/dist/controller-hitl.d.ts +22 -0
- package/dist/controller-options.d.ts +15 -0
- package/dist/controller-thread-events.d.ts +7 -0
- package/dist/controller.d.ts +4 -16
- package/dist/index.cjs +217 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +205 -118
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +36 -18
- package/dist/ui/agent-response-timeline.d.ts +3 -3
- package/dist/ui/index.cjs +169 -156
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +169 -156
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agents24 Chat React
|
|
2
2
|
|
|
3
|
-
Last Updated: 2026-07-
|
|
3
|
+
Last Updated: 2026-07-15
|
|
4
4
|
|
|
5
5
|
Headless React primitives for Agents24 chat surfaces.
|
|
6
6
|
|
|
@@ -22,16 +22,17 @@ 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`
|
|
25
26
|
- `partsFromResponseBlocks(blocks, fallbackText)`
|
|
26
27
|
- `renderChatPart(part, message, renderOptions)`
|
|
27
28
|
- `@agents24/chat-react/ui` for shared shadcn-derived `Message`, `Bubble`, `Attachment`, `Marker`, `MessageResponse`, `AgentChatMessage`, `AgentChatComposer`, `McpConnectRequiredCard`, and Agents24 message/attachment adapters
|
|
28
29
|
- `@agents24/chat-react/templates` for the slot-based `AgentChatShell` starter shell
|
|
29
30
|
|
|
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.
|
|
31
|
+
`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
32
|
|
|
32
33
|
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
34
|
|
|
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`, `
|
|
35
|
+
`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 compact HITL card renders pending and terminal states for Tool review, MCP authentication, User Approval, and app-data permission. Tool review exposes only **Allow once** and **Don't allow**; Edit and Respond are not part of the contract. Tool UI is client-owned through `renderPart`, `toolRenderers`, and `fallbackToolRenderer`; the package does not infer English tool labels or group tool rows.
|
|
35
36
|
|
|
36
37
|
`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
38
|
|
|
@@ -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;
|
package/dist/controller.d.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ChatController
|
|
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
|
-
|
|
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;
|