feat(eda): record every terminal binding outcome and flag failing bindings
This commit is contained in:
1 parent
83cc810e94
commit
dff26fe98b
6 files changed
+50
-21
No files matched your search
@@ -40,8 +40,7 @@ func (d *Daemon) workflowEnablement(ctx context.Context) (workflowtask.WorkflowE
|
||||
|
||||
// resolveBindingTarget checks a matched binding against the workflow it
|
||||
// targets and resolves the task's repository and inputs. A non-empty reason
|
||||
// means the binding does not dispatch and the reason is recorded on it; ok
|
||||
// false with no reason means resolveBindingRepo already logged why.
|
||||
// means the binding does not dispatch and the reason is recorded on it.
|
||||
func (d *Daemon) resolveBindingTarget(b binding.Binding, values map[string]any, workflows workflow.WorkflowDefinitionCollection) (target bindingTarget, reason string, ok bool) {
|
||||
entry, found := workflows.DefinitionByID(b.Workflow)
|
||||
if !found {
|
||||
@@ -72,9 +71,9 @@ func (d *Daemon) resolveBindingTarget(b binding.Binding, values map[string]any,
|
||||
case mode == workflowtask.RepositoryOptional && b.Owner == "":
|
||||
return target, "", true
|
||||
}
|
||||
owner, repo, resolved := d.resolveBindingRepo(b)
|
||||
if !resolved {
|
||||
return bindingTarget{}, "", false
|
||||
owner, repo, reason := d.resolveBindingRepo(b)
|
||||
if reason != "" {
|
||||
return bindingTarget{}, reason, false
|
||||
}
|
||||
target.owner, target.repo = owner, repo
|
||||
return target, "", true
|
||||
|
||||
@@ -617,8 +617,8 @@ func (d *Daemon) dispatchCapture(ctx context.Context, c storecontract.CapturedEv
|
||||
}
|
||||
|
||||
// bindingMapping returns b's mapping, or nil after logging why it is
|
||||
// unavailable.
|
||||
func (d *Daemon) bindingMapping(ctx context.Context, b binding.Binding) *mapping.Mapping {
|
||||
// unavailable. A mapping that no longer exists is a terminal outcome.
|
||||
func (d *Daemon) bindingMapping(ctx context.Context, b binding.Binding, c storecontract.CapturedEvent) *mapping.Mapping {
|
||||
if d.Mappings == nil {
|
||||
d.Log.Warn("binding dispatch: mapping store unavailable", "binding", b.ID)
|
||||
return nil
|
||||
@@ -629,7 +629,7 @@ func (d *Daemon) bindingMapping(ctx context.Context, b binding.Binding) *mapping
|
||||
return nil
|
||||
}
|
||||
if m == nil {
|
||||
d.Log.Warn("binding dispatch: mapping missing", "binding", b.ID, "mapping", b.MappingID)
|
||||
d.recordDispatchFailure(ctx, b, c, fmt.Sprintf("mapping %q does not exist", b.MappingID), nil)
|
||||
}
|
||||
return m
|
||||
}
|
||||
@@ -640,7 +640,7 @@ func (d *Daemon) bindingMapping(ctx context.Context, b binding.Binding) *mapping
|
||||
// dispatch is claimed in the ledger before the task is enqueued, so each
|
||||
// binding fires at most once per capture.
|
||||
func (d *Daemon) dispatchOneBinding(ctx context.Context, b binding.Binding, c storecontract.CapturedEvent, workflows workflow.WorkflowDefinitionCollection) {
|
||||
m := d.bindingMapping(ctx, b)
|
||||
m := d.bindingMapping(ctx, b, c)
|
||||
if m == nil || m.EventTypeID != c.EventType {
|
||||
return
|
||||
}
|
||||
@@ -665,10 +665,8 @@ func (d *Daemon) dispatchOneBinding(ctx context.Context, b binding.Binding, c st
|
||||
}
|
||||
|
||||
target, reason, ok := d.resolveBindingTarget(b, values, workflows)
|
||||
if reason != "" {
|
||||
d.recordDispatchFailure(ctx, b, c, reason, nil)
|
||||
}
|
||||
if !ok {
|
||||
d.recordDispatchFailure(ctx, b, c, reason, nil)
|
||||
return
|
||||
}
|
||||
// The chain decides dispatch: the workflow's identity may `run` this
|
||||
@@ -834,18 +832,15 @@ func renderBindingBody(values map[string]any, c storecontract.CapturedEvent) str
|
||||
|
||||
// resolveBindingRepo returns the binding's pinned owner/repo, or the only
|
||||
// configured repo. With zero or several repos and no pin it refuses.
|
||||
func (d *Daemon) resolveBindingRepo(b binding.Binding) (string, string, bool) {
|
||||
func (d *Daemon) resolveBindingRepo(b binding.Binding) (owner, repo, reason string) {
|
||||
if b.Owner != "" && b.Repo != "" {
|
||||
return b.Owner, b.Repo, true
|
||||
return b.Owner, b.Repo, ""
|
||||
}
|
||||
repos := d.Cfg.Get().Repos
|
||||
if len(repos) == 1 {
|
||||
return repos[0].Owner, repos[0].Name, true
|
||||
return repos[0].Owner, repos[0].Name, ""
|
||||
}
|
||||
d.Log.Warn("binding dispatch: cannot resolve target repo",
|
||||
"hint", "configure exactly one [[repos]] entry, or pin the binding to a specific owner/repo",
|
||||
"configured_repos", len(repos))
|
||||
return "", "", false
|
||||
return "", "", fmt.Sprintf("cannot pick a repository: %d are configured; pin the binding to one", len(repos))
|
||||
}
|
||||
|
||||
// drainReactions turns available review reactions into queued remediate
|
||||
|
||||
@@ -40,6 +40,9 @@ type bindingView struct {
|
||||
// WorkflowDisabled marks a binding whose org has disabled the workflow it
|
||||
// targets; it does not dispatch until the workflow is enabled again.
|
||||
WorkflowDisabled bool `json:"workflow_disabled"`
|
||||
// LastOutcome is the binding's newest ledger row: the task it started or
|
||||
// the reason it started none.
|
||||
LastOutcome *storecontract.Dispatch `json:"last_outcome,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Server) handleBindingsList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -67,11 +70,28 @@ func (s *Server) handleBindingsList(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
views := make([]bindingView, 0, len(bindings))
|
||||
for _, b := range bindings {
|
||||
views = append(views, bindingView{Binding: b, Unsigned: unsigned[b.Matcher.Source], WorkflowDisabled: !enablement.Enabled(b.OrgID, b.Workflow)})
|
||||
views = append(views, bindingView{
|
||||
Binding: b, Unsigned: unsigned[b.Matcher.Source], WorkflowDisabled: !enablement.Enabled(b.OrgID, b.Workflow),
|
||||
LastOutcome: s.lastOutcome(r.Context(), b.ID),
|
||||
})
|
||||
}
|
||||
writeJSON(w, map[string]any{"bindings": views})
|
||||
}
|
||||
|
||||
// lastOutcome returns a binding's newest dispatch, or nil when it has none or
|
||||
// the ledger is unreadable.
|
||||
func (s *Server) lastOutcome(ctx context.Context, bindingID string) *storecontract.Dispatch {
|
||||
rows, err := s.Bindings.ListDispatches(ctx, storecontract.DispatchFilter{BindingID: bindingID, Limit: 1})
|
||||
if err != nil {
|
||||
s.Log.Warn("binding last outcome", "binding", bindingID, "err", err)
|
||||
return nil
|
||||
}
|
||||
if len(rows) == 0 {
|
||||
return nil
|
||||
}
|
||||
return &rows[0]
|
||||
}
|
||||
|
||||
func (s *Server) handleBindingCreate(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.authorizeTaskMutation(w, r) {
|
||||
return
|
||||
|
||||
Vendored
+1
-1
@@ -18,7 +18,7 @@ Defaulting to \`null\`.`),null)}function TS(e){return CS(e)&&!Number.isNaN(e)&&e
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=AE(c),u=e+1<n.length?AE(n[e+1]):null;if(l&&u&&jE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=AE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>OE(e)),rows:r.map(e=>e.map(e=>OE(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:OE(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:OE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function AE(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 jE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var ME={class:`[overflow-wrap:anywhere]`},NE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},PE={class:`font-mono text-[0.85em]`},FE={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},IE={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},zee={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Bee={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Vee={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Hee={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Uee={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Wee={key:8,class:`mb-2.5 last:mb-0`},Gee=L({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=Y(()=>kE(t.text));return(e,t)=>(V(),H(`div`,ME,[(V(!0),H(B,null,R(n.value,(e,t)=>(V(),H(B,{key:t},[e.kind===`pre`?(V(),H(`pre`,NE,[W(`code`,PE,M(e.code),1)])):e.kind===`table`?(V(),H(`table`,FE,[W(`thead`,null,[W(`tr`,null,[(V(!0),H(B,null,R(e.head,(e,t)=>(V(),H(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[G(EE,{inline:e},null,8,[`inline`])]))),128))])]),W(`tbody`,null,[(V(!0),H(B,null,R(e.rows,(e,t)=>(V(),H(`tr`,{key:t},[(V(!0),H(B,null,R(e,(e,t)=>(V(),H(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[G(EE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(V(),H(`blockquote`,IE,[G(EE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(V(),H(`h1`,zee,[G(EE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(V(),H(`h2`,Bee,[G(EE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(V(),H(`h3`,Vee,[G(EE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(V(),H(`ul`,Hee,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(EE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(V(),H(`ol`,Uee,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(EE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(V(),H(`p`,Wee,[G(EE,{inline:e.inline},null,8,[`inline`])])):q(``,!0)],64))),128))]))}}),Kee={class:`truncate`},qee=L({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Qi(`RouterLink`);return V(),U(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:F(()=>[G(P(Xu),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),W(`span`,Kee,M(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Jee={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Yee={class:`font-semibold text-foreground`},Xee={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Zee=L({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=Y(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=Y(()=>t.tool.parameters||t.tool.Parameters||``),i=Y(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=Y(()=>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?(V(),U(qee,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(V(),H(`div`,Jee,[G(P(Zd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),W(`span`,Yee,M(n.value),1),r.value?(V(),H(`code`,Xee,M(r.value),1)):q(``,!0),W(`span`,{class:j(P(X)(`text-fg-muted`,i.value&&`text-danger`))},M(a.value),3)]))}}),Qee={key:0,class:`mb-2 grid gap-0.5 text-xs`},$ee={key:1,class:`mb-2 flex flex-wrap gap-1.5`},ete={key:3,class:`whitespace-pre-wrap`},LE=L({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(V(),H(`div`,{class:j([`flex`,e.assistant?`justify-start`:`justify-end`])},[W(`div`,{class:j(P(X)(`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?(V(),H(`div`,Qee,[(V(!0),H(B,null,R(e.tools,(t,n)=>(V(),U(Zee,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):q(``,!0),e.media.length?(V(),H(`div`,$ee,[(V(!0),H(B,null,R(e.media,(e,t)=>(V(),U(yE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):q(``,!0),e.assistant?(V(),U(Gee,{key:2,text:e.text},null,8,[`text`])):(V(),H(`div`,ete,M(e.text),1)),z(t.$slots,`default`)],2)],2))}}),tte={class:`w-full self-center justify-self-center py-6 text-center`},nte={class:`grid gap-2`},rte=[`onClick`],ite=L(
Line truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>Mj?`${n.slice(0,Mj).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var Pj=[`title`],Fj=L({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>ij(n.event)),a=Y(()=>Nj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=Y(()=>n.event.at?fA(n.event.at):`—`);return(e,t)=>(V(),U(P(kj),{class:j(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:[Hl(Bl(o,[`prevent`]),[`enter`]),Hl(Bl(o,[`prevent`]),[`space`])]},{default:F(()=>[G(P(Oj),{class:`font-medium`},{default:F(()=>[K(M(n.event.kind||n.event.type||`event`),1)]),_:1}),G(P(Oj),{class:`font-mono`},{default:F(()=>[K(M(i.value>0?`#${i.value}`:`—`),1)]),_:1}),G(P(Oj),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},M(a.value.text),9,Pj)]),_:1}),G(P(Oj),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),Ij=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function Lj(e){return(Number(e?.task_id)||0)>0}function Rj(e,t){return t===`tasks`?Lj(e):t!==`system`||!Lj(e)}function zj(e,t){return e.filter(e=>Rj(e,t))}function Bj(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function Vj(e,t){return`${e}:${t??0}`}function Hj(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=Vj(Nj(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var Uj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},Wj={class:`max-h-[28rem] overflow-y-auto`},Gj=[`aria-expanded`,`aria-label`,`onClick`],Kj=[`title`],qj=L({__name:`LiveActivityCard`,setup(e){let t=QE(),{activity:n,streamKind:r,streamState:i}=Fu(hk()),a=N(`all`),o=Y(()=>zj(n.value,a.value)),s=Y(()=>Bj(o.value.length,a.value)),c=qt(new Set),l=Y(()=>Hj(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return Nj(e.representative)}function p(e){return e.representative.at?fA(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(V(),U(P(aA),null,{default:F(()=>[G(P(uA),null,{default:F(()=>[G(P(dA),null,{default:F(()=>[...t[1]||=[K(`Live activity`,-1)]]),_:1}),G(P(oA),{class:`flex items-center gap-2`},{default:F(()=>[G(P(wj),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:P(Ij)},null,8,[`modelValue`,`options`]),G(P(nA),{variant:P(r)},{default:F(()=>[K(M(P(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),G(P(sA),null,{default:F(()=>[W(`div`,Uj,[W(`div`,Wj,[G(P(Ej),null,{default:F(()=>[G(P(jj),{class:`sticky top-0 z-10 bg-card`},{default:F(()=>[G(P(kj),null,{default:F(()=>[G(P(Aj),null,{default:F(()=>[...t[2]||=[K(`Event`,-1)]]),_:1}),G(P(Aj),null,{default:F(()=>[...t[3]||=[K(`Task`,-1)]]),_:1}),G(P(Aj),null,{default:F(()=>[...t[4]||=[K(`Detail`,-1)]]),_:1}),G(P(Aj),null,{default:F(()=>[...t[5]||=[K(`When`,-1)]]),_:1})]),_:1})]),_:1}),G(P(Dj),null,{default:F(()=>[o.value.length?q(``,!0):(V(),U(P(kj),{key:0},{default:F(()=>[G(P(Oj),{colspan:`4`},{default:F(()=>[G(P(Jk),null,{default:F(()=>[G(P(Zk),null,{default:F(()=>[G(P(eA),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(V(!0),H(B,{key:1},R(l.value,e=>(V(),H(B,{key:e.key},[e.count===1?(V(),U(Fj,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(V(),H(B,{key:1},[G(P(kj),{class:j(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[Hl(Bl(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Hl(Bl(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:F(()=>[G(P(Oj),{class:`font-medium`},{default:F(()=>[W(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:Bl(t=>u(e.key),[`stop`])},[d(e)?(V(),U(P(rd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(V(),U(P(id),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),K(` `+M(e.label)+` `,1),G(P(nA),{variant:`idle`},{default:F(()=>[K(`×`+M(e.count),1)]),_:2},1024)],8,Gj)]),_:2},1024),G(P(Oj),{class:`font-mono`},{default:F(()=>[K(M(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),G(P(Oj),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},M(f(e).text),9,Kj)]),_:2},1024),G(P(Oj),null,{default:F(()=>[K(M(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(V(!0),H(B,{key:0},R(e.events,(t,n)=>(V(),U(Fj,{key:`${e.key}:${n}`,ev
Line truncated
|
||||
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function mN(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function hN(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function gN(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function _N(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var vN=N([]),yN=N([]),bN=N(!0),xN=N(null),SN=N(null),CN=N(!1),wN=N(null);async function TN(){try{let e=await Z.eventTypes();bN.value=e.enabled!==!1,vN.value=e.event_types||[],yN.value=e.proposals||[],xN.value=null}catch(e){xN.value=e.message||String(e)}}function EN(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function DN(e){wN.value=null,SN.value=e}function ON(e){let t=IN.value.find(t=>String(t.id)===e.sample_id);DN({mode:`proposal`,id:null,source:e.source,name:``,rule:EN(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function kN(e=``){DN({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function AN(e){DN({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:EN(e.rule),headersText:``,body:``,exampleHeaders:{}})}function jN(){SN.value=null}async function MN(){let e=SN.value;if(e){CN.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:_N(e.rule)});else{let t=e.mode===`paste`?pN(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:_N(e.rule),example:{headers:t,body:e.body}})}SN.value=null,await TN()}catch(e){wN.value=e.message||String(e)}finally{CN.value=!1}}}var NN=N(null);async function PN(){let e=NN.value;if(NN.value=null,e)try{await Z.eventTypeDelete(e.id),await TN()}catch(e){xN.value=e.message||String(e)}}var FN=100,IN=N([]),LN=N(!0),RN=N(null),zN=N(!0),BN=N(null);async function VN(){try{let e=await Z.captures(FN);LN.value=e.enabled!==!1,IN.value=e.captures||[],RN.value=null}catch(e){RN.value=e.message||String(e)}finally{zN.value=!1}}function HN(e){let t=IN.value.find(t=>t.id===e);return t&&(BN.value=t),!!t}function UN(){IN.value.length&&(BN.value=IN.value[0])}function WN(){gk(`captures`,()=>{VN(),TN()})}var GN=`archie.theme`,KN=`archie.density`,qN=`archie.motion`,JN=`archie.tooltips`;function YN(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function XN(e,t){try{localStorage.setItem(e,t)}catch{}}function ZN(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var QN=Pu(`appearance`,()=>{let e=N(YN(GN,[`system`,`dark`,`light`],`dark`)),t=N(YN(KN,[`comfortable`,`compact`],`comfortable`)),n=N(YN(qN,[`system`,`reduced`],`system`)),r=N(YN(JN,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=ZN(e.value)}function o(t){e.value=t,a(),XN(GN,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,XN(KN,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,XN(qN,e)}function l(e){r.value=e,XN(JN,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),$N=L({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=Xh(n,t),{tooltipsEnabled:i}=Fu(QN());return(e,t)=>(V(),U(P(XC),J({"data-slot":`tooltip`},P(r),{disabled:n.disabled||!P(i)}),{default:F(t=>[z(e.$slots,`default`,ve(cs(t)))]),_:3},16,[`disabled`]))}}),eP=L({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=Xh(gw(n,`class`),r);return(e,t)=>(V(),U(P(ew),null,{default:F(
Line truncated
|
||||
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function mN(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function hN(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function gN(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function _N(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var vN=N([]),yN=N([]),bN=N(!0),xN=N(null),SN=N(null),CN=N(!1),wN=N(null);async function TN(){try{let e=await Z.eventTypes();bN.value=e.enabled!==!1,vN.value=e.event_types||[],yN.value=e.proposals||[],xN.value=null}catch(e){xN.value=e.message||String(e)}}function EN(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function DN(e){wN.value=null,SN.value=e}function ON(e){let t=IN.value.find(t=>String(t.id)===e.sample_id);DN({mode:`proposal`,id:null,source:e.source,name:``,rule:EN(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function kN(e=``){DN({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function AN(e){DN({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:EN(e.rule),headersText:``,body:``,exampleHeaders:{}})}function jN(){SN.value=null}async function MN(){let e=SN.value;if(e){CN.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:_N(e.rule)});else{let t=e.mode===`paste`?pN(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:_N(e.rule),example:{headers:t,body:e.body}})}SN.value=null,await TN()}catch(e){wN.value=e.message||String(e)}finally{CN.value=!1}}}var NN=N(null);async function PN(){let e=NN.value;if(NN.value=null,e)try{await Z.eventTypeDelete(e.id),await TN()}catch(e){xN.value=e.message||String(e)}}var FN=100,IN=N([]),LN=N(!0),RN=N(null),zN=N(!0),BN=N(null);async function VN(){try{let e=await Z.captures(FN);LN.value=e.enabled!==!1,IN.value=e.captures||[],RN.value=null}catch(e){RN.value=e.message||String(e)}finally{zN.value=!1}}function HN(e){let t=IN.value.find(t=>t.id===e);return t&&(BN.value=t),!!t}function UN(){IN.value.length&&(BN.value=IN.value[0])}function WN(){gk(`captures`,()=>{VN(),TN()})}var GN=`archie.theme`,KN=`archie.density`,qN=`archie.motion`,JN=`archie.tooltips`;function YN(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function XN(e,t){try{localStorage.setItem(e,t)}catch{}}function ZN(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var QN=Pu(`appearance`,()=>{let e=N(YN(GN,[`system`,`dark`,`light`],`dark`)),t=N(YN(KN,[`comfortable`,`compact`],`comfortable`)),n=N(YN(qN,[`system`,`reduced`],`system`)),r=N(YN(JN,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=ZN(e.value)}function o(t){e.value=t,a(),XN(GN,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,XN(KN,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,XN(qN,e)}function l(e){r.value=e,XN(JN,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),$N=L({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=Xh(n,t),{tooltipsEnabled:i}=Fu(QN());return(e,t)=>(V(),U(P(XC),J({"data-slot":`tooltip`},P(r),{disabled:n.disabled||!P(i)}),{default:F(t=>[z(e.$slots,`default`,ve(cs(t)))]),_:3},16,[`disabled`]))}}),eP=L({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=Xh(gw(n,`class`),r);return(e,t)=>(V(),U(P(ew),null,{default:F(
Line truncated
|
||||
`)}};aJ.defaultYaml={explicit:!1,version:`1.2`},aJ.defaultTags={"!!":`tag:yaml.org,2002:`};function oJ(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function sJ(e){let t=new Set;return Qq(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function cJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function lJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=sJ(e);let a=cJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(Wq(t.node)||Kq(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function uJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=uJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=uJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=uJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=uJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function dJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>dJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Jq(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var fJ=class{constructor(e){Object.defineProperty(this,zq,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Vq(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=dJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?uJ(i,{"":o},``,o):o}},pJ=class extends fJ{constructor(e){super(Nq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Qq(e,{Node:(e,t)=>{(Bq(t)||Jq(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(dJ(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=mJ(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(oJ(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function mJ(e,t,n){if(Bq(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(Kq(t)){let r=0;for(let i of t.items){let t=mJ(e,i,n);t>r&&(r=t)}return r}if(Uq(t)){let r=mJ(e,t.key,n),i=mJ(e,t.value,n);return Math.max(r,i)}return 1}var hJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,gJ=class extends fJ{constructor(e){super(Lq),this.value=e}toJSON(e,t){return t?.keep?this.value:dJ(this.value,e,t)}toString(){return String(this.value)}};gJ.BLOCK_FOLDED=`BLOCK_FOLDED`,gJ.BLOCK_LITERAL=`BLOCK_LITERAL`,gJ.PLAIN=`PLAIN`,gJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,gJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var _J=`tag:yaml.org,2002:`;function vJ(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function yJ(e,t,n){if(Vq(e)&&(e=e.contents),qq(e))return e;if(Uq(e)){let t=n.schema[Fq].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new pJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=_J+t.slice(2));let l=vJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new gJ(e);return c&&(c.node=t),t
Line truncated
|
||||
`)?wJ(n,t):n.includes(`
|
||||
`)?`
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { Check, Pencil, Trash2 } from "@lucide/vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -19,6 +20,12 @@ const props = defineProps<{
|
||||
mappings: MappingOption[];
|
||||
eventTypes: EventType[];
|
||||
}>();
|
||||
// A filtered capture is the filter doing its job; any other reason means the
|
||||
// binding matched an event and could not start its workflow.
|
||||
const failing = computed(() => {
|
||||
const reason = props.binding.last_outcome?.reason;
|
||||
return !!reason && reason !== "filtered";
|
||||
});
|
||||
const emit = defineEmits<{
|
||||
edit: [binding: Binding];
|
||||
approve: [binding: Binding];
|
||||
@@ -50,6 +57,12 @@ const emit = defineEmits<{
|
||||
<div class="flex items-center gap-2">
|
||||
{{ props.binding.workflow || "—" }}
|
||||
<Badge v-if="props.binding.workflow_disabled" variant="warn">Disabled</Badge>
|
||||
<Badge
|
||||
v-if="failing"
|
||||
variant="danger"
|
||||
:title="props.binding.last_outcome?.reason"
|
||||
>Not dispatching</Badge
|
||||
>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell class="font-mono text-fg-muted">{{
|
||||
|
||||
@@ -31,6 +31,8 @@ export interface Binding {
|
||||
unsigned?: boolean;
|
||||
/** Set when the binding's org has disabled the workflow it targets. */
|
||||
workflow_disabled?: boolean;
|
||||
/** The newest ledger row: a task started, or why none was. */
|
||||
last_outcome?: { task_id?: number; reason?: string; dispatched_at: string };
|
||||
}
|
||||
|
||||
/** One workflow input's assignment on the wire. */
|
||||
|
||||
Reference in new issue
Block a user