scriptorium 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -8
- package/bin/scriptorium.js +1 -1
- package/build/client/assets/_layout-4p0zIumj.js +1 -0
- package/build/client/assets/_layout-CG4jvKXd.js +1 -0
- package/build/client/assets/_layout-DUvno75Q.js +1 -0
- package/build/client/assets/_layout-tj841ZFj.js +3 -0
- package/build/client/assets/auth-shell-CM4lzbUg.js +1 -0
- package/build/client/assets/breadcrumbs-CLMk50vh.js +1 -0
- package/build/client/assets/{chunk-EPOLDU6W-B-j6nV8T.js → chunk-EPOLDU6W-BT1NqV1s.js} +11 -11
- package/build/client/assets/confirm-passkey-sqNHrDN7.js +1 -0
- package/build/client/assets/document-title-CaFCBnQ-.js +1 -0
- package/build/client/assets/entry.client-B2qwDNf_.js +13 -0
- package/build/client/assets/events-BGAz2o24.js +39 -0
- package/build/client/assets/files-247Zppti.js +1 -0
- package/build/client/assets/files-COflIyot.js +1 -0
- package/build/client/assets/files-browser-DKxCza7c.js +1 -0
- package/build/client/assets/files.browse-BBMm6lgA.js +1 -0
- package/build/client/assets/files.browse-Dq0nnEAB.js +1 -0
- package/build/client/assets/index-BumTGMZF.js +1 -0
- package/build/client/assets/index-CLO24mr0.js +1 -0
- package/build/client/assets/index-D-coH8u1.js +34 -0
- package/build/client/assets/index-DxuBmPz-.js +1 -0
- package/build/client/assets/jsx-runtime-u17CrQMm.js +1 -0
- package/build/client/assets/login-SMI1sC8T.js +1 -0
- package/build/client/assets/manifest-27a6038b.js +1 -0
- package/build/client/assets/passkeys-Cg-Qx1Gj.js +1 -0
- package/build/client/assets/project-events-provider-Cz1h_7Z0.js +1 -0
- package/build/client/assets/project-route-Cqnw3iG7.js +1 -0
- package/build/client/assets/projects-CcOVpbnV.js +1 -0
- package/build/client/assets/projects._projectId.proxy._-l0sNRNKZ.js +1 -0
- package/build/client/assets/projects.new-BIAajDmU.js +1 -0
- package/build/client/assets/register-CwUWzMvC.js +1 -0
- package/build/client/assets/review-browser-CkLIZsiU.js +1 -0
- package/build/client/assets/review._mode-CjiM88Yw.js +1 -0
- package/build/client/assets/review.uncommitted-DnCOhh-l.js +1 -0
- package/build/client/assets/root-DtlaHd7Y.js +1 -0
- package/build/client/assets/root-h1ZnuAzH.css +1 -0
- package/build/client/assets/{scroll-indicator-CFaTM_rb.js → scroll-indicator-DxagqbkL.js} +8 -8
- package/build/client/assets/scrollable-layout-CR2OL0dM.js +1 -0
- package/build/client/assets/session-route-Cd_9l4G7.js +1 -0
- package/build/client/assets/sessions-provider-xySz_P7U.js +1 -0
- package/build/client/assets/settings-CYavUXKt.js +1 -0
- package/build/client/assets/sidebar-BpDMNa9u.js +1 -0
- package/build/client/assets/use-double-check-BJPDnzvf.js +1 -0
- package/build/runtime/app/lib/runtime-config/cache.server.js +15 -0
- package/build/runtime/app/lib/runtime-config/cli.server.js +79 -0
- package/build/runtime/app/lib/runtime-config/docs.server.js +170 -0
- package/build/runtime/app/lib/runtime-config/loader.server.js +69 -0
- package/build/runtime/app/lib/runtime-config/schema.server.js +128 -0
- package/build/runtime/server/index.js +176 -0
- package/build/server/index.js +8989 -4661
- package/docs/config.md +12 -8
- package/drizzle/20260324172031_curved_junta/migration.sql +20 -0
- package/drizzle/20260324172031_curved_junta/snapshot.json +684 -0
- package/drizzle/20260327233106_model_usage/migration.sql +15 -0
- package/drizzle/20260327233106_model_usage/snapshot.json +830 -0
- package/drizzle/20260331000000_projects_and_model_usages/migration.sql +41 -0
- package/package.json +16 -3
- package/build/client/assets/_layout-D-bxuQBW.js +0 -1
- package/build/client/assets/_layout-D2eOWFrG.js +0 -1
- package/build/client/assets/_layout-D4m0RbUC.js +0 -1
- package/build/client/assets/_layout-DggtTDZp.js +0 -1
- package/build/client/assets/auth-shell-FEL5QDuP.js +0 -1
- package/build/client/assets/confirm-passkey-ntLsS7_k.js +0 -1
- package/build/client/assets/entry.client-BkscxSA6.js +0 -5
- package/build/client/assets/file-list-DBDZbrBp.js +0 -1
- package/build/client/assets/files-Bzkr7-i7.js +0 -1
- package/build/client/assets/files-browser-KNurSsen.js +0 -1
- package/build/client/assets/files-cnv1kfgp.js +0 -1
- package/build/client/assets/files.browse-9p4xl9MV.js +0 -1
- package/build/client/assets/git-CjSY0eSC.js +0 -1
- package/build/client/assets/git-T0lLjMNd.js +0 -1
- package/build/client/assets/git-browser-DwSOY6QN.js +0 -1
- package/build/client/assets/iconify-BDcX0yw8.js +0 -1
- package/build/client/assets/index-8zQ7Fizv.js +0 -9
- package/build/client/assets/index-BUN6tnpl.js +0 -1
- package/build/client/assets/index-BlNoCKAt.js +0 -1
- package/build/client/assets/index-g2QB9BbT.js +0 -1
- package/build/client/assets/instance-events-provider-DTYnvumj.js +0 -39
- package/build/client/assets/instance-route-C25LRYYo.js +0 -1
- package/build/client/assets/instances-CzjXhR3c.js +0 -1
- package/build/client/assets/instances._instanceId.sessions._sessionId.test-COZIMxji.js +0 -208
- package/build/client/assets/instances.new-BZi5xwEV.js +0 -1
- package/build/client/assets/login-Bwt79t7_.js +0 -1
- package/build/client/assets/magic-string.es-DjU5CGuV.js +0 -10
- package/build/client/assets/manifest-3c01c628.js +0 -1
- package/build/client/assets/message-card-DJ5C3WNp.js +0 -34
- package/build/client/assets/passkeys-DpNQs4bn.js +0 -1
- package/build/client/assets/register-DXPj5RLZ.js +0 -1
- package/build/client/assets/root-DxD-Skic.css +0 -1
- package/build/client/assets/root-DxyfhNRI.js +0 -1
- package/build/client/assets/scrollable-layout-CS-vPTNM.js +0 -1
- package/build/client/assets/session-route-oxi4s_Qg.js +0 -1
- package/build/client/assets/sessions-provider-D1t07kir.js +0 -1
- package/build/client/assets/settings-CameSNIM.js +0 -1
- package/build/client/assets/sidebar-DRhB33rT.js +0 -1
- package/build/client/assets/use-double-check-CbbarqDt.js +0 -1
- package/build/runtime/app/lib/runtime-config.server.js +0 -422
- package/build/runtime/cli/scriptorium.js +0 -21
- package/build/runtime/cli/serve.js +0 -101
- /package/build/client/assets/{message-card-BclR_JqA.css → index-BclR_JqA.css} +0 -0
- /package/build/client/assets/{instances._instanceId.proxy._-l0sNRNKZ.js → projects._projectId.file-references.resolve-l0sNRNKZ.js} +0 -0
package/README.md
CHANGED
|
@@ -13,10 +13,12 @@ This repo is intentionally exploratory. Expect rough edges, fast iteration, and
|
|
|
13
13
|
|
|
14
14
|
## Requirements
|
|
15
15
|
|
|
16
|
-
- Node.js
|
|
16
|
+
- Node.js 24+
|
|
17
17
|
- npm
|
|
18
18
|
- `opencode` available on your PATH, or an explicit `OPENCODE_BIN`
|
|
19
|
-
- Optional: Tailscale if you want
|
|
19
|
+
- Optional: Tailscale if you want Scriptorium exposed through `tailscale serve`
|
|
20
|
+
|
|
21
|
+
This repository uses `npm` as its canonical package manager.
|
|
20
22
|
|
|
21
23
|
## Getting Started
|
|
22
24
|
|
|
@@ -32,7 +34,13 @@ Run the development server:
|
|
|
32
34
|
npm run dev
|
|
33
35
|
```
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
The dev server runs through Scriptorium's unified Node server entrypoint with Vite in middleware mode.
|
|
38
|
+
|
|
39
|
+
To expose the dev server through Tailscale for a run:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm run dev -- --tailscale
|
|
43
|
+
```
|
|
36
44
|
|
|
37
45
|
Create a production build:
|
|
38
46
|
|
|
@@ -46,6 +54,8 @@ Start the built app:
|
|
|
46
54
|
npm start
|
|
47
55
|
```
|
|
48
56
|
|
|
57
|
+
`npm start` uses the same server entrypoint as development, but serves the built React Router app instead of Vite middleware.
|
|
58
|
+
|
|
49
59
|
The published package uses the same entrypoint:
|
|
50
60
|
|
|
51
61
|
```bash
|
|
@@ -71,31 +81,44 @@ Scriptorium reads runtime settings from:
|
|
|
71
81
|
- `config.yml` for non-sensitive settings
|
|
72
82
|
- `secrets.yml` for secrets such as the session signing secret
|
|
73
83
|
|
|
84
|
+
Use `--config-dir <path>` / `SCRIPTORIUM_CONFIG_DIR` to override config location.
|
|
85
|
+
Use `--data-dir <path>` / `SCRIPTORIUM_DATA_DIR` to override runtime data location.
|
|
86
|
+
|
|
87
|
+
Default per-platform directories:
|
|
88
|
+
|
|
89
|
+
| Platform | Default config dir | Default data dir |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| macOS | `$XDG_CONFIG_HOME/scriptorium` or `~/.config/scriptorium` | `$XDG_DATA_HOME/scriptorium` or `~/.local/share/scriptorium` |
|
|
92
|
+
| Linux | `$XDG_CONFIG_HOME/scriptorium` or `~/.config/scriptorium` | `$XDG_DATA_HOME/scriptorium` or `~/.local/share/scriptorium` |
|
|
93
|
+
| Windows | `%XDG_CONFIG_HOME%\\scriptorium` or `%USERPROFILE%\\.config\\scriptorium` | `%XDG_DATA_HOME%\\scriptorium` or `%USERPROFILE%\\.local\\share\\scriptorium` |
|
|
94
|
+
|
|
74
95
|
Precedence is: CLI flags -> environment variables -> YAML values -> schema defaults.
|
|
75
96
|
|
|
76
97
|
Common flags and env vars include:
|
|
77
98
|
|
|
78
|
-
- `--host` / `
|
|
79
|
-
- `--port` / `
|
|
99
|
+
- `--host` / `SCRIPTORIUM_HOST`
|
|
100
|
+
- `--port` / `SCRIPTORIUM_PORT`
|
|
80
101
|
- `--browser-root` / `SCRIPTORIUM_BROWSER_ROOT`
|
|
81
102
|
- `--db-path` / `SCRIPTORIUM_DB_PATH`
|
|
82
103
|
- `--opencode-bin` / `OPENCODE_BIN`
|
|
104
|
+
- `--opencode-url` / `SCRIPTORIUM_OPENCODE_URL`
|
|
83
105
|
- `--tailscale` / `--no-tailscale`
|
|
84
106
|
- `SESSION_SECRET` to override the generated session secret
|
|
85
107
|
|
|
86
108
|
Example:
|
|
87
109
|
|
|
88
110
|
```bash
|
|
89
|
-
|
|
90
|
-
|
|
111
|
+
SCRIPTORIUM_HOST=127.0.0.1 \
|
|
112
|
+
SCRIPTORIUM_PORT=6200 \
|
|
91
113
|
SCRIPTORIUM_BROWSER_ROOT=$HOME/src \
|
|
114
|
+
SCRIPTORIUM_OPENCODE_URL=http://127.0.0.1:44556 \
|
|
92
115
|
OPENCODE_BIN=opencode \
|
|
93
116
|
npm start -- --no-tailscale
|
|
94
117
|
```
|
|
95
118
|
|
|
96
119
|
## Tailscale On Launch
|
|
97
120
|
|
|
98
|
-
The
|
|
121
|
+
The unified server optionally runs `tailscale serve` when `network.tailscale: true` is set in config or `--tailscale` is passed.
|
|
99
122
|
|
|
100
123
|
Use `--no-tailscale` to force local-only startup for a run.
|
|
101
124
|
|
package/bin/scriptorium.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
6
6
|
|
|
7
7
|
process.env.NODE_ENV = process.env.NODE_ENV ?? "production";
|
|
8
8
|
|
|
9
|
-
const runtimeCliPath = fileURLToPath(new URL("../build/runtime/
|
|
9
|
+
const runtimeCliPath = fileURLToPath(new URL("../build/runtime/server/index.js", import.meta.url));
|
|
10
10
|
|
|
11
11
|
if (!existsSync(runtimeCliPath)) {
|
|
12
12
|
process.stderr.write(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{N as c,F as p,h as E,O as P,w as L}from"./chunk-EPOLDU6W-BT1NqV1s.js";import{j as e}from"./jsx-runtime-u17CrQMm.js";import{u as C,a as v,b as $,c as A,S as R,d as z}from"./sessions-provider-xySz_P7U.js";import{r}from"./index-CLO24mr0.js";import{u as _}from"./events-BGAz2o24.js";import{a as O,u as B}from"./breadcrumbs-CLMk50vh.js";import{a as w,S as N,i as F,f as H}from"./sidebar-BpDMNa9u.js";import{I as u}from"./files.browse-BBMm6lgA.js";import{c as d}from"./cn-Kn7NbJqM.js";import{s as f}from"./safe-area.module-CwCzHS6V.js";import{n as M,r as h}from"./route-handle-DcEil3NY.js";function U(){const s=_();r.useEffect(()=>{function n(){s()}function t(){document.visibilityState==="visible"&&s()}function a(){s()}return window.addEventListener("focus",n),window.addEventListener("pageshow",a),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("focus",n),window.removeEventListener("pageshow",a),document.removeEventListener("visibilitychange",t)}},[s])}const y=r.createContext(null);function V(s,n){switch(n.type){case"reset":return n.projects;case"add-session":{const t=s[n.projectId];return!t||t.sessionIds.includes(n.sessionId)?s:{...s,[n.projectId]:{...t,sessionIds:[...t.sessionIds,n.sessionId]}}}case"remove-session":{const t=s[n.projectId];return!t||!t.sessionIds.includes(n.sessionId)?s:{...s,[n.projectId]:{...t,sessionIds:t.sessionIds.filter(a=>a!==n.sessionId)}}}}}function D({children:s,initialProjects:n}){const[t,a]=r.useReducer(V,n);return r.useEffect(()=>{a({type:"reset",projects:n})},[n]),C(i=>{switch(i.type){case"session.summary":if(!w(i.summary))return;a({type:"add-session",projectId:i.projectId,sessionId:i.summary.id});return;case"session.deleted":a({type:"remove-session",projectId:i.projectId,sessionId:i.sessionId})}},{types:["session.summary","session.deleted"]}),e.jsx(y.Provider,{value:t,children:s})}function T(){const s=r.useContext(y);if(!s)throw new Error("useProjects must be used within a ProjectsProvider.");return s}function g({variant:s="solid"}){return e.jsx("span",{"aria-hidden":"true",className:d("inline-block box-border size-2 rounded-full",s==="solid"?"bg-black":"border-2 border-black bg-transparent"),"data-testid":"unread-badge"})}function K(s){return[...s].sort((n,t)=>n.name.localeCompare(t.name))}function S(){const s=T(),n=v(),[t,a]=r.useState(()=>Date.now());return r.useEffect(()=>{const i=window.setInterval(()=>{a(Date.now())},6e4);return()=>{window.clearInterval(i)}},[]),r.useMemo(()=>K(Object.values(s).map(i=>{const m=H(i.sessionIds.map(l=>n[l]).filter(l=>l!==void 0).filter(w),t).map(l=>l.id);return{...i,sessionIds:m}})).filter(i=>i.sessionIds.length>0),[t,s,n])}function q(){const s=S(),n=v();return s.some(t=>t.sessionIds.slice(0,N).some(a=>{const i=n[a];return i?F(i,i.lastReadAt):!1}))}function G(s,n){return s||n.slice(0,12)}function J({project:s}){const n=s.sessionIds.slice(0,N);return e.jsxs("li",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 px-3 py-1",children:[e.jsx(c,{className:({isActive:t})=>d("block min-h-9 flex-1 py-2 text-base text-black",{"underline underline-offset-4":t}),to:`/projects/${s.id}`,children:e.jsx("span",{className:"font-bold",children:s.name})}),e.jsxs(p,{action:`/projects/${s.id}?index`,method:"post",children:[e.jsx("input",{name:"intent",type:"hidden",value:"create-session"}),e.jsx("button",{"aria-label":`New session for ${s.name}`,className:"inline-flex h-9 min-w-9 items-center justify-center",type:"submit",children:e.jsx(u,{className:"size-5",icon:"mdi:plus"})})]})]}),e.jsx("ul",{className:"space-y-0.5 pl-6",children:n.map(t=>e.jsx(Q,{projectId:s.id,sessionId:t},t))})]})}function Q({projectId:s,sessionId:n}){const t=$(n),a=A(n);return t?e.jsx("li",{children:e.jsx(c,{className:()=>d("grid min-h-9 grid-cols-[0.5rem_minmax(0,1fr)] items-center gap-2 px-3 py-1 text-sm leading-6","text-black"),to:`/projects/${s}/sessions/${n}`,children:({isActive:i})=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex justify-center",children:a!=="none"?e.jsx(g,{variant:a}):null}),e.jsx("span",{className:d({"underline underline-offset-4":i}),children:G(t.title,n)})]})})}):null}function W(){const s=S();return s.length?e.jsx("ul",{className:"space-y-1",children:s.map(n=>e.jsx(J,{project:n},n.id))}):null}function X(){return e.jsx("nav",{"aria-label":"Sidebar",className:"pt-2",children:e.jsx(W,{})})}function j(s=!1){return`inline-flex min-h-11 min-w-11 items-center justify-center ${s?"bg-black text-white":"bg-white text-black"}`}function b({action:s}){return"to"in s?e.jsx(c,{"aria-label":s.label,className:({isActive:n})=>j(n),end:s.end,to:s.to,children:e.jsx(u,{className:"size-6",icon:s.icon})}):e.jsxs(p,{action:s.action,method:s.method,children:[Object.entries(s.fields??{}).map(([n,t])=>e.jsx("input",{name:n,type:"hidden",value:t},n)),e.jsx("button",{"aria-label":s.label,className:j(),type:"submit",children:e.jsx(u,{className:"size-6",icon:s.icon})})]})}function Y({breadcrumbs:s,leadingIconAction:n,iconNavActions:t}){const[a,i]=r.useState(!1),m=q(),l=E(),I=s.map(o=>typeof o.content=="string"?o.content:null).filter(Boolean).join(" / "),k=a?"mdi:menu-open":"mdi:menu";return r.useEffect(()=>{i(!1)},[l.pathname]),r.useEffect(()=>{if(!a)return;function o(x){x.key==="Escape"&&i(!1)}return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[a]),e.jsxs("main",{className:`${f.appShell} relative flex min-h-dvh flex-col bg-white text-black`,children:[a?e.jsxs(e.Fragment,{children:[e.jsx("button",{"aria-label":"Close navigation",className:"fixed inset-0 z-20 bg-white/0",onClick:()=>i(!1),type:"button"}),e.jsx("aside",{className:`${f.sidebarShell} fixed inset-y-0 left-0 z-30 w-80 border-r-2 border-black bg-white`,children:e.jsxs("div",{className:"flex h-full flex-col gap-4",children:[e.jsxs("header",{className:"flex items-center justify-between gap-3",children:[e.jsx(c,{className:"inline-flex min-h-11 items-center px-3 py-2 text-sm uppercase tracking-[0.08em] text-black",to:"/projects",children:e.jsx("span",{className:"font-bold",children:"Projects"})}),e.jsx("button",{"aria-label":"Close navigation",className:"inline-flex min-h-11 min-w-11 items-center justify-center",onClick:()=>i(!1),type:"button",children:e.jsx(u,{className:"size-6",icon:"mdi:close"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(X,{})}),e.jsxs("div",{className:"mt-auto space-y-2 border-t-2 border-black",children:[e.jsx(c,{className:"inline-flex min-h-11 w-full items-center justify-center px-3 py-2 text-base",to:"/settings",children:"Settings"}),e.jsx(p,{action:"/logout",method:"post",children:e.jsx("button",{className:"inline-flex min-h-11 min-w-full items-center justify-center bg-black px-3 py-2 text-base text-white",type:"submit",children:"Log out"})})]})]})})]}):null,e.jsxs("div",{className:d(f.appShellContent,"mx-auto flex w-full max-w-5xl flex-col"),children:[e.jsxs("header",{className:"grid grid-cols-[auto_1fr_auto] items-center gap-3 border-b-2 border-black",children:[e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsxs("button",{"aria-label":"Toggle navigation",className:"relative inline-flex min-h-11 min-w-11 items-center justify-center",onClick:()=>i(o=>!o),type:"button",children:[e.jsx(u,{className:"size-6",icon:k}),m?e.jsx("span",{className:d("pointer-events-none absolute right-1.5 top-0 z-10"),children:e.jsx(g,{})}):null]}),n?e.jsx(b,{action:n}):null]}),e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{"aria-label":I,className:"overflow-hidden text-2xl font-bold",children:e.jsx("span",{className:"flex w-full min-w-0 items-center overflow-hidden whitespace-nowrap",style:{"--count":s.length},children:s.map((o,x)=>e.jsxs("span",{className:"flex flex-[1_1_0] items-center overflow-hidden min-w-[min(max-content,calc(100%/var(--count)))] max-w-max",children:[x>0?e.jsx("span",{className:"mx-2 shrink-0",children:"/"}):null,o.to?e.jsx(c,{className:"block min-w-0 truncate",to:o.to,children:o.content}):e.jsx("span",{className:"block min-w-0 truncate",children:o.content})]},`${o.to??"breadcrumb"}-${x}`))})})}),e.jsx("div",{className:"flex items-center",children:t.map(o=>e.jsx("div",{children:e.jsx(b,{action:o})},"to"in o?o.to:`${o.method}:${o.action}:${o.label}`))})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(P,{})})]})]})}function Z({breadcrumbsFallback:s,iconNavActions:n,leadingIconAction:t}){const a=B();return e.jsx(Y,{breadcrumbs:a.length?a:s,leadingIconAction:t,iconNavActions:n??[]})}const me=L(function({loaderData:n,matches:t}){U();const a=M(t),i=h(a,"leadingIconAction"),m=h(a,"iconNavActions")??[];return e.jsx(R,{children:e.jsx(z,{initialSessions:n.initialSessions,initialStatuses:n.initialSessionStatuses,children:e.jsx(D,{initialProjects:n.initialProjects,children:e.jsx(O,{children:e.jsx(Z,{breadcrumbsFallback:[{content:"Scriptorium"}],leadingIconAction:i,iconNavActions:m})})})})})});export{me as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{w as t}from"./chunk-EPOLDU6W-BT1NqV1s.js";import{j as o}from"./jsx-runtime-u17CrQMm.js";import{A as r}from"./auth-shell-CM4lzbUg.js";import"./index-CLO24mr0.js";import"./safe-area.module-CwCzHS6V.js";const n=t(function(){return o.jsx(r,{})});export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{w as r,O as i}from"./chunk-EPOLDU6W-BT1NqV1s.js";import{j as t}from"./jsx-runtime-u17CrQMm.js";import{P as n}from"./project-events-provider-Cz1h_7Z0.js";import{d as c}from"./route-handle-DcEil3NY.js";import{g as s}from"./project-route-Cqnw3iG7.js";import"./index-CLO24mr0.js";import"./events-BGAz2o24.js";const f=c({leadingIconAction:o=>{const e=o.params.projectId??"";return s(e)},iconNavActions:o=>{const e=o.params.projectId??"";return[{icon:"mdi:view-dashboard-outline",label:"Project overview",to:`/projects/${e}`,end:!0},{icon:"mdi:source-branch",label:"Review",to:`/projects/${e}/review/uncommitted`,end:!0},{icon:"mdi:file-document-multiple-outline",label:"Files view",to:`/projects/${e}/files`,end:!0}]}}),v=r(function({params:e}){return t.jsx(n,{projectIds:[e.projectId],children:t.jsx(i,{})})});export{v as default,f as handle};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{u as me,w as Fe,g as ze,O as Ve}from"./chunk-EPOLDU6W-BT1NqV1s.js";import{j as s}from"./jsx-runtime-u17CrQMm.js";import{r as c}from"./index-CLO24mr0.js";import{B as ue}from"./breadcrumbs-CLMk50vh.js";import{S as _e}from"./scrollable-layout-CR2OL0dM.js";import{d as Ue}from"./route-handle-DcEil3NY.js";import{g as qe}from"./project-route-Cqnw3iG7.js";import{s as He}from"./safe-area.module-CwCzHS6V.js";import{I as V}from"./files.browse-BBMm6lgA.js";import{c as z}from"./cn-Kn7NbJqM.js";import{S as We,u as Ke,g as Je,b as Ge,c as Qe,a as Ye}from"./session-route-Cd_9l4G7.js";import"./project-events-provider-Cz1h_7Z0.js";import"./events-BGAz2o24.js";const Xe=e=>e.mode!=="subagent"&&e.hidden!==!0;function Ce(e){return e.filter(Xe)}function Ze(e,t){const n=Ce(t);if(!n.length)return null;const a=new Set(n.map(f=>f.name)),o=e.reduce((f,p)=>{const r=p.info.agent;return typeof r!="string"||!a.has(r)?f:f?p.info.time.created>f.info.time.created?p:f:p},null);return o?.info.agent?o.info.agent:n[0].name}function ie({children:e}){return s.jsx("div",{className:"absolute inset-x-0 bottom-full border-y-2 border-black bg-white",children:e})}function ve({children:e}){return s.jsx("div",{className:"overflow-x-auto px-3 py-3",children:s.jsx("div",{className:"flex min-w-max items-stretch gap-2",children:e})})}function De({children:e,title:t}){return s.jsx("div",{className:"max-h-[50dvh] overflow-y-auto p-3",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm font-bold uppercase tracking-[0.08em]",children:t}),e]})})}function et({commands:e,isDisabled:t,onCommand:n}){return s.jsx(ie,{children:s.jsx(ve,{children:e.map(a=>s.jsxs("button",{"aria-label":`Insert /${a.name}`,className:"min-h-11 shrink-0 bg-white px-3 py-2 text-base disabled:opacity-25",disabled:t,onClick:()=>n(a.name),type:"button",children:["/",a.name]},a.name))})})}function tt({commandDescription:e}){return s.jsx(ie,{children:s.jsx(De,{title:"Command",children:s.jsx("p",{className:"text-base leading-6",children:e})})})}function ne(e){return`${e.providerID}/${e.modelID}`}function nt(e,t){const n=t.find(a=>a.id===e.providerID)?.models[e.modelID];return n?.variants?Object.keys(n.variants):[]}function st(e,t){return e?t.find(n=>n.id===e.providerID)?.models[e.modelID]?.name??e.modelID:"No model"}function at(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:e>=1e6?`${(e/1e6).toFixed(e%1e6===0?0:1)}M ctx`:e>=1e3?`${Math.round(e/1e3)}k ctx`:`${e} ctx`}function se(e){return e>=1||e>=.1?e.toFixed(2):e>=.01?e.toFixed(3):e.toFixed(4)}function ot(e){if(!e||typeof e!="object")return null;const t="input"in e&&typeof e.input=="number"?e.input:null,n="output"in e&&typeof e.output=="number"?e.output:null;return t===null&&n===null?null:t===0&&n===0?"free":t!==null&&n!==null?`$${se(t)}/$${se(n)}`:t!==null?`$${se(t)} in`:`$${se(n??0)} out`}function je(e){const t="capabilities"in e&&e.capabilities&&typeof e.capabilities=="object"?e.capabilities:null,n="cost"in e?ot(e.cost):null,a="limit"in e&&e.limit&&typeof e.limit=="object"?e.limit:null,o=a&&"context"in a?at(a.context):null;return{capabilities:{files:!!(t&&"attachment"in t&&t.attachment===!0),reasoning:!!(t&&"reasoning"in t&&t.reasoning===!0),tools:!!(t&&"toolcall"in t&&t.toolcall===!0)},context:o,cost:n,status:"status"in e&&typeof e.status=="string"&&e.status!=="active"?e.status:null,variants:e.variants&&Object.keys(e.variants).length>0?`${Object.keys(e.variants).length} variants`:null}}function fe(e){return z("min-h-11 px-3 py-2 text-left text-sm leading-5 disabled:opacity-25",e?"bg-black text-white":"bg-white text-black")}function rt(e){return e==="commands-description"||e==="commands-list"?"bg-black text-white":"bg-white text-black"}function it({agents:e,currentVariant:t,isAbortPending:n,isBusy:a,isPromptPending:o,onAbort:f,onCommandsToggle:p,onCycleAgent:r,onModelToggle:m,onSubmit:d,onVariantCycle:x,providers:j,selectedAgent:y,selectedModel:i,variantOptions:v,visibleTray:N}){return s.jsxs("div",{className:"flex items-stretch justify-between gap-2 pb-1",children:[s.jsxs("div",{className:"flex min-w-0 items-stretch gap-2 overflow-x-auto",children:[s.jsx("button",{"aria-label":"Cycle agent",className:fe(!1),disabled:!e.length,onClick:r,onPointerDown:S=>S.preventDefault(),type:"button",children:y??"No agent"}),s.jsx("button",{"aria-label":"Toggle model tray",className:fe(N==="model"),onClick:m,onPointerDown:S=>S.preventDefault(),type:"button",children:i?st(i,j):"Default"}),s.jsx("button",{"aria-label":"Cycle variant",className:fe(!1),disabled:v.length===0,onClick:x,onPointerDown:S=>S.preventDefault(),type:"button",children:t??"Auto"})]}),s.jsxs("div",{className:"ml-auto flex shrink-0 items-stretch gap-2",children:[s.jsx("button",{"aria-label":"Toggle commands tray",className:z("inline-flex min-h-11 min-w-11 items-center justify-center disabled:opacity-25",rt(N)),disabled:!1,onClick:p,onPointerDown:S=>S.preventDefault(),type:"button",children:s.jsx(V,{className:"size-6",icon:"mdi:robot-excited"})}),s.jsx("button",{"aria-label":"Stop current response",className:"inline-flex min-h-11 min-w-11 items-center justify-center disabled:opacity-25",disabled:n||!a,onClick:f,onPointerDown:S=>S.preventDefault(),type:"button",children:s.jsx(V,{className:"size-6",icon:"mdi:stop-circle"})}),s.jsx("button",{"aria-label":"Send message",className:"inline-flex min-h-11 min-w-11 items-center justify-center bg-black text-white disabled:opacity-25",disabled:o,onClick:d,onPointerDown:S=>S.preventDefault(),type:"button",children:s.jsx(V,{className:"size-6",icon:"mdi:send"})})]})]})}function lt({images:e,onRemoveImage:t}){return e.length?s.jsx(ie,{children:s.jsx(ve,{children:e.map(n=>s.jsxs("div",{"aria-label":n.file.name,className:"relative size-20 overflow-hidden border-2 border-black bg-white",children:[s.jsx("img",{alt:n.file.name,className:"size-full object-cover",src:n.preview}),s.jsx("button",{"aria-label":`Remove ${n.file.name}`,className:"absolute right-1 top-1 inline-flex size-6 items-center justify-center border-2 border-black bg-white",onClick:()=>{t(n.id)},type:"button",children:s.jsx(V,{className:"size-4",icon:"mdi:close"})})]},n.id))})}):null}function Se(e){return Array.from(e).filter(t=>t.type.startsWith("image/"))}function ct({composerInputRef:e,composerText:t,imageInputRef:n,isPromptPending:a,onAddImages:o,onComposerTextChange:f,onUpdateSelection:p}){return s.jsxs("div",{className:"relative min-w-0",children:[s.jsx("input",{accept:"image/*",className:"hidden",multiple:!0,onChange:r=>{r.currentTarget.files&&o(r.currentTarget.files),r.currentTarget.value=""},ref:n,type:"file"}),s.jsx("textarea",{className:"min-h-32 w-full px-3 py-2 pr-14 text-base leading-7",name:"text",onBlur:r=>p(r.currentTarget),onChange:r=>{f(r.currentTarget.value),p(r.currentTarget)},onClick:r=>p(r.currentTarget),onDragOver:r=>{Array.from(r.dataTransfer?.files??[]).some(m=>m.type.startsWith("image/"))&&r.preventDefault()},onDrop:r=>{const m=Se(r.dataTransfer.files??[]);m.length!==0&&(r.preventDefault(),o(m))},onKeyUp:r=>p(r.currentTarget),onPaste:r=>{const m=Se(r.clipboardData.files??[]);m.length!==0&&(r.preventDefault(),o(m))},onSelect:r=>p(r.currentTarget),placeholder:"Send a message, paste an image, or attach one",ref:e,value:t}),s.jsx("button",{"aria-label":"Attach image",className:"absolute bottom-3 right-3 inline-flex min-h-11 min-w-11 items-center justify-center bg-white disabled:opacity-25",disabled:a,onClick:()=>n.current?.click(),type:"button",children:s.jsx(V,{className:"size-6",icon:"mdi:image-plus"})})]})}function we({capabilities:e,isSelected:t}){const n=z("size-4",t?"text-white":"text-black"),a=z("inline-block size-4",t?"text-white/25":"text-black/25");return s.jsxs("span",{className:"inline-flex items-center gap-1","aria-hidden":"true",children:[e.reasoning?s.jsx(V,{className:n,icon:"mdi:brain"}):s.jsx("span",{className:a}),e.tools?s.jsx(V,{className:n,icon:"mdi:wrench"}):s.jsx("span",{className:a}),e.files?s.jsx(V,{className:n,icon:"mdi:paperclip"}):s.jsx("span",{className:a})]})}function dt({collapsedProviderIDs:e,modelGroups:t,modelSearch:n,onModelSearchChange:a,onModelSelect:o,onProviderToggle:f,recentModels:p,selectedModel:r}){const m=n.trim()?new Set:e;return s.jsx(ie,{children:s.jsxs(De,{title:"Model",children:[s.jsx("input",{"aria-label":"Search models",className:"min-h-11 w-full bg-white px-3 py-2 text-base",placeholder:"Search models",onChange:d=>a(d.currentTarget.value),type:"text",value:n}),s.jsxs("div",{className:"space-y-4",children:[p.length?s.jsxs("section",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-bold uppercase tracking-[0.08em]",children:"Recent"}),s.jsx("div",{children:p.map((d,x)=>{const j=r?.providerID===d.model.providerID&&r?.modelID===d.model.modelID;return s.jsx("button",{"aria-label":`Use recent ${d.providerLabel} ${d.modelLabel}`,className:z("flex min-h-14 w-full items-start justify-between gap-3 px-1 py-3 text-left text-base",x>0?"border-t border-black":"",j?"bg-black text-white":"bg-white text-black"),onClick:()=>o(d.model,d.variant),type:"button",children:s.jsxs("span",{className:"min-w-0 space-y-1",children:[s.jsx("span",{className:"block",children:d.modelLabel}),s.jsxs("span",{className:z("flex items-center gap-3 text-sm",j?"text-white/80":"text-black/70"),children:[s.jsx(we,{capabilities:d.metadata.capabilities,isSelected:j}),s.jsx("span",{children:[d.metadata.context,d.metadata.cost].filter(Boolean).join(" ")}),d.metadata.status||d.metadata.variants||d.variant?s.jsx("span",{children:[d.metadata.status,d.metadata.variants,d.variant?`variant ${d.variant}`:null].filter(Boolean).join(" · ")}):null]})]})},d.key)})})]}):null,t.length?t.map(d=>s.jsxs("section",{className:"space-y-2",children:[s.jsxs("button",{"aria-label":`Toggle ${d.providerLabel} models`,className:"flex min-h-11 w-full items-center gap-2 text-left text-sm font-bold uppercase tracking-[0.08em]",onClick:()=>f(d.providerID),type:"button",children:[s.jsx(V,{className:z("size-4 transition-transform",m.has(d.providerID)?"-rotate-90":"rotate-0"),icon:"mdi:chevron-down"}),s.jsx("span",{children:d.providerLabel})]}),s.jsx("div",{hidden:m.has(d.providerID),children:d.models.map((x,j)=>{const y=r?.providerID===x.model.providerID&&r?.modelID===x.model.modelID;return s.jsx("button",{"aria-label":`Use ${d.providerLabel} ${x.modelLabel}`,className:z("flex min-h-14 w-full items-start justify-between gap-3 px-1 py-3 text-left text-base",j>0?"border-t border-black":"",y?"bg-black text-white":"bg-white text-black"),onClick:()=>o(x.model),type:"button",children:s.jsxs("span",{className:"min-w-0 space-y-1",children:[s.jsx("span",{className:"block",children:x.modelLabel}),s.jsxs("span",{className:z("flex items-center gap-3 text-sm",y?"text-white/80":"text-black/70"),children:[s.jsx(we,{capabilities:x.metadata.capabilities,isSelected:y}),s.jsx("span",{children:[x.metadata.context,x.metadata.cost].filter(Boolean).join(" ")}),x.metadata.status||x.metadata.variants?s.jsx("span",{children:[x.metadata.status,x.metadata.variants].filter(Boolean).join(" · ")}):null]})]})},x.key)})})]},d.providerID)):null,p.length===0&&t.length===0?s.jsx("p",{className:"text-base leading-6",children:"No models match that search."}):null]})]})})}function mt({abortError:e,commandError:t,isRestoringAttachments:n,promptError:a,sessionError:o}){return s.jsxs("div",{className:"space-y-3",children:[a?s.jsx("p",{className:"text-base leading-6",children:a}):null,t?s.jsx("p",{className:"text-base leading-6",children:t}):null,e?s.jsx("p",{className:"text-base leading-6",children:e}):null,o?s.jsx("p",{className:"text-base leading-6",children:o}):null,n?s.jsx("p",{className:"text-sm leading-6",children:"Restoring attachments..."}):null]})}function ut(e,t){if(!e.startsWith("/"))return null;const n=e.indexOf(`
|
|
2
|
+
`),o=(n===-1?e:e.slice(0,n)).slice(1),f=o.search(/\s/),p=(f===-1?o:o.slice(0,f)).trim();if(!p||t&&!new Set(t).has(p))return null;const r=n===-1?"":e.slice(n+1);return{arguments:(f===-1?"":o.slice(f).trimStart())+(r?`
|
|
3
|
+
${r}`:""),command:p}}const ft="scriptorium-session-composer",pt=1,re="attachments",oe={start:0,end:0};function bt(e){return e.type.startsWith("image/")}function xt(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`image-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ie(e,t){return{file:e,id:t,preview:URL.createObjectURL(e)}}function ae(e){e.forEach(t=>URL.revokeObjectURL(t.preview))}function be(e){return`session-composer:${e}`}function gt(e){if(!e||typeof e!="object")return null;const t="modelID"in e?e.modelID:void 0,n="providerID"in e?e.providerID:void 0;return typeof t=="string"&&typeof n=="string"?{modelID:t,providerID:n}:null}function ye(e){return{id:e.id,lastModified:e.file.lastModified,name:e.file.name,size:e.file.size,type:e.file.type}}function ht(e){if(typeof window>"u")return null;const t=window.sessionStorage.getItem(be(e));if(!t)return null;try{const n=JSON.parse(t);return{attachments:Array.isArray(n.attachments)?n.attachments.filter(a=>!!(a&&typeof a.id=="string"&&typeof a.name=="string"&&typeof a.type=="string"&&typeof a.size=="number"&&typeof a.lastModified=="number")):[],selectedModel:gt(n.selectedModel),selectedAgent:typeof n.selectedAgent=="string"?n.selectedAgent:null,selection:n.selection&&typeof n.selection.start=="number"&&typeof n.selection.end=="number"?n.selection:oe,text:typeof n.text=="string"?n.text:"",variants:n.variants&&typeof n.variants=="object"?Object.fromEntries(Object.entries(n.variants).filter(a=>typeof a[0]=="string"&&typeof a[1]=="string")):{}}}catch{return null}}function pe(e,t){typeof window>"u"||window.sessionStorage.setItem(be(e),JSON.stringify(t))}async function jt(){return typeof indexedDB>"u"?null:await new Promise((e,t)=>{const n=indexedDB.open(ft,pt);n.onupgradeneeded=()=>{const a=n.result;a.objectStoreNames.contains(re)||a.createObjectStore(re,{keyPath:["sessionId","id"]}).createIndex("sessionId","sessionId",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Failed to open session composer database."))})}function Z(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??new Error("IndexedDB request failed."))})}async function le(e,t){const n=await jt();if(!n)return null;try{const a=n.transaction(re,e),o=a.objectStore(re),f=await t(o);return await new Promise((p,r)=>{a.oncomplete=()=>p(),a.onerror=()=>r(a.error??new Error("IndexedDB transaction failed.")),a.onabort=()=>r(a.error??new Error("IndexedDB transaction aborted."))}),f}finally{n.close()}}async function St(e){await le("readwrite",async t=>(await Z(t.put(e)),null))}async function wt(e,t){return await le("readonly",async a=>await Z(a.get([e,t])))}async function yt(e,t){await le("readwrite",async n=>(await Z(n.delete([e,t])),null))}async function Ct(e){typeof window<"u"&&window.sessionStorage.removeItem(be(e)),await le("readwrite",async t=>{const n=t.index("sessionId"),a=await Z(n.getAll(IDBKeyRange.only(e)));return await Promise.all(a.map(o=>Z(t.delete([e,o.id])))),null})}async function vt(e,t){return(await Promise.all(t.map(async a=>{const o=await wt(e,a.id);if(!o)return null;const f=new File([o.blob],o.name,{lastModified:o.lastModified,type:o.type});return Ie(f,o.id)}))).filter(a=>a!==null)}function Dt({defaultAgent:e,defaultModel:t,defaultVariant:n,prefilledPrompt:a,sessionId:o}){const f=c.useRef(null),p=c.useRef(null),r=c.useRef(oe),m=c.useRef([]),d=c.useRef(!1),x=c.useRef(0),j=c.useRef(!1),[y,i]=c.useState(""),[v,N]=c.useState([]),[S,P]=c.useState(!1),[k,W]=c.useState(e),[D,U]=c.useState(null),[M,L]=c.useState({});c.useEffect(()=>{m.current=v},[v]),c.useEffect(()=>()=>{ae(m.current)},[]),c.useEffect(()=>{const w=x.current+1;x.current=w,d.current=!1,j.current=!1,ae(m.current),m.current=[],N([]),P(!0);const u=ht(o),C=u?.text??a,g=u?.selection??{start:C.length,end:C.length},I=u?.selectedAgent??e,T=u?.selectedModel??t,K={...u?.variants??{}};T&&t&&T.providerID===t.providerID&&T.modelID===t.modelID&&n&&(K[ne(T)]??=n),r.current=g,i(C),W(I),U(T),L(K),j.current=!u?.text&&!!a,vt(o,u?.attachments??[]).then(A=>{if(x.current!==w){ae(A);return}m.current=A,N(A),d.current=!0,P(!1)})},[e,t,n,a,o]),c.useEffect(()=>{j.current&&(j.current=!1,window.requestAnimationFrame(()=>{const w=f.current;if(!w)return;const u=r.current.end;w.focus(),w.setSelectionRange(u,u)}))},[y]),c.useEffect(()=>{d.current&&pe(o,{attachments:v.map(ye),selectedModel:D,selectedAgent:k,selection:r.current,text:y,variants:M})},[y,v,k,D,o,M]);const O=c.useCallback(w=>{const u=w??f.current;u&&(r.current={start:u.selectionStart??0,end:u.selectionEnd??u.selectionStart??0},d.current&&pe(o,{attachments:m.current.map(ye),selectedModel:D,selectedAgent:k,selection:r.current,text:u.value,variants:M}))},[k,D,o,M]),Q=c.useCallback(w=>{let u=0,C=0;i(g=>{const I=g.length,T=r.current.start,K=r.current.end,A=Math.max(0,Math.min(T,I)),R=Math.max(A,Math.min(K,I)),ee=A>0&&/\S/.test(g[A-1]??"")?" ":"",$=R===g.length||/\S/.test(g[R]??"")?" ":"",F=`${ee}${w}${$}`,ce=`${g.slice(0,A)}${F}${g.slice(R)}`,J=A+F.length;return u=J,C=J,r.current={start:J,end:J},ce}),window.requestAnimationFrame(()=>{const g=f.current;g&&(g.focus(),g.setSelectionRange(u,C),r.current={start:u,end:C})})},[]),E=c.useCallback(async w=>{const u=Array.from(w).filter(bt);if(u.length===0)return;const C=await Promise.all(u.map(async g=>{const I=xt();return await St({blob:g,id:I,lastModified:g.lastModified,name:g.name,sessionId:o,size:g.size,type:g.type}),Ie(g,I)}));N(g=>[...g,...C])},[o]),q=c.useCallback(async w=>{let u;N(C=>(u=C.find(g=>g.id===w),C.filter(g=>g.id!==w))),u&&URL.revokeObjectURL(u.preview),await yt(o,w)},[o]),Y=c.useCallback(async()=>{ae(m.current),m.current=[],N([]),i(""),r.current=oe,await Ct(o),(k||d.current)&&pe(o,{attachments:[],selectedModel:D,selectedAgent:k,selection:oe,text:"",variants:M})},[k,D,o,M]),H=D?M[ne(D)]??null:null,X=c.useCallback(w=>{L(u=>{if(!D)return u;const C=ne(D);if(!w){const{[C]:g,...I}=u;return I}return{...u,[C]:w}})},[D]),B=c.useCallback((w,u)=>{U(w),u!==void 0&&L(C=>{const g=ne(w);if(!u){const{[g]:I,...T}=C;return T}return{...C,[g]:u}})},[]);return{addImages:E,applySelectedModel:B,clearDraftContent:Y,composerInputRef:f,composerText:y,imageInputRef:p,images:v,insertComposerReference:Q,isRestoringAttachments:S,removeImage:q,selectedAgent:k,selectedModel:D,selectedVariant:H,setComposerText:i,setSelectedAgent:W,setSelectedModel:U,setSelectedVariant:X,updateComposerSelection:O}}function It(e){return Array.from(e).filter(t=>t.type.startsWith("image/"))}function Nt({agents:e,commands:t,defaultAgent:n,defaultModel:a,defaultVariant:o,insertReferenceEvents:f,onClearSessionError:p,prefilledPrompt:r,providers:m,recentModels:d,sessionId:x}){const j=me(),y=me(),i=me(),v=c.useRef(null),[N,S]=c.useState(null),[P,k]=c.useState(""),[W,D]=c.useState(()=>new Set),{addImages:U,clearDraftContent:M,composerInputRef:L,composerText:O,imageInputRef:Q,images:E,insertComposerReference:q,isRestoringAttachments:Y,removeImage:H,selectedAgent:X,selectedModel:B,selectedVariant:w,applySelectedModel:u,setComposerText:C,setSelectedAgent:g,setSelectedVariant:I,updateComposerSelection:T}=Dt({defaultAgent:n,defaultModel:a,defaultVariant:o,prefilledPrompt:r,sessionId:x});c.useEffect(()=>{function l(b){!(b instanceof CustomEvent)||typeof b.detail!="string"||q(b.detail)}return f.addEventListener("insert-reference",l),()=>{f.removeEventListener("insert-reference",l)}},[q,f]),c.useEffect(()=>{const l=j.data;if(!l){v.current=null;return}v.current!==l&&l.ok&&l.clearDraft&&(v.current=l,p(),M())},[M,p,j.data]),c.useEffect(()=>{S(null),k(""),D(new Set)},[x]);const K=c.useCallback(()=>{g(l=>{if(e.length===0)return l;const b=l?e.indexOf(l):-1;return b===-1?e[0]??null:e[(b+1)%e.length]??null})},[e,g]),A=c.useMemo(()=>t.map(l=>l.name),[t]),R=c.useMemo(()=>ut(O,A),[A,O]),ee=c.useMemo(()=>R?t.find(l=>l.name===R.command)??null:null,[t,R]),$=c.useMemo(()=>B?nt(B,m):[],[m,B]),F=w&&$.includes(w)?w:null,ce=c.useMemo(()=>{const l=P.trim().toLowerCase();return m.map(b=>({providerID:b.id,providerLabel:b.name,models:Object.values(b.models).map(h=>({key:`${b.id}/${h.id}`,metadata:je(h),model:{modelID:h.id,providerID:b.id},modelLabel:h.name})).filter(h=>l?[h.key,h.modelLabel,b.name,h.metadata.context,h.metadata.cost,h.metadata.status,h.metadata.variants,h.metadata.capabilities.reasoning?"reasoning":"",h.metadata.capabilities.tools?"tools":"",h.metadata.capabilities.files?"files":""].some(G=>(G??"").toLowerCase().includes(l)):!0)})).filter(b=>b.models.length>0)},[P,m]),J=c.useMemo(()=>{const l=P.trim().toLowerCase();return d.flatMap(b=>{const h=m.find(de=>de.id===b.model.providerID),G=h?.models[b.model.modelID];if(!h||!G)return[];const _=je(G),te={key:`recent:${h.id}/${G.id}`,metadata:_,model:b.model,modelLabel:G.name,providerLabel:h.name,variant:b.variant};return l?[te.modelLabel,te.providerLabel,b.variant,_.context,_.cost,_.status,_.variants,_.capabilities.reasoning?"reasoning":"",_.capabilities.tools?"tools":"",_.capabilities.files?"files":""].some(de=>(de??"").toLowerCase().includes(l))?[te]:[]:[te]})},[P,m,d]),Ne=c.useCallback(()=>{S(b=>b==="commands"?null:b);const l=new FormData;if(l.set("agent",X??""),l.set("modelProviderID",B?.providerID??""),l.set("modelID",B?.modelID??""),l.set("variant",F??""),E.forEach(b=>l.append("attachments",b.file,b.file.name)),R){p(),M(),l.set("intent","command"),l.set("arguments",R.arguments),l.set("clearDraft","1"),l.set("command",R.command),y.submit(l,{encType:"multipart/form-data",method:"post"});return}l.set("intent","prompt"),l.set("text",O),j.submit(l,{encType:"multipart/form-data",method:"post"})},[M,y,O,F,E,p,R,j,X,B]),ke=c.useCallback(()=>{const l=new FormData;l.set("intent","abort"),i.submit(l,{method:"post"})},[i]),Me=c.useCallback(()=>{S(l=>l==="commands"?null:"commands")},[]),Te=c.useCallback(()=>{S(l=>l==="model"?null:"model")},[]),Ae=c.useCallback(l=>{D(b=>{const h=new Set(b);return h.has(l)?h.delete(l):h.add(l),h})},[]),Re=c.useCallback(()=>{if($.length===0)return;if(!F){I($[0]??null);return}const l=$.indexOf(F);if(l===-1||l===$.length-1){I(null);return}I($[l+1]??null)},[F,I,$]),Pe=c.useCallback(l=>{const b=`/${l} `;C(b),window.requestAnimationFrame(()=>{const h=L.current;h&&(h.focus(),h.setSelectionRange(b.length,b.length),T(h))})},[L,C,T]),Ee=c.useCallback((l,b)=>{u(l,b),S(null),k("")},[u]),xe=j.data,ge=y.data,he=i.data,$e=ge?.intent==="command"?ge.error??null:null,Le=xe?.intent==="prompt"?xe.error??null:null,Oe=he?.intent==="abort"?he.error??null:null,Be=N==="model"?"model":N==="commands"?ee?.description?"commands-description":"commands-list":E.length?"images":null;return{abortError:Oe,collapsedProviderIDs:W,commandDescription:ee?.description??null,commandError:$e,commands:t,composerInputRef:L,composerText:O,currentVariant:F,imageInputRef:Q,images:E,isAbortPending:i.state!=="idle",isCommandPending:y.state!=="idle",isPromptPending:j.state!=="idle",isRestoringAttachments:Y,modelGroups:ce,modelSearch:P,promptError:Le,recentModels:J,selectedAgent:X,selectedModel:B,variantOptions:$,visibleTray:Be,onAbort:ke,onAddImages:l=>U(It(l)),onCommand:Pe,onCommandsToggle:Me,onComposerTextChange:C,onCycleAgent:K,onModelSearchChange:k,onModelSelect:Ee,onModelToggle:Te,onProviderToggle:Ae,onRemoveImage:H,onSubmit:Ne,onUpdateSelection:T,onVariantCycle:Re}}function kt({agents:e,commands:t,defaultAgent:n,defaultModel:a,defaultVariant:o,insertReferenceEvents:f,isBusy:p,onClearSessionError:r,providers:m,prefilledPrompt:d,recentModels:x=[],sessionError:j,sessionId:y}){const i=Nt({agents:e,commands:t,defaultAgent:n,defaultModel:a,defaultVariant:o,insertReferenceEvents:f,onClearSessionError:r,prefilledPrompt:d,providers:m,recentModels:x,sessionId:y});return s.jsxs("div",{className:`${He.footerPad4} relative border-t-2 border-black px-6 pt-4 sm:px-8`,children:[s.jsx(mt,{abortError:i.abortError,commandError:i.commandError,isRestoringAttachments:i.isRestoringAttachments,promptError:i.promptError,sessionError:j}),i.visibleTray==="images"?s.jsx(lt,{images:i.images,onRemoveImage:i.onRemoveImage}):null,i.visibleTray==="commands-list"?s.jsx(et,{commands:i.commands,isDisabled:p||i.isCommandPending,onCommand:i.onCommand}):null,i.visibleTray==="commands-description"&&i.commandDescription?s.jsx(tt,{commandDescription:i.commandDescription}):null,i.visibleTray==="model"?s.jsx(dt,{collapsedProviderIDs:i.collapsedProviderIDs,modelGroups:i.modelGroups,modelSearch:i.modelSearch,onModelSearchChange:i.onModelSearchChange,onModelSelect:i.onModelSelect,onProviderToggle:i.onProviderToggle,recentModels:i.recentModels,selectedModel:i.selectedModel}):null,s.jsx("div",{className:"mt-3",children:s.jsx("form",{className:"min-w-0",onSubmit:v=>{v.preventDefault(),i.onSubmit()},children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(ct,{composerInputRef:i.composerInputRef,composerText:i.composerText,imageInputRef:i.imageInputRef,isPromptPending:i.isPromptPending,onAddImages:i.onAddImages,onComposerTextChange:i.onComposerTextChange,onUpdateSelection:i.onUpdateSelection}),s.jsx(it,{agents:e,currentVariant:i.currentVariant,isAbortPending:i.isAbortPending,isBusy:p,isPromptPending:i.isPromptPending,onAbort:i.onAbort,onCommandsToggle:i.onCommandsToggle,onCycleAgent:i.onCycleAgent,onModelToggle:i.onModelToggle,onSubmit:i.onSubmit,onVariantCycle:i.onVariantCycle,providers:m,selectedAgent:i.selectedAgent,selectedModel:i.selectedModel,variantOptions:i.variantOptions,visibleTray:i.visibleTray})]})})})]})}const Ht=Ue({leadingIconAction:({params:e})=>{const t=e.projectId??"";return qe(t)},iconNavActions:({params:e})=>{const t=e.projectId??"",n=e.sessionId??"";return Ye(t,n)}});function Mt({projectId:e,projectName:t,matches:n,sessionId:a}){const o=Ke();return s.jsxs(ue,{depth:n.length,children:[s.jsx(ue.Item,{to:`/projects/${e}`,children:t}),s.jsx(ue.Item,{to:`/projects/${e}/sessions/${a}`,children:Je(o)})]})}function Tt({agents:e,commands:t,defaultAgent:n,defaultModel:a,defaultVariant:o,insertReferenceEvents:f,prefilledPrompt:p,providers:r,recentModels:m,sessionId:d}){const x=Ge(),{clearSessionError:j,sessionError:y}=Qe();return s.jsx(kt,{agents:e,commands:t,defaultAgent:n,defaultModel:a,defaultVariant:o,insertReferenceEvents:f,isBusy:x.type!=="idle",onClearSessionError:j,prefilledPrompt:p,providers:r,recentModels:m,sessionError:y,sessionId:d})}const Wt=Fe(function({loaderData:t,matches:n}){const{initialAgents:a,initialCommands:o,initialDefaultModel:f,initialDefaultVariant:p,initialHistoryCursor:r,initialMessages:m,initialPermissions:d,initialQuestions:x,initialProviders:j,initialRecentModels:y,initialStatus:i,project:v,parentSession:N,session:S}=t,[P]=ze(),k=P.get("prompt")??"",W=c.useMemo(()=>Ce(a),[a]),D=c.useMemo(()=>o,[o]),U=c.useMemo(()=>j,[j]),M=c.useMemo(()=>Ze(m,a),[m,a]),L=c.useMemo(()=>f,[f]),O=c.useMemo(()=>p,[p]),Q=c.useMemo(()=>y,[y]),E=c.useMemo(()=>new EventTarget,[]),q=c.useCallback(H=>{E.dispatchEvent(new CustomEvent("insert-reference",{detail:H}))},[E]),Y=c.useMemo(()=>({actionPath:`/projects/${v.id}/sessions/${S.id}`,project:v,insertComposerReference:q,parentSession:N,sessionId:S.id,transcriptInitialState:{initialHistoryCursor:r,initialMessages:m,initialPermissions:d,initialQuestions:x}}),[r,m,d,x,q,v,N,S.id]);return s.jsxs(We,{initialSession:S,initialStatus:i,projectId:v.id,children:[s.jsx(Mt,{projectId:v.id,projectName:v.name,matches:n,sessionId:S.id}),s.jsx(_e,{footer:s.jsx(Tt,{agents:W.map(H=>H.name),commands:D,defaultAgent:M,defaultModel:L,defaultVariant:O,insertReferenceEvents:E,prefilledPrompt:k,providers:U,recentModels:Q,sessionId:S.id}),children:s.jsx(Ve,{context:Y})})]})});export{Wt as default,Ht as handle};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-u17CrQMm.js";import{O as s}from"./chunk-EPOLDU6W-BT1NqV1s.js";import{s as l}from"./safe-area.module-CwCzHS6V.js";function i(){return e.jsx("main",{className:`${l.pageShell} flex min-h-dvh bg-white text-black`,children:e.jsxs("div",{className:"mx-auto flex min-h-0 max-w-4xl flex-1 flex-col gap-8",children:[e.jsx("header",{className:"border-b-2 border-black pb-4",children:e.jsx("p",{className:"text-sm uppercase tracking-[0.08em]",children:"Scriptorium"})}),e.jsx("section",{className:"max-w-xl self-start",children:e.jsx(s,{})})]})})}function r(a){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("h2",{className:"text-3xl font-bold",children:a.title}),a.copy?e.jsx("p",{className:"max-w-xl text-base leading-6",children:a.copy}):null]}),a.children,a.footer?e.jsx("footer",{className:"pt-2 text-sm leading-6",children:a.footer}):null]})}function x(a){return a.message?e.jsx("p",{className:`text-base leading-6 ${a.tone==="muted"?"opacity-60":"font-bold"}`,children:a.message}):null}export{i as A,x as S,r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as d}from"./jsx-runtime-u17CrQMm.js";import{r as e}from"./index-CLO24mr0.js";const f=e.createContext(null),p=e.createContext([]);function l(r){return null}function x(r){return e.isValidElement(r)&&r.type===l}function b({children:r}){const i=e.useRef(0),[n,u]=e.useState([]),a=e.useMemo(()=>({register(c){const s=i.current++;return u(t=>[...t.filter(m=>m.id!==c.id),{...c,mountOrder:s}]),()=>{u(t=>t.filter(m=>m.id!==c.id))}}}),[]),o=e.useMemo(()=>n.reduce((s,t)=>s?t.depth!==s.depth?t.depth>s.depth?t:s:t.mountOrder>s.mountOrder?t:s:t,null)?.items??[],[n]);return d.jsx(f.Provider,{value:a,children:d.jsx(p.Provider,{value:o,children:r})})}const B=({children:r,depth:i})=>{const n=e.useContext(f),u=e.useId(),a=e.useMemo(()=>e.Children.toArray(r).flatMap(o=>x(o)?[{content:o.props.children,...o.props.to?{to:o.props.to}:{}}]:[]),[r]);return e.useEffect(()=>{if(!n)throw new Error("Breadcrumbs must be used within a BreadcrumbsProvider.");return n.register({depth:i,id:u,items:a})},[n,i,u,a]),null},g=Object.assign(B,{Item:l});function C(){return e.useContext(p)}export{g as B,b as a,C as u};
|