@agentuity/workbench 0.0.86 → 0.0.88
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/App.d.ts.map +1 -1
- package/dist/components/App.js +18 -2
- package/dist/components/App.js.map +1 -1
- package/dist/components/ai-elements/code-block.d.ts +3 -3
- package/dist/components/ai-elements/code-block.d.ts.map +1 -1
- package/dist/components/ai-elements/code-block.js +29 -7
- package/dist/components/ai-elements/code-block.js.map +1 -1
- package/dist/components/internal/Chat.d.ts +3 -2
- package/dist/components/internal/Chat.d.ts.map +1 -1
- package/dist/components/internal/Chat.js +23 -24
- package/dist/components/internal/Chat.js.map +1 -1
- package/dist/components/internal/InputSection.d.ts +3 -2
- package/dist/components/internal/InputSection.d.ts.map +1 -1
- package/dist/components/internal/InputSection.js +68 -6
- package/dist/components/internal/InputSection.js.map +1 -1
- package/dist/components/internal/MonacoJsonEditor.d.ts +3 -1
- package/dist/components/internal/MonacoJsonEditor.d.ts.map +1 -1
- package/dist/components/internal/MonacoJsonEditor.js +41 -57
- package/dist/components/internal/MonacoJsonEditor.js.map +1 -1
- package/dist/components/internal/Schema.d.ts +1 -2
- package/dist/components/internal/Schema.d.ts.map +1 -1
- package/dist/components/internal/Schema.js +2 -3
- package/dist/components/internal/Schema.js.map +1 -1
- package/dist/components/internal/WorkbenchProvider.d.ts.map +1 -1
- package/dist/components/internal/WorkbenchProvider.js +55 -8
- package/dist/components/internal/WorkbenchProvider.js.map +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/input-group.js +2 -2
- package/dist/components/ui/input-group.js.map +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -6
- package/dist/index.js.map +1 -1
- package/dist/{styles.css → standalone.css} +206 -1554
- package/package.json +29 -29
- package/src/{styles.css → base.css} +36 -52
- package/src/components/App.tsx +41 -5
- package/src/components/ai-elements/code-block.tsx +42 -10
- package/src/components/internal/Chat.tsx +112 -119
- package/src/components/internal/InputSection.tsx +79 -9
- package/src/components/internal/MonacoJsonEditor.tsx +59 -65
- package/src/components/internal/Schema.tsx +74 -86
- package/src/components/internal/WorkbenchProvider.tsx +69 -10
- package/src/components/ui/input-group.tsx +2 -2
- package/src/components/ui/input.tsx +2 -3
- package/src/index.ts +5 -14
- package/src/integration.css +15 -0
- package/src/standalone.css +25 -0
- package/dist/components/ConnectionStatus.d.ts +0 -7
- package/dist/components/ConnectionStatus.d.ts.map +0 -1
- package/dist/components/ConnectionStatus.js +0 -52
- package/dist/components/ConnectionStatus.js.map +0 -1
- package/dist/components/Inline.d.ts +0 -10
- package/dist/components/Inline.d.ts.map +0 -1
- package/dist/components/Inline.js +0 -11
- package/dist/components/Inline.js.map +0 -1
- package/dist/components/ai-elements/artifact.d.ts +0 -24
- package/dist/components/ai-elements/artifact.d.ts.map +0 -1
- package/dist/components/ai-elements/artifact.js +0 -21
- package/dist/components/ai-elements/artifact.js.map +0 -1
- package/dist/components/ai-elements/branch.d.ts +0 -21
- package/dist/components/ai-elements/branch.d.ts.map +0 -1
- package/dist/components/ai-elements/branch.js +0 -71
- package/dist/components/ai-elements/branch.js.map +0 -1
- package/dist/components/ai-elements/canvas.d.ts +0 -9
- package/dist/components/ai-elements/canvas.d.ts.map +0 -1
- package/dist/components/ai-elements/canvas.js +0 -6
- package/dist/components/ai-elements/canvas.js.map +0 -1
- package/dist/components/ai-elements/chain-of-thought.d.ts +0 -30
- package/dist/components/ai-elements/chain-of-thought.d.ts.map +0 -1
- package/dist/components/ai-elements/chain-of-thought.js +0 -52
- package/dist/components/ai-elements/chain-of-thought.js.map +0 -1
- package/dist/components/ai-elements/confirmation.d.ts +0 -27
- package/dist/components/ai-elements/confirmation.d.ts.map +0 -1
- package/dist/components/ai-elements/confirmation.js +0 -57
- package/dist/components/ai-elements/confirmation.js.map +0 -1
- package/dist/components/ai-elements/connection.d.ts +0 -3
- package/dist/components/ai-elements/connection.d.ts.map +0 -1
- package/dist/components/ai-elements/connection.js +0 -4
- package/dist/components/ai-elements/connection.js.map +0 -1
- package/dist/components/ai-elements/context.d.ts +0 -33
- package/dist/components/ai-elements/context.d.ts.map +0 -1
- package/dist/components/ai-elements/context.js +0 -167
- package/dist/components/ai-elements/context.js.map +0 -1
- package/dist/components/ai-elements/controls.d.ts +0 -5
- package/dist/components/ai-elements/controls.d.ts.map +0 -1
- package/dist/components/ai-elements/controls.js +0 -6
- package/dist/components/ai-elements/controls.js.map +0 -1
- package/dist/components/ai-elements/edge.d.ts +0 -6
- package/dist/components/ai-elements/edge.d.ts.map +0 -1
- package/dist/components/ai-elements/edge.js +0 -83
- package/dist/components/ai-elements/edge.js.map +0 -1
- package/dist/components/ai-elements/image.d.ts +0 -7
- package/dist/components/ai-elements/image.d.ts.map +0 -1
- package/dist/components/ai-elements/image.js +0 -4
- package/dist/components/ai-elements/image.js.map +0 -1
- package/dist/components/ai-elements/inline-citation.d.ts +0 -39
- package/dist/components/ai-elements/inline-citation.d.ts.map +0 -1
- package/dist/components/ai-elements/inline-citation.js +0 -62
- package/dist/components/ai-elements/inline-citation.js.map +0 -1
- package/dist/components/ai-elements/loader.d.ts +0 -6
- package/dist/components/ai-elements/loader.d.ts.map +0 -1
- package/dist/components/ai-elements/loader.js +0 -5
- package/dist/components/ai-elements/loader.js.map +0 -1
- package/dist/components/ai-elements/node.d.ts +0 -22
- package/dist/components/ai-elements/node.d.ts.map +0 -1
- package/dist/components/ai-elements/node.js +0 -12
- package/dist/components/ai-elements/node.js.map +0 -1
- package/dist/components/ai-elements/open-in-chat.d.ts +0 -29
- package/dist/components/ai-elements/open-in-chat.d.ts.map +0 -1
- package/dist/components/ai-elements/open-in-chat.js +0 -97
- package/dist/components/ai-elements/open-in-chat.js.map +0 -1
- package/dist/components/ai-elements/panel.d.ts +0 -6
- package/dist/components/ai-elements/panel.d.ts.map +0 -1
- package/dist/components/ai-elements/panel.js +0 -5
- package/dist/components/ai-elements/panel.js.map +0 -1
- package/dist/components/ai-elements/plan.d.ts +0 -26
- package/dist/components/ai-elements/plan.d.ts.map +0 -1
- package/dist/components/ai-elements/plan.js +0 -32
- package/dist/components/ai-elements/plan.js.map +0 -1
- package/dist/components/ai-elements/queue.d.ts +0 -62
- package/dist/components/ai-elements/queue.d.ts.map +0 -1
- package/dist/components/ai-elements/queue.js +0 -25
- package/dist/components/ai-elements/queue.js.map +0 -1
- package/dist/components/ai-elements/reasoning.d.ts +0 -17
- package/dist/components/ai-elements/reasoning.d.ts.map +0 -1
- package/dist/components/ai-elements/reasoning.js +0 -77
- package/dist/components/ai-elements/reasoning.js.map +0 -1
- package/dist/components/ai-elements/response.d.ts +0 -6
- package/dist/components/ai-elements/response.d.ts.map +0 -1
- package/dist/components/ai-elements/response.js +0 -8
- package/dist/components/ai-elements/response.js.map +0 -1
- package/dist/components/ai-elements/sources.d.ts +0 -13
- package/dist/components/ai-elements/sources.d.ts.map +0 -1
- package/dist/components/ai-elements/sources.js +0 -10
- package/dist/components/ai-elements/sources.js.map +0 -1
- package/dist/components/ai-elements/suggestion.d.ts +0 -11
- package/dist/components/ai-elements/suggestion.d.ts.map +0 -1
- package/dist/components/ai-elements/suggestion.js +0 -13
- package/dist/components/ai-elements/suggestion.js.map +0 -1
- package/dist/components/ai-elements/task.d.ts +0 -15
- package/dist/components/ai-elements/task.d.ts.map +0 -1
- package/dist/components/ai-elements/task.js +0 -11
- package/dist/components/ai-elements/task.js.map +0 -1
- package/dist/components/ai-elements/tool.d.ts +0 -24
- package/dist/components/ai-elements/tool.d.ts.map +0 -1
- package/dist/components/ai-elements/tool.js +0 -47
- package/dist/components/ai-elements/tool.js.map +0 -1
- package/dist/components/ai-elements/toolbar.d.ts +0 -6
- package/dist/components/ai-elements/toolbar.d.ts.map +0 -1
- package/dist/components/ai-elements/toolbar.js +0 -5
- package/dist/components/ai-elements/toolbar.js.map +0 -1
- package/dist/components/ai-elements/web-preview.d.ts +0 -35
- package/dist/components/ai-elements/web-preview.d.ts.map +0 -1
- package/dist/components/ai-elements/web-preview.js +0 -63
- package/dist/components/ai-elements/web-preview.js.map +0 -1
- package/dist/components/ui/alert.d.ts +0 -10
- package/dist/components/ui/alert.d.ts.map +0 -1
- package/dist/components/ui/alert.js +0 -25
- package/dist/components/ui/alert.js.map +0 -1
- package/dist/components/ui/badge.d.ts +0 -10
- package/dist/components/ui/badge.d.ts.map +0 -1
- package/dist/components/ui/badge.js +0 -23
- package/dist/components/ui/badge.js.map +0 -1
- package/dist/components/ui/card.d.ts +0 -10
- package/dist/components/ui/card.d.ts.map +0 -1
- package/dist/components/ui/card.js +0 -25
- package/dist/components/ui/card.js.map +0 -1
- package/dist/components/ui/carousel.d.ts +0 -20
- package/dist/components/ui/carousel.d.ts.map +0 -1
- package/dist/components/ui/carousel.js +0 -92
- package/dist/components/ui/carousel.js.map +0 -1
- package/dist/components/ui/checkbox.d.ts +0 -5
- package/dist/components/ui/checkbox.d.ts.map +0 -1
- package/dist/components/ui/checkbox.js +0 -9
- package/dist/components/ui/checkbox.js.map +0 -1
- package/dist/components/ui/collapsible.d.ts +0 -6
- package/dist/components/ui/collapsible.d.ts.map +0 -1
- package/dist/components/ui/collapsible.js +0 -14
- package/dist/components/ui/collapsible.js.map +0 -1
- package/dist/components/ui/field.d.ts +0 -25
- package/dist/components/ui/field.d.ts.map +0 -1
- package/dist/components/ui/field.js +0 -74
- package/dist/components/ui/field.js.map +0 -1
- package/dist/components/ui/form.d.ts +0 -25
- package/dist/components/ui/form.d.ts.map +0 -1
- package/dist/components/ui/form.js +0 -58
- package/dist/components/ui/form.js.map +0 -1
- package/dist/components/ui/label.d.ts +0 -5
- package/dist/components/ui/label.d.ts.map +0 -1
- package/dist/components/ui/label.js +0 -9
- package/dist/components/ui/label.js.map +0 -1
- package/dist/components/ui/progress.d.ts +0 -5
- package/dist/components/ui/progress.d.ts.map +0 -1
- package/dist/components/ui/progress.js +0 -9
- package/dist/components/ui/progress.js.map +0 -1
- package/dist/components/ui/separator.d.ts +0 -5
- package/dist/components/ui/separator.d.ts.map +0 -1
- package/dist/components/ui/separator.js +0 -9
- package/dist/components/ui/separator.js.map +0 -1
- package/dist/components/ui/switch.d.ts +0 -5
- package/dist/components/ui/switch.d.ts.map +0 -1
- package/dist/components/ui/switch.js +0 -8
- package/dist/components/ui/switch.js.map +0 -1
- package/dist/components/ui/tabs.d.ts +0 -8
- package/dist/components/ui/tabs.d.ts.map +0 -1
- package/dist/components/ui/tabs.js +0 -17
- package/dist/components/ui/tabs.js.map +0 -1
- package/dist/components/ui/toggle.d.ts +0 -10
- package/dist/components/ui/toggle.d.ts.map +0 -1
- package/dist/components/ui/toggle.js +0 -26
- package/dist/components/ui/toggle.js.map +0 -1
- package/dist/components.d.ts +0 -12
- package/dist/components.d.ts.map +0 -1
- package/dist/components.js +0 -13
- package/dist/components.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -5
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useWorkbenchSchemas.d.ts +0 -56
- package/dist/hooks/useWorkbenchSchemas.d.ts.map +0 -1
- package/dist/hooks/useWorkbenchSchemas.js +0 -63
- package/dist/hooks/useWorkbenchSchemas.js.map +0 -1
- package/src/components/ConnectionStatus.tsx +0 -67
- package/src/components/Inline.tsx +0 -16
- package/src/components/ai-elements/artifact.tsx +0 -118
- package/src/components/ai-elements/branch.tsx +0 -187
- package/src/components/ai-elements/canvas.tsx +0 -24
- package/src/components/ai-elements/chain-of-thought.tsx +0 -198
- package/src/components/ai-elements/confirmation.tsx +0 -119
- package/src/components/ai-elements/connection.tsx +0 -16
- package/src/components/ai-elements/context.tsx +0 -357
- package/src/components/ai-elements/controls.tsx +0 -18
- package/src/components/ai-elements/edge.tsx +0 -131
- package/src/components/ai-elements/image.tsx +0 -16
- package/src/components/ai-elements/inline-citation.tsx +0 -246
- package/src/components/ai-elements/loader.tsx +0 -88
- package/src/components/ai-elements/node.tsx +0 -66
- package/src/components/ai-elements/open-in-chat.tsx +0 -333
- package/src/components/ai-elements/panel.tsx +0 -12
- package/src/components/ai-elements/plan.tsx +0 -123
- package/src/components/ai-elements/queue.tsx +0 -231
- package/src/components/ai-elements/reasoning.tsx +0 -163
- package/src/components/ai-elements/response.tsx +0 -19
- package/src/components/ai-elements/sources.tsx +0 -53
- package/src/components/ai-elements/suggestion.tsx +0 -47
- package/src/components/ai-elements/task.tsx +0 -64
- package/src/components/ai-elements/tool.tsx +0 -136
- package/src/components/ai-elements/toolbar.tsx +0 -13
- package/src/components/ai-elements/web-preview.tsx +0 -238
- package/src/components/ui/alert.tsx +0 -60
- package/src/components/ui/badge.tsx +0 -40
- package/src/components/ui/card.tsx +0 -41
- package/src/components/ui/carousel.tsx +0 -234
- package/src/components/ui/checkbox.tsx +0 -27
- package/src/components/ui/collapsible.tsx +0 -21
- package/src/components/ui/field.tsx +0 -234
- package/src/components/ui/form.tsx +0 -154
- package/src/components/ui/label.tsx +0 -21
- package/src/components/ui/progress.tsx +0 -28
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/switch.tsx +0 -26
- package/src/components/ui/tabs.tsx +0 -52
- package/src/components/ui/toggle.tsx +0 -44
- package/src/components.tsx +0 -29
- package/src/hooks/index.ts +0 -20
- package/src/hooks/useWorkbenchSchemas.ts +0 -69
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Alert, AlertDescription } from '../ui/alert';
|
|
4
|
-
import { Button } from '../ui/button';
|
|
5
|
-
import { cn } from '../../lib/utils';
|
|
6
|
-
import type { ToolUIPart } from 'ai';
|
|
7
|
-
import { type ComponentProps, createContext, type ReactNode, useContext } from 'react';
|
|
8
|
-
|
|
9
|
-
type ConfirmationContextValue = {
|
|
10
|
-
approval: any;
|
|
11
|
-
state: any;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const ConfirmationContext = createContext<ConfirmationContextValue | null>(null);
|
|
15
|
-
|
|
16
|
-
const useConfirmation = () => {
|
|
17
|
-
const context = useContext(ConfirmationContext);
|
|
18
|
-
|
|
19
|
-
if (!context) {
|
|
20
|
-
throw new Error('Confirmation components must be used within Confirmation');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return context;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type ConfirmationProps = ComponentProps<typeof Alert> & {
|
|
27
|
-
approval?: any;
|
|
28
|
-
state: any;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const Confirmation = ({ className, approval, state, ...props }: ConfirmationProps) => {
|
|
32
|
-
if (!approval || state === 'input-streaming' || state === 'input-available') {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<ConfirmationContext.Provider value={{ approval, state }}>
|
|
38
|
-
<Alert className={cn('flex flex-col gap-2', className)} {...props} />
|
|
39
|
-
</ConfirmationContext.Provider>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type ConfirmationTitleProps = ComponentProps<typeof AlertDescription>;
|
|
44
|
-
|
|
45
|
-
export const ConfirmationTitle = ({ className, ...props }: ConfirmationTitleProps) => (
|
|
46
|
-
<AlertDescription className={cn('inline', className)} {...props} />
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
export type ConfirmationRequestProps = {
|
|
50
|
-
children?: ReactNode;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const ConfirmationRequest = ({ children }: ConfirmationRequestProps) => {
|
|
54
|
-
const { state } = useConfirmation();
|
|
55
|
-
|
|
56
|
-
// Only show when approval is requested
|
|
57
|
-
if (state !== 'approval-requested') {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return children;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export type ConfirmationAcceptedProps = {
|
|
65
|
-
children?: ReactNode;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const ConfirmationAccepted = ({ children }: ConfirmationAcceptedProps) => {
|
|
69
|
-
const { approval, state } = useConfirmation();
|
|
70
|
-
|
|
71
|
-
// Only show when approved and in response states
|
|
72
|
-
if (
|
|
73
|
-
!approval?.approved ||
|
|
74
|
-
(state !== 'approval-responded' && state !== 'output-denied' && state !== 'output-available')
|
|
75
|
-
) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return children;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export type ConfirmationRejectedProps = {
|
|
83
|
-
children?: ReactNode;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const ConfirmationRejected = ({ children }: ConfirmationRejectedProps) => {
|
|
87
|
-
const { approval, state } = useConfirmation();
|
|
88
|
-
|
|
89
|
-
// Only show when rejected and in response states
|
|
90
|
-
if (
|
|
91
|
-
approval?.approved !== false ||
|
|
92
|
-
(state !== 'approval-responded' && state !== 'output-denied' && state !== 'output-available')
|
|
93
|
-
) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return children;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export type ConfirmationActionsProps = ComponentProps<'div'>;
|
|
101
|
-
|
|
102
|
-
export const ConfirmationActions = ({ className, ...props }: ConfirmationActionsProps) => {
|
|
103
|
-
const { state } = useConfirmation();
|
|
104
|
-
|
|
105
|
-
// Only show when approval is requested
|
|
106
|
-
if (state !== 'approval-requested') {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<div className={cn('flex items-center justify-end gap-2 self-end', className)} {...props} />
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export type ConfirmationActionProps = ComponentProps<typeof Button>;
|
|
116
|
-
|
|
117
|
-
export const ConfirmationAction = (props: ConfirmationActionProps) => (
|
|
118
|
-
<Button className="h-8 px-3 text-sm" type="button" {...props} />
|
|
119
|
-
);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ConnectionLineComponent } from '@xyflow/react';
|
|
2
|
-
|
|
3
|
-
const HALF = 0.5;
|
|
4
|
-
|
|
5
|
-
export const Connection: ConnectionLineComponent = ({ fromX, fromY, toX, toY }) => (
|
|
6
|
-
<g>
|
|
7
|
-
<path
|
|
8
|
-
className="animated"
|
|
9
|
-
d={`M${fromX},${fromY} C ${fromX + (toX - fromX) * HALF},${fromY} ${fromX + (toX - fromX) * HALF},${toY} ${toX},${toY}`}
|
|
10
|
-
fill="none"
|
|
11
|
-
stroke="var(--color-ring)"
|
|
12
|
-
strokeWidth={1}
|
|
13
|
-
/>
|
|
14
|
-
<circle cx={toX} cy={toY} fill="#fff" r={3} stroke="var(--color-ring)" strokeWidth={1} />
|
|
15
|
-
</g>
|
|
16
|
-
);
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Button } from '../ui/button';
|
|
4
|
-
import { HoverCard, HoverCardContent, HoverCardTrigger } from '../ui/hover-card';
|
|
5
|
-
import { Progress } from '../ui/progress';
|
|
6
|
-
import { cn } from '../../lib/utils';
|
|
7
|
-
import type { LanguageModelUsage } from 'ai';
|
|
8
|
-
import { type ComponentProps, createContext, useContext } from 'react';
|
|
9
|
-
import { getUsage } from 'tokenlens';
|
|
10
|
-
|
|
11
|
-
const PERCENT_MAX = 100;
|
|
12
|
-
const ICON_RADIUS = 10;
|
|
13
|
-
const ICON_VIEWBOX = 24;
|
|
14
|
-
const ICON_CENTER = 12;
|
|
15
|
-
const ICON_STROKE_WIDTH = 2;
|
|
16
|
-
|
|
17
|
-
type ModelId = string;
|
|
18
|
-
|
|
19
|
-
type ContextSchema = {
|
|
20
|
-
usedTokens: number;
|
|
21
|
-
maxTokens: number;
|
|
22
|
-
usage?: LanguageModelUsage;
|
|
23
|
-
modelId?: ModelId;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const ContextContext = createContext<ContextSchema | null>(null);
|
|
27
|
-
|
|
28
|
-
const useContextValue = () => {
|
|
29
|
-
const context = useContext(ContextContext);
|
|
30
|
-
|
|
31
|
-
if (!context) {
|
|
32
|
-
throw new Error('Context components must be used within Context');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return context;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type ContextProps = ComponentProps<typeof HoverCard> & ContextSchema;
|
|
39
|
-
|
|
40
|
-
export const Context = ({ usedTokens, maxTokens, usage, modelId, ...props }: ContextProps) => (
|
|
41
|
-
<ContextContext.Provider
|
|
42
|
-
value={{
|
|
43
|
-
usedTokens,
|
|
44
|
-
maxTokens,
|
|
45
|
-
usage,
|
|
46
|
-
modelId,
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
<HoverCard closeDelay={0} openDelay={0} {...props} />
|
|
50
|
-
</ContextContext.Provider>
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const ContextIcon = () => {
|
|
54
|
-
const { usedTokens, maxTokens } = useContextValue();
|
|
55
|
-
const circumference = 2 * Math.PI * ICON_RADIUS;
|
|
56
|
-
const usedPercent = usedTokens / maxTokens;
|
|
57
|
-
const dashOffset = circumference * (1 - usedPercent);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<svg
|
|
61
|
-
aria-label="Model context usage"
|
|
62
|
-
height="20"
|
|
63
|
-
role="img"
|
|
64
|
-
style={{ color: 'currentcolor' }}
|
|
65
|
-
viewBox={`0 0 ${ICON_VIEWBOX} ${ICON_VIEWBOX}`}
|
|
66
|
-
width="20"
|
|
67
|
-
>
|
|
68
|
-
<circle
|
|
69
|
-
cx={ICON_CENTER}
|
|
70
|
-
cy={ICON_CENTER}
|
|
71
|
-
fill="none"
|
|
72
|
-
opacity="0.25"
|
|
73
|
-
r={ICON_RADIUS}
|
|
74
|
-
stroke="currentColor"
|
|
75
|
-
strokeWidth={ICON_STROKE_WIDTH}
|
|
76
|
-
/>
|
|
77
|
-
<circle
|
|
78
|
-
cx={ICON_CENTER}
|
|
79
|
-
cy={ICON_CENTER}
|
|
80
|
-
fill="none"
|
|
81
|
-
opacity="0.7"
|
|
82
|
-
r={ICON_RADIUS}
|
|
83
|
-
stroke="currentColor"
|
|
84
|
-
strokeDasharray={`${circumference} ${circumference}`}
|
|
85
|
-
strokeDashoffset={dashOffset}
|
|
86
|
-
strokeLinecap="round"
|
|
87
|
-
strokeWidth={ICON_STROKE_WIDTH}
|
|
88
|
-
style={{ transformOrigin: 'center', transform: 'rotate(-90deg)' }}
|
|
89
|
-
/>
|
|
90
|
-
</svg>
|
|
91
|
-
);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type ContextTriggerProps = ComponentProps<typeof Button>;
|
|
95
|
-
|
|
96
|
-
export const ContextTrigger = ({ children, ...props }: ContextTriggerProps) => {
|
|
97
|
-
const { usedTokens, maxTokens } = useContextValue();
|
|
98
|
-
const usedPercent = usedTokens / maxTokens;
|
|
99
|
-
const renderedPercent = new Intl.NumberFormat('en-US', {
|
|
100
|
-
style: 'percent',
|
|
101
|
-
maximumFractionDigits: 1,
|
|
102
|
-
}).format(usedPercent);
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<HoverCardTrigger asChild>
|
|
106
|
-
{children ?? (
|
|
107
|
-
<Button type="button" variant="ghost" {...props}>
|
|
108
|
-
<span className="font-medium text-muted-foreground">{renderedPercent}</span>
|
|
109
|
-
<ContextIcon />
|
|
110
|
-
</Button>
|
|
111
|
-
)}
|
|
112
|
-
</HoverCardTrigger>
|
|
113
|
-
);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export type ContextContentProps = ComponentProps<typeof HoverCardContent>;
|
|
117
|
-
|
|
118
|
-
export const ContextContent = ({ className, ...props }: ContextContentProps) => (
|
|
119
|
-
<HoverCardContent
|
|
120
|
-
className={cn('min-w-60 divide-y overflow-hidden p-0', className)}
|
|
121
|
-
{...props}
|
|
122
|
-
/>
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
export type ContextContentHeaderProps = ComponentProps<'div'>;
|
|
126
|
-
|
|
127
|
-
export const ContextContentHeader = ({
|
|
128
|
-
children,
|
|
129
|
-
className,
|
|
130
|
-
...props
|
|
131
|
-
}: ContextContentHeaderProps) => {
|
|
132
|
-
const { usedTokens, maxTokens } = useContextValue();
|
|
133
|
-
const usedPercent = usedTokens / maxTokens;
|
|
134
|
-
const displayPct = new Intl.NumberFormat('en-US', {
|
|
135
|
-
style: 'percent',
|
|
136
|
-
maximumFractionDigits: 1,
|
|
137
|
-
}).format(usedPercent);
|
|
138
|
-
const used = new Intl.NumberFormat('en-US', {
|
|
139
|
-
notation: 'compact',
|
|
140
|
-
}).format(usedTokens);
|
|
141
|
-
const total = new Intl.NumberFormat('en-US', {
|
|
142
|
-
notation: 'compact',
|
|
143
|
-
}).format(maxTokens);
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<div className={cn('w-full space-y-2 p-3', className)} {...props}>
|
|
147
|
-
{children ?? (
|
|
148
|
-
<>
|
|
149
|
-
<div className="flex items-center justify-between gap-3 text-xs">
|
|
150
|
-
<p>{displayPct}</p>
|
|
151
|
-
<p className="font-mono text-muted-foreground">
|
|
152
|
-
{used} / {total}
|
|
153
|
-
</p>
|
|
154
|
-
</div>
|
|
155
|
-
<div className="space-y-2">
|
|
156
|
-
<Progress className="bg-muted" value={usedPercent * PERCENT_MAX} />
|
|
157
|
-
</div>
|
|
158
|
-
</>
|
|
159
|
-
)}
|
|
160
|
-
</div>
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export type ContextContentBodyProps = ComponentProps<'div'>;
|
|
165
|
-
|
|
166
|
-
export const ContextContentBody = ({ children, className, ...props }: ContextContentBodyProps) => (
|
|
167
|
-
<div className={cn('w-full p-3', className)} {...props}>
|
|
168
|
-
{children}
|
|
169
|
-
</div>
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
export type ContextContentFooterProps = ComponentProps<'div'>;
|
|
173
|
-
|
|
174
|
-
export const ContextContentFooter = ({
|
|
175
|
-
children,
|
|
176
|
-
className,
|
|
177
|
-
...props
|
|
178
|
-
}: ContextContentFooterProps) => {
|
|
179
|
-
const { modelId, usage } = useContextValue();
|
|
180
|
-
const costUSD = modelId
|
|
181
|
-
? getUsage({
|
|
182
|
-
modelId,
|
|
183
|
-
usage: {
|
|
184
|
-
input: usage?.inputTokens ?? 0,
|
|
185
|
-
output: usage?.outputTokens ?? 0,
|
|
186
|
-
},
|
|
187
|
-
}).costUSD?.totalUSD
|
|
188
|
-
: undefined;
|
|
189
|
-
const totalCost = new Intl.NumberFormat('en-US', {
|
|
190
|
-
style: 'currency',
|
|
191
|
-
currency: 'USD',
|
|
192
|
-
}).format(costUSD ?? 0);
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<div
|
|
196
|
-
className={cn(
|
|
197
|
-
'flex w-full items-center justify-between gap-3 bg-secondary p-3 text-xs',
|
|
198
|
-
className
|
|
199
|
-
)}
|
|
200
|
-
{...props}
|
|
201
|
-
>
|
|
202
|
-
{children ?? (
|
|
203
|
-
<>
|
|
204
|
-
<span className="text-muted-foreground">Total cost</span>
|
|
205
|
-
<span>{totalCost}</span>
|
|
206
|
-
</>
|
|
207
|
-
)}
|
|
208
|
-
</div>
|
|
209
|
-
);
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
export type ContextInputUsageProps = ComponentProps<'div'>;
|
|
213
|
-
|
|
214
|
-
export const ContextInputUsage = ({ className, children, ...props }: ContextInputUsageProps) => {
|
|
215
|
-
const { usage, modelId } = useContextValue();
|
|
216
|
-
const inputTokens = usage?.inputTokens ?? 0;
|
|
217
|
-
|
|
218
|
-
if (children) {
|
|
219
|
-
return children;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (!inputTokens) {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const inputCost = modelId
|
|
227
|
-
? getUsage({
|
|
228
|
-
modelId,
|
|
229
|
-
usage: { input: inputTokens, output: 0 },
|
|
230
|
-
}).costUSD?.totalUSD
|
|
231
|
-
: undefined;
|
|
232
|
-
const inputCostText = new Intl.NumberFormat('en-US', {
|
|
233
|
-
style: 'currency',
|
|
234
|
-
currency: 'USD',
|
|
235
|
-
}).format(inputCost ?? 0);
|
|
236
|
-
|
|
237
|
-
return (
|
|
238
|
-
<div className={cn('flex items-center justify-between text-xs', className)} {...props}>
|
|
239
|
-
<span className="text-muted-foreground">Input</span>
|
|
240
|
-
<TokensWithCost costText={inputCostText} tokens={inputTokens} />
|
|
241
|
-
</div>
|
|
242
|
-
);
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export type ContextOutputUsageProps = ComponentProps<'div'>;
|
|
246
|
-
|
|
247
|
-
export const ContextOutputUsage = ({ className, children, ...props }: ContextOutputUsageProps) => {
|
|
248
|
-
const { usage, modelId } = useContextValue();
|
|
249
|
-
const outputTokens = usage?.outputTokens ?? 0;
|
|
250
|
-
|
|
251
|
-
if (children) {
|
|
252
|
-
return children;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (!outputTokens) {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const outputCost = modelId
|
|
260
|
-
? getUsage({
|
|
261
|
-
modelId,
|
|
262
|
-
usage: { input: 0, output: outputTokens },
|
|
263
|
-
}).costUSD?.totalUSD
|
|
264
|
-
: undefined;
|
|
265
|
-
const outputCostText = new Intl.NumberFormat('en-US', {
|
|
266
|
-
style: 'currency',
|
|
267
|
-
currency: 'USD',
|
|
268
|
-
}).format(outputCost ?? 0);
|
|
269
|
-
|
|
270
|
-
return (
|
|
271
|
-
<div className={cn('flex items-center justify-between text-xs', className)} {...props}>
|
|
272
|
-
<span className="text-muted-foreground">Output</span>
|
|
273
|
-
<TokensWithCost costText={outputCostText} tokens={outputTokens} />
|
|
274
|
-
</div>
|
|
275
|
-
);
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
export type ContextReasoningUsageProps = ComponentProps<'div'>;
|
|
279
|
-
|
|
280
|
-
export const ContextReasoningUsage = ({
|
|
281
|
-
className,
|
|
282
|
-
children,
|
|
283
|
-
...props
|
|
284
|
-
}: ContextReasoningUsageProps) => {
|
|
285
|
-
const { usage, modelId } = useContextValue();
|
|
286
|
-
const reasoningTokens = usage?.reasoningTokens ?? 0;
|
|
287
|
-
|
|
288
|
-
if (children) {
|
|
289
|
-
return children;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if (!reasoningTokens) {
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const reasoningCost = modelId
|
|
297
|
-
? getUsage({
|
|
298
|
-
modelId,
|
|
299
|
-
usage: { reasoningTokens },
|
|
300
|
-
}).costUSD?.totalUSD
|
|
301
|
-
: undefined;
|
|
302
|
-
const reasoningCostText = new Intl.NumberFormat('en-US', {
|
|
303
|
-
style: 'currency',
|
|
304
|
-
currency: 'USD',
|
|
305
|
-
}).format(reasoningCost ?? 0);
|
|
306
|
-
|
|
307
|
-
return (
|
|
308
|
-
<div className={cn('flex items-center justify-between text-xs', className)} {...props}>
|
|
309
|
-
<span className="text-muted-foreground">Reasoning</span>
|
|
310
|
-
<TokensWithCost costText={reasoningCostText} tokens={reasoningTokens} />
|
|
311
|
-
</div>
|
|
312
|
-
);
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
export type ContextCacheUsageProps = ComponentProps<'div'>;
|
|
316
|
-
|
|
317
|
-
export const ContextCacheUsage = ({ className, children, ...props }: ContextCacheUsageProps) => {
|
|
318
|
-
const { usage, modelId } = useContextValue();
|
|
319
|
-
const cacheTokens = usage?.cachedInputTokens ?? 0;
|
|
320
|
-
|
|
321
|
-
if (children) {
|
|
322
|
-
return children;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (!cacheTokens) {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const cacheCost = modelId
|
|
330
|
-
? getUsage({
|
|
331
|
-
modelId,
|
|
332
|
-
usage: { cacheReads: cacheTokens, input: 0, output: 0 },
|
|
333
|
-
}).costUSD?.totalUSD
|
|
334
|
-
: undefined;
|
|
335
|
-
const cacheCostText = new Intl.NumberFormat('en-US', {
|
|
336
|
-
style: 'currency',
|
|
337
|
-
currency: 'USD',
|
|
338
|
-
}).format(cacheCost ?? 0);
|
|
339
|
-
|
|
340
|
-
return (
|
|
341
|
-
<div className={cn('flex items-center justify-between text-xs', className)} {...props}>
|
|
342
|
-
<span className="text-muted-foreground">Cache</span>
|
|
343
|
-
<TokensWithCost costText={cacheCostText} tokens={cacheTokens} />
|
|
344
|
-
</div>
|
|
345
|
-
);
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const TokensWithCost = ({ tokens, costText }: { tokens?: number; costText?: string }) => (
|
|
349
|
-
<span>
|
|
350
|
-
{tokens === undefined
|
|
351
|
-
? '—'
|
|
352
|
-
: new Intl.NumberFormat('en-US', {
|
|
353
|
-
notation: 'compact',
|
|
354
|
-
}).format(tokens)}
|
|
355
|
-
{costText ? <span className="ml-2 text-muted-foreground">• {costText}</span> : null}
|
|
356
|
-
</span>
|
|
357
|
-
);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { cn } from '../../lib/utils';
|
|
4
|
-
import { Controls as ControlsPrimitive } from '@xyflow/react';
|
|
5
|
-
import type { ComponentProps } from 'react';
|
|
6
|
-
|
|
7
|
-
export type ControlsProps = ComponentProps<typeof ControlsPrimitive>;
|
|
8
|
-
|
|
9
|
-
export const Controls = ({ className, ...props }: ControlsProps) => (
|
|
10
|
-
<ControlsPrimitive
|
|
11
|
-
className={cn(
|
|
12
|
-
'gap-px overflow-hidden rounded-md border bg-card p-1 shadow-none!',
|
|
13
|
-
'[&>button]:rounded-md [&>button]:border-none! [&>button]:bg-transparent! [&>button]:hover:bg-secondary!',
|
|
14
|
-
className
|
|
15
|
-
)}
|
|
16
|
-
{...props}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseEdge,
|
|
3
|
-
type EdgeProps,
|
|
4
|
-
getBezierPath,
|
|
5
|
-
getSimpleBezierPath,
|
|
6
|
-
type InternalNode,
|
|
7
|
-
type Node,
|
|
8
|
-
Position,
|
|
9
|
-
useInternalNode,
|
|
10
|
-
} from '@xyflow/react';
|
|
11
|
-
|
|
12
|
-
const Temporary = ({
|
|
13
|
-
id,
|
|
14
|
-
sourceX,
|
|
15
|
-
sourceY,
|
|
16
|
-
targetX,
|
|
17
|
-
targetY,
|
|
18
|
-
sourcePosition,
|
|
19
|
-
targetPosition,
|
|
20
|
-
}: EdgeProps) => {
|
|
21
|
-
const [edgePath] = getSimpleBezierPath({
|
|
22
|
-
sourceX,
|
|
23
|
-
sourceY,
|
|
24
|
-
sourcePosition,
|
|
25
|
-
targetX,
|
|
26
|
-
targetY,
|
|
27
|
-
targetPosition,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<BaseEdge
|
|
32
|
-
className="stroke-1 stroke-ring"
|
|
33
|
-
id={id}
|
|
34
|
-
path={edgePath}
|
|
35
|
-
style={{
|
|
36
|
-
strokeDasharray: '5, 5',
|
|
37
|
-
}}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const getHandleCoordsByPosition = (node: InternalNode<Node>, handlePosition: Position) => {
|
|
43
|
-
// Choose the handle type based on position - Left is for target, Right is for source
|
|
44
|
-
const handleType = handlePosition === Position.Left ? 'target' : 'source';
|
|
45
|
-
|
|
46
|
-
const handle = node.internals.handleBounds?.[handleType]?.find(
|
|
47
|
-
(h) => h.position === handlePosition
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
if (!handle) {
|
|
51
|
-
return [0, 0] as const;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
let offsetX = handle.width / 2;
|
|
55
|
-
let offsetY = handle.height / 2;
|
|
56
|
-
|
|
57
|
-
// this is a tiny detail to make the markerEnd of an edge visible.
|
|
58
|
-
// The handle position that gets calculated has the origin top-left, so depending which side we are using, we add a little offset
|
|
59
|
-
// when the handlePosition is Position.Right for example, we need to add an offset as big as the handle itself in order to get the correct position
|
|
60
|
-
switch (handlePosition) {
|
|
61
|
-
case Position.Left:
|
|
62
|
-
offsetX = 0;
|
|
63
|
-
break;
|
|
64
|
-
case Position.Right:
|
|
65
|
-
offsetX = handle.width;
|
|
66
|
-
break;
|
|
67
|
-
case Position.Top:
|
|
68
|
-
offsetY = 0;
|
|
69
|
-
break;
|
|
70
|
-
case Position.Bottom:
|
|
71
|
-
offsetY = handle.height;
|
|
72
|
-
break;
|
|
73
|
-
default:
|
|
74
|
-
throw new Error(`Invalid handle position: ${handlePosition}`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const x = node.internals.positionAbsolute.x + handle.x + offsetX;
|
|
78
|
-
const y = node.internals.positionAbsolute.y + handle.y + offsetY;
|
|
79
|
-
|
|
80
|
-
return [x, y] as const;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const getEdgeParams = (source: InternalNode<Node>, target: InternalNode<Node>) => {
|
|
84
|
-
const sourcePos = Position.Right;
|
|
85
|
-
const [sx, sy] = getHandleCoordsByPosition(source, sourcePos);
|
|
86
|
-
const targetPos = Position.Left;
|
|
87
|
-
const [tx, ty] = getHandleCoordsByPosition(target, targetPos);
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
sx,
|
|
91
|
-
sy,
|
|
92
|
-
tx,
|
|
93
|
-
ty,
|
|
94
|
-
sourcePos,
|
|
95
|
-
targetPos,
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const Animated = ({ id, source, target, markerEnd, style }: EdgeProps) => {
|
|
100
|
-
const sourceNode = useInternalNode(source);
|
|
101
|
-
const targetNode = useInternalNode(target);
|
|
102
|
-
|
|
103
|
-
if (!(sourceNode && targetNode)) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(sourceNode, targetNode);
|
|
108
|
-
|
|
109
|
-
const [edgePath] = getBezierPath({
|
|
110
|
-
sourceX: sx,
|
|
111
|
-
sourceY: sy,
|
|
112
|
-
sourcePosition: sourcePos,
|
|
113
|
-
targetX: tx,
|
|
114
|
-
targetY: ty,
|
|
115
|
-
targetPosition: targetPos,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<>
|
|
120
|
-
<BaseEdge id={id} markerEnd={markerEnd} path={edgePath} style={style} />
|
|
121
|
-
<circle fill="var(--primary)" r="4">
|
|
122
|
-
<animateMotion dur="2s" path={edgePath} repeatCount="indefinite" />
|
|
123
|
-
</circle>
|
|
124
|
-
</>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const Edge = {
|
|
129
|
-
Temporary,
|
|
130
|
-
Animated,
|
|
131
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { cn } from '../../lib/utils';
|
|
2
|
-
import type { Experimental_GeneratedImage } from 'ai';
|
|
3
|
-
|
|
4
|
-
export type ImageProps = Experimental_GeneratedImage & {
|
|
5
|
-
className?: string;
|
|
6
|
-
alt?: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Image = ({ base64, uint8Array, mediaType, ...props }: ImageProps) => (
|
|
10
|
-
<img
|
|
11
|
-
{...props}
|
|
12
|
-
alt={props.alt}
|
|
13
|
-
className={cn('h-auto max-w-full overflow-hidden rounded-md', props.className)}
|
|
14
|
-
src={`data:${mediaType};base64,${base64}`}
|
|
15
|
-
/>
|
|
16
|
-
);
|