heyquilt 0.3.167 → 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,11 @@ 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
+
14
19
  ## 0.3.167 — 2026-11-13
15
20
 
16
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.167",
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) })
@@ -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)
@@ -142,6 +142,22 @@ export function createMemoryStore ({ now = Date.now } = {}) {
142
142
  profiles.set(userId, { id: userId, name: name || email.split('@')[0] || 'You', color: null, tool: null, kind })
143
143
  users.set(userId, { email, confirmed })
144
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
+ },
145
161
  async createLink (l) {
146
162
  const row = { id: uuid(), status: 'pending', userId: null, deviceId: null, createdAt: now(), ...l }
147
163
  links.set(row.id, row); return { ...row }
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) => {
@@ -70,7 +70,8 @@ const PAGE = 1000
70
70
  export const rowFrom = (row) => row && Object.fromEntries(Object.entries(toCamel(row)).map(([k, v]) => [k, /At$/.test(k) ? ms(v) : v]))
71
71
 
72
72
  // `client` lets tests pass a stand-in for the supabase client.
73
- 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)
74
75
  const db = client || createClient(url, serviceKey, { auth: { persistSession: false, autoRefreshToken: false } })
75
76
  const one = async (q) => { const { data, error } = await q; if (error) throw error; return data }
76
77
  // A lease call (relay_leases), or the git_sync_leases one while the relay_leases migration is not applied (PGRST202: no such function).
@@ -373,6 +374,28 @@ export function createSupabaseStore ({ url, serviceKey, client }) {
373
374
  throw error
374
375
  },
375
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
+
376
399
  // The address a person signs in with, and whether they've confirmed it.
