@axiom-lattice/react-sdk 1.0.11 → 1.0.13
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/dist/index.d.mts +139 -3
- package/dist/index.d.ts +139 -3
- package/dist/index.js +1756 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1777 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Message, MessageChunk } from '@axiom-lattice/protocols';
|
|
2
2
|
export * from '@axiom-lattice/protocols';
|
|
3
|
-
import
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default, { ReactNode } from 'react';
|
|
4
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
import { Client } from '@axiom-lattice/client-sdk';
|
|
7
|
+
import { Prompts } from '@ant-design/x';
|
|
8
|
+
import { GetProp } from 'antd';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Types for the Axiom Lattice React SDK
|
|
@@ -86,6 +89,15 @@ interface ChatState {
|
|
|
86
89
|
*/
|
|
87
90
|
streamingMessage: MessageChunk | null;
|
|
88
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Extended chat state with agent state
|
|
94
|
+
*/
|
|
95
|
+
interface ChatStateWithAgent extends ChatState {
|
|
96
|
+
/**
|
|
97
|
+
* Current agent state (when enableReturnStateWhenStreamCompleted is true)
|
|
98
|
+
*/
|
|
99
|
+
agentState: AgentState | null;
|
|
100
|
+
}
|
|
89
101
|
/**
|
|
90
102
|
* Chat hook options
|
|
91
103
|
*/
|
|
@@ -98,6 +110,19 @@ interface UseChatOptions {
|
|
|
98
110
|
* Initial messages to populate the chat with
|
|
99
111
|
*/
|
|
100
112
|
initialMessages?: Message[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether to return and update agent state when streaming is completed
|
|
115
|
+
*/
|
|
116
|
+
enableReturnStateWhenStreamCompleted?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to automatically resume streaming after loading messages
|
|
119
|
+
* When enabled, the hook will continuously receive new messages as they arrive
|
|
120
|
+
*/
|
|
121
|
+
enableResumeStream?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Polling interval for resume stream in milliseconds (default: 100ms)
|
|
124
|
+
*/
|
|
125
|
+
resumeStreamPollInterval?: number;
|
|
101
126
|
}
|
|
102
127
|
/**
|
|
103
128
|
* Thread hook state
|
|
@@ -196,12 +221,13 @@ interface StreamEventHandlerOptions {
|
|
|
196
221
|
* - Receiving streaming and non-streaming responses
|
|
197
222
|
* - Loading message history
|
|
198
223
|
* - Managing the chat state
|
|
224
|
+
* - Optionally returning agent state when streaming completes
|
|
199
225
|
*
|
|
200
226
|
* @param threadId - Thread ID to use for chat
|
|
201
227
|
* @param options - Chat options
|
|
202
228
|
* @returns Chat state and operations
|
|
203
229
|
*/
|
|
204
|
-
declare function useChat(threadId: string | null, options?:
|
|
230
|
+
declare function useChat<T extends UseChatOptions>(threadId: string | null, options?: T): (T["enableReturnStateWhenStreamCompleted"] extends true ? ChatStateWithAgent : ChatState) & {
|
|
205
231
|
sendMessage: (data: {
|
|
206
232
|
input?: {
|
|
207
233
|
message: string;
|
|
@@ -284,4 +310,114 @@ declare function AxiomLatticeProvider({ config, children, }: AxiomLatticeProvide
|
|
|
284
310
|
*/
|
|
285
311
|
declare function useAxiomLattice(): Client;
|
|
286
312
|
|
|
287
|
-
|
|
313
|
+
declare const MDResponse: ({ content, context, embeddedLink, interactive, userData, noGenUI, eventHandler, }: {
|
|
314
|
+
context?: any;
|
|
315
|
+
content: string;
|
|
316
|
+
embeddedLink?: boolean;
|
|
317
|
+
interactive?: boolean;
|
|
318
|
+
userData?: any;
|
|
319
|
+
noGenUI?: boolean;
|
|
320
|
+
eventHandler?: (action: string, data: any, message: string, agent?: string) => void;
|
|
321
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
322
|
+
declare const MDViewFormItem: ({ value }: {
|
|
323
|
+
value?: string;
|
|
324
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
325
|
+
|
|
326
|
+
declare const MDMermaid: ({ children }: any) => react_jsx_runtime.JSX.Element;
|
|
327
|
+
|
|
328
|
+
type ElementEventHandler = (action: string | "__open_side_app", data: {
|
|
329
|
+
component_key?: string;
|
|
330
|
+
data?: any;
|
|
331
|
+
message?: string;
|
|
332
|
+
action?: string;
|
|
333
|
+
size?: "small" | "middle" | "large";
|
|
334
|
+
config?: {
|
|
335
|
+
thread_id?: string;
|
|
336
|
+
work_log_id?: string;
|
|
337
|
+
};
|
|
338
|
+
}, message: string, agent?: string) => void;
|
|
339
|
+
type ElementProps<T = any> = {
|
|
340
|
+
component_key: string;
|
|
341
|
+
data: T;
|
|
342
|
+
eventHandler: ElementEventHandler;
|
|
343
|
+
interactive?: boolean;
|
|
344
|
+
default_open_in_side_app?: boolean;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
interface ElementMeta {
|
|
348
|
+
card_view: React.FC<ElementProps>;
|
|
349
|
+
side_app_view?: React.FC<ElementProps>;
|
|
350
|
+
action?: (data: any) => void;
|
|
351
|
+
}
|
|
352
|
+
declare const elements: Record<string, ElementMeta>;
|
|
353
|
+
declare const getElement: (language: string | undefined) => ElementMeta | null;
|
|
354
|
+
declare const regsiterElement: (language: string, ElementMeta: ElementMeta) => ElementMeta;
|
|
355
|
+
|
|
356
|
+
interface ChatingProps {
|
|
357
|
+
name?: string;
|
|
358
|
+
description?: string;
|
|
359
|
+
tenant_id: string;
|
|
360
|
+
messages: any[];
|
|
361
|
+
isLoading: boolean;
|
|
362
|
+
sendMessage: (params: any) => void;
|
|
363
|
+
stopStreaming: () => void;
|
|
364
|
+
default_submit_message?: string;
|
|
365
|
+
avatar?: string;
|
|
366
|
+
attachment_placeholder?: React__default.ReactNode;
|
|
367
|
+
onOpenSidePanel: (data: any) => void;
|
|
368
|
+
onReminderClick: () => void;
|
|
369
|
+
styles: any;
|
|
370
|
+
reminderCount: number;
|
|
371
|
+
handleMDResponseEvent: (action: string, data?: any, message?: string, agent?: string) => void;
|
|
372
|
+
senderPromptsItems: GetProp<typeof Prompts, "items">;
|
|
373
|
+
extra?: React__default.ReactNode;
|
|
374
|
+
extraMeta?: Array<{
|
|
375
|
+
id: string;
|
|
376
|
+
}>;
|
|
377
|
+
}
|
|
378
|
+
declare const Chating: React__default.FC<ChatingProps>;
|
|
379
|
+
|
|
380
|
+
interface UIMessage {
|
|
381
|
+
id: string;
|
|
382
|
+
run_id?: string;
|
|
383
|
+
content: string;
|
|
384
|
+
name?: string;
|
|
385
|
+
files?: AttachFile[];
|
|
386
|
+
role: "human" | "ai" | "tool";
|
|
387
|
+
items?: UIMessage[];
|
|
388
|
+
type: "message" | "action" | "message_chunk" | "start_thinking" | "thinking_chunk" | "end_thinking";
|
|
389
|
+
parent_id?: number | string;
|
|
390
|
+
status?: string;
|
|
391
|
+
think_id?: string;
|
|
392
|
+
think_type?: string;
|
|
393
|
+
}
|
|
394
|
+
interface AttachFile {
|
|
395
|
+
name: string;
|
|
396
|
+
id: string;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
declare const ThinkingChain: ({ message }: {
|
|
400
|
+
message: UIMessage;
|
|
401
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
402
|
+
declare const ThinkingChainGroup: ({ message }: {
|
|
403
|
+
message: UIMessage;
|
|
404
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
405
|
+
|
|
406
|
+
interface SideAppViewBrowserProps {
|
|
407
|
+
open_uri: {
|
|
408
|
+
component_key: string;
|
|
409
|
+
data: any;
|
|
410
|
+
message?: string;
|
|
411
|
+
size?: "small" | "middle" | "large" | "full";
|
|
412
|
+
};
|
|
413
|
+
eventHandler: (action: string, data: any, message: string, agent?: string) => void;
|
|
414
|
+
onClose: () => void;
|
|
415
|
+
onChangeSize: (size: "small" | "middle" | "large" | "full") => void;
|
|
416
|
+
}
|
|
417
|
+
declare const SideAppViewBrowser: React__default.FC<SideAppViewBrowserProps>;
|
|
418
|
+
|
|
419
|
+
declare const chatContext: React$1.Context<{
|
|
420
|
+
eventHandler: (component_key: string, data: any, message: string) => void;
|
|
421
|
+
}>;
|
|
422
|
+
|
|
423
|
+
export { type AgentState, type AttachFile, AxiomLatticeProvider, type AxiomLatticeProviderProps, type ChatResponse, type ChatState, type ChatStateWithAgent, Chating, type ClientConfig, type ElementEventHandler, type ElementProps, MDMermaid, MDResponse, MDViewFormItem, SideAppViewBrowser, type StreamEventHandlerOptions, ThinkingChain, ThinkingChainGroup, type Thread, type ThreadState, type UIMessage, type UseAgentStateOptions, type UseAgentStateReturn, type UseChatOptions, chatContext, elements, getElement, regsiterElement, useAgentGraph, useAgentState, useAxiomLattice, useChat, useThread };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Message, MessageChunk } from '@axiom-lattice/protocols';
|
|
2
2
|
export * from '@axiom-lattice/protocols';
|
|
3
|
-
import
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default, { ReactNode } from 'react';
|
|
4
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
import { Client } from '@axiom-lattice/client-sdk';
|
|
7
|
+
import { Prompts } from '@ant-design/x';
|
|
8
|
+
import { GetProp } from 'antd';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Types for the Axiom Lattice React SDK
|
|
@@ -86,6 +89,15 @@ interface ChatState {
|
|
|
86
89
|
*/
|
|
87
90
|
streamingMessage: MessageChunk | null;
|
|
88
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Extended chat state with agent state
|
|
94
|
+
*/
|
|
95
|
+
interface ChatStateWithAgent extends ChatState {
|
|
96
|
+
/**
|
|
97
|
+
* Current agent state (when enableReturnStateWhenStreamCompleted is true)
|
|
98
|
+
*/
|
|
99
|
+
agentState: AgentState | null;
|
|
100
|
+
}
|
|
89
101
|
/**
|
|
90
102
|
* Chat hook options
|
|
91
103
|
*/
|
|
@@ -98,6 +110,19 @@ interface UseChatOptions {
|
|
|
98
110
|
* Initial messages to populate the chat with
|
|
99
111
|
*/
|
|
100
112
|
initialMessages?: Message[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether to return and update agent state when streaming is completed
|
|
115
|
+
*/
|
|
116
|
+
enableReturnStateWhenStreamCompleted?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to automatically resume streaming after loading messages
|
|
119
|
+
* When enabled, the hook will continuously receive new messages as they arrive
|
|
120
|
+
*/
|
|
121
|
+
enableResumeStream?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Polling interval for resume stream in milliseconds (default: 100ms)
|
|
124
|
+
*/
|
|
125
|
+
resumeStreamPollInterval?: number;
|
|
101
126
|
}
|
|
102
127
|
/**
|
|
103
128
|
* Thread hook state
|
|
@@ -196,12 +221,13 @@ interface StreamEventHandlerOptions {
|
|
|
196
221
|
* - Receiving streaming and non-streaming responses
|
|
197
222
|
* - Loading message history
|
|
198
223
|
* - Managing the chat state
|
|
224
|
+
* - Optionally returning agent state when streaming completes
|
|
199
225
|
*
|
|
200
226
|
* @param threadId - Thread ID to use for chat
|
|
201
227
|
* @param options - Chat options
|
|
202
228
|
* @returns Chat state and operations
|
|
203
229
|
*/
|
|
204
|
-
declare function useChat(threadId: string | null, options?:
|
|
230
|
+
declare function useChat<T extends UseChatOptions>(threadId: string | null, options?: T): (T["enableReturnStateWhenStreamCompleted"] extends true ? ChatStateWithAgent : ChatState) & {
|
|
205
231
|
sendMessage: (data: {
|
|
206
232
|
input?: {
|
|
207
233
|
message: string;
|
|
@@ -284,4 +310,114 @@ declare function AxiomLatticeProvider({ config, children, }: AxiomLatticeProvide
|
|
|
284
310
|
*/
|
|
285
311
|
declare function useAxiomLattice(): Client;
|
|
286
312
|
|
|
287
|
-
|
|
313
|
+
declare const MDResponse: ({ content, context, embeddedLink, interactive, userData, noGenUI, eventHandler, }: {
|
|
314
|
+
context?: any;
|
|
315
|
+
content: string;
|
|
316
|
+
embeddedLink?: boolean;
|
|
317
|
+
interactive?: boolean;
|
|
318
|
+
userData?: any;
|
|
319
|
+
noGenUI?: boolean;
|
|
320
|
+
eventHandler?: (action: string, data: any, message: string, agent?: string) => void;
|
|
321
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
322
|
+
declare const MDViewFormItem: ({ value }: {
|
|
323
|
+
value?: string;
|
|
324
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
325
|
+
|
|
326
|
+
declare const MDMermaid: ({ children }: any) => react_jsx_runtime.JSX.Element;
|
|
327
|
+
|
|
328
|
+
type ElementEventHandler = (action: string | "__open_side_app", data: {
|
|
329
|
+
component_key?: string;
|
|
330
|
+
data?: any;
|
|
331
|
+
message?: string;
|
|
332
|
+
action?: string;
|
|
333
|
+
size?: "small" | "middle" | "large";
|
|
334
|
+
config?: {
|
|
335
|
+
thread_id?: string;
|
|
336
|
+
work_log_id?: string;
|
|
337
|
+
};
|
|
338
|
+
}, message: string, agent?: string) => void;
|
|
339
|
+
type ElementProps<T = any> = {
|
|
340
|
+
component_key: string;
|
|
341
|
+
data: T;
|
|
342
|
+
eventHandler: ElementEventHandler;
|
|
343
|
+
interactive?: boolean;
|
|
344
|
+
default_open_in_side_app?: boolean;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
interface ElementMeta {
|
|
348
|
+
card_view: React.FC<ElementProps>;
|
|
349
|
+
side_app_view?: React.FC<ElementProps>;
|
|
350
|
+
action?: (data: any) => void;
|
|
351
|
+
}
|
|
352
|
+
declare const elements: Record<string, ElementMeta>;
|
|
353
|
+
declare const getElement: (language: string | undefined) => ElementMeta | null;
|
|
354
|
+
declare const regsiterElement: (language: string, ElementMeta: ElementMeta) => ElementMeta;
|
|
355
|
+
|
|
356
|
+
interface ChatingProps {
|
|
357
|
+
name?: string;
|
|
358
|
+
description?: string;
|
|
359
|
+
tenant_id: string;
|
|
360
|
+
messages: any[];
|
|
361
|
+
isLoading: boolean;
|
|
362
|
+
sendMessage: (params: any) => void;
|
|
363
|
+
stopStreaming: () => void;
|
|
364
|
+
default_submit_message?: string;
|
|
365
|
+
avatar?: string;
|
|
366
|
+
attachment_placeholder?: React__default.ReactNode;
|
|
367
|
+
onOpenSidePanel: (data: any) => void;
|
|
368
|
+
onReminderClick: () => void;
|
|
369
|
+
styles: any;
|
|
370
|
+
reminderCount: number;
|
|
371
|
+
handleMDResponseEvent: (action: string, data?: any, message?: string, agent?: string) => void;
|
|
372
|
+
senderPromptsItems: GetProp<typeof Prompts, "items">;
|
|
373
|
+
extra?: React__default.ReactNode;
|
|
374
|
+
extraMeta?: Array<{
|
|
375
|
+
id: string;
|
|
376
|
+
}>;
|
|
377
|
+
}
|
|
378
|
+
declare const Chating: React__default.FC<ChatingProps>;
|
|
379
|
+
|
|
380
|
+
interface UIMessage {
|
|
381
|
+
id: string;
|
|
382
|
+
run_id?: string;
|
|
383
|
+
content: string;
|
|
384
|
+
name?: string;
|
|
385
|
+
files?: AttachFile[];
|
|
386
|
+
role: "human" | "ai" | "tool";
|
|
387
|
+
items?: UIMessage[];
|
|
388
|
+
type: "message" | "action" | "message_chunk" | "start_thinking" | "thinking_chunk" | "end_thinking";
|
|
389
|
+
parent_id?: number | string;
|
|
390
|
+
status?: string;
|
|
391
|
+
think_id?: string;
|
|
392
|
+
think_type?: string;
|
|
393
|
+
}
|
|
394
|
+
interface AttachFile {
|
|
395
|
+
name: string;
|
|
396
|
+
id: string;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
declare const ThinkingChain: ({ message }: {
|
|
400
|
+
message: UIMessage;
|
|
401
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
402
|
+
declare const ThinkingChainGroup: ({ message }: {
|
|
403
|
+
message: UIMessage;
|
|
404
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
405
|
+
|
|
406
|
+
interface SideAppViewBrowserProps {
|
|
407
|
+
open_uri: {
|
|
408
|
+
component_key: string;
|
|
409
|
+
data: any;
|
|
410
|
+
message?: string;
|
|
411
|
+
size?: "small" | "middle" | "large" | "full";
|
|
412
|
+
};
|
|
413
|
+
eventHandler: (action: string, data: any, message: string, agent?: string) => void;
|
|
414
|
+
onClose: () => void;
|
|
415
|
+
onChangeSize: (size: "small" | "middle" | "large" | "full") => void;
|
|
416
|
+
}
|
|
417
|
+
declare const SideAppViewBrowser: React__default.FC<SideAppViewBrowserProps>;
|
|
418
|
+
|
|
419
|
+
declare const chatContext: React$1.Context<{
|
|
420
|
+
eventHandler: (component_key: string, data: any, message: string) => void;
|
|
421
|
+
}>;
|
|
422
|
+
|
|
423
|
+
export { type AgentState, type AttachFile, AxiomLatticeProvider, type AxiomLatticeProviderProps, type ChatResponse, type ChatState, type ChatStateWithAgent, Chating, type ClientConfig, type ElementEventHandler, type ElementProps, MDMermaid, MDResponse, MDViewFormItem, SideAppViewBrowser, type StreamEventHandlerOptions, ThinkingChain, ThinkingChainGroup, type Thread, type ThreadState, type UIMessage, type UseAgentStateOptions, type UseAgentStateReturn, type UseChatOptions, chatContext, elements, getElement, regsiterElement, useAgentGraph, useAgentState, useAxiomLattice, useChat, useThread };
|