@timqi/pier 0.0.27 → 0.0.29
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/config-sync.js +39 -8
- package/dist/agent/config.js +72 -15
- package/dist/agent/events.js +24 -4
- package/dist/core/identity.js +17 -1
- package/dist/core/router.js +10 -0
- package/dist/db.js +27 -0
- package/dist/main.js +1 -0
- package/dist/settings.js +4 -1
- package/dist/tasks/service.js +4 -0
- package/dist/tasks/store.js +12 -0
- package/dist/tools.js +17 -3
- package/dist/web/public/assets/{activity-B44nbhXy.js → activity-D3m4L2IL.js} +2 -2
- package/dist/web/public/assets/activity-D3m4L2IL.js.br +0 -0
- package/dist/web/public/assets/activity-D3m4L2IL.js.gz +0 -0
- package/dist/web/public/assets/boards-BIObcQeX.js +1 -0
- package/dist/web/public/assets/boards-BIObcQeX.js.br +0 -0
- package/dist/web/public/assets/boards-BIObcQeX.js.gz +0 -0
- package/dist/web/public/assets/explorer-C_rSWPNB.js +4 -0
- package/dist/web/public/assets/explorer-C_rSWPNB.js.br +0 -0
- package/dist/web/public/assets/explorer-C_rSWPNB.js.gz +0 -0
- package/dist/web/public/assets/index-CX3fYZY5.css +2 -0
- package/dist/web/public/assets/index-CX3fYZY5.css.br +0 -0
- package/dist/web/public/assets/index-CX3fYZY5.css.gz +0 -0
- package/dist/web/public/assets/index-uFsZkKOQ.js +85 -0
- package/dist/web/public/assets/index-uFsZkKOQ.js.br +0 -0
- package/dist/web/public/assets/index-uFsZkKOQ.js.gz +0 -0
- package/dist/web/public/assets/runs-Ch6DZq6O.js +1 -0
- package/dist/web/public/assets/runs-Ch6DZq6O.js.br +0 -0
- package/dist/web/public/assets/runs-Ch6DZq6O.js.gz +0 -0
- package/dist/web/public/assets/settings-BWcEIEcv.js +5 -0
- package/dist/web/public/assets/settings-BWcEIEcv.js.br +0 -0
- package/dist/web/public/assets/settings-BWcEIEcv.js.gz +0 -0
- package/dist/web/public/assets/{task-runs-BW06ZEVz.js → task-runs-DPkwv2UE.js} +2 -2
- package/dist/web/public/assets/task-runs-DPkwv2UE.js.br +0 -0
- package/dist/web/public/assets/task-runs-DPkwv2UE.js.gz +0 -0
- package/dist/web/public/assets/tasks-DTiCi2mH.js +4 -0
- package/dist/web/public/assets/tasks-DTiCi2mH.js.br +0 -0
- package/dist/web/public/assets/tasks-DTiCi2mH.js.gz +0 -0
- package/dist/web/public/index.html +41 -27
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/server.js +30 -76
- package/dist/web/session-state.js +55 -52
- package/package.json +1 -1
- package/skills/pier-tasks/SKILL.md +113 -79
- package/dist/web/public/assets/activity-B44nbhXy.js.br +0 -0
- package/dist/web/public/assets/activity-B44nbhXy.js.gz +0 -0
- package/dist/web/public/assets/boards-CeiKKBaY.js +0 -1
- package/dist/web/public/assets/boards-CeiKKBaY.js.br +0 -0
- package/dist/web/public/assets/boards-CeiKKBaY.js.gz +0 -0
- package/dist/web/public/assets/code-I0lxXuvE.js +0 -1
- package/dist/web/public/assets/explorer-BOeDogsY.js +0 -5
- package/dist/web/public/assets/explorer-BOeDogsY.js.br +0 -0
- package/dist/web/public/assets/explorer-BOeDogsY.js.gz +0 -0
- package/dist/web/public/assets/index-BmKvoulH.js +0 -84
- package/dist/web/public/assets/index-BmKvoulH.js.br +0 -0
- package/dist/web/public/assets/index-BmKvoulH.js.gz +0 -0
- package/dist/web/public/assets/index-CZeL3DfU.css +0 -2
- package/dist/web/public/assets/index-CZeL3DfU.css.br +0 -0
- package/dist/web/public/assets/index-CZeL3DfU.css.gz +0 -0
- package/dist/web/public/assets/runs-C4OlQT7W.js +0 -1
- package/dist/web/public/assets/runs-C4OlQT7W.js.br +0 -0
- package/dist/web/public/assets/runs-C4OlQT7W.js.gz +0 -0
- package/dist/web/public/assets/settings-Cn8i_QiP.js +0 -6
- package/dist/web/public/assets/settings-Cn8i_QiP.js.br +0 -0
- package/dist/web/public/assets/settings-Cn8i_QiP.js.gz +0 -0
- package/dist/web/public/assets/task-runs-BW06ZEVz.js.br +0 -0
- package/dist/web/public/assets/task-runs-BW06ZEVz.js.gz +0 -0
- package/dist/web/public/assets/tasks-DZzYlKsd.js +0 -4
- package/dist/web/public/assets/tasks-DZzYlKsd.js.br +0 -0
- package/dist/web/public/assets/tasks-DZzYlKsd.js.gz +0 -0
- package/dist/web/repos.js +0 -75
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{C as e,D as t,E as n,F as r,H as i,J as a,K as o,M as s,N as c,O as l,P as u,R as d,S as f,T as p,U as m,_ as h,b as g,c as _,d as v,f as y,g as b,h as x,j as S,k as C,m as w,o as T,p as E,r as D,t as O,u as k,v as A,x as j,y as M}from"./index-uFsZkKOQ.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=()=>j(`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`)=>j(`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 e=h(`Create Slack app ↗`,!0);e.classList.add(`mt-1`,`w-fit`),e.onclick=()=>window.open(P(),`_blank`,`noreferrer`);let t=r(`btn w-fit text-[12.5px]`,()=>JSON.stringify(N,null,2));return j(`Creating a Slack app`,[S(`Opens Slack with every scope, event and Socket Mode already filled in. Pick your workspace → Create.`,e),"`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.",S(`Prefer to paste it yourself? Create the app from a manifest and use this:`,t)])}var R=()=>j(`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`)=>j(`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=()=>j(`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`)=>j(`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)=>d(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,d(`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(n){let r=localStorage.getItem(U),i=V.some(([e])=>e===r)?r:`telegram`,a=null,s=[],c=d(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),l=d(`div`,`sticky top-0 z-30 flex items-center gap-1 border-b border-neutral-200 bg-white px-4 py-2`,c),f=d(`div`,`px-4 py-5`);n.append(d(`div`,`min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,l,f));function p(){l.replaceChildren(...V.map(([t,n])=>e(n,t===i,()=>{_&&j(),i=t,localStorage.setItem(U,t),N()})),c)}let _,v=!1,y=null;function S(e){if(c.replaceChildren(),e!==`clean`){if(c.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${w[e]}`,e===`saving`)c.append(d(`span`,`spinner`),d(`span`,``,`Saving…`));else if(e===`saved`)c.append(d(`span`,``,`✓`),d(`span`,``,`Saved`)),setTimeout(()=>{c.textContent?.includes(`Saved`)&&S(`clean`)},2e3);else{let e=b(`Retry`,`cursor-pointer underline`);e.onclick=j,c.append(d(`span`,``,`⚠`),d(`span`,``,`Save failed`),e)}}}function T(){S(`saving`),clearTimeout(_),_=setTimeout(j,500)}let E=e=>t=>{e(t),T()};async function k(e){v=!0,S(`saving`);try{S((await o(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{S(`failed`)}finally{v=!1;let e=y;y=null,e&&k(e)}}function j(){if(clearTimeout(_),_=void 0,!a)return;let e={platform:i,config:a};v?y=e:k(e)}async function N(){if(!s.length){let e=await m(`/api/models`,`Could not load the model catalog`);e.ok&&(s=e.value)}let e=await m(`/api/channels/${i}`,`Failed to load`);if(!e.ok){a=null,p(),f.replaceChildren(M(e.error));return}a=e.value,S(`clean`),G()}function P(e){let n=i===`slack`,r=i===`lark`,a=t(e.token,n?`xoxb-…`:r?`cli_…`:`123456789:AA…`,E(t=>e.token=t),!0),o=t(e.appToken,r?``:`xapp-…`,E(t=>e.appToken=t),!0),s=O(e.cwd,`(pier process cwd)`,E(t=>e.cwd=t));return A(`Connection`,n?`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,E(t=>{e.enabled=t,p()})),g(r?`App ID`:`Bot token`,a,{hint:`Stored locally, shown masked once saved.`,help:i===`telegram`?F():n?L():ee()}),...n?[g(`App-level token`,o,{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,E(t=>e.agentTool=t),R())]:[],...r?[g(`App Secret`,o,{hint:`From Credentials & Basic Info, beside the App ID.`})]:[],g(`Default working directory`,s.el,{hint:`Where sessions this channel opens start.`}))}function ne(e){return A(`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,E(t=>e.requireMention=t)),C(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,E(t=>e.requireBind=t)),...i===`slack`?[H(`Thread mode: always on`,z())]:i===`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,E(t=>e.topicMode=t),I())],D(`Model & reasoning`,e,s,E(t=>{e.model=t.model,e.thinking=t.thinking,G()})))}function W(e){let t=d(`span`,`font-mono text-[15px] font-semibold tracking-widest`),n=d(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,d(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),r=h(`Generate bind code`);r.onclick=async()=>{let e=await fetch(`/api/channels/${i}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:r}=await e.json();t.textContent=r,n.classList.replace(`hidden`,`flex`)};let a=d(`div`,`flex flex-col`);e.users.length||a.append(M(`No bound users yet.`));for(let t of e.users){let e=b(`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/${i}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await N()},a.append(d(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,d(`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()),d(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),d(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return A(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,a,d(`div`,`flex flex-col gap-2`,r,n))}function re(e,t){let n=d(`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=d(`div`,`flex items-center gap-2`,d(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),x(t.kind,te[t.kind]),d(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),a=C(``,``,t.enabled,E(e=>{t.enabled=e,G()}));a.classList.add(`flex-none`,`items-center`),r.append(a);let o=d(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?o.append(d(`span`,`text-[13px] text-neutral-400`,i===`telegram`?`Direct message · bound users only, mention and topics not applicable`:`Direct message · bound users only, mention not applicable`)):o.append(C(`Require mention`,``,t.requireMention,E(e=>t.requireMention=e)),C(`Require bind`,``,t.requireBind,E(e=>t.requireBind=e)),i===`slack`?H(`Thread mode: always on`,z(`right`)):i===`lark`?H(`Thread mode: always on`,B(`right`)):t.kind===`forum`?C(`Topic mode`,``,t.topicMode,E(e=>t.topicMode=e),I(`right`)):H(`Topic mode: forum groups only`,I(`right`)));let c=O(t.cwd,``,E(e=>t.cwd=e)),l=d(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,g(`Working directory`,c.el),D(`Model & reasoning`,t,s,E(e=>{t.model=e.model,t.thinking=e.thinking,G()})));return n.append(r,o,l),n}function ie(e){let t=d(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>re(e,t))):t.append(M(`None yet. Chats appear here after the bot sees a message in them.`)),A(i===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function G(){if(!a)return;p();let e=d(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(P(a),ne(a),W(a),ie(a)),f.replaceChildren(e)}return u(n,()=>void N(),()=>{_&&j()})}function W(){let e=d(`div`,`min-h-0 min-w-0 flex-1 overflow-y-auto p-4`),a=d(`div`,`mx-auto flex max-w-3xl min-w-0 flex-col gap-4`),s=d(`p`,`text-[12px] break-words`),c=d(`section`,`flex min-w-0 flex-col gap-3 border-b border-neutral-200 pb-4`),l=d(`section`,`flex min-w-0 flex-col gap-3`);a.append(d(`h2`,`text-[14px] font-semibold text-neutral-700`,`Configuration sync`),s,c,l),e.append(a);let u=null,f=!1,p=!1,_=0,v=``,y=!1,b=e=>e?new Date(e).toLocaleString():`Never`;async function x(){let e=_,t=await m(`/api/config-sync`,`Could not load configuration sync`,{cache:`no-store`});if(!(p||e!==_)){if(!t.ok){n(s,`failed`,t.error);return}u=t.value,y||(v=u.sourceUrl),T()}}async function S(e){if(!f){++_,f=!0,T(),n(s,`saving`,`Working...`);try{let t=await o(`/api/config-sync`,{action:e,...e===`subscribe`?{url:v}:{}});if(!t.ok)throw Error(await i(t,`Configuration sync failed`));let r=await t.json();u=r,y=!1,v=r.sourceUrl,n(s,`saved`,r.result??`Saved`)}catch(e){n(s,`failed`,e instanceof Error?e.message:`Configuration sync failed`),await x()}finally{f=!1,p||T()}}}function w(e,t){let n=h(e);return n.disabled=f,n.onclick=()=>{S(t)},n}function T(){if(!u||p)return;if(c.replaceChildren(d(`h3`,`text-[13px] font-medium text-neutral-700`,`Publish`)),u.publishedPath){let e=`${u.publicUrl||window.location.origin}${u.publishedPath}`,n=t(e,``,()=>{},!0);n.readOnly=!0,n.setAttribute(`aria-label`,`Sharing URL`),c.append(n,d(`div`,`flex flex-wrap items-center gap-2`,r(`btn text-[12px]`,()=>e),w(`Revoke link`,`revoke`)))}else c.append(d(`div`,``,w(`Generate link`,`publish`)));c.append(d(`p`,`text-[12px] text-neutral-500`,`Anyone with the link can read shared prompts, model definitions, the default model and its reasoning effort. API keys, headers and endpoints stay private.`));let e=t(v,`https://example.com/config-sync/...`,e=>{v=e,y=!0},!0);e.type=`url`,e.setAttribute(`aria-label`,`Configuration source URL`),e.disabled=f||u.enabled;let n=C(`Automatic sync`,``,u.enabled,e=>{S(e?`subscribe`:`pause`)});n.querySelector(`input`).disabled=f;let i=d(`div`,`flex flex-wrap items-center gap-3`,n);u.enabled&&i.append(w(`Sync now`,`sync`)),l.replaceChildren(d(`h3`,`text-[13px] font-medium text-neutral-700`,`Source`),g(`Source URL`,e),i);let a=d(`dl`,`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[12px]`);for(let[e,t]of[[`Last checked`,b(u.lastChecked)],[`Last applied`,b(u.lastApplied)],[`Next check`,u.enabled?b(u.nextRunAt):`Paused`]])a.append(d(`dt`,`text-neutral-500`,e),d(`dd`,`min-w-0 break-words text-neutral-700`,t));if(l.append(a),u.error&&l.append(d(`p`,`text-[12px] break-words text-red-600`,u.error)),u.needsReload&&l.append(d(`p`,`text-[12px] text-amber-700`,`Reload pending; retry synchronization.`)),u.taskId){let e=d(`a`,`text-[12px] text-indigo-600 hover:underline`,`Sync task history`);e.href=`#/tasks/${encodeURIComponent(u.taskId)}`,l.append(e)}}x();let E=setInterval(()=>{!f&&!y&&x()},15e3);return{el:e,dispose:()=>{p=!0,clearInterval(E)}}}async function re(e,t){let n;try{n=await o(`/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 i(n,`could not save`)}};let r;try{r=await n.json()}catch(e){return{outcome:{state:`failed`,text:`Saved, but the answer could not be read: ${String(e)}`}}}return r.toolsSync?.state===`refused`?{outcome:{state:`failed`,text:`Saved, but nothing will install it: ${r.toolsSync.reason}`},answer:r}:r.toolsSync?.state===`waiting`?{outcome:{state:`saved`,text:`Saved — a sync is already running; this change goes in the run right after it.`},answer:r}:{outcome:{state:`saved`,text:t},answer:r}}function ie(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 G(e,r){let a=`global`,s=null,l=0,f=0,p=``,h=null,_=[],b=``,S=null,w=null,T=()=>{w?.dispose(),w=null},D=()=>{T(),++f,w=W(),L.replaceChildren(w.el)},O=[],A=()=>_.filter(e=>e.kind===`extension`),j=e=>e.source===`binary`&&e.custom===!0,M=()=>_.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=()=>{T(),a=N.value,s=null,q.clear(),te()};let P=d(`div`,`flex flex-none flex-col gap-1 border-b border-neutral-200 px-3 pb-2.5 pt-2`);P.append(d(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Scope`),N);let F=d(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),I=d(`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=d(`div`,`flex min-w-0 flex-1 flex-col`),R=d(`div`,`flex min-h-0 flex-1 max-md:flex-col`);R.append(I,L),e.append(R);let z=(e=``)=>`?scope=${encodeURIComponent(a)}${e}`;async function ee(){if(a!==`global`){_=[],b=``;return}let e=await m(`/api/settings`,`could not be loaded`,{cache:`no-store`});if(!e.ok){_=[],b=e.error;return}B(e.value),b=``}function B(e){_=e.catalog,O=e.customTools,S=e.toolsTaskId}async function V(e,t){let{outcome:n,answer:r}=await re(e,t);return r&&(B(r),Y(h)),n}function H(e,t){let n={name:e,on:t};return _.find(t=>t.name===e)?.source===`binary`?{tool:n}:{extension:n}}async function te(){let e=++l;f++;let[t]=await Promise.all([m(`/api/config${z()}`,`failed to load config`,{cache:`no-store`}),ee()]);if(e!==l)return;if(!t.ok){Y(null),X(t.error);return}let n=t.value;a===`global`&&n.dir&&(p=n.dir,pe()),h=n,Y(n),s?s.type===`sync`&&D():oe()}function U(e){return d(`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=d(`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},G=()=>d(`span`,`flex-none rounded bg-emerald-50 px-1 text-[10px] font-semibold uppercase tracking-wide text-emerald-700`,`on`);function K(e,t,n,r,i=0,a){let o=d(`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 o.append(d(`span`,`truncate`,e)),a&&o.append(a),o.style.paddingLeft=`${20+i*14}px`,o.title=e,o.onclick=r,o}function ae(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 q=new Set;function J(e,t,n,r,i,a){let o=[];for(let[s,c]of t.dirs){let t=n?`${n}/${s}`:s,l=`${e}:${t}`,u=document.createElement(`details`);u.open=q.has(l),u.ontoggle=()=>u.open?q.add(l):q.delete(l);let f=d(`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(d(`span`,`chev`,`▶`),d(`span`,`truncate text-neutral-600`,s)),c.link&&f.append(ne()),u.append(f,...J(e,c,t,r+1,i,a)),o.push(u)}for(let s of t.files){let t={type:`resource`,kind:e,name:n?`${n}/${s.name}`:s.name};o.push(K(s.name,i(t),!1,()=>a(t),r,s.link?ne():void 0))}return o}function Y(e){if(!e){F.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(s),n=t=>{T(),s=t,Y(e),t.type===`file`?se(t.name):t.type===`bundled`?ue(t.name):t.type===`tools`?$():t.type===`sync`?D():fe(t.kind,t.name)},r=[];if(a===`global`){let e={type:`sync`};r.push(U(`Instance`),K(`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(K(i.name,t(e),!i.exists,()=>n(e)))}if(a===`global`){r.push(U(`bundled with Pier`)),b?r.push(d(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-red-600`,b)):A().length||r.push(d(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`));for(let e of A()){let i={type:`bundled`,name:e.name};r.push(K(e.name,t(i),!1,()=>n(i),0,e.enabled?G():void 0))}if(!b){let e={type:`tools`},i=M().filter(e=>e.enabled).length;r.push(K(`command-line tools`,t(e),!1,()=>n(e),0,i?G():void 0))}}for(let i of[`extensions`,`skills`]){r.push(U(`${i} (read-only)`));let a=e.resources[i];a.length||r.push(d(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),r.push(...J(i,ae(a),``,0,t,n))}F.replaceChildren(...r)}function oe(){L.replaceChildren(d(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Select a file to edit, or browse extensions and skills.`))}function X(e){L.replaceChildren(d(`p`,`px-4 py-3 text-[13px] text-red-600`,e))}let Z=(e,...t)=>d(`div`,`flex flex-none items-center gap-3 border-b border-neutral-200 px-4 py-2`,d(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function se(e){let t=++f,r=await m(`/api/config/files/${encodeURIComponent(e)}${z()}`,`failed to load ${e}`,{cache:`no-store`});if(!r.ok){t===f&&X(r.error);return}if(t!==f)return;let{content:a}=r.value,s=a,c=d(`span`,`text-[11.5px] text-neutral-400`,``),l=d(`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=a;let p=async()=>{if(l.disabled)return;let t=u.value;l.disabled=!0,n(c,`saving`,`saving…`);try{let r=await o(`/api/config/files/${encodeURIComponent(e)}${z()}`,{content:t,expected:s},`PUT`);if(!r.ok)return n(c,`failed`,await i(r,`save failed`));let a=await r.json();s=a.content,u.value===t?(u.value=a.content,n(c,`saved`,`saved — applies to new sessions`)):n(c,`idle`,`saved; newer changes are unsaved`)}catch(e){n(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=()=>{n(c,`idle`,`unsaved changes`)},L.replaceChildren(Z(e,c,l),u),u.focus()}function ce(e){if(!S)return null;let t=d(`a`,`text-indigo-600 hover:underline`,e);return t.href=`#/tasks/${encodeURIComponent(S)}`,t}let Q=()=>{let e=d(`a`,`text-indigo-600 hover:underline`,`ubix`);return e.href=`https://github.com/timqi/ubix`,e.target=`_blank`,e.rel=`noreferrer`,e};function le(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){f++;let r=_.find(t=>t.name===e&&t.kind===`extension`);if(!r)return X(`unknown extension: ${e}`);let i=d(`span`,`text-[11.5px] text-neutral-400`,``);t&&n(i,t.state,t.text);let a=ce(`every run of the update task`);L.replaceChildren(Z(r.name,d(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,r.source===`binary`?`installed by Pier`:`ships with Pier`)),d(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,d(`p`,`max-w-2xl text-[13px] leading-relaxed text-neutral-600`,r.summary),d(`dl`,`flex max-w-2xl flex-col gap-1.5`,...(r.source===`bundled`?r.adds:[]).flatMap(e=>[d(`dt`,`font-mono text-[12px] text-neutral-700`,e.name),d(`dd`,`text-[12px] leading-snug text-neutral-500`,`needs ${e.needs}`)]),...r.source===`binary`?[d(`dt`,`font-mono text-[12px] text-neutral-700`,`binary`),d(`dd`,`font-mono text-[12px] leading-snug ${r.binary.error?`text-red-600`:`text-neutral-500`}`,le(r))]:[]),C(`Enabled`,r.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.`,r.enabled,t=>void de(r.name,t,t=>ue(e,t))),d(`p`,`max-w-2xl text-[12px] leading-snug text-neutral-400`,...r.source===`binary`?a?[`A daily task installs and updates it — its history is `,a,`.`]:[`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.`]),i))}function $(e,r={name:``,toml:``}){f++;let i=d(`span`,`text-[11.5px] text-neutral-400`,``);e&&n(i,e.state,e.text);let a=M(),o=ce(`the update task`),s=e=>{let t=d(`div`,`flex min-w-0 flex-1 flex-col gap-0.5`,d(`span`,`flex items-center gap-2 text-[13px] text-neutral-700`,d(`span`,`font-mono`,e.name),...j(e)?[x(`yours`,`bg-neutral-50 text-neutral-500 ring-neutral-200`)]:[]),d(`span`,`text-[11.5px] leading-snug text-neutral-400`,e.summary||le(e)),...e.summary?[d(`span`,`font-mono text-[11px] leading-snug ${e.source===`binary`&&e.binary.error?`text-red-600`:`text-neutral-400`}`,le(e))]:[]),n=C(``,``,e.enabled,t=>void de(e.name,t,e=>$(e))),r=d(`button`,`btn text-[12px] text-neutral-500 hover:text-red-600`,`Remove`);return r.onclick=()=>{r.disabled=!0;let t=ie(e,O);V(t.body,t.saved).then(e=>$(e))},d(`div`,`flex max-w-2xl items-start gap-3 border-b border-neutral-100 py-2.5 last:border-0`,t,...j(e)?[r]:[],n)},c={...r},l=d(`span`,`font-mono text-[12px] text-neutral-500`,`[tools.<name>]`),u=t(c.name,`claude`,e=>{c.name=e,l.textContent=`[tools.${e.trim()||`<name>`}]`},!0),p=document.createElement(`textarea`);p.className=`${E} h-24 resize-y font-mono leading-snug`,p.spellcheck=!1,p.value=c.toml,p.placeholder=`spec = "github:owner/repo"
|
|
2
|
+
exe = "tool"`,p.oninput=()=>c.toml=p.value;let m=d(`button`,`btn btn-primary text-[12.5px]`,`Add`);m.onclick=()=>{let e={name:c.name.trim(),toml:c.toml.trim()};if(!e.name||!e.toml)return n(i,`failed`,`A custom tool needs a name and a block with a spec line.`);m.disabled=!0,V({customTools:[...O,e],tool:{name:e.name,on:!0}},`Added ${e.name} — installing now.`).then(e=>$(e,e.state===`failed`?c:void 0))},L.replaceChildren(Z(`command-line tools`,d(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`installed by Pier`)),d(`div`,`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4`,d(`p`,`max-w-2xl text-[12.5px] leading-relaxed text-neutral-500`,`Pier writes no downloader: `,Q(),` does the work — a declarative installer that resolves a spec like `,d(`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.`),b?d(`p`,`max-w-2xl text-[12.5px] text-red-600`,b):d(`div`,`flex max-w-2xl flex-col`,...a.map(s)),d(`div`,`flex max-w-2xl flex-col gap-2 border-t border-neutral-200 pt-4`,d(`span`,`text-[12.5px] font-medium text-neutral-600`,`Add one of your own`),g(`Name`,u),g(`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.`}),d(`div`,`flex items-center gap-3`,l,m)),d(`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.`]),i))}async function de(e,t,n){let r=_.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=++f,r=await m(`/api/config/resource${z(`&kind=${e}&name=${encodeURIComponent(t)}`)}`,`failed to load ${t}`,{cache:`no-store`});if(!r.ok){n===f&&X(r.error);return}if(n!==f)return;let{content:i}=r.value,a=await y(t);n===f&&L.replaceChildren(Z(t,d(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`read-only`)),d(`div`,`min-h-0 flex-1 overflow-auto`,k(v(i),a)))}function pe(){N.replaceChildren(new Option(p?`Global (${p})`:`Global`,`global`),...r().map(e=>new Option(`${c(e)} — ${e}`,e))),[...N.options].some(e=>e.value===a)||(a=`global`),N.value=a}return u(e,()=>{pe(),te()},T)}var K=e=>`${e.provider}/${e.id}`,ae=[`hardest reasoning — architecture, gnarly debugging`,`long autonomous implementation runs`,`balanced default — implementation, review`,`cheap & fast — listings, extraction, simple checks`,`cross-vendor second opinion`];function q(){let e=[],t=[],r=!1,s=d(`span`,`text-[11.5px]`,``),c=h(`Save menu`,!0),l=d(`div`,`flex min-w-0 flex-col gap-2`),u=d(`div`,`flex items-center gap-2`),v=d(`div`,`mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-6`);function y(){r=!0,n(s,`idle`,`unsaved changes`)}function b(t){let n=f(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,y()};let r=p([[`thinking: model default`,``],..._.map(e=>[`thinking: ${a(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,y()};let i=h(`Remove`);i.classList.add(`flex-none`),i.onclick=()=>{e=e.filter(e=>e!==t),y(),S()};let o=d(`span`,`w-52 flex-none truncate font-mono text-[12px] text-neutral-700`,K(t));return o.title=K(t),d(`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 x(){let n=t.filter(t=>!e.some(e=>K(e)===K(t))),r=p(n.map(e=>[K(e),K(e)]),n[0]?K(n[0]):``);r.classList.replace(`w-full`,`flex-1`),r.classList.add(`min-w-0`);let i=h(`+ Pin model`);i.classList.add(`flex-none`,`whitespace-nowrap`),i.disabled=n.length===0,i.onclick=()=>{let t=n.find(e=>K(e)===r.value);t&&(e.push({...t}),y(),S())},u.replaceChildren(r,i)}function S(){l.replaceChildren(...e.length?e.map(b):[M(`Nothing pinned — every picker shows the curated catalog as is.`)]),x()}async function C(){n(s,`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()}:{}})),a=await o(`/api/settings`,{modelMenu:t},`PUT`);if(!a.ok)return n(s,`failed`,await i(a,`Could not save`));e=(await a.json()).modelMenu,r=!1,n(s,`saved`,`Saved — agents see it on their next models call.`),S()}c.onclick=()=>void C();function w(){r||(async()=>{let[r,i]=await Promise.all([m(`/api/settings`,`Could not load the menu`),m(`/api/models`,`Could not load the model catalog`)]);if(!r.ok)return n(s,`failed`,r.error);e=r.value.modelMenu,t=i.ok?i.value:[],s.textContent=``,S()})()}let T=d(`datalist`,``);return T.id=`model-menu-notes`,T.append(...ae.map(e=>new Option(e))),v.append(A(`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.`,g(`Pinned models`,l,{hint:`The note is what an agent matches a task against — say when to reach for it, not what it is.`}),g(`Add`,u,{hint:`The list is the live catalog — only models that exist right now can be pinned.`}),d(`div`,`flex items-center gap-3`,c,s),T)),{el:v,load:w}}var J=(e,t)=>{let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`http:`&&n.protocol!==`https:`)return null;let r=d(`a`,`text-indigo-600 hover:underline`,t);return r.href=n.href,r.target=`_blank`,r.rel=`noreferrer`,r};function Y(e,t,n,a){let s=document.createElement(`dialog`);s.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let c=d(`div`,`flex flex-col gap-2`),l=d(`div`,`flex flex-col gap-2`),u=d(`p`,`text-[12.5px] text-neutral-400`,`Starting…`),p=h(`Cancel`),m=(e,t)=>{u.className=`text-[12.5px] ${w[e]}`,u.textContent=t};s.append(d(`div`,`border-b border-neutral-200 px-4 py-2.5 text-[14px] font-semibold`,t),d(`div`,`flex max-h-[65vh] flex-col gap-3 overflow-y-auto px-4 py-3`,c,l,u),d(`div`,`flex justify-end border-t border-neutral-200 px-4 py-2.5`,p)),document.body.append(s),s.showModal();let g=e.id,_=e.state,v,y,b=new Set,x=!1,S=!1,C=async e=>{if(!S){if(e&&_===`running`){S=!0,p.disabled=!0;try{let e=await o(`/api/providers/flows/${g}/cancel`,{});if(!e.ok&&e.status!==404){m(`failed`,await i(e,`Could not cancel authentication flow`));return}}catch(e){m(`failed`,`Could not cancel authentication flow: ${String(e)}`);return}finally{S=!1,p.disabled=!1}}clearTimeout(v),s.close()}};p.onclick=()=>void C(!0),s.oncancel=e=>{e.preventDefault(),C(!0)},s.onclose=()=>{x=!0,clearTimeout(v),s.remove()};let T=e=>{if(e.type===`auth_url`){let t=d(`div`,`flex flex-col gap-1 text-[12.5px] text-neutral-600`);return e.instructions&&t.append(d(`p`,``,e.instructions)),t.append(J(e.url,`Open authorization page`)??d(`span`,`text-red-600`,`Invalid authorization URL`)),t}if(e.type===`device_code`){let t=d(`div`,`flex flex-col gap-2 text-[12.5px] text-neutral-600`);return t.append(d(`div`,`flex items-center gap-2`,d(`code`,`font-mono text-[17px] font-semibold text-neutral-800`,e.userCode),r(`btn text-[11px]`,()=>e.userCode))),t.append(J(e.verificationUri,`Open verification page`)??d(`span`,`text-red-600`,`Invalid verification URL`)),t}let t=d(`div`,`text-[12.5px] text-neutral-600`,e.message);if(e.type===`info`)for(let n of e.links??[]){let e=J(n.url,n.label??n.url);e&&t.append(` `,e)}return t},E=(e,t)=>{y=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=f(``,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 r=h(`Continue`,!0);r.type=`submit`;let a=d(`form`,`flex flex-col gap-2`,d(`label`,`text-[12.5px] font-medium text-neutral-700`,t.message),n,d(`div`,`flex justify-end`,r));a.onsubmit=a=>{a.preventDefault(),r.disabled=!0,(async()=>{try{let r=await o(`/api/providers/flows/${e.id}/respond`,{promptId:t.id,value:n.value});if(x)return;if(!r.ok){m(`failed`,await i(r,`Could not submit response`));return}b.add(t.id),y=void 0,l.replaceChildren(),m(`saving`,`Waiting for provider…`)}catch(e){x||m(`failed`,`Could not submit response: ${String(e)}`)}finally{r.disabled=!1}})()},l.replaceChildren(a),n.focus()},D=e=>{_=e.state,c.replaceChildren(...e.events.map(T));let t=e.prompt&&!b.has(e.prompt.id)?e.prompt:void 0;if(t?.id!==y&&(t?E(e,t):(y=void 0,l.replaceChildren())),e.state===`running`){m(`saving`,t?`Waiting for your response.`:`Waiting for provider…`);return}clearTimeout(v),l.replaceChildren(),e.state===`succeeded`?m(`saved`,`${n} configured.`):m(`failed`,e.state===`cancelled`?`Cancelled.`:e.error??`Authentication failed.`),p.textContent=`Close`,p.onclick=()=>void C(!1),e.state===`succeeded`&&a()},O=async()=>{if(!(x||_!==`running`))try{let e=await fetch(`/api/providers/flows/${g}`,{cache:`no-store`});if(x)return;if(!e.ok){m(`failed`,await i(e,`Authentication status unavailable`)),e.status===404?_=`failed`:v=setTimeout(()=>void O(),1e3);return}D(await e.json()),_===`running`&&(v=setTimeout(()=>void O(),500))}catch(e){if(x)return;m(`failed`,`Authentication status unavailable: ${String(e)}`),v=setTimeout(()=>void O(),1e3)}};D(e),_===`running`&&(v=setTimeout(()=>void O(),500))}var oe=[`anthropic`,`openai`,`openai-codex`,`google`,`openrouter`,`deepseek`],X=[[`OpenAI Chat Completions`,`openai-completions`],[`OpenAI Responses`,`openai-responses`],[`Anthropic Messages`,`anthropic-messages`],[`Google Generative AI`,`google-generative-ai`]],Z=`__custom__`;async function se(e){let t=h(`Add provider`,!0);t.classList.add(`ml-auto`);let r=d(`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`,d(`h2`,`text-[13px] font-semibold text-neutral-700`,`Providers`),t),a=d(`div`,`min-h-0 flex-1 overflow-y-auto`);e.replaceChildren(r,a);let s=[],c=``,l=async()=>{a.replaceChildren(d(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Loading…`));try{let[e,n]=await Promise.all([m(`/api/providers`,`Could not load providers`,{cache:`no-store`}),m(`/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){a.replaceChildren(M(e.error));return}let r=e.value;t.onclick=()=>Q(r,void 0,l),v(r)}catch(e){a.replaceChildren(M(`Could not load providers: ${String(e)}`))}},u=async e=>{if(window.confirm(`Remove the stored credential for ${e.name}?`))try{let t=await o(`/api/providers/${encodeURIComponent(e.id)}/logout`,{});if(!t.ok){window.alert(await i(t,`Could not remove credential`));return}await l()}catch(e){window.alert(`Could not remove credential: ${String(e)}`)}},f=e=>[...new Set([...(e.models??[]).map(e=>e.id),...s.filter(t=>t.provider===e.id).map(e=>e.id)])],g=(e,t)=>d(`div`,`flex flex-col gap-1`,d(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),d(`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)),_=async(e,t)=>{try{let n=await o(`/api/providers/${encodeURIComponent(e)}/check`,{model:t});return n.ok?await n.json():await i(n,`Could not test`)}catch(e){return`Could not test: ${String(e)}`}},v=e=>{let t=e.filter(e=>e.configured);if(!t.length){a.replaceChildren(M(`No providers configured.`));return}a.replaceChildren(...t.map(t=>{let r=d(`div`,`min-w-0 flex-1`,d(`div`,`truncate text-[13px] font-medium text-neutral-700`,t.name),d(`div`,`truncate font-mono text-[11px] text-neutral-400`,t.id)),i=t.stored===`api_key`?`API key`:t.stored===`oauth`?`OAuth`:t.source??`configured`,a=t.endpoint??`Default endpoint`,o=d(`div`,`flex min-w-32 flex-col items-start gap-1`,x(`configured`,`bg-emerald-50 text-emerald-700 ring-emerald-200`),d(`span`,`max-w-48 truncate text-[11px] text-neutral-500`,i),d(`span`,`max-w-48 truncate text-[11px] text-neutral-400`,a));o.title=a;let s=d(`span`,`text-[11.5px]`,``),m=d(`div`,`hidden flex-col gap-2 px-4 pb-3`,s),v=d(`div`,`flex flex-wrap justify-end gap-1.5`),y=f(t);if(!y.length)n(s,`idle`,c||`No models to test: none are configured here.`),m.classList.replace(`hidden`,`flex`);else{let e=p([[`Model to test…`,``],...y.map(e=>[e,e])],``);e.classList.add(`max-w-52`,`text-[12px]`);let r=h(`Test`);r.disabled=!0,e.onchange=()=>r.disabled=!e.value,r.onclick=()=>{let i=e.value;r.disabled=!0,m.replaceChildren(s),m.classList.replace(`hidden`,`flex`),n(s,`saving`,`asking ${i}…`),_(t.id,i).then(e=>{if(r.disabled=!1,typeof e==`string`)return n(s,`failed`,e);n(s,e.ok?`saved`:`failed`,`${e.model} ${e.ok?`answered`:`did not answer`} in ${e.ms} ms`),m.append(g(`sent`,e.request||`(the request was never made)`),g(e.ok?`answered`:`replied`,e.response))})},v.append(e,r)}if(t.builtin||t.api&&t.models){let n=h(`Edit`);n.onclick=()=>Q(e,t,l),v.append(n)}if(t.stored){let e=h(`Remove credential`);e.onclick=()=>void u(t),v.append(e)}return d(`div`,`border-b border-neutral-100`,d(`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]`,r,o,v),m)}))};await l()}function ce(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`,oe.flatMap(e=>n.filter(t=>t.id===e))),r(`More providers`,n.filter(e=>e.builtin&&!oe.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…`,Z))}function Q(e,t,n){let r=document.createElement(`dialog`);r.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let a=document.createElement(`select`);a.className=`${E} select`,t||ce(a,e);let s=f(),c=f(),u=f(),p=document.createElement(`select`);p.className=`${E} select`,p.append(...X.map(([e,t])=>new Option(e,t)));let m=l(``,4);m.placeholder=`model-id
|
|
3
|
+
another-model-id`;let _=document.createElement(`input`);_.type=`checkbox`;let v=document.createElement(`select`);v.className=`${E} select`;let y=d(`div`,`flex flex-col gap-4`),b=d(`span`,`text-[11.5px] text-red-600`,``),x=h(`Cancel`),S=h(t?`Save`:`Add`,!0);S.type=`submit`;let C=()=>t??e.find(e=>e.id===a.value),w=()=>{let e=C(),n=e?!e.builtin:a.value===Z;s.value=e?.id??``,s.disabled=t!==void 0,c.value=e?.name??``,u.value=e?.endpoint??``,p.value=e?.api??`openai-completions`,m.value=e?.models?.map(e=>e.id).join(`
|
|
4
|
+
`)??``;let r=e?.models?.map(e=>e.reasoning)??[];_.checked=r.length?r.every(Boolean):!e,_.indeterminate=r.some(Boolean)&&!r.every(Boolean);let i=[];e?.configured&&i.push(new Option(`Keep current authentication`,``));let o=e?.methods??[{type:`api_key`,name:`API key`}];for(let t of o.filter(t=>e?.builtin!==!1||t.type===`api_key`))i.push(new Option(t.name,t.type));v.replaceChildren(...i);let l=[];t||l.push(g(`Provider`,a)),n?l.push(g(`Provider ID`,s),g(`Display name`,c),g(`Endpoint`,u),g(`API format`,p),g(`Models`,m),g(`Model capabilities`,d(`label`,`flex items-center gap-2 text-[12.5px] text-neutral-600`,_,d(`span`,``,`Reasoning`)))):(u.placeholder=`Provider default`,l.push(g(`Endpoint`,u))),l.push(g(`Authentication`,v)),y.replaceChildren(...l)};a.onchange=w,w();let T=d(`form`,`flex flex-col gap-4 px-4 py-3`,y,d(`div`,`flex items-center justify-end gap-2`,b,x,S)),D=!1;x.onclick=()=>{D||r.close()},r.oncancel=e=>{D&&e.preventDefault()},T.onsubmit=e=>{if(e.preventDefault(),D)return;b.textContent=``;let t=C(),l=(t?!t.builtin:a.value===Z)?{kind:`custom`,id:s.value.trim(),...c.value.trim()?{name:c.value.trim()}:{},endpoint:u.value.trim(),api:p.value,models:[...new Set(m.value.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(Boolean))].map(e=>({id:e,reasoning:_.indeterminate?t?.models?.find(t=>t.id===e)?.reasoning??_.checked:_.checked}))}:{kind:`builtin`,id:t.id,...u.value.trim()?{endpoint:u.value.trim()}:{}},d=v.value||null;D=!0,S.disabled=!0,x.disabled=!0,(async()=>{try{let e=await o(`/api/providers/setup`,{setup:l,authType:d});if(!e.ok){b.textContent=await i(e,`Could not configure provider`);return}if(r.close(),e.status===202){let t=v.selectedOptions[0]?.textContent??`Authentication`;Y(await e.json(),l.id,t,()=>void n())}else await n()}catch(e){b.textContent=`Could not configure provider: ${String(e)}`}finally{D=!1,S.disabled=!1,x.disabled=!1}})()},r.append(d(`div`,`border-b border-neutral-200 px-4 py-2.5 text-[14px] font-semibold`,t?`Edit ${t.name}`:`Add provider`),T),r.onclose=()=>r.remove(),document.body.append(r),r.showModal(),(t?u:a).focus()}var le=[[`models`,`Models`],[`files`,`Agent`],[`channels`,`Channels`],[`instance`,`Instance`],[`security`,`Security`]],ue=e=>le.some(([t])=>t===e),$=`pier.settingsTopic`;function de(e){return[/\bEdg\//.test(e)?`Edge`:/\b(Firefox|Chrome|Safari)\/[\d.]+/.exec(e)?.[1],/\(([^;)]+)/.exec(e)?.[1]?.trim()].filter(Boolean).join(` · `)||e||`unknown client`}function fe(t,r,a){let c=localStorage.getItem($)??void 0,l=ue(c)?c:`models`,p=d(`header`,`flex h-10 flex-none items-center gap-3 border-b border-neutral-200 bg-white px-4 max-md:hidden`,d(`span`,`font-medium`,`Settings`)),_=d(`div`,`tabstrip bg-white`);function v(){_.replaceChildren(...le.map(([t,n])=>e(n,t===l,()=>a(t))))}let y=f();y.placeholder=`https://pier.example.com`,y.autocomplete=`off`;let b=d(`span`,`text-[11.5px]`,``),S=h(`Save`,!0);async function C(){n(b,`saving`,`saving…`);let e=await o(`/api/settings`,{publicUrl:y.value},`PUT`);if(!e.ok)return n(b,`failed`,await i(e,`Could not save`));let{publicUrl:t}=await e.json();y.value=t,n(b,`saved`,t?`Saved — boards link as ${t}/p/<slug>-<token>/`:`Cleared.`)}S.onclick=()=>void C(),y.onkeydown=e=>{e.key===`Enter`&&C()};let w=A(`Public URL`,`Where this Pier is reached from outside — the proxy's address, not the port it listens on.`,g(`Base URL`,y,{hint:`Agents read it to hand you a clickable board link instead of a path. Nothing here changes what Pier serves; leave it empty if Pier is only reachable locally.`}),d(`div`,`flex items-center gap-3`,S,b)),E=f(``,`password`),D=f(``,`password`),O=f(``,`password`);for(let e of[E,D,O])e.autocomplete=`off`;let k=d(`span`,`text-[11.5px]`,``),j=h(`Change password`,!0);async function N(){if(D.value!==O.value)return n(k,`failed`,`The two new passwords differ.`);n(k,`saving`,`changing…`);let e=await o(`/api/password`,{current:E.value,next:D.value});if(!e.ok)return n(k,`failed`,await i(e,`Could not change the password`));for(let e of[E,D,O])e.value=``;n(k,`saved`,`Changed. Sign in again with the new password.`),location.href=`/login`}j.onclick=()=>void N(),O.onkeydown=e=>{e.key===`Enter`&&N()};let P=A(`Password`,`One shared password guards every page and API route. Changing it signs out every signed-in browser, this one included.`,g(`Current password`,E),g(`New password`,D,{hint:`At least 10 characters.`}),g(`Repeat new password`,O),d(`div`,`flex items-center gap-3`,j,k)),F=h(`Reload`,!0),I=d(`span`,`text-[11.5px]`,``);F.onclick=()=>{F.disabled=!0,n(I,`saving`,`reloading…`),(async()=>{let e=await o(`/api/reload`,{});if(F.disabled=!1,!e.ok)return n(I,`failed`,await i(e,`Could not reload`));let{recycled:t,busy:r}=await e.json(),a=t?`Recycled ${t} session(s).`:`No idle session needed it.`,s=r?` ${r} still mid-turn — they take it when the turn ends.`:``;n(I,r?`idle`:`saved`,a+s)})()};let L=A(`Reload configuration`,`Re-reads channel configuration and lets go of idle sessions, so the next message opens them with the current agent files, skills and credentials. Saving here does this on its own — use it after something outside the Console changed a file.`,d(`div`,`flex items-center gap-3`,F,I)),R=d(`div`,`flex flex-col gap-2`),z=d(`span`,`text-[11.5px]`,``);async function ee(e,t){n(z,`saving`,`signing out…`);try{let r=await o(e,{});if(r.ok)return!0;n(z,`failed`,await i(r,t))}catch(e){n(z,`failed`,`${t}: ${String(e)}`)}return!1}let B=h(`Sign out`);B.onclick=()=>{B.disabled=!0,ee(`/logout`,`Could not sign out`).then(e=>{e?location.href=`/login`:B.disabled=!1})};function V(e){R.replaceChildren(...e.map(e=>{let t=h(e.current?`This browser`:`Sign out`);t.disabled=e.current,t.onclick=()=>{t.disabled=!0,ee(`/api/devices/${encodeURIComponent(e.id)}/signout`,`Could not sign it out`).then(e=>{if(!e)return void(t.disabled=!1);n(z,`saved`,`Signed out.`),H()})};let r=d(`div`,`flex min-w-0 flex-col`,d(`span`,`truncate text-[12.5px] text-neutral-700`,de(e.agent)));return r.title=e.agent,r.append(d(`span`,`truncate text-[11.5px] text-neutral-400`,`${e.ip} · seen ${s(e.seenAt)} · signed in ${s(e.createdAt)}`)),d(`div`,`flex items-center justify-between gap-3 rounded-lg border border-neutral-200 px-3 py-2`,r,t)}))}async function H(){let e=await m(`/api/devices`,`Could not load signed-in devices`);if(!e.ok){R.replaceChildren(M(e.error));return}V(e.value)}let te=A(`Signed-in devices`,`One row per browser holding a session. Signing one out invalidates its cookie immediately; sessions expire on their own 7 days after last use.`,R,d(`div`,`flex items-center gap-3`,B,z)),U=d(`div`,`mx-auto flex max-w-2xl flex-col gap-6`,w,T(),L),W=e=>d(`div`,`hidden min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,d(`div`,`px-4 py-5`,e)),re=q(),ie=d(`div`,`mx-auto flex w-full min-w-0 max-w-3xl flex-col rounded-xl border border-neutral-200 bg-white shadow-xs`),K=d(`section`,`hidden min-h-0 flex-1 flex-col`),ae=ne(K),J=d(`section`,`hidden min-h-0 flex-1 flex-col`),Y=G(J,r);function oe(){(async()=>{let e=await m(`/api/settings`,`Could not load settings`);if(!e.ok)return n(b,`failed`,e.error);y.value=e.value.publicUrl,b.textContent=``})()}let X=d(`div`,`mx-auto flex max-w-2xl flex-col gap-6`),Z=e=>X.replaceChildren(e,P,te);async function ce(){k.textContent=``,z.textContent=``,H();let e=await m(`/api/secrets`,`Could not load key status`);if(!e.ok){Z(M(e.error));return}Q(e.value)}function Q(e,t){let r=e.state===`locked`,a=d(`span`,`text-[11.5px]`,``);t&&n(a,`saved`,t);let s=d(`div`,`flex items-center gap-2`,x(e.state,r?`bg-red-50 text-red-700 ring-red-200`:`bg-emerald-50 text-emerald-700 ring-emerald-200`),d(`span`,`text-[12.5px] text-neutral-600`,r?`Stored credentials cannot be read until the key is unlocked.`:e.mode===`vt`?`Key mode: vt:// — unlocking takes one vt approval per process start.`:`Key mode: file — the key sits raw in master.key; switch to vt:// to require an approval.`)),c=d(`a`,`text-indigo-600 hover:underline`,`vt`);c.href=`https://github.com/timqi/vt`,c.target=`_blank`,c.rel=`noreferrer`;let l=[s,d(`p`,`text-[12px] leading-snug text-neutral-500`,c,` is a small local KMS: it keeps the key wrapped and releases it only on an explicit approval — Touch ID on a Mac, a phone passkey on a headless host. Pier only stores the vt:// record, so master.key alone unlocks nothing.`)];if(r){l.push(d(`p`,`text-[12.5px] leading-snug text-red-600`,e.reason??`No reason reported.`));let t=h(`Unlock`,!0);t.onclick=()=>{n(a,`saving`,`unlocking… (vt mode waits on your approval)`),(async()=>{let e=await o(`/api/secrets/unlock`,{});if(!e.ok)return n(a,`failed`,await i(e,`Could not unlock`));Q(await e.json(),`Unlocked — channels are starting.`)})()},l.push(d(`div`,`flex items-center gap-3`,t,a))}else{let t=async(e,t,r)=>{if(!window.confirm(t))return;n(a,`saving`,e===`vt`?`rotating… (vt asks for an approval)`:`rotating…`);let s=await o(`/api/secrets/rotate`,{mode:e});if(!s.ok)return n(a,`failed`,await i(s,`Could not rotate`));Q(await s.json(),r)},r=e.mode??`file`,s=h(`Rotate key`,!0);s.onclick=()=>void t(r,`Generate a new master key? Stored credentials stay valid; the old key stops working.`,`Rotated.`);let c=r===`vt`?`file`:`vt`,u=h(c===`vt`?`Switch to vt://`:`Switch to file`);u.onclick=()=>void t(c,c===`vt`?`Move the master key into vt? Every process start will then wait on a vt approval.`:`Store the master key raw in master.key? Anyone who can read the file can read every credential.`,c===`vt`?`Switched to vt:// mode.`:`Switched to file mode.`),l.push(d(`div`,`flex items-center gap-3`,s,u,a))}if(r||e.mode===`vt`){let e=d(`pre`,`hidden overflow-x-auto rounded-lg bg-neutral-50 p-3 text-[11.5px] leading-snug text-neutral-700`),t=h(`vt doctor`);t.onclick=()=>{t.disabled=!0,e.classList.remove(`hidden`),e.textContent=`running vt doctor…`,(async()=>{let n=await m(`/api/secrets/doctor`,`Could not run vt doctor`);e.textContent=n.ok?n.value.report:n.error,t.disabled=!1})()},l.push(d(`div`,`flex items-center gap-3`,t),e)}Z(A(`Master key`,`Seals every credential Pier stores (channel tokens, API keys). Rotating rewraps the key file; no stored data is rewritten.`,...l))}let fe=W(U),pe=W(d(`div`,`flex flex-col gap-6`,ie,re.el)),me=W(X),he=[[`instance`,fe,oe],[`models`,pe,()=>{se(ie),re.load()}],[`security`,me,()=>void ce()]];t.append(p,_,fe,pe,K,J,me);function ge(e){ue(e)&&(l=e),localStorage.setItem($,l),v();for(let[e,t,n]of he){let r=e===l;t.classList.toggle(`hidden`,!r),r&&n()}l===`channels`?ae.show():ae.hide(),l===`files`?Y.show():Y.hide()}return u(t,ge)}export{fe as createSettingsView};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e,L as t,R as n,U as r,_ as i,h as a,y as o}from"./index-uFsZkKOQ.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 r=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)r.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=i(`Open session`);o.onclick=()=>t(a),r.append(n(`span`,``,``),o)}return r}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
|
-
[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=
|
|
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=i(`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=e(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([r(`/api/task-runs/${a}`,`Could not load the run`),r(`/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 e=await r(`/api/task-groups/${a}`,S.error);if(!t.isConnected||t.dataset.runRequest!==f||u.selectedId!==a)return;if(u.drawn=``,!e.ok){t.replaceChildren(g,n(`p`,`p-4 text-[13px] text-red-600`,S.error));return}let{group:i,members:o}=e.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=i(`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=i(`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=i(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
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{A as e,G as t,H as n,J as r,K as i,O as a,P as o,R as s,S as c,T as l,U as u,V as d,_ as f,b as p,c as m,h,l as g,p as _,w as v,y}from"./index-uFsZkKOQ.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-DPkwv2UE.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 n=document.createElement(`dialog`);n.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=s(`span`,`mr-auto text-[12px] text-red-600`),u=s(`header`,`flex h-11 flex-none items-center border-b border-neutral-200 px-4 font-medium`,t?`Edit task`:`New task`),d=s(`div`,`grid min-h-0 flex-1 grid-cols-2 gap-3 overflow-y-auto p-4`),h=c(t?.name??``);h.required=!0;let _=c(t?.description??``),v=c(String(t?.timeoutSeconds??900),`number`);v.min=`1`,v.max=`86400`;let y=l([[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watch`,`watch`]],t?.trigger.type??`manual`),b=l([[`Bash`,`bash`],[`Agent`,`agent`],[`Task`,`task`]],t?.action.type??`bash`),x=l([[`No callback`,`none`],[`Invoking session`,`origin`],[`Specific session`,`session`]],t?.callback.type??`none`),S=t?.callback.type===`session`?t.callback.sessionId:null,C=l(O(e.sessions(),S),S??``),w=p(`Callback session`,C);w.classList.toggle(`hidden`,x.value!==`session`),x.onchange=()=>w.classList.toggle(`hidden`,x.value!==`session`),d.append(p(`Name`,h),p(`Description`,_),p(`Trigger`,y),p(`Action`,b),p(`Callback`,x),w,p(`Timeout (seconds)`,v));let T=s(`div`,`col-span-2 grid grid-cols-2 gap-3 border-t border-neutral-200 pt-3`);d.append(T);let E=()=>{T.replaceChildren();let u,d,f,S,w,E;if(y.value===`cron`)u=c(t?.trigger.type===`cron`?t.trigger.expression:`0 9 * * *`),d=c(t?.trigger.type===`cron`?t.trigger.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone),T.append(p(`Cron`,u),p(`Timezone`,d));else if(y.value===`watch`){f=a(t?.trigger.type===`watch`?t.trigger.script:``,4),E=c(t?.trigger.type===`watch`?t.trigger.cwd:e.sessions()[0]?.cwd??``),S=c(String(t?.trigger.type===`watch`?t.trigger.intervalSeconds:60),`number`),w=l([[`Continue after matches`,`repeat`],[`Stop after first match`,`once`]],t?.trigger.type===`watch`?t.trigger.mode:`repeat`);let n=p(`Probe script (0=match, 1=no match)`,f);n.classList.add(`col-span-2`),T.append(n,p(`Probe directory`,E),p(`Interval (seconds)`,S),p(`Mode`,w))}let D,k,j,M,N,P,F,I,L,R;if(b.value===`bash`){k=c(t?.action.type===`bash`?t.action.cwd:e.sessions()[0]?.cwd??``),D=a(t?.action.type===`bash`?t.action.script:``,6);let n=p(`Bash script`,D);n.classList.add(`col-span-2`),T.append(p(`Working directory`,k),s(`span`,``),n)}else if(b.value===`agent`){let n=e.sessions(),i=t?.action.type===`agent`?t.action:null,o=i?.session.mode===`reuse`?i.session.sessionId:``,s=O(n,o||null);j=l([[`Reuse session`,`reuse`],[`Fresh child per run`,`fresh`]],i?.session.mode===`reuse`?`reuse`:`fresh`),M=l(s,o||s[0]?.[1]||``);let u=i&&`cwd`in i.session?i.session.cwd??``:``;N=c(u||n[0]?.cwd||``),P=a(i?.prompt??``,6),F=l([[`Project default`,``],...m.map(e=>[r(e),e])],i?.launch?.thinking??``),I=c(i?.launch?.model?.provider??``),L=c(i?.launch?.model?.id??``);let d=p(`Session`,M),f=p(`Child directory`,N),h=[p(`Thinking`,F),p(`Model provider (optional)`,I),p(`Model id (optional)`,L)],g=()=>{let e=j?.value===`reuse`;d.classList.toggle(`hidden`,!e),f.classList.toggle(`hidden`,e);for(let t of h)t.classList.toggle(`hidden`,e)};j.onchange=g,g();let _=p(`Prompt`,P);_.classList.add(`col-span-2`),T.append(p(`Session policy`,j),d,f,...h,_)}else R=l(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(p(`Target task`,R));i.onsubmit=r=>{r.preventDefault();let i=y.value===`manual`?{type:`manual`}:y.value===`cron`?{type:`cron`,expression:u.value,timezone:d.value}:{type:`watch`,script:f.value,cwd:E.value,intervalSeconds:Number(S.value),mode:w.value},a=b.value===`agent`&&j.value!==`reuse`?{...g(F.value)?{thinking:F.value}:{},...I.value.trim()&&L.value.trim()?{model:{provider:I.value.trim(),id:L.value.trim()}}:{}}:void 0,s=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},c=x.value===`origin`?{type:`origin`}:x.value===`session`?{type:`session`,sessionId:C.value}:{type:`none`},l={name:h.value,description:_.value,trigger:i,action:s,callback:c,timeoutSeconds:Number(v.value)};o.textContent=``,A(t?.id,l,n,o,e.onSaved)}};y.onchange=E,b.onchange=E,E();let D=f(`Cancel`);D.onclick=()=>n.close();let k=f(`Save`,!0);k.type=`submit`;let j=s(`footer`,`flex flex-none justify-end gap-2 border-t border-neutral-200 px-4 py-3`);j.append(o,D,k),i.append(u,d,j),n.append(i),n.addEventListener(`close`,()=>n.remove()),document.body.append(n),n.showModal(),h.focus()}async function A(e,t,n,r,a){let o=await i(e?`/api/tasks/${e}`:`/api/tasks`,t,e?`PATCH`:`POST`);if(!o.ok){r.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(r,a,c,p,m,g,O){let A=[],j=[],M=null,N=`active`,P=`all`,F=``,I=`runs`,L={top:0},R=0,z=0,B=``,V=d(async()=>{if(M||!$.visible)return;let e=R,t=`${N}:${P}`,n=await u(`/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=d(async()=>{M&&$.visible&&await re(M)});function U(){return M?H():V()}function W(e){r.querySelector(`[role=alert]`)?.remove();let t=s(`p`,`flex-none p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),r.append(t)}async function G(){let e=M,t=await u(`/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:a,tasks:()=>j,onSaved:e=>{J(e),I=`definition`,O(e)}},q=(t,n)=>e(...t,s(`div`,`ml-auto flex flex-wrap items-center gap-2 max-md:w-full`,...n));function J(e){M=e,R++,I=`runs`,L.top=0}function Y(){M=null,R++,X()}function ee(){!$.visible||M!==null||Promise.all([c(),G()]).then(([,e])=>{!$.visible||M!==null||(j=e,k(K))})}function X(){let e=[],t=(t,n,r,i)=>{let a=l(n,r);a.setAttribute(`aria-label`,t),a.dataset.active=String(r!==n[0]?.[1]),a.onchange=()=>{a.dataset.active=String(a.value!==n[0]?.[1]),i(a.value),z=0,U()},e.push(s(`label`,`filter-field`,s(`span`,``,t),a))},n=s(`input`,_);n.type=`search`,n.placeholder=`Search tasks`,n.setAttribute(`aria-label`,`Search tasks`),n.value=F,n.dataset.active=String(!!F),n.oninput=()=>{F=n.value,n.dataset.active=String(!!F),o()},e.push(s(`label`,`filter-field filter-search`,s(`span`,``,`Search`),n)),t(`Status`,[[`Current`,`active`],[`Archived`,`archived`]],N,e=>{N=e}),t(`Trigger`,[[`All triggers`,`all`],[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watching`,`watch`]],P,e=>{P=e});let i=document.createElement(`table`);i.className=`w-full table-fixed text-left text-[12.5px]`,i.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
|
+
<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
|
+
<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
|
+
<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 a=document.createElement(`tbody`),o=()=>{let e=A.filter(e=>`${e.name} ${e.description??``}`.toLowerCase().includes(F.toLowerCase()));a.replaceChildren(...e.map(te)),c.classList.toggle(`hidden`,e.length>0)};i.append(a);let c=s(`div`,`p-4`,y(`No matching tasks.`)),u=s(`div`,`min-h-0 flex-1 overflow-auto`,i,c);o(),u.onscroll=()=>{z=u.scrollTop},r.replaceChildren(s(`div`,`automation-filters task-filters`,...e),u),u.scrollTop=z}function te(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=f(e.name);n.className=`min-w-0 cursor-pointer truncate text-left font-medium text-neutral-800`,n.title=e.name,t.append(s(`td`,`py-2.5 pl-4 pr-2`,s(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1`,n,S(e),...ne(e)),s(`div`,`truncate text-[11px] text-neutral-400`,e.description||``),s(`div`,`truncate text-[11px] text-neutral-400 md:hidden`,D(e))));for(let n of[E(e),D(e),C(e.nextRunAt)]){let e=s(`td`,`hidden truncate px-2 py-2.5 text-neutral-600 md:table-cell`,n);e.title=n,t.append(e)}t.append(s(`td`,`px-2 py-2.5`,e.lastRun?s(`div`,`flex`,T(e.lastRun)):s(`div`,`text-neutral-400`,`–`),s(`div`,`mt-0.5 font-mono text-[11px] text-neutral-400`,e.lastRun?x(e.lastRun):``)));let r=f(`Run now`);return r.disabled=e.archived,r.onclick=t=>{t.stopPropagation(),Z(e.id)},t.append(s(`td`,`px-2 py-1 text-right`,r)),t}function ne(e){if(!e.createdBySessionId)return[];let t=h(`agent`,`bg-violet-50 text-violet-700 ring-violet-200`);return t.title=`Created by session ${e.createdBySessionId}`,[t]}async function re(t){let n=++R,i=r.querySelector(`[data-task-detail]`),[a,o]=await Promise.all([u(`/api/tasks/${t}`,`Failed to load task`),u(`/api/tasks/${t}/runs`,`Failed to load the task's runs`)]);if(!$.visible||n!==R||M!==t)return;if(!a.ok)return W(a.error);if(!o.ok)return W(o.error);let l=a.value,d=o.value,m=f(`Tasks`);m.className=`cursor-pointer text-neutral-500 hover:text-neutral-800 hover:underline`,m.onclick=()=>O();let h=s(`span`,`flex min-w-0 items-center gap-2`,m,s(`span`,`text-neutral-400`,`›`),s(`span`,`truncate font-medium`,l.name),S(l)),_=f(`Run now`,!0);_.disabled=l.archived,_.onclick=()=>void Z(l.id);let y=f(l.enabled?`Pause schedule`:`Resume schedule`);y.disabled=l.archived||l.action.type===`system`||l.trigger.type===`manual`,y.onclick=()=>void Q(`/api/tasks/${l.id}/${l.enabled?`pause`:`resume`}`);let x=f(`Edit`);x.disabled=l.archived||l.action.type===`system`,x.onclick=()=>{!$.visible||M!==l.id||Promise.all([c(),G()]).then(([,e])=>{!$.visible||M!==l.id||(j=e,k(K,l))})};let C=f(`Archive`);C.disabled=l.archived||l.action.type===`system`,C.onclick=()=>void Q(`/api/tasks/${l.id}/archive`);let T=e(),E=s(`div`,`min-h-0 flex-1 overflow-auto`);E.dataset.taskDetail=t;let D=f(`All runs`);D.onclick=()=>g({taskId:l.id});let A=()=>{T.replaceChildren(v([[`Recent runs (${d.length})`,`runs`],[`Definition`,`definition`]],I,e=>{I=e,A()}),s(`span`,`ml-auto`,D)),I===`runs`?b(E,d,e=>g({},e),L):(E.onscroll=null,E.replaceChildren(w(l,p)))},N=i?.scrollTop??0;r.replaceChildren(q([h],[_,...l.trigger.type===`manual`?[]:[y],x,C]),T,E),A(),E.scrollTop=N}async function Z(e){try{let t=await i(`/api/tasks/${e}/run`,{sourceSessionId:m()});if(!t.ok)return W(await n(t,`Failed to run task`));g({},(await t.json()).runId)}catch(e){W(`Failed to run task: ${String(e)}`)}}async function Q(e){let n=await t(e,`POST`,`Task update failed`);if(n)return W(n);await U()}let $=o(r,e=>{e&&e!==M&&J(e),e||Y(),r.childElementCount||X(),U()});return Object.assign($,{create:ee,refresh(e){$.visible&&(!M||!e||M===e)&&U()}})}export{j as createTasksView};
|
|
Binary file
|
|
Binary file
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<!-- viewport-fit=cover lets the safe-area insets in style.css do their job
|
|
6
|
-
under an iPhone's home indicator.
|
|
7
|
-
|
|
6
|
+
under an iPhone's home indicator. No user scaling: a fixed-viewport
|
|
7
|
+
workbench zoomed by a stray gesture has no visible way back — said again
|
|
8
|
+
as `touch-action` (style.css) for the engines that ignore this pair. -->
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover" />
|
|
8
10
|
<meta name="theme-color" content="#fafafa" />
|
|
9
11
|
<!-- Ahead of the stylesheet, because a workbench that flashes white and then
|
|
10
12
|
goes dark reads as a bug. This is the only place "system" is resolved
|
|
@@ -33,8 +35,8 @@
|
|
|
33
35
|
which style.css pays for with the safe-area inset. -->
|
|
34
36
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
35
37
|
<title>Pier</title>
|
|
36
|
-
<script type="module" crossorigin src="/assets/index-
|
|
37
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
38
|
+
<script type="module" crossorigin src="/assets/index-uFsZkKOQ.js"></script>
|
|
39
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CX3fYZY5.css">
|
|
38
40
|
</head>
|
|
39
41
|
<!-- The document never scrolls: this is a fixed-viewport workbench, and every
|
|
40
42
|
scrollable region is an inner pane. h-dvh, not h-screen, because 100vh can
|
|
@@ -55,11 +57,11 @@
|
|
|
55
57
|
</svg>
|
|
56
58
|
</button>
|
|
57
59
|
<aside id="sidebar" class="flex flex-col overflow-hidden border-r border-neutral-200 bg-neutral-50">
|
|
58
|
-
<header class="flex items-center gap-2 px-3
|
|
60
|
+
<header class="flex h-12 flex-none items-center gap-2 px-3">
|
|
59
61
|
<!-- The same mark as the tab and the home-screen icon, so an installed
|
|
60
62
|
Pier looks like the thing you installed. -->
|
|
61
|
-
<img src="/icon.svg" alt="" width="20" height="20" class="h-
|
|
62
|
-
<h1 class="text-[
|
|
63
|
+
<img src="/icon.svg" alt="" width="20" height="20" class="h-7 w-7 flex-none rounded-lg border border-neutral-200/70 bg-white p-1 shadow-xs" />
|
|
64
|
+
<h1 class="text-[17px] font-semibold tracking-tight">Pier</h1>
|
|
63
65
|
<!-- A link, not a label: AGPL-3.0 section 13 asks a network service to
|
|
64
66
|
point its users at the source it is running. Beside the title
|
|
65
67
|
because a version is something you look up, not something you find
|
|
@@ -76,9 +78,9 @@
|
|
|
76
78
|
</header>
|
|
77
79
|
<details id="console-section" open class="flex-none border-b border-neutral-200/70">
|
|
78
80
|
<summary class="flex cursor-pointer select-none items-center gap-1 px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-neutral-500 hover:bg-neutral-100">
|
|
79
|
-
<
|
|
81
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true" class="chev h-3 w-3"><path d="m6 4 4 4-4 4" stroke-linecap="round" stroke-linejoin="round" /></svg>Console
|
|
80
82
|
</summary>
|
|
81
|
-
<ul class="pb-
|
|
83
|
+
<ul class="pb-2 text-[13.5px]">
|
|
82
84
|
<!-- One row for the tasks area: Tasks, Runs and Activity are tabs of
|
|
83
85
|
the Automation page (views.ts), not three sidebar entries. -->
|
|
84
86
|
<li><button type="button" id="open-tasks"
|
|
@@ -101,7 +103,7 @@
|
|
|
101
103
|
</ul>
|
|
102
104
|
</details>
|
|
103
105
|
<div class="flex items-center gap-1 px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-neutral-500">
|
|
104
|
-
|
|
106
|
+
Sessions
|
|
105
107
|
<button type="button" id="open-archive"
|
|
106
108
|
class="icon-btn ml-auto" aria-label="Search sessions and Console">
|
|
107
109
|
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" class="h-3.5 w-3.5">
|
|
@@ -116,7 +118,7 @@
|
|
|
116
118
|
</svg>
|
|
117
119
|
</button>
|
|
118
120
|
</div>
|
|
119
|
-
<div id="
|
|
121
|
+
<div id="session-list" class="flex-1 overflow-y-auto text-[13.5px]"></div>
|
|
120
122
|
</aside>
|
|
121
123
|
|
|
122
124
|
<main class="flex min-w-0 flex-col overflow-hidden">
|
|
@@ -161,7 +163,7 @@
|
|
|
161
163
|
<!-- The transcript's own type scale, inherited by rows, chips and markdown. -->
|
|
162
164
|
<!-- data-gallery: the lightbox pages within the container it was opened
|
|
163
165
|
from (see attachments.ts), so transcript and pending strip stay apart. -->
|
|
164
|
-
<div id="turns" data-gallery class="flex-1 overflow-y-auto pb-
|
|
166
|
+
<div id="turns" data-gallery class="flex-1 overflow-y-auto pb-5 pt-2 text-[15px] leading-[1.55]"></div>
|
|
165
167
|
<!-- Pi's queue primitives are whole-queue (steer / clear), so the actions
|
|
166
168
|
live on the header row and read as "the queue", never per message. -->
|
|
167
169
|
<div id="queue-panel" class="hidden flex-col border-t border-neutral-200 px-3 py-1.5">
|
|
@@ -201,8 +203,8 @@
|
|
|
201
203
|
(18px leading) rather than shrinking the turns pane any further. -->
|
|
202
204
|
<ul id="queue-rows" class="flex max-h-[6rem] flex-col gap-1 overflow-y-auto overscroll-contain"></ul>
|
|
203
205
|
</div>
|
|
204
|
-
<form id="composer" class="
|
|
205
|
-
<div class="rounded-
|
|
206
|
+
<form id="composer" class="flex-none px-4 pb-3 pt-2">
|
|
207
|
+
<div class="glass rounded-[1.75rem] border border-neutral-200 px-3 py-2.5 transition-shadow focus-within:border-indigo-400">
|
|
206
208
|
<div id="image-strip" data-gallery class="hidden flex-wrap gap-2 px-1 pb-1.5 pt-1"></div>
|
|
207
209
|
<!-- items-end keeps the icons on the bottom row while the textarea grows upward -->
|
|
208
210
|
<div class="flex items-end gap-1.5">
|
|
@@ -235,7 +237,7 @@
|
|
|
235
237
|
</form>
|
|
236
238
|
</main>
|
|
237
239
|
|
|
238
|
-
<dialog id="new-dialog" class="m-auto w-[min(24rem,92vw)] rounded-
|
|
240
|
+
<dialog id="new-dialog" class="m-auto w-[min(24rem,92vw)] rounded-3xl border border-neutral-200 p-5 shadow-xl backdrop:bg-black/20">
|
|
239
241
|
<form id="new-form" method="dialog" class="flex flex-col gap-3">
|
|
240
242
|
<h3 class="font-semibold">New session</h3>
|
|
241
243
|
<label class="flex flex-col gap-1 text-[13px] text-neutral-600">
|
|
@@ -253,7 +255,7 @@
|
|
|
253
255
|
<!-- Not m-auto: a palette that grows downward as you type should not also
|
|
254
256
|
drift upward to stay centred. Pinned near the top instead, which is
|
|
255
257
|
where the eye already is and where every other ⌘K lives. -->
|
|
256
|
-
<dialog id="archive-dialog" class="mx-auto mb-auto mt-[12vh] w-[35rem] max-w-[90vw] rounded-
|
|
258
|
+
<dialog id="archive-dialog" class="mx-auto mb-auto mt-[12vh] w-[35rem] max-w-[90vw] rounded-3xl border border-neutral-200 p-0 shadow-xl backdrop:bg-black/20">
|
|
257
259
|
<div class="flex items-center gap-2 border-b border-neutral-200 px-3 py-2">
|
|
258
260
|
<input id="archive-search" type="text" placeholder="Search sessions and Console…"
|
|
259
261
|
class="w-full bg-transparent text-[14px] focus:outline-none" />
|
|
@@ -263,25 +265,37 @@
|
|
|
263
265
|
<ul id="archive-list" class="max-h-[60vh] overflow-y-auto py-1 text-[13.5px]"></ul>
|
|
264
266
|
</dialog>
|
|
265
267
|
|
|
266
|
-
<!-- Full-size view of a thumbnail; click
|
|
267
|
-
The arrows page through the gallery it was
|
|
268
|
-
they hide when there is only one image to look
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
268
|
+
<!-- Full-size view of a thumbnail; a single click (or Esc) closes, a double
|
|
269
|
+
one zooms about the point. The arrows page through the gallery it was
|
|
270
|
+
opened from, as do ← / →; they hide when there is only one image to look
|
|
271
|
+
at. The dialog fills the viewport rather than hugging the image, so the
|
|
272
|
+
arrows sit at the screen's edges and a tall shot and a wide one don't
|
|
273
|
+
move the control under your thumb; #image-stage is the box a zoomed
|
|
274
|
+
image scrolls inside (ui/attachments.ts). -->
|
|
275
|
+
<!-- The size is written out, not left to `inset-0`: a dialog is `width:
|
|
276
|
+
fit-content` in the UA sheet, and an inset pair does not stretch a box
|
|
277
|
+
that already has a width — it sized itself to the image and sat in the
|
|
278
|
+
top-left corner, with the backdrop clicks landing on the dialog instead
|
|
279
|
+
of on #image-stage. -->
|
|
280
|
+
<dialog id="image-dialog" class="fixed inset-0 m-0 h-[100dvh] w-full max-h-none max-w-none bg-transparent p-0 backdrop:bg-black/70">
|
|
281
|
+
<div id="image-stage" class="flex h-full w-full items-center justify-center overflow-hidden">
|
|
282
|
+
<img id="image-full" alt="" class="max-h-[92dvh] max-w-[92vw] cursor-zoom-in rounded-xl object-contain" />
|
|
274
283
|
</div>
|
|
284
|
+
<!-- Siblings of the stage, not children of it: the stage is what scrolls
|
|
285
|
+
when zoomed, and an arrow inside it would scroll away with the image. -->
|
|
286
|
+
<button type="button" id="image-prev" aria-label="Previous image" class="lightbox-nav left-2">‹</button>
|
|
287
|
+
<button type="button" id="image-next" aria-label="Next image" class="lightbox-nav right-2">›</button>
|
|
275
288
|
</dialog>
|
|
276
289
|
|
|
277
|
-
<!-- Text preview of an agent attachment
|
|
278
|
-
|
|
290
|
+
<!-- Text preview of an agent attachment — the Files view's code pane fills
|
|
291
|
+
#file-text; download stays one click away. -->
|
|
292
|
+
<dialog id="file-dialog" class="m-auto w-[45rem] max-w-[92vw] rounded-3xl border border-neutral-200 p-0 shadow-xl backdrop:bg-black/40">
|
|
279
293
|
<div class="flex items-center gap-2 border-b border-neutral-200 px-3 py-2">
|
|
280
294
|
<span id="file-name" class="min-w-0 flex-1 truncate font-mono text-[12.5px] text-neutral-700"></span>
|
|
281
295
|
<a id="file-download" download class="btn flex-none text-[12px] no-underline">Download</a>
|
|
282
296
|
<button type="button" id="file-close" class="btn flex-none text-[12px]">Close</button>
|
|
283
297
|
</div>
|
|
284
|
-
<
|
|
298
|
+
<div id="file-text" class="max-h-[70vh] overflow-auto"></div>
|
|
285
299
|
</dialog>
|
|
286
300
|
|
|
287
301
|
<!-- Before the bundle, and only until it loads: a module that throws while
|
|
Binary file
|
|
Binary file
|
package/dist/web/server.js
CHANGED
|
@@ -20,7 +20,6 @@ import { isThinkingLevel } from "../core/types.js";
|
|
|
20
20
|
import { SESSION_TITLE_MAX } from "../limits.js";
|
|
21
21
|
import { saveInbound } from "../core/inbox.js";
|
|
22
22
|
import { MAX_INBOUND_BYTES } from "../core/inbound-file.js";
|
|
23
|
-
import { RepoIndex } from "./repos.js";
|
|
24
23
|
import {} from "./session-state.js";
|
|
25
24
|
import { registerInstanceRoutes } from "./instance.js";
|
|
26
25
|
import { registerProviderRoutes } from "./providers.js";
|
|
@@ -58,7 +57,7 @@ const HEARTBEAT_MS = 15_000;
|
|
|
58
57
|
const SSE_HIGH_WATER = 4 * 1024 * 1024;
|
|
59
58
|
// Canonical base64 only: Buffer.from(.., "base64") happily "decodes" garbage.
|
|
60
59
|
const BASE64_RE = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
61
|
-
export function createServer({ factory, router, hub, sessions: state, config, providers, settings, catalog, names, onToolsChanged, validateCustomTools, secrets, onUnlocked, reload, updates, updater, backgroundRuns, activeBackgroundRunCounts, channelOf, }) {
|
|
60
|
+
export function createServer({ factory, router, hub, sessions: state, config, providers, settings, catalog, names, onToolsChanged, validateCustomTools, secrets, onUnlocked, reload, updates, updater, backgroundRuns, activeBackgroundRunCounts, taskSessions, channelOf, }) {
|
|
62
61
|
const app = new Hono();
|
|
63
62
|
const epoch = randomUUID();
|
|
64
63
|
// One frame shared by synchronous fan-out to every watching tab. The epoch
|
|
@@ -90,8 +89,6 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
90
89
|
state.setUnread(e.sessionId, true);
|
|
91
90
|
hub.emitWorkspace({ type: "sessions-changed" });
|
|
92
91
|
});
|
|
93
|
-
// Repository identity per project directory, refreshed off the request path.
|
|
94
|
-
const repos = new RepoIndex(() => hub.emitWorkspace({ type: "sessions-changed" }));
|
|
95
92
|
/** Background runs still in flight, per launching session. One query for a
|
|
96
93
|
* whole list: asking row by row loaded every run object of every session to
|
|
97
94
|
* draw one dot each. */
|
|
@@ -106,7 +103,7 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
106
103
|
* not survive a restart or an eviction (Pi persisted nothing), but while
|
|
107
104
|
* this process lives it is in `nascent` and therefore in the rail — left
|
|
108
105
|
* alone, clicking it 404s forever. The load path is where a ghost is
|
|
109
|
-
* discovered, so it is where the entry and its
|
|
106
|
+
* discovered, so it is where the entry and its row are dropped and every
|
|
110
107
|
* rail told; the 404 then says what happened instead of looking like a
|
|
111
108
|
* crash (§5b). */
|
|
112
109
|
const ensureLoadable = async (id) => {
|
|
@@ -131,8 +128,9 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
131
128
|
const listSessions = () => listing ??= factory.list().finally(() => {
|
|
132
129
|
listing = undefined;
|
|
133
130
|
});
|
|
134
|
-
/** Every session
|
|
135
|
-
* created here that it has not persisted yet
|
|
131
|
+
/** Every session the rail may show: what Pi has written, plus the ones
|
|
132
|
+
* created here that it has not persisted yet, minus the ones task runs
|
|
133
|
+
* made for themselves. */
|
|
136
134
|
const allSessions = async () => {
|
|
137
135
|
const sessions = await listSessions();
|
|
138
136
|
for (const s of sessions)
|
|
@@ -141,62 +139,31 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
141
139
|
for (const [id, n] of nascent)
|
|
142
140
|
if (Date.now() - n.createdAt > 86_400_000)
|
|
143
141
|
nascent.delete(id);
|
|
142
|
+
const owned = taskSessions?.() ?? new Set();
|
|
144
143
|
return [
|
|
145
144
|
...[...nascent].map(([id, n]) => ({ id, ...n })),
|
|
146
|
-
...sessions,
|
|
145
|
+
...sessions.filter((s) => !owned.has(s.id)),
|
|
147
146
|
];
|
|
148
147
|
};
|
|
149
148
|
// One session as every list renders it: the summary, what the workbench
|
|
150
|
-
// decided about it, and what is true of it right now.
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
const present = (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
// without it there un-groups the worktrees the rail had just grouped.
|
|
161
|
-
// Whatever is known now — the probe is never waited on, and its answer
|
|
162
|
-
// arrives as a `sessions-changed`.
|
|
163
|
-
...repos.get(s.cwd),
|
|
164
|
-
state: router.stateOf(s.id) ?? "idle",
|
|
165
|
-
listed: own?.pinned ?? false,
|
|
166
|
-
unread: own?.unread ?? false,
|
|
167
|
-
channel: channelOf?.(s.id) ?? "web",
|
|
168
|
-
activeRuns: active.get(s.id) ?? 0,
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
// The rail: the same rows as the full list, minus everything Projects is not
|
|
172
|
-
// showing. One source, one shape — the rail used to read a second copy of
|
|
173
|
-
// the summaries out of SQLite, which is what had to be kept in step.
|
|
174
|
-
app.get("/api/projects", async (c) => {
|
|
175
|
-
const flags = state.flags();
|
|
176
|
-
const active = activeRuns();
|
|
177
|
-
return c.json((await allSessions())
|
|
178
|
-
.map((s) => present(s, flags.get(s.id), active))
|
|
179
|
-
.filter((row) => row.listed));
|
|
149
|
+
// decided about it, and what is true of it right now. `rank` is the place in
|
|
150
|
+
// the rail's working set, when it has one; `modified` rides along for the
|
|
151
|
+
// row's tooltip, and orders nothing.
|
|
152
|
+
const present = (s, own, active) => ({
|
|
153
|
+
...s,
|
|
154
|
+
...(own?.rank === undefined ? {} : { rank: own.rank }),
|
|
155
|
+
state: router.stateOf(s.id) ?? "idle",
|
|
156
|
+
unread: own?.unread ?? false,
|
|
157
|
+
channel: channelOf?.(s.id) ?? "web",
|
|
158
|
+
activeRuns: active.get(s.id) ?? 0,
|
|
180
159
|
});
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
? undefined
|
|
189
|
-
: Array.isArray(raw) && raw.every((x) => typeof x === "string" && x)
|
|
190
|
-
? raw
|
|
191
|
-
: null;
|
|
192
|
-
const sessions = list(body?.sessions);
|
|
193
|
-
const projects = list(body?.projects);
|
|
194
|
-
if (sessions === null || projects === null || (!sessions && !projects)) {
|
|
195
|
-
return c.json({ error: "sessions and/or projects must be lists of ids" }, 400);
|
|
196
|
-
}
|
|
197
|
-
state.reorder({ sessions, projects });
|
|
198
|
-
hub.emitWorkspace({ type: "sessions-changed" });
|
|
199
|
-
return c.json({ ok: true });
|
|
160
|
+
// The rail's top rows are maintained here and nowhere else: a session a
|
|
161
|
+
// human speaks to and that is not in the working set already takes the front
|
|
162
|
+
// slot (web/session-state.ts). No route — there is no gesture to make, and
|
|
163
|
+
// an IM message has no browser to make it from.
|
|
164
|
+
router.onSpokenTo((id) => {
|
|
165
|
+
if (state.promote(id))
|
|
166
|
+
hub.emitWorkspace({ type: "sessions-changed" });
|
|
200
167
|
});
|
|
201
168
|
app.get("/api/sessions", async (c) => {
|
|
202
169
|
const flags = state.flags();
|
|
@@ -212,8 +179,6 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
212
179
|
const createdAt = Date.now();
|
|
213
180
|
nascent.set(session.id, { cwd: body.cwd, createdAt });
|
|
214
181
|
router.attach({ channelId: "web", conversationId: session.id }, session);
|
|
215
|
-
// Created here = part of the workspace; pinning is what Projects lists.
|
|
216
|
-
state.pin(session.id, body.cwd, true);
|
|
217
182
|
hub.emitWorkspace({ type: "sessions-changed" });
|
|
218
183
|
return c.json({ id: session.id }, 201);
|
|
219
184
|
});
|
|
@@ -227,22 +192,6 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
227
192
|
}
|
|
228
193
|
return c.json({ ok: true });
|
|
229
194
|
});
|
|
230
|
-
app.post("/api/sessions/:id/pin", async (c) => {
|
|
231
|
-
const body = await c.req.json().catch(() => null);
|
|
232
|
-
if (typeof body?.pinned !== "boolean")
|
|
233
|
-
return c.json({ error: "pinned required" }, 400);
|
|
234
|
-
const id = c.req.param("id");
|
|
235
|
-
// The directory comes from the listing, not from the client that clicked:
|
|
236
|
-
// it is the one fact this row keeps about the session, it is the key a
|
|
237
|
-
// project's manual place is stamped on, and the browser is not where a
|
|
238
|
-
// path should come from when the server already knows it.
|
|
239
|
-
const cwd = (await factory.find(id))?.cwd ?? nascent.get(id)?.cwd;
|
|
240
|
-
if (!cwd)
|
|
241
|
-
return c.json({ error: `session ${id} has no directory Pier can find` }, 404);
|
|
242
|
-
state.pin(id, cwd, body.pinned);
|
|
243
|
-
hub.emitWorkspace({ type: "sessions-changed" });
|
|
244
|
-
return c.json({ pinned: body.pinned });
|
|
245
|
-
});
|
|
246
195
|
// The two responses big enough to matter: a transcript, and one turn's tool
|
|
247
196
|
// detail. Scoped to these routes on purpose — compressing the SSE streams
|
|
248
197
|
// would sit on events until the encoder's buffer filled.
|
|
@@ -409,6 +358,11 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
409
358
|
const session = await ensure(id);
|
|
410
359
|
if (session.state === "streaming")
|
|
411
360
|
return c.json({ error: "busy — stop the turn first" }, 409);
|
|
361
|
+
const latest = (await session.history()).filter((turn) => turn.role === "user").length - 1;
|
|
362
|
+
if (index !== latest)
|
|
363
|
+
return c.json({ error: "only the latest user message can be edited — refresh and try again" }, 409);
|
|
364
|
+
if (session.state !== "idle")
|
|
365
|
+
return c.json({ error: "busy — stop the turn first" }, 409);
|
|
412
366
|
await session.rewindToUserTurn(index);
|
|
413
367
|
// The rewind took the turns after this one out of the context, headers and
|
|
414
368
|
// all; what the model was told about who is speaking went with them.
|
|
@@ -485,7 +439,7 @@ export function createServer({ factory, router, hub, sessions: state, config, pr
|
|
|
485
439
|
return c.json({ ok: true }, 202);
|
|
486
440
|
});
|
|
487
441
|
// Workspace stream: one per client, keeps every session list in sync
|
|
488
|
-
// (created/
|
|
442
|
+
// (created/promoted → re-list, run state → patch) without polling.
|
|
489
443
|
app.get("/api/events", (c) => streamSSE(c, async (stream) => {
|
|
490
444
|
// A write to a torn-down stream must not become an unhandled rejection.
|
|
491
445
|
const unsubscribe = hub.subscribeWorkspace((e) => void stream.writeSSE({ data: JSON.stringify(e) }).catch(() => { }));
|