@vercel/board 0.50.0 → 0.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +6 -2
- package/dist/access.mjs +1 -1
- package/dist/{backend-CcaaS9Xl.d.mts → backend-C2JUnbm5.d.mts} +7 -2
- package/dist/backend-local.d.mts +1 -1
- package/dist/backend-local.mjs +1 -1
- package/dist/{chat-provider-HJ7y_ipp.mjs → chat-provider-Br2RXgLV.mjs} +4 -3
- package/dist/{chat-provider-DQ1GHm4o.d.mts → chat-provider-z4nzV8A-.d.mts} +1 -1
- package/dist/cli-embedded.d.mts +8 -5
- package/dist/cli-embedded.mjs +8 -5
- package/dist/cli.mjs +5 -5
- package/dist/{conformance-Cr-umDl0.mjs → conformance-jHhuKZe8.mjs} +1 -1
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-DJZ8Xy_g.mjs → engine-I887QHnP.mjs} +13 -5
- package/dist/{events-BdOCmnZh.mjs → events-mWKc1uvZ.mjs} +1 -1
- package/dist/{exports-CuD-Mxkw.mjs → exports-DRId1Cks.mjs} +88 -23
- package/dist/{exports-lmr6UHHc.d.mts → exports-DkdCh3Zi.d.mts} +1 -1
- package/dist/{external-D2jq_DEQ.mjs → external-DkWafjn-.mjs} +5 -1
- package/dist/{index-_KxJu15n.d.mts → index-DpuOtt0J.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.node.d.mts +3 -3
- package/dist/index.node.mjs +2 -2
- package/dist/inspect/app.js +30 -30
- package/dist/inspect/engine.js +1 -1
- package/dist/inspect-DLLoYeg7.mjs +2 -0
- package/dist/{inspect-CZeoSm7E.mjs → inspect-DSBG5VDl.mjs} +2 -2
- package/dist/inspect.mjs +1 -1
- package/dist/{local-BVSFSSYf.mjs → local-DjrvtIoE.mjs} +7 -7
- package/dist/{main-B016auoG.mjs → main-VTkjxFcG.mjs} +11 -9
- package/dist/{memory-C2lzMV_t.mjs → memory-wmUDblhm.mjs} +2 -2
- package/dist/{provider-Dwb_9mnu.d.mts → provider-BgUS6ZpP.d.mts} +2 -0
- package/dist/{routes-BE0y6wCk.mjs → routes-BSBUdD2X.mjs} +1 -1
- package/dist/{serve-B10e7QaY.mjs → serve-C2xn_cQV.mjs} +6 -5
- package/dist/{server-ViWNvg5q.mjs → server-BLQxoL0g.mjs} +36 -26
- package/dist/{serving-SbqeWqlA.mjs → serving-Bulte-NO.mjs} +1 -1
- package/dist/{shell-DmpmgOPC.mjs → shell-Bny3-l_d.mjs} +1 -1
- package/dist/{sql-iABdyCiz.mjs → sql-D0MqINA6.mjs} +1 -1
- package/dist/{sqlite-28EMrmk7.mjs → sqlite-Dj2ZEtgy.mjs} +2 -2
- package/dist/{sqlite-db-Ckd-ceNe.mjs → sqlite-db-DjbTlUwN.mjs} +1 -1
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +3 -3
- package/dist/sync-linear.d.mts +2 -2
- package/dist/sync-linear.mjs +3 -3
- package/dist/sync-slack.d.mts +20 -3
- package/dist/sync-slack.mjs +35 -11
- package/dist/sync.d.mts +1 -1
- package/dist/sync.mjs +2 -2
- package/dist/{tags-D0qra0Qy.mjs → tags-CxDCF_tt.mjs} +1 -1
- package/dist/{task-batch-9lVDG3d-.mjs → task-batch-CE6BKnRw.mjs} +3 -3
- package/dist/{tokens-C-iK0Cku.mjs → tokens-DnDHSPml.mjs} +28 -5
- package/dist/{version-C70RLVEK.mjs → version-DWvOShz3.mjs} +1 -1
- package/docs/01-board/01-mounting.md +1 -1
- package/docs/01-board/07-schedules.md +1 -1
- package/docs/02-sync/01-overview.md +3 -3
- package/docs/02-sync/03-slack.md +4 -3
- package/docs/03-guides/01-coding-agents.md +1 -1
- package/docs/04-reference/01-cli.md +19 -14
- package/docs/index.md +1 -1
- package/package.json +14 -2
- package/dist/inspect-UCcPViyA.mjs +0 -2
package/dist/inspect/engine.js
CHANGED
|
@@ -2,4 +2,4 @@ import{A as e,C as t,D as n,E as r,F as i,M as a,N as o,O as s,P as c,S as l,T a
|
|
|
2
2
|
`,r)+1||e.length,!i.startsWith(`|`)||/^\|\s*(Project|Name)\s*\|/.test(i)||/^\|\s*:?-/.test(i))continue;let o=i.split(`|`).slice(1,-1).map(e=>e.trim());if(o.length<2)continue;let s=F.exec(o[1]);if(!s)continue;let c=[...o[0].matchAll(P)].at(-1),l=c?.[1]??o[0].replace(/<[^>]*>/g,``).trim();if(!l)continue;let u=o[2]?[...o[2].matchAll(P)].find(e=>/preview/i.test(e[1])):void 0,d=o[3]?.match(/<relative-time[^>]*>([^<]+)<\/relative-time>/)?.[1]?.trim()??(o[3]?.replace(/<[^>]*>/g,``).trim()||null),f=o[3]?.match(/<relative-time[^>]*\sdatetime="([^"]+)"/)?.[1]??null;n.push({project:l,projectUrl:c?.[2]??null,status:s[1].trim(),deploymentUrl:s[2]??null,previewUrl:u?.[2]??null,updated:d,updatedAt:f!==null&&!Number.isNaN(Date.parse(f))?f:null,skipped:t!==-1&&a>t})}return n.length>0?n:null}const I={ready:`✅`,building:`⏳`,queued:`⏳`,initializing:`⏳`,error:`❌`,failed:`❌`,canceled:`⚪`,ignored:`⚪`},L=(e,t)=>t?`[${e}](${t})`:e;function R(e){return e.map(e=>`- ${[`${I[e.status.toLowerCase()]??`▲`} **${L(e.project,e.projectUrl)}**`,`${L(e.status,e.deploymentUrl)}${e.skipped?` (skipped)`:``}`,...e.previewUrl?[L(`Preview`,e.previewUrl)]:[],...e.updated?[e.updated]:[]].join(` · `)}`).join(`
|
|
3
3
|
`)}function fe(e,t){return e.by.actor===`github:user:35613825`||e.by.profile===`github:user:35613825`&&!!e.from&&t?.kind===`external`&&t.verified===!0&&t.platform===`github`}function pe(e,t){let n=t?de(e):null;return n?`**▲ Vercel**\n${R(n)}`:e}const z=(e,t=!1)=>{let n=D(e),r=n.trim()===``?t?``:`(no text)`:n;return r.length>1e4?`${r.slice(0,l-1).toWellFormed()}…`:r},B=(e,t,r=e.name??`a file`)=>`📎 ${r}${e.size===void 0?``:` (${n(e.size)})`} didn't come over: ${t}`,V=e=>e instanceof _&&e.code===`no_files`,me=(e,t)=>{let n=e.name??`a file`;if(!e.url||!/^https?:\/\//.test(e.url))return B(e,t);let r=n.replace(/[[\]\\]/g,e=>`\\${e}`),i=e.url.replace(/[ ()]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`);return B(e,t,`[${r}](${i})`)},H=(e,t)=>t.length?`${e.trim()?`${e}\n\n`:``}${t.join(`
|
|
4
4
|
`)}`:e,he=e=>e.split(`
|
|
5
|
-
`).filter(e=>/^📎 .* didn't come over: /u.test(e)),U=e=>JSON.stringify([e.url,e.message,e.snapshot,e.unavailable]),ge=(e,t)=>e.length===t.length&&e.every((e,n)=>U(e)===U(t[n])),_e=new AbortController().signal,ve=e=>{try{return JSON.parse(JSON.stringify(e??null))}catch{return null}},W=e=>typeof e==`string`?D(e):Array.isArray(e)?e.map(W):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[D(e),W(t)])):e,G=e=>{let t=e?.data?.error,n=typeof t==`string`?t:e instanceof Error?e.message:String(e);return D(n.slice(0,500))||`unknown error`},ye=e=>e instanceof _&&e.status===404;function K(e,t,n){return n.startsWith(`${e}:`)?n:`${e}:${n.startsWith(`${t}:`)?n.slice(t.length+1):n}`}function be(e,t,n){return e===t?n:re(n,n=>n.kind===`actor`&&n.actor.startsWith(`${t}:`)?`@[${K(e,t,n.actor)}]`:null)}function xe(e,t,n){if(!(`author`in n))return n;let r={...n.author,id:K(e,t,n.author.id)};return n.kind!==`message`&&n.kind!==`edited`||e===t?{...n,author:r}:{...n,author:r,...n.mentioned?{mentioned:n.mentioned.map(n=>({...n,id:K(e,t,n.id)}))}:{},text:be(e,t,n.text)}}function q(e){let t=null,i=()=>{if(!t)throw Error(`sync used before board() bound it`);return t},a={self:`sync`,origin:{via:{kind:`engine`}}};function o(e,t,n=_e,r=a){let o=i().backend;return o[e].call(o,r,t,n)}let c=t=>{let n=e[t];if(!n)throw d(`no sync entry named ${t}`);return n},l=e=>e.slice(0,e.indexOf(`:`)),g=e=>i().syncedHere(e),b=async t=>e[l(t)]!==void 0&&await g(l(t)),x=e=>e.slice(e.indexOf(`:`)+1);async function E(e){try{return await o(`syncThread`,{thread:e})}catch(e){if(ye(e))return null;throw e}}async function D(e){try{let{message:t,replies:n}=await o(`message`,{id:e});return[t,...n]}catch(e){if(ye(e))return[];throw e}}async function O(e){return(await D(e)).find(t=>t.id===e)??null}async function M(e){return e.length===0?{}:(await o(`syncCopies`,{message:[...new Set(e)]})).copies}let N=(e,t)=>o(`syncFind`,e,t),P=null;function F(){if(P)return P;let e=o(`me`,{}).then(e=>e.principal);return P=e,e.catch(()=>{P===e&&(P=null)}),e}async function I(){let[{actors:e},t]=await Promise.all([o(`actors`,{}),F().catch(()=>null)]),n={byId:{},principal:t};for(let t of e)n.byId[t.id]={id:t.id,kind:t.kind,handle:t.handle,name:t.name,avatar:t.avatar,...t.via?{via:{...t.via}}:{},...t.platform?{platform:t.platform}:{},...t.verified?{verified:!0}:{}};return n}let L=/* @__PURE__ */ new Map;function R(e,t){let n=`${e}:${t}`,r=L.get(n);if(r&&(!r.failed||Date.now()-r.at<6e4))return r.id;let i={id:c(e).resolveChannel(t),failed:!1,at:Date.now()};return i.id.catch(r=>{i.failed=!0;let a=se(r);!a&&L.get(n)===i&&L.delete(n),console.warn(`[board] sync ${e}: ${a?`skipping`:`couldn't resolve`} ${t}: ${r.message}`)}),L.set(n,i),i.id}function U(e,t){if(!v(t))return x(t);try{let n=c(e).inboxChannel(e,t);return n===null?null:x(n)}catch{return null}}let q=/* @__PURE__ */ new Map;function Se(e,t){let n=`${e}\u001f${t.toLowerCase()}`,r=q.get(n);if(r&&Date.now()-r.at<3e5)return r.mention;q.size>=1e3&&q.clear();let i=c(e),a=i.findByEmail(t).then(e=>e?i.mention({id:e.id,kind:`external`,handle:e.handle,name:e.name,avatar:e.avatar}):null,()=>null);return q.set(n,{at:Date.now(),mention:a}),a}async function Ce(e){let t=e.indexOf(`:`);if(t<=0)throw d(`sync targets look like <key>:<channel or thread>, got: ${e}`);let n=e.slice(0,t),r=c(n);try{let i=oe.parse(await r.resolveTarget(e.slice(t+1)));if(i.kind===`channel`&&!r.canStartThreads)throw Error(`${r.platform} cannot start threads; use an existing thread`);return{target:`${n}:${i.target}`,kind:i.kind}}catch(t){throw d(`can't sync to ${e}: ${t.message}`)}}async function we(e,t){let{event:n,raw:r,dedupe:i}=ce.parse(W({...t,raw:ve(t.raw)}));for(let t of[n.channel,n.thread,`subthread`in n?n.subthread:null])if(t!==null&&!t.startsWith(`${e}:`))throw d(`provider locations must belong to sync entry ${e}`);let a=le(c(e)),s=a&&await a(x(n.channel),t=>R(e,t)).catch(async e=>{if(await Te(n.thread))return!0;throw e});(!a||s||await Te(n.thread))&&await o(`inboxPush`,{key:e,events:[{id:i,event:n,raw:r}]})}async function Te(e){try{return(await N({thread:e},AbortSignal.timeout(2e3))).thread!==null}catch(e){let t=e?.name;if(t===`TimeoutError`||t===`AbortError`)return!0;throw e}}async function Ee(t,n){let r=e[t];if(!r)throw ie(`no sync entry named ${t}`);if(!await g(t))return new Response(null,{status:200});let i;try{i=await r.receive(t,n,e=>we(t,e))}catch(e){return e instanceof _&&e.status===400?(console.error(`[board] dropped an event the board refuses`,e),new Response(null,{status:200})):(console.error(`[board] intake failed`,e),new Response(`intake failed`,{status:500}))}let a=De([t]).catch(e=>console.error(`[board] couldn't pull ${t}'s inbox:`,G(e)));return ee(a),i}async function De(t=Object.keys(e)){let n=0,r=Date.now()+24e4;for(let e of t)if(await g(e))for(;Date.now()<r;){let{items:t}=await o(`inboxNext`,{key:e,limit:10});if(t.length===0)break;await Promise.all(t.map(t=>Oe(e,t))),n+=t.length}return n}async function Oe(e,t){let n;try{await je(e,{event:t.event,raw:t.raw},{id:t.id,attempt:t.attempt+1})}catch(r){console.error(`[board] sync ${e} couldn't import ${t.id}:`,G(r)),n=G(r)}await o(`inboxAck`,{key:e,id:t.id,lease:t.lease,...n===void 0?{}:{error:n}}).catch(e=>console.error(`[board] couldn't ack an inbox event:`,G(e)))}async function ke(e,t,n,r,i=[]){if(t.length===0)return[];let a=[];for(let o of t){if(a.some(e=>e.url===o.url))continue;let t=(await N({thread:o.thread,message:o.message})).message,s=t===null?null:await O(t);if(s&&!s.deleted&&s.channel===r){a.push({url:o.url,message:s.id,unavailable:null,snapshot:{author:s.author?T(s.author):s.by.actor,text:s.text,createdAt:s.createdAt,files:s.attachments.map(e=>({name:e.name,url:null}))}});continue}if(o.snapshot){a.push({url:o.url,message:null,snapshot:o.snapshot,unavailable:null});continue}let c=i.find(e=>e.url===o.url&&e.snapshot&&e.message===null);if(c){a.push(c);continue}let l=await e.fetchLink(o,n).catch(e=>({snapshot:null,unavailable:G(e)}));a.push({url:o.url,message:null,snapshot:l.snapshot,unavailable:l.snapshot?null:(l.unavailable??`unknown`).slice(0,300)})}return W(a)}async function Ae(e,t,n){let i=[],a=[],c=null;for(let l of t.slice(0,10)){if(c!==null){a.push(me(l,c));continue}if(l.size!==void 0&&l.size>26214400){a.push(B(l,`over ${r/1024/1024} MB`));continue}let t;try{let n=await e.fetchFile(l);if(n===null){a.push(B(l,`${e.platform} can't hand it over`));continue}t=n}catch(t){if(n<3)throw t;console.warn(`[board] couldn't fetch ${l.name??`a file`} from ${e.platform}:`,G(t)),a.push(B(l,`${e.platform} wouldn't hand it over`));continue}if(t.byteLength>26214400){a.push(B(l,`over ${r/1024/1024} MB`));continue}if(t.byteLength===0){a.push(B(l,`it was empty`));continue}let d=l.name??`${l.type}`;try{i.push((await o(`upload`,{data:t,name:d,type:l.mimeType||s(d)})).attachment)}catch(e){if(e instanceof _&&(e.code===`too_large`||e.code===`no_direct_uploads`)){a.push(B(l,`over ${u/1024/1024} MB`));continue}if(!V(e))throw e;c=e.message,a.push(me(l,c))}}for(let e of t.slice(10))a.push(B(e,`a message carries at most 10`));return{attachments:i,notes:a}}async function je(e,t,n){let r=c(e),a={...t,event:xe(e,r.platform,t.event)},{event:o,raw:s}=a,l=(await N({thread:o.thread})).thread??void 0;if(o.kind===`message`){let e=(await N({thread:o.subthread??o.thread,message:o.message})).message;if(e!==null){let t=(await O(e))?.origin;if(!t||t.message!==o.message||(t.subthread??t.thread)!==(o.subthread??o.thread))return}}let u=`author`in o?o.author:{id:`${e}:system`,handle:r.platform,name:r.platform,avatar:null,isBot:!0},f,p=()=>f??=A(r.event({id:n.id,key:e,event:o,raw:s})),m,h,g=!0,_={direction:`in`,key:e,channel:x(o.channel),get event(){return p()},board:i().client({author:u,key:e,...Ne(e,o)},n.id),import(t,r={}){if(!g)throw d(`the sync function has finished`);return m??=Me(e,a,n,l,t,r),m},permalink(){let e=h??r.permalink(p());return h=e,e.catch(()=>{h===e&&(h=void 0)}),e},resolve:t=>R(e,t)};try{await r.sync(_),await m}finally{g=!1}}async function Me(e,t,n,r,i,a){let o=i??(r?(await E(r))?.channel:void 0);if(o===void 0)return{root:null,message:null};try{return await Pe(e,t,n,p.parse(o),ae.parse(a))}catch(e){if(!(e instanceof ne))throw e;let n=(await N({thread:t.event.thread})).thread;return{root:n===null?null:(await E(n))?.root??null,message:null}}}function Ne(e,t){let n=c(e),r=(`subthread`in t?t.subthread:null)??t.thread;return{via:{kind:`sync`,key:e,platform:n.platform,channel:t.channel,thread:r},respond:async e=>{await n.post(x(r),`thread`,{markdown:e})}}}async function Pe(e,t,n,r,i){let{event:a,raw:s}=t,l=Ne(e,a),u=c(e),f=(await N({thread:a.thread})).thread??void 0,p=f?await E(f):null,m=p?.root,g=e=>h(`board-inbound`,n.id,String(e)),_={key:e,channel:l.via.channel,thread:l.via.thread},v=async e=>{if(!e.dropped)return e.message;for(let t of e.dropped)await l.respond(t);throw new ne(e.dropped)},y=async({attachments:t=[],...n})=>({id:await v(await o(`syncImport`,{op:`post`,from:e,source:_,...n,origin:n.origin??null,...t.length?{attachments:t.map(e=>e.id)}:{}})),re:n.re??null}),b=e=>({root:e.re??e.id,message:e.id}),S=(e={})=>{let t={...e,...i.labels};for(let e of i.unset??[])delete t[e];return t},C=e=>{if(!i.root)return e;let t=i.root(A(structuredClone(e)));if(t&&typeof t==`object`&&`then`in t)throw d(`root overrides must be synchronous`);let n=ae.pick({text:!0,labels:!0}).parse(t);return{...e,text:n.text??e.text,labels:{...e.labels,...n.labels}}},w=(t,n,r)=>o(`syncImport`,{op:`labels`,author:t,from:e,origin:{thread:a.thread},set:n,unset:r}),T=async(e,t)=>{if(!i.labels&&!i.unset)return;let n=await O(t),r=Object.fromEntries(Object.entries(i.labels??{}).filter(([e,t])=>n?.labels[e]!==t)),a=(i.unset??[]).filter(e=>n?.labels[e]!==void 0);(Object.keys(r).length||a.length)&&await w(e,r,a)};switch(a.kind){case`message`:{let t=(await N({thread:a.subthread??a.thread,message:a.message})).message;if(t!==null)return{root:m??t,message:t};let{attachments:o,notes:c}=a.files?.length?await Ae(u,a.files,n.attempt):{attachments:[],notes:[]},l=await ke(u,a.links??[],{thread:a.subthread??a.thread,message:a.message},p?.channel??r),d={...l.length?{links:l}:{},...a.mentioned?.length?{mentioned:a.mentioned}:{},author:a.author,text:z(H(i.text??a.text,c),o.length>0),...o.length?{attachments:o}:{},origin:{channel:a.channel,thread:a.thread,subthread:a.subthread,message:a.message,context:a.context},id:await g(0)},f={...d,...i.noSync?{noSync:!0}:{}};if(m!==void 0)return await T(a.author,m),b(await y({...f,re:m}));let h=await u.fetchRoot(x(a.thread));if(h===null){let e=C({text:a.text,labels:{},author:a.author,raw:s});return b(await y({...d,channel:r,text:z(H(i.text??e.text,c),o.length>0),labels:S(e.labels)}))}let _=C({...h,raw:h.raw??null}),v=await y({author:{...h.author,id:K(e,u.platform,h.author.id)},channel:r,text:z(_.text),labels:S(_.labels),origin:{channel:a.channel,thread:a.thread,subthread:null,message:`root:${n.id}`,context:null},id:await g(1)});return b(await y({...f,re:v.id}))}case`edited`:case`deleted`:case`reaction`:{let t=(await N({thread:a.subthread??a.thread,message:a.message})).message;if(t===null)return{root:m??null,message:null};let n=`author`in a?a.author:{id:`${e}:system`,handle:u.platform,name:u.platform,avatar:null,isBot:!0},r={thread:a.subthread??a.thread,message:a.message};if(m!==void 0&&await T(n,m),a.kind===`deleted`)await o(`syncImport`,{op:`delete`,author:n,from:e,origin:r});else if(a.kind===`edited`){let s=await O(t),c=z(H(i.text??a.text,s?he(s.text):[]),(s?.attachments.length??0)>0),l=a.mentioned?.length?{mentioned:a.mentioned}:{};s&&!a.linksOnly&&s.text!==c&&await v(await o(`syncImport`,{op:`edit`,author:n,from:e,origin:r,text:c,source:_,...l}));let d=s?await ke(u,a.links??[],r,s.channel,s.links):[];s&&!ge(d,s.links)&&await o(`syncImport`,{op:`links`,author:n,from:e,origin:r,links:d})}else{if(u.singleReaction){let i=k(a.emoji),s=/* @__PURE__ */ new Set([n.id,`${await F()}+${n.id}`]);for(let[c,l]of Object.entries((await O(t))?.reactions??{}))l.some(e=>s.has(e))&&!(a.added&&c===i)&&await o(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:c,remove:!0})}(!u.singleReaction||a.added)&&await o(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:a.emoji,remove:!a.added})}return{root:m??null,message:t}}case`lifecycle`:{if(m!==void 0){let t=await O(m),r=t?.origin?.message===`lifecycle:${n.id}`,c=S((r?C({text:J(a),labels:a.labels,author:a.author,raw:s}):null)?.labels??a.labels),l=e=>a.owns?.some(t=>e.startsWith(t))??!1,u=Object.fromEntries(Object.entries(c).filter(([e,n])=>t?.labels[e]!==n)),d=Object.keys(t?.labels??{}).filter(e=>!(e in c)&&(a.unset.includes(e)||i.unset?.includes(e)||l(e)));if(t&&!t.deleted&&(Object.keys(u).length||d.length)&&await w(a.author,u,d),a.retitled&&t&&!t.deleted&&t.from===e&&t.origin?.thread===a.thread){let n=z(i.text??C({text:J(a),labels:t.labels,author:a.author,raw:s}).text);t.text!==n&&await v(await o(`syncImport`,{op:`edit`,author:a.author,from:e,origin:{thread:t.origin.thread,message:t.origin.message},text:n}))}return a.reply?b(await y({author:a.author,re:m,text:z(i.text??a.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):{root:m,message:r?m:null}}if(!a.createRoot)return{root:null,message:null};let t=C({text:J(a),labels:a.labels,author:a.author,raw:s}),c=await y({author:a.author,channel:r,text:z(a.reply?t.text:i.text??t.text),labels:S(t.labels),origin:{channel:a.channel,thread:a.thread,subthread:null,message:`lifecycle:${n.id}`,context:null},id:await g(0)});return a.reply?b(await y({author:a.author,re:c.id,text:z(i.text??a.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):b(c)}}}async function Fe(e,t,n){let r=m(n).flatMap(e=>e.kind===`actor`?[e.actor]:[]);if(r.length===0)return n;let i=/* @__PURE__ */ new Map;for(let n of r)!t.byId[n]&&S(n)&&i.set(n,await Se(e,n));return re(n,n=>{if(n.kind===`handle`)return null;if(i.has(n.actor))return i.get(n.actor)??n.actor;let r=Le(n.actor,t);return r?ze(e,r.id,t)??r.name:Ie(e,n.actor,t)})}function Ie(e,t,n){let r=Re(e,t,n);if(r===null)return null;let i=c(e);return i.mentionById(`${i.platform}:${r}`)}function Le(e,t){return t.byId[e]??(t.principal?t.byId[`${t.principal}+${e}`]:void 0)??null}function Re(e,t,n){let{principal:r,profile:i}=y(t),a=i===null?t:f(i)!==null&&r===n.principal?i:null;return a?.startsWith(`${e}:`)?a.slice(e.length+1):null}function ze(e,t,n){let r=n.byId[t],i=r?Re(e,t,n):null;if(i===null)return null;let a=c(e);return a.mention({...r,id:`${a.platform}:${i}`})}async function Be(t,n,r,i,a){let o=i.byId[r.by.actor],s=o?.name??r.by.actor,l=`${o?.via?` ${te(o.via)}`:``}${r.from?` (${o?.platform??e[r.from]?.platform??r.from})`:``}`,u=o?.kind===`deployment`&&!o.via?/(?:@[^@/]+| \([^()]+\))$/.exec(s)?.[0]??``:``,f=`${s}${l}`,p=`${u}${l}`,m=c(t),h=fe(r,o),g=(a??(e=>m.render(e)))(A({message:{...structuredClone(r),text:pe(r.text,h)},author:o?{...o}:null,mentionOf:e=>ze(t,e,i),label:f,target:n}));if(typeof g!=`string`)throw d(`a provider renderer must return markdown`);let _=`**${f}**: `,v=await Fe(t,i,g.startsWith(_)&&ue(g.slice(_.length))?`**${f}**:\n\n${g.slice(_.length)}`:g),y=h?de(r.text):null;return{markdown:v,...o?.verified?{as:{name:f,avatar:Ve(r,o),attribution:p}}:{},...y?{deployments:y}:{}}}function Ve(e,t){let n=e=>!e||/\/avatars\/[a-z0-9-]+$/.test(e),r=t?.avatar??null;if(!n(r))return r;let i=t?.handle.split(`/`)[0]??``,a=e.by.principal.slice(12);return!e.by.principal.startsWith(`vercel:user:`)||!i||/^user-/.test(i)||i.toLowerCase()===a.toLowerCase()?r:`https://vercel.com/api/www/avatar?u=${encodeURIComponent(i)}&s=64&format=png`}let He=e=>e.attachments.map(t=>`\n📎 ${t.name} (${n(t.size)}, on the board: #${e.id})`).join(``),Y=async(e,t,n,r=!1,i)=>{let a=l(e),{markdown:o,...s}=await Be(a,e,t,n,i);return{markdown:t.attachments.length>0&&(r||!c(a).uploadsFiles)?`${o}\n${He(t)}`:o,...s}};async function Ue(e,t,n,r,i){let a=e.replyTo===null?void 0:(await M([e.replyTo]))[e.replyTo]?.[t],o=a!==void 0&&a.thread!==n?a.thread:n,s=c(l(t)),u=await Y(t,e,r,!1,i),f,p;if(!u.markdown.trim()&&e.attachments.length&&s.uploadsFiles)try{let n=await Ke(e,t,o);p=n.message,f=n.files}catch(n){if(!s.refusesFiles(n)&&!V(n))throw n;u=await Y(t,e,r,!0,i),p=(await s.post(x(o),`thread`,u)).message,f=null}else{if(!u.markdown.trim())throw d(`a renderer must return text unless the message has media`);p=(await s.post(x(o),`thread`,u)).message}let m={thread:o,message:p,...f===void 0?{}:{files:f}};return await We(e,t,m),m}async function We(e,t,n){await o(`syncReceipt`,{kind:`message`,message:e.id,target:t,external:{thread:n.thread,message:n.message},...n.files===void 0?{}:{files:n.files}})}async function Ge(e){return Promise.all(e.attachments.map(async e=>{let{data:t}=await o(`attachment`,{id:e.id});return{data:t instanceof Uint8Array?t:new Uint8Array(await new Response(t).arrayBuffer()),filename:e.name,mimeType:e.type}}))}async function Ke(e,t,n){return c(l(t)).uploadFiles(x(n),await Ge(e))}async function X(e,t,n,r,i){let a=c(l(t));if(!a.uploadsFiles||e.attachments.length===0||n.files!==void 0)return;let s;try{s=(await Ke(e,t,n.thread)).files}catch(o){if(!a.refusesFiles(o)&&!V(o))throw Object.assign(/* @__PURE__ */ Error(`files: ${G(o)}`),{cause:o,data:{error:`files: ${G(o)}`}});console.warn(`[board] ${t} won't take #${e.id}'s files (${G(o)}); noting them in its text`),s=null,await Y(t,e,r,!0,i).then(e=>a.edit(x(n.thread),n.message,e)).catch(n=>console.warn(`[board] couldn't note #${e.id}'s files on ${t}:`,G(n)))}await o(`syncReceipt`,{kind:`files`,message:e.id,target:t,files:s})}let Z=(e,t,n,r)=>{e.some(e=>e.error===r)||e.push({id:t,target:n,error:r})};async function Q(e,t){if(t.length!==0){if(e<5||w(e))throw t[0].error;for(let{id:e,target:n,error:r}of t)console.error(`[board] gave up ${n===null?`syncing #${e}`:`delivering #${e} to ${n}`}:`,G(r)),n!==null&&await o(`syncReceipt`,{kind:`failed`,message:e,target:n,error:G(r)})}}async function $(e,t,n,r,i){let a,o=!0,s=()=>d(`the sync function has finished`),l={direction:`out`,key:e,channel:r===null?null:U(e,r),event:A(structuredClone(t)),message:A(structuredClone(n)),target:r,deliver(e={}){if(!o)throw s();return a??=r===null?Promise.resolve():i(e.render),a},start(t){if(!o)throw s();return qe(e,n,t)},resolve:t=>R(e,t)};try{await c(e).sync(l),await a}finally{o=!1}}async function qe(e,t,n){let{target:r,kind:i}=await Ce(`${e}:${n}`),a=t.re===null?t:await O(t.re);!a||a.deleted||a.noSync||r!==(a.origin?a.origin.channel??C(a.origin.thread):null)&&await o(`syncReceipt`,{kind:`thread`,message:a.id,target:r,targetKind:i,cause:`config`})}async function Je(t,n){let r=[];for(let t of Object.keys(e))e[t].canStartThreads&&await g(t)&&r.push(t);if(t.payload.noSync||r.length===0)return;let i=await O(t.message.id);if(!i||i.deleted)return;let a=[];for(let e of r)try{await $(e,t,i,null,async()=>{})}catch(e){Z(a,i.id,null,e)}await Q(n,a)}async function Ye(e,t){let{thread:n,target:r}=e.payload;if(!await b(r)||(e.payload.kind??(v(r)?`thread`:`channel`))===`thread`)return;let i=await E(n);if(!i?.targets.includes(r))return;let[a,...o]=await D(i.root);if(!a||a.id!==i.root||a.deleted||a.noSync)return;let s=[];try{await $(l(r),e,a,r,e=>Xe(i,a,o,r,s,e))}catch(e){Z(s,a.id,r,e)}await Q(t,s)}async function Xe(e,t,n,r,i,a){let o=await I(),s=await M([t.id,...n.map(e=>e.id)]),u=e=>(i.push({id:t.id,target:r,error:e}),e),f=e.external[r];if(f){let e=s[t.id]?.[r];if(e)try{await X(t,r,e,o,a)}catch(e){throw u(e)}}else try{let e=c(l(r)),n=await Y(r,t,o,!1,a),i=!n.markdown.trim()&&t.attachments.length>0&&e.uploadsFiles;if(!n.markdown.trim()&&!i)throw d(`a renderer must return text unless the message has media`);let s,u=await(async()=>{if(!i&&(t.attachments.length===0||!e.startsThreadsWithFiles))return e.post(x(r),`channel`,n);try{let a=await e.post(x(r),`channel`,{...n,files:await Ge(t)});return s=i?a.files??[]:a.files,a}catch(n){if(!e.refusesFiles(n)&&!V(n))throw n;return s=null,e.post(x(r),`channel`,await Y(r,t,o,!0,a))}})();f=`${l(r)}:${u.thread}`;let p={thread:f,message:u.message,...s===void 0?{}:{files:s}};await We(t,r,p),await X(t,r,p,o,a)}catch(e){throw u(e)}let p=[];for(let e of n)if(!(e.deleted||e.noSync||Ze(e,r)))try{await X(e,r,s[e.id]?.[r]??await Ue(e,r,f,o,a),o,a)}catch(t){p.push({id:e.id,target:r,error:t})}if(i.push(...p),p.length)throw p[0].error}let Ze=(e,t)=>e.origin?.thread===t||e.from!==null&&l(t)===e.from;async function Qe(e,t){if(!e.message)return;if(e.message.re===null)return Je(e,t);if(e.payload.noSync)return;let n=await E(e.payload.thread);if(!n||n.targets.length===0)return;let r=await D(n.root);if(r[0]?.id!==n.root||r[0].noSync)return;let i=r.find(t=>t.id===e.message.id);if(!i||i.deleted)return;let a=await I(),o=[];for(let t of n.targets){let r=n.external[t];if(await b(t)&&r&&!Ze(i,t))try{await $(l(t),e,i,t,async e=>{let n=(await M([i.id]))[i.id]?.[t]??await Ue(i,t,r,a,e);await X(i,t,n,a,e)})}catch(e){Z(o,i.id,t,e)}}await Q(t,o)}async function $e(e){let t=(await M([e.payload.id]))[e.payload.id]??{};if(Object.keys(t).length===0)return;let n=e.type===`message.edited`?await O(e.payload.id):e.message??await O(e.payload.id);if(!n||e.type===`message.edited`&&n.deleted)return;let r=await I();for(let[i,a]of Object.entries(t))if(!(!await b(i)||e.payload.from!==null&&l(i)===e.payload.from))try{await $(l(i),e,n,i,async t=>{let o=c(l(i)),s=x(a.thread);e.type===`message.edited`?await o.edit(s,a.message,await Y(i,n,r,a.files===null,t)):e.type===`message.deleted`?(await o.delete(s,a.message),a.files?.length&&await o.deleteFiles(a.files)):e.type===`reaction.added`?await o.react(s,a.message,k(e.payload.emoji),!0):await o.react(s,a.message,k(e.payload.emoji),!1)})}catch(t){console.warn(`[board] skipped ${e.type} on ${i}:`,t.message)}}async function et(e){let{id:t}=e.payload,n=(await M([t]))[t]??{},r=e.message;if(!r||Object.keys(n).length===0)return;let i=await O(t);if(!i||i.deleted)return;let a=await I(),o={...i,labels:r.labels},s={...i,labels:e.before?.labels??{}};for(let[t,r]of Object.entries(n))if(await b(t))try{await $(l(t),e,o,t,async e=>{let n=await Y(t,o,a,r.files===null,e);n.markdown!==(await Y(t,s,a,r.files===null,e)).markdown&&await c(l(t)).edit(x(r.thread),r.message,n)})}catch(e){console.warn(`[board] skipped labels.changed on ${t}:`,G(e))}}async function tt(e,{attempt:t}){switch(e.type){case`thread.synced`:return Ye(e,t);case`message.posted`:return Qe(e,t);case`message.edited`:case`message.deleted`:case`reaction.added`:case`reaction.removed`:return $e(e);case`labels.changed`:return et(e)}}async function nt(e,t){let n=e[0]?await E(e[0].thread):null;if(!n)return[];let r=[];for(let e of new Set(Object.values(n.external)))await b(e)&&r.push(e);return(await Promise.all(r.map(async n=>{let r=l(n);try{let i=c(r),a=null;for(let t=e.length-1;t>=0&&a===null;t--){let r=e[t];!r.deleted&&r.origin?.thread===n&&(a=r.origin.message)}return await i.startTyping(x(n),a,t),n}catch(e){return console.warn(`[board] skipped typing on ${n}:`,G(e)),null}}))).filter(e=>e!==null)}async function rt(e,t){try{return`${e}:${await c(e).resolveChannel(t)}`}catch(e){throw d(`can't resolve inbox channel: ${e.message}`)}}let it=e=>e===`unsupported`||e===`invalid_target`?400:e===`channel_not_found`?404:e===`ratelimited`?429:[`no_client`,`list_failed`,`internal_error`,`fatal_error`,`service_unavailable`,`request_timeout`].includes(e)?502:403;async function at(e,t,n,r){let i=c(e);try{let a=await i.read(t,{limit:n,after:r});return{...a,messages:a.messages.map(t=>({...t,text:be(e,i.platform,t.text)}))}}catch(n){throw n instanceof j?new _(it(n.code),n.code,n.message):d(`can't read ${t} from ${e}: ${G(n)}`,`platform_error`)}}async function ot(e,t){let n=c(e);try{return await n.join(t)}catch(n){throw n instanceof j?new _(it(n.code),n.code,n.message):d(`can't join ${t} on ${e}: ${G(n)}`,`platform_error`)}}return{entries:e,bind(e){t=e},caller:a,deliver:tt,receive:je,pull:De,normalizeTarget:Ce,handleWebhook:Ee,inboxChannel:rt,typing:nt,readSource:at,joinSource:ot}}function J(e){let t=e.url?`${e.title}\n${e.url}`:e.title;return e.body?`${t}\n\n${e.body}`:t}export{q as createSyncEngine,K as keyedId};
|
|
5
|
+
`).filter(e=>/^📎 .* didn't come over: /u.test(e)),U=e=>JSON.stringify([e.url,e.message,e.snapshot,e.unavailable]),ge=(e,t)=>e.length===t.length&&e.every((e,n)=>U(e)===U(t[n])),_e=new AbortController().signal,ve=e=>{try{return JSON.parse(JSON.stringify(e??null))}catch{return null}},W=e=>typeof e==`string`?D(e):Array.isArray(e)?e.map(W):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[D(e),W(t)])):e,G=e=>{let t=e?.data?.error,n=typeof t==`string`?t:e instanceof Error?e.message:String(e);return D(n.slice(0,500))||`unknown error`},ye=e=>e instanceof _&&e.status===404;function K(e,t,n){return n.startsWith(`${e}:`)?n:`${e}:${n.startsWith(`${t}:`)?n.slice(t.length+1):n}`}function be(e,t,n){return e===t?n:re(n,n=>n.kind===`actor`&&n.actor.startsWith(`${t}:`)?`@[${K(e,t,n.actor)}]`:null)}function xe(e,t,n){if(!(`author`in n))return n;let r={...n.author,id:K(e,t,n.author.id)};return n.kind!==`message`&&n.kind!==`edited`||e===t?{...n,author:r}:{...n,author:r,...n.mentioned?{mentioned:n.mentioned.map(n=>({...n,id:K(e,t,n.id)}))}:{},text:be(e,t,n.text)}}function q(e){let t=null,i=()=>{if(!t)throw Error(`sync used before board() bound it`);return t},a={self:`sync`,origin:{via:{kind:`engine`}}};function o(e,t,n=_e,r=a){let o=i().backend;return o[e].call(o,r,t,n)}let c=t=>{let n=e[t];if(!n)throw d(`no sync entry named ${t}`);return n},l=e=>e.slice(0,e.indexOf(`:`)),g=e=>i().syncedHere(e),b=async t=>e[l(t)]!==void 0&&await g(l(t)),x=e=>e.slice(e.indexOf(`:`)+1);async function E(e){try{return await o(`syncThread`,{thread:e})}catch(e){if(ye(e))return null;throw e}}async function D(e){try{let{message:t,replies:n}=await o(`message`,{id:e});return[t,...n]}catch(e){if(ye(e))return[];throw e}}async function O(e){return(await D(e)).find(t=>t.id===e)??null}async function M(e){return e.length===0?{}:(await o(`syncCopies`,{message:[...new Set(e)]})).copies}let N=(e,t)=>o(`syncFind`,e,t),P=null;function F(){if(P)return P;let e=o(`me`,{}).then(e=>e.principal);return P=e,e.catch(()=>{P===e&&(P=null)}),e}async function I(){let[{actors:e},t]=await Promise.all([o(`actors`,{}),F().catch(()=>null)]),n={byId:{},principal:t};for(let t of e)n.byId[t.id]={id:t.id,kind:t.kind,handle:t.handle,name:t.name,avatar:t.avatar,...t.via?{via:{...t.via}}:{},...t.platform?{platform:t.platform}:{},...t.verified?{verified:!0}:{}};return n}let L=/* @__PURE__ */ new Map;function R(e,t){let n=`${e}:${t}`,r=L.get(n);if(r&&(!r.failed||Date.now()-r.at<6e4))return r.id;let i={id:c(e).resolveChannel(t),failed:!1,at:Date.now()};return i.id.catch(r=>{i.failed=!0;let a=se(r);!a&&L.get(n)===i&&L.delete(n),console.warn(`[board] sync ${e}: ${a?`skipping`:`couldn't resolve`} ${t}: ${r.message}`)}),L.set(n,i),i.id}function U(e,t){if(!v(t))return x(t);try{let n=c(e).inboxChannel(e,t);return n===null?null:x(n)}catch{return null}}let q=/* @__PURE__ */ new Map;function Se(e,t){let n=`${e}\u001f${t.toLowerCase()}`,r=q.get(n);if(r&&Date.now()-r.at<3e5)return r.mention;q.size>=1e3&&q.clear();let i=c(e),a=i.findByEmail(t).then(e=>e?i.mention({id:e.id,kind:`external`,handle:e.handle,name:e.name,avatar:e.avatar}):null,()=>null);return q.set(n,{at:Date.now(),mention:a}),a}async function Ce(e){let t=e.indexOf(`:`);if(t<=0)throw d(`sync targets look like <key>:<channel or thread>, got: ${e}`);let n=e.slice(0,t),r=c(n);try{let i=oe.parse(await r.resolveTarget(e.slice(t+1)));if(i.kind===`channel`&&!r.canStartThreads)throw Error(`${r.platform} cannot start threads; use an existing thread`);return{target:`${n}:${i.target}`,kind:i.kind}}catch(t){throw d(`can't sync to ${e}: ${t.message}`)}}async function we(e,t){let{event:n,raw:r,dedupe:i}=ce.parse(W({...t,raw:ve(t.raw)}));for(let t of[n.channel,n.thread,`subthread`in n?n.subthread:null])if(t!==null&&!t.startsWith(`${e}:`))throw d(`provider locations must belong to sync entry ${e}`);let a=le(c(e)),s=a&&await a(x(n.channel),t=>R(e,t)).catch(async e=>{if(await Te(n.thread))return!0;throw e});(!a||s||await Te(n.thread))&&await o(`inboxPush`,{key:e,events:[{id:i,event:n,raw:r}]})}async function Te(e){try{return(await N({thread:e},AbortSignal.timeout(2e3))).thread!==null}catch(e){let t=e?.name;if(t===`TimeoutError`||t===`AbortError`)return!0;throw e}}async function Ee(t,n){let r=e[t];if(!r)throw ie(`no sync entry named ${t}`);if(!await g(t))return new Response(null,{status:200});let i;try{i=await r.receive(t,n,e=>we(t,e))}catch(e){return e instanceof _&&e.status===400?(console.error(`[board] dropped an event the board refuses`,e),new Response(null,{status:200})):(console.error(`[board] intake failed`,e),new Response(`intake failed`,{status:500}))}let a=De([t]).catch(e=>console.error(`[board] couldn't pull ${t}'s inbox:`,G(e)));return ee(a),i}async function De(t=Object.keys(e)){let n=0,r=Date.now()+24e4;for(let e of t)if(await g(e))for(;Date.now()<r;){let{items:t}=await o(`inboxNext`,{key:e,limit:10});if(t.length===0)break;await Promise.all(t.map(t=>Oe(e,t))),n+=t.length}return n}async function Oe(e,t){let n;try{await je(e,{event:t.event,raw:t.raw},{id:t.id,attempt:t.attempt+1})}catch(r){console.error(`[board] sync ${e} couldn't import ${t.id}:`,G(r)),n=G(r)}await o(`inboxAck`,{key:e,id:t.id,lease:t.lease,...n===void 0?{}:{error:n}}).catch(e=>console.error(`[board] couldn't ack an inbox event:`,G(e)))}async function ke(e,t,n,r,i=[]){if(t.length===0)return[];let a=[];for(let o of t){if(a.some(e=>e.url===o.url))continue;let t=(await N({thread:o.thread,message:o.message})).message,s=t===null?null:await O(t);if(s&&!s.deleted&&s.channel===r){a.push({url:o.url,message:s.id,unavailable:null,snapshot:{author:s.author?T(s.author):s.by.actor,text:s.text,createdAt:s.createdAt,files:s.attachments.map(e=>({name:e.name,url:null}))}});continue}if(o.snapshot){a.push({url:o.url,message:null,snapshot:o.snapshot,unavailable:null});continue}let c=i.find(e=>e.url===o.url&&e.snapshot&&e.message===null);if(c){a.push(c);continue}let l=await e.fetchLink(o,n).catch(e=>({snapshot:null,unavailable:G(e)}));a.push({url:o.url,message:null,snapshot:l.snapshot,unavailable:l.snapshot?null:(l.unavailable??`unknown`).slice(0,300)})}return W(a)}async function Ae(e,t,n){let i=[],a=[],c=null;for(let l of t.slice(0,10)){if(c!==null){a.push(me(l,c));continue}if(l.size!==void 0&&l.size>26214400){a.push(B(l,`over ${r/1024/1024} MB`));continue}let t;try{let n=await e.fetchFile(l);if(n===null){a.push(B(l,`${e.platform} can't hand it over`));continue}t=n}catch(t){if(n<3)throw t;console.warn(`[board] couldn't fetch ${l.name??`a file`} from ${e.platform}:`,G(t)),a.push(B(l,`${e.platform} wouldn't hand it over`));continue}if(t.byteLength>26214400){a.push(B(l,`over ${r/1024/1024} MB`));continue}if(t.byteLength===0){a.push(B(l,`it was empty`));continue}let d=l.name??`${l.type}`;try{i.push((await o(`upload`,{data:t,name:d,type:l.mimeType||s(d)})).attachment)}catch(e){if(e instanceof _&&(e.code===`too_large`||e.code===`no_direct_uploads`)){a.push(B(l,`over ${u/1024/1024} MB`));continue}if(!V(e))throw e;c=e.message,a.push(me(l,c))}}for(let e of t.slice(10))a.push(B(e,`a message carries at most 10`));return{attachments:i,notes:a}}async function je(e,t,n){let r=c(e),a={...t,event:xe(e,r.platform,t.event)},{event:o,raw:s}=a,l=(await N({thread:o.thread})).thread??void 0;if(o.kind===`message`){let e=(await N({thread:o.subthread??o.thread,message:o.message})).message;if(e!==null){let t=(await O(e))?.origin;if(!t||t.message!==o.message||(t.subthread??t.thread)!==(o.subthread??o.thread))return}}let u=`author`in o?o.author:{id:`${e}:system`,handle:r.platform,name:r.platform,avatar:null,isBot:!0},f,p=()=>f??=A(r.event({id:n.id,key:e,event:o,raw:s})),m,h,g=!0,_={direction:`in`,key:e,channel:x(o.channel),get event(){return p()},board:i().client({author:u,key:e,...Ne(e,o)},n.id),import(t,r={}){if(!g)throw d(`the sync function has finished`);return m??=Me(e,a,n,l,t,r),m},permalink(){let e=h??r.permalink(p());return h=e,e.catch(()=>{h===e&&(h=void 0)}),e},resolve:t=>R(e,t)};try{await r.sync(_),await m}finally{g=!1}}async function Me(e,t,n,r,i,a){let o=i??(r?(await E(r))?.channel:void 0);if(o===void 0)return{root:null,message:null};try{return await Pe(e,t,n,p.parse(o),ae.parse(a))}catch(e){if(!(e instanceof ne))throw e;let n=(await N({thread:t.event.thread})).thread;return{root:n===null?null:(await E(n))?.root??null,message:null}}}function Ne(e,t){let n=c(e),r=(`subthread`in t?t.subthread:null)??t.thread;return{via:{kind:`sync`,key:e,platform:n.platform,channel:t.channel,thread:r},respond:async e=>{await n.post(x(r),`thread`,{markdown:e})}}}async function Pe(e,t,n,r,i){let{event:a,raw:s}=t,l=Ne(e,a),u=c(e),f=(await N({thread:a.thread})).thread??void 0,p=f?await E(f):null,m=p?.root,g=e=>h(`board-inbound`,n.id,String(e)),_={key:e,channel:l.via.channel,thread:l.via.thread},v=async e=>{if(!e.dropped)return e.message;for(let t of e.dropped)await l.respond(t);throw new ne(e.dropped)},y=async({attachments:t=[],...n})=>({id:await v(await o(`syncImport`,{op:`post`,from:e,source:_,...n,origin:n.origin??null,...t.length?{attachments:t.map(e=>e.id)}:{}})),re:n.re??null}),b=e=>({root:e.re??e.id,message:e.id}),S=(e={})=>{let t={...e,...i.labels};for(let e of i.unset??[])delete t[e];return t},C=e=>{if(!i.root)return e;let t=i.root(A(structuredClone(e)));if(t&&typeof t==`object`&&`then`in t)throw d(`root overrides must be synchronous`);let n=ae.pick({text:!0,labels:!0}).parse(t);return{...e,text:n.text??e.text,labels:{...e.labels,...n.labels}}},w=(t,n,r)=>o(`syncImport`,{op:`labels`,author:t,from:e,origin:{thread:a.thread},set:n,unset:r}),T=async(e,t)=>{if(!i.labels&&!i.unset)return;let n=await O(t),r=Object.fromEntries(Object.entries(i.labels??{}).filter(([e,t])=>n?.labels[e]!==t)),a=(i.unset??[]).filter(e=>n?.labels[e]!==void 0);(Object.keys(r).length||a.length)&&await w(e,r,a)};switch(a.kind){case`message`:{let t=(await N({thread:a.subthread??a.thread,message:a.message})).message;if(t!==null)return{root:m??t,message:t};let{attachments:o,notes:c}=a.files?.length?await Ae(u,a.files,n.attempt):{attachments:[],notes:[]},l=await ke(u,a.links??[],{thread:a.subthread??a.thread,message:a.message},p?.channel??r),d={...l.length?{links:l}:{},...a.mentioned?.length?{mentioned:a.mentioned}:{},author:a.author,text:z(H(i.text??a.text,c),o.length>0),...o.length?{attachments:o}:{},origin:{channel:a.channel,thread:a.thread,subthread:a.subthread,message:a.message,context:a.context},id:await g(0)},f={...d,...i.noSync?{noSync:!0}:{}};if(m!==void 0)return await T(a.author,m),b(await y({...f,re:m}));let h=await u.fetchRoot(x(a.thread));if(h===null){let e=C({text:a.text,labels:{},author:a.author,raw:s});return b(await y({...d,channel:r,text:z(H(i.text??e.text,c),o.length>0),labels:S(e.labels)}))}let _=C({...h,raw:h.raw??null}),v=await y({author:{...h.author,id:K(e,u.platform,h.author.id)},channel:r,text:z(_.text),labels:S(_.labels),origin:{channel:a.channel,thread:a.thread,subthread:null,message:`root:${n.id}`,context:null},id:await g(1)});return b(await y({...f,re:v.id}))}case`edited`:case`deleted`:case`reaction`:{let t=(await N({thread:a.subthread??a.thread,message:a.message})).message;if(t===null)return{root:m??null,message:null};let n=`author`in a?a.author:{id:`${e}:system`,handle:u.platform,name:u.platform,avatar:null,isBot:!0},r={thread:a.subthread??a.thread,message:a.message};if(m!==void 0&&await T(n,m),a.kind===`deleted`)await o(`syncImport`,{op:`delete`,author:n,from:e,origin:r});else if(a.kind===`edited`){let s=await O(t),c=z(H(i.text??a.text,s?he(s.text):[]),(s?.attachments.length??0)>0),l=a.mentioned?.length?{mentioned:a.mentioned}:{};s&&!a.linksOnly&&s.text!==c&&await v(await o(`syncImport`,{op:`edit`,author:n,from:e,origin:r,text:c,source:_,...l}));let d=s?await ke(u,a.links??[],r,s.channel,s.links):[];s&&!ge(d,s.links)&&await o(`syncImport`,{op:`links`,author:n,from:e,origin:r,links:d})}else{if(u.singleReaction){let i=k(a.emoji),s=/* @__PURE__ */ new Set([n.id,`${await F()}+${n.id}`]);for(let[c,l]of Object.entries((await O(t))?.reactions??{}))l.some(e=>s.has(e))&&!(a.added&&c===i)&&await o(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:c,remove:!0})}(!u.singleReaction||a.added)&&await o(`syncImport`,{op:`react`,author:n,from:e,origin:r,emoji:a.emoji,remove:!a.added})}return{root:m??null,message:t}}case`lifecycle`:{if(m!==void 0){let t=await O(m),r=t?.origin?.message===`lifecycle:${n.id}`,c=S((r?C({text:J(a),labels:a.labels,author:a.author,raw:s}):null)?.labels??a.labels),l=e=>a.owns?.some(t=>e.startsWith(t))??!1,u=Object.fromEntries(Object.entries(c).filter(([e,n])=>t?.labels[e]!==n)),d=Object.keys(t?.labels??{}).filter(e=>!(e in c)&&(a.unset.includes(e)||i.unset?.includes(e)||l(e)));if(t&&!t.deleted&&(Object.keys(u).length||d.length)&&await w(a.author,u,d),a.retitled&&t&&!t.deleted&&t.from===e&&t.origin?.thread===a.thread){let n=z(i.text??C({text:J(a),labels:t.labels,author:a.author,raw:s}).text);t.text!==n&&await v(await o(`syncImport`,{op:`edit`,author:a.author,from:e,origin:{thread:t.origin.thread,message:t.origin.message},text:n}))}return a.reply?b(await y({author:a.author,re:m,text:z(i.text??a.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):{root:m,message:r?m:null}}if(!a.createRoot)return{root:null,message:null};let t=C({text:J(a),labels:a.labels,author:a.author,raw:s}),c=await y({author:a.author,channel:r,text:z(a.reply?t.text:i.text??t.text),labels:S(t.labels),origin:{channel:a.channel,thread:a.thread,subthread:null,message:`lifecycle:${n.id}`,context:null},id:await g(0)});return a.reply?b(await y({author:a.author,re:c.id,text:z(i.text??a.reply),...i.noSync?{noSync:!0}:{},id:await g(1)})):b(c)}}}async function Fe(e,t,n){let r=m(n).flatMap(e=>e.kind===`actor`?[e.actor]:[]);if(r.length===0)return n;let i=/* @__PURE__ */ new Map,a=0;for(let n of r)t.byId[n]||!S(n)||i.has(n)||i.set(n,a++<10?await Se(e,n):null);return re(n,n=>{if(n.kind===`handle`)return null;if(i.has(n.actor))return i.get(n.actor)??n.actor;let r=Le(n.actor,t);return r?ze(e,r.id,t)??r.name:Ie(e,n.actor,t)})}function Ie(e,t,n){let r=Re(e,t,n);if(r===null)return null;let i=c(e);return i.mentionById(`${i.platform}:${r}`)}function Le(e,t){return t.byId[e]??(t.principal?t.byId[`${t.principal}+${e}`]:void 0)??null}function Re(e,t,n){let{principal:r,profile:i}=y(t),a=i===null?t:f(i)!==null&&r===n.principal?i:null;return a?.startsWith(`${e}:`)?a.slice(e.length+1):null}function ze(e,t,n){let r=n.byId[t],i=r?Re(e,t,n):null;if(i===null)return null;let a=c(e);return a.mention({...r,id:`${a.platform}:${i}`})}async function Be(t,n,r,i,a){let o=i.byId[r.by.actor],s=o?.name??r.by.actor,l=`${o?.via?` ${te(o.via)}`:``}${r.from?` (${o?.platform??e[r.from]?.platform??r.from})`:``}`,u=o?.kind===`deployment`&&!o.via?/(?:@[^@/]+| \([^()]+\))$/.exec(s)?.[0]??``:``,f=`${s}${l}`,p=`${u}${l}`,m=c(t),h=fe(r,o),g=(a??(e=>m.render(e)))(A({message:{...structuredClone(r),text:pe(r.text,h)},author:o?{...o}:null,mentionOf:e=>ze(t,e,i),label:f,target:n}));if(typeof g!=`string`)throw d(`a provider renderer must return markdown`);let _=`**${f}**: `,v=await Fe(t,i,g.startsWith(_)&&ue(g.slice(_.length))?`**${f}**:\n\n${g.slice(_.length)}`:g),y=h?de(r.text):null;return{markdown:v,...o?.verified?{as:{name:f,avatar:Ve(r,o),attribution:p}}:{},...y?{deployments:y}:{}}}function Ve(e,t){let n=e=>!e||/\/avatars\/[a-z0-9-]+$/.test(e),r=t?.avatar??null;if(!n(r))return r;let i=t?.handle.split(`/`)[0]??``,a=e.by.principal.slice(12);return!e.by.principal.startsWith(`vercel:user:`)||!i||/^user-/.test(i)||i.toLowerCase()===a.toLowerCase()?r:`https://vercel.com/api/www/avatar?u=${encodeURIComponent(i)}&s=64&format=png`}let He=e=>e.attachments.map(t=>`\n📎 ${t.name} (${n(t.size)}, on the board: #${e.id})`).join(``),Y=async(e,t,n,r=!1,i)=>{let a=l(e),{markdown:o,...s}=await Be(a,e,t,n,i);return{markdown:t.attachments.length>0&&(r||!c(a).uploadsFiles)?`${o}\n${He(t)}`:o,...s,external:t.from!==null&&t.from!==`board`}};async function Ue(e,t,n,r,i){let a=e.replyTo===null?void 0:(await M([e.replyTo]))[e.replyTo]?.[t],o=a!==void 0&&a.thread!==n?a.thread:n,s=c(l(t)),u=await Y(t,e,r,!1,i),f,p;if(!u.markdown.trim()&&e.attachments.length&&s.uploadsFiles)try{let n=await Ke(e,t,o);p=n.message,f=n.files}catch(n){if(!s.refusesFiles(n)&&!V(n))throw n;u=await Y(t,e,r,!0,i),p=(await s.post(x(o),`thread`,u)).message,f=null}else{if(!u.markdown.trim())throw d(`a renderer must return text unless the message has media`);p=(await s.post(x(o),`thread`,u)).message}let m={thread:o,message:p,...f===void 0?{}:{files:f}};return await We(e,t,m),m}async function We(e,t,n){await o(`syncReceipt`,{kind:`message`,message:e.id,target:t,external:{thread:n.thread,message:n.message},...n.files===void 0?{}:{files:n.files}})}async function Ge(e){return Promise.all(e.attachments.map(async e=>{let{data:t}=await o(`attachment`,{id:e.id});return{data:t instanceof Uint8Array?t:new Uint8Array(await new Response(t).arrayBuffer()),filename:e.name,mimeType:e.type}}))}async function Ke(e,t,n){return c(l(t)).uploadFiles(x(n),await Ge(e))}async function X(e,t,n,r,i){let a=c(l(t));if(!a.uploadsFiles||e.attachments.length===0||n.files!==void 0)return;let s;try{s=(await Ke(e,t,n.thread)).files}catch(o){if(!a.refusesFiles(o)&&!V(o))throw Object.assign(/* @__PURE__ */ Error(`files: ${G(o)}`),{cause:o,data:{error:`files: ${G(o)}`}});console.warn(`[board] ${t} won't take #${e.id}'s files (${G(o)}); noting them in its text`),s=null,await Y(t,e,r,!0,i).then(e=>a.edit(x(n.thread),n.message,e)).catch(n=>console.warn(`[board] couldn't note #${e.id}'s files on ${t}:`,G(n)))}await o(`syncReceipt`,{kind:`files`,message:e.id,target:t,files:s})}let Z=(e,t,n,r)=>{e.some(e=>e.error===r)||e.push({id:t,target:n,error:r})};async function Q(e,t){if(t.length!==0){if(e<5||w(e))throw t[0].error;for(let{id:e,target:n,error:r}of t)console.error(`[board] gave up ${n===null?`syncing #${e}`:`delivering #${e} to ${n}`}:`,G(r)),n!==null&&await o(`syncReceipt`,{kind:`failed`,message:e,target:n,error:G(r)})}}async function $(e,t,n,r,i){let a,o=!0,s=()=>d(`the sync function has finished`),l={direction:`out`,key:e,channel:r===null?null:U(e,r),event:A(structuredClone(t)),message:A(structuredClone(n)),target:r,deliver(e={}){if(!o)throw s();return a??=r===null?Promise.resolve():i(e.render),a},start(t){if(!o)throw s();return qe(e,n,t)},resolve:t=>R(e,t)};try{await c(e).sync(l),await a}finally{o=!1}}async function qe(e,t,n){let{target:r,kind:i}=await Ce(`${e}:${n}`),a=t.re===null?t:await O(t.re);!a||a.deleted||a.noSync||r!==(a.origin?a.origin.channel??C(a.origin.thread):null)&&await o(`syncReceipt`,{kind:`thread`,message:a.id,target:r,targetKind:i,cause:`config`})}async function Je(t,n){let r=[];for(let t of Object.keys(e))e[t].canStartThreads&&await g(t)&&r.push(t);if(t.payload.noSync||r.length===0)return;let i=await O(t.message.id);if(!i||i.deleted)return;let a=[];for(let e of r)try{await $(e,t,i,null,async()=>{})}catch(e){Z(a,i.id,null,e)}await Q(n,a)}async function Ye(e,t){let{thread:n,target:r}=e.payload;if(!await b(r)||(e.payload.kind??(v(r)?`thread`:`channel`))===`thread`)return;let i=await E(n);if(!i?.targets.includes(r))return;let[a,...o]=await D(i.root);if(!a||a.id!==i.root||a.deleted||a.noSync)return;let s=[];try{await $(l(r),e,a,r,e=>Xe(i,a,o,r,s,e))}catch(e){Z(s,a.id,r,e)}await Q(t,s)}async function Xe(e,t,n,r,i,a){let o=await I(),s=await M([t.id,...n.map(e=>e.id)]),u=e=>(i.push({id:t.id,target:r,error:e}),e),f=e.external[r];if(f){let e=s[t.id]?.[r];if(e)try{await X(t,r,e,o,a)}catch(e){throw u(e)}}else try{let e=c(l(r)),n=await Y(r,t,o,!1,a),i=!n.markdown.trim()&&t.attachments.length>0&&e.uploadsFiles;if(!n.markdown.trim()&&!i)throw d(`a renderer must return text unless the message has media`);let s,u=await(async()=>{if(!i&&(t.attachments.length===0||!e.startsThreadsWithFiles))return e.post(x(r),`channel`,n);try{let a=await e.post(x(r),`channel`,{...n,files:await Ge(t)});return s=i?a.files??[]:a.files,a}catch(n){if(!e.refusesFiles(n)&&!V(n))throw n;return s=null,e.post(x(r),`channel`,await Y(r,t,o,!0,a))}})();f=`${l(r)}:${u.thread}`;let p={thread:f,message:u.message,...s===void 0?{}:{files:s}};await We(t,r,p),await X(t,r,p,o,a)}catch(e){throw u(e)}let p=[];for(let e of n)if(!(e.deleted||e.noSync||Ze(e,r)))try{await X(e,r,s[e.id]?.[r]??await Ue(e,r,f,o,a),o,a)}catch(t){p.push({id:e.id,target:r,error:t})}if(i.push(...p),p.length)throw p[0].error}let Ze=(e,t)=>e.origin?.thread===t||e.from!==null&&l(t)===e.from;async function Qe(e,t){if(!e.message)return;if(e.message.re===null)return Je(e,t);if(e.payload.noSync)return;let n=await E(e.payload.thread);if(!n||n.targets.length===0)return;let r=await D(n.root);if(r[0]?.id!==n.root||r[0].noSync)return;let i=r.find(t=>t.id===e.message.id);if(!i||i.deleted)return;let a=await I(),o=[];for(let t of n.targets){let r=n.external[t];if(await b(t)&&r&&!Ze(i,t))try{await $(l(t),e,i,t,async e=>{let n=(await M([i.id]))[i.id]?.[t]??await Ue(i,t,r,a,e);await X(i,t,n,a,e)})}catch(e){Z(o,i.id,t,e)}}await Q(t,o)}async function $e(e){let t=(await M([e.payload.id]))[e.payload.id]??{};if(Object.keys(t).length===0)return;let n=e.type===`message.edited`?await O(e.payload.id):e.message??await O(e.payload.id);if(!n||e.type===`message.edited`&&n.deleted)return;let r=await I();for(let[i,a]of Object.entries(t))if(!(!await b(i)||e.payload.from!==null&&l(i)===e.payload.from))try{await $(l(i),e,n,i,async t=>{let o=c(l(i)),s=x(a.thread);e.type===`message.edited`?await o.edit(s,a.message,await Y(i,n,r,a.files===null,t)):e.type===`message.deleted`?(await o.delete(s,a.message),a.files?.length&&await o.deleteFiles(a.files)):e.type===`reaction.added`?await o.react(s,a.message,k(e.payload.emoji),!0):await o.react(s,a.message,k(e.payload.emoji),!1)})}catch(t){console.warn(`[board] skipped ${e.type} on ${i}:`,t.message)}}async function et(e){let{id:t}=e.payload,n=(await M([t]))[t]??{},r=e.message;if(!r||Object.keys(n).length===0)return;let i=await O(t);if(!i||i.deleted)return;let a=await I(),o={...i,labels:r.labels},s={...i,labels:e.before?.labels??{}};for(let[t,r]of Object.entries(n))if(await b(t))try{await $(l(t),e,o,t,async e=>{let n=await Y(t,o,a,r.files===null,e);n.markdown!==(await Y(t,s,a,r.files===null,e)).markdown&&await c(l(t)).edit(x(r.thread),r.message,n)})}catch(e){console.warn(`[board] skipped labels.changed on ${t}:`,G(e))}}async function tt(e,{attempt:t}){switch(e.type){case`thread.synced`:return Ye(e,t);case`message.posted`:return Qe(e,t);case`message.edited`:case`message.deleted`:case`reaction.added`:case`reaction.removed`:return $e(e);case`labels.changed`:return et(e)}}async function nt(e,t){let n=e[0]?await E(e[0].thread):null;if(!n)return[];let r=[];for(let e of new Set(Object.values(n.external)))await b(e)&&r.push(e);return(await Promise.all(r.map(async n=>{let r=l(n);try{let i=c(r),a=null;for(let t=e.length-1;t>=0&&a===null;t--){let r=e[t];!r.deleted&&r.origin?.thread===n&&(a=r.origin.message)}return await i.startTyping(x(n),a,t),n}catch(e){return console.warn(`[board] skipped typing on ${n}:`,G(e)),null}}))).filter(e=>e!==null)}async function rt(e,t){try{return`${e}:${await c(e).resolveChannel(t)}`}catch(e){throw d(`can't resolve inbox channel: ${e.message}`)}}let it=e=>e===`unsupported`||e===`invalid_target`?400:e===`channel_not_found`?404:e===`ratelimited`?429:[`no_client`,`list_failed`,`internal_error`,`fatal_error`,`service_unavailable`,`request_timeout`].includes(e)?502:403;async function at(e,t,n,r){let i=c(e);try{let a=await i.read(t,{limit:n,after:r});return{...a,messages:a.messages.map(t=>({...t,text:be(e,i.platform,t.text)}))}}catch(n){throw n instanceof j?new _(it(n.code),n.code,n.message):d(`can't read ${t} from ${e}: ${G(n)}`,`platform_error`)}}async function ot(e,t){let n=c(e);try{return await n.join(t)}catch(n){throw n instanceof j?new _(it(n.code),n.code,n.message):d(`can't join ${t} on ${e}: ${G(n)}`,`platform_error`)}}return{entries:e,bind(e){t=e},caller:a,deliver:tt,receive:je,pull:De,normalizeTarget:Ce,handleWebhook:Ee,inboxChannel:rt,typing:nt,readSource:at,joinSource:ot}}function J(e){let t=e.url?`${e.title}\n${e.url}`:e.title;return e.body?`${t}\n\n${e.body}`:t}export{q as createSyncEngine,K as keyedId};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as ATTACHMENT_BYTES_MAX, r as parseProfileHeader, t as InvalidProfileHeader } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
2
|
import "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import { t as Failed, u as who } from "./main-
|
|
4
|
-
import { n as relative, r as shell, t as CSP } from "./shell-
|
|
3
|
+
import { t as Failed, u as who } from "./main-VTkjxFcG.mjs";
|
|
4
|
+
import { n as relative, r as shell, t as CSP } from "./shell-Bny3-l_d.mjs";
|
|
5
5
|
import { t as page } from "./page-7KWSGxyC.mjs";
|
|
6
6
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
7
7
|
import { createServer } from "node:http";
|
package/dist/inspect.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as ATTACHMENT_BYTES_MAX, r as parseProfileHeader, t as InvalidProfileHeader } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
2
|
import "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import { n as relative, r as shell, t as CSP } from "./shell-
|
|
3
|
+
import { n as relative, r as shell, t as CSP } from "./shell-Bny3-l_d.mjs";
|
|
4
4
|
import { t as page } from "./page-7KWSGxyC.mjs";
|
|
5
5
|
//#region src/inspect/handler.ts
|
|
6
6
|
/**
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { a as DIRECT_UPLOAD_BYTES_MAX, i as ATTACHMENT_BYTES_MAX, l as mediaType, o as IMPORT_BYTES_MAX, s as fileName } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
2
|
import { A as actorKind, D as TaskHoldKind, E as TASK_NOTE_MAX, M as platformAvatar, N as storable, O as TaskNote, T as TASK_LABEL, a as CAN_MAX, b as RemoteWatcherId, c as EDITED_HOLD, d as LabelKey, g as MessageText, h as MessageId, i as Author, j as authorView, l as Emoji, n as Attachment, o as CHANNEL_PATTERN_MAX, p as Labels, s as ChannelPath, t as ActorId, u as Handle, v as OPEN_TASK_STATES, x as SeenActorKind } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin } from "./external-
|
|
4
|
-
import "./routes-
|
|
3
|
+
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin } from "./external-DkWafjn-.mjs";
|
|
4
|
+
import "./routes-BSBUdD2X.mjs";
|
|
5
5
|
import { a as duplicateId, c as notFound, f as BoardError, i as batchTooLarge, l as textTooLong, m as duration, o as forbidden$1, r as badRequest, t as HttpError, u as toErrorResponse } from "./errors-DYF4hhIc.mjs";
|
|
6
6
|
import { a as waitUntil, c as platformProfile, d as userIdOf, h as isKeyIdOf, l as shownName, m as derivedId, n as MIDDLEWARE_ACTOR, o as actorParts, s as importedHandle, t as DroppedError } from "./middleware-DUKIITFZ.mjs";
|
|
7
7
|
import { a as SCHEMA_DESCRIPTION_MAX, c as canonical, d as parseSchemaId, f as schemaId, i as BUILT_IN_SCHEMAS, l as checkDefinition, n as blocksIn, o as SCHEMA_NAME, s as SCHEMA_VERSION_MAX, u as isBuiltInName } from "./blocks-CVoBC7ur.mjs";
|
|
8
8
|
import { a as replaceMentions, i as mentionTerms, n as isEmail, r as mentionTerm, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
|
|
9
|
-
import { t as VERSION } from "./version-
|
|
9
|
+
import { t as VERSION } from "./version-DWvOShz3.mjs";
|
|
10
10
|
import { c as compileAccess, i as authorize, o as checkGrantChange, t as FULL_ACCESS, u as parseCan } from "./access-BbgmsAFF.mjs";
|
|
11
|
-
import { a as runMatch, h as SYNC, i as canonicalWatchers, l as METHODS, n as SYNC_ACTOR, o as compileWatcher, r as syncTarget, s as hasCriteria, t as batchPlan } from "./task-batch-
|
|
11
|
+
import { a as runMatch, h as SYNC, i as canonicalWatchers, l as METHODS, n as SYNC_ACTOR, o as compileWatcher, r as syncTarget, s as hasCriteria, t as batchPlan } from "./task-batch-CE6BKnRw.mjs";
|
|
12
12
|
import { T as wroteAs, b as removes, c as checkCan, g as joined, h as issuerName, l as checkGrant, n as GITHUB_ISSUER, p as grantIssuers, s as authenticates, u as checkPrincipal, w as workflowPath } from "./auth-DJDTfgAL.mjs";
|
|
13
13
|
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
14
14
|
import { i as ownedActor, n as actorSeen, o as viaOf } from "./actors-CX2D22hL.mjs";
|
|
15
15
|
import { C as sessionClearedError, a as SOCKET_TIMINGS, c as drainSettledHooks, d as nullProtoRecord, f as runtimeConsumerFactory, g as A2Error, h as stateTailReaders, i as RESERVED_PARTICIPANT_IDS, l as failedPreviousAttempt, m as serverInternals, n as POLL_TIMINGS, o as STATE_CACHE, p as runtimeConsumers, r as PRESENCE_TIMINGS, s as STREAM_TIMINGS, t as DRAIN_TIMINGS, u as markSchedulerSendFailure, v as NonRetriableError, x as isSessionCleared, y as asStoreUnavailable } from "./internal-CvsrprnU-CEPOUpAv.mjs";
|
|
16
16
|
import { i as streamActivities, n as defaultSleep, t as createStreamActivity } from "./store-polling-BZt2Rf3D-oh3aU_An.mjs";
|
|
17
|
-
import { a as foldActors, i as concernedMessageId, o as foldMessages, s as iso, t as TABLES_CONSUMER } from "./sql-
|
|
17
|
+
import { a as foldActors, i as concernedMessageId, o as foldMessages, s as iso, t as TABLES_CONSUMER } from "./sql-D0MqINA6.mjs";
|
|
18
18
|
import { z } from "zod";
|
|
19
19
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
20
20
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
@@ -10492,10 +10492,10 @@ function local(options = {}) {
|
|
|
10492
10492
|
opening ??= (async () => {
|
|
10493
10493
|
const file = localFile(bound.name);
|
|
10494
10494
|
let store;
|
|
10495
|
-
if (options.memory) store = (await import("./memory-
|
|
10495
|
+
if (options.memory) store = (await import("./memory-wmUDblhm.mjs")).memory();
|
|
10496
10496
|
else {
|
|
10497
10497
|
const { mkdir } = await import("node:fs/promises");
|
|
10498
|
-
const { sqlite } = await import("./sqlite-
|
|
10498
|
+
const { sqlite } = await import("./sqlite-Dj2ZEtgy.mjs");
|
|
10499
10499
|
const path = join(dir, `${file}.db`);
|
|
10500
10500
|
try {
|
|
10501
10501
|
await mkdir(dir, {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { a as DIRECT_UPLOAD_BYTES_MAX, c as fileSize } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
2
|
import { m as MESSAGE_TEXT_MAX, r as AttachmentId } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import "./routes-
|
|
3
|
+
import "./routes-BSBUdD2X.mjs";
|
|
4
4
|
import { n as displayEmoji, r as normalizeEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
5
5
|
import { f as BoardError } from "./errors-DYF4hhIc.mjs";
|
|
6
6
|
import { l as shownName } from "./middleware-DUKIITFZ.mjs";
|
|
7
7
|
import { d as parseSchemaId, r as findBlocks, t as block } from "./blocks-CVoBC7ur.mjs";
|
|
8
8
|
import { a as replaceMentions, n as isEmail, t as extractMentions } from "./mentions-CnWt9Z5b.mjs";
|
|
9
|
-
import { t as VERSION } from "./version-
|
|
9
|
+
import { t as VERSION } from "./version-DWvOShz3.mjs";
|
|
10
10
|
import { r as PERMISSIONS } from "./access-BbgmsAFF.mjs";
|
|
11
|
-
import { c as withMentions } from "./task-batch-
|
|
12
|
-
import {
|
|
11
|
+
import { c as withMentions } from "./task-batch-CE6BKnRw.mjs";
|
|
12
|
+
import { a as isBoardName, c as isApiMessageId, n as createTasksInChunks, t as TasksInChunksError } from "./exports-DRId1Cks.mjs";
|
|
13
13
|
import { i as groups, n as filters$1, o as options, r as globalOptions, s as usage$1, t as commands } from "./commands-nN8WpvCe.mjs";
|
|
14
|
-
import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server-
|
|
15
|
-
import { t as conformance } from "./conformance-
|
|
14
|
+
import { _ as vercelProjectFile, a as vercel, c as boardUrl, d as environmentProfile, f as handFetch, i as handTeam, l as configDir, m as handToken, n as credentialSource, o as http, p as handLogin, r as credentialed, t as board, u as connect } from "./server-BLQxoL0g.mjs";
|
|
15
|
+
import { t as conformance } from "./conformance-jHhuKZe8.mjs";
|
|
16
16
|
import { n as displayText, t as byVercelBot } from "./bots-CqPYxkqK.mjs";
|
|
17
17
|
import { spawn } from "node:child_process";
|
|
18
18
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -942,7 +942,8 @@ const AGENTS = {
|
|
|
942
942
|
file: () => join(process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent"), "extensions", "board.ts")
|
|
943
943
|
}
|
|
944
944
|
};
|
|
945
|
-
|
|
945
|
+
/** A command an install wrote: `<vb> hook stop --agent <one of AGENTS>`, with whatever flags followed. Another tool's `hook stop` isn't ours. */
|
|
946
|
+
const ours = (entry) => / hook stop --agent (?:claude|codex|cursor|pi)(?:\s|$)/.test(entry.command ?? "");
|
|
946
947
|
function readConfig(path) {
|
|
947
948
|
try {
|
|
948
949
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
@@ -989,7 +990,8 @@ function installedHook(agent) {
|
|
|
989
990
|
const spec = AGENTS[agent];
|
|
990
991
|
if (spec.shape === "extension") try {
|
|
991
992
|
const line = PI_COMMAND.exec(readFileSync(spec.file(), "utf8"));
|
|
992
|
-
|
|
993
|
+
const command = line ? JSON.parse(line[1]) : null;
|
|
994
|
+
return command !== null && ours({ command }) ? command : null;
|
|
993
995
|
} catch {
|
|
994
996
|
return null;
|
|
995
997
|
}
|
|
@@ -2161,7 +2163,7 @@ function failureOf(error) {
|
|
|
2161
2163
|
details: []
|
|
2162
2164
|
};
|
|
2163
2165
|
if (status === 400) return theirs("usage", specific("invalid_arguments"), `Can't ${doing()}.`);
|
|
2164
|
-
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] :
|
|
2166
|
+
if (status === 401) return theirs("auth", "login_required", "The board didn't accept your credentials.", sent() === "the token you passed" ? [{ instruction: "Pass a token it accepts" }] : sent() === "BOARD_TOKEN" ? [{ instruction: "Pass a token it accepts in BOARD_TOKEN, or unset it" }] : [{
|
|
2165
2167
|
instruction: "Log in again",
|
|
2166
2168
|
argv: ["vercel", "login"]
|
|
2167
2169
|
}]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as sqlTables } from "./sql-
|
|
1
|
+
import { r as sqlTables } from "./sql-D0MqINA6.mjs";
|
|
2
2
|
import { t as memory$1 } from "./store-memory-CKQVEzXN.mjs";
|
|
3
|
-
import { t as sqliteDb } from "./sqlite-db-
|
|
3
|
+
import { t as sqliteDb } from "./sqlite-db-DjbTlUwN.mjs";
|
|
4
4
|
//#region src/store/memory.ts
|
|
5
5
|
/**
|
|
6
6
|
* A board that lives in memory, for tests: its log in A2's memory store, its
|
|
@@ -516,6 +516,8 @@ type ProviderPost = {
|
|
|
516
516
|
files?: ProviderFile[];
|
|
517
517
|
as?: ProviderSender;
|
|
518
518
|
deployments?: VercelDeployment[];
|
|
519
|
+
/** Written on another platform, not on the board: markup in it that notifies people here is the platform's to keep inert. */
|
|
520
|
+
external?: boolean;
|
|
519
521
|
};
|
|
520
522
|
type ProviderDelivery = {
|
|
521
523
|
thread: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as DIRECT_UPLOAD_BYTES_MAX } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
2
|
import { C as SentTaskNote, M as platformAvatar, N as storable, S as SentTaskHoldKind, _ as NewLabels, c as EDITED_HOLD, d as LabelKey, f as LabelValue, g as MessageText, k as TaskState, l as Emoji, m as MESSAGE_TEXT_MAX, o as CHANNEL_PATTERN_MAX, p as Labels, r as AttachmentId, s as ChannelPath, t as ActorId, w as SentText } from "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-
|
|
3
|
+
import { a as Link, i as ExternalTarget, n as ExternalEvent, o as Origin, t as ExternalAuthor } from "./external-DkWafjn-.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
//#region src/api/routes.ts
|
|
6
6
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DYF4hhIc.mjs";
|
|
2
|
+
import { i as hostCheckedBy } from "./exports-DRId1Cks.mjs";
|
|
2
3
|
import { i as LOGINS, r as LOGIN } from "./auth-DJDTfgAL.mjs";
|
|
3
|
-
import { h as localTokenFile, t as board } from "./server-
|
|
4
|
-
import { t as oidcTokens } from "./tokens-
|
|
5
|
-
import { t as local } from "./local-
|
|
4
|
+
import { h as localTokenFile, t as board } from "./server-BLQxoL0g.mjs";
|
|
5
|
+
import { t as oidcTokens } from "./tokens-DnDHSPml.mjs";
|
|
6
|
+
import { t as local } from "./local-DjrvtIoE.mjs";
|
|
6
7
|
import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
7
8
|
import { userInfo } from "node:os";
|
|
8
9
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -127,11 +128,11 @@ async function serveLocal(options) {
|
|
|
127
128
|
issuer: ISSUER,
|
|
128
129
|
jwks
|
|
129
130
|
} });
|
|
130
|
-
const team = board({
|
|
131
|
+
const team = board(hostCheckedBy({
|
|
131
132
|
backend,
|
|
132
133
|
authenticate: tailnet.size > 0 ? tailscale(tokens, (audience) => servedAt(tailnet, audience)) : tokens,
|
|
133
134
|
basePath: MOUNT
|
|
134
|
-
});
|
|
135
|
+
}));
|
|
135
136
|
try {
|
|
136
137
|
await team.channels();
|
|
137
138
|
} catch (error) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as formatProfileHeader } from "./profile-header-Cj0Cb1cf.mjs";
|
|
2
2
|
import "./schemas-CUSTEFIy.mjs";
|
|
3
|
-
import { Z as routes } from "./routes-
|
|
3
|
+
import { Z as routes } from "./routes-BSBUdD2X.mjs";
|
|
4
4
|
import { f as BoardError, p as createBoardClient, t as HttpError } from "./errors-DYF4hhIc.mjs";
|
|
5
5
|
import { g as keyId, p as DERIVED_ID } from "./middleware-DUKIITFZ.mjs";
|
|
6
|
-
import { l as METHODS, o as compileWatcher } from "./task-batch-
|
|
7
|
-
import {
|
|
6
|
+
import { l as METHODS, o as compileWatcher } from "./task-batch-CE6BKnRw.mjs";
|
|
7
|
+
import { d as tailWatchers, f as deployedOnVercel, l as PROTOCOL_ROUTES, r as createBoard, s as createVercel, u as withoutToken } from "./exports-DRId1Cks.mjs";
|
|
8
8
|
import { execFile } from "node:child_process";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
@@ -123,8 +123,8 @@ async function writeCache(audience, login, cached) {
|
|
|
123
123
|
let handed$1 = null;
|
|
124
124
|
/**
|
|
125
125
|
* Hands board a login to ask for when a request needs one, as `vercel board` does with its own:
|
|
126
|
-
* nothing asks for it before then, so help, a typo, or misuse never refreshes or prompts.
|
|
127
|
-
* takes it back.
|
|
126
|
+
* nothing asks for it before then, so help, a typo, or misuse never refreshes or prompts. It's the
|
|
127
|
+
* login that goes, wherever the app runs (`appLogin`). Null takes it back.
|
|
128
128
|
*/
|
|
129
129
|
function handLogin(login) {
|
|
130
130
|
handed$1 = login;
|
|
@@ -172,6 +172,13 @@ const passedToken = () => passed;
|
|
|
172
172
|
/** Whether the login is one a CLI handed over (`createApp`'s `token` or `login`, or `VERCEL_AUTH_TOKEN`). */
|
|
173
173
|
const loginHanded = () => passed !== null || handed$1 !== null || !!process.env.VERCEL_AUTH_TOKEN;
|
|
174
174
|
/**
|
|
175
|
+
* Whether the app that runs board's CLI in its own process gave it a login (`createApp`'s `token`
|
|
176
|
+
* or `login`). The app says who its commands run as, so that login is the one that goes, wherever
|
|
177
|
+
* the app runs: nothing the environment holds stands in for it, a deployment's own token and
|
|
178
|
+
* `BOARD_TOKEN` included. A variable isn't the app's word (`VERCEL_AUTH_TOKEN`): anything sets one.
|
|
179
|
+
*/
|
|
180
|
+
const appLogin = () => passed !== null || handed$1 !== null;
|
|
181
|
+
/**
|
|
175
182
|
* Your Vercel login: what the CLI that runs board's hands it, as `vercel board` does (the token
|
|
176
183
|
* it was passed, its `login`, or `VERCEL_AUTH_TOKEN`), or else what `vercel login` saved.
|
|
177
184
|
*/
|
|
@@ -281,7 +288,7 @@ function boardUrl() {
|
|
|
281
288
|
}
|
|
282
289
|
/**
|
|
283
290
|
* How a client reaches the board at `url` from Node: through Deployment Protection, with a token
|
|
284
|
-
* from `token`, the login
|
|
291
|
+
* from `token`, the login of an app that runs board's CLI (`appLogin`), `BOARD_TOKEN`, a local
|
|
285
292
|
* board's token file (`vb serve`), GitHub Actions, the Vercel runtime, or your Vercel CLI login,
|
|
286
293
|
* in that order. Who you are is the token's to say: the board
|
|
287
294
|
* names you from what it verifies. A board with no Vercel project has no token for your login to
|
|
@@ -321,9 +328,9 @@ function connect(url, options = {}) {
|
|
|
321
328
|
expiresAt: expiry(token)
|
|
322
329
|
};
|
|
323
330
|
}
|
|
324
|
-
if (
|
|
331
|
+
if (appLogin()) {
|
|
325
332
|
const discovered = await discover();
|
|
326
|
-
if (discovered.project_id) return asPerson(discovered, PASSED);
|
|
333
|
+
if (discovered.project_id) return asPerson(discovered, passed !== null ? PASSED : "vercel login");
|
|
327
334
|
}
|
|
328
335
|
if (process.env.BOARD_TOKEN) {
|
|
329
336
|
const token = process.env.BOARD_TOKEN;
|
|
@@ -941,21 +948,23 @@ function http(url, options = {}) {
|
|
|
941
948
|
}
|
|
942
949
|
//#endregion
|
|
943
950
|
//#region src/backend-vercel/index.ts
|
|
944
|
-
/** On Vercel, or with its OIDC token pulled (`vercel env pull`): a deployment acts as its project. */
|
|
945
|
-
const deployed = () => process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN;
|
|
946
|
-
/** Off a deployment, a credential Vercel's API takes, set for board: what a sandbox or CI passes. */
|
|
947
|
-
const boardToken = () => deployed() ? null : process.env.BOARD_TOKEN || null;
|
|
948
|
-
/** Whether what goes is a Vercel login: a token passed for this run, or with no deployment's token and no `BOARD_TOKEN`, yours. */
|
|
949
|
-
const asLogin = () => passedToken() !== null || !deployed() && !boardToken();
|
|
950
951
|
/**
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
*
|
|
952
|
+
* Whether this deployment's own token is what goes: on Vercel, or with its OIDC token pulled
|
|
953
|
+
* (`vercel env pull`), a deployment acts as its project. Never under an app that runs board's CLI
|
|
954
|
+
* with a login of its own: that login goes.
|
|
955
|
+
*/
|
|
956
|
+
const asDeployment = () => !appLogin() && (process.env.VERCEL === "1" || !!process.env.VERCEL_OIDC_TOKEN);
|
|
957
|
+
/** Off a deployment, a credential Vercel's API takes, set for board: what a sandbox or CI passes. Not ahead of an app's login either. */
|
|
958
|
+
const boardToken = () => appLogin() || asDeployment() ? null : process.env.BOARD_TOKEN || null;
|
|
959
|
+
/** Whether what goes is a Vercel login: an app's, or with no deployment's token and no `BOARD_TOKEN`, yours. */
|
|
960
|
+
const asLogin = () => !asDeployment() && !boardToken();
|
|
961
|
+
/**
|
|
962
|
+
* A token Vercel's API takes: the login of the app that runs board's CLI, when it gave one (the
|
|
963
|
+
* token it was passed, as `vercel board --token`, or else its own), or else this deployment's OIDC
|
|
964
|
+
* token, or else `BOARD_TOKEN`, or your Vercel login: `VERCEL_AUTH_TOKEN`, or your `vercel login`.
|
|
954
965
|
*/
|
|
955
966
|
async function token() {
|
|
956
|
-
|
|
957
|
-
if (passed !== null) return passed;
|
|
958
|
-
if (deployed()) return getVercelOidcToken();
|
|
967
|
+
if (asDeployment()) return getVercelOidcToken();
|
|
959
968
|
const set = boardToken();
|
|
960
969
|
if (set) return set;
|
|
961
970
|
return vercelLogin().catch(() => {
|
|
@@ -968,7 +977,7 @@ async function token() {
|
|
|
968
977
|
/** Where `token` comes from, in words: what `vb whoami` says. */
|
|
969
978
|
function credentialSource() {
|
|
970
979
|
if (passedToken() !== null) return PASSED;
|
|
971
|
-
if (
|
|
980
|
+
if (asDeployment()) return "Vercel OIDC";
|
|
972
981
|
if (boardToken()) return "BOARD_TOKEN";
|
|
973
982
|
return loginHanded() ? "the Vercel CLI" : "vercel login";
|
|
974
983
|
}
|
|
@@ -983,8 +992,9 @@ function handTeam(resolve) {
|
|
|
983
992
|
}
|
|
984
993
|
/**
|
|
985
994
|
* The team: the one a CLI that runs board's hands it, `VERCEL_ORG_ID`, the one the deployment's OIDC
|
|
986
|
-
* token names, or the linked project's (the nearest
|
|
987
|
-
* throws fails the request with what it threw: the
|
|
995
|
+
* token names when that token is what goes, or the linked project's (the nearest
|
|
996
|
+
* `.vercel/project.json`). A handed one that throws fails the request with what it threw: the
|
|
997
|
+
* app's own words, not an internal error.
|
|
988
998
|
*/
|
|
989
999
|
async function team() {
|
|
990
1000
|
if (handed) try {
|
|
@@ -993,7 +1003,7 @@ async function team() {
|
|
|
993
1003
|
throw new HttpError(502, "no_team", error instanceof Error ? error.message : String(error), { origin: "handle" });
|
|
994
1004
|
}
|
|
995
1005
|
if (process.env.VERCEL_ORG_ID) return process.env.VERCEL_ORG_ID;
|
|
996
|
-
if (
|
|
1006
|
+
if (asDeployment()) try {
|
|
997
1007
|
const owner = decodeJwt(await getVercelOidcToken()).owner_id;
|
|
998
1008
|
if (typeof owner === "string") return owner;
|
|
999
1009
|
} catch {}
|
|
@@ -1040,8 +1050,8 @@ function vercel(options = {}) {
|
|
|
1040
1050
|
function board(options = {}) {
|
|
1041
1051
|
return createBoard(options, {
|
|
1042
1052
|
backend: (fetch) => process.env.BOARD_URL?.trim() ? http() : vercel(fetch ? { fetch } : {}),
|
|
1043
|
-
sync: () => import("./engine-
|
|
1044
|
-
serving: () => import("./serving-
|
|
1053
|
+
sync: () => import("./engine-I887QHnP.mjs"),
|
|
1054
|
+
serving: () => import("./serving-Bulte-NO.mjs"),
|
|
1045
1055
|
sandbox: (url, token) => sandboxHeaders(url, url, token)
|
|
1046
1056
|
});
|
|
1047
1057
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-
|
|
1
|
+
import { i as ownTeamId, n as discoveryIdentity, r as ownProjectId, t as oidcTokens } from "./tokens-DnDHSPml.mjs";
|
|
2
2
|
export { discoveryIdentity, oidcTokens, ownProjectId, ownTeamId };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as actorKind, T as TASK_LABEL } from "./schemas-CUSTEFIy.mjs";
|
|
2
|
-
import { c as externalMessageKey, l as isThreadTarget } from "./external-
|
|
2
|
+
import { c as externalMessageKey, l as isThreadTarget } from "./external-DkWafjn-.mjs";
|
|
3
3
|
import { t as canonicalEmoji } from "./emoji-CTLpvH-A.mjs";
|
|
4
4
|
import { i as mentionTerms } from "./mentions-CnWt9Z5b.mjs";
|
|
5
5
|
import { n as setOwn, t as own } from "./own-OwgPWdmh.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as sqlTables } from "./sql-
|
|
1
|
+
import { r as sqlTables } from "./sql-D0MqINA6.mjs";
|
|
2
2
|
import { t as sqlite$1 } from "./store-sqlite-D6fIszST.mjs";
|
|
3
|
-
import { t as sqliteDb } from "./sqlite-db-
|
|
3
|
+
import { t as sqliteDb } from "./sqlite-db-DjbTlUwN.mjs";
|
|
4
4
|
//#region src/store/sqlite.ts
|
|
5
5
|
/**
|
|
6
6
|
* A local board in one SQLite file, its log and board's tables side by side. It
|
package/dist/sync-chat-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-
|
|
2
|
-
import { r as ChatTransport, t as ChatInput } from "./chat-provider-
|
|
1
|
+
import { _ as SyncFn, m as SyncProvider, x as channels } from "./provider-BgUS6ZpP.mjs";
|
|
2
|
+
import { r as ChatTransport, t as ChatInput } from "./chat-provider-z4nzV8A-.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ReactionEvent } from "chat";
|
|
5
5
|
//#region src/sync/chat-sdk.d.ts
|
package/dist/sync-chat-sdk.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as eventSchema, p as channels, r as envelope } from "./events-
|
|
2
|
-
import { t as ChatSyncProvider } from "./chat-provider-
|
|
1
|
+
import { i as eventSchema, p as channels, r as envelope } from "./events-mWKc1uvZ.mjs";
|
|
2
|
+
import { t as ChatSyncProvider } from "./chat-provider-Br2RXgLV.mjs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
//#region src/sync/chat-sdk.ts
|
|
5
5
|
const schemaOf = (platform) => eventSchema(platform, "message");
|
package/dist/sync-github.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-
|
|
2
|
-
import { n as ChatSyncProvider } from "./chat-provider-
|
|
1
|
+
import { _ as SyncFn, b as SyncUnit, p as SyncContext } from "./provider-BgUS6ZpP.mjs";
|
|
2
|
+
import { n as ChatSyncProvider } from "./chat-provider-z4nzV8A-.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Adapter } from "chat";
|
|
5
5
|
//#region src/sync/github.d.ts
|
package/dist/sync-github.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as withRoutes, i as eventSchema, m as into, r as envelope } from "./events-
|
|
2
|
-
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-
|
|
3
|
-
import { n as tagOf } from "./tags-
|
|
1
|
+
import { _ as withRoutes, i as eventSchema, m as into, r as envelope } from "./events-mWKc1uvZ.mjs";
|
|
2
|
+
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-Br2RXgLV.mjs";
|
|
3
|
+
import { n as tagOf } from "./tags-CxDCF_tt.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { connectGitHubAdapter } from "@vercel/connect/chat";
|
|
6
6
|
import { createGitHubAdapter } from "@chat-adapter/github";
|
package/dist/sync-linear.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mt as SourceRead } from "./routes-B6SEA9yw.mjs";
|
|
2
|
-
import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-
|
|
3
|
-
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-
|
|
2
|
+
import { _ as SyncFn, b as SyncUnit, f as ResolvedTarget, l as ReceivedEvent, o as ProviderPost, p as SyncContext, r as ProviderDelivery } from "./provider-BgUS6ZpP.mjs";
|
|
3
|
+
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-z4nzV8A-.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Adapter } from "chat";
|
|
6
6
|
//#region src/sync/linear.d.ts
|
package/dist/sync-linear.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-
|
|
2
|
-
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-
|
|
3
|
-
import { n as tagOf, t as slug } from "./tags-
|
|
1
|
+
import { i as eventSchema, l as UnreadableError, p as channels, r as envelope } from "./events-mWKc1uvZ.mjs";
|
|
2
|
+
import { n as markdownOf, t as ChatSyncProvider } from "./chat-provider-Br2RXgLV.mjs";
|
|
3
|
+
import { n as tagOf, t as slug } from "./tags-CxDCF_tt.mjs";
|
|
4
4
|
import "zod";
|
|
5
5
|
import { connectLinearAdapter } from "@vercel/connect/chat";
|
|
6
6
|
import { createLinearAdapter } from "@chat-adapter/linear";
|
package/dist/sync-slack.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { zn as ExternalLink } from "./routes-B6SEA9yw.mjs";
|
|
2
|
-
import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-
|
|
3
|
-
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-
|
|
2
|
+
import { _ as SyncFn, f as ResolvedTarget, o as ProviderPost, p as SyncContext, r as ProviderDelivery, s as ProviderSender, x as channels } from "./provider-BgUS6ZpP.mjs";
|
|
3
|
+
import { n as ChatSyncProvider, t as ChatInput } from "./chat-provider-z4nzV8A-.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Adapter } from "chat";
|
|
6
6
|
//#region src/sync/slack-deployments.d.ts
|
|
@@ -125,6 +125,7 @@ export type SlackClient = {
|
|
|
125
125
|
test(args?: Record<string, unknown>): Promise<{
|
|
126
126
|
user_id?: string;
|
|
127
127
|
user?: string;
|
|
128
|
+
team_id?: string;
|
|
128
129
|
response_metadata?: {
|
|
129
130
|
scopes?: string[];
|
|
130
131
|
};
|
|
@@ -149,6 +150,15 @@ type SlackPost = {
|
|
|
149
150
|
export declare function slackUsername({ name, attribution }: Pick<ProviderSender, 'name' | 'attribution'>): string | null;
|
|
150
151
|
/** The `**name**: ` a message's text opens with (on a line of its own before a block), taken out when Slack shows the name as the sender. */
|
|
151
152
|
export declare function withoutLabel(markdown: string, name: string): string;
|
|
153
|
+
/**
|
|
154
|
+
* Slack's `<!channel>`, `<!here>`, `<!everyone>`, and `<!subteam^…>` notify a whole channel or user
|
|
155
|
+
* group. Text from other platforms (a GitHub comment) isn't allowed to ping them, so a word joiner
|
|
156
|
+
* breaks the markup; the text reads the same. A message written on the board isn't touched: its
|
|
157
|
+
* author may mean to ping a group. Code isn't spared: what Slack takes for code isn't what a regex
|
|
158
|
+
* here does (an escaped backtick, runs that don't match, a fence nobody closed), and guessing wrong
|
|
159
|
+
* pings a channel, where a joiner in copied code is only in the way.
|
|
160
|
+
*/
|
|
161
|
+
export declare const withoutBroadcasts: (markdown: string) => string;
|
|
152
162
|
/** GitHub's markdown allows inline HTML, which Slack shows as raw tags: as markdown instead, outside code. */
|
|
153
163
|
export declare function withoutHtml(markdown: string): string;
|
|
154
164
|
/**
|
|
@@ -161,6 +171,13 @@ type SlackUser = {
|
|
|
161
171
|
name?: string;
|
|
162
172
|
real_name?: string;
|
|
163
173
|
is_bot?: boolean;
|
|
174
|
+
/** A guest: one channel or several, never every public channel. */
|
|
175
|
+
is_restricted?: boolean;
|
|
176
|
+
is_ultra_restricted?: boolean;
|
|
177
|
+
/** Someone from another organization, in a Slack Connect channel. */
|
|
178
|
+
is_stranger?: boolean;
|
|
179
|
+
/** The workspace they belong to: the app's own for its people, another's for a Slack Connect member. */
|
|
180
|
+
team_id?: string;
|
|
164
181
|
profile?: {
|
|
165
182
|
display_name?: string;
|
|
166
183
|
real_name?: string;
|
|
@@ -401,7 +418,7 @@ export declare class SlackProvider extends ChatSyncProvider<SlackEvent> {
|
|
|
401
418
|
private scopes;
|
|
402
419
|
constructor(given: SlackOptions, sync: SyncFn<SlackEvent>);
|
|
403
420
|
/**
|
|
404
|
-
* A message goes out under its author's name (`
|
|
421
|
+
* A message goes out under its author's name (`Ada Lovelace`, `clever-lemur via acme-agents`,
|
|
405
422
|
* `Malte via support (slack)`), and their picture when it has one Slack can show, instead of the
|
|
406
423
|
* app's, with the text's `**name**: ` label dropped. Without `chat:write.customize` it posts as
|
|
407
424
|
* the app, label and all.
|