@chatpanel/gateway 0.144.1 → 0.147.1
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/native/darwin-arm64/chatpanel-apple-model +0 -0
- package/package.json +2 -2
- package/src/configstore.js +1 -1
- package/src/context.js +1 -0
- package/src/egress.js +2 -2
- package/src/extract/pdf.js +1 -1
- package/src/kb-bucket-sync.js +1 -0
- package/src/kb-store.js +2 -2
- package/src/kb.js +3 -3
- package/src/mcp.js +23 -22
- package/src/reveal.js +1 -0
- package/src/server.js +32 -32
- package/src/version.js +1 -1
package/src/mcp.js
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
import{loadConfig as y}from"./config.js";import{VERSION as b}from"./version.js";import{readBridgeToken as x}from"./bridge.js";import{ensureGatewayToken as k}from"./gateway-token.js";import{MEMORY_KINDS as P,MEMORY_KIND_NAMES as _}from"./memory.js";import{parseBriefText as
|
|
2
|
-
`);async function
|
|
3
|
-
`)}catch{return""}}function S(){try{return y().mcp?.ask||{}}catch{return{}}}let m="unknown";function O(n){try{const e=k();fetch(`${f()}/v1/observability/access`,{method:"POST",headers:{"content-type":"application/json",...e?{Authorization:`Bearer ${e}`}:{}},body:JSON.stringify(n)}).catch(()=>{})}catch{}}function f(){const n=process.env.CHATPANEL_GATEWAY_URL;if(n)return n.replace(/\/+$/,"");let e=4320;try{e=y().port||4320}catch{}return`http://127.0.0.1:${e}`}function C(){try{return String(y().bridge?.url||"http://127.0.0.1:4319").replace(/\/+$/,"")}catch{return"http://127.0.0.1:4319"}}function X(){try{return x(y().bridge?.token||"")}catch{return x("")}}async function $(n){const e=X(),a=await fetch(C()+n,{headers:{Accept:"application/json",...e?{Authorization:`Bearer ${e}`}:{}}}),i=await a.json().catch(()=>({}));if(!a.ok||i.ok===!1)throw new Error(i?.error||`bridge ${a.status}`);return i}const Q=[{name:"smart_search",description:'BEST first choice for a question about the user\'s ChatPanel history (meetings, notes, past chats). Ask it a natural-language QUESTION and it expands that into several complementary keyword queries, runs them all, and fuses the rankings — which finds things a single query misses, in one round trip instead of several probes. You know the domain, so pass 2-4 of your own phrasings in `queries` too (e.g. for "what did we decide in the Ben demo": ["Ben demo decisions", "tooling demo action items", "demo outcome next steps"]). Supports the same filters as search_history (type, since, before) and returns snippets with each result\'s id; follow up with get_record for the full text or find_related to expand around a hit. BRIEFS come first when they match: a brief is a maintained page about one person, project or topic, derived from ALL the records that mention it, with every claim citing its record — so for "what do we know about X" read the brief, then open only the records it cites.',inputSchema:{type:"object",properties:{question:{type:"string",description:"The user's question, in natural language."},queries:{type:"array",items:{type:"string"},description:"Your own 2-4 keyword formulations of it — these lead the search."},type:{type:"string",enum:["brief","chat","meeting","note"],description:'Only this kind of record. `brief` = a maintained page about one person/project/topic, with every claim cited — start there for "what do we know about X".'},since:{type:"string",description:'Earliest date: 2026-08-01, or a window like "7d"/"yesterday".'},before:{type:"string",description:"Latest date: a date or window like `since`."},limit:{type:"number",description:"Max fused results (default 10)."}},required:["question"]}},{name:"research",description:'Research a question about the user\'s OWN meetings, notes and past chats from the WHOLE ChatPanel store, not a few snippets: it frames the question (which kind of record, which people, which dates, the latest or the first, a count, counts per person or per month), queries every record that matches — sorted by date when the question asks for the last one, counted when it asks how many — reads the top records in full, and returns what it searched, what it found (with record ids and dates) and what those records say. Use it for "when was my last meeting with Alex", "how many calls did I have in August", "who do I meet with most", "what did we decide about pricing". For a follow-up ("no, even later", "what was it about") pass back the `previous` it returned. Cite the [id]s it gives; follow up with get_record for more of one record.',inputSchema:{type:"object",properties:{question:{type:"string",description:"The user's question, in their words."},previous:{type:"object",description:"The `previous` value the last research call returned, to continue that question (a follow-up)."}},required:["question"]}},{name:"search_history",description:'Search the user\'s ChatPanel history — their past chats, meeting/call transcripts, and notes — by keyword relevance. Consult this (in ADDITION to your other tools) whenever the question touches a meeting, call, demo, note, or past conversation: "outcome of the meeting", "what did we decide", "action items", "what did <person> say", "notes from yesterday". Filters: `type` (chat|meeting|note), `since`/`before` (a date like 2026-08-01 or a relative window like "7d"/"yesterday"), and `limit`/`offset` for paging. Returns compact SNIPPETS (the matching excerpt) with each record\'s id/title/type/date — token-friendly; call get_record for the full text and find_related to follow connections. This is a LOCAL WARM COPY that syncs from ChatPanel; very recent items may not be here yet — results report how current the index is, so if something is missing it likely has not synced. Meeting titles are often generic ("Zoom Meeting"), so search by CONTENT, not the title.',inputSchema:{type:"object",properties:{query:{type:"string",description:"Content keywords (topics, names, decisions) — not the meeting title."},type:{type:"string",enum:["brief","chat","meeting","note"],description:'Only this kind of record. `brief` = a maintained page about one person/project/topic, with every claim cited — start there for "what do we know about X".'},since:{type:"string",description:'Earliest date: 2026-08-01, or a relative window like "7d", "2 weeks", "yesterday".'},before:{type:"string",description:"Latest date: a date or relative window like `since`."},limit:{type:"number",description:"Max results (default 10)."},offset:{type:"number",description:"Skip N results for paging (default 0)."}},required:["query"]}},{name:"get_record",description:"Fetch one history record's full text by id (chat:<id>, meeting:<id>, note:<id> from search_history). For a long transcript, page it with maxChars + offset instead of pulling it all into context — the result says how many chars remain.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Record id such as chat:abc, meeting:imp_123, or note:xyz."},maxChars:{type:"number",description:"Return at most this many characters (token management for long transcripts)."},offset:{type:"number",description:"Start at this character offset — page through with the offset the previous call reports."}},required:["id"]}},{name:"find_related",description:"Graph navigation: given a record id (from search_history), return the records most connected to it by shared content — the meetings/notes/chats about the same topic, people or thread. Use it to expand from one hit to the surrounding context instead of re-searching.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The record id to find neighbours of."},limit:{type:"number",description:"Max related records (default 5)."}},required:["id"]}},{name:"list_history",description:"List history records (newest first) with their id, title, type and date — no bodies. Reports how current this warm copy is (its newest record). Use to see the index horizon and browse/page the corpus.",inputSchema:{type:"object",properties:{limit:{type:"number",description:"Max items (default 50)."},offset:{type:"number",description:"Skip N items for paging (default 0)."}}}},{name:"list_briefs",description:`The BRIEFS ChatPanel maintains — one page per person, project or topic that appears across enough records, each claim citing the record it came from. This is the index of what the user's corpus KNOWS, as opposed to what it merely contains: read it before asking "what do we know about X", then get_brief for the one you need. Briefs are rebuilt from the records, so they are as current as the last rebuild (dates shown).`,inputSchema:{type:"object",properties:{limit:{type:"number",description:"Max briefs (default 50)."},offset:{type:"number",description:"Skip N for paging (default 0)."}}}},{name:"get_brief",description:"One brief as STRUCTURE: the subject, its other spellings, and each claim with the record ids it cites — so you can cite the record rather than the synthesis, and open only what you need with get_record. Prefer this over get_record for a brief:… id; get_record returns the same text as prose.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A brief id (brief:…) from list_briefs or search results."}},required:["id"]}},{name:"recall",description:"What ChatPanel already knows about the USER — their name, how they want answers written, their ongoing work and environment. Short and cheap; call it at the START of a session and whenever the user states a preference, then just FOLLOW what it returns without announcing that you checked. Pass the current task in `text` and it also returns the facts relevant to that task, not only the always-on ones. This is memory, not history: for what was said in a meeting or a past chat use smart_search instead.",inputSchema:{type:"object",properties:{text:{type:"string",description:"What the user is asking about right now, so task-relevant facts come back too. Omit for just the always-on ones."}}}},{name:"remember",description:`Save a durable fact about the USER to ChatPanel, carried into every future session on every model and agent — the side panel, other CLIs, everything. Use it the moment they state a standing preference ("always use pnpm"), an identity fact ("call me Alex") or a constraint that will still be true next week. Do NOT use it for task details, anything obvious from the current work, or notes about a codebase — those belong in the repo. One short self-contained sentence, written in the third person. Saving is a change to the user's own data, so say in a short clause what you saved.`,inputSchema:{type:"object",properties:{text:{type:"string",description:'The fact, one short sentence in the third person ("Prefers pnpm over npm"). Max 280 characters.'},kind:{type:"string",enum:_,description:_.map(n=>`${n}: ${P[n].hint}`).join(" ")},tags:{type:"array",items:{type:"string"},description:"Optional short tags for grouping."}},required:["text"]}},{name:"forget",description:'Remove a memory from ChatPanel when the user says it no longer holds. Name it however they did ("the Frankfurt thing") or pass the id from recall — it matches on meaning, and tells you exactly what it removed.',inputSchema:{type:"object",properties:{query:{type:"string",description:"The memory to remove: its text, roughly how the user named it, or its id."}},required:["query"]}},{name:"list_skills",description:"List the reusable skills installed on this machine (via the ChatPanel bridge) — across every agent harness (Claude Code, Codex, Copilot, Gemini, Hermes) and any configured folder. Returns each skill's name and one-line description. Call open_skill to load the one that fits the task.",inputSchema:{type:"object",properties:{}}},{name:"open_skill",description:"Load one skill's full instructions by name (from list_skills), then follow them. If the instructions point at reference files, read one with read_skill_file.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The skill name from list_skills."}},required:["name"]}},{name:"read_skill_file",description:"Read one reference file a skill's instructions point at (any path inside the skill's own folder). Use only when the task needs it.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The skill name."},path:{type:"string",description:"The reference path as written in the instructions, e.g. references/auth.md."}},required:["name","path"]}},{name:"kb_list",description:"The knowledge bases on this machine — the user's indexed documents (PDFs, office files, folders, web pages), each with its id, name and size. START HERE for any question about a document the user has, then kb_search that base. Read a base's REPORT with kb_report before reading pages: it is the map (documents, outlines, the names that bind them).",inputSchema:{type:"object",properties:{}}},{name:"kb_search",description:"Search one knowledge base for the passages that answer a question — the words (several query shapes), the meaning (vectors) and the graph (passages sharing a name with a hit) fused, a reranker on top, best first, each with its citation like [report.pdf p.12] and its passage id. Search BEFORE paging a document; pass 1–3 of your own phrasings in `queries` when you know the domain.",inputSchema:{type:"object",properties:{kb:{type:"string",description:"The base id (from kb_list)."},query:{type:"string",description:"The question, or key words."},queries:{type:"array",items:{type:"string"},description:"Your own phrasings, searched too and fused."},limit:{type:"integer",minimum:1,maximum:30,description:"How many passages (default 8)."},doc:{type:"string",description:"Only this document id."}},required:["kb","query"]}},{name:"kb_read",description:"Read one passage by its id (from kb_search), or one page of a document by document id and page number. A page call says which page is next.",inputSchema:{type:"object",properties:{kb:{type:"string",description:"The base id."},id:{type:"string",description:'A passage id like "d3f2a1b4c5d6#12".'},doc:{type:"string",description:"A document id (with page)."},page:{type:"integer",minimum:1,description:"The page (with doc)."}},required:["kb"]}},{name:"kb_outline",description:"The table of contents of a document in a base (its sections, with the page each starts on and the first passage id), or of every document when none is named.",inputSchema:{type:"object",properties:{kb:{type:"string"},doc:{type:"string",description:"A document id; omit for all."}},required:["kb"]}},{name:"kb_graph",description:'What connects to a name, a section or a topic in a base — its neighbours in the graph, or the path between two nodes ("what connects Atlas to the refund clause").',inputSchema:{type:"object",properties:{kb:{type:"string"},node:{type:"string",description:"An entity, section or topic by name."},to:{type:"string",description:"A second node: the path from node to it."},hops:{type:"integer",minimum:1,maximum:3}},required:["kb","node"]}},{name:"kb_status",description:"What one base holds: its documents (ids, titles, pages, passages), notes, entities, connections, and whether it has vectors.",inputSchema:{type:"object",properties:{kb:{type:"string"}},required:["kb"]}},{name:"kb_report",description:"The base's graph report as Markdown: every document with its outline, the most-mentioned entities, the communities of names that keep appearing together, the notes filed so far. Read it once before searching a base you have not seen.",inputSchema:{type:"object",properties:{kb:{type:"string"}},required:["kb"]}},{name:"kb_note",description:"File a note into a base — a fact you established, a summary, a correction — citing the passage ids it rests on. It is PROPOSED until the user accepts it in ChatPanel; proposed notes are searched and shown as proposed. Use it when the user asks to remember or record something about these documents, or when you resolved something that took work to find.",inputSchema:{type:"object",properties:{kb:{type:"string"},text:{type:"string",description:"One to three sentences."},cites:{type:"array",items:{type:"string"},description:"Passage ids the note stands on."}},required:["kb","text"]}}],q={[I]:" The gateway decides in-process unless it was turned off: ChatPanel › Settings › Runtime › Decide (or the OpenDecision container, or a server that provides `decide` under Models).",[L]:" The gateway reranks in-process unless it was turned off: ChatPanel › Settings › Runtime › Rerank (or the Reranker container, or a server that provides `rerank` under Models)."};function N(){const n=f(),e=c=>[{id:"gateway",name:"the gateway",url:`${n}${c}`,where:"this device"}],a=A({providers:{decide:e("/v1/decide"),rerank:e("/v1/rerank")},fetch:(c,o)=>fetch(c,o)}),i=B({search:async c=>{const o=await d("/v1/search",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({q:c,limit:8,read:W.aliasRead})});return{query:c,engines:o.engines||[],results:(o.results||[]).map((t,r)=>({rank:r+1,title:t.title||t.url,url:t.url,engine:t.engine||"",text:t.read?.markdown||t.read?.text||t.snippet||""}))}}});return[a,i]}const Z=N().flatMap(n=>n.specs.map(e=>({name:e.name,description:e.description,inputSchema:e.parameters})));async function ee(n,e){const a=N().find(o=>o.specs.some(t=>t.name===n));if(!a)return null;const i=await a.execute(n,e);let c=typeof i=="string"?i:String(i?.text??i);return q[n]&&/^No (decision model|reranker) answered/.test(c)&&(c+=q[n]),c}function w(n,e){if(!n)return`Index: ${e} records (warm copy synced from ChatPanel).`;const a=new Date(n),i=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")} ${String(a.getHours()).padStart(2,"0")}:${String(a.getMinutes()).padStart(2,"0")}`;return`Index: ${e} records, current through ${i} (local warm copy — items newer than this may not have synced from ChatPanel yet).`}function R(){try{const n=k();return n?{Authorization:`Bearer ${n}`}:{}}catch{return{}}}async function d(n,e){let a;try{a=await fetch(f()+n,e)}catch(c){throw new Error(`the ChatPanel gateway is not running at ${f()} — start it with "chatpanel-gateway --install" (or run "chatpanel-gateway"), then retry. [${c.message}]`)}const i=await a.json().catch(()=>({}));if(!a.ok)throw new Error(i?.error?.message||`the gateway returned HTTP ${a.status} for ${n}`);return i}function g(n){if(n==null||n==="")return null;if(typeof n=="number")return n;const e=String(n).trim().toLowerCase(),a=864e5;if(e==="today")return Date.now()-a;if(e==="yesterday")return Date.now()-2*a;const i=/^(\d+)\s*(d|day|days|w|week|weeks|m|month|months|y|year|years)$/.exec(e);if(i){const o=Number(i[1]),t=i[2][0],r=t==="d"?a:t==="w"?7*a:t==="m"?30*a:365*a;return Date.now()-o*r}const c=Date.parse(e);return Number.isNaN(c)?null:c}const v=(n,e)=>`${e+1}. [${n.id}] ${n.title||"(untitled)"} · ${n.type}${n.date?" · "+new Date(n.date).toISOString().slice(0,10):""}${n.snippet?`
|
|
4
|
-
${n.snippet}`:""}`;async function
|
|
1
|
+
import{loadConfig as y}from"./config.js";import{VERSION as b}from"./version.js";import{readBridgeToken as x}from"./bridge.js";import{ensureGatewayToken as k}from"./gateway-token.js";import{MEMORY_KINDS as P,MEMORY_KIND_NAMES as _}from"./memory.js";import{parseBriefText as A}from"./knowledge.js";import{capabilityToolsProvider as E,DECIDE_TOOL_NAME as I,RERANK_TOOL_NAME as L}from"./capability-tools.js";import{renderSearch as M,renderOutline as U,renderGraph as D,renderStatus as H}from"@chatpanel/events/kb-tool.js";import{renderContext as B}from"@chatpanel/events/context-api.js";import{webSearchToolProvider as W}from"./web-search-tool.js";import{SEARCH_DEFAULTS as F}from"./retrieval/search.js";import{askToolsFor as T,callAsk as J}from"./mcp-ask.js";import{CAPABILITY_TOOLS as Y,callCapability as z}from"./mcp-capabilities.js";const G="2024-11-05",K={name:"chatpanel-history",version:b},V=["ChatPanel holds the USER'S OWN meetings, notes and past chats — transcripts, decisions,","action items, summaries — which usually are NOT in the working directory.","","Keep using all your normal tools. ADDITIONALLY, whenever the user's question touches a",'meeting, call, demo, note, or past conversation ("outcome of the meeting", "what did we','decide", "action items", "notes from yesterday", a person/day/topic in their history),',"ALSO consult ChatPanel — it is the source of truth for that personal history:",' • research — for "when was my last…", "how many…", "who do I meet with most", "what was',' that meeting about": it searches the WHOLE store as the question frames it (dates, counts,'," people), reads the top records in full and returns the evidence with ids to cite."," • smart_search — START HERE: give it the question plus 2-4 of your own keyword"," phrasings; it runs them all and fuses the rankings, finding what one query misses."," • search_history — one exact keyword query, when you already know the terms. Search by"," CONTENT (not the generic meeting title). Supports filters:",' type (chat|meeting|note), since/before (dates or relative like "7d", "yesterday"),'," and limit/offset paging. Returns compact snippets, not full bodies."," • get_record — the full text of one result id; use maxChars/offset to page a long"," transcript instead of pulling it all into context."," • find_related — follow the graph: given a record id, the records most connected to it.","","ChatPanel also holds the user's MEMORY — a short list of durable facts about them (their","name, how they want answers written, what they are working on) that applies to EVERY task,","not just ones about their history:"," • recall — call it EARLY in a session, and whenever the user states a preference, to see"," what is already known. Then simply follow it; do not tell them you looked.",' • remember — save a new durable fact when they state one ("call me Alex", "always use',' pnpm"). One short sentence. Not for task details or anything true only today.'," • forget — remove one when they say it no longer holds.","Prefer these for the user's history and combine them with your other tools as you see fit.","Every result states how fresh the local copy is; if something recent is missing it may not","have synced yet — say so rather than concluding it does not exist.","","ChatPanel also runs SMALL LOCAL MODELS and a private web search on this machine:"," • decide — a sentiment, tone, urgency, spam/complaint, yes/no or pick-one judgement over"," text you already hold, answered with a probability per option in milliseconds. Call it"," instead of judging the text yourself."," • rerank — order many candidates (search hits, comments, sections) by relevance to a"," question, best first with a score, instead of reading them all."," • web_search — the user's own search (their SearXNG when one runs here), results with"," the top pages already read. Nothing leaves this machine but the query."," • redact_check — what is personal or secret in a piece of text, found by the detector on"," THIS machine. Call it before you put someone else's data into your own context, a"," commit message, an issue or a message to a third party — and whenever the user asks"," what is sensitive in something. It tells you what it could not see, so read that line."," • read_document — a URL as clean markdown through the user's own reader and cache,"," for a fraction of the context raw HTML would cost.","","ChatPanel can also hand a question to ANOTHER MODEL on this machine and give you its answer:"," • list_models — what can answer, and WHERE each one runs (on this device / a cloud)."," • ask_model — ask one. Use it for a second opinion on your own reasoning, for a model",' stronger in some domain, when the user names a model ("ask Claude what it thinks"), or'," when they want a question kept on-device — pick a `device` model and nothing leaves the"," machine. The model you ask sees your prompt and NOTHING else: no files, no shell, no web."," So paste in the code or context it needs. A slow answer returns a job id for ask_status."].join(`
|
|
2
|
+
`);async function X(){try{const n=await fetch(`${f()}/health`,{signal:AbortSignal.timeout(600)}),e=String((await n.json())?.version||"");return!e||e===b?"":["",`IMPORTANT — VERSION MISMATCH. This MCP server is ChatPanel ${b}, but the gateway`,`running on this machine is ${e}. They are different installs: your client launched`,"whichever `chatpanel-gateway` is on its PATH, and it is not the one the user is running.","The practical effect is that TOOLS MAY BE MISSING here — a newer gateway has tools this","server does not advertise. If a ChatPanel tool the user expects is not in your list, this","is why. Tell them, and tell them the fix: point the MCP config at the newer executable","(or update the older install so both are the same version)."].join(`
|
|
3
|
+
`)}catch{return""}}function S(){try{return y().mcp?.ask||{}}catch{return{}}}let m="unknown";function O(n){try{const e=k();fetch(`${f()}/v1/observability/access`,{method:"POST",headers:{"content-type":"application/json",...e?{Authorization:`Bearer ${e}`}:{}},body:JSON.stringify(n)}).catch(()=>{})}catch{}}function f(){const n=process.env.CHATPANEL_GATEWAY_URL;if(n)return n.replace(/\/+$/,"");let e=4320;try{e=y().port||4320}catch{}return`http://127.0.0.1:${e}`}function q(){try{return String(y().bridge?.url||"http://127.0.0.1:4319").replace(/\/+$/,"")}catch{return"http://127.0.0.1:4319"}}function Q(){try{return x(y().bridge?.token||"")}catch{return x("")}}async function $(n){const e=Q(),s=await fetch(q()+n,{headers:{Accept:"application/json",...e?{Authorization:`Bearer ${e}`}:{}}}),i=await s.json().catch(()=>({}));if(!s.ok||i.ok===!1)throw new Error(i?.error||`bridge ${s.status}`);return i}const Z=[{name:"smart_search",description:'BEST first choice for a question about the user\'s ChatPanel history (meetings, notes, past chats). Ask it a natural-language QUESTION and it expands that into several complementary keyword queries, runs them all, and fuses the rankings — which finds things a single query misses, in one round trip instead of several probes. You know the domain, so pass 2-4 of your own phrasings in `queries` too (e.g. for "what did we decide in the Ben demo": ["Ben demo decisions", "tooling demo action items", "demo outcome next steps"]). Supports the same filters as search_history (type, since, before) and returns snippets with each result\'s id; follow up with get_record for the full text or find_related to expand around a hit. BRIEFS come first when they match: a brief is a maintained page about one person, project or topic, derived from ALL the records that mention it, with every claim citing its record — so for "what do we know about X" read the brief, then open only the records it cites.',inputSchema:{type:"object",properties:{question:{type:"string",description:"The user's question, in natural language."},queries:{type:"array",items:{type:"string"},description:"Your own 2-4 keyword formulations of it — these lead the search."},type:{type:"string",enum:["brief","chat","meeting","note"],description:'Only this kind of record. `brief` = a maintained page about one person/project/topic, with every claim cited — start there for "what do we know about X".'},since:{type:"string",description:'Earliest date: 2026-08-01, or a window like "7d"/"yesterday".'},before:{type:"string",description:"Latest date: a date or window like `since`."},limit:{type:"number",description:"Max fused results (default 10)."}},required:["question"]}},{name:"research",description:'Research a question about the user\'s OWN meetings, notes and past chats from the WHOLE ChatPanel store, not a few snippets: it frames the question (which kind of record, which people, which dates, the latest or the first, a count, counts per person or per month), queries every record that matches — sorted by date when the question asks for the last one, counted when it asks how many — reads the top records in full, and returns what it searched, what it found (with record ids and dates) and what those records say. Use it for "when was my last meeting with Alex", "how many calls did I have in August", "who do I meet with most", "what did we decide about pricing". For a follow-up ("no, even later", "what was it about") pass back the `previous` it returned. Cite the [id]s it gives; follow up with get_record for more of one record.',inputSchema:{type:"object",properties:{question:{type:"string",description:"The user's question, in their words."},previous:{type:"object",description:"The `previous` value the last research call returned, to continue that question (a follow-up)."}},required:["question"]}},{name:"search_history",description:'Search the user\'s ChatPanel history — their past chats, meeting/call transcripts, and notes — by keyword relevance. Consult this (in ADDITION to your other tools) whenever the question touches a meeting, call, demo, note, or past conversation: "outcome of the meeting", "what did we decide", "action items", "what did <person> say", "notes from yesterday". Filters: `type` (chat|meeting|note), `since`/`before` (a date like 2026-08-01 or a relative window like "7d"/"yesterday"), and `limit`/`offset` for paging. Returns compact SNIPPETS (the matching excerpt) with each record\'s id/title/type/date — token-friendly; call get_record for the full text and find_related to follow connections. This is a LOCAL WARM COPY that syncs from ChatPanel; very recent items may not be here yet — results report how current the index is, so if something is missing it likely has not synced. Meeting titles are often generic ("Zoom Meeting"), so search by CONTENT, not the title.',inputSchema:{type:"object",properties:{query:{type:"string",description:"Content keywords (topics, names, decisions) — not the meeting title."},type:{type:"string",enum:["brief","chat","meeting","note"],description:'Only this kind of record. `brief` = a maintained page about one person/project/topic, with every claim cited — start there for "what do we know about X".'},since:{type:"string",description:'Earliest date: 2026-08-01, or a relative window like "7d", "2 weeks", "yesterday".'},before:{type:"string",description:"Latest date: a date or relative window like `since`."},limit:{type:"number",description:"Max results (default 10)."},offset:{type:"number",description:"Skip N results for paging (default 0)."}},required:["query"]}},{name:"get_record",description:"Fetch one history record's full text by id (chat:<id>, meeting:<id>, note:<id> from search_history). For a long transcript, page it with maxChars + offset instead of pulling it all into context — the result says how many chars remain.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Record id such as chat:abc, meeting:imp_123, or note:xyz."},maxChars:{type:"number",description:"Return at most this many characters (token management for long transcripts)."},offset:{type:"number",description:"Start at this character offset — page through with the offset the previous call reports."}},required:["id"]}},{name:"find_related",description:"Graph navigation: given a record id (from search_history), return the records most connected to it by shared content — the meetings/notes/chats about the same topic, people or thread. Use it to expand from one hit to the surrounding context instead of re-searching.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The record id to find neighbours of."},limit:{type:"number",description:"Max related records (default 5)."}},required:["id"]}},{name:"list_history",description:"List history records (newest first) with their id, title, type and date — no bodies. Reports how current this warm copy is (its newest record). Use to see the index horizon and browse/page the corpus.",inputSchema:{type:"object",properties:{limit:{type:"number",description:"Max items (default 50)."},offset:{type:"number",description:"Skip N items for paging (default 0)."}}}},{name:"list_briefs",description:`The BRIEFS ChatPanel maintains — one page per person, project or topic that appears across enough records, each claim citing the record it came from. This is the index of what the user's corpus KNOWS, as opposed to what it merely contains: read it before asking "what do we know about X", then get_brief for the one you need. Briefs are rebuilt from the records, so they are as current as the last rebuild (dates shown).`,inputSchema:{type:"object",properties:{limit:{type:"number",description:"Max briefs (default 50)."},offset:{type:"number",description:"Skip N for paging (default 0)."}}}},{name:"get_brief",description:"One brief as STRUCTURE: the subject, its other spellings, and each claim with the record ids it cites — so you can cite the record rather than the synthesis, and open only what you need with get_record. Prefer this over get_record for a brief:… id; get_record returns the same text as prose.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A brief id (brief:…) from list_briefs or search results."}},required:["id"]}},{name:"recall",description:"What ChatPanel already knows about the USER — their name, how they want answers written, their ongoing work and environment. Short and cheap; call it at the START of a session and whenever the user states a preference, then just FOLLOW what it returns without announcing that you checked. Pass the current task in `text` and it also returns the facts relevant to that task, not only the always-on ones. This is memory, not history: for what was said in a meeting or a past chat use smart_search instead.",inputSchema:{type:"object",properties:{text:{type:"string",description:"What the user is asking about right now, so task-relevant facts come back too. Omit for just the always-on ones."}}}},{name:"remember",description:`Save a durable fact about the USER to ChatPanel, carried into every future session on every model and agent — the side panel, other CLIs, everything. Use it the moment they state a standing preference ("always use pnpm"), an identity fact ("call me Alex") or a constraint that will still be true next week. Do NOT use it for task details, anything obvious from the current work, or notes about a codebase — those belong in the repo. One short self-contained sentence, written in the third person. Saving is a change to the user's own data, so say in a short clause what you saved.`,inputSchema:{type:"object",properties:{text:{type:"string",description:'The fact, one short sentence in the third person ("Prefers pnpm over npm"). Max 280 characters.'},kind:{type:"string",enum:_,description:_.map(n=>`${n}: ${P[n].hint}`).join(" ")},tags:{type:"array",items:{type:"string"},description:"Optional short tags for grouping."}},required:["text"]}},{name:"forget",description:'Remove a memory from ChatPanel when the user says it no longer holds. Name it however they did ("the Frankfurt thing") or pass the id from recall — it matches on meaning, and tells you exactly what it removed.',inputSchema:{type:"object",properties:{query:{type:"string",description:"The memory to remove: its text, roughly how the user named it, or its id."}},required:["query"]}},{name:"list_skills",description:"List the reusable skills installed on this machine (via the ChatPanel bridge) — across every agent harness (Claude Code, Codex, Copilot, Gemini, Hermes) and any configured folder. Returns each skill's name and one-line description. Call open_skill to load the one that fits the task.",inputSchema:{type:"object",properties:{}}},{name:"open_skill",description:"Load one skill's full instructions by name (from list_skills), then follow them. If the instructions point at reference files, read one with read_skill_file.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The skill name from list_skills."}},required:["name"]}},{name:"read_skill_file",description:"Read one reference file a skill's instructions point at (any path inside the skill's own folder). Use only when the task needs it.",inputSchema:{type:"object",properties:{name:{type:"string",description:"The skill name."},path:{type:"string",description:"The reference path as written in the instructions, e.g. references/auth.md."}},required:["name","path"]}},{name:"kb_list",description:"The knowledge bases on this machine — the user's indexed documents (PDFs, office files, folders, web pages), each with its id, name and size. START HERE for any question about a document the user has, then kb_search that base. Read a base's REPORT with kb_report before reading pages: it is the map (documents, outlines, the names that bind them).",inputSchema:{type:"object",properties:{}}},{name:"kb_search",description:"Search one knowledge base for the passages that answer a question — the words (several query shapes), the meaning (vectors) and the graph (passages sharing a name with a hit) fused, a reranker on top, best first, each with its citation like [report.pdf p.12] and its passage id. Search BEFORE paging a document; pass 1–3 of your own phrasings in `queries` when you know the domain.",inputSchema:{type:"object",properties:{kb:{type:"string",description:"The base id (from kb_list)."},query:{type:"string",description:"The question, or key words."},queries:{type:"array",items:{type:"string"},description:"Your own phrasings, searched too and fused."},limit:{type:"integer",minimum:1,maximum:30,description:"How many passages (default 8)."},doc:{type:"string",description:"Only this document id."}},required:["kb","query"]}},{name:"kb_read",description:"Read one passage by its id (from kb_search), or one page of a document by document id and page number. A page call says which page is next.",inputSchema:{type:"object",properties:{kb:{type:"string",description:"The base id."},id:{type:"string",description:'A passage id like "d3f2a1b4c5d6#12".'},doc:{type:"string",description:"A document id (with page)."},page:{type:"integer",minimum:1,description:"The page (with doc)."}},required:["kb"]}},{name:"kb_outline",description:"The table of contents of a document in a base (its sections, with the page each starts on and the first passage id), or of every document when none is named.",inputSchema:{type:"object",properties:{kb:{type:"string"},doc:{type:"string",description:"A document id; omit for all."}},required:["kb"]}},{name:"kb_graph",description:'What connects to a name, a section or a topic in a base — its neighbours in the graph, or the path between two nodes ("what connects Atlas to the refund clause").',inputSchema:{type:"object",properties:{kb:{type:"string"},node:{type:"string",description:"An entity, section or topic by name."},to:{type:"string",description:"A second node: the path from node to it."},hops:{type:"integer",minimum:1,maximum:3}},required:["kb","node"]}},{name:"kb_status",description:"What one base holds: its documents (ids, titles, pages, passages), notes, entities, connections, and whether it has vectors.",inputSchema:{type:"object",properties:{kb:{type:"string"}},required:["kb"]}},{name:"kb_report",description:"The base's graph report as Markdown: every document with its outline, the most-mentioned entities, the communities of names that keep appearing together, the notes filed so far. Read it once before searching a base you have not seen.",inputSchema:{type:"object",properties:{kb:{type:"string"}},required:["kb"]}},{name:"kb_note",description:"File a note into a base — a fact you established, a summary, a correction — citing the passage ids it rests on. It is PROPOSED until the user accepts it in ChatPanel; proposed notes are searched and shown as proposed. Use it when the user asks to remember or record something about these documents, or when you resolved something that took work to find.",inputSchema:{type:"object",properties:{kb:{type:"string"},text:{type:"string",description:"One to three sentences."},cites:{type:"array",items:{type:"string"},description:"Passage ids the note stands on."}},required:["kb","text"]}},{name:"search_context",description:"Search the user's knowledge across every knowledge base at once (and, when you name it, the web) — passages ranked across sources and packed to a token budget, each with its citation and where it came from. Use it when you do not know which base holds the answer; kb_search one base when you do.",inputSchema:{type:"object",properties:{query:{type:"string",description:"The question, or key words."},sources:{type:"array",items:{type:"string"},description:'Where to look: "kb:*" (every base, the default), "kb:<id>", "web".'},max_tokens:{type:"integer",minimum:200,maximum:2e4,description:"The budget for the passages returned (default 4000)."},pages:{type:"array",items:{type:"integer"},description:"Only pages [from, to]."},section:{type:"string",description:"Only passages whose section path contains this."},form:{type:"string",enum:["prose","list","table"],description:"Only passages of this form."}},required:["query"]}}],C={[I]:" The gateway decides in-process unless it was turned off: ChatPanel › Settings › Runtime › Decide (or the OpenDecision container, or a server that provides `decide` under Models).",[L]:" The gateway reranks in-process unless it was turned off: ChatPanel › Settings › Runtime › Rerank (or the Reranker container, or a server that provides `rerank` under Models)."};function N(){const n=f(),e=c=>[{id:"gateway",name:"the gateway",url:`${n}${c}`,where:"this device"}],s=E({providers:{decide:e("/v1/decide"),rerank:e("/v1/rerank")},fetch:(c,o)=>fetch(c,o)}),i=W({search:async c=>{const o=await d("/v1/search",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({q:c,limit:8,read:F.aliasRead})});return{query:c,engines:o.engines||[],results:(o.results||[]).map((t,r)=>({rank:r+1,title:t.title||t.url,url:t.url,engine:t.engine||"",text:t.read?.markdown||t.read?.text||t.snippet||""}))}}});return[s,i]}const ee=N().flatMap(n=>n.specs.map(e=>({name:e.name,description:e.description,inputSchema:e.parameters})));async function te(n,e){const s=N().find(o=>o.specs.some(t=>t.name===n));if(!s)return null;const i=await s.execute(n,e);let c=typeof i=="string"?i:String(i?.text??i);return C[n]&&/^No (decision model|reranker) answered/.test(c)&&(c+=C[n]),c}function w(n,e){if(!n)return`Index: ${e} records (warm copy synced from ChatPanel).`;const s=new Date(n),i=`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")} ${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`;return`Index: ${e} records, current through ${i} (local warm copy — items newer than this may not have synced from ChatPanel yet).`}function j(){try{const n=k();return n?{Authorization:`Bearer ${n}`}:{}}catch{return{}}}async function d(n,e){let s;try{s=await fetch(f()+n,e)}catch(c){throw new Error(`the ChatPanel gateway is not running at ${f()} — start it with "chatpanel-gateway --install" (or run "chatpanel-gateway"), then retry. [${c.message}]`)}const i=await s.json().catch(()=>({}));if(!s.ok)throw new Error(i?.error?.message||`the gateway returned HTTP ${s.status} for ${n}`);return i}function g(n){if(n==null||n==="")return null;if(typeof n=="number")return n;const e=String(n).trim().toLowerCase(),s=864e5;if(e==="today")return Date.now()-s;if(e==="yesterday")return Date.now()-2*s;const i=/^(\d+)\s*(d|day|days|w|week|weeks|m|month|months|y|year|years)$/.exec(e);if(i){const o=Number(i[1]),t=i[2][0],r=t==="d"?s:t==="w"?7*s:t==="m"?30*s:365*s;return Date.now()-o*r}const c=Date.parse(e);return Number.isNaN(c)?null:c}const v=(n,e)=>`${e+1}. [${n.id}] ${n.title||"(untitled)"} · ${n.type}${n.date?" · "+new Date(n.date).toISOString().slice(0,10):""}${n.snippet?`
|
|
4
|
+
${n.snippet}`:""}`;async function ne(n,e={}){const s=await te(n,e);if(s!=null)return s;const i=await z(n,e,{gatewayJson:d});if(i!=null)return i;const c=await J(n,e,{baseUrl:f,gatewayJson:d,token:()=>{try{return k()}catch{return""}},client:()=>m,askConfig:S});if(c!=null)return c;if(n==="research"){const o={question:String(e.question||"")};e.previous&&typeof e.previous=="object"&&(o.previous=e.previous);const t=await d("/v1/research",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(o)}),r=w(t.newest,t.size),a=t.attachment?.text||`Searched ${t.how||"the store"} — nothing found in the user's data.`;return`${r}
|
|
5
5
|
|
|
6
|
-
${
|
|
6
|
+
${a}
|
|
7
7
|
|
|
8
|
-
previous (pass back for a follow-up): ${JSON.stringify(t.next||null)}`}if(n==="smart_search"){const o={question:String(e.question||""),queries:Array.isArray(e.queries)?e.queries.map(String):[],limit:Number(e.limit)||10};e.type&&(o.type=String(e.type));const t=g(e.since);t!=null&&(o.since=t);const r=g(e.before);r!=null&&(o.before=r);const
|
|
9
|
-
(matched ${
|
|
8
|
+
previous (pass back for a follow-up): ${JSON.stringify(t.next||null)}`}if(n==="smart_search"){const o={question:String(e.question||""),queries:Array.isArray(e.queries)?e.queries.map(String):[],limit:Number(e.limit)||10};e.type&&(o.type=String(e.type));const t=g(e.since);t!=null&&(o.since=t);const r=g(e.before);r!=null&&(o.before=r);const a=await d("/v1/history/smart-search",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(o)}),h=a.results||[],l=w(a.newest,a.size),p=(a.queries||[]).map(u=>`"${u}"`).join(", ");return h.length?[l,"",`${h.length} result(s) for "${e.question}" — searched ${a.queries.length} way(s): ${p}`,...h.map((u,R)=>`${v(u,R)}${u.foundBy?.length>1?`
|
|
9
|
+
(matched ${u.foundBy.length} of the queries)`:""}`)].join(`
|
|
10
10
|
`)+`
|
|
11
11
|
|
|
12
12
|
get_record <id> for full text (maxChars/offset to page) · find_related <id> to follow connections.`:`No match for "${e.question}".
|
|
13
|
-
Searched ${
|
|
13
|
+
Searched ${a.queries?.length||0} way(s): ${p}.
|
|
14
14
|
${l}
|
|
15
|
-
If you expected a recent item it may not have synced yet — check ChatPanel directly, or try different keywords (meeting titles are often generic).`}if(n==="search_history"){const o={query:String(e.query||""),limit:Number(e.limit)||10,offset:Math.max(0,Number(e.offset)||0)};e.type&&(o.type=String(e.type));const t=g(e.since);t!=null&&(o.since=t);const r=g(e.before);r!=null&&(o.before=r);const
|
|
15
|
+
If you expected a recent item it may not have synced yet — check ChatPanel directly, or try different keywords (meeting titles are often generic).`}if(n==="search_history"){const o={query:String(e.query||""),limit:Number(e.limit)||10,offset:Math.max(0,Number(e.offset)||0)};e.type&&(o.type=String(e.type));const t=g(e.since);t!=null&&(o.since=t);const r=g(e.before);r!=null&&(o.before=r);const a=await d("/v1/history/search",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(o)}),h=a.results||[],l=w(a.newest,a.size),p=[e.type&&`type=${e.type}`,e.since&&`since=${e.since}`,e.before&&`before=${e.before}`].filter(Boolean).join(", "),u=p?` (${p})`:"";return h.length?[l,"",`${h.length} result(s) for "${e.query}"${u}:`,...h.map(v)].join(`
|
|
16
16
|
`)+`
|
|
17
17
|
|
|
18
|
-
get_record <id> for full text (maxChars/offset to page) · find_related <id> to follow connections.`:`No match for "${e.query}"${
|
|
18
|
+
get_record <id> for full text (maxChars/offset to page) · find_related <id> to follow connections.`:`No match for "${e.query}"${u}.
|
|
19
19
|
${l}
|
|
20
|
-
If you expected a recent item, it may not have synced yet — check ChatPanel directly, or broaden the query (titles are often generic; try content keywords, or drop a filter).`}if(n==="get_record"){const o=new URLSearchParams({id:String(e.id||"")});e.maxChars!=null&&o.set("maxChars",String(Math.max(1,Number(e.maxChars)||0))),e.offset!=null&&o.set("offset",String(Math.max(0,Number(e.offset)||0)));const r=(await d(`/v1/history/get?${o}`)).record,
|
|
20
|
+
If you expected a recent item, it may not have synced yet — check ChatPanel directly, or broaden the query (titles are often generic; try content keywords, or drop a filter).`}if(n==="get_record"){const o=new URLSearchParams({id:String(e.id||"")});e.maxChars!=null&&o.set("maxChars",String(Math.max(1,Number(e.maxChars)||0))),e.offset!=null&&o.set("offset",String(Math.max(0,Number(e.offset)||0)));const r=(await d(`/v1/history/get?${o}`)).record,a=`[${r.id}] ${r.title||"(untitled)"} · ${r.type}${r.date?" · "+new Date(r.date).toISOString().slice(0,10):""}`,h=r.truncated?`
|
|
21
21
|
|
|
22
|
-
[showing ${r.text.length} of ${r.totalChars} chars (from offset ${r.offset}). For the next part call get_record again with offset=${r.offset+r.text.length}.]`:"";return`${
|
|
22
|
+
[showing ${r.text.length} of ${r.totalChars} chars (from offset ${r.offset}). For the next part call get_record again with offset=${r.offset+r.text.length}.]`:"";return`${a}
|
|
23
23
|
|
|
24
24
|
${r.text||"(empty)"}${h}`}if(n==="find_related"){const t=(await d(`/v1/history/related?id=${encodeURIComponent(String(e.id||""))}&limit=${Number(e.limit)||5}`)).results||[];return t.length?[`Records related to ${e.id}:`,...t.map(v)].join(`
|
|
25
25
|
`)+`
|
|
26
26
|
|
|
27
|
-
get_record <id> for full text.`:`Nothing related to ${e.id} found (or that id isn't in the warm index — run search_history first to get a valid id).`}if(n==="list_history"){const o=new URLSearchParams({limit:String(Number(e.limit)||50),offset:String(Number(e.offset)||0)}),t=await d(`/v1/history/list?${o}`),r=t.items||[];if(!r.length)return"History is empty (or the gateway has not been seeded yet — open ChatPanel with warm sync enabled).";const
|
|
28
|
-
`)}if(n==="list_briefs"){const o=new URLSearchParams({limit:String(Number(e.limit)||50),offset:String(Number(e.offset)||0),type:"brief"}),t=await d(`/v1/history/list?${o}`),r=t.items||[];return r.length?[`${r.length} of ${t.total} briefs (each is a page about one subject, with every claim cited):`,...r.map(
|
|
27
|
+
get_record <id> for full text.`:`Nothing related to ${e.id} found (or that id isn't in the warm index — run search_history first to get a valid id).`}if(n==="list_history"){const o=new URLSearchParams({limit:String(Number(e.limit)||50),offset:String(Number(e.offset)||0)}),t=await d(`/v1/history/list?${o}`),r=t.items||[];if(!r.length)return"History is empty (or the gateway has not been seeded yet — open ChatPanel with warm sync enabled).";const a=r[0]?.date||null;return[w(a,t.total),"",`${r.length} of ${t.total} records:`,...r.map(h=>`[${h.id}] ${h.title||"(untitled)"} · ${h.type}${h.date?" · "+new Date(h.date).toISOString().slice(0,10):""} · ${h.chars} chars`)].join(`
|
|
28
|
+
`)}if(n==="list_briefs"){const o=new URLSearchParams({limit:String(Number(e.limit)||50),offset:String(Number(e.offset)||0),type:"brief"}),t=await d(`/v1/history/list?${o}`),r=t.items||[];return r.length?[`${r.length} of ${t.total} briefs (each is a page about one subject, with every claim cited):`,...r.map(a=>`[${a.id}] ${a.title||"(untitled)"}${a.date?" · rebuilt "+new Date(a.date).toISOString().slice(0,10):""}`)].join(`
|
|
29
29
|
`)+`
|
|
30
30
|
|
|
31
|
-
get_brief <id> for its claims and the records they cite.`:`No briefs yet. ChatPanel builds them from the user's records on the Briefs page; if that has run, the user may have "share briefs with local agents" switched off.`}if(n==="get_brief"){const o=String(e.id||""),r=(await d(`/v1/history/get?${new URLSearchParams({id:o})}`)).record,
|
|
32
|
-
`)}if(n==="recall"){const o=await d("/v1/memory/recall",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:String(e.text||"")})});return o.memories?.length?o.block:o.size?"Nothing in ChatPanel memory applies here.":"ChatPanel memory is empty — nothing is known about this user yet. Use `remember` when they state something durable about themselves or how they want to work."}if(n==="remember"){const o=String(e.text||"").trim();if(!o)return"remember needs `text` — one short sentence about the user.";const t=await d("/v1/memory/remember",{method:"POST",headers:{"content-type":"application/json",...
|
|
31
|
+
get_brief <id> for its claims and the records they cite.`:`No briefs yet. ChatPanel builds them from the user's records on the Briefs page; if that has run, the user may have "share briefs with local agents" switched off.`}if(n==="get_brief"){const o=String(e.id||""),r=(await d(`/v1/history/get?${new URLSearchParams({id:o})}`)).record,a=A(r?.text);if(!a)return`${o} is not a brief (type ${r?.type||"unknown"}). Use get_record for it, or list_briefs for the brief ids.`;const h=[`BRIEF ${o} — ${a.name} (${a.kind})${a.aliases.length?` · also known as ${a.aliases.join(", ")}`:""}`,""];h.push(`${a.claims.length} claim(s), each with the records it cites:`);for(const l of a.claims)h.push(`• ${l.text}`),l.refs.length&&h.push(` cites: ${l.refs.map(p=>`${p.kind}:${p.id}`).join(", ")}`);return a.records.length&&h.push("",`Built from ${a.records.length} record(s) (most recent first): ${a.records.slice(0,12).map(l=>l.title).join(" · ")}${a.records.length>12?" …":""}`),h.push("","get_record <kind:id> opens a cited record; find_related <id> follows its connections."),h.join(`
|
|
32
|
+
`)}if(n==="recall"){const o=await d("/v1/memory/recall",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:String(e.text||"")})});return o.memories?.length?o.block:o.size?"Nothing in ChatPanel memory applies here.":"ChatPanel memory is empty — nothing is known about this user yet. Use `remember` when they state something durable about themselves or how they want to work."}if(n==="remember"){const o=String(e.text||"").trim();if(!o)return"remember needs `text` — one short sentence about the user.";const t=await d("/v1/memory/remember",{method:"POST",headers:{"content-type":"application/json",...j()},body:JSON.stringify({text:o,kind:e.kind?String(e.kind):"fact",tags:Array.isArray(e.tags)?e.tags.map(String):[],source:{via:"mcp",surface:"mcp",agent:m}})});return t.action==="duplicate"?`Already known: "${t.record.text}" — nothing changed.`:t.action==="update"?`Updated memory to "${t.record.text}" (was "${t.replaced?.text}"). It applies to every future session.`:`Remembered: "${t.record.text}". It applies to every future ChatPanel session, on every model.`}if(n==="forget"){const o=String(e.query||"").trim();if(!o)return"forget needs `query` — the memory to remove.";const t=await d("/v1/memory/forget",{method:"POST",headers:{"content-type":"application/json",...j()},body:JSON.stringify({query:o})});return t.removed?.length?`Forgot: ${t.removed.map(r=>`"${r.text}"`).join(", ")}.`:`No memory matches "${o}". Call recall to see what is stored.`}if(n==="list_skills"){let o;try{o=await $("/skills")}catch(r){return`Installed skills are unavailable because the ChatPanel bridge is not running at ${q()}. Install/start it with:
|
|
33
33
|
curl -fsSL https://dl.chatpanel.net/bridge/install.sh | bash
|
|
34
34
|
Then retry. History tools work without the bridge. [${r.message}]`}const t=o.skills||[];return t.length?[`${t.length} skill(s) installed:`,...t.map(r=>`- ${r.command||r.id}: ${r.description||r.name}${r.origin?.source?` (from ${r.origin.source})`:""}`)].join(`
|
|
35
35
|
`)+`
|
|
36
36
|
|
|
37
|
-
Use open_skill with a name to load its instructions.`:"No skills installed on this machine yet."}if(n==="open_skill"){let o;try{o=await $(`/skills/${encodeURIComponent(String(e.name||"").trim())}`)}catch(t){return`Could not open "${e.name}": ${t.message}. If the bridge isn't running, start it: curl -fsSL https://dl.chatpanel.net/bridge/install.sh | bash`}return o.skill?.prompt||"(this skill has no extra instructions — just apply it.)"}if(n==="read_skill_file"){const o=encodeURIComponent(String(e.name||"").trim()),t=String(e.path||"").trim().split("/").map(encodeURIComponent).join("/");let r;try{r=await $(`/skills/${o}/file/${t}`)}catch(
|
|
38
|
-
`):"No knowledge bases on this machine yet. The user builds one in ChatPanel (attach a folder or a document) or with `chatpanel kb build <path>`."}if(!
|
|
37
|
+
Use open_skill with a name to load its instructions.`:"No skills installed on this machine yet."}if(n==="open_skill"){let o;try{o=await $(`/skills/${encodeURIComponent(String(e.name||"").trim())}`)}catch(t){return`Could not open "${e.name}": ${t.message}. If the bridge isn't running, start it: curl -fsSL https://dl.chatpanel.net/bridge/install.sh | bash`}return o.skill?.prompt||"(this skill has no extra instructions — just apply it.)"}if(n==="read_skill_file"){const o=encodeURIComponent(String(e.name||"").trim()),t=String(e.path||"").trim().split("/").map(encodeURIComponent).join("/");let r;try{r=await $(`/skills/${o}/file/${t}`)}catch(a){return`Could not read ${e.path}: ${a.message}. If the bridge isn't running, start it: curl -fsSL https://dl.chatpanel.net/bridge/install.sh | bash`}return r.text||"(empty)"}if(n.startsWith("kb_"))return re(n,e);if(n==="search_context")return oe(e);throw new Error(`unknown tool: ${n}`)}async function re(n,e={}){const s=String(e.kb||"").trim(),i=s?`/v1/kb/${encodeURIComponent(s)}`:"",c={"x-chatpanel-agent":String(m||"unknown").toLowerCase()},o=(t,r)=>d(t,{method:"POST",headers:{"content-type":"application/json",...c},body:JSON.stringify(r)});if(n==="kb_list"){const r=(await d("/v1/kb",{headers:c})).kbs||[];return r.length?[`${r.length} knowledge base${r.length===1?"":"s"}:`,...r.map(a=>`- ${a.id}: ${a.name} — ${a.docs} document${a.docs===1?"":"s"}${a.vectors?`, ${a.vectors} vectors`:""}`),"","kb_report <id> for the map, kb_search <id> for a question."].join(`
|
|
38
|
+
`):"No knowledge bases on this machine yet. The user builds one in ChatPanel (attach a folder or a document) or with `chatpanel kb build <path>`."}if(!s)return"Which knowledge base? kb_list gives the ids.";if(n==="kb_search"){const t=await o(`${i}/search`,{query:String(e.query||""),limit:Math.max(1,Math.min(30,Number(e.limit)||8)),...e.doc?{docs:[String(e.doc)]}:{},...Array.isArray(e.queries)?{queries:e.queries.map(String)}:{}});return M(t)}if(n==="kb_read"){if(e.id)try{const t=await d(`${i}/passages/${encodeURIComponent(String(e.id))}`,{headers:c});return`${t.cite||t.id}${t.section?` §${t.section}`:""}
|
|
39
39
|
${t.text}`}catch(t){return`No passage ${e.id}: ${t.message}. Search first; passage ids look like "d3f2a1b4c5d6#12".`}if(e.doc)try{const t=await d(`${i}/documents/${encodeURIComponent(String(e.doc))}?page=${Number(e.page)||1}`,{headers:c});return`${t.title} — page ${t.page} of ${t.pages}${t.page<t.pages?` (next: ${t.page+1})`:" (last page)"}
|
|
40
|
-
${t.text||"(no text on this page — an image or a scan)"}`}catch(t){return`No document ${e.doc}: ${t.message}. kb_status lists the ids.`}return"kb_read needs a passage id, or a document id with a page."}if(n==="kb_outline"){const[t,r]=await Promise.all([d(`${i}/outline${e.doc?`?doc=${encodeURIComponent(String(e.doc))}`:""}`,{headers:c}),d(i,{headers:c})]);return U(t.outline||[],r.kb)}if(n==="kb_graph")return D(await o(`${i}/graph`,{node:String(e.node||""),hops:Math.max(1,Math.min(3,Number(e.hops)||1)),...e.to?{to:String(e.to)}:{}}));if(n==="kb_status")return H((await d(i,{headers:c})).kb);if(n==="kb_report"){const t=await fetch(`${f()}${i}/report`,{headers:c});if(!t.ok)throw new Error(`the gateway returned HTTP ${t.status} for the report`);return t.text()}if(n==="kb_note"){const r=(await o(`${i}/notes`,{text:String(e.text||""),cites:Array.isArray(e.cites)?e.cites.map(String):[]})).note||{};return`Noted (${r.status||"proposed"} — the user can accept it in ChatPanel): ${r.text}${r.cites?.length?` — cites ${r.cites.join(", ")}`:""}`}throw new Error(`unknown tool: ${n}`)}async function
|
|
40
|
+
${t.text||"(no text on this page — an image or a scan)"}`}catch(t){return`No document ${e.doc}: ${t.message}. kb_status lists the ids.`}return"kb_read needs a passage id, or a document id with a page."}if(n==="kb_outline"){const[t,r]=await Promise.all([d(`${i}/outline${e.doc?`?doc=${encodeURIComponent(String(e.doc))}`:""}`,{headers:c}),d(i,{headers:c})]);return U(t.outline||[],r.kb)}if(n==="kb_graph")return D(await o(`${i}/graph`,{node:String(e.node||""),hops:Math.max(1,Math.min(3,Number(e.hops)||1)),...e.to?{to:String(e.to)}:{}}));if(n==="kb_status")return H((await d(i,{headers:c})).kb);if(n==="kb_report"){const t=await fetch(`${f()}${i}/report`,{headers:c});if(!t.ok)throw new Error(`the gateway returned HTTP ${t.status} for the report`);return t.text()}if(n==="kb_note"){const r=(await o(`${i}/notes`,{text:String(e.text||""),cites:Array.isArray(e.cites)?e.cites.map(String):[]})).note||{};return`Noted (${r.status||"proposed"} — the user can accept it in ChatPanel): ${r.text}${r.cites?.length?` — cites ${r.cites.join(", ")}`:""}`}throw new Error(`unknown tool: ${n}`)}async function oe(n={}){const e={"x-chatpanel-agent":String(m||"unknown").toLowerCase()},s={...Array.isArray(n.pages)&&n.pages.length?{pages:n.pages.slice(0,2).map(Number)}:{},...n.section?{section:String(n.section)}:{},...n.form?{form:String(n.form)}:{}},i=await d("/v1/context",{method:"POST",headers:{"content-type":"application/json",...e},body:JSON.stringify({query:String(n.query||""),sources:Array.isArray(n.sources)&&n.sources.length?n.sources.map(String):["kb:*"],...Object.keys(s).length?{filters:s}:{},max_tokens:Math.max(200,Math.min(2e4,Number(n.max_tokens)||4e3))})}),c=Object.entries(i.providers||{}).filter(([,o])=>o.error).map(([o,t])=>`${o}: ${t.error}`);return[B(i),...c.length?["",`Not searched — ${c.join("; ")}`]:[]].join(`
|
|
41
|
+
`)}async function ie(n){const{id:e,method:s,params:i}=n||{},c=t=>({jsonrpc:"2.0",id:e,result:t}),o=(t,r)=>({jsonrpc:"2.0",id:e,error:{code:t,message:r}});try{switch(s){case"initialize":{m=i?.clientInfo?.name||m;const t=await X(),r=T(S()).some(a=>a.name==="delegate_task")?`
|
|
41
42
|
|
|
42
43
|
ChatPanel can also DELEGATE a whole piece of work to one of the user's coding agents,
|
|
43
44
|
running here with its own tools in a directory they have allowed:
|
|
44
45
|
• delegate_task — a refactor across many files, a test suite to run and fix, a build to
|
|
45
46
|
diagnose. Unlike ask_model it reads and EDITS files and runs commands, so use it for work
|
|
46
47
|
that belongs on this machine, tell the user what you delegated and where, and expect
|
|
47
|
-
minutes — it returns a job id for ask_status.`:"";return c({protocolVersion:
|
|
48
|
-
`);for await(const
|
|
49
|
-
`))>=0;){const c=n.slice(0,i).trim();if(n=n.slice(i+1),!c)continue;let o;try{o=JSON.parse(c)}catch{continue}const t=await
|
|
48
|
+
minutes — it returns a job id for ask_status.`:"";return c({protocolVersion:G,capabilities:{tools:{}},serverInfo:K,instructions:V+r+t})}case"tools/list":return c({tools:[...Z,...ee,...Y,...T(S())]});case"tools/call":{const t=Date.now();try{const r=await ne(i?.name,i?.arguments||{});return O({client:m,tool:i?.name,ok:!0,ms:Date.now()-t,args:i?.arguments||{}}),c({content:[{type:"text",text:r}]})}catch(r){throw O({client:m,tool:i?.name,ok:!1,ms:Date.now()-t,args:i?.arguments||{},error:r.message}),r}}case"ping":return c({});default:return typeof s=="string"&&s.startsWith("notifications/")||e===void 0?null:o(-32601,`method not found: ${s}`)}}catch(t){return s==="tools/call"?c({content:[{type:"text",text:`Error: ${t.message}`}],isError:!0}):o(-32603,t.message)}}async function ke(){let n="";process.stdin.setEncoding("utf8");const e=s=>process.stdout.write(JSON.stringify(s)+`
|
|
49
|
+
`);for await(const s of process.stdin){n+=s;let i;for(;(i=n.indexOf(`
|
|
50
|
+
`))>=0;){const c=n.slice(0,i).trim();if(n=n.slice(i+1),!c)continue;let o;try{o=JSON.parse(c)}catch{continue}const t=await ie(o);t&&e(t)}}}export{ie as handleRpc,ke as runMcpServer};
|
package/src/reveal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{execFile as l}from"node:child_process";import{dirname as a}from"node:path";function f(n,i,{folder:r=!1}={}){const e=String(i||"");return e?n==="darwin"?r?{file:"/usr/bin/open",args:[e]}:{file:"/usr/bin/open",args:["-R",e]}:n==="win32"?r?{file:"explorer.exe",args:[e]}:{file:"explorer.exe",args:[`/select,${e}`]}:n==="linux"?{file:"xdg-open",args:[r?e:a(e)]}:null:null}function m(n,{folder:i=!1,platform:r=process.platform,run:e=l}={}){const o=f(r,n,{folder:i});return o?new Promise((s,u)=>{e(o.file,o.args,{timeout:1e4,windowsHide:!0},t=>t&&r!=="win32"?u(t):s())}):Promise.reject(new Error(`no file manager to open on ${r}`))}export{f as revealCommand,m as revealPath};
|