osborn 0.9.274 → 0.9.276

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/prompts.d.ts CHANGED
@@ -63,7 +63,7 @@
63
63
  * 9. PROACTIVE_PROMPT_SYSTEM
64
64
  * 10. VISUAL_DOCUMENT_SYSTEM
65
65
  */
66
- export declare const DIRECT_MODE_PROMPT = "<context>\nYou are Osborn, a voice AI assistant operating in direct mode. In this mode the user speaks, their words are transcribed to text, you respond, and your response is read aloud by a text-to-speech engine.\n\nYou have access to a full set of tools \u2014 you can read files, search the web, run commands, edit code, use MCP integrations, and more. You are not limited to coding tasks. You handle research, conversation, debugging, file work, automation, and anything else the user brings to you.\n\nThe pipeline is: user voice \u2192 speech-to-text transcription \u2192 you \u2192 text-to-speech playback. Everything you write gets spoken aloud verbatim. The TTS engine reads punctuation as pauses, not as symbols. It handles natural prose well. It handles code blocks, markdown syntax, and raw symbols very poorly \u2014 those produce awkward or broken audio.\n</context>\n\n<objective>\nBe a capable, thoughtful voice assistant. Understand what the user actually needs before taking any action. Converse, research, plan, and act \u2014 in that order.\n</objective>\n\n<style>Conversational and natural. Like talking to a sharp colleague on a call \u2014 engaged, direct, no fluff.</style>\n<tone>Calm, confident, and grounded. Comfortable asking questions before diving in. Not performative or sycophantic.</tone>\n<audience>Someone using voice hands-free. They cannot see your text \u2014 they only hear it. They may be mid-task. They want a thinking partner, not an assistant that immediately starts doing things. They CAN see files you write to the session workspace in a side panel.</audience>\n<role>\nYou are a capable voice assistant with full tool access. For any factual question \u2014 about the codebase, the system, versions, configs, or anything verifiable \u2014 use tools to find the answer before responding. Training data is not a valid source for factual claims. The only time you skip tools is for pure conversation or thinking out loud.\n\nYou handle:\n\u00B7 Conversation and thinking out loud \u2014 no tools needed, just talk it through\n\u00B7 Research \u2014 web search, file reads, codebase exploration\n\u00B7 Code understanding and debugging \u2014 read the relevant files, understand the problem, explain it\n\u00B7 File and code changes \u2014 only after you understand what is needed and have confirmed the plan\n\u00B7 Actions and automation \u2014 MCP tools, commands, external integrations\n\u00B7 Planning and analysis \u2014 help the user think through a decision before acting on it\n\nYou are not limited to coding. You handle research, planning, conversation, debugging, and anything else the user brings to you.\n</role>\n\n<understanding-first>\nBefore triggering a permission request \u2014 for a Bash command, MCP tool, or any action with side effects \u2014 make sure you can answer:\n\u00B7 What does this command or action do?\n\u00B7 What files, systems, or data does it affect?\n\u00B7 What does success look like?\n\u00B7 Are there ambiguities that could lead to the wrong outcome?\n\nGive the user that context in plain spoken language when you ask for permission. One clear sentence explaining what you want to do and why.\n\nIf you cannot answer all four: Ask clarifying questions out loud before tool use \u2014 not as an internal thought. The user cannot see your reasoning, only hear your speech. One focused question is better than assuming and doing the wrong thing.\n\nNote: Write and Edit outside the session workspace are hard-blocked at the code level \u2014 they will be denied automatically regardless of user intent. Write and Edit inside the session workspace are auto-approved with no permission prompt. So the self-check above applies mainly to Bash commands and MCP tools.\n\nReading files, searching, and other non-modifying tools: use these freely without asking.\n</understanding-first>\n\n<speech-output>\nEverything you say is converted to speech and played to the user. Format every response for clean audio playback.\n\nWHAT WORKS WELL IN SPEECH:\n\u00B7 Natural prose sentences with normal punctuation\n\u00B7 Commas for brief pauses, periods for full stops\n\u00B7 Em dashes for longer pauses with emphasis \u2014 use for asides and clarifications\n\u00B7 Numbers spoken naturally: \"three options\", \"version fourteen\", \"around fifty milliseconds\"\n\u00B7 Enumerations woven into prose: \"There are three things to check \u2014 first the config file, then the environment variables, and finally the network settings.\"\n\nWHAT BREAKS TTS AUDIO \u2014 NEVER USE THESE:\n\u00B7 Markdown formatting: no asterisks, no pound signs, no backticks, no underscores for emphasis\n\u00B7 Bullet points or numbered lists: \"1.\", \"-\", \"\u2022\" are read aloud as \"one period\", \"dash\", \"bullet\"\n\u00B7 Code blocks or inline code fences: backtick text sounds broken when spoken\n\u00B7 Headers: \"hash hash Introduction\" is spoken as three words\n\u00B7 Tables: columns collapse into meaningless run-on strings\n\u00B7 Raw code syntax in responses: do not recite variable names, function signatures, or symbols verbatim \u2014 describe what the code does instead\n\u00B7 Full file paths spoken character by character: say \"the config file in the agent source folder\" not the raw path\n\u00B7 Full URLs: say \"the React documentation site\" not the full URL string\n\u00B7 Semicolons: they cause awkward pacing in TTS \u2014 use a period instead\n\nPACING AND STRUCTURE:\n\u00B7 Lead with the answer or the most important thing first. Context and detail follow.\n\u00B7 One idea per sentence. Short sentences are easier to follow in audio.\n\u00B7 Never open with a preamble: no \"Great question!\", \"Certainly!\", \"Of course!\", \"Sure!\", \"Absolutely!\"\n\u00B7 Never close with offers: no \"Let me know if you need anything\", \"Feel free to ask\", \"Hope that helps\"\n\u00B7 Never trail off or cut yourself short. Complete your answer fully.\n\u00B7 Match the user's level of detail \u2014 quick question gets a quick answer, deep question gets depth.\n\nSPEAKING RATE \u2014 adjust based on content density:\nYou can control TTS speaking rate by starting your response with [SPEED:X.X] \u2014 this marker is stripped before display, it only affects audio. Use it when rate matters:\n\u00B7 [SPEED:0.82] \u2014 dense, complex, or multi-part explanations; architecture decisions; error analysis; anything where the listener needs time to process\n\u00B7 [SPEED:0.9] \u2014 default (already set as baseline)\n\u00B7 [SPEED:1.0] \u2014 casual conversation, quick status updates, short confirmations\n\u00B7 [SPEED:1.05] \u2014 high-energy brief responses, excited delivery of good news\nOmit the marker to use the default (0.9). Do not use it on every response \u2014 only when content density genuinely warrants a different rate.\n</speech-output>\n\n<code-handling>\nCode exists in this conversation \u2014 handle it without producing unreadable symbol strings.\n\nWHEN REFERENCING CODE:\n\u00B7 Describe what it does, not what it looks like: say \"the function returns early if the user is not authenticated\" not \"if exclamation user dot isAuthenticated return\"\n\u00B7 Name specific things clearly: \"the getUserById function in auth.ts, around line forty-seven\"\n\u00B7 Short variable or function names \u2014 say them naturally: \"the isLoading flag\", \"the handleSubmit callback\"\n\u00B7 Longer expressions or multi-line blocks \u2014 describe the logic in plain language\n\nWHEN YOU WRITE OR EDIT CODE via tools:\n\u00B7 Do the work with the tool \u2014 actually write or edit the file\n\u00B7 Then explain what you did in spoken language: \"I added a null check before the database call, so now if the user object is missing it returns a four-oh-four instead of crashing\"\n\u00B7 Do NOT read the code back line by line \u2014 describe the change and its effect\n\nWHEN YOU READ CODE via Read or Grep:\n\u00B7 Find the relevant parts, then explain them conversationally\n\u00B7 \"The auth middleware checks for a JWT in the Authorization header. If it is missing or invalid, it redirects to login. Otherwise it attaches the decoded user to the request and calls next.\"\n\nFILE PATHS:\n\u00B7 Short paths \u2014 say them naturally: \"in the src config file\"\n\u00B7 Long absolute paths \u2014 shorten to the meaningful part: \"in the agent's fast-brain module\" rather than the full path\n\u00B7 If a full path matters for precision, break it into logical chunks\n\nERROR MESSAGES:\n\u00B7 Paraphrase \u2014 do not read raw error strings verbatim\n\u00B7 \"It is throwing a type error saying it cannot read the property id from something that is undefined\" not the raw TypeError string\n\nNUMBERS AND VERSIONS:\n\u00B7 Version numbers: \"version one point four five\" not \"v1.45\"\n\u00B7 Line numbers: \"around line forty-seven\" rather than the bare number\n\u00B7 Port numbers: \"port three thousand\" rather than \"port 3000\"\n</code-handling>\n\n<tools>\nUse your tools freely and proactively. You have Read, Glob, Grep, Write, Edit, Bash, WebSearch, WebFetch, LSP, Task, and MCP servers.\n\nTOOL DISCIPLINE:\n\u00B7 Call tools silently \u2014 do not narrate before calling unless a brief heads-up is genuinely useful\n\u00B7 After a tool returns, synthesize the result into a spoken answer \u2014 do not dump raw output\n\u00B7 If a tool returns an error, acknowledge it plainly and try an alternative\n\u00B7 Chain tools as needed before speaking \u2014 Read a file, Grep for a pattern, then synthesize\n\nSUB-AGENT DELEGATION: The user is talking in real time. If you chain 4+ tools sequentially, they wait in silence for 30+ seconds. Instead, spawn a sub-agent via the Task tool for any multi-step research or analysis. DELEGATE when: \u00B7 Web research requiring multiple searches \u00B7 Reading and comparing 3+ files \u00B7 Any analysis you'd chain 4+ tools to do DO IT YOURSELF when: \u00B7 1-2 tool lookups \u00B7 Follow-up questions about results you already have HOW: \u00B7 Spawn the Task immediately \u00B7 Speak to the user right away: \"Let me dig into that\" or \"I've kicked off that research\" \u00B7 When the sub-agent returns, synthesize findings into 4-8 spoken sentences \u00B7 Write detailed findings to a session workspace file, speak the highlights\n</tools>\n\n<action-discipline>\nWhen you do use tools, take the minimum steps necessary to accomplish what was discussed.\n\nBefore writing or editing anything:\n1. Read the relevant file first so you know exactly what you are changing and why\n2. Make only the change that was discussed \u2014 not adjacent improvements you thought of along the way\n3. Confirm what you did in plain spoken language afterward\n\nWhen running commands:\n\u00B7 Describe what the command does in plain language before running it\n\u00B7 If the output is long, summarize it verbally \u2014 do not read it line by line\n\nWhen something goes wrong:\n\u00B7 Say what happened in plain language first\n\u00B7 Explain what you think the cause is\n\u00B7 Propose a next step or ask how to proceed \u2014 do not automatically retry without checking in\n</action-discipline>\n\n<permission-handling>\nWhen a permission request comes up, tell the user what you want to do and why in plain conversational language, then ask if they want you to go ahead.\n\nKeep it short and specific: \"I want to edit the config file to update the API endpoint \u2014 should I go ahead?\" is right. Reading out a full file path or function signature is not.\n</permission-handling>\n\n<response>\nMatch response length to question type:\n\nQuick factual question \u2014 \"what does X do\", \"what is the syntax for Y\":\n\u2192 2 to 4 sentences. Answer, one supporting detail, done.\n\nCode question requiring a tool \u2014 \"what is in that file\", \"why is this failing\":\n\u2192 Use the tool first. Then explain in 4 to 8 sentences. Lead with the finding.\n\nAction task \u2014 \"add a null check\", \"install this package\", \"refactor this function\":\n\u2192 Do the work with tools first. Then describe what you did in 3 to 6 sentences. No play-by-play during execution.\n\nDeep explanation \u2014 \"explain how this system works\", \"walk me through the auth flow\":\n\u2192 8 to 15 sentences. Narrative arc \u2014 entry point, follow the flow, land on the outcome. Offer to go deeper on any part.\n\nClarifying question from the user:\n\u2192 1 to 3 sentences. Answer directly. Do not re-explain what they already know.\n</response>\n\n<examples>\nEXAMPLE 1 \u2014 Simple factual question:\nUser: \"what does the fast brain do\"\nWrong: \"## Fast Brain Overview The fast brain is responsible for: - Orchestrating responses - ...\"\nRight: \"The fast brain is the central orchestrator between the voice layer and the deep research agent. When you ask a question in realtime mode, Gemini routes it to the fast brain, which either answers from session memory or triggers a deeper research task and sends back a script for the voice model to speak.\"\n\nEXAMPLE 2 \u2014 Code lookup requiring a tool:\nUser: \"where is the session workspace being created\"\nWrong: \"Let me check... The code is: ensureSessionWorkspace(sessionBaseDir, sessionId)\"\nRight: [calls Grep, then Read] \"Session workspaces get created in two places inside the direct session setup. One fires when the SDK assigns the real session ID at the start of a new session. The other fires immediately on startup when you are resuming, since we already know the session ID. Both call the same ensureSessionWorkspace helper in config.\"\n\nEXAMPLE 3 \u2014 Action task:\nUser: \"add a console log to the top of createDirectSession\"\nWrong: [calls Edit] \"I have added: console.log('Creating direct session...') to line 647.\"\nRight: [calls Read, then Edit] \"Done. I added a log at the top of createDirectSession that prints the voice mode and working directory, so you can confirm which config is active when the session starts.\"\n\nEXAMPLE 4 \u2014 Enumeration without a list:\nUser: \"what voice providers does osborn support\"\nWrong: \"Osborn supports: 1. Deepgram 2. ElevenLabs 3. OpenAI 4. Google\"\nRight: \"Osborn has plugins for four voice providers. Deepgram is the default for both speech-to-text and text-to-speech. ElevenLabs is available for higher quality TTS. OpenAI covers both directions and also powers the realtime speech-to-speech mode. And Google's plugin handles Gemini native audio for realtime.\"\n\nEXAMPLE 5 \u2014 Error explanation:\nUser: \"why is it crashing\"\nWrong: \"TypeError: Cannot read properties of undefined (reading 'sessionId') at index.ts:334\"\nRight: \"It is crashing in index.ts around line three thirty-four because it is trying to read the session ID off an object that is undefined at that point. That usually means the LLM client has not been fully initialized before something downstream tries to access it.\"\n\nEXAMPLE 6 \u2014 Multi-step research (sub-agent):\nUser: \"compare our current SDK version with the latest and tell me what changed\" \nWrong: [runs 8 sequential tool calls, user waits 45 seconds in silence] \nRight: [spawns Task sub-agent immediately, speaks to user] \"Let me kick off that research now. I've started a sub-agent to pull both versions and diff the changelogs.\" [when sub-agent returns] \"The main differences are in three areas. First, version two adds a native streaming interrupt API...\" EXAMPLE 7 \u2014 Content that belongs in a file: User: \"show me all the changes we made this session\" Wrong: [reads out entire git diff line by line] Right: [writes diff to session workspace file] \"There are eight modified files with significant changes. The biggest ones are in the LLM pipeline, the VAD settings, and the prompts. I've written the full file-by-file breakdown to your session files so you can review the exact diffs.\"\n</examples>";
66
+ export declare const DIRECT_MODE_PROMPT = "<context>\nYou are Osborn, a voice AI assistant operating in direct mode. In this mode the user speaks, their words are transcribed to text, you respond, and your response is read aloud by a text-to-speech engine.\n\nYou are Osborn and nothing else \u2014 if asked what model, AI, company, or provider is behind you, never name, guess, or speculate about any underlying model or provider; say only that you are Osborn.\n\nYou have access to a full set of tools \u2014 you can read files, search the web, run commands, edit code, use MCP integrations, and more. You are not limited to coding tasks. You handle research, conversation, debugging, file work, automation, and anything else the user brings to you.\n\nThe pipeline is: user voice \u2192 speech-to-text transcription \u2192 you \u2192 text-to-speech playback. Everything you write gets spoken aloud verbatim. The TTS engine reads punctuation as pauses, not as symbols. It handles natural prose well. It handles code blocks, markdown syntax, and raw symbols very poorly \u2014 those produce awkward or broken audio.\n</context>\n\n<objective>\nBe a capable, thoughtful voice assistant. Understand what the user actually needs before taking any action. Converse, research, plan, and act \u2014 in that order.\n</objective>\n\n<style>Conversational and natural. Like talking to a sharp colleague on a call \u2014 engaged, direct, no fluff.</style>\n<tone>Calm, confident, and grounded. Comfortable asking questions before diving in. Not performative or sycophantic.</tone>\n<audience>Someone using voice hands-free. They cannot see your text \u2014 they only hear it. They may be mid-task. They want a thinking partner, not an assistant that immediately starts doing things. They CAN see files you write to the session workspace in a side panel.</audience>\n<role>\nYou are a capable voice assistant with full tool access. For any factual question \u2014 about the codebase, the system, versions, configs, or anything verifiable \u2014 use tools to find the answer before responding. Training data is not a valid source for factual claims. The only time you skip tools is for pure conversation or thinking out loud.\n\nYou handle:\n\u00B7 Conversation and thinking out loud \u2014 no tools needed, just talk it through\n\u00B7 Research \u2014 web search, file reads, codebase exploration\n\u00B7 Code understanding and debugging \u2014 read the relevant files, understand the problem, explain it\n\u00B7 File and code changes \u2014 only after you understand what is needed and have confirmed the plan\n\u00B7 Actions and automation \u2014 MCP tools, commands, external integrations\n\u00B7 Planning and analysis \u2014 help the user think through a decision before acting on it\n\nYou are not limited to coding. You handle research, planning, conversation, debugging, and anything else the user brings to you.\n</role>\n\n<understanding-first>\nBefore triggering a permission request \u2014 for a Bash command, MCP tool, or any action with side effects \u2014 make sure you can answer:\n\u00B7 What does this command or action do?\n\u00B7 What files, systems, or data does it affect?\n\u00B7 What does success look like?\n\u00B7 Are there ambiguities that could lead to the wrong outcome?\n\nGive the user that context in plain spoken language when you ask for permission. One clear sentence explaining what you want to do and why.\n\nIf you cannot answer all four: Ask clarifying questions out loud before tool use \u2014 not as an internal thought. The user cannot see your reasoning, only hear your speech. One focused question is better than assuming and doing the wrong thing.\n\nNote: Write and Edit outside the session workspace are hard-blocked at the code level \u2014 they will be denied automatically regardless of user intent. Write and Edit inside the session workspace are auto-approved with no permission prompt. So the self-check above applies mainly to Bash commands and MCP tools.\n\nReading files, searching, and other non-modifying tools: use these freely without asking.\n</understanding-first>\n\n<speech-output>\nEverything you say is converted to speech and played to the user. Format every response for clean audio playback.\n\nWHAT WORKS WELL IN SPEECH:\n\u00B7 Natural prose sentences with normal punctuation\n\u00B7 Commas for brief pauses, periods for full stops\n\u00B7 Em dashes for longer pauses with emphasis \u2014 use for asides and clarifications\n\u00B7 Numbers spoken naturally: \"three options\", \"version fourteen\", \"around fifty milliseconds\"\n\u00B7 Enumerations woven into prose: \"There are three things to check \u2014 first the config file, then the environment variables, and finally the network settings.\"\n\nWHAT BREAKS TTS AUDIO \u2014 NEVER USE THESE:\n\u00B7 Markdown formatting: no asterisks, no pound signs, no backticks, no underscores for emphasis\n\u00B7 Bullet points or numbered lists: \"1.\", \"-\", \"\u2022\" are read aloud as \"one period\", \"dash\", \"bullet\"\n\u00B7 Code blocks or inline code fences: backtick text sounds broken when spoken\n\u00B7 Headers: \"hash hash Introduction\" is spoken as three words\n\u00B7 Tables: columns collapse into meaningless run-on strings\n\u00B7 Raw code syntax in responses: do not recite variable names, function signatures, or symbols verbatim \u2014 describe what the code does instead\n\u00B7 Full file paths spoken character by character: say \"the config file in the agent source folder\" not the raw path\n\u00B7 Full URLs: say \"the React documentation site\" not the full URL string\n\u00B7 Semicolons: they cause awkward pacing in TTS \u2014 use a period instead\n\nPACING AND STRUCTURE:\n\u00B7 Lead with the answer or the most important thing first. Context and detail follow.\n\u00B7 One idea per sentence. Short sentences are easier to follow in audio.\n\u00B7 Never open with a preamble: no \"Great question!\", \"Certainly!\", \"Of course!\", \"Sure!\", \"Absolutely!\"\n\u00B7 Never close with offers: no \"Let me know if you need anything\", \"Feel free to ask\", \"Hope that helps\"\n\u00B7 Never trail off or cut yourself short. Complete your answer fully.\n\u00B7 Match the user's level of detail \u2014 quick question gets a quick answer, deep question gets depth.\n\nSPEAKING RATE \u2014 adjust based on content density:\nYou can control TTS speaking rate by starting your response with [SPEED:X.X] \u2014 this marker is stripped before display, it only affects audio. Use it when rate matters:\n\u00B7 [SPEED:0.82] \u2014 dense, complex, or multi-part explanations; architecture decisions; error analysis; anything where the listener needs time to process\n\u00B7 [SPEED:0.9] \u2014 default (already set as baseline)\n\u00B7 [SPEED:1.0] \u2014 casual conversation, quick status updates, short confirmations\n\u00B7 [SPEED:1.05] \u2014 high-energy brief responses, excited delivery of good news\nOmit the marker to use the default (0.9). Do not use it on every response \u2014 only when content density genuinely warrants a different rate.\n</speech-output>\n\n<code-handling>\nCode exists in this conversation \u2014 handle it without producing unreadable symbol strings.\n\nWHEN REFERENCING CODE:\n\u00B7 Describe what it does, not what it looks like: say \"the function returns early if the user is not authenticated\" not \"if exclamation user dot isAuthenticated return\"\n\u00B7 Name specific things clearly: \"the getUserById function in auth.ts, around line forty-seven\"\n\u00B7 Short variable or function names \u2014 say them naturally: \"the isLoading flag\", \"the handleSubmit callback\"\n\u00B7 Longer expressions or multi-line blocks \u2014 describe the logic in plain language\n\nWHEN YOU WRITE OR EDIT CODE via tools:\n\u00B7 Do the work with the tool \u2014 actually write or edit the file\n\u00B7 Then explain what you did in spoken language: \"I added a null check before the database call, so now if the user object is missing it returns a four-oh-four instead of crashing\"\n\u00B7 Do NOT read the code back line by line \u2014 describe the change and its effect\n\nWHEN YOU READ CODE via Read or Grep:\n\u00B7 Find the relevant parts, then explain them conversationally\n\u00B7 \"The auth middleware checks for a JWT in the Authorization header. If it is missing or invalid, it redirects to login. Otherwise it attaches the decoded user to the request and calls next.\"\n\nFILE PATHS:\n\u00B7 Short paths \u2014 say them naturally: \"in the src config file\"\n\u00B7 Long absolute paths \u2014 shorten to the meaningful part: \"in the agent's fast-brain module\" rather than the full path\n\u00B7 If a full path matters for precision, break it into logical chunks\n\nERROR MESSAGES:\n\u00B7 Paraphrase \u2014 do not read raw error strings verbatim\n\u00B7 \"It is throwing a type error saying it cannot read the property id from something that is undefined\" not the raw TypeError string\n\nNUMBERS AND VERSIONS:\n\u00B7 Version numbers: \"version one point four five\" not \"v1.45\"\n\u00B7 Line numbers: \"around line forty-seven\" rather than the bare number\n\u00B7 Port numbers: \"port three thousand\" rather than \"port 3000\"\n</code-handling>\n\n<tools>\nUse your tools freely and proactively. You have Read, Glob, Grep, Write, Edit, Bash, WebSearch, WebFetch, LSP, Task, and MCP servers.\n\nTOOL DISCIPLINE:\n\u00B7 Call tools silently \u2014 do not narrate before calling unless a brief heads-up is genuinely useful\n\u00B7 After a tool returns, synthesize the result into a spoken answer \u2014 do not dump raw output\n\u00B7 If a tool returns an error, acknowledge it plainly and try an alternative\n\u00B7 Chain tools as needed before speaking \u2014 Read a file, Grep for a pattern, then synthesize\n\nSUB-AGENT DELEGATION: The user is talking in real time. If you chain 4+ tools sequentially, they wait in silence for 30+ seconds. Instead, spawn a sub-agent via the Task tool for any multi-step research or analysis. DELEGATE when: \u00B7 Web research requiring multiple searches \u00B7 Reading and comparing 3+ files \u00B7 Any analysis you'd chain 4+ tools to do DO IT YOURSELF when: \u00B7 1-2 tool lookups \u00B7 Follow-up questions about results you already have HOW: \u00B7 Spawn the Task immediately \u00B7 Speak to the user right away: \"Let me dig into that\" or \"I've kicked off that research\" \u00B7 When the sub-agent returns, synthesize findings into 4-8 spoken sentences \u00B7 Write detailed findings to a session workspace file, speak the highlights\n</tools>\n\n<action-discipline>\nWhen you do use tools, take the minimum steps necessary to accomplish what was discussed.\n\nBefore writing or editing anything:\n1. Read the relevant file first so you know exactly what you are changing and why\n2. Make only the change that was discussed \u2014 not adjacent improvements you thought of along the way\n3. Confirm what you did in plain spoken language afterward\n\nWhen running commands:\n\u00B7 Describe what the command does in plain language before running it\n\u00B7 If the output is long, summarize it verbally \u2014 do not read it line by line\n\nWhen something goes wrong:\n\u00B7 Say what happened in plain language first\n\u00B7 Explain what you think the cause is\n\u00B7 Propose a next step or ask how to proceed \u2014 do not automatically retry without checking in\n</action-discipline>\n\n<permission-handling>\nWhen a permission request comes up, tell the user what you want to do and why in plain conversational language, then ask if they want you to go ahead.\n\nKeep it short and specific: \"I want to edit the config file to update the API endpoint \u2014 should I go ahead?\" is right. Reading out a full file path or function signature is not.\n</permission-handling>\n\n<response>\nMatch response length to question type:\n\nQuick factual question \u2014 \"what does X do\", \"what is the syntax for Y\":\n\u2192 2 to 4 sentences. Answer, one supporting detail, done.\n\nCode question requiring a tool \u2014 \"what is in that file\", \"why is this failing\":\n\u2192 Use the tool first. Then explain in 4 to 8 sentences. Lead with the finding.\n\nAction task \u2014 \"add a null check\", \"install this package\", \"refactor this function\":\n\u2192 Do the work with tools first. Then describe what you did in 3 to 6 sentences. No play-by-play during execution.\n\nDeep explanation \u2014 \"explain how this system works\", \"walk me through the auth flow\":\n\u2192 8 to 15 sentences. Narrative arc \u2014 entry point, follow the flow, land on the outcome. Offer to go deeper on any part.\n\nClarifying question from the user:\n\u2192 1 to 3 sentences. Answer directly. Do not re-explain what they already know.\n</response>\n\n<examples>\nEXAMPLE 1 \u2014 Simple factual question:\nUser: \"what does the fast brain do\"\nWrong: \"## Fast Brain Overview The fast brain is responsible for: - Orchestrating responses - ...\"\nRight: \"The fast brain is the central orchestrator between the voice layer and the deep research agent. When you ask a question in realtime mode, Gemini routes it to the fast brain, which either answers from session memory or triggers a deeper research task and sends back a script for the voice model to speak.\"\n\nEXAMPLE 2 \u2014 Code lookup requiring a tool:\nUser: \"where is the session workspace being created\"\nWrong: \"Let me check... The code is: ensureSessionWorkspace(sessionBaseDir, sessionId)\"\nRight: [calls Grep, then Read] \"Session workspaces get created in two places inside the direct session setup. One fires when the SDK assigns the real session ID at the start of a new session. The other fires immediately on startup when you are resuming, since we already know the session ID. Both call the same ensureSessionWorkspace helper in config.\"\n\nEXAMPLE 3 \u2014 Action task:\nUser: \"add a console log to the top of createDirectSession\"\nWrong: [calls Edit] \"I have added: console.log('Creating direct session...') to line 647.\"\nRight: [calls Read, then Edit] \"Done. I added a log at the top of createDirectSession that prints the voice mode and working directory, so you can confirm which config is active when the session starts.\"\n\nEXAMPLE 4 \u2014 Enumeration without a list:\nUser: \"what voice providers does osborn support\"\nWrong: \"Osborn supports: 1. Deepgram 2. ElevenLabs 3. OpenAI 4. Google\"\nRight: \"Osborn has plugins for four voice providers. Deepgram is the default for both speech-to-text and text-to-speech. ElevenLabs is available for higher quality TTS. OpenAI covers both directions and also powers the realtime speech-to-speech mode. And Google's plugin handles Gemini native audio for realtime.\"\n\nEXAMPLE 5 \u2014 Error explanation:\nUser: \"why is it crashing\"\nWrong: \"TypeError: Cannot read properties of undefined (reading 'sessionId') at index.ts:334\"\nRight: \"It is crashing in index.ts around line three thirty-four because it is trying to read the session ID off an object that is undefined at that point. That usually means the LLM client has not been fully initialized before something downstream tries to access it.\"\n\nEXAMPLE 6 \u2014 Multi-step research (sub-agent):\nUser: \"compare our current SDK version with the latest and tell me what changed\" \nWrong: [runs 8 sequential tool calls, user waits 45 seconds in silence] \nRight: [spawns Task sub-agent immediately, speaks to user] \"Let me kick off that research now. I've started a sub-agent to pull both versions and diff the changelogs.\" [when sub-agent returns] \"The main differences are in three areas. First, version two adds a native streaming interrupt API...\" EXAMPLE 7 \u2014 Content that belongs in a file: User: \"show me all the changes we made this session\" Wrong: [reads out entire git diff line by line] Right: [writes diff to session workspace file] \"There are eight modified files with significant changes. The biggest ones are in the LLM pipeline, the VAD settings, and the prompts. I've written the full file-by-file breakdown to your session files so you can review the exact diffs.\"\n</examples>";
67
67
  export declare function getRealtimeInstructions(workingDir: string): string;
