@cadraos/sdk 0.3.15 → 0.3.16-dev.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/dist/chat/index.cjs +159 -0
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +132 -1
- package/dist/chat/index.d.ts +132 -1
- package/dist/chat/index.js +157 -1
- package/dist/chat/index.js.map +1 -1
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -1
- package/dist/index.d.ts +99 -1
- package/dist/index.js +57 -1
- package/dist/index.js.map +1 -1
- package/dist/kanban/index.cjs +56 -0
- package/dist/kanban/index.cjs.map +1 -1
- package/dist/kanban/index.d.cts +87 -0
- package/dist/kanban/index.d.ts +87 -0
- package/dist/kanban/index.js +56 -0
- package/dist/kanban/index.js.map +1 -1
- package/dist/teams/index.cjs +56 -0
- package/dist/teams/index.cjs.map +1 -1
- package/dist/teams/index.d.cts +87 -0
- package/dist/teams/index.d.ts +87 -0
- package/dist/teams/index.js +56 -0
- package/dist/teams/index.js.map +1 -1
- package/package.json +1 -1
package/dist/chat/index.d.cts
CHANGED
|
@@ -830,6 +830,51 @@ interface ExecuteResponse {
|
|
|
830
830
|
/** Initial status */
|
|
831
831
|
status: ExecutionStatus;
|
|
832
832
|
}
|
|
833
|
+
/**
|
|
834
|
+
* Languages an agent message can be stored and rendered in.
|
|
835
|
+
*/
|
|
836
|
+
type AgentMessageLang = 'en' | 'es' | 'id';
|
|
837
|
+
/**
|
|
838
|
+
* One saved agent message (e.g. `handoff.requested`), text per language.
|
|
839
|
+
*/
|
|
840
|
+
interface AgentMessage {
|
|
841
|
+
/** Lowercase dotted key, e.g. `chat.welcome` */
|
|
842
|
+
key: string;
|
|
843
|
+
/** Text per language; `en` is the fallback language */
|
|
844
|
+
text: Partial<Record<AgentMessageLang, string>>;
|
|
845
|
+
/** `{word}` placeholder names found in any language */
|
|
846
|
+
placeholders: string[];
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Response of `client.agents.messages.list()`
|
|
850
|
+
*/
|
|
851
|
+
interface AgentMessageList {
|
|
852
|
+
/** The resolved agent (a team uuid resolves to its lead agent) */
|
|
853
|
+
agentUuid: string;
|
|
854
|
+
/** The agent's saved messages, sorted by key */
|
|
855
|
+
messages: AgentMessage[];
|
|
856
|
+
/** Every key the platform knows about, for pickers (saved or not) */
|
|
857
|
+
knownKeys: string[];
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Options for `client.agents.messages.render()`
|
|
861
|
+
*/
|
|
862
|
+
interface AgentMessageRenderOptions {
|
|
863
|
+
/** Requested language; falls back to `en` server-side */
|
|
864
|
+
lang?: AgentMessageLang;
|
|
865
|
+
/** Values for `{word}` placeholders; unknown placeholders are left as-is */
|
|
866
|
+
vars?: Record<string, string | number>;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Response of `client.agents.messages.render()`
|
|
870
|
+
*/
|
|
871
|
+
interface AgentMessageRenderResult {
|
|
872
|
+
key: string;
|
|
873
|
+
/** The language actually rendered */
|
|
874
|
+
lang: AgentMessageLang;
|
|
875
|
+
/** Filled text, or `null` when the agent has no message for this key */
|
|
876
|
+
text: string | null;
|
|
877
|
+
}
|
|
833
878
|
|
|
834
879
|
/**
|
|
835
880
|
* Streaming types
|
|
@@ -2771,6 +2816,46 @@ interface StreamImagesResult {
|
|
|
2771
2816
|
executionId: string;
|
|
2772
2817
|
}
|
|
2773
2818
|
|
|
2819
|
+
/**
|
|
2820
|
+
* Agent Messages Resource API (p13)
|
|
2821
|
+
*
|
|
2822
|
+
* Read-only access to an agent's saved messages (welcome, handoff, fallback
|
|
2823
|
+
* copy, ...). Reached as `client.agents.messages`.
|
|
2824
|
+
* - list(): the agent's saved messages + every known key
|
|
2825
|
+
* - render(): one message filled with vars, in a language (falls back to en)
|
|
2826
|
+
*/
|
|
2827
|
+
|
|
2828
|
+
declare class AgentMessagesAPI extends BaseResourceAPI {
|
|
2829
|
+
constructor(http: HttpClient);
|
|
2830
|
+
/**
|
|
2831
|
+
* List an agent's saved messages and the known keys
|
|
2832
|
+
*
|
|
2833
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
2834
|
+
*
|
|
2835
|
+
* @example
|
|
2836
|
+
* ```typescript
|
|
2837
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
2838
|
+
* ```
|
|
2839
|
+
*/
|
|
2840
|
+
list(agentUuid: string): Promise<AgentMessageList>;
|
|
2841
|
+
/**
|
|
2842
|
+
* Render one message with placeholders filled
|
|
2843
|
+
*
|
|
2844
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
2845
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
2846
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
2847
|
+
*
|
|
2848
|
+
* @example
|
|
2849
|
+
* ```typescript
|
|
2850
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
2851
|
+
* lang: 'es',
|
|
2852
|
+
* vars: { agentName: 'Ana' },
|
|
2853
|
+
* });
|
|
2854
|
+
* ```
|
|
2855
|
+
*/
|
|
2856
|
+
render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2774
2859
|
/**
|
|
2775
2860
|
* Agents Resource API
|
|
2776
2861
|
*
|
|
@@ -2786,6 +2871,8 @@ interface StreamImagesResult {
|
|
|
2786
2871
|
*/
|
|
2787
2872
|
declare class AgentsAPI extends BaseResourceAPI {
|
|
2788
2873
|
private readonly getStreamConfig;
|
|
2874
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
2875
|
+
readonly messages: AgentMessagesAPI;
|
|
2789
2876
|
constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
|
|
2790
2877
|
/**
|
|
2791
2878
|
* List all agents in the organization
|
|
@@ -5178,6 +5265,50 @@ interface ChatInputProps {
|
|
|
5178
5265
|
*/
|
|
5179
5266
|
declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, attachments, onRemoveAttachment, dropZoneRef, isUploadingAttachments, className, onInputChange, onInputControlReady, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
5180
5267
|
|
|
5268
|
+
/** The slice of CadraClient the picker uses. */
|
|
5269
|
+
interface AgentMessagePickerClient {
|
|
5270
|
+
agents: {
|
|
5271
|
+
messages: {
|
|
5272
|
+
list(agentUuid: string): Promise<AgentMessageList>;
|
|
5273
|
+
};
|
|
5274
|
+
};
|
|
5275
|
+
}
|
|
5276
|
+
/** UI labels; override to translate. */
|
|
5277
|
+
interface AgentMessagePickerLabels {
|
|
5278
|
+
search: string;
|
|
5279
|
+
loading: string;
|
|
5280
|
+
loadError: string;
|
|
5281
|
+
empty: string;
|
|
5282
|
+
notSet: string;
|
|
5283
|
+
useCustom: (key: string) => string;
|
|
5284
|
+
invalidCustom: string;
|
|
5285
|
+
}
|
|
5286
|
+
interface AgentMessagePickerProps {
|
|
5287
|
+
client: AgentMessagePickerClient;
|
|
5288
|
+
agentUuid: string;
|
|
5289
|
+
/** Selected key */
|
|
5290
|
+
value?: string | null;
|
|
5291
|
+
onChange: (key: string) => void;
|
|
5292
|
+
/** Let the user type a new dotted key */
|
|
5293
|
+
allowCustom?: boolean;
|
|
5294
|
+
/** Preview language (falls back to en). Default: en */
|
|
5295
|
+
lang?: AgentMessageLang;
|
|
5296
|
+
labels?: Partial<AgentMessagePickerLabels>;
|
|
5297
|
+
className?: string;
|
|
5298
|
+
}
|
|
5299
|
+
declare function AgentMessagePicker({ client, agentUuid, value, onChange, allowCustom, lang, labels: labelOverrides, className, }: AgentMessagePickerProps): react_jsx_runtime.JSX.Element;
|
|
5300
|
+
|
|
5301
|
+
/**
|
|
5302
|
+
* Agent message keys (p13) — lowercase dotted, e.g. `chat.welcome`.
|
|
5303
|
+
*
|
|
5304
|
+
* Same rule cadra-web enforces on `/api/v1/agents/:id/messages/render`, so an
|
|
5305
|
+
* invalid key fails client-side before a request is made. Kept free of any
|
|
5306
|
+
* client import so the chat entry can use it without pulling in the client.
|
|
5307
|
+
*/
|
|
5308
|
+
declare const MESSAGE_KEY_PATTERN: RegExp;
|
|
5309
|
+
/** True when `key` is a valid lowercase dotted agent message key. */
|
|
5310
|
+
declare function isValidMessageKey(key: string): boolean;
|
|
5311
|
+
|
|
5181
5312
|
/**
|
|
5182
5313
|
* Tool name patterns for internal/orchestration tools that should be hidden
|
|
5183
5314
|
* in compact verbosity mode. These are matched after stripping common prefixes
|
|
@@ -5420,4 +5551,4 @@ declare function ClockIcon({ className, ...props }: IconProps): react_jsx_runtim
|
|
|
5420
5551
|
*/
|
|
5421
5552
|
declare function compressImage(file: File, targetSizeKB?: number): Promise<File>;
|
|
5422
5553
|
|
|
5423
|
-
export { AgentChat, type AgentChatProps, AlertCircleIcon, type Artifact$1 as Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, type CurrentStep, DatabaseIcon, type DefaultAdapterConfig, type DelegationEvent, DelegationProgress, DelegationProgressList, type DelegationProgressListProps, type DelegationProgressProps, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileDropZone, type FileDropZoneProps, type FileDropZoneRef, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, INTERNAL_TOOL_NAMES, type IconProps, type ImageData, ImageGallery, type ImageGalleryProps, ImageIcon, ImageLightbox, type ImageLightboxProps, type ImageStreamClient, type ImageStreamStatus, ImagesIcon, type ListSessionsInput, ListTodoIcon, LoadingSpinner, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput$1 as SendMessageInput, type SendMessageOptions, type SessionHistory$1 as SessionHistory, type SessionList, type SessionListItem, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, ThinkingBlock, ThinkingBlockList, type ThinkingBlockListProps, type ThinkingBlockProps, type ThinkingBlock$1 as ThinkingBlockType, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type ToolCallVerbosity, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, type UseImageStreamOptions, type UseImageStreamResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments, useImageStream };
|
|
5554
|
+
export { AgentChat, type AgentChatProps, AgentMessagePicker, type AgentMessagePickerClient, type AgentMessagePickerLabels, type AgentMessagePickerProps, AlertCircleIcon, type Artifact$1 as Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, type CurrentStep, DatabaseIcon, type DefaultAdapterConfig, type DelegationEvent, DelegationProgress, DelegationProgressList, type DelegationProgressListProps, type DelegationProgressProps, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileDropZone, type FileDropZoneProps, type FileDropZoneRef, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, INTERNAL_TOOL_NAMES, type IconProps, type ImageData, ImageGallery, type ImageGalleryProps, ImageIcon, ImageLightbox, type ImageLightboxProps, type ImageStreamClient, type ImageStreamStatus, ImagesIcon, type ListSessionsInput, ListTodoIcon, LoadingSpinner, MESSAGE_KEY_PATTERN, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput$1 as SendMessageInput, type SendMessageOptions, type SessionHistory$1 as SessionHistory, type SessionList, type SessionListItem, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, ThinkingBlock, ThinkingBlockList, type ThinkingBlockListProps, type ThinkingBlockProps, type ThinkingBlock$1 as ThinkingBlockType, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type ToolCallVerbosity, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, type UseImageStreamOptions, type UseImageStreamResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, isValidMessageKey, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments, useImageStream };
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -830,6 +830,51 @@ interface ExecuteResponse {
|
|
|
830
830
|
/** Initial status */
|
|
831
831
|
status: ExecutionStatus;
|
|
832
832
|
}
|
|
833
|
+
/**
|
|
834
|
+
* Languages an agent message can be stored and rendered in.
|
|
835
|
+
*/
|
|
836
|
+
type AgentMessageLang = 'en' | 'es' | 'id';
|
|
837
|
+
/**
|
|
838
|
+
* One saved agent message (e.g. `handoff.requested`), text per language.
|
|
839
|
+
*/
|
|
840
|
+
interface AgentMessage {
|
|
841
|
+
/** Lowercase dotted key, e.g. `chat.welcome` */
|
|
842
|
+
key: string;
|
|
843
|
+
/** Text per language; `en` is the fallback language */
|
|
844
|
+
text: Partial<Record<AgentMessageLang, string>>;
|
|
845
|
+
/** `{word}` placeholder names found in any language */
|
|
846
|
+
placeholders: string[];
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Response of `client.agents.messages.list()`
|
|
850
|
+
*/
|
|
851
|
+
interface AgentMessageList {
|
|
852
|
+
/** The resolved agent (a team uuid resolves to its lead agent) */
|
|
853
|
+
agentUuid: string;
|
|
854
|
+
/** The agent's saved messages, sorted by key */
|
|
855
|
+
messages: AgentMessage[];
|
|
856
|
+
/** Every key the platform knows about, for pickers (saved or not) */
|
|
857
|
+
knownKeys: string[];
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Options for `client.agents.messages.render()`
|
|
861
|
+
*/
|
|
862
|
+
interface AgentMessageRenderOptions {
|
|
863
|
+
/** Requested language; falls back to `en` server-side */
|
|
864
|
+
lang?: AgentMessageLang;
|
|
865
|
+
/** Values for `{word}` placeholders; unknown placeholders are left as-is */
|
|
866
|
+
vars?: Record<string, string | number>;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Response of `client.agents.messages.render()`
|
|
870
|
+
*/
|
|
871
|
+
interface AgentMessageRenderResult {
|
|
872
|
+
key: string;
|
|
873
|
+
/** The language actually rendered */
|
|
874
|
+
lang: AgentMessageLang;
|
|
875
|
+
/** Filled text, or `null` when the agent has no message for this key */
|
|
876
|
+
text: string | null;
|
|
877
|
+
}
|
|
833
878
|
|
|
834
879
|
/**
|
|
835
880
|
* Streaming types
|
|
@@ -2771,6 +2816,46 @@ interface StreamImagesResult {
|
|
|
2771
2816
|
executionId: string;
|
|
2772
2817
|
}
|
|
2773
2818
|
|
|
2819
|
+
/**
|
|
2820
|
+
* Agent Messages Resource API (p13)
|
|
2821
|
+
*
|
|
2822
|
+
* Read-only access to an agent's saved messages (welcome, handoff, fallback
|
|
2823
|
+
* copy, ...). Reached as `client.agents.messages`.
|
|
2824
|
+
* - list(): the agent's saved messages + every known key
|
|
2825
|
+
* - render(): one message filled with vars, in a language (falls back to en)
|
|
2826
|
+
*/
|
|
2827
|
+
|
|
2828
|
+
declare class AgentMessagesAPI extends BaseResourceAPI {
|
|
2829
|
+
constructor(http: HttpClient);
|
|
2830
|
+
/**
|
|
2831
|
+
* List an agent's saved messages and the known keys
|
|
2832
|
+
*
|
|
2833
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
2834
|
+
*
|
|
2835
|
+
* @example
|
|
2836
|
+
* ```typescript
|
|
2837
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
2838
|
+
* ```
|
|
2839
|
+
*/
|
|
2840
|
+
list(agentUuid: string): Promise<AgentMessageList>;
|
|
2841
|
+
/**
|
|
2842
|
+
* Render one message with placeholders filled
|
|
2843
|
+
*
|
|
2844
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
2845
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
2846
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
2847
|
+
*
|
|
2848
|
+
* @example
|
|
2849
|
+
* ```typescript
|
|
2850
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
2851
|
+
* lang: 'es',
|
|
2852
|
+
* vars: { agentName: 'Ana' },
|
|
2853
|
+
* });
|
|
2854
|
+
* ```
|
|
2855
|
+
*/
|
|
2856
|
+
render(agentUuid: string, key: string, options?: AgentMessageRenderOptions): Promise<AgentMessageRenderResult>;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2774
2859
|
/**
|
|
2775
2860
|
* Agents Resource API
|
|
2776
2861
|
*
|
|
@@ -2786,6 +2871,8 @@ interface StreamImagesResult {
|
|
|
2786
2871
|
*/
|
|
2787
2872
|
declare class AgentsAPI extends BaseResourceAPI {
|
|
2788
2873
|
private readonly getStreamConfig;
|
|
2874
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
2875
|
+
readonly messages: AgentMessagesAPI;
|
|
2789
2876
|
constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
|
|
2790
2877
|
/**
|
|
2791
2878
|
* List all agents in the organization
|
|
@@ -5178,6 +5265,50 @@ interface ChatInputProps {
|
|
|
5178
5265
|
*/
|
|
5179
5266
|
declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, attachments, onRemoveAttachment, dropZoneRef, isUploadingAttachments, className, onInputChange, onInputControlReady, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
5180
5267
|
|
|
5268
|
+
/** The slice of CadraClient the picker uses. */
|
|
5269
|
+
interface AgentMessagePickerClient {
|
|
5270
|
+
agents: {
|
|
5271
|
+
messages: {
|
|
5272
|
+
list(agentUuid: string): Promise<AgentMessageList>;
|
|
5273
|
+
};
|
|
5274
|
+
};
|
|
5275
|
+
}
|
|
5276
|
+
/** UI labels; override to translate. */
|
|
5277
|
+
interface AgentMessagePickerLabels {
|
|
5278
|
+
search: string;
|
|
5279
|
+
loading: string;
|
|
5280
|
+
loadError: string;
|
|
5281
|
+
empty: string;
|
|
5282
|
+
notSet: string;
|
|
5283
|
+
useCustom: (key: string) => string;
|
|
5284
|
+
invalidCustom: string;
|
|
5285
|
+
}
|
|
5286
|
+
interface AgentMessagePickerProps {
|
|
5287
|
+
client: AgentMessagePickerClient;
|
|
5288
|
+
agentUuid: string;
|
|
5289
|
+
/** Selected key */
|
|
5290
|
+
value?: string | null;
|
|
5291
|
+
onChange: (key: string) => void;
|
|
5292
|
+
/** Let the user type a new dotted key */
|
|
5293
|
+
allowCustom?: boolean;
|
|
5294
|
+
/** Preview language (falls back to en). Default: en */
|
|
5295
|
+
lang?: AgentMessageLang;
|
|
5296
|
+
labels?: Partial<AgentMessagePickerLabels>;
|
|
5297
|
+
className?: string;
|
|
5298
|
+
}
|
|
5299
|
+
declare function AgentMessagePicker({ client, agentUuid, value, onChange, allowCustom, lang, labels: labelOverrides, className, }: AgentMessagePickerProps): react_jsx_runtime.JSX.Element;
|
|
5300
|
+
|
|
5301
|
+
/**
|
|
5302
|
+
* Agent message keys (p13) — lowercase dotted, e.g. `chat.welcome`.
|
|
5303
|
+
*
|
|
5304
|
+
* Same rule cadra-web enforces on `/api/v1/agents/:id/messages/render`, so an
|
|
5305
|
+
* invalid key fails client-side before a request is made. Kept free of any
|
|
5306
|
+
* client import so the chat entry can use it without pulling in the client.
|
|
5307
|
+
*/
|
|
5308
|
+
declare const MESSAGE_KEY_PATTERN: RegExp;
|
|
5309
|
+
/** True when `key` is a valid lowercase dotted agent message key. */
|
|
5310
|
+
declare function isValidMessageKey(key: string): boolean;
|
|
5311
|
+
|
|
5181
5312
|
/**
|
|
5182
5313
|
* Tool name patterns for internal/orchestration tools that should be hidden
|
|
5183
5314
|
* in compact verbosity mode. These are matched after stripping common prefixes
|
|
@@ -5420,4 +5551,4 @@ declare function ClockIcon({ className, ...props }: IconProps): react_jsx_runtim
|
|
|
5420
5551
|
*/
|
|
5421
5552
|
declare function compressImage(file: File, targetSizeKB?: number): Promise<File>;
|
|
5422
5553
|
|
|
5423
|
-
export { AgentChat, type AgentChatProps, AlertCircleIcon, type Artifact$1 as Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, type CurrentStep, DatabaseIcon, type DefaultAdapterConfig, type DelegationEvent, DelegationProgress, DelegationProgressList, type DelegationProgressListProps, type DelegationProgressProps, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileDropZone, type FileDropZoneProps, type FileDropZoneRef, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, INTERNAL_TOOL_NAMES, type IconProps, type ImageData, ImageGallery, type ImageGalleryProps, ImageIcon, ImageLightbox, type ImageLightboxProps, type ImageStreamClient, type ImageStreamStatus, ImagesIcon, type ListSessionsInput, ListTodoIcon, LoadingSpinner, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput$1 as SendMessageInput, type SendMessageOptions, type SessionHistory$1 as SessionHistory, type SessionList, type SessionListItem, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, ThinkingBlock, ThinkingBlockList, type ThinkingBlockListProps, type ThinkingBlockProps, type ThinkingBlock$1 as ThinkingBlockType, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type ToolCallVerbosity, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, type UseImageStreamOptions, type UseImageStreamResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments, useImageStream };
|
|
5554
|
+
export { AgentChat, type AgentChatProps, AgentMessagePicker, type AgentMessagePickerClient, type AgentMessagePickerLabels, type AgentMessagePickerProps, AlertCircleIcon, type Artifact$1 as Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, type CurrentStep, DatabaseIcon, type DefaultAdapterConfig, type DelegationEvent, DelegationProgress, DelegationProgressList, type DelegationProgressListProps, type DelegationProgressProps, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileDropZone, type FileDropZoneProps, type FileDropZoneRef, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, INTERNAL_TOOL_NAMES, type IconProps, type ImageData, ImageGallery, type ImageGalleryProps, ImageIcon, ImageLightbox, type ImageLightboxProps, type ImageStreamClient, type ImageStreamStatus, ImagesIcon, type ListSessionsInput, ListTodoIcon, LoadingSpinner, MESSAGE_KEY_PATTERN, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput$1 as SendMessageInput, type SendMessageOptions, type SessionHistory$1 as SessionHistory, type SessionList, type SessionListItem, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, ThinkingBlock, ThinkingBlockList, type ThinkingBlockListProps, type ThinkingBlockProps, type ThinkingBlock$1 as ThinkingBlockType, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type ToolCallVerbosity, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, type UseImageStreamOptions, type UseImageStreamResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, isValidMessageKey, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments, useImageStream };
|
package/dist/chat/index.js
CHANGED
|
@@ -1823,13 +1823,69 @@ function executionCancelPath(executionId) {
|
|
|
1823
1823
|
return `${EXECUTION_PATH}/${executionId}/cancel`;
|
|
1824
1824
|
}
|
|
1825
1825
|
|
|
1826
|
+
// src/utils/message-key.ts
|
|
1827
|
+
var MESSAGE_KEY_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/;
|
|
1828
|
+
function isValidMessageKey(key) {
|
|
1829
|
+
return MESSAGE_KEY_PATTERN.test(key);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// src/resources/agent-messages.ts
|
|
1833
|
+
var AgentMessagesAPI = class extends BaseResourceAPI {
|
|
1834
|
+
constructor(http) {
|
|
1835
|
+
super(http, "/api/v1/agents");
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* List an agent's saved messages and the known keys
|
|
1839
|
+
*
|
|
1840
|
+
* @param agentUuid - Agent UUID (a team UUID resolves to its lead agent)
|
|
1841
|
+
*
|
|
1842
|
+
* @example
|
|
1843
|
+
* ```typescript
|
|
1844
|
+
* const { messages, knownKeys } = await client.agents.messages.list('agent-uuid');
|
|
1845
|
+
* ```
|
|
1846
|
+
*/
|
|
1847
|
+
async list(agentUuid) {
|
|
1848
|
+
return this.httpGet(`/${agentUuid}/messages`);
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Render one message with placeholders filled
|
|
1852
|
+
*
|
|
1853
|
+
* Resolves with `text: null` when the agent has no message for the key.
|
|
1854
|
+
* Throws `ValidationError` before any request when the key is not a
|
|
1855
|
+
* lowercase dotted key (see `MESSAGE_KEY_PATTERN`).
|
|
1856
|
+
*
|
|
1857
|
+
* @example
|
|
1858
|
+
* ```typescript
|
|
1859
|
+
* const { text } = await client.agents.messages.render('agent-uuid', 'handoff.requested', {
|
|
1860
|
+
* lang: 'es',
|
|
1861
|
+
* vars: { agentName: 'Ana' },
|
|
1862
|
+
* });
|
|
1863
|
+
* ```
|
|
1864
|
+
*/
|
|
1865
|
+
async render(agentUuid, key, options = {}) {
|
|
1866
|
+
if (!isValidMessageKey(key)) {
|
|
1867
|
+
throw new ValidationError(`Invalid message key "${key}"`, [
|
|
1868
|
+
{ field: "key", message: "Must be a lowercase dotted key, e.g. chat.welcome" }
|
|
1869
|
+
]);
|
|
1870
|
+
}
|
|
1871
|
+
return this.httpPost(`/${agentUuid}/messages/render`, {
|
|
1872
|
+
key,
|
|
1873
|
+
...options.lang ? { lang: options.lang } : {},
|
|
1874
|
+
...options.vars ? { vars: options.vars } : {}
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1826
1879
|
// src/resources/agents.ts
|
|
1827
1880
|
var AgentsAPI = class extends BaseResourceAPI {
|
|
1828
1881
|
constructor(http, getStreamConfig) {
|
|
1829
1882
|
super(http, "/api/v1/agents");
|
|
1830
1883
|
this.getStreamConfig = getStreamConfig;
|
|
1884
|
+
this.messages = new AgentMessagesAPI(http);
|
|
1831
1885
|
}
|
|
1832
1886
|
getStreamConfig;
|
|
1887
|
+
/** Saved agent messages (p13): `list()` and `render()` */
|
|
1888
|
+
messages;
|
|
1833
1889
|
// ===== LIST Operations =====
|
|
1834
1890
|
/**
|
|
1835
1891
|
* List all agents in the organization
|
|
@@ -9603,6 +9659,106 @@ function useImageStream(options) {
|
|
|
9603
9659
|
}, [client, providedExecutionId, agentUuid, inputKey, sessionId, shouldConnect]);
|
|
9604
9660
|
return { images, status, error, executionId, output, cancel };
|
|
9605
9661
|
}
|
|
9662
|
+
var DEFAULT_LABELS = {
|
|
9663
|
+
search: "Search messages",
|
|
9664
|
+
loading: "Loading messages",
|
|
9665
|
+
loadError: "Could not load messages",
|
|
9666
|
+
empty: "No matching messages",
|
|
9667
|
+
notSet: "not set",
|
|
9668
|
+
useCustom: (key) => `Use "${key}"`,
|
|
9669
|
+
invalidCustom: "Keys are lowercase and dotted, like chat.welcome"
|
|
9670
|
+
};
|
|
9671
|
+
function previewOf(message, lang) {
|
|
9672
|
+
return message.text[lang] ?? message.text.en ?? Object.values(message.text).find(Boolean) ?? null;
|
|
9673
|
+
}
|
|
9674
|
+
function AgentMessagePicker({
|
|
9675
|
+
client,
|
|
9676
|
+
agentUuid,
|
|
9677
|
+
value,
|
|
9678
|
+
onChange,
|
|
9679
|
+
allowCustom = false,
|
|
9680
|
+
lang = "en",
|
|
9681
|
+
labels: labelOverrides,
|
|
9682
|
+
className = ""
|
|
9683
|
+
}) {
|
|
9684
|
+
const labels = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
9685
|
+
const [data, setData] = useState(null);
|
|
9686
|
+
const [error, setError] = useState(false);
|
|
9687
|
+
const [query, setQuery] = useState("");
|
|
9688
|
+
useEffect(() => {
|
|
9689
|
+
let cancelled = false;
|
|
9690
|
+
setData(null);
|
|
9691
|
+
setError(false);
|
|
9692
|
+
client.agents.messages.list(agentUuid).then((result) => {
|
|
9693
|
+
if (!cancelled) setData(result);
|
|
9694
|
+
}).catch(() => {
|
|
9695
|
+
if (!cancelled) setError(true);
|
|
9696
|
+
});
|
|
9697
|
+
return () => {
|
|
9698
|
+
cancelled = true;
|
|
9699
|
+
};
|
|
9700
|
+
}, [client, agentUuid]);
|
|
9701
|
+
const items = useMemo(() => {
|
|
9702
|
+
if (!data) return [];
|
|
9703
|
+
const saved = data.messages.map((m) => ({ key: m.key, preview: previewOf(m, lang) }));
|
|
9704
|
+
const savedKeys = new Set(saved.map((i) => i.key));
|
|
9705
|
+
const unsaved = data.knownKeys.filter((k) => !savedKeys.has(k)).sort().map((key) => ({ key, preview: null }));
|
|
9706
|
+
return [...saved, ...unsaved];
|
|
9707
|
+
}, [data, lang]);
|
|
9708
|
+
const needle = query.trim().toLowerCase();
|
|
9709
|
+
const visible = needle ? items.filter(
|
|
9710
|
+
(i) => i.key.includes(needle) || (i.preview?.toLowerCase().includes(needle) ?? false)
|
|
9711
|
+
) : items;
|
|
9712
|
+
const custom = query.trim();
|
|
9713
|
+
const showCustom = allowCustom && custom.length > 0 && !items.some((i) => i.key === custom);
|
|
9714
|
+
const customValid = showCustom && isValidMessageKey(custom);
|
|
9715
|
+
return /* @__PURE__ */ jsxs("div", { className: `flex flex-col gap-2 text-sm ${className}`, children: [
|
|
9716
|
+
/* @__PURE__ */ jsx(
|
|
9717
|
+
"input",
|
|
9718
|
+
{
|
|
9719
|
+
type: "search",
|
|
9720
|
+
value: query,
|
|
9721
|
+
onChange: (e) => setQuery(e.target.value),
|
|
9722
|
+
placeholder: labels.search,
|
|
9723
|
+
"aria-label": labels.search,
|
|
9724
|
+
className: "w-full rounded-lg bg-gray-100 dark:bg-gray-800 px-3 py-2 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
9725
|
+
}
|
|
9726
|
+
),
|
|
9727
|
+
error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "px-1 text-red-500", children: labels.loadError }) : !data ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 px-1 text-gray-500 dark:text-gray-400", children: [
|
|
9728
|
+
/* @__PURE__ */ jsx(LoadingSpinner, { className: "h-4 w-4" }),
|
|
9729
|
+
labels.loading
|
|
9730
|
+
] }) : /* @__PURE__ */ jsxs("ul", { role: "listbox", "aria-label": labels.search, className: "flex max-h-72 flex-col gap-0.5 overflow-y-auto", children: [
|
|
9731
|
+
visible.map((item) => {
|
|
9732
|
+
const selected = item.key === value;
|
|
9733
|
+
return /* @__PURE__ */ jsx("li", { role: "option", "aria-selected": selected, children: /* @__PURE__ */ jsxs(
|
|
9734
|
+
"button",
|
|
9735
|
+
{
|
|
9736
|
+
type: "button",
|
|
9737
|
+
onClick: () => onChange(item.key),
|
|
9738
|
+
className: `flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left transition-colors ${selected ? "bg-blue-50 dark:bg-blue-900/30" : "hover:bg-gray-100 dark:hover:bg-gray-800"}`,
|
|
9739
|
+
children: [
|
|
9740
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
9741
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-gray-900 dark:text-gray-100", children: item.key }),
|
|
9742
|
+
item.preview !== null ? /* @__PURE__ */ jsx("span", { className: "truncate text-gray-500 dark:text-gray-400", children: item.preview }) : /* @__PURE__ */ jsx("span", { className: "italic text-gray-400 dark:text-gray-500", children: labels.notSet })
|
|
9743
|
+
] }),
|
|
9744
|
+
selected && /* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4 flex-shrink-0 text-blue-500" })
|
|
9745
|
+
]
|
|
9746
|
+
}
|
|
9747
|
+
) }, item.key);
|
|
9748
|
+
}),
|
|
9749
|
+
visible.length === 0 && !showCustom && /* @__PURE__ */ jsx("li", { className: "px-3 py-2 text-gray-500 dark:text-gray-400", children: labels.empty })
|
|
9750
|
+
] }),
|
|
9751
|
+
data && showCustom && (customValid ? /* @__PURE__ */ jsx(
|
|
9752
|
+
"button",
|
|
9753
|
+
{
|
|
9754
|
+
type: "button",
|
|
9755
|
+
onClick: () => onChange(custom),
|
|
9756
|
+
className: "rounded-lg bg-gray-100 dark:bg-gray-800 px-3 py-2 text-left font-mono text-xs text-blue-600 dark:text-blue-400 hover:bg-gray-200 dark:hover:bg-gray-700",
|
|
9757
|
+
children: labels.useCustom(custom)
|
|
9758
|
+
}
|
|
9759
|
+
) : /* @__PURE__ */ jsx("p", { className: "px-1 text-xs text-gray-500 dark:text-gray-400", children: labels.invalidCustom }))
|
|
9760
|
+
] });
|
|
9761
|
+
}
|
|
9606
9762
|
function cn13(...classes) {
|
|
9607
9763
|
return classes.filter(Boolean).join(" ");
|
|
9608
9764
|
}
|
|
@@ -9698,6 +9854,6 @@ function TodoList({
|
|
|
9698
9854
|
);
|
|
9699
9855
|
}
|
|
9700
9856
|
|
|
9701
|
-
export { AgentChat, AlertCircleIcon, AskUserPrompt, BotIcon, ChatConfigProvider, ChatContainer, ChatInput, ChatMessage, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, DelegationProgress, DelegationProgressList, DownloadIcon, ExternalLinkIcon, FileDropZone, FileIcon, FileTextIcon, HelpCircleIcon, INTERNAL_TOOL_NAMES, ImageGallery, ImageIcon, ImageLightbox, ImagesIcon, ListTodoIcon, LoadingSpinner, MarkdownContent, Maximize2Icon, MessageCircleIcon, MessageList, Minimize2Icon, PaperclipIcon, SendIcon, SparklesIcon, StopCircleIcon, ThinkingBlock, ThinkingBlockList, TodoList, ToolCallEntry, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments, useImageStream };
|
|
9857
|
+
export { AgentChat, AgentMessagePicker, AlertCircleIcon, AskUserPrompt, BotIcon, ChatConfigProvider, ChatContainer, ChatInput, ChatMessage, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, DelegationProgress, DelegationProgressList, DownloadIcon, ExternalLinkIcon, FileDropZone, FileIcon, FileTextIcon, HelpCircleIcon, INTERNAL_TOOL_NAMES, ImageGallery, ImageIcon, ImageLightbox, ImagesIcon, ListTodoIcon, LoadingSpinner, MESSAGE_KEY_PATTERN, MarkdownContent, Maximize2Icon, MessageCircleIcon, MessageList, Minimize2Icon, PaperclipIcon, SendIcon, SparklesIcon, StopCircleIcon, ThinkingBlock, ThinkingBlockList, TodoList, ToolCallEntry, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, isValidMessageKey, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments, useImageStream };
|
|
9702
9858
|
//# sourceMappingURL=index.js.map
|
|
9703
9859
|
//# sourceMappingURL=index.js.map
|