feat(webui): read the derived resource schema in the document editor
The control-plane descriptors now derive a JSON Schema from the Go type of
the document they describe (a19cd24b), and nothing consumed it: the editor
rendered dashed keys, guessed no format, and synthesised a new row from a
literal skeleton per array path.
A pure reader (settings/resource-schema.ts) resolves the schema node for an
editor path -- nested keys, array items, and a keyed collection's
additionalProperties -- and the editor uses it for labels (title ahead of
the dashed-key fallback), a duration placeholder, a hint when the schema
carries prose, and the shape of a new row. A descriptor with no schema, or
one describing nothing, renders exactly as before.
Deletes ControlPlaneResourceCard.vue: 121 lines, zero references, the
abandoned schema-driven card and the only other consumer of schema_json.
This commit is contained in:
6 files changed
+315
-149
No files matched your search
Vendored
+2
-2
@@ -15,5 +15,5 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
|
||||
Defaulting to \`null\`.`),null)}function Tx(e){return Cx(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${bx}\`.`),bx)}var Ex=N({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:bx},getValueLabel:{type:Function,required:!1,default:(e,t)=>Cx(e)?`${Math.round(e/t*bx)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;X();let i=yh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=yh(n,`max`,r,{passive:n.max===void 0});M(()=>i.value,async e=>{let t=wx(e,n.max);t!==e&&(await ar(),i.value=t)},{immediate:!0}),M(()=>n.max,e=>{let t=Tx(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=G(()=>Um(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return Sx({modelValue:i,max:a,progressState:o}),(e,t)=>(L(),z(A(Z),{"as-child":e.asChild,as:e.as,"aria-valuemax":A(a),"aria-valuemin":0,"aria-valuenow":Cx(A(i))?A(i):void 0,"aria-valuetext":e.getValueText?.(A(i),A(a)),"aria-label":e.getValueLabel(A(i),A(a)),role:`progressbar`,"data-state":o.value,"data-value":A(i)??void 0,"data-max":A(a)},{default:j(()=>[F(e.$slots,`default`,{modelValue:A(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),Dx=N({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=xx();return X(),(e,r)=>(L(),z(A(Z),W(t,{"data-state":A(n).progressState.value,"data-value":A(n).modelValue?.value??void 0,"data-max":A(n).max.value}),{default:j(()=>[F(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),Ox=[` `,`Enter`,`ArrowUp`,`ArrowDown`],kx=[` `,`Enter`];function Ax(e,t,n){return e===void 0?!1:Array.isArray(e)?e.some(e=>jx(e,t,n)):jx(e,t,n)}function jx(e,t,n){return e===void 0||t===void 0?!1:typeof e==`string`?e===t:typeof n==`function`?n(e,t):typeof n==`string`?e?.[n]===t?.[n]:Rm(e,t)}function Mx(e){return e==null||e===``||Array.isArray(e)&&e.length===0}var Nx=[`value`],[Px,Fx]=Bm(`SelectRoot`),Ix=N({inheritAttrs:!1,__name:`SelectRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},nullableValue:{type:String,required:!1,default:``},by:{type:[String,Function],required:!1},dir:{type:String,required:!1},multiple:{type:Boolean,required:!1},autocomplete:{type:String,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`,`update:open`],setup(e,{emit:t}){let n=e,r=t,{required:i,disabled:a,multiple:o,dir:s}=En(n),c=yh(n,`modelValue`,r,{defaultValue:n.defaultValue??(o.value?[]:void 0),passive:n.modelValue===void 0,deep:!0}),l=yh(n,`open`,r,{defaultValue:n.defaultOpen,passive:n.open===void 0}),u=k(),d=k(),f=k({x:0,y:0}),p=G(()=>o.value&&Array.isArray(c.value)?c.value?.length===0:Um(c.value));D_({isProvider:!0});let m=Fh(s),h=Bh(u),g=k(new Set),_=G(()=>Array.from(g.value).map(e=>e.value).join(`;`));function v(e){if(o.value){let t=Array.isArray(c.value)?[...c.value]:[],r=t.findIndex(t=>jx(t,e,n.by));r===-1?t.push(e):t.splice(r,1),c.value=[...t]}else c.value=e}function y(e){return Array.from(g.value).find(t=>Ax(e,t.value,n.by))}return Fx({triggerElement:u,onTriggerChange:e=>{u.value=e},valueElement:d,onValueElementChange:e=>{d.value=e},contentId:``,modelValue:c,onValueChange:v,by:n.by,open:l,multiple:o,required:i,onOpenChange:e=>{l.value=e},dir:m,triggerPointerDownPosRef:f,disabled:a,isEmptyModelValue:p,optionsSet:g,onOptionAdd:e=>{let t=y(e.value);t&&g.value.delete(t),g.value.add(e)},onOptionRemove:e=>{let t=y(e.value);t&&g.value.delete(t)}}),(e,t)=>(L(),z(A(B_),null,{default:j(()=>[F(e.$slots,`default`,{modelValue:A(c),open:A(l)}),A(h)&&e.name?(L(),z(Lx,{key:_.value,"aria-hidden":`true`,tabindex:`-1`,multiple:A(o),required:A(i),name:e.name,autocomplete:e.autocomplete,disabled:A(a),value:A(c)},{default:j(()=>[A(Um)(A(c))?(L(),R(`option`,{key:0,value:e.nullableValue},null,8,Nx)):U(`v-if`,!0),(L(!0),R(I,null,P(Array.from(g.value),e=>(L(),R(`option`,W({key:e.value??``},{ref_for:!0},e),null,16))),128))]),_:1},8,[`multiple`,`required`,`name`,`autocomplete`,`disabled`,`value`])):U(`v-if`,!0)]),_:3}))}}),Lx=N({__name:`BubbleSelect`,props:{autocomplete:{type:String,required:!1},autofocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},form:{type:String,required:!1},multiple:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},size:{type:Number,required:!1},value:{type:null,required:!1}},setup(e){let t=e,n=k(),r=Px();M(()=>t.value,(e,t)=>{let r=window.HTMLSelectElement.prototype,i=Object.getOwnPropertyDescrLine truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:nT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>nT(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=iT(c),u=e+1<n.length?iT(n[e+1]):null;if(l&&u&&aT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=iT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>nT(e)),rows:r.map(e=>e.map(e=>nT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:nT(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:nT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function iT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function aT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var oT={class:`[overflow-wrap:anywhere]`},sT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},cT={class:`font-mono text-[0.85em]`},lT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},uT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},dT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},fT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},pT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},mT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},hT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},gT={key:8,class:`mb-2.5 last:mb-0`},_T=N({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>rT(t.text));return(e,t)=>(L(),R(`div`,oT,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,sT,[B(`code`,cT,O(e.code),1)])):e.kind===`table`?(L(),R(`table`,lT,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(eT,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(eT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,uT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,dT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,fT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,pT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,mT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,hT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,gT,[V(eT,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),vT={class:`truncate`},yT=N({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:j(()=>[V(A(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,vT,O(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),bT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},xT={class:`font-semibold text-foreground`},ST={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},CT=N({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(yT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,bT,[V(A(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,xT,O(n.value),1),r.value?(L(),R(`code`,ST,O(r.value),1)):U(``,!0),B(`span`,{class:D(A(J)(`text-fg-muted`,i.value&&`text-danger`))},O(a.value),3)]))}}),wT={key:0,class:`mb-2 grid gap-0.5 text-xs`},TT={key:2,class:`whitespace-pre-wrap`},ET=N({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:D([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:D(A(J)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,wT,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(CT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.assistant?(L(),z(_T,{key:1,text:e.text},null,8,[`text`])):(L(),R(`div`,TT,O(e.text),1)),F(t.$slots,`default`)],2)],2))}}),DT={class:`w-full self-center justify-self-center py-6 text-center`},OT={class:`grid gap-2`},kT=[`onClick`],AT=N({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(L(),R(`div`,DT,[t[0]||=B(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>_j?`${n.slice(0,_j).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var yj=[`title`],bj=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>HA(n.event)),a=G(()=>vj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?ak(n.event.at):`—`);return(e,t)=>(L(),z(A(IO),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,yj)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),xj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},Sj=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(JD());function a(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(_O),null,{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...t[1]||=[H(`Last 50, newest first`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[V(A(zO),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[B(`div`,xj,[V(A(PO),null,{default:j(()=>[V(A(RO),null,{default:j(()=>[V(A(IO),null,{default:j(()=>[V(A(LO),null,{default:j(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(FO),null,{default:j(()=>[A(n).length?(L(!0),R(I,{key:1},P(A(n),(e,t)=>(L(),z(bj,{key:t,event:e,onOpen:a},null,8,[`event`]))),128)):(L(),z(A(IO),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(wO),null,{default:j(()=>[V(A(DO),null,{default:j(()=>[V(A(AO),null,{default:j(()=>[...t[6]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})]),_:1})])]),_:1})]),_:1}))}}),Cj=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Dx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`transform: translateX(-${100-(t.modelValue??0)}%);`)},null,8,[`style`])]),_:1},16,[`class`]))}}),wj=`archie.setup-complete.dismissed.v1`;function Tj(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(wj),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Ej(e=globalThis.localStorage){e?.setItem?.(wj,`1`)}var Dj={class:`text-lg font-semibold text-link`},Oj={class:`flex flex-col gap-3`},kj={key:0,class:`mt-0.5 text-xs text-fg-subtle`},Aj=N({__name:`SetupPanel`,setup(e){let t=k(Tj(FA.value));M(FA,()=>{t.value=Tj(FA.value)});let n=G(()=>FA.value?.steps??[]),r=G(()=>{let e=n.value.length;return e?Math.round((e-t.value.remaining.length)/e*100):0});function i(){Ej(),t.value=Tj(FA.value)}return(e,a)=>t.value.kind===`incomplete`?(L(),z(A(_O),{key:0},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[0]||=[H(`Finish setting up`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...a[1]||=[H(`Archie needs these before it can work on its own.`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[B(`span`,Dj,O(r.value)+`%`,1)]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[V(A(Cj),{"model-value":r.value,class:`mb-4`},null,8,[`model-value`]),B(`ul`,Oj,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(`li`,{key:t,class:`flex items-start gap-3`},[B(`span`,{class:D([`mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle`,e.done?`border-transparent bg-ok-soft text-ok`:``])},[e.done?(L(),z(A(bd),{key:0,class:`size-3`})):U(``,!0)],2),B(`div`,null,[B(`div`,{class:D([`text-sm`,e.done?`text-fg-muted line-through`:``])},O(e.title),3),e.detail?(L(),R(`div`,kj,O(e.detail),1)):U(``,!0)])]))),128))])]),_:1})]),_:1})):t.value.kind===`complete`?(L(),z(A(_O),{key:1},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[2]||=[H(`Setup complete`Line truncated
|
||||
`)}),t}function iT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function aT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var oT={class:`[overflow-wrap:anywhere]`},sT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},cT={class:`font-mono text-[0.85em]`},lT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},uT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},dT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},fT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},pT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},mT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},hT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},gT={key:8,class:`mb-2.5 last:mb-0`},_T=N({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>rT(t.text));return(e,t)=>(L(),R(`div`,oT,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,sT,[B(`code`,cT,O(e.code),1)])):e.kind===`table`?(L(),R(`table`,lT,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(eT,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(eT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,uT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,dT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,fT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,pT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,mT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,hT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,gT,[V(eT,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),vT={class:`truncate`},yT=N({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:j(()=>[V(A(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,vT,O(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),bT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},xT={class:`font-semibold text-foreground`},ST={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},CT=N({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(yT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,bT,[V(A(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,xT,O(n.value),1),r.value?(L(),R(`code`,ST,O(r.value),1)):U(``,!0),B(`span`,{class:D(A(J)(`text-fg-muted`,i.value&&`text-danger`))},O(a.value),3)]))}}),wT={key:0,class:`mb-2 grid gap-0.5 text-xs`},TT={key:2,class:`whitespace-pre-wrap`},ET=N({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:D([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:D(A(J)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,wT,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(CT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.assistant?(L(),z(_T,{key:1,text:e.text},null,8,[`text`])):(L(),R(`div`,TT,O(e.text),1)),F(t.$slots,`default`)],2)],2))}}),DT={class:`w-full self-center justify-self-center py-6 text-center`},OT={class:`grid gap-2`},kT=[`onClick`],AT=N({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(L(),R(`div`,DT,[t[0]||=B(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>Ej?`${n.slice(0,Ej).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var Oj=[`title`],kj=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>ZA(n.event)),a=G(()=>Dj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?ak(n.event.at):`—`);return(e,t)=>(L(),z(A(IO),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,Oj)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),Aj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},jj=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(JD());function a(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(_O),null,{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...t[1]||=[H(`Last 50, newest first`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[V(A(zO),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[B(`div`,Aj,[V(A(PO),null,{default:j(()=>[V(A(RO),null,{default:j(()=>[V(A(IO),null,{default:j(()=>[V(A(LO),null,{default:j(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(FO),null,{default:j(()=>[A(n).length?(L(!0),R(I,{key:1},P(A(n),(e,t)=>(L(),z(kj,{key:t,event:e,onOpen:a},null,8,[`event`]))),128)):(L(),z(A(IO),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(wO),null,{default:j(()=>[V(A(DO),null,{default:j(()=>[V(A(AO),null,{default:j(()=>[...t[6]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})]),_:1})])]),_:1})]),_:1}))}}),Mj=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Dx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`transform: translateX(-${100-(t.modelValue??0)}%);`)},null,8,[`style`])]),_:1},16,[`class`]))}}),Nj=`archie.setup-complete.dismissed.v1`;function Pj(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(Nj),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Fj(e=globalThis.localStorage){e?.setItem?.(Nj,`1`)}var Ij={class:`text-lg font-semibold text-link`},Lj={class:`flex flex-col gap-3`},Rj={key:0,class:`mt-0.5 text-xs text-fg-subtle`},zj=N({__name:`SetupPanel`,setup(e){let t=k(Pj(WA.value));M(WA,()=>{t.value=Pj(WA.value)});let n=G(()=>WA.value?.steps??[]),r=G(()=>{let e=n.value.length;return e?Math.round((e-t.value.remaining.length)/e*100):0});function i(){Fj(),t.value=Pj(WA.value)}return(e,a)=>t.value.kind===`incomplete`?(L(),z(A(_O),{key:0},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[0]||=[H(`Finish setting up`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...a[1]||=[H(`Archie needs these before it can work on its own.`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[B(`span`,Ij,O(r.value)+`%`,1)]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[V(A(Mj),{"model-value":r.value,class:`mb-4`},null,8,[`model-value`]),B(`ul`,Lj,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(`li`,{key:t,class:`flex items-start gap-3`},[B(`span`,{class:D([`mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle`,e.done?`border-transparent bg-ok-soft text-ok`:``])},[e.done?(L(),z(A(bd),{key:0,class:`size-3`})):U(``,!0)],2),B(`div`,null,[B(`div`,{class:D([`text-sm`,e.done?`text-fg-muted line-through`:``])},O(e.title),3),e.detail?(L(),R(`div`,Rj,O(e.detail),1)):U(``,!0)])]))),128))])]),_:1})]),_:1})):t.value.kind===`complete`?(L(),z(A(_O),{key:1},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[2]||=[H(`Setup complete`Line truncated
|
||||
@@ -1,121 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, watch } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Field, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { useControlPlaneStore, type ResourceDescriptor } from "@/stores/control-plane";
|
||||
import ApplyStatusRows from "./ApplyStatusRows.vue";
|
||||
import ConfigCard from "./ConfigCard.vue";
|
||||
import ResourceHistory from "./ResourceHistory.vue";
|
||||
|
||||
interface JSONSchemaProperty {
|
||||
type?: "integer" | "number" | "string" | "boolean";
|
||||
title?: string;
|
||||
description?: string;
|
||||
minimum?: number;
|
||||
maximum?: number;
|
||||
enum?: Array<string | number>;
|
||||
}
|
||||
|
||||
const props = defineProps<{ descriptor: ResourceDescriptor }>();
|
||||
const store = useControlPlaneStore();
|
||||
const state = computed(() => store.stateFor(props.descriptor.kind));
|
||||
const draft = reactive<Record<string, unknown>>({});
|
||||
const touched = reactive<Record<string, boolean>>({});
|
||||
|
||||
const schema = computed(() => {
|
||||
try { return JSON.parse(props.descriptor.schema_json) as { properties?: Record<string, JSONSchemaProperty> }; }
|
||||
catch { return {}; }
|
||||
});
|
||||
const fields = computed(() => Object.entries(schema.value.properties ?? {}));
|
||||
|
||||
watch(() => state.value.resource, (resource) => {
|
||||
if (!resource) return;
|
||||
for (const key of Object.keys(draft)) delete draft[key];
|
||||
Object.assign(draft, resource.value as Record<string, unknown>);
|
||||
}, { immediate: true });
|
||||
|
||||
function label(key: string, property: JSONSchemaProperty): string {
|
||||
if (property.title) return property.title;
|
||||
const taskLabels: Record<string, string> = {
|
||||
max_model_tool_steps: "Max model steps",
|
||||
max_runtime_seconds: "Max runtime (seconds)",
|
||||
max_consecutive_gate_failures: "Max gate failures",
|
||||
};
|
||||
return taskLabels[key] ?? key.replaceAll("_", " ").replace(/^./, (value) => value.toUpperCase());
|
||||
}
|
||||
|
||||
function update(key: string, property: JSONSchemaProperty, value: unknown): void {
|
||||
touched[key] = true;
|
||||
if (property.type === "integer" || property.type === "number") draft[key] = Number(value);
|
||||
else if (property.type === "boolean") draft[key] = value === true || value === "true";
|
||||
else draft[key] = value;
|
||||
}
|
||||
|
||||
function invalid(key: string, property: JSONSchemaProperty): boolean {
|
||||
if (!touched[key]) return false;
|
||||
const value = draft[key];
|
||||
if ((property.type === "integer" || property.type === "number") && !Number.isFinite(value)) return true;
|
||||
if (typeof value === "number" && property.minimum !== undefined && value < property.minimum) return true;
|
||||
if (typeof value === "number" && property.maximum !== undefined && value > property.maximum) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
async function save(): Promise<void> {
|
||||
for (const [key] of fields.value) touched[key] = true;
|
||||
if (fields.value.some(([key, property]) => invalid(key, property))) return;
|
||||
if (await store.replace(props.descriptor.kind, { ...draft })) {
|
||||
for (const key of Object.keys(touched)) touched[key] = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ConfigCard :title="descriptor.title">
|
||||
<form class="flex flex-col gap-5" @submit.prevent="save">
|
||||
<FieldGroup>
|
||||
<Field v-for="[key, property] in fields" :key="key" :data-invalid="invalid(key, property)">
|
||||
<FieldLabel :for="`${descriptor.kind}-${key}`">{{ label(key, property) }}</FieldLabel>
|
||||
<Select v-if="property.type === 'boolean' || property.enum" :model-value="String(draft[key])" @update:model-value="update(key, property, $event)">
|
||||
<SelectTrigger :id="`${descriptor.kind}-${key}`" :aria-invalid="invalid(key, property)"><SelectValue /></SelectTrigger>
|
||||
<SelectContent><SelectGroup>
|
||||
<SelectItem v-for="option in property.enum ?? ['true', 'false']" :key="String(option)" :value="String(option)">{{ option }}</SelectItem>
|
||||
</SelectGroup></SelectContent>
|
||||
</Select>
|
||||
<Input
|
||||
v-else
|
||||
:id="`${descriptor.kind}-${key}`"
|
||||
:model-value="draft[key] as string | number"
|
||||
:type="property.type === 'integer' || property.type === 'number' ? 'number' : 'text'"
|
||||
:min="property.minimum"
|
||||
:max="property.maximum"
|
||||
:step="property.type === 'integer' ? 1 : undefined"
|
||||
:aria-invalid="invalid(key, property)"
|
||||
autocomplete="off"
|
||||
@update:model-value="update(key, property, $event)"
|
||||
/>
|
||||
<FieldDescription v-if="property.description">{{ property.description }}</FieldDescription>
|
||||
<FieldDescription v-if="invalid(key, property)" class="text-destructive">Enter a valid value.</FieldDescription>
|
||||
</Field>
|
||||
</FieldGroup>
|
||||
<p v-if="state.error" class="text-sm text-destructive" role="alert">{{ state.error }}</p>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<Badge :variant="state.stream === 'live' ? 'ok' : 'warn'">{{ state.stream === 'live' ? 'Live' : 'Connecting' }}</Badge>
|
||||
<Badge v-if="descriptor.apply_mode === 'restart-required'" variant="warn">Restart required</Badge>
|
||||
<span v-if="state.resource" class="text-xs text-muted-foreground">Version {{ state.resource.version }}</span>
|
||||
</div>
|
||||
<Button type="submit" :disabled="state.saving || state.loading">
|
||||
<Spinner v-if="state.saving" data-icon="inline-start" />
|
||||
Save changes
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
<ApplyStatusRows :kind="descriptor.kind" />
|
||||
<ResourceHistory :kind="descriptor.kind" />
|
||||
</ConfigCard>
|
||||
</template>
|
||||
@@ -8,12 +8,19 @@ import { cloneControlPlaneValue, useControlPlaneStore, type ResourceDescriptor }
|
||||
import ConfigCard from "./ConfigCard.vue";
|
||||
import ResourceHistory from "./ResourceHistory.vue";
|
||||
import StructuredValueEditor from "./StructuredValueEditor.vue";
|
||||
import { parseSchema } from "./resource-schema";
|
||||
|
||||
const props = defineProps<{ descriptor: ResourceDescriptor; rootPath?: string }>();
|
||||
const store = useControlPlaneStore();
|
||||
const state = computed(() => store.stateFor(props.descriptor.kind));
|
||||
const draft = ref<unknown>({});
|
||||
|
||||
// The schema the descriptor derives from its document type: the editor reads
|
||||
// it for labels, hints, formatted placeholders and the shape of a new row. A
|
||||
// descriptor that carries none reads as null, and the editor falls back to
|
||||
// rendering the value alone.
|
||||
const schema = computed(() => parseSchema(props.descriptor.schema_json));
|
||||
|
||||
watch(() => state.value.resource, (resource) => {
|
||||
if (resource) draft.value = cloneControlPlaneValue(resource.value);
|
||||
}, { immediate: true });
|
||||
@@ -26,7 +33,12 @@ async function save(): Promise<void> {
|
||||
<template>
|
||||
<ConfigCard :title="descriptor.title">
|
||||
<form class="space-y-5" @submit.prevent="save">
|
||||
<StructuredValueEditor v-model="draft" :path="rootPath ?? descriptor.kind" />
|
||||
<StructuredValueEditor
|
||||
v-model="draft"
|
||||
:path="rootPath ?? descriptor.kind"
|
||||
:root-path="rootPath ?? descriptor.kind"
|
||||
:schema="schema"
|
||||
/>
|
||||
<p v-if="state.error" class="text-sm text-destructive" role="alert">{{ state.error }}</p>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
@@ -7,12 +7,26 @@ import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { blankFromSchema, fieldHint, fieldPlaceholder, fieldTitle, schemaAt, type SchemaProperty } from "./resource-schema";
|
||||
|
||||
/**
|
||||
* The document editor, driven by the value it was given and annotated by the
|
||||
* schema the descriptor carries.
|
||||
*
|
||||
* The value decides which fields exist (this walks what is stored, so a
|
||||
* document with a field the schema has not caught up with still edits); the
|
||||
* schema decides what those fields are called, what example a formatted field
|
||||
* shows, what prose qualifies it, and what a newly added row starts as. A
|
||||
* descriptor with no schema, or one describing nothing, renders exactly as it
|
||||
* did before there was a reader.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue: unknown;
|
||||
path?: string;
|
||||
rootPath?: string;
|
||||
schema?: SchemaProperty | null;
|
||||
locked?: boolean;
|
||||
}>(), { path: "value", locked: false });
|
||||
}>(), { path: "value", rootPath: "", schema: null, locked: false });
|
||||
const emit = defineEmits<{ "update:modelValue": [value: unknown] }>();
|
||||
|
||||
const isArray = computed(() => Array.isArray(props.modelValue));
|
||||
@@ -20,6 +34,12 @@ const isObject = computed(() => props.modelValue !== null && typeof props.modelV
|
||||
const entries = computed(() => Object.entries((props.modelValue ?? {}) as Record<string, unknown>));
|
||||
const readOnly = computed(() => props.locked || /(^|\.)(has_credential|credential_configured|headers_configured)$/.test(props.path));
|
||||
|
||||
/** The schema node for this editor, and for one of its keys. */
|
||||
const property = computed(() => schemaAt(props.schema, props.path, props.rootPath));
|
||||
function propertyFor(key: string): SchemaProperty | null {
|
||||
return schemaAt(props.schema, `${props.path}.${key}`, props.rootPath);
|
||||
}
|
||||
|
||||
function label(value: string): string {
|
||||
return value.replaceAll("_", " ").replace(/^./, (character) => character.toUpperCase());
|
||||
}
|
||||
@@ -55,28 +75,13 @@ function setArray(index: number, value: unknown): void {
|
||||
emit("update:modelValue", current);
|
||||
}
|
||||
|
||||
// A new row comes from the schema rather than from the path that holds it: the
|
||||
// editor used to carry a literal skeleton per array path (a repository, an MCP
|
||||
// server), which went stale the moment the document changed and said nothing
|
||||
// about fields it did not know.
|
||||
function addArray(): void {
|
||||
const current = props.modelValue as unknown[];
|
||||
const sample = current[0];
|
||||
let value: unknown = Array.isArray(sample) ? [] : sample && typeof sample === "object" ? {} : "";
|
||||
if (props.path === "repositories") value = {
|
||||
owner: "", name: "", base: "main", gate: [], protect: [], ecosystem: "go", preflight: [], test_glob: "",
|
||||
persistent_storage: false, max_retries: 0, allow_concurrent: false, review_enabled: false,
|
||||
};
|
||||
else if (props.path.endsWith("mcp_servers")) value = {
|
||||
name: "", transport: "stdio", command: "", args: [], work_dir: "", url: "",
|
||||
sse_endpoint: "", message_endpoint: "", headers_configured: false,
|
||||
};
|
||||
else if (props.path.endsWith("gate") || props.path.endsWith("preflight")) value = [];
|
||||
else if (props.path.endsWith("allowed_user_ids")) value = 0;
|
||||
else if (props.path.endsWith("personas")) value = { name: "", prompt: "" };
|
||||
else if (props.path === "schedules") value = {
|
||||
id: "", pool: "sequential", detail: "", kind: "workflow",
|
||||
schedule: { kind: "interval", interval: 3600000000000, start: "0001-01-01T00:00:00Z" },
|
||||
target: {}, payload: { text: "" }, next_run: "0001-01-01T00:00:00Z",
|
||||
created: "0001-01-01T00:00:00Z", updated: "0001-01-01T00:00:00Z",
|
||||
};
|
||||
emit("update:modelValue", [...current, value]);
|
||||
emit("update:modelValue", [...current, blankFromSchema(property.value?.items)]);
|
||||
}
|
||||
|
||||
function removeArray(index: number): void {
|
||||
@@ -92,7 +97,13 @@ function scalar(value: string | number): void {
|
||||
<div v-if="isArray" class="space-y-2 rounded-lg border border-border/70 p-3">
|
||||
<div v-for="(item, index) in modelValue as unknown[]" :key="index" class="flex items-start gap-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<StructuredValueEditor :model-value="item" :path="`${path}.${index}`" @update:model-value="setArray(index, $event)" />
|
||||
<StructuredValueEditor
|
||||
:model-value="item"
|
||||
:path="`${path}.${index}`"
|
||||
:root-path="rootPath"
|
||||
:schema="schema"
|
||||
@update:model-value="setArray(index, $event)"
|
||||
/>
|
||||
</div>
|
||||
<Button type="button" variant="ghost" size="icon-sm" :aria-label="`Remove ${label(path)} row ${index + 1}`" @click="removeArray(index)">
|
||||
<Trash2 />
|
||||
@@ -104,13 +115,21 @@ function scalar(value: string | number): void {
|
||||
<fieldset v-else-if="isObject" class="space-y-4 rounded-lg border border-border/70 p-3">
|
||||
<div v-for="[key, value] in entries" :key="key" class="space-y-1.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<Label :for="`${path}.${key}`" class="flex-1">{{ label(key) }}</Label>
|
||||
<Label :for="`${path}.${key}`" class="flex-1">{{ fieldTitle(key, propertyFor(key)) }}</Label>
|
||||
<template v-if="path.endsWith('_map') || path.endsWith('labels') || path === 'providers' || path === 'roles'">
|
||||
<Input class="h-7 max-w-48" :model-value="key" aria-label="Entry key" @change="renameObject(key, ($event.target as HTMLInputElement).value)" />
|
||||
<Button type="button" variant="ghost" size="icon-sm" :aria-label="`Remove ${key}`" @click="removeObject(key)"><Trash2 /></Button>
|
||||
</template>
|
||||
</div>
|
||||
<StructuredValueEditor :id="`${path}.${key}`" :model-value="value" :path="`${path}.${key}`" @update:model-value="setObject(key, $event)" />
|
||||
<p v-if="fieldHint(propertyFor(key))" class="text-xs text-fg-subtle">{{ fieldHint(propertyFor(key)) }}</p>
|
||||
<StructuredValueEditor
|
||||
:id="`${path}.${key}`"
|
||||
:model-value="value"
|
||||
:path="`${path}.${key}`"
|
||||
:root-path="rootPath"
|
||||
:schema="schema"
|
||||
@update:model-value="setObject(key, $event)"
|
||||
/>
|
||||
</div>
|
||||
<Button v-if="path.endsWith('_map') || path.endsWith('labels') || path === 'providers' || path === 'roles'" type="button" variant="outline" size="sm" @click="addObject"><Plus /> Add entry</Button>
|
||||
</fieldset>
|
||||
@@ -120,5 +139,16 @@ function scalar(value: string | number): void {
|
||||
<span v-if="readOnly" class="text-xs text-muted-foreground">Reported by Archie</span>
|
||||
</div>
|
||||
<Textarea v-else-if="path.endsWith('.prompt')" :id="path" :model-value="modelValue as string" :readonly="readOnly" autocomplete="off" @update:model-value="scalar" />
|
||||
<Input v-else :id="path" :model-value="modelValue as string | number" :type="typeof modelValue === 'number' ? 'number' : 'text'" :readonly="readOnly" autocomplete="off" @update:model-value="scalar" />
|
||||
<div v-else class="space-y-1">
|
||||
<Input
|
||||
:id="path"
|
||||
:model-value="modelValue as string | number"
|
||||
:type="typeof modelValue === 'number' ? 'number' : 'text'"
|
||||
:readonly="readOnly"
|
||||
:placeholder="fieldPlaceholder(property)"
|
||||
autocomplete="off"
|
||||
@update:model-value="scalar"
|
||||
/>
|
||||
<p v-if="fieldHint(property)" class="text-xs text-fg-subtle">{{ fieldHint(property) }}</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* Reading the JSON Schema a control-plane descriptor advertises.
|
||||
*
|
||||
* The descriptor's schema is derived in internal/app/controlplane/schema.go
|
||||
* from the Go type of the document itself, so it is structure only: keys,
|
||||
* types, and the `format`/`title`/`doc` annotations a field declares in its own
|
||||
* tags. It carries no prose of its own -- field descriptions have one home in
|
||||
* internal/webui/config_schema.go -- so everything here treats a missing
|
||||
* annotation as absent rather than inventing one.
|
||||
*
|
||||
* The live editor is value-driven (it walks the document it was given), so this
|
||||
* is metadata layered onto fields that exist, never a field list. A document
|
||||
* whose schema describes no properties renders exactly as it did before.
|
||||
*/
|
||||
|
||||
/** One node of the derived schema. Only what the derivation emits is read. */
|
||||
export interface SchemaProperty {
|
||||
type?: string;
|
||||
format?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
properties?: Record<string, SchemaProperty>;
|
||||
items?: SchemaProperty;
|
||||
additionalProperties?: SchemaProperty | boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* parseSchema reads a descriptor's schema_json. A descriptor that carries none,
|
||||
* or carries one this reader cannot parse, reports null: an unreadable schema
|
||||
* costs a placeholder, never a field.
|
||||
*/
|
||||
export function parseSchema(json: string | null | undefined): SchemaProperty | null {
|
||||
if (!json) return null;
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(json);
|
||||
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
||||
return parsed as SchemaProperty;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function isKeyed(property: SchemaProperty): boolean {
|
||||
return property.type === "object" && !property.properties && typeof property.additionalProperties === "object";
|
||||
}
|
||||
|
||||
/**
|
||||
* schemaAt resolves the property that describes one editor path.
|
||||
*
|
||||
* Paths are the editor's own (`repositories.0.owner`): dotted, with an array
|
||||
* item addressed by its index. `rootPath` is stripped first, because the
|
||||
* editor's path starts at the document rather than inside it -- the schema
|
||||
* describes the document, not a field of it.
|
||||
*/
|
||||
export function schemaAt(
|
||||
schema: SchemaProperty | null,
|
||||
path: string,
|
||||
rootPath = "",
|
||||
): SchemaProperty | null {
|
||||
if (!schema) return null;
|
||||
const root = rootPath.split(".").filter(Boolean);
|
||||
let segments = path.split(".").filter(Boolean);
|
||||
if (root.length && root.every((segment, index) => segments[index] === segment)) {
|
||||
segments = segments.slice(root.length);
|
||||
}
|
||||
|
||||
let current: SchemaProperty | null = schema;
|
||||
for (const segment of segments) {
|
||||
if (!current) return null;
|
||||
if (/^\d+$/.test(segment)) {
|
||||
current = current.items ?? null;
|
||||
continue;
|
||||
}
|
||||
const named = current.properties?.[segment];
|
||||
if (named) {
|
||||
current = named;
|
||||
continue;
|
||||
}
|
||||
// A keyed collection's keys belong to the operator, so the value's
|
||||
// schema describes whatever key they typed.
|
||||
current = typeof current.additionalProperties === "object" ? current.additionalProperties : null;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/** fieldTitle is the schema's own label for a key, or the dashed-key fallback
|
||||
* the editor has always used. */
|
||||
export function fieldTitle(key: string, property: SchemaProperty | null | undefined): string {
|
||||
if (property?.title) return property.title;
|
||||
return key.replaceAll("_", " ").replace(/^./, (character) => character.toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* fieldPlaceholder offers an example only where the schema declares a format
|
||||
* the field's value must match. A duration column is a string to the document
|
||||
* and a duration to the operator, and the example is what says so.
|
||||
*/
|
||||
export function fieldPlaceholder(property: SchemaProperty | null | undefined): string | undefined {
|
||||
if (property?.format === "duration") return "1m0s";
|
||||
if (property?.format === "date-time") return "2026-01-01T00:00:00Z";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** fieldHint is the schema's own prose for a field, empty when it has none. */
|
||||
export function fieldHint(property: SchemaProperty | null | undefined): string {
|
||||
return property?.description ?? "";
|
||||
}
|
||||
|
||||
/** isKeyedCollection reports a document whose keys are the operator's: a map
|
||||
* with no fixed properties, which the schema marks with additionalProperties. */
|
||||
export function isKeyedCollection(property: SchemaProperty | null | undefined): boolean {
|
||||
return Boolean(property) && isKeyed(property as SchemaProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
* blankFromSchema synthesises a new row from the schema rather than from the
|
||||
* path that happens to hold it.
|
||||
*
|
||||
* The editor used to carry a literal template per array path -- a repository
|
||||
* skeleton, an MCP server skeleton -- which went stale the moment the document
|
||||
* was reshaped, and said nothing about the fields it did not know. A blank from
|
||||
* the schema cannot be stale, because the schema is derived from the document.
|
||||
* What it loses is the seeded convenience value (a default branch name, say):
|
||||
* a schema that wants those emits a default, which is the same single source of
|
||||
* truth this reader exists to honour.
|
||||
*/
|
||||
export function blankFromSchema(property: SchemaProperty | null | undefined): unknown {
|
||||
if (!property) return "";
|
||||
if (property.type === "object") {
|
||||
const blank: Record<string, unknown> = {};
|
||||
for (const [key, child] of Object.entries(property.properties ?? {})) {
|
||||
blank[key] = blankFromSchema(child);
|
||||
}
|
||||
return blank;
|
||||
}
|
||||
if (property.type === "array") return [];
|
||||
if (property.type === "boolean") return false;
|
||||
if (property.type === "integer" || property.type === "number") return 0;
|
||||
return "";
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const { blankFromSchema, fieldHint, fieldPlaceholder, fieldTitle, isKeyedCollection, parseSchema, schemaAt } = await import(
|
||||
"../src/settings/resource-schema.ts"
|
||||
);
|
||||
|
||||
// The shapes the control-plane descriptors actually advertise (derived in
|
||||
// internal/app/controlplane/schema.go), plus the two degenerate ones.
|
||||
const objectSchema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
email: { type: "object", properties: { listen_addr: { type: "string", title: "Listen address" } } },
|
||||
rate_limit: {
|
||||
type: "object",
|
||||
properties: {
|
||||
window: { type: "string", format: "duration" },
|
||||
max_requests: { type: "integer", description: "0 disables rate limiting." },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const arraySchema = {
|
||||
type: "array",
|
||||
items: { type: "object", properties: { owner: { type: "string" }, base: { type: "string" } } },
|
||||
};
|
||||
const keyedSchema = { type: "object", additionalProperties: { type: "object", properties: { class: { type: "string" } } } };
|
||||
const bareSchema = { type: "object" };
|
||||
|
||||
test("parseSchema tolerates a missing or unparseable schema", () => {
|
||||
assert.equal(parseSchema(undefined), null);
|
||||
assert.equal(parseSchema(""), null);
|
||||
assert.equal(parseSchema("{"), null);
|
||||
assert.deepEqual(parseSchema(JSON.stringify(bareSchema)), bareSchema);
|
||||
});
|
||||
|
||||
test("schemaAt walks nested fields, array items and keyed-collection values", () => {
|
||||
assert.deepEqual(schemaAt(objectSchema, "channel-settings.rate_limit.window", "channel-settings"), {
|
||||
type: "string",
|
||||
format: "duration",
|
||||
});
|
||||
assert.deepEqual(schemaAt(arraySchema, "repositories.0.owner", "repositories"), { type: "string" });
|
||||
assert.deepEqual(schemaAt(keyedSchema, "providers.anything.class", "providers"), { type: "string" });
|
||||
assert.deepEqual(schemaAt(objectSchema, "channel-settings", "channel-settings"), objectSchema);
|
||||
});
|
||||
|
||||
test("schemaAt answers nothing for a path the schema does not describe", () => {
|
||||
assert.equal(schemaAt(objectSchema, "channel-settings.telegram.token", "channel-settings"), null);
|
||||
assert.equal(schemaAt(null, "channel-settings.email", "channel-settings"), null);
|
||||
assert.equal(schemaAt(bareSchema, "channel-settings.email.listen_addr", "channel-settings"), null);
|
||||
});
|
||||
|
||||
test("fieldTitle prefers the schema title over the dashed-key fallback", () => {
|
||||
assert.equal(fieldTitle("listen_addr", { title: "Listen address" }), "Listen address");
|
||||
assert.equal(fieldTitle("listen_addr", { type: "string" }), "Listen addr");
|
||||
assert.equal(fieldTitle("listen_addr", null), "Listen addr");
|
||||
});
|
||||
|
||||
test("fieldPlaceholder offers a duration only where the schema says duration", () => {
|
||||
assert.equal(fieldPlaceholder({ type: "string", format: "duration" }), "1m0s");
|
||||
assert.equal(fieldPlaceholder({ type: "string", format: "date-time" }), "2026-01-01T00:00:00Z");
|
||||
assert.equal(fieldPlaceholder({ type: "string" }), undefined);
|
||||
assert.equal(fieldPlaceholder({ type: "integer" }), undefined);
|
||||
assert.equal(fieldPlaceholder(null), undefined);
|
||||
});
|
||||
|
||||
test("fieldHint carries the schema's own prose, and nothing when it has none", () => {
|
||||
assert.equal(fieldHint({ description: "0 disables rate limiting." }), "0 disables rate limiting.");
|
||||
assert.equal(fieldHint({ type: "integer" }), "");
|
||||
assert.equal(fieldHint(null), "");
|
||||
});
|
||||
|
||||
test("isKeyedCollection is the schema signal that keys are the operator's", () => {
|
||||
assert.equal(isKeyedCollection(keyedSchema), true);
|
||||
assert.equal(isKeyedCollection(objectSchema), false);
|
||||
assert.equal(isKeyedCollection(bareSchema), false);
|
||||
assert.equal(isKeyedCollection(null), false);
|
||||
});
|
||||
|
||||
test("blankFromSchema synthesises a new row from the schema, not from a path", () => {
|
||||
assert.deepEqual(blankFromSchema(arraySchema.items), { owner: "", base: "" });
|
||||
assert.deepEqual(blankFromSchema(keyedSchema), {});
|
||||
assert.deepEqual(blankFromSchema({ type: "array", items: { type: "string" } }), []);
|
||||
assert.equal(blankFromSchema({ type: "boolean" }), false);
|
||||
assert.equal(blankFromSchema({ type: "integer" }), 0);
|
||||
assert.equal(blankFromSchema({ type: "string", format: "duration" }), "");
|
||||
assert.equal(blankFromSchema(null), "");
|
||||
});
|
||||
|
||||
test("the live editor reads the schema, and no longer hardcodes document shapes", async () => {
|
||||
const editor = await readFile(new URL("../src/settings/StructuredValueEditor.vue", import.meta.url), "utf8");
|
||||
assert.match(editor, /fieldPlaceholder/, "the editor offers the duration placeholder from the schema");
|
||||
assert.match(editor, /fieldTitle/, "labels come from the schema title");
|
||||
assert.match(editor, /blankFromSchema/, "a new row is synthesised from the schema");
|
||||
for (const stale of ["base: \"main\"", "ecosystem: \"go\"", "transport: \"stdio\"", "interval: 3600000000000"]) {
|
||||
assert.ok(!editor.includes(stale), `the editor still hardcodes a document shape: ${stale}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("the resource card hands the derived schema to the editor", async () => {
|
||||
const card = await readFile(new URL("../src/settings/StructuredResourceCard.vue", import.meta.url), "utf8");
|
||||
assert.match(card, /parseSchema/, "the card parses the descriptor's schema");
|
||||
assert.match(card, /:schema=/, "the card passes it down");
|
||||
});
|
||||
Reference in new issue
Block a user