heyquilt 0.3.165 → 0.3.168

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/RELEASES.md CHANGED
@@ -11,6 +11,21 @@ Format: `## <version> — <YYYY-MM-DD>`, an optional one-line summary, then bull
11
11
  Lead each bullet with a short bold phrase. Inline `code` and **bold** are rendered;
12
12
  nothing else is.
13
13
 
14
+ ## 0.3.168 — 2026-11-13
15
+
16
+ - **Sign up right in the app.** **Create an account** on Quilt's sign-in screen now asks for your name, email and a password, emails you a 6-digit code, and once you type it in you're signed in, with this computer linked to your new account. No browser needed. You can still sign up on heyquilt.com instead.
17
+ - **Approving this computer signs the app in, every time.** After signing out and back in, the app could forget the code it was waiting on (it went back to the sign-in screen), and **Sign in** then said "Already signed in." It now keeps waiting until you approve, and **Sign in** goes straight in when you already are.
18
+
19
+ ## 0.3.167 — 2026-11-13
20
+
21
+ - **Downloading Quilt says how to open it.** Clicking a download button on heyquilt.com now shows, right under it, the steps for your computer: on a Mac, where to click **Open Anyway** the first time (Quilt isn't notarized by Apple while it's in beta); on Windows, **More info → Run anyway**; then signing in. heyquilt.com/download is a page of its own with the same steps.
22
+ - **Creating an account from the app comes back to the app.** **Create an account** on the sign-in screen now signs this computer in once your account is made, instead of leaving you on the website.
23
+ - **A fresh install opens on sign-in, not the release notes.** "What's new" shows after an update, not the first time you open Quilt.
24
+
25
+ ## 0.3.166 — 2026-11-13
26
+
27
+ - **The previous design is back.** The session sidebar, chat and tabs, Connections and the rest of the app are as they were before the redesign that started in 0.3.155. App connections through Composio stay.
28
+
14
29
  ## 0.3.165 — 2026-11-13
15
30
 
16
31
  - **Chat header lines up**: the chat panel's header is now the same height as the session bar beside it, so their bottom lines meet.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.165",
3
+ "version": "0.3.168",
4
4
  "description": "Real-time, tool-agnostic pair vibe coding: sync a project folder live between collaborators using any AI coding tool.",
5
5
  "author": {
6
6
  "name": "Daniel Carmichael",
package/src/account.js CHANGED
@@ -91,6 +91,16 @@ export async function startLink ({ identity, api = apiUrl(), fetch: fetchImpl =
91
91
  })
92
92
  }
93
93
 
94
+ /** Signing up in the app, for the link `deviceCode` is waiting on: Quilt emails `email` a 6-digit code. */
95
+ export async function signUpForLink ({ deviceCode, name, email, password, api = apiUrl(), fetch: fetchImpl = globalThis.fetch } = {}) {
96
+ return call(fetchImpl, api, 'POST', '/v1/device/signup', { deviceCode, name, email, password })
97
+ }
98
+
99
+ /** Confirms that sign-up with the emailed code: the link is approved for the new account. */
100
+ export async function confirmSignUpForLink ({ deviceCode, email, code, api = apiUrl(), fetch: fetchImpl = globalThis.fetch } = {}) {
101
+ return call(fetchImpl, api, 'POST', '/v1/device/signup/confirm', { deviceCode, email, code })
102
+ }
103
+
94
104
  /** One poll: { status: 'pending' } or { status: 'approved', token, profile }. Throws with .status 410 (expired) or 403 (declined). */
