UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.51 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{li as t,oi as n}from"./_4____________________________.js";import{Mm as r,jm as i}from"./_2_____________________________.js";import{n as a,t as o}from"./en-openclaw-id-Don6YXzi.js";function s(e,n){if(e.channel!==`local_operator`||!e.link.linked||e.status.state===`off`)return null;let r=e.status.state===`keys_refused`;return!r&&(n?.state!==`failed`||n.code!==`binding_superseded`)?null:{type:`attention`,category:`system`,kind:`openClawIdKeys`,severity:`error`,icon:`key`,requiresAction:!0,dismissal:null,signature:JSON.stringify([e.link.clawId,r?e.status.reason:`binding_superseded`]),label:t(r?e.status.reason===`key_mismatch`?`openclawId.keysMismatch`:`openclawId.keysMissing`:`openclawId.bindingSuperseded`),detail:t(r?`openclawId.keysRefusedDetail`:`openclawId.bindingSupersededDetail`),action:{kind:`openClawIdRecovery`,label:t(`openclawId.moveToNewKeys`)}}}function c(e){return[...(e.invites??[]).map(e=>({kind:`member`,invite:e,name:e.pending?.reported.displayName||e.pending?.reported.email||e.label})),...(e.nodeInvites??[]).map(e=>({kind:`node`,invite:e,name:e.label}))].flatMap(({kind:e,invite:t,name:n})=>{let r=t.status===`pending`?t.pending:void 0;return r?[{kind:e,inviteId:t.inviteId,name:n,requestedAt:r.requestedAt,decideByMs:r.decideBy*1e3}]:[]})}function l(e,n){return{type:`attention`,category:`system`,kind:`openClawIdRequest`,severity:`warning`,icon:`users`,requiresAction:!0,dismissal:null,signature:JSON.stringify([e.kind,e.inviteId,e.requestedAt]),label:t(e.kind===`node`?`openclawId.nodeAskedToJoin`:`openclawId.memberAskedToJoin`,{name:e.name}),detail:t(`openclawId.joinRequestDetail`),meta:{status:t(`openclawId.joinRequestTimeLeft`,{time:i(e.decideByMs-n)})},arrivedAtMs:e.requestedAt*1e3,action:{kind:`navigate`,routeId:`plugin`,search:f}}}function u(e){return e>864e5?36e5:e>36e5?6e4:5e3}async function d(e,t){let n=await e.request(`openclawId.status`,{});if(!t())return null;let r=n.status.state!==`keys_refused`&&n.status.state!==`off`&&n.owner&&n.link.linked?(await e.request(`openclawId.people`,{})).link:null,i=s(n,r?.publication),a=r?c(r):[],o=e=>a.filter(t=>t.decideByMs>e);return{items:e=>[...i?[i]:[],...o(e).map(t=>l(t,e))],nextChangeAt:e=>{let t=o(e);return t.length?Math.min(...t.map(t=>Math.min(t.decideByMs,e+u(t.decideByMs-e)))):void 0}}}var f;function p(){return(p=e((()=>{n(),o(),r(),a(),f=`?${new URLSearchParams({plugin:`openclaw-id-access`,id:`access`})}`})))()}p();export{d as readOpenClawIdAttention};