heyquilt 0.3.144 → 0.3.145

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 CHANGED
@@ -11,6 +11,11 @@ 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.145 — 2026-11-03
15
+
16
+ - **Each agent keeps one voice.** An agent is given a voice when it registers (one of four American voices, two men and two women) and speaks in it every time, whatever it is named.
17
+ - **Agents in calls are for Quilt run from source for now.** While they are being built, agents join only a call someone joined from Quilt run from source; the installed app's calls have no agents in them.
18
+
14
19
  ## 0.3.144 — 2026-11-02
15
20
 
16
21
  - **Agents in a call wake only when you say their name.** An agent read what was said for a minute and a half after it was named or spoke, and every line in that time woke it. Now only a line that says its name wakes it, with what was said just before; its face shows unmuted while it answers, then it mutes again.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.144",
3
+ "version": "0.3.145",
4
4
  "description": "Real-time, tool-agnostic pair vibe coding: sync a project folder live between collaborators using any AI coding tool.",
5
5
  "author": {
6
6
  "name": "Daniel Carmichael",
package/src/account.js CHANGED
@@ -585,6 +585,6 @@ export async function transcribeVoice ({ token, audio, seconds, api = apiUrl(),
585
585
  }
586
586
 
587
587
  /** An agent's line in a call, spoken in its voice: { audio (base64 WAV), voice, used, cap }. */
588
- export async function speakVoice ({ token, text, by, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
589
- return call(fetchImpl, api, 'POST', '/v1/voice/speak', { text, by }, token)
588
+ export async function speakVoice ({ token, text, by, agent, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
589
+ return call(fetchImpl, api, 'POST', '/v1/voice/speak', { text, by, ...(agent ? { agent } : {}) }, token)
590
590
  }
@@ -0,0 +1,9 @@
1
+ // The voices agents speak with in calls (plans/voice.md): Fluxions' American ones, two men and two
2
+ // women (Daniel's pick, 2026-11-03; the rest of its 69 include joke and regional voices). An agent
3
+ // is given one when it registers and keeps it (agents.voice), so it sounds the same every time.
4
+ import crypto from 'node:crypto'
5
+
6
+ export const AGENT_VOICE_NAMES = ['alba', 'ivy', 'june', 'miles']
7
+
8
+ /** A voice for a new agent. */
9
+ export const pickAgentVoice = () => AGENT_VOICE_NAMES[crypto.randomInt(AGENT_VOICE_NAMES.length)]
@@ -1,5 +1,6 @@
1
1
  // The accounts API's data, in memory. Used by tests and `quilt api --memory`;
2
2
  // production uses supabase-store.js, which has the same methods.
3
+ import { pickAgentVoice } from './agent-voices.js'
3
4
  import crypto from 'node:crypto'
4
5
  import { FALLBACK_TYPE } from '../session-access.js'
5
6
 
@@ -186,13 +187,14 @@ export function createMemoryStore ({ now = Date.now } = {}) {
186
187
  async createAgent ({ name, provider, type, description = '', publicKey = null, resumeHash = null, ownerUserId = null, orgId = null, invitedBy = null }) {
187
188
  if ((ownerUserId == null) === (orgId == null)) throw Object.assign(new Error('an agent belongs to one person or one org'), { code: '23514' })
188
189
  if (publicKey && all(agents, (a) => a.publicKey === publicKey).length) throw duplicatePublicKey()
189
- const row = { id: uuid(), name, provider, type, description, publicKey, ownerUserId, orgId, invitedBy, createdAt: now(), lastUsedAt: null, revokedAt: null }
190
+ const row = { id: uuid(), name, provider, type, description, publicKey, ownerUserId, orgId, invitedBy, voice: pickAgentVoice(), createdAt: now(), lastUsedAt: null, revokedAt: null }
190
191
  agents.set(row.id, row)
191
192
  // Kept apart from the row, like the database never selecting it with the agent.
192
193
  if (resumeHash) resumeHashes.set(resumeHash, row.id)
193
194
  return copy(row)
194
195
  },
195
196
  async agentById (id) { return copy(agents.get(id)) },
197
+ async setAgentVoice (id, voice) { const a = agents.get(id); if (a) a.voice = voice },
196
198
  async agentByResume (hash) { return copy(agents.get(resumeHashes.get(hash))) },
197
199
  async agentByPublicKey (publicKey) { return publicKey ? copy(all(agents, (a) => a.publicKey === publicKey)[0]) : null },
198
200
  async listPersonalAgents (userId) {
@@ -6,6 +6,7 @@
6
6
  // with Fluxions' text-to-speech, under a monthly cap of characters per account.
7
7
  import crypto from 'node:crypto'
8
8
  import { HttpError } from '../http.js'
9
+ import { AGENT_VOICE_NAMES, pickAgentVoice } from '../agent-voices.js'
9
10
 
10
11
  export const STUN = { urls: ['stun:stun.cloudflare.com:3478'] }
11
12
  export const WHISPER = '@cf/openai/whisper-large-v3-turbo'
@@ -23,13 +24,14 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
23
24
  const PHANTOM = /^(?:thank you\.?|thanks for watching[.!]?|thank you for watching[.!]?|you|bye\.?|\.+|…)$/i
24
25
 
25
26
  export const FLUXIONS = 'https://api.fluxions.ai/vui'
26
- // Fluxions' built-in voices when its list can't be read; the list is read again after an hour.
27
- export const FALLBACK_VOICES = ['maeve.h8ff7e07da', 'abraham.h8ff7e07da', 'harry.h8ff7e07da']
27
+ // The agents' voices (agent-voices.js), matched by name in Fluxions' list, read again after an hour,
28
+ // so a new id suffix is followed; these ids when it can't be read.
29
+ export const FALLBACK_VOICES = AGENT_VOICE_NAMES.map((n) => `${n}.h8ff7e07da`)
28
30
  const VOICES_TTL_MS = 60 * 60 * 1000
29
31
  // A line an agent says (voice.js MAX_LINE).
30
32
  export const MAX_SPOKEN = 2000
31
33
 
32
- /** The voice an agent speaks with: the same one for the same name, in every app and on every machine. */
34
+ /** The voice of a speaker with no registered voice (a chat link, a persona): the same one for the same name. */
33
35
  export function voiceFor (name, voices) {
34
36
  const list = voices && voices.length ? voices : FALLBACK_VOICES
35
37
  const h = crypto.createHash('sha256').update(String(name || '').toLowerCase()).digest()
@@ -79,19 +81,32 @@ export function voiceRoutes ({ store, person, now = Date.now, log = () => {}, vo
79
81
  // Agents' lines, spoken: each app in the call asks for each line, a few a minute in a busy call.
80
82
  const limitSpeech = makeLimiter(120, 'too much speech at once; slow down', { keyOf: (userId) => userId })
81
83
  let voices = { list: null, at: 0 }
82
- // Fluxions' built-in voices, read once an hour; the fallback list when it can't be read.
84
+ // The agents' voices from Fluxions' list, read once an hour; the fallback list when it can't be read.
83
85
  const voiceList = async () => {
84
86
  if (voices.list && now() - voices.at < VOICES_TTL_MS) return voices.list
85
87
  let list = null
86
88
  try {
87
89
  const res = await fetchImpl(`${FLUXIONS}/voices`, { headers: { authorization: fluxionsKey } })
88
90
  const data = res.ok ? await res.json().catch(() => null) : null
89
- list = Array.isArray(data?.voices) ? data.voices.map((v) => v && v.voice_id).filter((id) => typeof id === 'string' && id).sort() : null
91
+ list = Array.isArray(data?.voices) ? data.voices.map((v) => v && v.voice_id).filter((id) => typeof id === 'string' && AGENT_VOICE_NAMES.includes(id.split('.')[0])).sort() : null
90
92
  if (!res.ok) log(`voice speak: Fluxions voices answered ${res.status}`)
91
93
  } catch (err) { log(`voice speak: ${err.message}`) }
92
94
  voices = { list: list && list.length ? list : FALLBACK_VOICES, at: list && list.length ? now() : now() - VOICES_TTL_MS + 5 * 60 * 1000 }
93
95
  return voices.list
94
96
  }
97
+ // A registered agent's voice id in Fluxions' list; one it lacks (made before voices, or a voice
98
+ // since dropped) is given now and kept.
99
+ const registeredVoice = async (agentId, list) => {
100
+ if (typeof agentId !== 'string' || !/^[0-9a-f-]{36}$/i.test(agentId)) return ''
101
+ const agent = await store.agentById(agentId).catch(() => null)
102
+ if (!agent) return ''
103
+ let name = agent.voice
104
+ if (!AGENT_VOICE_NAMES.includes(name)) {
105
+ name = pickAgentVoice()
106
+ await store.setAgentVoice(agent.id, name).catch((err) => log(`voice speak: ${err.message}`))
107
+ }
108
+ return list.find((id) => id.split('.')[0] === name) || ''
109
+ }
95
110
  // Per person: ICE servers a few times an hour, clips about one every couple of seconds of a long talk.
96
111
  const limitIce = makeLimiter(30, 'too many requests for call servers; try again in a minute', { keyOf: (userId) => userId })
97
112
  const limitClips = makeLimiter(60, 'too much speech at once; slow down', { keyOf: (userId) => userId })
@@ -163,7 +178,8 @@ export function voiceRoutes ({ store, person, now = Date.now, log = () => {}, vo
163
178
  return { text, seconds: billed, used: total, cap: capSeconds }
164
179
  }, { maxBody: MAX_CLIP_BODY + 4096 }],
165
180
 
166
- // A line an agent said in a call, as speech: { text, by } in, a WAV out (base64), in the agent's voice.
181
+ // A line an agent said in a call, as speech: { text, by, agent? } in, a WAV out (base64), in the
182
+ // agent's voice: the one it was given when it registered (`agent`, its id), else one from its name.
167
183
  ['POST', /^\/v1\/voice\/speak$/, async (req, body) => {
168
184
  const { userId } = await person(req)
169
185
  if (!fluxionsKey) throw new HttpError(503, "Agents' voices are not set up on this server.")
@@ -175,7 +191,8 @@ export function voiceRoutes ({ store, person, now = Date.now, log = () => {}, vo
175
191
  const month = monthOf(now())
176
192
  const used = await store.voiceSpeechChars(userId, month)
177
193
  if (used >= capChars) throw new HttpError(429, "You've heard this month's share of agents speaking. Their lines still show in the call; their voices start again next month.")
178
- const voice = voiceFor(by, await voiceList())
194
+ const list = await voiceList()
195
+ const voice = (await registeredVoice(body.agent, list)) || voiceFor(by, list)
179
196
  let res
180
197
  try {
181
198
  res = await fetchImpl(`${FLUXIONS}/v1/tts`, {
@@ -1,5 +1,6 @@
1
1
  // The accounts API's data in Supabase, using the service role (row-level security is
2
2
  // for the website; the API is trusted and writes the secrets).
3
+ import { pickAgentVoice } from './agent-voices.js'
3
4
  import { createClient } from '@supabase/supabase-js'
4
5
 
5
6
  const toCamel = (row) => row && Object.fromEntries(Object.entries(row).map(([k, v]) => [k.replace(/_([a-z])/g, (m, c) => c.toUpperCase()), v]))
@@ -13,7 +14,7 @@ const ms = (v) => (v == null ? v : Date.parse(v))
13
14
  // Postgres's foreign-key-violation code, for the same checks memory-store.js mirrors.
14
15
  const fkViolation = (what) => Object.assign(new Error(`${what} is still referenced`), { code: '23503' })
15
16
  // No secrets live on agents any more; the columns are still named, like every other table.
16
- const AGENT = 'id, name, provider, type, description, public_key, owner_user_id, org_id, invited_by, created_at, last_used_at, revoked_at'
17
+ const AGENT = 'id, name, provider, type, description, public_key, owner_user_id, org_id, invited_by, voice, created_at, last_used_at, revoked_at'
17
18
  // Named columns for the org tables, so a select never picks up a secret by accident.
18
19
  const ORG = 'id, name, slug, owner_id, domain, domain_requests, created_at'
19
20
  const ROLE = 'id, org_id, name, builtin, grants, created_at'
@@ -128,7 +129,7 @@ export function createSupabaseStore ({ url, serviceKey, client }) {
128
129
  },
129
130
  async createAgent ({ name, provider, type, description = '', publicKey = null, resumeHash = null, ownerUserId = null, orgId = null, invitedBy = null }) {
130
131
  return rowFrom(await one(db.from('agents')
131
- .insert({ name, provider, type, description, public_key: publicKey, resume_hash: resumeHash, owner_user_id: ownerUserId, org_id: orgId, invited_by: invitedBy })
132
+ .insert({ name, provider, type, description, public_key: publicKey, resume_hash: resumeHash, owner_user_id: ownerUserId, org_id: orgId, invited_by: invitedBy, voice: pickAgentVoice() })
132
133
  .select(AGENT).single()))
133
134
  },
134
135
  async agentById (id) { return rowFrom(await one(db.from('agents').select(AGENT).eq('id', id).maybeSingle())) },
@@ -145,6 +146,7 @@ export function createSupabaseStore ({ url, serviceKey, client }) {
145
146
  async listOrgAgents (orgId) {
146
147
  return (await one(db.from('agents').select(AGENT).eq('org_id', orgId).is('revoked_at', null).order('name'))).map(rowFrom)
147
148
  },
149
+ async setAgentVoice (id, voice) { await one(db.from('agents').update({ voice }).eq('id', id)) },
148
150
  async touchAgent (id) { await one(db.from('agents').update({ last_used_at: new Date().toISOString() }).eq('id', id)) },
149
151
  // Revoking an agent kills every key it holds at once.
150
152
  async revokeAgent (id) {
package/src/session.js CHANGED
@@ -57,7 +57,7 @@ import { RELAY_NAME as RELAY_BY, isRelay } from './ui/chat.js'
57
57
  import { cleanTyping, TYPING_MS, AGENT_TYPING_MS } from './ui/chat.js'
58
58
  import { DEFAULT_KEY } from './branchdocs.js'
59
59
  import { boxEntry } from './boxes.js'
60
- import { cleanVoice, newCallId, voiceView, inVoice, transcribeSetting, setTranscribe, addLine, readLines, MAX_IN_CALL, CALL_FULL, callAgents, setAgentLeft, notInCall, callEntries, agentSays } from './voice.js'
60
+ import { cleanVoice, newCallId, voiceView, inVoice, transcribeSetting, setTranscribe, addLine, readLines, MAX_IN_CALL, CALL_FULL, callAgents, setAgentLeft, notInCall, callEntries, agentSays, markCallForAgents } from './voice.js'
61
61
  import { toolInUse } from './agents/common.js'
62
62
  import { squareShort } from '@heyquilt/seam/lib/quilts/errors.js'
63
63
 
@@ -3104,6 +3104,7 @@ export class Session extends EventEmitter {
3104
3104
  transcribing: v.transcribing === true && view.transcribe
3105
3105
  })
3106
3106
  this.conn.awareness.setLocalStateField('voice', next)
3107
+ if (v.agents === true) markCallForAgents(this.doc, next.call)
3107
3108
  } else if (this.conn.awareness.getLocalState()?.voice) {
3108
3109
  this.conn.awareness.setLocalStateField('voice', null)
3109
3110
  }
@@ -272,7 +272,8 @@ export class VoiceCall {
272
272
  publish () {
273
273
  if (!this.in) return
274
274
  if (this.sending) { this.again = true; return }
275
- this.sending = this.post({ muted: this.muted, transcribing: this.transcribing, sharing: !!this.screen, sig: this.sig })
275
+ // Agents join only calls from Quilt run from source while they are being built (voice.js markCallForAgents).
276
+ this.sending = this.post({ muted: this.muted, transcribing: this.transcribing, sharing: !!this.screen, sig: this.sig, agents: globalThis.quiltDesktop?.dev === true })
276
277
  .then((view) => { this.sending = null; this.update(view) }, () => { this.sending = null })
277
278
  .finally(() => { if (this.again) { this.again = false; this.publish() } })
278
279
  }
package/src/ui-server.js CHANGED
@@ -704,7 +704,10 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
704
704
  const line = s.voiceTranscript({ call: v.call, limit: 1000 }).lines.find((l) => l.id === lineId)
705
705
  if (!line || !line.spoken || !v.agents.some((a) => a.name === line.by)) throw httpError(404, 'That is not an agent\'s line in this call.')
706
706
  if (!spoken.has(line.id)) {
707
- const got = asAccount((token) => speakVoice({ token, text: line.text, by: line.by })).then((r) => ({ audio: r.audio, voice: r.voice }))
707
+ // A registered agent is in the room as agent:<its id>: its own voice, given when it registered.
708
+ const key = (s.members || []).find((m) => m && m.kind === 'agent' && m.name === line.by)?.key || ''
709
+ const agent = /^agent:[0-9a-f-]{36}$/i.test(key) ? key.slice(6) : ''
710
+ const got = asAccount((token) => speakVoice({ token, text: line.text, by: line.by, agent })).then((r) => ({ audio: r.audio, voice: r.voice }))
708
711
  spoken.set(line.id, got)
709
712
  got.catch(() => spoken.delete(line.id))
710
713
  if (spoken.size > 50) spoken.delete(spoken.keys().next().value)
@@ -1046,7 +1049,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1046
1049
  'POST /api/sessions/:id/focus': (b, id) => { get(id).setFocus(b.text); return { ok: true } },
1047
1050
  // Voice (voice.js): the call as this app sees it, and our part in it, from the app window, which does the audio.
1048
1051
  'GET /api/sessions/:id/voice': (b, id) => get(id).voice(),
1049
- '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 }),
1052
+ '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 }),
1050
1053
  'POST /api/sessions/:id/voice/transcribe': (b, id) => get(id).setVoiceTranscribe(b.on === true),
1051
1054
  'POST /api/sessions/:id/voice/clip': (b, id) => voiceClip(get(id), b),
1052
1055
  'GET /api/sessions/:id/voice/transcript': (b, id, url) => get(id).voiceTranscript({ call: url.searchParams.get('call') || '' }),
package/src/voice.js CHANGED
@@ -124,6 +124,27 @@ export const AGENT_OPEN_MS = 30 * 1000
124
124
  // Lines of the call before one that wakes an agent, shown with it.
125
125
  export const AGENT_CONTEXT = 8
126
126
  export const AGENT_NEEDS_TRANSCRIPTS = 'Agents hear a call through its transcript, and this one is not transcribed: the session owner turns transcripts on.'
127
+ // Agents in calls are being built: only a call someone joined from Quilt run from source takes them,
128
+ // marked in the session (voiceCalls) so every app, agent and the relay agree.
129
+ export const AGENTS_DEV_ONLY = 'Agents are not in this call: agents in calls are still being built, and join only calls joined from Quilt run from source.'
130
+ const KEEP_CALL_MARKS = 50
131
+
132
+ /** Whether call `call` takes agents (markCallForAgents). */
133
+ const takesAgents = (doc, call) => {
134
+ const v = doc.getMap('voiceCalls').get(call)
135
+ return !!(v && typeof v === 'object' && v.agents === true)
136
+ }
137
+
138
+ /** Call `call` takes agents: someone joined it from Quilt run from source. The oldest marks go. */
139
+ export function markCallForAgents (doc, call, now = Date.now()) {
140
+ if (!call || takesAgents(doc, call)) return
141
+ const map = doc.getMap('voiceCalls')
142
+ doc.transact(() => {
143
+ map.set(call, { agents: true, ts: now })
144
+ const old = [...map.entries()].sort((a, b) => (a[1]?.ts || 0) - (b[1]?.ts || 0))
145
+ for (const [k] of old.slice(0, Math.max(0, old.length - KEEP_CALL_MARKS))) map.delete(k)
146
+ })
147
+ }
127
148
 
128
149
  /** Whether agent `name` left call `call` (quilt_voice_join leave). */
129
150
  const leftCall = (doc, call, name) => {
@@ -148,7 +169,7 @@ export function agentOpenUntil (lines, names) {
148
169
  * is transcribed, but those that left it. Each with `until`: unmuted until then (0: muted).
149
170
  */
150
171
  export function callAgents (doc, call, members = []) {
151
- if (!call || !transcribeSetting(doc, members).on) return []
172
+ if (!call || !takesAgents(doc, call) || !transcribeSetting(doc, members).on) return []
152
173
  const lines = callLines(doc, call)
153
174
  return (members || []).filter((m) => m && m.kind === 'agent' && m.name && !leftCall(doc, call, m.name))
154
175
  .map((m) => ({ name: m.name, until: agentOpenUntil(lines, [m.name]) }))
@@ -164,6 +185,7 @@ export function setAgentLeft (doc, { call, name, leave = true, now = Date.now()
164
185
  /** Why agent `name` isn't in call `call` now, or '' when it is. */
165
186
  export function notInCall (doc, { call, name, members = [] }) {
166
187
  if (!call) return 'There is no call going on in this session.'
188
+ if (!takesAgents(doc, call)) return AGENTS_DEV_ONLY
167
189
  if (!transcribeSetting(doc, members).on) return AGENT_NEEDS_TRANSCRIPTS
168
190
  if (!(members || []).some((m) => m && m.kind === 'agent' && m.name === name)) return 'Only the session\'s agents are in its calls.'
169
191
  if (leftCall(doc, call, name)) return 'You left this call: come back with quilt_voice_join.'