heyquilt 0.3.154 → 0.3.156

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
@@ -18,6 +18,7 @@ import { execFile } from 'node:child_process'
18
18
  import { installedEditors, openIn, copyToClipboard } from './editors.js'
19
19
  import { autowork, autoConfig, publicConfig, AUTO_MODES } from './autowork.js'
20
20
  import { migrateDir } from './legacy.js'
21
+ import { devServers } from './dev-servers.js'
21
22
  import { writePrivateJson } from './private-file.js'
22
23
  import { autoToolFor } from './autowork-tools.js'
23
24
  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'
@@ -32,7 +33,7 @@ import { currentVersion, localReleases, latestRelease, compareVersions, download
32
33
  import { createReporter } from './report.js'
33
34
  import { queryHistory } from './history.js'
34
35
  import { contentDisposition } from './api/file-paths.js'
35
- import { getSecrets, putSecretSettings, setSecretWho, deleteSecret, secretUses, saveSecrets, secretAsks, answerAsk } from './secrets-client.js'
36
+ import { apiCall, getSecrets, putSecretSettings, setSecretWho, deleteSecret, secretUses, saveSecrets, secretAsks, answerAsk } from './secrets-client.js'
36
37
  import { envFilesIn, knownEnvFile, envValues } from './secret-import.js'
37
38
  import { appWorkspaces } from './app-workspaces.js'
38
39
  import { guessTool } from './tool-guess.js'
@@ -215,6 +216,10 @@ export const STATIC = {
215
216
  '/sandbox-keys-model.js': ['sandbox-keys-model.js', 'text/javascript; charset=utf-8'],
216
217
  '/secrets.js': ['secrets.js', 'text/javascript; charset=utf-8'],
217
218
  '/secrets-view.js': ['secrets-view.js', 'text/javascript; charset=utf-8'],
219
+ '/connections.js': ['connections.js', 'text/javascript; charset=utf-8'],
220
+ '/home-view.js': ['home-view.js', 'text/javascript; charset=utf-8'],
221
+ '/people-view.js': ['people-view.js', 'text/javascript; charset=utf-8'],
222
+ '/palette.js': ['palette.js', 'text/javascript; charset=utf-8'],
218
223
  '/secret-rules.js': ['secret-rules.js', 'text/javascript; charset=utf-8'],
219
224
  '/voice.js': ['voice.js', 'text/javascript; charset=utf-8'],
220
225
  '/voice-model.js': ['voice-model.js', 'text/javascript; charset=utf-8'],
@@ -233,6 +238,8 @@ const CSP = [
233
238
  "style-src 'self' 'unsafe-inline'",
234
239
  "img-src 'self' data: https: https://www.google.com https://*.gstatic.com",
235
240
  "font-src 'self'",
241
+ // The Preview tab shows the session's links (a dev server, staging, production) in a sandboxed frame.
242
+ "frame-src http: https:",
236
243
  "connect-src 'self'",
237
244
  "object-src 'none'",
238
245
  "base-uri 'none'",
@@ -949,6 +956,27 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
949
956
  throw httpError(404, 'not found')
950
957
  })
951
958
  }
959
+ // App connections (src/ui/connections.js): through the accounts API, which holds Composio's key.
960
+ async function connectionsRoute (method, url, body) {
961
+ const p = url.pathname
962
+ const enc = (v) => encodeURIComponent(String(v))
963
+ return asAccount(async (token) => {
964
+ const c = secretsApi(token)
965
+ if (method === 'GET' && p === '/api/connections/apps') return apiCall(c, 'GET', `/v1/connections/apps?search=${enc(url.searchParams.get('search') || '')}&category=${enc(url.searchParams.get('category') || '')}&offset=${enc(url.searchParams.get('offset') || '0')}&limit=${enc(url.searchParams.get('limit') || '48')}`)
966
+ const sc = p.match(/^\/api\/connections\/(org|workspace|session)\/([^/]+)(?:\/([0-9a-f-]{36}))?$/i)
967
+ if (sc && SECRET_SCOPE_ID[sc[1]].test(decodeURIComponent(sc[2]))) {
968
+ const base = `/v1/connections/${sc[1]}/${enc(decodeURIComponent(sc[2]))}`
969
+ if (!sc[3] && method === 'GET') return apiCall(c, 'GET', base)
970
+ if (!sc[3] && method === 'POST') return apiCall(c, 'POST', base, { app: String(body.app || ''), ...(body.who ? { who: String(body.who) } : {}) })
971
+ if (sc[3] && method === 'PATCH') return apiCall(c, 'PATCH', `${base}/${sc[3]}`, { who: String(body.who || '') })
972
+ if (sc[3] && method === 'DELETE') return apiCall(c, 'DELETE', `${base}/${sc[3]}`)
973
+ }
974
+ const calls = p.match(/^\/api\/app-calls\/([A-Za-z0-9_-]{1,64})(?:\/([0-9a-f-]{36}))?$/i)
975
+ if (calls && !calls[2] && method === 'GET') return apiCall(c, 'GET', `/v1/sessions/${enc(calls[1])}/app-calls${url.searchParams.get('waiting') === '1' ? '?waiting=1' : ''}`)
976
+ 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)
977
+ throw httpError(404, 'not found')
978
+ })
979
+ }
952
980
  /** The folders whose .env files a card may import: one session's, or a workspace's sessions' on this computer. */
