The run selector is the only control that gives up width, and beside the workflow list it had none left: Open and the run's version move into the one menu at every width, so the picked run stays readable from 390 to 1440. Step editor and binding fields take the next rung (h-8) so they match the selects and switches they sit beside.
145 lines
6.6 KiB
Vue
145 lines
6.6 KiB
Vue
<script setup lang="ts">
|
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
import { computed, ref, onMounted } from "vue";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import { Switch } from "@/components/ui/switch";
|
|
import { api } from "@/lib/api";
|
|
import type { Identity } from "@/stores/org";
|
|
import { useOrgStore } from "@/stores/org";
|
|
import { useSettingsStore } from "@/stores/settings";
|
|
import OptionSelect from "./OptionSelect.vue";
|
|
import SpecList from "./SpecList.vue";
|
|
import { setWorkflowField, workflowField } from "./workflow-edit";
|
|
|
|
const props = defineProps<{ yaml: string }>();
|
|
const emit = defineEmits<{ "update:yaml": [string] }>();
|
|
|
|
const text = (key: string) => {
|
|
const value = workflowField(props.yaml, key);
|
|
return typeof value === "string" ? value : "";
|
|
};
|
|
function set(key: string, value: unknown): void {
|
|
emit("update:yaml", setWorkflowField(props.yaml, key, value));
|
|
}
|
|
|
|
// The identity a run acts as must be an agent, never a person; a workflow
|
|
// naming none is refused when it runs, so it defaults to the agent identity
|
|
// every install seeds (identity.AgentID).
|
|
const SEEDED_AGENT_ID = "6f129e29-0e26-5246-99bd-74cb4496203b";
|
|
const identities = useOrgStore();
|
|
const agents = ref<Identity[]>([]);
|
|
const identitiesLoading = ref(true);
|
|
const identitiesError = ref("");
|
|
async function loadAgents(): Promise<void> {
|
|
identitiesLoading.value = true;
|
|
identitiesError.value = "";
|
|
agents.value = [];
|
|
try {
|
|
await identities.loadOrg();
|
|
const response = await api.orgAgents<{ agents: Identity[] }>(identities.homeOrg);
|
|
agents.value = response.agents.filter((agent) => agent.lifecycle === "active");
|
|
if (!text("identity") && agents.value.some((agent) => agent.id === SEEDED_AGENT_ID)) set("identity", SEEDED_AGENT_ID);
|
|
} catch (cause) {
|
|
identitiesError.value = String((cause as Error).message || cause);
|
|
} finally { identitiesLoading.value = false; }
|
|
}
|
|
onMounted(loadAgents);
|
|
const identityOptions = computed(() => {
|
|
const current = text("identity");
|
|
const options = agents.value.map((agent) => ({ value: agent.id, label: agent.display_name }));
|
|
return current && !agents.value.some((agent) => agent.id === current) ? [{ value: current, label: `${current} (unknown)`, disabled: true }, ...options] : options;
|
|
});
|
|
|
|
const settings = useSettingsStore();
|
|
const profileOptions = computed(() => {
|
|
const names = Object.keys((settings.stateFor("agent-profiles").resource?.value ?? {}) as Record<string, unknown>).sort();
|
|
const current = text("profile");
|
|
if (current && !names.includes(current)) names.unshift(current);
|
|
return [{ value: "", label: "Default" }, ...names.map((name) => ({ value: name, label: name }))];
|
|
});
|
|
|
|
const MODES = [
|
|
{ value: "required", label: "Repository", hint: "Clones the task's repository" },
|
|
{ value: "optional", label: "If given", hint: "Clones one when the run names it" },
|
|
{ value: "none", label: "None", hint: "Scratch workspace, no clone" },
|
|
];
|
|
const repository = computed(() => text("repository") || "required");
|
|
|
|
// needs is the workflow's declared harness requirements: captures (a stage
|
|
// returns structured output through capture tools) and the largest gate-retry
|
|
// budget any stage declares.
|
|
const needs = computed<{ captures?: boolean; gate_retries?: number }>(() => {
|
|
const value = workflowField(props.yaml, "needs");
|
|
return value && typeof value === "object" ? (value as { captures?: boolean; gate_retries?: number }) : {};
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="space-y-4 px-3 py-3">
|
|
<div class="divide-y divide-border rounded-md border border-border">
|
|
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
|
<span class="flex-1 text-[13px]">Runs as</span>
|
|
<OptionSelect
|
|
:model-value="text('identity')"
|
|
:options="identityOptions"
|
|
aria-label="Execution identity"
|
|
:placeholder="identitiesLoading ? 'Loading agents…' : 'Choose an agent'"
|
|
:disabled="identitiesLoading || !!identitiesError"
|
|
class="w-44"
|
|
@update:model-value="set('identity', $event)"
|
|
/>
|
|
</label>
|
|
<p v-if="identitiesError" role="alert" class="px-3 py-2 text-xs text-danger">{{ identitiesError }} <Button variant="link" size="xs" @click="loadAgents">Retry</Button></p>
|
|
<p v-else-if="!identitiesLoading && !agents.length" class="px-3 py-2 text-xs text-fg-subtle">No active agents in your organisation.</p>
|
|
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
|
<span class="flex-1 text-[13px]">Container profile</span>
|
|
<OptionSelect :model-value="text('profile')" :options="profileOptions" aria-label="Container profile" class="w-44" @update:model-value="set('profile', $event || undefined)" />
|
|
</label>
|
|
<div class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
|
<span class="flex-1 text-[13px]">Works on</span>
|
|
<ToggleGroup
|
|
type="single"
|
|
variant="outline"
|
|
size="sm"
|
|
:model-value="repository"
|
|
aria-label="Works on"
|
|
@update:model-value="(value) => { if (value) set('repository', value === 'required' ? undefined : String(value)); }"
|
|
>
|
|
<ToggleGroupItem v-for="mode in MODES" :key="mode.value" :value="mode.value" :title="mode.hint">{{ mode.label }}</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
</div>
|
|
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
|
<span class="flex-1 text-[13px]" title="Stages return structured output through capture tools">Captures</span>
|
|
<Switch :model-value="needs.captures === true" @update:model-value="set('needs', { ...needs, captures: $event || undefined })" />
|
|
</label>
|
|
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
|
<span class="flex-1 text-[13px]">Gate retries</span>
|
|
<Input
|
|
type="number"
|
|
min="0"
|
|
placeholder="0"
|
|
class="h-8 w-20 text-right text-[13px]"
|
|
:model-value="needs.gate_retries ?? ''"
|
|
@update:model-value="(value) => set('needs', { ...needs, gate_retries: String(value) === '' ? undefined : Number(String(value)) })"
|
|
/>
|
|
</label>
|
|
</div>
|
|
|
|
<section class="space-y-1.5">
|
|
<label for="workflow-instructions" class="text-xs font-medium text-fg-muted">Instructions</label>
|
|
<Textarea
|
|
id="workflow-instructions"
|
|
:model-value="text('instructions')"
|
|
:rows="4"
|
|
class="font-mono text-[13px]"
|
|
@change="set('instructions', ($event.target as HTMLTextAreaElement).value)"
|
|
/>
|
|
</section>
|
|
|
|
<SpecList :yaml="yaml" field="outputs" @update:yaml="emit('update:yaml', $event)" />
|
|
</div>
|
|
</template>
|