@gram-ai/elements 1.17.0 → 1.18.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/dist/components/Chat/stories/ColorScheme.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Composer.stories.d.ts +7 -0
- package/dist/components/Chat/stories/Customization.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Density.stories.d.ts +8 -0
- package/dist/components/Chat/stories/FrontendTools.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Modal.stories.d.ts +11 -0
- package/dist/components/Chat/stories/Model.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Plugins.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Radius.stories.d.ts +8 -0
- package/dist/components/Chat/stories/ToolApproval.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Tools.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Variants.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Welcome.stories.d.ts +6 -0
- package/dist/components/assistant-ui/tooltip-icon-button.d.ts +2 -1
- package/dist/components/ui/tool-ui.d.ts +60 -8
- package/dist/components/ui/tool-ui.stories.d.ts +14 -0
- package/dist/contexts/ToolApprovalContext.d.ts +24 -0
- package/dist/contexts/contexts.d.ts +4 -0
- package/dist/elements.cjs +42 -42
- package/dist/elements.css +1 -1
- package/dist/elements.js +8719 -8380
- package/dist/hooks/useMCPTools.d.ts +1 -1
- package/dist/hooks/useToolApproval.d.ts +5 -0
- package/dist/{index-BAP7yZTT.js → index-1qi_Rje5.js} +60 -60
- package/dist/index-DY3aJC4I.cjs +16 -0
- package/dist/index.d.ts +2 -1
- package/dist/lib/tools.d.ts +21 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +30 -26
- package/dist/types/index.d.ts +28 -10
- package/package.json +5 -9
- package/dist/contexts/elementsContextType.d.ts +0 -2
- package/dist/index-DTl5_PjQ.cjs +0 -16
- package/dist/types/schemas.d.ts +0 -28
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const Light: Story;
|
|
7
|
+
export declare const Dark: Story;
|
|
8
|
+
export declare const System: Story;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const CustomPlaceholder: Story;
|
|
7
|
+
export declare const AttachmentsDisabled: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const SystemPrompt: Story;
|
|
7
|
+
export declare const ComponentOverridesStory: Story;
|
|
8
|
+
export declare const LanguageModel: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const Compact: Story;
|
|
7
|
+
export declare const Normal: Story;
|
|
8
|
+
export declare const Spacious: Story;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const CustomIcon: Story;
|
|
7
|
+
export declare const Expandable: Story;
|
|
8
|
+
export declare const PositionTopRight: Story;
|
|
9
|
+
export declare const PositionBottomRight: Story;
|
|
10
|
+
export declare const PositionBottomLeft: Story;
|
|
11
|
+
export declare const PositionTopLeft: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const Round: Story;
|
|
7
|
+
export declare const Soft: Story;
|
|
8
|
+
export declare const Sharp: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const SingleTool: Story;
|
|
7
|
+
export declare const MultipleGroupedTools: Story;
|
|
8
|
+
export declare const FrontendTool: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chat } from '..';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof Chat>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof Chat>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Standalone: Story;
|
|
8
|
+
export declare const Sidecar: Story;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import { Button } from '../ui/button';
|
|
3
|
-
|
|
3
|
+
type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & {
|
|
4
4
|
tooltip: string;
|
|
5
5
|
side?: 'top' | 'bottom' | 'left' | 'right';
|
|
6
6
|
align?: 'start' | 'center' | 'end';
|
|
7
7
|
};
|
|
8
8
|
export declare const TooltipIconButton: import('react').ForwardRefExoticComponent<Omit<TooltipIconButtonProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export {};
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
import { BundledLanguage } from 'shiki';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
type ToolStatus = 'pending' | 'running' | 'complete' | 'error';
|
|
3
|
+
type ToolStatus = 'pending' | 'running' | 'complete' | 'error' | 'approval';
|
|
4
|
+
type ContentItem = {
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
_meta?: {
|
|
8
|
+
'getgram.ai/mime-type'?: string;
|
|
9
|
+
};
|
|
10
|
+
} | {
|
|
11
|
+
type: 'image';
|
|
12
|
+
data: string;
|
|
13
|
+
_meta?: {
|
|
14
|
+
'getgram.ai/mime-type'?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
3
17
|
interface ToolUIProps {
|
|
4
18
|
/** Display name of the tool */
|
|
5
19
|
name: string;
|
|
@@ -11,22 +25,60 @@ interface ToolUIProps {
|
|
|
11
25
|
status?: ToolStatus;
|
|
12
26
|
/** Request/input data - can be string or object */
|
|
13
27
|
request?: string | Record<string, unknown>;
|
|
14
|
-
/** Result/output data - can be string or
|
|
15
|
-
result?: string | Record<string, unknown
|
|
28
|
+
/** Result/output data - can be string, object, or structured content array */
|
|
29
|
+
result?: string | Record<string, unknown> | {
|
|
30
|
+
content: ContentItem[];
|
|
31
|
+
};
|
|
16
32
|
/** Whether the tool card starts expanded */
|
|
17
33
|
defaultExpanded?: boolean;
|
|
18
34
|
/** Additional class names */
|
|
19
35
|
className?: string;
|
|
36
|
+
/** Approval callbacks */
|
|
37
|
+
onApproveOnce?: () => void;
|
|
38
|
+
onApproveForSession?: () => void;
|
|
39
|
+
onDeny?: () => void;
|
|
20
40
|
}
|
|
21
41
|
interface ToolUISectionProps {
|
|
22
42
|
/** Section title */
|
|
23
43
|
title: string;
|
|
24
44
|
/** Content to display - string or object (will be JSON stringified) */
|
|
25
|
-
content: string | Record<string, unknown
|
|
45
|
+
content: string | Record<string, unknown> | {
|
|
46
|
+
content: ContentItem[];
|
|
47
|
+
};
|
|
26
48
|
/** Whether section starts expanded */
|
|
27
49
|
defaultExpanded?: boolean;
|
|
50
|
+
/** Enable syntax highlighting */
|
|
51
|
+
highlightSyntax?: boolean;
|
|
52
|
+
/** Language hint for syntax highlighting */
|
|
53
|
+
language?: BundledLanguage;
|
|
28
54
|
}
|
|
29
|
-
declare function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
declare function StatusIndicator({ status }: {
|
|
56
|
+
status: ToolStatus;
|
|
57
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
declare function CopyButton({ content }: {
|
|
59
|
+
content: string;
|
|
60
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
declare function SyntaxHighlightedCode({ text, language, className, }: {
|
|
62
|
+
text: string;
|
|
63
|
+
language?: BundledLanguage;
|
|
64
|
+
className?: string;
|
|
65
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
declare function ToolUISection({ title, content, defaultExpanded, highlightSyntax, language, }: ToolUISectionProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
declare function ToolUI({ name, icon, provider, status, request, result, defaultExpanded, className, onApproveOnce, onApproveForSession, onDeny, }: ToolUIProps): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
interface ToolUIGroupProps {
|
|
69
|
+
/** Title for the group header */
|
|
70
|
+
title: string;
|
|
71
|
+
/** Optional icon */
|
|
72
|
+
icon?: React.ReactNode;
|
|
73
|
+
/** Overall status of the group */
|
|
74
|
+
status?: 'running' | 'complete';
|
|
75
|
+
/** Whether the group starts expanded */
|
|
76
|
+
defaultExpanded?: boolean;
|
|
77
|
+
/** Child tool UI components */
|
|
78
|
+
children: React.ReactNode;
|
|
79
|
+
/** Additional class names */
|
|
80
|
+
className?: string;
|
|
81
|
+
}
|
|
82
|
+
declare function ToolUIGroup({ title, icon, status, defaultExpanded, children, className, }: ToolUIGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export { ToolUI, ToolUISection, ToolUIGroup, SyntaxHighlightedCode, StatusIndicator, CopyButton, };
|
|
84
|
+
export type { ToolUIProps, ToolUISectionProps, ToolUIGroupProps, ToolStatus, ContentItem, };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
2
|
+
import { ToolUI } from './tool-ui';
|
|
3
|
+
declare const meta: Meta<typeof ToolUI>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryFn<typeof ToolUI>;
|
|
6
|
+
export declare const Complete: Story;
|
|
7
|
+
export declare const Running: Story;
|
|
8
|
+
export declare const Pending: Story;
|
|
9
|
+
export declare const Error: Story;
|
|
10
|
+
export declare const WithoutProvider: Story;
|
|
11
|
+
export declare const WithCustomIcon: Story;
|
|
12
|
+
export declare const DefaultExpanded: Story;
|
|
13
|
+
export declare const LongContent: Story;
|
|
14
|
+
export declare const MultipleTools: Story;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface PendingApproval {
|
|
3
|
+
toolCallId: string;
|
|
4
|
+
toolName: string;
|
|
5
|
+
args: unknown;
|
|
6
|
+
resolve: (approved: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
interface ToolApprovalContextType {
|
|
9
|
+
pendingApprovals: Map<string, PendingApproval>;
|
|
10
|
+
approvedTools: Set<string>;
|
|
11
|
+
requestApproval: (toolName: string, toolCallId: string, args: unknown) => Promise<boolean>;
|
|
12
|
+
/** Whitelist a tool name so all future calls are auto-approved */
|
|
13
|
+
whitelistTool: (toolName: string) => void;
|
|
14
|
+
/** Confirm a specific pending tool call approval */
|
|
15
|
+
confirmPendingApproval: (toolCallId: string) => void;
|
|
16
|
+
/** Reject a specific pending tool call approval */
|
|
17
|
+
rejectPendingApproval: (toolCallId: string) => void;
|
|
18
|
+
isToolApproved: (toolName: string) => boolean;
|
|
19
|
+
getPendingApproval: (toolCallId: string) => PendingApproval | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare function ToolApprovalProvider({ children }: {
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export type { ToolApprovalContextType };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ElementsContextType } from '../types';
|
|
2
|
+
import { ToolApprovalContextType } from './ToolApprovalContext';
|
|
3
|
+
export declare const ElementsContext: import('react').Context<ElementsContextType | undefined>;
|
|
4
|
+
export declare const ToolApprovalContext: import('react').Context<ToolApprovalContextType | null>;
|