953
981
  const envDirs = (b) => {
954
982
  if (b && b.sessionId) { const r = runs.get(String(b.sessionId)); return r ? [r.run.dir] : [] }
@@ -963,8 +991,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
963
991
  try {
964
992
  const res = await fetch(`${apiUrl()}/v1/features`, { signal: AbortSignal.timeout(5000) })
965
993
  const f = res.ok ? await res.json() : {}
966
- return { secrets: !!f.secrets, workspaces: !!f.workspaces && appWorkspaces() }
967
- } catch { return { secrets: false, workspaces: false } }
994
+ return { secrets: !!f.secrets, connections: !!f.connections, workspaces: !!f.workspaces && appWorkspaces() }
995
+ } catch { return { secrets: false, connections: false, workspaces: false } }
968
996
  },
969
997
  'POST /api/secrets/env-scan': (b) => {
970
998
  const dirs = envDirs(b)
@@ -1003,6 +1031,22 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1003
1031
  'GET /api/orgs': () => asAccount(async (token) => ({ orgs: await listOrgs({ token }) })),
1004
1032
  '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 }) })),
1005
1033
  'GET /api/workspaces/:id': (b, id) => asAccount(async (token) => ({ ...(await getWorkspace({ token, id: needWorkspaceId(id) })), ...ofWorkspace(id) })),
1034
+ // The workspace's home (plans/app-redesign.md): AI time from the accounts API, merges onto main from Seam for
1035
+ // the workspace's sessions open on this computer, and its links (previews).
1036
+ 'GET /api/workspaces/:id/insights': (b, id) => asAccount(async (token) => {
1037
+ const wid = needWorkspaceId(id)
1038
+ const ai = await apiCall({ api: apiUrl(), token }, 'GET', `/v1/workspaces/${encodeURIComponent(wid)}/insights?days=14`)
1039
+ const since = Date.now() - 14 * 24 * 60 * 60 * 1000
1040
+ const merges = []
1041
+ for (const [key, r] of runs) {
1042
+ const sm = summary(key)
1043
+ if (!sm || sm.workspace !== wid || !r.run.session.seamMerges) continue
1044
+ 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
1045
+ }
1046
+ return { ...ai, merges }
1047
+ }),
1048
+ '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 || '') })),
1049
+ '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 } }),
1006
1050
  '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 } }) })),
1007
1051
  'POST /api/workspaces/:id/delete': (b, id) => asAccount(async (token) => { await deleteWorkspace({ token, id: needWorkspaceId(id) }); return { ok: true } }),
1008
1052
  '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) }) })),
@@ -1095,6 +1139,14 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1095
1139
  'POST /api/sessions/:id/focus': (b, id) => { get(id).setFocus(b.text); return { ok: true } },
1096
1140
  // Voice (voice.js): the call as this app sees it, and our part in it, from the app window, which does the audio.
1097
1141
  'GET /api/sessions/:id/voice': (b, id) => get(id).voice(),
1142
+ // The Calls tab (dm06): the session's calls from their transcripts, newest first, each with its opening lines.
1143
+ 'GET /api/sessions/:id/calls': (b, id) => {
1144
+ const { lines, calls } = get(id).voiceTranscript({ limit: 1000 })
1145
+ 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 })) })) }
1146
+ },
1147
+ // The Preview tab: dev servers running from this session's folder on this computer (dev-servers.js).
1148
+ 'GET /api/sessions/:id/dev-servers': async (b, id) => { get(id); return { servers: await devServers(runs.get(id)?.run.dir, { skip: [server.address()?.port].filter(Boolean) }) } },
1149
+ 'GET /api/sessions/:id/calls/:call': (b, id, url, call) => ({ lines: get(id).voiceTranscript({ call, limit: 1000 }).lines }),
1098
1150
  '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 }),
1099
1151
  'POST /api/sessions/:id/voice/transcribe': (b, id) => get(id).setVoiceTranscribe(b.on === true),
1100
1152
  'POST /api/sessions/:id/voice/clip': (b, id) => voiceClip(get(id), b),
