flyspace-cli 0.1.63 → 0.1.64
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/{chunk-SBNBTJKW.js → chunk-FNKFJQB7.js} +427 -72
- package/dist/{chunk-UZMHXV4D.js → chunk-O7OYNQND.js} +46 -15
- package/dist/{chunk-PLLJ7M62.js → chunk-WFUR2BYO.js} +12 -1
- package/dist/cli.js +118 -252
- package/dist/index.js +2 -2
- package/dist/{threads-BFRTS4EB.js → threads-VOXFIRD6.js} +4 -3
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
sweepScratchDir,
|
|
31
31
|
uploadLocalImages,
|
|
32
32
|
useHostDbWithoutCredentials
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-O7OYNQND.js";
|
|
34
34
|
|
|
35
35
|
// ../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
|
|
36
36
|
var require_delayed_stream = __commonJS({
|
|
@@ -8832,7 +8832,7 @@ var require_mime_types = __commonJS({
|
|
|
8832
8832
|
"../../node_modules/.pnpm/mime-types@2.1.35/node_modules/mime-types/index.js"(exports) {
|
|
8833
8833
|
"use strict";
|
|
8834
8834
|
var db = require_mime_db();
|
|
8835
|
-
var
|
|
8835
|
+
var extname4 = __require("path").extname;
|
|
8836
8836
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
8837
8837
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
8838
8838
|
exports.charset = charset;
|
|
@@ -8886,7 +8886,7 @@ var require_mime_types = __commonJS({
|
|
|
8886
8886
|
if (!path || typeof path !== "string") {
|
|
8887
8887
|
return false;
|
|
8888
8888
|
}
|
|
8889
|
-
var extension2 =
|
|
8889
|
+
var extension2 = extname4("x." + path).toLowerCase().substr(1);
|
|
8890
8890
|
if (!extension2) {
|
|
8891
8891
|
return false;
|
|
8892
8892
|
}
|
|
@@ -25505,7 +25505,7 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
|
|
|
25505
25505
|
|
|
25506
25506
|
// ../api/src/version.ts
|
|
25507
25507
|
import { readFileSync as readFileSync8 } from "fs";
|
|
25508
|
-
var CLI_VERSION = true ? "0.1.
|
|
25508
|
+
var CLI_VERSION = true ? "0.1.64" : devVersion();
|
|
25509
25509
|
function isOlderVersion(a, b) {
|
|
25510
25510
|
const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
|
|
25511
25511
|
const [pa, pb] = [parse2(a), parse2(b)];
|
|
@@ -27416,7 +27416,7 @@ async function offloadPluginUi(workspace, state) {
|
|
|
27416
27416
|
var pluginUiHash = (state) => sha256(JSON.stringify(state));
|
|
27417
27417
|
|
|
27418
27418
|
// src/dashboard/doc-mention-guard.ts
|
|
27419
|
-
import { existsSync as existsSync21, statSync as
|
|
27419
|
+
import { existsSync as existsSync21, statSync as statSync10 } from "fs";
|
|
27420
27420
|
|
|
27421
27421
|
// src/dashboard/docs-routes.ts
|
|
27422
27422
|
import {
|
|
@@ -27428,15 +27428,15 @@ import {
|
|
|
27428
27428
|
openSync,
|
|
27429
27429
|
readSync,
|
|
27430
27430
|
readdirSync as readdirSync6,
|
|
27431
|
-
readFileSync as
|
|
27431
|
+
readFileSync as readFileSync18,
|
|
27432
27432
|
realpathSync as realpathSync2,
|
|
27433
27433
|
renameSync as renameSync3,
|
|
27434
27434
|
rmSync as rmSync10,
|
|
27435
|
-
statSync as
|
|
27435
|
+
statSync as statSync9,
|
|
27436
27436
|
writeFileSync as writeFileSync7
|
|
27437
27437
|
} from "fs";
|
|
27438
27438
|
import { Readable } from "stream";
|
|
27439
|
-
import { basename as basename6, dirname as dirname3, extname as
|
|
27439
|
+
import { basename as basename6, dirname as dirname3, extname as extname3, join as join21, relative as relative2, resolve as resolve7, sep as sep4 } from "path";
|
|
27440
27440
|
import { Hono as Hono4 } from "hono";
|
|
27441
27441
|
import { streamSSE } from "hono/streaming";
|
|
27442
27442
|
|
|
@@ -27616,6 +27616,257 @@ function closeEntry(cwd) {
|
|
|
27616
27616
|
entry.watcher.close();
|
|
27617
27617
|
}
|
|
27618
27618
|
|
|
27619
|
+
// ../api/src/dashboard/bridge-types.ts
|
|
27620
|
+
var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
|
|
27621
|
+
|
|
27622
|
+
// src/dashboard/doc-share-publisher.ts
|
|
27623
|
+
import { readFileSync as readFileSync14, statSync as statSync7 } from "fs";
|
|
27624
|
+
import { extname as extname2, posix } from "path";
|
|
27625
|
+
var MAX_ASSET_BYTES = 20 * 1024 * 1024;
|
|
27626
|
+
var MAX_CONTENT_BYTES = 2 * 1024 * 1024;
|
|
27627
|
+
var MAX_ASSETS = 50;
|
|
27628
|
+
var MAX_BUNDLE_ASSET_BYTES = 48 * 1024 * 1024;
|
|
27629
|
+
var MAX_INLINE_BYTES = 200 * 1024;
|
|
27630
|
+
var MAX_TOTAL_INLINE_BYTES = 1024 * 1024;
|
|
27631
|
+
var MD_LINK = /(!?\[[^\]]*\]\()\s*(<[^>]+>|[^)\s]+)/g;
|
|
27632
|
+
var MD_LINK_FULL = /(!?)\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)((?:\s+"[^"]*"|\s+'[^']*'|\s+\([^)]*\))?)\s*\)/g;
|
|
27633
|
+
var HTML_URL_ATTR = /\b(src|href|poster)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
27634
|
+
var HTML_CSS_URL = /\burl\(\s*("[^"]*"|'[^']*'|[^)'"\s]+)\s*\)/gi;
|
|
27635
|
+
var HTML_URL_PATTERNS = [
|
|
27636
|
+
{ re: HTML_URL_ATTR, group: 2 },
|
|
27637
|
+
{ re: HTML_CSS_URL, group: 1 }
|
|
27638
|
+
];
|
|
27639
|
+
function unquote2(value) {
|
|
27640
|
+
const q = value[0];
|
|
27641
|
+
if ((q === '"' || q === "'") && value.length >= 2 && value.endsWith(q)) {
|
|
27642
|
+
return { quote: q, url: value.slice(1, -1) };
|
|
27643
|
+
}
|
|
27644
|
+
return { quote: "", url: value };
|
|
27645
|
+
}
|
|
27646
|
+
function htmlUrls(source) {
|
|
27647
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27648
|
+
const out = [];
|
|
27649
|
+
for (const { re, group } of HTML_URL_PATTERNS) {
|
|
27650
|
+
for (const match of source.matchAll(re)) {
|
|
27651
|
+
const { url } = unquote2(match[group]);
|
|
27652
|
+
if (!url || seen.has(url)) continue;
|
|
27653
|
+
seen.add(url);
|
|
27654
|
+
out.push(url);
|
|
27655
|
+
}
|
|
27656
|
+
}
|
|
27657
|
+
return out;
|
|
27658
|
+
}
|
|
27659
|
+
function rewriteHtml(source, rewritten) {
|
|
27660
|
+
return source.replace(HTML_URL_ATTR, (whole, attr, value) => {
|
|
27661
|
+
const { quote, url } = unquote2(value);
|
|
27662
|
+
const next = rewritten.get(url);
|
|
27663
|
+
return next ? `${attr}=${quote || '"'}${next}${quote || '"'}` : whole;
|
|
27664
|
+
}).replace(HTML_CSS_URL, (whole, value) => {
|
|
27665
|
+
const { quote, url } = unquote2(value);
|
|
27666
|
+
const next = rewritten.get(url);
|
|
27667
|
+
return next ? `url(${quote || '"'}${next}${quote || '"'})` : whole;
|
|
27668
|
+
});
|
|
27669
|
+
}
|
|
27670
|
+
var MAX_PREVIEW_INLINE_BYTES = 10 * 1024 * 1024;
|
|
27671
|
+
function inlinePreviewImages(cwd, sourcePath, source) {
|
|
27672
|
+
const docDir = posix.dirname(sourcePath) === "." ? "" : posix.dirname(sourcePath);
|
|
27673
|
+
const inlined = /* @__PURE__ */ new Map();
|
|
27674
|
+
for (const url of htmlUrls(source)) {
|
|
27675
|
+
const ref = classifyHref(cwd, docDir, url);
|
|
27676
|
+
if (ref?.kind !== "local") continue;
|
|
27677
|
+
const resolved2 = resolveRawPath(cwd, ref.rel);
|
|
27678
|
+
if (!resolved2 || !resolved2.contentType.startsWith("image/")) continue;
|
|
27679
|
+
try {
|
|
27680
|
+
if (statSync7(resolved2.abs).size > MAX_PREVIEW_INLINE_BYTES) continue;
|
|
27681
|
+
const data = readFileSync14(resolved2.abs).toString("base64");
|
|
27682
|
+
inlined.set(url, `data:${resolved2.contentType};base64,${data}`);
|
|
27683
|
+
} catch {
|
|
27684
|
+
}
|
|
27685
|
+
}
|
|
27686
|
+
return inlined.size ? rewriteHtml(source, inlined) : source;
|
|
27687
|
+
}
|
|
27688
|
+
function shareKindOf(absPath) {
|
|
27689
|
+
const ext = extname2(absPath).toLowerCase();
|
|
27690
|
+
if (ext === ".md" || ext === ".markdown") return "markdown";
|
|
27691
|
+
if (ext === ".html" || ext === ".htm") return "html";
|
|
27692
|
+
if (ext === ".excalidraw") return "excalidraw";
|
|
27693
|
+
return null;
|
|
27694
|
+
}
|
|
27695
|
+
function isExternalHref(href) {
|
|
27696
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("#");
|
|
27697
|
+
}
|
|
27698
|
+
function sanitizeAssetName(name) {
|
|
27699
|
+
const base = name.split(/[/\\]/).pop() ?? "";
|
|
27700
|
+
const cleaned = base.replace(/\s+/g, "-").replace(/[^\w.-]/g, "").trim();
|
|
27701
|
+
return (cleaned || "file").slice(-100);
|
|
27702
|
+
}
|
|
27703
|
+
function renderAttachments(files) {
|
|
27704
|
+
if (files.length === 0) return "";
|
|
27705
|
+
const blocks = files.map((f) => {
|
|
27706
|
+
const longest = Math.max(0, ...[...f.text.matchAll(/`{3,}/g)].map((m) => m[0].length));
|
|
27707
|
+
const fence = "`".repeat(Math.max(3, longest + 1));
|
|
27708
|
+
const label = f.path.replace(/["\r\n]/g, "");
|
|
27709
|
+
return `${fence}${f.lang} file="${label}" id=${f.anchor}
|
|
27710
|
+
${f.text.replace(/\s+$/, "")}
|
|
27711
|
+
${fence}`;
|
|
27712
|
+
});
|
|
27713
|
+
return `
|
|
27714
|
+
|
|
27715
|
+
---
|
|
27716
|
+
|
|
27717
|
+
${blocks.join("\n\n")}
|
|
27718
|
+
`;
|
|
27719
|
+
}
|
|
27720
|
+
function classifyHref(cwd, docDir, rawHref) {
|
|
27721
|
+
const href = rawHref.startsWith("<") && rawHref.endsWith(">") ? rawHref.slice(1, -1) : rawHref;
|
|
27722
|
+
if (!href) return null;
|
|
27723
|
+
const attachment = href.match(/^\/api\/attachments\/(.+)$/);
|
|
27724
|
+
if (attachment) {
|
|
27725
|
+
const key = attachment[1].split("/").map((s) => {
|
|
27726
|
+
try {
|
|
27727
|
+
return decodeURIComponent(s);
|
|
27728
|
+
} catch {
|
|
27729
|
+
return s;
|
|
27730
|
+
}
|
|
27731
|
+
}).join("/");
|
|
27732
|
+
return key.startsWith("chat/") ? { kind: "attachment", key } : null;
|
|
27733
|
+
}
|
|
27734
|
+
if (isExternalHref(href)) return null;
|
|
27735
|
+
const pathPart = href.split(/[?#]/)[0];
|
|
27736
|
+
if (!pathPart) return null;
|
|
27737
|
+
if (pathPart.startsWith("/")) {
|
|
27738
|
+
if (pathPart !== cwd && !pathPart.startsWith(`${cwd}/`)) return null;
|
|
27739
|
+
return { kind: "local", rel: pathPart.slice(cwd.length).replace(/^\/+/, "") };
|
|
27740
|
+
}
|
|
27741
|
+
return { kind: "local", rel: posix.normalize(docDir ? `${docDir}/${pathPart}` : pathPart) };
|
|
27742
|
+
}
|
|
27743
|
+
function readDocShareBundle({ cwd, sourcePath }) {
|
|
27744
|
+
const abs = resolveDocPath(cwd, sourcePath);
|
|
27745
|
+
if (!abs) return { status: "not-found" };
|
|
27746
|
+
const kind = shareKindOf(abs);
|
|
27747
|
+
if (!kind) return { status: "unsupported" };
|
|
27748
|
+
let stat;
|
|
27749
|
+
try {
|
|
27750
|
+
stat = statSync7(abs);
|
|
27751
|
+
} catch {
|
|
27752
|
+
return { status: "not-found" };
|
|
27753
|
+
}
|
|
27754
|
+
if (!stat.isFile()) return { status: "not-found" };
|
|
27755
|
+
if (stat.size > MAX_CONTENT_BYTES) return { status: "too-large" };
|
|
27756
|
+
const source = readFileSync14(abs, "utf8");
|
|
27757
|
+
const title = extractTitle(abs, kind === "markdown" ? "md" : kind);
|
|
27758
|
+
if (kind === "excalidraw") {
|
|
27759
|
+
try {
|
|
27760
|
+
const parsed = JSON.parse(source);
|
|
27761
|
+
if (!parsed || typeof parsed !== "object") return { status: "unsupported" };
|
|
27762
|
+
} catch {
|
|
27763
|
+
return { status: "unsupported" };
|
|
27764
|
+
}
|
|
27765
|
+
return { status: "ok", kind, title, content: source, assets: [] };
|
|
27766
|
+
}
|
|
27767
|
+
const docDir = sourcePath.includes("/") ? sourcePath.slice(0, sourcePath.lastIndexOf("/")) : "";
|
|
27768
|
+
const rewritten = /* @__PURE__ */ new Map();
|
|
27769
|
+
const usedNames = /* @__PURE__ */ new Set();
|
|
27770
|
+
const usedAnchors = /* @__PURE__ */ new Set();
|
|
27771
|
+
const assets = [];
|
|
27772
|
+
let assetBytes = 0;
|
|
27773
|
+
const attachments = [];
|
|
27774
|
+
let inlinedBytes = 0;
|
|
27775
|
+
const claimName = (candidate) => {
|
|
27776
|
+
const safe = sanitizeAssetName(candidate);
|
|
27777
|
+
if (!usedNames.has(safe)) {
|
|
27778
|
+
usedNames.add(safe);
|
|
27779
|
+
return safe;
|
|
27780
|
+
}
|
|
27781
|
+
const ext = extname2(safe);
|
|
27782
|
+
const stem = safe.slice(0, safe.length - ext.length);
|
|
27783
|
+
for (let n = 2; ; n += 1) {
|
|
27784
|
+
const next = `${stem}-${n}${ext}`;
|
|
27785
|
+
if (!usedNames.has(next)) {
|
|
27786
|
+
usedNames.add(next);
|
|
27787
|
+
return next;
|
|
27788
|
+
}
|
|
27789
|
+
}
|
|
27790
|
+
};
|
|
27791
|
+
const claimAnchor = (rel) => {
|
|
27792
|
+
const stem = sanitizeAssetName(rel).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
27793
|
+
const base = `file-${stem || "attachment"}`;
|
|
27794
|
+
if (!usedAnchors.has(base)) {
|
|
27795
|
+
usedAnchors.add(base);
|
|
27796
|
+
return base;
|
|
27797
|
+
}
|
|
27798
|
+
for (let n = 2; ; n += 1) {
|
|
27799
|
+
const next = `${base}-${n}`;
|
|
27800
|
+
if (!usedAnchors.has(next)) {
|
|
27801
|
+
usedAnchors.add(next);
|
|
27802
|
+
return next;
|
|
27803
|
+
}
|
|
27804
|
+
}
|
|
27805
|
+
};
|
|
27806
|
+
const refs = [];
|
|
27807
|
+
const hrefs = kind === "html" ? htmlUrls(source) : [...source.matchAll(MD_LINK)].map((m) => m[2]);
|
|
27808
|
+
for (const href of hrefs) {
|
|
27809
|
+
if (rewritten.has(href) || refs.some((r) => r.href === href)) continue;
|
|
27810
|
+
const ref = classifyHref(cwd, docDir, href);
|
|
27811
|
+
if (ref) refs.push({ href, ref });
|
|
27812
|
+
}
|
|
27813
|
+
for (const { href, ref } of refs.slice(0, MAX_ASSETS)) {
|
|
27814
|
+
if (ref.kind === "attachment") {
|
|
27815
|
+
const name2 = claimName(ref.key.split("/").pop() ?? "file");
|
|
27816
|
+
assets.push({ name: name2, copyFrom: ref.key });
|
|
27817
|
+
rewritten.set(href, `${SHARE_ASSET_PLACEHOLDER}${name2}`);
|
|
27818
|
+
continue;
|
|
27819
|
+
}
|
|
27820
|
+
const docAbs = kind === "markdown" ? resolveDocPath(cwd, ref.rel) : null;
|
|
27821
|
+
const lang = docAbs ? highlightLanguageOf(docAbs) : null;
|
|
27822
|
+
if (docAbs && lang) {
|
|
27823
|
+
const budget = Math.min(MAX_INLINE_BYTES, MAX_TOTAL_INLINE_BYTES - inlinedBytes);
|
|
27824
|
+
let text = null;
|
|
27825
|
+
try {
|
|
27826
|
+
const size = statSync7(docAbs).size;
|
|
27827
|
+
if (size <= budget) text = readFileSync14(docAbs, "utf8");
|
|
27828
|
+
} catch {
|
|
27829
|
+
continue;
|
|
27830
|
+
}
|
|
27831
|
+
if (text !== null) {
|
|
27832
|
+
const anchor = claimAnchor(ref.rel);
|
|
27833
|
+
inlinedBytes += Buffer.byteLength(text);
|
|
27834
|
+
attachments.push({ anchor, path: ref.rel, lang, text });
|
|
27835
|
+
rewritten.set(href, `#${anchor}`);
|
|
27836
|
+
continue;
|
|
27837
|
+
}
|
|
27838
|
+
}
|
|
27839
|
+
const resolved2 = resolveRawPath(cwd, ref.rel) ?? (docAbs ? { abs: docAbs, contentType: "text/plain; charset=utf-8" } : null);
|
|
27840
|
+
if (!resolved2) continue;
|
|
27841
|
+
let body;
|
|
27842
|
+
try {
|
|
27843
|
+
if (statSync7(resolved2.abs).size > MAX_ASSET_BYTES) continue;
|
|
27844
|
+
body = readFileSync14(resolved2.abs);
|
|
27845
|
+
} catch {
|
|
27846
|
+
continue;
|
|
27847
|
+
}
|
|
27848
|
+
assetBytes += body.length;
|
|
27849
|
+
if (assetBytes > MAX_BUNDLE_ASSET_BYTES) return { status: "too-large" };
|
|
27850
|
+
const name = claimName(ref.rel.split("/").pop() ?? "file");
|
|
27851
|
+
assets.push({ name, contentType: resolved2.contentType, data: body.toString("base64") });
|
|
27852
|
+
rewritten.set(href, `${SHARE_ASSET_PLACEHOLDER}${name}`);
|
|
27853
|
+
}
|
|
27854
|
+
if (kind === "html") {
|
|
27855
|
+
return { status: "ok", kind, title, content: rewriteHtml(source, rewritten), assets };
|
|
27856
|
+
}
|
|
27857
|
+
const content = source.replace(
|
|
27858
|
+
MD_LINK_FULL,
|
|
27859
|
+
(whole, bang, label, href, title2) => {
|
|
27860
|
+
const replacement = rewritten.get(href);
|
|
27861
|
+
if (replacement?.startsWith("#") && bang) return label;
|
|
27862
|
+
if (replacement) return `${bang}[${label}](${replacement}${title2})`;
|
|
27863
|
+
if (classifyHref(cwd, docDir, href)?.kind === "local") return label;
|
|
27864
|
+
return whole;
|
|
27865
|
+
}
|
|
27866
|
+
);
|
|
27867
|
+
return { status: "ok", kind, title, content: content + renderAttachments(attachments), assets };
|
|
27868
|
+
}
|
|
27869
|
+
|
|
27619
27870
|
// src/store/doc-translation-store.ts
|
|
27620
27871
|
async function getDocTranslation(channelId, sourcePath, lang, contentHash) {
|
|
27621
27872
|
const { data, error } = await getSupabaseClient().from("doc_translations").select("title, content").eq("channel_id", channelId).eq("source_path", sourcePath).eq("lang", lang).eq("content_hash", contentHash).maybeSingle();
|
|
@@ -27682,6 +27933,8 @@ function rowToShare(row) {
|
|
|
27682
27933
|
translationEnabled: row["translation_enabled"] === true,
|
|
27683
27934
|
translationLangs: Array.isArray(row["translation_langs"]) ? row["translation_langs"] : [],
|
|
27684
27935
|
sourceLang: row["source_lang"] ?? null,
|
|
27936
|
+
// `not null default true`: only an explicit false turns it off.
|
|
27937
|
+
autoUpdate: row["auto_update"] !== false,
|
|
27685
27938
|
audioKey: row["audio_key"] ?? null,
|
|
27686
27939
|
audioStatus: row["audio_status"] ?? null,
|
|
27687
27940
|
audioHash: row["audio_hash"] ?? null,
|
|
@@ -27721,7 +27974,22 @@ async function setDocShareSlug(id, slug) {
|
|
|
27721
27974
|
if (error) throw new Error(`setDocShareSlug(${id}): ${error.message}`);
|
|
27722
27975
|
return data ? rowToShare(data) : null;
|
|
27723
27976
|
}
|
|
27724
|
-
|
|
27977
|
+
async function setDocShareAutoUpdate(id, autoUpdate) {
|
|
27978
|
+
const { data, error } = await getSupabaseClient().from("doc_shares").update({ auto_update: autoUpdate }).eq("id", id).is("revoked_at", null).select("*").maybeSingle();
|
|
27979
|
+
if (error) throw new Error(`setDocShareAutoUpdate(${id}): ${error.message}`);
|
|
27980
|
+
return data ? rowToShare(data) : null;
|
|
27981
|
+
}
|
|
27982
|
+
async function listAutoUpdateDocShares(profiles) {
|
|
27983
|
+
let query = getSupabaseClient().from("doc_shares").select("channel_id, source_path").eq("auto_update", true).is("revoked_at", null);
|
|
27984
|
+
if (profiles !== null) query = query.in("profile", profiles);
|
|
27985
|
+
const { data, error } = await query;
|
|
27986
|
+
if (error) throw new Error(`listAutoUpdateDocShares: ${error.message}`);
|
|
27987
|
+
return (data ?? []).map((row) => ({
|
|
27988
|
+
channelId: row["channel_id"],
|
|
27989
|
+
sourcePath: row["source_path"]
|
|
27990
|
+
}));
|
|
27991
|
+
}
|
|
27992
|
+
var SUMMARY_COLUMNS = "id, slug, tags, profile, channel_id, source_path, title, kind, created_by, created_at, updated_at, audio_enabled, ask_enabled, social_enabled, branding_enabled, translation_enabled, translation_langs, auto_update, audio_status";
|
|
27725
27993
|
function rowToSummary(row) {
|
|
27726
27994
|
return {
|
|
27727
27995
|
id: row["id"],
|
|
@@ -27740,6 +28008,7 @@ function rowToSummary(row) {
|
|
|
27740
28008
|
askEnabled: row["ask_enabled"] !== false,
|
|
27741
28009
|
socialEnabled: row["social_enabled"] === true,
|
|
27742
28010
|
brandingEnabled: row["branding_enabled"] !== false,
|
|
28011
|
+
autoUpdate: row["auto_update"] !== false,
|
|
27743
28012
|
translationEnabled: row["translation_enabled"] === true,
|
|
27744
28013
|
translationLangs: Array.isArray(row["translation_langs"]) ? row["translation_langs"] : [],
|
|
27745
28014
|
audioStatus: row["audio_status"] ?? null
|
|
@@ -28902,7 +29171,7 @@ function createFeatureFlagsRouter() {
|
|
|
28902
29171
|
}
|
|
28903
29172
|
|
|
28904
29173
|
// ../api/src/dashboard/public-share-routes.ts
|
|
28905
|
-
import { existsSync as existsSync19, readFileSync as
|
|
29174
|
+
import { existsSync as existsSync19, readFileSync as readFileSync16, statSync as statSync8 } from "fs";
|
|
28906
29175
|
import { join as join20 } from "path";
|
|
28907
29176
|
import { Hono as Hono3 } from "hono";
|
|
28908
29177
|
import { GetObjectCommand as GetObjectCommand3 } from "@aws-sdk/client-s3";
|
|
@@ -29110,7 +29379,7 @@ function injectShareHead(html, head) {
|
|
|
29110
29379
|
|
|
29111
29380
|
// ../api/src/dashboard/app-icon.ts
|
|
29112
29381
|
import { createHash as createHash9 } from "crypto";
|
|
29113
|
-
import { existsSync as existsSync18, readFileSync as
|
|
29382
|
+
import { existsSync as existsSync18, readFileSync as readFileSync15 } from "fs";
|
|
29114
29383
|
import { join as join19 } from "path";
|
|
29115
29384
|
import sharp3 from "sharp";
|
|
29116
29385
|
var PLATE = "#0A0A0F";
|
|
@@ -29139,7 +29408,7 @@ function roundedPlate(size, fill = PLATE) {
|
|
|
29139
29408
|
}
|
|
29140
29409
|
async function renderBadge(box) {
|
|
29141
29410
|
const transparent = { r: 0, g: 0, b: 0, alpha: 0 };
|
|
29142
|
-
const raster = await sharp3(
|
|
29411
|
+
const raster = await sharp3(readFileSync15(MARK_SVG_FILE)).resize(512, 512, { fit: "contain", background: transparent }).png().toBuffer();
|
|
29143
29412
|
return sharp3(raster).trim().resize(box, box, { fit: "contain", background: transparent }).png().toBuffer();
|
|
29144
29413
|
}
|
|
29145
29414
|
async function sampleBackground(logo) {
|
|
@@ -29194,7 +29463,7 @@ async function renderAppIcon({
|
|
|
29194
29463
|
if (hit) return hit;
|
|
29195
29464
|
const out = logo && await composeIcon(logo, size, maskable, plain).catch(() => null) || // No workspace logo to lead with — the stock mark is still the best icon,
|
|
29196
29465
|
// either on its usual dark plate or, for a favicon, trimmed and bare.
|
|
29197
|
-
(transparent ? await renderBadge(size) : await sharp3(
|
|
29466
|
+
(transparent ? await renderBadge(size) : await sharp3(readFileSync15(MARK_FILE)).resize(size, size, { fit: "cover" }).png().toBuffer());
|
|
29198
29467
|
cache4.set(key, out);
|
|
29199
29468
|
return out;
|
|
29200
29469
|
}
|
|
@@ -29731,9 +30000,9 @@ function createPublicShareApiRouter() {
|
|
|
29731
30000
|
var BUILD_PREFIX = "/share/_assets";
|
|
29732
30001
|
var shellCache = null;
|
|
29733
30002
|
function readShell(path) {
|
|
29734
|
-
const { mtimeMs } =
|
|
30003
|
+
const { mtimeMs } = statSync8(path);
|
|
29735
30004
|
if (shellCache?.mtimeMs === mtimeMs) return shellCache.html;
|
|
29736
|
-
const html =
|
|
30005
|
+
const html = readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
|
|
29737
30006
|
shellCache = { mtimeMs, html };
|
|
29738
30007
|
return html;
|
|
29739
30008
|
}
|
|
@@ -29758,12 +30027,12 @@ function serveBuildFile(c, webDist, dir, name) {
|
|
|
29758
30027
|
c.header("Content-Type", type);
|
|
29759
30028
|
c.header("Cache-Control", "public, max-age=31536000, immutable");
|
|
29760
30029
|
if (ext === ".css") {
|
|
29761
|
-
return c.body(
|
|
30030
|
+
return c.body(readFileSync16(path, "utf8").replaceAll("url(/fonts/", `url(${BUILD_PREFIX}/fonts/`));
|
|
29762
30031
|
}
|
|
29763
30032
|
if (ext === ".js") {
|
|
29764
|
-
return c.body(
|
|
30033
|
+
return c.body(readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`));
|
|
29765
30034
|
}
|
|
29766
|
-
return c.body(new Uint8Array(
|
|
30035
|
+
return c.body(new Uint8Array(readFileSync16(path)));
|
|
29767
30036
|
}
|
|
29768
30037
|
var HTML_SHARE_CSP = "sandbox allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox";
|
|
29769
30038
|
function servePublishedHtml(c, share) {
|
|
@@ -29961,7 +30230,7 @@ ${analytics}` : head);
|
|
|
29961
30230
|
}
|
|
29962
30231
|
|
|
29963
30232
|
// src/dashboard/artifact-export.ts
|
|
29964
|
-
import { readFileSync as
|
|
30233
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
29965
30234
|
async function exportDocAsArtifact(channelId, docPath) {
|
|
29966
30235
|
const owningProfile = findOwningProfile(channelId);
|
|
29967
30236
|
const channelConfig = await runWithProfile(
|
|
@@ -29970,7 +30239,7 @@ async function exportDocAsArtifact(channelId, docPath) {
|
|
|
29970
30239
|
);
|
|
29971
30240
|
const abs = resolveDocPath(channelConfig.cwd, docPath);
|
|
29972
30241
|
if (!abs) throw new Error(`doc not found: ${docPath}`);
|
|
29973
|
-
const content =
|
|
30242
|
+
const content = readFileSync17(abs, "utf8");
|
|
29974
30243
|
const title = extractTitle(abs, "md");
|
|
29975
30244
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
29976
30245
|
const prompt = `Publish the document at \`${docPath}\` (already read below) as a Claude Artifact, then record the result as a stub file under this channel's \`docs/artifacts/\` folder (create the folder if it doesn't exist).
|
|
@@ -30084,7 +30353,7 @@ var CODE_EXTENSIONS = {
|
|
|
30084
30353
|
".gql": "graphql"
|
|
30085
30354
|
};
|
|
30086
30355
|
function highlightLanguageOf(path) {
|
|
30087
|
-
const ext =
|
|
30356
|
+
const ext = extname3(path).toLowerCase();
|
|
30088
30357
|
const doc = DOC_EXTENSIONS[ext];
|
|
30089
30358
|
if (doc) return doc === "md" ? "markdown" : doc === "excalidraw" ? "json" : "xml";
|
|
30090
30359
|
return CODE_EXTENSIONS[ext] ?? null;
|
|
@@ -30117,7 +30386,7 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
30117
30386
|
var MAX_ENTRIES = 500;
|
|
30118
30387
|
var MAX_SEARCH_DEPTH = 6;
|
|
30119
30388
|
var MAX_FLAT_DOCS = 2e3;
|
|
30120
|
-
var
|
|
30389
|
+
var MAX_CONTENT_BYTES2 = 2 * 1024 * 1024;
|
|
30121
30390
|
var TITLE_SCAN_BYTES = 8 * 1024;
|
|
30122
30391
|
function byMtime(sort) {
|
|
30123
30392
|
return (a, b) => {
|
|
@@ -30132,7 +30401,7 @@ function entryKind(entry, abs) {
|
|
|
30132
30401
|
if (entry.isFile()) return "file";
|
|
30133
30402
|
if (!entry.isSymbolicLink()) return null;
|
|
30134
30403
|
try {
|
|
30135
|
-
const target =
|
|
30404
|
+
const target = statSync9(abs);
|
|
30136
30405
|
return target.isDirectory() ? "dir" : target.isFile() ? "file" : null;
|
|
30137
30406
|
} catch {
|
|
30138
30407
|
return null;
|
|
@@ -30140,12 +30409,12 @@ function entryKind(entry, abs) {
|
|
|
30140
30409
|
}
|
|
30141
30410
|
function fileNode(root, abs, name) {
|
|
30142
30411
|
if (!isListableFile(name)) return null;
|
|
30143
|
-
const ext =
|
|
30412
|
+
const ext = extname3(name).toLowerCase();
|
|
30144
30413
|
const kind = DOC_EXTENSIONS[ext];
|
|
30145
30414
|
const lang = CODE_EXTENSIONS[ext];
|
|
30146
30415
|
let stat;
|
|
30147
30416
|
try {
|
|
30148
|
-
stat =
|
|
30417
|
+
stat = statSync9(abs);
|
|
30149
30418
|
} catch {
|
|
30150
30419
|
return null;
|
|
30151
30420
|
}
|
|
@@ -30208,7 +30477,7 @@ function resolveDirPath(root, rel) {
|
|
|
30208
30477
|
}
|
|
30209
30478
|
function isListableFile(name) {
|
|
30210
30479
|
if (SKIP_FILES.has(name)) return false;
|
|
30211
|
-
const ext =
|
|
30480
|
+
const ext = extname3(name).toLowerCase();
|
|
30212
30481
|
return ext in DOC_EXTENSIONS || ext in CODE_EXTENSIONS || ASSET_LIST_EXTENSIONS.has(ext);
|
|
30213
30482
|
}
|
|
30214
30483
|
var HAS_DOCS_BUDGET = 4e3;
|
|
@@ -30251,13 +30520,13 @@ function probeDir(absDir, showHidden) {
|
|
|
30251
30520
|
function readGitBranch(dir) {
|
|
30252
30521
|
try {
|
|
30253
30522
|
let gitDir = join21(dir, ".git");
|
|
30254
|
-
if (
|
|
30255
|
-
const pointer =
|
|
30523
|
+
if (statSync9(gitDir).isFile()) {
|
|
30524
|
+
const pointer = readFileSync18(gitDir, "utf8").trim();
|
|
30256
30525
|
const match = pointer.match(/^gitdir:\s*(.+)$/);
|
|
30257
30526
|
if (!match) return void 0;
|
|
30258
30527
|
gitDir = resolve7(dir, match[1]);
|
|
30259
30528
|
}
|
|
30260
|
-
const head =
|
|
30529
|
+
const head = readFileSync18(join21(gitDir, "HEAD"), "utf8").trim();
|
|
30261
30530
|
const branchMatch = head.match(/^ref:\s*refs\/heads\/(.+)$/);
|
|
30262
30531
|
if (branchMatch) return branchMatch[1];
|
|
30263
30532
|
return /^[0-9a-f]{7,40}$/i.test(head) ? head.slice(0, 7) : void 0;
|
|
@@ -30344,7 +30613,7 @@ function resolveDocPath(root, rel) {
|
|
|
30344
30613
|
if (!rel || rel.includes("\0")) return null;
|
|
30345
30614
|
const abs = resolve7(root, rel);
|
|
30346
30615
|
if (abs !== root && !abs.startsWith(root + sep4)) return null;
|
|
30347
|
-
const ext =
|
|
30616
|
+
const ext = extname3(abs).toLowerCase();
|
|
30348
30617
|
if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return null;
|
|
30349
30618
|
return abs;
|
|
30350
30619
|
}
|
|
@@ -30353,7 +30622,7 @@ function writeDocContent(root, rel, content, baseMtime) {
|
|
|
30353
30622
|
if (!abs) return { status: "not-found" };
|
|
30354
30623
|
let stat;
|
|
30355
30624
|
try {
|
|
30356
|
-
stat =
|
|
30625
|
+
stat = statSync9(abs);
|
|
30357
30626
|
} catch {
|
|
30358
30627
|
return { status: "not-found" };
|
|
30359
30628
|
}
|
|
@@ -30361,17 +30630,17 @@ function writeDocContent(root, rel, content, baseMtime) {
|
|
|
30361
30630
|
if (baseMtime && stat.mtime.toISOString() !== baseMtime) {
|
|
30362
30631
|
return { status: "conflict", mtime: stat.mtime.toISOString() };
|
|
30363
30632
|
}
|
|
30364
|
-
if (Buffer.byteLength(content, "utf8") >
|
|
30633
|
+
if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES2) {
|
|
30365
30634
|
return { status: "too-large" };
|
|
30366
30635
|
}
|
|
30367
30636
|
writeFileSync7(abs, content, "utf8");
|
|
30368
|
-
return { status: "ok", mtime:
|
|
30637
|
+
return { status: "ok", mtime: statSync9(abs).mtime.toISOString() };
|
|
30369
30638
|
}
|
|
30370
30639
|
function resolveRawPath(root, rel) {
|
|
30371
30640
|
if (!rel || rel.includes("\0")) return null;
|
|
30372
30641
|
const abs = resolve7(root, rel);
|
|
30373
30642
|
if (abs !== root && !abs.startsWith(root + sep4)) return null;
|
|
30374
|
-
const contentType = MEDIA_EXTENSIONS[
|
|
30643
|
+
const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()];
|
|
30375
30644
|
if (!contentType) return null;
|
|
30376
30645
|
return { abs, contentType };
|
|
30377
30646
|
}
|
|
@@ -30379,7 +30648,7 @@ function resolveHtmlPath(root, rel) {
|
|
|
30379
30648
|
if (!rel || rel.includes("\0")) return null;
|
|
30380
30649
|
const abs = resolve7(root, rel);
|
|
30381
30650
|
if (abs !== root && !abs.startsWith(root + sep4)) return null;
|
|
30382
|
-
if (DOC_EXTENSIONS[
|
|
30651
|
+
if (DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "html") return null;
|
|
30383
30652
|
return abs;
|
|
30384
30653
|
}
|
|
30385
30654
|
function resolveDownloadPath(root, rel) {
|
|
@@ -30387,7 +30656,7 @@ function resolveDownloadPath(root, rel) {
|
|
|
30387
30656
|
const abs = resolve7(root, rel);
|
|
30388
30657
|
if (abs !== root && !abs.startsWith(root + sep4)) return null;
|
|
30389
30658
|
if (!isListableFile(basename6(abs))) return null;
|
|
30390
|
-
const contentType = MEDIA_EXTENSIONS[
|
|
30659
|
+
const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()] ?? "application/octet-stream";
|
|
30391
30660
|
return { abs, contentType };
|
|
30392
30661
|
}
|
|
30393
30662
|
function sanitizeUploadName(name) {
|
|
@@ -30397,12 +30666,12 @@ function sanitizeUploadName(name) {
|
|
|
30397
30666
|
return cleaned.slice(-120);
|
|
30398
30667
|
}
|
|
30399
30668
|
function uniqueName(absDir, name) {
|
|
30400
|
-
const ext =
|
|
30669
|
+
const ext = extname3(name);
|
|
30401
30670
|
const stem = name.slice(0, name.length - ext.length);
|
|
30402
30671
|
let candidate = name;
|
|
30403
30672
|
for (let n = 1; n < 1e3; n++) {
|
|
30404
30673
|
try {
|
|
30405
|
-
|
|
30674
|
+
statSync9(join21(absDir, candidate));
|
|
30406
30675
|
} catch {
|
|
30407
30676
|
return candidate;
|
|
30408
30677
|
}
|
|
@@ -30414,13 +30683,13 @@ function saveUploadedFile(root, relDir, name, data) {
|
|
|
30414
30683
|
const absDir = resolveDirPath(root, relDir);
|
|
30415
30684
|
if (absDir === null) return { status: "no-dir" };
|
|
30416
30685
|
try {
|
|
30417
|
-
if (!
|
|
30686
|
+
if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
|
|
30418
30687
|
} catch {
|
|
30419
30688
|
return { status: "no-dir" };
|
|
30420
30689
|
}
|
|
30421
30690
|
const safe = sanitizeUploadName(name);
|
|
30422
30691
|
if (!safe) return { status: "bad-name" };
|
|
30423
|
-
const ext =
|
|
30692
|
+
const ext = extname3(safe).toLowerCase();
|
|
30424
30693
|
if (!(ext in DOC_EXTENSIONS) && !ASSET_LIST_EXTENSIONS.has(ext)) return { status: "bad-type" };
|
|
30425
30694
|
if (data.byteLength > MAX_UPLOAD_BYTES) return { status: "too-large" };
|
|
30426
30695
|
const final = uniqueName(absDir, safe);
|
|
@@ -30432,7 +30701,7 @@ function createDocFolder(root, relDir, name) {
|
|
|
30432
30701
|
const absDir = resolveDirPath(root, relDir);
|
|
30433
30702
|
if (absDir === null) return { status: "no-dir" };
|
|
30434
30703
|
try {
|
|
30435
|
-
if (!
|
|
30704
|
+
if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
|
|
30436
30705
|
} catch {
|
|
30437
30706
|
return { status: "no-dir" };
|
|
30438
30707
|
}
|
|
@@ -30440,7 +30709,7 @@ function createDocFolder(root, relDir, name) {
|
|
|
30440
30709
|
if (!safe) return { status: "bad-name" };
|
|
30441
30710
|
const abs = join21(absDir, safe);
|
|
30442
30711
|
try {
|
|
30443
|
-
|
|
30712
|
+
statSync9(abs);
|
|
30444
30713
|
return { status: "exists" };
|
|
30445
30714
|
} catch {
|
|
30446
30715
|
}
|
|
@@ -30451,16 +30720,16 @@ function createDocFile(root, relDir, name, content) {
|
|
|
30451
30720
|
const absDir = resolveDirPath(root, relDir);
|
|
30452
30721
|
if (absDir === null) return { status: "no-dir" };
|
|
30453
30722
|
try {
|
|
30454
|
-
if (!
|
|
30723
|
+
if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
|
|
30455
30724
|
} catch {
|
|
30456
30725
|
return { status: "no-dir" };
|
|
30457
30726
|
}
|
|
30458
30727
|
const safe = sanitizeUploadName(name);
|
|
30459
30728
|
if (!safe) return { status: "bad-name" };
|
|
30460
|
-
const ext =
|
|
30729
|
+
const ext = extname3(safe).toLowerCase();
|
|
30461
30730
|
if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return { status: "bad-name" };
|
|
30462
30731
|
if (SKIP_FILES.has(safe)) return { status: "bad-name" };
|
|
30463
|
-
if (Buffer.byteLength(content, "utf8") >
|
|
30732
|
+
if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES2) return { status: "too-large" };
|
|
30464
30733
|
const abs = join21(absDir, safe);
|
|
30465
30734
|
try {
|
|
30466
30735
|
writeFileSync7(abs, content, { encoding: "utf8", flag: "wx" });
|
|
@@ -30476,7 +30745,7 @@ function moveDocEntry(root, from, to) {
|
|
|
30476
30745
|
if (!absFrom.startsWith(root + sep4)) return { status: "not-found" };
|
|
30477
30746
|
let stat;
|
|
30478
30747
|
try {
|
|
30479
|
-
stat =
|
|
30748
|
+
stat = statSync9(absFrom);
|
|
30480
30749
|
} catch {
|
|
30481
30750
|
return { status: "not-found" };
|
|
30482
30751
|
}
|
|
@@ -30487,7 +30756,7 @@ function moveDocEntry(root, from, to) {
|
|
|
30487
30756
|
const name = sanitizeUploadName(basename6(absTo));
|
|
30488
30757
|
if (!name) return { status: "bad-target" };
|
|
30489
30758
|
if (!isDir) {
|
|
30490
|
-
const ext =
|
|
30759
|
+
const ext = extname3(name).toLowerCase();
|
|
30491
30760
|
if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS) && !ASSET_LIST_EXTENSIONS.has(ext)) {
|
|
30492
30761
|
return { status: "bad-target" };
|
|
30493
30762
|
}
|
|
@@ -30495,7 +30764,7 @@ function moveDocEntry(root, from, to) {
|
|
|
30495
30764
|
const absToDir = dirname3(absTo);
|
|
30496
30765
|
if (resolveDirPath(root, relative2(root, absToDir)) === null) return { status: "bad-target" };
|
|
30497
30766
|
try {
|
|
30498
|
-
if (!
|
|
30767
|
+
if (!statSync9(absToDir).isDirectory()) return { status: "bad-target" };
|
|
30499
30768
|
} catch {
|
|
30500
30769
|
return { status: "bad-target" };
|
|
30501
30770
|
}
|
|
@@ -30555,7 +30824,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30555
30824
|
if (!resolved2) return c.json({ error: "not found" }, 404);
|
|
30556
30825
|
let stat;
|
|
30557
30826
|
try {
|
|
30558
|
-
stat =
|
|
30827
|
+
stat = statSync9(resolved2.abs);
|
|
30559
30828
|
} catch {
|
|
30560
30829
|
return c.json({ error: "not found" }, 404);
|
|
30561
30830
|
}
|
|
@@ -30577,13 +30846,14 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30577
30846
|
if (!abs) return c.json({ error: "not found" }, 404);
|
|
30578
30847
|
let stat;
|
|
30579
30848
|
try {
|
|
30580
|
-
stat =
|
|
30849
|
+
stat = statSync9(abs);
|
|
30581
30850
|
} catch {
|
|
30582
30851
|
return c.json({ error: "not found" }, 404);
|
|
30583
30852
|
}
|
|
30584
30853
|
if (!stat.isFile()) return c.json({ error: "not found" }, 404);
|
|
30585
30854
|
if (stat.size > MAX_RAW_BYTES) return c.json({ error: "file too large" }, 413);
|
|
30586
|
-
|
|
30855
|
+
const html = inlinePreviewImages(cwd, c.req.query("path") ?? "", readFileSync18(abs, "utf8"));
|
|
30856
|
+
return c.body(withDocLinkBridge(html), 200, {
|
|
30587
30857
|
"Content-Type": "text/html; charset=utf-8",
|
|
30588
30858
|
"Content-Security-Policy": HTML_SHARE_CSP,
|
|
30589
30859
|
"X-Content-Type-Options": "nosniff",
|
|
@@ -30701,11 +30971,11 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30701
30971
|
if (!abs) return c.json({ error: "not found" }, 404);
|
|
30702
30972
|
let stat;
|
|
30703
30973
|
try {
|
|
30704
|
-
stat =
|
|
30974
|
+
stat = statSync9(abs);
|
|
30705
30975
|
} catch {
|
|
30706
30976
|
return c.json({ error: "not found" }, 404);
|
|
30707
30977
|
}
|
|
30708
|
-
if (!stat.isFile() || DOC_EXTENSIONS[
|
|
30978
|
+
if (!stat.isFile() || DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "md") {
|
|
30709
30979
|
return c.json({ error: "not a markdown doc" }, 400);
|
|
30710
30980
|
}
|
|
30711
30981
|
void exportDocAsArtifact(channelId, rel).catch((err) => {
|
|
@@ -30750,14 +31020,14 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30750
31020
|
if (!abs) return c.json({ error: "not found" }, 404);
|
|
30751
31021
|
let stat;
|
|
30752
31022
|
try {
|
|
30753
|
-
stat =
|
|
31023
|
+
stat = statSync9(abs);
|
|
30754
31024
|
} catch {
|
|
30755
31025
|
return c.json({ error: "not found" }, 404);
|
|
30756
31026
|
}
|
|
30757
31027
|
if (!stat.isFile()) return c.json({ error: "not found" }, 404);
|
|
30758
|
-
const ext =
|
|
31028
|
+
const ext = extname3(abs).toLowerCase();
|
|
30759
31029
|
const kind = DOC_EXTENSIONS[ext];
|
|
30760
|
-
const tooLarge = stat.size >
|
|
31030
|
+
const tooLarge = stat.size > MAX_CONTENT_BYTES2;
|
|
30761
31031
|
if (tooLarge && kind !== "html") return c.json({ error: "file too large" }, 413);
|
|
30762
31032
|
return c.json({
|
|
30763
31033
|
path: rel,
|
|
@@ -30768,7 +31038,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30768
31038
|
title: kind ? extractTitle(abs, kind) : basename6(abs),
|
|
30769
31039
|
mtime: stat.mtime.toISOString(),
|
|
30770
31040
|
tooLarge: tooLarge || void 0,
|
|
30771
|
-
content: tooLarge ? "" :
|
|
31041
|
+
content: tooLarge ? "" : readFileSync18(abs, "utf8")
|
|
30772
31042
|
});
|
|
30773
31043
|
});
|
|
30774
31044
|
app.put("/:id/docs/content", async (c) => {
|
|
@@ -30796,22 +31066,22 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30796
31066
|
if (!channel) return { error: c.json({ error: "channel not found" }, 404) };
|
|
30797
31067
|
const rel = c.req.query("path") ?? "";
|
|
30798
31068
|
const abs = resolveDocPath(channel.cwd, rel);
|
|
30799
|
-
if (!abs || DOC_EXTENSIONS[
|
|
31069
|
+
if (!abs || DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "md") {
|
|
30800
31070
|
return { error: c.json({ error: "not found" }, 404) };
|
|
30801
31071
|
}
|
|
30802
31072
|
let stat;
|
|
30803
31073
|
try {
|
|
30804
|
-
stat =
|
|
31074
|
+
stat = statSync9(abs);
|
|
30805
31075
|
} catch {
|
|
30806
31076
|
return { error: c.json({ error: "not found" }, 404) };
|
|
30807
31077
|
}
|
|
30808
31078
|
if (!stat.isFile()) return { error: c.json({ error: "not found" }, 404) };
|
|
30809
|
-
if (stat.size >
|
|
31079
|
+
if (stat.size > MAX_CONTENT_BYTES2) return { error: c.json({ error: "file too large" }, 413) };
|
|
30810
31080
|
return {
|
|
30811
31081
|
channel,
|
|
30812
31082
|
rel,
|
|
30813
31083
|
title: extractTitle(abs, "md"),
|
|
30814
|
-
content:
|
|
31084
|
+
content: readFileSync18(abs, "utf8")
|
|
30815
31085
|
};
|
|
30816
31086
|
};
|
|
30817
31087
|
app.get("/:id/docs/translation/:lang", async (c) => {
|
|
@@ -30871,7 +31141,7 @@ function isRealDoc(root, rel) {
|
|
|
30871
31141
|
const abs = resolveDocPath(root, rel);
|
|
30872
31142
|
if (!abs || !existsSync21(abs)) return false;
|
|
30873
31143
|
try {
|
|
30874
|
-
return
|
|
31144
|
+
return statSync10(abs).isFile();
|
|
30875
31145
|
} catch {
|
|
30876
31146
|
return false;
|
|
30877
31147
|
}
|
|
@@ -30924,6 +31194,82 @@ function slackMrkdwnToMarkdown(text) {
|
|
|
30924
31194
|
return resolveSlackTokens(text).replace(/(?<![\w*])\*(?!\*)(\S(?:[^*\n]*?\S)?)\*(?!\*)(?![\w*])/g, "**$1**").replace(/(?<![\w~])~(?!~)(\S(?:[^~\n]*?\S)?)~(?!~)(?![\w~])/g, "~~$1~~").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
30925
31195
|
}
|
|
30926
31196
|
|
|
31197
|
+
// ../api/src/dashboard/support-guide.ts
|
|
31198
|
+
var GUIDE_ANCHORS = {
|
|
31199
|
+
"sidebar.add-channel": 'any /chat page: "+" next to Channels, creates a channel or category',
|
|
31200
|
+
"header.workspace-switcher": "any page: switch or create a workspace",
|
|
31201
|
+
"header.settings": "any page: opens workspace settings",
|
|
31202
|
+
"header.account": "any page: account menu (profile, theme, log out)",
|
|
31203
|
+
"thread.new": "any /chat page: start a new thread (topic)",
|
|
31204
|
+
"thread.status": "open thread: set the thread status",
|
|
31205
|
+
"channel.docs": "channel page: open this channel's docs",
|
|
31206
|
+
"composer.send": "message composer: send",
|
|
31207
|
+
"composer.attach": "message composer: attach a file",
|
|
31208
|
+
"composer.dictate": "message composer: dictate by voice",
|
|
31209
|
+
"composer.model": "message composer: pick the agent model and effort",
|
|
31210
|
+
"docs.upload": "docs pane: upload files to the channel folder",
|
|
31211
|
+
"docs.new-doc": "docs pane: new doc in the channel folder",
|
|
31212
|
+
"members.invite": "/settings/members: invite a member by email (admins only)"
|
|
31213
|
+
};
|
|
31214
|
+
var SETTINGS_SECTIONS = [
|
|
31215
|
+
"general",
|
|
31216
|
+
"agent",
|
|
31217
|
+
"prompt",
|
|
31218
|
+
"models",
|
|
31219
|
+
"labs",
|
|
31220
|
+
"auto-topic",
|
|
31221
|
+
"output-styles",
|
|
31222
|
+
"skills",
|
|
31223
|
+
"memory",
|
|
31224
|
+
"members",
|
|
31225
|
+
"connections",
|
|
31226
|
+
"automations",
|
|
31227
|
+
"activity",
|
|
31228
|
+
"channels",
|
|
31229
|
+
"domain",
|
|
31230
|
+
"workspaces",
|
|
31231
|
+
"usage",
|
|
31232
|
+
"sessions",
|
|
31233
|
+
"mcp-servers",
|
|
31234
|
+
"logs"
|
|
31235
|
+
];
|
|
31236
|
+
for (const s of SETTINGS_SECTIONS) GUIDE_ANCHORS[`settings.${s}`] = `/settings/*: the ${s} tab`;
|
|
31237
|
+
var GUIDE_ROUTES = {
|
|
31238
|
+
"/chat": "chat home, channel list",
|
|
31239
|
+
"/chat/threads": "all threads in the workspace",
|
|
31240
|
+
"/chat/search": "search",
|
|
31241
|
+
"/chat/archive": "archived threads",
|
|
31242
|
+
"/chat/docs": "shared doc links",
|
|
31243
|
+
...Object.fromEntries(SETTINGS_SECTIONS.map((s) => [`/settings/${s}`, `settings: ${s}`]))
|
|
31244
|
+
};
|
|
31245
|
+
var GUIDE_RULES = `
|
|
31246
|
+
On-screen guide: whenever the answer tells the user where to click or which page to open and a route or anchor below matches, end your reply with one line:
|
|
31247
|
+
<guide>{"navigate": <route or null>, "steps": [{"action": "guide" | "highlight", "anchor": "<anchor id>", "say": "<a few words>"}]}</guide>
|
|
31248
|
+
- navigate: a route from the list below to open first, or null to stay on the current page. The steps then run on that page, so never point at the button that leads to it.
|
|
31249
|
+
- steps: at most 3, in order, anchors from the list only, never invented. "guide" waits for the user to click it; use "highlight" for the last step when it only shows where something is. "say" uses the reply's language.
|
|
31250
|
+
- Leave the guide out when nothing below fits. Never mention the guide or anchor ids in the answer text.
|
|
31251
|
+
Routes:
|
|
31252
|
+
${Object.entries(GUIDE_ROUTES).map(([r, d]) => `- ${r}: ${d}`).join("\n")}
|
|
31253
|
+
Anchors:
|
|
31254
|
+
${Object.entries(GUIDE_ANCHORS).map(([a, d]) => `- ${a}: ${d}`).join("\n")}
|
|
31255
|
+
`;
|
|
31256
|
+
var GUIDE_RE = /<guide>([\s\S]*?)<\/guide>/;
|
|
31257
|
+
function extractGuide(text) {
|
|
31258
|
+
const match = text.match(GUIDE_RE);
|
|
31259
|
+
if (!match) return { answer: text, guide: null };
|
|
31260
|
+
const answer = text.replace(match[0], "").trim();
|
|
31261
|
+
try {
|
|
31262
|
+
const raw = JSON.parse(match[1]);
|
|
31263
|
+
const navigate = typeof raw.navigate === "string" && raw.navigate in GUIDE_ROUTES ? raw.navigate : null;
|
|
31264
|
+
const steps = (Array.isArray(raw.steps) ? raw.steps : []).filter(
|
|
31265
|
+
(s) => !!s && (s.action === "guide" || s.action === "highlight") && typeof s.anchor === "string" && s.anchor in GUIDE_ANCHORS && typeof s.say === "string"
|
|
31266
|
+
).slice(0, 3).map(({ action, anchor, say }) => ({ action, anchor, say: say.slice(0, 200) }));
|
|
31267
|
+
return { answer, guide: navigate || steps.length ? { navigate, steps } : null };
|
|
31268
|
+
} catch {
|
|
31269
|
+
return { answer, guide: null };
|
|
31270
|
+
}
|
|
31271
|
+
}
|
|
31272
|
+
|
|
30927
31273
|
// ../api/src/dashboard/support-bot.ts
|
|
30928
31274
|
var GROQ_API_URL7 = "https://api.groq.com/openai/v1/chat/completions";
|
|
30929
31275
|
var SUPPORT_MODEL = "openai/gpt-oss-120b";
|
|
@@ -31004,13 +31350,14 @@ async function recordEvent(row) {
|
|
|
31004
31350
|
const { error } = await getSupabaseClient().from("support_events").insert(row);
|
|
31005
31351
|
if (error) console.error("support_events insert failed:", error.message);
|
|
31006
31352
|
}
|
|
31007
|
-
async function postReply(threadId, body, offerHuman = false) {
|
|
31353
|
+
async function postReply(threadId, body, offerHuman = false, guide = null) {
|
|
31008
31354
|
const { data, error } = await getSupabaseClient().from("thread_replies").insert({
|
|
31009
31355
|
thread_id: threadId,
|
|
31010
31356
|
author: SUPPORT_BOT_AUTHOR,
|
|
31011
31357
|
author_kind: "support_bot",
|
|
31012
31358
|
body,
|
|
31013
|
-
...offerHuman ? { support_escalation: "offered" } : {}
|
|
31359
|
+
...offerHuman ? { support_escalation: "offered" } : {},
|
|
31360
|
+
...guide ? { guide } : {}
|
|
31014
31361
|
}).select("id").single();
|
|
31015
31362
|
if (error) throw new Error(`support reply insert: ${error.message}`);
|
|
31016
31363
|
return data.id;
|
|
@@ -31074,7 +31421,8 @@ async function handleSupportMention(trigger, deps = {}) {
|
|
|
31074
31421
|
// cache can reuse them; the per-thread content goes last.
|
|
31075
31422
|
messages: [
|
|
31076
31423
|
{ role: "system", content: `${RULES}${docs}
|
|
31077
|
-
</docs
|
|
31424
|
+
</docs>
|
|
31425
|
+
${GUIDE_RULES}` },
|
|
31078
31426
|
{
|
|
31079
31427
|
role: "user",
|
|
31080
31428
|
content: `<environment>
|
|
@@ -31085,7 +31433,7 @@ ${env}
|
|
|
31085
31433
|
${transcript}
|
|
31086
31434
|
</thread>
|
|
31087
31435
|
|
|
31088
|
-
Answer the latest @support mention, from ${trigger.author}.`
|
|
31436
|
+
Answer the latest @support mention, from ${trigger.author}. Add the <guide> line when the answer points at something in the UI.`
|
|
31089
31437
|
}
|
|
31090
31438
|
]
|
|
31091
31439
|
})
|
|
@@ -31093,7 +31441,8 @@ Answer the latest @support mention, from ${trigger.author}.`
|
|
|
31093
31441
|
if (!res.ok) throw new Error(`Groq ${res.status}: ${(await res.text()).slice(0, 300)}`);
|
|
31094
31442
|
const data = await res.json();
|
|
31095
31443
|
const text = (data.choices?.[0]?.message?.content ?? "").trim();
|
|
31096
|
-
const answer = text
|
|
31444
|
+
const { answer: withMarker, guide } = extractGuide(text);
|
|
31445
|
+
const answer = withMarker.replaceAll(NO_DOC_MARKER, "").trim();
|
|
31097
31446
|
const noDoc = text.includes(NO_DOC_MARKER) || citedDocs(answer).length === 0;
|
|
31098
31447
|
event = {
|
|
31099
31448
|
...event,
|
|
@@ -31105,7 +31454,12 @@ Answer the latest @support mention, from ${trigger.author}.`
|
|
|
31105
31454
|
};
|
|
31106
31455
|
if (!answer)
|
|
31107
31456
|
throw new Error(`empty answer (finish_reason ${data.choices?.[0]?.finish_reason})`);
|
|
31108
|
-
event.reply_id = await postReply(
|
|
31457
|
+
event.reply_id = await postReply(
|
|
31458
|
+
trigger.threadId,
|
|
31459
|
+
answer,
|
|
31460
|
+
noDoc || wantsHuman(trigger.body),
|
|
31461
|
+
guide
|
|
31462
|
+
);
|
|
31109
31463
|
} catch (err) {
|
|
31110
31464
|
console.error("Support bot answer failed:", err);
|
|
31111
31465
|
if (!event.reply_id) {
|
|
@@ -35237,9 +35591,14 @@ export {
|
|
|
35237
35591
|
resolveDocsAccess,
|
|
35238
35592
|
filterReadableDocsChannels,
|
|
35239
35593
|
requireDocsAccess,
|
|
35594
|
+
watchDocs,
|
|
35595
|
+
SHARE_ASSET_PLACEHOLDER,
|
|
35596
|
+
readDocShareBundle,
|
|
35240
35597
|
DocShareSlugTakenError,
|
|
35241
35598
|
isSlugAvailable,
|
|
35242
35599
|
setDocShareSlug,
|
|
35600
|
+
setDocShareAutoUpdate,
|
|
35601
|
+
listAutoUpdateDocShares,
|
|
35243
35602
|
listLiveDocShares,
|
|
35244
35603
|
findDocShareBySource,
|
|
35245
35604
|
createDocShare,
|
|
@@ -35268,11 +35627,7 @@ export {
|
|
|
35268
35627
|
clientKey,
|
|
35269
35628
|
createPublicShareApiRouter,
|
|
35270
35629
|
createPublicShareAssetRouter,
|
|
35271
|
-
highlightLanguageOf,
|
|
35272
|
-
extractTitle,
|
|
35273
35630
|
flatDocs,
|
|
35274
|
-
resolveDocPath,
|
|
35275
|
-
resolveRawPath,
|
|
35276
35631
|
createDocsRouter,
|
|
35277
35632
|
slackMrkdwnToMarkdown,
|
|
35278
35633
|
handleSupportMention,
|