slack-term 1.53.0 → 1.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -251,7 +251,7 @@ Use: slack tail "#channel" --me`),process.exit(1);if(!t)console.error("Usage: sl
|
|
|
251
251
|
`))>=0){let s=e.slice(0,n);e=e.slice(n+2);let r="message",o,i=[];for(let l of s.split(`
|
|
252
252
|
`)){if(!l||l.startsWith(":"))continue;let u=l.indexOf(":"),a=u<0?l:l.slice(0,u),c=u<0?"":l.slice(u+1).replace(/^ /,"");if(a==="event")r=c;else if(a==="data")i.push(c);else if(a==="id")o=c}if(i.length)t(r,i.join(`
|
|
253
253
|
`),o)}return e}var mw="slack-term-relay.v1";function yw(e){return`bearer.${Buffer.from(e,"utf8").toString("base64url")}`}function Da(e){return e==="websocket"||e==="sse"?e:"auto"}var bw=32;function sf(e){return e===void 0?"":`?after=${e.seq}${e.epoch?`&epoch=${encodeURIComponent(e.epoch)}`:""}`}function ka(e,t,n=70000,s={}){let r=e.replace(/\/+$/,""),o=s.transport??"auto",i=Dw(r,t,n);return async(l,u,a)=>{let c=s.WebSocket===void 0?globalThis.WebSocket:s.WebSocket;if(o!=="sse")if(!c){if(o==="websocket")throw Error("relay: this runtime has no WebSocket")}else{if(await ww(c,r,t,n,s.pingMs??25000,s.ackDelayMs??100,l,u,a)||u.aborted)return;if(o==="websocket")throw Error("relay: WebSocket connection failed")}return i(l,u,a)}}function ww(e,t,n,s,r,o,i,l,u){return new Promise((a,c)=>{if(l.aborted)return a(!0);let d;try{d=new e(`${t.replace(/^http/i,"ws")}/ws${sf(i)}`,[mw,yw(n)])}catch{return a(!1)}let f=!1,p=!1,g,h,m,y=0,w=0,x=(S)=>{if(p)return;p=!0,clearTimeout(g),clearTimeout(h),clearInterval(m),l.removeEventListener("abort",D),d.onopen=d.onmessage=d.onerror=d.onclose=null;try{d.close(1000)}catch{}if(S)c(S);else a(f||l.aborted)},D=()=>x();l.addEventListener("abort",D,{once:!0});let E=()=>{clearTimeout(g),g=setTimeout(()=>x(f?Error(`relay: no data for ${Math.round(s/1000)}s`):void 0),s)},C=()=>{if(clearTimeout(h),h=void 0,y<=w)return;w=y;try{d.send(JSON.stringify({type:"ack",seq:y}))}catch{}};E(),d.onopen=()=>{f=!0,E(),m=setInterval(()=>{try{d.send("ping")}catch{}},r)},d.onmessage=(S)=>{if(E(),typeof S.data!=="string"||S.data==="pong")return;let k;try{k=JSON.parse(S.data)}catch(O){return x(O)}if(k.type==="hello"){let{type:O,...L}=k;y=w=L.seq,u.hello({...L,via:"websocket"})}else if(k.type==="bell"&&typeof k.seq==="number"){if(u.bell(k.seq,k.bell),p)return;if(y=Math.max(y,k.seq),y-w>=bw)C();else h??=setTimeout(C,o)}},d.onerror=()=>{},d.onclose=(S)=>{if(!f||S.code===1000)return x();x(Error(`relay: WebSocket closed (${S.code}${S.reason?` ${S.reason}`:""})`))}})}function Dw(e,t,n){return async(s,r,o)=>{let i=new AbortController,l=()=>i.abort();r.addEventListener("abort",l,{once:!0});let u,a=!1,c=()=>{clearTimeout(u),u=setTimeout(()=>{a=!0,i.abort()},n)};try{c();let d=await fetch(`${e}/stream${sf(s)}`,{headers:{authorization:`Bearer ${t}`,accept:"text/event-stream"},signal:i.signal});if(d.status===401)throw new nf("relay rejected the token (401)");if(!d.ok||!d.body)throw Error(`relay: HTTP ${d.status}`);let f=d.body.getReader(),p=new TextDecoder,g="";for(;;){let{done:h,value:m}=await f.read();if(h)return;c(),g=gw((g+p.decode(m,{stream:!0})).replace(/\r\n/g,`
|
|
254
|
-
`),(y,w,x)=>{let D=JSON.parse(w);if(y==="hello")o.hello({...D,via:"sse"});else if(y==="bell"&&x!==void 0)o.bell(Number(x),D)})}}catch(d){if(r.aborted)return;if(a)throw Error(`relay: no data for ${Math.round(n/1000)}s`);throw d}finally{clearTimeout(u),r.removeEventListener("abort",l)}}}import{spawnSync as lf}from"node:child_process";import{closeSync as kw,mkdirSync as xw,openSync as Sw,readFileSync as uf,unlinkSync as of,writeFileSync as _w}from"node:fs";import{dirname as Ew}from"node:path";function rf(e){if(!e||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var af=1000;function cf(e,t){let n=e.split(/\s+/).filter(Boolean).join(" ");if(t<=1)return"";return n.length<=t?n:`${n.slice(0,t-1)}…`}function df(e){let t=`[ask-answer] ${e.link} →`,n=cf(e.answer,300),s=e.how?` (${e.how})`:"";if(e.freeText)s+=" — a free-text reply, not a choice: the question stays open";else if(e.collected)s+=" — collected ✅";let r=cf(e.question,af-t.length-n.length-s.length-8);return`${t} ${n}${s}. Q: ${r}`.slice(0,af)}var $w=(e,t)=>lf(e,t,{encoding:"utf8",timeout:60000});function Cw(e){try{let t=uf(`/proc/${e}/stat`,"utf8");return Number(t.slice(t.lastIndexOf(")")+2).split(" ")[1])||0}catch{let t=lf("ps",["-o","ppid=","-p",String(e)],{encoding:"utf8",timeout:2000});return Number((t.stdout??"").trim())||0}}function ff(e,t,n=$w,s=Cw){for(let r=0;r<4&&e>1;r++,e=s(e)){let o=n(process.env.SLACK_TERM_AY||"ay",["send",String(e),"--force",t]);if(o.error)return;let i=`${o.stdout??""}${o.stderr??""}`;if(/no agent matched/i.test(i))continue;if(o.status===0||/QUEUED|sent to pid|NOT SUBMITTED/.test(i))return e}return}function pf(e){xw(Ew(e),{recursive:!0});for(let t=0;t<2;t++)try{let n=Sw(e,"wx");return _w(n,String(process.pid)),kw(n),()=>{try{of(e)}catch{}}}catch{let n=0;try{n=Number(uf(e,"utf8").trim())}catch{}if(n&&n!==process.pid&&rf(n))return;try{of(e)}catch{}}return}import{existsSync as Fw,mkdirSync as Tw,writeFileSync as Ow}from"node:fs";import{basename as Rw,join as xa,resolve as gf}from"node:path";import{randomBytes as Iw}from"node:crypto";var hf={name:"slack-term",version:"1.
|
|
254
|
+
`),(y,w,x)=>{let D=JSON.parse(w);if(y==="hello")o.hello({...D,via:"sse"});else if(y==="bell"&&x!==void 0)o.bell(Number(x),D)})}}catch(d){if(r.aborted)return;if(a)throw Error(`relay: no data for ${Math.round(n/1000)}s`);throw d}finally{clearTimeout(u),r.removeEventListener("abort",l)}}}import{spawnSync as lf}from"node:child_process";import{closeSync as kw,mkdirSync as xw,openSync as Sw,readFileSync as uf,unlinkSync as of,writeFileSync as _w}from"node:fs";import{dirname as Ew}from"node:path";function rf(e){if(!e||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var af=1000;function cf(e,t){let n=e.split(/\s+/).filter(Boolean).join(" ");if(t<=1)return"";return n.length<=t?n:`${n.slice(0,t-1)}…`}function df(e){let t=`[ask-answer] ${e.link} →`,n=cf(e.answer,300),s=e.how?` (${e.how})`:"";if(e.freeText)s+=" — a free-text reply, not a choice: the question stays open";else if(e.collected)s+=" — collected ✅";let r=cf(e.question,af-t.length-n.length-s.length-8);return`${t} ${n}${s}. Q: ${r}`.slice(0,af)}var $w=(e,t)=>lf(e,t,{encoding:"utf8",timeout:60000});function Cw(e){try{let t=uf(`/proc/${e}/stat`,"utf8");return Number(t.slice(t.lastIndexOf(")")+2).split(" ")[1])||0}catch{let t=lf("ps",["-o","ppid=","-p",String(e)],{encoding:"utf8",timeout:2000});return Number((t.stdout??"").trim())||0}}function ff(e,t,n=$w,s=Cw){for(let r=0;r<4&&e>1;r++,e=s(e)){let o=n(process.env.SLACK_TERM_AY||"ay",["send",String(e),"--force",t]);if(o.error)return;let i=`${o.stdout??""}${o.stderr??""}`;if(/no agent matched/i.test(i))continue;if(o.status===0||/QUEUED|sent to pid|NOT SUBMITTED/.test(i))return e}return}function pf(e){xw(Ew(e),{recursive:!0});for(let t=0;t<2;t++)try{let n=Sw(e,"wx");return _w(n,String(process.pid)),kw(n),()=>{try{of(e)}catch{}}}catch{let n=0;try{n=Number(uf(e,"utf8").trim())}catch{}if(n&&n!==process.pid&&rf(n))return;try{of(e)}catch{}}return}import{existsSync as Fw,mkdirSync as Tw,writeFileSync as Ow}from"node:fs";import{basename as Rw,join as xa,resolve as gf}from"node:path";import{randomBytes as Iw}from"node:crypto";var hf={name:"slack-term",version:"1.55.0",repository:{type:"git",url:"https://github.com/snomiao/slack-term.git"},bugs:{url:"https://github.com/snomiao/slack-term/issues"},devDependencies:{"@semantic-release/commit-analyzer":"^13","@semantic-release/github":"^12","@semantic-release/npm":"^13","@semantic-release/release-notes-generator":"^14","@types/bun":"latest","@types/node":"^22","@types/yargs":"^17.0.35","@typescript/native-preview":"^7.0.0-dev.20260707.2","@vitest/coverage-istanbul":"4.1.10","semantic-release":"^24",typescript:"^5.6",vitest:"4.1.10"},bin:{slack:"./ts/cli.ts"},exports:{"./worker":"./worker/src/index.ts","./package.json":"./package.json"},description:"Slack CLI — read activity/news/mentions, search, send messages with a confirm-hash safety gate.",engines:{node:">=18"},files:["ts/","locales/","dist/","worker/src/","README.md","SKILL.md","LICENSE"],homepage:"https://github.com/snomiao/slack-term",keywords:["slack","cli","messaging","agent","terminal"],license:"MIT",overrides:{"@semantic-release/npm":"^13","@semantic-release/github":"^12"},publishConfig:{access:"public",bin:{slack:"./dist/cli.js"}},scripts:{dev:"bun run ts/cli.ts",build:"bun build ts/cli.ts --target=node --outfile dist/cli.js --minify",typecheck:"tsgo --noEmit","typecheck:tsc":"tsc --noEmit","typecheck:worker":"bun install --cwd worker --frozen-lockfile && tsgo --noEmit -p worker",test:"bun test tests/ --timeout 90000 --parallel=2","test:watch":"bun test tests/ --timeout 90000 --isolate --watch","test:parity":"bash tests/parity.sh",record:"bun run tests/record.ts",anonymize:"bun run tests/anonymize.ts","scan-pii":"bash .githooks/pre-commit","scan-pii:all":"bash .githooks/pre-commit --all",prepare:"git config core.hooksPath .githooks 2>/dev/null || true",prepublishOnly:"bun run scan-pii:all && bun run typecheck && bun run build","test:coverage":"vitest run --coverage --exclude tests/parity.test.ts --no-file-parallelism"},type:"module",dependencies:{yargs:"^18.0.0"},peerDependencies:{"@cloudflare/workers-types":"^4"},peerDependenciesMeta:{"@cloudflare/workers-types":{optional:!0}}};var vw="4.105.0",Pw="2026-07-01",Sa="slack-term-relay",Lw="https://github.com/snomiao/slack-term/blob/main/worker/README.md";function Nw(e){return/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(e)}function Mw(e){return Rw(gf(e)).toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63).replace(/-+$/,"")||Sa}function Bw(e,t={}){let n={name:e,private:!0,type:"module",scripts:{deploy:"wrangler deploy",dev:"wrangler dev --local"},dependencies:{"slack-term":t.slackTerm??`^${hf.version}`},devDependencies:{wrangler:vw},engines:{node:">=22"}};return{"package.json":`${JSON.stringify(n,null,2)}
|
|
255
255
|
`,"wrangler.jsonc":`// slack-term relay: Slack Events API -> doorbells for \`slack stream\`.
|
|
256
256
|
// Secrets (not in this file): wrangler secret put SLACK_SIGNING_SECRET / RELAY_TOKEN / SLACK_TEAM_ID (optional)
|
|
257
257
|
{
|