@agents24/react 0.2.6 → 0.2.8
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/compatibility.json +8 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +852 -299
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +17 -1
- package/dist/state.d.ts +5 -1
- package/dist/thread-message-queue.d.ts +47 -0
- package/dist/thread-summary-subscription.d.ts +12 -0
- package/dist/use-agent-chat-feedback.d.ts +13 -0
- package/dist/use-agent-chat-queue-actions.d.ts +20 -0
- package/dist/use-agent-chat-thread-list.d.ts +20 -0
- package/dist/use-agent-chat.d.ts +11 -1
- package/dist/use-agent-resources.d.ts +14 -1
- package/package.json +3 -3
package/dist/model.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AttachmentResult, FailureView, HitlAction, ResponseFeedback, RuntimeEvent, ThreadDetail, ThreadSummary } from "@agents24/client";
|
|
2
2
|
import { type ContextCompression, type ContextWindow } from "@agents24/client/protocol";
|
|
3
3
|
export type AgentChatMessageRole = "user" | "assistant";
|
|
4
|
-
export type AgentChatRunState = "idle" | "uploading" | "streaming" | "reconnecting" | "paused" | "cancelling" | "completed" | "cancelled" | "failed";
|
|
4
|
+
export type AgentChatRunState = "idle" | "uploading" | "streaming" | "reconnecting" | "paused" | "waiting" | "interrupted" | "cancelling" | "completed" | "cancelled" | "failed";
|
|
5
5
|
export type ChatCitation = {
|
|
6
6
|
title: string;
|
|
7
7
|
url: string;
|
|
@@ -64,6 +64,13 @@ export type ChatTextPart = ChatPartMetadata & {
|
|
|
64
64
|
kind: "text";
|
|
65
65
|
text: string;
|
|
66
66
|
};
|
|
67
|
+
export type ChatComputerResourceTarget = {
|
|
68
|
+
type: "computer";
|
|
69
|
+
thread_id: string;
|
|
70
|
+
computer_id: string;
|
|
71
|
+
path: string;
|
|
72
|
+
kind: "file" | "directory";
|
|
73
|
+
};
|
|
67
74
|
export type ChatToolPart = ChatPartMetadata & {
|
|
68
75
|
type: `tool-${string}`;
|
|
69
76
|
kind: "tool";
|
|
@@ -77,6 +84,7 @@ export type ChatToolPart = ChatPartMetadata & {
|
|
|
77
84
|
state: ChatToolState;
|
|
78
85
|
input?: unknown;
|
|
79
86
|
output?: unknown;
|
|
87
|
+
resourceTargets?: readonly ChatComputerResourceTarget[];
|
|
80
88
|
errorText?: string | null;
|
|
81
89
|
failure?: FailureView | null;
|
|
82
90
|
presentation: ChatToolPresentation;
|
|
@@ -194,6 +202,9 @@ export type ChatAttachmentPart = ChatPartMetadata & {
|
|
|
194
202
|
export type ChatPart = ChatTextPart | ChatToolPart | ChatReasoningPart | ChatModelTurnPart | ChatContextCompressionPart | ChatNodeActivityPart | ChatUiBlocksPart | ChatHitlPart | ChatErrorPart | ChatDataPart | ChatSourcePart | ChatCitationPart | ChatAttachmentPart;
|
|
195
203
|
export type ChatMessage = {
|
|
196
204
|
id: string;
|
|
205
|
+
/** Durable timeline identity when a mounted optimistic turn keeps its display key. */
|
|
206
|
+
durableId?: string;
|
|
207
|
+
segmentIndex?: number | null;
|
|
197
208
|
role: AgentChatMessageRole;
|
|
198
209
|
runId?: string | null;
|
|
199
210
|
content: string;
|
|
@@ -215,6 +226,9 @@ export type ChatMessage = {
|
|
|
215
226
|
isVoice?: boolean;
|
|
216
227
|
};
|
|
217
228
|
export type StoredChatThread = ThreadSummary & {
|
|
229
|
+
taskNotifications?: Array<Record<string, unknown> & {
|
|
230
|
+
handle: string;
|
|
231
|
+
}>;
|
|
218
232
|
messages: ChatMessage[];
|
|
219
233
|
isHydrated?: boolean;
|
|
220
234
|
hasOlderTurns?: boolean;
|
|
@@ -232,6 +246,7 @@ export type ThreadActivity = {
|
|
|
232
246
|
isCancelled: boolean;
|
|
233
247
|
};
|
|
234
248
|
export declare function getThreadActivity(thread: Pick<ThreadSummary, "active_run" | "last_run_id" | "last_run_status">): ThreadActivity;
|
|
249
|
+
export declare function computerResourceTargets(value: unknown): ChatComputerResourceTarget[];
|
|
235
250
|
export declare function partsFromResponseBlocks(blocks: unknown, fallbackText?: string, fallbackPartId?: string): ChatPart[];
|
|
236
251
|
export declare function assistantProjectionFromEvent(event: RuntimeEvent): {
|
|
237
252
|
content: string;
|
|
@@ -240,6 +255,7 @@ export declare function assistantProjectionFromEvent(event: RuntimeEvent): {
|
|
|
240
255
|
export declare function modelTurnPartFromEvent(event: RuntimeEvent): ChatModelTurnPart | null;
|
|
241
256
|
export declare function contextCompressionPartFromEvent(event: RuntimeEvent, existingParts?: readonly ChatPart[]): ChatContextCompressionPart | null;
|
|
242
257
|
export declare function threadDetailToMessages(detail: ThreadDetail): ChatMessage[];
|
|
258
|
+
export declare function threadTimelineToMessages(items: readonly import("@agents24/client").ThreadMessage[], detail?: ThreadDetail): ChatMessage[];
|
|
243
259
|
export declare function latestThreadContext(detail: ThreadDetail): {
|
|
244
260
|
contextWindow: ContextWindow | null;
|
|
245
261
|
contextCompression: ContextCompression | null;
|
package/dist/state.d.ts
CHANGED
|
@@ -42,7 +42,8 @@ export declare function clearAgentChatBackgroundError(state: AgentChatState): Ag
|
|
|
42
42
|
* Reconcile the authoritative first page without dropping a locally-created
|
|
43
43
|
* active thread before it becomes visible in the server's list projection.
|
|
44
44
|
*/
|
|
45
|
-
export declare function reconcileRefreshedThreads(current: StoredChatThread[], incoming: StoredChatThread[], activeThreadId: string | null): StoredChatThread[];
|
|
45
|
+
export declare function reconcileRefreshedThreads(current: StoredChatThread[], incoming: StoredChatThread[], activeThreadId: string | null, concurrentEvents?: readonly ThreadSummaryEvent[]): StoredChatThread[];
|
|
46
|
+
export declare function preferNewestThreadSummary(current: StoredChatThread | undefined, incoming: StoredChatThread): StoredChatThread;
|
|
46
47
|
/** Adopt the server-created thread without reloading the in-memory transcript. */
|
|
47
48
|
export declare function adoptStreamingThread(state: AgentChatState, threadId: string): AgentChatState;
|
|
48
49
|
export type StableChatMessageBase = {
|
|
@@ -55,9 +56,12 @@ export type StableAssistantUpsertInput<TMessage extends StableChatMessageBase> =
|
|
|
55
56
|
create: () => TMessage;
|
|
56
57
|
messageId?: string | null;
|
|
57
58
|
runId?: string | null;
|
|
59
|
+
strictMessageId?: boolean;
|
|
58
60
|
update: (message: TMessage) => TMessage;
|
|
59
61
|
};
|
|
60
62
|
export declare function appendStableStreamingTurn<TMessage extends StableChatMessageBase>(messages: TMessage[], userMessage: TMessage, assistantMessage: TMessage): TMessage[];
|
|
63
|
+
/** Keep mounted display keys while matching only durable IDs and run linkage. */
|
|
64
|
+
export declare function preserveMountedMessageIds(canonical: ChatMessage[], current: ChatMessage[]): ChatMessage[];
|
|
61
65
|
export declare function upsertStableAssistantMessage<TMessage extends StableChatMessageBase>(messages: TMessage[], input: StableAssistantUpsertInput<TMessage>): TMessage[];
|
|
62
66
|
export declare function applyRuntimeEvent(state: AgentChatState, event: RuntimeEvent): AgentChatState;
|
|
63
67
|
export declare function applyRuntimeEvents(state: AgentChatState, events: readonly RuntimeEvent[]): AgentChatState;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ThreadMessage, ThreadMessageInput, ThreadMessageQueueState, ThreadMessageSubmission, ThreadMessagesPage } from "@agents24/client";
|
|
2
|
+
export type ThreadMessageNotice = {
|
|
3
|
+
messageId: string;
|
|
4
|
+
status: string;
|
|
5
|
+
runId: string | null;
|
|
6
|
+
cursor?: number;
|
|
7
|
+
};
|
|
8
|
+
export type ThreadMessageQueueTransport = {
|
|
9
|
+
list(threadId: string): Promise<ThreadMessagesPage>;
|
|
10
|
+
submit(input: ThreadMessageInput): Promise<ThreadMessageSubmission>;
|
|
11
|
+
edit(message: ThreadMessage, input: {
|
|
12
|
+
text: string;
|
|
13
|
+
attachmentIds?: readonly string[];
|
|
14
|
+
requestedAgentId?: string;
|
|
15
|
+
requestedModelId?: string;
|
|
16
|
+
mode?: "steer";
|
|
17
|
+
}): Promise<ThreadMessage>;
|
|
18
|
+
remove(message: ThreadMessage): Promise<void>;
|
|
19
|
+
resume(threadId: string): Promise<{
|
|
20
|
+
run_id: string | null;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
export type RetractedMessageDraft = Pick<ThreadMessage, "text" | "attachment_ids" | "attachments">;
|
|
24
|
+
export declare function useThreadMessageQueue({ threadId, transport, onPromoted }: {
|
|
25
|
+
threadId: string | null;
|
|
26
|
+
transport: ThreadMessageQueueTransport;
|
|
27
|
+
onPromoted: (message: ThreadMessage, runId: string) => void;
|
|
28
|
+
}): {
|
|
29
|
+
pendingMessages: readonly ThreadMessage[];
|
|
30
|
+
messageQueue: ThreadMessageQueueState | null;
|
|
31
|
+
refresh: (selectedThreadId?: string | null) => Promise<ThreadMessagesPage | null>;
|
|
32
|
+
hydrate: (page: ThreadMessagesPage, selectedThreadId: string) => void;
|
|
33
|
+
acceptNotice: (notice: ThreadMessageNotice) => boolean;
|
|
34
|
+
submit: (input: Omit<ThreadMessageInput, "threadId">) => Promise<ThreadMessageSubmission>;
|
|
35
|
+
edit: (message: ThreadMessage, input: {
|
|
36
|
+
text: string;
|
|
37
|
+
attachmentIds?: readonly string[];
|
|
38
|
+
requestedAgentId?: string;
|
|
39
|
+
requestedModelId?: string;
|
|
40
|
+
mode?: "steer";
|
|
41
|
+
}) => Promise<ThreadMessage>;
|
|
42
|
+
remove: (message: ThreadMessage) => Promise<void>;
|
|
43
|
+
retractForEdit: (message: ThreadMessage) => Promise<RetractedMessageDraft>;
|
|
44
|
+
resume: () => Promise<{
|
|
45
|
+
run_id: string | null;
|
|
46
|
+
} | null>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AbortSignalLike, AgentClient, ThreadSummaryEvent } from "@agents24/client";
|
|
2
|
+
type ThreadSummarySubscription = {
|
|
3
|
+
client: AgentClient;
|
|
4
|
+
signal: AbortSignalLike;
|
|
5
|
+
onEvent(event: ThreadSummaryEvent): Promise<void> | void;
|
|
6
|
+
onError(error: unknown): void;
|
|
7
|
+
onRecovered(): void;
|
|
8
|
+
refresh(): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
/** Keep the thread list connected across clean EOFs and transient stream failures. */
|
|
11
|
+
export declare function subscribeToThreadSummaries(input: ThreadSummarySubscription): Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentClient, FeedbackReason } from "@agents24/client";
|
|
2
|
+
import type { ChatMessage } from "./model";
|
|
3
|
+
import { type AgentChatOperation, type AgentChatState } from "./state";
|
|
4
|
+
export declare function useAgentChatFeedback({ client, update, clearOperationError, failOperation }: {
|
|
5
|
+
client: AgentClient;
|
|
6
|
+
update: (updater: (current: AgentChatState) => AgentChatState) => void;
|
|
7
|
+
clearOperationError: () => void;
|
|
8
|
+
failOperation: (operation: AgentChatOperation, cause: unknown) => void;
|
|
9
|
+
}): (message: ChatMessage, input: {
|
|
10
|
+
rating: "like" | "dislike" | null;
|
|
11
|
+
reason?: FeedbackReason | null;
|
|
12
|
+
comment?: string | null;
|
|
13
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ThreadMessage } from "@agents24/client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import type { AgentChatSubmitInput } from "./use-agent-chat";
|
|
4
|
+
import { useThreadMessageQueue } from "./thread-message-queue";
|
|
5
|
+
import type { AgentChatOperation, AgentChatState } from "./state";
|
|
6
|
+
export declare function useAgentChatQueueActions({ queue, stateRef, createId, clearOperationError, failOperation, refreshMessages, attachRun }: {
|
|
7
|
+
queue: ReturnType<typeof useThreadMessageQueue>;
|
|
8
|
+
stateRef: React.RefObject<AgentChatState>;
|
|
9
|
+
createId: () => string;
|
|
10
|
+
clearOperationError: () => void;
|
|
11
|
+
failOperation: (operation: AgentChatOperation, cause: unknown) => void;
|
|
12
|
+
refreshMessages: (threadId: string) => Promise<void>;
|
|
13
|
+
attachRun: (runId: string) => Promise<void>;
|
|
14
|
+
}): {
|
|
15
|
+
steer: (text: string) => Promise<void>;
|
|
16
|
+
editPendingMessage: (message: ThreadMessage, input: Pick<AgentChatSubmitInput, "text" | "attachmentIds" | "requestedAgentId" | "requestedModelId">) => Promise<void>;
|
|
17
|
+
steerPendingMessage: (message: ThreadMessage) => Promise<void>;
|
|
18
|
+
removePendingMessage: (message: ThreadMessage) => Promise<void>;
|
|
19
|
+
resumeQueue: () => Promise<void>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentClient, ThreadSummaryEvent } from "@agents24/client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import type { StoredChatThread } from "./model";
|
|
4
|
+
import { type AgentChatOperation, type AgentChatState } from "./state";
|
|
5
|
+
export declare function summaryToStored(thread: Record<string, unknown>): StoredChatThread;
|
|
6
|
+
export declare function useAgentChatThreadList({ client, threadPageSize, stateRef, update, clearOperationError, failOperation }: {
|
|
7
|
+
client: AgentClient;
|
|
8
|
+
threadPageSize: number;
|
|
9
|
+
stateRef: React.RefObject<AgentChatState>;
|
|
10
|
+
update: (updater: (current: AgentChatState) => AgentChatState) => void;
|
|
11
|
+
clearOperationError: () => void;
|
|
12
|
+
failOperation: (operation: AgentChatOperation, cause: unknown) => void;
|
|
13
|
+
}): {
|
|
14
|
+
isLoadingThreads: boolean;
|
|
15
|
+
isLoadingMoreThreads: boolean;
|
|
16
|
+
threadTotal: number | undefined;
|
|
17
|
+
eventsDuringRefreshRef: React.RefObject<ThreadSummaryEvent[] | null>;
|
|
18
|
+
refreshThreads: () => Promise<void>;
|
|
19
|
+
loadMoreThreads: () => Promise<void>;
|
|
20
|
+
};
|
package/dist/use-agent-chat.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AgentClient, FeedbackReason, HitlResponse, PortableUpload } from "@agents24/client";
|
|
1
|
+
import type { AgentClient, FeedbackReason, HitlResponse, PortableUpload, ThreadMessage, ThreadMessageQueueState } from "@agents24/client";
|
|
2
2
|
import type { ChatAttachment, ChatHitlPart, ChatMessage, StoredChatThread } from "./model";
|
|
3
|
+
import { type RetractedMessageDraft } from "./thread-message-queue";
|
|
3
4
|
import { type AgentChatOperation, type AgentChatState } from "./state";
|
|
4
5
|
export type AgentChatSubmitInput = {
|
|
5
6
|
text: string;
|
|
@@ -16,6 +17,8 @@ export type UseAgentChatOptions = {
|
|
|
16
17
|
threadPageSize?: number;
|
|
17
18
|
};
|
|
18
19
|
export type AgentChatController = AgentChatState & {
|
|
20
|
+
pendingMessages: readonly ThreadMessage[];
|
|
21
|
+
messageQueue: ThreadMessageQueueState | null;
|
|
19
22
|
activeThread: StoredChatThread | null;
|
|
20
23
|
hasOlderTurns: boolean;
|
|
21
24
|
hasMoreThreads: boolean;
|
|
@@ -35,6 +38,13 @@ export type AgentChatController = AgentChatState & {
|
|
|
35
38
|
openThread(threadId: string): Promise<void>;
|
|
36
39
|
refreshThreads(): Promise<void>;
|
|
37
40
|
regenerate(message: ChatMessage): Promise<void>;
|
|
41
|
+
refreshMessages(threadId?: string): Promise<void>;
|
|
42
|
+
editPendingMessage(message: ThreadMessage, input: Pick<AgentChatSubmitInput, "text" | "attachmentIds" | "requestedAgentId" | "requestedModelId">): Promise<void>;
|
|
43
|
+
steerPendingMessage(message: ThreadMessage): Promise<void>;
|
|
44
|
+
removePendingMessage(message: ThreadMessage): Promise<void>;
|
|
45
|
+
retractPendingMessage(message: ThreadMessage): Promise<RetractedMessageDraft>;
|
|
46
|
+
resumeQueue(): Promise<void>;
|
|
47
|
+
steer(text: string): Promise<void>;
|
|
38
48
|
resumeHitl(part: ChatHitlPart, response: HitlResponse): Promise<void>;
|
|
39
49
|
setFeedback(message: ChatMessage, input: {
|
|
40
50
|
rating: "like" | "dislike" | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AbortSignalLike, AttachmentResult, BinaryUploadData, HitlAction, HitlResumeResult, McpAuthorizationResult, McpCallbackResult, RuntimeEvent, ThreadDetail, ThreadSummary } from "@agents24/client";
|
|
1
|
+
import type { AbortSignalLike, AttachmentResult, BinaryUploadData, HitlAction, HitlResumeResult, McpAuthorizationResult, McpCallbackResult, RuntimeEvent, ThreadDetail, ThreadComputerStatus, ThreadSummary } from "@agents24/client";
|
|
2
2
|
export declare function useAgentThreads(options?: {
|
|
3
3
|
limit?: number;
|
|
4
4
|
skip?: number;
|
|
@@ -18,6 +18,19 @@ export declare function useAgentThread(threadId: string | null, options?: {
|
|
|
18
18
|
refresh: () => Promise<ThreadDetail | null>;
|
|
19
19
|
thread: ThreadDetail | null;
|
|
20
20
|
};
|
|
21
|
+
export declare function useThreadComputer(threadId: string | null): {
|
|
22
|
+
computer: ThreadComputerStatus | null;
|
|
23
|
+
error: unknown;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
list: (input: {
|
|
26
|
+
path?: string;
|
|
27
|
+
cursor?: number;
|
|
28
|
+
limit?: number;
|
|
29
|
+
}) => Promise<import("@agents24/client").ThreadComputerFiles>;
|
|
30
|
+
read: (path: string) => Promise<import("@agents24/client").ThreadComputerFileText>;
|
|
31
|
+
createContentAccess: (path: string, download?: boolean) => Promise<import("@agents24/client").ThreadComputerContentAccess>;
|
|
32
|
+
refresh: () => Promise<ThreadComputerStatus | null>;
|
|
33
|
+
};
|
|
21
34
|
export declare function useAgentRun(): {
|
|
22
35
|
attach: (runId: string, onEvent: (event: RuntimeEvent) => void | Promise<void>, cursor?: number) => Promise<import("@agents24/client").StreamResult>;
|
|
23
36
|
cancel: (runId: string) => Promise<Record<string, unknown>>;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agents24/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "DOM-free React state and hooks for Agents24 client applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/agents24/talmudpedia.git",
|
|
9
9
|
"directory": "packages/agents24-react"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"prepack": "pnpm run build && pnpm run check:boundaries"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@agents24/client": "0.2.
|
|
43
|
+
"@agents24/client": "0.2.8"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=19.0.0 <20.0.0"
|