@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.
@@ -0,0 +1,2 @@
1
+ import type { ChatMcpOauthCompletion, WaitForMcpOauthCompleteInput } from "./types";
2
+ export declare function waitForMcpOauthComplete({ popup, callbackOrigin, serverId, timeoutMs, }: WaitForMcpOauthCompleteInput): Promise<ChatMcpOauthCompletion>;
package/dist/types.d.ts CHANGED
@@ -80,13 +80,30 @@ export type ChatUiBlocksPart = {
80
80
  errorText?: string | null;
81
81
  raw: Record<string, unknown>;
82
82
  };
83
+ export type ChatHitlKind = "tool_review" | "mcp_auth" | "user_approval" | "app_data_permission";
84
+ export type ChatHitlAction = "approve" | "reject" | "connect" | "skip";
85
+ export type ChatHitlStatus = "pending" | "resolved" | "expired" | "cancelled" | "invalidated";
86
+ export type ChatHitlResolution = {
87
+ action?: ChatHitlAction | null;
88
+ outcome?: string | null;
89
+ reason?: string | null;
90
+ resolvedAt?: string | null;
91
+ resolver?: {
92
+ principalType?: string | null;
93
+ principalId?: string | null;
94
+ } | null;
95
+ };
83
96
  export type ChatHitlPart = {
84
97
  id: string;
85
98
  type: "hitl";
86
99
  kind: "hitl";
87
- hitl: Record<string, unknown>;
88
- interruptId?: string | null;
89
- hitlKind?: string | null;
100
+ interruptId: string;
101
+ hitlKind: ChatHitlKind;
102
+ message: string;
103
+ allowedActions: ChatHitlAction[];
104
+ status: ChatHitlStatus;
105
+ presentation: Record<string, unknown>;
106
+ resolution?: ChatHitlResolution | null;
90
107
  raw: Record<string, unknown>;
91
108
  };
92
109
  export type ChatErrorPart = {
@@ -235,21 +252,21 @@ export type ChatSubmitMessage = {
235
252
  state?: Record<string, unknown>;
236
253
  [key: string]: unknown;
237
254
  };
238
- export type ChatHitlDecisionType = "approve" | "edit" | "reject" | "respond" | "connect" | string;
239
- export type ChatHitlResumeDecision = {
240
- type: ChatHitlDecisionType;
241
- action_id?: string | null;
242
- message?: string;
243
- response?: string;
244
- edited_action?: Record<string, unknown>;
245
- [key: string]: unknown;
246
- };
247
255
  export type ChatHitlResumeInput = {
248
256
  runId: string;
249
257
  interruptId: string;
250
- decisions: ChatHitlResumeDecision[];
258
+ action: ChatHitlAction;
259
+ comment?: string;
251
260
  client?: Record<string, unknown>;
252
261
  };
262
+ export type ChatHitlResumeResult = {
263
+ run_id: string;
264
+ thread_id?: string | null;
265
+ interrupt_id: string;
266
+ run_status: string;
267
+ resolution_status: string;
268
+ idempotent: boolean;
269
+ };
253
270
  export type ChatMcpAuthStartInput = {
254
271
  runId: string;
255
272
  interruptId?: string | null;
@@ -260,6 +277,16 @@ export type ChatMcpAuthStartInput = {
260
277
  };
261
278
  export type ChatMcpAuthStartResult = {
262
279
  authorization_url: string;
280
+ callback_origin: string;
281
+ };
282
+ export type ChatMcpOauthCompletion = {
283
+ connectionId: string;
284
+ };
285
+ export type WaitForMcpOauthCompleteInput = {
286
+ popup: Window | null;
287
+ callbackOrigin: string;
288
+ serverId: string;
289
+ timeoutMs?: number;
263
290
  };
264
291
  export type ChatTransport = {
265
292
  listThreads: (input?: {
@@ -296,11 +323,7 @@ export type ChatTransport = {
296
323
  file: File;
297
324
  signal?: AbortSignal;
298
325
  }) => Promise<ChatAttachment>;
299
- resumeHitl?: (input: ChatHitlResumeInput) => Promise<{
300
- run_id?: string;
301
- status?: string;
302
- thread_id?: string | null;
303
- }>;
326
+ resumeHitl?: (input: ChatHitlResumeInput) => Promise<ChatHitlResumeResult>;
304
327
  startMcpAuth?: (input: ChatMcpAuthStartInput) => Promise<ChatMcpAuthStartResult>;
305
328
  subscribeThreadEvents?: (input: {
306
329
  cursor?: number | null;
@@ -346,8 +369,13 @@ export type ChatController = {
346
369
  copiedMessageId: string | null;
347
370
  lastThinkingDurationMs: number | null;
348
371
  activeRunId: string | null;
372
+ pendingHitl: ChatHitlPart | null;
373
+ isResolvingHitl: boolean;
349
374
  handleSubmit: (message: ChatSubmitMessage) => Promise<void>;
350
375
  attachRun: (runId: string, threadId?: string | null) => Promise<void>;
376
+ resumeHitl: (input: Omit<ChatHitlResumeInput, "runId"> & {
377
+ runId?: string;
378
+ }) => Promise<ChatHitlResumeResult>;
351
379
  handleStop: () => void;
352
380
  handleCopy: (content: string, messageId: string) => void;
353
381
  handleLike: (msg: ChatMessage) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
- import type { ChatHitlPart, ChatMessage, ChatPart } from "../types";
3
- import { type McpConnectRequiredStatus } from "./mcp-connect-required-card";
2
+ import type { ChatHitlAction, ChatHitlPart, ChatMessage, ChatPart } from "../types";
3
+ import type { McpConnectRequiredStatus } from "./mcp-connect-required-card";
4
4
  export type AgentChatPartActionState = {
5
5
  status?: McpConnectRequiredStatus | string;
6
6
  error?: string | null;
@@ -9,7 +9,7 @@ export type AgentResponseTimelineProps = {
9
9
  getHitlActionState?: (part: ChatHitlPart) => AgentChatPartActionState | undefined;
10
10
  isLoading?: boolean;
11
11
  message: ChatMessage;
12
- onHitlAction?: (part: ChatHitlPart, decision: string) => void;
12
+ onHitlAction?: (part: ChatHitlPart, action: ChatHitlAction, comment?: string) => void;
13
13
  renderPart?: (part: ChatPart, message: ChatMessage) => React.ReactNode;
14
14
  };
15
15
  declare function DefaultPartRow({ activeToolId, getHitlActionState, isLoading, message, onHitlAction, part, }: {
@@ -0,0 +1,4 @@
1
+ import type { ChatHitlAction, ChatHitlPart } from "../types";
2
+ export declare function hitlActionLabel(part: ChatHitlPart, action: ChatHitlAction): string;
3
+ export declare function hitlTitle(part: ChatHitlPart): string;
4
+ export declare function resolvedHitlLabel(part: ChatHitlPart): string;