heyquilt 0.3.182 → 0.3.184

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.
Files changed (126) hide show
  1. package/README.md +101 -97
  2. package/RELEASES.md +14 -0
  3. package/bin/quilt.js +32 -32
  4. package/desktop/main.js +1 -1
  5. package/package.json +1 -1
  6. package/src/account.js +17 -2
  7. package/src/admit-policy.js +2 -2
  8. package/src/agent-join.js +3 -3
  9. package/src/agent-task-workflow.js +14 -14
  10. package/src/ai-vm.js +1 -1
  11. package/src/api/agent-placement.js +2 -2
  12. package/src/api/audit.js +1 -1
  13. package/src/api/file-paths.js +1 -1
  14. package/src/api/file-store.js +1 -1
  15. package/src/api/invite-email.js +4 -4
  16. package/src/api/join-text.js +5 -5
  17. package/src/api/memory-store.js +22 -1
  18. package/src/api/notify.js +7 -7
  19. package/src/api/permissions.js +1 -1
  20. package/src/api/routes/agent-wake.js +1 -1
  21. package/src/api/routes/agents.js +2 -2
  22. package/src/api/routes/ai-vm.js +5 -5
  23. package/src/api/routes/connections.js +66 -25
  24. package/src/api/routes/grants.js +2 -2
  25. package/src/api/routes/mail.js +10 -10
  26. package/src/api/routes/relay.js +1 -1
  27. package/src/api/routes/secrets.js +11 -11
  28. package/src/api/routes/session-invites.js +5 -5
  29. package/src/api/routes/sessions.js +3 -3
  30. package/src/api/routes/workspace-agents.js +14 -14
  31. package/src/api/routes/workspace-chat.js +77 -0
  32. package/src/api/routes/workspace-files.js +12 -12
  33. package/src/api/routes/workspace-invites.js +5 -5
  34. package/src/api/routes/workspaces.js +11 -11
  35. package/src/api/secrets-access.js +1 -1
  36. package/src/api/server.js +5 -4
  37. package/src/api/supabase-store.js +25 -1
  38. package/src/api/team-access.js +1 -1
  39. package/src/api/workspace-access.js +1 -1
  40. package/src/api/workspace-reach.js +3 -3
  41. package/src/app-tools.js +11 -11
  42. package/src/autowork.js +4 -4
  43. package/src/branch-view.js +1 -1
  44. package/src/catchup.js +5 -5
  45. package/src/chat-links.js +18 -18
  46. package/src/connection.js +11 -11
  47. package/src/control.js +5 -5
  48. package/src/conversation.js +1 -1
  49. package/src/doctor.js +2 -2
  50. package/src/duties.js +1 -1
  51. package/src/fsutil.js +1 -1
  52. package/src/held.js +4 -4
  53. package/src/hooks.js +3 -3
  54. package/src/hosted-client.js +2 -2
  55. package/src/identity.js +1 -1
  56. package/src/inbox.js +1 -1
  57. package/src/key-cli.js +1 -1
  58. package/src/mail-tools.js +11 -11
  59. package/src/mcp-proxy.js +1 -1
  60. package/src/mcp.js +59 -59
  61. package/src/new-session.js +6 -6
  62. package/src/project-rules.js +2 -2
  63. package/src/relay-ask.js +2 -2
  64. package/src/relay-cluster.js +3 -3
  65. package/src/relay-live-write.js +3 -3
  66. package/src/relay-mcp.js +56 -56
  67. package/src/relay-prune.js +1 -1
  68. package/src/relay-turn-sync.js +1 -1
  69. package/src/secret-import.js +1 -1
  70. package/src/secret-names.js +6 -6
  71. package/src/secret-run.js +3 -3
  72. package/src/server.js +41 -41
  73. package/src/session-access.js +3 -3
  74. package/src/session-name.js +1 -1
  75. package/src/session.js +50 -50
  76. package/src/setup.js +7 -7
  77. package/src/status.js +2 -2
  78. package/src/tasks.js +1 -1
  79. package/src/turn-sync.js +4 -4
  80. package/src/ui/account-sessions.js +2 -2
  81. package/src/ui/agent-env-key.js +1 -1
  82. package/src/ui/agent-guide.js +35 -35
  83. package/src/ui/agent-kinds.js +8 -8
  84. package/src/ui/agent-place.js +16 -16
  85. package/src/ui/agents-table.js +6 -6
  86. package/src/ui/app.css +345 -0
  87. package/src/ui/app.js +28 -13
  88. package/src/ui/board.js +2 -2
  89. package/src/ui/catchup.js +5 -5
  90. package/src/ui/changes-seen.js +2 -2
  91. package/src/ui/changes.js +3 -3
  92. package/src/ui/cloud-ai.js +12 -12
  93. package/src/ui/common.js +1 -1
  94. package/src/ui/connections.js +48 -8
  95. package/src/ui/diffview.js +2 -2
  96. package/src/ui/feed.js +1 -1
  97. package/src/ui/feedback.js +4 -4
  98. package/src/ui/files.js +120 -14
  99. package/src/ui/fileview.js +3 -3
  100. package/src/ui/git-rule.js +3 -3
  101. package/src/ui/home.js +97 -47
  102. package/src/ui/index.html +1 -1
  103. package/src/ui/invite.js +8 -8
  104. package/src/ui/invites.js +3 -3
  105. package/src/ui/new-session.js +3 -3
  106. package/src/ui/prail-model.js +22 -0
  107. package/src/ui/prail.js +43 -0
  108. package/src/ui/project-board.js +359 -0
  109. package/src/ui/project-channel.js +93 -0
  110. package/src/ui/project-model.js +224 -0
  111. package/src/ui/project-pop.js +451 -0
  112. package/src/ui/projects.js +464 -0
  113. package/src/ui/sandbox-keys.js +3 -3
  114. package/src/ui/secrets-view.js +5 -5
  115. package/src/ui/session-words.js +2 -2
  116. package/src/ui/session.js +174 -47
  117. package/src/ui/tree.js +3 -3
  118. package/src/ui/voice.js +6 -6
  119. package/src/ui/workspaces.js +23 -23
  120. package/src/ui-server.js +88 -27
  121. package/src/update-check.js +2 -2
  122. package/src/voice.js +7 -7
  123. package/src/wake-tool.js +1 -1
  124. package/src/webhooks.js +1 -1
  125. package/src/workspace-cli.js +12 -12
  126. package/src/workspace-tools.js +33 -33
