The organisation's standing instructions are stored per organisation and join the system prompt of chat turns and workflow agent steps. The Org configuration group is served: schedules, alert webhook, playbooks, models, connections and credential bindings open the page that already owns the concept.
77 lines
2.4 KiB
Vue
77 lines
2.4 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onMounted, ref } from "vue";
|
|
import { Check } from "@lucide/vue";
|
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Section } from "@/components/ui/section";
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
import PageHeader from "@/base/PageHeader.vue";
|
|
import { api, describeError } from "@/lib/api";
|
|
|
|
// The server refuses more than this; it joins every agent's system prompt.
|
|
const MAX_BYTES = 8192;
|
|
|
|
const saved = ref<string | null>(null);
|
|
const text = ref("");
|
|
const error = ref("");
|
|
const busy = ref(false);
|
|
const justSaved = ref(false);
|
|
|
|
const dirty = computed(() => saved.value !== null && text.value !== saved.value);
|
|
const chars = computed(() => text.value.length);
|
|
const tooLong = computed(() => new TextEncoder().encode(text.value).length > MAX_BYTES);
|
|
|
|
async function load() {
|
|
try {
|
|
const body = await api.instructions();
|
|
saved.value = text.value = body.text;
|
|
} catch (cause) {
|
|
error.value = describeError(cause, "Could not load the instructions.");
|
|
}
|
|
}
|
|
|
|
async function save() {
|
|
busy.value = true;
|
|
error.value = "";
|
|
justSaved.value = false;
|
|
try {
|
|
const body = await api.saveInstructions(text.value);
|
|
saved.value = text.value = body.text;
|
|
justSaved.value = true;
|
|
} catch (cause) {
|
|
error.value = describeError(cause, "Could not save the instructions.");
|
|
} finally {
|
|
busy.value = false;
|
|
}
|
|
}
|
|
|
|
onMounted(load);
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<PageHeader title="Instructions" />
|
|
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{ error }}</AlertDescription></Alert>
|
|
<form v-if="saved !== null" @submit.prevent="save">
|
|
<Section>
|
|
<Textarea
|
|
id="instructions-text"
|
|
v-model="text"
|
|
:rows="18"
|
|
class="mt-1 font-mono text-label"
|
|
aria-label="Instructions"
|
|
:aria-invalid="tooLong"
|
|
@input="justSaved = false"
|
|
/>
|
|
<p class="mt-1.5 text-caption text-fg-subtle">
|
|
{{ chars.toLocaleString() }} chars · ~{{ Math.round(chars / 4).toLocaleString() }} tokens
|
|
</p>
|
|
</Section>
|
|
<div class="mt-3 flex items-center justify-end gap-2">
|
|
<Check v-if="justSaved" role="status" aria-label="Saved" class="size-4 text-fg-muted" />
|
|
<Button type="submit" :disabled="busy || !dirty || tooLong">Save</Button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</template>
|