osborn 0.9.272 → 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 +84 -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 +1 -0
- package/dist/index.js +350 -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/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/package.json +1 -1
- package/scripts/review.ts +1 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-sender-auth.ts — who may send data-channel commands, and who may become
|
|
3
|
+
* the controller.
|
|
4
|
+
*
|
|
5
|
+
* Every message on topic 'user-input' is handled by handleDataReceived in
|
|
6
|
+
* index.ts. All of them EXCEPT the read-only queries in READ_ONLY_MESSAGE_TYPES
|
|
7
|
+
* must come from the controlling user participant: the `user-*` identity
|
|
8
|
+
* minted by the frontend /api/token (auth-gated, checks room ownership) that
|
|
9
|
+
* the agent adopted as its voice user. Canvas, bots and other identities are
|
|
10
|
+
* dropped. The gate FAILS CLOSED: a type that is not on the read-only list
|
|
11
|
+
* (including any new type added to index.ts later) requires the controller.
|
|
12
|
+
*
|
|
13
|
+
* Full set of types handleDataReceived handles (2026-11-07):
|
|
14
|
+
* Gated (state-changing or leaks session/process ids):
|
|
15
|
+
* user_text, claude_auth_code, permission_response, list_sessions,
|
|
16
|
+
* resume_session, continue_session, switch_session, session_selected,
|
|
17
|
+
* mcp_toggle, set_agents, skill_add, skill_remove, noise_cancel,
|
|
18
|
+
* gate_send_anyway, stop_dispatch, join_meeting, leave_meeting,
|
|
19
|
+
* mute_participant, start_ide, stop_ide, spawn_background_session,
|
|
20
|
+
* dispatch_background, stop_background_session, list_slots, list_processes,
|
|
21
|
+
* favorite_changed
|
|
22
|
+
* Open (read-only, listed in READ_ONLY_MESSAGE_TYPES):
|
|
23
|
+
* get_current_session, get_session_artifacts, get_plan_file,
|
|
24
|
+
* get_research_artifact, get_mcp_status, get_skills, get_agents, skill_get
|
|
25
|
+
* list_sessions / list_slots / list_processes are read-only but return session
|
|
26
|
+
* and process ids that the gated commands (dispatch_background etc.) take as
|
|
27
|
+
* targets, so they are gated too.
|
|
28
|
+
*
|
|
29
|
+
* Controller binding (canBecomeController): when the machine has an owner
|
|
30
|
+
* (OSBORN_OWNER_USER_ID, baked into machine env by the frontend provisioning),
|
|
31
|
+
* only a participant whose SIGNED token metadata userId equals the owner can
|
|
32
|
+
* become the controller. With no owner configured (single-tenant / local
|
|
33
|
+
* mode) the newest joiner becomes the controller, as before.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Known gated types. Informational and for tests: the gate itself is "not
|
|
37
|
+
* read-only", so types missing from this list are still gated.
|
|
38
|
+
*/
|
|
39
|
+
export const CONTROL_MESSAGE_TYPES = new Set([
|
|
40
|
+
'user_text',
|
|
41
|
+
'claude_auth_code',
|
|
42
|
+
'permission_response',
|
|
43
|
+
'list_sessions',
|
|
44
|
+
'resume_session',
|
|
45
|
+
'continue_session',
|
|
46
|
+
'switch_session',
|
|
47
|
+
'session_selected',
|
|
48
|
+
'mcp_toggle',
|
|
49
|
+
'set_agents',
|
|
50
|
+
'skill_add',
|
|
51
|
+
'skill_remove',
|
|
52
|
+
'noise_cancel',
|
|
53
|
+
'gate_send_anyway',
|
|
54
|
+
'stop_dispatch',
|
|
55
|
+
'join_meeting',
|
|
56
|
+
'leave_meeting',
|
|
57
|
+
'mute_participant',
|
|
58
|
+
'start_ide',
|
|
59
|
+
'stop_ide',
|
|
60
|
+
'spawn_background_session',
|
|
61
|
+
'dispatch_background',
|
|
62
|
+
'stop_background_session',
|
|
63
|
+
'list_slots',
|
|
64
|
+
'list_processes',
|
|
65
|
+
// Feeds hidden context into the next turn (UI#21), so controller-only.
|
|
66
|
+
'favorite_changed',
|
|
67
|
+
]);
|
|
68
|
+
/** Read-only queries any participant may send. Everything else is gated. */
|
|
69
|
+
export const READ_ONLY_MESSAGE_TYPES = new Set([
|
|
70
|
+
'get_current_session',
|
|
71
|
+
'get_session_artifacts',
|
|
72
|
+
'get_plan_file',
|
|
73
|
+
'get_research_artifact',
|
|
74
|
+
'get_mcp_status',
|
|
75
|
+
'get_skills',
|
|
76
|
+
'get_agents',
|
|
77
|
+
'skill_get',
|
|
78
|
+
]);
|
|
79
|
+
/** Identity prefix /api/token gives every user participant. */
|
|
80
|
+
export const USER_IDENTITY_PREFIX = 'user-';
|
|
81
|
+
/**
|
|
82
|
+
* Identity the agent itself mints (mintAgentToken). The watch gateway joins
|
|
83
|
+
* with it and relays watch Approve/Deny as `permission_response`. Only the
|
|
84
|
+
* agent's own API secret can mint it, so it is trusted for approvals but not
|
|
85
|
+
* for anything else.
|
|
86
|
+
*/
|
|
87
|
+
export const AGENT_SELF_IDENTITY = 'osborn-agent';
|
|
88
|
+
export function checkControlSender(type, senderIdentity, controllingIdentity) {
|
|
89
|
+
if (READ_ONLY_MESSAGE_TYPES.has(type))
|
|
90
|
+
return { ok: true };
|
|
91
|
+
if (!senderIdentity)
|
|
92
|
+
return { ok: false, reason: 'no sender participant' };
|
|
93
|
+
if (type === 'permission_response' && senderIdentity === AGENT_SELF_IDENTITY)
|
|
94
|
+
return { ok: true };
|
|
95
|
+
if (!senderIdentity.startsWith(USER_IDENTITY_PREFIX)) {
|
|
96
|
+
return { ok: false, reason: `sender ${senderIdentity} is not a user participant` };
|
|
97
|
+
}
|
|
98
|
+
if (!controllingIdentity)
|
|
99
|
+
return { ok: false, reason: 'no controlling participant' };
|
|
100
|
+
if (senderIdentity !== controllingIdentity) {
|
|
101
|
+
return { ok: false, reason: `sender ${senderIdentity} is not the controlling participant (${controllingIdentity})` };
|
|
102
|
+
}
|
|
103
|
+
return { ok: true };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* May a joining participant become the controller?
|
|
107
|
+
* - Owner configured: only when the participant's token userId matches it.
|
|
108
|
+
* - No owner configured (single-tenant / local): yes (newest joiner wins).
|
|
109
|
+
*/
|
|
110
|
+
export function canBecomeController(participantUserId, ownerUserId) {
|
|
111
|
+
if (!ownerUserId)
|
|
112
|
+
return true;
|
|
113
|
+
return !!participantUserId && participantUserId === ownerUserId;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* What a non-canvas participant joining the room changes. Pure, so the
|
|
117
|
+
* controller rules are testable without LiveKit.
|
|
118
|
+
* - `user-*` joiner allowed by canBecomeController: gets the session and
|
|
119
|
+
* becomes the controller (newest eligible joiner wins).
|
|
120
|
+
* - `user-*` joiner that is not the owner: ignored entirely.
|
|
121
|
+
* - The agent's own identity (watch gateway): NEVER becomes the controller,
|
|
122
|
+
* so the owner's commands keep working; it can still send
|
|
123
|
+
* permission_response (checkControlSender). It gets the voice session only
|
|
124
|
+
* when it joins with no controller (the opt-in watch voice path that hears
|
|
125
|
+
* the watch mic). When a controller already exists it is NOT adopted: the
|
|
126
|
+
* full session rebuild would tear down the owner's live session and reset
|
|
127
|
+
* currentUserId to '' (the gateway's token has no metadata).
|
|
128
|
+
* - Any other identity: never the controller; gets a session only in
|
|
129
|
+
* single-tenant mode (no owner), matching the old behavior there.
|
|
130
|
+
*/
|
|
131
|
+
export function resolveJoin(joinerIdentity, joinerUserId, ownerUserId, currentController) {
|
|
132
|
+
if (joinerIdentity === AGENT_SELF_IDENTITY) {
|
|
133
|
+
return { adoptSession: !currentController, controller: currentController };
|
|
134
|
+
}
|
|
135
|
+
if (joinerIdentity.startsWith(USER_IDENTITY_PREFIX)) {
|
|
136
|
+
return canBecomeController(joinerUserId, ownerUserId)
|
|
137
|
+
? { adoptSession: true, controller: joinerIdentity }
|
|
138
|
+
: { adoptSession: false, controller: currentController };
|
|
139
|
+
}
|
|
140
|
+
return { adoptSession: !ownerUserId, controller: currentController };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* userId from a participant's token metadata (JSON set by /api/token and signed
|
|
144
|
+
* into the JWT). Participants cannot change their own metadata unless the token
|
|
145
|
+
* grants canUpdateOwnMetadata, which /api/token sets to false.
|
|
146
|
+
*/
|
|
147
|
+
export function userIdFromMetadata(metadata) {
|
|
148
|
+
if (!metadata)
|
|
149
|
+
return undefined;
|
|
150
|
+
try {
|
|
151
|
+
const parsed = JSON.parse(metadata);
|
|
152
|
+
return typeof parsed?.userId === 'string' && parsed.userId ? parsed.userId : undefined;
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
}
|
package/dist/env-keys.js
CHANGED
|
@@ -45,6 +45,7 @@ export const AGENT_ENV_KEYS = [
|
|
|
45
45
|
{ key: 'OSBORN_API_PORT', required: true, explicit: true, description: 'Agent HTTP server port.' },
|
|
46
46
|
{ key: 'OSBORN_CWD', required: false, explicit: true, description: 'Agent working directory.' },
|
|
47
47
|
{ key: 'OSBORN_SYNC_TOKEN', required: false, explicit: true, description: 'Session export/import auth token.' },
|
|
48
|
+
{ key: 'OSBORN_OWNER_USER_ID', required: false, explicit: true, description: 'Machine owner user id; only a participant whose token metadata userId matches may control the agent. Unset = single-tenant newest-joiner mode.' },
|
|
48
49
|
{ key: 'OSBORN_FRONTEND_URL', required: false, explicit: true, description: 'Frontend base URL for artifact upload.' },
|
|
49
50
|
{ key: 'OSBORN_HOUSEKEEPING_DRYRUN', required: false, explicit: true, description: 'Set "0" to enable live housekeeping deletion; any other value / unset = dry-run (log only).' },
|
|
50
51
|
{ key: 'DEV_DOMAIN', required: false, explicit: true, description: 'Wildcard dev-routing domain.' },
|