@@ -60,7 +60,7 @@ function cardHtml (w) {
60
60
  <div class="ws-card-body">
61
61
  <h3>${esc(w.name)} <span class="pill ws-space${w.space?.kind === 'org' ? ' coral' : ''}">${esc(spaceLabel(w))}</span></h3>
62
62
  <p class="ws-desc">${esc(w.description || '')}</p>
63
- <div class="ws-stats"><span><b>${w.counts?.sessions ?? 0}</b> ${w.counts?.sessions === 1 ? 'session' : 'sessions'}</span><span><b>${w.counts?.files ?? 0}</b> ${w.counts?.files === 1 ? 'file' : 'files'}</span></div>
63
+ <div class="ws-stats"><span><b>${w.counts?.sessions ?? 0}</b> ${w.counts?.sessions === 1 ? 'codebase' : 'codebases'}</span><span><b>${w.counts?.files ?? 0}</b> ${w.counts?.files === 1 ? 'artifact' : 'artifacts'}</span></div>
64
64
  </div>
65
65
  <div class="ws-foot"><span>${esc(plural((w.counts?.members ?? 0) + (w.space?.kind === 'personal' ? 1 : 0), 'member', 'members'))}</span><span class="spacer"></span><span>${w.archivedAt ? 'archived' : esc(ago(w.createdAt))}</span></div>
66
66
  </div>`
@@ -69,7 +69,7 @@ function cardHtml (w) {
69
69
  function addCardHtml () {
70
70
  return `
71
71
  <div class="ws-card add" data-add-ws role="button" tabindex="0">
72
- <span class="ws-plus">${I.plus}</span><b>Add workspace</b><span>Sessions, files and agents in one place</span>
72
+ <span class="ws-plus">${I.plus}</span><b>Add project</b><span>Codebases, artifacts and agents in one place</span>
73
73
  </div>`
74
74
  }
75
75
 
@@ -103,22 +103,22 @@ export function workspacesHtml () {
103
103
  const loose = looseRows()
104
104
  return `
105
105
  <section class="workspaces">
106
- <div class="sec-head"><h2>Your workspaces</h2><span class="count">${list.length}</span><span class="spacer"></span>
106
+ <div class="sec-head"><h2>Your projects</h2><span class="count">${list.length}</span><span class="spacer"></span>
107
107
  ${spaces().size > 2 ? `<div class="segmented ws-filter" role="tablist">${[...spaces()].map(([k, label]) => `<button type="button" role="tab" data-space-filter="${esc(k)}" class="${filter === k ? 'on' : ''}" aria-selected="${filter === k}">${esc(label)}</button>`).join('')}</div>` : ''}
108
108
  </div>
109
109
  <div class="ws-grid">${list.map(cardHtml).join('')}${state.addingWorkspace ? addFormHtml() : addCardHtml()}</div>
110
110
  </section>
111
111
  <section class="ws-loose">
112
- <div class="sec-head"><h2 class="ws-loose-h">Sessions not in a workspace</h2><span class="count">${loose.length}</span><span class="spacer"></span>
112
+ <div class="sec-head"><h2 class="ws-loose-h">Codebases not in a project</h2><span class="count">${loose.length}</span><span class="spacer"></span>
113
113
  <button class="btn sm ghost" data-join-session>${I.link}<span>Join with an invite</span></button>
114
- <button class="btn sm" data-new-session>${I.plus}<span>New session</span></button>
114
+ <button class="btn sm" data-new-session>${I.plus}<span>New codebase</span></button>
115
115
  </div>
116
116
  ${loose.length ? `<div class="ws-chips">${loose.map((r) => `
117
117
  <div class="ws-chip"><span class="folder-ico${r.live ? ' live' : ''}">${I.folder}</span>
118
118
  <span class="t"><b>${esc(basename(r.dir))}</b><span>${r.live ? (r.peers ? `${r.peers} other${r.peers === 1 ? '' : 's'} here` : 'just you') : esc(ago(r.lastUsed))}</span></span>
119
119
  ${r.live ? `<button class="btn sm primary" data-go="${esc(r.id)}">Open</button>` : `<button class="btn sm" data-rejoin="${esc(r.dir)}">Rejoin</button>`}
120
- ${state.workspaces?.length ? `<button class="btn sm ghost" data-move-session="${esc(r.dir)}" title="Move to a workspace" aria-label="Move to a workspace">${I.folder}</button>` : ''}
121
- </div>`).join('')}</div>` : `<p class="hint">${state.sessions.size || state.recent.length ? 'Every session is in a workspace.' : 'No sessions yet.'}</p>`}
120
+ ${state.workspaces?.length ? `<button class="btn sm ghost" data-move-session="${esc(r.dir)}" title="Move to a project" aria-label="Move to a project">${I.folder}</button>` : ''}
121
+ </div>`).join('')}</div>` : `<p class="hint">${state.sessions.size || state.recent.length ? 'Every codebase is in a project.' : 'No codebases yet.'}</p>`}
122
122
  </section>`
123
123
  }
124
124
 
@@ -158,7 +158,7 @@ export function bindWorkspaces (root, { go, rerender }) {
158
158
  root.querySelectorAll('[data-move-session]').forEach((b) => {
159
159
  b.onclick = async () => {
160
160
  const options = (state.workspaces || []).filter((w) => w.access === 'edit')
161
- if (!options.length) return toast('No workspace you can edit.')
161
+ if (!options.length) return toast('No project you can edit.')
162
162
  const choice = await ask({ title: `Move ${basename(b.dataset.moveSession)} to`, input: { select: options.map((w) => ({ value: w.id, label: w.name })) }, ok: 'Move' })
163
163
  if (!choice) return
164
164
  try {
@@ -169,7 +169,7 @@ export function bindWorkspaces (root, { go, rerender }) {
169
169
  for (const sum of st.sessions) { const s = state.sessions.get(sum.id); if (s) s.workspace = sum.workspace }
170
170
  await loadWorkspaces(); rerender()
171
171
  const n = (moved.added || []).length
172
- toast(moved.peopleNeedAdmin ? "Moved. Only the workspace's admins can add its people." : n ? `Moved, with ${n} ${n === 1 ? 'person or agent' : 'people and agents'} added to the workspace` : 'Moved')
172
+ toast(moved.peopleNeedAdmin ? "Moved. Only the project's admins can add its people." : n ? `Moved, with ${n} ${n === 1 ? 'person or agent' : 'people and agents'} added to the project` : 'Moved')
173
173
  } catch (err) { toast(err.message) }
174
174
  }
175
175
  })
@@ -226,7 +226,7 @@ export function workspacePageHtml () {
226
226
  // A refresh while it is still loading draws it again without fading it in again.
227
227
  const steady = state.wsLoading === id
228
228
  state.wsLoading = id
229
- return loadingHtml({ label: 'Loading workspace', name: (state.workspaces || []).find((x) => x.id === id)?.name || '', steady })
229
+ return loadingHtml({ label: 'Loading project', name: (state.workspaces || []).find((x) => x.id === id)?.name || '', steady })
230
230
  }
231
231
  const w = d.workspace
232
232
  const admin = d.access.admin
@@ -252,29 +252,29 @@ export function workspacePageHtml () {
252
252
  state.wsLoading = null
253
253
  return `
254
254
  <div class="ws-page${enter ? ' enter' : ''}">
255
- <a class="ws-back" href="#" data-ws-back>${I.caret} All workspaces</a>
255
+ <a class="ws-back" href="#" data-ws-back>${I.caret} All projects</a>
256
256
  <header class="ws-head">
257
257
  <span class="ws-mark big" style="background:${coverOf(w)}">${esc(initial(w.name))}</span>
258
258
  <div class="ws-head-t">
259
259
  <h1>${esc(w.name)} <span class="pill ws-space${w.orgId ? ' coral' : ''}">${esc(w.orgId ? d.owner.name : 'Personal')}</span>${w.archivedAt ? ' <span class="pill">Archived</span>' : ''}</h1>
260
260
  ${w.description ? `<p>${esc(w.description)}</p>` : ''}
