osborn 0.9.290 → 0.9.292

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.
Files changed (86) hide show
  1. package/.claude/skills/browser-apply/SKILL.md +5 -4
  2. package/.claude/skills/browser-apply/candidate.example.env +4 -1
  3. package/.claude/skills/browser-apply/fill.mjs +13 -2
  4. package/.claude/skills/meetings/SKILL.md +26 -7
  5. package/.env.example +6 -0
  6. package/dist/agent-store.d.ts +6 -0
  7. package/dist/agent-store.js +36 -6
  8. package/dist/approval-policy.d.ts +99 -0
  9. package/dist/approval-policy.js +196 -0
  10. package/dist/claude-llm.d.ts +6 -2
  11. package/dist/claude-llm.js +68 -20
  12. package/dist/config.d.ts +12 -16
  13. package/dist/config.js +75 -21
  14. package/dist/content/compaction-lens-worker.d.ts +5 -0
  15. package/dist/content/compaction-lens-worker.js +78 -7
  16. package/dist/content/content-llm.d.ts +14 -3
  17. package/dist/content/content-llm.js +33 -142
  18. package/dist/content/lens-db.d.ts +16 -5
  19. package/dist/content/lens-db.js +58 -11
  20. package/dist/content/lens-ingest.d.ts +1 -0
  21. package/dist/content/lens-ingest.js +1 -1
  22. package/dist/content/lens-launch.d.ts +42 -1
  23. package/dist/content/lens-launch.js +202 -40
  24. package/dist/content/lens-library-digest.d.ts +85 -0
  25. package/dist/content/lens-library-digest.js +305 -0
  26. package/dist/content/lens-library-index.d.ts +14 -3
  27. package/dist/content/lens-library-index.js +35 -8
  28. package/dist/content/lens-library-select.d.ts +1 -1
  29. package/dist/content/lens-library-select.js +1 -1
  30. package/dist/content/lens-library-sweep.d.ts +36 -0
  31. package/dist/content/lens-library-sweep.js +331 -0
  32. package/dist/content/lens-library.d.ts +29 -0
  33. package/dist/content/lens-library.js +130 -20
  34. package/dist/content/lens-model.d.ts +4 -0
  35. package/dist/content/lens-model.js +5 -0
  36. package/dist/content/lens-paths.d.ts +72 -0
  37. package/dist/content/lens-paths.js +248 -5
  38. package/dist/content/period-run.js +2 -2
  39. package/dist/content/secret-rules.d.ts +51 -0
  40. package/dist/content/secret-rules.js +185 -0
  41. package/dist/content/transcript-sanitizer.d.ts +1 -41
  42. package/dist/content/transcript-sanitizer.js +4 -171
  43. package/dist/data-sender-auth.d.ts +112 -3
  44. package/dist/data-sender-auth.js +165 -39
  45. package/dist/env-keys.d.ts +10 -2
  46. package/dist/env-keys.js +26 -5
  47. package/dist/index.js +616 -109
  48. package/dist/phone-code.d.ts +76 -0
  49. package/dist/phone-code.js +124 -0
  50. package/dist/phone-voice-actions.d.ts +132 -0
  51. package/dist/phone-voice-actions.js +223 -0
  52. package/dist/pipeline-direct-llm.d.ts +8 -1
  53. package/dist/pipeline-direct-llm.js +13 -1
  54. package/dist/prompts/library-digest.md +11 -0
  55. package/dist/prompts.d.ts +4 -0
  56. package/dist/prompts.js +6 -2
  57. package/dist/pushover.d.ts +2 -1
  58. package/dist/pushover.js +7 -6
  59. package/dist/risk-tier.d.ts +14 -0
  60. package/dist/risk-tier.js +140 -0
  61. package/dist/session-store.d.ts +1 -0
  62. package/dist/session-store.js +3 -2
  63. package/dist/session-switch.d.ts +22 -7
  64. package/dist/session-switch.js +58 -24
  65. package/dist/steward-verdict.d.ts +16 -3
  66. package/dist/steward-verdict.js +37 -18
  67. package/dist/watch-gateway.js +3 -1
  68. package/package.json +1 -1
  69. package/dist/bridge-llm.d.ts +0 -22
  70. package/dist/bridge-llm.js +0 -39
  71. package/dist/codex-handler.d.ts +0 -38
  72. package/dist/codex-handler.js +0 -83
  73. package/dist/codex-llm.d.ts +0 -40
  74. package/dist/codex-llm.js +0 -144
  75. package/dist/fast-brain.d.ts +0 -176
  76. package/dist/fast-brain.js +0 -1887
  77. package/dist/index-3-2-26-legacy.d.ts +0 -1
  78. package/dist/index-3-2-26-legacy.js +0 -2233
  79. package/dist/leagcyprompts2.d.ts +0 -0
  80. package/dist/leagcyprompts2.js +0 -573
  81. package/dist/prompts-2-25-26.d.ts +0 -0
  82. package/dist/prompts-2-25-26.js +0 -518
  83. package/dist/prompts-3-2-26.d.ts +0 -78
  84. package/dist/prompts-3-2-26.js +0 -1319
  85. package/dist/summary-index.d.ts +0 -90
  86. package/dist/summary-index.js +0 -585
@@ -35,177 +35,10 @@
35
35
  */
36
36
  import { readFileSync } from 'node:fs';
37
37
  import { stripInjected } from './lens-strip.js';
