feat(eda): workflow inputs, optional repository and agent profiles

Workflow definitions declare inputs, repository (none, optional or
required; default required) and profile. A binding assigns each input
from a mapped parameter or a constant and may take its repository from a
parameter, which must name a configured repo; both are checked when the
binding is saved and again at dispatch. Inputs travel as structured task
data (tasks.inputs, the task brief, and a JSON block in the agent's
mission), never as body text.

A task with no repository runs in a per-task scratch workspace with no
clone and no publication grant. The agent.run step runs one mission
without a repository and finishes the task in the new completed status.

Agent profiles live under [containers.profiles.<name>]: an image and an
allowlist over the tools archie adds (MCP, scripts, plugins).
[containers].image is the default profile; an unconfigured profile parks
the task. The workflow is now pinned before the container starts so the
profile can choose its image.

Also stop two archied tests writing embedded NATS state into the package
directory, refuse an empty state_dir for embedded NATS, and drop the NATS
store files an earlier lane commit tracked.
This commit is contained in:
sam committed 2026-09-24 20:29:33 +10:00
1 parent 7181e7917d
commit c431834e2b
118 files changed
+2163 -327

No files matched your search

+77 -3
View File
@@ -13,6 +13,8 @@ import {
draftFromBinding,
emptyDraft,
mappingsForEventType,
paramsForType,
takesRepository,
type Binding,
type BindingDraft,
type MappingOption,
@@ -21,8 +23,9 @@ import {
/**
* The binding editor: name, the event type it applies to, one of that type's
* mappings, an optional filter over the mapping's parameters, the workflow and
* an optional repo pin. Signing is the source's.
* mappings, an optional filter over the mapping's parameters, the workflow, its
* inputs, and the repository when the workflow takes one. Signing is the
* source's.
*/
const props = defineProps<{
@@ -60,6 +63,36 @@ watch(
},
);
const workflow = computed(() => props.workflows.find((w) => w.id === draft.value.workflow));
const declaredInputs = computed(() => Object.entries(workflow.value?.inputs ?? {}).sort(([a], [b]) => a.localeCompare(b)));
const mappingFields = computed(() => props.mappings.find((m) => m.id === draft.value.mappingId)?.fields ?? []);
const stringParams = computed(() => paramsForType(mappingFields.value, "string"));
// The constant sentinel stands for "no parameter": Select items cannot carry
// an empty value.
const CONSTANT = "__constant__";
function inputDraft(name: string) {
draft.value.inputs[name] ??= { param: "", value: "" };
return draft.value.inputs[name];
}
function inputSource(name: string): string {
return inputDraft(name).param || CONSTANT;
}
function setInputSource(name: string, source: unknown): void {
inputDraft(name).param = source === CONSTANT ? "" : String(source);
}
const NO_PARAM = "__none__";
const repoSource = computed({
get: () => draft.value.repoParam || NO_PARAM,
set: (v: string) => {
draft.value.repoParam = v === NO_PARAM ? "" : v;
},
});
const title = computed(() => (props.binding ? "Edit binding" : "New binding"));
</script>
@@ -136,7 +169,48 @@ const title = computed(() => (props.binding ? "Edit binding" : "New binding"));
</Select>
</Field>
<Field>
<Field v-for="[name, spec] in declaredInputs" :key="name">
<FieldLabel :for="`binding-input-${name}`">
Input <span class="font-mono">{{ name }}</span>
<span class="text-fg-muted">({{ spec.type }}{{ spec.required ? ", required" : "" }})</span>
</FieldLabel>
<div class="grid grid-cols-2 items-start gap-3">
<Select :model-value="inputSource(name)" @update:model-value="setInputSource(name, $event)">
<SelectTrigger :id="`binding-input-${name}`" class="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem :value="CONSTANT">Constant</SelectItem>
<SelectItem v-for="field in paramsForType(mappingFields, spec.type)" :key="field.name" :value="field.name">
{{ field.name }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<Input v-if="!inputDraft(name).param" v-model="inputDraft(name).value" class="font-mono text-xs" placeholder="value" />
</div>
</Field>
<Field v-if="takesRepository(workflow)">
<FieldLabel for="binding-repo-param">Repository from</FieldLabel>
<Select v-model="repoSource">
<SelectTrigger id="binding-repo-param" class="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem :value="NO_PARAM">A pinned or configured repo</SelectItem>
<SelectItem v-for="field in stringParams" :key="field.name" :value="field.name">
Parameter {{ field.name }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<FieldDescription>A parameter must hold owner/name and name a configured repo.</FieldDescription>
</Field>
<Field v-if="takesRepository(workflow) && !draft.repoParam">
<div class="grid grid-cols-2 items-start gap-3">
<Field>
<FieldLabel for="binding-owner">Pinned owner</FieldLabel>
+89 -3
View File
@@ -22,16 +22,33 @@ export interface Binding {
/** A pin is a complete owner/repo pair or not a pin at all. */
owner?: string;
repo?: string;
/** The mapped parameter holding "owner/name", when the repository comes from the event. */
repo_param?: string;
/** Each workflow input from a mapped parameter or a constant. */
inputs?: Record<string, InputSource>;
status?: string;
version?: number;
unsigned?: boolean;
}
/** One workflow input's assignment on the wire. */
export interface InputSource {
param?: string;
value?: unknown;
}
/** A mapped parameter: its name and field type. */
export interface MappingField {
name: string;
type: string;
}
/** The fields of GET /api/mappings this page needs. */
export interface MappingOption {
id: string;
name: string;
event_type_id?: string;
fields?: MappingField[];
}
/** The mappings that belong to one event type, which are the ones a binding
@@ -46,6 +63,49 @@ export interface WorkflowOption {
id: string;
name: string;
enabled?: boolean;
/** The inputs the workflow declares, by name. */
inputs?: Record<string, { type: string; required?: boolean }>;
/** none, optional or required; a workflow that declares none needs a repository. */
repository?: string;
}
/** Whether a binding for this workflow may name a repository. */
export function takesRepository(workflow?: WorkflowOption): boolean {
return (workflow?.repository ?? "required") !== "none";
}
/** A mapping's parameters a workflow input of this type can read. */
export function paramsForType(fields: MappingField[], type: string): MappingField[] {
return fields.filter((f) => type === "any" || f.type === "any" || f.type === type);
}
/** One input's assignment as the editor holds it: a parameter name, or the
* constant's text. */
export interface InputDraft {
param: string;
value: string;
}
/**
* The constant an input's text stands for, in the input's declared type. Text
* that does not read as that type is returned as-is, so the server's type check
* names the mismatch rather than the editor guessing.
*/
export function constantValue(text: string, type: string): unknown {
switch (type) {
case "string":
return text;
case "number":
return text.trim() !== "" && !Number.isNaN(Number(text)) ? Number(text) : text;
case "bool":
return text === "true" ? true : text === "false" ? false : text;
default:
try {
return JSON.parse(text);
} catch {
return text;
}
}
}
/** The Badge variants a binding status maps onto. */
@@ -85,6 +145,8 @@ export interface BindingDraft {
workflow: string;
owner: string;
repo: string;
repoParam: string;
inputs: Record<string, InputDraft>;
}
export function emptyDraft(): BindingDraft {
@@ -97,6 +159,8 @@ export function emptyDraft(): BindingDraft {
workflow: "",
owner: "",
repo: "",
repoParam: "",
inputs: {},
};
}
@@ -111,26 +175,48 @@ export function draftFromBinding(binding: Binding, mappings: MappingOption[]): B
workflow: binding.workflow || "",
owner: binding.owner || "",
repo: binding.repo || "",
repoParam: binding.repo_param || "",
inputs: Object.fromEntries(
Object.entries(binding.inputs ?? {}).map(([name, src]) => [
name,
{ param: src.param ?? "", value: src.param ? "" : typeof src.value === "string" ? src.value : JSON.stringify(src.value) },
]),
),
};
}
/** The body POST /api/bindings and PATCH /api/bindings/{id} both accept. */
export function bindingPayload(draft: BindingDraft, eventTypes: EventType[]): Record<string, unknown> {
export function bindingPayload(
draft: BindingDraft,
eventTypes: EventType[],
workflow?: WorkflowOption,
): Record<string, unknown> {
const eventType = eventTypes.find((t) => t.id === draft.eventTypeId);
const declared = workflow?.inputs ?? {};
const inputs: Record<string, InputSource> = {};
for (const [name, spec] of Object.entries(declared)) {
const src = draft.inputs[name];
if (src?.param) inputs[name] = { param: src.param };
else if (src && src.value !== "") inputs[name] = { value: constantValue(src.value, spec.type) };
}
const repository = takesRepository(workflow);
return {
name: draft.name,
matcher: { source: eventType?.source || "" },
mapping_id: draft.mappingId,
filter: draft.filter.trim(),
workflow: draft.workflow,
owner: draft.owner,
repo: draft.repo,
owner: repository && !draft.repoParam ? draft.owner : "",
repo: repository && !draft.repoParam ? draft.repo : "",
repo_param: repository ? draft.repoParam : "",
inputs,
};
}
/** The repo pin a row shows, or an em dash when the binding takes the
* single-configured-repo default. */
export function repoPin(binding: Binding): string {
if (binding.repo_param) return `from ${binding.repo_param}`;
return binding.owner && binding.repo ? `${binding.owner}/${binding.repo}` : "—";
}
+2 -1
View File
@@ -77,7 +77,8 @@ export function useBindings() {
saving.value = true;
saveFailure.value = null;
try {
const body = bindingPayload(draft, eventTypes.value);
const workflow = workflows.value.find((w) => w.id === draft.workflow);
const body = bindingPayload(draft, eventTypes.value, workflow);
if (draft.id) {
await api.bindingUpdate(String(draft.id), body);
} else {
+1
View File
@@ -44,6 +44,7 @@ const DEFAULT_STATUSES: StatusMeta[] = [
{ id: "waiting_human", label: "Waiting for you", kind: "warn", needs_you: true },
{ id: "pr_open", label: "In review", kind: "ok" },
{ id: "merged", label: "Merged", kind: "ok" },
{ id: "completed", label: "Done", kind: "ok" },
{ id: "parked", label: "Parked", kind: "warn", needs_you: true },
{ id: "dead", label: "Stopped (too many retries)", kind: "danger" },
{ id: "rejected", label: "Rejected", kind: "danger" },