@@ -1166,6 +1218,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1166
1218
  'GET /api/sessions/:id/search': (b, id, url) => get(id).quiltSearch(String(url.searchParams.get('q') || '')),
1167
1219
  // In a session that moved into Seam: the square panel's Commit and Merge onto main, as this member (control.js seamTool).
1168
1220
  'POST /api/sessions/:id/seam': (b, id) => squareTool(get(id), b),
1221
+ 'GET /api/sessions/:id/github': (b, id) => seamGithub(get(id), {}),
1222
+ 'POST /api/sessions/:id/github': (b, id) => seamGithub(get(id), b),
1169
1223
  'GET /api/sessions/:id/file': (b, id, url) => {
1170
1224
  const f = get(id).readShared(url.searchParams.get('path'))
1171
1225
  if (!f) throw httpError(404, 'That file is not in this session.')
@@ -1329,6 +1383,13 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1329
1383
  return json(404, { error: 'not found' })
1330
1384
  }
1331
1385
 
1386
+ // App connections: /api/connections/…, and an app call waiting for a person (/api/app-calls/<room>[/<id>]).
1387
+ if (url.pathname.startsWith('/api/connections/') || url.pathname.startsWith('/api/app-calls/')) {
1388
+ let raw = ''
1389
+ for await (const chunk of req) raw += chunk
1390
+ return json(200, await connectionsRoute(req.method, url, raw ? JSON.parse(raw) : {}))
1391
+ }
1392
+
1332
1393
  let pathKey = url.pathname
1333
1394
  .replace(/^\/api\/sessions\/[a-f0-9]+/, '/api/sessions/:id')
1334
1395
  .replace(/^\/api\/workspaces\/[^/]+/, '/api/workspaces/:id')
@@ -1344,6 +1405,12 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1344
1405
  // A workspace's invite, the same way.
1345
1406
  const iid = (url.pathname.match(/^\/api\/workspaces\/[^/]+\/invites\/([^/]+)\//) || [])[1]
1346
1407
  if (iid) pathKey = pathKey.replace(/^(\/api\/workspaces\/:id\/invites)\/[^/]+/, '$1/:iid')
1408
+ // A workspace's link (a preview), the same way.
1409
+ const lid = (url.pathname.match(/^\/api\/workspaces\/[^/]+\/links\/([^/]+)\//) || [])[1]
1410
+ if (lid) pathKey = pathKey.replace(/^(\/api\/workspaces\/:id\/links)\/[^/]+/, '$1/:lid')
1411
+ // A call's transcript (the Calls tab), by the call's id.
1412
+ const cid = (url.pathname.match(/^\/api\/sessions\/[a-f0-9]+\/calls\/([^/]+)$/) || [])[1]
1413
+ if (cid) pathKey = pathKey.replace(/^(\/api\/sessions\/:id\/calls)\/[^/]+$/, '$1/:call')
1347
1414
  const key = `${req.method} ${pathKey}`
1348
1415
  const handler = api[key]
1349
1416
  if (!handler) {
@@ -1355,7 +1422,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1355
1422
  const body = raw ? JSON.parse(raw) : {}
1356
1423
  const startedAt = Date.now()
1357
1424
  try {
1358
- const out = await handler(body, sid, url, fid || aid || iid)
1425
+ const out = await handler(body, sid, url, fid || aid || iid || lid || (cid && decodeURIComponent(cid)))
1359
1426
  // A reply that streams (an agent's speech): straight through as it comes.
1360
1427
  if (out && out[STREAMED]) {
1361
1428
  res.writeHead(200, { 'content-type': out.type, 'cache-control': 'no-store' })
@@ -1577,6 +1644,14 @@ export function underJoinDir (joinDir, name, message = INVALID_INVITE) {
1577
1644
  * commits first), as this member through Seam's own tools; or open_square, for a folder whose branch has
1578
1645
  * none (Session.openSquareHere). The answer as { text }, a refusal as a 400.
1579
1646
  */
1647
+ /** Session settings' GitHub card: Seam's GitHub (the Seam app's installations, and the quilt's export to a repository). */
1648
+ async function seamGithub (s, b) {
1649
+ if (!s.seamGithub) return { quilt: false }
1650
+ const repo = b && typeof b.repo === 'string' ? b.repo.trim() : ''
1651
+ if (repo && !(/^[\w.-]+\/[\w.-]+$/.test(repo) && /^\d+$/.test(String(b.installation || '')))) throw httpError(400, 'Pick a repository the Seam app reaches.')
1652
+ 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) }
1653
+ }
1654
+
1580
1655
  export async function squareTool (s, b) {
1581
1656
  const tool = String((b && b.tool) || '')
1582
1657
  if (tool === 'open_square') {