@spscommerce/max 0.0.1 → 0.1.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/lib/MaxPanel.d.ts +14 -2
- package/lib/api-service.d.ts +23 -0
- package/lib/components/AgentMessage.d.ts +13 -0
- package/lib/components/AgentTextarea.d.ts +7 -0
- package/lib/components/ConversationList.d.ts +10 -0
- package/lib/components/DeleteConversationModal.d.ts +7 -0
- package/lib/components/MemoizedMarkdown.d.ts +7 -0
- package/lib/components/RenameConversationModal.d.ts +7 -0
- package/lib/components/ResponseLoader.d.ts +2 -0
- package/lib/components/StreamingMessage.d.ts +7 -0
- package/lib/components/SuggestedPrompt.d.ts +5 -0
- package/lib/components/UserMessage.d.ts +5 -0
- package/lib/hooks/AgentContext.d.ts +31 -0
- package/lib/hooks/AgentProvider.d.ts +20 -0
- package/lib/hooks/useAppContext.d.ts +1 -0
- package/lib/hooks/useMaxChat.d.ts +26 -0
- package/lib/icons/index.d.ts +4 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +63596 -3311
- package/lib/index.umd.cjs +12989 -36
- package/lib/models/Chat.d.ts +6 -0
- package/lib/models/Conversation.d.ts +33 -0
- package/lib/models/CurrentApp.d.ts +6 -0
- package/lib/models/CurrentUser.d.ts +23 -0
- package/lib/models/FeatureFlagsTitles.d.ts +5 -0
- package/lib/models/UsageStatus.d.ts +8 -0
- package/lib/style.css +1 -1
- package/lib/utils.d.ts +7 -0
- package/package.json +7 -5
- package/lib/useMaxChat.d.ts +0 -3
package/lib/MaxPanel.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { FeatureFlagsTitles } from "./models/FeatureFlagsTitles";
|
|
3
|
+
import { CurrentApp } from "./models/CurrentApp";
|
|
4
|
+
import { CurrentUser } from "./models/CurrentUser";
|
|
5
|
+
export declare function MaxPanel({ token, currentUser, hideAgentPanel, isAgentPanelOpen, isInCustomerView, flags, env, currentApp, context, currentConversationId, }: {
|
|
6
|
+
token: string | null;
|
|
7
|
+
currentUser: CurrentUser | undefined;
|
|
8
|
+
hideAgentPanel: () => void;
|
|
9
|
+
isAgentPanelOpen: boolean;
|
|
10
|
+
isInCustomerView: boolean;
|
|
11
|
+
flags: FeatureFlagsTitles;
|
|
12
|
+
env: string;
|
|
13
|
+
currentApp: CurrentApp;
|
|
14
|
+
context: () => Record<any, any>;
|
|
15
|
+
currentConversationId?: string | null;
|
|
4
16
|
}): React.ReactNode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConversationList, ConversationMessages } from "./models/Conversation";
|
|
2
|
+
import type { UsageStatus } from "./models/UsageStatus";
|
|
3
|
+
export declare class AgentApiService {
|
|
4
|
+
private readonly url;
|
|
5
|
+
private readonly urlWs;
|
|
6
|
+
private readonly environment;
|
|
7
|
+
private readonly axios;
|
|
8
|
+
private token;
|
|
9
|
+
private socket;
|
|
10
|
+
constructor(env: string, token?: string | null);
|
|
11
|
+
setToken(token?: string | null): void;
|
|
12
|
+
getSocket(): WebSocket | null;
|
|
13
|
+
fetchConversationMessages: (conversationId: string, options?: {
|
|
14
|
+
cursor?: string;
|
|
15
|
+
limit?: number;
|
|
16
|
+
}) => Promise<ConversationMessages>;
|
|
17
|
+
fetchConversationList: () => Promise<ConversationList>;
|
|
18
|
+
renameConversation: (conversationId: string, newTitle: string) => Promise<void>;
|
|
19
|
+
deleteConversation: (conversationId: string) => Promise<void>;
|
|
20
|
+
postFeedback: (messageId: string, score: string, comment: string) => Promise<void>;
|
|
21
|
+
fetchUsageStatus: (userId: string) => Promise<UsageStatus>;
|
|
22
|
+
postChat(message: string, currentAppName: string, currentConversationId: string | null, agentContext: object, currentUrl: string, appInitiated: boolean, userTimezone: string | null): Promise<unknown>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Chat } from "../models/Chat";
|
|
3
|
+
import { Message } from "../models/Conversation";
|
|
4
|
+
interface AgentMessageProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
message?: Chat;
|
|
7
|
+
sendFeedback?: (messageId: string, score: string, comment: string) => void;
|
|
8
|
+
fetchMessagePair?: (messageId: string) => Promise<Message | undefined>;
|
|
9
|
+
handleSendMessage?: (message: string | undefined) => Promise<void>;
|
|
10
|
+
suggestedMessages?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const AgentMessage: React.MemoExoticComponent<({ children, message, sendFeedback, fetchMessagePair, handleSendMessage, suggestedMessages, }: AgentMessageProps) => React.JSX.Element>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export declare function AgentTextarea({ onSendMessage, setMessage, message, isMessageLoading, }: {
|
|
3
|
+
onSendMessage: (message: string, appInitiated: boolean, currentAppName?: string | undefined) => Promise<void>;
|
|
4
|
+
setMessage: (message: string) => void;
|
|
5
|
+
message: string;
|
|
6
|
+
isMessageLoading: boolean;
|
|
7
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Conversation } from "../models/Conversation";
|
|
3
|
+
export declare const ConversationList: ({ conversations, setShowConversationList, onLoadConversation, onRefreshConversationList, onLoading, isInCustomerView, }: {
|
|
4
|
+
conversations: Conversation[];
|
|
5
|
+
setShowConversationList: (show: boolean) => void;
|
|
6
|
+
onLoadConversation: (id: string) => void;
|
|
7
|
+
onRefreshConversationList: () => void;
|
|
8
|
+
onLoading: boolean;
|
|
9
|
+
isInCustomerView: boolean;
|
|
10
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Conversation } from "../models/Conversation";
|
|
3
|
+
export declare function DeleteConversationModal({ conversation, setShowModal, onDelete, }: {
|
|
4
|
+
conversation: Conversation | null;
|
|
5
|
+
setShowModal: (show: Conversation | null) => void;
|
|
6
|
+
onDelete: () => void;
|
|
7
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type Components } from "react-markdown";
|
|
3
|
+
export declare const MemoizedMarkdown: React.MemoExoticComponent<({ content, components, useRehypeRaw, }: {
|
|
4
|
+
content: string | undefined;
|
|
5
|
+
components?: Components;
|
|
6
|
+
useRehypeRaw?: boolean;
|
|
7
|
+
}) => React.JSX.Element>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Conversation } from "../models/Conversation";
|
|
3
|
+
export declare function RenameConversationModal({ conversation, setShowModal, onRename, }: {
|
|
4
|
+
conversation: Conversation | null;
|
|
5
|
+
setShowModal: (show: Conversation | null) => void;
|
|
6
|
+
onRename: () => void;
|
|
7
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Components } from "react-markdown";
|
|
3
|
+
export declare const StreamingMessage: React.MemoExoticComponent<({ streamingResponse, isAgentThinking, markdownComponents, }: {
|
|
4
|
+
streamingResponse: string | undefined;
|
|
5
|
+
isAgentThinking: boolean;
|
|
6
|
+
markdownComponents?: Components;
|
|
7
|
+
}) => React.JSX.Element>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AgentApiService } from "../api-service";
|
|
3
|
+
import { CurrentUser } from "../models/CurrentUser";
|
|
4
|
+
import { CurrentApp } from "../models/CurrentApp";
|
|
5
|
+
import { FeatureFlagsTitles } from "../models/FeatureFlagsTitles";
|
|
6
|
+
import { UserStatus } from "../models/UsageStatus";
|
|
7
|
+
export type AgentContextValue = {
|
|
8
|
+
agentApiService: AgentApiService | null;
|
|
9
|
+
showAgentPanel: () => void;
|
|
10
|
+
hideAgentPanel: () => void;
|
|
11
|
+
toggleAgentPanelVisibility: () => void;
|
|
12
|
+
isAgentPanelOpen: boolean;
|
|
13
|
+
currentConversationId: string | null;
|
|
14
|
+
updateCurrentConversationId: (conversationId: string | null) => void;
|
|
15
|
+
lastSentUserMessage: string;
|
|
16
|
+
updateLastSentUserMessage: (message: string) => void;
|
|
17
|
+
usageStatus: UserStatus;
|
|
18
|
+
updateUsageStatus: (status: UserStatus) => void;
|
|
19
|
+
userHasAgentPerms: boolean;
|
|
20
|
+
updateUserHasAgentPerms: (value: boolean) => void;
|
|
21
|
+
isInPreprod: boolean;
|
|
22
|
+
updateIsInPreprod: (preprod: boolean) => void;
|
|
23
|
+
currentUser: CurrentUser | null;
|
|
24
|
+
flags: FeatureFlagsTitles | null;
|
|
25
|
+
isInCustomerView: boolean;
|
|
26
|
+
token: string | null;
|
|
27
|
+
env: string;
|
|
28
|
+
currentApp: CurrentApp | null;
|
|
29
|
+
};
|
|
30
|
+
export declare const AgentContext: React.Context<AgentContextValue>;
|
|
31
|
+
export declare const useAgentContext: () => AgentContextValue;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AgentApiService } from "../api-service";
|
|
3
|
+
import { CurrentApp } from "../models/CurrentApp";
|
|
4
|
+
import { FeatureFlagsTitles } from "../models/FeatureFlagsTitles";
|
|
5
|
+
import { CurrentUser } from "../models/CurrentUser";
|
|
6
|
+
type AgentProviderProps = {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
token: string | null;
|
|
9
|
+
env: string;
|
|
10
|
+
currentUser: CurrentUser | undefined;
|
|
11
|
+
flags: FeatureFlagsTitles;
|
|
12
|
+
isInCustomerView: boolean;
|
|
13
|
+
agentApiService: AgentApiService;
|
|
14
|
+
hideAgentPanelCallback: () => void;
|
|
15
|
+
isAgentPanelOpenProp: boolean;
|
|
16
|
+
currentApp: CurrentApp;
|
|
17
|
+
currentConversationId: string | null;
|
|
18
|
+
};
|
|
19
|
+
declare const AgentProvider: React.FC<AgentProviderProps>;
|
|
20
|
+
export { AgentProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAppContext: () => import("./AgentContext").AgentContextValue;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Chat } from "../models/Chat";
|
|
2
|
+
import { Conversation, Message } from "../models/Conversation";
|
|
3
|
+
import { AgentApiService } from "../api-service";
|
|
4
|
+
export declare function useMaxChat(agentApi: AgentApiService, context: () => Record<any, any>): {
|
|
5
|
+
error: boolean;
|
|
6
|
+
loading: boolean;
|
|
7
|
+
isAgentThinking: boolean;
|
|
8
|
+
messages: Chat[];
|
|
9
|
+
displayedMessages: Chat[];
|
|
10
|
+
hasMoreMessages: boolean;
|
|
11
|
+
loadOlderMessages: () => Promise<void>;
|
|
12
|
+
isLoadingOlderMessages: boolean;
|
|
13
|
+
streamingResponse: string | undefined;
|
|
14
|
+
sendMessage: (message: string, isAppInitiated: boolean, currentAppName?: string) => Promise<void>;
|
|
15
|
+
startNewConversation: () => void;
|
|
16
|
+
suggestedMessages: string[];
|
|
17
|
+
loadConversation: (conversationId: string) => Promise<void>;
|
|
18
|
+
conversationList: Conversation[];
|
|
19
|
+
fetchConversationList: () => Promise<void>;
|
|
20
|
+
sendFeedback: (messageId: string, score: string, comment: string) => Promise<void>;
|
|
21
|
+
fetchMessagePair: (messageId: string) => Promise<Message | undefined>;
|
|
22
|
+
retrySendMessage: () => Promise<void>;
|
|
23
|
+
messageHasBeenSent: boolean;
|
|
24
|
+
fetchUsageStatus: () => Promise<import("../models/UsageStatus").UserStatus | undefined>;
|
|
25
|
+
doesUserHaveAgentPerms: () => boolean;
|
|
26
|
+
};
|
package/lib/index.d.ts
CHANGED