377
400
  async userEmail (userId) {
378
401
  const { data, error } = await db.auth.admin.getUserById(userId)
package/src/ui/app.css CHANGED
@@ -2990,3 +2990,6 @@ body.has-asks .ws { height: calc(100vh - var(--update-bar, 0px) - var(--asks-bar
2990
2990
  .task-nopickup:hover, .task-nopickup:focus-visible { background: color-mix(in srgb, var(--warn) 20%, transparent); outline: none; }
2991
2991
  /* A cloud AI's own name in chat, then whose AI it is ("Juniper Daniel's AI"). */
2992
2992
  .msg .head .ai-tag { font-size: 10.5px; padding: 0 7px; }
2993
+ .signup-form { width: 100%; text-align: left; }
2994
+ .signup-form .signin-btn { margin-top: 4px; }
2995
+ .signup-code { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; }
package/src/ui/app.js CHANGED
@@ -73,6 +73,8 @@ async function boot () {
73
73
 
74
74
  /** Back to the sign-in screen: after Sign out, or when the API turned this computer away. */
75
75
  export function signedOutNow (message = '') {
76
+ // Already on the sign-in screen: leave it alone, or a stray 401 would wipe the code being approved.
77
+ if (!state.loaded && document.querySelector('#app .signin')) return
76
78
  sessionUnmount() // stops an open session view's timers and bindings
77
79
  clearInterval(state.pollTimer)
78
80
  state.pollTimer = null
package/src/ui/secrets.js CHANGED
@@ -274,7 +274,9 @@ export function watchSecretAsks () {
274
274
  drawAsks()
275
275
  wait = asks.length ? 3000 : 250
276
276
  } catch (err) {
277
- // Secrets off on the server, or signed out: look again much later.
277
+ // Signed out: stop; signing back in starts it again (boot in app.js).
278
+ if (err.signedOut) { asking = false; return }
279
+ // Secrets off on the server: look again much later.
278
280
  wait = err.status === 503 || err.status === 404 ? 10 * 60 * 1000 : 15000
279
281
  }
280
282
  setTimeout(loop, wait)
package/src/ui/signin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // The sign-in screen. Until this computer is linked to a heyquilt.com account the
2
- // app shows only this. Signing in opens the website, where you approve this computer.
2
+ // app shows only this. Signing in opens the website, where you approve this computer;
3
+ // signing up happens right here, confirmed by a code emailed to you, and links this computer.
3
4
  import { $, esc, api, loadingNote } from './common.js'
4
5
  import { quiltMark } from './mark.js'
5
6
 
@@ -23,10 +24,82 @@ export function renderSignIn (message = '', onSignedIn = () => window.location.r
23
24
  <p class="hint">New to Quilt? <a href="${SIGNUP}" id="signin-new" target="_blank" rel="noopener">Create an account</a></p>
24
25
  <p class="error" id="signin-error"></p>`)
25
26
  $('#signin-go').onclick = () => begin(onSignedIn)
26
- // A new account also signs this computer in: sign-up comes back to approving it, not to the website.
27
- $('#signin-new').onclick = (e) => { e.preventDefault(); begin(onSignedIn, true) }
27
+ $('#signin-new').onclick = (e) => { e.preventDefault(); renderSignUp(onSignedIn) }
28
28
  }
29
29
 
30
+ /** Signing up in the app: name, email and password, then the code Quilt emails. This computer is signed in to the new account. */
31
+ function renderSignUp (onSignedIn, values = {}) {
32
+ screen(`
33
+ <h1>Create your Quilt account</h1>
34
+ <form class="signup-form" id="signup-form" novalidate>
35
+ <div class="field"><label for="su-name">Your name</label><input class="input" id="su-name" autocomplete="name" maxlength="60" value="${esc(values.name || '')}" required></div>
36
+ <div class="field"><label for="su-email">Email</label><input class="input" id="su-email" type="email" autocomplete="email" value="${esc(values.email || '')}" required></div>
37
+ <div class="field"><label for="su-password">Password <span class="hint">at least 8 characters</span></label><input class="input" id="su-password" type="password" autocomplete="new-password" minlength="8" required></div>
38
+ <button class="btn primary signin-btn" id="su-go" type="submit">Create account</button>
39
+ </form>
40
+ <p class="error" id="signin-error"></p>
41
+ <p class="hint">Already have an account? <a href="#" id="su-signin">Sign in</a></p>
42
+ <p class="hint">Or <a href="${SIGNUP}" id="su-web" target="_blank" rel="noopener">sign up in your browser</a></p>`)
43
+ $('#su-name').focus()
44
+ $('#su-signin').onclick = (e) => { e.preventDefault(); renderSignIn('', onSignedIn) }
45
+ // On the website, sign-up comes back to approving this computer.
46
+ $('#su-web').onclick = (e) => { e.preventDefault(); begin(onSignedIn, true) }
47
+ $('#signup-form').onsubmit = async (e) => {
48
+ e.preventDefault()
49
+ const details = { name: $('#su-name').value.trim(), email: $('#su-email').value.trim(), password: $('#su-password').value }
50
+ if (!details.name || !details.email || !details.password) return fail('Fill in your name, email and a password.')
51
+ if (details.password.length < 8) return fail('Use a password of at least 8 characters.')
52
+ $('#su-go').disabled = true
53
+ try {
54
+ const acc = await api('POST', '/api/account/signup', details)
55
+ if (acc.signedIn) return onSignedIn()
56
+ renderCode(onSignedIn, details)
57
+ } catch (err) {
58
+ $('#su-go').disabled = false
59
+ fail(err.message)
60
+ }
61
+ }
62
+ }
63
+
64
+ function renderCode (onSignedIn, details) {
65
+ screen(`
66
+ <h1>Check your email</h1>
67
+ <p>We sent a 6-digit code to <b>${esc(details.email)}</b>.</p>
68
+ <form class="signup-form" id="code-form" novalidate>
69
+ <div class="field"><label for="su-code">Code</label><input class="input signup-code" id="su-code" inputmode="numeric" autocomplete="one-time-code" maxlength="7" required></div>
70
+ <button class="btn primary signin-btn" id="code-go" type="submit">Continue</button>
71
+ </form>
72
+ <p class="error" id="signin-error"></p>
73
+ <p class="hint">No email? Check spam, or <a href="#" id="code-again">send a new code</a>. <a href="#" id="code-back">Use a different email</a></p>`)
74
+ $('#su-code').focus()
75
+ $('#code-back').onclick = (e) => { e.preventDefault(); renderSignUp(onSignedIn, details) }
76
+ $('#code-again').onclick = async (e) => {
77
+ e.preventDefault()
78
+ try { await api('POST', '/api/account/signup', details); fail('A new code is on its way.') } catch (err) { fail(err.message) }
79
+ }
80
+ $('#code-form').onsubmit = async (e) => {
81
+ e.preventDefault()
82
+ const code = $('#su-code').value.replace(/\s+/g, '')
83
+ if (!/^\d{6}$/.test(code)) return fail('Enter the 6-digit code from the email.')
84
+ $('#code-go').disabled = true
85
+ try {
86
+ const acc = await api('POST', '/api/account/signup/confirm', { code })
87
+ if (acc.signedIn) return onSignedIn()
88
+ $('#code-go').textContent = 'Signing in…'
89
+ // Confirmed: the app collects this computer's sign-in within a few seconds.
90
+ poller = setInterval(async () => {
91
+ const now = await api('GET', '/api/account').catch(() => null)
92
+ if (now?.signedIn) { clearInterval(poller); onSignedIn() }
93
+ }, 1000)
94
+ } catch (err) {
95
+ $('#code-go').disabled = false
96
+ fail(err.message)
97
+ }
98
+ }
99
+ }
100
+
101
+ const fail = (message) => { $('#signin-error').textContent = message }
102
+
30
103
  async function begin (onSignedIn, signup = false) {
31
104
  const btn = $('#signin-go')
32
105
  btn.disabled = true
package/src/ui-server.js CHANGED
@@ -20,7 +20,7 @@ import { autowork, autoConfig, publicConfig, AUTO_MODES } from './autowork.js'
20
20
  import { migrateDir } from './legacy.js'
21
21
  import { writePrivateJson } from './private-file.js'
22
22
  import { autoToolFor } from './autowork-tools.js'
23
- import { readAccount, saveAccount, clearAccount, clearAccountIf, resumeAccount, startLink, waitForLink, fetchMe, signOut, revokeToken, accountFromProfile, renameSession, createAgentInvite, listAgents, agentDetails, listAccessTypes, listCollaborators, listGrants, putGrant, deleteGrant, inviteToSession, listSessionInvites, cancelSessionInvite, listWorkspaces, listOrgs, createWorkspace, getWorkspace, updateWorkspace, deleteWorkspace, putWorkspaceMember, removeWorkspaceMember, getAgentPlacement, putAgentPlacement, listOrgAgents, putWorkspaceAgent, deleteWorkspaceAgent, createWorkspaceAgentInvite, excludeSessionAgent, listExcludedSessionAgents, listSessionAgents, includeSessionAgent, setSessionWorkspace, moveSessionToWorkspace, listWorkspaceInvites, inviteToWorkspace, cancelWorkspaceInvite, listMyInvites, answerMyInvite, listMySessions, announceSessionStarted, announceWhenReported, listWorkspaceFiles, createWorkspaceFile, confirmWorkspaceFile, workspaceFileDownload, updateWorkspaceFile, deleteWorkspaceFile, createWorkspaceFolder, listWorkspaceFileVersions, listSandboxKeys, createSandboxKey, rotateSandboxKey, revokeSandboxKey, removeSandboxKey, aiVmFollow, aiVmUnfollow, aiVmStatus, aiVmConnect, aiVmUpdate, aiVmSignIn, aiVmWake, aiVmDisconnect, voiceIce, transcribeVoice, speakVoice, speakVoiceStream, apiUrl } from './account.js'
23
+ import { readAccount, saveAccount, clearAccount, clearAccountIf, resumeAccount, startLink, waitForLink, signUpForLink, confirmSignUpForLink, fetchMe, signOut, revokeToken, accountFromProfile, renameSession, createAgentInvite, listAgents, agentDetails, listAccessTypes, listCollaborators, listGrants, putGrant, deleteGrant, inviteToSession, listSessionInvites, cancelSessionInvite, listWorkspaces, listOrgs, createWorkspace, getWorkspace, updateWorkspace, deleteWorkspace, putWorkspaceMember, removeWorkspaceMember, getAgentPlacement, putAgentPlacement, listOrgAgents, putWorkspaceAgent, deleteWorkspaceAgent, createWorkspaceAgentInvite, excludeSessionAgent, listExcludedSessionAgents, listSessionAgents, includeSessionAgent, setSessionWorkspace, moveSessionToWorkspace, listWorkspaceInvites, inviteToWorkspace, cancelWorkspaceInvite, listMyInvites, answerMyInvite, listMySessions, announceSessionStarted, announceWhenReported, listWorkspaceFiles, createWorkspaceFile, confirmWorkspaceFile, workspaceFileDownload, updateWorkspaceFile, deleteWorkspaceFile, createWorkspaceFolder, listWorkspaceFileVersions, listSandboxKeys, createSandboxKey, rotateSandboxKey, revokeSandboxKey, removeSandboxKey, aiVmFollow, aiVmUnfollow, aiVmStatus, aiVmConnect, aiVmUpdate, aiVmSignIn, aiVmWake, aiVmDisconnect, voiceIce, transcribeVoice, speakVoice, speakVoiceStream, apiUrl } from './account.js'
24
24
  import { aiName } from './persona.js'
25
25
  import { effectiveAccess, builtinType } from './session-access.js'
26
26
  import { cleanSessionName, BAD_SESSION_NAME, SESSION_NAME_MAX } from './session-name.js'
@@ -51,7 +51,7 @@ const LOCAL_RELAY_GONE = "This session ran on your computer's own relay, which Q
51
51
  export const GITHUB_GONE = 'Starting a session from GitHub is gone: start one from a folder (a new session\'s code is committed in Seam from the start), and bring a repository\'s history into Seam with seam github import.'
52
52
  const STATUS_PUSH_MS = 500 // a session's status goes to the window at most this often when the session changes it
53
53
  // Until this computer is signed in, only these answer.
54
- const OPEN_ROUTES = new Set(['GET /api/account', 'POST /api/account/start', 'POST /api/account/cancel', 'POST /api/account/signout', 'GET /api/events', 'POST /api/shutdown', 'POST /api/report'])
54
+ const OPEN_ROUTES = new Set(['GET /api/account', 'POST /api/account/start', 'POST /api/account/signup', 'POST /api/account/signup/confirm', 'POST /api/account/cancel', 'POST /api/account/signout', 'GET /api/events', 'POST /api/shutdown', 'POST /api/report'])
55
55
 
56
56
  // The sound switches in Settings, one per event (SOUND_EVENTS in src/ui/sounds.js).
57
57
  const SOUND_SETTINGS = ['soundMentions', 'soundLetIn', 'soundTasks']
@@ -346,7 +346,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
346
346
 
347
347
  /** Starts linking this computer; the website approves it, and we collect the token in the background. */
348
348
  async function beginLink () {
349
- if (readAccount()) throw httpError(409, 'Already signed in.')
349
+ // Already signed in (approved while the window lost track of it): say so, and the app goes on in.
350
+ if (readAccount()) return accountState()
350
351
  // A computer linked before signs straight back in: no browser, no approving it again.
351
352
  try {
352
353
  if (await resumeAccount({ asked: true })) {
@@ -358,6 +359,12 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
358
359
  return accountState()
359
360
  }
360
361
  } catch {}
362
+ await newLink()
363
+ return accountState()
364
+ }
365
+
366
+ /** A fresh link for this computer, collected in the background once it's approved (on the website, or by a sign-up code). */
367
+ async function newLink () {
361
368
  const identity = loadIdentity()
362
369
  const mine = { ...await startLink({ identity }), state: 'waiting', error: null }
363
370
  link = mine
@@ -387,6 +394,27 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
387
394
  mine.state = err.expired ? 'expired' : err.denied ? 'denied' : 'failed'
388
395
  mine.error = err.message
389
396
  })
397
+ return mine
398
+ }
399
+
400
+ /**
401
+ * Signing up in the app: the account is made on Quilt's API for a link this computer starts
402
+ * (or the one it's waiting on), and the emailed code approves that link for it. No browser.
403
+ */
404
+ async function signUp ({ name, email, password }) {
405
+ if (readAccount()) return accountState()
406
+ const mine = link && link.state === 'waiting' ? link : await newLink()
407
+ const r = await signUpForLink({ deviceCode: mine.deviceCode, name, email, password }).catch((err) => { throw httpError(err.status && err.status < 500 ? 400 : 502, err.message) })
408
+ mine.signUpEmail = r.email
409
+ return { ...await accountState(), signUp: { email: r.email } }
410
+ }
411
+
412
+ async function confirmSignUp ({ code }) {
413
+ if (readAccount()) return accountState()
414
+ const mine = link
415
+ if (!mine || mine.state !== 'waiting' || !mine.signUpEmail) throw httpError(409, 'That sign-up timed out. Start again.')
416
+ await confirmSignUpForLink({ deviceCode: mine.deviceCode, email: mine.signUpEmail, code }).catch((err) => { throw httpError(err.status && err.status < 500 ? 400 : 502, err.message) })
417
+ // Approved: the link's own poll collects the sign-in within a few seconds.
390
418
  return accountState()
391
419
  }
392
420
 
@@ -1087,6 +1115,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1087
1115
  'POST /api/workspaces/:id/files/:fid/delete': (b, id, url, fid) => asAccount(async (token) => { await deleteWorkspaceFile({ token, id: needWorkspaceId(id), fileId: fid }); return { ok: true } }),
1088
1116
  'POST /api/workspaces/:id/folders': (b, id) => asAccount(async (token) => ({ file: await createWorkspaceFolder({ token, id: needWorkspaceId(id), path: String(b.path || '') }) })),
1089
1117
  'POST /api/account/start': () => beginLink(),
1118
+ 'POST /api/account/signup': (b) => signUp(b || {}),
1119
+ 'POST /api/account/signup/confirm': (b) => confirmSignUp(b || {}),
1090
1120
  'POST /api/account/cancel': () => { link = null; return accountState() },
1091
1121
  'POST /api/account/signout': async () => {
1092
1122
  const account = readAccount()