heyquilt 0.3.197 → 0.3.198
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/RELEASES.md +4 -0
- package/package.json +1 -1
- package/src/account.js +12 -0
- package/src/api/leader.js +2 -2
- package/src/api/routes/workspace-calls.js +138 -0
- package/src/api/server.js +2 -1
- package/src/ui/app.css +8 -0
- package/src/ui/project-call.js +158 -0
- package/src/ui/project-channel.js +5 -1
- package/src/ui/projects.js +17 -6
- package/src/ui/session.js +2 -0
- package/src/ui/voice.js +4 -0
- package/src/ui-server.js +6 -2
package/RELEASES.md
CHANGED
|
@@ -11,6 +11,10 @@ Format: `## <version> — <YYYY-MM-DD>`, an optional one-line summary, then bull
|
|
|
11
11
|
Lead each bullet with a short bold phrase. Inline `code` and **bold** are rendered;
|
|
12
12
|
nothing else is.
|
|
13
13
|
|
|
14
|
+
## 0.3.198 — 2026-11-24
|
|
15
|
+
|
|
16
|
+
- **Calls in a project's channels.** Call in a channel's header starts a voice call there, in the project's own channel and in the ones its people made. It reaches everyone in the project wherever they are: on the project's page with no codebase open, or inside any of its codebases. Who is in it shows in the header with Join, then mute and leave, and the channel's row in the sidebar says how many are in the call. One call at a time: joining a codebase's call leaves a channel's, and the other way round. These calls are not transcribed, and a screen cannot be shared in them yet.
|
|
17
|
+
|
|
14
18
|
## 0.3.197 — 2026-11-24
|
|
15
19
|
|
|
16
20
|
- **One short invite.** A codebase's Invite is two tiles: a person (Copy invite link) and an AI (Copy prompt). There is nothing to pick first: no edit or view-only link, no "Invite as", no kinds of AI. Under them the owner can still let someone straight in by their email, or by picking someone they have worked with; invites still waiting sit beside them. A view-only link is one quiet line at the bottom.
|
package/package.json
CHANGED
package/src/account.js
CHANGED
|
@@ -372,6 +372,18 @@ export async function workspaceChannels ({ token, id, api = apiUrl(), fetch: fet
|
|
|
372
372
|
if (!Array.isArray(r.channels)) throw new Error(BAD_REPLY)
|
|
373
373
|
return r
|
|
374
374
|
}
|
|
375
|
+
/** The calls going on in a project's channels: { calls: { <channel id, or '' for the project's own>: { since, people } } }. */
|
|
376
|
+
export async function workspaceCalls ({ token, id, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
|
|
377
|
+
const r = await call(fetchImpl, api, 'GET', `${ws$(id)}/call`, null, token)
|
|
378
|
+
if (!r.calls || typeof r.calls !== 'object') throw new Error(BAD_REPLY)
|
|
379
|
+
return r
|
|
380
|
+
}
|
|
381
|
+
/** One app window's part in a project channel's call (`body`: { channel, client, in, muted, sharing, sig }); answers the call as that window sees it. */
|
|
382
|
+
export async function workspaceCall ({ token, id, body, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
|
|
383
|
+
const r = await call(fetchImpl, api, 'POST', `${ws$(id)}/call`, body, token)
|
|
384
|
+
if (!Array.isArray(r.peers)) throw new Error(BAD_REPLY)
|
|
385
|
+
return r
|
|
386
|
+
}
|
|
375
387
|
export async function addWorkspaceChannel ({ token, id, name, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
|
|
376
388
|
const r = await call(fetchImpl, api, 'POST', `${ws$(id)}/channels`, { name }, token)
|
|
377
389
|
if (!r.channel) throw new Error(BAD_REPLY)
|
package/src/api/leader.js
CHANGED
|
@@ -36,5 +36,5 @@ export function leader ({ store, machineId = '', log = () => {}, ttlMs = TTL_MS,
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/** Requests that only the leader may answer: people's cloud AI machines and their spares. */
|
|
40
|
-
export const LEADER_ONLY = /^\/v1\/(?:me\/ai-vm(?:\/|$)|ai-vm\/|relay\/ai-vm\/)/
|
|
39
|
+
/** Requests that only the leader may answer: people's cloud AI machines and their spares, and the calls in projects' channels (routes/workspace-calls.js). */
|
|
40
|
+
export const LEADER_ONLY = /^\/v1\/(?:me\/ai-vm(?:\/|$)|ai-vm\/|relay\/ai-vm\/|workspaces\/[^/]+\/call$)/
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// A call in a project's channel (plans/voice.md, "A call in a project's channel"): the project's
|
|
2
|
+
// own channel and each one its people made has a voice call of its own, for everyone in the
|
|
3
|
+
// project wherever they are: on the project's page or inside any of its codebases.
|
|
4
|
+
//
|
|
5
|
+
// A codebase's call rides the relay's presence. A project is not on the relay, so this keeps the
|
|
6
|
+
// same thing here: who is in each call, muted or sharing or not, and the call setup each pair
|
|
7
|
+
// leaves the other (their WebRTC offer and answer). The audio goes from app window to app window,
|
|
8
|
+
// never through here. An app window in a call says so every second or two, with everything it
|
|
9
|
+
// has to say; one that stops is out of the call a few seconds later. Nothing is kept in the
|
|
10
|
+
// database: the calls live in this machine's memory, so on several machines they are the
|
|
11
|
+
// leader's (leader.js), and a new leader hears each window's part again within a second or two.
|
|
12
|
+
//
|
|
13
|
+
// These calls are never transcribed, so no agent hears them and they leave no card in the channel.
|
|
14
|
+
import { HttpError, needId, stripInvisible } from '../http.js'
|
|
15
|
+
import { workspaceReach, canSeeFiles } from '../workspace-reach.js'
|
|
16
|
+
import { cleanVoice, newCallId, MAX_IN_CALL, CALL_FULL } from '../../voice.js'
|
|
17
|
+
|
|
18
|
+
// A window that has not said it is in the call for this long has left it.
|
|
19
|
+
export const CALL_STALE_MS = 12 * 1000
|
|
20
|
+
// How long a window that left is still named as there but out of the call, so the others hang up at once.
|
|
21
|
+
const LEFT_MS = 30 * 1000
|
|
22
|
+
// Who may be in a project's calls is looked up again this often, not at every word from a window.
|
|
23
|
+
const KNOWN_MS = 60 * 1000
|
|
24
|
+
const CLIENT = /^[1-9]\d{0,11}$/
|
|
25
|
+
|
|
26
|
+
export function workspaceCallRoutes (ctx) {
|
|
27
|
+
const { store, now = Date.now, workspaces = false } = ctx
|
|
28
|
+
const { reach } = workspaceReach(ctx)
|
|
29
|
+
const gated = (fn) => (...args) => {
|
|
30
|
+
if (!workspaces) throw new HttpError(404, 'not found')
|
|
31
|
+
return fn(...args)
|
|
32
|
+
}
|
|
33
|
+
const rooms = new Map() // `${project}|${channel}` -> { call, in: Map(window -> { account, name, muted, sharing, since, sig, seen }), left: Map(window -> when) }
|
|
34
|
+
const known = new Map() // who asked, for which project -> { ws, account, name, until }
|
|
35
|
+
|
|
36
|
+
/** The project and the caller, a person in it. Looked up at most once a minute for each. */
|
|
37
|
+
async function inProject (req, id) {
|
|
38
|
+
const key = `${req.headers.authorization || ''}|${id}`
|
|
39
|
+
const at = now()
|
|
40
|
+
const hit = known.get(key)
|
|
41
|
+
if (hit && hit.until > at) return hit
|
|
42
|
+
const r = await reach(req, needId(id, 'project'))
|
|
43
|
+
if (!canSeeFiles(r.access)) throw new HttpError(403, 'Only people in this project are in its calls.')
|
|
44
|
+
const [kind, pid] = String(r.me.account).split(':')
|
|
45
|
+
if (kind !== 'person') throw new HttpError(403, 'Agents are not in a project\'s calls.')
|
|
46
|
+
const name = stripInvisible((await store.profile(pid))?.name || '').join('').trim() || 'Someone'
|
|
47
|
+
const got = { ws: r.ws.id, account: r.me.account, name, until: at + KNOWN_MS }
|
|
48
|
+
known.set(key, got)
|
|
49
|
+
if (known.size > 5000) for (const [k, v] of known) if (v.until <= at) known.delete(k)
|
|
50
|
+
return got
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Windows that stopped saying they are in a call are out of it; an empty call is forgotten. */
|
|
54
|
+
function sweep (at) {
|
|
55
|
+
for (const [key, room] of rooms) {
|
|
56
|
+
for (const [id, e] of room.in) if (at - e.seen > CALL_STALE_MS) { room.in.delete(id); room.left.set(id, at) }
|
|
57
|
+
for (const [id, when] of room.left) if (at - when > LEFT_MS) room.left.delete(id)
|
|
58
|
+
if (!room.in.size) room.call = ''
|
|
59
|
+
if (!room.in.size && !room.left.size) rooms.delete(key)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The call as one window sees it: the shape a codebase's call has (voice.js), so the app's audio code is the same. */
|
|
64
|
+
function viewFor (room, client) {
|
|
65
|
+
const mine = room ? room.in.get(client) : null
|
|
66
|
+
const peers = room ? [...room.in].filter(([id]) => id !== client).map(([id, e]) => ({ id: Number(id), name: e.name, color: '', muted: e.muted, since: e.since, call: room.call, ...(e.sharing ? { sharing: true } : {}), signal: e.sig[client] || null })) : []
|
|
67
|
+
peers.sort((a, b) => a.since - b.since || a.id - b.id)
|
|
68
|
+
const starts = [...(mine ? [mine.since] : []), ...peers.map((p) => p.since)].filter((x) => x > 0)
|
|
69
|
+
return {
|
|
70
|
+
me: Number(client) || 0,
|
|
71
|
+
in: !!mine,
|
|
72
|
+
muted: !!(mine && mine.muted),
|
|
73
|
+
sharing: !!(mine && mine.sharing),
|
|
74
|
+
call: room ? room.call : '',
|
|
75
|
+
since: starts.length ? Math.min(...starts) : 0,
|
|
76
|
+
transcribe: false,
|
|
77
|
+
peers,
|
|
78
|
+
// Everyone this call knows of, in it or just out of it: someone here but not a peer hung up.
|
|
79
|
+
here: room ? [...peers.map((p) => p.id), ...[...room.left.keys()].filter((id) => id !== client).map(Number)] : [],
|
|
80
|
+
recent: [],
|
|
81
|
+
calls: [],
|
|
82
|
+
agents: []
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** '' for the project's own channel, or the id of one its people made, which must be this project's. */
|
|
87
|
+
async function channelOf (ws, raw) {
|
|
88
|
+
const cid = String(raw || '')
|
|
89
|
+
if (!cid) return ''
|
|
90
|
+
if (rooms.has(`${ws}|${cid}`)) return cid
|
|
91
|
+
const ch = await store.workspaceChannelById(needId(cid, 'channel')).catch(() => null)
|
|
92
|
+
if (!ch || ch.workspaceId !== ws) throw new HttpError(404, 'no such channel')
|
|
93
|
+
return cid
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return [
|
|
97
|
+
// The calls going on in the project: for each channel with one ('' is the project's own), who is in it.
|
|
98
|
+
['GET', /^\/v1\/workspaces\/([^/]+)\/call$/, gated(async (req, body, [id]) => {
|
|
99
|
+
const me = await inProject(req, id)
|
|
100
|
+
sweep(now())
|
|
101
|
+
const calls = {}
|
|
102
|
+
for (const [key, room] of rooms) {
|
|
103
|
+
const [ws, channel] = key.split('|')
|
|
104
|
+
if (ws !== me.ws || !room.in.size) continue
|
|
105
|
+
calls[channel] = { since: Math.min(...[...room.in.values()].map((e) => e.since)), people: [...new Set([...room.in.values()].map((e) => e.name))] }
|
|
106
|
+
}
|
|
107
|
+
return { calls }
|
|
108
|
+
})],
|
|
109
|
+
|
|
110
|
+
// One app window's part in a channel's call: in it or not, muted, sharing, and what it leaves each
|
|
111
|
+
// of the others to set the call up. Answers the call as that window sees it. Said again every
|
|
112
|
+
// second or two while in the call; `in: false` leaves, and asks nothing more.
|
|
113
|
+
['POST', /^\/v1\/workspaces\/([^/]+)\/call$/, gated(async (req, body, [id]) => {
|
|
114
|
+
const me = await inProject(req, id)
|
|
115
|
+
const client = String(body.client ?? '')
|
|
116
|
+
if (!CLIENT.test(client)) throw new HttpError(400, 'client is this window\'s number in the call.')
|
|
117
|
+
const channel = await channelOf(me.ws, body.channel)
|
|
118
|
+
const key = `${me.ws}|${channel}`
|
|
119
|
+
const at = now()
|
|
120
|
+
sweep(at)
|
|
121
|
+
let room = rooms.get(key)
|
|
122
|
+
const mine = room ? room.in.get(client) : null
|
|
123
|
+
// A window's number is its own: nobody else speaks for it.
|
|
124
|
+
if (mine && mine.account !== me.account) throw new HttpError(409, 'That window is someone else\'s.')
|
|
125
|
+
if (body.in === false) {
|
|
126
|
+
if (mine) { room.in.delete(client); room.left.set(client, at); if (!room.in.size) room.call = '' }
|
|
127
|
+
return viewFor(room, client)
|
|
128
|
+
}
|
|
129
|
+
const v = cleanVoice({ in: true, muted: body.muted, sharing: body.sharing, sig: body.sig })
|
|
130
|
+
if (!mine && room && room.in.size >= MAX_IN_CALL) throw new HttpError(409, CALL_FULL)
|
|
131
|
+
if (!room) { room = { call: '', in: new Map(), left: new Map() }; rooms.set(key, room) }
|
|
132
|
+
if (!room.call) room.call = newCallId(at)
|
|
133
|
+
room.left.delete(client)
|
|
134
|
+
room.in.set(client, { account: me.account, name: me.name, muted: v.muted, sharing: !!v.sharing, since: mine ? mine.since : at, sig: v.sig, seen: at })
|
|
135
|
+
return viewFor(room, client)
|
|
136
|
+
})]
|
|
137
|
+
]
|
|
138
|
+
}
|
package/src/api/server.js
CHANGED
|
@@ -37,6 +37,7 @@ import { workspaceFileRoutes } from './routes/workspace-files.js'
|
|
|
37
37
|
import { workspaceAgentRoutes } from './routes/workspace-agents.js'
|
|
38
38
|
import { workspaceInviteRoutes } from './routes/workspace-invites.js'
|
|
39
39
|
import { workspaceChatRoutes } from './routes/workspace-chat.js'
|
|
40
|
+
import { workspaceCallRoutes } from './routes/workspace-calls.js'
|
|
40
41
|
import { HOSTED_RELAY } from '../settings.js'
|
|
41
42
|
import { roomAccessFrom } from './access.js'
|
|
42
43
|
import { joiningRoom, sessionArg } from '../mcp-room.js'
|
|
@@ -454,7 +455,7 @@ export function startApi ({ port = 0, host = '127.0.0.1', store, verifyUser, sit
|
|
|
454
455
|
// Always routed: with the flag off each answers a plain 404 of its own, so the app's
|
|
455
456
|
// check at every launch isn't filed as a missing route.
|
|
456
457
|
// Only these take a hosted agent's pass (workspaceReach), so they alone get the pass key.
|
|
457
|
-
routes.push(...workspaceRoutes({ ...ctx, workspaces, passKey, policyChanged }), ...workspaceInviteRoutes({ ...ctx, workspaces, passKey }), ...workspaceChatRoutes({ ...ctx, workspaces, passKey }), ...workspaceAgentRoutes({ ...ctx, workspaces, passKey, relayUrl, webhookFetch, webhookLookup, allowLocalWebhooks, trackDelivery, limitAnnounce }))
|
|
458
|
+
routes.push(...workspaceRoutes({ ...ctx, workspaces, passKey, policyChanged }), ...workspaceInviteRoutes({ ...ctx, workspaces, passKey }), ...workspaceChatRoutes({ ...ctx, workspaces, passKey }), ...workspaceCallRoutes({ ...ctx, workspaces, passKey }), ...workspaceAgentRoutes({ ...ctx, workspaces, passKey, relayUrl, webhookFetch, webhookLookup, allowLocalWebhooks, trackDelivery, limitAnnounce }))
|
|
458
459
|
const wsFiles = workspaceFileRoutes({ ...ctx, workspaces, passKey })
|
|
459
460
|
routes.push(...wsFiles.routes)
|
|
460
461
|
// Secrets (routes/secrets.js): off until the vault is set up (QUILT_VAULT_SECRET).
|
package/src/ui/app.css
CHANGED
|
@@ -1949,6 +1949,14 @@ iframe.pv-page { flex: 1; min-height: 0; width: 100%; border: 0; background: #ff
|
|
|
1949
1949
|
.pj-chanpage, .pj-chan { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
1950
1950
|
.pj-chan .files-head { flex: none; margin: 0; padding: 16px 24px 12px; border-bottom: 1px solid var(--border); }
|
|
1951
1951
|
.pj-chan .files-head .pj-hash { margin-right: 6px; color: var(--muted); }
|
|
1952
|
+
/* The channel's call, in its header (project-call.js): Call, or who is in it with Join, or our own mute and leave. */
|
|
1953
|
+
.pj-chan .files-head { display: flex; align-items: center; gap: 16px; }
|
|
1954
|
+
.pj-chan .files-head .t { flex: 1; min-width: 0; }
|
|
1955
|
+
.pj-chan-call { flex: none; display: flex; align-items: center; }
|
|
1956
|
+
.pj-chan-call .chat-call { margin-left: 0; height: 32px; padding: 0 14px; font-size: 13px; }
|
|
1957
|
+
.pc-on { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel); font-size: 13px; }
|
|
1958
|
+
.pc-on b { font-weight: 600; white-space: nowrap; }
|
|
1959
|
+
.pc-who { display: flex; flex-direction: column; line-height: 1.25; }
|
|
1952
1960
|
.pj-chan .messages { padding: 18px 24px; }
|
|
1953
1961
|
.pj-chan .composer { flex: none; padding: 12px 24px 20px; }
|
|
1954
1962
|
.pj-rooms button .avatar { width: 18px; height: 18px; font-size: 9px; flex: none; }
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// A call in one of a project's channels (plans/voice.md, "A call in a project's channel"): Call
|
|
2
|
+
// in the channel's header starts it, and it is there for everyone in the project, on the
|
|
3
|
+
// project's page or inside any of its codebases. The audio is voice-call.js, the same as a
|
|
4
|
+
// codebase's call; who is in the call and each pair's call setup go through the accounts API
|
|
5
|
+
// (routes/workspace-calls.js) instead of the relay, said again every second or two while in it.
|
|
6
|
+
// It is never transcribed, and no screen is shared in it yet.
|
|
7
|
+
import { $, esc, api, toast, avatar, I, TOKEN } from './common.js'
|
|
8
|
+
import { VoiceCall } from './voice-call.js'
|
|
9
|
+
import { playSound } from './sounds.js'
|
|
10
|
+
|
|
11
|
+
// This window's number in a project's calls: its own for as long as the window is open.
|
|
12
|
+
const CLIENT = Math.floor(Math.random() * 9e8) + 1e8
|
|
13
|
+
const BEAT_MS = 1500
|
|
14
|
+
const ASK_MS = 4000
|
|
15
|
+
const FULL = 6
|
|
16
|
+
const NO_MIC = "Quilt can't use your microphone. Allow it for Quilt in System Settings → Privacy & Security → Microphone, then try again."
|
|
17
|
+
const heard = new Map() // project id -> { calls: { <channel>: { since, people } }, asked }
|
|
18
|
+
let live = null // the call this window is in: { ws, channel, call, view, beat }
|
|
19
|
+
let joining = '' // the call being joined (`project|channel`), while the microphone opens
|
|
20
|
+
let shown = null // the channel on screen: { el, ws, channel, changed, drawn }
|
|
21
|
+
const keyOf = (ws, channel) => `${ws}|${channel || ''}`
|
|
22
|
+
const urlOf = (ws) => `/api/workspaces/${encodeURIComponent(ws)}/call`
|
|
23
|
+
const minutes = (from) => { const m = Math.round((Date.now() - from) / 60000); return m < 1 ? 'under a minute' : `${m} min` }
|
|
24
|
+
const names = (list) => list.length <= 2 ? list.join(' and ') : `${list.slice(0, -1).join(', ')} and ${list[list.length - 1]}`
|
|
25
|
+
|
|
26
|
+
/** How many people are in a channel's call (`channel` '' is the project's own), as last heard; 0 with no call. */
|
|
27
|
+
export function channelCall (ws, channel = '') {
|
|
28
|
+
if (live && live.ws === ws && live.channel === channel && live.call.in) return 1 + (live.view ? live.view.peers.length : 0)
|
|
29
|
+
return heard.get(ws)?.calls[channel]?.people.length || 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Asks which of a project's channels have a call going (at most every few seconds). `changed()`: one began, ended, or someone came or went. */
|
|
33
|
+
export async function loadCalls (ws, changed = () => {}) {
|
|
34
|
+
if (!heard.has(ws)) heard.set(ws, { calls: {}, asked: 0 })
|
|
35
|
+
const h = heard.get(ws)
|
|
36
|
+
if (Date.now() - h.asked < ASK_MS) return
|
|
37
|
+
h.asked = Date.now()
|
|
38
|
+
try {
|
|
39
|
+
const r = await api('GET', urlOf(ws))
|
|
40
|
+
const was = JSON.stringify(h.calls)
|
|
41
|
+
h.calls = r.calls || {}
|
|
42
|
+
if (JSON.stringify(h.calls) !== was) { changed(); draw() }
|
|
43
|
+
} catch {} // a server without calls in channels yet: no call is shown, and Call says why when pressed
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function join (ws, channel) {
|
|
47
|
+
if (joining) return
|
|
48
|
+
joining = keyOf(ws, channel)
|
|
49
|
+
draw()
|
|
50
|
+
try {
|
|
51
|
+
if (live) await leave()
|
|
52
|
+
// One call at a time: a codebase's call this window is in ends (voice.js hears this).
|
|
53
|
+
window.dispatchEvent(new CustomEvent('quilt-call', { detail: 'project' }))
|
|
54
|
+
const mine = { ws, channel, view: null, beat: null }
|
|
55
|
+
const call = new VoiceCall({
|
|
56
|
+
post: (b) => api('POST', urlOf(ws), { ...b, channel, client: CLIENT }).then((v) => { mine.view = v; return v }),
|
|
57
|
+
ice: () => api('GET', '/api/voice/ice'),
|
|
58
|
+
onChange: () => draw(),
|
|
59
|
+
onPeople: (sound) => playSound(sound, { force: true })
|
|
60
|
+
})
|
|
61
|
+
mine.call = call
|
|
62
|
+
live = mine
|
|
63
|
+
await call.join()
|
|
64
|
+
// Still in the call: said again every second or two, which is also how the others' news comes.
|
|
65
|
+
mine.beat = setInterval(() => call.publish(), BEAT_MS)
|
|
66
|
+
playSound('callIn', { force: true })
|
|
67
|
+
} catch (err) {
|
|
68
|
+
if (live && live.ws === ws && live.channel === channel) { clearInterval(live.beat); await live.call.leave().catch(() => {}); live = null }
|
|
69
|
+
toast(err && (err.name === 'NotAllowedError' || err.name === 'NotFoundError') ? NO_MIC : err.status === 404 ? "Calls in a project's channels aren't on Quilt's servers yet." : `Couldn't join the call: ${err.message}`)
|
|
70
|
+
} finally {
|
|
71
|
+
joining = ''
|
|
72
|
+
changedNow()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function leave () {
|
|
77
|
+
if (!live) return
|
|
78
|
+
const { call, beat, ws } = live
|
|
79
|
+
live = null
|
|
80
|
+
clearInterval(beat)
|
|
81
|
+
await call.leave().catch(() => {})
|
|
82
|
+
playSound('callOut', { force: true })
|
|
83
|
+
if (heard.has(ws)) heard.get(ws).asked = 0
|
|
84
|
+
changedNow()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The page's own counts (the sidebar's rows) and the header, after joining or leaving. */
|
|
88
|
+
function changedNow () {
|
|
89
|
+
draw()
|
|
90
|
+
if (shown) { shown.changed(); loadCalls(shown.ws, shown.changed) }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// A codebase's call was joined in this window: this one ends.
|
|
94
|
+
window.addEventListener('quilt-call', (e) => { if (e.detail !== 'project' && live) leave() })
|
|
95
|
+
// Closing or reloading the window leaves the call (the page can't wait for an answer).
|
|
96
|
+
window.addEventListener('pagehide', () => {
|
|
97
|
+
if (!live) return
|
|
98
|
+
navigator.sendBeacon(`${urlOf(live.ws)}?t=${encodeURIComponent(TOKEN || '')}`, new Blob([JSON.stringify({ channel: live.channel, client: CLIENT, in: false })], { type: 'application/json' }))
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const face = (key, name, muted) => `<span class="call-face" data-face="${key}" title="${esc(name)}${muted ? ' (muted)' : ''}">${avatar(name)}${muted ? `<span class="call-muted">${I.micOff}</span>` : ''}</span>`
|
|
102
|
+
|
|
103
|
+
/** The call's place in the channel's header: Call, or who is in it with Join, or our own mute and leave. */
|
|
104
|
+
function draw () {
|
|
105
|
+
if (!shown || !shown.el.isConnected) return
|
|
106
|
+
const { el, ws, channel } = shown
|
|
107
|
+
const here = !!(live && live.ws === ws && live.channel === channel && live.call.in)
|
|
108
|
+
const starting = joining === keyOf(ws, channel)
|
|
109
|
+
const elsewhere = !!(live && !here)
|
|
110
|
+
const others = here ? (live.view ? live.view.peers : []) : (heard.get(ws)?.calls[channel]?.people || []).map((name, i) => ({ id: `n${i}`, name, muted: false }))
|
|
111
|
+
const since = here ? live.view?.since : heard.get(ws)?.calls[channel]?.since
|
|
112
|
+
const c = here ? live.call : null
|
|
113
|
+
const key = JSON.stringify([ws, channel, here, starting, elsewhere, others.map((p) => [p.id, p.name, p.muted]), here && c.muted, since ? minutes(since) : ''])
|
|
114
|
+
if (key !== shown.drawn) {
|
|
115
|
+
shown.drawn = key
|
|
116
|
+
const you = meName()
|
|
117
|
+
if (starting) {
|
|
118
|
+
el.innerHTML = '<span class="pc-on"><span class="call-dot"></span><b>Joining the call…</b></span>'
|
|
119
|
+
} else if (here) {
|
|
120
|
+
el.innerHTML = `<span class="pc-on"><span class="call-dot"></span><span class="call-faces">${face('me', you, c.muted)}${others.map((p) => face(p.id, p.name, p.muted)).join('')}</span>
|
|
121
|
+
<span class="call-sub">${others.length ? esc(minutes(since || Date.now())) : 'Only you so far'}</span>
|
|
122
|
+
<button type="button" class="call-ic" data-pc-mute aria-pressed="${c.muted}" title="${c.muted ? 'Unmute' : 'Mute'}" aria-label="${c.muted ? 'Unmute' : 'Mute'}">${c.muted ? I.micOff : I.mic}</button>
|
|
123
|
+
<button type="button" class="call-ic bad" data-pc-leave title="Leave the call" aria-label="Leave the call">${I.hangUp}</button></span>`
|
|
124
|
+
} else if (others.length) {
|
|
125
|
+
el.innerHTML = `<span class="pc-on"><span class="call-dot"></span><span class="call-faces">${others.map((p) => face(p.id, p.name, false)).join('')}</span>
|
|
126
|
+
<span class="pc-who"><b>${esc(names(others.map((p) => p.name)))} ${others.length === 1 ? 'is' : 'are'} in a call</b><span class="call-sub">${since ? esc(minutes(since)) : ''}</span></span>
|
|
127
|
+
<button type="button" class="btn sm primary" data-pc-join ${elsewhere ? 'disabled title="Leave your other call first"' : others.length >= FULL ? 'disabled title="This call is full: calls hold six people for now."' : ''}>Join</button></span>`
|
|
128
|
+
} else {
|
|
129
|
+
el.innerHTML = `<button type="button" class="chat-call" data-pc-join title="${elsewhere ? 'Leave your other call first' : 'Start a voice call in this channel'}"${elsewhere ? ' disabled' : ''}>${I.headset}<span>Call</span></button>`
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Who is speaking: a ring, painted without drawing the buttons again under a press.
|
|
133
|
+
if (here) for (const f of el.querySelectorAll('[data-face]')) f.classList.toggle('talk', c.speaking(f.dataset.face === 'me' ? 'me' : Number(f.dataset.face)))
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let meName = () => 'You'
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* A channel is on screen: its call goes in `el`, in the channel's header. `me`: your name;
|
|
140
|
+
* `changed()`: how many are in a call changed (the sidebar's rows show it).
|
|
141
|
+
*/
|
|
142
|
+
export function mountChannelCall (el, { ws, channel = '', me = 'You', changed = () => {} }) {
|
|
143
|
+
meName = () => me
|
|
144
|
+
shown = { el, ws, channel, changed, drawn: '' }
|
|
145
|
+
el.onclick = (e) => {
|
|
146
|
+
const b = e.target.closest('button')
|
|
147
|
+
if (!b || !shown || shown.el !== el) return
|
|
148
|
+
if (b.hasAttribute('data-pc-join')) join(ws, channel)
|
|
149
|
+
else if (b.hasAttribute('data-pc-leave')) leave()
|
|
150
|
+
else if (b.hasAttribute('data-pc-mute') && live) live.call.setMuted(!live.call.muted)
|
|
151
|
+
}
|
|
152
|
+
draw()
|
|
153
|
+
if (heard.has(ws)) heard.get(ws).asked = 0
|
|
154
|
+
loadCalls(ws, changed)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// The call's minutes, and who is in a call we are not in, as the page stays open.
|
|
158
|
+
setInterval(() => { if (shown && shown.el.isConnected) { draw(); if (!live) loadCalls(shown.ws, shown.changed) } }, ASK_MS)
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// seconds while a project's page is open. A codebase's own channel is its chat.
|
|
5
5
|
import { I, state, $, esc, api, toast, avatar, clock } from './common.js'
|
|
6
6
|
import { textHtml } from './chat.js'
|
|
7
|
+
import { mountChannelCall } from './project-call.js'
|
|
7
8
|
|
|
8
9
|
const ASK_MS = 4000
|
|
9
10
|
// `channel` everywhere here: the id of a channel someone made, or '' for the project's own.
|
|
@@ -96,12 +97,14 @@ export function mountChannel (el, { d, changed = () => {}, channel = null }) {
|
|
|
96
97
|
const names = () => [...new Set([d.owner?.name, ...(d.members || []).map((m) => m.name), ...(d.agents || []).map((a) => a.name)].filter(Boolean))]
|
|
97
98
|
el.innerHTML = `
|
|
98
99
|
<div class="pj-chan">
|
|
99
|
-
<div class="files-head"><div class="t"><h2 class="crumbs"><span class="pj-hash">#</span>${esc(title)}</h2><p class="hint">Everyone in ${esc(d.workspace.name)} and its agents. It is here with no codebase open.</p></div></div>
|
|
100
|
+
<div class="files-head"><div class="t"><h2 class="crumbs"><span class="pj-hash">#</span>${esc(title)}</h2><p class="hint">Everyone in ${esc(d.workspace.name)} and its agents. It is here with no codebase open.</p></div><div class="pj-chan-call" data-chan-call></div></div>
|
|
100
101
|
<div class="messages" data-chan-list aria-live="polite"></div>
|
|
101
102
|
<form class="composer" data-chan-form><div class="box"><textarea rows="1" maxlength="8000" placeholder="Message ${esc(title)}…" aria-label="Message ${esc(title)}"></textarea><button type="submit" class="btn primary icon" title="Send" aria-label="Send">${I.send}</button></div></form>
|
|
102
103
|
</div>`
|
|
103
104
|
const list = $('[data-chan-list]', el)
|
|
104
105
|
const box = $('textarea', el)
|
|
106
|
+
// The channel's call, in its header: for everyone in the project, wherever they are.
|
|
107
|
+
mountChannelCall($('[data-chan-call]', el), { ws: id, channel: cid, me: me || 'You', changed })
|
|
105
108
|
const draw = () => {
|
|
106
109
|
const near = list.scrollHeight - list.scrollTop - list.clientHeight < 80
|
|
107
110
|
const all = names()
|
|
@@ -118,6 +121,7 @@ export function mountChannel (el, { d, changed = () => {}, channel = null }) {
|
|
|
118
121
|
box.value = c.draft
|
|
119
122
|
box.oninput = () => { c.draft = box.value; grow() }
|
|
120
123
|
grow()
|
|
124
|
+
requestAnimationFrame(grow) // again once the page is laid out: measured too early, an empty box comes out tall
|
|
121
125
|
box.onkeydown = (e) => { if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) { e.preventDefault(); $('[data-chan-form]', el).requestSubmit() } }
|
|
122
126
|
$('[data-chan-form]', el).onsubmit = async (e) => {
|
|
123
127
|
e.preventDefault()
|
package/src/ui/projects.js
CHANGED
|
@@ -6,6 +6,7 @@ import { I, state, $, esc, ago, api, toast, ask, avatar, COLORS, loadingHtml } f
|
|
|
6
6
|
import { quiltMark } from './mark.js'
|
|
7
7
|
import { quiltBlock, projectCodebases, looseCodebases, whoLine, readFolded, projectDms } from './project-model.js'
|
|
8
8
|
import { mountChannel, loadChannel, channelUnread, projectChannels, loadChannels, addChannel } from './project-channel.js'
|
|
9
|
+
import { channelCall, loadCalls } from './project-call.js'
|
|
9
10
|
import { tileLetter } from './prail-model.js'
|
|
10
11
|
import { loadWorkspaces, openWorkspace, wsIdOf } from './workspaces.js'
|
|
11
12
|
import { openNewProject, openProjectPop } from './project-pop.js'
|
|
@@ -42,6 +43,8 @@ export function drawSideShut (ws) {
|
|
|
42
43
|
b.title = `${shut ? 'Show' : 'Hide'} the sidebar`
|
|
43
44
|
b.setAttribute('aria-label', b.title)
|
|
44
45
|
}
|
|
46
|
+
// A call going on in a project's channel, on its row: how many are in it.
|
|
47
|
+
const callMark = (n) => n ? `<span class="pj-call" title="${n === 1 ? '1 person is' : `${n} people are`} in a call here">${I.headset}${n}</span>` : ''
|
|
45
48
|
// The plus beside Channels, in a project's sidebar and a codebase's: a row to name the new one in, in the list.
|
|
46
49
|
const newChannelBtn = `<button type="button" class="btn sm ghost icon" data-new-channel title="New channel" aria-label="New channel">${I.plus}</button>`
|
|
47
50
|
const newChannelRow = () => `<form class="pj-newchan" data-new-channel-form autocomplete="off"><span class="pj-hash">#</span><input name="name" maxlength="40" placeholder="Name the channel" aria-label="The new channel's name" value="${esc(state.newChannelDraft || '')}" spellcheck="false"></form>`
|
|
@@ -260,7 +263,7 @@ function sideHtml (p, d, page) {
|
|
|
260
263
|
const onChannel = page === 'channel' ? (made.list.some((c) => c.id === state.projectChannel) ? state.projectChannel : '') : null
|
|
261
264
|
const newHere = own + made.list.reduce((n, c) => n + c.unread, 0) + open.reduce((n, c) => n + ((state.sessions.get(c.id)?.status.unread) || 0), 0)
|
|
262
265
|
const naming = state.newChannel === p.id && made.canAdd
|
|
263
|
-
const room = (attrs, name, n, on) => `<button type="button" class="${on ? 'on' : ''}" ${attrs}${on ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>`
|
|
266
|
+
const room = (attrs, name, n, on, call = 0) => `<button type="button" class="${on ? 'on' : ''}" ${attrs}${on ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${callMark(call)}${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>`
|
|
264
267
|
// Direct messages, across the codebases open here: a row opens that codebase's chat on them.
|
|
265
268
|
const dms = projectDms(open.map((c) => ({ id: c.id, name: c.name, messages: state.messages.get(c.id) || [], me: state.sessions.get(c.id)?.status.me?.name || '' })))
|
|
266
269
|
const row = (c) => {
|
|
@@ -277,8 +280,8 @@ function sideHtml (p, d, page) {
|
|
|
277
280
|
<div class="side-sessions">${isFolded('codebases') ? '' : list.map(row).join('')}</div>
|
|
278
281
|
${label('channels', 'Channels', newHere, made.canAdd ? newChannelBtn : '')}
|
|
279
282
|
<div class="side-sessions pj-rooms">${isFolded('channels') && page !== 'channel' && !newHere && !naming ? '' : `
|
|
280
|
-
${isFolded('channels') && onChannel !== '' && !own ? '' : room(`data-page="channel" title="Everyone in ${esc(p.name)}"`, p.name, own, onChannel === '')}
|
|
281
|
-
${made.list.filter((c) => !isFolded('channels') || c.id === onChannel || c.unread).map((c) => room(`data-channel="${esc(c.id)}" title="Everyone in ${esc(p.name)}"`, c.name, c.unread, c.id === onChannel)).join('')}
|
|
283
|
+
${isFolded('channels') && onChannel !== '' && !own && !channelCall(p.id) ? '' : room(`data-page="channel" title="Everyone in ${esc(p.name)}"`, p.name, own, onChannel === '', channelCall(p.id))}
|
|
284
|
+
${made.list.filter((c) => !isFolded('channels') || c.id === onChannel || c.unread || channelCall(p.id, c.id)).map((c) => room(`data-channel="${esc(c.id)}" title="Everyone in ${esc(p.name)}"`, c.name, c.unread, c.id === onChannel, channelCall(p.id, c.id))).join('')}
|
|
282
285
|
${naming ? newChannelRow() : ''}
|
|
283
286
|
${isFolded('channels') ? '' : open.map((c) => room(`data-go-chat="${esc(c.id)}" title="Everyone working in ${esc(c.name)}"`, c.name, (state.sessions.get(c.id)?.status.unread) || 0, false)).join('')}`}</div>
|
|
284
287
|
${dms.length ? `${label('dms', 'Direct messages')}
|
|
@@ -321,7 +324,7 @@ export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, c
|
|
|
321
324
|
const ch = project && channels
|
|
322
325
|
const onCh = page.startsWith('channel:') ? page.slice('channel:'.length) : null
|
|
323
326
|
const chNew = ch ? ch.own + ch.list.reduce((n, c) => n + c.unread, 0) : 0
|
|
324
|
-
const room = (id, nm, n) => !isFolded('channels') || onCh === id || n ? `<button type="button" class="${onCh === id ? 'on' : ''}" data-code-page="channel:${esc(id)}" title="Everyone in ${esc(project.name)}"${onCh === id ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(nm)}</span>${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>` : ''
|
|
327
|
+
const room = (id, nm, n) => !isFolded('channels') || onCh === id || n || channelCall(project.id, id) ? `<button type="button" class="${onCh === id ? 'on' : ''}" data-code-page="channel:${esc(id)}" title="Everyone in ${esc(project.name)}"${onCh === id ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(nm)}</span>${callMark(channelCall(project.id, id))}${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>` : ''
|
|
325
328
|
return `
|
|
326
329
|
<nav class="side-nav" aria-label="Pages">${nav('loom', I.users, 'Loom')}${nav('tasks', I.board, 'Tasks', tasks)}${project ? nav('artifacts', I.folder, 'Artifacts', artifacts) : ''}${connections ? nav('connections', I.link, 'Connections') : ''}</nav>
|
|
327
330
|
${pvHtml}
|
|
@@ -509,14 +512,22 @@ export function bindProjectShell (view, { go, rerender, newSessionDialog, joinSe
|
|
|
509
512
|
for (const c of made().list) count([...root.querySelectorAll('.pj-side [data-channel]')].find((b) => b.dataset.channel === c.id), c.unread)
|
|
510
513
|
}
|
|
511
514
|
const made = () => projectChannels(p.id)
|
|
515
|
+
// A call began or ended in one of the channels, or someone came or went: the rows say so. With a channel open the page is not drawn again (what is being typed stays): only its rows' marks are.
|
|
516
|
+
const callsChanged = () => {
|
|
517
|
+
if (state.view !== view) return
|
|
518
|
+
if (!root.querySelector('[data-project-channel]') && !root.querySelector('[data-new-channel-form] input')) return rerender()
|
|
519
|
+
const mark = (row, n) => { if (!row) return; row.querySelector('.pj-call')?.remove(); if (n) row.querySelector('.nm').insertAdjacentHTML('afterend', callMark(n)) }
|
|
520
|
+
mark(root.querySelector('.pj-side [data-page="channel"]'), channelCall(p.id))
|
|
521
|
+
for (const c of made().list) mark([...root.querySelectorAll('.pj-side [data-channel]')].find((b) => b.dataset.channel === c.id), channelCall(p.id, c.id))
|
|
522
|
+
}
|
|
512
523
|
// The channel on the page: one someone made, by its id, or the project's own (also when that one is gone).
|
|
513
524
|
const openChannel = () => made().list.find((c) => c.id === state.projectChannel) || null
|
|
514
|
-
const ask = () => { loadChannel(p.id, newCount); loadChannels(p.id, newCount); const c = openChannel(); if (c && root.querySelector('[data-project-channel]')) loadChannel(p.id, newCount, { channel: c.id }) }
|
|
525
|
+
const ask = () => { loadChannel(p.id, newCount); loadChannels(p.id, newCount); loadCalls(p.id, callsChanged); const c = openChannel(); if (c && root.querySelector('[data-project-channel]')) loadChannel(p.id, newCount, { channel: c.id }) }
|
|
515
526
|
clearInterval(channelTimer)
|
|
516
527
|
channelTimer = setInterval(() => { if (state.view !== view || !root.isConnected) return clearInterval(channelTimer); ask() }, 4000)
|
|
517
528
|
ask()
|
|
518
529
|
const channel = root.querySelector('[data-project-channel]')
|
|
519
|
-
if (channel) mountChannel(channel, { d, changed: newCount, channel: openChannel() })
|
|
530
|
+
if (channel) mountChannel(channel, { d, changed: () => { newCount(); callsChanged() }, channel: openChannel() })
|
|
520
531
|
// A channel someone made opens as the project's own does.
|
|
521
532
|
root.querySelectorAll('.pj-side [data-channel]').forEach((b) => { b.onclick = () => { state.projectPage = 'channel'; state.projectChannel = b.dataset.channel; if (state.view === `ws:${p.id}`) rerender(); else go(`ws:${p.id}`) } })
|
|
522
533
|
// The plus beside Channels: a row to name the new one in, in the list. Enter makes it and opens it; Escape, or leaving it empty, takes the row away.
|
package/src/ui/session.js
CHANGED
|
@@ -29,6 +29,7 @@ import { heldCard } from './session-words.js'
|
|
|
29
29
|
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards, callCounts, callScope } from './voice.js'
|
|
30
30
|
import { codeSideHtml, codeCrumbHtml, sideShut, toggleSideShut, drawSideShut, foldSection, startNewChannel, bindNewChannel } from './projects.js'
|
|
31
31
|
import { mountChannel, loadChannel, loadChannels, channelUnread, projectChannels } from './project-channel.js'
|
|
32
|
+
import { loadCalls } from './project-call.js'
|
|
32
33
|
import { mountPreview } from './preview-page.js'
|
|
33
34
|
import { dmThreads } from './project-model.js'
|
|
34
35
|
|
|
@@ -501,6 +502,7 @@ function askChannels () {
|
|
|
501
502
|
if (!p) return
|
|
502
503
|
loadChannel(p.id, renderCodeSide)
|
|
503
504
|
loadChannels(p.id, renderCodeSide)
|
|
505
|
+
loadCalls(p.id, renderCodeSide) // a call going on in one of them shows on its row
|
|
504
506
|
const on = (ws(current).side || '').startsWith('channel:') ? ws(current).side.slice('channel:'.length) : ''
|
|
505
507
|
if (on) loadChannel(p.id, renderCodeSide, { channel: on })
|
|
506
508
|
}
|
package/src/ui/voice.js
CHANGED
|
@@ -179,6 +179,8 @@ async function join (id, transcribing) {
|
|
|
179
179
|
renderCall()
|
|
180
180
|
try {
|
|
181
181
|
if (live) await leave()
|
|
182
|
+
// One call at a time: a call in a project's channel this window is in ends (project-call.js hears this).
|
|
183
|
+
window.dispatchEvent(new CustomEvent('quilt-call', { detail: 'codebase' }))
|
|
182
184
|
const call = new VoiceCall({
|
|
183
185
|
post: (b) => api('POST', voiceUrl(id), b).then((v) => keep(id, v)),
|
|
184
186
|
ice: () => api('GET', '/api/voice/ice'),
|
|
@@ -229,6 +231,8 @@ async function leave () {
|
|
|
229
231
|
renderCall()
|
|
230
232
|
}
|
|
231
233
|
|
|
234
|
+
// A call in a project's channel was joined in this window: this one ends.
|
|
235
|
+
window.addEventListener('quilt-call', (e) => { if (e.detail !== 'codebase' && live) leave() })
|
|
232
236
|
// Closing or reloading the window leaves the call (the page can't wait for an answer).
|
|
233
237
|
window.addEventListener('pagehide', () => {
|
|
234
238
|
if (!live) return
|
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, workspaceChannels, addWorkspaceChannel } from './account.js'
|
|
24
|
+
import { workspaceMessages, sayInWorkspace, readWorkspaceMessages, workspaceChannels, addWorkspaceChannel, workspaceCalls, workspaceCall } 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'
|
|
@@ -192,6 +192,7 @@ export const STATIC = {
|
|
|
192
192
|
'/project-board.js': ['project-board.js', 'text/javascript; charset=utf-8'],
|
|
193
193
|
'/project-pop.js': ['project-pop.js', 'text/javascript; charset=utf-8'],
|
|
194
194
|
'/project-channel.js': ['project-channel.js', 'text/javascript; charset=utf-8'],
|
|
195
|
+
'/project-call.js': ['project-call.js', 'text/javascript; charset=utf-8'],
|
|
195
196
|
'/preview-page.js': ['preview-page.js', 'text/javascript; charset=utf-8'],
|
|
196
197
|
'/prail.js': ['prail.js', 'text/javascript; charset=utf-8'],
|
|
197
198
|
'/prail-model.js': ['prail-model.js', 'text/javascript; charset=utf-8'],
|
|
@@ -262,7 +263,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
262
263
|
// below — it returns earlier — so it needs no entry here.)
|
|
263
264
|
const UNRECORDED = new Set(['POST /api/report'])
|
|
264
265
|
// Sent many times a call (call setup, each clip of speech): only kept when slow or failed.
|
|
265
|
-
const QUIET_WHEN_OK = new Set(['POST /api/sessions/:id/voice', 'POST /api/sessions/:id/voice/clip', 'GET /api/sessions/:id/voice/speech', 'GET /api/sessions/:id/voice/speech-stream'])
|
|
266
|
+
const QUIET_WHEN_OK = new Set(['POST /api/workspaces/:id/call', 'POST /api/sessions/:id/voice', 'POST /api/sessions/:id/voice/clip', 'GET /api/sessions/:id/voice/speech', 'GET /api/sessions/:id/voice/speech-stream'])
|
|
266
267
|
function recordRoute (key, { startedAt, status, body, error }) {
|
|
267
268
|
// The reporter's own `enabled()` is the single gate on the "report" setting.
|
|
268
269
|
if (UNRECORDED.has(key)) return
|
|
@@ -1199,6 +1200,9 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
1199
1200
|
'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
1201
|
'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
1202
|
'POST /api/workspaces/:id/channels/:cid/messages/read': (b, id, url, cid) => asAccount((token) => readWorkspaceMessages({ token, id: needWorkspaceId(id), channel: needChannelId(cid) })),
|
|
1203
|
+
// A call in one of a project's channels (project-call.js): the calls going on, and this window's part in one.
|
|
1204
|
+
'GET /api/workspaces/:id/call': (b, id) => asAccount((token) => workspaceCalls({ token, id: needWorkspaceId(id) })),
|
|
1205
|
+
'POST /api/workspaces/:id/call': (b, id) => asAccount((token) => workspaceCall({ token, id: needWorkspaceId(id), body: { channel: b.channel ? needChannelId(b.channel) : '', client: Number(b.client), in: b.in !== false, muted: b.muted === true, sharing: b.sharing === true, sig: b.sig && typeof b.sig === 'object' ? b.sig : {} } })),
|
|
1202
1206
|
'GET /api/workspaces/:id/files': (b, id, url) => asAccount(async (token) => ({ files: await listWorkspaceFiles({ token, id: needWorkspaceId(id), folder: url.searchParams.get('folder') ?? undefined }) })),
|
|
1203
1207
|
'GET /api/workspaces/:id/files/:fid/versions': (b, id, url, fid) => asAccount(async (token) => ({ versions: await listWorkspaceFileVersions({ token, id: needWorkspaceId(id), fileId: fid }) })),
|
|
1204
1208
|
// The address an HTML artifact's frame loads (serveSealed): asked for by the page, with its token.
|