@awesomate/hosting-mcp 0.19.2 → 0.20.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/dist/index.js CHANGED
@@ -11593,7 +11593,7 @@ var require_formdata = __commonJS({
11593
11593
  var { File: NativeFile } = __require("node:buffer");
11594
11594
  var nodeUtil = __require("node:util");
11595
11595
  var File2 = globalThis.File ?? NativeFile;
11596
- var FormData = class _FormData {
11596
+ var FormData2 = class _FormData {
11597
11597
  constructor(form) {
11598
11598
  webidl.util.markAsUncloneable(this);
11599
11599
  if (form !== void 0) {
@@ -11695,8 +11695,8 @@ var require_formdata = __commonJS({
11695
11695
  return `FormData ${output.slice(output.indexOf("]") + 2)}`;
11696
11696
  }
11697
11697
  };
11698
- iteratorMixin("FormData", FormData, kState, "name", "value");
11699
- Object.defineProperties(FormData.prototype, {
11698
+ iteratorMixin("FormData", FormData2, kState, "name", "value");
11699
+ Object.defineProperties(FormData2.prototype, {
11700
11700
  append: kEnumerableProperty,
11701
11701
  delete: kEnumerableProperty,
11702
11702
  get: kEnumerableProperty,
@@ -11724,7 +11724,7 @@ var require_formdata = __commonJS({
11724
11724
  }
11725
11725
  return { name, value };
11726
11726
  }
11727
- module.exports = { FormData, makeEntry };
11727
+ module.exports = { FormData: FormData2, makeEntry };
11728
11728
  }
11729
11729
  });
11730
11730
 
@@ -11994,7 +11994,7 @@ var require_body = __commonJS({
11994
11994
  extractMimeType,
11995
11995
  utf8DecodeBytes
11996
11996
  } = require_util3();
11997
- var { FormData } = require_formdata();
11997
+ var { FormData: FormData2 } = require_formdata();
11998
11998
  var { kState } = require_symbols2();
11999
11999
  var { webidl } = require_webidl();
12000
12000
  var { Blob: Blob2 } = __require("node:buffer");
@@ -12214,13 +12214,13 @@ Content-Type: ${value.type || "application/octet-stream"}\r
12214
12214
  if (parsed === "failure") {
12215
12215
  throw new TypeError("Failed to parse body as FormData.");
12216
12216
  }
12217
- const fd = new FormData();
12217
+ const fd = new FormData2();
12218
12218
  fd[kState] = parsed;
12219
12219
  return fd;
12220
12220
  }
12221
12221
  case "application/x-www-form-urlencoded": {
12222
12222
  const entries = new URLSearchParams(value.toString());
12223
- const fd = new FormData();
12223
+ const fd = new FormData2();
12224
12224
  for (const [name, value2] of entries) {
12225
12225
  fd.append(name, value2);
12226
12226
  }
@@ -18891,7 +18891,7 @@ var require_response = __commonJS({
18891
18891
  } = require_constants3();
18892
18892
  var { kState, kHeaders } = require_symbols2();
18893
18893
  var { webidl } = require_webidl();
18894
- var { FormData } = require_formdata();
18894
+ var { FormData: FormData2 } = require_formdata();
18895
18895
  var { URLSerializer } = require_data_url();
18896
18896
  var { kConstruct } = require_symbols();
18897
18897
  var assert2 = __require("node:assert");
@@ -19204,7 +19204,7 @@ var require_response = __commonJS({
19204
19204
  ReadableStream
19205
19205
  );
19206
19206
  webidl.converters.FormData = webidl.interfaceConverter(
19207
- FormData
19207
+ FormData2
19208
19208
  );
19209
19209
  webidl.converters.URLSearchParams = webidl.interfaceConverter(
19210
19210
  URLSearchParams
@@ -39891,7 +39891,11 @@ async function hubRequest(config3, method, path, jsonBody, opts = {}) {
39891
39891
  body = text;
39892
39892
  }
39893
39893
  if (!res.ok) {
39894
- const serverMsg = body && typeof body === "object" && "error" in body && typeof body.error === "string" ? body.error : `Request failed (${res.status})`;
39894
+ const asObj = body && typeof body === "object" ? body : null;
39895
+ const errField = typeof asObj?.error === "string" ? asObj.error : null;
39896
+ const msgField = typeof asObj?.message === "string" && asObj.message.trim() ? asObj.message.trim() : null;
39897
+ const looksLikeCode = errField !== null && /^[a-z0-9_]+$/.test(errField);
39898
+ const serverMsg = msgField ? looksLikeCode ? `${msgField} (${errField})` : msgField : errField ?? `Request failed (${res.status})`;
39895
39899
  const code = body && typeof body === "object" && "code" in body && typeof body.code === "string" ? body.code : null;
39896
39900
  let hint = "";
39897
39901
  if (res.status === 401) {
@@ -39924,6 +39928,56 @@ async function hubRequest(config3, method, path, jsonBody, opts = {}) {
39924
39928
  }
39925
39929
  return body;
39926
39930
  }
39931
+ async function hubUploadFile(config3, path, file) {
39932
+ let blob;
39933
+ try {
39934
+ const { openAsBlob } = await import("node:fs");
39935
+ if (typeof openAsBlob === "function") {
39936
+ blob = await openAsBlob(file.localPath, { type: file.contentType });
39937
+ } else {
39938
+ throw new Error("openAsBlob unavailable");
39939
+ }
39940
+ } catch {
39941
+ const { readFile } = await import("node:fs/promises");
39942
+ blob = new Blob([await readFile(file.localPath)], { type: file.contentType });
39943
+ }
39944
+ const form = new FormData();
39945
+ form.append("file", blob, file.filename);
39946
+ const controller = new AbortController();
39947
+ const timer = setTimeout(() => controller.abort(), 6e5);
39948
+ let res;
39949
+ try {
39950
+ res = await (0, import_undici.fetch)(`${config3.apiBase}${path}`, {
39951
+ method: "POST",
39952
+ headers: { Authorization: `Bearer ${config3.pat}` },
39953
+ body: form,
39954
+ signal: controller.signal,
39955
+ dispatcher: proxyDispatcher
39956
+ });
39957
+ } catch (err) {
39958
+ const aborted2 = err instanceof Error && err.name === "AbortError";
39959
+ throw new HubApiError(
39960
+ aborted2 ? "The upload timed out after 10 minutes. Large media can exceed this \u2014 try a smaller file, or upload it in the hub at Knowledge \u2192 Sources." : `Could not reach the Awesomate hub at ${config3.apiBase} to upload. This is a connectivity issue, not an auth problem.`,
39961
+ 0,
39962
+ null
39963
+ );
39964
+ } finally {
39965
+ clearTimeout(timer);
39966
+ }
39967
+ const text = await res.text();
39968
+ let body;
39969
+ try {
39970
+ body = text ? JSON.parse(text) : null;
39971
+ } catch {
39972
+ body = text;
39973
+ }
39974
+ if (!res.ok) {
39975
+ const serverMsg = body && typeof body === "object" && "message" in body && typeof body.message === "string" ? body.message : body && typeof body === "object" && "error" in body && typeof body.error === "string" ? body.error : `Upload failed (${res.status})`;
39976
+ const hint = res.status === 413 ? " The file exceeds the 100 MB limit. Split it, compress it, or upload it in the hub at Knowledge \u2192 Sources." : res.status === 402 ? " NOTHING was ingested and nothing was purchased \u2014 the ingestion allowance is exhausted. State the pack price (1 credit = $100) and let the user decide in the hub." : "";
39977
+ throw new HubApiError(`${/[.!?]$/.test(serverMsg) ? serverMsg : `${serverMsg}.`}${hint}`, res.status, body);
39978
+ }
39979
+ return body;
39980
+ }
39927
39981
  function hubGet(config3, path) {
39928
39982
  return hubRequest(config3, "GET", path);
39929
39983
  }
@@ -40165,7 +40219,7 @@ async function knowledgeSources(config3, args) {
40165
40219
  if (!args.url && !args.sitemap) {
40166
40220
  return {
40167
40221
  error: "invalid_request",
40168
- note: "add needs url or sitemap. For a local FILE, send the user to the hub: Knowledge \u2192 Sources \u2192 Upload. Files stream there; this tool cannot carry file bytes in v1."
40222
+ note: "add needs url or sitemap. For a local FILE on this machine, use awesomate_knowledge_upload \u2014 it reads the file off disk and streams it, so the bytes never pass through the conversation."
40169
40223
  };
40170
40224
  }
40171
40225
  const body = args.url ? { url: args.url } : { sitemap: args.sitemap, ...args.since ? { since: args.since } : {} };
@@ -40221,9 +40275,24 @@ function renderAnswer(meta, streamedAnswer, streamError = null) {
40221
40275
  locator: s.locator ?? s.section_path ?? null,
40222
40276
  url: s.url ?? null
40223
40277
  }));
40278
+ const answer = typeof meta.answer_plain === "string" && meta.answer_plain ? meta.answer_plain : streamedAnswer;
40279
+ if (sources.length === 0) {
40280
+ return {
40281
+ status: "ok",
40282
+ grounded: false,
40283
+ answer,
40284
+ sources: [],
40285
+ not_in_verified_content: true,
40286
+ configured_fallback: fallback,
40287
+ ...typeof meta.score === "number" ? { score: meta.score } : {},
40288
+ ...session,
40289
+ note: "UNGROUNDED: the platform returned ok but ZERO sources, which means this answer came from the model, NOT from the verified content. Do NOT present it as an answer from their knowledge base, do not quote it as fact, and do not build on it. Tell the user their content does not cover this. If they need it to refuse instead of improvising, the agent's grounding setting is not strict \u2014 a purpose-built agent (awesomate_knowledge_agents) can be scoped and set strict, and that is what should be wired to anything customer-facing."
40290
+ };
40291
+ }
40224
40292
  return {
40225
40293
  status: "ok",
40226
- answer: typeof meta.answer_plain === "string" && meta.answer_plain ? meta.answer_plain : streamedAnswer,
40294
+ grounded: true,
40295
+ answer,
40227
40296
  sources,
40228
40297
  ...typeof meta.score === "number" ? { score: meta.score } : {},
40229
40298
  ...session,
@@ -41466,7 +41535,7 @@ server.registerTool(
41466
41535
  server.registerTool(
41467
41536
  "awesomate_knowledge_sources",
41468
41537
  {
41469
- description: "The knowledge base's content sources. action 'list' \u2014 ONE page of sources, most recently ingested first (default 50, max 200 via limit): read `page.has_more`/`next_cursor` and pass cursor to continue \u2014 a page is never the whole library. 'summary' \u2014 exact whole-library counts {total, by_kind, chunks, indexed_chunks, failed_sources}: use THIS to say what the knowledge base contains. 'jobs' \u2014 ingest job statuses (optional status filter: queued|running|succeeded|failed). 'add' \u2014 ingest a public page {url} or a whole site {sitemap, since?}; ALWAYS get explicit approval first (ingest costs money and counts against quota), and for local FILES send the user to the hub's Knowledge \u2192 Sources upload page \u2014 this tool cannot carry file bytes. A pack_required response means the allowance is exhausted: NOTHING was purchased \u2014 present the pack price (1 credit = $100) and let the user buy from the hub if they want it. 'remove' {sourceId} \u2014 deletes the source AND its indexed content; explicit approval required.",
41538
+ description: "The knowledge base's content sources. action 'list' \u2014 ONE page of sources, most recently ingested first (default 50, max 200 via limit): read `page.has_more`/`next_cursor` and pass cursor to continue \u2014 a page is never the whole library. 'summary' \u2014 exact whole-library counts {total, by_kind, chunks, indexed_chunks, failed_sources}: use THIS to say what the knowledge base contains. 'jobs' \u2014 ingest job statuses (optional status filter: queued|running|succeeded|failed). 'add' \u2014 ingest a public page {url} or a whole site {sitemap, since?}; ALWAYS get explicit approval first (ingest costs money and counts against quota), for a local FILE on the user's machine use awesomate_knowledge_upload instead (it streams the file from disk; this tool takes URLs only). A pack_required response means the allowance is exhausted: NOTHING was purchased \u2014 present the pack price (1 credit = $100) and let the user buy from the hub if they want it. 'remove' {sourceId} \u2014 deletes the source AND its indexed content; explicit approval required.",
41470
41539
  inputSchema: {
41471
41540
  action: external_exports.enum(["list", "summary", "add", "remove", "jobs"]),
41472
41541
  url: external_exports.string().url().optional().describe("add: one public page / blog post / YouTube link"),
@@ -41492,7 +41561,7 @@ server.registerTool(
41492
41561
  "awesomate_knowledge_search",
41493
41562
  {
41494
41563
  annotations: READ_ONLY,
41495
- description: "Instant search over the knowledge library with live facet counts: the fastest way to see WHAT is in there and to find the exact video moment, book page, dataset or web section. Returns hits (title, kind, locator like t=612-640 or p.42, snippet with **matched words**, score) plus facets {kind, year, category, author, people, places, topics} whose counts describe the current filters: repeat a facet value to OR within it, combine facets to AND. include_media adds presigned url/poster_url to hits: they expire in minutes, use immediately, never store. Keyword-only and free (no answer quota); for a verified ANSWER use awesomate_knowledge_ask, optionally with the same filters.",
41564
+ description: "Instant search over the knowledge library with live facet counts: the fastest way to see WHAT is in there and to find the exact video moment, book page, dataset or web section. Returns hits (title, kind, locator like t=612-640 or p.42, snippet with **matched words**, score) plus facets {kind, year, category, author, people, places, topics} whose counts describe the current filters: repeat a facet value to OR within it, combine facets to AND. include_media adds presigned url/poster_url to hits: they expire in minutes, use immediately, never store. Keyword-only and free (no answer quota); for a verified ANSWER use awesomate_knowledge_ask, optionally with the same filters. Citations from awesomate_knowledge_ask carry NO media URLs \u2014 when a cited source is an image/video and the user wants to SEE it, re-query here with include_media (ideally filtered by its doc id). The returned url/poster_url expire in minutes: fine to show in chat, never safe to embed in a page \u2014 see the awesomate-knowledge skill's showing-media.md.",
41496
41565
  inputSchema: {
41497
41566
  q: external_exports.string().max(2e3).optional().describe("Search words; empty lists the library filtered by the facets"),
41498
41567
  kind: external_exports.enum(["book", "document", "web", "image", "video", "audio", "post", "dataset"]).optional(),
@@ -41519,7 +41588,7 @@ server.registerTool(
41519
41588
  server.registerTool(
41520
41589
  "awesomate_knowledge_ask",
41521
41590
  {
41522
- description: `Ask the account's knowledge base a question and get the VERIFIED answer with numbered sources (title, locator, url) \u2014 the test surface for 'is my content in there and answering well'. Read status: ok \u2192 present answer + sources. no_results / failed_validation (not_in_verified_content:true) \u2192 the verified content has no answer: relay that honestly (use configured_fallback), never fill the gap from memory \u2014 an honest "it doesn't know" is the feature working. error (platform_error:true) \u2192 the platform itself failed (model/API/infra): NOT a content gap \u2014 never tell the user their content lacks the answer; retry once, then awesomate_support. Counts against the monthly answers quota.`,
41591
+ description: `Ask the account's knowledge base a question and get the VERIFIED answer with numbered sources (title, locator, url) \u2014 the test surface for 'is my content in there and answering well'. Read BOTH status and grounded. grounded:true \u2192 present the answer with its numbered sources. grounded:false (status ok but ZERO sources) \u2192 the agent answered from MODEL MEMORY, not their content: say their content does not cover it, never present it as an answer from their knowledge base, never build on it. The default workspace agent is not strict-grounded, so this is common \u2014 anything customer-facing should use a purpose-built agent (awesomate_knowledge_agents) with strict grounding. no_results / failed_validation (not_in_verified_content:true) \u2192 the verified content has no answer: relay that honestly (use configured_fallback), never fill the gap from memory \u2014 an honest "it doesn't know" is the feature working. error (platform_error:true) \u2192 the platform itself failed (model/API/infra): NOT a content gap \u2014 never tell the user their content lacks the answer; retry once, then awesomate_support. Counts against the monthly answers quota.`,
41523
41592
  inputSchema: {
41524
41593
  question: external_exports.string().min(1).max(2e3),
41525
41594
  session: external_exports.string().max(128).optional().describe("Stable id to keep follow-up questions in one conversation thread"),
@@ -41842,6 +41911,91 @@ server.registerTool(
41842
41911
  }
41843
41912
  }
41844
41913
  );
41914
+ var KB_UPLOAD_TYPES = {
41915
+ ".pdf": "application/pdf",
41916
+ ".doc": "application/msword",
41917
+ ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
41918
+ ".ppt": "application/vnd.ms-powerpoint",
41919
+ ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
41920
+ ".xls": "application/vnd.ms-excel",
41921
+ ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
41922
+ ".csv": "text/csv",
41923
+ ".txt": "text/plain",
41924
+ ".md": "text/markdown",
41925
+ ".rtf": "application/rtf",
41926
+ ".html": "text/html",
41927
+ ".htm": "text/html",
41928
+ ".json": "application/json",
41929
+ ".epub": "application/epub+zip",
41930
+ ".mp3": "audio/mpeg",
41931
+ ".m4a": "audio/mp4",
41932
+ ".wav": "audio/wav",
41933
+ ".mp4": "video/mp4",
41934
+ ".mov": "video/quicktime",
41935
+ ".m4v": "video/x-m4v",
41936
+ ".png": "image/png",
41937
+ ".jpg": "image/jpeg",
41938
+ ".jpeg": "image/jpeg",
41939
+ ".webp": "image/webp"
41940
+ };
41941
+ var KB_MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
41942
+ server.registerTool(
41943
+ "awesomate_knowledge_upload",
41944
+ {
41945
+ description: "Ingest ONE file from the user's own computer into their Knowledge Base (Pro+). Pass a LOCAL PATH \u2014 this server runs on their machine and streams the file to the hub itself, so the file contents never pass through the conversation. Handles documents (pdf, docx, pptx, xlsx, csv, txt, md, epub), audio and video (transcribed), and images. Max 100 MB per file; bigger media goes through the hub's Knowledge \u2192 Sources page. INGESTING COSTS MONEY and counts against the monthly allowance, so ALWAYS get explicit approval for the specific file(s) first and say what it will consume. For several files, call once per file and report progress \u2014 do not loop silently. Returns a job; poll awesomate_knowledge_sources {action:'jobs'} until it succeeds, then probe the content with awesomate_knowledge_ask before building anything on it. A pack_required response means the allowance is exhausted: nothing was ingested and nothing was purchased.",
41946
+ inputSchema: {
41947
+ path: external_exports.string().min(1).max(4096).describe("Path to the file on the user's machine (~ is expanded)"),
41948
+ title: external_exports.string().max(300).optional().describe("Display title; defaults to the filename")
41949
+ }
41950
+ },
41951
+ async ({ path: rawPath, title }) => {
41952
+ try {
41953
+ const { statSync, existsSync: existsSync3 } = await import("node:fs");
41954
+ const { resolve: resolve2, basename, extname } = await import("node:path");
41955
+ const expanded = rawPath.startsWith("~") ? join3(homedir3(), rawPath.slice(1).replace(/^[/\\]/, "")) : rawPath;
41956
+ const abs = resolve2(expanded);
41957
+ if (!existsSync3(abs)) {
41958
+ return errorResult(
41959
+ new Error(
41960
+ `No file at ${abs}. Check the path with the user \u2014 a path that works in their shell may differ from this server's working directory, so prefer an absolute path.`
41961
+ )
41962
+ );
41963
+ }
41964
+ const st = statSync(abs);
41965
+ if (st.isDirectory()) {
41966
+ return errorResult(
41967
+ new Error(
41968
+ `${abs} is a folder, not a file. This tool takes one file at a time \u2014 list the folder, agree with the user which files to ingest, then call once per file.`
41969
+ )
41970
+ );
41971
+ }
41972
+ if (!st.isFile()) return errorResult(new Error(`${abs} is not a regular file.`));
41973
+ if (st.size === 0) return errorResult(new Error(`${abs} is empty \u2014 nothing to ingest.`));
41974
+ if (st.size > KB_MAX_UPLOAD_BYTES) {
41975
+ return errorResult(
41976
+ new Error(
41977
+ `${basename(abs)} is ${(st.size / 1024 / 1024).toFixed(1)} MB, over the 100 MB limit. Split or compress it, or have the user upload it in the hub at Knowledge \u2192 Sources.`
41978
+ )
41979
+ );
41980
+ }
41981
+ const ext = extname(abs).toLowerCase();
41982
+ const contentType = KB_UPLOAD_TYPES[ext] ?? "application/octet-stream";
41983
+ const filename = title?.trim() ? `${title.trim()}${ext}` : basename(abs);
41984
+ const result = await hubUploadFile(requireConfig(), "/api/knowledge/sources", {
41985
+ localPath: abs,
41986
+ filename,
41987
+ contentType
41988
+ });
41989
+ return knowledgeResult({
41990
+ ...result,
41991
+ uploaded: { path: abs, filename, sizeBytes: st.size, contentType },
41992
+ note: `Queued \u2014 NOT yet ingested. Poll awesomate_knowledge_sources {action:"jobs"} and read the job's status AND error: a job that fails during processing creates no source row, so summary/failed_sources still look clean and the failure is invisible there. Big media is transcribed and can take a while. Only after the job reports succeeded, verify with awesomate_knowledge_ask before building on it.`
41993
+ });
41994
+ } catch (err) {
41995
+ return knowledgeError(err);
41996
+ }
41997
+ }
41998
+ );
41845
41999
  server.registerPrompt(
41846
42000
  "awesomate-status",
41847
42001
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomate/hosting-mcp",
3
- "version": "0.19.2",
3
+ "version": "0.20.1",
4
4
  "description": "Awesomate MCP server — lets Claude manage your Awesomate WordPress hosting, plan, limits, n8n automations, and build Node/static apps + databases",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "scripts": {
20
20
  "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=esm --outfile=dist/index.js --banner:js='#!/usr/bin/env node\nimport { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:*",
21
21
  "typecheck": "tsc --noEmit",
22
- "test": "npm run build && esbuild src/config.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/config.mjs --external:node:* && esbuild src/knowledge.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/knowledge.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/skills.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/skills.mjs --external:node:* && node --test test/*.test.mjs",
22
+ "test": "npm run build && esbuild src/config.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/config.mjs --external:node:* && esbuild src/knowledge.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/knowledge.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/skills.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/skills.mjs --external:node:* && esbuild src/http.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/http.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && node --test test/*.test.mjs",
23
23
  "prepublishOnly": "npm run typecheck && npm run test"
24
24
  },
25
25
  "dependencies": {
@@ -1,5 +1,19 @@
1
1
  {
2
2
  "versions": [
3
+ {
4
+ "version": "0.20.1",
5
+ "highlights": [
6
+ "Claude now tells you clearly when an answer did NOT come from your content, instead of showing it like a verified one",
7
+ "Clearer error messages when something is not supported, instead of a generic failure"
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.20.0",
12
+ "highlights": [
13
+ "Add your own documents, audio and video to your Knowledge Base straight from your computer - just point Claude at the files",
14
+ "Claude can take you all the way from your files to a tested chat agent live on your website"
15
+ ]
16
+ },
3
17
  {
4
18
  "version": "0.19.2",
5
19
  "highlights": [
@@ -71,10 +71,18 @@ Local FILES (PDFs, videos on disk) cannot travel through these tools — send
71
71
  the user to the hub's Knowledge → Sources upload page (100 MB per file;
72
72
  bigger media by URL). Formats + caps: [ingestion-sources.md](references/ingestion-sources.md).
73
73
 
74
+ **`awesomate_knowledge_upload {path, title?}`** — ingest ONE file from the
75
+ user's own computer. Pass a local path; the server streams it from disk, so
76
+ file contents never pass through the conversation. 100 MB max, one call per
77
+ file, explicit approval first (it spends allowance). URLs and sitemaps stay on
78
+ `awesomate_knowledge_sources`.
79
+
74
80
  ## 2. References — read on demand
75
81
 
76
82
  | When | Read |
77
83
  |---|---|
84
+ | **"Train this on my files and put a chat on my site"** — the full path | [from-your-files.md](references/from-your-files.md) |
85
+ | Showing a cited image or video (and why a built page breaks) | [showing-media.md](references/showing-media.md) |
78
86
  | Choosing/adding sources, estimating ingest cost & time | [ingestion-sources.md](references/ingestion-sources.md) |
79
87
  | Explaining citations, refusals, "verified" semantics | [citations-and-grounding.md](references/citations-and-grounding.md) |
80
88
  | Wiring the knowledge base into n8n agents | [n8n-connection.md](references/n8n-connection.md) |
@@ -116,12 +124,16 @@ enough to route through explicit REST calls the user has just approved.
116
124
 
117
125
  | Action | Endpoint |
118
126
  |---|---|
119
- | Status / provision / sources / jobs / agent / ask | `GET\|POST /api/knowledge/{status,provision,sources,jobs,agent,chat}` (tool equivalents) |
120
- | Faceted search (what `awesomate_knowledge_search` calls) | `GET /api/knowledge/explore?q=…` + the same facet params |
127
+ | Status / provision / sources / jobs / agent | `GET\|POST /api/knowledge/{status,provision,sources,jobs,agent}` (tool equivalents) |
128
+ | Ask the knowledge base | `POST /api/knowledge/chat` `{question, session?}` **returns SSE (`text/event-stream`), NOT JSON.** `JSON.parse` of the body yields `null` and reading `.status` off it throws. Concatenate `event: answer` data lines; the single `event: meta` line carries the verdict `{status, sources, score}`. |
129
+ | Whole-library counts | `GET /api/knowledge/sources/summary` — a PATH. **`?action=summary` is NOT a thing:** it returns 200 with a plain source list, so `.total` is `undefined` and any count derived from it silently becomes 0 or NaN. |
130
+ | Faceted search (what `awesomate_knowledge_search` calls) | `GET /api/knowledge/explore?q=…` + the same facet params. **Add `&include=media` to get `url`/`poster_url` on image/video hits** — without it you get titles with nothing to display. |
121
131
  | Business-data warehouse (what `awesomate_knowledge_data` calls) | `GET /api/knowledge/data/{metrics,datasets,datasets/:id,imports,imports/:id}` · `PATCH /api/knowledge/data/datasets/:id` · `POST /api/knowledge/data/imports/:id/:action` · `POST /api/knowledge/data/query` (read-only SQL) |
122
132
  | Agent builder (what `awesomate_knowledge_agents` calls) | `GET\|POST /api/knowledge/agents` · `GET\|PATCH\|DELETE /api/knowledge/agents/:agent_id` · `POST /api/knowledge/agents/:agent_id/{publish,suspend,resume}` |
133
+ | **Test a DRAFT agent** (`action:'test'`) | `POST /api/knowledge/agents/:agent_id/chat` `{message, session_id?}`. There is **no** `/test` endpoint — guessing one returns 404. |
123
134
  | Entity layer probe (`available` false = not enabled yet, stop) | `GET /api/knowledge/entities` |
124
- | People list / detail | `GET /api/knowledge/people?status=named\|unknown\|hidden\|all` · `GET /api/knowledge/people/:id` |
135
+ | People list / detail | `GET /api/knowledge/people?status=named\|unknown\|hidden\|all` · `GET /api/knowledge/people/:id` — returns `{people, next_cursor}` and **no `counts` key**. |
136
+ | Entity COUNTS + availability | `GET /api/knowledge/entities` → `{available, counts: {...}}` — counts are nested under `counts`. Reading `people.counts?.x ?? 0` prints a confident row of zeros next to data that plainly exists. |
125
137
  | Name or hide/unhide a person (after approval) | `PATCH /api/knowledge/people/:id` `{display_name}` or `{status: "hidden"\|"unknown"}` |
126
138
  | Merge two people (after approval; source is hidden) | `POST /api/knowledge/people/:id/merge` `{into_person_id}` |
127
139
  | Alias suggestions / decision (identity = kind + alias_norm) | `GET /api/knowledge/entities/aliases?status=pending` · `POST /api/knowledge/entities/aliases/decision` `{kind, alias_norm, decision, entity_id? \| create_person?}` |
@@ -132,6 +144,23 @@ enough to route through explicit REST calls the user has just approved.
132
144
  | Delete the WHOLE knowledge base | hub UI only (owner types the account slug) — never via PAT |
133
145
  | Fleet/admin views (Awesomate team) | `/api/fleet/knowledge/*` — admin JWT, not a client PAT |
134
146
 
147
+
148
+ **The two chat endpoints take OPPOSITE field names, and both reject unknown keys.**
149
+ Learning one shape and applying it to the other is a guaranteed `400`:
150
+
151
+ | Endpoint | Body |
152
+ |---|---|
153
+ | `POST /api/knowledge/chat` — ask the knowledge base | `{question, session?, filters?}` |
154
+ | `POST /api/knowledge/agents/:id/chat` — test a draft agent | `{message, session_id?, filters?}` |
155
+
156
+ `question` vs `message`, `session` vs `session_id`. Both are strict objects, so
157
+ sending both spellings to be safe fails too — as does **camelCase**: `{message,
158
+ sessionId}` is a 400, and so is an extra `{draft: true}`. Going direct, use
159
+ snake_case and send nothing the schema does not name. (The MCP tool parameters
160
+ are camelCase — `sessionId`, `agentId` — because the tool translates for you.) Measured on a real first-time
161
+ session (2026-09-01): fourteen `400`s and one `404` were spent rediscovering
162
+ exactly this.
163
+
135
164
  ## 5. Hard rules
136
165
 
137
166
  - **Never ask for, paste, or echo an API key** — not the platform key, not
@@ -0,0 +1,121 @@
1
+ # From the user's own files to a live, answering agent
2
+
3
+ The end-to-end path when someone says "train this on my documents and put a
4
+ chat on my website". Every step below has a tool; none of it needs the hub UI
5
+ except buying an allowance pack and reading an agent's API key.
6
+
7
+ Do the steps in order. The one rule that matters: **never build on content you
8
+ have not verified is actually in there.** An agent published over a failed
9
+ ingest answers confidently from nothing.
10
+
11
+ ## 1. Agree the file list, and what it will cost
12
+
13
+ Ingest spends real money against a monthly allowance. Before uploading
14
+ anything:
15
+
16
+ - `awesomate_knowledge_status` — plan, consent, and the month-to-date usage
17
+ against the included quota. If `upgrade_required`, relay it and stop.
18
+ - List the candidate files for the user and get an explicit yes on the set.
19
+ Say roughly what it will consume: documents bill as pages (~1 page per
20
+ 100 KB), audio and video as media-hours.
21
+ - If the allowance is exhausted, a call returns `pack_required`: **nothing was
22
+ ingested and nothing was bought**. State the price (1 credit = $100) and let
23
+ them buy it in the hub. Never imply you purchased anything.
24
+
25
+ Media is far more expensive than documents. A folder of PDFs is cheap; three
26
+ hours of video is not. Say so before, not after.
27
+
28
+ ## 2. Upload, one file at a time
29
+
30
+ `awesomate_knowledge_upload { path, title? }` — a LOCAL path on their machine.
31
+ The MCP server reads the file off disk and streams it to the hub, so the file
32
+ contents never pass through the conversation and a 100 MB PDF costs no context.
33
+
34
+ - One call per file. Report progress as you go; never loop silently through
35
+ twenty files.
36
+ - 100 MB per file. Bigger media goes through the hub at Knowledge → Sources.
37
+ - A folder path is rejected on purpose — list it, agree the files, then upload.
38
+ - Public URLs and whole sitemaps stay on `awesomate_knowledge_sources`
39
+ `{action:'add'}`. Use that for their website; use upload for their disk.
40
+
41
+ ## 3. Wait for ingestion, and check it actually succeeded
42
+
43
+ `awesomate_knowledge_sources {action:'jobs'}` until the job reports
44
+ `succeeded`. Transcription of audio/video takes minutes, not seconds.
45
+
46
+ **The JOBS list is the authority on whether an upload worked — not
47
+ `failed_sources`, and not the source list.** A job that fails during document
48
+ processing never creates a source row, so `{action:'summary'}` still reports
49
+ `failed_sources: 0` and the library total is unchanged. Measured live on
50
+ 2026-09-01: an upload failed with a platform error while summary read
51
+ `total: 75, failed_sources: 0`. If you check the summary instead of the job,
52
+ a failed ingest looks exactly like one that was never attempted.
53
+
54
+ So: read the job's `status` AND its `error`, and relay the error text to the
55
+ user. Two real ones seen in the wild, both platform-side configuration rather
56
+ than anything wrong with their file:
57
+
58
+ - `new row violates row-level security policy for table "documents"` —
59
+ document/markdown ingestion is not currently permitted for that tenant.
60
+ - `transcription_not_configured: DEEPGRAM_API_KEY is not set` — audio/video
61
+ cannot be transcribed on that deployment yet.
62
+
63
+ Neither is fixable by the user or by retrying. Say plainly that the upload
64
+ reached Awesomate and failed on our side, and raise it with support
65
+ (awesomate-support skill) rather than re-uploading and spending allowance again.
66
+
67
+ Then `{action:'summary'}` for the whole-library counts once the job has
68
+ actually succeeded.
69
+
70
+ ## 4. Probe the content before building anything on it
71
+
72
+ `awesomate_knowledge_ask` with five real questions the user cares about, and
73
+ **one question you know the content cannot answer**. A base that answers the
74
+ fifth is not grounded, and that is the single most valuable thing to catch
75
+ before a customer sees it. Show the citations.
76
+
77
+ ## 5. Draft the agent
78
+
79
+ `awesomate_knowledge_agents {action:'create', goal}` — describe what the agent
80
+ is for and the platform drafts instructions, scope, tone and test questions
81
+ from the account's own content. It saves as a **private draft**; nothing is
82
+ live and nothing is lost.
83
+
84
+ Then `{action:'test', agentId, message}` — free and unmetered, and the right
85
+ way to check behaviour. Test the awkward cases: something out of scope, a
86
+ pricing question, a complaint, an ambiguous question. Confirm the refusal
87
+ wording is what the business would actually want to say.
88
+
89
+ Editing fields, policies, and API keys is hub UI only (Knowledge → Agents).
90
+
91
+ ## 6. Publish only with explicit approval
92
+
93
+ `{action:'publish', agentId}` makes it live **immediately for every key bound
94
+ to the agent**. Ask first, publish, then read the version back and confirm.
95
+
96
+ ## 7. Put it where their customers are
97
+
98
+ Two destinations. Ask which they want; do not assume.
99
+
100
+ **A chat on their existing website — via n8n.** This is usually the right
101
+ answer, and the plumbing is already provisioned. See
102
+ `references/n8n-connection.md`: the hub creates the scope credential and the
103
+ `knowledge_answer` tool. Build the workflow with the awesomate-n8n skill
104
+ (Chat Trigger or Webhook -> AI Agent with the `knowledge_answer` tool ->
105
+ Respond), test it, promote it, and give them the webhook URL to embed. Read
106
+ `awesomate-n8n/references/ai-agents.md` before designing the agent node.
107
+
108
+ **A standalone page or app — via the app builder.** When they want a hosted
109
+ "ask our docs" page rather than a widget on an existing site, use the
110
+ awesomate-app-builder skill. A Node app calls the agent server-side so the key
111
+ stays out of the browser: get the agent's API key from the hub (shown once),
112
+ store it with the awesomate-credentials secret-drop flow, and never put it in
113
+ page JavaScript. A static site cannot hold a secret — if the page must call the
114
+ agent directly, route it through their n8n webhook instead.
115
+
116
+ ## What to tell the user at the end
117
+
118
+ The library size, what it cost against their allowance, the agent's live
119
+ version, where it is reachable, and how to add more later. If anything failed
120
+ to ingest, say which files and why — a knowledge base with a silent hole is
121
+ worse than a smaller one they trust.
@@ -0,0 +1,59 @@
1
+ # Showing an image or video the knowledge base cited
2
+
3
+ A citation on its own is a title and a locator. To actually DISPLAY the asset
4
+ you need a media URL, and the rules differ depending on whether you are showing
5
+ it in chat or embedding it in something that has to keep working.
6
+
7
+ ## Getting the URL
8
+
9
+ `awesomate_knowledge_ask` citations do **not** carry media URLs — they return
10
+ `{ref, title, kind, section_path, locator, url, excerpt}`. When a citation's
11
+ `kind` is `image`, `video` or `audio` and the user wants to see it, follow up
12
+ with a search:
13
+
14
+ ```
15
+ awesomate_knowledge_search { q: "<the cited title>", kind: "image", include_media: true }
16
+ ```
17
+
18
+ `include_media: true` is what adds `url` and `poster_url` to the hits (over
19
+ REST it is `&include=media` on `/api/knowledge/explore` — easy to miss, and
20
+ without it you get titles with nothing to display). `poster_url` is the still
21
+ frame for a video; `url` is the asset itself.
22
+
23
+ Prefer `doc` filtering when you have the doc id from the citation — it resolves
24
+ the exact asset rather than the best text match for its title.
25
+
26
+ ## The constraint that decides your architecture
27
+
28
+ **These URLs are presigned and expire in minutes.** They are for showing
29
+ something to the user right now, in this conversation. They are NOT a link you
30
+ can put in a page, save in a data table, email, or hand to a customer.
31
+
32
+ So:
33
+
34
+ - **Showing it in chat, now** — fetch with `include_media` and display it.
35
+ Fine. Re-fetch if the user comes back later; do not reuse an old URL.
36
+ - **Building a page, app, or an n8n chat that displays assets** — a presigned
37
+ URL will 403 by the time a visitor loads it. Do not embed one. There is
38
+ currently **no stable, routable media URL** for knowledge assets, so the
39
+ page must resolve the asset at request time:
40
+ - the app calls `explore?include=media` server-side (holding the key
41
+ server-side, never in browser JavaScript) and returns a fresh URL per
42
+ request, or
43
+ - it proxies the bytes through the app's own route, or
44
+ - for anything long-lived, upload the asset to somewhere with a durable URL
45
+ (WordPress media via `awesomate_wp_media_import`, or the app's own static
46
+ assets) and reference THAT, using the knowledge base for the text.
47
+
48
+ Say this to the user plainly when they ask for a gallery or an image-rich page:
49
+ the knowledge base is the index, not the CDN. Getting that wrong produces a
50
+ page that looks right when built and is full of broken images an hour later.
51
+
52
+ ## Deciding quickly
53
+
54
+ | The user wants | Do |
55
+ |---|---|
56
+ | "show me that photo" | search with `include_media`, display it |
57
+ | "which images mention X" | search `kind:image`, list titles + show a few |
58
+ | a gallery page / a site section | resolve server-side per request, or re-host the assets; never embed a presigned URL |
59
+ | an n8n chat that returns images | have the workflow call the search endpoint at answer time and return fresh URLs in the reply |