flyspace-cli 0.1.62 → 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.
@@ -30,7 +30,7 @@ import {
30
30
  sweepScratchDir,
31
31
  uploadLocalImages,
32
32
  useHostDbWithoutCredentials
33
- } from "./chunk-UZMHXV4D.js";
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 extname3 = __require("path").extname;
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 = extname3("x." + path).toLowerCase().substr(1);
8889
+ var extension2 = extname4("x." + path).toLowerCase().substr(1);
8890
8890
  if (!extension2) {
8891
8891
  return false;
8892
8892
  }
@@ -20392,7 +20392,7 @@ function interpretCliOutcome(result, resumeSessionId, maxBudgetUsd, model, using
20392
20392
  }
20393
20393
  var DEFAULT_IDLE_TIMEOUT_SECONDS = 300;
20394
20394
  var DEFAULT_MAX_DURATION_SECONDS = 600;
20395
- var DEFAULT_STREAMING_MAX_DURATION_SECONDS = 1800;
20395
+ var DEFAULT_STREAMING_MAX_DURATION_SECONDS = 7200;
20396
20396
  var KILL_GRACE_MS = 1e4;
20397
20397
  function envSeconds(name, defaultSeconds) {
20398
20398
  const raw = process.env[name];
@@ -20704,6 +20704,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20704
20704
  let liveSessionId;
20705
20705
  const streamedText = [];
20706
20706
  let killedTool = false;
20707
+ let mcpNeedsAuth = [];
20707
20708
  const onLine = options.onActivity ? createLineSplitter((line) => {
20708
20709
  let event;
20709
20710
  try {
@@ -20712,6 +20713,9 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20712
20713
  return;
20713
20714
  }
20714
20715
  if (event.session_id) liveSessionId = event.session_id;
20716
+ if (event.mcp_servers) {
20717
+ mcpNeedsAuth = event.mcp_servers.filter((server) => server.status === "needs-auth" && server.name).map((server) => server.name);
20718
+ }
20715
20719
  if (event.type === "result") streamResultLine = line;
20716
20720
  if (pluginUi) {
20717
20721
  pluginUi.onEvent(event);
@@ -20823,7 +20827,11 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20823
20827
  stderrTail: stderrTail(stderr),
20824
20828
  message: (result.result ?? "").slice(0, 500)
20825
20829
  }
20826
- } : killedTool ? { ...response, killedTool } : response
20830
+ } : {
20831
+ ...response,
20832
+ ...killedTool ? { killedTool } : {},
20833
+ ...mcpNeedsAuth.length ? { mcpNeedsAuth } : {}
20834
+ }
20827
20835
  );
