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
@@ -27,7 +27,7 @@ export const LABELS = {
27
27
  team_members: 'Team membership',
28
28
  invites: 'User invites',
29
29
  roles: 'Roles',
30
- workspaces: 'Workspaces',
30
+ workspaces: 'Projects',
31
31
  billing: 'Billing'
32
32
  }
33
33
 
@@ -56,7 +56,7 @@ export function agentWakeRoutes (ctx) {
56
56
  }
57
57
  const address = cleanAddress(body.address)
58
58
  if (!address) throw new HttpError(400, 'Give the email address you watch.')
59
- if (address.endsWith(`@${MAIL_DOMAIN}`)) throw new HttpError(400, "That's a session's own address: give the inbox you watch yourself.")
59
+ if (address.endsWith(`@${MAIL_DOMAIN}`)) throw new HttpError(400, "That's a codebase's own address: give the inbox you watch yourself.")
60
60
  if (!cf) throw new HttpError(503, 'Email is not set up on this server.')
61
61
  limitCodes(agent.id)
62
62
  const code = String(crypto.randomInt(0, 1_000_000)).padStart(6, '0')
@@ -243,7 +243,7 @@ export function agentRoutes ({ store, user, person, now, limit, limitTokens, lim
243
243
  const u = await person(req)
244
244
  const known = (await personSandboxKeys(u.userId)).filter((k) => k.room === String(body.room))
245
245
  session = known.map((k) => links.open(k.sessionLink)).find(Boolean) || ''
246
- if (!session) throw new HttpError(400, 'paste the session\'s invite link')
246
+ if (!session) throw new HttpError(400, 'paste the codebase\'s invite link')
247
247
  }
248
248
  return envKeyFor(agent, { session, name: body.name, label: body.sessionName })
249
249
  }],
