osborn 0.9.255 → 0.9.257
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/dist/claude-llm.js +2 -2
- package/dist/index.js +34 -2
- package/dist/noise-gate.d.ts +11 -0
- package/dist/noise-gate.js +69 -7
- package/dist/prompts/direct-mode-research.md +19 -0
- package/package.json +1 -1
package/dist/claude-llm.js
CHANGED
|
@@ -2075,8 +2075,8 @@ class ClaudeLLMStream extends llm.LLMStream {
|
|
|
2075
2075
|
// only, no shell chaining — not a general curl allowance.
|
|
2076
2076
|
if (toolName === 'Bash') {
|
|
2077
2077
|
const cmd = String(input?.command || '');
|
|
2078
|
-
if (/^\s*curl\b[^;&|]*https?:\/\/(localhost|127\.0\.0\.1):\d+\/(canvas|tts)\b/.test(cmd) && !/[;&|]/.test(cmd)) {
|
|
2079
|
-
console.log(`✅ Auto-approved Bash → own API (canvas/tts
|
|
2078
|
+
if (/^\s*curl\b[^;&|]*https?:\/\/(localhost|127\.0\.0\.1):\d+\/(canvas|tts|noise-cancel)\b/.test(cmd) && !/[;&|]/.test(cmd)) {
|
|
2079
|
+
console.log(`✅ Auto-approved Bash → own API (canvas/tts/noise-cancel path)`);
|
|
2080
2080
|
return { behavior: 'allow', updatedInput: input };
|
|
2081
2081
|
}
|
|
2082
2082
|
}
|
package/dist/index.js
CHANGED
|
@@ -311,7 +311,7 @@ function parseDevSubdomainPort(req) {
|
|
|
311
311
|
const AGENT_ROUTE_PREFIXES = [
|
|
312
312
|
'/health', '/sessions', '/skills', '/agents', '/canvas', '/canvas-token',
|
|
313
313
|
'/canvas-stream', '/events', '/room-code', '/connect-room', '/leave-room',
|
|
314
|
-
'/report-bug', '/restart', '/tts', '/webhook', '/sessions/export',
|
|
314
|
+
'/report-bug', '/restart', '/tts', '/noise-cancel', '/webhook', '/sessions/export',
|
|
315
315
|
'/sessions/import', '/sessions/manifest',
|
|
316
316
|
'/secrets',
|
|
317
317
|
'/editor',
|
|
@@ -932,6 +932,32 @@ function startApiServer(workingDir, port) {
|
|
|
932
932
|
});
|
|
933
933
|
return;
|
|
934
934
|
}
|
|
935
|
+
// ── Noise cancellation: agent self-service toggle ────────────────────────
|
|
936
|
+
// POST /noise-cancel { enabled: boolean }. Lets the AGENT flip the gate the
|
|
937
|
+
// moment its own meeting-mode detection fires ("that sounded like it was for
|
|
938
|
+
// someone near you") — the skill-based detection produces no [MEETING chunks,
|
|
939
|
+
// so without this bridge the gate never engaged in real side-conversations
|
|
940
|
+
// (verified in the 2026-10-21 Uber session). Auto-approved for the agent via
|
|
941
|
+
// the canvas/tts localhost curl allowance in claude-llm.ts canUseTool.
|
|
942
|
+
if (req.method === 'POST' && url.pathname === '/noise-cancel') {
|
|
943
|
+
let body = '';
|
|
944
|
+
req.on('data', (c) => { body += c; });
|
|
945
|
+
req.on('end', () => {
|
|
946
|
+
try {
|
|
947
|
+
const { enabled } = JSON.parse(body || '{}');
|
|
948
|
+
if (typeof enabled !== 'boolean')
|
|
949
|
+
throw new Error('enabled must be a boolean');
|
|
950
|
+
noiseGate.setEnabled(enabled, 'meeting');
|
|
951
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
952
|
+
res.end(JSON.stringify({ ok: true, enabled: noiseGate.enabled, reason: noiseGate.reason }));
|
|
953
|
+
}
|
|
954
|
+
catch (e) {
|
|
955
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
956
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
957
|
+
}
|
|
958
|
+
});
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
935
961
|
// GET /sessions/export — stream a gzipped tar of ~/.claude/projects/ AND
|
|
936
962
|
// ~/.claude/skills/ to the client. Both directories ship in one archive so
|
|
937
963
|
// a sync covers conversations (projects/) and learned skills together —
|
|
@@ -2820,7 +2846,13 @@ async function main() {
|
|
|
2820
2846
|
console.warn('🧹 housekeeping failed:', e);
|
|
2821
2847
|
}
|
|
2822
2848
|
};
|
|
2823
|
-
|
|
2849
|
+
// PERF (sub-second-connect initiative): the BOOT run is always forced dry-run
|
|
2850
|
+
// (no active session yet) — it scans thousands of artifacts purely to LOG them,
|
|
2851
|
+
// which blocked the listen port on every cold start. Defer it off the critical
|
|
2852
|
+
// path so boot reaches "ready" first; the periodic 6h runs (when a session
|
|
2853
|
+
// exists) do the real pruning. unref so it never holds the process open.
|
|
2854
|
+
const firstHousekeeping = setTimeout(runHousekeeping, 60_000);
|
|
2855
|
+
firstHousekeeping.unref?.();
|
|
2824
2856
|
setInterval(runHousekeeping, 6 * 60 * 60 * 1000);
|
|
2825
2857
|
// Claude auth code submission handler (set during OAuth flow, cleared after)
|
|
2826
2858
|
let pendingAuthSubmitCode = null;
|
package/dist/noise-gate.d.ts
CHANGED
|
@@ -38,12 +38,23 @@ export interface GateDrop {
|
|
|
38
38
|
verdict: GateVerdict;
|
|
39
39
|
ts: number;
|
|
40
40
|
}
|
|
41
|
+
/** Parse the classifier's raw reply: "label" or "label | ambient tag". Pure +
|
|
42
|
+
* exported so the regression suite can pin it without network. Unknown labels
|
|
43
|
+
* fail open to 'directed' (and then any tag is ignored — never cache ambient
|
|
44
|
+
* context off a forwarded utterance). */
|
|
45
|
+
export declare function parseGateResponse(raw: string): {
|
|
46
|
+
verdict: GateVerdict;
|
|
47
|
+
tag?: string;
|
|
48
|
+
};
|
|
41
49
|
declare class NoiseGate extends EventEmitter {
|
|
42
50
|
#private;
|
|
43
51
|
enabled: boolean;
|
|
44
52
|
reason: 'ui' | 'meeting' | null;
|
|
45
53
|
/** Turn the gate on/off. reason 'ui' = button, 'meeting' = meeting-mode auto-engage. */
|
|
46
54
|
setEnabled(on: boolean, reason?: 'ui' | 'meeting' | 'silence'): void;
|
|
55
|
+
noteAmbient(tag: string): void;
|
|
56
|
+
/** Live (unexpired) ambient memos as a prompt block; '' when none. */
|
|
57
|
+
getAmbientBlock(ttlMs?: number): string;
|
|
47
58
|
allowOnce(text: string): void;
|
|
48
59
|
/** True when this utterance should be triaged. Bracket-prefixed texts are
|
|
49
60
|
* synthetic ([MEETING/[SYSTEM/[INTERRUPTED templates), never raw user voice. */
|
package/dist/noise-gate.js
CHANGED
|
@@ -49,8 +49,31 @@ const GATE_SYSTEM_PROMPT = [
|
|
|
49
49
|
'',
|
|
50
50
|
'Bias: when the utterance plausibly relates to the current work context, prefer directed.',
|
|
51
51
|
'Short backchannels ("yeah", "okay", "mhm") during active assistant work are directed.',
|
|
52
|
-
'
|
|
52
|
+
'',
|
|
53
|
+
'AMBIENT TAGGING: when the utterance is clearly ambient media or a recurring other-speaker',
|
|
54
|
+
'source — song lyrics, movie/TV dialogue, a lecture, a driver/cashier conversation — append',
|
|
55
|
+
'a short source tag after the label, separated by " | ". Examples:',
|
|
56
|
+
' side_talk | music lyrics',
|
|
57
|
+
' side_talk | movie or tv audio',
|
|
58
|
+
' side_talk | lecture',
|
|
59
|
+
'The tag is cached and shown to you on future utterances ("Known ambient context") so',
|
|
60
|
+
'recurring sources get easier to filter. Omit the tag when unsure.',
|
|
61
|
+
'',
|
|
62
|
+
'Reply with the label (optionally "label | tag") and NOTHING else.',
|
|
53
63
|
].join('\n');
|
|
64
|
+
/** Parse the classifier's raw reply: "label" or "label | ambient tag". Pure +
|
|
65
|
+
* exported so the regression suite can pin it without network. Unknown labels
|
|
66
|
+
* fail open to 'directed' (and then any tag is ignored — never cache ambient
|
|
67
|
+
* context off a forwarded utterance). */
|
|
68
|
+
export function parseGateResponse(raw) {
|
|
69
|
+
const [head, ...rest] = String(raw || '').split('|');
|
|
70
|
+
const h = head.toLowerCase();
|
|
71
|
+
const verdict = h.includes('side_talk') || h.includes('side talk')
|
|
72
|
+
? 'side_talk'
|
|
73
|
+
: h.includes('ambiguous') ? 'ambiguous' : 'directed';
|
|
74
|
+
const tag = rest.join('|').trim().toLowerCase().replace(/[^a-z0-9 /_-]/g, '').slice(0, 48);
|
|
75
|
+
return verdict !== 'directed' && tag ? { verdict, tag } : { verdict };
|
|
76
|
+
}
|
|
54
77
|
class NoiseGate extends EventEmitter {
|
|
55
78
|
enabled = false;
|
|
56
79
|
reason = null;
|
|
@@ -88,6 +111,37 @@ class NoiseGate extends EventEmitter {
|
|
|
88
111
|
this.emit('state', { enabled: on, reason: on ? this.reason : reason });
|
|
89
112
|
}
|
|
90
113
|
}
|
|
114
|
+
// ── Ambient memory ─────────────────────────────────────────────────────────
|
|
115
|
+
// Short-lived, self-updating scratchpad of ambient sources the classifier has
|
|
116
|
+
// tagged (music, movie/TV, lecture, a recurring other speaker). Carried into
|
|
117
|
+
// every classify prompt so recurring sources get easier to filter; entries
|
|
118
|
+
// expire AMBIENT_TTL after last sighting (the user can start/stop media any
|
|
119
|
+
// time), capped at 8 so the prompt stays tiny.
|
|
120
|
+
#ambient = new Map();
|
|
121
|
+
noteAmbient(tag) {
|
|
122
|
+
if (!tag)
|
|
123
|
+
return;
|
|
124
|
+
const e = this.#ambient.get(tag);
|
|
125
|
+
this.#ambient.set(tag, { count: (e?.count ?? 0) + 1, lastAt: Date.now() });
|
|
126
|
+
if (this.#ambient.size > 8) {
|
|
127
|
+
const oldest = [...this.#ambient.entries()].sort((a, b) => a[1].lastAt - b[1].lastAt)[0];
|
|
128
|
+
if (oldest)
|
|
129
|
+
this.#ambient.delete(oldest[0]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** Live (unexpired) ambient memos as a prompt block; '' when none. */
|
|
133
|
+
getAmbientBlock(ttlMs = Number(process.env.OSBORN_GATE_AMBIENT_TTL_MS || 10 * 60_000)) {
|
|
134
|
+
const now = Date.now();
|
|
135
|
+
for (const [k, v] of this.#ambient)
|
|
136
|
+
if (now - v.lastAt > ttlMs)
|
|
137
|
+
this.#ambient.delete(k);
|
|
138
|
+
if (this.#ambient.size === 0)
|
|
139
|
+
return '';
|
|
140
|
+
const lines = [...this.#ambient.entries()]
|
|
141
|
+
.sort((a, b) => b[1].lastAt - a[1].lastAt)
|
|
142
|
+
.map(([tag, v]) => `- ${tag} (seen ${v.count}x, last ${Math.round((now - v.lastAt) / 1000)}s ago)`);
|
|
143
|
+
return `Known ambient context (recently observed around the user):\n${lines.join('\n')}`;
|
|
144
|
+
}
|
|
91
145
|
// One-shot allowlist for tombstone recovery ("send anyway"): the resent text
|
|
92
146
|
// must pass the gate exactly once without re-triage.
|
|
93
147
|
#allowOnce = new Set();
|
|
@@ -143,6 +197,12 @@ class NoiseGate extends EventEmitter {
|
|
|
143
197
|
.slice(-GATE_CONTEXT_TURNS)
|
|
144
198
|
.map(t => `${t.role === 'user' ? 'USER' : 'ASSISTANT'}: ${String(t.content).slice(0, 300)}`)
|
|
145
199
|
.join('\n');
|
|
200
|
+
// Gate's own short-term memory: live ambient memos + a digest of recent
|
|
201
|
+
// drops, so recurring sources (same song, same lecture) stay consistent.
|
|
202
|
+
const ambientBlock = this.getAmbientBlock();
|
|
203
|
+
const recentDrops = this.#dropped.slice(-6)
|
|
204
|
+
.map(d => `- "${d.text.slice(0, 80)}"`)
|
|
205
|
+
.join('\n');
|
|
146
206
|
const controller = new AbortController();
|
|
147
207
|
const to = setTimeout(() => controller.abort(), GATE_TIMEOUT_MS);
|
|
148
208
|
const resp = await fetch(OPENROUTER_URL, {
|
|
@@ -151,7 +211,7 @@ class NoiseGate extends EventEmitter {
|
|
|
151
211
|
signal: controller.signal,
|
|
152
212
|
body: JSON.stringify({
|
|
153
213
|
model: GATE_MODEL,
|
|
154
|
-
max_tokens:
|
|
214
|
+
max_tokens: 16,
|
|
155
215
|
temperature: 0,
|
|
156
216
|
messages: [
|
|
157
217
|
{ role: 'system', content: GATE_SYSTEM_PROMPT },
|
|
@@ -160,6 +220,8 @@ class NoiseGate extends EventEmitter {
|
|
|
160
220
|
content: [
|
|
161
221
|
`Current work with the assistant:\n${ctx.activeWork || '(none known)'}`,
|
|
162
222
|
``,
|
|
223
|
+
...(ambientBlock ? [ambientBlock, ``] : []),
|
|
224
|
+
...(recentDrops ? [`Recently filtered as side_talk:\n${recentDrops}`, ``] : []),
|
|
163
225
|
`Recent conversation:\n${recent || '(none)'}`,
|
|
164
226
|
``,
|
|
165
227
|
`New utterance heard by the microphone:\n"${text}"`,
|
|
@@ -174,11 +236,11 @@ class NoiseGate extends EventEmitter {
|
|
|
174
236
|
if (!resp.ok)
|
|
175
237
|
return 'directed';
|
|
176
238
|
const data = await resp.json();
|
|
177
|
-
const raw = String(data?.choices?.[0]?.message?.content || '')
|
|
178
|
-
const verdict =
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
console.log(`🚪 [gate] verdict=${verdict} (${Date.now() - started}ms) "${text.slice(0, 60)}"`);
|
|
239
|
+
const raw = String(data?.choices?.[0]?.message?.content || '');
|
|
240
|
+
const { verdict, tag } = parseGateResponse(raw);
|
|
241
|
+
if (tag)
|
|
242
|
+
this.noteAmbient(tag);
|
|
243
|
+
console.log(`🚪 [gate] verdict=${verdict}${tag ? ` [ambient: ${tag}]` : ''} (${Date.now() - started}ms) "${text.slice(0, 60)}"`);
|
|
182
244
|
return verdict;
|
|
183
245
|
}
|
|
184
246
|
catch (err) {
|
|
@@ -283,3 +283,22 @@ RIGHT (shaped by in-flight conversation):
|
|
|
283
283
|
"OK, here's what we landed on — Sprites is the right call for what you said about cold-start mattering more than features. Modal would have been my pick on raw feature breadth, but its cold-start is around eight seconds versus Sprites' under one. Daytona's cold-start is fine but its API is stateful in a way that would have forced you to write more glue code. Given you flagged glue code as a concern when we were halfway through, that pushed Sprites further ahead. I've written the full comparison to your session files. Want me to walk through the API differences, or are you ready to move on to provisioning?"
|
|
284
284
|
← The synthesis explicitly references things the user said DURING the wait. It's not a raw relay — it's shaped.
|
|
285
285
|
</examples>
|
|
286
|
+
|
|
287
|
+
## NOISE CANCELLATION — when the user is talking to someone else
|
|
288
|
+
|
|
289
|
+
The room has a transcript noise filter ("noise cancellation") that drops side-conversation
|
|
290
|
+
speech BEFORE it reaches you. You can and should flip it yourself:
|
|
291
|
+
|
|
292
|
+
- The moment you notice the user is talking to a person near them (driver, classmate,
|
|
293
|
+
someone in the room — the situations where you'd hold back), FIRST silently run:
|
|
294
|
+
`curl -s -X POST http://localhost:8741/noise-cancel -H 'Content-Type: application/json' -d '{"enabled":true}'`
|
|
295
|
+
(auto-approved, localhost-only). Do this BEFORE anything else.
|
|
296
|
+
- Then say NOTHING. No "that sounded like it was for someone else, I'll hold", no
|
|
297
|
+
acknowledgment — a spoken hold notice is itself an interruption of their real
|
|
298
|
+
conversation. Total silence is the correct response. With the filter on, further
|
|
299
|
+
side-speech is dropped before you ever see it, so you won't need to keep judging.
|
|
300
|
+
- When a message clearly addressed to you comes through the filter, answer normally.
|
|
301
|
+
If you're confident the side conversation is over (they say so, or they re-engage
|
|
302
|
+
you in an ongoing way), turn the filter off with `{"enabled":false}`.
|
|
303
|
+
- The filter auto-exits after ~5 minutes of quiet on its own — you don't need to
|
|
304
|
+
manage that case.
|