@arbidocs/blocks 0.4.75 → 0.4.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/index.cjs +265 -253
- package/dist/agents/index.js +3 -3
- package/dist/agents/tasks/TaskActivityTimeline.d.ts +1 -1
- package/dist/agents/tasks/WorkflowThreadStrip.d.ts +38 -1
- package/dist/agents/tasks/index.d.ts +2 -1
- package/dist/agents/tasks/linkedRuns.d.ts +31 -0
- package/dist/agents/workflows/index.d.ts +1 -1
- package/dist/agents/workflows/planSteps.d.ts +3 -1
- package/dist/agents/workflows/types.d.ts +27 -0
- package/dist/{chunk-YWYVIQ7T.js → chunk-22P5KNIM.js} +24 -4
- package/dist/chunk-22P5KNIM.js.map +1 -0
- package/dist/{chunk-F4LUD3YC.cjs → chunk-7FKARMA3.cjs} +158 -53
- package/dist/chunk-7FKARMA3.cjs.map +1 -0
- package/dist/{chunk-LT2UORRG.js → chunk-TKB7TVMW.js} +132 -29
- package/dist/chunk-TKB7TVMW.js.map +1 -0
- package/dist/{chunk-P2RBE3FD.cjs → chunk-VYRKO3XU.cjs} +24 -3
- package/dist/chunk-VYRKO3XU.cjs.map +1 -0
- package/dist/connect/index.cjs +10 -10
- package/dist/connect/index.js +3 -3
- package/dist/facts/index.cjs +1 -1
- package/dist/facts/index.js +1 -1
- package/dist/files/index.cjs +1 -1
- package/dist/files/index.js +1 -1
- package/dist/home/index.cjs +1 -1
- package/dist/home/index.js +1 -1
- package/dist/index.cjs +430 -418
- package/dist/index.js +7 -7
- package/dist/settings/index.cjs +1 -1
- package/dist/settings/index.js +1 -1
- package/dist/shell/index.cjs +1 -1
- package/dist/shell/index.js +1 -1
- package/dist/studio/index.cjs +1 -1
- package/dist/studio/index.js +1 -1
- package/dist/workflow-canvas/SignalsEditor.d.ts +41 -0
- package/dist/workflow-canvas/StepInspector.d.ts +4 -1
- package/dist/workflow-canvas/TriggerInspector.d.ts +11 -2
- package/dist/workflow-canvas/WorkflowBuilder.d.ts +7 -2
- package/dist/workflow-canvas/index.cjs +443 -149
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workflow-canvas/index.d.ts +2 -1
- package/dist/workflow-canvas/index.js +410 -123
- package/dist/workflow-canvas/index.js.map +1 -1
- package/dist/workflow-canvas/trigger.d.ts +20 -1
- package/package.json +4 -4
- package/dist/chunk-F4LUD3YC.cjs.map +0 -1
- package/dist/chunk-LT2UORRG.js.map +0 -1
- package/dist/chunk-P2RBE3FD.cjs.map +0 -1
- package/dist/chunk-YWYVIQ7T.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/agents/workflows/types.ts","../src/agents/workflows/workflow.ts","../src/agents/workflows/SchemaForm.tsx","../src/agents/workflows/run.ts","../src/agents/workflows/planSteps.ts","../src/agents/workflows/useWorkflowView.ts","../src/agents/workflows/WorkflowStepBar.tsx","../src/agents/workflows/WorkflowRunner.tsx"],"names":["compact","useState","act","jsx","useRef","jsxs","cn","Fragment","Loader2","Check","AlertTriangle","useEffect"],"mappings":";;;;;;;;;;AAiCO,IAAM,uBAAsC,EAAE,OAAA,EAAS,EAAC,EAAG,MAAA,EAAQ,EAAC;;;ACnBpE,IAAM,kBAAkB,CAAC,KAAA,KAC9B,OAAO,KAAA,KAAU,YACjB,KAAA,KAAU,IAAA,IACV,KAAA,CAAM,OAAA,CAAS,MAAwB,OAAO,CAAA,IAC9C,KAAA,CAAM,OAAA,CAAS,MAAwB,MAAM;AAExC,IAAM,oBAAA,GAAuB,CAAC,KAAA,KACnC,KAAA,CAAM,OAAA,CAAQ,MAAA,KAAW,CAAA,IAAK,KAAA,CAAM,MAAA,CAAO,MAAA,KAAW,CAAA,IAAK,CAAC,MAAM,SAAA,EAAW;AAG/E,IAAM,cAAc,CAAC,KAAA,KACnB,MAAM,IAAA,KAAS,OAAA,IAAW,MAAM,IAAA,KAAS,WAAA;AAE3C,SAAS,WAAW,KAAA,EAA0C;AAC5D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AAAA,0BAAAA,IAAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAU,qBAAA,EACb,QAAA,EAAA;AAAA,YAAA,MAAA;AAAA,YACA,MAAA;AAAA,YACA,cAAA,GAAiB,MAAM,GAAG;AAAA,WAAA,EAC7B,CAAA;AAAA,0BACAF,IAAC,KAAA,EAAA,EAAI,SAAA,EAAU,WAAW,QAAA,EAAA,iBAAA,CAAkB,IAAA,EAAM,KAAK,CAAA,EAAE;AAAA;AAAA;AAAA,KAC3D;AAAA,EAEJ;AACA,EAAA,uBACEE,KAAC,IAAA,EAAA,EAAK,SAAA,EAAU,iBAAgB,aAAA,EAAa,GAAA,CAAI,IAAA,CAAK,EAAE,CAAA,EACrD,QAAA,EAAA;AAAA,IAAA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,iBAAA,CAAkB,MAAM,KAAK,CAAA;AAAA,IAC7B,cAAA,GAAiB,MAAM,GAAG;AAAA,GAAA,EAC7B,CAAA;AAEJ","file":"chunk-YWYVIQ7T.js","sourcesContent":["/**\n * The one workflow model: a skill with a declared input schema. Everything launchable (a quick\n * action, a slash skill, a task body, an agent's job) is a `WorkflowDefinition`.\n *\n * The shape maps 1:1 onto future SKILL.md frontmatter (`inputs:` etc., snake_case on disk; see\n * `workflowFromFrontmatter`), so the backend can adopt it without a UI change. Blocks hold no\n * domain wording: titles, labels and prompt text are data supplied by the host.\n */\n\nexport type WorkflowFieldType =\n 'text' | 'longtext' | 'boolean' | 'select' | 'number' | 'date' | 'scope' | 'documents'\n\n/**\n * What a launching surface can hand a workflow without asking the user: the files it is looking at\n * (`documents`), the text the user selected (`selection`), or the image on screen (`image`, a file\n * id). A field binds to one with `context`; a surface offers a workflow when it can supply one of\n * the kinds the workflow declares (`workflowAccepts`).\n */\nexport type WorkflowContextKind = 'documents' | 'selection' | 'image'\n\n/** Where the user ends up after launching. `current-chat` sends into the chat already on screen. */\nexport type WorkflowLanding = 'chat' | 'current-chat' | 'files'\n\n/** Which files a run is limited to. Empty folders and labels = every file. */\nexport interface WorkflowScope {\n /** Folder paths; `''` is the unfiled bucket. */\n folders: string[]\n /** Label (tag) ids. */\n labels: string[]\n /** Exactly these files (ids). When present it wins over folders and labels: a `documents` field or a context launch. */\n documents?: string[]\n}\n\nexport const EMPTY_WORKFLOW_SCOPE: WorkflowScope = { folders: [], labels: [] }\n\nexport type WorkflowInputValue = string | number | boolean | WorkflowScope\n\nexport interface WorkflowFieldOption {\n value: string\n label: string\n description?: string\n /** Prompt fragment substituted for `{{name}}` when chosen (falls back to the label). */\n text?: string\n /** Key into the host's icon map. */\n icon?: string\n}\n\nexport interface WorkflowField {\n /** Key in `inputs`; also the `{{placeholder}}` in the prompt template. */\n name: string\n type: WorkflowFieldType\n label: string\n description?: string\n placeholder?: string\n required?: boolean\n default?: WorkflowInputValue\n /** `select` only. */\n options?: WorkflowFieldOption[]\n /** `number` only. */\n min?: number\n max?: number\n /** `boolean`: prompt fragments substituted for `{{name}}`. */\n trueText?: string\n falseText?: string\n /** Fold behind a disclosure: advanced wording the common run does not need. */\n advanced?: boolean\n /** `scope` only: which dimensions are offered. Default both. */\n by?: Array<'folders' | 'labels'>\n /** `documents` only: what kind of file is offered; `max` is how many may be picked (default 1). */\n accept?: 'image'\n /** Prefilled by a launching surface that supplies this kind of context (see `WorkflowContextKind`). */\n context?: WorkflowContextKind\n}\n\nexport type WorkflowRun =\n /** Compose a message from `promptTemplate` and send it. */\n | { kind: 'prompt'; promptTemplate: string }\n /** The host performs it (bound by workflow id), e.g. create a label then generate. */\n | { kind: 'operation' }\n /**\n * A guided run of named steps that form a graph. A run is a work thread on the server: the\n * thread's plan carries the steps (`toPlanSteps`), its activity log records each step's progress,\n * and the work runner starts each agent step as a turn in the thread. A person does the form,\n * upload and review steps (`useWorkflowThread` / `WorkflowRunner`). Not schedulable from a single\n * form: a workflow (automation) carries the steps and its trigger (`WorkflowBuilder`).\n */\n | {\n kind: 'steps'\n /** The run thread's title, a template over the run's inputs; defaults to the workflow's. */\n threadTitle?: string\n /** In dependency order: a step only waits for steps listed before it (`orderSteps`). */\n steps: WorkflowStep[]\n completion?: WorkflowCompletion\n /** Where each step sits on the builder's canvas, by step id. */\n layout?: Record<string, { x: number; y: number }>\n }\n\n/* ------------------------------- steps ------------------------------- */\n\ninterface WorkflowStepBase {\n /** Unique within the workflow (`[a-z][a-z0-9_-]*`): the thread's progress is keyed by it. */\n id: string\n /** The step's name: the stepper and the thread's top bar show it. */\n title: string\n /** One line under the step's heading. */\n description?: string\n /** Key into the host's icon map. */\n icon?: string\n /**\n * The host commits this step before the run moves on (`commit[id]`), e.g. creates the record\n * later steps work in. Once committed the step's inputs are locked.\n */\n commit?: boolean\n /** Primary button text while on this step (until it is committed); defaults to \"Continue\". */\n nextLabel?: string\n /**\n * The steps this one waits for. Absent: the step before it in the list, so a plain list is a\n * sequence. `[]`: it starts with the run. A step waiting for several waits for them all.\n */\n after?: string[]\n}\n\n/** Ask for inputs. Every step's fields share the run's one input namespace (`{{name}}`). */\nexport interface WorkflowFormStep extends WorkflowStepBase {\n kind: 'form'\n inputs: WorkflowField[]\n}\n\n/** Add files to the run's workspace. Skippable unless `required`. */\nexport interface WorkflowUploadStep extends WorkflowStepBase {\n kind: 'upload'\n required?: boolean\n /** `accept` of the file picker, e.g. `.pdf,.docx`. */\n accept?: string\n /** Small muted line under the drop target. */\n hint?: string\n}\n\n/**\n * A turn the assistant takes in the run's thread. It runs a skill or another workflow\n * (`workflow`, its inputs filled from `with`) or its own `run`. It continues the thread's main\n * line, so it sees everything before it; a `branch` step runs off the main line instead and\n * delivers only its result back to it.\n */\nexport interface WorkflowAgentStep extends WorkflowStepBase {\n kind: 'agent'\n /** Id of the skill or workflow this step runs; its inputs come from `with`. */\n workflow?: string\n /**\n * The named workflow's inputs, each a template over the run's inputs: `{{client}}`, with\n * `{{a || b}}` falling back to `b` when `a` is blank. A bare `{{name}}` passes the value as is.\n */\n with?: Record<string, string>\n /** Used when no `workflow` is named. `operation`: the host composes the prompt (`compose`). */\n run?: Extract<WorkflowRun, { kind: 'prompt' } | { kind: 'operation' }>\n /** What the step shows: the answer (default) or the drafted document. */\n output?: 'answer' | 'artifact'\n /** Runs off the thread's main line and delivers only its result to it. */\n branch?: boolean\n}\n\n/** A person's review or approval: whoever completes it on the thread approves it. */\nexport interface WorkflowReviewStep extends WorkflowStepBase {\n kind: 'review'\n /** What to review, a template over the run's inputs. */\n instructions?: string\n}\n\nexport type WorkflowStep =\n WorkflowFormStep | WorkflowUploadStep | WorkflowAgentStep | WorkflowReviewStep\n\n/** The finish screen of a stepped run. */\nexport interface WorkflowCompletion {\n title: string\n description?: string\n icon?: string\n}\n\n/**\n * Where a step of a run is, as the thread records it: not reached yet (`pending`), `running`,\n * `done`, `skipped`, or `failed` (it can be retried or skipped).\n */\nexport type WorkflowStepStatus = 'pending' | 'running' | 'done' | 'skipped' | 'failed'\n\nexport interface WorkflowStepState {\n status: WorkflowStepStatus\n /** The step's answer in the thread (an agent step), or the result a branch delivered. */\n responseId?: string | null\n /** The answer's text, once read. */\n text?: string\n error?: string | null\n /** When it started running (ISO), for the elapsed time while it runs. */\n startedAt?: string\n}\n\nexport interface WorkflowDefinition {\n /** Execute a document operation directly, without creating a chat. */\n documentAction?: 'annotate_documents' | 'email_documents'\n\n /** The skill slug. */\n id: string\n title: string\n /** One line: the tile text and the task picker's hint. */\n description: string\n /** Longer explanation shown in the dialog header; defaults to `description`. */\n details?: string\n /** Key into the host's icon map. */\n icon?: string\n /** Primary button text; defaults to the dialog's generic \"Start\". */\n startLabel?: string\n /** Shipped with the app/deployment (pinned, not deletable, forkable into the user's own skills). */\n builtin?: boolean\n /** Backed by a server skill (its slug): a task runs it as a skill rather than as a prompt. */\n skill?: string\n inputs: WorkflowField[]\n run: WorkflowRun\n /** Where the user ends up after launching by default; a launch may override it. */\n landing: WorkflowLanding\n /** A model this run asks for (a run option the host applies, e.g. a stronger one for summaries). */\n model?: string\n /** Only offered by this host (e.g. `'word'`); absent = offered everywhere. */\n host?: string\n /** Needs workspace files to make sense: the dialog offers the host's add-files slot when none. */\n requiresFiles?: boolean\n /** Default agent; absent = the user's own assistant. */\n defaultAgentId?: string\n /** A free-form entry (\"my own instruction\", \"remind me\"), not a named skill: it does not name the dialog. */\n generic?: boolean\n /** Can be the body of a task (unattended). `action` workflows are not. */\n schedulable?: boolean\n /** Run options the form offers (all shown by default). */\n options?: { agent?: boolean }\n}\n\n/** What `onLaunch` receives. The host performs the launch (chat, scoping, send). */\nexport interface WorkflowLaunch {\n workflow: WorkflowDefinition\n inputs: Record<string, WorkflowInputValue>\n /** The first `scope` field's value, hoisted: the host scopes documents with it. */\n scope: WorkflowScope\n /** `undefined` = the user's own assistant, in this chat. */\n agentId?: string\n /** Overrides `workflow.landing` for this launch (the empty chat sends in place). */\n landing?: WorkflowLanding\n}\n\nexport type OnWorkflowLaunch = (launch: WorkflowLaunch) => void | Promise<void>\n\nexport type WorkflowInputs = Record<string, WorkflowInputValue>\n\n/** Validation problem of one field: the dialog maps the code to a label. */\nexport type WorkflowFieldError = 'required' | 'min' | 'max' | 'number'\nexport type WorkflowErrors = Record<string, WorkflowFieldError>\n","import {\n EMPTY_WORKFLOW_SCOPE,\n type WorkflowDefinition,\n type WorkflowErrors,\n type WorkflowField,\n type WorkflowFieldOption,\n type WorkflowContextKind,\n type WorkflowFieldType,\n type WorkflowInputs,\n type WorkflowInputValue,\n type WorkflowLaunch,\n type WorkflowScope,\n} from './types'\n\nexport const isWorkflowScope = (value: unknown): value is WorkflowScope =>\n typeof value === 'object' &&\n value !== null &&\n Array.isArray((value as WorkflowScope).folders) &&\n Array.isArray((value as WorkflowScope).labels)\n\nexport const isEmptyWorkflowScope = (scope: WorkflowScope): boolean =>\n scope.folders.length === 0 && scope.labels.length === 0 && !scope.documents?.length\n\n/** A field that selects files: a folder/label scope or an explicit pick. */\nconst isFileField = (field: WorkflowField): boolean =>\n field.type === 'scope' || field.type === 'documents'\n\nfunction emptyValue(field: WorkflowField): WorkflowInputValue {\n switch (field.type) {\n case 'boolean':\n return false\n case 'scope':\n return { folders: [], labels: [] }\n case 'documents':\n return { folders: [], labels: [], documents: [] }\n default:\n return ''\n }\n}\n\n/** The inputs a fresh form starts with: each field's default, else an empty value of its type. */\nexport function defaultInputs(workflow: WorkflowDefinition): WorkflowInputs {\n const inputs: WorkflowInputs = {}\n for (const field of workflow.inputs) {\n const d = field.default\n inputs[field.name] =\n d === undefined\n ? emptyValue(field)\n : isWorkflowScope(d)\n ? { ...d }\n : (d as WorkflowInputValue)\n }\n return inputs\n}\n\n/** Required-field and range problems, keyed by field name. Empty object = launchable. */\nexport function validateInputs(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs\n): WorkflowErrors {\n const errors: WorkflowErrors = {}\n for (const field of workflow.inputs) {\n const value = inputs[field.name]\n if (field.type === 'number') {\n const blank = value === '' || value === undefined\n if (blank) {\n if (field.required) errors[field.name] = 'required'\n continue\n }\n const n = Number(value)\n if (Number.isNaN(n)) errors[field.name] = 'number'\n else if (field.min !== undefined && n < field.min) errors[field.name] = 'min'\n else if (field.max !== undefined && n > field.max) errors[field.name] = 'max'\n continue\n }\n if (!field.required) continue\n if (field.type === 'documents') {\n if (!isWorkflowScope(value) || !value.documents?.length) errors[field.name] = 'required'\n continue\n }\n if (field.type === 'boolean' || field.type === 'scope') continue\n if (typeof value !== 'string' || value.trim() === '') errors[field.name] = 'required'\n }\n return errors\n}\n\n/**\n * The field that holds what the user asks for: the first common (not folded away) free-text field.\n * Text typed after a slash pre-fills it; the form puts the cursor in it when it comes first.\n */\nexport function promptFieldName(workflow: WorkflowDefinition): string | undefined {\n return workflow.inputs.find((f) => !f.advanced && (f.type === 'text' || f.type === 'longtext'))\n ?.name\n}\n\n/** What the host knows that the inputs alone do not: file ids resolved to names for the wording. */\nexport interface WorkflowComposeContext {\n documentTitles?: Record<string, string>\n}\n\nconst quoteList = (names: string[]): string => {\n const quoted = names.map((n) => `\"${n}\"`)\n return quoted.length <= 1\n ? (quoted[0] ?? '')\n : `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`\n}\n\nfunction fragment(\n field: WorkflowField,\n value: WorkflowInputValue | undefined,\n ctx: WorkflowComposeContext | undefined\n): string {\n switch (field.type) {\n case 'documents': {\n // The quoted file name(s): \"the document <name>\" reads the same whichever file was picked.\n const ids = isWorkflowScope(value) ? (value.documents ?? []) : []\n const names = ids.flatMap((id) => {\n const title = ctx?.documentTitles?.[id]\n return title ? [title] : []\n })\n return quoteList(names)\n }\n case 'boolean':\n return value ? (field.trueText ?? 'yes') : (field.falseText ?? 'no')\n case 'select': {\n const option = field.options?.find((o) => o.value === value)\n return option ? (option.text ?? option.label) : String(value ?? '')\n }\n case 'scope':\n // The scope decides WHICH files the run is given; naming it in the wording only churns it.\n return ''\n default:\n return typeof value === 'string' ? value.trim() : String(value ?? '')\n }\n}\n\n/**\n * The single place a prompt string is composed from (workflow, inputs): `{{name}}` placeholders in\n * the template are replaced by each field's text. Whitespace left by empty fragments is tidied.\n */\nexport function composeWorkflowPrompt(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs,\n ctx?: WorkflowComposeContext\n): string {\n if (workflow.run.kind !== 'prompt') return ''\n const byName = new Map(workflow.inputs.map((f) => [f.name, f]))\n const template = workflow.run.promptTemplate\n // Whitespace left by empty fragments is tidied in the template's own text only: what the user\n // typed or selected (tabs, runs of spaces) reaches the prompt exactly as it was.\n let out = ''\n let last = 0\n const append = (text: string, isValue: boolean) => {\n let t = text\n if (!isValue) {\n t = t.replace(/[ \\t]{2,}/g, ' ')\n if (/[ \\t]$/.test(out)) t = t.replace(/^[ \\t]+/, '')\n }\n out += t\n }\n for (const m of template.matchAll(/\\{\\{\\s*([a-z][a-z0-9_]*)\\s*\\}\\}/gi)) {\n append(template.slice(last, m.index), false)\n const field = byName.get(m[1])\n append(field ? fragment(field, inputs[m[1]], ctx) : '', true)\n last = m.index + m[0].length\n }\n append(template.slice(last), false)\n return out.trim()\n}\n\n/** Assemble the launch the host receives: inputs, the hoisted scope and the chosen agent. */\nexport function buildLaunch(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs,\n agentId?: string\n): WorkflowLaunch {\n const scopeField = workflow.inputs.find(isFileField)\n const raw = scopeField ? inputs[scopeField.name] : undefined\n const scope = isWorkflowScope(raw) ? raw : { ...EMPTY_WORKFLOW_SCOPE }\n return { workflow, inputs, scope, agentId: agentId || workflow.defaultAgentId || undefined }\n}\n\n/* --------------------------- context launch --------------------------- */\n\n/** What a surface hands a workflow: the files in view, the selected text, the image on screen. */\nexport interface WorkflowContext {\n documents?: string[]\n selection?: string\n /** A file id. */\n image?: string\n}\n\n/** The kinds of context a workflow declares it can be started from. */\nexport function workflowAccepts(workflow: WorkflowDefinition): WorkflowContextKind[] {\n const kinds = new Set<WorkflowContextKind>()\n for (const field of workflow.inputs) if (field.context) kinds.add(field.context)\n return [...kinds]\n}\n\n/** Workflows a surface can offer: those that accept at least one kind of context it supplies. */\nexport function workflowsAccepting(\n workflows: WorkflowDefinition[],\n supplied: WorkflowContextKind[]\n): WorkflowDefinition[] {\n return workflows.filter((w) => workflowAccepts(w).some((k) => supplied.includes(k)))\n}\n\n/** Workflows a host offers: its own plus every one that is not tied to another host. */\nexport function workflowsForHost(\n workflows: WorkflowDefinition[],\n host: string\n): WorkflowDefinition[] {\n return workflows.filter((w) => !w.host || w.host === host)\n}\n\n/**\n * The inputs a context pre-fills: each field bound to a kind the surface supplied. Fields it does\n * not supply are left to the form's defaults, so the dialog still asks for them.\n */\nexport function inputsFromContext(\n workflow: WorkflowDefinition,\n context: WorkflowContext\n): WorkflowInputs {\n const inputs: WorkflowInputs = {}\n for (const field of workflow.inputs) {\n if (!field.context) continue\n if (field.context === 'selection') {\n if (context.selection) inputs[field.name] = context.selection\n continue\n }\n const ids =\n field.context === 'image' ? (context.image ? [context.image] : []) : context.documents\n if (ids?.length && isFileField(field)) {\n inputs[field.name] = { folders: [], labels: [], documents: ids.slice(0, field.max ?? 1) }\n }\n }\n return inputs\n}\n\n/* ------------------------------ skills ------------------------------- */\n\n/** The slice of a skill listing row the model needs (`SkillSummaryResponse`). */\nexport interface SkillLike {\n name: string\n slug: string\n description?: string\n arg_hint?: string\n}\n\n/** The prompt field's label when a skill brings none of its own. */\nexport const SKILL_PROMPT_LABEL = 'What should it work on?'\nexport const SKILL_PROMPT_FALLBACK_PLACEHOLDER = 'Describe what you want'\n\n/** `<prompt>` / `[topic]` becomes `prompt` / `topic`: a hint reads as a placeholder, not syntax. */\nconst plainHint = (hint: string): string => hint.replace(/^[<[]\\s*|\\s*[>\\]]$/g, '').trim()\n\n/**\n * A skill is run WITH a prompt, so it always gets a one-field form: a required free-text field\n * (`args`) whose placeholder is the skill's `arg_hint` (brackets removed). Starting one with\n * nothing is never offered; text typed after the slash pre-fills the field.\n */\nexport function skillToWorkflow(skill: SkillLike): WorkflowDefinition {\n const hint = plainHint((skill.arg_hint ?? '').trim())\n const inputs: WorkflowField[] = [\n {\n name: 'args',\n type: 'longtext',\n label: SKILL_PROMPT_LABEL,\n placeholder: hint || SKILL_PROMPT_FALLBACK_PLACEHOLDER,\n required: true,\n },\n ]\n return {\n id: skill.slug,\n skill: skill.slug,\n title: skill.name || skill.slug,\n description: skill.description ?? '',\n inputs,\n run: { kind: 'prompt', promptTemplate: `/${skill.slug} {{args}}` },\n landing: 'chat',\n schedulable: true,\n }\n}\n\nconst FIELD_TYPES: WorkflowFieldType[] = [\n 'text',\n 'longtext',\n 'boolean',\n 'select',\n 'number',\n 'date',\n 'scope',\n 'documents',\n]\n\nconst str = (v: unknown): string | undefined => (typeof v === 'string' ? v : undefined)\nconst num = (v: unknown): number | undefined => (typeof v === 'number' ? v : undefined)\nconst bool = (v: unknown): boolean | undefined => (typeof v === 'boolean' ? v : undefined)\n\nfunction fieldFromFrontmatter(raw: unknown): WorkflowField | null {\n if (typeof raw !== 'object' || raw === null) return null\n const r = raw as Record<string, unknown>\n const name = str(r.name)\n const type = FIELD_TYPES.find((t) => t === r.type)\n if (!name || !/^[a-z][a-z0-9_]*$/.test(name) || !type) return null\n const options = Array.isArray(r.options)\n ? r.options.flatMap((o): WorkflowFieldOption[] => {\n const ro = o as Record<string, unknown>\n const value = str(ro?.value)\n const label = str(ro?.label)\n return value && label\n ? [\n {\n value,\n label,\n description: str(ro.description),\n text: str(ro.text),\n icon: str(ro.icon),\n },\n ]\n : []\n })\n : undefined\n return {\n name,\n type,\n label: str(r.label) ?? name,\n description: str(r.description),\n placeholder: str(r.placeholder),\n required: bool(r.required),\n default: r.default as WorkflowInputValue | undefined,\n options,\n min: num(r.min),\n max: num(r.max),\n trueText: str(r.true_text),\n falseText: str(r.false_text),\n advanced: bool(r.advanced),\n accept: r.accept === 'image' ? 'image' : undefined,\n context:\n r.context === 'documents' || r.context === 'selection' || r.context === 'image'\n ? r.context\n : undefined,\n by: Array.isArray(r.by)\n ? (r.by.filter((b) => b === 'folders' || b === 'labels') as Array<'folders' | 'labels'>)\n : undefined,\n }\n}\n\n/**\n * Build a workflow from parsed SKILL.md frontmatter (snake_case keys) and its body (the prompt\n * template). The inverse of what the backend will publish; seeded workflows use the same shape.\n */\nexport function workflowFromFrontmatter(\n id: string,\n frontmatter: Record<string, unknown>,\n body: string\n): WorkflowDefinition {\n const inputs = Array.isArray(frontmatter.inputs)\n ? frontmatter.inputs.flatMap((f) => {\n const field = fieldFromFrontmatter(f)\n return field ? [field] : []\n })\n : []\n return {\n id,\n title: str(frontmatter.name) ?? id,\n description: str(frontmatter.description) ?? '',\n icon: str(frontmatter.icon),\n inputs,\n run: { kind: 'prompt', promptTemplate: body.trim() },\n landing: frontmatter.landing === 'files' ? 'files' : 'chat',\n requiresFiles: bool(frontmatter.requires_files),\n schedulable: bool(frontmatter.schedulable) ?? true,\n }\n}\n\n/** snake_case keys of the on-disk form of a field (what `workflowFromFrontmatter` reads). */\nexport function fieldToFrontmatter(field: WorkflowField): Record<string, unknown> {\n return compact({\n name: field.name,\n type: field.type,\n label: field.label,\n description: field.description,\n placeholder: field.placeholder,\n required: field.required,\n default: field.default,\n options: field.options?.map((o) =>\n compact({\n value: o.value,\n label: o.label,\n description: o.description,\n text: o.text,\n icon: o.icon,\n })\n ),\n min: field.min,\n max: field.max,\n true_text: field.trueText,\n false_text: field.falseText,\n advanced: field.advanced,\n by: field.by,\n accept: field.accept,\n context: field.context,\n })\n}\n\nconst compact = (o: Record<string, unknown>): Record<string, unknown> =>\n Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined))\n","import { useState, type ReactNode } from 'react'\nimport {\n Input,\n Label,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Switch,\n Textarea,\n cn,\n} from '@arbidocs/react/ui'\nimport { prefixedTestId, testIdOr } from '../../chat/test-id'\nimport { FoldSection } from '../../home/FoldSection'\nimport { isWorkflowScope } from './workflow'\nimport type {\n WorkflowErrors,\n WorkflowField,\n WorkflowFieldError,\n WorkflowInputs,\n WorkflowInputValue,\n WorkflowScope,\n} from './types'\n\nexport interface SchemaFormLabels {\n /** Appended to the label of an optional field. */\n optional: string\n /** Heading of the folded block that holds `advanced` fields. */\n advanced: string\n errors: Record<WorkflowFieldError, string>\n}\n\nexport const DEFAULT_SCHEMA_FORM_LABELS: SchemaFormLabels = {\n optional: '(optional)',\n advanced: 'More options',\n errors: {\n required: 'This is needed to continue',\n min: 'Too small',\n max: 'Too large',\n number: 'Enter a number',\n },\n}\n\nexport interface SchemaFormProps {\n fields: WorkflowField[]\n values: WorkflowInputs\n onChange: (name: string, value: WorkflowInputValue) => void\n /** Per-field problems to show (the dialog passes them once a launch was attempted). */\n errors?: WorkflowErrors\n /** Renders a `scope` field: the host owns the file data behind the picker. */\n renderScope?: (\n field: WorkflowField,\n value: WorkflowScope,\n onChange: (s: WorkflowScope) => void\n ) => ReactNode\n /** Renders a `documents` field (an explicit file pick): the host owns the file list. */\n renderDocuments?: (\n field: WorkflowField,\n value: WorkflowScope,\n onChange: (s: WorkflowScope) => void\n ) => ReactNode\n /** Maps an option's `icon` key to a mark. */\n renderIcon?: (key: string) => ReactNode\n /**\n * Plain Enter in a multi-line field submits the form (Shift+Enter inserts the newline), the\n * chat's own convention. Single-line fields submit natively.\n */\n onEnterSubmit?: () => void\n /** Prefix of field ids: `<prefix>-<field name>`; default `workflow-field`. */\n testIdPrefix?: string\n labels?: Partial<SchemaFormLabels>\n className?: string\n}\n\n/** Selects with at most this many options render as tiles; more fall back to a dropdown. */\nconst TILE_MAX = 4\n\ninterface FieldProps {\n field: WorkflowField\n value: WorkflowInputValue | undefined\n error?: WorkflowFieldError\n onChange: (value: WorkflowInputValue) => void\n l: SchemaFormLabels\n idFor: (suffix?: string) => string\n renderScope: SchemaFormProps['renderScope']\n renderDocuments: SchemaFormProps['renderDocuments']\n renderIcon: SchemaFormProps['renderIcon']\n onEnterSubmit: SchemaFormProps['onEnterSubmit']\n}\n\nfunction FieldControl({\n field,\n value,\n error,\n onChange,\n l,\n idFor,\n renderScope,\n renderDocuments,\n renderIcon,\n onEnterSubmit,\n}: FieldProps) {\n const id = `${idFor()}-control`\n const testId = idFor()\n switch (field.type) {\n case 'text':\n return (\n <Input\n id={id}\n data-testid={testId}\n value={String(value ?? '')}\n placeholder={field.placeholder}\n aria-required={field.required || undefined}\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? idFor('error') : undefined}\n onChange={(e) => onChange(e.target.value)}\n />\n )\n case 'longtext':\n return (\n <Textarea\n id={id}\n data-testid={testId}\n value={String(value ?? '')}\n placeholder={field.placeholder}\n aria-required={field.required || undefined}\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? idFor('error') : undefined}\n className=\"min-h-[96px]\"\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={(e) => {\n if (onEnterSubmit && e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {\n e.preventDefault()\n onEnterSubmit()\n }\n }}\n />\n )\n case 'number':\n return (\n <Input\n id={id}\n data-testid={testId}\n type=\"number\"\n inputMode=\"decimal\"\n min={field.min}\n max={field.max}\n value={value === undefined ? '' : String(value)}\n placeholder={field.placeholder}\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? idFor('error') : undefined}\n onChange={(e) => onChange(e.target.value === '' ? '' : Number(e.target.value))}\n />\n )\n case 'date':\n return (\n <Input\n id={id}\n data-testid={testId}\n type=\"date\"\n value={String(value ?? '')}\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? idFor('error') : undefined}\n onChange={(e) => onChange(e.target.value)}\n />\n )\n case 'boolean':\n return (\n <Switch\n id={id}\n data-testid={testId}\n checked={Boolean(value)}\n onCheckedChange={(checked) => onChange(checked)}\n />\n )\n case 'select': {\n const options = field.options ?? []\n if (options.length > 0 && options.length <= TILE_MAX) {\n return (\n <div\n role=\"radiogroup\"\n aria-label={field.label}\n className=\"grid grid-cols-2 gap-2 sm:grid-cols-4\"\n data-testid={testId}\n >\n {options.map((option) => {\n const selected = value === option.value\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n data-testid={prefixedTestId(testId, option.value, {\n testId: `workflow-field-${field.name}-${option.value}`,\n })}\n onClick={() => {\n onChange(option.value)\n }}\n className={cn(\n 'flex min-h-24 flex-col items-center justify-center gap-1.5 rounded-lg border p-3 text-center transition-colors pointer-coarse:min-h-28 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',\n selected\n ? 'border-primary bg-primary/10'\n : 'border-border bg-card [&:hover]:border-primary [&:hover]:bg-muted'\n )}\n >\n {option.icon && renderIcon && (\n <span className=\"text-muted-foreground\">{renderIcon(option.icon)}</span>\n )}\n <span className=\"text-sm font-medium text-foreground\">{option.label}</span>\n {option.description && (\n <span className=\"text-xs text-muted-foreground\">{option.description}</span>\n )}\n </button>\n )\n })}\n </div>\n )\n }\n return (\n <Select value={String(value ?? '')} onValueChange={(v) => onChange(v)}>\n <SelectTrigger id={id} data-testid={testId} className=\"pointer-coarse:min-h-11\">\n <SelectValue placeholder={field.placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options.map((o) => (\n <SelectItem key={o.value} value={o.value}>\n {o.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )\n }\n case 'scope': {\n const scope = isWorkflowScope(value) ? value : { folders: [], labels: [] }\n return <div data-testid={testId}>{renderScope?.(field, scope, onChange)}</div>\n }\n case 'documents': {\n const picked = isWorkflowScope(value) ? value : { folders: [], labels: [], documents: [] }\n return <div data-testid={testId}>{renderDocuments?.(field, picked, onChange)}</div>\n }\n }\n}\n\nfunction FormField(props: FieldProps) {\n const { field, error, l, idFor } = props\n const isBoolean = field.type === 'boolean'\n const showOptional = !field.required && field.type !== 'boolean' && field.type !== 'scope'\n const label = (\n <Label\n htmlFor={`${idFor()}-control`}\n className={isBoolean ? 'cursor-pointer font-normal' : undefined}\n >\n {field.label}\n {showOptional && (\n <>\n {' '}\n <span className=\"font-normal text-muted-foreground\">{l.optional}</span>\n </>\n )}\n </Label>\n )\n return (\n <div className=\"flex flex-col gap-1.5\" data-slot=\"schema-field\" data-field={field.name}>\n {isBoolean ? (\n <div className=\"flex items-center gap-2.5 pointer-coarse:min-h-11\">\n <FieldControl {...props} />\n {label}\n </div>\n ) : (\n <>\n {field.type !== 'scope' && label}\n <FieldControl {...props} />\n </>\n )}\n {field.description && <p className=\"text-xs text-muted-foreground\">{field.description}</p>}\n {error && (\n <p\n id={idFor('error')}\n role=\"alert\"\n className=\"text-xs text-destructive\"\n data-testid={idFor('error')}\n >\n {l.errors[error]}\n </p>\n )}\n </div>\n )\n}\n\n/**\n * Renders a workflow's declared inputs as a form. Controlled: the caller owns `values` (see\n * `defaultInputs`) and decides when to validate (`validateInputs`) and show `errors`.\n */\nexport function SchemaForm({\n fields,\n values,\n onChange,\n errors,\n renderScope,\n renderDocuments,\n renderIcon,\n onEnterSubmit,\n testIdPrefix,\n labels,\n className,\n}: SchemaFormProps) {\n const l: SchemaFormLabels = {\n ...DEFAULT_SCHEMA_FORM_LABELS,\n ...labels,\n errors: { ...DEFAULT_SCHEMA_FORM_LABELS.errors, ...labels?.errors },\n }\n const [advancedOpen, setAdvancedOpen] = useState(false)\n const common = fields.filter((f) => !f.advanced)\n const advanced = fields.filter((f) => f.advanced)\n\n const render = (field: WorkflowField) => (\n <FormField\n key={field.name}\n field={field}\n value={values[field.name]}\n error={errors?.[field.name]}\n onChange={(v) => onChange(field.name, v)}\n l={l}\n idFor={(suffix) =>\n suffix\n ? `${testIdOr(testIdPrefix, { testId: 'workflow-field' })}-${field.name}-${suffix}`\n : `${testIdOr(testIdPrefix, { testId: 'workflow-field' })}-${field.name}`\n }\n renderScope={renderScope}\n renderDocuments={renderDocuments}\n renderIcon={renderIcon}\n onEnterSubmit={onEnterSubmit}\n />\n )\n\n return (\n <div className={cn('flex flex-col gap-4', className)} data-slot=\"schema-form\">\n {common.map(render)}\n {advanced.length > 0 && (\n <FoldSection\n label={l.advanced}\n open={advancedOpen}\n onOpenChange={setAdvancedOpen}\n testId={`${testIdOr(testIdPrefix, { testId: 'workflow-field' })}-advanced-toggle`}\n >\n <div className=\"flex flex-col gap-4\">{advanced.map(render)}</div>\n </FoldSection>\n )}\n </div>\n )\n}\n","/**\n * The model of a stepped workflow (`run: { kind: 'steps' }`): the steps form a graph (each waits\n * for the steps in its `after`), and a run's progress is each step's `WorkflowStepState`, as the\n * run's thread records it (`stepStatesFromActivity`). Pure functions, shared by the thread runner\n * (`useWorkflowThread`), the builder's preview and the thread's top bar.\n */\n\nimport type {\n WorkflowAgentStep,\n WorkflowDefinition,\n WorkflowErrors,\n WorkflowInputs,\n WorkflowInputValue,\n WorkflowReviewStep,\n WorkflowStep,\n WorkflowStepState,\n WorkflowStepStatus,\n} from './types'\nimport { composeWorkflowPrompt, defaultInputs, validateInputs } from './workflow'\n\n/** A stepped workflow's steps; empty for a single-run one. */\nexport function workflowSteps(workflow: WorkflowDefinition): WorkflowStep[] {\n return workflow.run.kind === 'steps' ? workflow.run.steps : []\n}\n\nexport const isSteppedWorkflow = (workflow: WorkflowDefinition): boolean =>\n workflow.run.kind === 'steps'\n\n/* ------------------------------- graph ------------------------------- */\n\n/** What a step waits for: its `after`, else the step before it in the list (a sequence). */\nexport function stepDependencies(steps: WorkflowStep[], id: string): string[] {\n const i = steps.findIndex((s) => s.id === id)\n if (i < 0) return []\n return steps[i].after ?? (i > 0 ? [steps[i - 1].id] : [])\n}\n\n/** `a` waits for `b`, directly or through other steps. */\nexport function dependsOn(steps: WorkflowStep[], a: string, b: string): boolean {\n const seen = new Set<string>()\n const stack = [...stepDependencies(steps, a)]\n while (stack.length) {\n const id = stack.pop() as string\n if (id === b) return true\n if (seen.has(id)) continue\n seen.add(id)\n stack.push(...stepDependencies(steps, id))\n }\n return false\n}\n\n/**\n * The steps in dependency order, keeping the given order wherever the graph allows (a stable\n * topological sort). Every implicit dependency is written out as `after` first, so reordering\n * never changes what a step waits for. Steps in a cycle keep their place at the end; validation\n * reports them.\n */\nexport function orderSteps(steps: WorkflowStep[]): WorkflowStep[] {\n const explicit = steps.map((s) => ({ ...s, after: stepDependencies(steps, s.id) }))\n const known = new Set(explicit.map((s) => s.id))\n const placed = new Set<string>()\n const out: WorkflowStep[] = []\n let progress = true\n while (out.length < explicit.length && progress) {\n progress = false\n for (const s of explicit) {\n if (placed.has(s.id)) continue\n if (s.after.every((d) => placed.has(d) || !known.has(d))) {\n out.push(s)\n placed.add(s.id)\n progress = true\n break\n }\n }\n }\n return [...out, ...explicit.filter((s) => !placed.has(s.id))]\n}\n\nexport type WorkflowGraphProblem =\n | { code: 'duplicate'; step: string }\n | { code: 'unknown'; step: string; dependency: string }\n | { code: 'cycle'; step: string }\n | { code: 'order'; step: string; dependency: string }\n\n/** What makes a stepped workflow unrunnable. Empty = valid. */\nexport function validateWorkflowGraph(steps: WorkflowStep[]): WorkflowGraphProblem[] {\n const problems: WorkflowGraphProblem[] = []\n const ids = new Set<string>()\n for (const s of steps) {\n if (ids.has(s.id)) problems.push({ code: 'duplicate', step: s.id })\n ids.add(s.id)\n }\n steps.forEach((s, i) => {\n for (const d of stepDependencies(steps, s.id)) {\n if (!ids.has(d)) problems.push({ code: 'unknown', step: s.id, dependency: d })\n else if (d === s.id || dependsOn(steps, d, s.id)) problems.push({ code: 'cycle', step: s.id })\n else if (steps.findIndex((x) => x.id === d) > i)\n problems.push({ code: 'order', step: s.id, dependency: d })\n }\n })\n return problems\n}\n\n/**\n * The steps by depth (the longest chain before each): what the stepper shows side by side.\n * A sequence is one step per level.\n */\nexport function stepLevels(steps: WorkflowStep[]): WorkflowStep[][] {\n const depth = new Map<string, number>()\n for (const s of steps) {\n const deps = stepDependencies(steps, s.id).filter((d) => depth.has(d))\n depth.set(s.id, deps.length ? Math.max(...deps.map((d) => depth.get(d) as number)) + 1 : 0)\n }\n const levels: WorkflowStep[][] = []\n for (const s of steps) (levels[depth.get(s.id) as number] ??= []).push(s)\n return levels.filter(Boolean)\n}\n\n/* ----------------------------- progress ----------------------------- */\n\n/** One entry of a thread's activity log, as far as steps are concerned. */\nexport interface WorkflowActivityEvent {\n kind: string\n detail?: Record<string, unknown> | null\n created_at?: string\n}\n\nconst STEP_EVENTS: Record<string, WorkflowStepStatus> = {\n step_started: 'running',\n step_done: 'done',\n step_skipped: 'skipped',\n step_failed: 'failed',\n}\n\n/** Each step's state from the thread's activity log (oldest first): its latest step event wins. */\nexport function stepStatesFromActivity(\n events: WorkflowActivityEvent[]\n): Record<string, WorkflowStepState> {\n const states: Record<string, WorkflowStepState> = {}\n for (const e of events) {\n const status = STEP_EVENTS[e.kind]\n const step = e.detail?.step\n if (!status || typeof step !== 'string') continue\n const responseId = typeof e.detail?.response_id === 'string' ? e.detail.response_id : undefined\n const error = typeof e.detail?.error === 'string' ? e.detail.error : null\n const startedAt = status === 'running' ? e.created_at : states[step]?.startedAt\n states[step] = {\n status,\n responseId: responseId ?? states[step]?.responseId ?? null,\n error,\n ...(startedAt ? { startedAt } : {}),\n }\n }\n return states\n}\n\n/** Every field the run asks for: the launch form's, then each form step's. */\nexport function runFields(workflow: WorkflowDefinition) {\n return [\n ...workflow.inputs,\n ...workflowSteps(workflow).flatMap((s) => (s.kind === 'form' ? s.inputs : [])),\n ]\n}\n\n/** A fresh run's inputs: every field at its default, then the prefills. */\nexport function initialRunInputs(\n workflow: WorkflowDefinition,\n inputs: WorkflowInputs = {}\n): WorkflowInputs {\n return { ...defaultInputs({ ...workflow, inputs: runFields(workflow) }), ...inputs }\n}\n\nconst finished = (s: WorkflowStepState | undefined): boolean =>\n s?.status === 'done' || s?.status === 'skipped'\n\n/**\n * Where a step stands: `blocked` until everything it waits for has finished (done or skipped),\n * then `ready`, then its own status.\n */\nexport type WorkflowStepPhase = 'blocked' | 'ready' | 'running' | 'done' | 'skipped' | 'failed'\n\nexport function stepPhase(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>,\n id: string\n): WorkflowStepPhase {\n const s = states[id]\n if (s && s.status !== 'pending') return s.status\n return stepDependencies(steps, id).every((d) => finished(states[d])) ? 'ready' : 'blocked'\n}\n\nexport const isRunFinished = (\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>\n): boolean => steps.length > 0 && steps.every((s) => finished(states[s.id]))\n\n/** A step a person does (form, upload, review); agent steps run themselves. */\nexport const isPersonStep = (step: WorkflowStep): boolean => step.kind !== 'agent'\n\n/**\n * What the primary button does on the step in view:\n * - `complete`: finish this form, upload or review (approve) and move on;\n * - `move`: view the next step: this one is finished, or the next does not wait for it;\n * - `skip`: give up on this agent step (it failed) so what waits for it can go on;\n * - `finish`: show the completion (every step has finished);\n * - `wait`: nothing yet (this step is under way and the next waits for it, or it is blocked).\n */\nexport type WorkflowNextAction = 'complete' | 'move' | 'skip' | 'finish' | 'wait'\n\nexport function nextAction(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>,\n current: string | null\n): WorkflowNextAction {\n const i = steps.findIndex((s) => s.id === current)\n const step = steps[i]\n if (!step) return 'wait'\n const phase = stepPhase(steps, states, step.id)\n if (phase === 'blocked') return 'wait'\n const following = steps[i + 1]\n const independentNext = !!following && !dependsOn(steps, following.id, step.id)\n if (phase === 'done' || phase === 'skipped') {\n if (following) return 'move'\n return isRunFinished(steps, states) ? 'finish' : 'wait'\n }\n if (isPersonStep(step)) return 'complete'\n // An agent step on its way (about to start, or running): look ahead if nothing there waits for it.\n if (phase !== 'failed') return independentNext ? 'move' : 'wait'\n const waitedFor = steps.slice(i + 1).some((s) => dependsOn(steps, s.id, step.id))\n return waitedFor || !following ? 'skip' : 'move'\n}\n\n/** A form step's problems (empty = it can move on); other steps have none. */\nexport function validateStep(step: WorkflowStep, inputs: WorkflowInputs): WorkflowErrors {\n if (step.kind !== 'form') return {}\n return validateInputs(\n {\n id: step.id,\n title: step.title,\n description: '',\n inputs: step.inputs,\n run: { kind: 'operation' },\n landing: 'chat',\n },\n inputs\n )\n}\n\n/* ----------------------------- composing ----------------------------- */\n\nconst asText = (value: WorkflowInputValue | undefined): string =>\n typeof value === 'string' ? value.trim() : typeof value === 'number' ? String(value) : ''\n\n/**\n * Fill a step's `with` templates from the run's inputs: `{{a}}`, `{{a || b}}` (first non-blank).\n * A template that is exactly one bare reference passes the value through untouched.\n */\nexport function fillStepInputs(\n templates: Record<string, string> | undefined,\n inputs: WorkflowInputs\n): WorkflowInputs {\n const out: WorkflowInputs = {}\n for (const [name, template] of Object.entries(templates ?? {})) {\n const bare = /^\\{\\{\\s*([a-z][a-z0-9_]*)\\s*\\}\\}$/i.exec(template)\n if (bare) {\n out[name] = inputs[bare[1]] ?? ''\n continue\n }\n out[name] = fillRunText(template, inputs)\n }\n return out\n}\n\n/** A template over the run's inputs, as text (`{{a}}`, `{{a || b}}`). */\nexport function fillRunText(template: string, inputs: WorkflowInputs): string {\n return template\n .replace(/\\{\\{([^}]*)\\}\\}/g, (_, expr: string) => {\n for (const ref of expr.split('||')) {\n const text = asText(inputs[ref.trim()])\n if (text) return text\n }\n return ''\n })\n .trim()\n}\n\n/** The run thread's title: the workflow's `threadTitle` template, else its title. */\nexport function runThreadTitle(workflow: WorkflowDefinition, inputs: WorkflowInputs): string {\n const template = workflow.run.kind === 'steps' ? workflow.run.threadTitle : undefined\n return (template && fillRunText(template, inputs)) || workflow.title\n}\n\n/** What a review asks for: its instructions filled from the run, else its title. */\nexport function reviewInstructions(step: WorkflowReviewStep, inputs: WorkflowInputs): string {\n return (step.instructions && fillRunText(step.instructions, inputs)) || step.title\n}\n\nexport interface StepComposeOptions {\n /** Looks up the workflow a step names (`step.workflow`). */\n resolveWorkflow?: (id: string) => WorkflowDefinition | undefined\n /**\n * The host's wording for `operation` runs: the named workflow's id (or the step's own id when it\n * runs inline), its filled inputs, and the whole run's inputs (e.g. to ground it in the record).\n */\n compose?: (id: string, inputs: WorkflowInputs, runInputs: WorkflowInputs) => string | undefined\n}\n\n/** The prompt an agent step of `workflow` sends; '' when nothing could compose it (no binding). */\nexport function composeStepPrompt(\n workflow: WorkflowDefinition,\n step: WorkflowAgentStep,\n runInputs: WorkflowInputs,\n { resolveWorkflow, compose }: StepComposeOptions = {}\n): string {\n if (step.workflow) {\n const target = resolveWorkflow?.(step.workflow)\n if (!target) return ''\n const inputs = { ...defaultInputs(target), ...fillStepInputs(step.with, runInputs) }\n return target.run.kind === 'prompt'\n ? composeWorkflowPrompt(target, inputs)\n : (compose?.(target.id, inputs, runInputs) ?? '')\n }\n if (step.run?.kind === 'prompt') {\n return composeWorkflowPrompt(\n { ...workflow, inputs: runFields(workflow), run: step.run },\n runInputs\n )\n }\n return compose?.(step.id, runInputs, runInputs) ?? ''\n}\n","/**\n * A stepped workflow as the plan a run thread carries (`TaskPlan.steps`) and back. The server reads\n * the structure to start each step: an agent step runs a skill (`skill` + `inputs` templates) or a\n * prompt (filled from the run's inputs as it starts); everything only a client shows (form fields,\n * icon, canvas position, which workflow a step names) rides along in `ui`.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { composeStepPrompt, runFields, workflowSteps, type StepComposeOptions } from './run'\nimport type {\n WorkflowAgentStep,\n WorkflowDefinition,\n WorkflowField,\n WorkflowInputs,\n WorkflowStep,\n} from './types'\n\nexport type TaskPlanStep = components['schemas']['TaskPlanStep']\nexport type TaskPlan = components['schemas']['TaskPlan']\n\n/** What a step keeps for clients only (the server stores it as plain data). */\ninterface StepUi {\n description?: string\n icon?: string\n commit?: boolean\n next_label?: string\n fields?: WorkflowField[]\n required?: boolean\n accept?: string\n hint?: string\n output?: 'answer' | 'artifact'\n instructions?: string\n /** The skill or workflow an agent step names, and its input templates (the builder edits these). */\n workflow?: string\n with?: Record<string, string>\n prompt_template?: string\n position?: { x: number; y: number }\n}\n\nconst compact = <T extends object>(o: T): T =>\n Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined && v !== '')) as T\n\nexport interface ToPlanOptions extends StepComposeOptions {\n /**\n * The run's inputs when it starts: prompts are composed with them. Fields not given yet (or\n * absent altogether, saving a workflow to run later) keep `{{field}}` placeholders, which the\n * server fills from the run's inputs.\n */\n inputs?: WorkflowInputs\n}\n\n/** Each run field as its own `{{name}}` placeholder: composing with these keeps the template. */\nfunction placeholders(workflow: WorkflowDefinition): WorkflowInputs {\n return Object.fromEntries(runFields(workflow).map((f) => [f.name, `{{${f.name}}}`]))\n}\n\nfunction agentStep(\n workflow: WorkflowDefinition,\n step: WorkflowAgentStep,\n options: ToPlanOptions\n): Pick<TaskPlanStep, 'skill' | 'inputs' | 'prompt'> {\n const target = step.workflow ? options.resolveWorkflow?.(step.workflow) : undefined\n // A server skill: the server runs the skill itself with the step's inputs.\n if (target?.skill) return { skill: target.skill, inputs: step.with ?? {}, prompt: null }\n // A field still blank when the run starts (a later form fills it) keeps its placeholder, so the\n // server fills it from the run's inputs as the step starts.\n const given = Object.entries(options.inputs ?? {}).filter(\n ([, v]) => v !== undefined && v !== null && v !== ''\n )\n const inputs = { ...placeholders(workflow), ...Object.fromEntries(given) }\n return { skill: null, inputs: null, prompt: composeStepPrompt(workflow, step, inputs, options) }\n}\n\n/** The plan steps a run thread (or a saved workflow) carries for `workflow`. */\nexport function toPlanSteps(\n workflow: WorkflowDefinition,\n options: ToPlanOptions = {}\n): TaskPlanStep[] {\n const layout = workflow.run.kind === 'steps' ? workflow.run.layout : undefined\n return workflowSteps(workflow).map((step) => {\n const ui: StepUi = compact({\n description: step.description,\n icon: step.icon,\n commit: step.commit,\n next_label: step.nextLabel,\n position: layout?.[step.id],\n ...(step.kind === 'form' ? { fields: step.inputs } : {}),\n ...(step.kind === 'upload'\n ? { required: step.required, accept: step.accept, hint: step.hint }\n : {}),\n ...(step.kind === 'review' ? { instructions: step.instructions } : {}),\n ...(step.kind === 'agent'\n ? {\n output: step.output,\n workflow: step.workflow,\n with: step.with,\n prompt_template: step.run?.kind === 'prompt' ? step.run.promptTemplate : undefined,\n }\n : {}),\n })\n return {\n id: step.id,\n title: step.title,\n kind: step.kind,\n after: step.after ?? null,\n branch: step.kind === 'agent' && !!step.branch,\n requires_files: false,\n ui: ui as Record<string, unknown>,\n ...(step.kind === 'agent'\n ? agentStep(workflow, step, options)\n : { skill: null, inputs: null, prompt: null }),\n }\n })\n}\n\n/** Steps from a run's (or a saved workflow's) plan: what the runner, the builder and the top bar show. */\nexport function fromPlanSteps(steps: TaskPlanStep[] | null | undefined): WorkflowStep[] {\n return (steps ?? []).map((p): WorkflowStep => {\n const ui = (p.ui ?? {}) as StepUi\n const base = {\n id: p.id,\n title: p.title,\n description: ui.description,\n icon: ui.icon,\n commit: ui.commit,\n nextLabel: ui.next_label,\n ...(p.after != null ? { after: p.after } : {}),\n }\n switch (p.kind) {\n case 'form':\n return { ...base, kind: 'form', inputs: ui.fields ?? [] }\n case 'upload':\n return { ...base, kind: 'upload', required: ui.required, accept: ui.accept, hint: ui.hint }\n case 'review':\n return { ...base, kind: 'review', instructions: ui.instructions }\n default: {\n const promptTemplate = ui.prompt_template ?? p.prompt ?? undefined\n return {\n ...base,\n kind: 'agent',\n workflow: ui.workflow ?? p.skill ?? undefined,\n with: ui.with ?? (p.inputs as Record<string, string> | null) ?? undefined,\n run:\n !ui.workflow && !p.skill && promptTemplate\n ? { kind: 'prompt', promptTemplate }\n : undefined,\n output: ui.output,\n branch: p.branch || undefined,\n }\n }\n }\n })\n}\n\n/** Where each step sits on the builder's canvas, as the plan keeps it. */\nexport function layoutFromPlanSteps(\n steps: TaskPlanStep[] | null | undefined\n): Record<string, { x: number; y: number }> | undefined {\n const entries = (steps ?? []).flatMap((p) => {\n const position = (p.ui as StepUi | null | undefined)?.position\n return position ? [[p.id, position] as const] : []\n })\n return entries.length ? Object.fromEntries(entries) : undefined\n}\n","/**\n * The screen side of a stepped run: which step is in view, form problems, and what the primary\n * button does. The run itself happens elsewhere (the thread on the server, `useWorkflowThread`, or\n * the builder's preview): this hook gets each step's state and the host's actions, so every host\n * shows a run the same way (`WorkflowRunner`).\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n isRunFinished,\n nextAction,\n stepPhase,\n validateStep,\n type WorkflowNextAction,\n type WorkflowStepPhase,\n} from './run'\nimport type {\n WorkflowErrors,\n WorkflowInputValue,\n WorkflowInputs,\n WorkflowStep,\n WorkflowStepState,\n} from './types'\n\nexport interface UseWorkflowViewOptions {\n steps: WorkflowStep[]\n /** Each step's state (missing = pending). */\n states: Record<string, WorkflowStepState>\n inputs: WorkflowInputs\n setInput: (name: string, value: WorkflowInputValue) => void\n /** Finish a person's step (a form, an upload, a review's approval). A throw keeps the user on it. */\n complete: (step: WorkflowStep) => Promise<void>\n /** Give up on a step so what waits for it can go on. */\n skip: (stepId: string) => Promise<void>\n /** Run a failed agent step again. */\n retry?: (stepId: string) => Promise<void>\n /** A form step whose inputs can no longer change (committed, or recorded on the thread). */\n isLocked?: (stepId: string) => boolean\n}\n\n/** What `WorkflowRunner` shows and does. */\nexport interface WorkflowRunView {\n steps: WorkflowStep[]\n /** The step in view; `undefined` once the run's completion is shown. */\n step: WorkflowStep | undefined\n current: string | null\n isComplete: boolean\n inputs: WorkflowInputs\n setInput: (name: string, value: WorkflowInputValue) => void\n stateOf: (stepId: string) => WorkflowStepState | undefined\n phaseOf: (stepId: string) => WorkflowStepPhase\n isLocked: (stepId: string) => boolean\n /** The form step in view's problems, shown once moving on was attempted. */\n errors: WorkflowErrors\n /** An action is under way (completing, skipping). */\n busy: boolean\n actionError: string | null\n /** Some agent step is running. */\n isRunning: boolean\n action: WorkflowNextAction\n canBack: boolean\n next: () => Promise<void>\n back: () => void\n /** View a step (one further down the plan too: it can be skipped from there). */\n goTo: (stepId: string) => void\n skip: (stepId: string) => Promise<void>\n retry?: (stepId: string) => Promise<void>\n /** Show the run from the start again (a host that starts a new run resets its own state). */\n restart: () => void\n}\n\nconst errorMessage = (e: unknown): string =>\n e instanceof Error ? e.message : typeof e === 'string' ? e : 'Something went wrong.'\n\n/** The first step that is not finished yet: where a run opens. */\nfunction firstOpen(\n steps: WorkflowStep[],\n states: Record<string, WorkflowStepState>\n): string | null {\n const open = steps.find((s) => !['done', 'skipped'].includes(states[s.id]?.status ?? 'pending'))\n return open?.id ?? (steps.length && isRunFinished(steps, states) ? null : (steps[0]?.id ?? null))\n}\n\nexport function useWorkflowView(options: UseWorkflowViewOptions): WorkflowRunView {\n const { steps, states, inputs, setInput } = options\n const [current, setCurrent] = useState<string | null>(() => firstOpen(steps, states))\n const [showErrors, setShowErrors] = useState(false)\n const [busy, setBusy] = useState(false)\n const [actionError, setActionError] = useState<string | null>(null)\n const optionsRef = useRef(options)\n optionsRef.current = options\n\n // A run loaded after the first render (its thread arrived) opens where it is.\n const placed = useRef(steps.length > 0)\n useEffect(() => {\n if (placed.current || steps.length === 0) return\n placed.current = true\n setCurrent(firstOpen(steps, states))\n }, [steps, states])\n\n const step = steps.find((s) => s.id === current)\n const following = useCallback(\n (id: string | null): string | null => {\n const i = steps.findIndex((s) => s.id === id)\n return steps[i + 1]?.id ?? null\n },\n [steps]\n )\n // Where to go once the step in view is finished (completed or skipped): the next one still to\n // do, else simply the next one. The step just finished counts as finished whatever the states\n // say yet (they may not have caught up).\n const onward = useCallback(\n (id: string): string | null => {\n const { steps: s, states: st } = optionsRef.current\n const i = s.findIndex((x) => x.id === id)\n const open = s\n .slice(i + 1)\n .find((x) => !['done', 'skipped'].includes(st[x.id]?.status ?? 'pending'))\n return open?.id ?? following(id)\n },\n [following]\n )\n const action: WorkflowNextAction = busy ? 'wait' : nextAction(steps, states, current)\n\n const next = useCallback(async () => {\n const { steps: s, states: st, inputs: values } = optionsRef.current\n const at = s.find((x) => x.id === current)\n const act = nextAction(s, st, current)\n if (!at || act === 'wait' || busy) return\n setActionError(null)\n if (act === 'finish') return setCurrent(null)\n if (act === 'move') return setCurrent(following(current))\n setBusy(true)\n try {\n if (act === 'skip') {\n await optionsRef.current.skip(at.id)\n } else {\n if (Object.keys(validateStep(at, values)).length > 0) {\n setShowErrors(true)\n return\n }\n await optionsRef.current.complete(at)\n }\n setShowErrors(false)\n setCurrent(onward(at.id) ?? current)\n } catch (e) {\n setActionError(errorMessage(e))\n } finally {\n setBusy(false)\n }\n }, [current, busy, following, onward])\n\n const goTo = useCallback((stepId: string) => {\n setShowErrors(false)\n setActionError(null)\n setCurrent(stepId)\n }, [])\n\n const index = steps.findIndex((s) => s.id === current)\n const back = useCallback(() => {\n const i = steps.findIndex((s) => s.id === current)\n const to = i < 0 ? steps[steps.length - 1] : steps[i - 1]\n if (to) goTo(to.id)\n }, [steps, current, goTo])\n\n const act = useCallback(\n (fn: ((id: string) => Promise<void>) | undefined) =>\n fn &&\n (async (stepId: string) => {\n setBusy(true)\n setActionError(null)\n try {\n await fn(stepId)\n } catch (e) {\n setActionError(errorMessage(e))\n } finally {\n setBusy(false)\n }\n }),\n []\n )\n // A skip moves the view on the way completing does (when it was the step in view).\n const currentRef = useRef(current)\n currentRef.current = current\n const skip = useMemo(\n () =>\n act(async (id) => {\n await optionsRef.current.skip(id)\n if (currentRef.current !== id) return\n setShowErrors(false)\n setCurrent(onward(id) ?? id)\n }) as (id: string) => Promise<void>,\n [act, onward]\n )\n const retry = useMemo(\n () =>\n options.retry ? act((id) => optionsRef.current.retry?.(id) ?? Promise.resolve()) : undefined,\n // Only whether the host offers retry matters here.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [act, !!options.retry]\n )\n\n const isLocked = useCallback(\n (stepId: string) => optionsRef.current.isLocked?.(stepId) ?? false,\n []\n )\n\n return {\n steps,\n step,\n current,\n isComplete: current === null,\n inputs,\n setInput,\n stateOf: (id) => states[id],\n phaseOf: (id) => stepPhase(steps, states, id),\n isLocked,\n errors: showErrors && step && !isLocked(step.id) ? validateStep(step, inputs) : {},\n busy,\n actionError,\n isRunning: Object.values(states).some((s) => s.status === 'running'),\n action,\n canBack: (current === null || index > 0) && !busy,\n next,\n back,\n goTo,\n skip,\n retry,\n restart: () => {\n setShowErrors(false)\n setActionError(null)\n setCurrent(steps[0]?.id ?? null)\n },\n }\n}\n","/**\n * The run's stepper: the graph by depth (a sequence is one row, steps side by side stack in a\n * column). It shows every label while they fit the width it has; when they do not, only the step\n * in view keeps its label and the rest are icons (named on hover and to assistive technology).\n * Labels never run past their pill: a long title is cut with an ellipsis, in full in `title`.\n */\n\nimport { useLayoutEffect, useRef, useState, type ReactNode } from 'react'\nimport { AlertTriangle, Check, Loader2, MinusCircle } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { useElementSize } from '../../lib/useElementSize'\nimport type { WorkflowStepPhase } from './run'\nimport type { WorkflowRunView } from './useWorkflowView'\nimport type { WorkflowStep } from './types'\n\nexport function PhaseMark({ phase, icon }: { phase: WorkflowStepPhase; icon?: ReactNode }) {\n if (phase === 'done') return <Check className=\"size-3.5 shrink-0\" />\n if (phase === 'running') return <Loader2 className=\"size-3.5 shrink-0 animate-spin\" />\n if (phase === 'failed') return <AlertTriangle className=\"size-3.5 shrink-0\" />\n if (phase === 'skipped') return <MinusCircle className=\"size-3.5 shrink-0\" />\n return icon ? (\n <span className=\"flex size-3.5 shrink-0 items-center justify-center [&_svg]:size-3.5\">\n {icon}\n </span>\n ) : null\n}\n\nconst PILL =\n 'flex min-w-0 max-w-full shrink-0 items-center gap-2 whitespace-nowrap rounded-full border px-2.5 py-1.5 text-xs font-medium'\n/** The longest a label gets, compact or not: about 30 characters of text-xs. */\nconst LABEL = 'min-w-0 max-w-[12rem] truncate'\n\nexport interface WorkflowStepBarProps {\n run: WorkflowRunView\n levels: WorkflowStep[][]\n doneTitle: string\n doneIcon?: ReactNode\n icon: (key?: string) => ReactNode\n tid: (suffix: string) => string\n}\n\nexport function WorkflowStepBar({\n run,\n levels,\n doneTitle,\n doneIcon,\n icon,\n tid,\n}: WorkflowStepBarProps) {\n const box = useRef<HTMLDivElement>(null)\n const measure = useRef<HTMLDivElement>(null)\n const row = useRef<HTMLOListElement>(null)\n const { width } = useElementSize(box)\n const [compact, setCompact] = useState(false)\n const titles = levels.map((l) => l.map((s) => s.title).join('\\u0000')).join('\\u0001') + doneTitle\n\n // What every label would need, from an invisible copy laid out at its natural width.\n useLayoutEffect(() => {\n const needed = measure.current?.scrollWidth ?? 0\n setCompact(width > 0 && needed > width)\n }, [width, titles])\n\n // A compact row may still be wider than its box (a very long run): keep the step in view on it.\n useLayoutEffect(() => {\n if (!compact) return\n const el = row.current?.querySelector<HTMLElement>('[aria-current=\"step\"]')\n el?.scrollIntoView?.({ block: 'nearest', inline: 'nearest' })\n }, [compact, run.current])\n\n const pill = (s: WorkflowStep) => {\n const phase = run.phaseOf(s.id)\n const current = s.id === run.current\n return (\n <button\n key={s.id}\n type=\"button\"\n onClick={() => run.goTo(s.id)}\n disabled={run.busy}\n className={cn(\n PILL,\n 'transition-colors disabled:cursor-default',\n current\n ? 'border-primary bg-primary/10 text-primary'\n : phase === 'failed'\n ? 'border-destructive/40 text-destructive'\n : phase === 'done' || phase === 'skipped' || phase === 'running'\n ? 'border-primary/30 bg-primary/5 text-primary'\n : 'border-border text-muted-foreground'\n )}\n aria-current={current ? 'step' : undefined}\n aria-label={s.title}\n title={s.title}\n data-phase={phase}\n data-testid={tid(`step-${s.id}`)}\n >\n <PhaseMark phase={phase} icon={icon(s.icon)} />\n {(current || !compact) && (\n <span className={LABEL} data-testid={tid(`step-${s.id}-label`)}>\n {s.title}\n </span>\n )}\n </button>\n )\n }\n\n const done = run.isComplete\n return (\n <div ref={box} className=\"relative min-w-0\">\n {/* The measure: every label at full width. Its text is CSS content, so it is not read out or\n found by text, and it takes no room. */}\n <div\n ref={measure}\n aria-hidden\n className=\"pointer-events-none invisible absolute left-0 top-0 flex w-max items-center gap-1.5\"\n >\n {[...levels, [{ id: '__done', title: doneTitle } as WorkflowStep]].map((level, i) => (\n <div key={i} className=\"flex items-center gap-1.5\">\n <div className=\"flex flex-col items-start gap-1\">\n {level.map((s) => (\n <div key={s.id} className={PILL}>\n <span className=\"size-3.5 shrink-0\" />\n <span\n className={cn(LABEL, 'before:content-[attr(data-label)]')}\n data-label={s.title}\n />\n </div>\n ))}\n </div>\n {i < levels.length && <div className=\"w-2\" />}\n </div>\n ))}\n </div>\n <ol\n ref={row}\n className={cn('flex w-full items-center gap-1.5', compact && 'overflow-x-auto pb-1')}\n data-compact={compact || undefined}\n data-testid={tid('steps')}\n >\n {[...levels, null].map((level, i) => (\n <li\n key={level ? level.map((s) => s.id).join('+') : 'done'}\n className={cn(\n 'flex min-w-0 items-center gap-1.5',\n i < levels.length && !compact && 'flex-1',\n compact && 'flex-none'\n )}\n >\n {level ? (\n <div className=\"flex min-w-0 flex-col items-start gap-1\">{level.map(pill)}</div>\n ) : (\n <div\n className={cn(\n PILL,\n done\n ? 'border-primary bg-primary/10 text-primary'\n : 'border-border text-muted-foreground'\n )}\n aria-current={done ? 'step' : undefined}\n aria-label={doneTitle}\n title={doneTitle}\n data-testid={tid('step-done')}\n >\n <PhaseMark phase=\"ready\" icon={doneIcon} />\n {(done || !compact) && <span className={LABEL}>{doneTitle}</span>}\n </div>\n )}\n {i < levels.length && (\n <div\n className={cn(\n 'h-px',\n compact ? 'w-3 flex-none' : 'min-w-2 flex-1',\n level?.every((s) => ['done', 'skipped'].includes(run.phaseOf(s.id)))\n ? 'bg-primary/40'\n : 'bg-border'\n )}\n />\n )}\n </li>\n ))}\n </ol>\n </div>\n )\n}\n","/**\n * A stepped workflow run, end to end: the stepper, the step in view (a form, an upload, an agent\n * step or a review) and moving on. The stepper lays the graph out by depth: a sequence is one row,\n * steps side by side stack in a column. The run comes from `useWorkflowThread` (a thread on the\n * server) or `useWorkflowPreview`; wording and the agent output's rendering come from the host.\n */\n\nimport { useEffect, useRef, useState, type ReactNode } from 'react'\nimport {\n AlertTriangle,\n ArrowLeft,\n ArrowRight,\n Check,\n CheckCircle2,\n FileText,\n GitBranch,\n Loader2,\n RotateCw,\n} from 'lucide-react'\nimport { Button, Card, cn } from '@arbidocs/react/ui'\nimport { UploadDropzone } from '../../files/UploadDropzone'\nimport { SchemaForm, type SchemaFormProps } from './SchemaForm'\nimport { reviewInstructions, stepDependencies, stepLevels } from './run'\nimport { WorkflowStepBar } from './WorkflowStepBar'\nimport type { WorkflowRunView } from './useWorkflowView'\nimport type {\n WorkflowAgentStep,\n WorkflowDefinition,\n WorkflowReviewStep,\n WorkflowStep,\n WorkflowStepState,\n WorkflowUploadStep,\n} from './types'\n\nexport interface WorkflowRunnerLabels {\n back: string\n next: string\n skip: string\n /** Skips the step in view (any unfinished step: the plan guides the thread, it does not hold it). */\n skipStep: string\n finish: string\n approve: string\n working: string\n /** An agent step under way: `{step}` is its title, `{elapsed}` how long it has run (m:ss). */\n stepWorking: string\n /** An agent step about to start (the run will pick it up). */\n starting: string\n retry: string\n failed: string\n /** A step whose dependencies have not finished; `{steps}` is replaced with their titles. */\n blocked: string\n awaitingReview: string\n approved: string\n skipped: string\n /** An agent step that runs off the main line and delivers its result to it. */\n branch: string\n /** The default finish heading (the workflow's `completion.title` wins). */\n complete: string\n restart: string\n /** The upload step's list of what else the workspace holds (folded); `{count}` is replaced. */\n filesHeading: string\n /** The upload step's list of the files added on it in this run; `{count}` is replaced. */\n addedHeading: string\n noFiles: string\n /** A file's processing status on the upload step. */\n fileReading: string\n fileReady: string\n fileFailed: string\n /** Continue on an upload step while its files are read; `{current}` and `{count}` are replaced. */\n readingFiles: string\n}\n\nexport const DEFAULT_WORKFLOW_RUNNER_LABELS: WorkflowRunnerLabels = {\n back: 'Back',\n next: 'Continue',\n skip: 'Skip',\n skipStep: 'Skip this step',\n finish: 'Finish',\n approve: 'Approve',\n working: 'Working…',\n stepWorking: '{step}… {elapsed}',\n starting: 'Starting…',\n retry: 'Retry',\n failed: 'This step did not finish.',\n blocked: 'Starts after {steps}.',\n awaitingReview: 'Waiting for approval.',\n approved: 'Approved.',\n skipped: 'Skipped.',\n branch: 'Runs alongside; its result joins the thread',\n complete: 'Done',\n restart: 'Start again',\n filesHeading: 'Already in the workspace ({count})',\n addedHeading: 'Added for this step ({count})',\n noFiles: 'No files yet.',\n fileReading: 'Reading…',\n fileReady: 'Ready',\n fileFailed: 'Could not be read',\n readingFiles: 'Reading {current} of {count} files…',\n}\n\n/** A file the upload step lists (what is in the run's workspace). */\nexport interface WorkflowRunnerFile {\n id: string\n name: string\n /** Where its processing is; absent = not known (shown as is). */\n status?: 'processing' | 'ready' | 'failed'\n /** The upload step it was added on in this run (listed first there, and holds it while read). */\n addedFor?: string\n}\n\nexport interface WorkflowRunnerProps extends Pick<\n SchemaFormProps,\n 'renderScope' | 'renderDocuments' | 'renderIcon'\n> {\n workflow: WorkflowDefinition\n run: WorkflowRunView\n /** An agent step's output (its answer, a drafted document). */\n renderAgentOutput: (step: WorkflowAgentStep, state: WorkflowStepState | undefined) => ReactNode\n /** A review's extras while it waits (e.g. who to ask). */\n renderReview?: (step: WorkflowReviewStep) => ReactNode\n /** Upload step: the host performs the upload into the run's workspace. */\n onUpload?: (files: File[], step: WorkflowUploadStep) => void | Promise<void>\n uploading?: boolean\n /** What the run's workspace holds, listed on the upload step. */\n files?: WorkflowRunnerFile[]\n /** Replaces an upload step's body. */\n renderUpload?: (step: WorkflowUploadStep) => ReactNode\n /** Extra content under a step's body (e.g. what a commit created). */\n renderStepNote?: (step: WorkflowStep, run: WorkflowRunView) => ReactNode\n /** Replaces the finish screen. */\n renderComplete?: (run: WorkflowRunView) => ReactNode\n labels?: Partial<WorkflowRunnerLabels>\n /**\n * Test ids: `<prefix>-step-<id>` (pill), `<prefix>-<id>` (body), `<prefix>-field-<name>`,\n * `<prefix>-next` / `-back`, `<prefix>-done`.\n */\n testIdPrefix?: string\n className?: string\n}\n\nexport function WorkflowRunner({\n workflow,\n run,\n renderAgentOutput,\n renderReview,\n onUpload,\n uploading = false,\n files,\n renderUpload,\n renderStepNote,\n renderComplete,\n renderScope,\n renderDocuments,\n renderIcon,\n labels,\n testIdPrefix = 'workflow-run',\n className,\n}: WorkflowRunnerProps) {\n const l = { ...DEFAULT_WORKFLOW_RUNNER_LABELS, ...labels }\n const { steps, step, isComplete, action } = run\n const completion = workflow.run.kind === 'steps' ? workflow.run.completion : undefined\n const tid = (suffix: string) => `${testIdPrefix}-${suffix}`\n const levels = stepLevels(steps)\n const icon = (key?: string) => (key && renderIcon ? renderIcon(key) : undefined)\n\n // An upload step's files are read before the run goes on (it can still be skipped).\n const added = step?.kind === 'upload' ? (files ?? []).filter((f) => f.addedFor === step.id) : []\n const unread = added.filter((f) => f.status === 'processing').length\n const reading = action === 'complete' && unread > 0\n\n const nextLabel = reading\n ? l.readingFiles\n .replace('{current}', String(Math.min(added.length - unread + 1, added.length)))\n .replace('{count}', String(added.length))\n : action === 'skip'\n ? l.skip\n : action === 'finish'\n ? l.finish\n : action === 'complete' && step?.kind === 'review'\n ? l.approve\n : action === 'wait' && (run.isRunning || run.busy)\n ? l.working\n : ((step && !run.isLocked(step.id) ? step.nextLabel : undefined) ?? l.next)\n\n return (\n <div className={cn('space-y-6', className)} data-testid={testIdPrefix}>\n <WorkflowStepBar\n run={run}\n levels={levels}\n doneTitle={completion?.title ?? l.complete}\n doneIcon={icon(completion?.icon)}\n icon={icon}\n tid={tid}\n />\n\n {isComplete ? (\n (renderComplete?.(run) ?? (\n <Card className=\"mx-auto max-w-lg p-8 text-center\" data-testid={tid('done')}>\n <CheckCircle2 className=\"mx-auto size-12 text-primary\" />\n <h2 className=\"mt-4 text-xl font-semibold\">{completion?.title ?? l.complete}</h2>\n {completion?.description && (\n <p className=\"mt-1 text-sm text-muted-foreground\">{completion.description}</p>\n )}\n <Button\n variant=\"outline\"\n className=\"mt-6\"\n onClick={run.restart}\n data-testid={tid('restart')}\n >\n {l.restart}\n </Button>\n </Card>\n ))\n ) : step ? (\n <div key={step.id} className=\"space-y-3\">\n {run.phaseOf(step.id) === 'blocked' ? (\n <Card className=\"max-w-2xl p-6\" data-testid={tid(step.id)}>\n <p className=\"text-sm text-muted-foreground\" data-testid={tid(`${step.id}-blocked`)}>\n {l.blocked.replace(\n '{steps}',\n stepDependencies(steps, step.id)\n .map((d) => steps.find((s) => s.id === d)?.title ?? d)\n .join(', ')\n )}\n </p>\n </Card>\n ) : step.kind === 'form' ? (\n <Card className=\"max-w-2xl space-y-4 p-6\" data-testid={tid(step.id)}>\n <StepHeading step={step} icon={icon(step.icon)} testId={tid(`${step.id}-title`)} />\n <fieldset disabled={run.isLocked(step.id)} className=\"contents\">\n <SchemaForm\n fields={step.inputs}\n values={run.inputs}\n onChange={run.setInput}\n errors={run.errors}\n renderScope={renderScope}\n renderDocuments={renderDocuments}\n renderIcon={renderIcon}\n onEnterSubmit={() => void run.next()}\n testIdPrefix={tid('field')}\n />\n </fieldset>\n {run.actionError && (\n <p className=\"text-sm text-destructive\" data-testid={tid('action-error')}>\n {run.actionError}\n </p>\n )}\n {renderStepNote?.(step, run)}\n </Card>\n ) : step.kind === 'upload' ? (\n <Card className=\"max-w-2xl space-y-4 p-6\" data-testid={tid(step.id)}>\n {renderUpload?.(step) ?? (\n <>\n <UploadDropzone\n onFiles={(picked) => void onUpload?.(picked, step)}\n uploading={uploading}\n disabled={!onUpload}\n accept={step.accept}\n title={step.title}\n description={step.description}\n hint={step.hint}\n testId={tid(`${step.id}-drop`)}\n />\n {files && (\n <UploadFiles\n added={added}\n others={files.filter((f) => f.addedFor !== step.id)}\n l={l}\n testId={tid(`${step.id}-files`)}\n />\n )}\n </>\n )}\n {run.actionError && <p className=\"text-sm text-destructive\">{run.actionError}</p>}\n {renderStepNote?.(step, run)}\n </Card>\n ) : step.kind === 'review' ? (\n <Card className=\"max-w-2xl space-y-4 p-6\" data-testid={tid(step.id)}>\n <StepHeading step={step} icon={icon(step.icon)} />\n <p className=\"whitespace-pre-line text-sm text-muted-foreground\">\n {reviewInstructions(step, run.inputs)}\n </p>\n <p className=\"text-sm\" data-testid={tid(`${step.id}-status`)}>\n {run.phaseOf(step.id) === 'done'\n ? l.approved\n : run.phaseOf(step.id) === 'skipped'\n ? l.skipped\n : l.awaitingReview}\n </p>\n {run.phaseOf(step.id) === 'ready' && renderReview?.(step)}\n {run.actionError && <p className=\"text-sm text-destructive\">{run.actionError}</p>}\n {renderStepNote?.(step, run)}\n </Card>\n ) : (\n <AgentStepBody\n step={step}\n run={run}\n renderAgentOutput={renderAgentOutput}\n icon={icon(step.icon)}\n renderStepNote={renderStepNote}\n l={l}\n tid={tid}\n />\n )}\n </div>\n ) : null}\n\n {!isComplete && (\n <div className=\"flex items-center justify-between border-t border-border pt-4\">\n <Button\n variant=\"ghost\"\n onClick={run.back}\n disabled={!run.canBack}\n data-testid={tid('back')}\n >\n <ArrowLeft className=\"size-4\" /> {l.back}\n </Button>\n <div className=\"flex items-center gap-2\">\n {step &&\n action !== 'skip' &&\n // A step that commits (creates the matter, starts the thread) is what the run stands on.\n !step.commit &&\n ['ready', 'blocked', 'failed'].includes(run.phaseOf(step.id)) && (\n <Button\n variant=\"ghost\"\n onClick={() => void run.skip(step.id)}\n disabled={run.busy}\n data-testid={tid('skip-step')}\n >\n {l.skipStep}\n </Button>\n )}\n <Button\n onClick={() => void run.next()}\n disabled={action === 'wait' || reading}\n data-testid={tid('next')}\n >\n {nextLabel}\n {reading || (action === 'wait' && (run.isRunning || run.busy)) ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <ArrowRight className=\"size-4\" />\n )}\n </Button>\n </div>\n </div>\n )}\n </div>\n )\n}\n\n/** What the upload step lists: this step's files first, with their status; the rest folded. */\nfunction UploadFiles({\n added,\n others,\n l,\n testId,\n}: {\n added: WorkflowRunnerFile[]\n others: WorkflowRunnerFile[]\n l: WorkflowRunnerLabels\n testId: string\n}) {\n const heading = 'text-xs font-semibold uppercase tracking-wide text-muted-foreground'\n const row = (f: WorkflowRunnerFile) => (\n <div\n key={f.id}\n className=\"flex items-center gap-2 text-sm text-muted-foreground\"\n data-status={f.status}\n data-testid={`${testId}-file-${f.id}`}\n >\n <FileText className=\"size-3.5 shrink-0 text-primary\" />\n <span className=\"min-w-0 flex-1 truncate\" title={f.name}>\n {f.name}\n </span>\n {f.status === 'processing' && (\n <span className=\"flex shrink-0 items-center gap-1 text-xs\">\n <Loader2 className=\"size-3 animate-spin\" /> {l.fileReading}\n </span>\n )}\n {f.status === 'ready' && (\n <span className=\"flex shrink-0 items-center gap-1 text-xs text-primary\">\n <Check className=\"size-3\" /> {l.fileReady}\n </span>\n )}\n {f.status === 'failed' && (\n <span className=\"flex shrink-0 items-center gap-1 text-xs text-destructive\">\n <AlertTriangle className=\"size-3\" /> {l.fileFailed}\n </span>\n )}\n </div>\n )\n return (\n <div className=\"space-y-3\" data-testid={testId}>\n {added.length > 0 && (\n <div className=\"space-y-1\" data-testid={`${testId}-added`}>\n <p className={heading}>{l.addedHeading.replace('{count}', String(added.length))}</p>\n {added.map(row)}\n </div>\n )}\n {added.length === 0 && others.length === 0 && (\n <p className=\"text-sm text-muted-foreground\">{l.noFiles}</p>\n )}\n {others.length > 0 && (\n <details className=\"space-y-1\" data-testid={`${testId}-others`}>\n <summary className={cn(heading, 'cursor-pointer select-none')}>\n {l.filesHeading.replace('{count}', String(others.length))}\n </summary>\n <div className=\"mt-1 max-h-48 space-y-1 overflow-y-auto\">{others.map(row)}</div>\n </details>\n )}\n </div>\n )\n}\n\nfunction StepHeading({\n step,\n icon,\n testId,\n}: {\n step: WorkflowStep\n icon?: ReactNode\n testId?: string\n}) {\n return (\n <div className=\"min-w-0\">\n <p className=\"flex items-center gap-2 text-sm font-medium\" data-testid={testId}>\n {icon && (\n <span className=\"flex size-4 items-center justify-center text-primary [&_svg]:size-4\">\n {icon}\n </span>\n )}\n {step.title}\n </p>\n {step.description && <p className=\"mt-1 text-xs text-muted-foreground\">{step.description}</p>}\n </div>\n )\n}\n\n/** m:ss (h:mm:ss past an hour). */\nexport function formatElapsed(ms: number): string {\n const total = Math.max(0, Math.floor(ms / 1000))\n const h = Math.floor(total / 3600)\n const m = Math.floor((total % 3600) / 60)\n const sec = String(total % 60).padStart(2, '0')\n return h ? `${h}:${String(m).padStart(2, '0')}:${sec}` : `${m}:${sec}`\n}\n\n/** \"<title>… 0:42\": the running step and how long it has run, ticking. */\nfunction StepWorking({ title, since, label }: { title: string; since?: string; label: string }) {\n // Without the server's start time, from when this screen first saw it running.\n const seen = useRef(Date.now())\n const start = (since && Date.parse(since)) || seen.current\n const [now, setNow] = useState(() => Date.now())\n useEffect(() => {\n const t = setInterval(() => setNow(Date.now()), 1000)\n return () => clearInterval(t)\n }, [])\n return (\n <span>{label.replace('{step}', title).replace('{elapsed}', formatElapsed(now - start))}</span>\n )\n}\n\nfunction AgentStepBody({\n step,\n run,\n renderAgentOutput,\n icon,\n renderStepNote,\n l,\n tid,\n}: {\n step: WorkflowAgentStep\n run: WorkflowRunView\n renderAgentOutput: WorkflowRunnerProps['renderAgentOutput']\n icon?: ReactNode\n renderStepNote?: WorkflowRunnerProps['renderStepNote']\n l: WorkflowRunnerLabels\n tid: (suffix: string) => string\n}) {\n const state = run.stateOf(step.id)\n const phase = run.phaseOf(step.id)\n const header = (\n <div className=\"flex items-start justify-between gap-3\">\n <StepHeading step={step} icon={icon} />\n {phase === 'failed' && (\n <div className=\"flex shrink-0 items-center gap-2\">\n {run.retry && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void run.retry?.(step.id)}\n disabled={run.busy}\n data-testid={tid(`${step.id}-retry`)}\n >\n <RotateCw className=\"size-4\" /> {l.retry}\n </Button>\n )}\n </div>\n )}\n </div>\n )\n const status = (\n <div className=\"space-y-1\">\n {step.branch && (\n <p className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n <GitBranch className=\"size-3.5\" /> {l.branch}\n </p>\n )}\n {(phase === 'ready' || phase === 'running') && !state?.text && (\n <p\n className=\"flex items-center gap-2 text-sm text-muted-foreground\"\n data-testid={tid(`${step.id}-working`)}\n >\n <Loader2 className=\"size-4 animate-spin\" />{' '}\n {phase === 'ready' ? (\n l.starting\n ) : (\n <StepWorking title={step.title} since={state?.startedAt} label={l.stepWorking} />\n )}\n </p>\n )}\n {phase === 'failed' && (\n <p className=\"text-sm text-destructive\" data-testid={tid(`${step.id}-failed`)}>\n {state?.error || l.failed}\n </p>\n )}\n {phase === 'skipped' && <p className=\"text-sm text-muted-foreground\">{l.skipped}</p>}\n </div>\n )\n\n if (step.output === 'artifact') {\n return (\n <div\n className=\"grid gap-4 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]\"\n data-testid={tid(step.id)}\n >\n <Card className=\"h-fit space-y-3 p-5\">\n {header}\n {status}\n {renderStepNote?.(step, run)}\n </Card>\n <div className=\"min-w-0\">{renderAgentOutput(step, state)}</div>\n </div>\n )\n }\n return (\n <Card className=\"space-y-3 p-6\" data-testid={tid(step.id)}>\n {header}\n {status}\n {renderAgentOutput(step, state)}\n {renderStepNote?.(step, run)}\n </Card>\n )\n}\n"]}
|