heyquilt 0.3.192 → 0.3.194

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.
@@ -27,6 +27,7 @@ export async function checkRelease () {
27
27
  r.unseen = false
28
28
  }
29
29
  renderUpdateBar()
30
+ downloadAhead()
30
31
  if (!checkRelease.timer) checkRelease.timer = setInterval(() => checkRelease().catch(() => {}), RECHECK_MS)
31
32
  }
32
33
 
@@ -34,17 +35,19 @@ export async function checkRelease () {
34
35
  const desktop = () => window.quiltDesktop?.installUpdate ? window.quiltDesktop : null
35
36
  // Quilt run from source can't install a build: its folder gets each release with main, by itself.
36
37
  const fromSource = () => window.quiltDesktop?.dev === true
37
- let update = null // { phase: 'downloading' | 'installing' | 'restarting' | 'failed', received, total, error }
38
+ let update = null // { phase: 'ready' | 'downloading' | 'installing' | 'restarting' | 'failed', received, total, error }: 'ready' is downloaded ahead, waiting for a restart
39
+ let fetching = '' // the version being downloaded ahead of time, or already asked for
38
40
 
39
41
  /** Downloads and installs the newest Quilt from inside the desktop app. */
40
42
  async function startUpdate () {
41
43
  const d = desktop()
42
- if (!d || (update && update.phase !== 'failed')) return
44
+ if (!d || (update && update.phase !== 'failed' && update.phase !== 'ready')) return
43
45
  if (!startUpdate.listening) { startUpdate.listening = true; d.onUpdateProgress?.((p) => { update = { ...update, ...p }; refreshUpdateControls() }) }
44
- update = { phase: 'downloading', received: 0, total: 0 }
46
+ // Downloaded ahead of time: there is only the install left.
47
+ update = update?.phase === 'ready' ? { phase: 'installing' } : { phase: 'downloading', received: 0, total: 0 }
45
48
  refreshUpdateControls()
46
49
  try {
47
- await d.installUpdate()
50
+ await d.installUpdate(state.release?.latest?.version || '')
48
51
  update = { phase: 'restarting' }
49
52
  } catch (err) {
50
53
  update = { phase: 'failed', error: String(err?.message || err).replace(/^Error invoking remote method '[^']*': (Error: )?/, '') }
@@ -52,6 +55,27 @@ async function startUpdate () {
52
55
  refreshUpdateControls()
53
56
  }
54
57
 
58
+ /**
59
+ * With "Download updates automatically" on (Settings, About Quilt): fetches the newer Quilt quietly as
60
+ * soon as it is out, so the button only has to restart. A download that fails says nothing: the
61
+ * button still downloads it.
62
+ */
63
+ export async function downloadAhead () {
64
+ const d = desktop()
65
+ const r = state.release
66
+ const version = r?.latest?.version || ''
67
+ if (!d?.downloadUpdate || fromSource() || !r?.outOfDate || !state.profile?.autoUpdate) return
68
+ if (update || fetching === version) return
69
+ fetching = version
70
+ try {
71
+ await d.downloadUpdate(version)
72
+ if (update || state.release?.latest?.version !== version) return
73
+ update = { phase: 'ready' }
74
+ refreshUpdateControls()
75
+ renderUpdateBar()
76
+ } catch { fetching = '' }
77
+ }
78
+
55
79
  /** The button that gets the newer Quilt: installs it in the desktop app, downloads it elsewhere. */
56
80
  export function updateControl () {
57
81
  const r = state.release
@@ -60,6 +84,7 @@ export function updateControl () {
60
84
  if (!desktop()) return `<span class="update-ctl">${download}</span>`
61
85
  const phase = update?.phase
62
86
  if (!phase) return `<span class="update-ctl"><button class="btn sm primary" type="button" data-update>${I.down}<span>Update Quilt</span></button></span>`
87
+ if (phase === 'ready') return `<span class="update-ctl"><button class="btn sm primary" type="button" data-update>${I.refresh}<span>Restart to update</span></button></span>`
63
88
  if (phase === 'failed') {
64
89
  return `<span class="update-ctl update-failed"><span class="update-err" title="${esc(update.error)}">${esc(update.error)}</span><button class="btn sm primary" type="button" data-update>${I.refresh}<span>Try again</span></button>${download}</span>`
65
90
  }
@@ -89,7 +114,7 @@ export function renderUpdateBar () {
89
114
  }
90
115
  bar.innerHTML = `
91
116
  <span class="ub-dot"></span>
92
- <span class="ub-text"><b>Quilt ${esc(r.latest.version)} is out.</b> You have ${esc(r.version)}.</span>
117
+ <span class="ub-text"><b>Quilt ${esc(r.latest.version)} is ${update?.phase === 'ready' ? 'downloaded' : 'out'}.</b> You have ${esc(r.version)}.</span>
93
118
  <button class="btn sm ghost" type="button" data-release-notes>What's new</button>
94
119
  ${updateControl()}
95
120
  <label class="ub-never" title="Hide this bar until a newer Quilt than ${esc(r.latest.version)} is out"><input type="checkbox" data-update-never><span class="ub-long">Don't show this again</span><span class="ub-short">Don't show again</span></label>
package/src/ui/session.js CHANGED
@@ -461,8 +461,8 @@ function renderCodeSide () {
461
461
  })
462
462
  }
463
463
  if (boxed === 'connections') {
464
- extra.innerHTML = '<div class="files-head"><div class="t"><h2 class="crumbs">Connections</h2><p class="hint">Apps the agents in this codebase can use: its own, and the ones it gets from above. Agents never see the logins.</p></div></div><div data-code-connections></div>'
465
- codeConns = mountConnections(extra.querySelector('[data-code-connections]'), { type: 'session', id: st.room })
464
+ extra.innerHTML = '<div data-code-connections></div>'
465
+ codeConns = mountConnections(extra.firstElementChild, { type: 'session', id: st.room, page: { title: 'Connections', hint: `Apps the agents in this codebase can use: its own, and the ones it gets from ${projectHere() ? projectHere().name : 'above'}.` } })
466
466
  }
467
467
  if (boxed === 'artifacts') { drawCodeArtifacts(); loadCodeArtifacts() }
468
468
  } else if (codePreview) codePreview.update()
package/src/ui-server.js CHANGED
@@ -21,7 +21,7 @@ import { autowork, autoConfig, publicConfig, AUTO_MODES } from './autowork.js'
21
21
  import { migrateDir } from './legacy.js'
22
22
  import { writePrivateJson } from './private-file.js'
23
23
  import { autoToolFor } from './autowork-tools.js'
24
- import { workspaceMessages, sayInWorkspace, readWorkspaceMessages } from './account.js'
24
+ import { workspaceMessages, sayInWorkspace, readWorkspaceMessages, workspaceChannels, addWorkspaceChannel } from './account.js'
25
25
  import { readAccount, saveAccount, clearAccount, clearAccountIf, resumeAccount, startLink, waitForLink, signUpForLink, confirmSignUpForLink, fetchMe, signOut, revokeToken, accountFromProfile, renameSession, createAgentInvite, listAgents, agentDetails, listAccessTypes, listCollaborators, listGrants, putGrant, deleteGrant, inviteToSession, listSessionInvites, cancelSessionInvite, listWorkspaces, listOrgs, createWorkspace, getWorkspace, updateWorkspace, deleteWorkspace, putWorkspaceMember, removeWorkspaceMember, getAgentPlacement, putAgentPlacement, listOrgAgents, putWorkspaceAgent, deleteWorkspaceAgent, createWorkspaceAgentInvite, excludeSessionAgent, listExcludedSessionAgents, listSessionAgents, includeSessionAgent, setSessionWorkspace, moveSessionToWorkspace, listWorkspaceInvites, inviteToWorkspace, cancelWorkspaceInvite, listMyInvites, answerMyInvite, listMySessions, announceSessionStarted, announceWhenReported, listWorkspaceFiles, createWorkspaceFile, confirmWorkspaceFile, workspaceFileDownload, updateWorkspaceFile, deleteWorkspaceFile, createWorkspaceFolder, listWorkspaceFileVersions, listSandboxKeys, createSandboxKey, rotateSandboxKey, revokeSandboxKey, removeSandboxKey, aiVmFollow, aiVmUnfollow, aiVmStatus, aiVmConnect, aiVmUpdate, aiVmSignIn, aiVmWake, aiVmDisconnect, voiceIce, transcribeVoice, speakVoice, speakVoiceStream, openPreview, apiUrl } from './account.js'
26
26
  import { aiName } from './persona.js'
27
27
  import { effectiveAccess, builtinType } from './session-access.js'
@@ -74,6 +74,8 @@ function profile () {
74
74
  preferLocal: !!s.preferLocal,
75
75
  theme: THEMES.includes(s.theme) ? s.theme : 'dark', // dark unless you pick another
76
76
  report: s.report !== false,
77
+ // Download updates automatically (the desktop app): a newer Quilt is fetched as soon as it is out, so updating is a restart.
78
+ autoUpdate: !!s.autoUpdate,
77
79
  aiTasks: pickupMode(s.aiTasks),
78
80
  // When work comes to your AI (autowork.js): 'chat', 'open' or 'auto', with its model, files and daily cap.
79
81
  auto: publicConfig(autoConfig(s)),
@@ -104,6 +106,7 @@ function updateProfile (b) {
104
106
  patch.theme = b.theme === 'dark' ? undefined : b.theme
105
107
  }
106
108
  if ('report' in b) patch.report = b.report ? undefined : false
109
+ if ('autoUpdate' in b) patch.autoUpdate = b.autoUpdate ? true : undefined
107
110
  if ('aiTasks' in b) {
108
111
  if (!PICKUP_MODES.includes(b.aiTasks)) throw httpError(400, 'Pick Off, Assigned to it, or Assigned and unassigned.')
109
112
  patch.aiTasks = b.aiTasks === 'off' ? undefined : b.aiTasks
@@ -863,6 +866,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
863
866
  })
864
867
  const needInviteId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which invite?'); return String(id) }
865
868
  const needWorkspaceId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which project?'); return id }
869
+ const needChannelId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which channel?'); return String(id) }
866
870
  const needAgentId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which agent?'); return id }
867
871
  const needKeyId = (id) => { if (!/^[0-9a-f-]{36}$/i.test(String(id || ''))) throw httpError(400, 'Which key?'); return String(id) }
868
872
  /**
@@ -1041,6 +1045,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1041
1045
  const enc = (v) => encodeURIComponent(String(v))
1042
1046
  return asAccount(async (token) => {
1043
1047
  const c = secretsApi(token)
1048
+ const one = method === 'GET' && p.match(/^\/api\/connections\/apps\/([a-z0-9][a-z0-9_-]{0,79})$/i)
1049
+ if (one) return apiCall(c, 'GET', `/v1/connections/apps/${enc(one[1])}`)
1044
1050
  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')}`)
1045
1051
  const sc = p.match(/^\/api\/connections\/(org|workspace|session|account)\/([^/]+)(?:\/([0-9a-f-]{36}))?$/i)
1046
1052
  // A person's own connections are always "me": the accounts API reads who from the sign-in.
@@ -1187,6 +1193,12 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1187
1193
  'GET /api/workspaces/:id/messages': (b, id, url) => asAccount((token) => workspaceMessages({ token, id: needWorkspaceId(id), after: Number(url.searchParams.get('after')) || 0 })),
1188
1194
  'POST /api/workspaces/:id/messages': (b, id) => asAccount((token) => sayInWorkspace({ token, id: needWorkspaceId(id), text: String(b.text || '').slice(0, 8000) })),
1189
1195
  'POST /api/workspaces/:id/messages/read': (b, id) => asAccount((token) => readWorkspaceMessages({ token, id: needWorkspaceId(id) })),
1196
+ // The channels people made in a project, and each one's messages (the same three calls).
1197
+ 'GET /api/workspaces/:id/channels': (b, id) => asAccount((token) => workspaceChannels({ token, id: needWorkspaceId(id) })),
1198
+ 'POST /api/workspaces/:id/channels': (b, id) => asAccount((token) => addWorkspaceChannel({ token, id: needWorkspaceId(id), name: String(b.name || '').slice(0, 200) })),
1199
+ 'GET /api/workspaces/:id/channels/:cid/messages': (b, id, url, cid) => asAccount((token) => workspaceMessages({ token, id: needWorkspaceId(id), channel: needChannelId(cid), after: Number(url.searchParams.get('after')) || 0 })),
1200
+ 'POST /api/workspaces/:id/channels/:cid/messages': (b, id, url, cid) => asAccount((token) => sayInWorkspace({ token, id: needWorkspaceId(id), channel: needChannelId(cid), text: String(b.text || '').slice(0, 8000) })),
1201
+ 'POST /api/workspaces/:id/channels/:cid/messages/read': (b, id, url, cid) => asAccount((token) => readWorkspaceMessages({ token, id: needWorkspaceId(id), channel: needChannelId(cid) })),
1190
1202
  'GET /api/workspaces/:id/files': (b, id, url) => asAccount(async (token) => ({ files: await listWorkspaceFiles({ token, id: needWorkspaceId(id), folder: url.searchParams.get('folder') ?? undefined }) })),
1191
1203
  'GET /api/workspaces/:id/files/:fid/versions': (b, id, url, fid) => asAccount(async (token) => ({ versions: await listWorkspaceFileVersions({ token, id: needWorkspaceId(id), fileId: fid }) })),
1192
1204
  // The address an HTML artifact's frame loads (serveSealed): asked for by the page, with its token.
@@ -1497,6 +1509,9 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1497
1509
  // A workspace's invite, the same way.
1498
1510
  const iid = (url.pathname.match(/^\/api\/workspaces\/[^/]+\/invites\/([^/]+)\//) || [])[1]
1499
1511
  if (iid) pathKey = pathKey.replace(/^(\/api\/workspaces\/:id\/invites)\/[^/]+/, '$1/:iid')
1512
+ // A channel someone made in a workspace, the same way.
1513
+ const cid = (url.pathname.match(/^\/api\/workspaces\/[^/]+\/channels\/([^/]+)\//) || [])[1]
1514
+ if (cid) pathKey = pathKey.replace(/^(\/api\/workspaces\/:id\/channels)\/[^/]+/, '$1/:cid')
1500
1515
  const key = `${req.method} ${pathKey}`
1501
1516
  const handler = api[key]
1502
1517
  if (!handler) {
@@ -1508,7 +1523,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1508
1523
  const body = raw ? JSON.parse(raw) : {}
1509
1524
  const startedAt = Date.now()
1510
1525
  try {
1511
- const out = await handler(body, sid, url, fid || aid || iid)
1526
+ const out = await handler(body, sid, url, fid || aid || iid || cid)
1512
1527
  // A reply that streams (an agent's speech): straight through as it comes.
1513
1528
  if (out && out[STREAMED]) {
1514
1529
  res.writeHead(200, { 'content-type': out.type, 'cache-control': 'no-store' })