tabglutton-gullet 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/dist/gullet.js +24 -7
  2. package/package.json +1 -1
package/dist/gullet.js CHANGED
@@ -1072,7 +1072,7 @@ async function runDetachedHub(options) {
1072
1072
  }
1073
1073
 
1074
1074
  // src/version.ts
1075
- var GULLET_VERSION = "0.4.0";
1075
+ var GULLET_VERSION = "0.4.1";
1076
1076
 
1077
1077
  // src/backend.ts
1078
1078
  var ELECTION_RETRY_MS = 400;
@@ -1763,7 +1763,7 @@ async function dispatch(handle, line, send) {
1763
1763
 
1764
1764
  // src/clip-verify.ts
1765
1765
  import { readdir, readFile, stat } from "fs/promises";
1766
- import { basename, dirname as dirname3, join as join3 } from "path";
1766
+ import { basename, dirname as dirname3, join as join3, resolve as resolve2, sep } from "path";
1767
1767
  var CLIP_VERIFY_TIMEOUT_MS = 4000;
1768
1768
  var POLL_INTERVAL_MS = 200;
1769
1769
  var CLIP_MTIME_SLACK_MS = 2000;
@@ -1825,7 +1825,10 @@ function isClipNoteName(entry, base) {
1825
1825
  }
1826
1826
  function clipNotePath(vaultPath, file) {
1827
1827
  const relative = file.endsWith(".md") ? file : `${file}.md`;
1828
- return join3(vaultPath, relative);
1828
+ const root = resolve2(vaultPath);
1829
+ const target = resolve2(root, relative);
1830
+ const prefix = root.endsWith(sep) ? root : root + sep;
1831
+ return target.startsWith(prefix) ? target : null;
1829
1832
  }
1830
1833
  function prune(claimed, floor) {
1831
1834
  for (const [path, mtime] of claimed) {
@@ -1853,6 +1856,8 @@ function createClipVerifier(vaultPaths, options = {}) {
1853
1856
  if (!vaultPath)
1854
1857
  return "unknown";
1855
1858
  const target = clipNotePath(vaultPath, file);
1859
+ if (target === null)
1860
+ return "unknown";
1856
1861
  const dir = dirname3(target);
1857
1862
  const base = basename(target).slice(0, -3);
1858
1863
  const fresh = since - CLIP_MTIME_SLACK_MS;
@@ -2037,6 +2042,8 @@ function renderTabs(tabs, opts = {}) {
2037
2042
  out.active = true;
2038
2043
  if (tab.hidden)
2039
2044
  out.hidden = true;
2045
+ if (tab.clipped)
2046
+ out.clipped = tab.clipped;
2040
2047
  if (shared === undefined && tab.windowId !== undefined)
2041
2048
  out.windowId = tab.windowId;
2042
2049
  return out;
@@ -2115,6 +2122,8 @@ var GULLET_TOOLS = [
2115
2122
 
2116
2123
  ` + `Titles longer than ${TAB_TITLE_MAX} characters are clipped with a trailing "\u2026", and URLs are shortened (tracking parameters and \`www.\` dropped). \`query\` always matches against the **full** title and URL, so a term that was clipped away still finds its tab. Use tab_read for a tab's real content.
2117
2124
 
2125
+ ` + `Already-filed pages carry \`clipped\`, from Tabglutton's own memory of what it has clipped \u2014 keyed by normalized URL, so it marks a page reached from a different link too. \`"launched"\` means the note was handed over without error; \`"verified"\` means something that can see the filesystem saw it land. **Neither says a note is on disk now** \u2014 notes get moved and deleted, and pages filed before this memory existed carry nothing at all. Treat it as a reason to skip tab_read, not as licence to close: ask the user first, as with any close.
2126
+
2118
2127
  ` + `Backlogs are large, so this returns the ${TABS_LIST_DEFAULT_LIMIT} most recently accessed tabs by default and reports \`matched\` (how many the filter actually hit) plus \`truncated: true\` when there were more. Narrow with \`query\` rather than raising \`limit\` \u2014 a full listing of a thousand tabs will not fit in your context.
2119
2128
 
2120
2129
  ` + `Start a triage run with \`groupBy: "domain"\`: it returns one row per domain with tab and discarded counts instead of any tabs, which is a few hundred bytes for the whole backlog and tells you what to pass as \`query\` next.`,
@@ -2185,7 +2194,7 @@ var GULLET_TOOLS = [
2185
2194
  {
2186
2195
  name: "tab_read",
2187
2196
  title: "Read a tab's content",
2188
- description: "Extract one open tab as clean markdown via Defuddle, with title, author, published date, description, site, and word count. Only works on loaded http(s) tabs: a discarded tab fails with tab-discarded and needs the user to open it manually. Does not navigate, click, or change the page.",
2197
+ description: "Extract one open tab as clean markdown via Defuddle, with title, author, published date, description, site, and word count. Only works on loaded http(s) tabs: a discarded tab fails with tab-discarded and needs the user to open it manually. Does not navigate, click, or change the page.\n\nA `thin` field means the page carried too little to be worth filing \u2014 with `challengeSuspect: true` it matched a bot-check signature, so what you are reading is most likely a Cloudflare or CAPTCHA interstitial standing where the real page was, not the page itself. You still get the text; judge it rather than trusting it, and note that tab_clip refuses the same page outright.",
2189
2198
  inputSchema: {
2190
2199
  type: "object",
2191
2200
  properties: {
@@ -2200,7 +2209,7 @@ var GULLET_TOOLS = [
2200
2209
  {
2201
2210
  name: "tab_clip",
2202
2211
  title: "File a tab as a markdown note",
2203
- description: 'Save a tab as a markdown note with frontmatter \u2014 exactly what the Tabglutton popup\'s Devour does, including per-site subfolders. Where it lands is the user\'s setting, not your choice: either their Obsidian vault or a markdown file in their download folder. The result says which under `destination` ("obsidian" or "file"), with `file` giving the note path \u2014 vault-relative for Obsidian, the absolute path on disk for a file \u2014 and `vault` naming the vault when there is one. Set close: true to close the tab afterwards; that close is undoable via the returned batchId. Filing alone changes nothing in the browser \u2014 the tool is annotated destructive because close: true removes the tab.\n\nNo tab is closed over a clip nobody could confirm, and `confirmedBy` says whose word it rests on:\n\u2022 `"browser"` \u2014 file destination, and the browser was seen to finish writing the file. Nothing checks it further because nothing is better placed to.\n\u2022 `"gullet"` \u2014 Obsidian destination, and a fresh note for this page was found in the vault. With a `contentHash` in the result that note is this exact clip\'s text, so it holds even against another agent session clipping the same URL at the same moment; without one it means only "a fresh note for this page landed just now".\n\u2022 `"nobody"` \u2014 nobody could check. For Obsidian that is an unreadable or unknown vault: the clip was still handed over, and the close, if asked for, still happened. For a file it means the browser had already erased the download\'s record, so there is no proof and no `file` path either \u2014 that tab is deliberately left open, with `closeSkipped` saying so. Check the download folder before re-clipping; the note may well be there.\n\nAn Obsidian clip that provably never reached the vault, or that found a note whose text is not the one handed over, is reported as an error with the tab left open.',
2212
+ description: "Save a tab as a markdown note with frontmatter \u2014 exactly what the Tabglutton popup's Devour does, including per-site subfolders. Where it lands is the user's setting, not your choice: their Obsidian vault, a markdown file in their download folder, or \u2014 for a paper, see below \u2014 their Zotero library. The result says which under `destination`, with `file` giving the note path \u2014 vault-relative for Obsidian, the absolute path on disk for a file \u2014 and `vault` naming the vault when there is one. Set close: true to close the tab afterwards; that close is undoable via the returned batchId. Filing alone changes nothing in the browser \u2014 the tool is annotated destructive because close: true removes the tab.\n\nA user who has switched on **Route papers to Zotero** gets a third destination, and it is chosen per tab rather than per user: if the Zotero Connector reads the page as a scholarly item or a PDF, the tab is saved to their Zotero library instead of being written as a note, and the result says `destination: \"zotero\"` with no `file` and no `vault`. That is the same routing the popup does, so a backlog you clear lands where their own clicks would have put it. Passing `vault` turns it off for that one call. If the Connector cannot take a routed tab the call fails with `zotero-failed` and the tab is left open \u2014 it is never quietly filed into Obsidian instead.\n\nNo tab is closed over a clip nobody could confirm, and `confirmedBy` says whose word it rests on:\n\u2022 `\"browser\"` \u2014 the file destination with the browser seen to finish writing the file, or the Zotero destination with the Connector reporting the save done. Nothing checks either further because nothing is better placed to; for Zotero that means the Connector's own word that its save completed, not an inspection of the library item.\n\u2022 `\"gullet\"` \u2014 Obsidian destination, and a fresh note for this page was found in the vault. With a `contentHash` in the result that note is this exact clip's text, so it holds even against another agent session clipping the same URL at the same moment; without one it means only \"a fresh note for this page landed just now\".\n\u2022 `\"nobody\"` \u2014 nobody could check. For Obsidian that is an unreadable or unknown vault: the clip was still handed over, and the close, if asked for, still happened. For a file it means the browser had already erased the download's record, so there is no proof and no `file` path either \u2014 that tab is deliberately left open, with `closeSkipped` saying so. Check the download folder before re-clipping; the note may well be there.\n\nAn Obsidian clip that provably never reached the vault, or that found a note whose text is not the one handed over, is reported as an error with the tab left open.",
2204
2213
  inputSchema: {
2205
2214
  type: "object",
2206
2215
  properties: {
@@ -2212,7 +2221,7 @@ var GULLET_TOOLS = [
2212
2221
  },
2213
2222
  vault: {
2214
2223
  type: "string",
2215
- description: "File into this vault instead of the configured one, for this call only \u2014 nothing is saved. Naming a vault also picks Obsidian as the destination, for a user whose setting files clips as markdown files. Use ONLY when the user names a destination vault themselves; never choose one on your own, and never guess at a name. Pass the exact name from Obsidian's vault switcher, not a path. Gullet rejects names missing from Obsidian's local registry when it can read that registry; an unavailable or unrecognised registry stays a soft check and does not block the clip."
2224
+ description: "File into this vault instead of the configured one, for this call only \u2014 nothing is saved. Naming a vault also picks Obsidian as the destination, for a user whose setting files clips as markdown files or routes papers to Zotero. Use ONLY when the user names a destination vault themselves; never choose one on your own, and never guess at a name. Pass the exact name from Obsidian's vault switcher, not a path. Gullet rejects names missing from Obsidian's local registry when it can read that registry; an unavailable or unrecognised registry stays a soft check and does not block the clip."
2216
2225
  }
2217
2226
  },
2218
2227
  required: ["tabId"],
@@ -2311,7 +2320,7 @@ async function clipAndVerify(ctx, connectionId, params) {
2311
2320
  } : {}
2312
2321
  };
2313
2322
  }
2314
- } else {
2323
+ } else if (result.destination !== "zotero") {
2315
2324
  const vault = typeof result.vault === "string" ? result.vault : "";
2316
2325
  if (!vault || !file) {
2317
2326
  return {
@@ -2323,6 +2332,8 @@ async function clipAndVerify(ctx, connectionId, params) {
2323
2332
  };
2324
2333
  }
2325
2334
  upgrade = { confirmedBy: await verifyObsidianClip(verify, result, vault, file, startedAt) };
2335
+ if (upgrade.confirmedBy === "gullet")
2336
+ confirmClipMemory(ctx, connectionId, result);
2326
2337
  }
2327
2338
  if (!wantsClose)
2328
2339
  return { ...result, ...upgrade };
@@ -2342,6 +2353,12 @@ async function clipAndVerify(ctx, connectionId, params) {
2342
2353
  ...didClose ? {} : { closeSkipped: closeError ?? closed?.skipped ?? closed?.missing ?? true }
2343
2354
  };
2344
2355
  }
2356
+ function confirmClipMemory(ctx, connectionId, result) {
2357
+ const url = typeof result.url === "string" ? result.url : "";
2358
+ if (!url)
2359
+ return;
2360
+ ctx.request(connectionId, "clip_confirm", { url }).catch(() => {});
2361
+ }
2345
2362
  async function verifyObsidianClip(verify, result, vault, file, since) {
2346
2363
  const sourceUrl = typeof result.url === "string" ? result.url : undefined;
2347
2364
  const contentHash = typeof result.contentHash === "string" ? result.contentHash : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabglutton-gullet",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Tabglutton's agent bridge: an MCP server over stdio, a WebSocket hub on loopback.",
5
5
  "keywords": [
6
6
  "browser",