95
105
  export async function pollLink ({ identity, deviceCode, api = apiUrl(), fetch: fetchImpl = globalThis.fetch } = {}) {
96
106
  return call(fetchImpl, api, 'POST', '/v1/device/poll', { deviceCode, signature: signDeviceLink(identity, deviceCode) })
package/src/api/audit.js CHANGED
@@ -43,7 +43,6 @@ export function endReasonOf (v, revokedAt) {
43
43
  export function auditTrail ({ visits, actions, revoked = new Map(), appCalls = [] }) {
44
44
  const byVisit = new Map()
45
45
  for (const a of actions) {
46
- if (a.action === 'ai') continue // a minute of AI work: the workspace's AI time, not something the member did
47
46
  if (!byVisit.has(a.visitStartId)) byVisit.set(a.visitStartId, [])
48
47
  byVisit.get(a.visitStartId).push({ at: a.at, action: a.action, target: a.target || '' })
49
48
  }
@@ -5,8 +5,6 @@
5
5
  import { HttpError } from './http.js'
6
6
 
7
7
  export const COMPOSIO_API = 'https://backend.composio.dev/api/v3.1'
8
- // How long the app catalog (1,700+ apps, a few pages from Composio) is kept before it's fetched again.
9
- export const CATALOG_MS = 6 * 60 * 60 * 1000
10
8
 
11
9
  // Composio tags each action with what it does; only reads run without a person's approval.
12
10
  export const READ_TAG = 'readOnlyHint'
@@ -65,17 +63,6 @@ export function composioClient ({ apiKey = '', base = COMPOSIO_API, fetch: fetch
65
63
  noAuth: !!t.no_auth
66
64
  })
67
65
 
68
- /**
69
- * An app in the catalog: appView with its categories and how one connects it (`how`: 'oneclick', Composio's own
70
- * sign-in; 'key', the person's own API key or token; 'none', no sign-in), or how '' when it needs an OAuth app of ours.
71
- */
72
- const catalogView = (t) => {
73
- const a = appView(t)
74
- const how = a.noAuth ? 'none' : a.managed ? 'oneclick' : a.schemes.some((x) => !/^OAUTH[12]$/.test(x)) ? 'key' : ''
75
- const categories = ((t.meta && t.meta.categories) || []).map((c) => ({ id: String(c.id || c.slug || c.name || c), name: String(c.name || c.id || c) })).filter((c) => c.id)
76
- return { ...a, how, categories }
77
- }
78
-
79
66
  /** An action as agents see it: { slug, name, description, app, readOnly, input }. */
80
67
  const toolView = (t) => ({
81
68
  slug: t.slug,
@@ -93,27 +80,6 @@ export function composioClient ({ apiKey = '', base = COMPOSIO_API, fetch: fetch
93
80
  return (r.items || []).filter((t) => !t.deprecated || !t.deprecated.is_deprecated).map(appView)
94
81
  }
95
82
 
96
- // The whole catalog, cached CATALOG_MS: every app that can be connected without an OAuth app of our own (one-click
97
- // sign-in through Composio, the person's own API key or token, or none at all), most used first.
98
- let catalogCache = { at: 0, apps: null, pending: null }
99
- async function catalog () {
100
- if (catalogCache.apps && Date.now() - catalogCache.at < CATALOG_MS) return catalogCache.apps
101
- if (catalogCache.pending) return catalogCache.pending
102
- catalogCache.pending = (async () => {
103
- const items = []
104
- let cursor = ''
105
- do {
106
- const r = await call('GET', `/toolkits${q({ sort_by: 'usage', limit: 1000, cursor })}`)
107
- items.push(...(r.items || []))
108
- cursor = r.next_cursor || ''
109
- } while (cursor && items.length < 5000)
110
- const apps = items.filter((t) => !t.deprecated || !t.deprecated.is_deprecated).map(catalogView).filter((a) => a.how && a.slug !== 'composio')
111
- catalogCache = { at: Date.now(), apps, pending: null }
112
- return apps
113
- })().catch((err) => { catalogCache.pending = null; throw err })
114
- return catalogCache.pending
115
- }
116
-
117
83
  async function toolkit (slug) {
118
84
  return appView(await call('GET', `/toolkits/${encodeURIComponent(slug)}`))
119
85
  }
@@ -124,35 +90,6 @@ export function composioClient ({ apiKey = '', base = COMPOSIO_API, fetch: fetch
124
90
  return (r.items || []).filter((t) => !t.is_deprecated).map(toolView)
125
91
  }
126
92
 
127
- // What an app lets agents do, for its card on the Connections page, cached CATALOG_MS: up to 100 of its actions
128
- // (the ones Composio marks important first, none deprecated), and how many it has in all.
129
- const actionsCache = new Map()
130
- // A description cut to `n` characters at a word, with an ellipsis when it was cut.
131
- const short = (text, n) => text.length <= n ? text : `${text.slice(0, n).replace(/\s+\S*$/, '')}…`
132
- async function appActions (app, { all = false } = {}) {
133
- const key = `${app}|${all ? 'all' : 'top'}`
134
- const hit = actionsCache.get(key)
135
- if (hit && Date.now() - hit.at < CATALOG_MS) return hit.value
136
- // The app shows up to 100; its page on the website (all) every one, a page of 500 at a time.
137
- const items = []
138
- let cursor = ''
139
- let total = 0
140
- do {
141
- const r = await call('GET', `/tools${q({ toolkit_slug: app, limit: all ? 500 : 100, cursor })}`)
142
- items.push(...(r.items || []))
143
- total = r.total_items ?? total
144
- cursor = all ? (r.next_cursor || '') : ''
145
- } while (cursor && items.length < 3000)
146
- const live = items.filter((t) => !t.is_deprecated && !/deprecated/i.test(`${t.name} ${String(t.description || '').slice(0, 40)}`))
147
- // The ones Composio marks important first, then the rest as it lists them.
148
- const important = (t) => ((t.tags || []).includes('important') ? 0 : 1)
149
- const actions = live.map((t, i) => ({ t, i })).sort((x, y) => important(x.t) - important(y.t) || x.i - y.i).map(({ t }) => toolView(t))
150
- .map((t) => ({ slug: t.slug, name: t.name, description: short(t.description.split(/(?<=\.)\s/)[0], 240), readOnly: t.readOnly }))
151
- const value = { actions, total: Number(total) || actions.length }
152
- actionsCache.set(key, { at: Date.now(), value })
153
- return value
154
- }
155
-
156
93
  async function tool (slug) {
157
94
  return toolView(await call('GET', `/tools/${encodeURIComponent(slug)}`))
158
95
  }
@@ -198,5 +135,5 @@ export function composioClient ({ apiKey = '', base = COMPOSIO_API, fetch: fetch
198
135
  return { ok: r.successful !== false && !r.error, data: r.data ?? null, error: r.error || null }
199
136
  }
200
137
 
201
- return { on: !!apiKey, toolkits, catalog, toolkit, tools, tool, appActions, link, account, remove, execute }
138
+ return { on: !!apiKey, toolkits, toolkit, tools, tool, link, account, remove, execute }
202
139
  }
@@ -33,7 +33,7 @@ export function createMemoryStore ({ now = Date.now } = {}) {
33
33
  const settings = new Map() // the API's own settings (a webhook secret it made), key -> value
34
34
  const leases = new Map() // key -> { room, holder, generation, heartbeatAt } (relay_leases)
35
35
  const authSessions = new Map()
36
- const users = new Map(); const orgs = new Map(); const roles = new Map(); const members = new Map()
36
+ const users = new Map(); const signUps = new Map(); const orgs = new Map(); const roles = new Map(); const members = new Map()
37
37
  const teams = new Map(); const teamMembers = new Map(); const invites = new Map(); const requests = new Map()
38
38
  const agentInvites = new Map(); const keyRows = new Map(); const appKeys = new Map()
39
39
  const appKeyUses = new Map() // "key id\nday" -> requests that day (agent_app_key_uses)
@@ -62,7 +62,6 @@ export function createMemoryStore ({ now = Date.now } = {}) {
62
62
  const secretTickets = new Map(); const secretRuns = new Map(); const secretAsks = new Map(); const secretUses = []
63
63
  // App connections (20261112000000_app_connections.sql).
64
64
  const appConnections = new Map(); const appCalls = new Map()
65
- const workspaceLinks = new Map() // 20261112100000_workspace_home.sql
66
65
  const scopeKey = (scopeType, scopeId) => `${scopeType}\n${scopeId}`
67
66
  // A secret as the API's routes see it: never its sealed value (secretSealed reads that, for the vault).
68
67
  const secretMeta = (r) => { if (!r) return null; const { sealedValue, ...rest } = copy(r); return rest }
@@ -143,6 +142,22 @@ export function createMemoryStore ({ now = Date.now } = {}) {
143
142
  profiles.set(userId, { id: userId, name: name || email.split('@')[0] || 'You', color: null, tool: null, kind })
144
143
  users.set(userId, { email, confirmed })
145
144
  },
145
+ // Signing up in the app (POST /v1/device/signup): an account waiting on the code emailed to it.
146
+ async startSignUp ({ email, name }) {
147
+ const known = [...users.entries()].find(([, u]) => u.email === email)
148
+ if (known && known[1].confirmed) throw Object.assign(new Error('taken'), { taken: true })
149
+ const code = String(crypto.randomInt(0, 1e6)).padStart(6, '0')
150
+ signUps.set(email, { code, name, userId: known ? known[0] : uuid() })
151
+ return { code }
152
+ },
153
+ // The new account's id once `code` is right, or null.
154
+ async confirmSignUp ({ email, code }) {
155
+ const s = signUps.get(email)
156
+ if (!s || s.code !== code) return null
157
+ signUps.delete(email)
158
+ this.addUser(s.userId, { name: s.name, email, confirmed: true })
159
+ return s.userId
160
+ },
146
161
  async createLink (l) {
147
162
  const row = { id: uuid(), status: 'pending', userId: null, deviceId: null, createdAt: now(), ...l }
148
163
  links.set(row.id, row); return { ...row }
@@ -580,12 +595,6 @@ export function createMemoryStore ({ now = Date.now } = {}) {
580
595
  },
581
596
  // Mirrors prune_activity.
582
597
  // What was done in a session in [from, to), oldest first, at most `limit` (actions_in_room).
583
- async aiMinutes (rooms, since) {
584
- return all(actions, (a) => a.action === 'ai' && rooms.includes(a.room) && a.at >= since).sort((a, b) => a.at - b.at).map((a) => ({ room: a.room, account: a.account, at: a.at }))
585
- },
586
- async listWorkspaceLinks (workspaceId) { return all(workspaceLinks, (l) => l.workspaceId === workspaceId).sort((a, b) => a.createdAt - b.createdAt).map(copy) },
587
- async addWorkspaceLink (l) { const row = { id: uuid(), room: null, note: '', ...copy(l), createdAt: now() }; workspaceLinks.set(row.id, row); return copy(row) },
588
- async deleteWorkspaceLink (workspaceId, id) { const l = workspaceLinks.get(id); if (l && l.workspaceId === workspaceId) workspaceLinks.delete(id) },
589
598
  async actionsInRoom (room, { from, to, limit }) {
590
599
  return all(actions, (a) => a.room === room && a.at >= from && a.at < to)
591
600
  .sort((a, b) => a.at - b.at).slice(0, limit).map(copy) // stable: ties keep arrival order
@@ -25,52 +25,6 @@ const MAX_KEPT = 16_000
25
25
  const MAX_ARGS = 32_000
26
26
 
27
27
  /** An action's arguments in a line: what people read on the approval card. */
28
- // The catalog's tabs (Daniel, 2026-11-12: laid out as Kylon's): Composio's categories grouped. An app is in every
29
- // group one of its categories is in; Other has the apps in none; Recommended is every app, most used first.
30
- export const APP_GROUPS = [
31
- { id: 'email', name: 'Email & Calendar', cats: ['email', 'calendar', 'scheduling-&-booking', 'email-newsletters', 'transactional-email', 'drip-emails', 'video-conferencing', 'ai-meeting-assistants', 'webinars', 'event-management'] },
32
- { id: 'code', name: 'Projects & Code', cats: ['developer-tools', 'project-management', 'task-management', 'product-management', 'server-monitoring', 'it-operations', 'databases', 'app-builder', 'website-&-app-building', 'website-builders', 'security-&-identity-tools', 'time-tracking-software'] },
33
- { id: 'marketing', name: 'Marketing & Growth', cats: ['marketing-automation', 'marketing', 'analytics', 'social-media-marketing', 'social-media-accounts', 'ads-&-conversion', 'seo-&-ai-visibility', 'url-shortener', 'business-intelligence', 'dashboards', 'reviews', 'forms-&-surveys', 'customer-appreciation', 'social-&-creator-data', 'call-tracking'] },
34
- { id: 'business', name: 'Business Ops', cats: ['crm', 'sales-&-crm', 'ecommerce', 'commerce', 'accounting', 'payment-processing', 'customer-support', 'support', 'contact-management', 'human-resources', 'hr-talent-&-recruitment', 'proposal-&-invoice-management', 'signatures', 'taxes', 'fundraising', 'ai-sales-tools', 'people-&-contact-data', 'company-data', 'legal-&-public-records', 'phone-&-sms', 'communication', 'team-chat', 'notifications'] },
35
- { id: 'knowledge', name: 'Knowledge', cats: ['documents', 'productivity', 'team-collaboration', 'notes', 'file-management-&-storage', 'spreadsheets', 'content-&-files', 'documents-&-ocr', 'bookmark-managers', 'web-search-&-research', 'education', 'online-courses', 'transcription', 'ai-document-extraction'] }
36
- ]
37
- /** The names of the tabs an app is under, for its page on the website. */
38
- export const groupNames = (a) => groupsOf(a).map((id) => (APP_GROUPS.find((g) => g.id === id) || { name: 'Other' }).name)
39
- const groupsOf = (a) => {
40
- const ids = a.categories.map((c) => c.id)
41
- const in_ = APP_GROUPS.filter((g) => g.cats.some((c) => ids.includes(c))).map((g) => g.id)
42
- return in_.length ? in_ : ['other']
43
- }
44
-
45
- /**
46
- * A page of the catalog for the Connections page: { apps, total, all, groups }. `group`: one of APP_GROUPS (or
47
- * 'other'), '' for every app. A search matches names first, then descriptions and categories, across every group.
48
- * `groups`: each tab with how many apps it has.
49
- */
50
- export function pickApps (all, { search = '', group = '', offset = 0, limit = 48 }) {
51
- const words = String(search).toLowerCase().trim().slice(0, 100).split(/\s+/).filter(Boolean)
52
- let list = group && !words.length ? all.filter((a) => groupsOf(a).includes(group)) : all
53
- if (words.length) {
54
- const score = (a) => {
55
- const name = a.name.toLowerCase()
56
- const rest = `${a.slug} ${a.description} ${a.categories.map((c) => c.name).join(' ')}`.toLowerCase()
57
- if (!words.every((w) => name.includes(w) || rest.includes(w))) return 0
58
- return words.every((w) => name.includes(w)) ? (name.startsWith(words[0]) ? 3 : 2) : 1
59
- }
60
- list = list.map((a, i) => ({ a, s: score(a), i })).filter((x) => x.s).sort((x, y) => y.s - x.s || x.i - y.i).map((x) => x.a)
61
- }
62
- const n = new Map()
63
- for (const a of all) for (const g of groupsOf(a)) n.set(g, (n.get(g) || 0) + 1)
64
- const from = Math.max(0, offset)
65
- const size = Math.min(200, Math.max(1, limit))
66
- return {
67
- apps: list.slice(from, from + size),
68
- total: list.length,
69
- all: all.length,
70
- groups: [...APP_GROUPS.map((g) => ({ id: g.id, name: g.name, n: n.get(g.id) || 0 })), { id: 'other', name: 'Other', n: n.get('other') || 0 }]
71
- }
72
- }
73
-
74
28
  export function argsLine (args, max = 400) {
75
29
  const s = JSON.stringify(args || {})
76
30
  return s.length > max ? `${s.slice(0, max)}…` : s
@@ -221,38 +175,7 @@ export function connectionRoutes (ctx) {
221
175
  ['GET', /^\/v1\/connections\/apps$/, async (req, body, params, url) => {
222
176
  await whoCalls(req)
223
177
  const u = url || new URL(req.url, 'http://x')
224
- return pickApps(await composio.catalog(), {
225
- search: u.searchParams.get('search') || '',
226
- group: u.searchParams.get('group') || '',
227
- offset: Number(u.searchParams.get('offset')) || 0,
228
- limit: Number(u.searchParams.get('limit')) || 48
229
- })
230
- }],
231
-
232
- // The website's integrations pages (heyquilt.com/integrations): the catalog and one app with every action. Public,
233
- // no sign-in: it is Composio's public catalog, without anyone's connections.
234
- ['GET', /^\/v1\/integrations$/, async (req, body, params, url) => {
235
- const u = url || new URL(req.url, 'http://x')
236
- return pickApps(await composio.catalog(), {
237
- search: u.searchParams.get('search') || '',
238
- group: u.searchParams.get('group') || '',
239
- offset: Number(u.searchParams.get('offset')) || 0,
240
- limit: Number(u.searchParams.get('limit')) || 48
241
- })
242
- }],
243
- ['GET', /^\/v1\/integrations\/([a-z0-9_-]{1,80})$/, async (req, body, params) => {
244
- const app = (await composio.catalog()).find((a) => a.slug === params[0])
245
- if (!app) throw new HttpError(404, 'No such app.')
246
- return { app, groups: groupNames(app), ...(await composio.appActions(app.slug, { all: true })) }
247
- }],
248
-
249
- // One app's card opened on the Connections page: what it is, how one signs in, and what agents can do with it.
250
- ['GET', /^\/v1\/connections\/apps\/([a-z0-9_-]{1,80})$/, async (req, body, params) => {
251
- await whoCalls(req)
252
- const slug = params[0]
253
- const app = (await composio.catalog()).find((a) => a.slug === slug)
254
- if (!app) throw new HttpError(404, 'No such app.')
255
- return { app, ...(await composio.appActions(slug)) }
178
+ return { apps: await composio.toolkits({ search: u.searchParams.get('search') || '', limit: Number(u.searchParams.get('limit')) || 60 }) }
256
179
  }],
257
180
 
258
181
  // Composio sends the browser back here once someone signed in (or gave up).
@@ -1,6 +1,6 @@
1
1
  // Workspaces: a container owned by a person or an org, holding sessions and members.
2
2
  // Behind the QUILT_WORKSPACES flag (startApi({ workspaces })): off, every route answers 404.
3
- import { HttpError, cleanName, needId } from '../http.js'
3
+ import { HttpError, cleanName } from '../http.js'
4
4
  import { orgAccess } from '../org-access.js'
5
5
  import { workspaceAccess, cleanColor, cleanDescription, cleanAccess, autoColor } from '../workspace-access.js'
6
6
  import { workspaceReach, canSeeFiles } from '../workspace-reach.js'
@@ -14,10 +14,6 @@ const ROOM = /^[A-Za-z0-9_-]{1,64}$/
14
14
  const ACCOUNT = /^(person|agent):[A-Za-z0-9_-]{1,64}$/
15
15
  const OPEN_MS = 10 * 60 * 1000
16
16
 
17
- const DAY_MS = 24 * 60 * 60 * 1000
18
- const HOUR_MS = 60 * 60 * 1000
19
- const linkView = (l) => ({ id: l.id, name: l.name, url: l.url, room: l.room || null, note: l.note || '', by: l.createdBy, at: l.createdAt })
20
-
21
17
  export function workspaceRoutes (ctx) {
22
18
  const { store, now, files: fileStore, workspaces = false, log = () => {}, policyChanged = null } = ctx
23
19
  const { caller, grantsIn, reach } = workspaceReach(ctx)
@@ -137,7 +133,7 @@ export function workspaceRoutes (ctx) {
137
133
  const sessions = (await store.listWorkspaceSessions(ws.id)).map((s) => sessionView(s, t))
138
134
  const files = canSeeFiles(access) ? await listedFiles(store, await store.listWorkspaceFiles(ws.id)) : []
139
135
  const agents = await workspaceAgents(store, ws, { admin: access.admin })
140
- return { workspace: ws, access, canDelete, owner, members, agents, sessions, files, usage: await usageView(store, ws, ctx), links: (await store.listWorkspaceLinks(ws.id)).map(linkView) }
136
+ return { workspace: ws, access, canDelete, owner, members, agents, sessions, files, usage: await usageView(store, ws, ctx) }
141
137
  }],
142
138
 
143
139
  ['PATCH', /^\/v1\/workspaces\/([^/]+)$/, async (req, body, [id]) => {
@@ -230,43 +226,7 @@ export function workspaceRoutes (ctx) {
230
226
  await store.setSessionWorkspace(room, null, { linkedBy: null, at: now() })
231
227
  if (policyChanged) policyChanged(room) // the workspace's rule no longer covers it
232
228
  return { ok: true }
233
- }],
234
-
235
- // The workspace's home (plans/app-redesign.md): AI time per session, by the hour (each 'ai' action is a
236
- // minute an AI worked: presence.js), for its charts; the app adds merges from Seam.
237
- ['GET', /^\/v1\/workspaces\/([^/]+)\/insights$/, async (req, body, [id], url) => {
238
- const { ws } = await reach(req, id)
239
- const days = Math.min(31, Math.max(1, Number((url || new URL(req.url, 'http://x')).searchParams.get('days')) || 14))
240
- const t = now()
241
- const sessions = await store.listWorkspaceSessions(ws.id)
242
- const minutes = await store.aiMinutes(sessions.map((s) => s.room), t - days * DAY_MS)
243
- const hours = new Map()
244
- for (const m of minutes) {
245
- const k = `${m.room}\n${Math.floor(m.at / HOUR_MS) * HOUR_MS}`
246
- hours.set(k, (hours.get(k) || 0) + 1)
247
- }
248
- return { days, sessions: sessions.map((s) => ({ room: s.room, name: s.name || '' })), aiHours: [...hours].map(([k, n]) => { const [room, at] = k.split('\n'); return { room, at: Number(at), minutes: n } }) }
249
- }],
250
-
251
- // Previews: the links a workspace keeps at hand (production, staging, a square's preview, a shared localhost).
252
- ['POST', /^\/v1\/workspaces\/([^/]+)\/links$/, async (req, body, [id]) => {
253
- const r = await reach(req, id)
254
- if (r.access.access !== 'edit' && !r.access.admin) throw new HttpError(403, 'Only people who can edit the workspace add its links.')
255
- const name = String(body.name || '').trim().slice(0, 80)
256
- const link = String(body.url || '').trim()
257
- if (!name) throw new HttpError(400, 'Give the link a name.')
258
- if (!/^https?:\/\/\S{3,490}$/.test(link)) throw new HttpError(400, 'That is not a web address (http:// or https://).')
259
- const room = typeof body.room === 'string' && body.room ? body.room.slice(0, 64) : null
260
- if (room && !(await store.listWorkspaceSessions(r.ws.id)).some((s) => s.room === room)) throw new HttpError(400, 'That session is not in this workspace.')
261
- const who = await caller(req)
262
- return linkView(await store.addWorkspaceLink({ workspaceId: r.ws.id, room, name, url: link, note: String(body.note || '').slice(0, 200), createdBy: who.account }))
263
- }],
264
- ['DELETE', /^\/v1\/workspaces\/([^/]+)\/links\/([^/]+)$/, async (req, body, [id, linkId]) => {
265
- const r = await reach(req, id)
266
- if (r.access.access !== 'edit' && !r.access.admin) throw new HttpError(403, 'Only people who can edit the workspace remove its links.')
267
- await store.deleteWorkspaceLink(r.ws.id, needId(linkId, 'link'))
268
- return { ok: true }
269
- }],
229
+ }]
270
230
  ]
271
231
  return routes.map(([method, pattern, fn, ...options]) => [method, pattern, gated(fn), ...options])
272
232
  }
package/src/api/server.js CHANGED
@@ -65,6 +65,8 @@ const COLLECT_GRACE_MS = 5 * 60 * 1000
65
65
  // A linked computer signing back in with its key: how far its clock may be from ours.
66
66
  const RESUME_WINDOW_MS = 10 * 60 * 1000
67
67
  const POLL_INTERVAL_S = 3
68
+ // Signing up in the app: the shortest password it takes (the website's Supabase minimum too).
69
+ const SIGNUP_MIN_PASSWORD = 8
68
70
  const MAX_BODY = 16 * 1024
69
71
  // A hosted agent's MCP request (a whole file, at most) and how long it may take on the relay.
70
72
  const MAX_MCP_BODY = 2 * 1024 * 1024
@@ -95,6 +97,34 @@ export function startApi ({ port = 0, host = '127.0.0.1', store, verifyUser, sit
95
97
  return u
96
98
  }
97
99
 
100
+ // A link claimed for approval: this computer becomes one of `userId`'s, and the app collects its token.
101
+ async function approveClaimed (link, userId) {
102
+ let device
103
+ try {
104
+ device = await store.upsertDevice({ userId, name: link.deviceName, platform: link.platform, publicKey: link.publicKey })
105
+ } catch (err) {
106
+ // Put the link back so the person can retry rather than being stuck mid-approval.
107
+ await store.updateLink(link.id, { status: 'pending' }).catch(() => {})
108
+ throw err
109
+ }
110
+ await store.updateLink(link.id, { status: 'approved', userId, deviceId: device.id })
111
+ return { status: 'approved', device: { id: device.id, name: device.name } }
112
+ }
113
+
114
+ // The link an app is waiting on, by its device code (only that app has it): pending and not expired.
115
+ async function waitingLink (deviceCode) {
116
+ const link = deviceCode ? await store.linkByDeviceCode(hashToken(String(deviceCode))) : null
117
+ if (!link) throw new HttpError(404, 'unknown device code')
118
+ if (link.status !== 'pending' || link.expiresAt < now()) throw new HttpError(410, 'This sign-up timed out. Start again.')
119
+ return link
120
+ }
121
+
122
+ function signUpEmail (raw) {
123
+ const email = String(raw || '').trim().toLowerCase()
124
+ if (!email || email.length > 254 || !/^[^\s@,;<>"()\\]+@[^\s@,;<>"()\\]+\.[^\s@,;<>"()\\]+$/.test(email)) throw new HttpError(400, "That email doesn't look right.")
125
+ return email
126
+ }
127
+
98
128
  async function device (req) {
99
129
  const d = await store.deviceByToken(hashToken(bearer(req)))
100
130
  if (!d) throw new HttpError(401, 'this computer is signed out')
@@ -297,16 +327,46 @@ export function startApi ({ port = 0, host = '127.0.0.1', store, verifyUser, sit
297
327
  // Claim the link first, so two approvals racing on one code can't both make a device.
298
328
  if (!await store.claimLink(link.id, 'pending', 'approving')) throw new HttpError(410, 'this code has expired or was already used')
299
329
  if (!body.approve) { await store.updateLink(link.id, { status: 'denied', userId: u.userId }); return { status: 'denied' } }
300
- let device
330
+ return approveClaimed(link, u.userId)
331
+ }],
332
+
333
+ // Signing up in the app, no browser: the app that is waiting on a link (it holds the device
334
+ // code) makes the account here, Quilt emails a 6-digit code to the address, and confirming
335
+ // that code approves the link for the new account, so this computer is signed in to it.
336
+ ['POST', /^\/v1\/device\/signup$/, async (req, body) => {
337
+ limitStarts(req)
338
+ await waitingLink(body.deviceCode)
339
+ const email = signUpEmail(body.email)
340
+ const password = String(body.password || '')
341
+ if (password.length < SIGNUP_MIN_PASSWORD) throw new HttpError(400, `Use a password of at least ${SIGNUP_MIN_PASSWORD} characters.`)
342
+ if (password.length > 72) throw new HttpError(400, 'Use a password of at most 72 characters.')
343
+ const name = String(body.name || '').trim().slice(0, 60)
344
+ let code
301
345
  try {
302
- device = await store.upsertDevice({ userId: u.userId, name: link.deviceName, platform: link.platform, publicKey: link.publicKey })
346
+ ({ code } = await store.startSignUp({ email, password, name }))
303
347
  } catch (err) {
304
- // Put the link back so the person can retry rather than being stuck mid-approval.
305
- await store.updateLink(link.id, { status: 'pending' }).catch(() => {})
348
+ if (err.taken) throw new HttpError(409, 'That email already has a Quilt account. Sign in instead.')
349
+ if (err.weak) throw new HttpError(400, 'Choose a stronger password.')
306
350
  throw err
307
351
  }
308
- await store.updateLink(link.id, { status: 'approved', userId: u.userId, deviceId: device.id })
309
- return { status: 'approved', device: { id: device.id, name: device.name } }
352
+ await mailer.send({
353
+ to: email,
354
+ subject: `${code} is your Quilt code`,
355
+ text: `Your code to finish signing up for Quilt is:\n\n${code}\n\nType it into the Quilt app within 10 minutes.\n\nIf you didn't sign up for Quilt, you can ignore this email.\n`
356
+ })
357
+ return { status: 'code-sent', email }
358
+ }],
359
+
360
+ ['POST', /^\/v1\/device\/signup\/confirm$/, async (req, body) => {
361
+ limitStarts(req)
362
+ const link = await waitingLink(body.deviceCode)
363
+ const email = signUpEmail(body.email)
364
+ const code = String(body.code || '').replace(/\s+/g, '')
365
+ if (!/^\d{6}$/.test(code)) throw new HttpError(400, 'Enter the 6-digit code from the email.')
366
+ const userId = await store.confirmSignUp({ email, code })
367
+ if (!userId) throw new HttpError(400, "That code isn't right, or it has expired. Check the email, or send a new code.")
368
+ if (!await store.claimLink(link.id, 'pending', 'approving')) throw new HttpError(410, 'this code has expired or was already used')
369
+ return approveClaimed(link, userId)
310
370
  }],
311
371
 
312
372
  ['GET', /^\/v1\/me$/, async (req) => {
@@ -51,8 +51,6 @@ const SECRET_TICKET = 'id, token_hash, scope_type, scope_id, entries, created_by
51
51
  const SECRET_RUN = 'id, token_hash, room, account, kind, label, created_at, expires_at, revoked_at'
52
52
  const SECRET_ASK = 'run_id, secret_id, name, state, asked_at, answered_at'
53
53
  const SECRET_USE = 'id, secret_id, run_id, room, account, upstream, at'
54
- // A workspace's links (20261112100000_workspace_home.sql).
55
- const WORKSPACE_LINK = 'id, workspace_id, room, name, url, note, created_by, created_at'
56
54
  // App connections (20261112000000_app_connections.sql).
57
55
  const APP_CONNECTION = 'id, scope_type, scope_id, app, app_name, logo, composio_id, status, who, created_by, created_at, updated_at'
58
56
  const APP_CALL = 'id, room, cap_key, connection_id, app, tool, args, read_only, state, account, decided_by, result, error, created_at, decided_at, ran_at'
@@ -72,7 +70,8 @@ const PAGE = 1000
72
70
  export const rowFrom = (row) => row && Object.fromEntries(Object.entries(toCamel(row)).map(([k, v]) => [k, /At$/.test(k) ? ms(v) : v]))
73
71
 
74
72
  // `client` lets tests pass a stand-in for the supabase client.
75
- export function createSupabaseStore ({ url, serviceKey, client }) {
73
+ export function createSupabaseStore ({ url, serviceKey, client, fetch: authFetchImpl = globalThis.fetch }) {
74
+ const authFetch = (route, init) => authFetchImpl(`${String(url).replace(/\/+$/, '')}${route}`, init)
76
75
  const db = client || createClient(url, serviceKey, { auth: { persistSession: false, autoRefreshToken: false } })
77
76
  const one = async (q) => { const { data, error } = await q; if (error) throw error; return data }
78
77
  // A lease call (relay_leases), or the git_sync_leases one while the relay_leases migration is not applied (PGRST202: no such function).
@@ -375,6 +374,28 @@ export function createSupabaseStore ({ url, serviceKey, client }) {
375
374
  throw error
376
375
  },
377
376
 
377
+ // Signing up in the app (POST /v1/device/signup): an unconfirmed account and the 6-digit code
378
+ // that confirms it. generateLink makes both without sending anything: the API emails the code.
379
+ async startSignUp ({ email, password, name }) {
380
+ const { data, error } = await db.auth.admin.generateLink({ type: 'signup', email, password, options: { data: { name } } })
381
+ if (error) {
382
+ if (error.code === 'email_exists' || error.code === 'user_already_exists' || /already (been )?registered/i.test(error.message)) throw Object.assign(new Error('taken'), { taken: true })
383
+ if (error.code === 'weak_password') throw Object.assign(new Error('weak password'), { weak: true })
384
+ throw error
385
+ }
386
+ const code = data?.properties?.email_otp
387
+ if (!code) throw new Error('Supabase gave no sign-up code')
388
+ return { code }
389
+ },
390
+ // Confirms the account with its code: its id, or null when the code is wrong or expired. Asked of
391
+ // Supabase Auth directly, so the session it answers with never becomes this client's.
392
+ async confirmSignUp ({ email, code }) {
393
+ const res = await authFetch('/auth/v1/verify', { method: 'POST', headers: { apikey: serviceKey, 'content-type': 'application/json' }, body: JSON.stringify({ type: 'signup', email, token: code }) })
394
+ if (!res.ok) return null
395
+ const body = await res.json().catch(() => null)
396
+ return body?.user?.id || null
397
+ },
398
+
378
399
  // The address a person signs in with, and whether they've confirmed it.
379
400
  async userEmail (userId) {
380
401
  const { data, error } = await db.auth.admin.getUserById(userId)
@@ -424,15 +445,6 @@ export function createSupabaseStore ({ url, serviceKey, client }) {
424
445
  // `at` isn't a `*At` column, so it's turned into epoch ms here.
425
446
  return (await pages(() => db.rpc('actions_in_room', { p_room: room, p_from: ts(from), p_to: ts(to), p_limit: limit }))).map((r) => ({ ...rowFrom(r), at: ms(r.at) }))
426
447
  },
427
- /** Each minute an AI worked in these rooms since `since` ('ai' actions): [{ room, account, at }]. */
428
- async aiMinutes (rooms, since) {
429
- if (!rooms.length) return []
430
- return (await pages(() => db.from('visit_actions').select('room, account, at').eq('action', 'ai').in('room', rooms).gte('at', ts(since)).order('at'))).map((r) => ({ room: r.room, account: r.account, at: ms(r.at) }))
431
- },
432
- // The workspace's links (previews), 20261112100000_workspace_home.sql.
433
- async listWorkspaceLinks (workspaceId) { return (await one(db.from('workspace_links').select(WORKSPACE_LINK).eq('workspace_id', workspaceId).order('created_at'))).map(rowFrom) },
434
- async addWorkspaceLink (l) { return rowFrom(await one(db.from('workspace_links').insert(toSnake(l)).select(WORKSPACE_LINK).single())) },
435
- async deleteWorkspaceLink (workspaceId, id) { await one(db.from('workspace_links').delete().eq('workspace_id', workspaceId).eq('id', id)) },
436
448
  async sessionByRoom (room) { return rowFrom(await one(db.from('relay_sessions').select(RELAY_SESSION).eq('room', room).maybeSingle())) },
437
449
  async visitsInRooms (rooms) {
438
450
  if (!rooms.length) return []
package/src/control.js CHANGED
@@ -82,27 +82,6 @@ export async function startControl (session, extras = {}) {
82
82
  }
83
83
  // The app's square panel (ui-server.js) commits and merges through the same tools, as the same member.
84
84
  session.seamTool = seamTool
85
- // GitHub for Session settings: Seam connects to GitHub (through the Seam app on GitHub), never Quilt. What the
86
- // app reaches and where this quilt's main goes; connecting exports main to a repository it reaches after each merge.
87
- session.seamGithub = async (b = {}) => {
88
- const q = session.quilt
89
- if (!q || !q.id) return { quilt: false }
90
- const { client } = await seam.client(q.id, [])
91
- const now = await client.exportStatus(q.id).catch(() => null)
92
- if (b.repo) await client.setExport(q.id, { target: `https://github.com/${b.repo}.git`, credential: `github.${b.installation}`, enabled: true })
93
- else if (b.disconnect && now && now.target) await client.setExport(q.id, { target: now.target, enabled: false })
94
- const [github, exp] = await Promise.all([client.github(), b.repo || b.disconnect ? client.exportStatus(q.id).catch(() => null) : now])
95
- return { quilt: true, github, export: exp && exp.target ? { target: exp.target, enabled: exp.enabled !== false, status: exp.status || null } : null }
96
- }
97
- // The workspace's home: this quilt's merges onto main (each patch on main is one), newest first, as times.
98
- session.seamMerges = async ({ since = 0 } = {}) => {
99
- const q = session.quilt
100
- if (!q || !q.id) return []
101
- const { client } = await seam.client(q.id, [])
102
- const r = await client.linePatches(q.id, 'main', { limit: 500 })
103
- const list = Array.isArray(r) ? r : (r && (r.patches || r.items)) || []
104
- return list.map((p) => Date.parse(p.at || p.created_at || p.merged_at || p.createdAt || '') || 0).filter((t) => t >= since)
105
- }
106
85
  const routes = {
107
86
  'GET /status': (b) => {
108
87
  // To one of the AI sessions working through this app, "you" is that session (persona.js).
package/src/presence.js CHANGED
@@ -25,8 +25,7 @@ const SYNC_MS = 1000
25
25
  export const ACT_COALESCE_MS = 60 * 1000
26
26
  /** Why a visit ended. The accounts API turns an agent's `pass_expired` or `idle` into `revoked` when its keys were revoked first. */
27
27
  export const END_REASONS = ['left', 'disconnected', 'removed', 'pass_expired', 'session_ended', 'relay_restart', 'idle', 'replaced', 'needs_update']
28
- // 'ai': a minute in which the member's AI was working (the workspace's AI time; not shown in the audit trail).
29
- export const ACTIONS = ['created', 'edited', 'deleted', 'claimed', 'released', 'requested', 'handed_off', 'withdrew', 'messaged', 'task', 'tool', 'ai']
28
+ export const ACTIONS = ['created', 'edited', 'deleted', 'claimed', 'released', 'requested', 'handed_off', 'withdrew', 'messaged', 'task', 'tool']
30
29
  const MAX_TARGET = 300
31
30
  const SEND_TIMEOUT_MS = 15 * 1000
32
31
  const CLOSE_TIMEOUT_MS = 5 * 1000
package/src/server.js CHANGED
@@ -660,20 +660,6 @@ class Room {
660
660
  }
661
661
 
662
662
  /** The audit trail, for a member by id: the visit of their connection here, or of the hosted agent. */
663
- /** Every member whose AI is working now: an 'ai' minute on their visit (presence.js coalesces it to one a minute). */
664
- noteAiWork () {
665
- if (!this.presence) return
666
- const states = this.awareness.getStates()
667
- for (const [ws, ids] of this.conns) {
668
- if (!ws.visit || !ws.pass) continue
669
- for (const id of ids) {
670
- const st = states.get(id)
671
- const ag = st && st.agent
672
- if (ag && ag.sharing !== false && (ag.status === 'working' || (st.work && st.work.state === 'working'))) { this.presence.act(ws.visit, 'ai', String(ag.tool || st.tool || '').slice(0, 40)); break }
673
- }
674
- }
675
- }
676
-
677
663
  audit (id, action, target) {
678
664
  if (!this.presence || !id) return
679
665
  for (const ws of this.conns.keys()) {
@@ -4999,7 +4985,7 @@ export function startServer ({ port = 4321, host = '0.0.0.0', dataDir = null, lo
4999
4985
  ws.isAlive = false
5000
4986
  ws.ping()
5001
4987
  }
5002
- for (const room of rooms.values()) if (!room.ended) { room.sweepClaims(); room.sweepBoxes(); room.pruneBranches(); room.noteAiWork() }
4988
+ for (const room of rooms.values()) if (!room.ended) { room.sweepClaims(); room.sweepBoxes(); room.pruneBranches() }
5003
4989
  if (sweepHosted) sweepHosted()
5004
4990
  }, 30000)
5005
4991