heyquilt 0.3.152 → 0.3.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ui/signin.js CHANGED
@@ -18,6 +18,7 @@ function screen (inner) {
18
18
  export function renderSignIn (message = '', onSignedIn = () => window.location.reload()) {
19
19
  screen(`
20
20
  <h1>Sign in to Quilt</h1>
21
+ <p class="signin-lead">Your sessions, files and agents, in one place. Signing in opens heyquilt.com in your browser, where you approve this computer.</p>
21
22
  ${message ? `<p class="signin-note">${esc(message)}</p>` : ''}
22
23
  <button class="btn primary signin-btn" id="signin-go">Sign in</button>
23
24
  <p class="hint">New to Quilt? <a href="${SIGNUP}" target="_blank" rel="noopener">Create an account</a></p>
@@ -2,6 +2,7 @@
2
2
  // (Sessions, Files, People & agents, Settings). Sessions stay in session.js; the file library
3
3
  // (the Files section, All files and uploads) is files.js.
4
4
  import { mountSecrets } from './secrets.js'
5
+ import { mountConnections } from './connections.js'
5
6
  import { I, state, $, esc, basename, toast, api, ask, avatar, colorFor, ago, bytes, COLORS, loadingHtml } from './common.js'
6
7
  import { filesSectionHtml, bindFilesSection } from './files.js'
7
8
  import { memberMiniHtml, memberMenuItems, openAgentMenu } from './agent-place.js'
@@ -277,6 +278,7 @@ export function workspacePageHtml () {
277
278
  </section>
278
279
  ${filesSectionHtml(d)}
279
280
  ${state.secretsOn ? '<section class="sec ws-secrets" data-ws-secrets></section>' : ''}
281
+ ${state.connectionsOn ? '<section class="sec ws-connections"><h3>Connections</h3><div data-ws-connections></div></section>' : ''}
280
282
  </div>
281
283
  </div>
282
284
  </div>`
@@ -367,7 +369,8 @@ export function bindWorkspacePage (root, { go, rerender, newSessionDialog, invit
367
369
  if (!d || d.workspace.id !== String(state.view).slice(3)) return
368
370
  const id = d.workspace.id
369
371
  const reload = async () => { await openWorkspace(id); await loadWorkspaces(); rerender() }
370
- root.querySelector('[data-ws-back]').onclick = (e) => { e.preventDefault(); go('home') }
372
+ const back = root.querySelector('[data-ws-back]')
373
+ if (back) back.onclick = (e) => { e.preventDefault(); go('home') }
371
374
  root.querySelectorAll('[data-go]').forEach((b) => { b.onclick = () => go(b.dataset.go) })
372
375
  root.querySelector('[data-new-session-in]')?.addEventListener('click', () => newSessionDialog(id))
373
376
  root.querySelector('[data-invite-ws]')?.addEventListener('click', () => inviteDialog(id))
@@ -378,6 +381,9 @@ export function bindWorkspacePage (root, { go, rerender, newSessionDialog, invit
378
381
  // Secrets: the workspace's, with its team's above (secrets.js); .env files come from its sessions on this computer.
379
382
  const sec = root.querySelector('[data-ws-secrets]')
380
383
  if (sec) mountSecrets(sec, { type: 'workspace', id, importFrom: { workspaceId: id } })
384
+ // Apps every session in the workspace can use (connections.js).
385
+ const conns = root.querySelector('[data-ws-connections]')
386
+ if (conns) mountConnections(conns, { type: 'workspace', id })
381
387
  }
382
388
 
383
389
  /** "1.2 GB of 5.0 GB used · 34 files", from the workspace's usage; nothing without one. */
package/src/ui-server.js CHANGED
@@ -20,19 +20,19 @@ import { autowork, autoConfig, publicConfig, AUTO_MODES } from './autowork.js'
20
20
  import { migrateDir } from './legacy.js'
21
21
  import { writePrivateJson } from './private-file.js'
22
22
  import { autoToolFor } from './autowork-tools.js'
23
- import { readAccount, saveAccount, clearAccount, clearAccountIf, resumeAccount, startLink, waitForLink, fetchMe, signOut, revokeToken, accountFromProfile, renameSession, createAgentInvite, listAgents, agentDetails, listAccessTypes, listCollaborators, listGrants, putGrant, deleteGrant, inviteToSession, listSessionInvites, cancelSessionInvite, listWorkspaces, listOrgs, createWorkspace, getWorkspace, updateWorkspace, deleteWorkspace, putWorkspaceMember, removeWorkspaceMember, getAgentPlacement, putAgentPlacement, listOrgAgents, putWorkspaceAgent, deleteWorkspaceAgent, createWorkspaceAgentInvite, excludeSessionAgent, listExcludedSessionAgents, listSessionAgents, includeSessionAgent, setSessionWorkspace, moveSessionToWorkspace, listWorkspaceInvites, inviteToWorkspace, cancelWorkspaceInvite, listMyInvites, answerMyInvite, announceSessionStarted, announceWhenReported, listWorkspaceFiles, createWorkspaceFile, confirmWorkspaceFile, workspaceFileDownload, updateWorkspaceFile, deleteWorkspaceFile, createWorkspaceFolder, listWorkspaceFileVersions, listSandboxKeys, createSandboxKey, rotateSandboxKey, revokeSandboxKey, removeSandboxKey, aiVmFollow, aiVmUnfollow, aiVmStatus, aiVmConnect, aiVmUpdate, aiVmSignIn, aiVmWake, aiVmDisconnect, voiceIce, transcribeVoice, speakVoice, speakVoiceStream, apiUrl } from './account.js'
23
+ import { readAccount, saveAccount, clearAccount, clearAccountIf, resumeAccount, startLink, waitForLink, fetchMe, signOut, revokeToken, accountFromProfile, renameSession, createAgentInvite, listAgents, agentDetails, listAccessTypes, listCollaborators, listGrants, putGrant, deleteGrant, inviteToSession, listSessionInvites, cancelSessionInvite, listWorkspaces, listOrgs, createWorkspace, getWorkspace, updateWorkspace, deleteWorkspace, putWorkspaceMember, removeWorkspaceMember, getAgentPlacement, putAgentPlacement, listOrgAgents, putWorkspaceAgent, deleteWorkspaceAgent, createWorkspaceAgentInvite, excludeSessionAgent, listExcludedSessionAgents, listSessionAgents, includeSessionAgent, setSessionWorkspace, moveSessionToWorkspace, listWorkspaceInvites, inviteToWorkspace, cancelWorkspaceInvite, listMyInvites, answerMyInvite, listMySessions, announceSessionStarted, announceWhenReported, listWorkspaceFiles, createWorkspaceFile, confirmWorkspaceFile, workspaceFileDownload, updateWorkspaceFile, deleteWorkspaceFile, createWorkspaceFolder, listWorkspaceFileVersions, listSandboxKeys, createSandboxKey, rotateSandboxKey, revokeSandboxKey, removeSandboxKey, aiVmFollow, aiVmUnfollow, aiVmStatus, aiVmConnect, aiVmUpdate, aiVmSignIn, aiVmWake, aiVmDisconnect, voiceIce, transcribeVoice, speakVoice, speakVoiceStream, apiUrl } from './account.js'
24
24
  import { aiName } from './persona.js'
25
25
  import { effectiveAccess, builtinType } from './session-access.js'
26
26
  import { cleanSessionName, BAD_SESSION_NAME, SESSION_NAME_MAX } from './session-name.js'
27
27
  import { personPasses, personApiAuth } from './pass-source.js'
28
- import { INVALID_INVITE } from './ui/invite.js'
28
+ import { INVALID_INVITE, NO_LINK_YET, joinFolderName } from './ui/invite.js'
29
29
  import { seamResultWords } from './ui/seam-model.js'
30
30
  import { loadIdentity } from './identity.js'
31
31
  import { currentVersion, localReleases, latestRelease, compareVersions, downloadUrl, seenVersion, markSeen, hiddenUpdate, hideUpdate } from './releases.js'
32
32
  import { createReporter } from './report.js'
33
33
  import { queryHistory } from './history.js'
34
34
  import { contentDisposition } from './api/file-paths.js'
35
- import { getSecrets, putSecretSettings, setSecretWho, deleteSecret, secretUses, saveSecrets, secretAsks, answerAsk } from './secrets-client.js'
35
+ import { apiCall, getSecrets, putSecretSettings, setSecretWho, deleteSecret, secretUses, saveSecrets, secretAsks, answerAsk } from './secrets-client.js'
36
36
  import { envFilesIn, knownEnvFile, envValues } from './secret-import.js'
37
37
  import { appWorkspaces } from './app-workspaces.js'
38
38
  import { guessTool } from './tool-guess.js'
@@ -197,6 +197,7 @@ export const STATIC = {
197
197
  '/schedule.js': ['schedule.js', 'text/javascript; charset=utf-8'],
198
198
  '/workspaces.js': ['workspaces.js', 'text/javascript; charset=utf-8'],
199
199
  '/invites.js': ['invites.js', 'text/javascript; charset=utf-8'],
200
+ '/account-sessions.js': ['account-sessions.js', 'text/javascript; charset=utf-8'],
200
201
  '/agent-place.js': ['agent-place.js', 'text/javascript; charset=utf-8'],
201
202
  '/agent-kinds.js': ['agent-kinds.js', 'text/javascript; charset=utf-8'],
202
203
  '/agents-table.js': ['agents-table.js', 'text/javascript; charset=utf-8'],
@@ -214,6 +215,10 @@ export const STATIC = {
214
215
  '/sandbox-keys-model.js': ['sandbox-keys-model.js', 'text/javascript; charset=utf-8'],
215
216
  '/secrets.js': ['secrets.js', 'text/javascript; charset=utf-8'],
216
217
  '/secrets-view.js': ['secrets-view.js', 'text/javascript; charset=utf-8'],
218
+ '/connections.js': ['connections.js', 'text/javascript; charset=utf-8'],
219
+ '/home-view.js': ['home-view.js', 'text/javascript; charset=utf-8'],
220
+ '/people-view.js': ['people-view.js', 'text/javascript; charset=utf-8'],
221
+ '/palette.js': ['palette.js', 'text/javascript; charset=utf-8'],
217
222
  '/secret-rules.js': ['secret-rules.js', 'text/javascript; charset=utf-8'],
218
223
  '/voice.js': ['voice.js', 'text/javascript; charset=utf-8'],
219
224
  '/voice-model.js': ['voice-model.js', 'text/javascript; charset=utf-8'],
@@ -232,6 +237,8 @@ const CSP = [
232
237
  "style-src 'self' 'unsafe-inline'",
233
238
  "img-src 'self' data: https: https://www.google.com https://*.gstatic.com",
234
239
  "font-src 'self'",
240
+ // The Preview tab shows the session's links (a dev server, staging, production) in a sandboxed frame.
241
+ "frame-src http: https:",
235
242
  "connect-src 'self'",
236
243
  "object-src 'none'",
237
244
  "base-uri 'none'",
@@ -411,7 +418,19 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
411
418
  pushTimers.set(id, t)
412
419
  }
413
420
 
414
- async function start ({ mode, dir, tool, invite, prefer, workspace }) {
421
+ // One of your sessions that isn't on this computer yet: joined by its room, with no link (accountSessions).
422
+ const byRoom = (room) => {
423
+ if (!/^[A-Za-z0-9_-]{1,64}$/.test(String(room))) throw httpError(400, 'Which session?')
424
+ return { server: relayUrl(), room: String(room), secret: '' }
425
+ }
426
+ // Its folder is named after the session when that folder is free, otherwise after its room.
427
+ const byRoomFolder = (joinDir, room, name) => {
428
+ const base = joinFolderName(name)
429
+ const dir = base && underJoinDir(joinDir, base)
430
+ return dir && !fs.existsSync(dir) ? dir : underJoinDir(joinDir, room)
431
+ }
432
+
433
+ async function start ({ mode, dir, tool, invite, room, name, prefer, workspace }) {
415
434
  // New session from GitHub went in 16's R2: new sessions are quilts (quilt-default.js), and a repository's history comes into Seam by its import.
416
435
  if (mode === 'github') throw httpError(410, GITHUB_GONE)
417
436
  const me = profile()
@@ -425,8 +444,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
425
444
  tool = tool || me.tool
426
445
  prefer = prefer || (me.preferLocal ? 'local' : 'remote')
427
446
  if (mode === 'join' && !dir) {
428
- const inv = decodeInvite(invite || '')
429
- dir = underJoinDir(me.joinDir, inv.room)
447
+ dir = room ? byRoomFolder(me.joinDir, byRoom(room).room, name) : underJoinDir(me.joinDir, decodeInvite(invite || '').room)
430
448
  }
431
449
  if (!dir) throw new Error('Choose a project folder.')
432
450
  dir = path.resolve(expandHome(dir))
@@ -436,7 +454,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
436
454
  let conn
437
455
  let inviteServer
438
456
  if (mode === 'join') {
439
- conn = decodeInvite(invite || '')
457
+ conn = room ? byRoom(room) : decodeInvite(invite || '')
440
458
  } else if (mode === 'rejoin') {
441
459
  const saved = readConfig(dir)
442
460
  if (!saved) throw new Error('No previous session in that folder.')
@@ -522,7 +540,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
522
540
  s.doc.getArray('voiceLines').observe(pushVoice)
523
541
  s.doc.getMap('voiceAgents').observe(pushVoice)
524
542
  // The person's cloud AI, when they connected one, joins the sessions they join.
525
- followWithCloudAi(entry.run.invite, log)
543
+ if (entry.run.invite) followWithCloudAi(entry.run.invite, log)
526
544
  if (workspace && mode === 'create') {
527
545
  // Put the new room in its workspace before anyone else connects. A failure is logged, never
528
546
  // fatal, and the session is outside any workspace here too, as it is on the API.
@@ -912,6 +930,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
912
930
  return asAccount(async (token) => {
913
931
  const type = await typeById(token, typeId)
914
932
  const link = type.files === 'view' && run.viewInvite ? run.viewInvite : run.invite
933
+ if (!link) throw httpError(409, NO_LINK_YET)
915
934
  return { invite: await inviteToSession({ token, room: s.room, typeId, to, link }) }
916
935
  })
917
936
  }
@@ -936,6 +955,27 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
936
955
  throw httpError(404, 'not found')
937
956
  })
938
957
  }
958
+ // App connections (src/ui/connections.js): through the accounts API, which holds Composio's key.
959
+ async function connectionsRoute (method, url, body) {
960
+ const p = url.pathname
961
+ const enc = (v) => encodeURIComponent(String(v))
962
+ return asAccount(async (token) => {
963
+ const c = secretsApi(token)
964
+ 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')}`)
965
+ const sc = p.match(/^\/api\/connections\/(org|workspace|session)\/([^/]+)(?:\/([0-9a-f-]{36}))?$/i)
966
+ if (sc && SECRET_SCOPE_ID[sc[1]].test(decodeURIComponent(sc[2]))) {
967
+ const base = `/v1/connections/${sc[1]}/${enc(decodeURIComponent(sc[2]))}`
968
+ if (!sc[3] && method === 'GET') return apiCall(c, 'GET', base)
969
+ if (!sc[3] && method === 'POST') return apiCall(c, 'POST', base, { app: String(body.app || ''), ...(body.who ? { who: String(body.who) } : {}) })
970
+ if (sc[3] && method === 'PATCH') return apiCall(c, 'PATCH', `${base}/${sc[3]}`, { who: String(body.who || '') })
971
+ if (sc[3] && method === 'DELETE') return apiCall(c, 'DELETE', `${base}/${sc[3]}`)
972
+ }
973
+ const calls = p.match(/^\/api\/app-calls\/([A-Za-z0-9_-]{1,64})(?:\/([0-9a-f-]{36}))?$/i)
974
+ if (calls && !calls[2] && method === 'GET') return apiCall(c, 'GET', `/v1/sessions/${enc(calls[1])}/app-calls${url.searchParams.get('waiting') === '1' ? '?waiting=1' : ''}`)
975
+ if (calls && calls[2] && method === 'POST') return apiCall(c, 'POST', `/v1/sessions/${enc(calls[1])}/app-calls/${calls[2]}`, { allow: body.allow === true }, 90_000)
976
+ throw httpError(404, 'not found')
977
+ })
978
+ }
939
979
  /** The folders whose .env files a card may import: one session's, or a workspace's sessions' on this computer. */
940
980
  const envDirs = (b) => {
941
981
  if (b && b.sessionId) { const r = runs.get(String(b.sessionId)); return r ? [r.run.dir] : [] }
@@ -950,8 +990,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
950
990
  try {
951
991
  const res = await fetch(`${apiUrl()}/v1/features`, { signal: AbortSignal.timeout(5000) })
952
992
  const f = res.ok ? await res.json() : {}
953
- return { secrets: !!f.secrets, workspaces: !!f.workspaces && appWorkspaces() }
954
- } catch { return { secrets: false, workspaces: false } }
993
+ return { secrets: !!f.secrets, connections: !!f.connections, workspaces: !!f.workspaces && appWorkspaces() }
994
+ } catch { return { secrets: false, connections: false, workspaces: false } }
955
995
  },
956
996
  'POST /api/secrets/env-scan': (b) => {
957
997
  const dirs = envDirs(b)
@@ -990,6 +1030,22 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
990
1030
  'GET /api/orgs': () => asAccount(async (token) => ({ orgs: await listOrgs({ token }) })),
991
1031
  'POST /api/workspaces': (b) => asAccount(async (token) => ({ workspace: await createWorkspace({ token, name: String(b.name || ''), description: String(b.description || ''), color: String(b.color || ''), org: b.org ? String(b.org) : undefined }) })),
992
1032
  'GET /api/workspaces/:id': (b, id) => asAccount(async (token) => ({ ...(await getWorkspace({ token, id: needWorkspaceId(id) })), ...ofWorkspace(id) })),
1033
+ // The workspace's home (plans/app-redesign.md): AI time from the accounts API, merges onto main from Seam for
1034
+ // the workspace's sessions open on this computer, and its links (previews).
1035
+ 'GET /api/workspaces/:id/insights': (b, id) => asAccount(async (token) => {
1036
+ const wid = needWorkspaceId(id)
1037
+ const ai = await apiCall({ api: apiUrl(), token }, 'GET', `/v1/workspaces/${encodeURIComponent(wid)}/insights?days=14`)
1038
+ const since = Date.now() - 14 * 24 * 60 * 60 * 1000
1039
+ const merges = []
1040
+ for (const [key, r] of runs) {
1041
+ const sm = summary(key)
1042
+ if (!sm || sm.workspace !== wid || !r.run.session.seamMerges) continue
1043
+ try { for (const at of await r.run.session.seamMerges({ since })) merges.push({ room: r.run.session.room, at }) } catch {} // one session's Seam not answering leaves its merges out
1044
+ }
1045
+ return { ...ai, merges }
1046
+ }),
1047
+ 'POST /api/workspaces/:id/links': (b, id) => asAccount((token) => apiCall({ api: apiUrl(), token }, 'POST', `/v1/workspaces/${encodeURIComponent(needWorkspaceId(id))}/links`, { name: String(b.name || ''), url: String(b.url || ''), room: b.room ? String(b.room) : null, note: String(b.note || '') })),
1048
+ 'POST /api/workspaces/:id/links/:lid/remove': (b, id, url, lid) => asAccount(async (token) => { await apiCall({ api: apiUrl(), token }, 'DELETE', `/v1/workspaces/${encodeURIComponent(needWorkspaceId(id))}/links/${encodeURIComponent(String(lid))}`); return { ok: true } }),
993
1049
  'POST /api/workspaces/:id/update': (b, id) => asAccount(async (token) => ({ workspace: await updateWorkspace({ token, id: needWorkspaceId(id), patch: { name: b.name, description: b.description, color: b.color, archived: b.archived } }) })),
994
1050
  'POST /api/workspaces/:id/delete': (b, id) => asAccount(async (token) => { await deleteWorkspace({ token, id: needWorkspaceId(id) }); return { ok: true } }),
995
1051
  'POST /api/workspaces/:id/members': (b, id) => asAccount(async (token) => ({ member: await putWorkspaceMember({ token, id: needWorkspaceId(id), account: String(b.account || ''), access: String(b.access || ''), sessions: b.sessions === undefined ? undefined : String(b.sessions) }) })),
@@ -1037,6 +1093,12 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1037
1093
  }),
1038
1094
  'POST /api/workspaces/:id/invites/:iid/cancel': (b, id, url, iid) => asAccount(async (token) => { await cancelWorkspaceInvite({ token, id: needWorkspaceId(id), inviteId: needInviteId(iid) }); return { ok: true } }),
1039
1095
  // Invites waiting for you (workspaces, and sessions with their link); accept or decline them.
1096
+ // Your sessions (from your account) that aren't on this computer, to join here from Home: your sessions follow your account.
1097
+ 'GET /api/account-sessions': () => asAccount(async (token) => {
1098
+ const here = new Set([...[...runs.values()].map((r) => r.run.session.room), ...recentSessions().map((r) => r.room)])
1099
+ const sessions = (await listMySessions({ token })).filter((s) => !here.has(s.room))
1100
+ return { sessions: sessions.map((s) => ({ room: s.room, name: s.name || '', owner: s.owner?.name || '', mine: !!s.mine, lastActiveAt: s.lastActiveAt || 0, live: !!s.live, people: (s.people || []).length })) }
1101
+ }),
1040
1102
  'GET /api/invites': () => asAccount(async (token) => ({ invites: (await listMyInvites({ token })).filter((i) => i.kind !== 'workspace' || appWorkspaces()) })),
1041
1103
  'POST /api/invites/:id/accept': (b, id) => asAccount(async (token) => answerMyInvite({ token, id: needInviteId(id), how: 'accept' })),
1042
1104
  'POST /api/invites/:id/decline': (b, id) => asAccount(async (token) => answerMyInvite({ token, id: needInviteId(id), how: 'decline' })),
@@ -1076,6 +1138,12 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1076
1138
  'POST /api/sessions/:id/focus': (b, id) => { get(id).setFocus(b.text); return { ok: true } },
1077
1139
  // Voice (voice.js): the call as this app sees it, and our part in it, from the app window, which does the audio.
1078
1140
  'GET /api/sessions/:id/voice': (b, id) => get(id).voice(),
1141
+ // The Calls tab (dm06): the session's calls from their transcripts, newest first, each with its opening lines.
1142
+ 'GET /api/sessions/:id/calls': (b, id) => {
1143
+ const { lines, calls } = get(id).voiceTranscript({ limit: 1000 })
1144
+ return { calls: calls.reverse().slice(0, 50).map((c) => ({ ...c, opening: lines.filter((l) => l.call === c.call).slice(0, 3).map((l) => ({ by: l.by, text: l.text })) })) }
1145
+ },
1146
+ 'GET /api/sessions/:id/calls/:call': (b, id, url, call) => ({ lines: get(id).voiceTranscript({ call, limit: 1000 }).lines }),
1079
1147
  'POST /api/sessions/:id/voice': (b, id) => get(id).setVoice(b.in === false ? null : { muted: b.muted === true, sig: b.sig, transcribing: b.transcribing === true, sharing: b.sharing === true, agents: b.agents === true }),
1080
1148
  'POST /api/sessions/:id/voice/transcribe': (b, id) => get(id).setVoiceTranscribe(b.on === true),
1081
1149
  'POST /api/sessions/:id/voice/clip': (b, id) => voiceClip(get(id), b),
@@ -1147,6 +1215,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1147
1215
  'GET /api/sessions/:id/search': (b, id, url) => get(id).quiltSearch(String(url.searchParams.get('q') || '')),
1148
1216
  // In a session that moved into Seam: the square panel's Commit and Merge onto main, as this member (control.js seamTool).
1149
1217
  'POST /api/sessions/:id/seam': (b, id) => squareTool(get(id), b),
1218
+ 'GET /api/sessions/:id/github': (b, id) => seamGithub(get(id), {}),
1219
+ 'POST /api/sessions/:id/github': (b, id) => seamGithub(get(id), b),
1150
1220
  'GET /api/sessions/:id/file': (b, id, url) => {
1151
1221
  const f = get(id).readShared(url.searchParams.get('path'))
1152
1222
  if (!f) throw httpError(404, 'That file is not in this session.')
@@ -1310,6 +1380,13 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1310
1380
  return json(404, { error: 'not found' })
1311
1381
  }
1312
1382
 
1383
+ // App connections: /api/connections/…, and an app call waiting for a person (/api/app-calls/<room>[/<id>]).
1384
+ if (url.pathname.startsWith('/api/connections/') || url.pathname.startsWith('/api/app-calls/')) {
1385
+ let raw = ''
1386
+ for await (const chunk of req) raw += chunk
1387
+ return json(200, await connectionsRoute(req.method, url, raw ? JSON.parse(raw) : {}))
1388
+ }
1389
+
1313
1390
  let pathKey = url.pathname
1314
1391
  .replace(/^\/api\/sessions\/[a-f0-9]+/, '/api/sessions/:id')
1315
1392
  .replace(/^\/api\/workspaces\/[^/]+/, '/api/workspaces/:id')
@@ -1325,6 +1402,12 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1325
1402
  // A workspace's invite, the same way.
1326
1403
  const iid = (url.pathname.match(/^\/api\/workspaces\/[^/]+\/invites\/([^/]+)\//) || [])[1]
1327
1404
  if (iid) pathKey = pathKey.replace(/^(\/api\/workspaces\/:id\/invites)\/[^/]+/, '$1/:iid')
1405
+ // A workspace's link (a preview), the same way.
1406
+ const lid = (url.pathname.match(/^\/api\/workspaces\/[^/]+\/links\/([^/]+)\//) || [])[1]
1407
+ if (lid) pathKey = pathKey.replace(/^(\/api\/workspaces\/:id\/links)\/[^/]+/, '$1/:lid')
1408
+ // A call's transcript (the Calls tab), by the call's id.
1409
+ const cid = (url.pathname.match(/^\/api\/sessions\/[a-f0-9]+\/calls\/([^/]+)$/) || [])[1]
1410
+ if (cid) pathKey = pathKey.replace(/^(\/api\/sessions\/:id\/calls)\/[^/]+$/, '$1/:call')
1328
1411
  const key = `${req.method} ${pathKey}`
1329
1412
  const handler = api[key]
1330
1413
  if (!handler) {
@@ -1336,7 +1419,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1336
1419
  const body = raw ? JSON.parse(raw) : {}
1337
1420
  const startedAt = Date.now()
1338
1421
  try {
1339
- const out = await handler(body, sid, url, fid || aid || iid)
1422
+ const out = await handler(body, sid, url, fid || aid || iid || lid || (cid && decodeURIComponent(cid)))
1340
1423
  // A reply that streams (an agent's speech): straight through as it comes.
1341
1424
  if (out && out[STREAMED]) {
1342
1425
  res.writeHead(200, { 'content-type': out.type, 'cache-control': 'no-store' })
@@ -1558,6 +1641,14 @@ export function underJoinDir (joinDir, name, message = INVALID_INVITE) {
1558
1641
  * commits first), as this member through Seam's own tools; or open_square, for a folder whose branch has
1559
1642
  * none (Session.openSquareHere). The answer as { text }, a refusal as a 400.
1560
1643
  */
1644
+ /** Session settings' GitHub card: Seam's GitHub (the Seam app's installations, and the quilt's export to a repository). */
1645
+ async function seamGithub (s, b) {
1646
+ if (!s.seamGithub) return { quilt: false }
1647
+ const repo = b && typeof b.repo === 'string' ? b.repo.trim() : ''
1648
+ if (repo && !(/^[\w.-]+\/[\w.-]+$/.test(repo) && /^\d+$/.test(String(b.installation || '')))) throw httpError(400, 'Pick a repository the Seam app reaches.')
1649
+ try { return await s.seamGithub(repo ? { repo, installation: String(b.installation) } : b && b.disconnect ? { disconnect: true } : {}) } catch (err) { throw httpError(err.status || 502, err.message) }
1650
+ }
1651
+
1561
1652
  export async function squareTool (s, b) {
1562
1653
  const tool = String((b && b.tool) || '')
1563
1654
  if (tool === 'open_square') {