@spscommerce/max 0.0.1 → 0.1.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/lib/MaxPanel.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  import * as React from "react";
2
- export declare function MaxPanel({ currentUser, }: {
3
- currentUser?: any;
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,20 @@
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) => Promise<ConversationMessages>;
14
+ fetchConversationList: () => Promise<ConversationList>;
15
+ renameConversation: (conversationId: string, newTitle: string) => Promise<void>;
16
+ deleteConversation: (conversationId: string) => Promise<void>;
17
+ postFeedback: (messageId: string, score: string, comment: string) => Promise<void>;
18
+ fetchUsageStatus: (userId: string) => Promise<UsageStatus>;
19
+ postChat(message: string, currentAppName: string, currentConversationId: string | null, agentContext: object, currentUrl: string, appInitiated: boolean, userTimezone: string | null): Promise<unknown>;
20
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import { Chat } from "../models/Chat";
3
+ import { Message } from "../models/Conversation";
4
+ import "../max.scss";
5
+ interface AgentMessageProps {
6
+ children: React.ReactNode;
7
+ message?: Chat;
8
+ sendFeedback?: (messageId: string, score: string, comment: string) => void;
9
+ fetchMessagePair?: (messageId: string) => Promise<Message | undefined>;
10
+ handleSendMessage?: (message: string | undefined) => Promise<void>;
11
+ suggestedMessages?: string[];
12
+ }
13
+ export declare const AgentMessage: React.MemoExoticComponent<({ children, message, sendFeedback, fetchMessagePair, handleSendMessage, suggestedMessages, }: AgentMessageProps) => React.JSX.Element>;
14
+ 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,2 @@
1
+ import * as React from "react";
2
+ export declare const ResponseLoader: () => React.ReactNode;
@@ -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,5 @@
1
+ import * as React from "react";
2
+ export declare const SuggestedPrompt: ({ onClick, children, }: {
3
+ onClick: () => void;
4
+ children: React.ReactNode;
5
+ }) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ export declare const UserMessage: React.MemoExoticComponent<({ children }: {
3
+ children: React.ReactNode;
4
+ }) => React.JSX.Element>;
@@ -0,0 +1,30 @@
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
+ export type AgentContextValue = {
7
+ agentApiService: AgentApiService | null;
8
+ showAgentPanel: () => void;
9
+ hideAgentPanel: () => void;
10
+ toggleAgentPanelVisibility: () => void;
11
+ isAgentPanelOpen: boolean;
12
+ currentConversationId: string | null;
13
+ updateCurrentConversationId: (conversationId: string | null) => void;
14
+ lastSentUserMessage: string;
15
+ updateLastSentUserMessage: (message: string) => void;
16
+ usageStatus: "active" | "limited";
17
+ updateUsageStatus: (status: "active" | "limited") => void;
18
+ userHasAgentPerms: boolean;
19
+ updateUserHasAgentPerms: (value: boolean) => void;
20
+ isInPreprod: boolean;
21
+ updateIsInPreprod: (preprod: boolean) => void;
22
+ currentUser: CurrentUser | null;
23
+ flags: FeatureFlagsTitles | null;
24
+ isInCustomerView: boolean;
25
+ token: string | null;
26
+ env: string;
27
+ currentApp: CurrentApp | null;
28
+ };
29
+ export declare const AgentContext: React.Context<AgentContextValue>;
30
+ 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,25 @@
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
+ hasHiddenMessages: boolean;
11
+ expandRenderWindow: () => void;
12
+ streamingResponse: string | undefined;
13
+ sendMessage: (message: string, isAppInitiated: boolean, currentAppName?: string) => Promise<void>;
14
+ startNewConversation: () => void;
15
+ suggestedMessages: string[];
16
+ loadConversation: (conversationId: string) => Promise<void>;
17
+ conversationList: Conversation[];
18
+ fetchConversationList: () => Promise<void>;
19
+ sendFeedback: (messageId: string, score: string, comment: string) => Promise<void>;
20
+ fetchMessagePair: (messageId: string) => Promise<Message | undefined>;
21
+ retrySendMessage: () => Promise<void>;
22
+ messageHasBeenSent: boolean;
23
+ fetchUsageStatus: () => Promise<void>;
24
+ doesUserHaveAgentPerms: () => boolean;
25
+ };
@@ -0,0 +1,4 @@
1
+ import ANIMATED_LOGO from "./AI-logo-animated.gif";
2
+ import COLOR_LOGO from "./AI-logo-color.svg";
3
+ import BETA_LOGO from "./AI-logo-color-beta.svg";
4
+ export { ANIMATED_LOGO, COLOR_LOGO, BETA_LOGO };
package/lib/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import "./max.scss";
2
+ export * from "./icons";
2
3
  export * from "./MaxPanel";