20828
20836
  } catch {
20829
20837
  const fallback = onLine ? "" : stdout.trim();
@@ -24648,7 +24656,8 @@ async function ownIdentityFor(client) {
24648
24656
  async function mirrorIncomingMessage(client, msg) {
24649
24657
  if (!databaseReachable()) return;
24650
24658
  if (msg.subtype && SKIP_SUBTYPES.has(msg.subtype)) return;
24651
- if (msg.subtype === "message_changed" || msg.subtype === "message_deleted") return;
24659
+ if (msg.subtype === "message_deleted") return;
24660
+ if (msg.subtype === "message_changed") return mirrorEditedMessage(client, msg);
24652
24661
  try {
24653
24662
  await ensureUsersCached(client, mentionedUserIds(msg));
24654
24663
  const body = bodyTextFor(msg);
@@ -24744,6 +24753,19 @@ async function mirrorIncomingMessage(client, msg) {
24744
24753
  );
24745
24754
  }
24746
24755
  }
24756
+ async function mirrorEditedMessage(client, msg) {
24757
+ try {
24758
+ await ensureUsersCached(client, mentionedUserIds(msg));
24759
+ const body = bodyTextFor(msg);
24760
+ if (!body) return;
24761
+ const { error } = await getSupabaseClient().from("thread_replies").update({ body }).eq("external_thread_replies_id", `${msg.channel}:${msg.ts}`);
24762
+ if (error) throw new Error(error.message);
24763
+ } catch (err) {
24764
+ console.warn(
24765
+ `[live-mirror] edit ${msg.channel}:${msg.ts}: ${err instanceof Error ? err.message : String(err)}`
24766
+ );
24767
+ }
24768
+ }
24747
24769
 
24748
24770
  // src/slack/thread-summary.ts
24749
24771
  function buildSummaryPrompt(transcript) {
@@ -25483,7 +25505,7 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
25483
25505
 
25484
25506
  // ../api/src/version.ts
25485
25507
  import { readFileSync as readFileSync8 } from "fs";
25486
- var CLI_VERSION = true ? "0.1.62" : devVersion();
25508
+ var CLI_VERSION = true ? "0.1.64" : devVersion();
25487
25509
  function isOlderVersion(a, b) {
25488
25510
  const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
25489
25511
  const [pa, pb] = [parse2(a), parse2(b)];
@@ -27394,7 +27416,7 @@ async function offloadPluginUi(workspace, state) {
27394
27416
  var pluginUiHash = (state) => sha256(JSON.stringify(state));
27395
27417
 
27396
27418
  // src/dashboard/doc-mention-guard.ts
27397
- import { existsSync as existsSync21, statSync as statSync9 } from "fs";
27419
+ import { existsSync as existsSync21, statSync as statSync10 } from "fs";
27398
27420
 
27399
27421
  // src/dashboard/docs-routes.ts
27400
27422
  import {
@@ -27406,15 +27428,15 @@ import {
27406
27428
  openSync,
27407
27429
  readSync,
27408
27430
  readdirSync as readdirSync6,
27409
- readFileSync as readFileSync17,
27431
+ readFileSync as readFileSync18,
27410
27432
  realpathSync as realpathSync2,
27411
27433
  renameSync as renameSync3,
27412
27434
  rmSync as rmSync10,
27413
- statSync as statSync8,
27435
+ statSync as statSync9,
27414
27436
  writeFileSync as writeFileSync7
27415
27437
  } from "fs";
27416
27438
  import { Readable } from "stream";
27417
- import { basename as basename6, dirname as dirname3, extname as extname2, join as join21, relative as relative2, resolve as resolve7, sep as sep4 } from "path";
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";
27418
27440
  import { Hono as Hono4 } from "hono";
27419
27441
  import { streamSSE } from "hono/streaming";
27420
27442
 
@@ -27594,6 +27616,257 @@ function closeEntry(cwd) {
27594
27616
  entry.watcher.close();
27595
27617
  }
27596
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
+
27597
27870
  // src/store/doc-translation-store.ts
27598
27871
  async function getDocTranslation(channelId, sourcePath, lang, contentHash) {
27599
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();
@@ -27660,6 +27933,8 @@ function rowToShare(row) {
27660
27933
  translationEnabled: row["translation_enabled"] === true,
27661
27934
  translationLangs: Array.isArray(row["translation_langs"]) ? row["translation_langs"] : [],
27662
27935
  sourceLang: row["source_lang"] ?? null,
27936
+ // `not null default true`: only an explicit false turns it off.
27937
+ autoUpdate: row["auto_update"] !== false,
27663
27938
  audioKey: row["audio_key"] ?? null,
27664
27939
  audioStatus: row["audio_status"] ?? null,
27665
27940
  audioHash: row["audio_hash"] ?? null,
@@ -27699,7 +27974,22 @@ async function setDocShareSlug(id, slug) {
27699
27974
  if (error) throw new Error(`setDocShareSlug(${id}): ${error.message}`);
27700
27975
  return data ? rowToShare(data) : null;
27701
27976
  }
27702
- 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, audio_status";
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";
27703
27993
  function rowToSummary(row) {
27704
27994
  return {
27705
27995
  id: row["id"],
@@ -27718,6 +28008,7 @@ function rowToSummary(row) {
27718
28008
  askEnabled: row["ask_enabled"] !== false,
27719
28009
  socialEnabled: row["social_enabled"] === true,
27720
28010
  brandingEnabled: row["branding_enabled"] !== false,
28011
+ autoUpdate: row["auto_update"] !== false,
27721
28012
  translationEnabled: row["translation_enabled"] === true,
27722
28013
  translationLangs: Array.isArray(row["translation_langs"]) ? row["translation_langs"] : [],
27723
28014
  audioStatus: row["audio_status"] ?? null
@@ -28880,7 +29171,7 @@ function createFeatureFlagsRouter() {
28880
29171
  }
28881
29172
 
28882
29173
  // ../api/src/dashboard/public-share-routes.ts
28883
- import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "fs";
29174
+ import { existsSync as existsSync19, readFileSync as readFileSync16, statSync as statSync8 } from "fs";
28884
29175
  import { join as join20 } from "path";
28885
29176
  import { Hono as Hono3 } from "hono";
28886
29177
  import { GetObjectCommand as GetObjectCommand3 } from "@aws-sdk/client-s3";
@@ -29088,7 +29379,7 @@ function injectShareHead(html, head) {
29088
29379
 
29089
29380
  // ../api/src/dashboard/app-icon.ts
29090
29381
  import { createHash as createHash9 } from "crypto";
29091
- import { existsSync as existsSync18, readFileSync as readFileSync14 } from "fs";
29382
+ import { existsSync as existsSync18, readFileSync as readFileSync15 } from "fs";
29092
29383
  import { join as join19 } from "path";
29093
29384
  import sharp3 from "sharp";
29094
29385
  var PLATE = "#0A0A0F";
@@ -29117,7 +29408,7 @@ function roundedPlate(size, fill = PLATE) {
29117
29408
  }
29118
29409
  async function renderBadge(box) {
29119
29410
  const transparent = { r: 0, g: 0, b: 0, alpha: 0 };
29120
- const raster = await sharp3(readFileSync14(MARK_SVG_FILE)).resize(512, 512, { fit: "contain", background: transparent }).png().toBuffer();
29411
+ const raster = await sharp3(readFileSync15(MARK_SVG_FILE)).resize(512, 512, { fit: "contain", background: transparent }).png().toBuffer();
29121
29412
  return sharp3(raster).trim().resize(box, box, { fit: "contain", background: transparent }).png().toBuffer();
29122
29413
  }
29123
29414
  async function sampleBackground(logo) {
@@ -29172,7 +29463,7 @@ async function renderAppIcon({
29172
29463
  if (hit) return hit;
29173
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,
29174
29465
  // either on its usual dark plate or, for a favicon, trimmed and bare.
29175
- (transparent ? await renderBadge(size) : await sharp3(readFileSync14(MARK_FILE)).resize(size, size, { fit: "cover" }).png().toBuffer());
29466
+ (transparent ? await renderBadge(size) : await sharp3(readFileSync15(MARK_FILE)).resize(size, size, { fit: "cover" }).png().toBuffer());
29176
29467
  cache4.set(key, out);
29177
29468
  return out;
29178
29469
  }
@@ -29709,9 +30000,9 @@ function createPublicShareApiRouter() {
29709
30000
  var BUILD_PREFIX = "/share/_assets";
29710
30001
  var shellCache = null;
29711
30002
  function readShell(path) {
29712
- const { mtimeMs } = statSync7(path);
30003
+ const { mtimeMs } = statSync8(path);
29713
30004
  if (shellCache?.mtimeMs === mtimeMs) return shellCache.html;
29714
- const html = readFileSync15(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
30005
+ const html = readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
29715
30006
  shellCache = { mtimeMs, html };
29716
30007
  return html;
29717
30008
  }
@@ -29736,12 +30027,12 @@ function serveBuildFile(c, webDist, dir, name) {
29736
30027
  c.header("Content-Type", type);
29737
30028
  c.header("Cache-Control", "public, max-age=31536000, immutable");
29738
30029
  if (ext === ".css") {
29739
- return c.body(readFileSync15(path, "utf8").replaceAll("url(/fonts/", `url(${BUILD_PREFIX}/fonts/`));
30030
+ return c.body(readFileSync16(path, "utf8").replaceAll("url(/fonts/", `url(${BUILD_PREFIX}/fonts/`));
29740
30031
  }
29741
30032
  if (ext === ".js") {
29742
- return c.body(readFileSync15(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`));
30033
+ return c.body(readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`));
29743
30034
  }
29744
- return c.body(new Uint8Array(readFileSync15(path)));
30035
+ return c.body(new Uint8Array(readFileSync16(path)));
29745
30036
  }
29746
30037
  var HTML_SHARE_CSP = "sandbox allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox";
29747
30038
  function servePublishedHtml(c, share) {
@@ -29939,7 +30230,7 @@ ${analytics}` : head);
29939
30230
  }
29940
30231
 
29941
30232
  // src/dashboard/artifact-export.ts
29942
- import { readFileSync as readFileSync16 } from "fs";
30233
+ import { readFileSync as readFileSync17 } from "fs";
29943
30234
  async function exportDocAsArtifact(channelId, docPath) {
29944
30235
  const owningProfile = findOwningProfile(channelId);
29945
30236
  const channelConfig = await runWithProfile(
@@ -29948,7 +30239,7 @@ async function exportDocAsArtifact(channelId, docPath) {
29948
30239
  );
29949
30240
  const abs = resolveDocPath(channelConfig.cwd, docPath);
29950
30241
  if (!abs) throw new Error(`doc not found: ${docPath}`);
29951
- const content = readFileSync16(abs, "utf8");
30242
+ const content = readFileSync17(abs, "utf8");
29952
30243
  const title = extractTitle(abs, "md");
29953
30244
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
29954
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).
@@ -30062,7 +30353,7 @@ var CODE_EXTENSIONS = {
30062
30353
  ".gql": "graphql"
30063
30354
  };
30064
30355
  function highlightLanguageOf(path) {
30065
- const ext = extname2(path).toLowerCase();
30356
+ const ext = extname3(path).toLowerCase();
30066
30357
  const doc = DOC_EXTENSIONS[ext];
30067
30358
  if (doc) return doc === "md" ? "markdown" : doc === "excalidraw" ? "json" : "xml";
30068
30359
  return CODE_EXTENSIONS[ext] ?? null;
@@ -30095,7 +30386,7 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
30095
30386
  var MAX_ENTRIES = 500;
30096
30387
  var MAX_SEARCH_DEPTH = 6;
30097
30388
  var MAX_FLAT_DOCS = 2e3;
30098
- var MAX_CONTENT_BYTES = 2 * 1024 * 1024;
30389
+ var MAX_CONTENT_BYTES2 = 2 * 1024 * 1024;
30099
30390
  var TITLE_SCAN_BYTES = 8 * 1024;
30100
30391
  function byMtime(sort) {
30101
30392
  return (a, b) => {
@@ -30110,7 +30401,7 @@ function entryKind(entry, abs) {
30110
30401
  if (entry.isFile()) return "file";
30111
30402
  if (!entry.isSymbolicLink()) return null;
30112
30403
  try {
30113
- const target = statSync8(abs);
30404
+ const target = statSync9(abs);
30114
30405
  return target.isDirectory() ? "dir" : target.isFile() ? "file" : null;
30115
30406
  } catch {
30116
30407
  return null;
@@ -30118,12 +30409,12 @@ function entryKind(entry, abs) {
30118
30409
  }
30119
30410
  function fileNode(root, abs, name) {
30120
30411
  if (!isListableFile(name)) return null;
30121
- const ext = extname2(name).toLowerCase();
30412
+ const ext = extname3(name).toLowerCase();
30122
30413
  const kind = DOC_EXTENSIONS[ext];
30123
30414
  const lang = CODE_EXTENSIONS[ext];
30124
30415
  let stat;
30125
30416
  try {
30126
- stat = statSync8(abs);
30417
+ stat = statSync9(abs);
30127
30418
  } catch {
30128
30419
  return null;
30129
30420
  }
@@ -30186,7 +30477,7 @@ function resolveDirPath(root, rel) {
30186
30477
  }
30187
30478
  function isListableFile(name) {
30188
30479
  if (SKIP_FILES.has(name)) return false;
30189
- const ext = extname2(name).toLowerCase();
30480
+ const ext = extname3(name).toLowerCase();
30190
30481
  return ext in DOC_EXTENSIONS || ext in CODE_EXTENSIONS || ASSET_LIST_EXTENSIONS.has(ext);
30191
30482
  }
30192
30483
  var HAS_DOCS_BUDGET = 4e3;
@@ -30229,13 +30520,13 @@ function probeDir(absDir, showHidden) {
30229
30520
  function readGitBranch(dir) {
30230
30521
  try {
30231
30522
  let gitDir = join21(dir, ".git");
30232
- if (statSync8(gitDir).isFile()) {
30233
- const pointer = readFileSync17(gitDir, "utf8").trim();
30523
+ if (statSync9(gitDir).isFile()) {
30524
+ const pointer = readFileSync18(gitDir, "utf8").trim();
30234
30525
  const match = pointer.match(/^gitdir:\s*(.+)$/);
30235
30526
  if (!match) return void 0;
30236
30527
  gitDir = resolve7(dir, match[1]);
30237
30528
  }
30238
- const head = readFileSync17(join21(gitDir, "HEAD"), "utf8").trim();
30529
+ const head = readFileSync18(join21(gitDir, "HEAD"), "utf8").trim();
30239
30530
  const branchMatch = head.match(/^ref:\s*refs\/heads\/(.+)$/);
30240
30531
  if (branchMatch) return branchMatch[1];
30241
30532
  return /^[0-9a-f]{7,40}$/i.test(head) ? head.slice(0, 7) : void 0;
@@ -30322,7 +30613,7 @@ function resolveDocPath(root, rel) {
30322
30613
  if (!rel || rel.includes("\0")) return null;
30323
30614
  const abs = resolve7(root, rel);
30324
30615
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30325
- const ext = extname2(abs).toLowerCase();
30616
+ const ext = extname3(abs).toLowerCase();
30326
30617
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return null;
30327
30618
  return abs;
30328
30619
  }
@@ -30331,7 +30622,7 @@ function writeDocContent(root, rel, content, baseMtime) {
30331
30622
  if (!abs) return { status: "not-found" };
30332
30623
  let stat;
30333
30624
  try {
30334
- stat = statSync8(abs);
30625
+ stat = statSync9(abs);
30335
30626
  } catch {
30336
30627
  return { status: "not-found" };
30337
30628
  }
@@ -30339,17 +30630,17 @@ function writeDocContent(root, rel, content, baseMtime) {
30339
30630
  if (baseMtime && stat.mtime.toISOString() !== baseMtime) {
30340
30631
  return { status: "conflict", mtime: stat.mtime.toISOString() };
30341
30632
  }
30342
- if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES) {
30633
+ if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES2) {
30343
30634
  return { status: "too-large" };
30344
30635
  }
30345
30636
  writeFileSync7(abs, content, "utf8");
30346
- return { status: "ok", mtime: statSync8(abs).mtime.toISOString() };
30637
+ return { status: "ok", mtime: statSync9(abs).mtime.toISOString() };
30347
30638
  }
30348
30639
  function resolveRawPath(root, rel) {
30349
30640
  if (!rel || rel.includes("\0")) return null;
30350
30641
  const abs = resolve7(root, rel);
30351
30642
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30352
- const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()];
30643
+ const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()];
30353
30644
  if (!contentType) return null;
30354
30645
  return { abs, contentType };
30355
30646
  }
@@ -30357,7 +30648,7 @@ function resolveHtmlPath(root, rel) {
30357
30648
  if (!rel || rel.includes("\0")) return null;
30358
30649
  const abs = resolve7(root, rel);
30359
30650
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30360
- if (DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "html") return null;
30651
+ if (DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "html") return null;
30361
30652
  return abs;
30362
30653
  }
30363
30654
  function resolveDownloadPath(root, rel) {
@@ -30365,7 +30656,7 @@ function resolveDownloadPath(root, rel) {
30365
30656
  const abs = resolve7(root, rel);
30366
30657
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30367
30658
  if (!isListableFile(basename6(abs))) return null;
30368
- const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()] ?? "application/octet-stream";
30659
+ const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()] ?? "application/octet-stream";
30369
30660
  return { abs, contentType };
30370
30661
  }
30371
30662
  function sanitizeUploadName(name) {
@@ -30375,12 +30666,12 @@ function sanitizeUploadName(name) {
30375
30666
  return cleaned.slice(-120);
30376
30667
  }
30377
30668
  function uniqueName(absDir, name) {
30378
- const ext = extname2(name);
30669
+ const ext = extname3(name);
30379
30670
  const stem = name.slice(0, name.length - ext.length);
30380
30671
  let candidate = name;
30381
30672
  for (let n = 1; n < 1e3; n++) {
30382
30673
  try {
30383
- statSync8(join21(absDir, candidate));
30674
+ statSync9(join21(absDir, candidate));
30384
30675
  } catch {
30385
30676
  return candidate;
30386
30677
  }
@@ -30392,13 +30683,13 @@ function saveUploadedFile(root, relDir, name, data) {
30392
30683
  const absDir = resolveDirPath(root, relDir);
30393
30684
  if (absDir === null) return { status: "no-dir" };
30394
30685
  try {
30395
- if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30686
+ if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30396
30687
  } catch {
30397
30688
  return { status: "no-dir" };
30398
30689
  }
30399
30690
  const safe = sanitizeUploadName(name);
30400
30691
  if (!safe) return { status: "bad-name" };
30401
- const ext = extname2(safe).toLowerCase();
30692
+ const ext = extname3(safe).toLowerCase();
30402
30693
  if (!(ext in DOC_EXTENSIONS) && !ASSET_LIST_EXTENSIONS.has(ext)) return { status: "bad-type" };
30403
30694
  if (data.byteLength > MAX_UPLOAD_BYTES) return { status: "too-large" };
30404
30695
  const final = uniqueName(absDir, safe);
@@ -30410,7 +30701,7 @@ function createDocFolder(root, relDir, name) {
30410
30701
  const absDir = resolveDirPath(root, relDir);
30411
30702
  if (absDir === null) return { status: "no-dir" };
30412
30703
  try {
30413
- if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30704
+ if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30414
30705
  } catch {
30415
30706
  return { status: "no-dir" };
30416
30707
  }
@@ -30418,7 +30709,7 @@ function createDocFolder(root, relDir, name) {
30418
30709
  if (!safe) return { status: "bad-name" };
30419
30710
  const abs = join21(absDir, safe);
30420
30711
  try {
30421
- statSync8(abs);
30712
+ statSync9(abs);
30422
30713
  return { status: "exists" };
30423
30714
  } catch {
30424
30715
  }
@@ -30429,16 +30720,16 @@ function createDocFile(root, relDir, name, content) {
30429
30720
  const absDir = resolveDirPath(root, relDir);
30430
30721
  if (absDir === null) return { status: "no-dir" };
30431
30722
  try {
30432
- if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30723
+ if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30433
30724
  } catch {
30434
30725
  return { status: "no-dir" };
30435
30726
  }
30436
30727
  const safe = sanitizeUploadName(name);
30437
30728
  if (!safe) return { status: "bad-name" };
30438
- const ext = extname2(safe).toLowerCase();
30729
+ const ext = extname3(safe).toLowerCase();
30439
30730
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return { status: "bad-name" };
30440
30731
  if (SKIP_FILES.has(safe)) return { status: "bad-name" };
30441
- if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES) return { status: "too-large" };
30732
+ if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES2) return { status: "too-large" };
30442
30733
  const abs = join21(absDir, safe);
30443
30734
  try {
30444
30735
  writeFileSync7(abs, content, { encoding: "utf8", flag: "wx" });
@@ -30454,7 +30745,7 @@ function moveDocEntry(root, from, to) {
30454
30745
  if (!absFrom.startsWith(root + sep4)) return { status: "not-found" };
30455
30746
  let stat;
30456
30747
  try {
30457
- stat = statSync8(absFrom);
30748
+ stat = statSync9(absFrom);
30458
30749
  } catch {
30459
30750
  return { status: "not-found" };
30460
30751
  }
@@ -30465,7 +30756,7 @@ function moveDocEntry(root, from, to) {
30465
30756
  const name = sanitizeUploadName(basename6(absTo));
30466
30757
  if (!name) return { status: "bad-target" };
30467
30758
  if (!isDir) {
30468
- const ext = extname2(name).toLowerCase();
30759
+ const ext = extname3(name).toLowerCase();
30469
30760
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS) && !ASSET_LIST_EXTENSIONS.has(ext)) {
30470
30761
  return { status: "bad-target" };
30471
30762
  }
@@ -30473,7 +30764,7 @@ function moveDocEntry(root, from, to) {
30473
30764
  const absToDir = dirname3(absTo);
30474
30765
  if (resolveDirPath(root, relative2(root, absToDir)) === null) return { status: "bad-target" };
30475
30766
  try {
30476
- if (!statSync8(absToDir).isDirectory()) return { status: "bad-target" };
30767
+ if (!statSync9(absToDir).isDirectory()) return { status: "bad-target" };
30477
30768
  } catch {
30478
30769
  return { status: "bad-target" };
30479
30770
  }
@@ -30533,7 +30824,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30533
30824
  if (!resolved2) return c.json({ error: "not found" }, 404);
30534
30825
  let stat;
30535
30826
  try {
30536
- stat = statSync8(resolved2.abs);
30827
+ stat = statSync9(resolved2.abs);
30537
30828
  } catch {
30538
30829
  return c.json({ error: "not found" }, 404);
30539
30830
  }
@@ -30555,13 +30846,14 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30555
30846
  if (!abs) return c.json({ error: "not found" }, 404);
30556
30847
  let stat;
30557
30848
  try {
30558
- stat = statSync8(abs);
30849
+ stat = statSync9(abs);
30559
30850
  } catch {
30560
30851
  return c.json({ error: "not found" }, 404);
30561
30852
  }
30562
30853
  if (!stat.isFile()) return c.json({ error: "not found" }, 404);
30563
30854
  if (stat.size > MAX_RAW_BYTES) return c.json({ error: "file too large" }, 413);
30564
- return c.body(withDocLinkBridge(readFileSync17(abs, "utf8")), 200, {
30855
+ const html = inlinePreviewImages(cwd, c.req.query("path") ?? "", readFileSync18(abs, "utf8"));
30856
+ return c.body(withDocLinkBridge(html), 200, {
30565
30857
  "Content-Type": "text/html; charset=utf-8",
30566
30858
  "Content-Security-Policy": HTML_SHARE_CSP,
30567
30859
  "X-Content-Type-Options": "nosniff",
@@ -30679,11 +30971,11 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30679
30971
  if (!abs) return c.json({ error: "not found" }, 404);
30680
30972
  let stat;
30681
30973
  try {
30682
- stat = statSync8(abs);
30974
+ stat = statSync9(abs);
30683
30975
  } catch {
30684
30976
  return c.json({ error: "not found" }, 404);
30685
30977
  }
30686
- if (!stat.isFile() || DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "md") {
30978
+ if (!stat.isFile() || DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "md") {
30687
30979
  return c.json({ error: "not a markdown doc" }, 400);
30688
30980
  }
30689
30981
  void exportDocAsArtifact(channelId, rel).catch((err) => {
@@ -30728,14 +31020,14 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30728
31020
  if (!abs) return c.json({ error: "not found" }, 404);
30729
31021
  let stat;
30730
31022
  try {
30731
- stat = statSync8(abs);
31023
+ stat = statSync9(abs);
30732
31024
  } catch {
30733
31025
  return c.json({ error: "not found" }, 404);
30734
31026
  }
30735
31027
  if (!stat.isFile()) return c.json({ error: "not found" }, 404);
30736
- const ext = extname2(abs).toLowerCase();
31028
+ const ext = extname3(abs).toLowerCase();
30737
31029
  const kind = DOC_EXTENSIONS[ext];
30738
- const tooLarge = stat.size > MAX_CONTENT_BYTES;
31030
+ const tooLarge = stat.size > MAX_CONTENT_BYTES2;
30739
31031
  if (tooLarge && kind !== "html") return c.json({ error: "file too large" }, 413);
30740
31032
  return c.json({
30741
31033
  path: rel,
@@ -30746,7 +31038,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30746
31038
  title: kind ? extractTitle(abs, kind) : basename6(abs),
30747
31039
  mtime: stat.mtime.toISOString(),
30748
31040
  tooLarge: tooLarge || void 0,
30749
- content: tooLarge ? "" : readFileSync17(abs, "utf8")
31041
+ content: tooLarge ? "" : readFileSync18(abs, "utf8")
30750
31042
  });
30751
31043
  });
30752
31044
  app.put("/:id/docs/content", async (c) => {
@@ -30774,22 +31066,22 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30774
31066
  if (!channel) return { error: c.json({ error: "channel not found" }, 404) };
30775
31067
  const rel = c.req.query("path") ?? "";
30776
31068
  const abs = resolveDocPath(channel.cwd, rel);
30777
- if (!abs || DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "md") {
31069
+ if (!abs || DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "md") {
30778
31070
  return { error: c.json({ error: "not found" }, 404) };
30779
31071
  }
30780
31072
  let stat;
30781
31073
  try {
30782
- stat = statSync8(abs);
31074
+ stat = statSync9(abs);
30783
31075
  } catch {
30784
31076
  return { error: c.json({ error: "not found" }, 404) };
30785
31077
  }
30786
31078
  if (!stat.isFile()) return { error: c.json({ error: "not found" }, 404) };
30787
- if (stat.size > MAX_CONTENT_BYTES) return { error: c.json({ error: "file too large" }, 413) };
31079
+ if (stat.size > MAX_CONTENT_BYTES2) return { error: c.json({ error: "file too large" }, 413) };
30788
31080
  return {
30789
31081
  channel,
30790
31082
  rel,
30791
31083
  title: extractTitle(abs, "md"),
30792
- content: readFileSync17(abs, "utf8")
31084
+ content: readFileSync18(abs, "utf8")
30793
31085
  };
30794
31086
  };
30795
31087
  app.get("/:id/docs/translation/:lang", async (c) => {
@@ -30849,7 +31141,7 @@ function isRealDoc(root, rel) {
30849
31141
  const abs = resolveDocPath(root, rel);
30850
31142
  if (!abs || !existsSync21(abs)) return false;
30851
31143
  try {
30852
- return statSync9(abs).isFile();
31144
+ return statSync10(abs).isFile();
30853
31145
  } catch {
30854
31146
  return false;
30855
31147
  }
@@ -30902,6 +31194,82 @@ function slackMrkdwnToMarkdown(text) {
30902
31194
  return resolveSlackTokens(text).replace(/(?<![\w*])\*(?!\*)(\S(?:[^*\n]*?\S)?)\*(?!\*)(?![\w*])/g, "**$1**").replace(/(?<![\w~])~(?!~)(\S(?:[^~\n]*?\S)?)~(?!~)(?![\w~])/g, "~~$1~~").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
30903
31195
  }
30904
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
+
30905
31273
  // ../api/src/dashboard/support-bot.ts
30906
31274
  var GROQ_API_URL7 = "https://api.groq.com/openai/v1/chat/completions";
30907
31275
  var SUPPORT_MODEL = "openai/gpt-oss-120b";
@@ -30982,13 +31350,14 @@ async function recordEvent(row) {
30982
31350
  const { error } = await getSupabaseClient().from("support_events").insert(row);
30983
31351
  if (error) console.error("support_events insert failed:", error.message);
30984
31352
  }
30985
- async function postReply(threadId, body, offerHuman = false) {
31353
+ async function postReply(threadId, body, offerHuman = false, guide = null) {
30986
31354
  const { data, error } = await getSupabaseClient().from("thread_replies").insert({
30987
31355
  thread_id: threadId,
30988
31356
  author: SUPPORT_BOT_AUTHOR,
30989
31357
  author_kind: "support_bot",
30990
31358
  body,
30991
- ...offerHuman ? { support_escalation: "offered" } : {}
31359
+ ...offerHuman ? { support_escalation: "offered" } : {},
31360
+ ...guide ? { guide } : {}
30992
31361
  }).select("id").single();
30993
31362
  if (error) throw new Error(`support reply insert: ${error.message}`);
30994
31363
  return data.id;
@@ -31052,7 +31421,8 @@ async function handleSupportMention(trigger, deps = {}) {
31052
31421
  // cache can reuse them; the per-thread content goes last.
31053
31422
  messages: [
31054
31423
  { role: "system", content: `${RULES}${docs}
31055
- </docs>` },
31424
+ </docs>
31425
+ ${GUIDE_RULES}` },
31056
31426
  {
31057
31427
  role: "user",
31058
31428
  content: `<environment>
@@ -31063,7 +31433,7 @@ ${env}
31063
31433
  ${transcript}
31064
31434
  </thread>
31065
31435
 
31066
- 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.`
31067
31437
  }
31068
31438
  ]
31069
31439
  })
@@ -31071,7 +31441,8 @@ Answer the latest @support mention, from ${trigger.author}.`
31071
31441
  if (!res.ok) throw new Error(`Groq ${res.status}: ${(await res.text()).slice(0, 300)}`);
31072
31442
  const data = await res.json();
31073
31443
  const text = (data.choices?.[0]?.message?.content ?? "").trim();
31074
- const answer = text.replaceAll(NO_DOC_MARKER, "").trim();
31444
+ const { answer: withMarker, guide } = extractGuide(text);
31445
+ const answer = withMarker.replaceAll(NO_DOC_MARKER, "").trim();
31075
31446
  const noDoc = text.includes(NO_DOC_MARKER) || citedDocs(answer).length === 0;
31076
31447
  event = {
31077
31448
  ...event,
@@ -31083,7 +31454,12 @@ Answer the latest @support mention, from ${trigger.author}.`
31083
31454
  };
31084
31455
  if (!answer)
31085
31456
  throw new Error(`empty answer (finish_reason ${data.choices?.[0]?.finish_reason})`);
31086
- event.reply_id = await postReply(trigger.threadId, answer, noDoc || wantsHuman(trigger.body));
31457
+ event.reply_id = await postReply(
31458
+ trigger.threadId,
31459
+ answer,
31460
+ noDoc || wantsHuman(trigger.body),
31461
+ guide
31462
+ );
31087
31463
  } catch (err) {
31088
31464
  console.error("Support bot answer failed:", err);
31089
31465
  if (!event.reply_id) {
@@ -32248,7 +32624,11 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
32248
32624
  )) {
32249
32625
  return;
32250
32626
  }
32251
- await this.postReply(msg.threadId, response.text || "No response", activities);
32627
+ await this.postReply(
32628
+ msg.threadId,
32629
+ withMcpRetryButton(response.text || "No response", response.mcpNeedsAuth),
32630
+ activities
32631
+ );
32252
32632
  if (response.killedTool) {
32253
32633
  void this.continueAfterKilledTool(
32254
32634
  msg.threadId,
@@ -32787,6 +33167,12 @@ ${lines}
32787
33167
  }
32788
33168
  }
32789
33169
  };
33170
+ function withMcpRetryButton(text, needsAuth) {
33171
+ if (!needsAuth?.length || /\[BUTTONS:/i.test(text)) return text;
33172
+ return `${text}
33173
+
33174
+ [BUTTONS: \u{1F504} Signed in to ${needsAuth.join(", ")}, retry]`;
33175
+ }
32790
33176
 
32791
33177
  // src/slack/commands.ts
32792
33178
  var SKILL_SELECT_ACTION_ID = "custie_skill_select";
@@ -33418,6 +33804,11 @@ ${trimmedDetail.slice(0, 1500)}
33418
33804
  return;
33419
33805
  }
33420
33806
  const askOptions = {
33807
+ // Stream mode, even though Slack shows no live activity: it puts the
33808
+ // turn under the idle watchdog, so a busy turn keeps running instead
33809
+ // of hitting the short plain-json wall-clock cap.
33810
+ onActivity: () => {
33811
+ },
33421
33812
  model: effectiveModel2,
33422
33813
  effort: effectiveEffort,
33423
33814
  maxBudgetUsd,
@@ -33710,6 +34101,18 @@ retry: ${retryDetail}`);
33710
34101
  });
33711
34102
  });
33712
34103
  app.event("message", async ({ event, client }) => {
34104
+ if (event.subtype === "message_changed") {
34105
+ const edited = event.message;
34106
+ if (!edited.ts) return;
34107
+ await mirrorIncomingMessage(client, {
34108
+ channel: event.channel,
34109
+ ts: edited.ts,
34110
+ subtype: "message_changed",
34111
+ text: typeof edited.text === "string" ? edited.text : void 0,
34112
+ blocks: Array.isArray(edited.blocks) ? edited.blocks : void 0
34113
+ });
34114
+ return;
34115
+ }
33713
34116
  await mirrorIncomingMessage(client, {
33714
34117
  channel: event.channel,
33715
34118
  ts: event.ts,
@@ -35188,9 +35591,14 @@ export {
35188
35591
  resolveDocsAccess,
35189
35592
  filterReadableDocsChannels,
35190
35593
  requireDocsAccess,
35594
+ watchDocs,
35595
+ SHARE_ASSET_PLACEHOLDER,
35596
+ readDocShareBundle,
35191
35597
  DocShareSlugTakenError,
35192
35598
  isSlugAvailable,
35193
35599
  setDocShareSlug,
35600
+ setDocShareAutoUpdate,
35601
+ listAutoUpdateDocShares,
35194
35602
  listLiveDocShares,
35195
35603
  findDocShareBySource,
35196
35604
  createDocShare,
@@ -35219,11 +35627,7 @@ export {
35219
35627
  clientKey,
35220
35628
  createPublicShareApiRouter,
35221
35629
  createPublicShareAssetRouter,
35222
- highlightLanguageOf,
35223
- extractTitle,
35224
35630
  flatDocs,
35225
- resolveDocPath,
35226
- resolveRawPath,
35227
35631
  createDocsRouter,
35228
35632
  slackMrkdwnToMarkdown,
35229
35633
  handleSupportMention,