@agentuity/workbench 0.0.79 → 0.0.84
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/internal/Chat.d.ts.map +1 -1
- package/dist/components/internal/Chat.js +6 -1
- package/dist/components/internal/Chat.js.map +1 -1
- package/dist/components/internal/InputSection.d.ts.map +1 -1
- package/dist/components/internal/InputSection.js +29 -151
- package/dist/components/internal/InputSection.js.map +1 -1
- package/dist/components/internal/MonacoJsonEditor.d.ts +11 -0
- package/dist/components/internal/MonacoJsonEditor.d.ts.map +1 -0
- package/dist/components/internal/MonacoJsonEditor.js +270 -0
- package/dist/components/internal/MonacoJsonEditor.js.map +1 -0
- package/dist/components/internal/Schema.d.ts.map +1 -1
- package/dist/components/internal/Schema.js +1 -1
- 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 +30 -9
- package/dist/components/internal/WorkbenchProvider.js.map +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components.d.ts +1 -0
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +1 -0
- package/dist/components.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useAgentSchemas.d.ts +1 -0
- package/dist/hooks/useAgentSchemas.d.ts.map +1 -1
- package/dist/hooks/useAgentSchemas.js.map +1 -1
- package/dist/hooks/useLogger.d.ts +9 -0
- package/dist/hooks/useLogger.d.ts.map +1 -0
- package/dist/hooks/useLogger.js +41 -0
- package/dist/hooks/useLogger.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +31 -0
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles.css +60 -0
- package/package.json +10 -5
- package/src/components/internal/Chat.tsx +8 -1
- package/src/components/internal/InputSection.tsx +71 -193
- package/src/components/internal/MonacoJsonEditor.tsx +359 -0
- package/src/components/internal/Schema.tsx +2 -1
- package/src/components/internal/WorkbenchProvider.tsx +35 -9
- package/src/components.tsx +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAgentSchemas.ts +1 -0
- package/src/hooks/useLogger.ts +57 -0
- package/src/index.ts +1 -0
- package/src/lib/utils.ts +41 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/components/internal/Chat.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/components/internal/Chat.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAiB1B,MAAM,WAAW,SAAS;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,SAAS,2CA4KxD;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -9,18 +9,23 @@ import { InputSection } from './InputSection';
|
|
|
9
9
|
import { Shimmer } from '../ai-elements/shimmer';
|
|
10
10
|
import { cn } from '../../lib/utils';
|
|
11
11
|
import { useWorkbench } from './WorkbenchProvider';
|
|
12
|
+
import { useLogger } from '../../hooks/useLogger';
|
|
12
13
|
import { Schema } from './Schema';
|
|
13
14
|
/**
|
|
14
15
|
* Chat component - conversation and input area (everything except header)
|
|
15
16
|
* Must be used within WorkbenchProvider
|
|
16
17
|
*/
|
|
17
18
|
export function Chat({ className: _className }) {
|
|
19
|
+
const logger = useLogger('Chat');
|
|
18
20
|
const { agents, suggestions, messages, selectedAgent, setSelectedAgent, isLoading, submitMessage, } = useWorkbench();
|
|
19
21
|
const [value, setValue] = useState('');
|
|
20
22
|
const [schemaOpen, setSchemaOpen] = useState(false);
|
|
21
23
|
const handleSubmit = async () => {
|
|
22
|
-
|
|
24
|
+
logger.debug('🎯 Chat handleSubmit - selectedAgent:', selectedAgent, 'value:', value);
|
|
25
|
+
const selectedAgentData = Object.values(agents).find((agent) => agent.metadata.agentId === selectedAgent);
|
|
26
|
+
logger.debug('📊 Chat handleSubmit - selectedAgentData:', selectedAgentData);
|
|
23
27
|
const hasInputSchema = selectedAgentData?.schema?.input?.json;
|
|
28
|
+
logger.debug('📝 Chat handleSubmit - hasInputSchema:', hasInputSchema);
|
|
24
29
|
// If agent has no input schema, submit without requiring input
|
|
25
30
|
if (!hasInputSchema) {
|
|
26
31
|
await submitMessage('');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/components/internal/Chat.tsx"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACN,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMlC;;;GAGG;AACH,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AC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;qEACxB,IAAI,CAAC,EAAE,CAAC,CACV,EAEF,KAAK,EAAC,MAAM,EACZ,SAAS,EAAC,8BAA8B,YAExC,KAAC,IAAI,IAAC,SAAS,EAAC,QAAQ,GAAG,GACnB,IACA,IACR,CACH,KAzFQ,EAAE,CA0FN,CACN,CAAC;gCACH,CAAC,CAAC,GACmB,EAEtB,KAAC,wBAAwB,KAAG,IACd,EACf,KAAC,YAAY,IACZ,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,GACtC,IACG,EAEN,KAAC,MAAM,IAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,GAAI,IACpD,CACN,CAAC;AACH,CAAC;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputSection.d.ts","sourceRoot":"","sources":["../../../src/components/internal/InputSection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InputSection.d.ts","sourceRoot":"","sources":["../../../src/components/internal/InputSection.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAMnE,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,IAAI,CAAC;CACzB;AAcD,wBAAgB,YAAY,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,YAAY,GACZ,EAAE,iBAAiB,2CA4OnB"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
3
|
import { CheckIcon, ChevronsUpDownIcon, FileJson, SendIcon, Loader2Icon, Sparkles, } from 'lucide-react';
|
|
4
|
-
import {
|
|
4
|
+
import { MonacoJsonEditor } from './MonacoJsonEditor';
|
|
5
5
|
import { PromptInput, PromptInputBody, PromptInputFooter, PromptInputTextarea, } from '../ai-elements/prompt-input';
|
|
6
6
|
import { Button } from '../ui/button';
|
|
7
7
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from '../ui/command';
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
|
9
9
|
import { Select, SelectContent, SelectItem, SelectTrigger } from '../ui/select';
|
|
10
10
|
import { cn } from '../../lib/utils';
|
|
11
|
+
import { useLogger } from '../../hooks/useLogger';
|
|
11
12
|
import { convertJsonSchemaToZod } from 'zod-from-json-schema';
|
|
12
13
|
import { zocker } from 'zocker';
|
|
13
14
|
function isSchemaRootObject(schemaJson) {
|
|
@@ -22,13 +23,13 @@ function isSchemaRootObject(schemaJson) {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
export function InputSection({ value, onChange, onSubmit, isLoading, agents, selectedAgent, setSelectedAgent, suggestions, onSchemaOpen, }) {
|
|
26
|
+
const logger = useLogger('InputSection');
|
|
25
27
|
const [agentSelectOpen, setAgentSelectOpen] = useState(false);
|
|
26
|
-
const
|
|
27
|
-
const editorInstanceRef = useRef(null);
|
|
28
|
-
const selectedAgentData = agents[selectedAgent];
|
|
28
|
+
const selectedAgentData = Object.values(agents).find((agent) => agent.metadata.agentId === selectedAgent);
|
|
29
29
|
// Determine input type for switch case
|
|
30
30
|
const inputType = useMemo(() => {
|
|
31
31
|
const schema = selectedAgentData?.schema?.input?.json;
|
|
32
|
+
logger.debug('🎛️ InputSection - selectedAgent:', selectedAgent, 'selectedAgentData:', selectedAgentData, 'schema:', schema);
|
|
32
33
|
if (!schema) {
|
|
33
34
|
return 'none'; // Agent has no input schema
|
|
34
35
|
}
|
|
@@ -51,162 +52,39 @@ export function InputSection({ value, onChange, onSubmit, isLoading, agents, sel
|
|
|
51
52
|
const sampleData = zocker(zodSchema).generate();
|
|
52
53
|
const sampleJson = JSON.stringify(sampleData, null, 2);
|
|
53
54
|
onChange(sampleJson);
|
|
54
|
-
// Update Monaco editor directly if it exists
|
|
55
|
-
if (editorInstanceRef.current) {
|
|
56
|
-
editorInstanceRef.current.setValue(sampleJson);
|
|
57
|
-
editorInstanceRef.current.layout();
|
|
58
|
-
}
|
|
59
55
|
}
|
|
60
56
|
catch (error) {
|
|
61
57
|
console.error('Failed to generate sample JSON:', error);
|
|
62
58
|
}
|
|
63
59
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (editorInstanceRef.current) {
|
|
82
|
-
editorInstanceRef.current.dispose();
|
|
83
|
-
}
|
|
84
|
-
// Configure JSON schema if available
|
|
85
|
-
const jsonSchema = selectedAgentData?.schema.input?.json;
|
|
86
|
-
if (jsonSchema) {
|
|
87
|
-
// Parse schema if it's a string, otherwise use directly
|
|
88
|
-
const schemaObject = typeof jsonSchema === 'string' ? JSON.parse(jsonSchema) : jsonSchema;
|
|
89
|
-
// Access json namespace directly from monaco
|
|
90
|
-
if ('json' in monaco && typeof monaco.json === 'object' && monaco.json !== null) {
|
|
91
|
-
const jsonModule = monaco.json;
|
|
92
|
-
if ('jsonDefaults' in jsonModule &&
|
|
93
|
-
typeof jsonModule.jsonDefaults === 'object' &&
|
|
94
|
-
jsonModule.jsonDefaults !== null) {
|
|
95
|
-
const jsonDefaults = jsonModule.jsonDefaults;
|
|
96
|
-
if ('setDiagnosticsOptions' in jsonDefaults &&
|
|
97
|
-
typeof jsonDefaults.setDiagnosticsOptions === 'function') {
|
|
98
|
-
jsonDefaults.setDiagnosticsOptions({
|
|
99
|
-
validate: true,
|
|
100
|
-
schemas: [
|
|
101
|
-
{
|
|
102
|
-
// URI is just an identifier, doesn't need to be a real URL
|
|
103
|
-
uri: `agentuity://schema/${selectedAgentData.metadata.id}/input`,
|
|
104
|
-
fileMatch: ['*'],
|
|
105
|
-
schema: schemaObject,
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// Set initial height
|
|
114
|
-
const container = monacoEditorRef.current;
|
|
115
|
-
container.style.height = '64px'; // min-h-16 = 4rem = 64px
|
|
116
|
-
const editor = monaco.editor.create(container, {
|
|
117
|
-
value: value || '{}',
|
|
118
|
-
language: 'json',
|
|
119
|
-
minimap: { enabled: false },
|
|
120
|
-
fontSize: 14,
|
|
121
|
-
lineNumbers: 'off',
|
|
122
|
-
scrollBeyondLastLine: false,
|
|
123
|
-
wordWrap: 'on',
|
|
124
|
-
automaticLayout: true,
|
|
125
|
-
scrollbar: {
|
|
126
|
-
vertical: 'auto',
|
|
127
|
-
horizontal: 'auto',
|
|
128
|
-
},
|
|
129
|
-
padding: { top: 12, bottom: 12 },
|
|
130
|
-
});
|
|
131
|
-
// Make background transparent
|
|
132
|
-
setTimeout(() => {
|
|
133
|
-
if (disposed)
|
|
134
|
-
return;
|
|
135
|
-
const editorElement = container.querySelector('.monaco-editor');
|
|
136
|
-
if (editorElement) {
|
|
137
|
-
editorElement.style.backgroundColor = 'transparent';
|
|
138
|
-
}
|
|
139
|
-
const backgroundElement = container.querySelector('.monaco-editor .monaco-editor-background');
|
|
140
|
-
if (backgroundElement) {
|
|
141
|
-
backgroundElement.style.backgroundColor = 'transparent';
|
|
142
|
-
}
|
|
143
|
-
const viewLines = container.querySelector('.monaco-editor .view-lines');
|
|
144
|
-
if (viewLines) {
|
|
145
|
-
viewLines.style.backgroundColor = 'transparent';
|
|
146
|
-
}
|
|
147
|
-
}, 0);
|
|
148
|
-
editor.onDidChangeModelContent(() => {
|
|
149
|
-
const newValue = editor.getValue();
|
|
150
|
-
onChange(newValue);
|
|
151
|
-
// Auto-resize based on content
|
|
152
|
-
if (container) {
|
|
153
|
-
const contentHeight = editor.getContentHeight();
|
|
154
|
-
const maxHeight = 192; // max-h-48 = 12rem = 192px
|
|
155
|
-
const minHeight = 64; // min-h-16 = 4rem = 64px
|
|
156
|
-
const newHeight = Math.min(Math.max(contentHeight + 24, minHeight), maxHeight);
|
|
157
|
-
container.style.height = `${newHeight}px`;
|
|
158
|
-
editor.layout();
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
// Resize observer for container size changes
|
|
162
|
-
resizeObserver = new ResizeObserver(() => {
|
|
163
|
-
if (!disposed && editor && isMounted) {
|
|
164
|
-
editor.layout();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
resizeObserver.observe(container);
|
|
168
|
-
// Force layout update after creation
|
|
169
|
-
setTimeout(() => {
|
|
170
|
-
if (disposed)
|
|
171
|
-
return;
|
|
172
|
-
editor.layout();
|
|
173
|
-
}, 0);
|
|
174
|
-
editorInstanceRef.current = editor;
|
|
175
|
-
});
|
|
176
|
-
return () => {
|
|
177
|
-
isMounted = false;
|
|
178
|
-
disposed = true;
|
|
179
|
-
if (resizeObserver) {
|
|
180
|
-
resizeObserver.disconnect();
|
|
181
|
-
}
|
|
182
|
-
if (editorInstanceRef.current) {
|
|
183
|
-
editorInstanceRef.current.dispose();
|
|
184
|
-
editorInstanceRef.current = null;
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
}, [isObjectSchema, onChange, selectedAgentData]);
|
|
188
|
-
useEffect(() => {
|
|
189
|
-
if (isObjectSchema && editorInstanceRef.current) {
|
|
190
|
-
const currentValue = editorInstanceRef.current.getValue();
|
|
191
|
-
if (currentValue !== value) {
|
|
192
|
-
editorInstanceRef.current.setValue(value || '{}');
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}, [value, isObjectSchema]);
|
|
196
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 py-2 px-3", children: [_jsxs(Popover, { open: agentSelectOpen, onOpenChange: setAgentSelectOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { "aria-expanded": agentSelectOpen, className: "font-normal bg-transparent dark:bg-transparent", variant: "outline", size: "sm", children: [agents[selectedAgent]?.metadata.name || 'Select agent', _jsx(ChevronsUpDownIcon, { className: "size-4 shrink-0 opacity-50" })] }) }), _jsx(PopoverContent, { className: "w-fit p-0", children: _jsxs(Command, { children: [_jsx(CommandInput, { placeholder: "Search agents..." }), _jsxs(CommandList, { children: [_jsx(CommandEmpty, { children: "No agents found." }), _jsx(CommandGroup, { children: Object.values(agents).map((agent) => (_jsxs(CommandItem, { value: agent.metadata.identifier, onSelect: (currentValue) => {
|
|
197
|
-
setSelectedAgent(currentValue);
|
|
198
|
-
setAgentSelectOpen(false);
|
|
199
|
-
}, children: [_jsx(CheckIcon, { className: cn('size-4 text-green-500', selectedAgent === agent.metadata.identifier
|
|
200
|
-
? 'opacity-100'
|
|
201
|
-
: 'opacity-0') }), agent.metadata.name] }, agent.metadata.identifier))) })] })] }) })] }), suggestions.length > 0 && (_jsxs(Select, { onValueChange: (value) => onChange(value), children: [_jsx(SelectTrigger, { size: "sm", className: "ml-auto bg-transparent dark:bg-transparent text-foreground!", children: "Suggestions" }), _jsx(SelectContent, { className: "text-sm", side: "top", align: "end", children: suggestions.map((suggestion) => (_jsx(SelectItem, { value: suggestion, children: suggestion }, suggestion))) })] })), isObjectSchema && (_jsxs(Button, { "aria-label": "Generate Sample JSON", size: "sm", variant: "outline", className: "bg-none font-normal", onClick: handleGenerateSample, children: [_jsx(Sparkles, { className: "size-4" }), " Sample"] })), _jsxs(Button, { "aria-label": "View Schema", size: "sm", variant: "outline", className: "bg-none font-normal", onClick: onSchemaOpen, children: [_jsx(FileJson, { className: "size-4" }), " Schema"] })] }), _jsxs(PromptInput, { onSubmit: onSubmit, className: "px-3 pb-3", children: [_jsx(PromptInputBody, { children: (() => {
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 py-2 px-3", children: [_jsxs(Popover, { open: agentSelectOpen, onOpenChange: setAgentSelectOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { "aria-expanded": agentSelectOpen, className: "font-normal bg-transparent dark:bg-transparent", variant: "outline", size: "sm", children: [Object.values(agents).find((agent) => agent.metadata.agentId === selectedAgent)?.metadata.name || 'Select agent', _jsx(ChevronsUpDownIcon, { className: "size-4 shrink-0 opacity-50" })] }) }), _jsx(PopoverContent, { className: "w-fit p-0", children: _jsxs(Command, { children: [_jsx(CommandInput, { placeholder: "Search agents..." }), _jsxs(CommandList, { children: [_jsx(CommandEmpty, { children: "No agents found." }), _jsx(CommandGroup, { children: Object.values(agents)
|
|
61
|
+
.sort((a, b) => a.metadata.name.localeCompare(b.metadata.name))
|
|
62
|
+
.map((agent) => {
|
|
63
|
+
const isSelected = selectedAgent === agent.metadata.agentId;
|
|
64
|
+
// Use name for search but include agentId to ensure uniqueness
|
|
65
|
+
const searchValue = `${agent.metadata.name}|${agent.metadata.agentId}`;
|
|
66
|
+
return (_jsxs(CommandItem, { value: searchValue, onSelect: (currentValue) => {
|
|
67
|
+
// Extract agentId from the compound value
|
|
68
|
+
const agentId = currentValue.split('|')[1];
|
|
69
|
+
const selectedAgentData = Object.values(agents).find((a) => a.metadata.agentId === agentId);
|
|
70
|
+
if (selectedAgentData) {
|
|
71
|
+
logger.debug('🎯 Agent selected by name:', agent.metadata.name, 'agentId:', agentId);
|
|
72
|
+
setSelectedAgent(agentId);
|
|
73
|
+
}
|
|
74
|
+
setAgentSelectOpen(false);
|
|
75
|
+
}, children: [_jsx(CheckIcon, { className: cn('size-4 text-green-500', isSelected ? 'opacity-100' : 'opacity-0') }), agent.metadata.name] }, agent.metadata.agentId));
|
|
76
|
+
}) })] })] }) })] }), suggestions.length > 0 && (_jsxs(Select, { onValueChange: (value) => onChange(value), children: [_jsx(SelectTrigger, { size: "sm", className: "ml-auto bg-transparent dark:bg-transparent text-foreground!", children: "Suggestions" }), _jsx(SelectContent, { className: "text-sm", side: "top", align: "end", children: suggestions.map((suggestion) => (_jsx(SelectItem, { value: suggestion, children: suggestion }, suggestion))) })] })), isObjectSchema && (_jsxs(Button, { "aria-label": "Generate Sample JSON", size: "sm", variant: "outline", className: "bg-none font-normal", onClick: handleGenerateSample, children: [_jsx(Sparkles, { className: "size-4" }), " Sample"] })), _jsxs(Button, { "aria-label": "View Schema", size: "sm", variant: "outline", className: "bg-none font-normal", onClick: onSchemaOpen, children: [_jsx(FileJson, { className: "size-4" }), " Schema"] })] }), _jsxs(PromptInput, { onSubmit: onSubmit, className: "px-3 pb-3", children: [_jsx(PromptInputBody, { children: (() => {
|
|
202
77
|
switch (inputType) {
|
|
203
78
|
case 'object':
|
|
204
|
-
return (_jsx(
|
|
79
|
+
return (_jsx(MonacoJsonEditor, { value: value, onChange: onChange, schema: selectedAgentData?.schema.input?.json, schemaUri: `agentuity://schema/${selectedAgentData?.metadata.id}/input` }));
|
|
205
80
|
case 'string':
|
|
206
81
|
return (_jsx(PromptInputTextarea, { placeholder: "Enter a message to send...", value: value, onChange: (e) => onChange(e.target.value) }));
|
|
207
82
|
default:
|
|
208
|
-
return (_jsxs("div", { className: "flex flex-col items-center justify-center py-8 px-4 text-center ", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: _jsxs("span", { className: "font-medium", children: ["This agent has
|
|
83
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center py-8 px-4 text-center ", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: _jsxs("span", { className: "font-medium", children: ["This agent has no input schema.", ' '] }) }), _jsxs(Button, { "aria-label": "Run Agent", size: "sm", variant: "default", disabled: isLoading, onClick: onSubmit, className: "mt-2", children: [isLoading ? (_jsx(Loader2Icon, { className: "size-4 animate-spin mr-2" })) : (_jsx(SendIcon, { className: "size-4 mr-2" })), "Run Agent"] })] }));
|
|
209
84
|
}
|
|
210
|
-
})() }), _jsx(PromptInputFooter, { children: inputType !== 'none' && (_jsx(Button, { "aria-label": "Submit", size: "icon", variant: "default", disabled: isLoading || (inputType === 'string' && !value.trim()), onClick:
|
|
85
|
+
})() }), _jsx(PromptInputFooter, { children: inputType !== 'none' && (_jsx(Button, { "aria-label": "Submit", size: "icon", variant: "default", disabled: isLoading || (inputType === 'string' && !value.trim()), onClick: () => {
|
|
86
|
+
logger.debug('🔥 Submit button clicked! inputType:', inputType, 'value:', value);
|
|
87
|
+
onSubmit();
|
|
88
|
+
}, className: "ml-auto", children: isLoading ? (_jsx(Loader2Icon, { className: "size-4 animate-spin" })) : (_jsx(SendIcon, { className: "size-4" })) })) })] })] }));
|
|
211
89
|
}
|
|
212
90
|
//# sourceMappingURL=InputSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputSection.js","sourceRoot":"","sources":["../../../src/components/internal/InputSection.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"In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,EACtC,SAAS,EACT,QAAQ,EACR,KAAK,CACL,CAAC;gCACF,QAAQ,EAAE,CAAC;4BACZ,CAAC,EACD,SAAS,EAAC,SAAS,YAElB,SAAS,CAAC,CAAC,CAAC,CACZ,KAAC,WAAW,IAAC,SAAS,EAAC,qBAAqB,GAAG,CAC/C,CAAC,CAAC,CAAC,CACH,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,CAC/B,GACO,CACT,GACkB,IACP,IACZ,CACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'ai';
|
|
2
|
+
interface MonacoJsonEditorProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
schema?: JSONSchema7;
|
|
6
|
+
schemaUri?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function MonacoJsonEditor({ value, onChange, schema, schemaUri, className, }: MonacoJsonEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=MonacoJsonEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoJsonEditor.d.ts","sourceRoot":"","sources":["../../../src/components/internal/MonacoJsonEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAEtC,UAAU,qBAAqB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAwFD,wBAAgB,gBAAgB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,SAAwC,EACxC,SAAc,GACd,EAAE,qBAAqB,2CA4PvB"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import Editor from '@monaco-editor/react';
|
|
4
|
+
import { useTheme } from '../ui/theme-provider';
|
|
5
|
+
import { bundledThemes } from 'shiki';
|
|
6
|
+
// Convert color value to valid hex for Monaco
|
|
7
|
+
function normalizeColorForMonaco(color, isDark) {
|
|
8
|
+
if (!color)
|
|
9
|
+
return isDark ? 'abb2bf' : '383a42'; // Default foreground colors
|
|
10
|
+
// Remove # prefix if present
|
|
11
|
+
let normalized = color.replace('#', '');
|
|
12
|
+
// Handle common color names that might appear in themes
|
|
13
|
+
const colorMap = {
|
|
14
|
+
white: isDark ? 'ffffff' : '383a42',
|
|
15
|
+
black: isDark ? '000000' : 'abb2bf',
|
|
16
|
+
red: 'e45649',
|
|
17
|
+
green: '50a14f',
|
|
18
|
+
blue: '4078f2',
|
|
19
|
+
yellow: '986801',
|
|
20
|
+
cyan: '0184bc',
|
|
21
|
+
magenta: 'a626a4',
|
|
22
|
+
};
|
|
23
|
+
if (colorMap[normalized.toLowerCase()]) {
|
|
24
|
+
normalized = colorMap[normalized.toLowerCase()];
|
|
25
|
+
}
|
|
26
|
+
// Validate it's a proper hex color (3 or 6 characters)
|
|
27
|
+
if (!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/.test(normalized)) {
|
|
28
|
+
return isDark ? 'abb2bf' : '383a42'; // Fallback to default
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
// Convert Shiki theme to Monaco theme
|
|
33
|
+
function convertShikiToMonaco(shikiTheme, themeName) {
|
|
34
|
+
const colors = shikiTheme.colors || {};
|
|
35
|
+
const tokenColors = shikiTheme.tokenColors || [];
|
|
36
|
+
const isDark = themeName.includes('dark');
|
|
37
|
+
// Convert token colors to Monaco rules
|
|
38
|
+
const rules = [];
|
|
39
|
+
tokenColors.forEach((tokenColor) => {
|
|
40
|
+
if (tokenColor.scope && tokenColor.settings?.foreground) {
|
|
41
|
+
const scopes = Array.isArray(tokenColor.scope) ? tokenColor.scope : [tokenColor.scope];
|
|
42
|
+
scopes.forEach((scope) => {
|
|
43
|
+
// Map common scopes to Monaco tokens
|
|
44
|
+
let token = scope;
|
|
45
|
+
if (scope.includes('string.quoted.double.json'))
|
|
46
|
+
token = 'string.value.json';
|
|
47
|
+
if (scope.includes('support.type.property-name.json'))
|
|
48
|
+
token = 'string.key.json';
|
|
49
|
+
if (scope.includes('constant.numeric.json'))
|
|
50
|
+
token = 'number.json';
|
|
51
|
+
if (scope.includes('constant.language.json'))
|
|
52
|
+
token = 'keyword.json';
|
|
53
|
+
if (scope.includes('punctuation.definition.string.json'))
|
|
54
|
+
token = 'delimiter.bracket.json';
|
|
55
|
+
const normalizedColor = normalizeColorForMonaco(tokenColor.settings?.foreground, isDark);
|
|
56
|
+
rules.push({
|
|
57
|
+
token,
|
|
58
|
+
foreground: normalizedColor,
|
|
59
|
+
fontStyle: tokenColor.settings?.fontStyle || undefined,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
base: isDark ? 'vs-dark' : 'vs',
|
|
66
|
+
inherit: true,
|
|
67
|
+
rules,
|
|
68
|
+
colors: {
|
|
69
|
+
'editor.background': '#00000000', // Always transparent
|
|
70
|
+
'editor.foreground': normalizeColorForMonaco(colors['editor.foreground'], isDark),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function MonacoJsonEditor({ value, onChange, schema, schemaUri = 'agentuity://schema/default', className = '', }) {
|
|
75
|
+
const { theme } = useTheme();
|
|
76
|
+
const [editorInstance, setEditorInstance] = useState(null);
|
|
77
|
+
const [monacoInstance, setMonacoInstance] = useState(null);
|
|
78
|
+
const [editorHeight, setEditorHeight] = useState(120);
|
|
79
|
+
// Get resolved theme (similar to useTheme's resolvedTheme from next-themes)
|
|
80
|
+
const resolvedTheme = React.useMemo(() => {
|
|
81
|
+
if (theme === 'system') {
|
|
82
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
83
|
+
}
|
|
84
|
+
return theme;
|
|
85
|
+
}, [theme]);
|
|
86
|
+
// Configure JSON schema when schema or monacoInstance changes
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!monacoInstance || !schema)
|
|
89
|
+
return;
|
|
90
|
+
const schemaObject = typeof schema === 'string' ? JSON.parse(schema) : schema;
|
|
91
|
+
// Configure Monaco JSON language support for schema validation
|
|
92
|
+
monacoInstance.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
93
|
+
validate: true,
|
|
94
|
+
schemas: [
|
|
95
|
+
{
|
|
96
|
+
uri: schemaUri,
|
|
97
|
+
fileMatch: ['*'],
|
|
98
|
+
schema: schemaObject,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
}, [monacoInstance, schema, schemaUri]);
|
|
103
|
+
// Handle theme changes for existing editor instance
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (editorInstance && monacoInstance) {
|
|
106
|
+
editorInstance.updateOptions({
|
|
107
|
+
theme: resolvedTheme === 'light' ? 'custom-light' : 'custom-dark',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, [resolvedTheme, editorInstance, monacoInstance]);
|
|
111
|
+
return (_jsx("div", { className: `w-full pl-3 pb-3 [&_.monaco-editor]:!bg-transparent [&_.monaco-editor-background]:!bg-transparent [&_.view-lines]:!bg-transparent [&_.monaco-editor]:!shadow-none [&_.monaco-scrollable-element]:!shadow-none [&_.overflow-guard]:!shadow-none [&_.monaco-scrollable-element>.shadow.top]:!hidden [&_.monaco-editor_.scroll-decoration]:!hidden [&_.shadow.top]:!hidden [&_.scroll-decoration]:!hidden ${className}`, style: { minHeight: '64px', maxHeight: '192px', height: `${editorHeight}px` }, children: _jsx(Editor, { value: value || '{}', onChange: (newValue) => onChange(newValue || ''), language: "json", theme: resolvedTheme === 'light' ? 'custom-light' : 'custom-dark', height: "100%", options: {
|
|
112
|
+
minimap: { enabled: false },
|
|
113
|
+
lineNumbers: 'off',
|
|
114
|
+
folding: false,
|
|
115
|
+
scrollBeyondLastLine: false,
|
|
116
|
+
wordWrap: 'on',
|
|
117
|
+
renderLineHighlight: 'none',
|
|
118
|
+
overviewRulerBorder: false,
|
|
119
|
+
overviewRulerLanes: 0,
|
|
120
|
+
hideCursorInOverviewRuler: true,
|
|
121
|
+
fixedOverflowWidgets: true,
|
|
122
|
+
roundedSelection: false,
|
|
123
|
+
occurrencesHighlight: 'off',
|
|
124
|
+
selectionHighlight: false,
|
|
125
|
+
renderWhitespace: 'none',
|
|
126
|
+
fontSize: 14,
|
|
127
|
+
fontWeight: '400',
|
|
128
|
+
formatOnPaste: true,
|
|
129
|
+
formatOnType: true,
|
|
130
|
+
autoIndent: 'full',
|
|
131
|
+
glyphMargin: false,
|
|
132
|
+
lineDecorationsWidth: 0,
|
|
133
|
+
lineNumbersMinChars: 0,
|
|
134
|
+
automaticLayout: true,
|
|
135
|
+
scrollbar: {
|
|
136
|
+
vertical: 'auto',
|
|
137
|
+
horizontal: 'auto',
|
|
138
|
+
verticalScrollbarSize: 10,
|
|
139
|
+
horizontalScrollbarSize: 10,
|
|
140
|
+
// Disable scroll shadows
|
|
141
|
+
verticalHasArrows: false,
|
|
142
|
+
horizontalHasArrows: false,
|
|
143
|
+
},
|
|
144
|
+
padding: { top: 12, bottom: 12 },
|
|
145
|
+
// Additional background transparency options
|
|
146
|
+
renderValidationDecorations: 'off',
|
|
147
|
+
guides: {
|
|
148
|
+
indentation: false,
|
|
149
|
+
highlightActiveIndentation: false,
|
|
150
|
+
},
|
|
151
|
+
// Disable sticky scroll feature
|
|
152
|
+
stickyScroll: { enabled: false },
|
|
153
|
+
// Disable scroll decorations/shadows
|
|
154
|
+
scrollBeyondLastColumn: 0,
|
|
155
|
+
renderLineHighlightOnlyWhenFocus: true,
|
|
156
|
+
}, onMount: (editor, monaco) => {
|
|
157
|
+
setEditorInstance(editor);
|
|
158
|
+
setMonacoInstance(monaco);
|
|
159
|
+
editor.focus();
|
|
160
|
+
// Auto-resize based on content
|
|
161
|
+
const updateHeight = () => {
|
|
162
|
+
const contentHeight = editor.getContentHeight();
|
|
163
|
+
const maxHeight = 192; // max-h-48 = 12rem = 192px
|
|
164
|
+
const minHeight = 64; // min-h-16 = 4rem = 64px
|
|
165
|
+
const newHeight = Math.min(Math.max(contentHeight + 24, minHeight), maxHeight);
|
|
166
|
+
setEditorHeight(newHeight);
|
|
167
|
+
// Layout after height change
|
|
168
|
+
setTimeout(() => editor.layout(), 0);
|
|
169
|
+
};
|
|
170
|
+
// Update height on content changes
|
|
171
|
+
editor.onDidChangeModelContent(updateHeight);
|
|
172
|
+
// Initial height update
|
|
173
|
+
setTimeout(updateHeight, 0);
|
|
174
|
+
// Ensure background transparency and remove shadows
|
|
175
|
+
setTimeout(() => {
|
|
176
|
+
const editorElement = editor.getDomNode();
|
|
177
|
+
if (editorElement) {
|
|
178
|
+
// Set transparent backgrounds on all relevant elements
|
|
179
|
+
const elementsToMakeTransparent = [
|
|
180
|
+
'.monaco-editor',
|
|
181
|
+
'.monaco-editor .monaco-editor-background',
|
|
182
|
+
'.monaco-editor .view-lines',
|
|
183
|
+
'.monaco-editor .margin',
|
|
184
|
+
'.monaco-editor .monaco-scrollable-element',
|
|
185
|
+
'.monaco-editor .overflow-guard',
|
|
186
|
+
'.view-overlays',
|
|
187
|
+
'.decorationsOverviewRuler',
|
|
188
|
+
];
|
|
189
|
+
elementsToMakeTransparent.forEach((selector) => {
|
|
190
|
+
const element = editorElement.querySelector(selector);
|
|
191
|
+
if (element) {
|
|
192
|
+
element.style.backgroundColor = 'transparent';
|
|
193
|
+
element.style.boxShadow = 'none';
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
// Remove scroll shadows specifically - target the exact classes
|
|
197
|
+
const shadowTop = editorElement.querySelector('.monaco-scrollable-element > .shadow.top');
|
|
198
|
+
if (shadowTop) {
|
|
199
|
+
shadowTop.style.display = 'none';
|
|
200
|
+
}
|
|
201
|
+
const scrollDecorations = editorElement.querySelectorAll('.monaco-editor .scroll-decoration, .scroll-decoration');
|
|
202
|
+
scrollDecorations.forEach((decoration) => {
|
|
203
|
+
decoration.style.display = 'none';
|
|
204
|
+
});
|
|
205
|
+
const scrollableElement = editorElement.querySelector('.monaco-scrollable-element');
|
|
206
|
+
if (scrollableElement) {
|
|
207
|
+
scrollableElement.style.setProperty('--scroll-shadow', 'none');
|
|
208
|
+
scrollableElement.style.setProperty('box-shadow', 'none', 'important');
|
|
209
|
+
}
|
|
210
|
+
// Also set transparent and remove shadow on the editor element itself
|
|
211
|
+
editorElement.style.backgroundColor = 'transparent';
|
|
212
|
+
editorElement.style.boxShadow = 'none';
|
|
213
|
+
}
|
|
214
|
+
}, 0);
|
|
215
|
+
}, beforeMount: async (monaco) => {
|
|
216
|
+
setMonacoInstance(monaco);
|
|
217
|
+
try {
|
|
218
|
+
// Try to use actual Shiki themes
|
|
219
|
+
const oneLightThemeModule = await bundledThemes['one-light']();
|
|
220
|
+
const oneDarkProThemeModule = await bundledThemes['one-dark-pro']();
|
|
221
|
+
if (oneLightThemeModule?.default) {
|
|
222
|
+
const lightMonacoTheme = convertShikiToMonaco(oneLightThemeModule.default, 'one-light');
|
|
223
|
+
monaco.editor.defineTheme('custom-light', lightMonacoTheme);
|
|
224
|
+
}
|
|
225
|
+
if (oneDarkProThemeModule?.default) {
|
|
226
|
+
const darkMonacoTheme = convertShikiToMonaco(oneDarkProThemeModule.default, 'one-dark-pro');
|
|
227
|
+
monaco.editor.defineTheme('custom-dark', darkMonacoTheme);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
console.warn('Failed to load Shiki themes, falling back to manual themes:', error);
|
|
232
|
+
// Fallback to manual theme definitions
|
|
233
|
+
monaco.editor.defineTheme('custom-light', {
|
|
234
|
+
base: 'vs',
|
|
235
|
+
inherit: true,
|
|
236
|
+
rules: [
|
|
237
|
+
{ token: 'string.key.json', foreground: 'e45649' },
|
|
238
|
+
{ token: 'string.value.json', foreground: '50a14f' },
|
|
239
|
+
{ token: 'number.json', foreground: '986801' },
|
|
240
|
+
{ token: 'keyword.json', foreground: '986801' },
|
|
241
|
+
{ token: 'string', foreground: '50a14f' },
|
|
242
|
+
{ token: 'number', foreground: '986801' },
|
|
243
|
+
{ token: 'keyword', foreground: '986801' },
|
|
244
|
+
],
|
|
245
|
+
colors: {
|
|
246
|
+
'editor.background': '#00000000',
|
|
247
|
+
'editor.foreground': '#383a42',
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
monaco.editor.defineTheme('custom-dark', {
|
|
251
|
+
base: 'vs-dark',
|
|
252
|
+
inherit: true,
|
|
253
|
+
rules: [
|
|
254
|
+
{ token: 'string.key.json', foreground: 'e06c75' },
|
|
255
|
+
{ token: 'string.value.json', foreground: '98c379' },
|
|
256
|
+
{ token: 'number.json', foreground: 'd19a66' },
|
|
257
|
+
{ token: 'keyword.json', foreground: 'c678dd' },
|
|
258
|
+
{ token: 'string', foreground: '98c379' },
|
|
259
|
+
{ token: 'number', foreground: 'd19a66' },
|
|
260
|
+
{ token: 'keyword', foreground: 'c678dd' },
|
|
261
|
+
],
|
|
262
|
+
colors: {
|
|
263
|
+
'editor.background': '#00000000',
|
|
264
|
+
'editor.foreground': '#abb2bf',
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
} }) }));
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=MonacoJsonEditor.js.map
|