38
- /**
39
- * Order matters. Specific, high-confidence token shapes run FIRST so their KIND
40
- * label wins; the broad `*_API_KEY=/_SECRET=/_TOKEN=` assignment rule runs LAST
41
- * to catch any leftover generic value assignment (and skips already-redacted
42
- * values via a negative lookahead).
43
- */
44
- export const SECRET_RULES = [
45
- // npm registry auth line (contains an npm_ token; redact the whole value).
46
- {
47
- kind: 'NPM-AUTH',
48
- re: /\/\/registry\.npmjs\.org\/:_authToken=[^\s"'`]+/g,
49
- replace: '//registry.npmjs.org/:_authToken=[REDACTED-NPM-AUTH]',
50
- },
51
- // npm granular/automation token: npm_ + 36 base62 chars.
52
- { kind: 'NPM-TOKEN', re: /npm_[A-Za-z0-9]{36}/g, replace: '[REDACTED-NPM-TOKEN]' },
53
- // Fly.io macaroon tokens. A real token is a COMMA-SEPARATED list of
54
- // segments ("FlyV1 fm2_<a>,fm2_<b>,fm2_<c>"); redact the WHOLE list, not just
55
- // the first segment (the segment char class has no comma, so the old rule
56
- // stopped at the first "," and leaked the rest).
57
- {
58
- kind: 'FLY-TOKEN',
59
- re: /FlyV1\s+fm[12]_[A-Za-z0-9/+_=-]+(?:\s*,\s*fm[12]_[A-Za-z0-9/+_=-]+)*/g,
60
- replace: '[REDACTED-FLY-TOKEN]',
61
- },
62
- // Standalone Fly macaroon segment without the FlyV1 prefix (floor skips bare
63
- // "fm2_" word mentions).
64
- {
65
- kind: 'FLY-TOKEN',
66
- re: /(?<![A-Za-z0-9])fm[12]_[A-Za-z0-9/+_=-]{20,}/g,
67
- replace: '[REDACTED-FLY-TOKEN]',
68
- },
69
- // Fly GraphQL fo1_ token (floor skips bare "fo1_" word mentions).
70
- { kind: 'FLY-TOKEN', re: /fo1_[A-Za-z0-9/+_=-]{20,}/g, replace: '[REDACTED-FLY-TOKEN]' },
71
- // Supabase personal access token (real = 40 hex; floor skips "sbp_/" prose).
72
- { kind: 'SUPABASE-PAT', re: /sbp_[A-Za-z0-9]{20,}/g, replace: '[REDACTED-SUPABASE-PAT]' },
73
- // PEM private key blocks (multiline). Terminated block first, then a
74
- // truncated/unterminated block (header + base64 body, literal "\n" allowed).
75
- {
76
- kind: 'PEM-PRIVATE-KEY',
77
- re: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
78
- replace: '[REDACTED-PEM-PRIVATE-KEY]',
79
- },
80
- {
81
- kind: 'PEM-PRIVATE-KEY',
82
- re: /-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\sA-Za-z0-9+/=]|\\n)*/g,
83
- replace: '[REDACTED-PEM-PRIVATE-KEY]',
84
- },
85
- // Anthropic keys: sk-ant-api03-…, sk-ant-oat01-… (MUST run before OPENAI-KEY).
86
- { kind: 'ANTHROPIC-KEY', re: /sk-ant-[A-Za-z0-9_-]{20,}/g, replace: '[REDACTED-ANTHROPIC-KEY]' },
87
- // OpenRouter / OpenAI prefixed keys whose body contains _ or - (sk-or-v1-, sk-proj-, sk-svcacct-).
88
- {
89
- kind: 'OPENAI-KEY',
90
- re: /\bsk-(?:or-v1-|or-|proj-|svcacct-)[A-Za-z0-9_-]{20,}/g,
91
- replace: '[REDACTED-OPENAI-KEY]',
92
- },
93
- // OpenAI / OpenRouter keys (sk-, sk-or-, sk-proj-). Floor skips "task-budgets".
94
- { kind: 'OPENAI-KEY', re: /sk-(?:or-|proj-)?[A-Za-z0-9]{20,}/g, replace: '[REDACTED-OPENAI-KEY]' },
95
- // GitHub tokens: ghp_/gho_/ghu_/ghs_/ghr_ (+ fine-grained github_pat_).
96
- { kind: 'GITHUB-TOKEN', re: /\bgh[pousr]_[A-Za-z0-9]{30,}/g, replace: '[REDACTED-GITHUB-TOKEN]' },
97
- { kind: 'GITHUB-TOKEN', re: /\bgithub_pat_[A-Za-z0-9_]{30,}/g, replace: '[REDACTED-GITHUB-TOKEN]' },
98
- // Google API key.
99
- { kind: 'GOOGLE-API-KEY', re: /AIza[0-9A-Za-z_-]{35}/g, replace: '[REDACTED-GOOGLE-API-KEY]' },
100
- // Fireworks AI key: fw_ + ~24 base62 chars. Floor of 20 pure alphanumerics
101
- // skips snake_case identifiers like "fw_key" / "fw_test_script".
102
- {
103
- kind: 'FIREWORKS-KEY',
104
- re: /(?<![A-Za-z0-9_])fw_[A-Za-z0-9]{20,}/g,
105
- replace: '[REDACTED-FIREWORKS-KEY]',
106
- },
107
- // Soniox project key: snx_proj_ + key body (floor skips bare prefix mentions).
108
- {
109
- kind: 'SONIOX-KEY',
110
- re: /(?<![A-Za-z0-9_])snx_proj_[A-Za-z0-9_-]{20,}/g,
111
- replace: '[REDACTED-SONIOX-KEY]',
112
- },
113
- // Bare Soniox key (snx_<body>, no proj_ segment); the 16-char floor skips prefix mentions.
114
- {
115
- kind: 'SONIOX-KEY',
116
- re: /(?<![A-Za-z0-9_])snx_(?!proj_)[A-Za-z0-9]{16,}/g,
117
- replace: '[REDACTED-SONIOX-KEY]',
118
- },
119
- // JWTs (header.payload.signature, base64url).
120
- {
121
- kind: 'JWT',
122
- re: /eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
123
- replace: '[REDACTED-JWT]',
124
- },
125
- // API-key headers: x-api-key, x-goog-api-key (Gemini REST), and generic api-key
126
- // (Azure etc.) — curl -H, JSON headers, raw HTTP. Keeps the header name, masks
127
- // the value. Floor of 8 skips prose like "x-api-key: header".
128
- {
129
- kind: 'X-API-KEY',
130
- // (?!\$) skips $VAR / ${var} references — not secrets, just noise.
131
- re: /(\b(?:x-goog-|x-)?api-key["'`]?\s*[:=]\s*["'`]?)(?!\[REDACTED|\$)[^\s"'`,;}]{8,}/gi,
132
- replace: '$1[REDACTED-API-KEY]',
133
- },
134
- // Authorization header (optional Bearer/Basic/Token scheme). Keeps name +
135
- // scheme, masks the credential.
136
- {
137
- kind: 'AUTH-HEADER',
138
- re: /(Authorization["'`]?\s*:\s*["'`]?(?:(?:Bearer|Basic|Token)\s+)?)(?!\[REDACTED|\$)[^\s"'`,;}]{8,}/gi,
139
- replace: '$1[REDACTED-AUTH]',
140
- },
141
- // Slack tokens xoxb-/xoxa-/xoxp-/xoxr-/xoxs- (floor skips "xox/" prose).
142
- { kind: 'SLACK-TOKEN', re: /xox[baprs]-[A-Za-z0-9-]{10,}/g, replace: '[REDACTED-SLACK-TOKEN]' },
143
- // AWS access key id.
144
- { kind: 'AWS-KEY', re: /\bAKIA[0-9A-Z]{16}\b/g, replace: '[REDACTED-AWS-KEY]' },
145
- // Generic Bearer token (keep the word "Bearer"; floor skips "Bearer patterns").
146
- { kind: 'BEARER', re: /Bearer\s+[A-Za-z0-9._\-+/=]{20,}/g, replace: 'Bearer [REDACTED-TOKEN]' },
147
- // Generic *_API_KEY= / *_SECRET= / *_TOKEN= / *_ACCESS_KEY= / *_PASSWORD= assignments.
148
- // Keeps NAME= and any surrounding quote; masks only the value. Skips values
149
- // already replaced by a specific rule above (negative lookahead on [REDACTED).
150
- {
151
- kind: 'ENV-SECRET',
152
- re: /\b([A-Za-z0-9_]*(?:API_KEY|SECRET|ACCESS_KEY|PASSWORD|TOKEN))(\s*=\s*)(["'`“”]?)(?!\[REDACTED)([^\s"'`“”]{6,})\3/g,
153
- replace: '$1$2$3[REDACTED-ENV-SECRET]$3',
154
- },
155
- ];
156
- /**
157
- * Conservative high-entropy fallback, applied to ASSISTANT records only (the
158
- * assistant echoes tool output, so unknown-vendor keys can leak there). Matches
159
- * a standalone 32+ char token of [A-Za-z0-9_+=-] that has at least one
160
- * uppercase, one lowercase, and four digits. Mixed-case + digit floor skips
161
- * git SHAs / sha256 hex / UUIDs (lowercase) and CONSTANT_NAMES (no lowercase);
162
- * the "/" and "." boundaries skip paths and dotted identifiers. Measured 0 hits
163
- * across 2508 real assistant records in session c97588f4 (no false positives).
164
- */
165
- export const HIGH_ENTROPY_RULE = {
166
- kind: 'HIGH-ENTROPY',
167
- re: /(?<![A-Za-z0-9_+=\/.\[-])(?=[A-Za-z0-9_+=-]*[A-Z])(?=[A-Za-z0-9_+=-]*[a-z])(?=(?:[A-Za-z0-9_+=-]*\d){4})[A-Za-z0-9_+=-]{32,}(?![A-Za-z0-9_+=\/.\]-])/g,
168
- replace: '[REDACTED-HIGH-ENTROPY]',
169
- };
170
- function rulesFor(opts = {}) {
171
- return opts.assistant ? [...SECRET_RULES, HIGH_ENTROPY_RULE] : SECRET_RULES;
172
- }
173
- /** Mask every secret-shaped substring in `text`. Pure. */
174
- export function redactSecrets(text, opts = {}) {
175
- let out = text;
176
- for (const rule of rulesFor(opts)) {
177
- out = out.replace(rule.re, rule.replace);
178
- }
179
- return out;
180
- }
181
- /**
182
- * Detector used by the verification harness: returns the list of secret KINDs
183
- * that STILL match `text`. The authoritative "no secret survives" invariant is
184
- * `detectSecrets(output).length === 0`. This is precise (uses the same shapes
185
- * as redaction) rather than a naive substring scan, which would false-positive
186
- * on benign prose like "task-budgets" or "fo1_/sbp_/xox/Bearer patterns".
187
- */
188
- export function detectSecrets(text, opts = {}) {
189
- const hits = [];
190
- for (const rule of rulesFor(opts)) {
191
- // Fresh regex so lastIndex state never leaks between calls.
192
- const re = new RegExp(rule.re.source, rule.re.flags);
193
- let m;
194
- while ((m = re.exec(text)) !== null) {
195
- // The ENV-SECRET rule legitimately leaves a "NAME=[REDACTED-...]" shell;
196
- // that is NOT a surviving secret, so ignore matches whose value is already redacted.
197
- if (m[0].includes('[REDACTED')) {
198
- if (m.index === re.lastIndex)
199
- re.lastIndex++;
200
- continue;
201
- }
202
- hits.push({ kind: rule.kind, match: m[0] });
203
- if (m.index === re.lastIndex)
204
- re.lastIndex++;
205
- }
206
- }
207
- return hits;
208
- }
38
+ import { redactSecrets } from './secret-rules.js';
39
+ // Secret redaction lives in ./secret-rules.ts (no node imports, so the frontend's
40
+ // parity test can load it); re-exported here for existing callers.
41
+ export { redactSecrets, detectSecrets } from './secret-rules.js';
209
42
  // ============================================================================
210
43
  // VERIFIED STRIP / UNWRAP RULESET (source-independent, pure)
211
44
  // Grounded in real analysis of session c97588f4. Anchors confirmed against
@@ -20,7 +20,7 @@
20
20
  * gate_send_anyway, stop_dispatch, join_meeting, leave_meeting,
21
21
  * mute_participant, start_ide, stop_ide, spawn_background_session,
22
22
  * dispatch_background, stop_background_session, list_slots, list_processes,
23
- * favorite_changed
23
+ * favorite_changed, set_approval_mode
24
24
  * Open (read-only, listed in READ_ONLY_MESSAGE_TYPES):
25
25
  * get_current_session, get_session_artifacts, get_plan_file,
26
26
  * get_research_artifact, get_mcp_status, get_skills, skill_get, get_busy
@@ -34,6 +34,7 @@
34
34
  * become the controller. With no owner configured (single-tenant / local
35
35
  * mode) the newest joiner becomes the controller, as before.
36
36
  */
37
+ import type { PermissionAnswer } from './approval-policy.js';
37
38
  /**
38
39
  * Known gated types. Informational and for tests: the gate itself is "not
39
40
  * read-only", so types missing from this list are still gated.
@@ -41,6 +42,13 @@
41
42
  export declare const CONTROL_MESSAGE_TYPES: ReadonlySet<string>;
42
43
  /** Read-only queries any participant may send. Everything else is gated. */
43
44
  export declare const READ_ONLY_MESSAGE_TYPES: ReadonlySet<string>;
45
+ /**
46
+ * App commands a phone caller's voice actions (#367) may run through
47
+ * dispatchAction (index.ts): the same code the app's buttons use. Anything
48
+ * else is refused there. There is deliberately no HTTP route to these: the
49
+ * agent's own tools must never be able to loosen or answer its approvals.
50
+ */
51
+ export declare const PHONE_ACTION_TYPES: ReadonlySet<string>;
44
52
  /** Identity prefix /api/token gives every user participant. */
45
53
  export declare const USER_IDENTITY_PREFIX = "user-";
46
54
  /**
@@ -61,6 +69,102 @@ export declare function checkControlSender(type: string, senderIdentity: string
61
69
  * - No owner configured (single-tenant / local): yes (newest joiner wins).
62
70
  */
63
71
  export declare function canBecomeController(participantUserId: string | undefined | null, ownerUserId: string | undefined | null): boolean;
72
+ /** A room name POST /connect-room may join for a phone call. */
73
+ export declare function isPhoneRoomName(name: unknown): name is string;
74
+ /**
75
+ * Keypad answer to a pending approval on a phone call (#363): 1 allows, 2
76
+ * denies, 3 always allows (the browser's "Always"); anything else is ignored.
77
+ */
78
+ export declare function keypadAnswer(digit: string | undefined | null): PermissionAnswer | null;
79
+ /**
80
+ * Keypad approvals on a phone call. Off: caller ID alone is not proof enough
81
+ * to approve a tool, so every permission raised while a phone caller holds the
82
+ * session is denied and keypad 1 approves nothing. Turned on once a second
83
+ * factor confirms the caller.
84
+ */
85
+ export declare const PHONE_KEYPAD_APPROVALS_ENABLED = false;
86
+ /**
87
+ * Tools on a phone call. Off: a call is talk-only, so the PreToolUse hook
88
+ * (claude-llm.ts) denies every tool while a phone caller holds the session,
89
+ * including the ones allowedTools auto-approves (Bash, Read, WebFetch …),
90
+ * sub-agent dispatch and MCP tools. Turned on once a second factor confirms
91
+ * the caller.
92
+ */
93
+ export declare const PHONE_TOOLS_ENABLED = false;
94
+ /**
95
+ * Emailed code on a phone call (#362). On: a caller is not adopted (no voice
96
+ * session, no voice actions, no tools) until they type the 6-digit code the
97
+ * frontend emails to the account (phone-code.ts). Off: caller ID alone admits
98
+ * the call, as before. /connect-room tells the frontend to send the code.
99
+ */
100
+ export declare const PHONE_EMAIL_CODE_ENABLED = false;
101
+ /** What happens to a permission raised during a phone call: denied unless keypad approvals are on. */
102
+ export declare function phonePermissionPolicy(inPhoneCall: boolean, approvalsEnabled?: boolean): 'deny' | 'ask';
103
+ /**
104
+ * How a permission request is handled when its brain belongs to a phone call:
105
+ * the live call, or a brain parked after "keep working" on a call that no
106
+ * browser or app session has re-attached yet.
107
+ * - 'deny': keypad approvals off (phonePermissionPolicy) — denied at once.
108
+ * - 'hold': parked from a call — left pending for a person; never answered by
109
+ * the saved approval mode or the call's always-allow list.
110
+ * - 'normal': anything else (the live call with keypad approvals on, or no call).
111
+ */
112
+ export declare function phoneRequestRoute(s: {
113
+ liveCall: boolean;
114
+ parkedFromCall: boolean;
115
+ }, approvalsEnabled?: boolean): 'deny' | 'hold' | 'normal';
116
+ /** What happens to any tool call during a phone call: denied unless phone tools are on. */
117
+ export declare function phoneToolPolicy(inPhoneCall: boolean, toolsEnabled?: boolean): 'deny' | 'allow';
118
+ /**
119
+ * A phone call is live: the agent is in the room an authorised phone connect
120
+ * asked for AND a SIP participant is in it. False as soon as the caller leaves.
121
+ */
122
+ export declare function isPhoneCallLive(activeRoomName: string | null, phoneRoomName: string | null, sipPresent: boolean): boolean;
123
+ /**
124
+ * What POST /connect-room does with the room the agent is in.
125
+ * - 'fresh': no room, or an empty one: (tear it down and) make a new room
126
+ * (the requested phone room, else a new name).
127
+ * - 'reuse': return the occupied room: a browser connect while no phone call is
128
+ * live, or a phone connect for the room the agent is already in.
129
+ * - 'busy' (409): the room is someone else's: a phone connect while a user is in
130
+ * another room, or a browser connect during a live phone call (the caller's
131
+ * room is never handed to a browser).
132
+ */
133
+ export declare function planConnectRoom(s: {
134
+ activeRoomName: string | null;
135
+ occupied: boolean;
136
+ phoneCallLive: boolean;
137
+ phoneRoom?: string;
138
+ }): 'fresh' | 'reuse' | 'busy';
139
+ /**
140
+ * May a phone caller give this answer (keypad or a spoken yes/no, #367)? A
141
+ * deny always; an allow only once keypad approvals are on.
142
+ */
143
+ export declare function phoneAnswerAllowed(answer: PermissionAnswer, approvalsEnabled?: boolean): boolean;
144
+ /**
145
+ * Handles one keypad press (index.ts DtmfReceived). Only the SIP caller in an
146
+ * authorised phone room counts; with approvals off a 1 or 3 settles nothing
147
+ * (a 2 still denies). The answer goes to the same settle path the browser
148
+ * and watch use; the model never decides it. Returns what was done.
149
+ */
150
+ export declare function handlePhoneKeypad(press: {
151
+ sip: boolean;
152
+ inPhoneRoom: boolean;
153
+ digit: string | undefined | null;
154
+ }, settle: (answer: PermissionAnswer) => boolean, approvalsEnabled?: boolean): 'ignored' | 'approved' | 'always allowed' | 'denied' | 'no pending permission';
155
+ /** Most bytes POST /connect-room reads; its body is only `{ roomName }`. */
156
+ export declare const CONNECT_ROOM_MAX_BODY = 4096;
157
+ /**
158
+ * Reads a request body up to `max` bytes. Returns null as soon as it is
159
+ * longer (the caller answers 413) and stops reading.
160
+ */
161
+ export declare function readBodyCapped(body: AsyncIterable<Buffer | string>, max: number): Promise<string | null>;
162
+ export interface JoinOptions {
163
+ /** The joiner is a SIP (phone) participant. */
164
+ sip?: boolean;
165
+ /** The agent joined this room through an authorised phone connect (POST /connect-room with a roomName). */
166
+ phoneRoom?: boolean;
167
+ }
64
168
  export interface JoinDecision {
65
169
  /** Build the voice session for this joiner (index.ts participantConnectedHandler). */
66
170
  adoptSession: boolean;
@@ -79,11 +183,16 @@ export interface JoinDecision {
79
183
  * when it joins with no controller (the opt-in watch voice path that hears
80
184
  * the watch mic). When a controller already exists it is NOT adopted: the
81
185
  * full session rebuild would tear down the owner's live session and reset
82
- * currentUserId to '' (the gateway's token has no metadata).
186
+ * currentUserId to '' (the gateway's token has no metadata). Nor in a
187
+ * phone room, where the rebuild would take the caller's session.
188
+ * - A SIP (phone) joiner: never the controller, whatever its identity. It
189
+ * gets the voice session only in a room the agent joined through an
190
+ * authorised phone connect, and only while no controller holds the session.
191
+ * Anywhere else it is ignored, in single-tenant mode too.
83
192
  * - Any other identity: never the controller; gets a session only in
84
193
  * single-tenant mode (no owner), matching the old behavior there.
85
194
  */
86
- export declare function resolveJoin(joinerIdentity: string, joinerUserId: string | undefined | null, ownerUserId: string | undefined | null, currentController: string | null): JoinDecision;
195
+ export declare function resolveJoin(joinerIdentity: string, joinerUserId: string | undefined | null, ownerUserId: string | undefined | null, currentController: string | null, opts?: JoinOptions): JoinDecision;
87
196
  /**
88
197
  * userId from a participant's token metadata (JSON set by /api/token and signed
89
198
  * into the JWT). Participants cannot change their own metadata unless the token
@@ -1,39 +1,3 @@
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
- * cancel_session_switch,
18
- * mcp_toggle, set_agents, skill_add, skill_fork, skill_remove,
19
- * get_agent_prompt, noise_cancel,
20
- * gate_send_anyway, stop_dispatch, join_meeting, leave_meeting,
21
- * mute_participant, start_ide, stop_ide, spawn_background_session,
22
- * dispatch_background, stop_background_session, list_slots, list_processes,
23
- * favorite_changed
24
- * Open (read-only, listed in READ_ONLY_MESSAGE_TYPES):
25
- * get_current_session, get_session_artifacts, get_plan_file,
26
- * get_research_artifact, get_mcp_status, get_skills, skill_get, get_busy
27
- * list_sessions / list_slots / list_processes are read-only but return session
28
- * and process ids that the gated commands (dispatch_background etc.) take as
29
- * targets, so they are gated too.
30
- *
31
- * Controller binding (canBecomeController): when the machine has an owner
32
- * (OSBORN_OWNER_USER_ID, baked into machine env by the frontend provisioning),
33
- * only a participant whose SIGNED token metadata userId equals the owner can
34
- * become the controller. With no owner configured (single-tenant / local
35
- * mode) the newest joiner becomes the controller, as before.
36
- */
37
1
  /**
38
2
  * Known gated types. Informational and for tests: the gate itself is "not
39
3
  * read-only", so types missing from this list are still gated.
@@ -74,6 +38,8 @@ export const CONTROL_MESSAGE_TYPES = new Set([
74
38
  'list_processes',
75
39
  // Feeds hidden context into the next turn (UI#21), so controller-only.
76
40
  'favorite_changed',
41
+ // Changes which tool requests are approved without asking (#364).
42
+ 'set_approval_mode',
77
43
  ]);
78
44
  /** Read-only queries any participant may send. Everything else is gated. */
79
45
  export const READ_ONLY_MESSAGE_TYPES = new Set([
@@ -87,6 +53,22 @@ export const READ_ONLY_MESSAGE_TYPES = new Set([
87
53
  // End asks whether the agent is mid-task before offering keep-working.
88
54
  'get_busy',
89
55
  ]);
56
+ /**
57
+ * App commands a phone caller's voice actions (#367) may run through
58
+ * dispatchAction (index.ts): the same code the app's buttons use. Anything
59
+ * else is refused there. There is deliberately no HTTP route to these: the
60
+ * agent's own tools must never be able to loosen or answer its approvals.
61
+ */
62
+ export const PHONE_ACTION_TYPES = new Set([
63
+ 'permission_response',
64
+ 'set_approval_mode',
65
+ 'get_busy',
66
+ 'stop_dispatch',
67
+ 'list_sessions',
68
+ 'switch_session',
69
+ 'get_session_artifacts',
70
+ 'keep_working',
71
+ ]);
90
72
  /** Identity prefix /api/token gives every user participant. */
91
73
  export const USER_IDENTITY_PREFIX = 'user-';
92
74
  /**
@@ -123,6 +105,141 @@ export function canBecomeController(participantUserId, ownerUserId) {
123
105
  return true;
124
106
  return !!participantUserId && participantUserId === ownerUserId;
125
107
  }
108
+ /**
109
+ * Room-name prefix of the inbound phone dispatch rule (LiveKit `individual`
110
+ * rule, roomPrefix "call-"). POST /connect-room only joins a caller-supplied
111
+ * room with this prefix, and only behind the sync-token check.
112
+ */
113
+ const PHONE_ROOM_PREFIX = 'call-';
114
+ /** A room name POST /connect-room may join for a phone call. */
115
+ export function isPhoneRoomName(name) {
116
+ return typeof name === 'string'
117
+ && name.length <= 128
118
+ && name.startsWith(PHONE_ROOM_PREFIX)
119
+ && /^[A-Za-z0-9_+\-]+$/.test(name);
120
+ }
121
+ /**
122
+ * Keypad answer to a pending approval on a phone call (#363): 1 allows, 2
123
+ * denies, 3 always allows (the browser's "Always"); anything else is ignored.
124
+ */
125
+ export function keypadAnswer(digit) {
126
+ if (digit === '1')
127
+ return 'allow';
128
+ if (digit === '2')
129
+ return 'deny';
130
+ if (digit === '3')
131
+ return 'always_allow';
132
+ return null;
133
+ }
134
+ /**
135
+ * Keypad approvals on a phone call. Off: caller ID alone is not proof enough
136
+ * to approve a tool, so every permission raised while a phone caller holds the
137
+ * session is denied and keypad 1 approves nothing. Turned on once a second
138
+ * factor confirms the caller.
139
+ */
140
+ export const PHONE_KEYPAD_APPROVALS_ENABLED = false;
141
+ /**
142
+ * Tools on a phone call. Off: a call is talk-only, so the PreToolUse hook
143
+ * (claude-llm.ts) denies every tool while a phone caller holds the session,
144
+ * including the ones allowedTools auto-approves (Bash, Read, WebFetch …),
145
+ * sub-agent dispatch and MCP tools. Turned on once a second factor confirms
146
+ * the caller.
147
+ */
148
+ export const PHONE_TOOLS_ENABLED = false;
149
+ /**
150
+ * Emailed code on a phone call (#362). On: a caller is not adopted (no voice
151
+ * session, no voice actions, no tools) until they type the 6-digit code the
152
+ * frontend emails to the account (phone-code.ts). Off: caller ID alone admits
153
+ * the call, as before. /connect-room tells the frontend to send the code.
154
+ */
155
+ export const PHONE_EMAIL_CODE_ENABLED = false;
156
+ /** What happens to a permission raised during a phone call: denied unless keypad approvals are on. */
157
+ export function phonePermissionPolicy(inPhoneCall, approvalsEnabled = PHONE_KEYPAD_APPROVALS_ENABLED) {
158
+ return inPhoneCall && !approvalsEnabled ? 'deny' : 'ask';
159
+ }
160
+ /**
161
+ * How a permission request is handled when its brain belongs to a phone call:
162
+ * the live call, or a brain parked after "keep working" on a call that no
163
+ * browser or app session has re-attached yet.
164
+ * - 'deny': keypad approvals off (phonePermissionPolicy) — denied at once.
165
+ * - 'hold': parked from a call — left pending for a person; never answered by
166
+ * the saved approval mode or the call's always-allow list.
167
+ * - 'normal': anything else (the live call with keypad approvals on, or no call).
168
+ */
169
+ export function phoneRequestRoute(s, approvalsEnabled = PHONE_KEYPAD_APPROVALS_ENABLED) {
170
+ if (phonePermissionPolicy(s.liveCall || s.parkedFromCall, approvalsEnabled) === 'deny')
171
+ return 'deny';
172
+ return s.parkedFromCall && !s.liveCall ? 'hold' : 'normal';
173
+ }
174
+ /** What happens to any tool call during a phone call: denied unless phone tools are on. */
175
+ export function phoneToolPolicy(inPhoneCall, toolsEnabled = PHONE_TOOLS_ENABLED) {
176
+ return inPhoneCall && !toolsEnabled ? 'deny' : 'allow';
177
+ }
178
+ /**
179
+ * A phone call is live: the agent is in the room an authorised phone connect
180
+ * asked for AND a SIP participant is in it. False as soon as the caller leaves.
181
+ */
182
+ export function isPhoneCallLive(activeRoomName, phoneRoomName, sipPresent) {
183
+ return !!activeRoomName && activeRoomName === phoneRoomName && sipPresent;
184
+ }
185
+ /**
186
+ * What POST /connect-room does with the room the agent is in.
187
+ * - 'fresh': no room, or an empty one: (tear it down and) make a new room
188
+ * (the requested phone room, else a new name).
189
+ * - 'reuse': return the occupied room: a browser connect while no phone call is
190
+ * live, or a phone connect for the room the agent is already in.
191
+ * - 'busy' (409): the room is someone else's: a phone connect while a user is in
192
+ * another room, or a browser connect during a live phone call (the caller's
193
+ * room is never handed to a browser).
194
+ */
195
+ export function planConnectRoom(s) {
196
+ if (!s.activeRoomName || !s.occupied)
197
+ return 'fresh';
198
+ if (s.phoneRoom)
199
+ return s.activeRoomName === s.phoneRoom ? 'reuse' : 'busy';
200
+ return s.phoneCallLive ? 'busy' : 'reuse';
201
+ }
202
+ /**
203
+ * May a phone caller give this answer (keypad or a spoken yes/no, #367)? A
204
+ * deny always; an allow only once keypad approvals are on.
205
+ */
206
+ export function phoneAnswerAllowed(answer, approvalsEnabled = PHONE_KEYPAD_APPROVALS_ENABLED) {
207
+ return answer === 'deny' || approvalsEnabled;
208
+ }
209
+ /**
210
+ * Handles one keypad press (index.ts DtmfReceived). Only the SIP caller in an
211
+ * authorised phone room counts; with approvals off a 1 or 3 settles nothing
212
+ * (a 2 still denies). The answer goes to the same settle path the browser
213
+ * and watch use; the model never decides it. Returns what was done.
214
+ */
215
+ export function handlePhoneKeypad(press, settle, approvalsEnabled = PHONE_KEYPAD_APPROVALS_ENABLED) {
216
+ if (!press.sip || !press.inPhoneRoom)
217
+ return 'ignored';
218
+ const answer = keypadAnswer(press.digit);
219
+ if (answer === null || !phoneAnswerAllowed(answer, approvalsEnabled))
220
+ return 'ignored';
221
+ if (!settle(answer))
222
+ return 'no pending permission';
223
+ return answer === 'allow' ? 'approved' : answer === 'always_allow' ? 'always allowed' : 'denied';
224
+ }
225
+ /** Most bytes POST /connect-room reads; its body is only `{ roomName }`. */
226
+ export const CONNECT_ROOM_MAX_BODY = 4096;
227
+ /**
228
+ * Reads a request body up to `max` bytes. Returns null as soon as it is
229
+ * longer (the caller answers 413) and stops reading.
230
+ */
231
+ export async function readBodyCapped(body, max) {
232
+ const parts = [];
233
+ let size = 0;
234
+ for await (const chunk of body) {
235
+ const b = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
236
+ size += b.length;
237
+ if (size > max)
238
+ return null;
239
+ parts.push(b);
240
+ }
241
+ return Buffer.concat(parts).toString('utf8');
242
+ }
126
243
  /**
127
244
  * What a non-canvas participant joining the room changes. Pure, so the
128
245
  * controller rules are testable without LiveKit.
@@ -135,13 +252,22 @@ export function canBecomeController(participantUserId, ownerUserId) {
135
252
  * when it joins with no controller (the opt-in watch voice path that hears
136
253
  * the watch mic). When a controller already exists it is NOT adopted: the
137
254
  * full session rebuild would tear down the owner's live session and reset
138
- * currentUserId to '' (the gateway's token has no metadata).
255
+ * currentUserId to '' (the gateway's token has no metadata). Nor in a
256
+ * phone room, where the rebuild would take the caller's session.
257
+ * - A SIP (phone) joiner: never the controller, whatever its identity. It
258
+ * gets the voice session only in a room the agent joined through an
259
+ * authorised phone connect, and only while no controller holds the session.
260
+ * Anywhere else it is ignored, in single-tenant mode too.
139
261
  * - Any other identity: never the controller; gets a session only in
140
262
  * single-tenant mode (no owner), matching the old behavior there.
141
263
  */
142
- export function resolveJoin(joinerIdentity, joinerUserId, ownerUserId, currentController) {
264
+ export function resolveJoin(joinerIdentity, joinerUserId, ownerUserId, currentController, opts = {}) {
265
+ if (opts.sip) {
266
+ return { adoptSession: !!opts.phoneRoom && !currentController, controller: currentController };
267
+ }
143
268
  if (joinerIdentity === AGENT_SELF_IDENTITY) {
144
- return { adoptSession: !currentController, controller: currentController };
269
+ // In a phone room the caller holds the session without being the controller.
270
+ return { adoptSession: !currentController && !opts.phoneRoom, controller: currentController };
145
271
  }
146
272
  if (joinerIdentity.startsWith(USER_IDENTITY_PREFIX)) {
147
273
  return canBecomeController(joinerUserId, ownerUserId)
@@ -12,6 +12,7 @@
12
12
  *
13
13
  * Keep in sync with frontend/src/lib/platform-env.ts (PLATFORM_ENV_SPEC).
14
14
  */
15
+ import type { STTProvider, TTSProvider } from './config.js';
15
16
  export interface AgentEnvKey {
16
17
  key: string;
17
18
  required: boolean;
@@ -23,8 +24,15 @@ export interface AgentEnvKey {
23
24
  export declare const AGENT_ENV_KEYS: AgentEnvKey[];
24
25
  /** Keys the agent treats as required — absence should be surfaced at startup. */
25
26
  export declare const REQUIRED_AGENT_ENV_KEYS: string[];
26
- /** Return the required keys that are missing from the given env (default process.env). */
27
- export declare function missingRequiredEnv(env?: NodeJS.ProcessEnv): string[];
27
+ /**
28
+ * Return the required keys that are missing from the given env (default process.env).
29
+ * With `voice` (the resolved getDirectConfig providers), the STT/TTS key follows the providers in
30
+ * use instead of the Soniox default, so an OSBORN_STT_PROVIDER=deepgram machine asks for Deepgram.
31
+ */
32
+ export declare function missingRequiredEnv(env?: NodeJS.ProcessEnv, voice?: {
33
+ stt: STTProvider;
34
+ tts: TTSProvider;
35
+ }): string[];
28
36
  /**
29
37
  * Keys a user may add/rotate live (mid-session, no reboot) via the /secrets
30
38
  * endpoint. These are read by osborn's OWN code (not baked into a plugin SDK at
package/dist/env-keys.js CHANGED
@@ -18,8 +18,8 @@ export const AGENT_ENV_KEYS = [
18
18
  { key: 'LIVEKIT_API_KEY', required: true, explicit: true, description: 'LiveKit API key.' },
19
19
  { key: 'LIVEKIT_API_SECRET', required: true, explicit: true, description: 'LiveKit API secret.' },
20
20
  // STT / inference (plugin-consumed unless noted)
21
- { key: 'DEEPGRAM_API_KEY', required: true, explicit: false, description: 'Deepgram STT (LiveKit plugin).' },
22
- { key: 'SONIOX_API_KEY', required: false, explicit: false, description: 'Soniox STT (LiveKit plugin).' },
21
+ { key: 'SONIOX_API_KEY', required: true, explicit: false, description: 'Soniox STT and TTS, the default voice pipeline (config.ts DEFAULT_CONFIG; LiveKit plugin) and meeting TTS.' },
22
+ { key: 'DEEPGRAM_API_KEY', required: false, explicit: false, description: 'Deepgram STT/TTS (LiveKit plugin); needed only when OSBORN_STT_PROVIDER or OSBORN_TTS_PROVIDER selects deepgram.' },
23
23
  { key: 'GROQ_API_KEY', required: false, explicit: true, description: 'Groq fast-brain inference.' },
24
24
  { key: 'FIREWORKS_API_KEY', required: false, explicit: true, description: 'Fireworks AI — fast-brain inference + embeddings (preferred over OpenRouter when set).' },
25
25
  { key: 'OPENAI_API_KEY', required: true, explicit: true, description: 'OpenAI realtime + pipeline.' },
@@ -54,9 +54,30 @@ export const AGENT_ENV_KEYS = [
54
54
  export const REQUIRED_AGENT_ENV_KEYS = AGENT_ENV_KEYS
55
55
  .filter((k) => k.required)
56
56
  .map((k) => k.key);
57
- /** Return the required keys that are missing from the given env (default process.env). */
58
- export function missingRequiredEnv(env = process.env) {
59
- return REQUIRED_AGENT_ENV_KEYS.filter((k) => !env[k]);
57
+ /** The key each voice provider (voice-io.ts) reads, for providers this manifest lists. */
58
+ const VOICE_PROVIDER_KEYS = {
59
+ 'soniox': 'SONIOX_API_KEY',
60
+ 'deepgram': 'DEEPGRAM_API_KEY',
61
+ 'deepgram-flux': 'DEEPGRAM_API_KEY',
62
+ 'groq-whisper': 'GROQ_API_KEY',
63
+ 'groq-orpheus': 'GROQ_API_KEY',
64
+ 'openai': 'OPENAI_API_KEY',
65
+ 'openai-whisper': 'OPENAI_API_KEY',
66
+ };
67
+ /**
68
+ * Return the required keys that are missing from the given env (default process.env).
69
+ * With `voice` (the resolved getDirectConfig providers), the STT/TTS key follows the providers in
70
+ * use instead of the Soniox default, so an OSBORN_STT_PROVIDER=deepgram machine asks for Deepgram.
71
+ */
72
+ export function missingRequiredEnv(env = process.env, voice) {
73
+ const keys = new Set(REQUIRED_AGENT_ENV_KEYS);
74
+ if (voice) {
75
+ keys.delete('SONIOX_API_KEY');
76
+ for (const p of [voice.stt, voice.tts])
77
+ if (VOICE_PROVIDER_KEYS[p])
78
+ keys.add(VOICE_PROVIDER_KEYS[p]);
79
+ }
80
+ return [...keys].filter((k) => !env[k]);
60
81
  }
61
82
  /**
62
83
  * Keys a user may add/rotate live (mid-session, no reboot) via the /secrets