261
- <div class="ws-statline">${running.length ? `<span class="live"><span class="dot"></span><b>${running.length}</b> open now</span>` : ''}${stat(sessionCount, 'session', 'sessions')}${stat(fileCount, 'file', 'files')}${stat(people.length + agents.length, 'person or agent', 'people and agents')}</div>
261
+ <div class="ws-statline">${running.length ? `<span class="live"><span class="dot"></span><b>${running.length}</b> open now</span>` : ''}${stat(sessionCount, 'codebase', 'codebases')}${stat(fileCount, 'artifact', 'artifacts')}${stat(people.length + agents.length, 'person or agent', 'people and agents')}</div>
262
262
  </div>
263
- <div class="acts"><button class="btn sm" data-team title="People and agents in this workspace">${I.users}<span>Team</span><span class="count">${people.length + agents.length}</span></button>${admin ? `<button class="btn sm" data-invite-ws>${I.link}<span>Invite</span></button><button class="btn sm ghost icon" data-ws-settings title="Workspace settings" aria-label="Workspace settings">${I.gear}</button>` : ''}</div>
263
+ <div class="acts"><button class="btn sm" data-team title="People and agents in this project">${I.users}<span>Team</span><span class="count">${people.length + agents.length}</span></button>${admin ? `<button class="btn sm" data-invite-ws>${I.link}<span>Invite</span></button><button class="btn sm ghost icon" data-ws-settings title="Project settings" aria-label="Project settings">${I.gear}</button>` : ''}</div>
264
264
  </header>
265
265
 
266
266
  <div class="ws-dash">
267
267
  <div class="ws-main">
268
268
  <section class="sec">
269
- <div class="sec-head"><h2>Sessions</h2><span class="count">${sessionCount}</span><span class="spacer"></span>
270
- ${d.access.access === 'edit' ? `<button type="button" class="btn sm" data-new-session-in="${esc(w.id)}">${I.plus}<span>New session</span></button>` : ''}</div>
269
+ <div class="sec-head"><h2>Codebases</h2><span class="count">${sessionCount}</span><span class="spacer"></span>
270
+ ${d.access.access === 'edit' ? `<button type="button" class="btn sm" data-new-session-in="${esc(w.id)}">${I.plus}<span>New codebase</span></button>` : ''}</div>
271
271
  ${sessionCount
272
272
  ? `<div class="sr-list">
273
273
  ${running.map((s) => sessionRowHtml(d.sessions.find((x) => x.room === s.status.room), { live: true, dir: s.dir, id: s.id, peers: s.status.peers.length })).join('')}
274
274
  ${recent.map((r) => sessionRowHtml(d.sessions.find((x) => x.room === r.room), { live: false, dir: r.dir, lastUsed: r.lastUsed })).join('')}
275
275
  ${others.map((s) => sessionRowHtml(s, { live: false, mine: s.ownerAccount === me })).join('')}
276
276
  </div>`
277
- : `<p class="hint ws-empty">No sessions yet.${d.access.access === 'edit' ? ' Start one with New session: it opens a folder of yours here.' : ''}</p>`}
277
+ : `<p class="hint ws-empty">No codebases yet.${d.access.access === 'edit' ? ' Start one with New codebase: it opens a folder of yours here.' : ''}</p>`}
278
278
  </section>
279
279
  ${filesSectionHtml(d)}
280
280
  ${state.secretsOn ? '<section class="sec ws-secrets" data-ws-secrets></section>' : ''}
@@ -289,7 +289,7 @@ export function workspacePageHtml () {
289
289
  * badge), nine a page with a search, Add for admins, and each card's ⋮ menu. It reads the open
290
290
  * workspace afresh after every change, so it stays right while open.
291
291
  */