@@ -271,7 +271,7 @@ export function agentRoutes ({ store, user, person, now, limit, limitTokens, lim
271
271
  if (old.revokedAt) throw new HttpError(404, 'no such key')
272
272
  limit(req)
273
273
  const session = links.open(old.sessionLink)
274
- if (!session) throw new HttpError(409, 'make a new key for this session instead (paste its invite link)')
274
+ if (!session) throw new HttpError(409, 'make a new key for this codebase instead (paste its invite link)')
275
275
  const made = await envKeyFor(agent, { session, name: old.name, label: old.sessionName || '', slot: old.slot, rotating: true })
276
276
  await store.revokeAgentAppKey(agent.id, old.id)
277
277
  return { ...made, replaced: old.id }
@@ -322,7 +322,7 @@ export function aiVmRoutes ({ store, person, agentAuth, bearer, now, apiUrl, log
322
322
  out.sessionsMode = b.sessionsMode
323
323
  }
324
324
  if (b.rooms !== undefined) {
325
- if (!Array.isArray(b.rooms) || b.rooms.length > 200 || !b.rooms.every((r) => ROOM.test(String(r)))) throw new HttpError(400, 'rooms: session names')
325
+ if (!Array.isArray(b.rooms) || b.rooms.length > 200 || !b.rooms.every((r) => ROOM.test(String(r)))) throw new HttpError(400, 'rooms: codebase names')
326
326
  out.rooms = [...new Set(b.rooms.map(String))]
327
327
  }
328
328
  if (b.tool !== undefined) {
@@ -431,13 +431,13 @@ export function aiVmRoutes ({ store, person, agentAuth, bearer, now, apiUrl, log
431
431
  const { u, vm } = await mine(req)
432
432
  const f = liveOf(u.userId).forVm
433
433
  if (body.leave === true) {
434
- if (!ROOM.test(String(body.room || ''))) throw new HttpError(400, 'room must be a session name')
434
+ if (!ROOM.test(String(body.room || ''))) throw new HttpError(400, 'room must be a codebase name')
435
435
  f.follow = f.follow.filter((l) => parseInvite(l, { allowRelay: () => true }).room !== body.room)
436
436
  if (!f.leave.includes(body.room)) f.leave = [...f.leave, body.room].slice(-MAX_PENDING)
437
437
  } else {
438
438
  let invite
439
- try { invite = parseInvite(String(body.link || ''), { allowRelay: (s) => isHostedRelay(s) || String(s).replace(/\/+$/, '') === ownRelay }) } catch { throw new HttpError(400, "link must be a Quilt session's invite link") }
440
- if (!invite.secret) throw new HttpError(400, "link must be a Quilt session's invite link")
439
+ try { invite = parseInvite(String(body.link || ''), { allowRelay: (s) => isHostedRelay(s) || String(s).replace(/\/+$/, '') === ownRelay }) } catch { throw new HttpError(400, "link must be a Quilt codebase's invite link") }
440
+ if (!invite.secret) throw new HttpError(400, "link must be a Quilt codebase's invite link")
441
441
  // A session its person didn't choose for it: not joined (its app hands over every session).
442
442
  if (!joins(vm, invite.room)) return { ok: true, joins: false }
443
443
  const link = buildInvite({ server: invite.relay || HOSTED_RELAY, room: invite.room, secret: invite.secret }, isHostedRelay)
@@ -561,7 +561,7 @@ export function aiVmRoutes ({ store, person, agentAuth, bearer, now, apiUrl, log
561
561
  if (now() - last < RELAY_WAKE_MS) return { ok: true, already: true }
562
562
  relayWokeAt.set(agentId, now())
563
563
  if (relayWokeAt.size > 10_000) relayWokeAt.delete(relayWokeAt.keys().next().value)
564
- await wake(vm, `waiting in ${ROOM.test(String(body.room)) ? body.room : 'a session'}`)
564
+ await wake(vm, `waiting in ${ROOM.test(String(body.room)) ? body.room : 'a codebase'}`)
565
565
  return { ok: true }
566
566
  }]
567
567
  ]
@@ -1,9 +1,12 @@
1
- // App connections (plans/app-connections.md): apps a team, workspace or session connected through
1
+ // App connections (plans/app-connections.md): apps a team, workspace, session or person connected through
2
2
  // Composio (composio.js), and the agents' use of them (quilt_apps, quilt_app_tools, quilt_app_call
3
3
  // in app-tools.js). People connect at a scope, as with secrets; Composio holds the tokens. An
4
4
  // action that only reads runs at once; anything else waits for a person in the session, whose
5
5
  // approval runs it once. Every call is kept (app_calls): the approvals, the session's record of
6
6
  // what agents did in other apps, and the daily cap.
7
+ // A person's own connections (scope 'account') reach every project that person owns and their
8
+ // codebases in no project. A connection is for people and agents ('all'), people only, or only
9
+ // the agents chosen for it ('agents', with their ids).
7
10
  import { HttpError, Raw, needId } from '../http.js'
8
11
  import { orgAccess } from '../org-access.js'
9
12
  import { workspaceReach } from '../workspace-reach.js'
@@ -12,7 +15,11 @@ import { sessionMember, roomLevels, workspaceLevels, LEVEL_WORDS } from '../secr
12
15
  import { composioUser } from '../composio.js'
13
16
 
14
17
  const ROOM = /^[A-Za-z0-9_-]{1,64}$/
15
- const SCOPE = '(org|workspace|session)'
18
+ const SCOPE = '(org|workspace|session|account)'
19
+ const AGENT_ID = /^[0-9a-f-]{36}$/i
20
+ const MAX_CHOSEN = 100
21
+ // What each level is called (secrets have the first three; a person's own connections are for every project).
22
+ const WORDS = { ...LEVEL_WORDS, account: 'Every project' }
16
23
  const APP = /^[a-z0-9_-]{1,64}$/
17
24
  const TOOL = /^[A-Za-z0-9_-]{1,120}$/
18
25
  const DAY_MS = 24 * 60 * 60 * 1000
@@ -61,27 +68,50 @@ export function connectionRoutes (ctx) {
61
68
  return { account: `person:${p.userId}`, kind: 'person', userId: p.userId, agent: null }
62
69
  }
63
70
 
71
+ /** The level of a person's own connections: theirs reach every project they own. */
72
+ const accountLevel = async (userId) => ({ type: 'account', id: userId, name: (await store.profile(userId))?.name || '' })
73
+ /** A workspace's levels for connections: itself, its team, and (a person's own project) its owner's own. */
74
+ async function levelsOfWorkspace (ws) {
75
+ const levels = await workspaceLevels(store, ws)
76
+ if (ws.ownerUserId) levels.push(await accountLevel(ws.ownerUserId))
77
+ return levels
78
+ }
79
+ /** A session's levels for connections: as for secrets, then the own connections of whoever owns its project, or owns it when it is in none. */
80
+ async function levelsOfRoom (room) {
81
+ const found = await roomLevels(store, room)
82
+ if (!found) return null
83
+ const ws = found.session.workspaceId ? await store.workspaceById(found.session.workspaceId) : null
84
+ const owner = ws ? ws.ownerUserId : String(found.session.ownerAccount || '').startsWith('person:') ? found.session.ownerAccount.slice(7) : null
85
+ return owner ? { ...found, levels: [...found.levels, await accountLevel(owner)] } : found
86
+ }
87
+
64
88
  /** One scope as a person reaches it, as for secrets: { type, id, name, levels, canManage, me }. */
65
89
  async function scopeOf (req, type, rawId) {
66
90
  const me = await whoCalls(req)
67
91
  if (me.kind !== 'person') throw new HttpError(403, 'People connect apps; agents use them with quilt_app_call.')
92
+ if (type === 'account') {
93
+ // Only your own: "me", or your own id.
94
+ if (rawId !== 'me' && rawId !== me.userId) throw new HttpError(404, 'no such account')
95
+ const level = await accountLevel(me.userId)
96
+ return { type, id: me.userId, name: level.name, levels: [level], canManage: true, me }
97
+ }
68
98
  if (type === 'org') {
69
99
  const a = await orgAccess(store, me.userId, rawId)
70
100
  return { type, id: a.org.id, name: a.org.name, levels: [{ type, id: a.org.id, name: a.org.name }], canManage: a.can('org', 'u'), me }
71
101
  }
72
102
  if (type === 'workspace') {
73
- const r = await reach(req, needId(rawId, 'workspace'))
74
- return { type, id: r.ws.id, name: r.ws.name, levels: await workspaceLevels(store, r.ws), canManage: !!r.access.admin, me }
103
+ const r = await reach(req, needId(rawId, 'project'))
104
+ return { type, id: r.ws.id, name: r.ws.name, levels: await levelsOfWorkspace(r.ws), canManage: !!r.access.admin, me }
75
105
  }
76
106
  const room = String(rawId)
77
- if (!ROOM.test(room)) throw new HttpError(404, 'no such session')
78
- const found = await roomLevels(store, room)
79
- if (!found || !(await sessionMember(store, room, me.account))) throw new HttpError(404, 'no such session')
107
+ if (!ROOM.test(room)) throw new HttpError(404, 'no such codebase')
108
+ const found = await levelsOfRoom(room)
109
+ if (!found || !(await sessionMember(store, room, me.account))) throw new HttpError(404, 'no such codebase')
80
110
  // Anyone in the session connects apps for it (the owner removes any; others their own).
81
111
  return { type, id: room, name: found.session.name || '', levels: found.levels, canManage: true, owner: found.session.ownerAccount === me.account, me, session: found.session }
82
112
  }
83
113
 
84
- const needManage = (s) => { if (!s.canManage) throw new HttpError(403, s.type === 'org' ? 'Only the team\'s owner, or a role with Org settings: Update, connects apps for the team.' : 'Only the workspace\'s admins connect apps for it.') }
114
+ const needManage = (s) => { if (!s.canManage) throw new HttpError(403, s.type === 'org' ? 'Only the team\'s owner, or a role with Org settings: Update, connects apps for the team.' : 'Only the project\'s admins connect apps for it.') }
85
115
  const mayChange = (s, c) => s.type !== 'session' ? s.canManage : (s.owner || c.createdBy === s.me.account)
86
116
 
87
117
  /** A connection still pending at Composio: asked again, so one finished without the callback shows. */
@@ -95,10 +125,22 @@ export function connectionRoutes (ctx) {
95
125
  }
96
126
 
97
127
  const view = async (c, level, extra = {}) => ({
98
- id: c.id, app: c.app, name: c.appName || c.app, logo: c.logo, status: c.status, who: c.who,
128
+ id: c.id, app: c.app, name: c.appName || c.app, logo: c.logo, status: c.status, who: c.who, agents: c.who === 'agents' ? (c.agents || []) : [],
99
129
  level: level.type, levelName: level.name || '', by: await nameOf(c.createdBy), createdAt: c.createdAt, ...extra
100
130
  })
101
131
 
132
+ /** Who may use a connection, from a request: { who, agents }. 'agents' names the agents chosen for it by id. */
133
+ function whoFrom (body, fallback = null) {
134
+ const who = body.who === undefined && fallback ? fallback : body.who
135
+ if (who !== 'all' && who !== 'people' && who !== 'agents') throw new HttpError(400, 'who is "all", "people" or "agents"')
136
+ if (who !== 'agents') return { who, agents: [] }
137
+ const agents = [...new Set(Array.isArray(body.agents) ? body.agents.map(String) : [])]
138
+ if (!agents.length || agents.length > MAX_CHOSEN || !agents.every((a) => AGENT_ID.test(a))) throw new HttpError(400, 'Say which agents may use it: agents is a list of their ids.')
139
+ return { who, agents }
140
+ }
141
+ /** Whether an agent may use a connection: one for everyone, or one that chose it. */
142
+ const agentMay = (c, agentId) => c.who === 'all' || (c.who === 'agents' && !!agentId && (c.agents || []).includes(agentId))
143
+
102
144
  /** Every connection a session (or workspace) reaches, nearest level first: [{ connection, level }]. */
103
145
  async function reachable (levels) {
104
146
  const out = []
@@ -121,17 +163,17 @@ export function connectionRoutes (ctx) {
121
163
 
122
164
  /** The caller, when a member of the session: { me, found }; otherwise 404. */
123
165
  async function member (req, room) {
124
- if (!ROOM.test(room)) throw new HttpError(404, 'no such session')
166
+ if (!ROOM.test(room)) throw new HttpError(404, 'no such codebase')
125
167
  const me = await whoCalls(req)
126
- if (!(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such session')
127
- const found = await roomLevels(store, room)
128
- if (!found) throw new HttpError(404, 'no such session')
168
+ if (!(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such codebase')
169
+ const found = await levelsOfRoom(room)
170
+ if (!found) throw new HttpError(404, 'no such codebase')
129
171
  return { me, found }
130
172
  }
131
173
 
132
174
  /** The connections the caller may use in the session, nearest level first. */
133
175
  async function usable (me, found) {
134
- return (await reachable(found.levels)).filter(({ connection: c }) => c.status === 'active' && (me.kind === 'person' || c.who === 'all'))
176
+ return (await reachable(found.levels)).filter(({ connection: c }) => c.status === 'active' && (me.kind === 'person' || agentMay(c, me.agent && me.agent.id)))
135
177
  }
136
178
 
137
179
  const capKey = (session) => session.workspaceId ? `workspace:${session.workspaceId}` : `session:${session.room || ''}`
@@ -155,7 +197,7 @@ export function connectionRoutes (ctx) {
155
197
  Object.assign(out, { ok: call.state === 'ran', data: s.length > MAX_ANSWER ? { truncated: true, start: s.slice(0, MAX_ANSWER) } : data, error: call.error || null })
156
198
  }
157
199
  if (call.decidedBy) out.decidedBy = await nameOf(call.decidedBy)
158
- if (call.state === 'waiting') out.message = `Waiting for a person in the session to approve ${call.tool} on ${appName || call.app}: they see it in the session's chat. Call quilt_app_call again with approval "${call.id}" to get the result.`
200
+ if (call.state === 'waiting') out.message = `Waiting for a person in the codebase to approve ${call.tool} on ${appName || call.app}: they see it in the codebase's chat. Call quilt_app_call again with approval "${call.id}" to get the result.`
159
201
  if (call.state === 'declined') out.message = `${out.decidedBy || 'A person'} declined ${call.tool}: don't run it again unless they ask you to.`
160
202
  return out
161
203
  }
@@ -201,25 +243,24 @@ export function connectionRoutes (ctx) {
201
243
  if (!APP.test(app)) throw new HttpError(400, 'Say which app to connect.')
202
244
  const t = await composio.toolkit(app)
203
245
  const l = await composio.link({ user: composioUser(s.type, s.id), app, callbackUrl: `${apiUrl}/v1/connections/done` })
204
- const c = await store.addAppConnection({ scopeType: s.type, scopeId: s.id, app, appName: String(t.name || app).slice(0, 120), logo: String(t.logo || '').slice(0, 500), composioId: l.composioId, status: 'pending', who: body.who === 'people' ? 'people' : 'all', createdBy: s.me.account })
246
+ const c = await store.addAppConnection({ scopeType: s.type, scopeId: s.id, app, appName: String(t.name || app).slice(0, 120), logo: String(t.logo || '').slice(0, 500), composioId: l.composioId, status: 'pending', ...whoFrom(body, 'all'), createdBy: s.me.account })
205
247
  return { url: l.url, connection: await view(c, s.levels[0]) }
206
248
  }],
207
249
 
208
- // Who may use it: 'all' (people and agents) or 'people'.
250
+ // Who may use it: 'all' (people and agents), 'people', or 'agents' with the ids of the agents chosen.
209
251
  ['PATCH', new RegExp(`^/v1/connections/${SCOPE}/([^/]+)/([^/]+)$`), async (req, body, [type, id, cid]) => {
210
252
  const s = await scopeOf(req, type, id)
211
253
  const c = await store.appConnectionById(needId(cid, 'connection'))
212
254
  if (!c || c.scopeType !== s.type || c.scopeId !== s.id) throw new HttpError(404, 'no such connection')
213
- if (!mayChange(s, c)) throw new HttpError(403, 'Only whoever connected it, or the session\'s owner, changes it.')
214
- if (body.who !== 'all' && body.who !== 'people') throw new HttpError(400, 'who is "all" or "people"')
215
- return view(await store.updateAppConnection(c.id, { who: body.who }), s.levels[0])
255
+ if (!mayChange(s, c)) throw new HttpError(403, 'Only whoever connected it, or the codebase\'s owner, changes it.')
256
+ return view(await store.updateAppConnection(c.id, whoFrom(body)), s.levels[0])
216
257
  }],
217
258
 
218
259
  ['DELETE', new RegExp(`^/v1/connections/${SCOPE}/([^/]+)/([^/]+)$`), async (req, body, [type, id, cid]) => {
219
260
  const s = await scopeOf(req, type, id)
220
261
  const c = await store.appConnectionById(needId(cid, 'connection'))
221
262
  if (!c || c.scopeType !== s.type || c.scopeId !== s.id) throw new HttpError(404, 'no such connection')
222
- if (!mayChange(s, c)) throw new HttpError(403, 'Only whoever connected it, or the session\'s owner, removes it.')
263
+ if (!mayChange(s, c)) throw new HttpError(403, 'Only whoever connected it, or the codebase\'s owner, removes it.')
223
264
  await composio.remove(c.composioId)
224
265
  await store.deleteAppConnection(c.id)
225
266
  return { ok: true }
@@ -260,14 +301,14 @@ export function connectionRoutes (ctx) {
260
301
  const t = await composio.tool(toolSlug)
261
302
  const options = (await usable(me, found)).filter((x) => x.connection.app === t.app)
262
303
  const pick = body.connection ? options.find((x) => x.connection.id === body.connection) : options[0]
263
- if (!pick) throw new HttpError(400, `No ${t.app} connection you may use in this session. A person connects it in Session settings → Connections.`)
304
+ if (!pick) throw new HttpError(400, `No ${t.app} connection you may use in this codebase. A person connects it in Codebase settings → Connections.`)
264
305
  const session = found.session
265
306
  const key = capKey({ ...session, room })
266
- if (await store.countAppCalls(key, now() - DAY_MS) >= callsPerDay) throw new HttpError(429, `This ${session.workspaceId ? 'workspace' : 'session'} made its ${callsPerDay} app calls for the last day. Try again later.`)
307
+ if (await store.countAppCalls(key, now() - DAY_MS) >= callsPerDay) throw new HttpError(429, `This ${session.workspaceId ? 'project' : 'codebase'} made its ${callsPerDay} app calls for the last day. Try again later.`)
267
308
  const call = await store.addAppCall({ room, capKey: key, connectionId: pick.connection.id, app: t.app, tool: t.slug, args, readOnly: t.readOnly, state: 'waiting', account: me.account })
268
309
  if (t.readOnly) return answer(await run(call, pick.connection))
269
310
  const who = await nameOf(me.account)
270
- await sayInRoom(room, { approval: call.id, text: `${who} asks to run ${t.slug} on ${pick.connection.appName || t.app} (${LEVEL_WORDS[pick.level.type].toLowerCase()} connection): ${argsLine(args)}. A person in the session approves or declines it here.` }).catch((err) => log(`connections: tell ${room}: ${err.message}`))
311
+ await sayInRoom(room, { approval: call.id, text: `${who} asks to run ${t.slug} on ${pick.connection.appName || t.app} (${WORDS[pick.level.type].toLowerCase()} connection): ${argsLine(args)}. A person in the codebase approves or declines it here.` }).catch((err) => log(`connections: tell ${room}: ${err.message}`))
271
312
  return answer(await waitFor(call.id) || call, pick.connection.appName)
272
313
  }],
273
314
 
@@ -294,7 +335,7 @@ export function connectionRoutes (ctx) {
294
335
  let ended = decided
295
336
  if (allow) {
296
337
  const c = call.connectionId ? await store.appConnectionById(call.connectionId) : null
297
- const still = c && c.status === 'active' && (await usable({ kind: call.account.startsWith('person:') ? 'person' : 'agent' }, found)).some((x) => x.connection.id === c.id)
338
+ const still = c && c.status === 'active' && (await usable(call.account.startsWith('person:') ? { kind: 'person' } : { kind: 'agent', agent: { id: call.account.slice('agent:'.length) } }, found)).some((x) => x.connection.id === c.id)
298
339
  ended = still ? await run(decided, c) : (await store.updateAppCall(call.id, { state: 'failed', error: 'That connection was removed.', ranAt: now() }, { from: 'approved' })) || decided
299
340
  }
300
341
  const what = allow ? (ended.state === 'ran' ? 'ran it' : `it failed: ${String(ended.error || '').slice(0, 200)}`) : 'declined it'
@@ -7,13 +7,13 @@ import { ownType, grantView } from '../access.js'
7
7
  export const ROOM = /^[A-Za-z0-9_-]{1,64}$/
8
8
  export const ACCOUNT = /^(person|agent):[A-Za-z0-9_-]{1,64}$/
9
9
  const EMAIL_KEY = /^[^\s@,;<>"()\\]+@[^\s@,;<>"()\\]+$/
10
- export const NOT_YET = "That session hasn't reached heyquilt.com yet. Try again in a minute."
10
+ export const NOT_YET = "That codebase hasn't reached heyquilt.com yet. Try again in a minute."
11
11
 
12
12
  /**
13
13
  * The session's owner, from their request: { me: 'person:<id>', userId, session }. 404 for a
14
14
  * session the API hasn't heard of (the relay reports new ones within seconds), 403 for anyone else.
15
15
  */
16
- export async function sessionOwner (store, person, req, room, forbidden = 'Only the session owner can change who gets in.') {
16
+ export async function sessionOwner (store, person, req, room, forbidden = "Only the codebase's owner can change who gets in.") {
17
17
  const { userId } = await person(req)
18
18
  const me = `person:${userId}`
19
19
  if (!ROOM.test(room)) throw new HttpError(404, NOT_YET)
@@ -99,9 +99,9 @@ export function mailRoutes (ctx) {
99
99
 
100
100
  /** The caller, when they are a member of the session; otherwise 404 (no hint the session exists). */
101
101
  async function member (req, room) {
102
- if (!ROOM.test(room)) throw new HttpError(404, 'no such session')
102
+ if (!ROOM.test(room)) throw new HttpError(404, 'no such codebase')
103
103
  const me = await whoCalls(req)
104
- if (!(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such session')
104
+ if (!(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such codebase')
105
105
  return me
106
106
  }
107
107
 
@@ -173,7 +173,7 @@ export function mailRoutes (ctx) {
173
173
  })
174
174
 
175
175
  async function send (room, me, b, body) {
176
- if (!b.sending) throw new HttpError(403, "The session's owner turned sending off for this session.")
176
+ if (!b.sending) throw new HttpError(403, "The codebase's owner turned sending off for this codebase.")
177
177
  let original = null
178
178
  if (body.replyTo !== undefined) {
179
179
  if (!UUID.test(String(body.replyTo)) || !(original = await store.mailById(room, String(body.replyTo)))) throw new HttpError(404, 'no such message to reply to')
@@ -198,7 +198,7 @@ export function mailRoutes (ctx) {
198
198
  if (bytes > MAX_SEND_BYTES) throw new HttpError(413, 'A message is at most 5 MiB with its attachments.')
199
199
  // Counted before sending, so messages sent at once can't slip past the day's limit together.
200
200
  const sent = await store.countSentMail(room, now() - DAY_MS)
201
- if (sent >= sendPerDay) throw new HttpError(429, `This session has sent its ${sendPerDay} emails for today; try again tomorrow.`)
201
+ if (sent >= sendPerDay) throw new HttpError(429, `This codebase has sent its ${sendPerDay} emails for today; try again tomorrow.`)
202
202
 
203
203
  const from = mailAddress(b.localPart)
204
204
  const headers = { 'X-Quilt-Session': room }
@@ -326,7 +326,7 @@ export function mailRoutes (ctx) {
326
326
  if (!address) return { sent: false, why: 'not woken by email' }
327
327
  const events = Array.isArray(payload && payload.events) && payload.events.length ? payload.events : [payload]
328
328
  const room = String((events[0] && events[0].session) || '')
329
- if (!ROOM.test(room)) throw new HttpError(400, 'which session')
329
+ if (!ROOM.test(room)) throw new HttpError(400, 'which codebase')
330
330
  if (!cf) throw new HttpError(503, 'Sending email is not set up on this server.')
331
331
  limitWakeMail(account)
332
332
  const session = await store.sessionByRoom(room)
@@ -338,7 +338,7 @@ export function mailRoutes (ctx) {
338
338
  if (p.event === 'chat.mention') return `${who} mentioned you: ${text}`
339
339
  if (p.event === 'chat.dm') return `${who} wrote to you: ${text}`
340
340
  if (p.event === 'task.assigned') return `${who} handed you a task: "${text}"${p.task && p.task.id ? ` (task ${p.task.id})` : ''}`
341
- if (p.event === 'email.received') return `New email for the session: ${text}${p.mail && p.mail.id ? ` (read it with quilt_mail, read: "${p.mail.id}")` : ''}`
341
+ if (p.event === 'email.received') return `New email for the codebase: ${text}${p.mail && p.mail.id ? ` (read it with quilt_mail, read: "${p.mail.id}")` : ''}`
342
342
  if (p.event === 'webhook.test') return 'A test from Quilt: email wake works.'
343
343
  return `${who}: ${text}`
344
344
  }
@@ -352,8 +352,8 @@ export function mailRoutes (ctx) {
352
352
  const text = [
353
353
  ...events.map((p) => `- ${line(p)}`),
354
354
  '',
355
- `Answer in Quilt, in session ${room} (${sessionName}): quilt_message with session "${room}", or quilt_inbox to see what waits for you there.`,
356
- 'A reply to this email goes to the session\'s mailbox, not into its chat.'
355
+ `Answer in Quilt, in codebase ${room} (${sessionName}): quilt_message with session "${room}", or quilt_inbox to see what waits for you there.`,
356
+ 'A reply to this email goes to the codebase\'s mailbox, not into its chat.'
357
357
  ].join('\n')
358
358
  await cf.send({ from: { address: mailAddress(b.localPart), name: `Quilt · ${sessionName}`.slice(0, 100) }, to: [address], subject: subject.replace(/[\r\n]+/g, ' ').slice(0, 300), text, headers: { 'X-Quilt-Session': room } })
359
359
  return { sent: true, count: events.length }
@@ -403,7 +403,7 @@ export function mailRoutes (ctx) {
403
403
  const b = await mailboxOf(room, me.account)
404
404
  const rest = (b.wake || []).filter((n) => n.toLowerCase() !== name.toLowerCase())
405
405
  const wake = body.on === false ? rest : [...rest, name]
406
- if (wake.length > MAX_WAKE) throw new HttpError(400, `At most ${MAX_WAKE} email agents a session.`)
406
+ if (wake.length > MAX_WAKE) throw new HttpError(400, `At most ${MAX_WAKE} email agents a codebase.`)
407
407
  const sent = await store.countSentMail(room, now() - DAY_MS)
408
408
  return boxView(await store.updateMailbox(b.localPart, { wake }), sent)
409
409
  }],
@@ -411,7 +411,7 @@ export function mailRoutes (ctx) {
411
411
  ['PUT', /^\/v1\/sessions\/([^/]+)\/mail\/sending$/, async (req, body, [room]) => {
412
412
  const me = await member(req, room)
413
413
  const session = await store.sessionByRoom(room)
414
- if (!session || session.ownerAccount !== me.account) throw new HttpError(403, "Only the session's owner can turn sending on or off.")
414
+ if (!session || session.ownerAccount !== me.account) throw new HttpError(403, "Only the codebase's owner can turn sending on or off.")
415
415
  const b = await mailboxOf(room, me.account)
416
416
  const sent = await store.countSentMail(room, now() - DAY_MS)
417
417
  return boxView(await store.updateMailbox(b.localPart, { sending: body.on !== false }), sent)
@@ -80,7 +80,7 @@ export function relayRoutes ({ store, now, log, bearer, relaySecret }) {
80
80
  if (t - prunedAt >= DAY_MS) {
81
81
  prunedAt = t
82
82
  await store.pruneActivity({ before: t - KEEP_MS, seenBefore: t - SEEN_MS })
83
- .catch((err) => log(`could not prune session activity: ${err?.message || err}`))
83
+ .catch((err) => log(`could not prune codebase activity: ${err?.message || err}`))
84
84
  }
85
85
  return { ok: true, applied, skipped: body.events.length - events.length }
86
86
  }, { maxBody: PRESENCE_BODY }],
@@ -94,17 +94,17 @@ export function secretRoutes (ctx) {
94
94
  return { type, id: a.org.id, name: a.org.name, slug: a.org.slug, levels: [{ type, id: a.org.id, name: a.org.name, slug: a.org.slug }], canManage: a.can('org', 'u'), me }
95
95
  }
96
96
  if (type === 'workspace') {
97
- const r = await reach(req, needId(rawId, 'workspace'))
97
+ const r = await reach(req, needId(rawId, 'project'))
98
98
  return { type, id: r.ws.id, name: r.ws.name, levels: await workspaceLevels(store, r.ws), canManage: !!r.access.admin, me, ws: r.ws }
99
99
  }
100
100
  const room = String(rawId)
101
- if (!ROOM.test(room)) throw new HttpError(404, 'no such session')
101
+ if (!ROOM.test(room)) throw new HttpError(404, 'no such codebase')
102
102
  const found = await roomLevels(store, room)
103
- if (!found || !(await sessionMember(store, room, me.account))) throw new HttpError(404, 'no such session')
103
+ if (!found || !(await sessionMember(store, room, me.account))) throw new HttpError(404, 'no such codebase')
104
104
  return { type, id: room, name: found.session.name || '', levels: found.levels, canManage: found.session.ownerAccount === me.account, me, session: found.session }
105
105
  }
106
106
 
107
- const needManage = (s) => { if (!s.canManage) throw new HttpError(403, s.type === 'org' ? 'Only the team\'s owner, or a role with Org settings: Update, manages team secrets.' : s.type === 'workspace' ? 'Only the workspace\'s admins manage its secrets.' : 'Only the session owner manages its secrets.') }
107
+ const needManage = (s) => { if (!s.canManage) throw new HttpError(403, s.type === 'org' ? 'Only the team\'s owner, or a role with Org settings: Update, manages team secrets.' : s.type === 'workspace' ? 'Only the project\'s admins manage its secrets.' : "Only the codebase's owner manages its secrets.") }
108
108
 
109
109
  const rowView = (s, level, extra = {}) => ({
110
110
  id: s.id, name: s.name, level: level.type, levelName: level.name || '', digest: shortDigest(s.digest), upstream: s.upstream,
@@ -223,7 +223,7 @@ export function secretRoutes (ctx) {
223
223
  needManage(s)
224
224
  const patch = {}
225
225
  if (body.inheritOff !== undefined) {
226
- if (s.levels.length < 2) throw new HttpError(400, s.type === 'org' ? 'A team has nothing above it to switch off.' : 'Nothing above this to switch off: it is not in a workspace or team.')
226
+ if (s.levels.length < 2) throw new HttpError(400, s.type === 'org' ? 'A team has nothing above it to switch off.' : 'Nothing above this to switch off: it is not in a project or team.')
227
227
  patch.inheritOff = body.inheritOff === true
228
228
  patch.inheritOffBy = patch.inheritOff ? s.me.account : null
229
229
  patch.inheritOffAt = patch.inheritOff ? now() : null
@@ -291,9 +291,9 @@ export function secretRoutes (ctx) {
291
291
  // `quilt run` sets. Never a value.
292
292
  ['GET', /^\/v1\/sessions\/([^/]+)\/secret-names$/, async (req, body, [room]) => {
293
293
  const me = await whoCalls(req, { pass: /^QuiltPass\s/i.test(String(req.headers.authorization || '')) })
294
- if (!ROOM.test(room) || !(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such session')
294
+ if (!ROOM.test(room) || !(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such codebase')
295
295
  const names = await namesFor(room, me)
296
- if (!names) throw new HttpError(404, 'no such session')
296
+ if (!names) throw new HttpError(404, 'no such codebase')
297
297
  return { room, kind: me.kind, hosted: !!me.hosted, names: publicNames(names) }
298
298
  }],
299
299
 
@@ -303,10 +303,10 @@ export function secretRoutes (ctx) {
303
303
  const me = await whoCalls(req)
304
304
  if (me.hosted) throw new HttpError(403, 'Hosted agents run no commands, so they use no secrets.')
305
305
  const room = String(body.room || '')
306
- if (!ROOM.test(room) || !(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such session')
306
+ if (!ROOM.test(room) || !(await sessionMember(store, room, me.account, { agent: me.agent }))) throw new HttpError(404, 'no such codebase')
307
307
  limit(`run:${me.account}`, 120, 'too many runs; wait a minute')
308
308
  const names = await namesFor(room, me)
309
- if (!names) throw new HttpError(404, 'no such session')
309
+ if (!names) throw new HttpError(404, 'no such codebase')
310
310
  const label = String(body.label || '').replace(/[\u0000-\u001f\u007f]/g, ' ').slice(0, MAX_LABEL) // eslint-disable-line no-control-regex
311
311
  const token = newToken('qrun_')
312
312
  const run = await store.createSecretRun({ tokenHash: hashToken(token), room, account: me.account, kind: me.kind, label, expiresAt: now() + RUN_TTL_MS })
@@ -414,11 +414,11 @@ export function secretRoutes (ctx) {
414
414
  const [kind, id] = run.account.split(':')
415
415
  const agent = kind === 'agent' ? await store.agentById(id).catch(() => null) : null
416
416
  if (kind === 'agent' && (!agent || agent.revokedAt)) throw new HttpError(401, 'this agent was revoked')
417
- if (!(await sessionMember(store, run.room, run.account, { agent }))) throw new HttpError(403, 'not in this session any more')
417
+ if (!(await sessionMember(store, run.room, run.account, { agent }))) throw new HttpError(403, 'not in this codebase any more')
418
418
  const found = await roomLevels(store, run.room)
419
419
  const { effective } = await resolveLevels(store, found ? found.levels : [])
420
420
  const hit = effective.get(name)
421
- if (!hit) throw new HttpError(404, `${name.slice(0, 64)} is not a secret in this session (or it is switched off here)`)
421
+ if (!hit) throw new HttpError(404, `${name.slice(0, 64)} is not a secret in this codebase (or it is switched off here)`)
422
422
  const ask = run.kind === 'person' && hit.secret.who === 'people' ? (await store.listSecretRunAsks(run.id)).find((a) => a.secretId === hit.secret.id) || null : undefined
423
423
  const verdict = mayUse({ kind: run.kind, agentId: agent?.id || null, secret: hit.secret, level: hit.level, ask })
424
424
  if (!verdict.ok) throw new HttpError(403, `${name}: ${verdict.why}`)
@@ -12,7 +12,7 @@ import { sessionOwner, ACCOUNT, letAgentBackIn } from './grants.js'
12
12
  import { collaboratorsOf } from './sessions.js'
13
13
 
14
14
  export const SESSION_INVITE_TTL_MS = 7 * 24 * 60 * 60 * 1000
15
- const FORBIDDEN = 'Only the session owner can invite people.'
15
+ const FORBIDDEN = "Only the codebase's owner can invite people."
16
16
  // One address, nothing a mail header could split (the same rule as org invites).
17
17
  const STRICT_EMAIL = /^[^\s@,;<>"()\\]+@[^\s@,;<>"()\\]+$/
18
18
 
@@ -48,11 +48,11 @@ export function sessionInviteRoutes ({ store, person, now, site, mailer, log, li
48
48
  async function send (to, { userId, session, link }) {
49
49
  const inviter = await store.profile(userId)
50
50
  const inviterName = stripInvisible(inviter?.name || '').join('').trim() || undefined
51
- const msg = sessionInviteEmail({ inviterName, sessionName: session.name || 'Untitled session', link, site })
51
+ const msg = sessionInviteEmail({ inviterName, sessionName: session.name || 'Untitled codebase', link, site })
52
52
  try {
53
53
  await mailer.send({ to, ...msg })
54
54
  } catch (err) {
55
- log(`session invite email failed: ${err?.stack || err?.message || err}`)
55
+ log(`codebase invite email failed: ${err?.stack || err?.message || err}`)
56
56
  throw new HttpError(502, "The invite was saved, but the email didn't send. Cancel it and invite them again.")
57
57
  }
58
58
  }
@@ -70,7 +70,7 @@ export function sessionInviteRoutes ({ store, person, now, site, mailer, log, li
70
70
  if (!type) throw new HttpError(400, 'no such access type')
71
71
  let inv = null
72
72
  try { inv = parseInvite(body.link, { allowRelay: () => true }) } catch {}
73
- if (!inv || inv.room !== room) throw new HttpError(400, "Send this session's invite link.")
73
+ if (!inv || inv.room !== room) throw new HttpError(400, "Send this codebase's invite link.")
74
74
  const link = String(body.link).trim()
75
75
  const to = body.to && typeof body.to === 'object' ? body.to : {}
76
76
 
@@ -93,7 +93,7 @@ export function sessionInviteRoutes ({ store, person, now, site, mailer, log, li
93
93
  if (await store.openSessionInvite(room, { account }, now())) throw new HttpError(409, taken)
94
94
  // Inviting them again would overwrite the access they have, and cancelling that invite
95
95
  // would then take it all away.
96
- if (await store.grantFor(room, account)) throw new HttpError(409, 'They already have access to this session. Change it in Session settings.')
96
+ if (await store.grantFor(room, account)) throw new HttpError(409, 'They already have access to this codebase. Change it in Codebase settings.')
97
97
  const invite = await createInvite({ room, account, accountName: who.name, typeId: type.id, invitedBy: owner.me, expiresAt: now() + SESSION_INVITE_TTL_MS, link }, taken,
98
98
  { room, account, typeId: type.id, grantedBy: owner.me })
99
99
  // A person hears about it at their sign-in email (looked up here, never sent back). An
@@ -7,7 +7,7 @@ import { summarize, collaborators, myVisits, isTimeZone, weekStart, monthStart,
7
7
  import { cleanSessionName, BAD_SESSION_NAME } from '../../session-name.js'
8
8
 
9
9
  const ROOM = /^[A-Za-z0-9_-]{1,64}$/
10
- const NO_SESSION = 'no such session'
10
+ const NO_SESSION = 'no such codebase'
11
11
 
12
12
  /** An account's dashboard: its sessions, with the people in each, and the totals. */
13
13
  export async function overviewOf (store, account, tz, t) {
@@ -57,7 +57,7 @@ export function sessionRoutes ({ store, now, person }) {
57
57
  const name = cleanSessionName(body.name)
58
58
  if (!name) throw new HttpError(400, BAD_SESSION_NAME)
59
59
  const { session } = await mine(account, room)
60
- if (session.ownerAccount !== account) throw new HttpError(403, 'Only the session owner can rename it.')
60
+ if (session.ownerAccount !== account) throw new HttpError(403, "Only the codebase's owner can rename it.")
61
61
  const renamed = await store.renameSession(room, name, now())
62
62
  return { session: { room, name: renamed.name } }
63
63
  }],
@@ -67,7 +67,7 @@ export function sessionRoutes ({ store, now, person }) {
67
67
  ['GET', /^\/v1\/me\/sessions\/([^/]+)\/audit$/, async (req, body, [room]) => {
68
68
  const account = await me(req)
69
69
  const { session, visits } = await mine(account, room)
70
- if (session.ownerAccount !== account) throw new HttpError(403, 'Only the session owner can see its audit trail.')
70
+ if (session.ownerAccount !== account) throw new HttpError(403, "Only the codebase's owner can see its audit trail.")
71
71
  const q = new URL(req.url, 'http://x').searchParams
72
72
  const t = now()
73
73
  const num = (k, d) => { const n = Number(q.get(k)); return q.has(k) && Number.isFinite(n) ? n : d }
@@ -17,7 +17,7 @@ import { isHostedRelay, HOSTED_RELAY } from '../../settings.js'
17
17
  const ROOM = /^[A-Za-z0-9_-]{1,64}$/
18
18
  export const AGENT_WEBHOOK_EVENTS = ['session.started']
19
19
  /** Why someone else's agent in a workspace is never invited to every session there. */
20
- export const FOREIGN_JOINS = 'Only its owner can have an agent invited to every session.'
20
+ export const FOREIGN_JOINS = 'Only its owner can have an agent invited to every codebase.'
21
21
 
22
22
  /** A placement as the routes answer it; an agent with none is 'manual' (it works only where it is added). */
23
23
  export function placementView (agentId, p) {
@@ -28,7 +28,7 @@ export function placementView (agentId, p) {
28
28
  /** A member agent's `sessions`: 'all' or 'invited', and only for an agent. Undefined keeps what the member has. */
29
29
  export function cleanMemberSessions (value, kind) {
30
30
  if (value === undefined) return undefined
31
- if (kind !== 'agent') throw new HttpError(400, 'Only an agent joins sessions by itself.')
31
+ if (kind !== 'agent') throw new HttpError(400, 'Only an agent joins codebases by itself.')
32
32
  if (!SESSIONS.includes(value)) throw new HttpError(400, 'Sessions is all or invited.')
33
33
  return value
34
34
  }
@@ -94,7 +94,7 @@ export function workspaceAgentRoutes (ctx) {
94
94
  const p = cleanPlacement(body)
95
95
  for (const id of p.workspaceIds) {
96
96
  const ws = await store.workspaceById(id)
97
- if (!ws || !owns(ws)) throw new HttpError(400, 'An agent can only be placed in its owner\'s own workspaces.')
97
+ if (!ws || !owns(ws)) throw new HttpError(400, 'An agent can only be placed in its owner\'s own projects.')
98
98
  }
99
99
  return p
100
100
  }
@@ -121,10 +121,10 @@ export function workspaceAgentRoutes (ctx) {
121
121
  /** The room's session when the caller owns it (as the relay reports it). */
122
122
  async function ownRoom (req, room) {
123
123
  const me = await caller(req)
124
- if (!ROOM.test(room)) throw new HttpError(404, 'no such session')
124
+ if (!ROOM.test(room)) throw new HttpError(404, 'no such codebase')
125
125
  const session = await store.sessionByRoom(room)
126
- if (!session) throw new HttpError(404, 'no such session')
127
- if (!session.ownerAccount || session.ownerAccount !== me.account) throw new HttpError(403, 'Only the session owner can do that.')
126
+ if (!session) throw new HttpError(404, 'no such codebase')
127
+ if (!session.ownerAccount || session.ownerAccount !== me.account) throw new HttpError(403, "Only the codebase's owner can do that.")
128
128
  return { me, session }
129
129
  }
130
130
 
@@ -200,7 +200,7 @@ export function workspaceAgentRoutes (ctx) {
200
200
  ['PUT', /^\/v1\/workspaces\/([^/]+)\/agents\/([^/]+)$/, async (req, body, [id, agentId]) => {
201
201
  const r = await reach(req, id)
202
202
  r.needAdmin()
203
- if (!(await placementIn(store, r.ws, agentId))) throw new HttpError(404, 'that agent is not placed in this workspace')
203
+ if (!(await placementIn(store, r.ws, agentId))) throw new HttpError(404, 'that agent is not placed in this project')
204
204
  const b = body && typeof body === 'object' ? body : {}
205
205
  if (b.sessions !== undefined && b.sessions !== null && !SESSIONS.includes(b.sessions)) throw new HttpError(400, 'Sessions is all, invited or null.')
206
206
  if (b.excluded !== undefined && typeof b.excluded !== 'boolean') throw new HttpError(400, 'excluded is true or false.')
@@ -278,15 +278,15 @@ export function workspaceAgentRoutes (ctx) {
278
278
  // who owns the session (the app tries again shortly).
279
279
  ['POST', /^\/v1\/workspaces\/([^/]+)\/sessions\/([^/]+)\/started$/, async (req, body, [id, room]) => {
280
280
  const r = await reach(req, id)
281
- if (!ROOM.test(room)) throw new HttpError(404, 'that session is not in this workspace')
281
+ if (!ROOM.test(room)) throw new HttpError(404, 'that codebase is not in this project')
282
282
  const session = await store.sessionByRoom(room)
283
- if (!session || session.workspaceId !== r.ws.id) throw new HttpError(404, 'that session is not in this workspace')
284
- if (session.workspaceLinkedBy !== r.me.account) throw new HttpError(403, 'Only the session owner can do that.')
285
- if (!session.ownerAccount) throw new HttpError(409, 'Quilt has not heard who owns this session yet; try again in a moment.')
286
- if (session.ownerAccount !== r.me.account) throw new HttpError(403, 'Only the session owner can do that.')
283
+ if (!session || session.workspaceId !== r.ws.id) throw new HttpError(404, 'that codebase is not in this project')
284
+ if (session.workspaceLinkedBy !== r.me.account) throw new HttpError(403, "Only the codebase's owner can do that.")
285
+ if (!session.ownerAccount) throw new HttpError(409, 'Quilt has not heard who owns this codebase yet; try again in a moment.')
286
+ if (session.ownerAccount !== r.me.account) throw new HttpError(403, "Only the codebase's owner can do that.")
287
287
  let invite
288
- try { invite = parseInvite(String(body.link || ''), { allowRelay: (s) => isHostedRelay(s) || relayForm(s) === ownRelay }) } catch { throw new HttpError(400, 'link must be this session\'s Quilt invite link') }
289
- if (invite.room !== room || !invite.secret) throw new HttpError(400, 'link must be this session\'s Quilt invite link')
288
+ try { invite = parseInvite(String(body.link || ''), { allowRelay: (s) => isHostedRelay(s) || relayForm(s) === ownRelay }) } catch { throw new HttpError(400, 'link must be this codebase\'s Quilt invite link') }
289
+ if (invite.room !== room || !invite.secret) throw new HttpError(400, 'link must be this codebase\'s Quilt invite link')
290
290
  // `agents` (optional): only these of the agents it invites, e.g. one invited again.
291
291
  const only = body.agents === undefined ? null : body.agents
292
292
  if (only !== null && (!Array.isArray(only) || only.length > 100 || only.some((x) => typeof x !== 'string'))) throw new HttpError(400, 'agents must be a list of agent ids.')