osborn 0.9.271 → 0.9.274
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/.claude/skills/browser-apply/SKILL.md +82 -30
- package/.claude/skills/browser-apply/candidate.example.env +16 -0
- package/.claude/skills/browser-apply/fill.mjs +294 -0
- package/Dockerfile +1 -1
- package/dist/claude-llm.d.ts +3 -0
- package/dist/claude-llm.js +100 -17
- package/dist/compaction-log.d.ts +67 -0
- package/dist/compaction-log.js +195 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +122 -65
- package/dist/content/transcript-sanitizer.d.ts +20 -6
- package/dist/content/transcript-sanitizer.js +66 -11
- package/dist/data-sender-auth.d.ts +90 -0
- package/dist/data-sender-auth.js +157 -0
- package/dist/env-keys.js +11 -0
- package/dist/index.js +411 -92
- package/dist/meeting-addressing.d.ts +176 -0
- package/dist/meeting-addressing.js +288 -0
- package/dist/pipeline-direct-llm.d.ts +27 -0
- package/dist/pipeline-direct-llm.js +117 -37
- package/dist/prompts/direct-mode-fallback.md +1 -1
- package/dist/prompts/direct-mode-research.md +2 -2
- package/dist/prompts.d.ts +1 -1
- package/dist/prompts.js +3 -3
- package/dist/pushover.d.ts +77 -0
- package/dist/pushover.js +276 -0
- package/dist/recall-client.js +21 -2
- package/dist/session-store.d.ts +15 -5
- package/dist/session-store.js +37 -10
- package/dist/transcript-wiring.d.ts +121 -0
- package/dist/transcript-wiring.js +252 -0
- package/dist/voice-io.d.ts +0 -9
- package/dist/voice-io.js +5 -19
- package/dist/watch-gateway.d.ts +38 -0
- package/dist/watch-gateway.js +205 -0
- package/package.json +1 -1
- package/scripts/review.ts +1 -1
- package/dist/bridge-llm.d.ts +0 -22
- package/dist/bridge-llm.js +0 -39
- package/dist/codex-handler.d.ts +0 -38
- package/dist/codex-handler.js +0 -83
- package/dist/codex-llm.d.ts +0 -40
- package/dist/codex-llm.js +0 -144
- package/dist/fast-brain.d.ts +0 -176
- package/dist/fast-brain.js +0 -1887
- package/dist/index-3-2-26-legacy.d.ts +0 -1
- package/dist/index-3-2-26-legacy.js +0 -2233
- package/dist/leagcyprompts2.d.ts +0 -0
- package/dist/leagcyprompts2.js +0 -573
- package/dist/prompts-2-25-26.d.ts +0 -0
- package/dist/prompts-2-25-26.js +0 -518
- package/dist/prompts-3-2-26.d.ts +0 -78
- package/dist/prompts-3-2-26.js +0 -1319
- package/dist/summary-index.d.ts +0 -90
- package/dist/summary-index.js +0 -585
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { dirname, join } from 'node:path';
|
|
|
20
20
|
import { fileURLToPath } from 'node:url';
|
|
21
21
|
import { spawn } from 'node:child_process';
|
|
22
22
|
import { getHeapStatistics } from 'node:v8';
|
|
23
|
-
import { randomUUID, randomBytes } from 'node:crypto';
|
|
23
|
+
import { randomUUID, randomBytes, createHmac, timingSafeEqual } from 'node:crypto';
|
|
24
24
|
import httpProxy from 'http-proxy';
|
|
25
25
|
import { createRequire } from 'node:module';
|
|
26
26
|
// 0.9.71: createRequire for resolving package.json versions inside ESM
|
|
@@ -45,11 +45,17 @@ import { createSmitheryProxy, destroySmitheryProxy, parseSmitheryUrl, isSmithery
|
|
|
45
45
|
import { DIRECT_MODE_PROMPT } from './prompts.js';
|
|
46
46
|
import { MCP_CATALOG } from './config.js';
|
|
47
47
|
import { storeExists, openStore, recentRows } from './session-store.js';
|
|
48
|
+
import { readCompactionMarkers } from './compaction-log.js';
|
|
49
|
+
import { sessionListEntry, cleanHistoryRows, userEchoText, TypedEchoTracker, ClientNoteQueue, parseFavoriteChanged, parseLegacyFavoriteNotice } from './transcript-wiring.js';
|
|
48
50
|
import { getRecallClient } from './recall-client.js';
|
|
49
51
|
import { MeetingTranscriptPoller } from './meeting-transcript-poller.js';
|
|
50
52
|
import { missingRequiredEnv } from './env-keys.js';
|
|
53
|
+
import { armPermissionPush, handleWatchAck, setWatchResultHandler } from './pushover.js';
|
|
54
|
+
import { startWatchGateway } from './watch-gateway.js';
|
|
51
55
|
import { noiseGate } from './noise-gate.js';
|
|
56
|
+
import { meetingAddressing, isRoutableTarget } from './meeting-addressing.js';
|
|
52
57
|
import { listSecretStatus, setSecrets, deleteSecret } from './secrets-store.js';
|
|
58
|
+
import { AGENT_SELF_IDENTITY, checkControlSender, resolveJoin, userIdFromMetadata } from './data-sender-auth.js';
|
|
53
59
|
import { llm } from '@livekit/agents';
|
|
54
60
|
// ============================================================
|
|
55
61
|
// PIPELINE MODE: STT (Deepgram) → Claude Agent SDK → TTS
|
|
@@ -340,6 +346,48 @@ wsProxy.on('error', (err, _req, socket) => {
|
|
|
340
346
|
// valid cookie are forwarded, so a forgotten agent route can never be silently
|
|
341
347
|
// swallowed by the IDE proxy. Cleared in stopIde().
|
|
342
348
|
let ideSessionToken = null;
|
|
349
|
+
// ── /editor access token (closes the unauthenticated-RCE hole) ──────────────
|
|
350
|
+
// The agent's HTTP server is public (0.0.0.0:8741 via fly.toml). GET /editor
|
|
351
|
+
// used to mint the osborn_ide cookie with NO auth, and code-server runs
|
|
352
|
+
// --auth none — so anyone who knew a machine's fly.dev address could open the
|
|
353
|
+
// IDE/terminal = remote code execution on the paying owner's machine.
|
|
354
|
+
//
|
|
355
|
+
// Fix: /editor now requires a short-lived HMAC token. The token is minted with
|
|
356
|
+
// OSBORN_SYNC_TOKEN (the per-machine owner secret) and embedded in the ideUrl
|
|
357
|
+
// the agent hands back over the LiveKit data channel — which is already
|
|
358
|
+
// owner-gated (control commands bound to OSBORN_OWNER_USER_ID). So only the
|
|
359
|
+
// owner ever receives a valid token; a direct hit to /editor without it is
|
|
360
|
+
// refused. Local dev (no FLY_APP_NAME) is localhost-only and skips the gate.
|
|
361
|
+
const EDITOR_TOKEN_TTL_MS = 24 * 60 * 60 * 1000; // long-lived: the URL is owner-only; avoids breaking "open editor later"
|
|
362
|
+
function mintEditorToken() {
|
|
363
|
+
const secret = process.env.OSBORN_SYNC_TOKEN;
|
|
364
|
+
if (!secret)
|
|
365
|
+
return '';
|
|
366
|
+
const exp = Date.now() + EDITOR_TOKEN_TTL_MS;
|
|
367
|
+
const sig = createHmac('sha256', secret).update(`editor:${exp}`).digest('base64url');
|
|
368
|
+
return `${exp}.${sig}`;
|
|
369
|
+
}
|
|
370
|
+
function verifyEditorToken(tok) {
|
|
371
|
+
const secret = process.env.OSBORN_SYNC_TOKEN;
|
|
372
|
+
if (!secret || !tok)
|
|
373
|
+
return false; // cloud with no secret → fail CLOSED
|
|
374
|
+
const dot = tok.indexOf('.');
|
|
375
|
+
if (dot < 0)
|
|
376
|
+
return false;
|
|
377
|
+
const exp = Number(tok.slice(0, dot));
|
|
378
|
+
if (!Number.isFinite(exp) || exp < Date.now())
|
|
379
|
+
return false;
|
|
380
|
+
const expected = createHmac('sha256', secret).update(`editor:${exp}`).digest('base64url');
|
|
381
|
+
const got = tok.slice(dot + 1);
|
|
382
|
+
if (got.length !== expected.length)
|
|
383
|
+
return false;
|
|
384
|
+
try {
|
|
385
|
+
return timingSafeEqual(Buffer.from(got), Buffer.from(expected));
|
|
386
|
+
}
|
|
387
|
+
catch {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
343
391
|
// Cancellation-generation guard for startCodeServer(). Incremented by stopIde()
|
|
344
392
|
// every time the IDE is torn down. startCodeServer() captures myGen at entry;
|
|
345
393
|
// if ideStartGeneration !== myGen when the poll resolves, the start has been
|
|
@@ -524,7 +572,32 @@ function startApiServer(workingDir, port) {
|
|
|
524
572
|
}
|
|
525
573
|
const url = new URL(req.url || '/', `http://localhost:${port}`);
|
|
526
574
|
const syncToken = process.env.OSBORN_SYNC_TOKEN;
|
|
575
|
+
// Fail-closed auth for the sensitive session/ops routes. Requires
|
|
576
|
+
// `Authorization: Bearer <OSBORN_SYNC_TOKEN>` whenever we're on a cloud
|
|
577
|
+
// machine (FLY_APP_NAME set) OR a sync token is configured. Local dev with
|
|
578
|
+
// no token stays open. Writes 401 and returns true when NOT authorized, so
|
|
579
|
+
// a caller does `if (unauthorized()) return`. This replaces the old
|
|
580
|
+
// fail-OPEN `if (syncToken) { ... }` pattern (which left these routes wide
|
|
581
|
+
// open on any machine that hadn't set a token).
|
|
582
|
+
const unauthorized = () => {
|
|
583
|
+
const requireAuth = !!process.env.FLY_APP_NAME || !!syncToken;
|
|
584
|
+
if (requireAuth && req.headers['authorization'] !== `Bearer ${syncToken}`) {
|
|
585
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
586
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
587
|
+
return true;
|
|
588
|
+
}
|
|
589
|
+
return false;
|
|
590
|
+
};
|
|
527
591
|
if (req.method === 'GET' && url.pathname === '/sessions') {
|
|
592
|
+
// Fail-closed in cloud: session lists reach only the owner (via the
|
|
593
|
+
// authenticated /api/agent proxy, which forwards Bearer OSBORN_SYNC_TOKEN).
|
|
594
|
+
// A direct hit to the public fly.dev address is rejected. Local dev
|
|
595
|
+
// (no FLY_APP_NAME) is localhost-only and stays open.
|
|
596
|
+
if (process.env.FLY_APP_NAME && (!syncToken || req.headers['authorization'] !== `Bearer ${syncToken}`)) {
|
|
597
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
598
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
528
601
|
try {
|
|
529
602
|
const limit = Math.min(parseInt(url.searchParams.get('limit') || '500', 10), 1000);
|
|
530
603
|
const sessions = await listAllClaudeSessions(limit);
|
|
@@ -537,16 +610,9 @@ function startApiServer(workingDir, port) {
|
|
|
537
610
|
// hardcoded base-path list — agent self-describes its base so
|
|
538
611
|
// the UI doesn't have to keep a sync'd copy.
|
|
539
612
|
baseCwd: workingDir,
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
projectPath: s.projectPath,
|
|
544
|
-
cwd: s.cwd,
|
|
545
|
-
timestamp: s.timestamp.toISOString(),
|
|
546
|
-
lastMessage: s.lastMessage,
|
|
547
|
-
messageCount: s.messageCount,
|
|
548
|
-
fileSize: s.fileSize,
|
|
549
|
-
})),
|
|
613
|
+
// sessionListEntry carries the L2a preview fields too (title, firstTs,
|
|
614
|
+
// lastActivityAt) so the dashboard can stop deriving them itself.
|
|
615
|
+
sessions: sessions.map(sessionListEntry),
|
|
550
616
|
total: sessions.length,
|
|
551
617
|
};
|
|
552
618
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
@@ -566,6 +632,12 @@ function startApiServer(workingDir, port) {
|
|
|
566
632
|
// store directly (readonly, no JSONL replay) — same source as the
|
|
567
633
|
// data-channel prior_messages push, which remains the fallback for older
|
|
568
634
|
// frontends. Rows carry real timestamps so the UI can date-stamp them.
|
|
635
|
+
// Fail-closed in cloud (real transcript content; owner-only via proxy).
|
|
636
|
+
if (process.env.FLY_APP_NAME && (!syncToken || req.headers['authorization'] !== `Bearer ${syncToken}`)) {
|
|
637
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
638
|
+
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
569
641
|
try {
|
|
570
642
|
const sessionId = url.searchParams.get('session') || '';
|
|
571
643
|
const limit = Math.min(parseInt(url.searchParams.get('limit') || '50', 10), 200);
|
|
@@ -574,21 +646,23 @@ function startApiServer(workingDir, port) {
|
|
|
574
646
|
res.end(JSON.stringify({ error: 'session required' }));
|
|
575
647
|
return;
|
|
576
648
|
}
|
|
649
|
+
// Durable compaction markers (sidecar, not the derived store) so a
|
|
650
|
+
// resumed transcript rebuilds every past "Conversation compacted" row at
|
|
651
|
+
// its real position — the store rebuild can't wipe these.
|
|
652
|
+
const compactions = readCompactionMarkers(sessionId, workingDir);
|
|
577
653
|
const dbPath = storeExists(sessionId, workingDir);
|
|
578
654
|
if (!dbPath) {
|
|
579
655
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
580
|
-
res.end(JSON.stringify({ sessionId, messages: [] }));
|
|
656
|
+
res.end(JSON.stringify({ sessionId, messages: [], compactions }));
|
|
581
657
|
return;
|
|
582
658
|
}
|
|
583
659
|
const db = openStore(dbPath, { readonly: true });
|
|
584
660
|
try {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
.map(r => ({ role: r.msgType === 'assistant' ? 'assistant' : 'user', content: (r.text || '').slice(0, 1200), ts: r.ts || null }))
|
|
589
|
-
.filter(m => m.content.trim().length > 0);
|
|
661
|
+
// Sanitize BEFORE truncating, over-fetching so rows the sanitizer drops
|
|
662
|
+
// (notices, injected blocks) don't shrink the page (L2b).
|
|
663
|
+
const messages = cleanHistoryRows(n => recentRows(db, n, ['user', 'assistant']), limit, 1200);
|
|
590
664
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
591
|
-
res.end(JSON.stringify({ sessionId, messages }));
|
|
665
|
+
res.end(JSON.stringify({ sessionId, messages, compactions }));
|
|
592
666
|
}
|
|
593
667
|
finally {
|
|
594
668
|
try {
|
|
@@ -837,6 +911,8 @@ function startApiServer(workingDir, port) {
|
|
|
837
911
|
}
|
|
838
912
|
// POST /restart — graceful process restart (process manager will restart)
|
|
839
913
|
if (req.method === 'POST' && url.pathname === '/restart') {
|
|
914
|
+
if (unauthorized())
|
|
915
|
+
return; // was unauthenticated: anyone with the address could kill the agent
|
|
840
916
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
841
917
|
res.end(JSON.stringify({ success: true, message: 'Agent restarting...' }));
|
|
842
918
|
console.log('🔄 Restart requested via HTTP — exiting for process manager restart');
|
|
@@ -1005,6 +1081,31 @@ function startApiServer(workingDir, port) {
|
|
|
1005
1081
|
});
|
|
1006
1082
|
return;
|
|
1007
1083
|
}
|
|
1084
|
+
// POST /watch/ack — landing for the Track 1 wrist bridge (Pushover ack OR
|
|
1085
|
+
// ntfy Approve/Deny buttons). The frontend /api/watch/ack/[qid] route
|
|
1086
|
+
// verifies the HMAC signature and forwards here; pushover.ts re-verifies
|
|
1087
|
+
// against its pending map before resolving the blocking permission.
|
|
1088
|
+
// Dormant unless a provider (PUSHOVER_*/NTFY_*) + WATCH_ACK_SECRET are set.
|
|
1089
|
+
if (req.method === 'POST' && url.pathname === '/watch/ack') {
|
|
1090
|
+
let body = '';
|
|
1091
|
+
req.on('data', (c) => { body += c; });
|
|
1092
|
+
req.on('end', () => {
|
|
1093
|
+
try {
|
|
1094
|
+
const { qid, receipt, allow } = JSON.parse(body || '{}');
|
|
1095
|
+
if (!qid)
|
|
1096
|
+
throw new Error('qid required');
|
|
1097
|
+
// allow defaults to true (Pushover ack = approve); ntfy's Deny button sends false.
|
|
1098
|
+
const ok = handleWatchAck(qid, receipt, allow !== false);
|
|
1099
|
+
res.writeHead(ok ? 200 : 404, { 'Content-Type': 'application/json' });
|
|
1100
|
+
res.end(JSON.stringify({ ok }));
|
|
1101
|
+
}
|
|
1102
|
+
catch (e) {
|
|
1103
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1104
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1008
1109
|
// GET /sessions/export — stream a gzipped tar of ~/.claude/projects/ AND
|
|
1009
1110
|
// ~/.claude/skills/ to the client. Both directories ship in one archive so
|
|
1010
1111
|
// a sync covers conversations (projects/) and learned skills together —
|
|
@@ -1013,14 +1114,8 @@ function startApiServer(workingDir, port) {
|
|
|
1013
1114
|
// Optional ?workDir= query param accepted for backwards compat but ignored
|
|
1014
1115
|
// (full export is always returned).
|
|
1015
1116
|
if (req.method === 'GET' && url.pathname === '/sessions/export') {
|
|
1016
|
-
if (
|
|
1017
|
-
|
|
1018
|
-
if (authHeader !== `Bearer ${syncToken}`) {
|
|
1019
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1020
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1117
|
+
if (unauthorized())
|
|
1118
|
+
return; // fail-closed (was fail-open: no token set → open)
|
|
1024
1119
|
const claudeDir = join(homedir(), '.claude');
|
|
1025
1120
|
const projectsDir = join(claudeDir, 'projects');
|
|
1026
1121
|
const skillsDir = join(claudeDir, 'skills');
|
|
@@ -1060,6 +1155,8 @@ function startApiServer(workingDir, port) {
|
|
|
1060
1155
|
// for the MVP — a per-share access token is a follow-up (tracked in
|
|
1061
1156
|
// shared_sessions). sessionId is regex-validated to block path traversal.
|
|
1062
1157
|
if (req.method === 'GET' && url.pathname === '/sessions/export-one') {
|
|
1158
|
+
if (unauthorized())
|
|
1159
|
+
return; // fail-closed; the sharing export leg now goes through the authed /api/agent proxy
|
|
1063
1160
|
const sessionId = (url.searchParams.get('sessionId') || '').trim();
|
|
1064
1161
|
if (!sessionId || !/^[a-zA-Z0-9._-]+$/.test(sessionId)) {
|
|
1065
1162
|
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
@@ -1287,6 +1384,8 @@ function startApiServer(workingDir, port) {
|
|
|
1287
1384
|
return { filesWritten, remapped, skillsWritten };
|
|
1288
1385
|
};
|
|
1289
1386
|
if (req.method === 'GET' && url.pathname === '/sessions/manifest') {
|
|
1387
|
+
if (unauthorized())
|
|
1388
|
+
return; // was public/no-auth: leaked the full session+skill file tree
|
|
1290
1389
|
// Walks BOTH ~/.claude/projects/ AND ~/.claude/skills/ — full tree per
|
|
1291
1390
|
// top-level directory.
|
|
1292
1391
|
// - projects/<slug>/<...> → session JSONLs, sub-agent transcripts, tool-results, osb/
|
|
@@ -1348,14 +1447,8 @@ function startApiServer(workingDir, port) {
|
|
|
1348
1447
|
}
|
|
1349
1448
|
// POST /sessions/import — accept a gzipped tar and extract into ~/.claude/projects/
|
|
1350
1449
|
if (req.method === 'POST' && url.pathname === '/sessions/import') {
|
|
1351
|
-
if (
|
|
1352
|
-
|
|
1353
|
-
if (authHeader !== `Bearer ${syncToken}`) {
|
|
1354
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1355
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1356
|
-
return;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1450
|
+
if (unauthorized())
|
|
1451
|
+
return; // fail-closed (was fail-open)
|
|
1359
1452
|
// 0.9.74: default targetWorkDir to this machine's own working directory.
|
|
1360
1453
|
// Stale sync clients that omit the param used to get source slugs written
|
|
1361
1454
|
// verbatim — those sessions LIST fine (the scanner walks all slugs) but
|
|
@@ -1428,14 +1521,8 @@ function startApiServer(workingDir, port) {
|
|
|
1428
1521
|
}
|
|
1429
1522
|
// POST /sessions/import-chunk — accept a single chunk of a multi-part upload
|
|
1430
1523
|
if (req.method === 'POST' && url.pathname === '/sessions/import-chunk') {
|
|
1431
|
-
if (
|
|
1432
|
-
|
|
1433
|
-
if (authHeader !== `Bearer ${syncToken}`) {
|
|
1434
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1435
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1524
|
+
if (unauthorized())
|
|
1525
|
+
return; // fail-closed (was fail-open)
|
|
1439
1526
|
const uploadId = url.searchParams.get('uploadId');
|
|
1440
1527
|
const chunkIndex = parseInt(url.searchParams.get('chunk') || '0');
|
|
1441
1528
|
if (!uploadId) {
|
|
@@ -1466,14 +1553,8 @@ function startApiServer(workingDir, port) {
|
|
|
1466
1553
|
}
|
|
1467
1554
|
// POST /sessions/import-finalize — reassemble chunks, extract, apply slug merge
|
|
1468
1555
|
if (req.method === 'POST' && url.pathname === '/sessions/import-finalize') {
|
|
1469
|
-
if (
|
|
1470
|
-
|
|
1471
|
-
if (authHeader !== `Bearer ${syncToken}`) {
|
|
1472
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1473
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1474
|
-
return;
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1556
|
+
if (unauthorized())
|
|
1557
|
+
return; // fail-closed (was fail-open)
|
|
1477
1558
|
const uploadId = url.searchParams.get('uploadId');
|
|
1478
1559
|
const total = parseInt(url.searchParams.get('total') || '0');
|
|
1479
1560
|
const targetWorkDir = url.searchParams.get('targetWorkDir') ?? undefined;
|
|
@@ -1554,14 +1635,8 @@ function startApiServer(workingDir, port) {
|
|
|
1554
1635
|
// Deletes ~/.claude/projects/<slug>/ and ~/.claude/projects/osb/<slug>/
|
|
1555
1636
|
// Used by the dashboard "delete project" button.
|
|
1556
1637
|
if (req.method === 'DELETE' && url.pathname === '/sessions/project') {
|
|
1557
|
-
if (
|
|
1558
|
-
|
|
1559
|
-
if (authHeader !== `Bearer ${syncToken}`) {
|
|
1560
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
1561
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
1562
|
-
return;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1638
|
+
if (unauthorized())
|
|
1639
|
+
return; // fail-closed (was fail-open) — this DELETES a project's sessions
|
|
1565
1640
|
const slug = url.searchParams.get('slug');
|
|
1566
1641
|
if (!slug || slug.includes('..') || slug.includes('/')) {
|
|
1567
1642
|
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
@@ -1670,7 +1745,16 @@ function startApiServer(workingDir, port) {
|
|
|
1670
1745
|
// self-refreshing "Starting…" page so the user naturally re-hits /editor every
|
|
1671
1746
|
// 3 s until ready.
|
|
1672
1747
|
if (url.pathname === '/editor' && req.method === 'GET') {
|
|
1673
|
-
// AUTH GATE
|
|
1748
|
+
// AUTH GATE: the editor URL is minted with an owner-only signed token (see
|
|
1749
|
+
// mintEditorToken) and delivered over the authenticated data channel. A
|
|
1750
|
+
// direct hit without a valid token is refused — this is what closes the
|
|
1751
|
+
// unauthenticated-RCE hole. Local dev (no FLY_APP_NAME) is localhost-only.
|
|
1752
|
+
const editorToken = url.searchParams.get('t');
|
|
1753
|
+
if (process.env.FLY_APP_NAME && !verifyEditorToken(editorToken)) {
|
|
1754
|
+
res.writeHead(403, { 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'no-store' });
|
|
1755
|
+
res.end('Forbidden — open the editor from inside your Voice Native session.');
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1674
1758
|
// Optional ?folder= param: must be an absolute path under /workspace with no
|
|
1675
1759
|
// directory-traversal sequences. If absent or invalid, fall back to bare '/'.
|
|
1676
1760
|
const rawFolder = url.searchParams.get('folder') ?? '';
|
|
@@ -1706,9 +1790,14 @@ function startApiServer(workingDir, port) {
|
|
|
1706
1790
|
console.error('❌ startCodeServer() from /editor failed:', err);
|
|
1707
1791
|
});
|
|
1708
1792
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1793
|
+
// Preserve BOTH folder and the access token across the 3s self-refresh,
|
|
1794
|
+
// or the poll loop would bounce to a tokenless /editor and 403.
|
|
1795
|
+
const refreshQs = new URLSearchParams();
|
|
1796
|
+
if (folderParam)
|
|
1797
|
+
refreshQs.set('folder', folderParam);
|
|
1798
|
+
if (editorToken)
|
|
1799
|
+
refreshQs.set('t', editorToken);
|
|
1800
|
+
const refreshTarget = refreshQs.toString() ? `/editor?${refreshQs.toString()}` : '/editor';
|
|
1712
1801
|
res.writeHead(200, {
|
|
1713
1802
|
'Content-Type': 'text/html; charset=utf-8',
|
|
1714
1803
|
'Cache-Control': 'no-store, must-revalidate',
|
|
@@ -2083,11 +2172,41 @@ async function main() {
|
|
|
2083
2172
|
// null while the agent is idle (between sessions).
|
|
2084
2173
|
let activeRoom = null;
|
|
2085
2174
|
let activeRoomName = null; // the temporary room name currently joined
|
|
2175
|
+
// Watch gateway (mobile Track 2): bridges the native watchOS app's WS audio
|
|
2176
|
+
// + JSON into the user's LiveKit room via rtc-node. Opt-in — dormant unless
|
|
2177
|
+
// WATCH_GATEWAY=1 (port WATCH_GATEWAY_PORT, default 8742).
|
|
2178
|
+
if (process.env.WATCH_GATEWAY === '1') {
|
|
2179
|
+
const livekitUrl = process.env.LIVEKIT_URL || '';
|
|
2180
|
+
if (livekitUrl) {
|
|
2181
|
+
startWatchGateway({
|
|
2182
|
+
port: parseInt(process.env.WATCH_GATEWAY_PORT || '8742', 10),
|
|
2183
|
+
livekitUrl,
|
|
2184
|
+
getActiveRoom: () => activeRoomName,
|
|
2185
|
+
mintToken: mintAgentToken,
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
else {
|
|
2189
|
+
console.log('⌚️ Watch gateway: WATCH_GATEWAY=1 but LIVEKIT_URL unset — not starting');
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2086
2192
|
// Track state
|
|
2087
2193
|
let pendingSessionClose = null; // Tracks async session close for reconnect safety
|
|
2088
2194
|
let currentSession = null;
|
|
2089
2195
|
// 0.9.81: callable handler reference — see registration site for why.
|
|
2090
2196
|
let participantConnectedHandler = null;
|
|
2197
|
+
// Identity of the user participant the voice session was last built for.
|
|
2198
|
+
// Only it may send state-changing data messages (data-sender-auth.ts).
|
|
2199
|
+
let controllingUserIdentity = null;
|
|
2200
|
+
// Machine owner (Supabase user id), baked into machine env by the frontend
|
|
2201
|
+
// provisioning (platform-env.ts). Empty = single-tenant / local mode:
|
|
2202
|
+
// newest joiner becomes the controller. NOTE: machines provisioned before
|
|
2203
|
+
// this env existed lack it until their next create / update-osborn /
|
|
2204
|
+
// pool repoint re-bakes the env, and run in newest-joiner mode until then.
|
|
2205
|
+
const OWNER_USER_ID = (process.env.OSBORN_OWNER_USER_ID || '').trim();
|
|
2206
|
+
if (OWNER_USER_ID)
|
|
2207
|
+
console.log('🔐 Control bound to machine owner (OSBORN_OWNER_USER_ID set)');
|
|
2208
|
+
else
|
|
2209
|
+
console.log('🔓 OSBORN_OWNER_USER_ID unset: single-tenant mode, newest joiner controls the agent');
|
|
2091
2210
|
let currentAgent = null; // For updateChatCtx() context injection
|
|
2092
2211
|
let currentLLM = null;
|
|
2093
2212
|
const slots = new Map();
|
|
@@ -2716,6 +2835,11 @@ async function main() {
|
|
|
2716
2835
|
// ────────────────────────────────────────────────────────────────────────
|
|
2717
2836
|
// LIVE meeting transcript → LLM (buffered webhook finals). See recall.on('transcript').
|
|
2718
2837
|
const meetingTranscriptBuffer = [];
|
|
2838
|
+
// Phase C routing target: the Tier-2 worker the most recent addressed turn
|
|
2839
|
+
// named (@researcher …). Captured in recall.on('transcript') when addressing
|
|
2840
|
+
// is enabled, consumed (and cleared) by the next addressed flushMeetingBuffer,
|
|
2841
|
+
// which injects a Task-dispatch directive for it. Null = no pending routing.
|
|
2842
|
+
let meetingAddressedTarget = null;
|
|
2719
2843
|
let meetingFlushTimer = null;
|
|
2720
2844
|
// Flush the buffered meeting turns to the LLM. `addressed=true` (the agent was
|
|
2721
2845
|
// called by name / asked directly) tags the message so the agent RESPONDS by
|
|
@@ -2751,9 +2875,36 @@ async function main() {
|
|
|
2751
2875
|
// Prepend + consume any interruption context (bot was cut off mid-sentence).
|
|
2752
2876
|
const interrupt = meetingInterruptContext ? `${meetingInterruptContext}\n` : '';
|
|
2753
2877
|
meetingInterruptContext = '';
|
|
2878
|
+
// Phase C — route an addressed turn to a specific Tier-2 worker. When the
|
|
2879
|
+
// addressing layer is on and the last addressed utterance named a routable
|
|
2880
|
+
// worker (not the orchestrator), STEER THE SINGLE SDK SESSION by injecting a
|
|
2881
|
+
// directive so the orchestrator dispatches that named agent via its Task
|
|
2882
|
+
// tool (the existing noteTaskDispatch/claimTaskDispatch/statusManager
|
|
2883
|
+
// plumbing in claude-llm.ts handles the rest). No parallel query() is
|
|
2884
|
+
// spawned — currentLLM.chat() feeds the one persistent session. Gated on
|
|
2885
|
+
// live dispatch headroom (statusManager) so a busy room can't fan out
|
|
2886
|
+
// unboundedly. The directive goes AFTER the `[MEETING` prefix so the ambient
|
|
2887
|
+
// non-interrupting + suppressMeetingTTS keying on that prefix still hold.
|
|
2888
|
+
let routingDirective = '';
|
|
2889
|
+
const pendingTarget = meetingAddressedTarget;
|
|
2890
|
+
meetingAddressedTarget = null;
|
|
2891
|
+
if (addressed && meetingAddressing.enabled && isRoutableTarget(pendingTarget)) {
|
|
2892
|
+
const active = statusManager.getActiveDispatchIds().length;
|
|
2893
|
+
const cap = Math.max(1, Number(process.env.OSBORN_MEETING_MAX_DISPATCH) || 3);
|
|
2894
|
+
if (active < cap) {
|
|
2895
|
+
routingDirective =
|
|
2896
|
+
`[ROUTING] A participant addressed @${pendingTarget}. Dispatch the "${pendingTarget}" ` +
|
|
2897
|
+
`agent via the Task tool (subagent_type "${pendingTarget}") to handle this turn instead of ` +
|
|
2898
|
+
`answering yourself, then relay its result into the meeting.\n`;
|
|
2899
|
+
console.log(`🎯 [meeting-addr] routing addressed turn → @${pendingTarget} via Task directive (dispatches ${active}/${cap})`);
|
|
2900
|
+
}
|
|
2901
|
+
else {
|
|
2902
|
+
console.log(`🎯 [meeting-addr] @${pendingTarget} routing skipped — at concurrency cap (${active}/${cap}); orchestrator handles it`);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2754
2905
|
try {
|
|
2755
2906
|
const ctx = new llm.ChatContext();
|
|
2756
|
-
ctx.addMessage({ role: 'user', content: `${interrupt}${header}\n${turns.join('\n')}` });
|
|
2907
|
+
ctx.addMessage({ role: 'user', content: `${interrupt}${header}\n${routingDirective}${turns.join('\n')}` });
|
|
2757
2908
|
currentLLM.chat({ chatCtx: ctx });
|
|
2758
2909
|
console.log(`📓 Flushed ${turns.length} meeting turn(s) to LLM${addressed ? ' (ADDRESSED — respond)' : ''}`);
|
|
2759
2910
|
}
|
|
@@ -2831,6 +2982,8 @@ async function main() {
|
|
|
2831
2982
|
activeMeetingBotId = null;
|
|
2832
2983
|
meetingAddressedUntil = 0;
|
|
2833
2984
|
meetingSpeakers.clear();
|
|
2985
|
+
meetingAddressedTarget = null;
|
|
2986
|
+
meetingAddressing.reset(); // inert when OSBORN_MEETING_ADDRESSING is unset (empty registry)
|
|
2834
2987
|
// leaveBot=false when Recall itself reported the meeting over (bot already gone).
|
|
2835
2988
|
if (opts.leaveBot !== false) {
|
|
2836
2989
|
const recall = getRecallClient();
|
|
@@ -3194,12 +3347,42 @@ async function main() {
|
|
|
3194
3347
|
recall.on('transcript', ({ botId, speaker, text, partial }) => {
|
|
3195
3348
|
console.log(`📝 Meeting transcript [${speaker}]${partial ? ' (partial)' : ''}: ${text}`);
|
|
3196
3349
|
if (!partial && text.trim()) {
|
|
3350
|
+
// Multi-agent meeting addressing/mute (OFF by default — set
|
|
3351
|
+
// OSBORN_MEETING_ADDRESSING=on to engage). When the flag is unset this
|
|
3352
|
+
// whole block is skipped: processUtterance() short-circuits and the
|
|
3353
|
+
// meeting path below behaves EXACTLY as before. When ON: a muted speaker
|
|
3354
|
+
// is dropped, a mute/unmute command updates the registry (and notifies
|
|
3355
|
+
// the frontend), and an addressed worker is captured for Phase-C routing
|
|
3356
|
+
// in the next addressed flush (see flushMeetingBuffer).
|
|
3357
|
+
if (meetingAddressing.enabled) {
|
|
3358
|
+
const verdict = meetingAddressing.processUtterance(speaker, text);
|
|
3359
|
+
if (verdict.muteChanged) {
|
|
3360
|
+
console.log(`🎛️ [meeting-addr] ${verdict.muteChanged.action} "${verdict.muteChanged.who}" — muted now: ${meetingAddressing.mutes.list().join(', ') || 'none'}`);
|
|
3361
|
+
emitMuteChanged(verdict.muteChanged.action, verdict.muteChanged.who);
|
|
3362
|
+
}
|
|
3363
|
+
if (verdict.drop) {
|
|
3364
|
+
console.log(`🔇 [meeting-addr] dropped utterance from muted speaker "${speaker}"`);
|
|
3365
|
+
return; // muted participant — do not buffer or forward to the LLM
|
|
3366
|
+
}
|
|
3367
|
+
if (verdict.target) {
|
|
3368
|
+
// Remember the addressed worker so the next addressed flush routes to
|
|
3369
|
+
// it (Phase C). Store regardless of routability so the UI can show the
|
|
3370
|
+
// chip; flushMeetingBuffer gates actual Task dispatch on isRoutableTarget.
|
|
3371
|
+
meetingAddressedTarget = verdict.target;
|
|
3372
|
+
console.log(`🎯 [meeting-addr] "${speaker}" addresses @${verdict.target}${isRoutableTarget(verdict.target) ? ' (will route to worker)' : ' (orchestrator — no worker dispatch)'}`);
|
|
3373
|
+
emitMeetingState(verdict.target);
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
const isNewSpeaker = !meetingSpeakers.has(speaker);
|
|
3197
3377
|
meetingTranscriptBuffer.push(`${speaker}: ${text.trim()}`);
|
|
3198
3378
|
// Addressed by name → flush NOW (don't wait the 20s batch) and tag it so
|
|
3199
3379
|
// the agent replies out loud into the meeting. This is the chat-mode path:
|
|
3200
3380
|
// named/asked → prompt response. Un-addressed chunks stay in the silent
|
|
3201
3381
|
// 20s batch for note-taking. That's the two-mode seam, mechanically.
|
|
3202
3382
|
meetingSpeakers.add(speaker);
|
|
3383
|
+
// New participant → refresh the frontend's mute roster (flag-gated no-op).
|
|
3384
|
+
if (isNewSpeaker)
|
|
3385
|
+
emitMeetingState();
|
|
3203
3386
|
// Fuzzy name match: meeting STT routinely mangles "Osborn" — observed
|
|
3204
3387
|
// live 2026-08-01: "Osborn can you hear me" → "i was born can you hear
|
|
3205
3388
|
// me" (name trigger missed, bot stayed silent). Accept common
|
|
@@ -3354,6 +3537,13 @@ async function main() {
|
|
|
3354
3537
|
}
|
|
3355
3538
|
console.log(`🤐 Suppressed text buffered (+${t.length} chars, total ${lastInterruption.suppressedText.length}): "${t.substring(0, 80)}${t.length > 80 ? '...' : ''}"`);
|
|
3356
3539
|
}
|
|
3540
|
+
// L2b: client notices (favorite_changed) ride the next real user turn as
|
|
3541
|
+
// hidden context (PipelineDirectLLM getAndConsumeClientNotes), never as a
|
|
3542
|
+
// user_text turn. typedEchoes carries a typed message's clientMsgId onto its
|
|
3543
|
+
// user_transcript echo.
|
|
3544
|
+
const clientNotes = new ClientNoteQueue();
|
|
3545
|
+
const typedEchoes = new TypedEchoTracker();
|
|
3546
|
+
const getAndConsumeClientNotes = () => clientNotes.drain();
|
|
3357
3547
|
/**
|
|
3358
3548
|
* Callback for PipelineDirectLLM — returns pending interruption context and clears it.
|
|
3359
3549
|
* Called in chat() when user's transcribed message arrives.
|
|
@@ -3602,6 +3792,31 @@ async function main() {
|
|
|
3602
3792
|
console.error('❌ sendToFrontend error:', err);
|
|
3603
3793
|
}
|
|
3604
3794
|
}
|
|
3795
|
+
// ── Phase B — meeting addressing/mute state → frontend (over the EXISTING
|
|
3796
|
+
// 'osborn-updates' data channel). Both are NO-OPS when the flag is unset, so
|
|
3797
|
+
// an un-flagged meeting emits nothing new (zero behavior change). `meeting_state`
|
|
3798
|
+
// is the full snapshot (roster, known speakers, muted set, who was addressed);
|
|
3799
|
+
// `mute_changed` is the lightweight per-change delta. Function declarations so
|
|
3800
|
+
// they're reachable from the transcript handler + handleDataReceived above.
|
|
3801
|
+
function emitMeetingState(addressed = null) {
|
|
3802
|
+
if (!meetingAddressing.enabled)
|
|
3803
|
+
return;
|
|
3804
|
+
const st = meetingAddressing.state();
|
|
3805
|
+
void sendToFrontend({
|
|
3806
|
+
type: 'meeting_state',
|
|
3807
|
+
enabled: st.enabled,
|
|
3808
|
+
roster: st.roster,
|
|
3809
|
+
speakers: [...meetingSpeakers],
|
|
3810
|
+
muted: st.muted,
|
|
3811
|
+
addressed,
|
|
3812
|
+
});
|
|
3813
|
+
}
|
|
3814
|
+
function emitMuteChanged(action, who) {
|
|
3815
|
+
if (!meetingAddressing.enabled)
|
|
3816
|
+
return;
|
|
3817
|
+
void sendToFrontend({ type: 'mute_changed', action, who, muted: meetingAddressing.mutes.list() });
|
|
3818
|
+
emitMeetingState();
|
|
3819
|
+
}
|
|
3605
3820
|
async function announceViaVoice(text) {
|
|
3606
3821
|
if (!currentSession)
|
|
3607
3822
|
return;
|
|
@@ -3700,6 +3915,19 @@ async function main() {
|
|
|
3700
3915
|
// PipelineDirectLLM (llmOverride path) wraps its own ClaudeLLM and may not expose setTurbo.
|
|
3701
3916
|
directLLM?.setTurbo?.(turboMode);
|
|
3702
3917
|
currentLLM = directLLM;
|
|
3918
|
+
// Watch bridge (mobile Track 1): a wrist ack/expiry settles whatever
|
|
3919
|
+
// permission is currently pending. Re-registered per session — harmless,
|
|
3920
|
+
// the latest closure wins and they all resolve through currentLLM.
|
|
3921
|
+
setWatchResultHandler((allow, toolName) => {
|
|
3922
|
+
if (currentLLM?.hasPendingPermission?.()) {
|
|
3923
|
+
currentLLM.respondToPermission(allow);
|
|
3924
|
+
console.log(`⌚️ Watch bridge settled ${toolName}: ${allow ? 'approve' : 'deny'}`);
|
|
3925
|
+
}
|
|
3926
|
+
else {
|
|
3927
|
+
// Already answered via the web UI — a late ack/expiry is a no-op.
|
|
3928
|
+
console.log(`⌚️ Watch bridge ${allow ? 'ack' : 'expiry'} for ${toolName} — no pending permission, ignoring`);
|
|
3929
|
+
}
|
|
3930
|
+
});
|
|
3703
3931
|
// P1 host-agent anchor: this dashboard-started session owns the room's env
|
|
3704
3932
|
// and keeps it alive (agentsActive → true) so background dispatches survive.
|
|
3705
3933
|
// Keep-alive keys off the hostActive boolean, NOT a session_id event;
|
|
@@ -3897,6 +4125,10 @@ async function main() {
|
|
|
3897
4125
|
agentRole: 'direct',
|
|
3898
4126
|
diff: diffString,
|
|
3899
4127
|
});
|
|
4128
|
+
// Watch bridge (mobile Track 1): mirror this blocking question to the
|
|
4129
|
+
// wrist via Pushover. Fire-and-forget — dormant unless PUSHOVER_* env is
|
|
4130
|
+
// configured; web-UI answers always win (late wrist acks are no-ops).
|
|
4131
|
+
void armPermissionPush({ toolName, description }).catch(() => { });
|
|
3900
4132
|
// Speak the descriptive request so user knows to respond
|
|
3901
4133
|
//do not delete!! Leave this section commented out
|
|
3902
4134
|
// say permission, request permission, ask for permission with session.say
|
|
@@ -4458,6 +4690,28 @@ async function main() {
|
|
|
4458
4690
|
console.log('📽️🔊 meeting-canvas joined the LiveKit room — native session.say relays to the meeting');
|
|
4459
4691
|
return; // not a user; skip session setup for it
|
|
4460
4692
|
}
|
|
4693
|
+
// Owner binding (data-sender-auth.ts resolveJoin): with OSBORN_OWNER_USER_ID
|
|
4694
|
+
// set (cloud machines), only a `user-*` participant whose SIGNED token
|
|
4695
|
+
// metadata userId is the owner takes the session and becomes the
|
|
4696
|
+
// controller; other users are ignored (no voice session, gated data
|
|
4697
|
+
// dropped). With no owner configured (single-tenant / local), the newest
|
|
4698
|
+
// `user-*` joiner wins, as before. The watch gateway (our own identity)
|
|
4699
|
+
// never becomes the controller, so the owner's commands keep working; it
|
|
4700
|
+
// may still send permission_response. It gets the voice session only when
|
|
4701
|
+
// no controller exists (watch voice alone); joining after the owner it is
|
|
4702
|
+
// not adopted, so the owner's session and currentUserId stay intact.
|
|
4703
|
+
const joinerUserId = userIdFromMetadata(participant.metadata);
|
|
4704
|
+
const join = resolveJoin(participant.identity, joinerUserId, OWNER_USER_ID, controllingUserIdentity);
|
|
4705
|
+
controllingUserIdentity = join.controller;
|
|
4706
|
+
if (!join.adoptSession) {
|
|
4707
|
+
if (participant.identity === AGENT_SELF_IDENTITY) {
|
|
4708
|
+
console.log(`⌚ ${participant.identity} joined while ${controllingUserIdentity} controls the session; keeping the owner's voice session`);
|
|
4709
|
+
}
|
|
4710
|
+
else {
|
|
4711
|
+
console.warn(`🚫 ${participant.identity} is not the machine owner (token userId=${joinerUserId ?? 'none'}); not adopting it as the voice user`);
|
|
4712
|
+
}
|
|
4713
|
+
return;
|
|
4714
|
+
}
|
|
4461
4715
|
// A user (re)arriving cancels the meeting leave-grace — the bot stays.
|
|
4462
4716
|
cancelMeetingLeaveGrace();
|
|
4463
4717
|
// A user is present — cancel any pending agent-side "alone" leave.
|
|
@@ -4656,6 +4910,7 @@ async function main() {
|
|
|
4656
4910
|
}
|
|
4657
4911
|
},
|
|
4658
4912
|
getAndConsumeInterruptionContext,
|
|
4913
|
+
getAndConsumeClientNotes,
|
|
4659
4914
|
onFastBrainResult: (result) => {
|
|
4660
4915
|
console.log(`🧠⚡ [FAST_BRAIN ${result.type.toUpperCase()} +${result.elapsedMs}ms]: "${result.answer.substring(0, 60)}"`);
|
|
4661
4916
|
sendToFrontend({
|
|
@@ -4705,19 +4960,28 @@ async function main() {
|
|
|
4705
4960
|
let lastSentUserTranscript = '';
|
|
4706
4961
|
let lastSentAgentTranscript = '';
|
|
4707
4962
|
function sendUserTranscript(transcript, source) {
|
|
4708
|
-
if (!transcript
|
|
4963
|
+
if (!transcript)
|
|
4709
4964
|
return;
|
|
4710
|
-
|
|
4711
|
-
|
|
4965
|
+
// A typed message (user_text) echoes back here with its frontend
|
|
4966
|
+
// clientMsgId so the UI can dedupe its optimistic bubble (L2b).
|
|
4967
|
+
const typed = typedEchoes.take(transcript);
|
|
4968
|
+
const clientMsgId = typed?.clientMsgId;
|
|
4969
|
+
// Shared sanitizer (L2b): drops the frontend [time:] tag, injected
|
|
4970
|
+
// blocks and client/voice-injection notices ([favorited],
|
|
4971
|
+
// [welcome-back], [SCRIPT]/[PROACTIVE]/[NOTIFICATION] — Gemini v1.0.51:
|
|
4972
|
+
// userInput in generateReply creates a user conversation item), plus
|
|
4973
|
+
// <noise> / "thank you". null = nothing the user said.
|
|
4974
|
+
const text = userEchoText(transcript, typed?.attachments);
|
|
4975
|
+
if (!text)
|
|
4712
4976
|
return;
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
// (Gemini v1.0.51: userInput in generateReply creates a user conversation item)
|
|
4717
|
-
if (normalized.startsWith('[SCRIPT]') || normalized.startsWith('[PROACTIVE]') || normalized.startsWith('[NOTIFICATION]'))
|
|
4977
|
+
const normalized = text.replace(/\s+/g, ' ');
|
|
4978
|
+
// A distinct typed message may repeat the previous text on purpose.
|
|
4979
|
+
if (!clientMsgId && normalized === lastSentUserTranscript)
|
|
4718
4980
|
return;
|
|
4719
4981
|
console.log(`📝 User (${source}, ${transcript.length} chars): "${transcript}"`);
|
|
4720
|
-
sendToFrontend(
|
|
4982
|
+
sendToFrontend(clientMsgId
|
|
4983
|
+
? { type: 'user_transcript', text, clientMsgId }
|
|
4984
|
+
: { type: 'user_transcript', text });
|
|
4721
4985
|
lastSentUserTranscript = normalized;
|
|
4722
4986
|
if (connectTiming && !connectTiming.sawUserMsg) {
|
|
4723
4987
|
connectTiming.sawUserMsg = true;
|
|
@@ -5113,6 +5377,7 @@ async function main() {
|
|
|
5113
5377
|
}
|
|
5114
5378
|
},
|
|
5115
5379
|
getAndConsumeInterruptionContext,
|
|
5380
|
+
getAndConsumeClientNotes,
|
|
5116
5381
|
onFastBrainResult: (r) => {
|
|
5117
5382
|
console.log(`🧠⚡ [FAST_BRAIN ${r.type.toUpperCase()} +${r.elapsedMs}ms]: "${r.answer.substring(0, 60)}"`);
|
|
5118
5383
|
sendToFrontend({
|
|
@@ -5302,14 +5567,14 @@ async function main() {
|
|
|
5302
5567
|
if (dbPath) {
|
|
5303
5568
|
const db = openStore(dbPath, { readonly: true });
|
|
5304
5569
|
try {
|
|
5305
|
-
|
|
5306
|
-
const priorMessages =
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5570
|
+
// Sanitized before truncation, over-fetched, chronological (L2b).
|
|
5571
|
+
const priorMessages = cleanHistoryRows(n => recentRows(db, n, ['user', 'assistant']), 20, 800);
|
|
5572
|
+
// Durable compaction markers ride the same push so the resumed
|
|
5573
|
+
// transcript rebuilds its "Conversation compacted" rows too.
|
|
5574
|
+
const compactions = readCompactionMarkers(preSelectedSessionId, workingDir);
|
|
5310
5575
|
if (priorMessages.length > 0) {
|
|
5311
|
-
await sendToFrontend({ type: 'prior_messages', sessionId: preSelectedSessionId, messages: priorMessages });
|
|
5312
|
-
console.log(`💬 Sent ${priorMessages.length} prior messages from DB for optimistic UI`);
|
|
5576
|
+
await sendToFrontend({ type: 'prior_messages', sessionId: preSelectedSessionId, messages: priorMessages, compactions });
|
|
5577
|
+
console.log(`💬 Sent ${priorMessages.length} prior messages (+${compactions.length} compaction markers) from DB for optimistic UI`);
|
|
5313
5578
|
}
|
|
5314
5579
|
}
|
|
5315
5580
|
finally {
|
|
@@ -5378,6 +5643,8 @@ async function main() {
|
|
|
5378
5643
|
// participantConnectedHandler above).
|
|
5379
5644
|
const handleParticipantDisconnected = (participant) => {
|
|
5380
5645
|
console.log(`👋 User left: ${participant.identity}`);
|
|
5646
|
+
if (participant.identity === controllingUserIdentity)
|
|
5647
|
+
controllingUserIdentity = null;
|
|
5381
5648
|
// Full cleanup — stop all background work to avoid accumulating API usage
|
|
5382
5649
|
voiceQueue.length = 0;
|
|
5383
5650
|
isProcessingQueue = false;
|
|
@@ -5484,6 +5751,11 @@ async function main() {
|
|
|
5484
5751
|
try {
|
|
5485
5752
|
const data = JSON.parse(new TextDecoder().decode(payload));
|
|
5486
5753
|
console.log('📨 Data:', data.type);
|
|
5754
|
+
const senderCheck = checkControlSender(String(data.type), participant?.identity, controllingUserIdentity);
|
|
5755
|
+
if (!senderCheck.ok) {
|
|
5756
|
+
console.warn(`🚫 Dropped ${data.type}: ${senderCheck.reason}`);
|
|
5757
|
+
return;
|
|
5758
|
+
}
|
|
5487
5759
|
if (data.type === 'claude_auth_code' && pendingAuthSubmitCode) {
|
|
5488
5760
|
console.log('🔑 Received auth code from frontend');
|
|
5489
5761
|
sendToFrontend({ type: 'claude_auth_submitting', message: 'Submitting code to Claude CLI...' });
|
|
@@ -5502,7 +5774,26 @@ async function main() {
|
|
|
5502
5774
|
console.log(`✅ Permission: ${data.response}`);
|
|
5503
5775
|
}
|
|
5504
5776
|
}
|
|
5777
|
+
else if (data.type === 'favorite_changed') {
|
|
5778
|
+
// L2b (UI#21): a favorite is a UI action, not something the user said.
|
|
5779
|
+
// Queue it as hidden context for the next real user turn; no reply, no
|
|
5780
|
+
// user_transcript echo, no JSONL user turn of its own.
|
|
5781
|
+
const change = parseFavoriteChanged(data);
|
|
5782
|
+
if (change) {
|
|
5783
|
+
clientNotes.favoriteChanged(change);
|
|
5784
|
+
console.log(`⭐ favorite_changed: ${change.fileName} → ${change.favorited ? 'on' : 'off'} (queued as context)`);
|
|
5785
|
+
}
|
|
5786
|
+
}
|
|
5505
5787
|
else if (data.type === 'user_text' && currentSession) {
|
|
5788
|
+
// Backward compat: older frontends send a favorite as user_text
|
|
5789
|
+
// "[time: …] [favorited] The user favorited the file X." — route it to
|
|
5790
|
+
// the same context queue instead of starting a user turn.
|
|
5791
|
+
const legacyFavorite = parseLegacyFavoriteNotice(String(data.content || ''));
|
|
5792
|
+
if (legacyFavorite && !(Array.isArray(data.files) && data.files.length)) {
|
|
5793
|
+
clientNotes.favoriteChanged(legacyFavorite);
|
|
5794
|
+
console.log(`⭐ legacy [favorited] user_text → context note: ${legacyFavorite.fileName}`);
|
|
5795
|
+
return;
|
|
5796
|
+
}
|
|
5506
5797
|
// Build message content — include attached files (URLs, text content)
|
|
5507
5798
|
let fullContent = String(data.content || '');
|
|
5508
5799
|
const files = data.files;
|
|
@@ -5523,6 +5814,9 @@ async function main() {
|
|
|
5523
5814
|
else {
|
|
5524
5815
|
console.log(`📝 Text (${fullContent.length} chars): "${fullContent}"`);
|
|
5525
5816
|
}
|
|
5817
|
+
// The session echoes this item as user_transcript; carry the frontend's
|
|
5818
|
+
// clientMsgId (bubble dedupe) and the attachment blocks onto that echo.
|
|
5819
|
+
typedEchoes.register(fullContent, data.clientMsgId, fullContent.slice(String(data.content || '').length));
|
|
5526
5820
|
// Skip interrupt for Gemini — disrupts state machine (hangs in speaking state)
|
|
5527
5821
|
if (true) { // always non-gemini in pipeline mode
|
|
5528
5822
|
currentSession.interrupt();
|
|
@@ -5544,16 +5838,7 @@ async function main() {
|
|
|
5544
5838
|
// Sent here too so the in-chat session list grouping stays
|
|
5545
5839
|
// consistent with the dashboard's grouping.
|
|
5546
5840
|
baseCwd: workingDir,
|
|
5547
|
-
sessions: sessions.map(
|
|
5548
|
-
sessionId: s.sessionId,
|
|
5549
|
-
projectSlug: s.projectSlug,
|
|
5550
|
-
projectPath: s.projectPath,
|
|
5551
|
-
cwd: s.cwd,
|
|
5552
|
-
timestamp: s.timestamp.toISOString(),
|
|
5553
|
-
lastMessage: s.lastMessage,
|
|
5554
|
-
messageCount: s.messageCount,
|
|
5555
|
-
fileSize: s.fileSize,
|
|
5556
|
-
})),
|
|
5841
|
+
sessions: sessions.map(sessionListEntry),
|
|
5557
5842
|
count: sessions.length,
|
|
5558
5843
|
});
|
|
5559
5844
|
}
|
|
@@ -6211,6 +6496,20 @@ async function main() {
|
|
|
6211
6496
|
recallJoin.registerBot(botId, sessionId);
|
|
6212
6497
|
activeMeetingBotId = botId;
|
|
6213
6498
|
await sendToFrontend({ type: 'meeting_joined', botId, message: 'Osborn has joined the meeting' });
|
|
6499
|
+
// Phase B — point the addressable roster at the REAL effective
|
|
6500
|
+
// agent set (built-ins minus user-removed, plus per-user agents),
|
|
6501
|
+
// same effective set get_agents/set_agents compute, with the
|
|
6502
|
+
// orchestrator ('osborn') first. Flag-gated: a no-op (no roster
|
|
6503
|
+
// change, no emit) when OSBORN_MEETING_ADDRESSING is unset.
|
|
6504
|
+
if (meetingAddressing.enabled) {
|
|
6505
|
+
const base = { ...NAMED_AGENTS };
|
|
6506
|
+
for (const r of userRemovedAgents)
|
|
6507
|
+
delete base[r];
|
|
6508
|
+
const effective = { ...base, ...(userNamedAgents || {}) };
|
|
6509
|
+
meetingAddressing.setRoster(['osborn', ...Object.keys(effective)]);
|
|
6510
|
+
console.log(`🎛️ [meeting-addr] roster → [${meetingAddressing.rosterIds.join(', ')}]`);
|
|
6511
|
+
emitMeetingState();
|
|
6512
|
+
}
|
|
6214
6513
|
// Minimal awareness injection (user directive 2026-08-04): tell the
|
|
6215
6514
|
// LLM it's in a meeting and how transcripts are tagged — nothing
|
|
6216
6515
|
// more. NO "do NOT speak / silent observer" coaching (that fought
|
|
@@ -6287,6 +6586,22 @@ async function main() {
|
|
|
6287
6586
|
await sendToFrontend({ type: 'meeting_error', message: err.message });
|
|
6288
6587
|
}
|
|
6289
6588
|
}
|
|
6589
|
+
// Phase B — authenticated frontend mute/unmute of a meeting participant.
|
|
6590
|
+
// Controller-only: checkControlSender fails CLOSED for any type not on the
|
|
6591
|
+
// read-only list, so this gated type already requires the controlling user.
|
|
6592
|
+
// Flag-gated: ignored entirely unless OSBORN_MEETING_ADDRESSING is on (the
|
|
6593
|
+
// MuteRegistry is only consulted by processUtterance when enabled anyway).
|
|
6594
|
+
else if (data.type === 'mute_participant') {
|
|
6595
|
+
if (meetingAddressing.enabled) {
|
|
6596
|
+
const action = data.action === 'unmute' ? 'unmute' : 'mute';
|
|
6597
|
+
const who = String(data.who || '').trim();
|
|
6598
|
+
const applied = who ? meetingAddressing.applyMuteControl(action, who) : null;
|
|
6599
|
+
if (applied) {
|
|
6600
|
+
console.log(`🎛️ [meeting-addr] ${applied.action} "${applied.who}" via control — muted now: ${meetingAddressing.mutes.list().join(', ') || 'none'}`);
|
|
6601
|
+
emitMuteChanged(applied.action, applied.who);
|
|
6602
|
+
}
|
|
6603
|
+
}
|
|
6604
|
+
}
|
|
6290
6605
|
// ── IDE (code-server) handlers ──────────────────────────────────────
|
|
6291
6606
|
else if (data.type === 'start_ide') {
|
|
6292
6607
|
try {
|
|
@@ -6295,10 +6610,14 @@ async function main() {
|
|
|
6295
6610
|
const flyAppHost = process.env.FLY_APP_NAME
|
|
6296
6611
|
? `${process.env.FLY_APP_NAME}.fly.dev`
|
|
6297
6612
|
: (process.env.OSBORN_PUBLIC_HOST || `localhost:${apiPort}`);
|
|
6298
|
-
|
|
6613
|
+
// Mint an owner-only access token into the URL. The frontend opens it
|
|
6614
|
+
// verbatim; a direct hit to /editor without it is refused (RCE fix).
|
|
6615
|
+
const editorTok = mintEditorToken();
|
|
6616
|
+
const tokQs = editorTok ? `?t=${encodeURIComponent(editorTok)}` : '';
|
|
6617
|
+
const ideUrl = (process.env.FLY_APP_NAME
|
|
6299
6618
|
? `https://${flyAppHost}/editor`
|
|
6300
|
-
: `http://${flyAppHost}/editor
|
|
6301
|
-
console.log(`✅ IDE proxy ready: ${ideUrl}`);
|
|
6619
|
+
: `http://${flyAppHost}/editor`) + tokQs;
|
|
6620
|
+
console.log(`✅ IDE proxy ready: ${process.env.FLY_APP_NAME ? `https://${flyAppHost}/editor` : ideUrl}${editorTok ? ' (token-gated)' : ''}`);
|
|
6302
6621
|
await sendToFrontend({ type: 'ide_ready', url: ideUrl });
|
|
6303
6622
|
}
|
|
6304
6623
|
catch (err) {
|