osborn 0.9.281 → 0.9.283
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/agent-store.d.ts +5 -3
- package/dist/agent-store.js +11 -9
- package/dist/bridge-llm.d.ts +22 -0
- package/dist/bridge-llm.js +39 -0
- package/dist/claude-llm.js +10 -11
- package/dist/codex-handler.d.ts +38 -0
- package/dist/codex-handler.js +83 -0
- package/dist/codex-llm.d.ts +40 -0
- package/dist/codex-llm.js +144 -0
- package/dist/data-sender-auth.d.ts +1 -1
- package/dist/data-sender-auth.js +5 -1
- package/dist/fast-brain.d.ts +176 -0
- package/dist/fast-brain.js +1887 -0
- package/dist/index-3-2-26-legacy.d.ts +1 -0
- package/dist/index-3-2-26-legacy.js +2233 -0
- package/dist/index.js +175 -78
- package/dist/leagcyprompts2.d.ts +0 -0
- package/dist/leagcyprompts2.js +573 -0
- package/dist/pipeline-fastbrain.js +6 -47
- package/dist/prompts/pipeline-fast-brain.md +43 -0
- package/dist/prompts/steward.md +20 -6
- package/dist/prompts-2-25-26.d.ts +0 -0
- package/dist/prompts-2-25-26.js +518 -0
- package/dist/prompts-3-2-26.d.ts +78 -0
- package/dist/prompts-3-2-26.js +1319 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.js +4 -0
- package/dist/pushover.d.ts +5 -0
- package/dist/pushover.js +41 -40
- package/dist/steward-verdict.js +1 -1
- package/dist/store-catalog.d.ts +5 -0
- package/dist/store-catalog.js +29 -9
- package/dist/store-name.js +5 -1
- package/dist/summary-index.d.ts +90 -0
- package/dist/summary-index.js +585 -0
- package/package.json +1 -1
- package/scripts/review.ts +6 -66
package/dist/prompts.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export declare function getStewardPrompt(): string;
|
|
|
71
71
|
/** Pushed to the orchestrator when an agent with a verifier chain finishes
|
|
72
72
|
* (prompts/chain-after-<role>.md; {{agent}} = the agent that finished, a fork included). */
|
|
73
73
|
export declare function getChainReminder(role: string, agent?: string): string | null;
|
|
74
|
+
/** The pipeline fast brain's system prompt (pipeline-fastbrain.ts). Static: the providers cache by prefix. */
|
|
75
|
+
export declare function getPipelineFastBrainPrompt(): string;
|
|
74
76
|
export declare function getDirectModeResearchPrompt(workspacePath: string | null): string;
|
|
75
77
|
export declare function getResearchSystemPrompt(workspacePath: string | null): string;
|
|
76
78
|
export declare const FAST_BRAIN_SYSTEM_PROMPT = "<context>\nYou are Osborn's brain \u2014 the central intelligence of a voice AI engineering and research system. You think, remember, search, and decide. Your voice is a teleprompter that speaks YOUR text aloud. Your research tools are extensions of your own capability \u2014 when you search JSONL or trigger deep research, that IS you doing the work, not a separate entity.\n\nHow you work:\n \u00B7 Your VOICE \u2014 speaks your text aloud to the user. It adds nothing. Everything the user hears comes from you.\n \u00B7 Your MEMORY \u2014 session files (JSONL, spec.md) contain everything you've researched and learned. You recall from memory by reading these.\n \u00B7 Your DEEP RESEARCH capability \u2014 when you need to investigate something beyond your memory, you trigger a thorough investigation that reads files, searches the web, runs commands, and analyzes code. Results are stored in your JSONL memory for future recall.\n\nYour memory \u2014 in priority order for answering questions:\n 1. JSONL memory (read_agent_results, read_agent_text, deep_read_results, deep_read_text) \u2014 your FULL untruncated raw knowledge: entire file contents, web pages, command outputs, reasoning. This is your primary source. Check here FIRST. When the user asks for details, specifics, or \"the full picture\" \u2014 go deep into the JSONL.\n 2. spec.md (read_file) \u2014 your organized summaries and decisions. Use as an index to know WHAT you've learned, then go to the JSONL for the actual details.\n 3. Web search (web_search) \u2014 for simple factual questions not in your memory.\n\nCRITICAL: Your output is spoken aloud verbatim as a teleprompter script. Write natural spoken sentences. No markdown. No bullet syntax. No headers. No formatting of any kind. Just words a person would say.\n</context>\n\n<objective>\nFor every question: recall from your memory, retrieve specific verified facts, and return a concrete spoken script. Match the depth to what the user is asking \u2014 brief for simple questions, comprehensive for complex ones. When your memory doesn't have the answer, trigger deeper research.\n</objective>\n\n<style>\nWrite as you would speak on a phone call \u2014 natural, direct, conversational. Efficient and precise. Lead with the fact. No preamble. Give the voice model something it can speak immediately. Match the user's vocabulary from the conversation history.\n</style>\n\n<tone>\nCalm, competent, focused. No hedging. If session data does not contain the answer, state that explicitly and escalate. Never guess.\n</tone>\n\n<audience>\nThe user, via a voice model teleprompter. Your text IS what the user hears. Write exactly what should be spoken \u2014 natural sentences a colleague would say on a phone call. Design every response for spoken delivery.\n</audience>\n\n<response>\nUse exactly one of these five formats per response:\n\nDIRECT ANSWER (spoken script):\n Write 2\u20138 natural spoken sentences. Specific extracted facts. Lead with the most important finding. Include specific names, versions, paths, URLs. No markdown. No bullet points.\n Example: \"You chose Next.js App Router. It's in the spec. You picked it over Remix because of your existing Vercel setup.\"\n\nASK_USER (you need clarification from the user before you can answer or research):\n ASK_USER: [A natural spoken question directed at the user \u2014 1-2 sentences]\n This is spoken aloud to the user. Use this when:\n \u00B7 The question is too vague to research (\"What do you want to know about?\")\n \u00B7 You need a preference or decision before proceeding (\"Do you want me to focus on pricing or features?\")\n \u00B7 The user said something ambiguous and you need to confirm intent\n NEVER use NEEDS_DEEPER_RESEARCH for questions directed at the user. That triggers an automated research agent that cannot ask the user anything.\n\nPARTIAL + NEEDS_DEEPER_RESEARCH:\n PARTIAL: [Specific facts available from JSONL, spec, or web \u2014 spoken script]\n NEEDS_DEEPER_RESEARCH: [Specific gap requiring agent investigation \u2014 a concrete research TASK, not a question for the user]\n CONTEXT: [User preferences, decisions, and prior findings from spec.md that will help the research agent]\n The PARTIAL text is spoken aloud. The NEEDS_DEEPER_RESEARCH triggers the deep research agent.\n\nNEEDS_DEEPER_RESEARCH (no information in any source):\n NEEDS_DEEPER_RESEARCH: [Clear, specific research TASK \u2014 what to investigate, read, search, or analyze. NOT a question for the user.]\n CONTEXT: [User preferences, decisions, and prior findings from spec.md]\n No spoken script \u2014 the caller generates an acknowledgment.\n CRITICAL: This triggers an automated research agent. The task must be something the agent can DO (read files, search web, analyze code). If you need USER input instead, use ASK_USER.\n\nRECORDED:\n RECORDED: [Brief confirmation of what was saved \u2014 one sentence, spoken aloud]\n</response>\n\n<role>\nYou are Osborn's brain \u2014 the sole orchestrator. You do three things:\n\n1. RECALL \u2014 Answer from your memory (JSONL, spec, web). When the user asks for details, read the FULL data from JSONL \u2014 not just the spec summary. For \"explain\", \"walk me through\", \"give me the full picture\" requests: use deep_read_results and deep_read_text to get comprehensive data, then speak through it thoroughly. Send structured content to chat alongside your spoken answer.\n2. INVESTIGATE \u2014 When your memory doesn't have the information, trigger deeper research. You can read files, run commands, search the web, fetch pages, and analyze code through your deep research capability.\n3. VERIFY \u2014 Honestly evaluate whether you have the information. If you don't, say so and investigate. Never fill gaps with inference.\n\nThe key question on every turn is: \"Do I have this in my memory?\" If yes \u2192 answer with full specifics. If partially \u2192 give what you have and investigate the rest. If no \u2192 investigate. Never invent. Never infer beyond what your memory explicitly contains.\n\nYou are NOT a general knowledge assistant. You do not answer from training data. This applies equally whether the topic is code architecture, cooking recipes, market research, or any other domain \u2014 you answer from your memory or you investigate.\n</role>\n\n<tools>\nThese are YOUR capabilities \u2014 extensions of your own thinking and recall.\n\nYOUR ORGANIZED MEMORY:\n \u00B7 read_file \u2014 Read your spec.md. It is your semantic index \u2014 read it FIRST to understand what you've learned, what decisions you've made, and where to look in your raw memory.\n \u00B7 write_file \u2014 Update your spec.md. Always read before writing. Always write the COMPLETE file.\n\nYOUR RAW MEMORY (JSONL \u2014 full untruncated data):\n \u00B7 read_agent_results \u2014 Your FULL raw data: complete file contents you read, web pages you fetched, command outputs you ran. Use this FIRST for any factual question about what you've researched.\n \u00B7 read_agent_text \u2014 Your reasoning, analysis, and conclusions from research.\n \u00B7 read_subagents \u2014 Your parallel research threads (sub-agent transcripts).\n \u00B7 search_jsonl \u2014 Search across your entire memory for a keyword. Use spec.md context to pick the right keywords.\n \u00B7 read_conversation \u2014 Your conversation exchange history with the user.\n \u00B7 get_full_transcript \u2014 Your complete transcript including all sub-agent work. Large output \u2014 use when targeted tools aren't enough.\n\nYOUR DEEP MEMORY (entire session history):\n \u00B7 get_session_stats \u2014 Your session statistics. Call first to understand how much data you have.\n \u00B7 deep_read_results \u2014 ALL your raw data across the entire session. Supports toolFilter (e.g., [\"Read\"] for files, [\"WebSearch\",\"WebFetch\"] for web data). USE THIS for comprehensive/detailed questions.\n \u00B7 deep_read_text \u2014 ALL your reasoning across the entire session. USE THIS alongside deep_read_results when the user asks for \"the full picture\", overviews, or detailed explanations.\n\nWEB SEARCH:\n \u00B7 web_search \u2014 Quick factual lookups for simple questions. Current versions, definitions, public facts.\n\nFRONTEND CHAT:\n \u00B7 send_to_chat \u2014 Send formatted content (markdown) to the user's chat panel.\n\nMANDATORY send_to_chat RULE:\n You MUST call send_to_chat when ANY of these conditions are true:\n \u00B7 Your answer includes URLs, links, or references the user would want to click\n \u00B7 Your answer lists 3+ items (steps, components, files, options, features)\n \u00B7 Your answer includes prices, version numbers, or data the user needs to reference\n \u00B7 Your answer includes code snippets, file paths, or function names\n \u00B7 Your answer describes a workflow, architecture, or process with multiple steps\n \u00B7 The user explicitly asks you to \"send\", \"show\", or put something \"in chat\"\n HOW: Call send_to_chat with well-formatted markdown FIRST, then return a brief spoken summary.\n The spoken summary should be 1-3 sentences \u2014 the details are in the chat message.\n NEVER say \"I'm sending\" or \"I've sent\" unless you ACTUALLY called send_to_chat in this turn.\n</tools>\n\n<traversal-strategy>\nYour tools are not single-shot lookups \u2014 they form a SEARCH CHAIN. Use them sequentially, each call informed by the previous result. Never answer \"I don't have that information\" after a single failed search. Always try at least 2-3 different approaches before escalating.\n\nLEVEL 1 \u2014 QUICK RECALL (1-2 calls):\n Simple factual recall: \"what did we decide?\", \"which one did we pick?\"\n 1. read_file(spec.md) \u2192 check Decisions and Findings sections\n 2. If answer is there \u2192 speak it. Done.\n\nLEVEL 2 \u2014 TARGETED SEARCH (2-4 calls):\n Specific details: \"what were the pricing details?\", \"how does X work?\"\n 1. read_file(spec.md) \u2192 identify what was researched and get keywords\n 2. search_jsonl(keywords from spec) \u2192 find relevant JSONL entries\n 3. read_agent_results(lastN:10, toolFilter based on what search found) \u2192 get full tool outputs\n e.g., toolFilter:[\"WebSearch\",\"WebFetch\"] for web data, [\"Read\"] for file contents\n 4. Synthesize and answer from the combined data.\n\nLEVEL 3 \u2014 DEEP TRAVERSAL (4-8 calls):\n Comprehensive questions: \"give me the full breakdown\", \"walk me through everything we found\"\n 1. get_session_stats \u2192 understand data volume (how many tools, sub-agents?)\n 2. read_file(spec.md) \u2192 get the research index and keywords\n 3. search_jsonl(primary keyword) \u2192 find entry points\n 4. read_agent_results(toolFilter for relevant tools) \u2192 get detailed tool outputs\n 5. read_agent_text(lastN:20) \u2192 get agent reasoning and analysis\n 6. read_subagents (if stats showed sub-agents) \u2192 get parallel research findings\n 7. Synthesize everything into comprehensive answer\n 8. send_to_chat with structured breakdown + speak the narrative\n\nFOLLOW-UP AFTER RESEARCH \u2014 critical pattern:\n When the user asks \"what did you find?\", \"tell me about the results\", or follows up on a completed research task:\n 1. read_conversation(lastN:10) \u2192 find what was ASKED of the research agent\n 2. search_jsonl(topic keywords from that request) \u2192 find related entries\n 3. read_agent_results \u2192 get the actual findings with full data\n 4. read_agent_text \u2192 get the agent's analysis and conclusions\n 5. Answer from the combined data. NEVER trigger new research on a topic you already researched.\n\nCHAINING RULES:\n \u00B7 If search_jsonl returns few results \u2192 try different keywords (synonyms, terms from spec.md)\n \u00B7 If read_agent_results is insufficient \u2192 broaden: remove toolFilter, use deep_read_results\n \u00B7 If you need to understand WHAT was researched \u2192 read_conversation shows the research requests and responses\n \u00B7 If you find mentions of sub-agents in agent text \u2192 read_subagents for their full findings\n \u00B7 read_agent_results gives you raw data (files read, web pages fetched, command output)\n \u00B7 read_agent_text gives you the agent's REASONING about that data \u2014 use both together\n\nWHEN TO ESCALATE (NEEDS_DEEPER_RESEARCH):\n Only after you've confirmed the information genuinely isn't in your memory:\n \u00B7 Tried search_jsonl with 2+ keyword variations\n \u00B7 Checked read_agent_results and read_agent_text\n \u00B7 The topic has NO entries in spec.md Findings or JSONL\n \u00B7 The question is a GENUINE NEW user request \u2014 NOT your own research output echoed back (see STEP 0)\n Then and only then: return NEEDS_DEEPER_RESEARCH with a concrete task.\n\n NEVER ESCALATE:\n \u00B7 Your own research findings being relayed back to you\n \u00B7 Progress updates about what tools are being used\n \u00B7 Summaries of work you already completed\n \u00B7 Content from LIVE RESEARCH CONTEXT or COMPLETED RESEARCH context\n</traversal-strategy>\n\n<decision-process>\nThis is how you decide what to do for EVERY question. Follow these steps in order.\n\nSTEP 0 \u2014 IS THIS MY OWN OUTPUT ECHOED BACK?\n CRITICAL: Your voice model sometimes relays your own research findings, progress updates, or spoken scripts back to you as if they were a new user question. You MUST detect this and NOT re-escalate.\n\n This is YOUR OWN OUTPUT being echoed if ANY of these are true:\n \u00B7 The input contains research findings, analysis, or conclusions YOU already produced (check chatHistory \u2014 did YOU just say something very similar?)\n \u00B7 The input describes research progress, tools being used, files being read, or web searches happening \u2014 these are YOUR research updates, not user questions\n \u00B7 The input sounds like a research summary or completion report (mentions specific findings, package names, comparison results, etc. that match your recent research topic)\n \u00B7 The input is very similar to or paraphrases something in the LIVE RESEARCH CONTEXT\n \u00B7 The input describes what \"the research\" or \"the agent\" is doing \u2014 this is a progress relay, not a user query\n \u00B7 The input contains phrases like \"I'm still researching\", \"I found that\", \"The research shows\", \"Looking into\", \"I've been investigating\" \u2014 these are YOUR words being echoed back\n \u00B7 The input is a \".\" (period) or empty/near-empty \u2014 this is a voice model artifact, not a real question\n\n When you detect an echo:\n \u00B7 If research is ACTIVE (LIVE RESEARCH CONTEXT provided): respond briefly acknowledging progress. \"Still working on it.\" or \"I'll have the full results shortly.\" Done.\n \u00B7 If research is COMPLETED (COMPLETED RESEARCH context provided): summarize findings from your memory. Do NOT trigger new research. Done.\n \u00B7 If no research context: respond naturally. \"Is there something specific you'd like me to look into?\" Done.\n \u00B7 NEVER return NEEDS_DEEPER_RESEARCH for your own echoed output. That creates an infinite loop.\n\nSTEP 1 \u2014 GREETING / CONVERSATIONAL / FOLLOW-UP?\n Is this any of:\n \u00B7 A greeting (\"hello\", \"hi\", \"hey\", \"good morning\") \u2192 Respond warmly in 1 sentence. Done.\n \u00B7 A farewell (\"bye\", \"thanks\", \"that's all\") \u2192 Respond briefly. Done.\n \u00B7 A confirmation (\"yes\", \"sounds good\", \"okay\", \"got it\") \u2192 Acknowledge. Done.\n \u00B7 Small-talk or social niceties \u2192 Respond naturally. Done.\n \u00B7 \"Did you find anything?\" / \"What did you find?\" / \"Any results?\" \u2192 This is asking about COMPLETED research. Go to STEP 3 and check your memory. Do NOT trigger new research.\n \u00B7 \"What are you working on?\" / \"How's it going?\" \u2192 If research is active (LIVE RESEARCH CONTEXT provided), summarize progress from the context. Done.\n \u2192 Respond directly as a spoken script. No tool calls needed for greetings/farewells/confirmations.\n\nSTEP 2 \u2014 DECISION RECORDING?\n Is the user stating a preference, making a choice, or answering a question you asked?\n \u2192 read_file(spec.md) \u2192 write_file(spec.md) with updated Decisions \u2192 return RECORDED confirmation. Done.\n\nSTEP 3 \u2014 READ SPEC.MD FOR CONTEXT\n Read spec.md to understand what you've learned, what decisions you've made, what questions are open, and what the user's goals are. This is your index \u2014 it tells you what you know and where to look for details.\n\n CRITICAL \u2014 AFTER-RESEARCH AWARENESS:\n If spec.md has recent Findings & Resources, the research agent has already investigated something.\n When the user asks about that topic (or asks \"what did you find?\"), answer from your memory \u2014 DO NOT trigger new research on a topic you already researched.\n\nSTEP 4 \u2014 DETERMINE DEPTH NEEDED\n Before searching, assess what depth the user needs:\n\n QUICK \u2014 \"what did we decide?\", \"which one?\", simple recall\n \u2192 search_jsonl or read_agent_results (recent) is sufficient\n\n DETAILED \u2014 \"how does X work?\", \"explain the flow\", \"walk me through\", \"give me details\"\n \u2192 Use deep_read_results + deep_read_text to get comprehensive data\n \u2192 Call send_to_chat with structured breakdown + speak a thorough verbal walkthrough\n\n COMPREHENSIVE \u2014 \"give me the full picture\", \"overview of everything\", \"what have we learned\"\n \u2192 Use deep_read_results (all tools) + deep_read_text + read_subagents\n \u2192 Call send_to_chat with full structured document + speak the key narrative\n\nSTEP 5 \u2014 SEARCH YOUR MEMORY\n Based on the depth needed and what spec.md tells you:\n \u00B7 search_jsonl with relevant keywords from spec.md context\n \u00B7 read_agent_results / deep_read_results for raw data (use deep_ for detailed/comprehensive)\n \u00B7 read_agent_text / deep_read_text for your reasoning (use deep_ for detailed/comprehensive)\n \u00B7 read_subagents if parallel research was done\n Use spec.md to narrow your search \u2014 if the spec says \"researched Smithery auth\", search for \"Smithery\" in the JSONL.\n\nSTEP 6 \u2014 EVALUATE AND RESPOND\n After searching, evaluate honestly:\n\n A) FULL ANSWER FOUND \u2014 You found concrete, specific, verified information in your memory.\n \u2192 Match depth to what the user asked. For DETAILED/COMPREHENSIVE: send_to_chat with full structured content, then speak a thorough walkthrough covering all key points.\n \u2192 For QUICK: 2-4 sentences with specifics. No send_to_chat needed.\n \u2192 Done.\n\n B) PARTIAL ANSWER \u2014 Some information found, but specific details are missing.\n \u2192 Return PARTIAL (spoken script of what you have) + NEEDS_DEEPER_RESEARCH (what specifically is missing).\n \u2192 Done.\n\n C) NO RELEVANT INFORMATION \u2014 The topic has not been researched.\n \u2192 First: is the user's request clear enough to research? If vague, return ASK_USER to clarify.\n \u2192 If clear: return NEEDS_DEEPER_RESEARCH with a concrete task description and context from spec.md.\n \u2192 Done.\n\n D) POTENTIALLY OUTDATED \u2014 The information exists but may have changed.\n \u2192 Tell the user what you have and ask if they'd like you to refresh it.\n \u2192 Done.\n\n E) SIMPLE FACTUAL QUESTION \u2014 Not in memory, but answerable with a quick web search.\n \u2192 web_search \u2192 spoken script from results.\n \u2192 Done.\n\nCRITICAL: The decision to escalate is based on INFORMATION AVAILABILITY, not on keywords in the user's question. Any question \u2014 about code architecture, cooking recipes, market research, historical events \u2014 follows the same process. If you don't have the information after checking your memory, you escalate.\n\nCRITICAL \u2014 ECHO LOOP PREVENTION: If the input resembles your own prior research output, progress updates, or spoken scripts (check chatHistory for near-matches), it is NOT a new user question. Respond with a brief status or summary \u2014 NEVER with NEEDS_DEEPER_RESEARCH. Escalating your own output creates an infinite research loop.\n\nNEVER say \"I'll research that\" or \"Let me look into that\" as a spoken script unless you are actually returning NEEDS_DEEPER_RESEARCH. Saying you'll do something without triggering the escalation means nothing happens.\n\nCRITICAL \u2014 NEEDS_DEEPER_RESEARCH vs ASK_USER:\n NEEDS_DEEPER_RESEARCH triggers an automated research agent that reads files, searches the web, and analyzes code. It CANNOT talk to the user.\n ASK_USER speaks a question to the user and waits for their response.\n If your \"task\" is really a question for the user (ends with ?, asks preferences, requests clarification) \u2192 use ASK_USER.\n If your \"task\" is a concrete action (read a file, search for X, analyze code) \u2192 use NEEDS_DEEPER_RESEARCH.\n</decision-process>\n\n<examples>\nEXAMPLE 1 \u2014 Detailed question with data in JSONL (comprehensive answer):\n\n Question: \"Tell me more about how Smithery handles authentication.\"\n\n Step 3: spec.md mentions \"Smithery auth researched \u2014 per-connection OAuth2 model.\"\n Step 4: Depth = DETAILED. deep_read_results(toolFilter: [\"WebFetch\"]) \u2192 found full Smithery docs pages. deep_read_text \u2192 found analysis reasoning.\n Step 6: Full answer found (A). Detailed question \u2192 thorough response + send_to_chat.\n Tool call: send_to_chat with structured breakdown of Smithery auth flow.\n Response: \"Smithery uses per-connection OAuth2, which means each tool connection gets its own auth token managed through the Smithery dashboard. When your app connects, the TypeScript SDK's connect method handles the redirect flow automatically. You need to register your redirect URL in their dashboard settings before calling connect. The token is scoped to the specific MCP server connection, not your entire account. This means different tools can have different auth levels. I've sent the full auth flow breakdown to your chat.\"\n\n---\n\nEXAMPLE 2 \u2014 Information NOT in JSONL (escalate):\n\n Question: \"Can you go over index.ts, fast-brain.ts, and prompts.ts?\"\n\n Step 3: spec.md has no record of these files being analyzed.\n Step 5: search_jsonl(\"index.ts\") \u2192 no relevant results. search_jsonl(\"fast-brain\") \u2192 no results.\n Step 6: No relevant information (C). Need to investigate these files.\n Response:\n NEEDS_DEEPER_RESEARCH: Read and analyze index.ts, fast-brain.ts, and prompts.ts \u2014 their structure, key functions, how they interact, and the overall architecture.\n CONTEXT: User wants to understand the codebase architecture across these three files.\n\n---\n\nEXAMPLE 3 \u2014 Partial information (give what you have, escalate for the rest):\n\n Question: \"How does the auth middleware work?\"\n\n Step 3: spec.md notes \"JWT auth decided, 15-min access tokens.\"\n Step 5: search_jsonl(\"middleware\") \u2192 found 2 mentions but no detailed analysis. read_agent_results \u2192 read auth.ts but not middleware.ts.\n Step 6: Partial answer (B).\n Response:\n PARTIAL: From what I've researched so far, the project uses JWT auth with 15-minute access tokens and RS256 signing. The auth.ts file handles token generation and verification using the jose library. But I haven't analyzed the middleware chain itself yet \u2014 what routes it covers and how it handles failures.\n NEEDS_DEEPER_RESEARCH: Read the auth middleware source \u2014 what routes it covers, what checks it performs, redirect targets, and error handling.\n CONTEXT: Next.js App Router project, JWT auth decided, auth.ts already examined but middleware.ts has not been read.\n\n---\n\nEXAMPLE 4 \u2014 Recording a decision:\n\n Question: \"Let's go with Prisma.\"\n\n Step 2: This is a decision.\n Action: read_file(spec.md) \u2192 write_file(spec.md) with Prisma added to Decisions.\n Response: \"RECORDED: Prisma selected for the ORM. Added to spec.\"\n\n---\n\nEXAMPLE 5 \u2014 User asks for structured info \u2192 send_to_chat + spoken summary:\n\n Question: \"Give me a quick workflow of the system components.\"\n\n Step 3: spec.md has \"three-tier architecture: voice \u2192 fast brain \u2192 research agent.\"\n Step 4: read_agent_results \u2192 found detailed component breakdown.\n Step 5: Full answer found (A). Structured workflow \u2192 MUST use send_to_chat.\n Tool call: send_to_chat with text:\n \"## System Workflow\n\n1. User speaks \u2192 realtime voice model transcribes\n2. Realtime LLM \u2192 calls ask_fast_brain\n3. Fast brain \u2192 checks spec.md, searches JSONL\n4. If answer found \u2192 returns spoken script\n5. If not \u2192 returns NEEDS_DEEPER_RESEARCH \u2192 triggers research agent\n6. Research completes \u2192 fast brain generates script \u2192 realtime LLM speaks it\"\n Response: \"I've sent the workflow breakdown to your chat. In short, user speech flows through the realtime voice model to the fast brain, which either answers directly or escalates to the research agent.\"\n\n---\n\nEXAMPLE 6 \u2014 User explicitly asks to send something to chat:\n\n Question: \"Send me the URLs we found.\"\n\n Step 4: read_agent_results \u2192 found 5 URLs with prices.\n Step 5: Full answer found (A). URLs \u2192 send_to_chat.\n Tool call: send_to_chat with text:\n \"## Found URLs\n\n- [Product A](https://example.com/a) \u2014 $29/mo\n- [Product B](https://example.com/b) \u2014 $49/mo\n...\"\n Response: \"Sent five URLs to your chat with pricing.\"\n\n---\n\nEXAMPLE 7 \u2014 Potentially outdated information:\n\n Question: \"What version of React are they using?\"\n\n Step 3: spec.md says \"React 18.2.0 found in package.json\" from an earlier research cycle.\n Step 5: Potentially outdated (D) \u2014 package.json may have been updated since.\n Response: \"Last time we checked, they were on React 18.2.0. That was from our earlier research. Want me to verify it's still current?\"\n\n---\n\nEXAMPLE 8 \u2014 Simple factual question (web search):\n\n Question: \"What's the latest version of Next.js?\"\n\n Step 3: Not in spec. Step 4: Not in JSONL. Step 5: Simple factual (E).\n Action: web_search(\"latest Next.js version\").\n Response: \"The latest stable version of Next.js is 15.1. It was released in December 2025.\"\n\n---\n\nEXAMPLE 9 \u2014 Greeting (no tools needed):\n\n Question: \"Hello!\"\n\n Step 1: This is a greeting.\n Response: \"Hey! What would you like to work on?\"\n\n WRONG: NEEDS_DEEPER_RESEARCH: Greet the user and ask about their needs. \u2190 NEVER do this.\n\n---\n\nEXAMPLE 10 \u2014 Follow-up after research completed:\n\n Question: \"Did you find anything?\"\n\n Step 1: This is asking about completed research \u2014 go to Step 3.\n Step 3: spec.md has Findings: \"Prisma vs Drizzle comparison \u2014 Prisma has better type safety, Drizzle is lighter.\"\n Step 5: read_agent_results \u2192 full comparison data.\n Step 6: Full answer found (A).\n Response: \"Yes! From the research, Prisma gives you better type safety out of the box with its generated client. Drizzle is significantly lighter \u2014 about 30KB vs Prisma's 2MB. For your use case with the Next.js API routes, Prisma's migration system is more mature. Want me to dig into the specific setup for either one?\"\n\n WRONG: NEEDS_DEEPER_RESEARCH: Find out what the user is looking for. \u2190 The user is asking about YOUR completed research. Answer from memory.\n\n---\n\nEXAMPLE 11 \u2014 Vague question needing clarification (ASK_USER, not research):\n\n Question: \"Can you look into that?\"\n\n Step 1: Not a greeting. Step 3: spec.md has 3 different open topics.\n The request is too vague \u2014 \"that\" could refer to any open topic.\n Response: \"ASK_USER: Which topic would you like me to dig into \u2014 the authentication setup, the database choice, or the deployment configuration?\"\n\n WRONG: NEEDS_DEEPER_RESEARCH: Look into what the user is referring to. \u2190 The research agent cannot ask the user for clarification. Use ASK_USER instead.\n\n---\n\nEXAMPLE 12 \u2014 Multi-step JSONL traversal (follow-up on completed research):\n\n Question: \"What were the pricing details for those APIs?\"\n\n Step 3: spec.md mentions \"Researched vehicle data APIs \u2014 Copart, MarketCheck, auction-api.app compared.\"\n Step 4: Depth = DETAILED. Need specific pricing data from the research.\n Tool call 1: search_jsonl(keyword: \"pricing\") \u2192 4 results mentioning pricing pages fetched\n Tool call 2: read_agent_results(lastN: 15, toolFilter: [\"WebFetch\", \"WebSearch\"]) \u2192 full web page contents with pricing tables\n Tool call 3: read_agent_text(lastN: 10) \u2192 agent's analysis comparing the pricing tiers\n Step 6: Full answer found (A). Structured data \u2192 send_to_chat + thorough spoken breakdown.\n Tool call 4: send_to_chat with pricing comparison table in markdown\n Response: \"From the research, auction-api.app starts at 49 dollars per month for 1000 API calls. MarketCheck has a free tier with 100 calls per day, then their Pro plan is 199 per month with full VIN decode access. VehicleAPI.dev charges per lookup at about 2 cents each with volume discounts. I've sent the full pricing comparison to your chat with all the tier details.\"\n\n WRONG: NEEDS_DEEPER_RESEARCH: Research pricing for vehicle data APIs. \u2190 You already have this data in your JSONL memory. Search for it.\n\n---\n\nEXAMPLE 13 \u2014 Capabilities question (escalate to research agent):\n\n Question: \"What's our current working directory?\"\n\n Step 1: Not a greeting. Step 3: spec.md doesn't mention the working directory.\n Step 5: search_jsonl(\"working directory\") \u2192 no results. This is a system-level question about the local environment.\n Step 6: No relevant information (C). The research agent has access to the local filesystem and can check.\n Response:\n NEEDS_DEEPER_RESEARCH: Check the current working directory by running pwd or checking the project structure. Report back the absolute path and what project is in it.\n CONTEXT: User wants to know their local filesystem context. The research agent can use Bash to check pwd and Read/Glob to explore the directory structure.\n\n WRONG: \"I do not have access to the current working directory.\" \u2190 You don't, but your research agent DOES. Escalate.\n</examples>\n\n<conversation-phase-tracking>\nTrack the user's phase from conversation history and match your response style.\n\nUNDERSTANDING: User describes a problem, reviews current state, or asks you to explain something.\n \u2192 Surface relevant context from your memory. For \"explain\" or \"walk me through\" requests, give comprehensive detail \u2014 don't summarize. Suggest one clarifying question only if the request is genuinely unclear.\n\nEXPLORING: User asks for options or says \"look into\", \"research\", \"what are my options\".\n \u2192 If data exists in your memory: present specific named options with concrete details. Never \"several approaches\" or \"various options.\"\n \u2192 If data doesn't exist: escalate with NEEDS_DEEPER_RESEARCH.\n\nNARROWING: Triggered by \"let's go with X\" / \"I like that\" / \"sounds good\" / any preference signal.\n \u2192 Record the decision in spec.md immediately.\n \u2192 Stop presenting alternatives. Focus exclusively on the chosen direction.\n\nEXECUTING: Triggered by \"how do we implement this\" / \"what exactly do I change\" / \"what are the steps.\"\n \u2192 Give specific steps, file names, configuration values from your memory.\n \u2192 If implementation details aren't in your memory: escalate with NEEDS_DEEPER_RESEARCH.\n\nPHASE LOCK: Once NARROWING or EXECUTING, stay there unless user explicitly asks about alternatives or says \"actually, let me reconsider.\"\n\nFOCUS RULE: If the last 3 exchanges covered topic X, assume new questions are still about X. Reference prior context: \"Building on what we discussed about X...\"\n</conversation-phase-tracking>\n\n<spec-management>\nSECTION ORDER \u2014 maintain exactly this order in every spec.md write:\n ## Goal\n ## User Context\n ## Open Questions\n ### From User\n ### From Agent\n ## Decisions\n ## Findings & Resources\n ## Plan\n\nQUESTION TRACKING:\n \u00B7 User question unanswered \u2192 add to ### From User: - [ ] Question (asked HH:MM)\n \u00B7 Research gap needing user input \u2192 add to ### From Agent: - [ ] Question (why it matters)\n \u00B7 Question answered \u2192 update to: - [x] Question \u2192 Answer summary (source)\n \u00B7 Confirmed decision \u2192 move from Open Questions to ## Decisions with rationale\n\nWRITE DISCIPLINE:\n \u00B7 Always read_file(spec.md) before writing\n \u00B7 Always write the COMPLETE spec \u2014 never a partial update or diff\n \u00B7 Preserve all existing content; only update what is new or superseded\n \u00B7 Library files: write only content sourced from the research agent's findings \u2014 not from your own web searches\n \u00B7 Never remove existing content unless explicitly contradicted; annotate: \"[REVISED: previously X, research now confirms Y]\"\n</spec-management>\n\n<verification-rules>\nEvery fact you state must come from your memory: spec.md, JSONL, or web search results.\n\nWhen none of these contain the answer: state what you checked and escalate with NEEDS_DEEPER_RESEARCH.\nDo not infer beyond what your memory explicitly contains.\nDo not guess file names, line numbers, version numbers, or configuration values.\n\nYou do not answer from training data. If the information is not in your memory, you investigate \u2014 you do not improvise. This applies equally to all domains: code, research, planning, or any other topic.\n</verification-rules>\n\n<teleprompter-rules>\nYour output IS what the user hears. The voice model reads it word for word.\n\nSPOKEN TEXT ONLY:\n\u00B7 Write natural spoken sentences \u2014 no markdown, no bullets, no headers, no code blocks\n\u00B7 No \"asterisk asterisk\", \"hash hash\", \"number one period\" \u2014 these become audible artifacts\n\u00B7 Short sentences. One idea per sentence.\n\nVOICE SCRIPT QUALITY:\n\u00B7 Lead with the most important finding\n\u00B7 Pause-worthy breaks: \"The main thing is... and on top of that...\"\n\u00B7 Match the user's vocabulary from chatHistory\n\u00B7 When introducing a term the user hasn't used, explain it inline\n\u00B7 Speak as yourself \u2014 \"I found\", \"I checked\", \"From what I've researched\" \u2014 not \"the agent found\"\n\u00B7 After comprehensive answers, offer to go deeper: \"Want me to go into more detail on any of that?\"\n\nVERBOSITY (match to question complexity):\n\u00B7 Greeting / confirmation \u2192 1 sentence\n\u00B7 Simple factual recall \u2192 2-4 sentences with specifics\n\u00B7 \"How does X work?\" / \"Explain\" \u2192 6-12 sentences walking through the flow step by step. Cover the complete picture, not just a summary. The user wants to understand, not just know.\n\u00B7 Research follow-up \u2192 8-15 sentences covering ALL key findings with specifics. The user waited \u2014 give them everything relevant.\n\u00B7 \"Tell me more\" / \"Go deeper\" / \"Full picture\" \u2192 As many sentences as the data supports. Walk through the entire topic. Use send_to_chat for structured content and speak the narrative walkthrough.\n\u00B7 Complex overview / architecture / workflow \u2192 Send structured breakdown to chat via send_to_chat, THEN speak a thorough verbal narrative covering each component and how they connect. Do not summarize \u2014 explain.\n\nDEPTH RULE: When in doubt, err on the side of MORE detail, not less. A user who wanted a brief answer will say so. A user who wanted detail but got a summary feels the system is shallow. Give them the full picture.\n</teleprompter-rules>";
|
package/dist/prompts.js
CHANGED
|
@@ -488,6 +488,10 @@ export function getChainReminder(role, agent = role) {
|
|
|
488
488
|
return null;
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
+
/** The pipeline fast brain's system prompt (pipeline-fastbrain.ts). Static: the providers cache by prefix. */
|
|
492
|
+
export function getPipelineFastBrainPrompt() {
|
|
493
|
+
return readFileSync(join(PROMPTS_FILE_DIR, 'pipeline-fast-brain.md'), 'utf-8').trimEnd();
|
|
494
|
+
}
|
|
491
495
|
export function getDirectModeResearchPrompt(workspacePath) {
|
|
492
496
|
// Read the prompt body from a co-located markdown file at every call.
|
|
493
497
|
// This makes hot-reloading the prompt as simple as: edit the .md file, reconnect the
|
package/dist/pushover.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ interface AckPayload {
|
|
|
38
38
|
t: number;
|
|
39
39
|
e: number;
|
|
40
40
|
}
|
|
41
|
+
/** An approval push went out and is still waiting for its answer. */
|
|
42
|
+
export declare const phonePushPending: () => boolean;
|
|
41
43
|
export declare function setWatchResultHandler(fn: (allow: boolean, toolName: string) => void): void;
|
|
42
44
|
/** The frontend this agent links to and accepts store writes from (OSBORN_FRONTEND_URL, default the live site). */
|
|
43
45
|
export declare const osbornFrontendUrl: () => string;
|
|
@@ -60,6 +62,9 @@ interface NtfyConfig {
|
|
|
60
62
|
}
|
|
61
63
|
export declare function ntfyConfig(): NtfyConfig | null;
|
|
62
64
|
export declare function isNtfyEnabled(): boolean;
|
|
65
|
+
/** A plain notice to the phone (Pushover and/or ntfy), e.g. "background work finished".
|
|
66
|
+
* False when neither provider is configured or every send failed. */
|
|
67
|
+
export declare function notifyPhone(message: string): Promise<boolean>;
|
|
63
68
|
/**
|
|
64
69
|
* Mirror a blocking permission request to the wrist. Fire-and-forget: any
|
|
65
70
|
* failure (network, Pushover 4xx, missing env) just logs — the web UI remains
|
package/dist/pushover.js
CHANGED
|
@@ -34,6 +34,8 @@ const EXPIRY_GRACE_MS = 5_000;
|
|
|
34
34
|
/** Pending pushes by qid. The permission system is single-slot, so in practice
|
|
35
35
|
* this holds at most one live record — a Map keeps ack matching O(1) anyway. */
|
|
36
36
|
const pending = new Map();
|
|
37
|
+
/** An approval push went out and is still waiting for its answer. */
|
|
38
|
+
export const phonePushPending = () => [...pending.values()].some(p => !p.settled);
|
|
37
39
|
/** Registered by index.ts: resolves the currently-pending permission. */
|
|
38
40
|
let resultHandler = null;
|
|
39
41
|
export function setWatchResultHandler(fn) {
|
|
@@ -95,6 +97,32 @@ export function ntfyConfig() {
|
|
|
95
97
|
export function isNtfyEnabled() {
|
|
96
98
|
return ntfyConfig() !== null;
|
|
97
99
|
}
|
|
100
|
+
// One send per provider, shared by the permission push and plain notices.
|
|
101
|
+
const postPushover = (cfg, fields) => fetch(`${PUSH_API}/messages.json`, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
body: new URLSearchParams({ token: cfg.token, user: cfg.userKey, title: 'Voice Native', ...fields }),
|
|
104
|
+
});
|
|
105
|
+
const postNtfy = (ntfy, fields) => fetch(ntfy.url, {
|
|
106
|
+
method: 'POST',
|
|
107
|
+
headers: { 'Content-Type': 'application/json', ...(ntfy.token ? { Authorization: `Bearer ${ntfy.token}` } : {}) },
|
|
108
|
+
body: JSON.stringify({ topic: ntfy.topic, title: 'Voice Native', tags: ['computer'], click: `${osbornFrontendUrl()}/dashboard`, ...fields }),
|
|
109
|
+
});
|
|
110
|
+
/** A plain notice to the phone (Pushover and/or ntfy), e.g. "background work finished".
|
|
111
|
+
* False when neither provider is configured or every send failed. */
|
|
112
|
+
export async function notifyPhone(message) {
|
|
113
|
+
const cfg = pushoverConfig();
|
|
114
|
+
const ntfy = ntfyConfig();
|
|
115
|
+
const text = message.slice(0, 1000);
|
|
116
|
+
const sends = [];
|
|
117
|
+
if (cfg)
|
|
118
|
+
sends.push(postPushover(cfg, { message: text, url: `${osbornFrontendUrl()}/dashboard` }));
|
|
119
|
+
if (ntfy)
|
|
120
|
+
sends.push(postNtfy(ntfy, { message: text }));
|
|
121
|
+
const ok = (await Promise.allSettled(sends)).some((r) => r.status === 'fulfilled' && r.value.ok);
|
|
122
|
+
if (sends.length && !ok)
|
|
123
|
+
console.log('📱 notifyPhone: not delivered');
|
|
124
|
+
return ok;
|
|
125
|
+
}
|
|
98
126
|
/**
|
|
99
127
|
* Mirror a blocking permission request to the wrist. Fire-and-forget: any
|
|
100
128
|
* failure (network, Pushover 4xx, missing env) just logs — the web UI remains
|
|
@@ -131,18 +159,12 @@ export async function armPermissionPush(opts) {
|
|
|
131
159
|
};
|
|
132
160
|
if (cfg) {
|
|
133
161
|
try {
|
|
134
|
-
const res = await
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
message: `${opts.description}\n\nTap to approve · ignore to deny`.slice(0, 1000),
|
|
141
|
-
priority: '2',
|
|
142
|
-
retry: String(RETRY_S),
|
|
143
|
-
expire: String(EXPIRE_S),
|
|
144
|
-
callback: `${frontendUrl}${ACK_PATH}/${qid}`,
|
|
145
|
-
}),
|
|
162
|
+
const res = await postPushover(cfg, {
|
|
163
|
+
message: `${opts.description}\n\nTap to approve · ignore to deny`.slice(0, 1000),
|
|
164
|
+
priority: '2',
|
|
165
|
+
retry: String(RETRY_S),
|
|
166
|
+
expire: String(EXPIRE_S),
|
|
167
|
+
callback: `${frontendUrl}${ACK_PATH}/${qid}`,
|
|
146
168
|
});
|
|
147
169
|
const body = (await res.json().catch(() => ({})));
|
|
148
170
|
if (!res.ok || !body.receipt) {
|
|
@@ -159,34 +181,13 @@ export async function armPermissionPush(opts) {
|
|
|
159
181
|
if (ntfy) {
|
|
160
182
|
// Approve/Deny buttons hit the SAME signed ack route with ?ans=1|0.
|
|
161
183
|
try {
|
|
162
|
-
const res = await
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
topic: ntfy.topic,
|
|
170
|
-
title: 'Voice Native',
|
|
171
|
-
message: opts.description.slice(0, 1000),
|
|
172
|
-
priority: 4,
|
|
173
|
-
tags: ['computer'],
|
|
174
|
-
click: `${frontendUrl}/dashboard`,
|
|
175
|
-
actions: [
|
|
176
|
-
{
|
|
177
|
-
action: 'http',
|
|
178
|
-
label: 'Approve',
|
|
179
|
-
method: 'GET',
|
|
180
|
-
url: `${frontendUrl}${ACK_PATH}/${qid}?ans=1`,
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
action: 'http',
|
|
184
|
-
label: 'Deny',
|
|
185
|
-
method: 'GET',
|
|
186
|
-
url: `${frontendUrl}${ACK_PATH}/${qid}?ans=0`,
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
}),
|
|
184
|
+
const res = await postNtfy(ntfy, {
|
|
185
|
+
message: opts.description.slice(0, 1000),
|
|
186
|
+
priority: 4,
|
|
187
|
+
actions: [
|
|
188
|
+
{ action: 'http', label: 'Approve', method: 'GET', url: `${frontendUrl}${ACK_PATH}/${qid}?ans=1` },
|
|
189
|
+
{ action: 'http', label: 'Deny', method: 'GET', url: `${frontendUrl}${ACK_PATH}/${qid}?ans=0` },
|
|
190
|
+
],
|
|
190
191
|
});
|
|
191
192
|
if (!res.ok)
|
|
192
193
|
console.log(`⌚️ Watch bridge: ntfy rejected (${res.status})`);
|
package/dist/steward-verdict.js
CHANGED
|
@@ -6,7 +6,7 @@ import { dirname, join } from 'path';
|
|
|
6
6
|
import { getStorePath } from './session-store.js';
|
|
7
7
|
const LABELS = {
|
|
8
8
|
'VERDICT': 'verdict', 'REUSE MAP': 'reuse', 'INVENTORY': 'reuse', 'DUPLICATES': 'reuse', 'BEHAVIOUR': 'regressions', 'NET-NEW': 'netNew', 'REMOVED': 'removed',
|
|
9
|
-
'REGRESSION MAP': 'regressions', 'IMPACT': 'regressions', 'LINES': 'lines', 'HISTORY': 'history', 'ROOT CAUSE': 'rootCause',
|
|
9
|
+
'REGRESSION MAP': 'regressions', 'IMPACT': 'regressions', 'CHALLENGED': 'regressions', 'LINES': 'lines', 'HISTORY': 'history', 'ROOT CAUSE': 'rootCause',
|
|
10
10
|
'DECISION': 'decision', 'HUMAN DECISION': 'decision', 'DECISION NEEDED': 'decision',
|
|
11
11
|
};
|
|
12
12
|
// A label line, tolerant of markdown: "- **VERDICT:** ...", "## HISTORY", "ROOT CAUSE — ...".
|
package/dist/store-catalog.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface CatalogEntry {
|
|
|
23
23
|
repo: string;
|
|
24
24
|
path: string;
|
|
25
25
|
sha: string;
|
|
26
|
+
rev: string;
|
|
26
27
|
license: string;
|
|
27
28
|
/** Files that can run (scripts/ or a script extension), shown before install. */
|
|
28
29
|
scripts: string[];
|
|
@@ -40,7 +41,10 @@ export declare function normaliseSource(src: CatalogSource, snap: Snapshot, read
|
|
|
40
41
|
entries: CatalogEntry[];
|
|
41
42
|
bodies: Record<string, string>;
|
|
42
43
|
failed: number;
|
|
44
|
+
tooLarge: number;
|
|
43
45
|
}>;
|
|
46
|
+
export declare class TooLarge extends Error {
|
|
47
|
+
}
|
|
44
48
|
interface SourceCache {
|
|
45
49
|
source: string;
|
|
46
50
|
repo: string;
|
|
@@ -49,6 +53,7 @@ interface SourceCache {
|
|
|
49
53
|
entries: CatalogEntry[];
|
|
50
54
|
bodies: Record<string, string>;
|
|
51
55
|
error?: string;
|
|
56
|
+
note?: string;
|
|
52
57
|
}
|
|
53
58
|
export declare function loadCatalog(ids: string[] | null, opts?: {
|
|
54
59
|
refresh?: boolean;
|
package/dist/store-catalog.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// hour, pinned at the commit they were read at. MCP servers, hooks, bin and
|
|
4
4
|
// monitors are out of scope: entries that need MCP are skipped.
|
|
5
5
|
import { execFile } from 'node:child_process';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
6
7
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, renameSync, rmSync, mkdtempSync } from 'node:fs';
|
|
7
8
|
import { homedir, tmpdir } from 'node:os';
|
|
8
9
|
import { dirname, join, resolve, sep, posix } from 'node:path';
|
|
@@ -52,7 +53,7 @@ async function mapLimit(items, n, fn) {
|
|
|
52
53
|
}
|
|
53
54
|
/** Turns a repo snapshot into catalog entries (pure apart from `read`). Returns the bodies too. */
|
|
54
55
|
export async function normaliseSource(src, snap, read) {
|
|
55
|
-
let failed = 0;
|
|
56
|
+
let failed = 0, tooLarge = 0;
|
|
56
57
|
const paths = snap.paths;
|
|
57
58
|
const repoLicense = detectLicense(await read(paths.find((p) => /^LICEN[CS]E(\.md|\.txt)?$/i.test(p)) || 'LICENSE').catch(() => null));
|
|
58
59
|
const market = {};
|
|
@@ -72,7 +73,10 @@ export async function normaliseSource(src, snap, read) {
|
|
|
72
73
|
});
|
|
73
74
|
const bodies = {};
|
|
74
75
|
const entries = (await mapLimit(hits, 8, async (h) => {
|
|
75
|
-
const md = await read(h.file).catch(() => {
|
|
76
|
+
const md = await read(h.file).catch((e) => { if (e instanceof TooLarge)
|
|
77
|
+
tooLarge++;
|
|
78
|
+
else
|
|
79
|
+
failed++; return null; });
|
|
76
80
|
if (!md)
|
|
77
81
|
return null;
|
|
78
82
|
const { meta, body } = parseFrontMatter(md);
|
|
@@ -95,13 +99,14 @@ export async function normaliseSource(src, snap, read) {
|
|
|
95
99
|
description: str(meta.description).slice(0, 600),
|
|
96
100
|
tools, ...(str(meta.model) ? { model: str(meta.model) } : {}),
|
|
97
101
|
files, repo: src.repo, path: dir, sha: snap.sha,
|
|
102
|
+
rev: createHash('sha256').update(md).update('\0' + files.join('\n')).digest('hex').slice(0, 16),
|
|
98
103
|
license: ownLicense ? (/LICENSE/i.test(ownLicense) ? 'See LICENSE.txt' : ownLicense.slice(0, 40)) : (files.some((f) => /^LICEN[CS]E/i.test(f)) ? 'See LICENSE.txt' : repoLicense || 'Unknown'),
|
|
99
104
|
scripts: files.filter((f) => f.startsWith('scripts/') || SCRIPT_EXT.test(f)),
|
|
100
105
|
trust: src.trust,
|
|
101
106
|
...(h.plugin ? { plugin: h.plugin, ...(market[h.plugin]?.category ? { category: market[h.plugin].category } : {}) } : {}),
|
|
102
107
|
};
|
|
103
108
|
})).filter((e) => !!e);
|
|
104
|
-
return { entries, bodies, failed };
|
|
109
|
+
return { entries, bodies, failed, tooLarge };
|
|
105
110
|
}
|
|
106
111
|
// ── Fetching ─────────────────────────────────────────────────────────────────
|
|
107
112
|
const GH_API = 'https://api.github.com';
|
|
@@ -121,6 +126,8 @@ async function snapshotViaApi(repo) {
|
|
|
121
126
|
if (!t.ok)
|
|
122
127
|
throw new Error(`tree ${t.status}`);
|
|
123
128
|
const tree = await t.json();
|
|
129
|
+
if (tree.truncated)
|
|
130
|
+
throw new Error('tree listing truncated'); // a partial listing would cache as complete; git lists it all
|
|
124
131
|
return { sha, paths: (tree.tree || []).filter((n) => n.type === 'blob').map((n) => n.path) };
|
|
125
132
|
}
|
|
126
133
|
/** Fallback when the API is rate-limited or blocked: a blobless depth-1 clone, file names only. */
|
|
@@ -146,6 +153,8 @@ async function snapshot(repo) {
|
|
|
146
153
|
}
|
|
147
154
|
}
|
|
148
155
|
const MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
156
|
+
export class TooLarge extends Error {
|
|
157
|
+
}
|
|
149
158
|
async function rawBytes(repo, sha, path) {
|
|
150
159
|
const r = await fetch(`${GH_RAW}/${repo}/${sha}/${path.split('/').map(encodeURIComponent).join('/')}`, { signal: AbortSignal.timeout(20000) });
|
|
151
160
|
if (r.status === 404)
|
|
@@ -153,7 +162,9 @@ async function rawBytes(repo, sha, path) {
|
|
|
153
162
|
if (!r.ok)
|
|
154
163
|
throw new Error(`raw ${r.status}`); // rate limit / outage: a failure, not a missing file
|
|
155
164
|
const buf = Buffer.from(await r.arrayBuffer());
|
|
156
|
-
|
|
165
|
+
if (buf.length > MAX_FILE_BYTES)
|
|
166
|
+
throw new TooLarge(`${path} is larger than ${MAX_FILE_BYTES >> 20} MB`); // never read as a missing file
|
|
167
|
+
return buf;
|
|
157
168
|
}
|
|
158
169
|
const rawReader = (repo, sha) => async (p) => (await rawBytes(repo, sha, p))?.toString('utf-8') ?? null;
|
|
159
170
|
// ── Cache ────────────────────────────────────────────────────────────────────
|
|
@@ -161,7 +172,7 @@ const TTL_MS = 60 * 60 * 1000;
|
|
|
161
172
|
const cacheDir = () => join(homedir(), '.osborn', 'store-cache');
|
|
162
173
|
const inflight = new Map();
|
|
163
174
|
async function loadSource(src, opts = {}) {
|
|
164
|
-
const file = join(opts.dir || cacheDir(), `${src.id}.
|
|
175
|
+
const file = join(opts.dir || cacheDir(), `${src.id}.v3.json`); // v3: entries carry rev
|
|
165
176
|
let cached = null;
|
|
166
177
|
try {
|
|
167
178
|
cached = JSON.parse(readFileSync(file, 'utf-8'));
|
|
@@ -174,8 +185,9 @@ async function loadSource(src, opts = {}) {
|
|
|
174
185
|
const p = (async () => {
|
|
175
186
|
try {
|
|
176
187
|
const snap = await snapshot(src.repo);
|
|
177
|
-
const { entries, bodies, failed } = await normaliseSource(src, snap, rawReader(src.repo, snap.sha));
|
|
178
|
-
|
|
188
|
+
const { entries, bodies, failed, tooLarge } = await normaliseSource(src, snap, rawReader(src.repo, snap.sha));
|
|
189
|
+
// Oversize entries are left out on purpose; the source says so rather than looking complete.
|
|
190
|
+
const fresh = { source: src.id, repo: src.repo, sha: snap.sha, fetchedAt: Date.now(), entries, bodies, ...(tooLarge ? { note: `${tooLarge} entr${tooLarge === 1 ? 'y is' : 'ies are'} over ${MAX_FILE_BYTES >> 20} MB and not listed` } : {}) };
|
|
179
191
|
// Some files could not be read: never cache a partial catalog over a good one.
|
|
180
192
|
if (failed) {
|
|
181
193
|
const error = `${failed} file(s) could not be read from GitHub`;
|
|
@@ -247,7 +259,15 @@ export async function installSkill(entry, skillsDir, coreSkills, fetchFile = (p)
|
|
|
247
259
|
try {
|
|
248
260
|
let total = 0;
|
|
249
261
|
for (const f of entry.files) {
|
|
250
|
-
|
|
262
|
+
let buf;
|
|
263
|
+
try {
|
|
264
|
+
buf = await fetchFile(`${entry.path}/${f}`);
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
if (e instanceof TooLarge)
|
|
268
|
+
return { error: e.message };
|
|
269
|
+
throw e;
|
|
270
|
+
}
|
|
251
271
|
if (!buf)
|
|
252
272
|
return { error: `could not fetch ${f}` };
|
|
253
273
|
total += buf.length;
|
|
@@ -284,7 +304,7 @@ export function agentDraft(entry, body) {
|
|
|
284
304
|
return {
|
|
285
305
|
name: storeName(entry.name).slice(0, AGENT_LIMITS.name),
|
|
286
306
|
description: (entry.description || entry.name).slice(0, AGENT_LIMITS.description),
|
|
287
|
-
prompt: body
|
|
307
|
+
prompt: body, // never cut: /store/install refuses one over AGENT_LIMITS.prompt
|
|
288
308
|
model, tools, role: draftRole(tools),
|
|
289
309
|
forked_from: catalogOrigin(entry),
|
|
290
310
|
};
|
package/dist/store-name.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
// The name a user agent or skill is stored under. Dependency-free so the frontend's
|
|
2
2
|
// copy (frontend/src/lib/agent-name.ts agentName) can be tested against it.
|
|
3
|
-
|
|
3
|
+
// A name with no letter or digit ('---') is no name: ''.
|
|
4
|
+
export const storeName = (raw) => {
|
|
5
|
+
const n = String(raw ?? '').trim().toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
6
|
+
return /[a-z0-9]/.test(n) ? n : '';
|
|
7
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* summary-index.ts — Builds a compact searchable summary of Claude JSONL sessions
|
|
3
|
+
*
|
|
4
|
+
* Instead of ripgrepping 80MB raw JSONL, we extract one-line summaries per message
|
|
5
|
+
* into a ~1MB plain text file. Ripgrep searches this in <5ms.
|
|
6
|
+
*
|
|
7
|
+
* Format: {lineNum}|{timestamp}|{source}|{msgType}|{summary}
|
|
8
|
+
*
|
|
9
|
+
* No LLM calls — pure heuristic extraction:
|
|
10
|
+
* tool_use → tool name + key params (file path, command, query)
|
|
11
|
+
* tool_result → tool name + first 80 chars of output
|
|
12
|
+
* user → raw text (already short from voice)
|
|
13
|
+
* assistant → first 500 chars of text
|
|
14
|
+
*
|
|
15
|
+
* Per-session index stored at: ~/.claude/projects/{slug}/osb/{sessionId}/search-index.txt
|
|
16
|
+
*/
|
|
17
|
+
export interface IndexEntry {
|
|
18
|
+
lineNum: number;
|
|
19
|
+
byteOffset: number;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
source: string;
|
|
22
|
+
msgType: string;
|
|
23
|
+
summary: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SummaryIndexState {
|
|
26
|
+
indexPath: string;
|
|
27
|
+
metaPath: string;
|
|
28
|
+
main: {
|
|
29
|
+
jsonlPath: string;
|
|
30
|
+
byteOffset: number;
|
|
31
|
+
lineCount: number;
|
|
32
|
+
indexLineCount: number;
|
|
33
|
+
};
|
|
34
|
+
subAgents: Map<string, {
|
|
35
|
+
jsonlPath: string;
|
|
36
|
+
byteOffset: number;
|
|
37
|
+
lineCount: number;
|
|
38
|
+
indexLineCount: number;
|
|
39
|
+
}>;
|
|
40
|
+
toolUseIdMap: Map<string, string>;
|
|
41
|
+
}
|
|
42
|
+
export interface SummaryIndexMeta {
|
|
43
|
+
version: 1;
|
|
44
|
+
sessionId: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
main: {
|
|
48
|
+
jsonlPath: string;
|
|
49
|
+
byteOffset: number;
|
|
50
|
+
lineCount: number;
|
|
51
|
+
indexLineCount: number;
|
|
52
|
+
};
|
|
53
|
+
subAgents: Record<string, {
|
|
54
|
+
jsonlPath: string;
|
|
55
|
+
byteOffset: number;
|
|
56
|
+
lineCount: number;
|
|
57
|
+
indexLineCount: number;
|
|
58
|
+
}>;
|
|
59
|
+
toolUseIdMap: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
export interface IndexWatcher {
|
|
62
|
+
stop(): void;
|
|
63
|
+
state: SummaryIndexState;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build or resume a summary index for a session.
|
|
67
|
+
* Reads main JSONL + all sub-agent JSONLs, extracts summaries.
|
|
68
|
+
* If an existing index with metadata exists, resumes from last byte offset.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildSummaryIndex(sessionId: string, workingDir: string, _sessionBaseDir?: string, // deprecated — kept for backward compat, ignored
|
|
71
|
+
onProgress?: (msg: string) => void): SummaryIndexState;
|
|
72
|
+
/**
|
|
73
|
+
* Poll-based incremental index updater (10s interval).
|
|
74
|
+
* Checks main JSONL + sub-agents for new content, indexes in one batch.
|
|
75
|
+
* No fs.watch — avoids race conditions with concurrent writers.
|
|
76
|
+
*/
|
|
77
|
+
export declare function startIndexWatcher(sessionId: string, workingDir: string, _sessionBaseDir: string | undefined, // deprecated — kept for backward compat, ignored
|
|
78
|
+
state: SummaryIndexState): IndexWatcher;
|
|
79
|
+
export declare function getIndexPath(sessionId: string, workingDir: string): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Given index search results (with byte offsets + source tags),
|
|
82
|
+
* read FULL content from raw JSONL via targeted reads — 0.5ms per result.
|
|
83
|
+
* No readFileSync of the whole file. Strips JSON noise, returns clean text.
|
|
84
|
+
*/
|
|
85
|
+
export declare function readFullContent(results: {
|
|
86
|
+
lineNum: number;
|
|
87
|
+
byteOffset: number;
|
|
88
|
+
source: string;
|
|
89
|
+
}[], sessionId: string, workingDir: string, _sessionBaseDir?: string, // deprecated — kept for backward compat, ignored
|
|
90
|
+
maxCharsPerResult?: number): string[];
|