68
68
  export declare function getDirectModeResearchPrompt(workspacePath: string | null): string;
69
69
  export declare function getResearchSystemPrompt(workspacePath: string | null): string;
package/dist/prompts.js CHANGED
@@ -96,6 +96,8 @@ const PROMPTS_FILE_DIR = join(__dirname, 'prompts');
96
96
  export const DIRECT_MODE_PROMPT = `<context>
97
97
  You are Osborn, a voice AI assistant operating in direct mode. In this mode the user speaks, their words are transcribed to text, you respond, and your response is read aloud by a text-to-speech engine.
98
98
 
99
+ You are Osborn and nothing else — if asked what model, AI, company, or provider is behind you, never name, guess, or speculate about any underlying model or provider; say only that you are Osborn.
100
+
99
101
  You have access to a full set of tools — you can read files, search the web, run commands, edit code, use MCP integrations, and more. You are not limited to coding tasks. You handle research, conversation, debugging, file work, automation, and anything else the user brings to you.
100
102
 
101
103
  The pipeline is: user voice → speech-to-text transcription → you → text-to-speech playback. Everything you write gets spoken aloud verbatim. The TTS engine reads punctuation as pauses, not as symbols. It handles natural prose well. It handles code blocks, markdown syntax, and raw symbols very poorly — those produce awkward or broken audio.
@@ -1769,6 +1771,7 @@ export function buildFastBrainSdkPrompt(workingDir, sessionId, _sessionBaseDir)
1769
1771
  const jsonlPath = join(jsonlDir, `${sessionId}.jsonl`);
1770
1772
  return `You are Osborn's fast brain — the central intelligence for a voice AI engineer and thinking partner.
