mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-16 18:25:17 +02:00
Update tool definitions to use isLibrary
This commit is contained in:
parent
3d4702c83e
commit
dbd836d5e6
6 changed files with 35 additions and 52 deletions
|
|
@ -49,8 +49,6 @@ export async function fetchMcpTools(projectId: string): Promise<z.infer<typeof W
|
|||
const tool: z.infer<typeof WorkflowTool> = {
|
||||
name: mcpTool.name,
|
||||
description: mcpTool.description ?? "",
|
||||
type: 'library',
|
||||
implementation: 'default',
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: props ?? {},
|
||||
|
|
|
|||
|
|
@ -55,12 +55,11 @@ You are an helpful customer support assistant
|
|||
{
|
||||
"name": "web_search",
|
||||
"description": "Fetch information from the web based on chat context",
|
||||
"type": "library",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
},
|
||||
"implementation": "default",
|
||||
"isLibrary": true
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,15 +36,7 @@ export const WorkflowPrompt = z.object({
|
|||
export const WorkflowTool = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
type: z.union([
|
||||
z.literal('library'),
|
||||
z.literal('custom'),
|
||||
]).default('custom'),
|
||||
implementation: z.union([
|
||||
z.literal('mock'),
|
||||
z.literal('default'),
|
||||
z.literal('api')
|
||||
]).default('mock'),
|
||||
mockTool: z.boolean().default(false).optional(),
|
||||
autoSubmitMockedResponse: z.boolean().default(false).optional(),
|
||||
mockInstructions: z.string().optional(),
|
||||
parameters: z.object({
|
||||
|
|
@ -56,6 +48,7 @@ export const WorkflowTool = z.object({
|
|||
required: z.array(z.string()).optional(),
|
||||
}),
|
||||
isMcp: z.boolean().default(false).optional(),
|
||||
isLibrary: z.boolean().default(false).optional(),
|
||||
mcpServerName: z.string().optional(),
|
||||
});
|
||||
export const Workflow = z.object({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { WorkflowTool } from "../../../lib/types/workflow_types";
|
||||
import { Checkbox, Select, SelectItem, RadioGroup, Radio } from "@heroui/react";
|
||||
import { z } from "zod";
|
||||
import { ImportIcon, XIcon, PlusIcon } from "lucide-react";
|
||||
import { ImportIcon, XIcon, PlusIcon, FolderIcon } from "lucide-react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Panel } from "@/components/common/panel-common";
|
||||
|
|
@ -161,7 +161,7 @@ export function ToolConfig({
|
|||
handleClose: () => void
|
||||
}) {
|
||||
const [selectedParams, setSelectedParams] = useState(new Set([]));
|
||||
const isReadOnly = tool.isMcp;
|
||||
const isReadOnly = tool.isMcp || tool.isLibrary;
|
||||
const [nameError, setNameError] = useState<string | null>(null);
|
||||
|
||||
function handleParamRename(oldName: string, newName: string) {
|
||||
|
|
@ -245,6 +245,12 @@ export function ToolConfig({
|
|||
<span className="text-xs">MCP: {tool.mcpServerName}</span>
|
||||
</div>
|
||||
)}
|
||||
{tool.isLibrary && (
|
||||
<div className="flex items-center gap-2 text-sm bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded-full text-gray-700 dark:text-gray-300">
|
||||
<FolderIcon className="w-4 h-4 text-blue-700 dark:text-blue-400" />
|
||||
<span className="text-xs">Library Tool</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
|
|
@ -259,7 +265,7 @@ export function ToolConfig({
|
|||
}
|
||||
>
|
||||
<div className="flex flex-col gap-6 p-4">
|
||||
{!isReadOnly && tool.type !== 'library' && (
|
||||
{!isReadOnly && (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label className={sectionHeaderStyles}>
|
||||
|
|
@ -310,7 +316,7 @@ export function ToolConfig({
|
|||
description: e.target.value
|
||||
})}
|
||||
placeholder="Describe what this tool does..."
|
||||
disabled={isReadOnly || tool.type === 'library'}
|
||||
disabled={isReadOnly}
|
||||
className={textareaStyles}
|
||||
autoResize
|
||||
/>
|
||||
|
|
@ -324,13 +330,12 @@ export function ToolConfig({
|
|||
</label>
|
||||
|
||||
<RadioGroup
|
||||
defaultValue={tool.implementation}
|
||||
value={tool.implementation}
|
||||
defaultValue="mock"
|
||||
value={tool.mockTool ? "mock" : "api"}
|
||||
onValueChange={(value) => handleUpdate({
|
||||
...tool,
|
||||
implementation: value as "mock" | "default" | "api",
|
||||
autoSubmitMockedResponse: value === "mock" ? true : undefined,
|
||||
mockInstructions: value === "mock" ? tool.mockInstructions : undefined
|
||||
mockTool: value === "mock",
|
||||
autoSubmitMockedResponse: value === "mock" ? true : undefined
|
||||
})}
|
||||
orientation="horizontal"
|
||||
classNames={{
|
||||
|
|
@ -347,32 +352,20 @@ export function ToolConfig({
|
|||
>
|
||||
Mock tool responses
|
||||
</Radio>
|
||||
{tool.type === "library" ? (
|
||||
<Radio
|
||||
value="default"
|
||||
classNames={{
|
||||
base: "p-0 data-[selected=true]:bg-indigo-50 dark:data-[selected=true]:bg-indigo-900/50 rounded-lg transition-colors",
|
||||
label: "text-base font-normal text-gray-900 dark:text-gray-100 px-3 py-1"
|
||||
}}
|
||||
>
|
||||
Use default implementation
|
||||
</Radio>
|
||||
) : (
|
||||
<Radio
|
||||
value="api"
|
||||
classNames={{
|
||||
base: "p-0 data-[selected=true]:bg-indigo-50 dark:data-[selected=true]:bg-indigo-900/50 rounded-lg transition-colors",
|
||||
label: "text-base font-normal text-gray-900 dark:text-gray-100 px-3 py-1"
|
||||
}}
|
||||
>
|
||||
Connect tool to your API
|
||||
</Radio>
|
||||
)}
|
||||
<Radio
|
||||
value="api"
|
||||
classNames={{
|
||||
base: "p-0 data-[selected=true]:bg-indigo-50 dark:data-[selected=true]:bg-indigo-900/50 rounded-lg transition-colors",
|
||||
label: "text-base font-normal text-gray-900 dark:text-gray-100 px-3 py-1"
|
||||
}}
|
||||
>
|
||||
Connect tool to your API
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tool.implementation === "mock" && (
|
||||
{tool.mockTool && (
|
||||
<div className={`space-y-4 ${dividerStyles} pt-6`}>
|
||||
<div className="space-y-4">
|
||||
<label className={sectionHeaderStyles}>
|
||||
|
|
@ -424,12 +417,12 @@ export function ToolConfig({
|
|||
handleUpdate={handleParamUpdate}
|
||||
handleDelete={handleParamDelete}
|
||||
handleRename={handleParamRename}
|
||||
readOnly={isReadOnly || tool.type === 'library'}
|
||||
readOnly={isReadOnly}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{!isReadOnly && tool.type !== 'library' && (
|
||||
{!isReadOnly && (
|
||||
<div className="pl-3">
|
||||
<Button
|
||||
variant="primary"
|
||||
|
|
@ -447,8 +440,6 @@ export function ToolConfig({
|
|||
|
||||
handleUpdate({
|
||||
...tool,
|
||||
type: 'custom',
|
||||
implementation: 'mock',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: newProperties,
|
||||
|
|
|
|||
|
|
@ -237,8 +237,11 @@ export function EntityList({
|
|||
variant="secondary"
|
||||
size="sm"
|
||||
onClick={() => onAddTool({
|
||||
type: 'custom',
|
||||
implementation: 'mock'
|
||||
mockTool: true,
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {}
|
||||
}
|
||||
})}
|
||||
className={`group ${buttonClasses}`}
|
||||
showHoverContent={true}
|
||||
|
|
|
|||
|
|
@ -295,8 +295,7 @@ function reducer(state: State, action: Action): State {
|
|||
type: 'object',
|
||||
properties: {},
|
||||
},
|
||||
type: 'custom',
|
||||
implementation: 'mock',
|
||||
mockTool: true,
|
||||
autoSubmitMockedResponse: true,
|
||||
...action.tool
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue