feat: per-agent tools toggle and better python scratchpad
Add ToolSelector for enabling sandboxed python per agent, drop unsafe filesystem/bash tools, bundle fetchUrl with web search, and return Monty's last expression value so agents need not print.
This commit is contained in:
@@ -50,6 +50,10 @@ const searchConfig = ref({
|
||||
rerank: props.agent?.config?.search?.rerank ?? false,
|
||||
});
|
||||
|
||||
const toolsConfig = ref({
|
||||
python: props.agent?.config?.tools?.python ?? false,
|
||||
});
|
||||
|
||||
watch(() => props.agent?.config?.search, (val) => {
|
||||
searchConfig.value = {
|
||||
enabled: val?.enabled ?? false,
|
||||
@@ -58,21 +62,45 @@ watch(() => props.agent?.config?.search, (val) => {
|
||||
};
|
||||
}, { deep: true });
|
||||
|
||||
const saveSearchConfig = async () => {
|
||||
watch(() => props.agent?.config?.tools, (val) => {
|
||||
toolsConfig.value = {
|
||||
python: val?.python ?? false,
|
||||
};
|
||||
}, { deep: true });
|
||||
|
||||
const saveAgentConfig = async (partial: {
|
||||
search?: typeof searchConfig.value;
|
||||
tools?: typeof toolsConfig.value;
|
||||
}) => {
|
||||
if (!props.agent) return;
|
||||
const currentConfig = props.agent.config ?? {};
|
||||
const newConfig = {
|
||||
...currentConfig,
|
||||
search: {
|
||||
enabled: searchConfig.value.enabled,
|
||||
maxResults: searchConfig.value.maxResults,
|
||||
rerank: searchConfig.value.rerank,
|
||||
},
|
||||
...(partial.search !== undefined ? {
|
||||
search: {
|
||||
enabled: partial.search.enabled,
|
||||
maxResults: partial.search.maxResults,
|
||||
rerank: partial.search.rerank,
|
||||
},
|
||||
} : {}),
|
||||
...(partial.tools !== undefined ? {
|
||||
tools: {
|
||||
python: partial.tools.python,
|
||||
},
|
||||
} : {}),
|
||||
};
|
||||
patchAgentLocally(props.agent.id, { config: newConfig });
|
||||
updateAgent(props.agent.id, { config: newConfig });
|
||||
};
|
||||
|
||||
const saveSearchConfig = async () => {
|
||||
await saveAgentConfig({ search: searchConfig.value });
|
||||
};
|
||||
|
||||
const saveToolsConfig = async () => {
|
||||
await saveAgentConfig({ tools: toolsConfig.value });
|
||||
};
|
||||
|
||||
const isUploading = computed(() => files.value.some((f) => f.status === 'uploading'));
|
||||
const hasFailedUploads = computed(() => files.value.some((f) => f.status === 'error'));
|
||||
|
||||
@@ -386,6 +414,8 @@ onUnmounted(() => {
|
||||
@update:enabled="(v: boolean) => { searchConfig.enabled = v; saveSearchConfig() }"
|
||||
@update:max-results="(v: number) => { searchConfig.maxResults = v; saveSearchConfig() }"
|
||||
@update:rerank="(v: boolean) => { searchConfig.rerank = v; saveSearchConfig() }" />
|
||||
<ToolSelector v-if="selectedModel?.capabilities.includes('tools')" :python="toolsConfig.python"
|
||||
@update:python="(v: boolean) => { toolsConfig.python = v; saveToolsConfig() }" />
|
||||
<FileSelector ref="fileSelectorRef" :selected-model="selectedModel" v-model="files" />
|
||||
</div>
|
||||
<div v-if="allowManualRole" class="flex items-center">
|
||||
|
||||
@@ -83,7 +83,7 @@ const openSettings = () => {
|
||||
</span>
|
||||
<span class="text-xs leading-snug"
|
||||
:class="enabled ? 'text-[var(--text-secondary)]' : 'text-[var(--text-dim)]'">
|
||||
Search the web automatically when needed
|
||||
Search the web and fetch URLs when needed
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
python: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:python': [value: boolean];
|
||||
}>();
|
||||
|
||||
const anyEnabled = computed(() => props.python);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dropdown dropdownClass="text-sm" placement="top">
|
||||
<template #default="{ toggle, setRef }">
|
||||
<button :ref="setRef" @click="toggle"
|
||||
class="flex items-center justify-center h-8.5 w-8.5 @hover:bg-[var(--color-hover)] rounded-lg transition-colors duration-200 ease-[cubic-bezier(0.5,_1,_0.89,_1)]">
|
||||
<span class="pointer-events-none i-mynaui-archive text-5 transition-colors duration-200"
|
||||
:class="anyEnabled ? 'text-[var(--color-accent)]' : 'text-[var(--text-secondary)]'"></span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<template #dropdown>
|
||||
<div class="flex flex-col gap-1 p-1 min-w-48">
|
||||
<label
|
||||
class="flex items-start gap-3 rounded-xl px-3 py-2.5 text-left cursor-pointer transition-colors duration-150 @hover:bg-[var(--color-hover)]"
|
||||
:class="python ? 'bg-[var(--color-active)]' : ''">
|
||||
<input type="checkbox" :checked="python"
|
||||
@change="emit('update:python', ($event.target as HTMLInputElement).checked)"
|
||||
class="mt-0.5 w-4 h-4 rounded border-[var(--color-border)] bg-transparent text-[var(--color-accent)] focus:ring-[var(--color-accent)] focus:ring-offset-0 cursor-pointer shrink-0" />
|
||||
<div class="flex flex-col gap-0.5">
|
||||
<span class="text-sm font-medium"
|
||||
:class="python ? 'text-[var(--text-primary)]' : 'text-[var(--text-secondary)]'">
|
||||
Python
|
||||
</span>
|
||||
<span class="text-xs leading-snug"
|
||||
:class="python ? 'text-[var(--text-secondary)]' : 'text-[var(--text-dim)]'">
|
||||
Run code in a sandbox
|
||||
</span>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</template>
|
||||
Reference in New Issue
Block a user