292
- function openTeamDialog ({ id, inviteDialog, reload, rerender }) {
292
+ export function openTeamDialog ({ id, inviteDialog, reload, rerender }) {
293
293
  $('#team-back')?.remove()
294
294
  const d = state.workspace
295
295
  if (!d || d.workspace.id !== id) return
@@ -338,11 +338,11 @@ function openTeamDialog ({ id, inviteDialog, reload, rerender }) {
338
338
  toast('Saved')
339
339
  }
340
340
  if (what === 'remove') {
341
- if (!await ask({ title: 'Remove from this workspace?', message: 'They lose access to its sessions unless a session owner lets them in directly.', ok: 'Remove', danger: true })) return
341
+ if (!await ask({ title: 'Remove from this project?', message: 'They lose access to its codebases unless a codebase\'s owner lets them in directly.', ok: 'Remove', danger: true })) return
342
342
  await api('POST', wsUrl(id, '/members/remove'), { account: m.account })
343
343
  }
344
344
  if (what === 'exclude') {
345
- if (!await ask({ title: 'Not in this workspace?', message: `${m.name} leaves this workspace and its sessions. It keeps its other workspaces, and you can let it back in here.`, ok: 'Not in this workspace', danger: true })) return
345
+ if (!await ask({ title: 'Not in this project?', message: `${m.name} leaves this project and its codebases. It keeps its other projects, and you can let it back in here.`, ok: 'Not in this project', danger: true })) return
346
346
  await api('POST', agentUrl(m.agentId), { excluded: true })
347
347
  }
348
348
  if (what === 'include') { await api('POST', agentUrl(m.agentId, '/remove')); toast('Back in') }
@@ -394,17 +394,17 @@ function usageLine (u) {
394
394
  }
395
395
 
396
396
  /** `dialog(html)` is home.js's: a modal form that closes on Cancel, Escape or a click outside. */
397
- function settingsDialog (reload, go, dialog) {
397
+ export function settingsDialog (reload, go, dialog) {
398
398
  const w = state.workspace.workspace
399
399
  const { form, close } = dialog(`
400
- <h3>Workspace settings</h3>
400
+ <h3>Project settings</h3>
401
401
  <div class="field"><label for="wss-name">Name</label><input class="input" id="wss-name" name="name" maxlength="80" required value="${esc(w.name)}"></div>
402
402
  <div class="field"><label for="wss-desc">About</label><input class="input" id="wss-desc" name="description" maxlength="500" value="${esc(w.description || '')}"></div>
403
403
  <div class="field"><span class="label">Colour</span><div class="swatches">${Object.entries(COLORS).map(([k, c]) => `<label class="swatch"><input type="radio" name="color" value="${k}" ${(w.color || 'lilac') === k ? 'checked' : ''}><span style="background:${c}"></span></label>`).join('')}</div></div>
404
404
  <label class="toggle"><input type="checkbox" name="archived" ${w.archivedAt ? 'checked' : ''}><span class="track"><span class="knob"></span></span><span class="tg-text"><b>Archived</b><span class="hint">Kept, but out of the way.</span></span></label>
405
405
  ${usageLine(state.workspace.usage)}
406
406
  <p class="error" data-error></p>
407
- <div class="actions">${state.workspace.canDelete ? '<button type="button" class="btn ghost danger" data-delete>Delete workspace</button>' : ''}<span class="spacer"></span><button type="button" class="btn ghost" data-cancel>Cancel</button><button class="btn primary" type="submit">Save</button></div>`)
407
+ <div class="actions">${state.workspace.canDelete ? '<button type="button" class="btn ghost danger" data-delete>Delete project</button>' : ''}<span class="spacer"></span><button type="button" class="btn ghost" data-cancel>Cancel</button><button class="btn primary" type="submit">Save</button></div>`)
408
408
  // Focus inside the dialog, so Escape (bound on the dialog) closes it straight away.
409
409
  form.querySelector('#wss-name').focus()
410
410
  form.onsubmit = async (e) => {
@@ -425,7 +425,7 @@ function settingsDialog (reload, go, dialog) {
425
425
  }
426
426
  }
427
427
  form.querySelector('[data-delete]')?.addEventListener('click', async () => {
428
- const typed = await ask({ title: `Delete ${w.name}?`, message: 'Its sessions stay, outside any workspace. Type the workspace name to confirm.', ok: 'Delete', danger: true, input: { placeholder: w.name } })
428
+ const typed = await ask({ title: `Delete ${w.name}?`, message: 'Its codebases stay, in no project. Type the project\'s name to confirm.', ok: 'Delete', danger: true, input: { placeholder: w.name } })
429
429
  if (typed !== w.name) { if (typed) toast('That is not the name.'); return }
430
430
  try { await api('POST', wsUrl(w.id, '/delete')); close(); await loadWorkspaces(); go('home') } catch (err) { toast(err.message) }
431
431
  })
package/src/ui-server.js CHANGED
@@ -21,6 +21,7 @@ import { autowork, autoConfig, publicConfig, AUTO_MODES } from './autowork.js'
21
21
  import { migrateDir } from './legacy.js'
22
22
  import { writePrivateJson } from './private-file.js'
23
23
  import { autoToolFor } from './autowork-tools.js'
24
+ import { workspaceMessages, sayInWorkspace, readWorkspaceMessages } from './account.js'
24
25
  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'
25
26
  import { aiName } from './persona.js'
26
27
  import { effectiveAccess, builtinType } from './session-access.js'
@@ -46,9 +47,9 @@ const COLOR_RE = /^#[0-9a-f]{6}$/i
46
47
  const THEMES = ['light', 'dark', 'system']
47
48
  const SAVE_FAILED = "Quilt couldn't save your sign-in on this computer."
48
49
  const SIGNED_OUT_MESSAGE = 'This computer was signed out. Sign in again.'
49
- const LOCAL_RELAY_GONE = "This session ran on your computer's own relay, which Quilt no longer supports. Your files are untouched."
50
+ const LOCAL_RELAY_GONE = "This codebase ran on your computer's own relay, which Quilt no longer supports. Your files are untouched."
50
51
  // There is no New session from GitHub. Said to an older window that still offers it.
51
- export const GITHUB_GONE = 'Starting a session from GitHub is gone: clone the repository and start a session from its folder. The session\'s folder is a git folder: commit and push with git as usual.'
52
+ export const GITHUB_GONE = 'Starting a codebase from GitHub is gone: clone the repository and start a codebase from its folder. The codebase\'s folder is a git folder: commit and push with git as usual.'
52
53
  const STATUS_PUSH_MS = 500 // a session's status goes to the window at most this often when the session changes it
53
54
  // Until this computer is signed in, only these answer.
54
55
  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'])
@@ -182,6 +183,13 @@ export const STATIC = {
182
183
  '/loom.js': ['loom.js', 'text/javascript; charset=utf-8'],
183
184
  '/loom-model.js': ['loom-model.js', 'text/javascript; charset=utf-8'],
184
185
  '/rail.js': ['rail.js', 'text/javascript; charset=utf-8'],
186
+ '/projects.js': ['projects.js', 'text/javascript; charset=utf-8'],
187
+ '/project-model.js': ['project-model.js', 'text/javascript; charset=utf-8'],
188
+ '/project-board.js': ['project-board.js', 'text/javascript; charset=utf-8'],
189
+ '/project-pop.js': ['project-pop.js', 'text/javascript; charset=utf-8'],
190
+ '/project-channel.js': ['project-channel.js', 'text/javascript; charset=utf-8'],
191
+ '/prail.js': ['prail.js', 'text/javascript; charset=utf-8'],
192
+ '/prail-model.js': ['prail-model.js', 'text/javascript; charset=utf-8'],
185
193
  '/rail-model.js': ['rail-model.js', 'text/javascript; charset=utf-8'],
186
194
  '/feedback.js': ['feedback.js', 'text/javascript; charset=utf-8'],
187
195
  '/feedback-model.js': ['feedback-model.js', 'text/javascript; charset=utf-8'],
@@ -436,7 +444,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
436
444
 
437
445
  // One of your sessions that isn't on this computer yet: joined by its room, with no link (accountSessions).
438
446
  const byRoom = (room) => {
439
- if (!/^[A-Za-z0-9_-]{1,64}$/.test(String(room))) throw httpError(400, 'Which session?')
447
+ if (!/^[A-Za-z0-9_-]{1,64}$/.test(String(room))) throw httpError(400, 'Which codebase?')
440
448
  return { server: relayUrl(), room: String(room), secret: '' }
441
449
  }
442
450
  // Its folder is named after the session when that folder is free, otherwise after its room.
@@ -455,7 +463,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
455
463
  // Signing out (or in again) replaces `passes`, so a start that outlives the sign-in it began under can tell.
456
464
  const current = () => passes === sessionPasses
457
465
  const outlived = () => readAccount()
458
- ? httpError(409, 'Your sign-in changed while this session was starting. Start it again.')
466
+ ? httpError(409, 'Your sign-in changed while this codebase was starting. Start it again.')
459
467
  : Object.assign(httpError(401, 'Sign in to Quilt first.'), { signedOut: true })
460
468
  tool = tool || me.tool
461
469
  prefer = prefer || (me.preferLocal ? 'local' : 'remote')
@@ -482,7 +490,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
482
490
  project = await prepareFolder({ source: source || 'folder', dir: dir || '', repo, name, brief, base: path.resolve(expandHome(into || me.joinDir)), who: { name: me.name } })
483
491
  dir = project.dir
484
492
  }
485
- if (!dir) throw new Error('Choose a project folder.')
493
+ if (!dir) throw new Error('Choose a folder.')
486
494
  dir = path.resolve(expandHome(dir))
487
495
  const id = idFor(dir)
488
496
  if (runs.has(id)) return summary(id)
@@ -493,7 +501,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
493
501
  conn = room ? byRoom(room) : decodeInvite(invite || '')
494
502
  } else if (mode === 'rejoin') {
495
503
  const saved = readConfig(dir)
496
- if (!saved) throw new Error('No previous session in that folder.')
504
+ if (!saved) throw new Error('No previous codebase in that folder.')
497
505
  if (unsupportedRelay(saved.server)) throw httpError(400, LOCAL_RELAY_GONE)
498
506
  conn = { server: saved.server, room: saved.room, secret: saved.secret, ...(saved.viewSecret ? { viewSecret: saved.viewSecret } : {}) }
499
507
  inviteServer = unsupportedRelay(saved.inviteServer) ? undefined : saved.inviteServer
@@ -588,7 +596,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
588
596
  // Put the new room in its workspace before anyone else connects. A failure is logged, never
589
597
  // fatal, and the session is outside any workspace here too, as it is on the API.
590
598
  const linked = await asAccount((token) => setSessionWorkspace({ token, id: workspace, room: conn.room })).then(() => true, (err) => {
591
- log(`could not add this session to its workspace: ${err.message}`)
599
+ log(`could not add this codebase to its project: ${err.message}`)
592
600
  forgetWorkspace(entry.run.dir)
593
601
  return false
594
602
  })
@@ -616,7 +624,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
616
624
 
617
625
  const get = (id) => {
618
626
  const r = runs.get(id)
619
- if (!r) throw httpError(404, 'That session is not running.')
627
+ if (!r) throw httpError(404, 'That codebase is not running.')
620
628
  return r.run.session
621
629
  }
622
630
 
@@ -627,7 +635,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
627
635
  */
628
636
  async function rename (id, raw) {
629
637
  const s = get(id)
630
- if (!s.isOwner) throw httpError(403, 'Only the session owner can rename it.')
638
+ if (!s.isOwner) throw httpError(403, "Only the codebase's owner can rename it.")
631
639
  const name = cleanSessionName(raw)
632
640
  if (!name) throw httpError(400, BAD_SESSION_NAME)
633
641
  await s.rename(name)
@@ -648,8 +656,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
648
656
  if (!readAccount()) return
649
657
  asAccount((token) => aiVmFollow({ token, link })).then((has) => {
650
658
  hasCloudAi = has
651
- if (has) log('☁️ your cloud AI is joining this session too')
652
- }, (err) => log(`could not tell your cloud AI about this session: ${err.message}`))
659
+ if (has) log('☁️ your cloud AI is joining this codebase too')
660
+ }, (err) => log(`could not tell your cloud AI about this codebase: ${err.message}`))
653
661
  }
654
662
  // Sessions handed to the cloud AI since it was connected (rooms), so each is handed over once.
655
663
  const handed = new Set()
@@ -837,7 +845,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
837
845
  }
838
846
  })
839
847
  const needInviteId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which invite?'); return String(id) }
840
- const needWorkspaceId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which workspace?'); return id }
848
+ const needWorkspaceId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which project?'); return id }
841
849
  const needAgentId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which agent?'); return id }
842
850
  const needKeyId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which key?'); return String(id) }
843
851
  /**
@@ -867,12 +875,12 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
867
875
  const ACCOUNT = /^(person|agent):[A-Za-z0-9_-]{1,64}$/
868
876
  const owned = (id) => {
869
877
  const s = get(id)
870
- if (!s.isOwner) throw httpError(403, 'Only the session owner can do that.')
878
+ if (!s.isOwner) throw httpError(403, "Only the codebase's owner can do that.")
871
879
  return s
872
880
  }
873
881
  const admitter = (id) => {
874
882
  const s = get(id)
875
- if (!s.canAdmit) throw httpError(403, 'You cannot let people into this session.')
883
+ if (!s.canAdmit) throw httpError(403, 'You cannot let people into this codebase.')
876
884
  return s
877
885
  }
878
886
  const typeById = async (token, typeId) => {
@@ -929,7 +937,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
929
937
  const workspace = r && readConfig(r.run.dir)?.workspace
930
938
  if (!workspacesOn || !workspace) return { ok: true, notified: false }
931
939
  const sent = await asAccount((token) => announceSessionStarted({ token, id: workspace, room: s.room, link: r.run.invite, agents: [agentId] }))
932
- .catch((err) => { r.log?.(`could not send that agent this session's link: ${err.message}`); return null })
940
+ .catch((err) => { r.log?.(`could not send that agent this codebase's link: ${err.message}`); return null })
933
941
  return { ok: true, notified: !!sent?.notified?.includes(agentId) }
934
942
  }
935
943
 
@@ -950,7 +958,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
950
958
  let timer
951
959
  const late = new Promise((resolve, reject) => { timer = setTimeout(() => reject(new Error('Quilt took too long to answer')), keepOutMs) })
952
960
  await Promise.race([asAccount((token) => excludeSessionAgent({ token, room: s.room, agentId: agent[1] })), late])
953
- .catch((err) => r.log?.(`could not keep that agent out of this session: ${err.message}`))
961
+ .catch((err) => r.log?.(`could not keep that agent out of this codebase: ${err.message}`))
954
962
  .finally(() => clearTimeout(timer))
955
963
  }
956
964
  let warning = ''
@@ -1004,12 +1012,13 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1004
1012
  return asAccount(async (token) => {
1005
1013
  const c = secretsApi(token)
1006
1014
  if (method === 'GET' && p === '/api/connections/apps') return apiCall(c, 'GET', `/v1/connections/apps?search=${enc(url.searchParams.get('search') || '')}&limit=${enc(url.searchParams.get('limit') || '60')}`)
1007
- const sc = p.match(/^\/api\/connections\/(org|workspace|session)\/([^/]+)(?:\/([0-9a-f-]{36}))?$/i)
1008
- if (sc && SECRET_SCOPE_ID[sc[1]].test(decodeURIComponent(sc[2]))) {
1015
+ const sc = p.match(/^\/api\/connections\/(org|workspace|session|account)\/([^/]+)(?:\/([0-9a-f-]{36}))?$/i)
1016
+ // A person's own connections are always "me": the accounts API reads who from the sign-in.
1017
+ if (sc && (sc[1] === 'account' ? sc[2] === 'me' : SECRET_SCOPE_ID[sc[1]].test(decodeURIComponent(sc[2])))) {
1009
1018
  const base = `/v1/connections/${sc[1]}/${enc(decodeURIComponent(sc[2]))}`
1010
1019
  if (!sc[3] && method === 'GET') return apiCall(c, 'GET', base)
1011
1020
  if (!sc[3] && method === 'POST') return apiCall(c, 'POST', base, { app: String(body.app || ''), ...(body.who ? { who: String(body.who) } : {}) })
1012
- if (sc[3] && method === 'PATCH') return apiCall(c, 'PATCH', `${base}/${sc[3]}`, { who: String(body.who || '') })
1021
+ if (sc[3] && method === 'PATCH') return apiCall(c, 'PATCH', `${base}/${sc[3]}`, { who: String(body.who || ''), ...(Array.isArray(body.agents) ? { agents: body.agents.map(String).slice(0, 100) } : {}) })
1013
1022
  if (sc[3] && method === 'DELETE') return apiCall(c, 'DELETE', `${base}/${sc[3]}`)
1014
1023
  }
1015
1024
  const calls = p.match(/^\/api\/app-calls\/([A-Za-z0-9_-]{1,64})(?:\/([0-9a-f-]{36}))?$/i)
@@ -1037,7 +1046,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1037
1046
  },
1038
1047
  'POST /api/secrets/env-scan': (b) => {
1039
1048
  const dirs = envDirs(b)
1040
- if (!dirs.length) return { files: [], empty: 'Open this session (or one of the workspace\'s) on this computer to import its .env files.' }
1049
+ if (!dirs.length) return { files: [], empty: 'Open this codebase (or one of the project\'s) on this computer to import its .env files.' }
1041
1050
  return { files: envFilesIn(dirs) }
1042
1051
  },
1043
1052
  'POST /api/secrets/env-import': (b) => {
@@ -1066,6 +1075,15 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1066
1075
  },
1067
1076
  'GET /api/agents': () => asAccount(async (token) => ({ agents: await listAgents({ token, activity: true }) })),
1068
1077
  'GET /api/agents/:id/details': (b, id) => asAccount((token) => agentDetails({ token, id: needAgentId(id) })),
1078
+ // Your agents with where each works (its placement), for Home's Agents: one answer for the page, eight agents asked at a time.
1079
+ 'GET /api/agents/placed': () => asAccount(async (token) => {
1080
+ const agents = await listAgents({ token })
1081
+ const out = []
1082
+ for (let i = 0; i < agents.length; i += 8) {
1083
+ out.push(...await Promise.all(agents.slice(i, i + 8).map(async (a) => ({ ...a, placement: await getAgentPlacement({ token, id: a.id }).catch(() => null) }))))
1084
+ }
1085
+ return { agents: out }
1086
+ }),
1069
1087
  // `global` (workspaces on): a global agent's invite. Without it, the invite as it always was.
1070
1088
  'POST /api/agent-invites': (b) => asAccount((token) => createAgentInvite({ token, global: workspacesOn && b?.global === true })),
1071
1089
  'GET /api/workspaces': () => workspaceList(),
@@ -1083,7 +1101,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1083
1101
  'POST /api/agents/:id/sandbox-keys': (b, id) => asAccount(async (token) => {
1084
1102
  const pick = String(b.session || '')
1085
1103
  const local = pick.startsWith('local:') ? localSessions().find((s) => s.value === pick) : null
1086
- if (pick.startsWith('local:') && !local) throw httpError(404, 'That session is not on this computer any more.')
1104
+ if (pick.startsWith('local:') && !local) throw httpError(404, 'That codebase is not on this computer any more.')
1087
1105
  const where = local ? { session: local.link, sessionName: local.name } : pick.startsWith('room:') ? { room: pick.slice(5) } : { session: String(b.link || '').trim() }
1088
1106
  const r = await createSandboxKey({ token, id: needAgentId(id), name: String(b.name || '').trim(), ...where })
1089
1107
  return { envKey: r.envKey, key: r.key }
@@ -1102,10 +1120,10 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1102
1120
  // workspace. Its people and agents come along when you manage the workspace (`added`).
1103
1121
  'POST /api/workspaces/:id/sessions/move': (b, id) => asAccount(async (token) => {
1104
1122
  const live = b.session ? runs.get(String(b.session)) : null
1105
- if (b.session && !live) throw httpError(404, 'That session is not open.')
1123
+ if (b.session && !live) throw httpError(404, 'That codebase is not open.')
1106
1124
  const dir = live ? live.run.dir : path.resolve(expandHome(String(b.dir || '')))
1107
1125
  const saved = readConfig(dir)
1108
- if (!saved) throw httpError(404, 'No session in that folder.')
1126
+ if (!saved) throw httpError(404, 'No codebase in that folder.')
1109
1127
  const r = await moveSessionToWorkspace({ token, id: needWorkspaceId(id), room: saved.room })
1110
1128
  writePrivateJson(path.join(dir, '.quilt', 'config.json'), { ...readConfig(dir), workspace: id })
1111
1129
  rememberWorkspace(dir, id)
@@ -1135,8 +1153,14 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1135
1153
  'GET /api/invites': () => asAccount(async (token) => ({ invites: (await listMyInvites({ token })).filter((i) => i.kind !== 'workspace' || appWorkspaces()) })),
1136
1154
  'POST /api/invites/:id/accept': (b, id) => asAccount(async (token) => answerMyInvite({ token, id: needInviteId(id), how: 'accept' })),
1137
1155
  'POST /api/invites/:id/decline': (b, id) => asAccount(async (token) => answerMyInvite({ token, id: needInviteId(id), how: 'decline' })),
1156
+ // A project's channel: kept by the accounts API, so it is there with no codebase open.
1157
+ 'GET /api/workspaces/:id/messages': (b, id, url) => asAccount((token) => workspaceMessages({ token, id: needWorkspaceId(id), after: Number(url.searchParams.get('after')) || 0 })),
1158
+ 'POST /api/workspaces/:id/messages': (b, id) => asAccount((token) => sayInWorkspace({ token, id: needWorkspaceId(id), text: String(b.text || '').slice(0, 8000) })),
1159
+ 'POST /api/workspaces/:id/messages/read': (b, id) => asAccount((token) => readWorkspaceMessages({ token, id: needWorkspaceId(id) })),
1138
1160
  'GET /api/workspaces/:id/files': (b, id, url) => asAccount(async (token) => ({ files: await listWorkspaceFiles({ token, id: needWorkspaceId(id), folder: url.searchParams.get('folder') ?? undefined }) })),
1139
1161
  'GET /api/workspaces/:id/files/:fid/versions': (b, id, url, fid) => asAccount(async (token) => ({ versions: await listWorkspaceFileVersions({ token, id: needWorkspaceId(id), fileId: fid }) })),
1162
+ // The address an HTML artifact's frame loads (serveSealed): asked for by the page, with its token.
1163
+ 'POST /api/workspaces/:id/files/:fid/view': (b, id, url, fid) => sealedTicket(id, fid, b.version),
1140
1164
  'POST /api/workspaces/:id/files/:fid/update': (b, id, url, fid) => asAccount(async (token) => ({ file: await updateWorkspaceFile({ token, id: needWorkspaceId(id), fileId: fid, patch: { path: b.path, note: b.note } }) })),
1141
1165
  '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 } }),
1142
1166
  'POST /api/workspaces/:id/folders': (b, id) => asAccount(async (token) => ({ file: await createWorkspaceFolder({ token, id: needWorkspaceId(id), path: String(b.path || '') }) })),
@@ -1188,7 +1212,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1188
1212
  'POST /api/sessions/:id/attach-from-workspace': async (b, id) => {
1189
1213
  const s = get(id)
1190
1214
  const workspace = (readConfig(s.root) || {}).workspace
1191
- if (!workspace) throw httpError(400, 'This session is not in a workspace.')
1215
+ if (!workspace) throw httpError(400, 'This codebase is not in a project.')
1192
1216
  const info = await asAccount((token) => workspaceFileDownload({ token, id: workspace, fileId: String(b.fileId || '') }))
1193
1217
  if (info.size > MAX_SHARED_FILE_BYTES) throw httpError(413, 'That file is too big to send in chat (100 MB at most).')
1194
1218
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'quilt-wsattach-'))
@@ -1229,7 +1253,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1229
1253
  },
1230
1254
  'GET /api/sessions/:id/file': (b, id, url) => {
1231
1255
  const f = get(id).readShared(url.searchParams.get('path'))
1232
- if (!f) throw httpError(404, 'That file is not in this session.')
1256
+ if (!f) throw httpError(404, 'That file is not in this codebase.')
1233
1257
  return f
1234
1258
  },
1235
1259
  'POST /api/sessions/:id/members/approve': async (b, id) => {
@@ -1255,7 +1279,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1255
1279
  'POST /api/sessions/:id/end': async (b, id) => { const room = get(id).room; await get(id).endForEveryone(); await stop(id); unfollowWithCloudAi(room); return { ok: true } },
1256
1280
  'POST /api/sessions/:id/summarize': (b, id) => {
1257
1281
  const r = runs.get(id)
1258
- if (!r) throw httpError(404, 'That session is not running.')
1282
+ if (!r) throw httpError(404, 'That codebase is not running.')
1259
1283
  return { on: r.run.session.setSummarize(b.on ? r.run.summarizer() : null) }
1260
1284
  },
1261
1285
  'POST /api/sessions/:id/sharing': (b, id) => ({ on: get(id).setAgentSharing(b.on !== false) }),
@@ -1359,6 +1383,10 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1359
1383
  return res.end(fs.readFileSync(LOGO))
1360
1384
  }
1361
1385
 
1386
+ // An HTML artifact, running in its sealed frame: the ticket in its address is all it has (never the token).
1387
+ const sealed = req.method === 'GET' && url.pathname.match(/^\/view\/([A-Za-z0-9_-]{20,64})$/)
1388
+ if (sealed) return serveSealed(res, sealed[1], req.headers.host).catch((err) => { if (!res.headersSent) json(502, { error: err.message }); else res.destroy() })
1389
+
1362
1390
  const supplied = req.headers['x-quilt-token'] || url.searchParams.get('t')
1363
1391
  if (supplied !== token) return json(401, { error: 'Open quilt from the link printed by `quilt ui`.' })
1364
1392
 
@@ -1516,7 +1544,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1516
1544
  // token): no sniffing, and a sandbox for every type but PDF, which Chromium won't render sandboxed.
1517
1545
  function serveRaw (res, session, rel, download) {
1518
1546
  const f = session.readSharedBytes(rel)
1519
- if (!f) throw httpError(404, 'That file is not in this session.')
1547
+ if (!f) throw httpError(404, 'That file is not in this codebase.')
1520
1548
  const name = path.basename(f.path)
1521
1549
  const type = download ? 'application/octet-stream' : rawType(name)
1522
1550
  res.writeHead(200, {
@@ -1562,6 +1590,39 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1562
1590
  } finally { fs.rmSync(dir, { recursive: true, force: true }) }
1563
1591
  }
1564
1592
 
1593
+ // An HTML artifact is shown running, as a page, inside a frame on the app's page. It must not be
1594
+ // able to reach the app: so the frame is given an address with a ticket in place of the token
1595
+ // (good for one file, for ten minutes), and the answer seals the page in. `sandbox allow-scripts`
1596
+ // gives it an origin of its own (no reading the app's page, its storage or its answers), and the
1597
+ // rest names what it may load: its own inline code and anything over https, never this computer.
1598
+ const SEALED_CSP = ["sandbox allow-scripts", "default-src 'none'", "script-src 'unsafe-inline' 'unsafe-eval' https:", "style-src 'unsafe-inline' https:", 'img-src https: data: blob:', 'font-src https: data:', 'media-src https: data: blob:', 'connect-src https:', 'worker-src blob:', "frame-src 'none'", "form-action 'none'", "base-uri 'none'"].join('; ')
1599
+ const SEALED_MS = 10 * 60 * 1000
1600
+ const SEALED_MAX_BYTES = 20 * 1024 * 1024
1601
+ const tickets = new Map() // ticket -> { id, fileId, version, until }
1602
+
1603
+ /** A ticket for one version of one workspace file, for the frame that shows it. */
1604
+ function sealedTicket (id, fileId, version) {
1605
+ const now = Date.now()
1606
+ for (const [k, t] of tickets) if (t.until < now) tickets.delete(k)
1607
+ if (tickets.size >= 500) tickets.delete(tickets.keys().next().value)
1608
+ const ticket = crypto.randomBytes(24).toString('base64url')
1609
+ tickets.set(ticket, { id: needWorkspaceId(id), fileId: String(fileId), version: version ? String(version) : undefined, until: now + SEALED_MS })
1610
+ return { url: `/view/${ticket}` }
1611
+ }
1612
+
1613
+ async function serveSealed (res, ticket, host) {
1614
+ const t = tickets.get(ticket)
1615
+ const plain = (status, text) => { res.writeHead(status, { 'content-type': 'text/plain; charset=utf-8', 'content-security-policy': "sandbox; default-src 'none'", 'x-content-type-options': 'nosniff', 'cache-control': 'no-store' }); res.end(text) }
1616
+ if (!t || t.until < Date.now()) { tickets.delete(ticket); return plain(404, 'This view has expired. Open the artifact again.') }
1617
+ const info = await asAccount((token) => workspaceFileDownload({ token, id: t.id, fileId: t.fileId, version: t.version }))
1618
+ if ((info.size || 0) > SEALED_MAX_BYTES) return plain(413, 'This page is too big to show here. Download it to open it.')
1619
+ const r = await fetch(info.url)
1620
+ if (!r.ok) return plain(502, `The file could not be fetched (${r.status}).`)
1621
+ // Only the app's own page may frame it. Named in full: sealed, the page's own origin is no origin, so 'self' would match nothing.
1622
+ res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'content-security-policy': `${SEALED_CSP}; frame-ancestors http://${host}`, 'x-content-type-options': 'nosniff', 'referrer-policy': 'no-referrer', 'cache-control': 'no-store' })
1623
+ await pipeline(Readable.fromWeb(r.body), res).catch(() => res.destroy())
1624
+ }
1625
+
1565
1626
  /** Streams a workspace file to the page, so previews stay same-origin. */
1566
1627
  async function streamWorkspaceFile (req, res, id, fileId) {
1567
1628
  const url = new URL(req.url, 'http://x')
@@ -5,13 +5,13 @@ import { currentVersion, latestRelease, compareVersions } from './releases.js'
5
5
 
6
6
  // How to update each kind of install. Not npm: the heyquilt package there is behind the releases.
7
7
  export const UPDATE_STEPS = 'In the desktop app: Settings → About → Update Quilt. On Linux without a desktop: curl -fsSL https://heyquilt.com/install.sh | sh'
8
- export const UPDATE_HOW = 'Update Quilt (the desktop app: Settings → About → Update Quilt; on Linux without a desktop, run curl -fsSL https://heyquilt.com/install.sh | sh), then rejoin the session.'
8
+ export const UPDATE_HOW = 'Update Quilt (the desktop app: Settings → About → Update Quilt; on Linux without a desktop, run curl -fsSL https://heyquilt.com/install.sh | sh), then join the codebase again.'
9
9
 
10
10
  /**
11
11
  * What the relay tells an app or CLI too old for a session: only what to do. `version` is the oldest
12
12
  * Quilt the session takes, when there is one. It fits a WebSocket close frame (123 bytes).
13
13
  */
14
- export const needsUpdateWords = (version = '') => `This session needs ${version ? `Quilt ${version} or later` : 'a newer version of Quilt'}. Update Quilt, then join again.`
14
+ export const needsUpdateWords = (version = '') => `This codebase needs ${version ? `Quilt ${version} or later` : 'a newer version of Quilt'}. Update Quilt, then join again.`
15
15
 
16
16
  const UPDATE_REFUSAL = /\bUpdate Quilt, then join again\./
17
17
 
package/src/voice.js CHANGED
@@ -125,7 +125,7 @@ export function readLines (doc, { call = '', since = 0, limit = 200 } = {}) {
125
125
  export const AGENT_OPEN_MS = 30 * 1000
126
126
  // A named agent shows joining this long; one that never comes drops out of the call again.
127
127
  export const AGENT_JOIN_MS = 10 * 60 * 1000
128
- export const AGENT_NEEDS_TRANSCRIPTS = 'Agents hear a call through its transcript, and this one is not transcribed: the session owner turns transcripts on.'
128
+ export const AGENT_NEEDS_TRANSCRIPTS = 'Agents hear a call through its transcript, and this one is not transcribed: the codebase\'s owner turns transcripts on.'
129
129
  // Agents in calls are paused (Daniel, 2026-11-06: "I dont want to see any agents join calls"):
130
130
  // agents read transcripts with quilt_voice_transcript, but no agent joins a call, is sent a call's
131
131
  // lines, or speaks in one, and the join and say tools are left out. setAgentsInCalls(true) is for
@@ -222,11 +222,11 @@ export function setAgentLeft (doc, { call, name, leave = true, now = Date.now()
222
222
 
223
223
  /** Why agent `name` isn't in call `call` now, or '' when it is. */
224
224
  export function notInCall (doc, { call, name, members = [] }) {
225
- if (!call) return 'There is no call going on in this session.'
225
+ if (!call) return 'There is no call going on in this codebase.'
226
226
  if (!agentsInCalls) return AGENTS_PAUSED
227
227
  if (!takesAgents(doc, call)) return AGENTS_DEV_ONLY
228
228
  if (!transcribeSetting(doc, members).on) return AGENT_NEEDS_TRANSCRIPTS
229
- if (!(members || []).some((m) => m && m.kind === 'agent' && m.name === name)) return 'Only the session\'s agents join its calls.'
229
+ if (!(members || []).some((m) => m && m.kind === 'agent' && m.name === name)) return 'Only the codebase\'s agents join its calls.'
230
230
  if (leftCall(doc, call, name)) return 'You left this call: come back with quilt_voice_join.'
231
231
  return ''
232
232
  }
@@ -305,7 +305,7 @@ export function agentSays (doc, { call, name, text, members = [], fromChat = fal
305
305
 
306
306
  /** Transcript lines as plain text for an agent: one per line, with who and when. */
307
307
  export function renderLines ({ lines, more, calls }, { tz } = {}) {
308
- if (!lines.length) return calls.length ? 'No transcript lines match.' : 'Nothing has been transcribed in this session yet.'
308
+ if (!lines.length) return calls.length ? 'No transcript lines match.' : 'Nothing has been transcribed in this codebase yet.'
309
309
  const time = (ts) => new Date(ts).toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', ...(tz ? { timeZone: tz } : {}) })
310
310
  const out = []
311
311
  if (more) out.push('(older lines left out; ask with since or call for them)')
@@ -374,7 +374,7 @@ export function inVoice (awareness, clientID) {
374
374
  return out
375
375
  }
376
376
 
377
- export const JOIN_DESCRIPTION = 'Join the session\'s voice call, or leave it (leave: true). Agents are not in a call until someone says their name in it: ' +
377
+ export const JOIN_DESCRIPTION = 'Join the codebase\'s voice call, or leave it (leave: true). Agents are not in a call until someone says their name in it: ' +
378
378
  'then that person\'s line comes to you as a direct message, and your reply to it is said out loud in the call (speaking with quilt_voice_say, or joining with this, works too). ' +
379
379
  'In the call you show muted unless you are speaking, and only a line that says your name reaches you; read the rest with quilt_voice_transcript.'
380
380
 
@@ -383,8 +383,8 @@ export const SAY_DESCRIPTION = 'Say something out loud in the voice call: everyo
383
383
  'When someone names you, first say a few words at once that fit what they asked (what you are about to do, in your own words, never a stock phrase) so they know you heard, then answer once you have it. ' +
384
384
  'Stay quiet when a line was not for you. [laugh], [sigh] and [hesitate] are spoken as sounds.'
385
385
 
386
- export const TRANSCRIPT_DESCRIPTION = 'Read what people said in the session\'s voice calls: the transcript lines, oldest first, with who said what and when. ' +
387
- 'People talk in calls in the Quilt app; while the session owner has transcripts on, each person who agreed has their own speech written here. ' +
386
+ export const TRANSCRIPT_DESCRIPTION = 'Read what people said in the codebase\'s voice calls: the transcript lines, oldest first, with who said what and when. ' +
387
+ 'People talk in calls in the Quilt app; while the codebase\'s owner has transcripts on, each person who agreed has their own speech written here. ' +
388
388
  'quilt_status says who is in a call now. Read the latest call before acting on something decided out loud, and ask in chat when a line is unclear.'
389
389
 
390
390
  /** Who is in a call, for an agent's status: a heading and a line each, or nothing when nobody is. `agents`: the agents in it ({ name }). */
package/src/wake-tool.js CHANGED
@@ -43,7 +43,7 @@ export async function runWakeTool (args, { api, relay, onMention = null }) {
43
43
  const r = await record({ code: args.code })
44
44
  await relay.subscribe({ email: true })
45
45
  await offElsewhere({ keepRelay: true })
46
- return `Quilt wakes you by email now: each event goes to ${r.wake.detail.address} (a few at once come as one email), from the session's own address. Recorded: ${r.wake.label}.`
46
+ return `Quilt wakes you by email now: each event goes to ${r.wake.detail.address} (a few at once come as one email), from the codebase's own address. Recorded: ${r.wake.label}.`
47
47
  }
48
48
  const r = await record({ address: args.address })
49
49
  return `Quilt emailed a code to ${r.wake.pending.address}. Give it back with quilt_wake { method: "email", code: "<the code>" } within 30 minutes; nothing else is sent there until you do.`
package/src/webhooks.js CHANGED
@@ -144,7 +144,7 @@ export function describeSubscription (sub, { showSecret = false } = {}) {
144
144
  if (!sub) return 'No webhook: Quilt only answers quilt_inbox when you ask.'
145
145
  const lines = [`Webhook: Quilt POSTs to ${sub.url} on ${sub.events.join(', ')}${sub.bearer ? ', with your bearer key in the Authorization header' : ''}${sub.coalesce ? ', a burst in one POST (its events in `events`)' : ''}${sub.local ? ' (sent from this computer: the relay cannot reach that URL)' : ''}.`]
146
146
  if (showSecret) lines.push(`Secret (shown once; check x-quilt-signature with it): ${sub.secret}`)
147
- lines.push('Each POST is JSON ({ event, id, session, workspace, room, to, by, text, ts, task?, mail?, call?, context? }; session: the session it is from, which you name as `session` in the tools you answer with, so an answer never lands in another session; workspace: { id } or null; mail: { id } of an email to the session, read with quilt_mail; call: { id } on a direct message that is a line said to you in the session voice call, whose reply is said out loud there; context: the messages before this one between you and its sender, oldest first) with x-quilt-event, x-quilt-delivery, x-quilt-timestamp and ' +
147
+ lines.push('Each POST is JSON ({ event, id, session, workspace, room, to, by, text, ts, task?, mail?, call?, context? }; session: the codebase it is from, which you name as `session` in the tools you answer with, so an answer never lands in another codebase; workspace: { id } of its project, or null; mail: { id } of an email to the codebase, read with quilt_mail; call: { id } on a direct message that is a line said to you in the codebase\'s voice call, whose reply is said out loud there; context: the messages before this one between you and its sender, oldest first) with x-quilt-event, x-quilt-delivery, x-quilt-timestamp and ' +
148
148
  'x-quilt-signature: sha256=HMAC-SHA256(secret, "<timestamp>.<body>"). Answer 2xx quickly; a failed POST is retried a few times. ' +
149
149
  'What you are told is still in quilt_inbox. quilt_webhook_test POSTs a webhook.test event now; stop with quilt_webhook_unsubscribe.')
150
150
  return lines.join('\n')