@timqi/pier 0.0.25 → 0.0.26
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/agent/pi.js +16 -16
- package/dist/channels/attach.js +6 -3
- package/dist/channels/lark-outbound.js +6 -1
- package/dist/channels/lark.js +16 -4
- package/dist/channels/slack-api.js +8 -0
- package/dist/channels/slack-outbound.js +14 -5
- package/dist/channels/slack-tool.js +83 -4
- package/dist/channels/slack.js +156 -8
- package/dist/channels/telegram.js +15 -4
- package/dist/core/inbound-file.js +69 -3
- package/dist/core/reply.js +17 -5
- package/dist/core/router.js +34 -1
- package/dist/web/fs.js +6 -22
- package/dist/web/public/assets/{activity-xRauUtIM.js → activity-BJ7YoxQo.js} +1 -1
- package/dist/web/public/assets/activity-BJ7YoxQo.js.br +0 -0
- package/dist/web/public/assets/activity-BJ7YoxQo.js.gz +0 -0
- package/dist/web/public/assets/{boards-CxXk1JfX.js → boards-7GDMK7s8.js} +1 -1
- package/dist/web/public/assets/boards-7GDMK7s8.js.br +0 -0
- package/dist/web/public/assets/boards-7GDMK7s8.js.gz +0 -0
- package/dist/web/public/assets/{code-pUOkepAa.js → code-8o-S-MIZ.js} +1 -1
- package/dist/web/public/assets/{explorer-C1KiLceA.js → explorer-DBusW0TA.js} +1 -1
- package/dist/web/public/assets/explorer-DBusW0TA.js.br +0 -0
- package/dist/web/public/assets/explorer-DBusW0TA.js.gz +0 -0
- package/dist/web/public/assets/{index-D9euDszY.js → index-CquEUmXo.js} +14 -13
- package/dist/web/public/assets/index-CquEUmXo.js.br +0 -0
- package/dist/web/public/assets/index-CquEUmXo.js.gz +0 -0
- package/dist/web/public/assets/{runs-BuE-mags.js → runs-BjcdVVmW.js} +1 -1
- package/dist/web/public/assets/runs-BjcdVVmW.js.br +0 -0
- package/dist/web/public/assets/runs-BjcdVVmW.js.gz +0 -0
- package/dist/web/public/assets/{settings-5KvCAMBF.js → settings-DH3Nlk9f.js} +1 -1
- package/dist/web/public/assets/settings-DH3Nlk9f.js.br +0 -0
- package/dist/web/public/assets/settings-DH3Nlk9f.js.gz +0 -0
- package/dist/web/public/assets/{task-runs-DIlw1pXt.js → task-runs-DsOxAyRj.js} +1 -1
- package/dist/web/public/assets/task-runs-DsOxAyRj.js.br +0 -0
- package/dist/web/public/assets/task-runs-DsOxAyRj.js.gz +0 -0
- package/dist/web/public/assets/{tasks-CcAxbMR8.js → tasks-CYfdrdF2.js} +1 -1
- package/dist/web/public/assets/tasks-CYfdrdF2.js.br +0 -0
- package/dist/web/public/assets/tasks-CYfdrdF2.js.gz +0 -0
- package/dist/web/public/index.html +1 -1
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/server.js +11 -11
- package/package.json +1 -1
- package/skills/pier-slack/SKILL.md +61 -133
- package/dist/web/public/assets/activity-xRauUtIM.js.br +0 -0
- package/dist/web/public/assets/activity-xRauUtIM.js.gz +0 -0
- package/dist/web/public/assets/boards-CxXk1JfX.js.br +0 -0
- package/dist/web/public/assets/boards-CxXk1JfX.js.gz +0 -0
- package/dist/web/public/assets/explorer-C1KiLceA.js.br +0 -0
- package/dist/web/public/assets/explorer-C1KiLceA.js.gz +0 -0
- package/dist/web/public/assets/index-D9euDszY.js.br +0 -0
- package/dist/web/public/assets/index-D9euDszY.js.gz +0 -0
- package/dist/web/public/assets/runs-BuE-mags.js.br +0 -0
- package/dist/web/public/assets/runs-BuE-mags.js.gz +0 -0
- package/dist/web/public/assets/settings-5KvCAMBF.js.br +0 -0
- package/dist/web/public/assets/settings-5KvCAMBF.js.gz +0 -0
- package/dist/web/public/assets/task-runs-DIlw1pXt.js.br +0 -0
- package/dist/web/public/assets/task-runs-DIlw1pXt.js.gz +0 -0
- package/dist/web/public/assets/tasks-CcAxbMR8.js.br +0 -0
- package/dist/web/public/assets/tasks-CcAxbMR8.js.gz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,D as t,E as n,G as r,H as i,L as a,M as o,N as s,O as c,P as l,S as u,T as d,V as f,_ as p,b as m,c as h,f as g,g as _,h as v,j as y,m as b,o as x,p as S,q as C,r as w,t as T,u as E,v as D,w as O,x as k,y as A}from"./index-D9euDszY.js";import{n as j,t as M}from"./code-pUOkepAa.js";var N={display_information:{name:`Pier`,description:`Coding agent sessions in Slack threads`,background_color:`#262626`},features:{bot_user:{display_name:`Pier`,always_online:!1},app_home:{messages_tab_enabled:!0,messages_tab_read_only_enabled:!1}},oauth_config:{scopes:{bot:[`chat:write`,`reactions:write`,`channels:history`,`channels:read`,`groups:history`,`groups:read`,`im:history`,`im:write`,`mpim:history`,`mpim:read`,`mpim:write`,`users:read`,`files:read`,`files:write`]}},settings:{event_subscriptions:{bot_events:[`message.channels`,`message.groups`,`message.im`,`message.mpim`]},interactivity:{is_enabled:!0},socket_mode_enabled:!0,token_rotation_enabled:!1}},P=()=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(N))}`,F=()=>m(`Getting a bot token`,[`Open [@BotFather](https://t.me/BotFather) in Telegram.`,"Send `/newbot`, pick a display name, then a username ending in `bot`.","Copy the token it prints (`123456789:AA…`) and paste it here.","Send `/setprivacy` → `Disable` if the bot should see plain group messages. Left enabled it only ever receives mentions, replies and commands — the usual reason a bot looks dead in a group.","Send `/setjoingroups` → `Enable`, then add the bot to your group or forum."]),I=(e=`left`)=>m(`Enabling topics on a group`,["In Telegram open the group → `Edit` → turn on `Topics`. Owner only; group size no longer matters.","The group becomes a forum supergroup and the existing chat becomes its `General` topic.","Make the bot an admin with `Manage Topics`. That is the one right topic creation needs — without it Pier logs the failure and answers in General instead.","Send one message in the group so Pier discovers it, then enable it under `Chats` below.","After that, a message in General opens its own topic with its own session. A reply, or anything starting with `/`, stays where it was sent."],e);function L(){let t=_(`Create Slack app ↗`,!0);t.classList.add(`mt-1`,`w-fit`),t.onclick=()=>window.open(P(),`_blank`,`noreferrer`);let n=l(`btn w-fit text-[12.5px]`,()=>JSON.stringify(N,null,2));return m(`Creating a Slack app`,[e(`Opens Slack with every scope, event and Socket Mode already filled in. Pick your workspace → Create.`,t),"`Install to Workspace` → allow. Then `OAuth & Permissions` → copy the bot token (`xoxb-…`) into the field above.","`Basic Information` → `App-Level Tokens` → `Generate` with scope `connections:write`. Paste that `xapp-…` token below. The manifest cannot mint this one for you.","In Slack, invite the bot where you want it: `/invite @Pier`. It answers in threads only, so it never adds noise to the channel.",e(`Prefer to paste it yourself? Create the app from a manifest and use this:`,n)])}var R=()=>m(`What agent access allows`,["Gives agent sessions a `slack` tool: read a channel's history for a time range, read one thread, and post, edit or delete a message.",`Editing and deleting reach only what Pier's own bot posted — Slack refuses either on anyone else's message.`,`Pier performs every call itself — the bot token is never given to the agent, and Slack's own membership rules still apply, so the bot reaches only channels it was invited to.`,`Every read fetches live from Slack — Pier keeps no message archive.`,`This includes sessions started by tasks and subagents. Switch it off if an agent should never post to your workspace on its own.`,`The tool is only given to sessions opened while Slack is connected and this is on, so an unused tool costs no context. A session opened earlier keeps it, and a call made after you switch it off is refused with the reason.`]),z=(e=`left`)=>m(`How Slack threads work here`,[`Pier never posts in a channel's main flow. A message in the channel is answered in *its own thread*; a message in a thread is answered in that thread.`,`Each thread is its own Pi session, so one channel hosts many parallel sessions.`,`The same applies in a DM: every new message you send there starts its own thread and its own session. Reply *inside* a thread to continue that conversation.`,"Inside a thread Pier already owns, no `@mention` is needed — continuing that thread is addressing it.","Commands are bare words after a mention: `@bot settings`, `@bot stop`, `@bot bind <code>`. Slack's client swallows an unregistered `/command` before it ever reaches an app."],e),ee=()=>m(`Creating a Feishu app`,["On [open.feishu.cn](https://open.feishu.cn/app) create a 企业自建应用 (custom app). `Credentials & Basic Info` shows the App ID (`cli_…`) and App Secret — paste both here.","`Add Features` → enable **Bot** (机器人).","`Permissions` (权限管理), add: `im:message` (read messages), `im:message:send_as_bot` (send), `im:resource` (attachments, both directions), `im:message.reactions:create` + `:read` + `:delete` (the 👀 receipt), `im:chat:readonly` (chat names for this page), `contact:user.base:readonly` (speaker names).","`Events & Callbacks` → set the mode to **长连接 (long connection)** — no public URL needed. Under Events subscribe `im.message.receive_v1` (接收消息); Callbacks gain `card.action.trigger` automatically once cards are sent, add it if listed.",`**Publish a version** (版本管理与发布 → 创建版本 → 申请发布). Nothing above takes effect until this is approved — the usual reason a configured bot stays silent.`,`Add the bot to a group (群设置 → 群机器人), or DM it directly.`]),B=(e=`left`)=>m(`How Lark topics work here`,[`Pier never posts in a chat's main flow. A message in the chat is answered in *its own topic* (话题); a message inside a topic is answered there.`,`Each topic is its own Pi session, so one group hosts many parallel sessions.`,`The same applies in a DM: every new message starts its own topic and its own session. Reply *inside* a topic to continue that conversation.`,`Inside a topic Pier already owns, no @mention is needed — continuing that topic is addressing it.`,"Commands are slash words: `/stop`, `/settings`, `/bind <code>`. A bare @mention with nothing else also opens the settings panel."],e),V=[[`telegram`,`Telegram`],[`slack`,`Slack`],[`lark`,`Lark`]],H=(e,t)=>a(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,a(`span`,``,e),t),te={dm:`bg-sky-50 text-sky-700 ring-sky-200`,group:`bg-neutral-100 text-neutral-600 ring-neutral-200`,forum:`bg-violet-50 text-violet-700 ring-violet-200`},U=`pier.channelsPlatform`;function ne(e){let t=localStorage.getItem(U),o=V.some(([e])=>e===t)?t:`telegram`,l=null,d=[],f=a(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),m=a(`div`,`sticky top-0 z-30 flex items-center gap-1 border-b border-neutral-200 bg-white px-4 py-2`,f),h=a(`div`,`px-4 py-5`);e.append(a(`div`,`min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,m,h));function g(){m.replaceChildren(...V.map(([e,t])=>u(t,e===o,()=>{y&&M(),o=e,localStorage.setItem(U,e),N()})),f)}let y,x=!1,C=null;function E(e){if(f.replaceChildren(),e!==`clean`){if(f.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${S[e]}`,e===`saving`)f.append(a(`span`,`spinner`),a(`span`,``,`Saving…`));else if(e===`saved`)f.append(a(`span`,``,`✓`),a(`span`,``,`Saved`)),setTimeout(()=>{f.textContent?.includes(`Saved`)&&E(`clean`)},2e3);else{let e=v(`Retry`,`cursor-pointer underline`);e.onclick=M,f.append(a(`span`,``,`⚠`),a(`span`,``,`Save failed`),e)}}}function O(){E(`saving`),clearTimeout(y),y=setTimeout(M,500)}let k=e=>t=>{e(t),O()};async function j(e){x=!0,E(`saving`);try{E((await r(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{E(`failed`)}finally{x=!1;let e=C;C=null,e&&j(e)}}function M(){if(clearTimeout(y),y=void 0,!l)return;let e={platform:o,config:l};x?C=e:j(e)}async function N(){if(!d.length){let e=await i(`/api/models`,`Could not load the model catalog`);e.ok&&(d=e.value)}let e=await i(`/api/channels/${o}`,`Failed to load`);if(!e.ok){l=null,g(),h.replaceChildren(D(e.error));return}l=e.value,E(`clean`),W()}function P(e){let t=o===`slack`,r=o===`lark`,i=n(e.token,t?`xoxb-…`:r?`cli_…`:`123456789:AA…`,k(t=>e.token=t),!0),a=n(e.appToken,r?``:`xapp-…`,k(t=>e.appToken=t),!0),s=T(e.cwd,`(pier process cwd)`,k(t=>e.cwd=t));return p(`Connection`,t?`Pier connects over Socket Mode; no public URL or webhook needed.`:r?`Pier connects over Feishu's WebSocket long connection; no public URL or webhook needed.`:`Pier polls Telegram for updates; no public URL or webhook needed.`,c(`Enabled`,`Start the adapter when Pier boots.`,e.enabled,k(t=>{e.enabled=t,g()})),A(r?`App ID`:`Bot token`,i,{hint:`Stored locally, shown masked once saved.`,help:o===`telegram`?F():t?L():ee()}),...t?[A(`App-level token`,a,{hint:`Opens the Socket Mode connection. Needs connections:write.`}),c(`Agent access`,`Let agent sessions read channel history and post through the slack tool. Off makes the tool refuse; inbound messages are unaffected.`,e.agentTool,k(t=>e.agentTool=t),R())]:[],...r?[A(`App Secret`,a,{hint:`From Credentials & Basic Info, beside the App ID.`})]:[],A(`Default working directory`,s.el,{hint:`Where sessions this channel opens start.`}))}function ne(e){return p(`Defaults for new chats`,`Copied into a group the first time the bot sees it; changing them here never touches a group that already exists. DMs are always bound-users-only.`,c(`Require mention in groups`,`Ignore group messages that do not @mention or reply to the bot.`,e.requireMention,k(t=>e.requireMention=t)),c(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,k(t=>e.requireBind=t)),...o===`slack`?[H(`Thread mode: always on`,z())]:o===`lark`?[H(`Thread mode: always on`,B())]:[c(`Topic mode`,`In a forum group, each new request opens its own topic and its own session.`,e.topicMode,k(t=>e.topicMode=t),I())],w(`Model & reasoning`,e,d,k(t=>{e.model=t.model,e.thinking=t.thinking,W()})))}function re(e){let t=a(`span`,`font-mono text-[15px] font-semibold tracking-widest`),n=a(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,a(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),r=_(`Generate bind code`);r.onclick=async()=>{let e=await fetch(`/api/channels/${o}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:r}=await e.json();t.textContent=r,n.classList.replace(`hidden`,`flex`)};let i=a(`div`,`flex flex-col`);e.users.length||i.append(D(`No bound users yet.`));for(let t of e.users){let e=v(`Remove`,`cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100`);e.onclick=async()=>{await fetch(`/api/channels/${o}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await N()},i.append(a(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,a(`span`,`flex h-6 w-6 flex-none items-center justify-center rounded-full bg-neutral-100 text-[11px] font-semibold text-neutral-500`,(t.name[0]??`?`).toUpperCase()),a(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),a(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return p(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,i,a(`div`,`flex flex-col gap-2`,r,n))}function ie(e,t){let n=a(`div`,`rounded-xl border px-3.5 py-3 transition-colors ${t.enabled?`border-neutral-200 bg-white`:`border-neutral-200 bg-neutral-50/60`}`),r=a(`div`,`flex items-center gap-2`,a(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),b(t.kind,te[t.kind]),a(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),i=c(``,``,t.enabled,k(e=>{t.enabled=e,W()}));i.classList.add(`flex-none`,`items-center`),r.append(i);let s=a(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?s.append(a(`span`,`text-[13px] text-neutral-400`,o===`telegram`?`Direct message · bound users only, mention and topics not applicable`:`Direct message · bound users only, mention not applicable`)):s.append(c(`Require mention`,``,t.requireMention,k(e=>t.requireMention=e)),c(`Require bind`,``,t.requireBind,k(e=>t.requireBind=e)),o===`slack`?H(`Thread mode: always on`,z(`right`)):o===`lark`?H(`Thread mode: always on`,B(`right`)):t.kind===`forum`?c(`Topic mode`,``,t.topicMode,k(e=>t.topicMode=e),I(`right`)):H(`Topic mode: forum groups only`,I(`right`)));let l=T(t.cwd,``,k(e=>t.cwd=e)),u=a(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,A(`Working directory`,l.el),w(`Model & reasoning`,t,d,k(e=>{t.model=e.model,t.thinking=e.thinking,W()})));return n.append(r,s,u),n}function ae(e){let t=a(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>ie(e,t))):t.append(D(`None yet. Chats appear here after the bot sees a message in them.`)),p(o===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function W(){if(!l)return;g();let e=a(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(P(l),ne(l),re(l),ae(l)),h.replaceChildren(e)}return s(e,()=>void N(),()=>{y&&M()})}function re(){let e=a(`div`,`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`),t=a(`div`,`mx-auto flex max-w-3xl min-w-0 flex-col gap-4`),o=a(`p`,`text-[12px] break-words`),s=a(`section`,`flex min-w-0 flex-col gap-3 border-b border-neutral-200 pb-4`),u=a(`section`,`flex min-w-0 flex-col gap-3`);t.append(a(`h2`,`text-[14px] font-semibold text-neutral-700`,`Configuration sync`),o,s,u),e.append(t);let p=null,m=!1,h=!1,g=0,v=``,y=!1,b=e=>e?new Date(e).toLocaleString():`Never`;async function x(){let e=g,t=await i(`/api/config-sync`,`Could not load configuration sync`,{cache:`no-store`});if(!(h||e!==g)){if(!t.ok){d(o,`failed`,t.error);return}p=t.value,y||(v=p.sourceUrl),w()}}async function S(e){if(!m){++g,m=!0,w(),d(o,`saving`,`Working...`);try{let t=await r(`/api/config-sync`,{action:e,...e===`subscribe`?{url:v}:{}});if(!t.ok)throw Error(await f(t,`Configuration sync failed`));let n=await t.json();p=n,y=!1,v=n.sourceUrl,d(o,`saved`,n.result??`Saved`)}catch(e){d(o,`failed`,e instanceof Error?e.message:`Configuration sync failed`),await x()}finally{m=!1,h||w()}}}function C(e,t){let n=_(e);return n.disabled=m,n.onclick=()=>{S(t)},n}function w(){if(!p||h)return;if(s.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Publish`)),p.publishedPath){let e=`${p.publicUrl||window.location.origin}${p.publishedPath}`,t=n(e,``,()=>{},!0);t.readOnly=!0,t.setAttribute(`aria-label`,`Sharing URL`),s.append(t,a(`div`,`flex flex-wrap items-center gap-2`,l(`btn text-[12px]`,()=>e),C(`Revoke link`,`revoke`)))}else s.append(a(`div`,``,C(`Generate link`,`publish`)));s.append(a(`p`,`text-[12px] text-neutral-500`,`Anyone with the link can read shared prompts and model definitions. API keys, headers and endpoints stay private.`));let e=n(v,`https://example.com/config-sync/...`,e=>{v=e,y=!0},!0);e.type=`url`,e.setAttribute(`aria-label`,`Configuration source URL`),e.disabled=m||p.enabled;let t=c(`Automatic sync`,``,p.enabled,e=>{S(e?`subscribe`:`pause`)});t.querySelector(`input`).disabled=m;let r=a(`div`,`flex flex-wrap items-center gap-3`,t);p.enabled&&r.append(C(`Sync now`,`sync`)),u.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Source`),A(`Source URL`,e),r);let i=a(`dl`,`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[12px]`);for(let[e,t]of[[`Last checked`,b(p.lastChecked)],[`Last applied`,b(p.lastApplied)],[`Next check`,p.enabled?b(p.nextRunAt):`Paused`]])i.append(a(`dt`,`text-neutral-500`,e),a(`dd`,`min-w-0 break-words text-neutral-700`,t));if(u.append(i),p.error&&u.append(a(`p`,`text-[12px] break-words text-red-600`,p.error)),p.needsReload&&u.append(a(`p`,`text-[12px] text-amber-700`,`Reload pending; retry synchronization.`)),p.taskId){let e=a(`a`,`text-[12px] text-indigo-600 hover:underline`,`Sync task history`);e.href=`#/tasks/${encodeURIComponent(p.taskId)}`,u.append(e)}}x();let T=setInterval(()=>{!m&&!y&&x()},15e3);return{el:e,dispose:()=>{h=!0,clearInterval(T)}}}async function ie(e,t){let n;try{n=await r(`/api/settings`,e,`PUT`)}catch(e){return{outcome:{state:`failed`,text:`Could not save: ${String(e)}`}}}if(!n.ok)return{outcome:{state:`failed`,text:await f(n,`could not save`)}};let i;try{i=await n.json()}catch(e){return{outcome:{state:`failed`,text:`Saved, but the answer could not be read: ${String(e)}`}}}return i.toolsSync?.state===`refused`?{outcome:{state:`failed`,text:`Saved, but nothing will install it: ${i.toolsSync.reason}`},answer:i}:i.toolsSync?.state===`waiting`?{outcome:{state:`saved`,text:`Saved — a sync is already running; this change goes in the run right after it.`},answer:i}:{outcome:{state:`saved`,text:t},answer:i}}function ae(e,t){return e.enabled?{body:{tool:{name:e.name,on:!1}},saved:`Switched ${e.name} off — the next run uninstalls it. Remove it again once its binary is gone.`}:{body:{customTools:t.filter(t=>t.name!==e.name)},saved:`Removed ${e.name}.`}}function W(e,t){let l=`global`,u=null,p=0,m=0,h=``,_=null,v=[],y=``,x=null,S=null,C=()=>{S?.dispose(),S=null},w=()=>{C(),++m,S=re(),L.replaceChildren(S.el)},T=[],D=()=>v.filter(e=>e.kind===`extension`),O=e=>e.source===`binary`&&e.custom===!0,k=()=>v.filter(e=>e.kind===`tool`),N=document.createElement(`select`);N.className=`select w-full rounded-md border border-neutral-300 px-2 py-1 text-[12.5px] focus:border-indigo-400 focus:outline-none`,N.onchange=()=>{C(),l=N.value,u=null,K.clear(),te()};let P=a(`div`,`flex flex-none flex-col gap-1 border-b border-neutral-200 px-3 pb-2.5 pt-2`);P.append(a(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Scope`),N);let F=a(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),I=a(`nav`,`flex w-64 flex-none flex-col border-r border-neutral-200 text-[13px] max-md:max-h-48 max-md:w-full max-md:border-r-0 max-md:border-b`);I.append(P,F);let L=a(`div`,`flex min-w-0 flex-1 flex-col`),R=a(`div`,`flex min-h-0 flex-1 max-md:flex-col`);R.append(I,L),e.append(R);let z=(e=``)=>`?scope=${encodeURIComponent(l)}${e}`;async function ee(){if(l!==`global`){v=[],y=``;return}let e=await i(`/api/settings`,`could not be loaded`,{cache:`no-store`});if(!e.ok){v=[],y=e.error;return}B(e.value),y=``}function B(e){v=e.catalog,T=e.customTools,x=e.toolsTaskId}async function V(e,t){let{outcome:n,answer:r}=await ie(e,t);return r&&(B(r),J(_)),n}function H(e,t){let n={name:e,on:t};return v.find(t=>t.name===e)?.source===`binary`?{tool:n}:{extension:n}}async function te(){let e=++p;m++;let[t]=await Promise.all([i(`/api/config${z()}`,`failed to load config`,{cache:`no-store`}),ee()]);if(e!==p)return;if(!t.ok){J(null),Y(t.error);return}let n=t.value;l===`global`&&n.dir&&(h=n.dir,pe()),_=n,J(n),u?u.type===`sync`&&w():se()}function U(e){return a(`div`,`px-3 pb-0.5 pt-2.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e)}let ne=()=>{let e=a(`span`,`flex-none rounded bg-neutral-100 px-1 text-[10px] font-semibold uppercase tracking-wide text-neutral-500`,`link`);return e.title=`Reached through a symlink`,e},W=()=>a(`span`,`flex-none rounded bg-emerald-50 px-1 text-[10px] font-semibold uppercase tracking-wide text-emerald-700`,`on`);function G(e,t,n,r,i=0,o){let s=a(`button`,`flex w-full cursor-pointer items-center gap-1.5 py-1 pr-3 text-left hover:bg-neutral-100 ${t?`bg-indigo-50 hover:bg-indigo-50`:``} ${n?`text-neutral-400`:``}`);return s.append(a(`span`,`truncate`,e)),o&&s.append(o),s.style.paddingLeft=`${20+i*14}px`,s.title=e,s.onclick=r,s}function oe(e){let t={files:[],dirs:new Map,link:!0};for(let n of e){let e=n.name.split(`/`),r=t;for(let t of e.slice(0,-1)){let e=r.dirs.get(t);e||r.dirs.set(t,e={files:[],dirs:new Map,link:!0}),e.link&&=n.link,r=e}r.files.push({name:e[e.length-1],link:n.link})}return t}let K=new Set;function q(e,t,n,r,i,o){let s=[];for(let[c,l]of t.dirs){let t=n?`${n}/${c}`:c,u=`${e}:${t}`,d=document.createElement(`details`);d.open=K.has(u),d.ontoggle=()=>d.open?K.add(u):K.delete(u);let f=a(`summary`,`flex cursor-pointer select-none items-center gap-1 truncate py-1 pr-3 hover:bg-neutral-100`);f.style.paddingLeft=`${20+r*14}px`,f.title=t,f.append(a(`span`,`chev`,`▶`),a(`span`,`truncate text-neutral-600`,c)),l.link&&f.append(ne()),d.append(f,...q(e,l,t,r+1,i,o)),s.push(d)}for(let a of t.files){let t={type:`resource`,kind:e,name:n?`${n}/${a.name}`:a.name};s.push(G(a.name,i(t),!1,()=>o(t),r,a.link?ne():void 0))}return s}function J(e){if(!e){F.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(u),n=t=>{C(),u=t,J(e),t.type===`file`?ce(t.name):t.type===`bundled`?ue(t.name):t.type===`tools`?$():t.type===`sync`?w():fe(t.kind,t.name)},r=[];if(l===`global`){let e={type:`sync`};r.push(U(`Instance`),G(`Configuration sync`,t(e),!1,()=>n(e)))}r.push(U(`Files`));for(let i of e.files){let e={type:`file`,name:i.name};r.push(G(i.name,t(e),!i.exists,()=>n(e)))}if(l===`global`){r.push(U(`bundled with Pier`)),y?r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-red-600`,y)):D().length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`));for(let e of D()){let i={type:`bundled`,name:e.name};r.push(G(e.name,t(i),!1,()=>n(i),0,e.enabled?W():void 0))}if(!y){let e={type:`tools`},i=k().filter(e=>e.enabled).length;r.push(G(`command-line tools`,t(e),!1,()=>n(e),0,i?W():void 0))}}for(let i of[`extensions`,`skills`]){r.push(U(`${i} (read-only)`));let o=e.resources[i];o.length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),r.push(...q(i,oe(o),``,0,t,n))}F.replaceChildren(...r)}function se(){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Select a file to edit, or browse extensions and skills.`))}function Y(e){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-red-600`,e))}let X=(e,...t)=>a(`div`,`flex flex-none items-center gap-3 border-b border-neutral-200 px-4 py-2`,a(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function ce(e){let t=++m,n=await i(`/api/config/files/${encodeURIComponent(e)}${z()}`,`failed to load ${e}`,{cache:`no-store`});if(!n.ok){t===m&&Y(n.error);return}if(t!==m)return;let{content:o}=n.value,s=o,c=a(`span`,`text-[11.5px] text-neutral-400`,``),l=a(`button`,`btn btn-primary ml-auto text-[12.5px]`,`Save`),u=document.createElement(`textarea`);u.className=`block min-h-0 flex-1 resize-none bg-white p-4 font-mono text-[13px] leading-relaxed focus:outline-none`,u.spellcheck=!1,u.value=o;let p=async()=>{if(l.disabled)return;let t=u.value;l.disabled=!0,d(c,`saving`,`saving…`);try{let n=await r(`/api/config/files/${encodeURIComponent(e)}${z()}`,{content:t,expected:s},`PUT`);if(!n.ok)return d(c,`failed`,await f(n,`save failed`));let i=await n.json();s=i.content,u.value===t?(u.value=i.content,d(c,`saved`,`saved — applies to new sessions`)):d(c,`idle`,`saved; newer changes are unsaved`)}catch(e){d(c,`failed`,`save failed: ${String(e)}`)}finally{l.disabled=!1}};l.onclick=()=>void p(),u.onkeydown=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),p())},u.oninput=()=>{d(c,`idle`,`unsaved changes`)},L.replaceChildren(X(e,c,l),u),u.focus()}function le(e){if(!x)return null;let t=a(`a`,`text-indigo-600 hover:underline`,e);return t.href=`#/tasks/${encodeURIComponent(x)}`,t}let Z=()=>{let e=a(`a`,`text-indigo-600 hover:underline`,`ubix`);return e.href=`https://github.com/timqi/ubix`,e.target=`_blank`,e.rel=`noreferrer`,e};function Q(e){if(e.source!==`binary`)return``;let{spec:t,error:n,installed:r,version:i,path:a}=e.binary;return n?`${t} — ${n}`:r?`${t} — ${i??`unknown version`} at ${a??`an unknown path`}`:`${t} — not installed`}function ue(e,t){m++;let n=v.find(t=>t.name===e&&t.kind===`extension`);if(!n)return Y(`unknown extension: ${e}`);let r=a(`span`,`text-[11.5px] text-neutral-400`,``);t&&d(r,t.state,t.text);let i=le(`every run of the update task`);L.replaceChildren(X(n.name,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,n.source===`binary`?`installed by Pier`:`ships with Pier`)),a(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,a(`p`,`max-w-2xl text-[13px] leading-relaxed text-neutral-600`,n.summary),a(`dl`,`flex max-w-2xl flex-col gap-1.5`,...(n.source===`bundled`?n.adds:[]).flatMap(e=>[a(`dt`,`font-mono text-[12px] text-neutral-700`,e.name),a(`dd`,`text-[12px] leading-snug text-neutral-500`,`needs ${e.needs}`)]),...n.source===`binary`?[a(`dt`,`font-mono text-[12px] text-neutral-700`,`binary`),a(`dd`,`font-mono text-[12px] leading-snug ${n.binary.error?`text-red-600`:`text-neutral-500`}`,Q(n))]:[]),c(`Enabled`,n.source===`binary`?`Installed into Pier's own bin directory, first on the PATH every session and task inherits; it registers its own Pi extension. Switching it off uninstalls both.`:`Loaded from inside Pier — nothing is installed and no update touches your own extensions. A session mid-turn keeps the tools it started with; the next message picks this up.`,n.enabled,t=>void de(n.name,t,t=>ue(e,t))),a(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...n.source===`binary`?i?[`A daily task installs and updates it — its history is `,i,`.`]:[`Its installs run as the daily update task.`]:[`An extension of your own that registers the same tool wins: this copy stands down and says so in the log.`]),r))}function $(e,t={name:``,toml:``}){m++;let r=a(`span`,`text-[11.5px] text-neutral-400`,``);e&&d(r,e.state,e.text);let i=k(),o=le(`the update task`),s=e=>{let t=a(`div`,`flex min-w-0 flex-1 flex-col gap-0.5`,a(`span`,`flex items-center gap-2 text-[13px] text-neutral-700`,a(`span`,`font-mono`,e.name),...O(e)?[b(`yours`,`bg-neutral-50 text-neutral-500 ring-neutral-200`)]:[]),a(`span`,`text-[11.5px] leading-snug text-neutral-400`,e.summary||Q(e)),...e.summary?[a(`span`,`font-mono text-[11px] leading-snug ${e.source===`binary`&&e.binary.error?`text-red-600`:`text-neutral-400`}`,Q(e))]:[]),n=c(``,``,e.enabled,t=>void de(e.name,t,e=>$(e))),r=a(`button`,`btn text-[12px] text-neutral-500 hover:text-red-600`,`Remove`);return r.onclick=()=>{r.disabled=!0;let t=ae(e,T);V(t.body,t.saved).then(e=>$(e))},a(`div`,`flex max-w-2xl items-start gap-3 border-b border-neutral-100 py-2.5 last:border-0`,t,...O(e)?[r]:[],n)},l={...t},u=a(`span`,`font-mono text-[12px] text-neutral-500`,`[tools.<name>]`),f=n(l.name,`claude`,e=>{l.name=e,u.textContent=`[tools.${e.trim()||`<name>`}]`},!0),p=document.createElement(`textarea`);p.className=`${g} h-24 resize-y font-mono leading-snug`,p.spellcheck=!1,p.value=l.toml,p.placeholder=`spec = "github:owner/repo"
|
|
1
|
+
import{A as e,D as t,E as n,G as r,H as i,L as a,M as o,N as s,O as c,P as l,S as u,T as d,V as f,_ as p,b as m,c as h,f as g,g as _,h as v,j as y,m as b,o as x,p as S,q as C,r as w,t as T,u as E,v as D,w as O,x as k,y as A}from"./index-CquEUmXo.js";import{n as j,t as M}from"./code-8o-S-MIZ.js";var N={display_information:{name:`Pier`,description:`Coding agent sessions in Slack threads`,background_color:`#262626`},features:{bot_user:{display_name:`Pier`,always_online:!1},app_home:{messages_tab_enabled:!0,messages_tab_read_only_enabled:!1}},oauth_config:{scopes:{bot:[`chat:write`,`reactions:write`,`channels:history`,`channels:read`,`groups:history`,`groups:read`,`im:history`,`im:write`,`mpim:history`,`mpim:read`,`mpim:write`,`users:read`,`files:read`,`files:write`]}},settings:{event_subscriptions:{bot_events:[`message.channels`,`message.groups`,`message.im`,`message.mpim`]},interactivity:{is_enabled:!0},socket_mode_enabled:!0,token_rotation_enabled:!1}},P=()=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(N))}`,F=()=>m(`Getting a bot token`,[`Open [@BotFather](https://t.me/BotFather) in Telegram.`,"Send `/newbot`, pick a display name, then a username ending in `bot`.","Copy the token it prints (`123456789:AA…`) and paste it here.","Send `/setprivacy` → `Disable` if the bot should see plain group messages. Left enabled it only ever receives mentions, replies and commands — the usual reason a bot looks dead in a group.","Send `/setjoingroups` → `Enable`, then add the bot to your group or forum."]),I=(e=`left`)=>m(`Enabling topics on a group`,["In Telegram open the group → `Edit` → turn on `Topics`. Owner only; group size no longer matters.","The group becomes a forum supergroup and the existing chat becomes its `General` topic.","Make the bot an admin with `Manage Topics`. That is the one right topic creation needs — without it Pier logs the failure and answers in General instead.","Send one message in the group so Pier discovers it, then enable it under `Chats` below.","After that, a message in General opens its own topic with its own session. A reply, or anything starting with `/`, stays where it was sent."],e);function L(){let t=_(`Create Slack app ↗`,!0);t.classList.add(`mt-1`,`w-fit`),t.onclick=()=>window.open(P(),`_blank`,`noreferrer`);let n=l(`btn w-fit text-[12.5px]`,()=>JSON.stringify(N,null,2));return m(`Creating a Slack app`,[e(`Opens Slack with every scope, event and Socket Mode already filled in. Pick your workspace → Create.`,t),"`Install to Workspace` → allow. Then `OAuth & Permissions` → copy the bot token (`xoxb-…`) into the field above.","`Basic Information` → `App-Level Tokens` → `Generate` with scope `connections:write`. Paste that `xapp-…` token below. The manifest cannot mint this one for you.","In Slack, invite the bot where you want it: `/invite @Pier`. It answers in threads only, so it never adds noise to the channel.",e(`Prefer to paste it yourself? Create the app from a manifest and use this:`,n)])}var R=()=>m(`What agent access allows`,["Gives agent sessions a `slack` tool: read a channel's history for a time range, read one thread, and post, edit or delete a message.",`Editing and deleting reach only what Pier's own bot posted — Slack refuses either on anyone else's message.`,`Pier performs every call itself — the bot token is never given to the agent, and Slack's own membership rules still apply, so the bot reaches only channels it was invited to.`,`Every read fetches live from Slack — Pier keeps no message archive.`,`This includes sessions started by tasks and subagents. Switch it off if an agent should never post to your workspace on its own.`,`The tool is only given to sessions opened while Slack is connected and this is on, so an unused tool costs no context. A session opened earlier keeps it, and a call made after you switch it off is refused with the reason.`]),z=(e=`left`)=>m(`How Slack threads work here`,[`Pier never posts in a channel's main flow. A message in the channel is answered in *its own thread*; a message in a thread is answered in that thread.`,`Each thread is its own Pi session, so one channel hosts many parallel sessions.`,`The same applies in a DM: every new message you send there starts its own thread and its own session. Reply *inside* a thread to continue that conversation.`,"Inside a thread Pier already owns, no `@mention` is needed — continuing that thread is addressing it.","Commands are bare words after a mention: `@bot settings`, `@bot stop`, `@bot bind <code>`. Slack's client swallows an unregistered `/command` before it ever reaches an app."],e),ee=()=>m(`Creating a Feishu app`,["On [open.feishu.cn](https://open.feishu.cn/app) create a 企业自建应用 (custom app). `Credentials & Basic Info` shows the App ID (`cli_…`) and App Secret — paste both here.","`Add Features` → enable **Bot** (机器人).","`Permissions` (权限管理), add: `im:message` (read messages), `im:message:send_as_bot` (send), `im:resource` (attachments, both directions), `im:message.reactions:create` + `:read` + `:delete` (the 👀 receipt), `im:chat:readonly` (chat names for this page), `contact:user.base:readonly` (speaker names).","`Events & Callbacks` → set the mode to **长连接 (long connection)** — no public URL needed. Under Events subscribe `im.message.receive_v1` (接收消息); Callbacks gain `card.action.trigger` automatically once cards are sent, add it if listed.",`**Publish a version** (版本管理与发布 → 创建版本 → 申请发布). Nothing above takes effect until this is approved — the usual reason a configured bot stays silent.`,`Add the bot to a group (群设置 → 群机器人), or DM it directly.`]),B=(e=`left`)=>m(`How Lark topics work here`,[`Pier never posts in a chat's main flow. A message in the chat is answered in *its own topic* (话题); a message inside a topic is answered there.`,`Each topic is its own Pi session, so one group hosts many parallel sessions.`,`The same applies in a DM: every new message starts its own topic and its own session. Reply *inside* a topic to continue that conversation.`,`Inside a topic Pier already owns, no @mention is needed — continuing that topic is addressing it.`,"Commands are slash words: `/stop`, `/settings`, `/bind <code>`. A bare @mention with nothing else also opens the settings panel."],e),V=[[`telegram`,`Telegram`],[`slack`,`Slack`],[`lark`,`Lark`]],H=(e,t)=>a(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,a(`span`,``,e),t),te={dm:`bg-sky-50 text-sky-700 ring-sky-200`,group:`bg-neutral-100 text-neutral-600 ring-neutral-200`,forum:`bg-violet-50 text-violet-700 ring-violet-200`},U=`pier.channelsPlatform`;function ne(e){let t=localStorage.getItem(U),o=V.some(([e])=>e===t)?t:`telegram`,l=null,d=[],f=a(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),m=a(`div`,`sticky top-0 z-30 flex items-center gap-1 border-b border-neutral-200 bg-white px-4 py-2`,f),h=a(`div`,`px-4 py-5`);e.append(a(`div`,`min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,m,h));function g(){m.replaceChildren(...V.map(([e,t])=>u(t,e===o,()=>{y&&M(),o=e,localStorage.setItem(U,e),N()})),f)}let y,x=!1,C=null;function E(e){if(f.replaceChildren(),e!==`clean`){if(f.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${S[e]}`,e===`saving`)f.append(a(`span`,`spinner`),a(`span`,``,`Saving…`));else if(e===`saved`)f.append(a(`span`,``,`✓`),a(`span`,``,`Saved`)),setTimeout(()=>{f.textContent?.includes(`Saved`)&&E(`clean`)},2e3);else{let e=v(`Retry`,`cursor-pointer underline`);e.onclick=M,f.append(a(`span`,``,`⚠`),a(`span`,``,`Save failed`),e)}}}function O(){E(`saving`),clearTimeout(y),y=setTimeout(M,500)}let k=e=>t=>{e(t),O()};async function j(e){x=!0,E(`saving`);try{E((await r(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{E(`failed`)}finally{x=!1;let e=C;C=null,e&&j(e)}}function M(){if(clearTimeout(y),y=void 0,!l)return;let e={platform:o,config:l};x?C=e:j(e)}async function N(){if(!d.length){let e=await i(`/api/models`,`Could not load the model catalog`);e.ok&&(d=e.value)}let e=await i(`/api/channels/${o}`,`Failed to load`);if(!e.ok){l=null,g(),h.replaceChildren(D(e.error));return}l=e.value,E(`clean`),W()}function P(e){let t=o===`slack`,r=o===`lark`,i=n(e.token,t?`xoxb-…`:r?`cli_…`:`123456789:AA…`,k(t=>e.token=t),!0),a=n(e.appToken,r?``:`xapp-…`,k(t=>e.appToken=t),!0),s=T(e.cwd,`(pier process cwd)`,k(t=>e.cwd=t));return p(`Connection`,t?`Pier connects over Socket Mode; no public URL or webhook needed.`:r?`Pier connects over Feishu's WebSocket long connection; no public URL or webhook needed.`:`Pier polls Telegram for updates; no public URL or webhook needed.`,c(`Enabled`,`Start the adapter when Pier boots.`,e.enabled,k(t=>{e.enabled=t,g()})),A(r?`App ID`:`Bot token`,i,{hint:`Stored locally, shown masked once saved.`,help:o===`telegram`?F():t?L():ee()}),...t?[A(`App-level token`,a,{hint:`Opens the Socket Mode connection. Needs connections:write.`}),c(`Agent access`,`Let agent sessions read channel history and post through the slack tool. Off makes the tool refuse; inbound messages are unaffected.`,e.agentTool,k(t=>e.agentTool=t),R())]:[],...r?[A(`App Secret`,a,{hint:`From Credentials & Basic Info, beside the App ID.`})]:[],A(`Default working directory`,s.el,{hint:`Where sessions this channel opens start.`}))}function ne(e){return p(`Defaults for new chats`,`Copied into a group the first time the bot sees it; changing them here never touches a group that already exists. DMs are always bound-users-only.`,c(`Require mention in groups`,`Ignore group messages that do not @mention or reply to the bot.`,e.requireMention,k(t=>e.requireMention=t)),c(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,k(t=>e.requireBind=t)),...o===`slack`?[H(`Thread mode: always on`,z())]:o===`lark`?[H(`Thread mode: always on`,B())]:[c(`Topic mode`,`In a forum group, each new request opens its own topic and its own session.`,e.topicMode,k(t=>e.topicMode=t),I())],w(`Model & reasoning`,e,d,k(t=>{e.model=t.model,e.thinking=t.thinking,W()})))}function re(e){let t=a(`span`,`font-mono text-[15px] font-semibold tracking-widest`),n=a(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,a(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),r=_(`Generate bind code`);r.onclick=async()=>{let e=await fetch(`/api/channels/${o}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:r}=await e.json();t.textContent=r,n.classList.replace(`hidden`,`flex`)};let i=a(`div`,`flex flex-col`);e.users.length||i.append(D(`No bound users yet.`));for(let t of e.users){let e=v(`Remove`,`cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100`);e.onclick=async()=>{await fetch(`/api/channels/${o}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await N()},i.append(a(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,a(`span`,`flex h-6 w-6 flex-none items-center justify-center rounded-full bg-neutral-100 text-[11px] font-semibold text-neutral-500`,(t.name[0]??`?`).toUpperCase()),a(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),a(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return p(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,i,a(`div`,`flex flex-col gap-2`,r,n))}function ie(e,t){let n=a(`div`,`rounded-xl border px-3.5 py-3 transition-colors ${t.enabled?`border-neutral-200 bg-white`:`border-neutral-200 bg-neutral-50/60`}`),r=a(`div`,`flex items-center gap-2`,a(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),b(t.kind,te[t.kind]),a(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),i=c(``,``,t.enabled,k(e=>{t.enabled=e,W()}));i.classList.add(`flex-none`,`items-center`),r.append(i);let s=a(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?s.append(a(`span`,`text-[13px] text-neutral-400`,o===`telegram`?`Direct message · bound users only, mention and topics not applicable`:`Direct message · bound users only, mention not applicable`)):s.append(c(`Require mention`,``,t.requireMention,k(e=>t.requireMention=e)),c(`Require bind`,``,t.requireBind,k(e=>t.requireBind=e)),o===`slack`?H(`Thread mode: always on`,z(`right`)):o===`lark`?H(`Thread mode: always on`,B(`right`)):t.kind===`forum`?c(`Topic mode`,``,t.topicMode,k(e=>t.topicMode=e),I(`right`)):H(`Topic mode: forum groups only`,I(`right`)));let l=T(t.cwd,``,k(e=>t.cwd=e)),u=a(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,A(`Working directory`,l.el),w(`Model & reasoning`,t,d,k(e=>{t.model=e.model,t.thinking=e.thinking,W()})));return n.append(r,s,u),n}function ae(e){let t=a(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>ie(e,t))):t.append(D(`None yet. Chats appear here after the bot sees a message in them.`)),p(o===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function W(){if(!l)return;g();let e=a(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(P(l),ne(l),re(l),ae(l)),h.replaceChildren(e)}return s(e,()=>void N(),()=>{y&&M()})}function re(){let e=a(`div`,`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`),t=a(`div`,`mx-auto flex max-w-3xl min-w-0 flex-col gap-4`),o=a(`p`,`text-[12px] break-words`),s=a(`section`,`flex min-w-0 flex-col gap-3 border-b border-neutral-200 pb-4`),u=a(`section`,`flex min-w-0 flex-col gap-3`);t.append(a(`h2`,`text-[14px] font-semibold text-neutral-700`,`Configuration sync`),o,s,u),e.append(t);let p=null,m=!1,h=!1,g=0,v=``,y=!1,b=e=>e?new Date(e).toLocaleString():`Never`;async function x(){let e=g,t=await i(`/api/config-sync`,`Could not load configuration sync`,{cache:`no-store`});if(!(h||e!==g)){if(!t.ok){d(o,`failed`,t.error);return}p=t.value,y||(v=p.sourceUrl),w()}}async function S(e){if(!m){++g,m=!0,w(),d(o,`saving`,`Working...`);try{let t=await r(`/api/config-sync`,{action:e,...e===`subscribe`?{url:v}:{}});if(!t.ok)throw Error(await f(t,`Configuration sync failed`));let n=await t.json();p=n,y=!1,v=n.sourceUrl,d(o,`saved`,n.result??`Saved`)}catch(e){d(o,`failed`,e instanceof Error?e.message:`Configuration sync failed`),await x()}finally{m=!1,h||w()}}}function C(e,t){let n=_(e);return n.disabled=m,n.onclick=()=>{S(t)},n}function w(){if(!p||h)return;if(s.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Publish`)),p.publishedPath){let e=`${p.publicUrl||window.location.origin}${p.publishedPath}`,t=n(e,``,()=>{},!0);t.readOnly=!0,t.setAttribute(`aria-label`,`Sharing URL`),s.append(t,a(`div`,`flex flex-wrap items-center gap-2`,l(`btn text-[12px]`,()=>e),C(`Revoke link`,`revoke`)))}else s.append(a(`div`,``,C(`Generate link`,`publish`)));s.append(a(`p`,`text-[12px] text-neutral-500`,`Anyone with the link can read shared prompts and model definitions. API keys, headers and endpoints stay private.`));let e=n(v,`https://example.com/config-sync/...`,e=>{v=e,y=!0},!0);e.type=`url`,e.setAttribute(`aria-label`,`Configuration source URL`),e.disabled=m||p.enabled;let t=c(`Automatic sync`,``,p.enabled,e=>{S(e?`subscribe`:`pause`)});t.querySelector(`input`).disabled=m;let r=a(`div`,`flex flex-wrap items-center gap-3`,t);p.enabled&&r.append(C(`Sync now`,`sync`)),u.replaceChildren(a(`h3`,`text-[13px] font-medium text-neutral-700`,`Source`),A(`Source URL`,e),r);let i=a(`dl`,`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[12px]`);for(let[e,t]of[[`Last checked`,b(p.lastChecked)],[`Last applied`,b(p.lastApplied)],[`Next check`,p.enabled?b(p.nextRunAt):`Paused`]])i.append(a(`dt`,`text-neutral-500`,e),a(`dd`,`min-w-0 break-words text-neutral-700`,t));if(u.append(i),p.error&&u.append(a(`p`,`text-[12px] break-words text-red-600`,p.error)),p.needsReload&&u.append(a(`p`,`text-[12px] text-amber-700`,`Reload pending; retry synchronization.`)),p.taskId){let e=a(`a`,`text-[12px] text-indigo-600 hover:underline`,`Sync task history`);e.href=`#/tasks/${encodeURIComponent(p.taskId)}`,u.append(e)}}x();let T=setInterval(()=>{!m&&!y&&x()},15e3);return{el:e,dispose:()=>{h=!0,clearInterval(T)}}}async function ie(e,t){let n;try{n=await r(`/api/settings`,e,`PUT`)}catch(e){return{outcome:{state:`failed`,text:`Could not save: ${String(e)}`}}}if(!n.ok)return{outcome:{state:`failed`,text:await f(n,`could not save`)}};let i;try{i=await n.json()}catch(e){return{outcome:{state:`failed`,text:`Saved, but the answer could not be read: ${String(e)}`}}}return i.toolsSync?.state===`refused`?{outcome:{state:`failed`,text:`Saved, but nothing will install it: ${i.toolsSync.reason}`},answer:i}:i.toolsSync?.state===`waiting`?{outcome:{state:`saved`,text:`Saved — a sync is already running; this change goes in the run right after it.`},answer:i}:{outcome:{state:`saved`,text:t},answer:i}}function ae(e,t){return e.enabled?{body:{tool:{name:e.name,on:!1}},saved:`Switched ${e.name} off — the next run uninstalls it. Remove it again once its binary is gone.`}:{body:{customTools:t.filter(t=>t.name!==e.name)},saved:`Removed ${e.name}.`}}function W(e,t){let l=`global`,u=null,p=0,m=0,h=``,_=null,v=[],y=``,x=null,S=null,C=()=>{S?.dispose(),S=null},w=()=>{C(),++m,S=re(),L.replaceChildren(S.el)},T=[],D=()=>v.filter(e=>e.kind===`extension`),O=e=>e.source===`binary`&&e.custom===!0,k=()=>v.filter(e=>e.kind===`tool`),N=document.createElement(`select`);N.className=`select w-full rounded-md border border-neutral-300 px-2 py-1 text-[12.5px] focus:border-indigo-400 focus:outline-none`,N.onchange=()=>{C(),l=N.value,u=null,K.clear(),te()};let P=a(`div`,`flex flex-none flex-col gap-1 border-b border-neutral-200 px-3 pb-2.5 pt-2`);P.append(a(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Scope`),N);let F=a(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),I=a(`nav`,`flex w-64 flex-none flex-col border-r border-neutral-200 text-[13px] max-md:max-h-48 max-md:w-full max-md:border-r-0 max-md:border-b`);I.append(P,F);let L=a(`div`,`flex min-w-0 flex-1 flex-col`),R=a(`div`,`flex min-h-0 flex-1 max-md:flex-col`);R.append(I,L),e.append(R);let z=(e=``)=>`?scope=${encodeURIComponent(l)}${e}`;async function ee(){if(l!==`global`){v=[],y=``;return}let e=await i(`/api/settings`,`could not be loaded`,{cache:`no-store`});if(!e.ok){v=[],y=e.error;return}B(e.value),y=``}function B(e){v=e.catalog,T=e.customTools,x=e.toolsTaskId}async function V(e,t){let{outcome:n,answer:r}=await ie(e,t);return r&&(B(r),J(_)),n}function H(e,t){let n={name:e,on:t};return v.find(t=>t.name===e)?.source===`binary`?{tool:n}:{extension:n}}async function te(){let e=++p;m++;let[t]=await Promise.all([i(`/api/config${z()}`,`failed to load config`,{cache:`no-store`}),ee()]);if(e!==p)return;if(!t.ok){J(null),Y(t.error);return}let n=t.value;l===`global`&&n.dir&&(h=n.dir,pe()),_=n,J(n),u?u.type===`sync`&&w():se()}function U(e){return a(`div`,`px-3 pb-0.5 pt-2.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e)}let ne=()=>{let e=a(`span`,`flex-none rounded bg-neutral-100 px-1 text-[10px] font-semibold uppercase tracking-wide text-neutral-500`,`link`);return e.title=`Reached through a symlink`,e},W=()=>a(`span`,`flex-none rounded bg-emerald-50 px-1 text-[10px] font-semibold uppercase tracking-wide text-emerald-700`,`on`);function G(e,t,n,r,i=0,o){let s=a(`button`,`flex w-full cursor-pointer items-center gap-1.5 py-1 pr-3 text-left hover:bg-neutral-100 ${t?`bg-indigo-50 hover:bg-indigo-50`:``} ${n?`text-neutral-400`:``}`);return s.append(a(`span`,`truncate`,e)),o&&s.append(o),s.style.paddingLeft=`${20+i*14}px`,s.title=e,s.onclick=r,s}function oe(e){let t={files:[],dirs:new Map,link:!0};for(let n of e){let e=n.name.split(`/`),r=t;for(let t of e.slice(0,-1)){let e=r.dirs.get(t);e||r.dirs.set(t,e={files:[],dirs:new Map,link:!0}),e.link&&=n.link,r=e}r.files.push({name:e[e.length-1],link:n.link})}return t}let K=new Set;function q(e,t,n,r,i,o){let s=[];for(let[c,l]of t.dirs){let t=n?`${n}/${c}`:c,u=`${e}:${t}`,d=document.createElement(`details`);d.open=K.has(u),d.ontoggle=()=>d.open?K.add(u):K.delete(u);let f=a(`summary`,`flex cursor-pointer select-none items-center gap-1 truncate py-1 pr-3 hover:bg-neutral-100`);f.style.paddingLeft=`${20+r*14}px`,f.title=t,f.append(a(`span`,`chev`,`▶`),a(`span`,`truncate text-neutral-600`,c)),l.link&&f.append(ne()),d.append(f,...q(e,l,t,r+1,i,o)),s.push(d)}for(let a of t.files){let t={type:`resource`,kind:e,name:n?`${n}/${a.name}`:a.name};s.push(G(a.name,i(t),!1,()=>o(t),r,a.link?ne():void 0))}return s}function J(e){if(!e){F.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(u),n=t=>{C(),u=t,J(e),t.type===`file`?ce(t.name):t.type===`bundled`?ue(t.name):t.type===`tools`?$():t.type===`sync`?w():fe(t.kind,t.name)},r=[];if(l===`global`){let e={type:`sync`};r.push(U(`Instance`),G(`Configuration sync`,t(e),!1,()=>n(e)))}r.push(U(`Files`));for(let i of e.files){let e={type:`file`,name:i.name};r.push(G(i.name,t(e),!i.exists,()=>n(e)))}if(l===`global`){r.push(U(`bundled with Pier`)),y?r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-red-600`,y)):D().length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`));for(let e of D()){let i={type:`bundled`,name:e.name};r.push(G(e.name,t(i),!1,()=>n(i),0,e.enabled?W():void 0))}if(!y){let e={type:`tools`},i=k().filter(e=>e.enabled).length;r.push(G(`command-line tools`,t(e),!1,()=>n(e),0,i?W():void 0))}}for(let i of[`extensions`,`skills`]){r.push(U(`${i} (read-only)`));let o=e.resources[i];o.length||r.push(a(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),r.push(...q(i,oe(o),``,0,t,n))}F.replaceChildren(...r)}function se(){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Select a file to edit, or browse extensions and skills.`))}function Y(e){L.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-red-600`,e))}let X=(e,...t)=>a(`div`,`flex flex-none items-center gap-3 border-b border-neutral-200 px-4 py-2`,a(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function ce(e){let t=++m,n=await i(`/api/config/files/${encodeURIComponent(e)}${z()}`,`failed to load ${e}`,{cache:`no-store`});if(!n.ok){t===m&&Y(n.error);return}if(t!==m)return;let{content:o}=n.value,s=o,c=a(`span`,`text-[11.5px] text-neutral-400`,``),l=a(`button`,`btn btn-primary ml-auto text-[12.5px]`,`Save`),u=document.createElement(`textarea`);u.className=`block min-h-0 flex-1 resize-none bg-white p-4 font-mono text-[13px] leading-relaxed focus:outline-none`,u.spellcheck=!1,u.value=o;let p=async()=>{if(l.disabled)return;let t=u.value;l.disabled=!0,d(c,`saving`,`saving…`);try{let n=await r(`/api/config/files/${encodeURIComponent(e)}${z()}`,{content:t,expected:s},`PUT`);if(!n.ok)return d(c,`failed`,await f(n,`save failed`));let i=await n.json();s=i.content,u.value===t?(u.value=i.content,d(c,`saved`,`saved — applies to new sessions`)):d(c,`idle`,`saved; newer changes are unsaved`)}catch(e){d(c,`failed`,`save failed: ${String(e)}`)}finally{l.disabled=!1}};l.onclick=()=>void p(),u.onkeydown=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),p())},u.oninput=()=>{d(c,`idle`,`unsaved changes`)},L.replaceChildren(X(e,c,l),u),u.focus()}function le(e){if(!x)return null;let t=a(`a`,`text-indigo-600 hover:underline`,e);return t.href=`#/tasks/${encodeURIComponent(x)}`,t}let Z=()=>{let e=a(`a`,`text-indigo-600 hover:underline`,`ubix`);return e.href=`https://github.com/timqi/ubix`,e.target=`_blank`,e.rel=`noreferrer`,e};function Q(e){if(e.source!==`binary`)return``;let{spec:t,error:n,installed:r,version:i,path:a}=e.binary;return n?`${t} — ${n}`:r?`${t} — ${i??`unknown version`} at ${a??`an unknown path`}`:`${t} — not installed`}function ue(e,t){m++;let n=v.find(t=>t.name===e&&t.kind===`extension`);if(!n)return Y(`unknown extension: ${e}`);let r=a(`span`,`text-[11.5px] text-neutral-400`,``);t&&d(r,t.state,t.text);let i=le(`every run of the update task`);L.replaceChildren(X(n.name,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,n.source===`binary`?`installed by Pier`:`ships with Pier`)),a(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,a(`p`,`max-w-2xl text-[13px] leading-relaxed text-neutral-600`,n.summary),a(`dl`,`flex max-w-2xl flex-col gap-1.5`,...(n.source===`bundled`?n.adds:[]).flatMap(e=>[a(`dt`,`font-mono text-[12px] text-neutral-700`,e.name),a(`dd`,`text-[12px] leading-snug text-neutral-500`,`needs ${e.needs}`)]),...n.source===`binary`?[a(`dt`,`font-mono text-[12px] text-neutral-700`,`binary`),a(`dd`,`font-mono text-[12px] leading-snug ${n.binary.error?`text-red-600`:`text-neutral-500`}`,Q(n))]:[]),c(`Enabled`,n.source===`binary`?`Installed into Pier's own bin directory, first on the PATH every session and task inherits; it registers its own Pi extension. Switching it off uninstalls both.`:`Loaded from inside Pier — nothing is installed and no update touches your own extensions. A session mid-turn keeps the tools it started with; the next message picks this up.`,n.enabled,t=>void de(n.name,t,t=>ue(e,t))),a(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...n.source===`binary`?i?[`A daily task installs and updates it — its history is `,i,`.`]:[`Its installs run as the daily update task.`]:[`An extension of your own that registers the same tool wins: this copy stands down and says so in the log.`]),r))}function $(e,t={name:``,toml:``}){m++;let r=a(`span`,`text-[11.5px] text-neutral-400`,``);e&&d(r,e.state,e.text);let i=k(),o=le(`the update task`),s=e=>{let t=a(`div`,`flex min-w-0 flex-1 flex-col gap-0.5`,a(`span`,`flex items-center gap-2 text-[13px] text-neutral-700`,a(`span`,`font-mono`,e.name),...O(e)?[b(`yours`,`bg-neutral-50 text-neutral-500 ring-neutral-200`)]:[]),a(`span`,`text-[11.5px] leading-snug text-neutral-400`,e.summary||Q(e)),...e.summary?[a(`span`,`font-mono text-[11px] leading-snug ${e.source===`binary`&&e.binary.error?`text-red-600`:`text-neutral-400`}`,Q(e))]:[]),n=c(``,``,e.enabled,t=>void de(e.name,t,e=>$(e))),r=a(`button`,`btn text-[12px] text-neutral-500 hover:text-red-600`,`Remove`);return r.onclick=()=>{r.disabled=!0;let t=ae(e,T);V(t.body,t.saved).then(e=>$(e))},a(`div`,`flex max-w-2xl items-start gap-3 border-b border-neutral-100 py-2.5 last:border-0`,t,...O(e)?[r]:[],n)},l={...t},u=a(`span`,`font-mono text-[12px] text-neutral-500`,`[tools.<name>]`),f=n(l.name,`claude`,e=>{l.name=e,u.textContent=`[tools.${e.trim()||`<name>`}]`},!0),p=document.createElement(`textarea`);p.className=`${g} h-24 resize-y font-mono leading-snug`,p.spellcheck=!1,p.value=l.toml,p.placeholder=`spec = "github:owner/repo"
|
|
2
2
|
exe = "tool"`,p.oninput=()=>l.toml=p.value;let h=a(`button`,`btn btn-primary text-[12.5px]`,`Add`);h.onclick=()=>{let e={name:l.name.trim(),toml:l.toml.trim()};if(!e.name||!e.toml)return d(r,`failed`,`A custom tool needs a name and a block with a spec line.`);h.disabled=!0,V({customTools:[...T,e],tool:{name:e.name,on:!0}},`Added ${e.name} — installing now.`).then(e=>$(e,e.state===`failed`?l:void 0))},L.replaceChildren(X(`command-line tools`,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`installed by Pier`)),a(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,a(`p`,`max-w-2xl text-[12.5px] leading-relaxed text-neutral-500`,`Pier writes no downloader: `,Z(),` does the work — a declarative installer that resolves a spec like `,a(`span`,`font-mono text-[11.5px]`,`github:owner/repo`),` to the right release asset for this machine, verifies it, and upgrades in place. Pier bootstraps it, generates its config from the switches below, and keeps its files under Pier's own directory — your own ubix setup is untouched.`),y?a(`p`,`max-w-2xl text-[12.5px] text-red-600`,y):a(`div`,`flex max-w-2xl flex-col`,...i.map(s)),a(`div`,`flex max-w-2xl flex-col gap-2 border-t border-neutral-200 pt-4`,a(`span`,`text-[12.5px] font-medium text-neutral-600`,`Add one of your own`),A(`Name`,f),A(`The block Pier writes under the header`,p,{hint:`A line that opens a section of its own is refused, because it could rewrite the rest of the file.`}),a(`div`,`flex items-center gap-3`,u,h)),a(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...o?[`Installs and daily updates run as `,o,` — output, failures and all.`]:[`Switching one on creates the daily task that installs it and keeps it current.`]),r))}async function de(e,t,n){let r=v.find(t=>t.name===e);n(await V(H(e,t),r?.source===`binary`?t?`Saved — installing now; watch the run.`:`Saved — uninstalling in the next run.`:`Saved — sessions take it on their next message.`))}async function fe(e,t){let n=++m,r=await i(`/api/config/resource${z(`&kind=${e}&name=${encodeURIComponent(t)}`)}`,`failed to load ${t}`,{cache:`no-store`});if(!r.ok){n===m&&Y(r.error);return}if(n!==m)return;let{content:o}=r.value,s=o.split(`
|
|
3
3
|
`);s.at(-1)===``&&s.pop();let c=await E(t);n===m&&L.replaceChildren(X(t,a(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`read-only`)),a(`div`,`min-h-0 flex-1 overflow-auto`,M(j(s),c)))}function pe(){N.replaceChildren(new Option(h?`Global (${h})`:`Global`,`global`),...t().map(e=>new Option(`${o(e)} — ${e}`,e))),[...N.options].some(e=>e.value===l)||(l=`global`),N.value=l}return s(e,()=>{pe(),te()},C)}var G=e=>`${e.provider}/${e.id}`,oe=[`hardest reasoning — architecture, gnarly debugging`,`long autonomous implementation runs`,`balanced default — implementation, review`,`cheap & fast — listings, extraction, simple checks`,`cross-vendor second opinion`];function K(){let e=[],t=[],n=!1,o=a(`span`,`text-[11.5px]`,``),s=_(`Save menu`,!0),c=a(`div`,`flex min-w-0 flex-col gap-2`),l=a(`div`,`flex items-center gap-2`),u=a(`div`,`mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-6`);function m(){n=!0,d(o,`idle`,`unsaved changes`)}function g(t){let n=k(t.note??``);n.classList.remove(`w-full`),n.classList.add(`min-w-0`,`flex-1`),n.placeholder=`why this one — pick a preset or write your own`,n.setAttribute(`list`,`model-menu-notes`),n.oninput=()=>{t.note=n.value,m()};let r=O([[`thinking: model default`,``],...h.map(e=>[`thinking: ${C(e)}`,e])],t.thinking??``);r.classList.replace(`w-full`,`w-44`),r.classList.add(`flex-none`),r.onchange=()=>{r.value?t.thinking=r.value:delete t.thinking,m()};let i=_(`Remove`);i.classList.add(`flex-none`),i.onclick=()=>{e=e.filter(e=>e!==t),m(),y()};let o=a(`span`,`w-52 flex-none truncate font-mono text-[12px] text-neutral-700`,G(t));return o.title=G(t),a(`div`,`flex min-w-0 items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 shadow-2xs max-md:flex-wrap`,o,r,n,i)}function v(){let n=t.filter(t=>!e.some(e=>G(e)===G(t))),r=O(n.map(e=>[G(e),G(e)]),n[0]?G(n[0]):``);r.classList.replace(`w-full`,`flex-1`),r.classList.add(`min-w-0`);let i=_(`+ Pin model`);i.classList.add(`flex-none`,`whitespace-nowrap`),i.disabled=n.length===0,i.onclick=()=>{let t=n.find(e=>G(e)===r.value);t&&(e.push({...t}),m(),y())},l.replaceChildren(r,i)}function y(){c.replaceChildren(...e.length?e.map(g):[D(`Nothing pinned — every picker shows the curated catalog as is.`)]),v()}async function b(){d(o,`saving`,`saving…`);let t=e.map(({provider:e,id:t,thinking:n,note:r})=>({provider:e,id:t,...n?{thinking:n}:{},...r?.trim()?{note:r.trim()}:{}})),i=await r(`/api/settings`,{modelMenu:t},`PUT`);if(!i.ok)return d(o,`failed`,await f(i,`Could not save`));e=(await i.json()).modelMenu,n=!1,d(o,`saved`,`Saved — agents see it on their next models call.`),y()}s.onclick=()=>void b();function x(){n||(async()=>{let[n,r]=await Promise.all([i(`/api/settings`,`Could not load the menu`),i(`/api/models`,`Could not load the model catalog`)]);if(!n.ok)return d(o,`failed`,n.error);e=n.value.modelMenu,t=r.ok?r.value:[],o.textContent=``,y()})()}let S=a(`datalist`,``);return S.id=`model-menu-notes`,S.append(...oe.map(e=>new Option(e))),u.append(p(`Model menu`,`Which few models this deployment favors, each with a usual reasoning level and one line of intent. Pinned entries lead every model picker, and agents delegating work match your notes against the task instead of guessing ids.`,A(`Pinned models`,c,{hint:`The note is what an agent matches a task against — say when to reach for it, not what it is.`}),A(`Add`,l,{hint:`The list is the live catalog — only models that exist right now can be pinned.`}),a(`div`,`flex items-center gap-3`,s,o),S)),{el:u,load:x}}var q=(e,t)=>{let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`http:`&&n.protocol!==`https:`)return null;let r=a(`a`,`text-indigo-600 hover:underline`,t);return r.href=n.href,r.target=`_blank`,r.rel=`noreferrer`,r};function J(e,t,n,i){let o=document.createElement(`dialog`);o.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let s=a(`div`,`flex flex-col gap-2`),c=a(`div`,`flex flex-col gap-2`),u=a(`p`,`text-[12.5px] text-neutral-400`,`Starting…`),d=_(`Cancel`),p=(e,t)=>{u.className=`text-[12.5px] ${S[e]}`,u.textContent=t};o.append(a(`div`,`border-b border-neutral-200 px-4 py-2.5 text-[14px] font-semibold`,t),a(`div`,`flex max-h-[65vh] flex-col gap-3 overflow-y-auto px-4 py-3`,s,c,u),a(`div`,`flex justify-end border-t border-neutral-200 px-4 py-2.5`,d)),document.body.append(o),o.showModal();let m=e.id,h=e.state,g,v,y=new Set,b=!1,x=!1,C=async e=>{if(!x){if(e&&h===`running`){x=!0,d.disabled=!0;try{let e=await r(`/api/providers/flows/${m}/cancel`,{});if(!e.ok&&e.status!==404){p(`failed`,await f(e,`Could not cancel authentication flow`));return}}catch(e){p(`failed`,`Could not cancel authentication flow: ${String(e)}`);return}finally{x=!1,d.disabled=!1}}clearTimeout(g),o.close()}};d.onclick=()=>void C(!0),o.oncancel=e=>{e.preventDefault(),C(!0)},o.onclose=()=>{b=!0,clearTimeout(g),o.remove()};let w=e=>{if(e.type===`auth_url`){let t=a(`div`,`flex flex-col gap-1 text-[12.5px] text-neutral-600`);return e.instructions&&t.append(a(`p`,``,e.instructions)),t.append(q(e.url,`Open authorization page`)??a(`span`,`text-red-600`,`Invalid authorization URL`)),t}if(e.type===`device_code`){let t=a(`div`,`flex flex-col gap-2 text-[12.5px] text-neutral-600`);return t.append(a(`div`,`flex items-center gap-2`,a(`code`,`font-mono text-[17px] font-semibold text-neutral-800`,e.userCode),l(`btn text-[11px]`,()=>e.userCode))),t.append(q(e.verificationUri,`Open verification page`)??a(`span`,`text-red-600`,`Invalid verification URL`)),t}let t=a(`div`,`text-[12.5px] text-neutral-600`,e.message);if(e.type===`info`)for(let n of e.links??[]){let e=q(n.url,n.label??n.url);e&&t.append(` `,e)}return t},T=(e,t)=>{v=t.id;let n;if(t.type===`select`){let e=document.createElement(`select`);e.append(...t.options.map(e=>new Option(e.description?`${e.label} — ${e.description}`:e.label,e.id))),n=e}else{let e=k(``,t.type===`secret`?`password`:`text`);e.placeholder=t.placeholder??``,e.autocomplete=`off`,n=e}n.className=`${n.tagName===`SELECT`?`select `:``}w-full rounded-lg border border-neutral-300 bg-white px-2.5 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`;let i=_(`Continue`,!0);i.type=`submit`;let o=a(`form`,`flex flex-col gap-2`,a(`label`,`text-[12.5px] font-medium text-neutral-700`,t.message),n,a(`div`,`flex justify-end`,i));o.onsubmit=a=>{a.preventDefault(),i.disabled=!0,(async()=>{try{let i=await r(`/api/providers/flows/${e.id}/respond`,{promptId:t.id,value:n.value});if(b)return;if(!i.ok){p(`failed`,await f(i,`Could not submit response`));return}y.add(t.id),v=void 0,c.replaceChildren(),p(`saving`,`Waiting for provider…`)}catch(e){b||p(`failed`,`Could not submit response: ${String(e)}`)}finally{i.disabled=!1}})()},c.replaceChildren(o),n.focus()},E=e=>{h=e.state,s.replaceChildren(...e.events.map(w));let t=e.prompt&&!y.has(e.prompt.id)?e.prompt:void 0;if(t?.id!==v&&(t?T(e,t):(v=void 0,c.replaceChildren())),e.state===`running`){p(`saving`,t?`Waiting for your response.`:`Waiting for provider…`);return}clearTimeout(g),c.replaceChildren(),e.state===`succeeded`?p(`saved`,`${n} configured.`):p(`failed`,e.state===`cancelled`?`Cancelled.`:e.error??`Authentication failed.`),d.textContent=`Close`,d.onclick=()=>void C(!1),e.state===`succeeded`&&i()},D=async()=>{if(!(b||h!==`running`))try{let e=await fetch(`/api/providers/flows/${m}`,{cache:`no-store`});if(b)return;if(!e.ok){p(`failed`,await f(e,`Authentication status unavailable`)),e.status===404?h=`failed`:g=setTimeout(()=>void D(),1e3);return}E(await e.json()),h===`running`&&(g=setTimeout(()=>void D(),500))}catch(e){if(b)return;p(`failed`,`Authentication status unavailable: ${String(e)}`),g=setTimeout(()=>void D(),1e3)}};E(e),h===`running`&&(g=setTimeout(()=>void D(),500))}var se=[`anthropic`,`openai`,`openai-codex`,`google`,`openrouter`,`deepseek`],Y=[[`OpenAI Chat Completions`,`openai-completions`],[`OpenAI Responses`,`openai-responses`],[`Anthropic Messages`,`anthropic-messages`],[`Google Generative AI`,`google-generative-ai`]],X=`__custom__`;async function ce(e){let t=_(`Add provider`,!0);t.classList.add(`ml-auto`);let n=a(`div`,`flex flex-none items-center gap-3 rounded-t-xl border-b border-neutral-200/70 bg-neutral-50/70 px-4 py-2`,a(`h2`,`text-[13px] font-semibold text-neutral-700`,`Providers`),t),o=a(`div`,`min-h-0 flex-1 overflow-y-auto`);e.replaceChildren(n,o);let s=[],c=``,l=async()=>{o.replaceChildren(a(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Loading…`));try{let[e,n]=await Promise.all([i(`/api/providers`,`Could not load providers`,{cache:`no-store`}),i(`/api/models`,`the model catalog could not be read`,{cache:`no-store`})]);if(s=n.ok?n.value:[],c=n.ok?``:n.error,!e.ok){o.replaceChildren(D(e.error));return}let r=e.value;t.onclick=()=>Z(r,void 0,l),g(r)}catch(e){o.replaceChildren(D(`Could not load providers: ${String(e)}`))}},u=async e=>{if(window.confirm(`Remove the stored credential for ${e.name}?`))try{let t=await r(`/api/providers/${encodeURIComponent(e.id)}/logout`,{});if(!t.ok){window.alert(await f(t,`Could not remove credential`));return}await l()}catch(e){window.alert(`Could not remove credential: ${String(e)}`)}},p=e=>[...new Set([...(e.models??[]).map(e=>e.id),...s.filter(t=>t.provider===e.id).map(e=>e.id)])],m=(e,t)=>a(`div`,`flex flex-col gap-1`,a(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),a(`pre`,`max-h-56 overflow-auto whitespace-pre-wrap break-all rounded-md bg-neutral-50 p-2 font-mono text-[11.5px] leading-relaxed text-neutral-600`,t)),h=async(e,t)=>{try{let n=await r(`/api/providers/${encodeURIComponent(e)}/check`,{model:t});return n.ok?await n.json():await f(n,`Could not test`)}catch(e){return`Could not test: ${String(e)}`}},g=e=>{let t=e.filter(e=>e.configured);if(!t.length){o.replaceChildren(D(`No providers configured.`));return}o.replaceChildren(...t.map(t=>{let n=a(`div`,`min-w-0 flex-1`,a(`div`,`truncate text-[13px] font-medium text-neutral-700`,t.name),a(`div`,`truncate font-mono text-[11px] text-neutral-400`,t.id)),r=t.stored===`api_key`?`API key`:t.stored===`oauth`?`OAuth`:t.source??`configured`,i=t.endpoint??`Default endpoint`,o=a(`div`,`flex min-w-32 flex-col items-start gap-1`,b(`configured`,`bg-emerald-50 text-emerald-700 ring-emerald-200`),a(`span`,`max-w-48 truncate text-[11px] text-neutral-500`,r),a(`span`,`max-w-48 truncate text-[11px] text-neutral-400`,i));o.title=i;let s=a(`span`,`text-[11.5px]`,``),f=a(`div`,`hidden flex-col gap-2 px-4 pb-3`,s),g=a(`div`,`flex flex-wrap justify-end gap-1.5`),v=p(t);if(!v.length)d(s,`idle`,c||`No models to test: none are configured here.`),f.classList.replace(`hidden`,`flex`);else{let e=O([[`Model to test…`,``],...v.map(e=>[e,e])],``);e.classList.add(`max-w-52`,`text-[12px]`);let n=_(`Test`);n.disabled=!0,e.onchange=()=>n.disabled=!e.value,n.onclick=()=>{let r=e.value;n.disabled=!0,f.replaceChildren(s),f.classList.replace(`hidden`,`flex`),d(s,`saving`,`asking ${r}…`),h(t.id,r).then(e=>{if(n.disabled=!1,typeof e==`string`)return d(s,`failed`,e);d(s,e.ok?`saved`:`failed`,`${e.model} ${e.ok?`answered`:`did not answer`} in ${e.ms} ms`),f.append(m(`sent`,e.request||`(the request was never made)`),m(e.ok?`answered`:`replied`,e.response))})},g.append(e,n)}if(t.builtin||t.api&&t.models){let n=_(`Edit`);n.onclick=()=>Z(e,t,l),g.append(n)}if(t.stored){let e=_(`Remove credential`);e.onclick=()=>void u(t),g.append(e)}return a(`div`,`border-b border-neutral-100`,a(`div`,`grid grid-cols-[minmax(8rem,1fr)_minmax(8rem,auto)_minmax(9rem,auto)] items-center gap-3 px-4 py-2.5 max-sm:grid-cols-[1fr_auto]`,n,o,g),f)}))};await l()}function le(e,t){let n=t.filter(e=>!e.configured&&e.methods.length&&(e.builtin||e.api!==void 0&&e.models!==void 0)),r=(t,n)=>{if(!n.length)return;let r=document.createElement(`optgroup`);r.label=t,r.append(...n.map(e=>new Option(e.name,e.id))),e.append(r)};r(`Common`,se.flatMap(e=>n.filter(t=>t.id===e))),r(`More providers`,n.filter(e=>e.builtin&&!se.includes(e.id)).sort((e,t)=>e.name.localeCompare(t.name))),r(`Custom providers`,n.filter(e=>!e.builtin).sort((e,t)=>e.name.localeCompare(t.name))),e.append(new Option(`Custom provider…`,X))}function Z(e,n,i){let o=document.createElement(`dialog`);o.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let s=document.createElement(`select`);s.className=`${g} select`,n||le(s,e);let c=k(),l=k(),u=k(),d=document.createElement(`select`);d.className=`${g} select`,d.append(...Y.map(([e,t])=>new Option(e,t)));let p=t(``,4);p.placeholder=`model-id
|
|
4
4
|
another-model-id`;let m=document.createElement(`input`);m.type=`checkbox`;let h=document.createElement(`select`);h.className=`${g} select`;let v=a(`div`,`flex flex-col gap-4`),y=a(`span`,`text-[11.5px] text-red-600`,``),b=_(`Cancel`),x=_(n?`Save`:`Add`,!0);x.type=`submit`;let S=()=>n??e.find(e=>e.id===s.value),C=()=>{let e=S(),t=e?!e.builtin:s.value===X;c.value=e?.id??``,c.disabled=n!==void 0,l.value=e?.name??``,u.value=e?.endpoint??``,d.value=e?.api??`openai-completions`,p.value=e?.models?.map(e=>e.id).join(`
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{H as e,I as t,L as n,g as r,k as i,m as a,v as o}from"./index-
|
|
1
|
+
import{H as e,I as t,L as n,g as r,k as i,m as a,v as o}from"./index-CquEUmXo.js";var s=e=>e===null?`-`:new Date(e).toLocaleString(),c=e=>e.startedAt===null?`-`:t((e.finishedAt??Date.now())-e.startedAt),l=e=>e.state===`succeeded`&&e.matched===!1?`No match`:e.state,u={queued:`bg-neutral-100 text-neutral-600 ring-neutral-200`,running:`bg-sky-50 text-sky-700 ring-sky-200`,succeeded:`bg-emerald-50 text-emerald-700 ring-emerald-200`,failed:`bg-red-50 text-red-700 ring-red-200`,cancelled:`bg-amber-50 text-amber-700 ring-amber-200`,interrupted:`bg-amber-50 text-amber-700 ring-amber-200`,skipped:`bg-neutral-100 text-neutral-600 ring-neutral-200`};function d(e){let t=l(e);return a(t,t===`No match`?u.skipped:u[e.state],e.state===`running`?`animate-pulse bg-sky-500`:void 0)}function f(e){return e.archived?a(`Archived`,`bg-neutral-50 text-neutral-400 ring-neutral-200`):e.trigger.type===`manual`?a(`Manual`,`bg-neutral-100 text-neutral-600 ring-neutral-200`):e.enabled?a(`Enabled`,`bg-emerald-50 text-emerald-700 ring-emerald-200`):a(`Paused`,`bg-amber-50 text-amber-700 ring-amber-200`)}var p=`px-4 pt-4 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,m=`m-4 mt-2 whitespace-pre-wrap break-words rounded-lg border border-black/[0.06] bg-black/[0.025] px-3 py-2 font-mono text-[12px] leading-snug dark:border-neutral-200 dark:bg-neutral-100`,h=e=>e.trigger.type===`manual`?`Manual`:e.trigger.type===`cron`?`${e.trigger.expression} (${e.trigger.timezone})`:`Every ${e.trigger.intervalSeconds}s · ${e.trigger.mode}`,g=e=>e.action.type===`agent`?`Agent · ${e.action.session.mode}`:e.action.type===`bash`?`Bash`:e.action.type===`system`?`System`:`Task`;function _(e,t){let i=n(`div`,`grid max-w-4xl grid-cols-[6rem_minmax(0,1fr)] gap-x-5 gap-y-3.5 p-4 text-[13px] md:grid-cols-[9.375rem_minmax(0,1fr)]`),a=[[`Status`,e.archived?`Archived`:e.trigger.type===`manual`?`Manual`:e.enabled?`Enabled`:`Paused`],[`Trigger`,h(e)],[`Action`,g(e)],[`Timeout`,`${e.timeoutSeconds}s`],[`Next run`,s(e.nextRunAt)],[`Revision`,String(e.revision)],[`Created by`,e.createdBySessionId??e.creator],[`Callback`,e.callback.type===`session`?e.callback.sessionId:e.callback.type],[`Description`,e.description||`-`]];e.action.type===`agent`&&(a.push([`Session policy`,e.action.session.mode]),e.action.session.mode===`reuse`&&a.push([`Session`,e.action.session.sessionId]),`cwd`in e.action.session&&a.push([`Directory`,e.action.session.cwd]),e.action.launch?.model&&a.push([`Model`,`${e.action.launch.model.provider}/${e.action.launch.model.id}`]),e.action.launch?.thinking&&a.push([`Thinking`,e.action.launch.thinking]),a.push([`Prompt`,e.action.prompt])),e.action.type===`bash`&&a.push([`Directory`,e.action.cwd],[`Script`,e.action.script]),e.action.type===`task`&&a.push([`Target task`,e.action.taskId]),e.action.type===`system`&&a.push([`System action`,e.action.name]),e.trigger.type===`watch`&&a.push([`Probe`,e.trigger.script]);for(let[e,t]of a)i.append(n(`span`,`pt-px text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),n(`pre`,`whitespace-pre-wrap break-words font-mono text-[12.5px] leading-snug`,t));if(e.action.type===`agent`&&e.action.session.mode===`reuse`){let{sessionId:a}=e.action.session,o=r(`Open session`);o.onclick=()=>t(a),i.append(n(`span`,``,``),o)}return i}function v(e){return[e.pendingDecisionId?`Awaiting decision`:``,e.callbackState&&e.callbackState!==`delivered`?`Callback not delivered (${e.callbackState})`:``,e.groupCallbackState&&e.groupCallbackState!==`delivered`?`Group callback not delivered (${e.groupCallbackState})`:``].filter(Boolean).join(` · `)}function y(e,t,r,i){let a=n(`div`,`divide-y divide-neutral-100`);for(let e of t){let t=n(`button`,`grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-4 py-2.5 text-left text-[12.5px] transition-colors hover:bg-neutral-50 md:grid-cols-[7.5rem_minmax(0,1fr)_7.5rem_6.25rem]`);t.setAttribute(`type`,`button`),t.append(n(`span`,`flex`,d(e)),n(`span`,`truncate text-neutral-500`,s(e.queuedAt)),n(`span`,`text-neutral-500`,e.triggerSource),n(`span`,`text-right font-mono text-[11.5px] text-neutral-400`,c(e))),t.onclick=()=>r(e.id),a.append(t)}t.length||a.append(n(`div`,`p-4`,o(`No runs yet.`))),e.replaceChildren(a),e.scrollTop=i.top,e.onscroll=()=>{i.top=e.scrollTop}}var b=e=>`Exit code: ${e.exitCode??`-`}\nstdout:\n${e.stdout}${e.stdoutTruncated?`
|
|
2
2
|
[stdout truncated]`:``}\nstderr:\n${e.stderr}${e.stderrTruncated?`
|
|
3
3
|
[stderr truncated]`:``}`;async function x(t,a,o,l,u){let f=String(Number(t.dataset.runRequest??0)+1);t.dataset.runRequest=f,t.onscroll=()=>{u.scrollTop=t.scrollTop};let h=r(`Runs`);h.className=`cursor-pointer text-neutral-500 hover:text-neutral-800 hover:underline`,h.onclick=()=>{u.selectedId=null,u.scrollTop=0,o()};let g=i(h,n(`span`,`text-neutral-400`,`›`),n(`span`,`min-w-0 truncate font-mono text-[12px] text-neutral-500`,a)),x=t.dataset.runId!==a;x&&(t.dataset.runId=a,t.replaceChildren(g,n(`p`,`p-4 text-[13px] text-neutral-500`,`Loading run...`)));let[S,C]=await Promise.all([e(`/api/task-runs/${a}`,`Could not load the run`),e(`/api/task-runs/${a}/messages`,`Could not load the run's messages`)]);if(!t.isConnected||t.dataset.runRequest!==f||u.selectedId!==a)return;if(!S.ok){let r=await e(`/api/task-groups/${a}`,S.error);if(!t.isConnected||t.dataset.runRequest!==f||u.selectedId!==a)return;if(u.drawn=``,!r.ok){t.replaceChildren(g,n(`p`,`p-4 text-[13px] text-red-600`,S.error));return}let{group:i,members:o}=r.value,s=n(`div`,`min-w-0`);t.replaceChildren(g,n(`div`,`border-b border-neutral-100 bg-neutral-50/60 px-4 py-3 text-[12.5px] text-neutral-600`,[`Task group \u00b7 join ${i.join}`,`${String(o.length)} runs`,i.callbackState?`callback ${i.callbackState}`:``].filter(Boolean).join(` · `)),s),y(s,o,l.openRun,{top:0});return}let w=S.value,T=C.ok?C.value:[],E=JSON.stringify([w,C]);if(!x&&u.drawn===E)return;if(u.drawn=E,w.targetSessionId){let e=r(`Open session`);e.classList.add(`ml-auto`),e.onclick=()=>l.openSession(w.targetSessionId),g.append(e)}if(w.state===`queued`||w.state===`running`){let e=r(`Stop run`);e.onclick=()=>{window.confirm(`Stop this run of "${w.context.definition.name}"?`)&&l.mutate(`/api/task-runs/${w.id}/cancel`)},g.append(e)}let D=n(`div`,`min-w-0`),O=v(w);D.append(n(`div`,`flex flex-wrap items-center gap-x-5 gap-y-2 border-b border-neutral-100 bg-neutral-50/60 px-4 py-3 text-[12.5px]`,n(`span`,`flex items-center gap-2`,d(w),n(`span`,`font-medium`,w.context.definition.name)),...O?[n(`span`,`rounded-md bg-amber-50 px-2 py-0.5 text-[12px] text-amber-700 ring-1 ring-amber-200`,O)]:[],n(`span`,`text-neutral-500`,s(w.queuedAt)),n(`span`,`text-neutral-500`,w.triggerSource),n(`span`,`font-mono text-[11.5px] text-neutral-400`,c(w))));let k=n(`div`,`flex flex-wrap items-center gap-2 border-b border-neutral-100 px-4 py-3 text-[12px]`),A=(e,t)=>{let n=r(e);n.classList.add(`max-w-full`,`break-all`,`!whitespace-normal`),n.onclick=t,k.append(n)};if(w.context.definition.kind===`task`&&A(`Task: ${w.context.definition.name}`,()=>l.openTask(w.taskId)),w.parentRunId&&A(`Parent: ${w.parentRunId}`,()=>l.openRun(w.parentRunId)),w.resumedFromRunId&&A(`Resumed from: ${w.resumedFromRunId}`,()=>l.openRun(w.resumedFromRunId)),w.result?.type===`task`){let e=w.result.runId;A(`Child result: ${e}`,()=>l.openRun(e))}w.groupId&&k.append(n(`span`,`break-all font-mono text-[11.5px] text-neutral-500`,`Group: ${w.groupId}`)),D.append(k);for(let e of[w.error,w.skipReason,w.callbackError])e&&D.append(n(`p`,`m-4 whitespace-pre-wrap break-words rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-[12.5px] text-red-700`,e));if(w.result){let e=w.result,t=e.type===`agent`||e.type===`system`?e.text:e.type===`bash`?b(e):e.type===`task`?`Child run: ${e.runId}`:`Watch did not match.`;D.append(n(`h3`,p,`Result`),n(`pre`,m,t||`No output.`))}w.probe&&D.append(n(`h3`,p,`Watch probe: ${w.matched===null?`not evaluated`:w.matched?`matched`:`not matched`}`),n(`pre`,m,b(w.probe)));let j=n(`details`,`border-t border-neutral-200`);if(j.append(n(`summary`,`flex cursor-pointer items-center gap-1.5 px-4 py-3 text-[12px] text-neutral-500 hover:text-neutral-800`,n(`span`,`chev`,`▶`),`Configuration snapshot (revision ${w.taskRevision})`),_(w.context.definition,l.openSession)),D.append(j),C.ok||D.append(n(`p`,`m-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-[12.5px] text-red-700`,C.error)),T.length){let e=n(`div`,`mt-2 divide-y divide-neutral-100 border-t border-neutral-100`);for(let t of T){let r=n(`div`,`grid grid-cols-[auto_1fr] gap-3 px-4 py-2 text-[12px] md:grid-cols-[6.25rem_6.25rem_minmax(0,1fr)]`);r.append(n(`span`,`font-medium`,t.kind),n(`span`,`text-neutral-500`,t.state),n(`span`,`col-span-2 whitespace-pre-wrap break-words md:col-span-1`,t.content)),t.error&&r.append(n(`span`,`col-span-2 break-words text-red-600 md:col-span-3`,t.error)),e.append(r)}D.append(n(`div`,`border-t border-neutral-200`,n(`div`,p,`Messages`),e))}let M=n(`details`,`border-t border-neutral-200`);M.open=u.rawOpen,M.ontoggle=()=>{M.isConnected&&(u.rawOpen=M.open)},M.append(n(`summary`,`flex cursor-pointer items-center gap-1.5 px-4 py-3 text-[12px] text-neutral-500 hover:text-neutral-800`,n(`span`,`chev`,`▶`),`Raw record`),n(`pre`,m,JSON.stringify(w,null,2))),D.append(M),t.replaceChildren(g,D),t.scrollTop=u.scrollTop,t.onscroll=()=>{u.scrollTop=t.scrollTop}}export{y as a,c,x as i,f as l,s as n,v as o,_ as r,d as s,g as t,h as u};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,C as t,D as n,G as r,H as i,L as a,N as o,V as s,W as c,c as l,f as u,g as d,k as f,l as p,m,q as h,v as g,w as _,x as v,y}from"./index-
|
|
1
|
+
import{B as e,C as t,D as n,G as r,H as i,L as a,N as o,V as s,W as c,c as l,f as u,g as d,k as f,l as p,m,q as h,v as g,w as _,x as v,y}from"./index-CquEUmXo.js";import{a as b,c as x,l as S,n as C,r as w,s as T,t as E,u as D}from"./task-runs-DsOxAyRj.js";function O(e,t){let n=e.map(e=>[`${e.title??`Untitled`} · ${e.cwd}`,e.id]);return t&&!n.some(([,e])=>e===t)&&n.push([`Current session · ${t}`,t]),n}function k(e,t){let r=document.createElement(`dialog`);r.className=`m-auto w-[38.75rem] max-w-[94vw] rounded-lg border border-neutral-200 p-0 shadow-xl backdrop:bg-black/20`;let i=document.createElement(`form`);i.className=`flex max-h-[88vh] flex-col`;let o=a(`span`,`mr-auto text-[12px] text-red-600`),s=a(`header`,`flex h-11 flex-none items-center border-b border-neutral-200 px-4 font-medium`,t?`Edit task`:`New task`),c=a(`div`,`grid min-h-0 flex-1 grid-cols-2 gap-3 overflow-y-auto p-4`),u=v(t?.name??``);u.required=!0;let f=v(t?.description??``),m=v(String(t?.timeoutSeconds??900),`number`);m.min=`1`,m.max=`86400`;let g=_([[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watch`,`watch`]],t?.trigger.type??`manual`),b=_([[`Bash`,`bash`],[`Agent`,`agent`],[`Task`,`task`]],t?.action.type??`bash`),x=_([[`No callback`,`none`],[`Invoking session`,`origin`],[`Specific session`,`session`]],t?.callback.type??`none`),S=t?.callback.type===`session`?t.callback.sessionId:null,C=_(O(e.sessions(),S),S??``),w=y(`Callback session`,C);w.classList.toggle(`hidden`,x.value!==`session`),x.onchange=()=>w.classList.toggle(`hidden`,x.value!==`session`),c.append(y(`Name`,u),y(`Description`,f),y(`Trigger`,g),y(`Action`,b),y(`Callback`,x),w,y(`Timeout (seconds)`,m));let T=a(`div`,`col-span-2 grid grid-cols-2 gap-3 border-t border-neutral-200 pt-3`);c.append(T);let E=()=>{T.replaceChildren();let s,c,d,S,w,E;if(g.value===`cron`)s=v(t?.trigger.type===`cron`?t.trigger.expression:`0 9 * * *`),c=v(t?.trigger.type===`cron`?t.trigger.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone),T.append(y(`Cron`,s),y(`Timezone`,c));else if(g.value===`watch`){d=n(t?.trigger.type===`watch`?t.trigger.script:``,4),E=v(t?.trigger.type===`watch`?t.trigger.cwd:e.sessions()[0]?.cwd??``),S=v(String(t?.trigger.type===`watch`?t.trigger.intervalSeconds:60),`number`),w=_([[`Continue after matches`,`repeat`],[`Stop after first match`,`once`]],t?.trigger.type===`watch`?t.trigger.mode:`repeat`);let r=y(`Probe script (0=match, 1=no match)`,d);r.classList.add(`col-span-2`),T.append(r,y(`Probe directory`,E),y(`Interval (seconds)`,S),y(`Mode`,w))}let D,k,j,M,N,P,F,I,L,R;if(b.value===`bash`){k=v(t?.action.type===`bash`?t.action.cwd:e.sessions()[0]?.cwd??``),D=n(t?.action.type===`bash`?t.action.script:``,6);let r=y(`Bash script`,D);r.classList.add(`col-span-2`),T.append(y(`Working directory`,k),a(`span`,``),r)}else if(b.value===`agent`){let r=e.sessions(),i=t?.action.type===`agent`?t.action:null,a=i?.session.mode===`reuse`?i.session.sessionId:``,o=O(r,a||null);j=_([[`Reuse session`,`reuse`],[`Fresh child per run`,`fresh`]],i?.session.mode===`reuse`?`reuse`:`fresh`),M=_(o,a||o[0]?.[1]||``);let s=i&&`cwd`in i.session?i.session.cwd??``:``;N=v(s||r[0]?.cwd||``),P=n(i?.prompt??``,6),F=_([[`Project default`,``],...l.map(e=>[h(e),e])],i?.launch?.thinking??``),I=v(i?.launch?.model?.provider??``),L=v(i?.launch?.model?.id??``);let c=y(`Session`,M),u=y(`Child directory`,N),d=[y(`Thinking`,F),y(`Model provider (optional)`,I),y(`Model id (optional)`,L)],f=()=>{let e=j?.value===`reuse`;c.classList.toggle(`hidden`,!e),u.classList.toggle(`hidden`,e);for(let t of d)t.classList.toggle(`hidden`,e)};j.onchange=f,f();let p=y(`Prompt`,P);p.classList.add(`col-span-2`),T.append(y(`Session policy`,j),c,u,...d,p)}else R=_(e.tasks().filter(e=>e.id!==t?.id&&!e.archived).map(e=>[e.name,e.id]),t?.action.type===`task`?t.action.taskId:``),T.append(y(`Target task`,R));i.onsubmit=n=>{n.preventDefault();let i=g.value===`manual`?{type:`manual`}:g.value===`cron`?{type:`cron`,expression:s.value,timezone:c.value}:{type:`watch`,script:d.value,cwd:E.value,intervalSeconds:Number(S.value),mode:w.value},a=b.value===`agent`&&j.value!==`reuse`?{...p(F.value)?{thinking:F.value}:{},...I.value.trim()&&L.value.trim()?{model:{provider:I.value.trim(),id:L.value.trim()}}:{}}:void 0,l=b.value===`bash`?{type:`bash`,cwd:k.value,script:D.value}:b.value===`agent`?{type:`agent`,prompt:P.value,session:j.value===`reuse`?{mode:`reuse`,sessionId:M.value}:{mode:`fresh`,cwd:N.value},...a?{launch:a}:{}}:{type:`task`,taskId:R.value},h=x.value===`origin`?{type:`origin`}:x.value===`session`?{type:`session`,sessionId:C.value}:{type:`none`},_={name:u.value,description:f.value,trigger:i,action:l,callback:h,timeoutSeconds:Number(m.value)};o.textContent=``,A(t?.id,_,r,o,e.onSaved)}};g.onchange=E,b.onchange=E,E();let D=d(`Cancel`);D.onclick=()=>r.close();let k=d(`Save`,!0);k.type=`submit`;let j=a(`footer`,`flex flex-none justify-end gap-2 border-t border-neutral-200 px-4 py-3`);j.append(o,D,k),i.append(s,c,j),r.append(i),r.addEventListener(`close`,()=>r.remove()),document.body.append(r),r.showModal(),u.focus()}async function A(e,t,n,i,a){let o=await r(e?`/api/tasks/${e}`:`/api/tasks`,t,e?`PATCH`:`POST`);if(!o.ok){i.textContent=(await o.json()).error??`Task save failed`;return}let s=await o.json(),c=`task`in s?s.task:s;n.close(),a(c.id)}function j(n,l,p,h,v,y,O){let A=[],j=[],M=null,N=`active`,P=`all`,F=``,I=`runs`,L={top:0},R=0,z=0,B=``,V=e(async()=>{if(M||!$.visible)return;let e=R,t=`${N}:${P}`,n=await i(`/api/tasks?state=${N}&kind=task`,`Failed to load tasks`);if(!$.visible||e!==R||t!==`${N}:${P}`)return;if(!n.ok)return B=``,W(n.error);let r=JSON.stringify(n.value);t+r!==B&&(B=t+r,A=n.value,P!==`all`&&(A=A.filter(e=>e.trigger.type===P)),X())}),H=e(async()=>{M&&$.visible&&await ne(M)});function U(){return M?H():V()}function W(e){n.querySelector(`[role=alert]`)?.remove();let t=a(`p`,`flex-none p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),n.append(t)}async function G(){let e=M,t=await i(`/api/tasks?state=active`,`Failed to load tasks`);return!t.ok&&$.visible&&M===e&&W(t.error),t.ok?t.value:j}let K={sessions:l,tasks:()=>j,onSaved:e=>{J(e),I=`definition`,O(e)}},q=(e,t)=>f(...e,a(`div`,`ml-auto flex flex-wrap items-center gap-2 max-md:w-full`,...t));function J(e){M=e,R++,I=`runs`,L.top=0}function Y(){M=null,R++,X()}function X(){let e=d(`New task`,!0);e.onclick=()=>{!$.visible||M!==null||Promise.all([p(),G()]).then(([,e])=>{!$.visible||M!==null||(j=e,k(K))})};let t=[],r=(e,n,r,i)=>{let a=_(n,r);a.setAttribute(`aria-label`,e),a.classList.add(`!w-auto`,`pr-8`),a.onchange=()=>{i(a.value),z=0,U()},t.push(a)},i=a(`input`,`${u} !w-48 max-md:!w-full`);i.type=`search`,i.placeholder=`Search tasks`,i.setAttribute(`aria-label`,`Search tasks`),i.value=F,i.oninput=()=>{F=i.value,c()},t.push(i),r(`Status`,[[`Current`,`active`],[`Archived`,`archived`]],N,e=>{N=e}),r(`Trigger`,[[`All triggers`,`all`],[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watching`,`watch`]],P,e=>{P=e});let o=document.createElement(`table`);o.className=`w-full table-fixed text-left text-[12.5px]`,o.innerHTML=`<thead class="sticky top-0 bg-neutral-50 text-[10.5px] uppercase tracking-wide text-neutral-400 shadow-[inset_0_-1px_0_var(--color-neutral-200)]"><tr>
|
|
2
2
|
<th class="w-[42%] px-4 py-2 font-semibold md:w-[24%]">Name</th><th class="hidden w-[10%] px-2 py-2 font-semibold md:table-cell">Action</th>
|
|
3
3
|
<th class="hidden w-[23%] px-2 py-2 font-semibold md:table-cell">Trigger</th><th class="hidden w-[17%] px-2 py-2 font-semibold md:table-cell">Next</th>
|
|
4
4
|
<th class="px-2 py-2 font-semibold md:w-[14%]">Last result</th><th class="w-[6rem] px-2 py-2 font-semibold"></th></tr></thead>`;let s=document.createElement(`tbody`),c=()=>{let e=A.filter(e=>`${e.name} ${e.description??``}`.toLowerCase().includes(F.toLowerCase()));s.replaceChildren(...e.map(ee)),l.classList.toggle(`hidden`,e.length>0)};o.append(s);let l=a(`div`,`p-4`,g(`No matching tasks.`)),f=a(`div`,`min-h-0 flex-1 overflow-auto`,o,l);c(),f.onscroll=()=>{z=f.scrollTop},n.replaceChildren(q(t,[e]),f),f.scrollTop=z}function ee(e){let t=document.createElement(`tr`);t.className=`cursor-pointer border-b border-neutral-100 transition-colors hover:bg-neutral-50`,t.onclick=()=>O(e.id);let n=d(e.name);n.className=`min-w-0 cursor-pointer truncate text-left font-medium text-neutral-800`,n.title=e.name,t.append(a(`td`,`py-2.5 pl-4 pr-2`,a(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1`,n,S(e),...te(e)),a(`div`,`truncate text-[11px] text-neutral-400`,e.description||``),a(`div`,`truncate text-[11px] text-neutral-400 md:hidden`,D(e))));for(let n of[E(e),D(e),C(e.nextRunAt)]){let e=a(`td`,`hidden truncate px-2 py-2.5 text-neutral-600 md:table-cell`,n);e.title=n,t.append(e)}t.append(a(`td`,`px-2 py-2.5`,e.lastRun?a(`div`,`flex`,T(e.lastRun)):a(`div`,`text-neutral-400`,`–`),a(`div`,`mt-0.5 font-mono text-[11px] text-neutral-400`,e.lastRun?x(e.lastRun):``)));let r=d(`Run now`);return r.disabled=e.archived,r.onclick=t=>{t.stopPropagation(),Z(e.id)},t.append(a(`td`,`px-2 py-1 text-right`,r)),t}function te(e){if(!e.createdBySessionId)return[];let t=m(`agent`,`bg-violet-50 text-violet-700 ring-violet-200`);return t.title=`Created by session ${e.createdBySessionId}`,[t]}async function ne(e){let r=++R,o=n.querySelector(`[data-task-detail]`),[s,c]=await Promise.all([i(`/api/tasks/${e}`,`Failed to load task`),i(`/api/tasks/${e}/runs`,`Failed to load the task's runs`)]);if(!$.visible||r!==R||M!==e)return;if(!s.ok)return W(s.error);if(!c.ok)return W(c.error);let l=s.value,u=c.value,m=d(`Tasks`);m.className=`cursor-pointer text-neutral-500 hover:text-neutral-800 hover:underline`,m.onclick=()=>O();let g=a(`span`,`flex min-w-0 items-center gap-2`,m,a(`span`,`text-neutral-400`,`›`),a(`span`,`truncate font-medium`,l.name),S(l)),_=d(`Run now`,!0);_.disabled=l.archived,_.onclick=()=>void Z(l.id);let v=d(l.enabled?`Pause schedule`:`Resume schedule`);v.disabled=l.archived||l.action.type===`system`||l.trigger.type===`manual`,v.onclick=()=>void Q(`/api/tasks/${l.id}/${l.enabled?`pause`:`resume`}`);let x=d(`Edit`);x.disabled=l.archived||l.action.type===`system`,x.onclick=()=>{!$.visible||M!==l.id||Promise.all([p(),G()]).then(([,e])=>{!$.visible||M!==l.id||(j=e,k(K,l))})};let C=d(`Archive`);C.disabled=l.archived||l.action.type===`system`,C.onclick=()=>void Q(`/api/tasks/${l.id}/archive`);let T=f(),E=a(`div`,`min-h-0 flex-1 overflow-auto`);E.dataset.taskDetail=e;let D=d(`All runs`);D.onclick=()=>y({taskId:l.id});let A=()=>{T.replaceChildren(t([[`Recent runs (${u.length})`,`runs`],[`Definition`,`definition`]],I,e=>{I=e,A()}),a(`span`,`ml-auto`,D)),I===`runs`?b(E,u,e=>y({},e),L):(E.onscroll=null,E.replaceChildren(w(l,h)))},N=o?.scrollTop??0;n.replaceChildren(q([g],[_,...l.trigger.type===`manual`?[]:[v],x,C]),T,E),A(),E.scrollTop=N}async function Z(e){try{let t=await r(`/api/tasks/${e}/run`,{sourceSessionId:v()});if(!t.ok)return W(await s(t,`Failed to run task`));y({},(await t.json()).runId)}catch(e){W(`Failed to run task: ${String(e)}`)}}async function Q(e){let t=await c(e,`POST`,`Task update failed`);if(t)return W(t);await U()}let $=o(n,e=>{e&&e!==M&&J(e),e||Y(),n.childElementCount||X(),U()});return Object.assign($,{refresh(e){$.visible&&(!M||!e||M===e)&&U()}})}export{j as createTasksView};
|
|
Binary file
|
|
Binary file
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
which style.css pays for with the safe-area inset. -->
|
|
34
34
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
35
35
|
<title>Pier</title>
|
|
36
|
-
<script type="module" crossorigin src="/assets/index-
|
|
36
|
+
<script type="module" crossorigin src="/assets/index-CquEUmXo.js"></script>
|
|
37
37
|
<link rel="stylesheet" crossorigin href="/assets/index-CZeL3DfU.css">
|
|
38
38
|
</head>
|
|
39
39
|
<!-- The document never scrolls: this is a fixed-viewport workbench, and every
|
|
Binary file
|
|
Binary file
|
package/dist/web/server.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// See docs/design/03-web-workbench.md for the route contract.
|
|
3
3
|
import { hostname } from "node:os";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
|
-
import { readFile, stat } from "node:fs/promises";
|
|
5
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
6
6
|
import { isAbsolute, join, relative } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
@@ -14,11 +14,11 @@ import { logger } from "../log.js";
|
|
|
14
14
|
import { QueueOperationError, Router } from "../core/router.js";
|
|
15
15
|
import { registerConfigRoutes } from "./config.js";
|
|
16
16
|
import { registerExplorerRoutes } from "./explorer.js";
|
|
17
|
-
import { fileHeaders, MAX_FILE_BYTES, registerFsRoutes
|
|
17
|
+
import { fileHeaders, MAX_FILE_BYTES, registerFsRoutes } from "./fs.js";
|
|
18
18
|
import { guarded } from "./route.js";
|
|
19
19
|
import { isThinkingLevel } from "../core/types.js";
|
|
20
20
|
import { SESSION_TITLE_MAX } from "../limits.js";
|
|
21
|
-
import {
|
|
21
|
+
import { saveInbound } from "../core/inbox.js";
|
|
22
22
|
import { MAX_INBOUND_BYTES } from "../core/inbound-file.js";
|
|
23
23
|
import { RepoIndex } from "./repos.js";
|
|
24
24
|
import {} from "./session-state.js";
|
|
@@ -292,21 +292,21 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
292
292
|
return c.json({ steps: turn.steps ?? [] });
|
|
293
293
|
});
|
|
294
294
|
// Attachments, both directions: the agent links a file it produced, the chat
|
|
295
|
-
// renders a file the user sent. Read-only, and
|
|
296
|
-
//
|
|
297
|
-
//
|
|
295
|
+
// renders a file the user sent. Read-only, and any readable file — the
|
|
296
|
+
// boundary here is the Console password (web/fs.ts), not the session's cwd:
|
|
297
|
+
// a cwd is chosen by whoever creates the session, so confining to it stopped
|
|
298
|
+
// nothing and left a report the agent wrote elsewhere as a dead card.
|
|
298
299
|
guarded(app, "GET", "/api/sessions/:id/files", 400, async (c) => {
|
|
299
300
|
const raw = c.req.query("path");
|
|
300
301
|
if (!raw)
|
|
301
302
|
return c.json({ error: "path required" }, 400);
|
|
302
|
-
const id = c.req.param("id");
|
|
303
|
-
const cwd = nascent.get(id)?.cwd ?? (await factory.find(id))?.cwd;
|
|
304
303
|
// Absolute only: a link into a session's files is written by the agent or
|
|
305
304
|
// by Pier, and neither of them writes a path relative to anything.
|
|
306
|
-
const file =
|
|
307
|
-
|
|
305
|
+
const file = isAbsolute(raw) ? await realpath(raw).catch(() => null) : null;
|
|
306
|
+
const info = file ? await stat(file).catch(() => null) : null;
|
|
307
|
+
if (!file || !info?.isFile())
|
|
308
308
|
return c.json({ error: "no such file" }, 404);
|
|
309
|
-
if (
|
|
309
|
+
if (info.size > MAX_FILE_BYTES)
|
|
310
310
|
return c.json({ error: "file too large" }, 413);
|
|
311
311
|
const bytes = await readFile(file);
|
|
312
312
|
return c.body(bytes, 200, {
|
package/package.json
CHANGED
|
@@ -3,158 +3,86 @@ name: pier-slack
|
|
|
3
3
|
description: Read and write Slack through Pier's slack tool, including the Slack-specific syntax for mentions and links. Read before answering questions about Slack conversations or posting anything to a workspace.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Writing Slack correctly
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
are live and nothing is kept between calls — write down what you need to keep.
|
|
8
|
+
The tool description lists the operations and parameters. This is what goes
|
|
9
|
+
wrong without instructions.
|
|
11
10
|
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
If this conversation reached you *through* Slack, omitting `channel` means
|
|
15
|
-
"here":
|
|
16
|
-
|
|
17
|
-
- `{"operation":"post","text":"..."}` replies in the thread you are in
|
|
18
|
-
- `{"operation":"read_thread"}` reads it
|
|
19
|
-
- `{"operation":"context"}` names it: `channel`, `channelName`, `kind`,
|
|
20
|
-
`threadTs`
|
|
21
|
-
|
|
22
|
-
`inSlack:false` from `context` means a task, subagent or web session started
|
|
23
|
-
this: there is no current conversation and `channel` is required.
|
|
24
|
-
|
|
25
|
-
`{"operation":"channels"}` lists what Pier can reach (`id`, `name`, `kind`,
|
|
26
|
-
`respondsToMessages`); pass either an id or a `#name` anywhere a channel is
|
|
27
|
-
wanted.
|
|
28
|
-
|
|
29
|
-
## Never ask for an id
|
|
30
|
-
|
|
31
|
-
You already have them: the sender header on the message you are answering,
|
|
32
|
-
`name[id]` on every line of a transcript, and `context` for this channel and
|
|
33
|
-
thread. Asking a human to paste their own user ID is never acceptable.
|
|
34
|
-
|
|
35
|
-
## Reading
|
|
36
|
-
|
|
37
|
-
```json
|
|
38
|
-
{"operation":"read_channel","channel":"#incidents",
|
|
39
|
-
"since":"2024-06-01T00:00:00Z","until":"2024-06-02T00:00:00Z"}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
```json
|
|
43
|
-
{"operation":"read_thread"}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Omit both arguments for the thread you are in; pass `channel` + `thread_ts` for
|
|
47
|
-
another. A thread read returns the parent plus every reply, with `threadTs` at
|
|
48
|
-
the top of the reply rather than on each line.
|
|
49
|
-
|
|
50
|
-
```json
|
|
51
|
-
{"operation":"read_message","channel":"#ops","ts":"1717243800.000100"}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
One message and nothing else, when that is the whole question. Add `thread_ts`
|
|
55
|
-
when it was posted inside a thread — a channel read cannot see thread replies,
|
|
56
|
-
and the error will say so.
|
|
57
|
-
|
|
58
|
-
- `since` / `until` / `after` take **ISO 8601, epoch seconds, or a `ts` from an
|
|
59
|
-
earlier read**. Omitting `until` reads up to now.
|
|
60
|
-
- `after` returns only what is strictly newer than that message — use it to
|
|
61
|
-
re-read a channel or thread without seeing what you saw last time.
|
|
62
|
-
- `limit` caps the result (default and max 400). When `truncated` is true,
|
|
63
|
-
narrow the range rather than raising the limit.
|
|
64
|
-
- Messages are oldest-first, one line each, shaped as the reply's `format`
|
|
65
|
-
field says — `<ts> | <time, UTC> | <name>[<id>] | <text>`:
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
1717243800.000100 | 2024-06-01T12:10Z | Ada[U1] | deploy? [thread: 4 replies]
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
The leading `ts` is Slack's id: pass it back as `thread_ts` or `after`.
|
|
72
|
-
- A channel read returns thread **parents** only; `[thread: N replies]` marks
|
|
73
|
-
the ones worth opening with `read_thread`.
|
|
74
|
-
- `incomplete` means the read stopped early and its value says why. Retry or
|
|
75
|
-
work with a partial answer, but do not report it as everything.
|
|
76
|
-
|
|
77
|
-
## Posting
|
|
78
|
-
|
|
79
|
-
```json
|
|
80
|
-
{"operation":"post","text":"**Deploy done** — 3 services, 0 rollbacks."}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
| Goal | Arguments |
|
|
84
|
-
| --- | --- |
|
|
85
|
-
| Reply where you are | omit `channel` and `thread_ts` |
|
|
86
|
-
| Reply in a specific thread | `channel` + `thread_ts` |
|
|
87
|
-
| Start a new top-level message | `thread_ts: "none"` |
|
|
88
|
-
|
|
89
|
-
Going top-level takes the explicit `"none"`: a channel's main flow is wider
|
|
90
|
-
than a thread. A `thread_ts` is never inherited across a change of `channel`.
|
|
91
|
-
The response carries `ts` and `threadTs` for replying under what you posted.
|
|
92
|
-
|
|
93
|
-
## Editing
|
|
94
|
-
|
|
95
|
-
```json
|
|
96
|
-
{"operation":"edit","channel":"#ops","ts":"1717243800.000100",
|
|
97
|
-
"text":"**Deploy done** — 3 services, 1 rollback."}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
`text` replaces the message outright; there is no partial edit. Read the
|
|
101
|
-
message first if you are changing part of it.
|
|
102
|
-
|
|
103
|
-
- `ts` is always explicit, as with `delete`, and means nothing outside the
|
|
104
|
-
channel it was read in.
|
|
105
|
-
- The old text is gone — Slack keeps no version a reader can open, and may not
|
|
106
|
-
mark the message as edited at all. When the previous wording mattered to
|
|
107
|
-
people reading, say what changed rather than quietly rewriting history.
|
|
108
|
-
- A long-running update — a status line, a running tally — is better as one
|
|
109
|
-
message edited in place than as a new message per change.
|
|
110
|
-
|
|
111
|
-
## Deleting
|
|
112
|
-
|
|
113
|
-
```json
|
|
114
|
-
{"operation":"delete","channel":"#ops","ts":"1717243800.000100"}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
- `ts` is always explicit. There is no "delete the last one" and no default
|
|
118
|
-
from the thread you are in: the wrong `ts` cannot be undone.
|
|
119
|
-
- A `ts` means nothing outside the conversation it came from — pass the
|
|
120
|
-
`channel` it was read in.
|
|
121
|
-
- Deleting a thread parent does not remove its replies. Say what you removed;
|
|
122
|
-
a message vanishing with no word looks like a Slack bug to everyone watching.
|
|
123
|
-
|
|
124
|
-
## Message syntax
|
|
11
|
+
## Markdown is not Slack syntax
|
|
125
12
|
|
|
126
13
|
`text` is **standard markdown** and Slack renders it natively: `**bold**`,
|
|
127
|
-
`_italic_`, `` `code` ``,
|
|
128
|
-
|
|
129
|
-
literally.
|
|
14
|
+
`_italic_`, `` `code` ``, fences, headings, lists, tables, blockquotes. Never
|
|
15
|
+
hand-convert to the older mrkdwn `*bold*` — it renders literally.
|
|
130
16
|
|
|
131
|
-
Four things
|
|
17
|
+
Four things markdown cannot express:
|
|
132
18
|
|
|
133
19
|
| Intent | Write | Not |
|
|
134
20
|
| --- | --- | --- |
|
|
135
|
-
| Mention a person | `<@U04B7Q2>` | `@alice` — plain text,
|
|
21
|
+
| Mention a person | `<@U04B7Q2>` | `@alice` — plain text, pings nobody |
|
|
136
22
|
| Link a channel | `<#C0123456>` | `#general` — plain text |
|
|
137
|
-
| Notify
|
|
23
|
+
| Notify the channel | `<!here>`, `<!channel>` | `@here` — plain text |
|
|
138
24
|
| Hyperlink | `[label](https://…)` | — |
|
|
139
25
|
|
|
140
|
-
- **Never guess an id from a name.** A wrong `<@U…>`
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
26
|
+
- **Never guess an id from a name.** A wrong `<@U…>` fails or pings a stranger,
|
|
27
|
+
and both look like it worked. With no id, write the person's name as prose.
|
|
28
|
+
- **You already have the ids** — the sender header on the message you are
|
|
29
|
+
answering, `name[id]` on every transcript line, `context` for this channel and
|
|
30
|
+
thread. Asking a human to paste their own user ID is never acceptable.
|
|
31
|
+
- Escape `&` `<` `>` when they are text, not markup: `&` `<` `>`.
|
|
145
32
|
- Emoji as `:white_check_mark:`, not the raw glyph.
|
|
146
|
-
- ~11,000
|
|
147
|
-
|
|
33
|
+
- ~11,000 chars per message: split longer content across replies in one thread
|
|
34
|
+
rather than truncating.
|
|
35
|
+
|
|
36
|
+
## Targeting
|
|
37
|
+
|
|
38
|
+
- Omitting `channel`/`thread_ts` means "here" — the conversation that reached
|
|
39
|
+
you. `context` names it; `inSlack:false` means a task, subagent or web session
|
|
40
|
+
started this, so `channel` is required.
|
|
41
|
+
- `channels` lists what Pier can reach; an id or a `#name` works anywhere a
|
|
42
|
+
channel is wanted.
|
|
43
|
+
- `thread_ts:"none"` is the only way to a new top-level message — a channel's
|
|
44
|
+
main flow is wider than a thread. A `thread_ts` is never inherited across a
|
|
45
|
+
change of `channel`.
|
|
46
|
+
- A `ts` means nothing outside the conversation it was read in, and `edit` /
|
|
47
|
+
`delete` always take it explicitly — no default from the thread you are in.
|
|
48
|
+
|
|
49
|
+
## Reading
|
|
50
|
+
|
|
51
|
+
- A channel read returns thread **parents** only; `[thread: N replies]` marks
|
|
52
|
+
the ones worth a `read_thread`.
|
|
53
|
+
- `read_message` also needs `thread_ts` when the message was posted inside a
|
|
54
|
+
thread — a channel read cannot see thread replies.
|
|
55
|
+
- The leading `ts` on a line is Slack's id: pass it back as `thread_ts` or
|
|
56
|
+
`after`. `after` is strictly newer, for re-reading without seeing what you
|
|
57
|
+
already saw.
|
|
58
|
+
- `truncated` → narrow the range rather than raising `limit` (default and max
|
|
59
|
+
400). `incomplete` → the read stopped early for the reason given; work with a
|
|
60
|
+
partial answer, but never report it as everything.
|
|
61
|
+
- Resolve a vague time ("yesterday") to an explicit ISO range and say which
|
|
62
|
+
range you used.
|
|
63
|
+
|
|
64
|
+
## Files
|
|
65
|
+
|
|
66
|
+
`[file: <name> <F… id> <size>]` on a line is an upload, never its bytes.
|
|
67
|
+
`fetch_file` with that `F…` id (no `channel` needed) saves it and replies with a
|
|
68
|
+
marker line — `[postmortem.pdf](file:///…)` — so you read it only if the
|
|
69
|
+
question needs its contents. Over 32 MB or refused by Slack: `[attachment lost:
|
|
70
|
+
<name> — <reason>]`.
|
|
148
71
|
|
|
149
72
|
## Rules
|
|
150
73
|
|
|
74
|
+
- Read before you write. A summary of the wrong thread is worse than none.
|
|
151
75
|
- **In a busy thread, say nothing unless you are needed.** You are handed every
|
|
152
76
|
message, including humans talking to each other. `<silent>why</silent>` sends
|
|
153
77
|
nothing at all — prefer it to acknowledging what was not addressed to you.
|
|
154
|
-
-
|
|
78
|
+
- `edit` replaces `text` outright; read the message first if you are changing
|
|
79
|
+
part of it. Slack keeps no version a reader can open and may not mark the
|
|
80
|
+
message as edited, so when the previous wording mattered to people, say what
|
|
81
|
+
changed instead of quietly rewriting history. A running status or tally is
|
|
82
|
+
better as one message edited in place than one message per change.
|
|
83
|
+
- `delete` cannot be undone, and deleting a thread parent leaves its replies.
|
|
84
|
+
Say what you removed; a message vanishing with no word looks like a bug.
|
|
155
85
|
- Never post credentials, tokens or file contents you were not asked to share:
|
|
156
86
|
a channel is usually wider than the conversation you are in.
|
|
157
87
|
- "Slack agent access is switched off" means the operator disabled it on
|
|
158
88
|
purpose. Say so and stop; do not look for another route.
|
|
159
|
-
- Resolve vague times ("yesterday") to an explicit ISO range and say which
|
|
160
|
-
range you used.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|