@chatpanel/events 0.389.0 → 0.392.0

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.
@@ -0,0 +1,32 @@
1
+ const u=Object.freeze({list:`function run() {
2
+ const Notes = Application('Notes');
3
+ const iso = (d) => { try { return d ? d.toISOString() : ''; } catch (e) { return ''; } };
4
+ const out = { accounts: [] };
5
+ for (const a of Notes.accounts()) {
6
+ const acc = { id: a.id(), name: a.name(), folders: [] };
7
+ const seen = {};
8
+ const queue = a.folders();
9
+ while (queue.length) {
10
+ const f = queue.shift();
11
+ const id = f.id();
12
+ if (seen[id]) continue;
13
+ seen[id] = true;
14
+ let parent = null;
15
+ try { const c = f.container(); const cid = c.id(); if (cid && cid !== acc.id) parent = cid; } catch (e) {}
16
+ try { for (const sub of f.folders()) queue.push(sub); } catch (e) {}
17
+ const ns = f.notes;
18
+ const ids = ns.id(), names = ns.name(), created = ns.creationDate(), modified = ns.modificationDate();
19
+ let locked = [];
20
+ try { locked = ns.passwordProtected(); } catch (e) {}
21
+ acc.folders.push({ id: id, name: f.name(), parent: parent, notes: ids.map((nid, i) => ({ id: nid, name: names[i], created: iso(created[i]), modified: iso(modified[i]), locked: !!locked[i] })) });
22
+ }
23
+ out.accounts.push(acc);
24
+ }
25
+ return JSON.stringify(out);
26
+ }`,body:`function run(argv) {
27
+ const Notes = Application('Notes');
28
+ const iso = (d) => { try { return d ? d.toISOString() : ''; } catch (e) { return ''; } };
29
+ const n = Notes.notes.byId(String(argv[0] || ''));
30
+ if (n.passwordProtected()) return JSON.stringify({ locked: true });
31
+ return JSON.stringify({ html: n.body(), title: n.name(), created: iso(n.creationDate()), modified: iso(n.modificationDate()) });
32
+ }`}),m=Object.freeze(Object.keys(u)),p=new Set(["recently deleted","zuletzt gelöscht","suppressions récentes","eliminados recientemente","eliminati di recente","recentemente apagadas","onlangs verwijderd","最近删除","最近削除した項目"]);function g(s){const i=String(s||"");return/-1743|not authori[sz]ed/i.test(i)?"ChatPanel is not allowed to read Notes yet. Open System Settings › Privacy & Security › Automation and allow Notes, then import again.":/-600|isn.t running/i.test(i)?"Notes could not be opened on this Mac.":i.trim().replace(/^.*?execution error:\s*/i,"").slice(0,300)||"Notes did not answer."}function S({run:s}){if(typeof s!="function")throw new Error("appleNotesSource needs run(op, arg)");const i=t=>typeof t=="string"?JSON.parse(t):t;let a=null;const c={app:"apple-notes",locked:0,async children(t){if(!a){a=i(await s("list")),c.locked=0;for(const e of a?.accounts||[]){e.folders=(e.folders||[]).filter(r=>!p.has(String(r.name||"").trim().toLowerCase()));for(const r of e.folders)c.locked+=(r.notes||[]).filter(o=>o.locked).length}}const n=a?.accounts||[];if(!t)return{containers:n.map(e=>({id:`acct:${e.id}`,kind:"acct",name:String(e.name||"Notes"),raw:e.id})),pages:[]};const l=new Set(n.flatMap(e=>(e.folders||[]).map(r=>r.id)));if(t.kind==="acct")return{containers:(n.find(o=>o.id===t.raw)?.folders||[]).filter(o=>!o.parent||!l.has(o.parent)).map(o=>({id:`f:${o.id}`,kind:"f",name:String(o.name||""),raw:o.id})),pages:[]};const d=n.flatMap(e=>e.folders||[]),f=d.find(e=>e.id===t.raw);return{containers:d.filter(e=>e.parent===t.raw).map(e=>({id:`f:${e.id}`,kind:"f",name:String(e.name||""),raw:e.id})),pages:(f?.notes||[]).filter(e=>!e.locked).map(e=>({id:String(e.id),title:String(e.name||""),createdAt:e.created||"",updatedAt:e.modified||""}))}},async page(t){const n=i(await s("body",t.id));if(n?.locked)throw new Error("this note is locked");return{html:String(n?.html||""),title:n?.title,createdAt:n?.created||t.createdAt,updatedAt:n?.modified||t.updatedAt}}};return c}export{m as APPLE_NOTES_OPS,u as APPLE_NOTES_SCRIPTS,S as appleNotesSource,g as appleScriptError};
package/backup-records.js CHANGED
@@ -1 +1 @@
1
- import{normalizeStoredRecord as g}from"./library.js";import{briefToText as b}from"./knowledge.js";const l=["id","title","tags","createdAt","updatedAt"];function p(d,a=l){const o={};for(const[n,s]of Object.entries(d||{}))a.includes(n)||(o[n]=s);return o}function A(d,a){const o={...d};for(const[n,s]of Object.entries(a))n in o||(o[n]=s);return o}function k(d,{now:a=0,origin:o="extension"}={}){const n=[],s=[],r=t=>{try{n.push(g(t,{now:a}))}catch(e){s.push({id:t?.id||"(no id)",reason:e.message})}};for(const t of d?.conversations||[])t?.id&&r({id:`chat:${t.id}`,title:t.title||"",tags:t.tags,createdAt:t.createdAt,updatedAt:t.updatedAt||t.createdAt,body:A(p(t),{messages:[]}),meta:{origin:o}});for(const t of d?.meetings||[]){const e=t?.record||t;if(!e?.id)continue;const i=t?.record?t:null;r({id:`meeting:${e.id}`,title:e.title||"",tags:e.tags,createdAt:e.startedAt||e.date,updatedAt:e.endedAt||e.startedAt||e.date,body:{...A(p(e,["id","title","tags"]),{segments:[]}),notes:typeof i?.notes=="string"?i.notes:"",topics:i?.topics??e.topics??null,...i?.meta!==void 0?{wrapperMeta:i.meta}:{}},meta:{origin:o,readOnly:!0}})}for(const t of d?.notes||[])t?.id&&r({id:`note:${t.id}`,title:t.title||"",tags:t.tags,createdAt:t.createdAt,updatedAt:t.updatedAt,body:{markdown:typeof t.body=="string"?t.body:"",...p(t,[...l,"body"])},meta:{origin:o}});for(const t of d?.briefs?.briefs||[])!t?.id||!t?.subject?.name||r({id:`brief:${t.id}`,title:t.subject.name,createdAt:t.createdAt||t.updatedAt,updatedAt:t.updatedAt,body:{text:b(t),brief:t},meta:{origin:o,readOnly:!0}});return n.skipped=s,n}function x(d,{now:a=0,exportedBy:o="chatpanel"}={}){const n=[],s=[],r=[];for(const t of d||[]){if(!t||t.deletedAt)continue;const e=String(t.id).split(":").slice(1).join(":"),i=t.body&&typeof t.body=="object"?t.body:{};if(t.kind==="chat")n.push({...i,id:e,title:t.title,tags:t.tags,createdAt:t.createdAt,updatedAt:t.updatedAt});else if(t.kind==="meeting"){const{notes:c,topics:u,wrapperMeta:f,...m}=i;s.push({record:{...m,id:e,title:t.title,tags:t.tags},notes:typeof c=="string"?c:"",topics:u??null,...f!==void 0?{meta:f}:{}})}else if(t.kind==="note"){const{markdown:c,...u}=i;r.push({...u,id:e,title:t.title,tags:t.tags,createdAt:t.createdAt,updatedAt:t.updatedAt,body:typeof c=="string"?c:""})}}return{type:"chatpanel-backup",version:8,exportedAt:a,exportedBy:o,count:n.length,conversations:n,meetingsCount:s.length,meetings:s,notesCount:r.length,notes:r}}export{x as backupFromRecords,k as recordsFromBackup};
1
+ import{normalizeStoredRecord as b}from"./library.js";import{briefToText as y}from"./knowledge.js";const A=["id","title","tags","createdAt","updatedAt"];function f(n,a=A){const o={};for(const[d,s]of Object.entries(n||{}))a.includes(d)||(o[d]=s);return o}function m(n,a){const o={...n};for(const[d,s]of Object.entries(a))d in o||(o[d]=s);return o}function x(n,{now:a=0,origin:o="extension"}={}){const d=[],s=[],i=t=>{try{d.push(b(t,{now:a}))}catch(e){s.push({id:t?.id||"(no id)",reason:e.message})}};for(const t of n?.conversations||[])t?.id&&i({id:`chat:${t.id}`,title:t.title||"",tags:t.tags,createdAt:t.createdAt,updatedAt:t.updatedAt||t.createdAt,body:m(f(t),{messages:[]}),meta:{origin:o}});for(const t of n?.meetings||[]){const e=t?.record||t;if(!e?.id)continue;const r=t?.record?t:null;i({id:`meeting:${e.id}`,title:e.title||"",tags:e.tags,createdAt:e.startedAt||e.date,updatedAt:e.endedAt||e.startedAt||e.date,body:{...m(f(e,["id","title","tags"]),{segments:[]}),notes:typeof r?.notes=="string"?r.notes:"",topics:r?.topics??e.topics??null,...r?.meta!==void 0?{wrapperMeta:r.meta}:{}},meta:{origin:o,readOnly:!0}})}for(const t of n?.notes||[])t?.id&&i({id:`note:${t.id}`,title:t.title||"",tags:t.tags,createdAt:t.createdAt,updatedAt:t.updatedAt,body:{markdown:typeof t.body=="string"?t.body:"",...f(t,[...A,"body"])},meta:{origin:o}});for(const t of n?.folders||[])String(t?.id||"").startsWith("folder:")&&i({...t,meta:{...t.meta||{},origin:o}});for(const t of n?.briefs?.briefs||[])!t?.id||!t?.subject?.name||i({id:`brief:${t.id}`,title:t.subject.name,createdAt:t.createdAt||t.updatedAt,updatedAt:t.updatedAt,body:{text:y(t),brief:t},meta:{origin:o,readOnly:!0}});return d.skipped=s,d}function j(n,{now:a=0,exportedBy:o="chatpanel"}={}){const d=[],s=[],i=[],t=[];for(const e of n||[]){if(!e||e.deletedAt)continue;const r=String(e.id).split(":").slice(1).join(":"),p=e.body&&typeof e.body=="object"?e.body:{};if(e.kind==="chat")d.push({...p,id:r,title:e.title,tags:e.tags,createdAt:e.createdAt,updatedAt:e.updatedAt});else if(e.kind==="meeting"){const{notes:c,topics:u,wrapperMeta:l,...g}=p;s.push({record:{...g,id:r,title:e.title,tags:e.tags},notes:typeof c=="string"?c:"",topics:u??null,...l!==void 0?{meta:l}:{}})}else if(e.kind==="folder"){const{origin:c,...u}=e.meta||{};t.push({id:e.id,kind:"folder",title:e.title,tags:[],createdAt:e.createdAt,updatedAt:e.updatedAt,deletedAt:0,body:p,meta:u})}else if(e.kind==="note"){const{markdown:c,...u}=p;i.push({...u,id:r,title:e.title,tags:e.tags,createdAt:e.createdAt,updatedAt:e.updatedAt,body:typeof c=="string"?c:""})}}return{type:"chatpanel-backup",version:8,exportedAt:a,exportedBy:o,count:d.length,conversations:d,meetingsCount:s.length,meetings:s,notesCount:i.length,notes:i,folders:t}}export{j as backupFromRecords,x as recordsFromBackup};
@@ -1 +1 @@
1
- function a(){return[{id:"mcp_ms_graph",name:"Microsoft 365 (Graph)",enabled:!1,transport:"stdio",command:"uvx",args:["--from","git+https://github.com/chatpanel/ms-graph-mcp@7437d1a","ms-graph-mcp"],env:{GRAPH_MCP_TOOLSETS:"core,notes",GRAPH_MCP_TENANT_ID:"consumers",GRAPH_MCP_FORCE_DEVICE_CODE:"true",GRAPH_MCP_CACHE_DIR:"~/.cache/ms-graph-mcp",GRAPH_MCP_SCOPES:"User.Read,Notes.Read,Files.Read.All,Mail.Read,Calendars.Read"},setup:{needs:["GRAPH_MCP_CLIENT_ID"],why:"Microsoft requires every client to be a registered application.",url:"https://github.com/chatpanel/ms-graph-mcp#set-up-the-entra-app"}}]}function t(e){return a().some(r=>r.id===e)}export{a as defaultMcpServers,t as isDefaultMcpServer};
1
+ const c="git+https://github.com/chatpanel/ms-graph-mcp",p="83c4f51",i=["","7437d1a"],u=Object.freeze({GRAPH_MCP_TOOLSETS:"core,notes",GRAPH_MCP_TENANT_ID:"consumers",GRAPH_MCP_FORCE_DEVICE_CODE:"true",GRAPH_MCP_CACHE_DIR:"~/.cache/ms-graph-mcp",GRAPH_MCP_SCOPES:"User.Read,Mail.Read,Calendars.Read,Files.Read.All,Notes.Read"});function _(){return["--from",`${c}@${p}`,"ms-graph-mcp"]}const m=/^git\+https:\/\/github\.com\/chatpanel\/ms-graph-mcp(?:\.git)?(?:@([0-9a-f]{6,40}))?$/i;function h(t){if(!Array.isArray(t))return{servers:t,changed:0};let r=0;const n=e=>{const a=m.exec(String(e));return!a||!i.includes((a[1]||"").toLowerCase())?e:(r++,`${c}@${p}`)},o=t.map(e=>{if(!e||e.command!=="uvx"||e.args==null)return e;const a=r,s=Array.isArray(e.args)?e.args.map(n):String(e.args).split(/(\s+)/).map(n).join("");return r===a?e:{...e,args:s}});return r?{servers:o,changed:r}:{servers:t,changed:0}}function g(){return[{id:"mcp_ms_graph",name:"Microsoft 365 (Graph)",enabled:!1,transport:"stdio",command:"uvx",args:_(),env:{...u},setup:{needs:["GRAPH_MCP_CLIENT_ID"],why:"Microsoft requires every client to be a registered application.",url:"https://github.com/chatpanel/ms-graph-mcp#set-up-the-entra-app"}}]}function P(t){return g().some(r=>r.id===t)}export{u as MS_GRAPH_MCP_ENV,c as MS_GRAPH_MCP_FORK,p as MS_GRAPH_MCP_PIN,g as defaultMcpServers,P as isDefaultMcpServer,_ as msGraphMcpArgs,h as upgradeShippedMcpPins};
package/feature-map.js CHANGED
@@ -1 +1 @@
1
- const s=["chat","privacy","notes","knowledge","meetings","voice","automation","sync","runtime","browser"],t=[{id:"chat.streaming-turn",surface:"chat",title:"Streaming turns",what:"A turn streams into the thread through its tool rounds, with a stop.",shared:["turn-loop.js","tool-round.js"]},{id:"chat.toolset",surface:"chat",title:"Per-turn toolset",what:"The tools a turn may call, chosen per target and policy.",shared:["toolset.js","tool-dispatch.js"]},{id:"chat.slash-skills",surface:"chat",title:"Skills as /commands",what:"The user’s skills and the packages the bridge found, offered as slash commands in every composer.",shared:["slash-commands.js","skill-vars.js"]},{id:"chat.slash-builtins",surface:"chat",title:"Built-in /commands",what:"/search and /history as commands, not tools the model may or may not call.",shared:["slash-commands.js"]},{id:"chat.bug-report",surface:"chat",title:"Report a problem",what:"/bug and About → Report a problem: a prefilled GitHub issue with whitelisted, scrubbed diagnostics, checked against existing issues first.",shared:["bug-report.js"]},{id:"chat.suggestions",surface:"chat",title:"Empty-chat suggestions",what:"Prompt suggestions on an empty thread, from the page or the recent history.",shared:[]},{id:"chat.attachments",surface:"chat",title:"Attachments",what:"Text, PDF and by-reference files attached to a turn.",shared:["context-attachments.js","attached-paths.js","pdf-layout.js"]},{id:"chat.html-artifacts",surface:"chat",title:"HTML artifacts",what:"An HTML reply rendered in a sandbox, never in the panel.",shared:[]},{id:"chat.diagram-artifacts",surface:"chat",title:"Diagram artifacts",what:"A mermaid block becomes a Diagram | Code card with zoom and copy.",shared:[]},{id:"chat.model-routing",surface:"chat",title:"Auto model routing",what:"An Auto target picks a candidate per message and fails over on error.",shared:["model-candidates.js","route-strategies.js","route-decider.js","failover.js"]},{id:"chat.history-rag",surface:"chat",title:"History in the turn",what:"Past chats, notes and meetings retrieved into a turn automatically, not only on request.",shared:["sources-retrieval.js","text-search.js"]},{id:"chat.history-search-tool",surface:"chat",title:"history_search tool",what:"The model searches the local history and reads one record in full.",shared:["sources.js"]},{id:"chat.sideline",surface:"chat",title:"Sideline",what:"A side conversation beside the thread, on the same context.",shared:["sideline.js"]},{id:"chat.fast-path",surface:"chat",title:"Fast path",what:"A turn answered without the model when a local answer exists.",shared:["fast-path.js"]},{id:"chat.capability-tools",surface:"chat",title:"decide / rerank tools",what:"The model hands a judgement or an ordering to a small local model mid-turn.",shared:["capability-tools.js","capability-providers.js"]},{id:"chat.presence",surface:"chat",title:"Situational presence",what:"What the client knows about the moment (time, place, page) stated to the model as facts.",shared:["presence.js"]},{id:"chat.usage",surface:"chat",title:"Usage meter",what:"Tokens and cost per turn and per day.",shared:["usage.js","usage-pricing.js"]},{id:"chat.web-search",surface:"chat",title:"Web search",what:"Web search as a tool, client-side or through the gateway.",shared:["web-search.js","web-search-tool.js"]},{id:"chat.weather",surface:"chat",title:"Weather",what:"Weather as a tool.",shared:["weather.js","weather-tool.js"]},{id:"chat.event-log",surface:"chat",title:"Event log",what:"What happened in a turn, in order, with where the time went.",shared:["event.js","trajectory.js"]},{id:"chat.teams",surface:"chat",title:"Agent teams",what:"Several agents on one task with a board, a plan and a trail.",shared:["team.js","team-run.js"]},{id:"chat.mcp",surface:"chat",title:"MCP servers",what:"MCP servers as tools.",shared:["mcp-client.js","mcp-manager.js"]},{id:"chat.mcp-oauth",surface:"chat",title:"MCP sign-in",what:"Signing in to an MCP server that asks for OAuth.",shared:["mcp-oauth.js","mcp-signin.js"]},{id:"chat.omni-search",surface:"chat",title:"Omni search",what:"One palette searching notes, chats and meetings at once.",shared:["omni.js"]},{id:"chat.date-filter",surface:"chat",title:"Calendar filter",what:"A calendar on every list and search of chats, notes and meetings: pick a day or a span, or type date:2026-09-30, and only what was made or changed then is listed.",shared:["date-filter.js"]},{id:"chat.memory",surface:"chat",title:"Memory",what:"Facts remembered across conversations, and the tool that writes them.",shared:["memory.js","memory-tool.js"]},{id:"chat.tool-result-shield",surface:"chat",title:"Tool-result shield",what:"A tool result is redacted before the model sees it.",shared:["tool-result.js"]},{id:"chat.read-aloud",surface:"chat",title:"Read aloud",what:"A reply spoken as it streams.",shared:["speak-stream.js"]},{id:"chat.structured-output",surface:"chat",title:"Typed answers",what:"A model call that expects a shape goes through one schema.",shared:["structured.js"]},{id:"chat.media-transcript",surface:"chat",title:"Video transcripts",what:"“Summarise this video” from a caption track.",shared:["media-transcript.js"]},{id:"privacy.redaction",surface:"privacy",title:"On-device redaction",what:"PII redacted before a cloud model and restored on the way back.",shared:["redaction-tokens.js","redaction-dictionary.js"]},{id:"privacy.redaction-preview",surface:"privacy",title:"Show what the model sees",what:"The redacted text, by type, before it leaves.",shared:[]},{id:"privacy.access-log",surface:"privacy",title:"Access log",what:"What left this device, on the record.",shared:["observability.js"]},{id:"privacy.vault",surface:"privacy",title:"Vault",what:"Records kept encrypted at rest.",shared:["vault.js"]},{id:"privacy.encrypted-backup",surface:"privacy",title:"Encrypted backup",what:"A backup sealed with the user’s key.",shared:["backup-envelope.js"]},{id:"notes.editor",surface:"notes",title:"Live-preview editor",what:"The note editor with regions, follow-tail and rich paste.",shared:[]},{id:"notes.images",surface:"notes",title:"Images in a note",what:"A picture pasted or dropped into a note, stored beside it and placed by reference.",shared:["note-images.js"]},{id:"notes.cowriter",surface:"notes",title:"Co-writer",what:"A writer swarm working the note, routed per section.",shared:["cowriter.js","cowriter-router.js"]},{id:"notes.fact-check",surface:"notes",title:"Fact check",what:"Claims in a note checked against sources.",shared:["cowriter-factcheck.js"]},{id:"notes.research",surface:"notes",title:"Note research",what:"Research gathered for a note from the web and the history.",shared:["note-research.js"]},{id:"notes.graph",surface:"notes",title:"Note graph",what:"Links and mentions between notes as a graph.",shared:["note-graph.js"]},{id:"notes.tags",surface:"notes",title:"Tags",what:"Tags on notes, with tag queries in search.",shared:["tags.js"]},{id:"knowledge.briefs",surface:"knowledge",title:"Briefs",what:"Briefs read with first-class citations.",shared:["knowledge.js"]},{id:"knowledge.brief-curation",surface:"knowledge",title:"Brief curation",what:"Briefs derived from the sources — the curator.",shared:["knowledge-derive.js","synthesis.js"]},{id:"knowledge.topics",surface:"knowledge",title:"Topics",what:"Topics extracted from chats, notes and meetings, and the index they build.",shared:[]},{id:"knowledge.corpus",surface:"knowledge",title:"Corpus overview",what:"What the local corpus holds, by kind and by time.",shared:[]},{id:"meetings.live-transcript",surface:"meetings",title:"Live transcript",what:"A meeting transcribed as it happens, kept as a record.",shared:["meeting-shape.js","meeting-text.js"]},{id:"meetings.charts",surface:"meetings",title:"Meeting charts",what:"Who spoke, how much, when.",shared:[]},{id:"meetings.insights",surface:"meetings",title:"Meeting insights",what:"Decisions, actions and the moments that need you, from the transcript.",shared:["meeting-insights.js","meeting-analyzers.js"]},{id:"meetings.monitors",surface:"meetings",title:"Monitors",what:"A profile watching meetings for what matters to it.",shared:["monitor-profile.js"]},{id:"meetings.transcript-import",surface:"meetings",title:"Transcript import",what:"A transcript pasted from Zoom, Teams or Meet becomes a meeting record.",shared:[]},{id:"meetings.speaker-names",surface:"meetings",title:"Speaker names",what:"Who “Speaker 1” is: named in the transcript or by typing “Speaker 1 is Sarah” in the chat, applied on every read and to every later line.",shared:["meeting-speakers.js","meeting-speakers-typed.js"]},{id:"meetings.voice-commands",surface:"meetings",title:"Spoken commands",what:"Commands spoken during a meeting, matched from the transcript.",shared:["voice-intents.js"]},{id:"meetings.audio-scribe",surface:"meetings",title:"Audio scribe",what:"A meeting with no captions, a desktop app, a playing video or a conversation in the room, transcribed locally from what is playing and the microphone as separate channels — a mic held by one person is You, everything else is diarized.",shared:["voice-channels.js","voice-scribe.js","speaker-cluster.js"]},{id:"voice.dictation",surface:"voice",title:"Dictation",what:"Speak into any composer.",shared:["voice-vad.js"]},{id:"voice.mode",surface:"voice",title:"Voice mode",what:"A spoken conversation with barge-in.",shared:["voice-loop.js"]},{id:"voice.tts",surface:"voice",title:"Speech",what:"Text to speech with the chosen voice, including the user’s own.",shared:["voice-speaker.js","voice-models.js"]},{id:"automation.jobs",surface:"automation",title:"Jobs",what:"Scheduled and triggered work that runs without a turn.",shared:["job.js","schedule.js"]},{id:"automation.text-triggers",surface:"automation",title:"Text triggers",what:"A phrase arriving anywhere, matched against the user’s jobs.",shared:[]},{id:"automation.alert-sound",surface:"automation",title:"Timer sound",what:"A timer that goes off makes a sound, not only a notification.",shared:[]},{id:"automation.widgets",surface:"automation",title:"Widgets",what:"Small HTML plugins the user or an agent wrote, hosted in a frame.",shared:["widget.js"]},{id:"automation.projects",surface:"automation",title:"Projects",what:"A folder an agent works in, with its runs.",shared:["project.js","project-run.js"]},{id:"automation.skills",surface:"automation",title:"Skills",what:"Skills written by the user or found on the machine.",shared:["skill-manifest.js","skill-runtime.js","skill-sources.js"]},{id:"automation.recipes",surface:"automation",title:"Recipes",what:"Saved multi-step prompts.",shared:["recipe.js"]},{id:"automation.channels",surface:"automation",title:"Channels",what:"Telegram and WhatsApp surfaces to the agents.",shared:[]},{id:"automation.channel-pairing-qr",surface:"automation",title:"Pairing QR",what:"The channel pairing link as a QR code, read from another device.",shared:[]},{id:"sync.auto-backup",surface:"sync",title:"Auto backup",what:"A backup written on a schedule.",shared:["backup-records.js"]},{id:"sync.warm",surface:"sync",title:"Warm sync",what:"Records pulled from and pushed to the gateway.",shared:["sync-plan.js"]},{id:"sync.prefs",surface:"sync",title:"Settings travel",what:"Every setting shared between the clients, live.",shared:["client-prefs.js"]},{id:"sync.link",surface:"sync",title:"Link your phone",what:"A phone paired by QR reaches this computer’s models, agents and knowledge through the end-to-end encrypted relay.",shared:["link-connect.js","link-protocol.js","link-noise.js","qr.js"]},{id:"sync.drive",surface:"sync",title:"Google Drive backup",what:"Backups to and from the user’s Drive.",shared:["drive-backup.js"]},{id:"runtime.model-place",surface:"runtime",title:"One model place",what:"Every model of every type — chat, vision, embeddings, speech, entity recognition, decisions, ranking — added by type and runtime, listed in one place with where it runs and which jobs may use it.",shared:["model-roles.js","capability-uses.js","model-entries.js"]},{id:"runtime.model-fusion",surface:"runtime",title:"Model fusion",what:"Several models as one — a union for recall (the entity detector with companions), a draft + target for speed (a server drafting with a small model or the model’s MTP head), a fallback for reliability (the next member answers when one is down) — shown with their members in the model place.",shared:["model-fusion.js"]},{id:"runtime.license",surface:"runtime",title:"Licence",what:"Pro and Team verified offline against the signed token.",shared:["entitlement.js"]},{id:"runtime.free-caps",surface:"runtime",title:"Free caps",what:"The Free limits on the workspace surfaces, asked the same way everywhere.",shared:["entitlement.js"]},{id:"runtime.managed",surface:"runtime",title:"Managed mode",what:"The organisation’s configuration, pushed by IT.",shared:[]},{id:"runtime.updates",surface:"runtime",title:"Updates",what:"The client, the gateway and the bridge know when a newer version exists.",shared:[]},{id:"runtime.bridge-health",surface:"runtime",title:"Runtime health",what:"The bridge and the gateway watched, with what to do when one is down.",shared:[]},{id:"runtime.local-pairing",surface:"runtime",title:"Local pairing",what:"This client paired with the local servers by token or pin.",shared:[]},{id:"runtime.model-roles",surface:"runtime",title:"What runs where",what:"Every model in use by job, where it runs, a jump to swap it.",shared:["model-roles.js"]},{id:"browser.page-actions",surface:"browser",title:"Page actions",what:"The agent acts on the open page.",shared:[]},{id:"browser.page-tools",surface:"browser",title:"Page tools",what:"The open page read, matched and calibrated as a tool.",shared:[]},{id:"browser.canvas",surface:"browser",title:"Canvas adapters",what:"Web apps (docs, sheets, whiteboards) driven through their canvas.",shared:[]},{id:"browser.in-browser-model",surface:"browser",title:"In-browser model",what:"A model run in the browser on WebGPU.",shared:[]},{id:"browser.floating-launcher",surface:"browser",title:"Floating launcher",what:"The button on web pages that opens the panel.",shared:[]}];function r(e){return e?t.filter(a=>a.surface===e):t.slice()}function i(){return t.map(e=>e.id)}export{t as FEATURES,s as SURFACES,i as featureIds,r as listFeatures};
1
+ const s=["chat","privacy","notes","knowledge","meetings","voice","automation","sync","runtime","browser"],t=[{id:"chat.streaming-turn",surface:"chat",title:"Streaming turns",what:"A turn streams into the thread through its tool rounds, with a stop.",shared:["turn-loop.js","tool-round.js"]},{id:"chat.toolset",surface:"chat",title:"Per-turn toolset",what:"The tools a turn may call, chosen per target and policy.",shared:["toolset.js","tool-dispatch.js"]},{id:"chat.slash-skills",surface:"chat",title:"Skills as /commands",what:"The user’s skills and the packages the bridge found, offered as slash commands in every composer.",shared:["slash-commands.js","skill-vars.js"]},{id:"chat.slash-builtins",surface:"chat",title:"Built-in /commands",what:"/search and /history as commands, not tools the model may or may not call.",shared:["slash-commands.js"]},{id:"chat.bug-report",surface:"chat",title:"Report a problem",what:"/bug and About → Report a problem: a prefilled GitHub issue with whitelisted, scrubbed diagnostics, checked against existing issues first.",shared:["bug-report.js"]},{id:"chat.suggestions",surface:"chat",title:"Empty-chat suggestions",what:"Prompt suggestions on an empty thread, from the page or the recent history.",shared:[]},{id:"chat.attachments",surface:"chat",title:"Attachments",what:"Text, PDF and by-reference files attached to a turn.",shared:["context-attachments.js","attached-paths.js","pdf-layout.js"]},{id:"chat.html-artifacts",surface:"chat",title:"HTML artifacts",what:"An HTML reply rendered in a sandbox, never in the panel.",shared:[]},{id:"chat.diagram-artifacts",surface:"chat",title:"Diagram artifacts",what:"A mermaid block becomes a Diagram | Code card with zoom and copy.",shared:[]},{id:"chat.model-routing",surface:"chat",title:"Auto model routing",what:"An Auto target picks a candidate per message and fails over on error.",shared:["model-candidates.js","route-strategies.js","route-decider.js","failover.js"]},{id:"chat.history-rag",surface:"chat",title:"History in the turn",what:"Past chats, notes and meetings retrieved into a turn automatically, not only on request.",shared:["sources-retrieval.js","text-search.js"]},{id:"chat.history-search-tool",surface:"chat",title:"history_search tool",what:"The model searches the local history and reads one record in full.",shared:["sources.js"]},{id:"chat.sideline",surface:"chat",title:"Sideline",what:"A side conversation beside the thread, on the same context.",shared:["sideline.js"]},{id:"chat.fast-path",surface:"chat",title:"Fast path",what:"A turn answered without the model when a local answer exists.",shared:["fast-path.js"]},{id:"chat.capability-tools",surface:"chat",title:"decide / rerank tools",what:"The model hands a judgement or an ordering to a small local model mid-turn.",shared:["capability-tools.js","capability-providers.js"]},{id:"chat.presence",surface:"chat",title:"Situational presence",what:"What the client knows about the moment (time, place, page) stated to the model as facts.",shared:["presence.js"]},{id:"chat.usage",surface:"chat",title:"Usage meter",what:"Tokens and cost per turn and per day.",shared:["usage.js","usage-pricing.js"]},{id:"chat.web-search",surface:"chat",title:"Web search",what:"Web search as a tool, client-side or through the gateway.",shared:["web-search.js","web-search-tool.js"]},{id:"chat.weather",surface:"chat",title:"Weather",what:"Weather as a tool.",shared:["weather.js","weather-tool.js"]},{id:"chat.event-log",surface:"chat",title:"Event log",what:"What happened in a turn, in order, with where the time went.",shared:["event.js","trajectory.js"]},{id:"chat.teams",surface:"chat",title:"Agent teams",what:"Several agents on one task with a board, a plan and a trail.",shared:["team.js","team-run.js"]},{id:"chat.mcp",surface:"chat",title:"MCP servers",what:"MCP servers as tools.",shared:["mcp-client.js","mcp-manager.js"]},{id:"chat.mcp-oauth",surface:"chat",title:"MCP sign-in",what:"Signing in to an MCP server that asks for OAuth.",shared:["mcp-oauth.js","mcp-signin.js"]},{id:"chat.omni-search",surface:"chat",title:"Omni search",what:"One palette searching notes, chats and meetings at once.",shared:["omni.js"]},{id:"chat.date-filter",surface:"chat",title:"Calendar filter",what:"A calendar on every list and search of chats, notes and meetings: pick a day or a span, or type date:2026-09-30, and only what was made or changed then is listed.",shared:["date-filter.js"]},{id:"chat.memory",surface:"chat",title:"Memory",what:"Facts remembered across conversations, and the tool that writes them.",shared:["memory.js","memory-tool.js"]},{id:"chat.tool-result-shield",surface:"chat",title:"Tool-result shield",what:"A tool result is redacted before the model sees it.",shared:["tool-result.js"]},{id:"chat.read-aloud",surface:"chat",title:"Read aloud",what:"A reply spoken as it streams.",shared:["speak-stream.js"]},{id:"chat.structured-output",surface:"chat",title:"Typed answers",what:"A model call that expects a shape goes through one schema.",shared:["structured.js"]},{id:"chat.media-transcript",surface:"chat",title:"Video transcripts",what:"“Summarise this video” from a caption track.",shared:["media-transcript.js"]},{id:"privacy.redaction",surface:"privacy",title:"On-device redaction",what:"PII redacted before a cloud model and restored on the way back.",shared:["redaction-tokens.js","redaction-dictionary.js"]},{id:"privacy.redaction-preview",surface:"privacy",title:"Show what the model sees",what:"The redacted text, by type, before it leaves.",shared:[]},{id:"privacy.access-log",surface:"privacy",title:"Access log",what:"What left this device, on the record.",shared:["observability.js"]},{id:"privacy.vault",surface:"privacy",title:"Vault",what:"Records kept encrypted at rest.",shared:["vault.js"]},{id:"privacy.encrypted-backup",surface:"privacy",title:"Encrypted backup",what:"A backup sealed with the user’s key.",shared:["backup-envelope.js"]},{id:"notes.editor",surface:"notes",title:"Live-preview editor",what:"The note editor with regions, follow-tail and rich paste.",shared:[]},{id:"notes.images",surface:"notes",title:"Images in a note",what:"A picture pasted or dropped into a note, stored beside it and placed by reference.",shared:["note-images.js"]},{id:"notes.cowriter",surface:"notes",title:"Co-writer",what:"A writer swarm working the note, routed per section.",shared:["cowriter.js","cowriter-router.js"]},{id:"notes.fact-check",surface:"notes",title:"Fact check",what:"Claims in a note checked against sources.",shared:["cowriter-factcheck.js"]},{id:"notes.research",surface:"notes",title:"Note research",what:"Research gathered for a note from the web and the history.",shared:["note-research.js"]},{id:"notes.graph",surface:"notes",title:"Note graph",what:"Links and mentions between notes as a graph.",shared:["note-graph.js"]},{id:"notes.tags",surface:"notes",title:"Tags",what:"Tags on notes, with tag queries in search.",shared:["tags.js"]},{id:"notes.folders",surface:"notes",title:"Folders",what:"Notes organised into folders: create, rename, move and delete one without losing a note, synced like the notes.",shared:["folders.js"]},{id:"notes.import",surface:"notes",title:"Import from other apps",what:"OneNote and Apple Notes imported into a folder per app, the source’s own tree inside it; run again, only what changed comes in.",shared:["notes-import.js","html-markdown.js","onenote-source.js","apple-notes-source.js"]},{id:"knowledge.briefs",surface:"knowledge",title:"Briefs",what:"Briefs read with first-class citations.",shared:["knowledge.js"]},{id:"knowledge.brief-curation",surface:"knowledge",title:"Brief curation",what:"Briefs derived from the sources — the curator.",shared:["knowledge-derive.js","synthesis.js"]},{id:"knowledge.topics",surface:"knowledge",title:"Topics",what:"Topics extracted from chats, notes and meetings, and the index they build.",shared:[]},{id:"knowledge.corpus",surface:"knowledge",title:"Corpus overview",what:"What the local corpus holds, by kind and by time.",shared:[]},{id:"meetings.live-transcript",surface:"meetings",title:"Live transcript",what:"A meeting transcribed as it happens, kept as a record.",shared:["meeting-shape.js","meeting-text.js"]},{id:"meetings.charts",surface:"meetings",title:"Meeting charts",what:"Who spoke, how much, when.",shared:[]},{id:"meetings.insights",surface:"meetings",title:"Meeting insights",what:"Decisions, actions and the moments that need you, from the transcript.",shared:["meeting-insights.js","meeting-analyzers.js"]},{id:"meetings.monitors",surface:"meetings",title:"Monitors",what:"A profile watching meetings for what matters to it.",shared:["monitor-profile.js"]},{id:"meetings.transcript-import",surface:"meetings",title:"Transcript import",what:"A transcript pasted from Zoom, Teams or Meet becomes a meeting record.",shared:[]},{id:"meetings.speaker-names",surface:"meetings",title:"Speaker names",what:"Who “Speaker 1” is: named in the transcript or by typing “Speaker 1 is Sarah” in the chat, applied on every read and to every later line.",shared:["meeting-speakers.js","meeting-speakers-typed.js"]},{id:"meetings.voice-commands",surface:"meetings",title:"Spoken commands",what:"Commands spoken during a meeting, matched from the transcript.",shared:["voice-intents.js"]},{id:"meetings.audio-scribe",surface:"meetings",title:"Audio scribe",what:"A meeting with no captions, a desktop app, a playing video or a conversation in the room, transcribed locally from what is playing and the microphone as separate channels — a mic held by one person is You, everything else is diarized.",shared:["voice-channels.js","voice-scribe.js","speaker-cluster.js"]},{id:"voice.dictation",surface:"voice",title:"Dictation",what:"Speak into any composer.",shared:["voice-vad.js"]},{id:"voice.mode",surface:"voice",title:"Voice mode",what:"A spoken conversation with barge-in.",shared:["voice-loop.js"]},{id:"voice.tts",surface:"voice",title:"Speech",what:"Text to speech with the chosen voice, including the user’s own.",shared:["voice-speaker.js","voice-models.js"]},{id:"automation.jobs",surface:"automation",title:"Jobs",what:"Scheduled and triggered work that runs without a turn.",shared:["job.js","schedule.js"]},{id:"automation.text-triggers",surface:"automation",title:"Text triggers",what:"A phrase arriving anywhere, matched against the user’s jobs.",shared:[]},{id:"automation.alert-sound",surface:"automation",title:"Timer sound",what:"A timer that goes off makes a sound, not only a notification.",shared:[]},{id:"automation.widgets",surface:"automation",title:"Widgets",what:"Small HTML plugins the user or an agent wrote, hosted in a frame.",shared:["widget.js"]},{id:"automation.projects",surface:"automation",title:"Projects",what:"A folder an agent works in, with its runs.",shared:["project.js","project-run.js"]},{id:"automation.skills",surface:"automation",title:"Skills",what:"Skills written by the user or found on the machine.",shared:["skill-manifest.js","skill-runtime.js","skill-sources.js"]},{id:"automation.recipes",surface:"automation",title:"Recipes",what:"Saved multi-step prompts.",shared:["recipe.js"]},{id:"automation.channels",surface:"automation",title:"Channels",what:"Telegram and WhatsApp surfaces to the agents.",shared:[]},{id:"automation.channel-pairing-qr",surface:"automation",title:"Pairing QR",what:"The channel pairing link as a QR code, read from another device.",shared:[]},{id:"sync.auto-backup",surface:"sync",title:"Auto backup",what:"A backup written on a schedule.",shared:["backup-records.js"]},{id:"sync.warm",surface:"sync",title:"Warm sync",what:"Records pulled from and pushed to the gateway.",shared:["sync-plan.js"]},{id:"sync.prefs",surface:"sync",title:"Settings travel",what:"Every setting shared between the clients, live.",shared:["client-prefs.js"]},{id:"sync.link",surface:"sync",title:"Link your phone",what:"A phone paired by QR reaches this computer’s models, agents and knowledge through the end-to-end encrypted relay.",shared:["link-connect.js","link-protocol.js","link-noise.js","qr.js"]},{id:"sync.drive",surface:"sync",title:"Google Drive backup",what:"Backups to and from the user’s Drive.",shared:["drive-backup.js"]},{id:"runtime.model-place",surface:"runtime",title:"One model place",what:"Every model of every type — chat, vision, embeddings, speech, entity recognition, decisions, ranking — added by type and runtime, listed in one place with where it runs and which jobs may use it.",shared:["model-roles.js","capability-uses.js","model-entries.js"]},{id:"runtime.model-fusion",surface:"runtime",title:"Model fusion",what:"Several models as one — a union for recall (the entity detector with companions), a draft + target for speed (a server drafting with a small model or the model’s MTP head), a fallback for reliability (the next member answers when one is down) — shown with their members in the model place.",shared:["model-fusion.js"]},{id:"runtime.license",surface:"runtime",title:"Licence",what:"Pro and Team verified offline against the signed token.",shared:["entitlement.js"]},{id:"runtime.free-caps",surface:"runtime",title:"Free caps",what:"The Free limits on the workspace surfaces, asked the same way everywhere.",shared:["entitlement.js"]},{id:"runtime.managed",surface:"runtime",title:"Managed mode",what:"The organisation’s configuration, pushed by IT.",shared:[]},{id:"runtime.updates",surface:"runtime",title:"Updates",what:"The client, the gateway and the bridge know when a newer version exists.",shared:[]},{id:"runtime.bridge-health",surface:"runtime",title:"Runtime health",what:"The bridge and the gateway watched, with what to do when one is down.",shared:[]},{id:"runtime.local-pairing",surface:"runtime",title:"Local pairing",what:"This client paired with the local servers by token or pin.",shared:[]},{id:"runtime.model-roles",surface:"runtime",title:"What runs where",what:"Every model in use by job, where it runs, a jump to swap it.",shared:["model-roles.js"]},{id:"browser.page-actions",surface:"browser",title:"Page actions",what:"The agent acts on the open page.",shared:[]},{id:"browser.page-tools",surface:"browser",title:"Page tools",what:"The open page read, matched and calibrated as a tool.",shared:[]},{id:"browser.canvas",surface:"browser",title:"Canvas adapters",what:"Web apps (docs, sheets, whiteboards) driven through their canvas.",shared:[]},{id:"browser.in-browser-model",surface:"browser",title:"In-browser model",what:"A model run in the browser on WebGPU.",shared:[]},{id:"browser.floating-launcher",surface:"browser",title:"Floating launcher",what:"The button on web pages that opens the panel.",shared:[]}];function r(e){return e?t.filter(a=>a.surface===e):t.slice()}function i(){return t.map(e=>e.id)}export{t as FEATURES,s as SURFACES,i as featureIds,r as listFeatures};
package/folders.js ADDED
@@ -0,0 +1 @@
1
+ import{makeRecordId as x,parseRecordId as y}from"./library.js";const h=120,w=32,u=t=>Number.isFinite(Number(t))?Number(t):0,a=t=>y(t)?.kind==="folder",p=t=>t&&!u(t.deletedAt);function g(t){const e=String(t??"").replace(/[\u0000-\u001f\u007f]+/g," ").replace(/\s+/g," ").trim();return e.length>h?e.slice(0,h).trimEnd():e}function S({name:t,parent:e=null,source:o=null,newId:r,now:n=0}={}){if(typeof r!="function")throw new Error("makeFolder needs newId()");const s=g(t);if(!s)throw new Error("a folder needs a name");if(e!=null&&!a(e))throw new Error(`not a folder id: ${e}`);const i=u(n);return{id:x("folder",r()),kind:"folder",title:s,tags:[],createdAt:i,updatedAt:i,deletedAt:0,body:{parent:e||null,...o?{source:{app:String(o.app),id:String(o.id)}}:{}},meta:{}}}function m(t){const e=new Map;for(const n of t||[])p(n)&&a(n.id)&&e.set(n.id,n);const o=n=>{const s=n?.body?.parent;return s&&s!==n.id&&e.has(s)?s:null},r=new Map;for(const[n,s]of e){const i=new Set([n]);let d=o(s),l=0,c=!0;for(;d;){if(i.has(d)||++l>w){c=!1;break}i.add(d),d=o(e.get(d))}r.set(n,{...s,parent:c?o(s):null})}return r}function F(t,e){const o=t?.body?.folder;return o&&e.has(o)?o:null}function N(t,e=[]){const o=m(t),r=new Map;for(const[d,l]of o)r.set(d,{id:d,name:l.title||"Untitled folder",folder:l,folders:[],notes:[],count:0});const n={folders:[],notes:[]};for(const[d,l]of o)(l.parent?r.get(l.parent).folders:n.folders).push(r.get(d));for(const d of e||[]){if(!p(d))continue;const l=F(d,o);(l?r.get(l).notes:n.notes).push(d)}const s=(d,l)=>d.name.localeCompare(l.name,void 0,{sensitivity:"base",numeric:!0}),i=d=>(d.folders.sort(s),d.count=d.notes.length+d.folders.reduce((l,c)=>l+i(c),0),d.count);n.folders.sort(s);for(const d of n.folders)i(d);return n}function _(t,e){const o=e instanceof Map?e:m(e),r=[];let n=t&&o.get(t);for(;n&&r.length<=w;)r.unshift({id:n.id,name:n.title||"Untitled folder"}),n=n.parent?o.get(n.parent):null;return r}function A(t,e){const o=e instanceof Map?e:m(e),r=new Set;if(!o.has(t))return r;const n=[t];for(;n.length;){const s=n.pop();if(!r.has(s)){r.add(s);for(const[i,d]of o)d.parent===s&&n.push(i)}}return r}function v(t,e,{now:o=0}={}){const r=g(e);if(!r)throw new Error("a folder needs a name");return{...t,title:r,updatedAt:u(o)}}function E(t,e,o,{now:r=0}={}){if(e!=null){if(!a(e))throw new Error(`not a folder id: ${e}`);if(A(t.id,o).has(e))throw new Error("a folder cannot move into itself")}return{...t,body:{...t.body||{},parent:e||null},updatedAt:u(r)}}function k(t,e,{now:o=0}={}){if(e!=null&&!a(e))throw new Error(`not a folder id: ${e}`);const{folder:r,...n}=t.body||{};return{...t,body:e?{...n,folder:e}:n,updatedAt:u(o)}}function I(t,{folders:e,notes:o=[],now:r=0}={}){const n=m(e),s=n.get(t);if(!s)return{folder:null,folders:[],notes:[]};const i=s.parent||null,d=u(r),{parent:l,...c}=s;return{folder:{...c,deletedAt:d,updatedAt:d},folders:[...n.values()].filter(f=>f.parent===t).map(({parent:f,...b})=>E(b,i,e,{now:d})),notes:(o||[]).filter(f=>p(f)&&f.body?.folder===t).map(f=>k(f,i,{now:d}))}}function R(t,e){for(const o of t||[]){const r=o?.body?.source;if(p(o)&&r&&r.app===e.app&&r.id===String(e.id))return o}return null}export{w as MAX_FOLDER_DEPTH,h as MAX_FOLDER_NAME,g as cleanFolderName,I as deleteFolderPlan,R as findSourceFolder,_ as folderPath,A as folderSubtree,N as folderTree,S as makeFolder,E as moveFolder,k as moveNote,F as noteFolder,v as renameFolder,m as repairFolders};
@@ -0,0 +1,24 @@
1
+ const q=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),L=new Set(["script","style","textarea","title","xmp"]),w=new Set(["script","style","head","template","noscript","svg","math","iframe","canvas","button","select","textarea","title","xmp","meta","link","base"]),v=new Set(["address","article","aside","blockquote","body","dd","details","dialog","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","html","li","main","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul","caption"]),A=new Set(["address","article","aside","blockquote","div","dl","fieldset","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","section","table","ul"]),I={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",shy:"",mdash:"—",ndash:"–",hellip:"…",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",laquo:"«",raquo:"»",bull:"•",middot:"·",copy:"©",reg:"®",trade:"™",deg:"°",times:"×",divide:"÷",plusmn:"±",euro:"€",pound:"£",yen:"¥",cent:"¢",sect:"§",para:"¶",larr:"←",rarr:"→",uarr:"↑",darr:"↓",harr:"↔",check:"✓",zwj:"",zwnj:"",lrm:"",rlm:""};function S(i){return String(i??"").replace(/&(#x[0-9a-f]+|#\d+|[a-z][a-z0-9]*);?/gi,(t,e)=>{if(e[0]==="#"){const r=e[1]==="x"||e[1]==="X"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return!Number.isFinite(r)||r<=0||r>1114111||r>=55296&&r<=57343?"":r===160?" ":String.fromCodePoint(r)}const n=I[e.toLowerCase()];return n===void 0?t:n})}function M(i){const t={},e=/([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;let n;for(;n=e.exec(i||"");){const r=n[1].toLowerCase();r in t||(t[r]=S(n[2]??n[3]??n[4]??""))}return t}function O(i){const t={tag:"#root",attrs:{},children:[]},e=[t];let n="";const r=()=>e[e.length-1],s=(l,f)=>{for(let h=e.length-1;h>0;h--){if(e[h].tag===l)return h;if(f&&f.includes(e[h].tag))return-1}return-1},o=l=>{e.length=l},c=(l,f,h)=>{if(A.has(l)){const u=s("p",["td","th","li","blockquote","div"]);u>0&&o(u)}if(l==="li"){const u=s("li",["ul","ol"]);u>0&&o(u)}if(l==="td"||l==="th"){const u=Math.max(s("td",["tr","table"]),s("th",["tr","table"]));u>0&&o(u)}if(l==="tr"){const u=s("tr",["table"]);u>0&&o(u)}if(l==="dt"||l==="dd"){const u=Math.max(s("dt",["dl"]),s("dd",["dl"]));u>0&&o(u)}const b={tag:l,attrs:M(f),children:[]};r().children.push(b),!q.has(l)&&!h&&e.push(b)},$=l=>{const f=s(l);f>0&&o(f)},d=l=>{l&&r().children.push(S(l))},a=String(i??""),m=/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?\]\]>|<![^>]*>|<\?[^>]*>|<\/\s*([a-zA-Z][\w:-]*)[^>]*>|<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;let p=0,g;for(;g=m.exec(a);){if(g.index>p&&d(a.slice(p,g.index)),p=m.lastIndex,g[1]){$(g[1].toLowerCase());continue}if(!g[2])continue;const l=g[2].toLowerCase(),f=g[3]||"";if(L.has(l)){const h=a.toLowerCase().indexOf(`</${l}`,p),b=a.slice(p,h<0?a.length:h);l==="title"&&!n&&(n=S(b).replace(/\s+/g," ").trim());const u=h<0?a.length:a.indexOf(">",h);p=u<0?a.length:u+1,m.lastIndex=p;continue}c(l,f,/\/\s*$/.test(f))}return p<a.length&&d(a.slice(p)),{root:t,title:n}}const j=i=>typeof i=="object"&&v.has(i.tag),z=i=>String(i.attrs?.style||"").toLowerCase().replace(/\s+/g,"");function C(i){const t=String(i||"").trim();return/^(https?:|mailto:)/i.test(t)?t.replace(/[\s()<>]/g,e=>encodeURIComponent(e)):null}function y(i){return typeof i=="string"?i:w.has(i.tag)?"":i.tag==="br"?`
2
+ `:i.children.map(y).join("")}function k(i,t){const e=/^(\s*)([\s\S]*?)(\s*)$/.exec(t);return e[2]?`${e[1]}${i}${e[2]}${i}${e[3]}`:t}function D(i){const t=i.replace(/\n/g," ");if(!t.trim())return t;const e=Math.max(0,...(t.match(/`+/g)||[]).map(s=>s.length)),n="`".repeat(e+1),r=t.startsWith("`")||t.endsWith("`")?" ":"";return`${n}${r}${t}${r}${n}`}function x(i){const t=String(i.attrs?.["data-tag"]||"").toLowerCase();if(/(^|,)to-do:completed(,|$)/.test(t))return"x";if(/(^|,)to-do(,|$)/.test(t))return" ";const e=` ${String(i.attrs?.class||"").toLowerCase()} `;if(/ (checked|done|completed) /.test(e))return"x";if(/ (unchecked|todo|to-do|checklist-item) /.test(e))return" ";const n=r=>{for(const s of r.children||[]){if(typeof s!="object"||s.tag==="ul"||s.tag==="ol")continue;if(s.tag==="input"&&String(s.attrs.type||"").toLowerCase()==="checkbox")return"checked"in s.attrs?"x":" ";const o=n(s);if(o)return o}return null};return n(i)}class E{constructor({image:t}){this.image=t}inline(t,e){if(typeof t=="string")return e.pre?t:t.replace(/\s+/g," ");if(w.has(t.tag))return"";const n=(r=e)=>t.children.map(s=>this.inline(s,r)).join("");switch(t.tag){case"br":return`
3
+ `;case"b":case"strong":return e.bold?n():k("**",n({...e,bold:!0}));case"i":case"em":case"cite":case"var":return e.italic?n():k("*",n({...e,italic:!0}));case"s":case"del":case"strike":return e.strike?n():k("~~",n({...e,strike:!0}));case"code":case"kbd":case"samp":case"tt":return e.pre?y(t):D(y(t));case"a":{const r=n().trim(),s=C(t.attrs.href);return s?r?`[${r.replace(/\n+/g," ")}](${s})`:`<${s}>`:r}case"img":{const r=String(t.attrs.alt||"").replace(/[\s[\]]+/g," ").trim(),s=this.image(String(t.attrs.src||""),{alt:t.attrs.alt||"",type:t.attrs["data-src-type"]||"",attrs:t.attrs});return s?`![${r}](${s})`:""}case"object":{const r=t.attrs["data-attachment"];return r?`*Attachment: ${String(r).replace(/\s+/g," ").trim()}*`:""}case"input":return"";default:{if(j(t))return`
4
+ ${this.blocks(t.children,e).join(`
5
+ `)}
6
+ `;const r=z(t);let s=n({...e,bold:e.bold||/font-weight:(bold|[6-9]00)/.test(r),italic:e.italic||/font-style:italic/.test(r),strike:e.strike||/text-decoration:[^;]*line-through/.test(r)});return!e.strike&&/text-decoration:[^;]*line-through/.test(r)&&(s=k("~~",s)),!e.italic&&/font-style:italic/.test(r)&&(s=k("*",s)),!e.bold&&/font-weight:(bold|[6-9]00)/.test(r)&&(s=k("**",s)),s}}}paragraphs(t){const e=[];let n=[];for(const r of t.split(`
7
+ `)){const s=r.trim();if(s){n.push(s);continue}n.length&&(e.push(n.join(`
8
+ `)),n=[])}return n.length&&e.push(n.join(`
9
+ `)),e}blocks(t,e={}){const n=[];let r="";const s=()=>{r&&n.push(...this.paragraphs(r)),r=""};for(const o of t)if(!(typeof o=="object"&&w.has(o.tag))){if(o.tag==="div"&&!o.children.some(j)&&!x(o)){r+=`${o.children.map(c=>this.inline(c,e)).join("")}
10
+ `;continue}j(o)?(s(),n.push(...this.block(o,e))):r+=this.inline(o,e)}return s(),n}block(t,e){switch(t.tag){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":{const n=t.children.map(r=>this.inline(r,e)).join("").replace(/\s*\n\s*/g," ").trim();return n?[`${"#".repeat(Number(t.tag[1]))} ${n}`]:[]}case"hr":return["---"];case"pre":{const n=y(t).replace(/^\n/,"").replace(/\s+$/,"");if(!n)return[];const r=Math.max(2,...(n.match(/`{3,}/g)||[]).map(o=>o.length)),s="`".repeat(r+1);return[`${s}
11
+ ${n}
12
+ ${s}`]}case"blockquote":{const n=this.blocks(t.children,e).join(`
13
+
14
+ `);return n?[n.split(`
15
+ `).map(r=>r?`> ${r}`:">").join(`
16
+ `)]:[]}case"ul":case"ol":return this.list(t,e);case"table":return this.table(t,e);case"dt":{const n=this.blocks(t.children,e).join(" ");return n?[`**${n}**`]:[]}default:{const n=this.blocks(t.children,e),r=t.tag==="li"?null:x(t);return r&&n.length&&(n[0]=`- [${r}] ${n[0]}`),n}}}list(t,e){const n=t.tag==="ol";let r=Math.max(0,parseInt(t.attrs.start,10)||1);const s=[];for(const c of t.children){if(typeof c=="string"){if(!c.trim())continue;s.length?s[s.length-1].extra.push(c):s.push({node:{tag:"li",attrs:{},children:[c]},extra:[]});continue}c.tag==="li"?s.push({node:c,extra:[]}):c.tag==="ul"||c.tag==="ol"?s.length?s[s.length-1].extra.push(c):s.push({node:{tag:"li",attrs:{},children:[c]},extra:[]}):w.has(c.tag)||(s.length?s[s.length-1].extra.push(c):s.push({node:{tag:"li",attrs:{},children:[c]},extra:[]}))}const o=[];for(const{node:c,extra:$}of s){const d=x(c),a=n?`${r++}. `:"- ",m=this.blocks([...c.children,...$],e),p=d?`[${d}] `:"",g=m.length?m[0]:"";if(!g&&!p&&m.length<=1)continue;const l=" ".repeat(a.length),f=`${p}${g}`.split(`
17
+ `);o.push(`${a}${f[0]}`,...f.slice(1).map(h=>h&&l+h));for(const h of m.slice(1))o.push(...h.split(`
18
+ `).map(b=>b&&l+b))}return o.length?[o.join(`
19
+ `)]:[]}table(t,e){const n=[],r=d=>{for(const a of d.children)typeof a=="object"&&(a.tag==="tr"?n.push(a):(a.tag==="thead"||a.tag==="tbody"||a.tag==="tfoot")&&r(a))};r(t);const s=n.map(d=>d.children.filter(a=>typeof a=="object"&&(a.tag==="td"||a.tag==="th")).map(a=>this.blocks(a.children,e).join(" ").replace(/\s*\n\s*/g," ").replace(/\|/g,"|").trim())),o=Math.max(0,...s.map(d=>d.length));if(!o)return[];const c=s.filter(d=>d.some(Boolean));if(!c.length)return[];if(o===1&&c.length===1)return[c[0][0]];const $=d=>`| ${Array.from({length:o},(a,m)=>d[m]||"").join(" | ")} |`;return[[$(c[0]),`|${" --- |".repeat(o)}`,...c.slice(1).map($)].join(`
20
+ `)]}}function B(i,{image:t=R}={}){const{root:e,title:n}=O(i);return{markdown:new E({image:t}).blocks(e.children).join(`
21
+
22
+ `).replace(/\n{3,}/g,`
23
+
24
+ `).trim(),title:n}}function R(i){return/^https:\/\//i.test(i)?C(i):null}export{S as decodeEntities,B as htmlToMarkdown};