refactor(ui): fold one-consumer workflow files into their consumers; move shared ones out (#1958)
This commit is contained in:
21 files changed
+187
-246
No files matched your search
@@ -20,7 +20,7 @@ import {
|
|||||||
} from "@/components/ui/tags-input";
|
} from "@/components/ui/tags-input";
|
||||||
import { errors } from "@/copy/errors";
|
import { errors } from "@/copy/errors";
|
||||||
import { api, describeError } from "@/lib/api";
|
import { api, describeError } from "@/lib/api";
|
||||||
import OptionSelect from "@/workflows/OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import { useOrgStore, type Identity } from "@/stores/org";
|
import { useOrgStore, type Identity } from "@/stores/org";
|
||||||
import { Section } from "@/components/ui/section";
|
import { Section } from "@/components/ui/section";
|
||||||
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
|
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
|
||||||
|
|||||||
File renamed without changes.
@@ -13,7 +13,7 @@ import { useOrgStore } from "@/stores/org";
|
|||||||
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
||||||
import { firstLine } from "@/tasks/first-line";
|
import { firstLine } from "@/tasks/first-line";
|
||||||
import type { WorkflowDefinition } from "@/workflows/workflow-rows";
|
import type { WorkflowDefinition } from "@/workflows/workflow-rows";
|
||||||
import { declaredInputs } from "@/workflows/work-request";
|
import { declaredInputs } from "@/tasks/work-request";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a task from a prompt. A workflow that needs more than the prompt (a
|
* Start a task from a prompt. A workflow that needs more than the prompt (a
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { NumberField, NumberFieldContent, NumberFieldDecrement, NumberFieldIncre
|
|||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { TagsInput, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText } from "@/components/ui/tags-input";
|
import { TagsInput, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText } from "@/components/ui/tags-input";
|
||||||
import type { ExtensionSettingSpec } from "@/stores/extensions";
|
import type { ExtensionSettingSpec } from "@/stores/extensions";
|
||||||
import OptionSelect from "@/workflows/OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import SecretRefField from "./SecretRefField.vue";
|
import SecretRefField from "./SecretRefField.vue";
|
||||||
|
|
||||||
// One typed setting. Every type reads and writes the string the server stores.
|
// One typed setting. Every type reads and writes the string the server stores.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
declaredInputs,
|
declaredInputs,
|
||||||
inputValues,
|
inputValues,
|
||||||
missingRequiredInputs,
|
missingRequiredInputs,
|
||||||
} from "@/workflows/work-request";
|
} from "@/tasks/work-request";
|
||||||
|
|
||||||
/** Starting work enters Archie's normal admitted task queue, not a side door. */
|
/** Starting work enters Archie's normal admitted task queue, not a side door. */
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
* change here.
|
* change here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { WorkflowDefinition } from "./workflow-rows";
|
import type { WorkflowDefinition } from "../workflows/workflow-rows.ts";
|
||||||
|
|
||||||
/** One input a workflow declares, as the form renders it. */
|
/** One input a workflow declares, as the form renders it. */
|
||||||
export interface DeclaredInput {
|
export interface DeclaredInput {
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { Handle, Position } from "@vue-flow/core";
|
|
||||||
|
|
||||||
import AddStepMenu from "./AddStepMenu.vue";
|
|
||||||
|
|
||||||
defineProps<{ data: { branch?: string; lane?: string; insertAfter?: unknown; types: string[]; editable: boolean; onInsert: (type: string) => void } }>();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="relative flex w-8 justify-center">
|
|
||||||
<Handle type="target" :position="Position.Top" class="!opacity-0" />
|
|
||||||
<AddStepMenu v-if="data.editable && data.insertAfter" :types="data.types" :label="data.branch ? `Add a step to ${data.branch}` : 'Add a step at the end'" @pick="data.onInsert" />
|
|
||||||
<Handle v-if="data.lane" type="source" :position="Position.Bottom" class="!opacity-0" />
|
|
||||||
<span v-if="!(data.editable && data.insertAfter)" class="size-2 rounded-full bg-border" aria-hidden="true" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { BotIcon, BrainIcon, CircleAlertIcon, FoldVerticalIcon, ScrollTextIcon, SparklesIcon, TargetIcon } from "@lucide/vue";
|
import { ArrowUpRightIcon, BotIcon, BrainIcon, CircleAlertIcon, CircleCheckIcon, FlagIcon, FlaskConicalIcon, FoldVerticalIcon, GlobeIcon, ScrollTextIcon, SparklesIcon, SquareTerminalIcon, TargetIcon } from "@lucide/vue";
|
||||||
import { createReusableTemplate } from "@vueuse/core";
|
import { createReusableTemplate } from "@vueuse/core";
|
||||||
import { computed, onUnmounted, ref, watch } from "vue";
|
import { computed, onUnmounted, ref, watch } from "vue";
|
||||||
|
|
||||||
@@ -25,8 +25,71 @@ import { keepValue } from "@/lib/keep-unchanged";
|
|||||||
import { useLiveResource } from "@/stores/session";
|
import { useLiveResource } from "@/stores/session";
|
||||||
import { duration } from "@/tasks/timeline-event";
|
import { duration } from "@/tasks/timeline-event";
|
||||||
import type { TaskEvent } from "@/tasks/task-run";
|
import type { TaskEvent } from "@/tasks/task-run";
|
||||||
import TranscriptTool from "./TranscriptTool.vue";
|
|
||||||
import { withClip, type TranscriptEntry as Entry } from "./transcript";
|
/** One agent_transcript entry, as the State Store records it. */
|
||||||
|
interface Entry {
|
||||||
|
seq: number;
|
||||||
|
kind: string;
|
||||||
|
text?: string;
|
||||||
|
text_bytes?: number;
|
||||||
|
reasoning?: string;
|
||||||
|
reasoning_bytes?: number;
|
||||||
|
tool_calls?: { id?: string; name: string }[];
|
||||||
|
call_id?: string;
|
||||||
|
tool?: string;
|
||||||
|
args?: string;
|
||||||
|
args_bytes?: number;
|
||||||
|
output?: string;
|
||||||
|
output_bytes?: number;
|
||||||
|
error?: string;
|
||||||
|
finish_reason?: string;
|
||||||
|
usage?: { prompt_tokens?: number; completion_tokens?: number; cached_tokens?: number };
|
||||||
|
latency_ms?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The text as recorded, with a note when it was clipped. */
|
||||||
|
function withClip(text: string | undefined, bytes: number | undefined): string {
|
||||||
|
if (!bytes) return text ?? "";
|
||||||
|
return `${text ?? ""}\n… clipped, ${(bytes / 1024).toFixed(1)} KB in full`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How one tool call is drawn: a shell command as a terminal, the gate as a
|
||||||
|
* test run, a fetch as a source, finish as the run's own verdict, anything
|
||||||
|
* else as input then output.
|
||||||
|
*/
|
||||||
|
function toolView(tool: Entry) {
|
||||||
|
let args: Record<string, unknown> = {};
|
||||||
|
try {
|
||||||
|
const parsed: unknown = JSON.parse(tool.args ?? "");
|
||||||
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) args = parsed as Record<string, unknown>;
|
||||||
|
} catch {
|
||||||
|
// Unparseable arguments draw as the raw text below.
|
||||||
|
}
|
||||||
|
const failed = !!tool.error;
|
||||||
|
const kind = tool.tool === "shell" ? "terminal" : tool.tool === "check" ? "tests" : tool.tool === "web_fetch" ? "source" : tool.tool === "finish" ? "finish" : "tool";
|
||||||
|
const command = String(args.command ?? "");
|
||||||
|
const url = String(args.url ?? "");
|
||||||
|
let host = url;
|
||||||
|
try {
|
||||||
|
host = new URL(url).hostname;
|
||||||
|
} catch {
|
||||||
|
// Not a URL: the row names it as given.
|
||||||
|
}
|
||||||
|
// A plain call is named by its main value, as "read src/main.go" rather
|
||||||
|
// than its JSON: the first string argument.
|
||||||
|
const first = Object.values(args).find((v) => typeof v === "string" && v);
|
||||||
|
const argument = typeof first === "string" ? first.split("\n", 1)[0] : "";
|
||||||
|
const ran = failed ? errors.workflows.transcript.tool.failedToRun : "Ran";
|
||||||
|
const title =
|
||||||
|
kind === "terminal" ? `${ran} ${command.split("\n", 1)[0]}`
|
||||||
|
: kind === "tests" ? (failed ? errors.workflows.transcript.tool.gateFailed : "Ran the gate")
|
||||||
|
: kind === "source" ? `${failed ? errors.workflows.transcript.tool.failedToRead : "Read"} ${host}`
|
||||||
|
: kind === "finish" ? `Finished as ${String(args.status ?? "unknown")}`
|
||||||
|
: `${ran} ${tool.tool} ${argument}`;
|
||||||
|
return { args, failed, kind, command, url, title, output: withClip(tool.output, tool.output_bytes) };
|
||||||
|
}
|
||||||
|
const [DefineTool, ToolView] = createReusableTemplate<{ tool: Entry; view: ReturnType<typeof toolView> }>();
|
||||||
|
|
||||||
/** One step's agent conversations for one attempt, oldest first. */
|
/** One step's agent conversations for one attempt, oldest first. */
|
||||||
const props = defineProps<{ taskId: number | string; attempt: number; match: (event: TaskEvent) => boolean; running: boolean }>();
|
const props = defineProps<{ taskId: number | string; attempt: number; match: (event: TaskEvent) => boolean; running: boolean }>();
|
||||||
@@ -123,6 +186,55 @@ const conversations = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<DefineTool v-slot="{ tool, view }">
|
||||||
|
<TraceCollapsible :default-open="view.failed">
|
||||||
|
<TraceCollapsibleTrigger>
|
||||||
|
<TraceLine :status="view.failed ? 'error' : undefined">
|
||||||
|
<TraceIcon>
|
||||||
|
<CircleAlertIcon v-if="view.failed" />
|
||||||
|
<SquareTerminalIcon v-else-if="view.kind === 'terminal'" />
|
||||||
|
<FlaskConicalIcon v-else-if="view.kind === 'tests'" />
|
||||||
|
<GlobeIcon v-else-if="view.kind === 'source'" />
|
||||||
|
<FlagIcon v-else-if="view.kind === 'finish'" />
|
||||||
|
<CircleCheckIcon v-else />
|
||||||
|
</TraceIcon>
|
||||||
|
<TraceTitle :class="view.kind === 'terminal' && 'font-mono'">{{ view.title }}</TraceTitle>
|
||||||
|
<TraceDescription v-if="tool.latency_ms">{{ duration(tool.latency_ms) }}</TraceDescription>
|
||||||
|
</TraceLine>
|
||||||
|
</TraceCollapsibleTrigger>
|
||||||
|
<TraceCollapsibleContent class="flex flex-col gap-2">
|
||||||
|
<template v-if="view.kind === 'terminal'">
|
||||||
|
<CodeBlock size="sm" :variant="view.failed ? 'destructive' : 'default'">
|
||||||
|
<CodeBlockContent wrap class="max-h-64 font-mono">$ {{ view.command }}
|
||||||
|
{{ view.output }}{{ tool.error ? `\n${tool.error}` : '' }}</CodeBlockContent>
|
||||||
|
</CodeBlock>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="view.kind === 'finish'">
|
||||||
|
<p class="whitespace-pre-wrap">{{ String(view.args.summary ?? '') }}</p>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<Trace v-if="view.kind === 'source' && view.url">
|
||||||
|
<a :href="view.url" target="_blank" rel="noreferrer">
|
||||||
|
<TraceLine>
|
||||||
|
<TraceIcon><GlobeIcon /></TraceIcon>
|
||||||
|
<TraceTitle>{{ view.url }}<span class="sr-only"> (opens in a new tab)</span></TraceTitle>
|
||||||
|
<TraceIcon><ArrowUpRightIcon /></TraceIcon>
|
||||||
|
</TraceLine>
|
||||||
|
</a>
|
||||||
|
</Trace>
|
||||||
|
<CodeBlock v-if="view.kind === 'tool'" size="sm">
|
||||||
|
<CodeBlockContent wrap class="max-h-48">{{ withClip(tool.args, tool.args_bytes) }}</CodeBlockContent>
|
||||||
|
</CodeBlock>
|
||||||
|
<CodeBlock v-if="tool.error" size="sm" variant="destructive">
|
||||||
|
<CodeBlockContent wrap class="max-h-64">{{ tool.error }}</CodeBlockContent>
|
||||||
|
</CodeBlock>
|
||||||
|
<CodeBlock v-if="tool.output || !tool.error" size="sm">
|
||||||
|
<CodeBlockContent wrap class="max-h-64">{{ view.output }}</CodeBlockContent>
|
||||||
|
</CodeBlock>
|
||||||
|
</template>
|
||||||
|
</TraceCollapsibleContent>
|
||||||
|
</TraceCollapsible>
|
||||||
|
</DefineTool>
|
||||||
<DefineConversation v-slot="{ conversation: c }">
|
<DefineConversation v-slot="{ conversation: c }">
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<template v-for="row in c.rows" :key="`${row.kind}-${row.kind === 'step' ? row.number : row.entry.seq}`">
|
<template v-for="row in c.rows" :key="`${row.kind}-${row.kind === 'step' ? row.number : row.entry.seq}`">
|
||||||
@@ -173,7 +285,7 @@ const conversations = computed(() => {
|
|||||||
<TraceTitle>{{ row.step.model.error ? errors.workflows.transcript.stepFailed(row.number, row.step.model.error) : `Step ${row.number}` }}</TraceTitle>
|
<TraceTitle>{{ row.step.model.error ? errors.workflows.transcript.stepFailed(row.number, row.step.model.error) : `Step ${row.number}` }}</TraceTitle>
|
||||||
<TraceDescription v-if="usage(row.step.model)">{{ usage(row.step.model) }}</TraceDescription>
|
<TraceDescription v-if="usage(row.step.model)">{{ usage(row.step.model) }}</TraceDescription>
|
||||||
</TraceLine>
|
</TraceLine>
|
||||||
<TranscriptTool v-for="tool in row.step.tools" :key="tool.seq" :tool="tool" />
|
<ToolView v-for="tool in row.step.tools" :key="tool.seq" :tool="tool" :view="toolView(tool)" />
|
||||||
</Trace>
|
</Trace>
|
||||||
</MessageContent>
|
</MessageContent>
|
||||||
</Message>
|
</Message>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
type InputRow,
|
type InputRow,
|
||||||
type InputSpec,
|
type InputSpec,
|
||||||
} from "./bind-event";
|
} from "./bind-event";
|
||||||
import OptionSelect from "./OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import { workflowField } from "./workflow-edit";
|
import { workflowField } from "./workflow-edit";
|
||||||
|
|
||||||
const props = defineProps<{ yaml: string; binding: Binding | null }>();
|
const props = defineProps<{ yaml: string; binding: Binding | null }>();
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { GitBranch, Split } from "@lucide/vue";
|
|
||||||
|
|
||||||
import type { StepNodeData } from "./workflow-graph";
|
|
||||||
|
|
||||||
defineProps<{ data: StepNodeData }>();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="pointer-events-none size-full rounded-xl border border-dashed border-border bg-muted/30">
|
|
||||||
<div class="flex items-center gap-1 px-2.5 pt-1.5 text-caption text-fg-subtle">
|
|
||||||
<template v-if="data.lane === 'switch'">
|
|
||||||
<Split class="size-3" aria-hidden="true" />
|
|
||||||
<span v-if="data.title === 'default'">otherwise</span>
|
|
||||||
<span v-else class="font-mono">= {{ data.title }}</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<GitBranch class="size-3" aria-hidden="true" />{{ data.title }}
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -25,7 +25,7 @@ import { constantValue, statusKind, statusLabel, type Binding, type InputSource
|
|||||||
import ScheduleEditor from "@/schedules/ScheduleEditor.vue";
|
import ScheduleEditor from "@/schedules/ScheduleEditor.vue";
|
||||||
import { blankSchedule, type Schedule } from "@/schedules/schedule";
|
import { blankSchedule, type Schedule } from "@/schedules/schedule";
|
||||||
import type { InputSpec } from "./bind-event";
|
import type { InputSpec } from "./bind-event";
|
||||||
import OptionSelect from "./OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import { workflowField } from "./workflow-edit";
|
import { workflowField } from "./workflow-edit";
|
||||||
import { SCHEDULE_FIELDS, SCHEDULE_MAPPING, SCHEDULE_SOURCE, scheduleFilter, scheduleOfBinding } from "./workflow-triggers";
|
import { SCHEDULE_FIELDS, SCHEDULE_MAPPING, SCHEDULE_SOURCE, scheduleFilter, scheduleOfBinding } from "./workflow-triggers";
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Plus, Trash2 } from "@lucide/vue";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import OptionSelect from "./OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import { errors } from "../copy/errors/index.ts";
|
import { errors } from "../copy/errors/index.ts";
|
||||||
import { setWorkflowField, workflowField } from "./workflow-edit";
|
import { setWorkflowField, workflowField } from "./workflow-edit";
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import { Textarea } from "@/components/ui/textarea";
|
|||||||
import { addBranch, branchingOf, deleteBranch, renameBranch, earlierStepIDs, replaceStep, stepAt, workflowField, type StepPath, type StepRecord } from "./workflow-edit";
|
import { addBranch, branchingOf, deleteBranch, renameBranch, earlierStepIDs, replaceStep, stepAt, workflowField, type StepPath, type StepRecord } from "./workflow-edit";
|
||||||
import type { WorkflowDefinitionEntry } from "@/stores/workflows";
|
import type { WorkflowDefinitionEntry } from "@/stores/workflows";
|
||||||
import type { InputSpec } from "./bind-event";
|
import type { InputSpec } from "./bind-event";
|
||||||
import { inputValue } from "./work-request";
|
import { inputValue } from "@/tasks/work-request";
|
||||||
import OptionSelect from "./OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import WorkflowPicker from "./WorkflowPicker.vue";
|
import WorkflowPicker from "./WorkflowPicker.vue";
|
||||||
import { stepControlsProblem, settingsProblem, type SettingsSchema, type StepTypeInfo } from "./workflow-yaml";
|
import { stepControlsProblem, settingsProblem, type SettingsSchema, type StepTypeInfo } from "./workflow-yaml";
|
||||||
|
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { errors } from "@/copy/errors";
|
|
||||||
import { ArrowUpRightIcon, CircleAlertIcon, CircleCheckIcon, FlagIcon, FlaskConicalIcon, GlobeIcon, SquareTerminalIcon } from "@lucide/vue";
|
|
||||||
import { computed } from "vue";
|
|
||||||
|
|
||||||
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
|
|
||||||
import {
|
|
||||||
Trace,
|
|
||||||
TraceCollapsible,
|
|
||||||
TraceCollapsibleContent,
|
|
||||||
TraceCollapsibleTrigger,
|
|
||||||
TraceDescription,
|
|
||||||
TraceIcon,
|
|
||||||
TraceLine,
|
|
||||||
TraceTitle,
|
|
||||||
} from "@/components/ui/trace";
|
|
||||||
import { duration } from "@/tasks/timeline-event";
|
|
||||||
import { withClip, type TranscriptEntry } from "./transcript";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* One tool call, drawn as the Trace pattern its tool calls for: a shell
|
|
||||||
* command as a terminal, the gate as a test run, a fetch as a source, finish
|
|
||||||
* as the run's own verdict, anything else as input then output.
|
|
||||||
*/
|
|
||||||
const props = defineProps<{ tool: TranscriptEntry }>();
|
|
||||||
|
|
||||||
const args = computed<Record<string, unknown>>(() => {
|
|
||||||
try {
|
|
||||||
const parsed: unknown = JSON.parse(props.tool.args ?? "");
|
|
||||||
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed as Record<string, unknown> : {};
|
|
||||||
} catch {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const failed = computed(() => !!props.tool.error);
|
|
||||||
const kind = computed(() => {
|
|
||||||
switch (props.tool.tool) {
|
|
||||||
case "shell": return "terminal";
|
|
||||||
case "check": return "tests";
|
|
||||||
case "web_fetch": return "source";
|
|
||||||
case "finish": return "finish";
|
|
||||||
default: return "tool";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const command = computed(() => String(args.value.command ?? ""));
|
|
||||||
const url = computed(() => String(args.value.url ?? ""));
|
|
||||||
const host = computed(() => {
|
|
||||||
try {
|
|
||||||
return new URL(url.value).hostname;
|
|
||||||
} catch {
|
|
||||||
return url.value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// The row names a plain call by its main value, as "read src/main.go" rather
|
|
||||||
// than its JSON: the first string argument.
|
|
||||||
const argument = computed(() => {
|
|
||||||
const first = Object.values(args.value).find((v) => typeof v === "string" && v);
|
|
||||||
return typeof first === "string" ? first.split("\n", 1)[0] : "";
|
|
||||||
});
|
|
||||||
const title = computed(() => {
|
|
||||||
switch (kind.value) {
|
|
||||||
case "terminal": return `${failed.value ? errors.workflows.transcript.tool.failedToRun : "Ran"} ${command.value.split("\n", 1)[0]}`;
|
|
||||||
case "tests": return failed.value ? errors.workflows.transcript.tool.gateFailed : "Ran the gate";
|
|
||||||
case "source": return `${failed.value ? errors.workflows.transcript.tool.failedToRead : "Read"} ${host.value}`;
|
|
||||||
case "finish": return `Finished as ${String(args.value.status ?? "unknown")}`;
|
|
||||||
default: return `${failed.value ? errors.workflows.transcript.tool.failedToRun : "Ran"} ${props.tool.tool} ${argument.value}`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const output = computed(() => withClip(props.tool.output, props.tool.output_bytes));
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<TraceCollapsible :default-open="failed">
|
|
||||||
<TraceCollapsibleTrigger>
|
|
||||||
<TraceLine :status="failed ? 'error' : undefined">
|
|
||||||
<TraceIcon>
|
|
||||||
<CircleAlertIcon v-if="failed" />
|
|
||||||
<SquareTerminalIcon v-else-if="kind === 'terminal'" />
|
|
||||||
<FlaskConicalIcon v-else-if="kind === 'tests'" />
|
|
||||||
<GlobeIcon v-else-if="kind === 'source'" />
|
|
||||||
<FlagIcon v-else-if="kind === 'finish'" />
|
|
||||||
<CircleCheckIcon v-else />
|
|
||||||
</TraceIcon>
|
|
||||||
<TraceTitle :class="kind === 'terminal' && 'font-mono'">{{ title }}</TraceTitle>
|
|
||||||
<TraceDescription v-if="tool.latency_ms">{{ duration(tool.latency_ms) }}</TraceDescription>
|
|
||||||
</TraceLine>
|
|
||||||
</TraceCollapsibleTrigger>
|
|
||||||
<TraceCollapsibleContent class="flex flex-col gap-2">
|
|
||||||
<template v-if="kind === 'terminal'">
|
|
||||||
<CodeBlock size="sm" :variant="failed ? 'destructive' : 'default'">
|
|
||||||
<CodeBlockContent wrap class="max-h-64 font-mono">$ {{ command }}
|
|
||||||
{{ output }}{{ tool.error ? `\n${tool.error}` : '' }}</CodeBlockContent>
|
|
||||||
</CodeBlock>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="kind === 'finish'">
|
|
||||||
<p class="whitespace-pre-wrap">{{ String(args.summary ?? '') }}</p>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<Trace v-if="kind === 'source' && url">
|
|
||||||
<a :href="url" target="_blank" rel="noreferrer">
|
|
||||||
<TraceLine>
|
|
||||||
<TraceIcon><GlobeIcon /></TraceIcon>
|
|
||||||
<TraceTitle>{{ url }}<span class="sr-only"> (opens in a new tab)</span></TraceTitle>
|
|
||||||
<TraceIcon><ArrowUpRightIcon /></TraceIcon>
|
|
||||||
</TraceLine>
|
|
||||||
</a>
|
|
||||||
</Trace>
|
|
||||||
<CodeBlock v-if="kind === 'tool'" size="sm">
|
|
||||||
<CodeBlockContent wrap class="max-h-48">{{ withClip(tool.args, tool.args_bytes) }}</CodeBlockContent>
|
|
||||||
</CodeBlock>
|
|
||||||
<CodeBlock v-if="tool.error" size="sm" variant="destructive">
|
|
||||||
<CodeBlockContent wrap class="max-h-64">{{ tool.error }}</CodeBlockContent>
|
|
||||||
</CodeBlock>
|
|
||||||
<CodeBlock v-if="tool.output || !tool.error" size="sm">
|
|
||||||
<CodeBlockContent wrap class="max-h-64">{{ output }}</CodeBlockContent>
|
|
||||||
</CodeBlock>
|
|
||||||
</template>
|
|
||||||
</TraceCollapsibleContent>
|
|
||||||
</TraceCollapsible>
|
|
||||||
</template>
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
import { computed, nextTick, ref, watch } from "vue";
|
import { computed, nextTick, ref, watch } from "vue";
|
||||||
import { VueFlow, type NodeMouseEvent, type VueFlowStore } from "@vue-flow/core";
|
import { Handle, Position, VueFlow, type NodeMouseEvent, type VueFlowStore } from "@vue-flow/core";
|
||||||
import { Background } from "@vue-flow/background";
|
import { Background } from "@vue-flow/background";
|
||||||
import { useMediaQuery, usePreferredReducedMotion, useResizeObserver, useTransition } from "@vueuse/core";
|
import { useMediaQuery, usePreferredReducedMotion, useResizeObserver, useTransition } from "@vueuse/core";
|
||||||
import { ArrowDown, ArrowUp, Copy, Maximize, Minus, Pencil, Plus, RotateCcw, Trash2 } from "@lucide/vue";
|
import { ArrowDown, ArrowUp, Copy, GitBranch, Maximize, Minus, Pencil, Plus, RotateCcw, Split, Trash2 } from "@lucide/vue";
|
||||||
import "@vue-flow/core/dist/style.css";
|
import "@vue-flow/core/dist/style.css";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -20,12 +20,11 @@ import {
|
|||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||||
import AddNode from "./AddNode.vue";
|
import AddStepMenu from "./AddStepMenu.vue";
|
||||||
import InsertEdge from "./InsertEdge.vue";
|
import InsertEdge from "./InsertEdge.vue";
|
||||||
import StepNode, { type StepCardData } from "./StepNode.vue";
|
import StepNode, { type StepCardData } from "./StepNode.vue";
|
||||||
import StepTypeItems from "./StepTypeItems.vue";
|
import StepTypeItems from "./StepTypeItems.vue";
|
||||||
import { inParallel, type StepPath } from "./workflow-edit";
|
import { inParallel, type StepPath } from "./workflow-edit";
|
||||||
import LaneNode from "./LaneNode.vue";
|
|
||||||
import { restartAt, stepTitle, withRuns, workflowGraph, type GraphNode, type StageRun, type StepNodeData } from "./workflow-graph";
|
import { restartAt, stepTitle, withRuns, workflowGraph, type GraphNode, type StageRun, type StepNodeData } from "./workflow-graph";
|
||||||
import type { WorkflowTrigger } from "./workflow-triggers";
|
import type { WorkflowTrigger } from "./workflow-triggers";
|
||||||
|
|
||||||
@@ -306,11 +305,29 @@ const beforePath = computed(() => menuPath.value ? [...menuPath.value.slice(0, -
|
|||||||
<template #node-step="nodeProps">
|
<template #node-step="nodeProps">
|
||||||
<StepNode v-bind="nodeProps"><slot name="body" :data="nodeProps.data" /></StepNode>
|
<StepNode v-bind="nodeProps"><slot name="body" :data="nodeProps.data" /></StepNode>
|
||||||
</template>
|
</template>
|
||||||
<template #node-lane="nodeProps">
|
<!-- A branch's dashed lane, labelled with its name or case. -->
|
||||||
<LaneNode v-bind="nodeProps" />
|
<template #node-lane="{ data }">
|
||||||
|
<div class="pointer-events-none size-full rounded-xl border border-dashed border-border bg-muted/30">
|
||||||
|
<div class="flex items-center gap-1 px-2.5 pt-1.5 text-caption text-fg-subtle">
|
||||||
|
<template v-if="data.lane === 'switch'">
|
||||||
|
<Split class="size-3" aria-hidden="true" />
|
||||||
|
<span v-if="data.title === 'default'">otherwise</span>
|
||||||
|
<span v-else class="font-mono">= {{ data.title }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<GitBranch class="size-3" aria-hidden="true" />{{ data.title }}
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #node-add="nodeProps">
|
<!-- The end of a lane or of the workflow: where a step is appended. -->
|
||||||
<AddNode v-bind="nodeProps" />
|
<template #node-add="{ data }">
|
||||||
|
<div class="relative flex w-8 justify-center">
|
||||||
|
<Handle type="target" :position="Position.Top" class="!opacity-0" />
|
||||||
|
<AddStepMenu v-if="data.editable && data.insertAfter" :types="data.types" :label="data.branch ? `Add a step to ${data.branch}` : 'Add a step at the end'" @pick="data.onInsert" />
|
||||||
|
<Handle v-if="data.lane" type="source" :position="Position.Bottom" class="!opacity-0" />
|
||||||
|
<span v-if="!(data.editable && data.insertAfter)" class="size-2 rounded-full bg-border" aria-hidden="true" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #edge-insert="edgeProps">
|
<template #edge-insert="edgeProps">
|
||||||
<InsertEdge v-bind="edgeProps" />
|
<InsertEdge v-bind="edgeProps" />
|
||||||
|
|||||||
@@ -29,13 +29,12 @@ import { statusLabel } from "@/lib/task-meta";
|
|||||||
import StepEditor from "./StepEditor.vue";
|
import StepEditor from "./StepEditor.vue";
|
||||||
import WorkflowSettings from "./WorkflowSettings.vue";
|
import WorkflowSettings from "./WorkflowSettings.vue";
|
||||||
import TriggerSettings from "./TriggerSettings.vue";
|
import TriggerSettings from "./TriggerSettings.vue";
|
||||||
import OptionSelect from "./OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import RunWorkflowButton from "./RunWorkflowButton.vue";
|
import RunWorkflowButton from "./RunWorkflowButton.vue";
|
||||||
import TaskRowActions from "@/tasks/TaskRowActions.vue";
|
import TaskRowActions from "@/tasks/TaskRowActions.vue";
|
||||||
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
||||||
import WorkflowHistory from "./WorkflowHistory.vue";
|
import WorkflowHistory from "./WorkflowHistory.vue";
|
||||||
import { useWorkflowHistory } from "./workflow-history";
|
import { revisionOfRun, useWorkflowHistory, type WorkflowRevision } from "./workflow-revisions";
|
||||||
import { revisionOfRun, type WorkflowRevision } from "./workflow-revisions";
|
|
||||||
import { deleteStep, duplicateStep, insertStep, moveStep, normalizeStepIDs, replaceStep, revertWorkflowChange, SEEDED_AGENT_ID, stepAt, stepIDs, workflowChanges, workflowField, type StepPath } from "./workflow-edit";
|
import { deleteStep, duplicateStep, insertStep, moveStep, normalizeStepIDs, replaceStep, revertWorkflowChange, SEEDED_AGENT_ID, stepAt, stepIDs, workflowChanges, workflowField, type StepPath } from "./workflow-edit";
|
||||||
import ChangeList from "@/components/ChangeList.vue";
|
import ChangeList from "@/components/ChangeList.vue";
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { errors } from "@/copy/errors";
|
|||||||
import type { Identity } from "@/stores/org";
|
import type { Identity } from "@/stores/org";
|
||||||
import { useOrgStore } from "@/stores/org";
|
import { useOrgStore } from "@/stores/org";
|
||||||
import { useSettingsStore } from "@/stores/settings";
|
import { useSettingsStore } from "@/stores/settings";
|
||||||
import OptionSelect from "./OptionSelect.vue";
|
import OptionSelect from "@/components/OptionSelect.vue";
|
||||||
import SpecList from "./SpecList.vue";
|
import SpecList from "./SpecList.vue";
|
||||||
import { SEEDED_AGENT_ID, setWorkflowField, workflowField } from "./workflow-edit";
|
import { SEEDED_AGENT_ID, setWorkflowField, workflowField } from "./workflow-edit";
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/** One agent_transcript entry, as the State Store records it. */
|
|
||||||
export interface TranscriptEntry {
|
|
||||||
seq: number;
|
|
||||||
kind: string;
|
|
||||||
text?: string;
|
|
||||||
text_bytes?: number;
|
|
||||||
reasoning?: string;
|
|
||||||
reasoning_bytes?: number;
|
|
||||||
tool_calls?: { id?: string; name: string }[];
|
|
||||||
call_id?: string;
|
|
||||||
tool?: string;
|
|
||||||
args?: string;
|
|
||||||
args_bytes?: number;
|
|
||||||
output?: string;
|
|
||||||
output_bytes?: number;
|
|
||||||
error?: string;
|
|
||||||
finish_reason?: string;
|
|
||||||
usage?: { prompt_tokens?: number; completion_tokens?: number; cached_tokens?: number };
|
|
||||||
latency_ms?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The text as recorded, with a note when it was clipped. */
|
|
||||||
export function withClip(text: string | undefined, bytes: number | undefined): string {
|
|
||||||
if (!bytes) return text ?? "";
|
|
||||||
return `${text ?? ""}\n… clipped, ${(bytes / 1024).toFixed(1)} KB in full`;
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import { computed, ref, watch, type Ref } from "vue";
|
|
||||||
|
|
||||||
import { useSettingsStore, type ResourceRevision } from "@/stores/settings";
|
|
||||||
import { workflowRevisions } from "./workflow-revisions";
|
|
||||||
import { describeError } from "@/lib/api";
|
|
||||||
import { errors } from "@/copy/errors";
|
|
||||||
|
|
||||||
const KIND = "workflow-definitions";
|
|
||||||
|
|
||||||
/** The history of workflow `id`, kept current as the definitions change. */
|
|
||||||
export function useWorkflowHistory(id: Ref<string>) {
|
|
||||||
const store = useSettingsStore();
|
|
||||||
const all = ref<ResourceRevision[]>([]);
|
|
||||||
const error = ref("");
|
|
||||||
const loaded = ref(false);
|
|
||||||
|
|
||||||
let generation = 0;
|
|
||||||
async function reload(): Promise<void> {
|
|
||||||
const current = ++generation;
|
|
||||||
try {
|
|
||||||
all.value = await store.history(KIND);
|
|
||||||
if (current !== generation) return;
|
|
||||||
error.value = "";
|
|
||||||
loaded.value = true;
|
|
||||||
} catch (err) {
|
|
||||||
if (current !== generation) return;
|
|
||||||
error.value = describeError(err, errors.workflows.history.notLoaded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
watch(() => store.stateFor(KIND).resource?.version, () => void reload(), { immediate: true });
|
|
||||||
|
|
||||||
const revisions = computed(() => workflowRevisions(id.value, all.value));
|
|
||||||
return { revisions, error, loaded, reload };
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
|
import { computed, ref, watch, type Ref } from "vue";
|
||||||
import { parseDocument } from "yaml";
|
import { parseDocument } from "yaml";
|
||||||
|
|
||||||
import type { ResourceRevision } from "../stores/settings.ts";
|
import { useSettingsStore, type ResourceRevision } from "../stores/settings.ts";
|
||||||
|
import { describeError } from "../lib/api.ts";
|
||||||
|
import { errors } from "../copy/errors/index.ts";
|
||||||
import { workflowGraph } from "./workflow-graph.ts";
|
import { workflowGraph } from "./workflow-graph.ts";
|
||||||
|
|
||||||
/** One revision of the definitions that changed a single workflow. */
|
/** One revision of the definitions that changed a single workflow. */
|
||||||
@@ -113,3 +116,31 @@ export function stepMarks(source: string, other: string, missing: "added" | "rem
|
|||||||
}
|
}
|
||||||
return marks;
|
return marks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const KIND = "workflow-definitions";
|
||||||
|
|
||||||
|
/** The history of workflow `id`, kept current as the definitions change. */
|
||||||
|
export function useWorkflowHistory(id: Ref<string>) {
|
||||||
|
const store = useSettingsStore();
|
||||||
|
const all = ref<ResourceRevision[]>([]);
|
||||||
|
const error = ref("");
|
||||||
|
const loaded = ref(false);
|
||||||
|
|
||||||
|
let generation = 0;
|
||||||
|
async function reload(): Promise<void> {
|
||||||
|
const current = ++generation;
|
||||||
|
try {
|
||||||
|
all.value = await store.history(KIND);
|
||||||
|
if (current !== generation) return;
|
||||||
|
error.value = "";
|
||||||
|
loaded.value = true;
|
||||||
|
} catch (err) {
|
||||||
|
if (current !== generation) return;
|
||||||
|
error.value = describeError(err, errors.workflows.history.notLoaded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
watch(() => store.stateFor(KIND).resource?.version, () => void reload(), { immediate: true });
|
||||||
|
|
||||||
|
const revisions = computed(() => workflowRevisions(id.value, all.value));
|
||||||
|
return { revisions, error, loaded, reload };
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
declaredInputs,
|
declaredInputs,
|
||||||
inputValues,
|
inputValues,
|
||||||
missingRequiredInputs,
|
missingRequiredInputs,
|
||||||
} from "../src/workflows/work-request.ts";
|
} from "../src/tasks/work-request.ts";
|
||||||
|
|
||||||
// The shape GET /api/workflows reports for a definition, as far as the
|
// The shape GET /api/workflows reports for a definition, as far as the
|
||||||
// work-request form reads it.
|
// work-request form reads it.
|
||||||
|
|||||||
Reference in new issue
Block a user