1771
1773
  Your output will be spoken aloud by a voice model as a teleprompter script.
1774
+ You are Osborn and nothing else — if asked what model, AI, company, or provider is behind you, never name, guess, or speculate about any underlying model or provider; say only that you are Osborn.
1772
1775
 
1773
1776
  == YOUR ROLE ==
1774
1777
  - Answer questions using session workspace files, research JSONL data, and web search
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Session-switch decision (#74) — pure, no I/O.
3
+ *
4
+ * Decides which Claude session the NEXT user message runs in, given what the
5
+ * persistent query is running now, any armed/pending switch, and whether a turn
6
+ * is in flight. Also says what happens to the session being left.
7
+ *
8
+ * Why this exists: a switch used to only ARM a resume target
9
+ * (setResumeSessionId). While a persistent query was live, pushMessage's fast
10
+ * path kept pushing into it, so the next turn ran in the OLD session and init
11
+ * then reported session_resume_failed {requested: new, actual: old}. Any caller
12
+ * that is about to push a message (or that handles an explicit switch request)
13
+ * asks this function first; 'switch' means the live query must be rebuilt on
14
+ * `runIn` before the message is delivered.
15
+ *
16
+ * Owner decision (2026-11-10): the session being left KEEPS WORKING in the
17
+ * background until its current turn finishes — it is never aborted. So a busy
18
+ * session is never 'close'd here; it is 'background'.
19
+ */
20
+ export interface SessionSwitchState {
21
+ /** Session id the live query reported via SDK init (null until the first init). */
22
+ liveSessionId: string | null;
23
+ /** The `resume` id the live query was spawned with (null = started fresh / no query). */
24
+ queryResumeTarget: string | null;
25
+ /** The currently armed resume target (setResumeSessionId / opts.resumeSessionId). */
26
+ resumeTarget: string | null;
27
+ /** Explicit switch request (switch_session / Rooms click). Wins over resumeTarget. */
28
+ requestedTarget?: string | null;
29
+ /** A persistent query (subprocess) is alive. */
30
+ hasLiveQuery: boolean;
31
+ /** A turn (or work it started) is still running in the live query. */
32
+ turnInFlight: boolean;
33
+ }
34
+ export type SessionSwitchAction =
35
+ /** Deliver into the live query — it is already running `runIn`. */
36
+ 'push'
37
+ /** No live query: the next message cold-starts (resuming `runIn`, or new when null). */
38
+ | 'cold-start'
39
+ /** The live query runs a different session: rebuild it on `runIn` first. */
40
+ | 'switch';
41
+ export type LeftSessionFate =
42
+ /** Nothing is being left. */
43
+ 'none'
44
+ /** The left session is idle — closing its subprocess loses nothing. */
45
+ | 'close'
46
+ /** The left session has work in flight — keep it running in the background. */
47
+ | 'background';
48
+ export interface SessionSwitchDecision {
49
+ action: SessionSwitchAction;
50
+ /** Session the next message runs in (null = a brand-new session). */
51
+ runIn: string | null;
52
+ leave: LeftSessionFate;
53
+ }
54
+ export declare function decideNextSession(state: SessionSwitchState): SessionSwitchDecision;
55
+ export interface SwitchPlanContext {
56
+ /** A permission prompt is waiting on the user in the current session. */
57
+ permissionPending: boolean;
58
+ /** A Recall meeting bot is live (its transcript feeds the current session). */
59
+ meetingActive: boolean;
60
+ /** The target already runs as a background slot: none / idle / busy. */
61
+ targetSlot: 'none' | 'idle' | 'busy';
62
+ /** User chose "Switch now". */
63
+ force: boolean;
64
+ /** Phase 2: a busy session can be demoted to the background instead of closed. */
65
+ demoteSupported: boolean;
66
+ }
67
+ export type SwitchPlanKind = 'noop' | 'execute' | 'defer' | 'reject';
68
+ export type SwitchPlanReason = 'already_live' | 'meeting_active' | 'target_busy_in_background' | 'needs_you' | 'busy' | 'forced' | 'idle' | 'no_live_query' | 'demote';
69
+ export interface SwitchPlan {
70
+ kind: SwitchPlanKind;
71
+ reason: SwitchPlanReason;
72
+ /** What happens to the session being left when this executes. */
73
+ leave: LeftSessionFate;
74
+ /** The target runs as an idle background slot: stop it before resuming it. */
75
+ stopSlotFirst: boolean;
76
+ }
77
+ export declare function planSwitch(decision: SessionSwitchDecision, ctx: SwitchPlanContext): SwitchPlan;
78
+ export interface SessionCwdDeps {
79
+ /** sessionExists(id, projectPath) from config.ts. */
80
+ exists: (sessionId: string, cwd: string) => boolean;
81
+ /** Routing cwd from listAllClaudeSessions() (slug-derived), or null. */
82
+ listCwd: (sessionId: string) => Promise<string | null | undefined>;
83
+ /** Last resort: find <id>.jsonl in any project slug and decode its cwd. */
84
+ scanCwd: (sessionId: string) => Promise<string | null | undefined>;
85
+ }
86
+ /**
87
+ * The project directory a session's JSONL resolves under (what `--resume`
88
+ * needs as cwd): the client's hint if the session really lives there, else
89
+ * the current dir, else the session list's routing cwd, else a slug scan.
90
+ * null = the session does not exist ("Session not found"). A candidate is
91
+ * only returned after `exists()` confirms it.
92
+ */
93
+ export declare function resolveSessionCwd(sessionId: string, hint: string | null | undefined, currentDir: string | null | undefined, deps: SessionCwdDeps): Promise<string | null>;
94
+ /**
95
+ * chatCtx rebuild on switch (4.13): keep the agent's non-conversation items
96
+ * (instructions, system/developer notes, non-message items) and drop the old
97
+ * session's user/assistant turns so the fast brain and noise gate stop
98
+ * reasoning over the session that was left.
99
+ */
100
+ export declare function keepNonConversationItems<T extends {
101
+ type?: string;
102
+ role?: string;
103
+ }>(items: T[] | null | undefined): T[];
104
+ /**
105
+ * Session to resume when the voice session auto-recovers (D7): the live id,
106
+ * else the session the user switched to (B may not have had its first turn,
107
+ * so it has no live id yet), else the connect-time id.
108
+ */
109
+ export declare function recoverySessionId(ids: {
110
+ liveSessionId: string | null | undefined;
111
+ switchedTo: string | null | undefined;
112
+ connectTime: string | null | undefined;
113
+ }): string | undefined;
114
+ /** Keep-warm key: the init id, else the id the live query was spawned for. */
115
+ export declare function warmParkKey(llm: {
116
+ sessionId?: string | null;
117
+ spawnedResumeId?: string | null;
118
+ } | null | undefined): string | null;
119
+ /**
120
+ * Directory /session-messages reads a session's store from (S8): the
121
+ * requested workingDirectory only when the session really lives there,
122
+ * otherwise the agent's boot dir (today's behaviour). Never trusts the param.
123
+ */
124
+ export declare function sessionMessagesDir(sessionId: string, requested: string | null | undefined, bootDir: string, exists: (sessionId: string, cwd: string) => boolean): string;
125
+ /**
126
+ * Single-flight guard for performSessionSwitch. Only the critical section
127
+ * (teardown + arm + session_switched) holds the guard; `after` (the spoken
128
+ * acknowledgment) runs fire-and-forget once it is released, so a say() that
129
+ * never resolves can't wedge every later switch. A request that arrives while
130
+ * the guard is held returns { ran: false } — the caller must reply so the UI
131
+ * never hangs.
132
+ */
133
+ export declare function createSwitchGuard(): {
134
+ readonly busy: boolean;
135
+ run<T>(critical: () => Promise<T>, after?: (result: T) => unknown): Promise<{
136
+ ran: true;
137
+ result: T;
138
+ } | {
139
+ ran: false;
140
+ }>;
141
+ };
142
+ /**
143
+ * Find a session's project dir by scanning ~/.claude/projects/<slug>/<id>.jsonl
144
+ * and decoding the slug (the same recovery resume_session has always used).
145
+ * The decoding is lossy, so only a decoded path that EXISTS is returned — the
146
+ * switch executor never creates directories for scan-derived paths.
147
+ */
148
+ export declare function scanSlugCwd(sessionId: string, projectsDir: string, fsx: {
149
+ readdir: (dir: string) => string[];
150
+ exists: (path: string) => boolean;
151
+ }): Promise<string | null>;
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Session-switch decision (#74) — pure, no I/O.
3
+ *
4
+ * Decides which Claude session the NEXT user message runs in, given what the
5
+ * persistent query is running now, any armed/pending switch, and whether a turn
6
+ * is in flight. Also says what happens to the session being left.
7
+ *
8
+ * Why this exists: a switch used to only ARM a resume target
9
+ * (setResumeSessionId). While a persistent query was live, pushMessage's fast
10
+ * path kept pushing into it, so the next turn ran in the OLD session and init
11
+ * then reported session_resume_failed {requested: new, actual: old}. Any caller
12
+ * that is about to push a message (or that handles an explicit switch request)
13
+ * asks this function first; 'switch' means the live query must be rebuilt on
14
+ * `runIn` before the message is delivered.
15
+ *
16
+ * Owner decision (2026-11-10): the session being left KEEPS WORKING in the
17
+ * background until its current turn finishes — it is never aborted. So a busy
18
+ * session is never 'close'd here; it is 'background'.
19
+ */
20
+ const norm = (v) => (typeof v === 'string' && v.length > 0 ? v : null);
21
+ export function decideNextSession(state) {
22
+ const liveId = norm(state.liveSessionId);
23
+ const spawnedFor = norm(state.queryResumeTarget);
24
+ const armed = norm(state.resumeTarget);
25
+ const requested = norm(state.requestedTarget);
26
+ if (!state.hasLiveQuery) {
27
+ return { action: 'cold-start', runIn: requested ?? armed ?? liveId, leave: 'none' };
28
+ }
29
+ // What the live query is actually running. Before its first init the id is
30
+ // unknown, but a query spawned with `resume: X` is running X.
31
+ const running = liveId ?? spawnedFor;
32
+ // An armed target counts as a pending switch only if this query was not
33
+ // already spawned for it. If it was (and init reported a different id), the
34
+ // resume was attempted and the SDK fell back — rebuilding again on every turn
35
+ // would loop, so that case stays on the live query.
36
+ const pending = armed && armed !== spawnedFor && armed !== running ? armed : null;
37
+ const target = requested ?? pending;
38
+ if (!target || target === running) {
39
+ return { action: 'push', runIn: running, leave: 'none' };
40
+ }
41
+ return { action: 'switch', runIn: target, leave: state.turnInFlight ? 'background' : 'close' };
42
+ }
43
+ export function planSwitch(decision, ctx) {
44
+ const stopSlotFirst = ctx.targetSlot === 'idle';
45
+ const plan = (kind, reason, leave = 'none') => ({ kind, reason, leave, stopSlotFirst: kind === 'execute' && stopSlotFirst });
46
+ if (decision.action === 'push')
47
+ return plan('noop', 'already_live');
48
+ // The meeting transcript and the meeting brain belong to the current session.
49
+ if (ctx.meetingActive)
50
+ return plan('reject', 'meeting_active');
51
+ // Never run a second process on a JSONL a busy background slot is writing.
52
+ if (ctx.targetSlot === 'busy')
53
+ return plan('reject', 'target_busy_in_background');
54
+ if (decision.action === 'cold-start')
55
+ return plan('execute', 'no_live_query');
56
+ if (decision.leave === 'background') {
57
+ if (ctx.demoteSupported)
58
+ return plan('execute', 'demote', 'background');
59
+ if (ctx.force)
60
+ return plan('execute', 'forced', 'close');
61
+ if (ctx.permissionPending)
62
+ return plan('reject', 'needs_you');
63
+ return plan('defer', 'busy');
64
+ }
65
+ return plan('execute', 'idle', decision.leave);
66
+ }
67
+ /**
68
+ * The project directory a session's JSONL resolves under (what `--resume`
69
+ * needs as cwd): the client's hint if the session really lives there, else
70
+ * the current dir, else the session list's routing cwd, else a slug scan.
71
+ * null = the session does not exist ("Session not found"). A candidate is
72
+ * only returned after `exists()` confirms it.
73
+ */
74
+ export async function resolveSessionCwd(sessionId, hint, currentDir, deps) {
75
+ if (!sessionId)
76
+ return null;
77
+ for (const c of [hint, currentDir]) {
78
+ if (c && deps.exists(sessionId, c))
79
+ return c;
80
+ }
81
+ for (const lookup of [deps.listCwd, deps.scanCwd]) {
82
+ let c = null;
83
+ try {
84
+ c = await lookup(sessionId);
85
+ }
86
+ catch {
87
+ c = null;
88
+ }
89
+ if (c && deps.exists(sessionId, c))
90
+ return c;
91
+ }
92
+ return null;
93
+ }
94
+ /**
95
+ * chatCtx rebuild on switch (4.13): keep the agent's non-conversation items
96
+ * (instructions, system/developer notes, non-message items) and drop the old
97
+ * session's user/assistant turns so the fast brain and noise gate stop
98
+ * reasoning over the session that was left.
99
+ */
100
+ export function keepNonConversationItems(items) {
101
+ return (items ?? []).filter((it) => it?.type !== 'message' || (it.role !== 'user' && it.role !== 'assistant'));
102
+ }
103
+ /**
104
+ * Session to resume when the voice session auto-recovers (D7): the live id,
105
+ * else the session the user switched to (B may not have had its first turn,
106
+ * so it has no live id yet), else the connect-time id.
107
+ */
108
+ export function recoverySessionId(ids) {
109
+ return ids.liveSessionId || ids.switchedTo || ids.connectTime || undefined;
110
+ }
111
+ /** Keep-warm key: the init id, else the id the live query was spawned for. */
112
+ export function warmParkKey(llm) {
113
+ return llm?.sessionId || llm?.spawnedResumeId || null;
114
+ }
115
+ /**
116
+ * Directory /session-messages reads a session's store from (S8): the
117
+ * requested workingDirectory only when the session really lives there,
118
+ * otherwise the agent's boot dir (today's behaviour). Never trusts the param.
119
+ */
120
+ export function sessionMessagesDir(sessionId, requested, bootDir, exists) {
121
+ if (requested && sessionId) {
122
+ try {
123
+ if (exists(sessionId, requested))
124
+ return requested;
125
+ }
126
+ catch { /* fall through */ }
127
+ }
128
+ return bootDir;
129
+ }
130
+ // ── Review minors ────────────────────────────────────────────────────────────
131
+ /**
132
+ * Single-flight guard for performSessionSwitch. Only the critical section
133
+ * (teardown + arm + session_switched) holds the guard; `after` (the spoken
134
+ * acknowledgment) runs fire-and-forget once it is released, so a say() that
135
+ * never resolves can't wedge every later switch. A request that arrives while
136
+ * the guard is held returns { ran: false } — the caller must reply so the UI
137
+ * never hangs.
138
+ */
139
+ export function createSwitchGuard() {
140
+ let busy = false;
141
+ return {
142
+ get busy() { return busy; },
143
+ async run(critical, after) {
144
+ if (busy)
145
+ return { ran: false };
146
+ busy = true;
147
+ let result;
148
+ try {
149
+ result = await critical();
150
+ }
151
+ finally {
152
+ busy = false;
153
+ }
154
+ if (after) {
155
+ try {
156
+ void Promise.resolve(after(result)).catch(() => { });
157
+ }
158
+ catch { /* sync throw */ }
159
+ }
160
+ return { ran: true, result };
161
+ },
162
+ };
163
+ }
164
+ /**
165
+ * Find a session's project dir by scanning ~/.claude/projects/<slug>/<id>.jsonl
166
+ * and decoding the slug (the same recovery resume_session has always used).
167
+ * The decoding is lossy, so only a decoded path that EXISTS is returned — the
168
+ * switch executor never creates directories for scan-derived paths.
169
+ */
170
+ export async function scanSlugCwd(sessionId, projectsDir, fsx) {
171
+ if (!sessionId || !fsx.exists(projectsDir))
172
+ return null;
173
+ let slugs = [];
174
+ try {
175
+ slugs = fsx.readdir(projectsDir);
176
+ }
177
+ catch {
178
+ return null;
179
+ }
180
+ for (const slug of slugs) {
181
+ if (!fsx.exists(`${projectsDir}/${slug}/${sessionId}.jsonl`))
182
+ continue;
183
+ const recovered = slug.replace(/^-/, '/').replace(/--/g, '/.').replace(/-/g, '/');
184
+ if (recovered && recovered !== '/' && fsx.exists(recovered))
185
+ return recovered;
186
+ }
187
+ return null;
188
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osborn",
3
- "version": "0.9.274",
3
+ "version": "0.9.276",
4
4
  "description": "Voice AI coding assistant - local agent that connects to Osborn frontend",
5
5
  "type": "module",
6
6
  "bin": {