flyspace-cli 0.1.52 → 0.1.53

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/cli.js CHANGED
@@ -212,6 +212,7 @@ import {
212
212
  resolveRawPath,
213
213
  resolveUserId,
214
214
  revokeDocShare,
215
+ rowToMemory,
215
216
  runAutomation,
216
217
  runScriptAutomation,
217
218
  runnerForModel,
@@ -276,7 +277,7 @@ import {
276
277
  workspaceHostname,
277
278
  workspaceSkillsDir,
278
279
  writeSkillFile
279
- } from "./chunk-ZBOOJCDU.js";
280
+ } from "./chunk-GX5467VC.js";
280
281
  import {
281
282
  firstReplyBody,
282
283
  getThread,
@@ -2153,8 +2154,8 @@ async function runUninstall(args = []) {
2153
2154
  if (backup) {
2154
2155
  const dir = join9(homedir4(), "Flyspace", ".uninstall-backups");
2155
2156
  mkdirSync6(dir, { recursive: true });
2156
- const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
2157
- backupFile = join9(dir, `flyspace-${stamp}.tar.gz`);
2157
+ const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
2158
+ backupFile = join9(dir, `flyspace-${stamp2}.tar.gz`);
2158
2159
  const rel = backupSources.map((s) => `"${s.replace(/^\//, "")}"`).join(" ");
2159
2160
  try {
2160
2161
  run2(`tar -czf "${backupFile}" -C / ${rel}`);
@@ -2346,7 +2347,7 @@ function npmEnv(target) {
2346
2347
  return nodeBin ? { ...process.env, PATH: `${nodeBin}:${process.env.PATH ?? ""}` } : process.env;
2347
2348
  }
2348
2349
  async function runUpgrade() {
2349
- const current = "0.1.52";
2350
+ const current = "0.1.53";
2350
2351
  console.log(`Current version: ${current}`);
2351
2352
  console.log("Checking for updates...\n");
2352
2353
  try {
@@ -6218,7 +6219,7 @@ async function runMcpCmd(args) {
6218
6219
  import { spawn as spawn6, spawnSync } from "child_process";
6219
6220
  import { existsSync as existsSync28 } from "fs";
6220
6221
  import { platform as platform7 } from "os";
6221
- import { join as join19 } from "path";
6222
+ import { join as join20 } from "path";
6222
6223
 
6223
6224
  // src/reconcile.ts
6224
6225
  import { existsSync as existsSync15, mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "fs";
@@ -6284,7 +6285,7 @@ async function ensureServices() {
6284
6285
  }
6285
6286
 
6286
6287
  // ../api/src/dashboard/api.ts
6287
- import { Hono as Hono32 } from "hono";
6288
+ import { Hono as Hono35 } from "hono";
6288
6289
 
6289
6290
  // ../api/src/dashboard/supabase-server-client.ts
6290
6291
  import { createServerClient, parseCookieHeader, serializeCookieHeader } from "@supabase/ssr";
@@ -7634,6 +7635,10 @@ function createAdminRouter() {
7634
7635
  // ../api/src/dashboard/agent-identities.ts
7635
7636
  var BOT_LABEL = "Workspace Agent";
7636
7637
  var BOT_DM_KEY = "claude";
7638
+ async function agentViewer(c) {
7639
+ const ctx = await resolveAuthContext(c);
7640
+ return ctx?.userId && ctx.email ? { userId: ctx.userId, email: ctx.email } : null;
7641
+ }
7637
7642
 
7638
7643
  // ../api/src/dashboard/data-api.ts
7639
7644
  import { existsSync as existsSync18 } from "fs";
@@ -7769,7 +7774,7 @@ function createCategoryWriteRouter() {
7769
7774
  }
7770
7775
 
7771
7776
  // ../api/src/dashboard/chat-routes.ts
7772
- import { Hono as Hono12 } from "hono";
7777
+ import { Hono as Hono13 } from "hono";
7773
7778
 
7774
7779
  // ../api/src/dashboard/fork-summary.ts
7775
7780
  var MAX_INPUT_CHARS = 6e4;
@@ -7813,6 +7818,188 @@ async function relevantThreadsPage(supabase, handle, channelIds, opts) {
7813
7818
  return data ?? [];
7814
7819
  }
7815
7820
 
7821
+ // ../api/src/dashboard/continuous-chat.ts
7822
+ import { Hono as Hono12 } from "hono";
7823
+ var GROQ_API_URL2 = "https://api.groq.com/openai/v1/chat/completions";
7824
+ var MODEL = "openai/gpt-oss-120b";
7825
+ var STREAM_DAYS = 30;
7826
+ var STREAM_LIMIT = 500;
7827
+ var ACTIVE_TOPIC_DAYS = 7;
7828
+ var BACKFILL_PER_REQUEST = 5;
7829
+ var UNSORTED = "unsorted";
7830
+ var isDmChannel = (ch) => !!(ch.dmKey || ch.agentName);
7831
+ var channelKeys = (ch) => ch.externalChannelId ? [ch.id, ch.externalChannelId] : [ch.id];
7832
+ function findChannel2(c, channelId) {
7833
+ return getProfileChannelRegistry().find(
7834
+ (ch) => (ch.id === channelId || ch.externalChannelId === channelId) && canSeeChannel(ch, c.get("auth"))
7835
+ );
7836
+ }
7837
+ function isShortAck(body) {
7838
+ const text = body.trim();
7839
+ return [...text].length <= 12 && !/[??]/.test(text);
7840
+ }
7841
+ var RULES = `You file one chat message from a personal assistant DM under a topic, so the user can later find everything about one subject together.
7842
+ You get the topics active in the last few days and the message (with a little preceding context).
7843
+ Pick the existing topic it belongs to, or name a NEW topic (2 to 5 words, in the language the user writes in, no punctuation) when it clearly starts a new subject.
7844
+ When you are not confident, answer unsorted.
7845
+ Output ONLY the topic name, or unsorted. No quotes, no explanation.`;
7846
+ async function askModel(apiKey, topics, examples, context, body) {
7847
+ const prompt = [
7848
+ `Active topics:
7849
+ ${topics.length ? topics.map((t) => `- ${t}`).join("\n") : "(none yet)"}`,
7850
+ examples.length ? `Corrections the user made earlier (message -> topic):
7851
+ ${examples.map((e) => `- ${e.body.slice(0, 160)} -> ${e.topic}`).join("\n")}` : "",
7852
+ context ? `Preceding messages:
7853
+ ${context}` : "",
7854
+ `Message to file:
7855
+ ${body.slice(0, 1500)}`
7856
+ ].filter(Boolean).join("\n\n");
7857
+ const res = await fetch(GROQ_API_URL2, {
7858
+ method: "POST",
7859
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
7860
+ signal: AbortSignal.timeout(1e4),
7861
+ body: JSON.stringify({
7862
+ model: MODEL,
7863
+ max_completion_tokens: 300,
7864
+ reasoning_effort: "low",
7865
+ include_reasoning: false,
7866
+ temperature: 0,
7867
+ messages: [
7868
+ { role: "system", content: RULES },
7869
+ { role: "user", content: prompt }
7870
+ ]
7871
+ })
7872
+ }).catch(() => null);
7873
+ if (!res?.ok) return null;
7874
+ const data = await res.json();
7875
+ const raw = (data.choices?.[0]?.message?.content ?? "").split("\n")[0].trim();
7876
+ const topic = raw.replace(/^["'「『]+|["'」』.。]+$/g, "").trim().slice(0, 60);
7877
+ if (!topic) return null;
7878
+ return topics.find((t) => t.toLowerCase() === topic.toLowerCase()) ?? topic;
7879
+ }
7880
+ async function tagReply(args) {
7881
+ const { channel, replyId, author, body, replyToId } = args;
7882
+ if (!isDmChannel(channel) || !isHumanAuthor(author)) return;
7883
+ const supabase = getSupabaseClient();
7884
+ const keys = channelKeys(channel);
7885
+ const channelKey = channel.id;
7886
+ const save = (topic2, source) => supabase.from("reply_topics").upsert({ reply_id: replyId, channel_id: channelKey, topic: topic2, source }).then(({ error: error2 }) => {
7887
+ if (error2) console.error("Reply topic save failed:", error2.message);
7888
+ });
7889
+ if (replyToId) {
7890
+ const { data } = await supabase.from("reply_topics").select("topic").eq("reply_id", replyToId).maybeSingle();
7891
+ if (data?.topic) return save(data.topic, "inherit");
7892
+ }
7893
+ const since2 = new Date(Date.now() - ACTIVE_TOPIC_DAYS * 864e5).toISOString();
7894
+ const { data: recentRows } = await supabase.from("reply_topics").select("reply_id, topic, source, created_at").in("channel_id", keys).gte("created_at", since2).order("created_at", { ascending: false }).limit(200);
7895
+ const recent = (recentRows ?? []).filter((r) => r.reply_id !== replyId);
7896
+ const previous = recent[0]?.topic;
7897
+ if (previous && isShortAck(body)) return save(previous, "inherit");
7898
+ const apiKey = process.env["GROQ_API_KEY"];
7899
+ if (!apiKey) return;
7900
+ const topics = [...new Set(recent.map((r) => r.topic).filter((t) => t !== UNSORTED))].slice(
7901
+ 0,
7902
+ 15
7903
+ );
7904
+ const manual = recent.filter((r) => r.source === "manual").slice(0, 5);
7905
+ const { data: manualBodies } = manual.length ? await supabase.from("thread_replies").select("id, body").in(
7906
+ "id",
7907
+ manual.map((m) => m.reply_id)
7908
+ ) : { data: [] };
7909
+ const bodyOf = new Map(
7910
+ (manualBodies ?? []).map((r) => [r.id, r.body])
7911
+ );
7912
+ const examples = manual.flatMap(
7913
+ (m) => bodyOf.has(m.reply_id) ? [{ body: bodyOf.get(m.reply_id), topic: m.topic }] : []
7914
+ );
7915
+ const { data: ctxRows } = await supabase.from("thread_replies").select("author, body, created_at, threads!inner(channel_id)").in("threads.channel_id", keys).neq("id", replyId).is("archived_at", null).order("created_at", { ascending: false }).limit(3);
7916
+ const context = (ctxRows ?? []).reverse().map((r) => `${r.author}: ${r.body.slice(0, 300)}`).join("\n");
7917
+ const topic = await askModel(apiKey, topics, examples, context, body);
7918
+ if (topic) await save(topic, "model");
7919
+ }
7920
+ function tagStoredReply(c, args) {
7921
+ void (async () => {
7922
+ if (!await isFeatureEnabled(c, "continuous-chat")) return;
7923
+ const { data } = await getSupabaseClient().from("threads").select("channel_id").eq("id", args.threadId).maybeSingle();
7924
+ const channel = data?.channel_id ? findChannel2(c, data.channel_id) : void 0;
7925
+ if (channel) await tagReply({ channel, ...args });
7926
+ })().catch((err) => console.error("Reply topic tagging failed:", err));
7927
+ }
7928
+ var backfilling = /* @__PURE__ */ new Set();
7929
+ function createContinuousChatRouter() {
7930
+ const app = new Hono12();
7931
+ app.get("/channels/:channelId/continuous", async (c) => {
7932
+ if (!await isFeatureEnabled(c, "continuous-chat"))
7933
+ return c.json({ error: "feature not enabled" }, 403);
7934
+ const channel = findChannel2(c, c.req.param("channelId"));
7935
+ if (!channel || !isDmChannel(channel)) return c.json({ error: "not found" }, 404);
7936
+ const supabase = getSupabaseClient();
7937
+ const since2 = new Date(Date.now() - STREAM_DAYS * 864e5).toISOString();
7938
+ const { data: rows, error: error2 } = await supabase.from("thread_replies").select("id, thread_id, author, body, created_at, threads!inner(channel_id)").in("threads.channel_id", channelKeys(channel)).is("archived_at", null).gte("created_at", since2).order("created_at", { ascending: false }).limit(STREAM_LIMIT);
7939
+ if (error2) return c.json({ error: error2.message }, 500);
7940
+ const replies = (rows ?? []).reverse();
7941
+ const { data: tagRows } = replies.length ? await supabase.from("reply_topics").select("reply_id, topic, source, created_at").in(
7942
+ "reply_id",
7943
+ replies.map((r) => r.id)
7944
+ ) : { data: [] };
7945
+ const tags = new Map((tagRows ?? []).map((t) => [t.reply_id, t]));
7946
+ const lastInThread = /* @__PURE__ */ new Map();
7947
+ const messages = replies.map((r) => {
7948
+ const tag = tags.get(r.id);
7949
+ const topic = tag?.topic ?? lastInThread.get(r.thread_id) ?? null;
7950
+ if (topic) lastInThread.set(r.thread_id, topic);
7951
+ return {
7952
+ id: r.id,
7953
+ thread_id: r.thread_id,
7954
+ author: r.author,
7955
+ body: slackMrkdwnToMarkdown(r.body),
7956
+ created_at: r.created_at,
7957
+ topic,
7958
+ tagged: !!tag
7959
+ };
7960
+ });
7961
+ const activeSince = Date.now() - ACTIVE_TOPIC_DAYS * 864e5;
7962
+ const pending = replies.filter(
7963
+ (r) => !tags.has(r.id) && isHumanAuthor(r.author) && Date.parse(r.created_at) >= activeSince && !backfilling.has(r.id)
7964
+ ).slice(0, BACKFILL_PER_REQUEST);
7965
+ if (pending.length) {
7966
+ for (const r of pending) backfilling.add(r.id);
7967
+ void (async () => {
7968
+ for (const r of pending) {
7969
+ await tagReply({ channel, replyId: r.id, author: r.author, body: r.body }).catch(
7970
+ () => {
7971
+ }
7972
+ );
7973
+ backfilling.delete(r.id);
7974
+ }
7975
+ })();
7976
+ }
7977
+ const activeTopics = [
7978
+ ...new Set(
7979
+ messages.filter((m) => m.topic && Date.parse(m.created_at) >= activeSince).map((m) => m.topic)
7980
+ )
7981
+ ];
7982
+ return c.json({ messages, topics: activeTopics, pendingTags: pending.length });
7983
+ });
7984
+ app.patch("/replies/:replyId/topic", async (c) => {
7985
+ if (!await isFeatureEnabled(c, "continuous-chat"))
7986
+ return c.json({ error: "feature not enabled" }, 403);
7987
+ const replyId = c.req.param("replyId");
7988
+ const input2 = await c.req.json().catch(() => null);
7989
+ const topic = typeof input2?.topic === "string" ? input2.topic.trim().slice(0, 60) : "";
7990
+ if (!topic) return c.json({ error: "topic is required" }, 400);
7991
+ const supabase = getSupabaseClient();
7992
+ const { data } = await supabase.from("thread_replies").select("id, threads!inner(channel_id)").eq("id", replyId).maybeSingle();
7993
+ const channelId = data?.threads?.channel_id;
7994
+ const channel = channelId ? findChannel2(c, channelId) : void 0;
7995
+ if (!channel || !isDmChannel(channel)) return c.json({ error: "not found" }, 404);
7996
+ const { error: error2 } = await supabase.from("reply_topics").upsert({ reply_id: replyId, channel_id: channel.id, topic, source: "manual" });
7997
+ if (error2) return c.json({ error: error2.message }, 500);
7998
+ return c.json({ ok: true, topic });
7999
+ });
8000
+ return app;
8001
+ }
8002
+
7816
8003
  // ../api/src/dashboard/thread-translate.ts
7817
8004
  import { createHash as createHash3 } from "crypto";
7818
8005
 
@@ -7822,11 +8009,11 @@ var TABLES = {
7822
8009
  title: { table: "thread_title_translations", idColumn: "thread_id" }
7823
8010
  };
7824
8011
  async function getThreadTranslations(lang, keys, kind = "reply") {
7825
- const { table, idColumn } = TABLES[kind];
8012
+ const { table: table2, idColumn } = TABLES[kind];
7826
8013
  const found = /* @__PURE__ */ new Map();
7827
8014
  if (keys.length === 0) return found;
7828
8015
  const clauses = keys.map((k) => `and(${idColumn}.eq.${k.replyId},body_hash.eq.${k.bodyHash})`).join(",");
7829
- const { data, error: error2 } = await getSupabaseClient().from(table).select(`${idColumn}, body, passthrough`).eq("lang", lang).or(clauses);
8016
+ const { data, error: error2 } = await getSupabaseClient().from(table2).select(`${idColumn}, body, passthrough`).eq("lang", lang).or(clauses);
7830
8017
  if (error2) throw new Error(`getThreadTranslations(${lang}): ${error2.message}`);
7831
8018
  for (const row of data ?? []) {
7832
8019
  const replyId = row[idColumn];
@@ -7840,8 +8027,8 @@ async function getThreadTranslations(lang, keys, kind = "reply") {
7840
8027
  }
7841
8028
  async function putThreadTranslations(lang, rows, kind = "reply") {
7842
8029
  if (rows.length === 0) return;
7843
- const { table, idColumn } = TABLES[kind];
7844
- const { error: error2 } = await getSupabaseClient().from(table).upsert(
8030
+ const { table: table2, idColumn } = TABLES[kind];
8031
+ const { error: error2 } = await getSupabaseClient().from(table2).upsert(
7845
8032
  rows.map((r) => ({
7846
8033
  [idColumn]: r.replyId,
7847
8034
  lang,
@@ -7874,7 +8061,7 @@ async function addTranslationTokens(workspaceId, tokens2) {
7874
8061
  }
7875
8062
 
7876
8063
  // ../api/src/dashboard/thread-translate.ts
7877
- var GROQ_API_URL2 = "https://api.groq.com/openai/v1/chat/completions";
8064
+ var GROQ_API_URL3 = "https://api.groq.com/openai/v1/chat/completions";
7878
8065
  var TRANSLATION_MODEL = "openai/gpt-oss-120b";
7879
8066
  var RECIPE_VERSION = 1;
7880
8067
  var BATCH_CHAR_BUDGET = 16e3;
@@ -7957,7 +8144,7 @@ async function translateBatch(batch, context, lang, scope) {
7957
8144
  batch.map((m) => m.body)
7958
8145
  )
7959
8146
  };
7960
- const res = await fetch(GROQ_API_URL2, {
8147
+ const res = await fetch(GROQ_API_URL3, {
7961
8148
  method: "POST",
7962
8149
  headers: { "content-type": "application/json", authorization: `Bearer ${apiKey}` },
7963
8150
  body: JSON.stringify({
@@ -8318,7 +8505,7 @@ async function generateAutoTitle(threadId, channelId, body) {
8318
8505
  await supabase.from("threads").update({ auto_title: autoTitle }).eq("id", threadId).is("title", null);
8319
8506
  }
8320
8507
  function createChatRouter(agent = {}) {
8321
- const app = new Hono12();
8508
+ const app = new Hono13();
8322
8509
  const {
8323
8510
  onChatMessage: onMessage,
8324
8511
  isAgentThinking,
@@ -8844,6 +9031,12 @@ function createChatRouter(agent = {}) {
8844
9031
  effort: effortFromRow(reply["effort"])
8845
9032
  });
8846
9033
  askSupport(c, thread.id, input2.author, input2.body);
9034
+ tagStoredReply(c, {
9035
+ threadId: thread.id,
9036
+ replyId: reply.id,
9037
+ author: input2.author,
9038
+ body: input2.body
9039
+ });
8847
9040
  }
8848
9041
  if (!replayed && pickedStatus !== void 0) {
8849
9042
  void rememberComposerStatus(c, channelId, pickedStatus).catch(
@@ -8962,6 +9155,13 @@ function createChatRouter(agent = {}) {
8962
9155
  effort: effortFromRow(data.effort)
8963
9156
  });
8964
9157
  askSupport(c, threadId, input2.author, input2.body);
9158
+ tagStoredReply(c, {
9159
+ threadId,
9160
+ replyId: data.id,
9161
+ author: input2.author,
9162
+ body: input2.body,
9163
+ replyToId: isNonEmptyString(input2.replyToId) ? input2.replyToId : void 0
9164
+ });
8965
9165
  void syncSupportReply({ threadId, author: input2.author, body: input2.body });
8966
9166
  return c.json(data, 201);
8967
9167
  });
@@ -8992,7 +9192,7 @@ function createChatRouter(agent = {}) {
8992
9192
  }
8993
9193
 
8994
9194
  // ../api/src/dashboard/doc-shares-routes.ts
8995
- import { Hono as Hono13 } from "hono";
9195
+ import { Hono as Hono14 } from "hono";
8996
9196
 
8997
9197
  // ../api/src/dashboard/doc-share-features.ts
8998
9198
  import { DeleteObjectCommand } from "@aws-sdk/client-s3";
@@ -9058,7 +9258,7 @@ import { CopyObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-s
9058
9258
  var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
9059
9259
 
9060
9260
  // ../api/src/dashboard/share-language.ts
9061
- var GROQ_API_URL3 = "https://api.groq.com/openai/v1/chat/completions";
9261
+ var GROQ_API_URL4 = "https://api.groq.com/openai/v1/chat/completions";
9062
9262
  var CLASSIFIER_MODEL = "openai/gpt-oss-20b";
9063
9263
  var SAMPLE_CHARS = 4e3;
9064
9264
  var NOISE = [
@@ -9097,7 +9297,7 @@ async function detectSourceLanguage(title, content) {
9097
9297
  const sample = languageSample(title, content);
9098
9298
  if (sample.length < MIN_SAMPLE_CHARS) return null;
9099
9299
  try {
9100
- const res = await fetch(GROQ_API_URL3, {
9300
+ const res = await fetch(GROQ_API_URL4, {
9101
9301
  method: "POST",
9102
9302
  headers: { "content-type": "application/json", authorization: `Bearer ${apiKey}` },
9103
9303
  body: JSON.stringify({
@@ -9327,7 +9527,7 @@ function resolveChannel2(c) {
9327
9527
  }
9328
9528
  var LIST_LIMIT = 500;
9329
9529
  function createDocShareListRouter() {
9330
- const app = new Hono13();
9530
+ const app = new Hono14();
9331
9531
  app.get("/shares", async (c) => {
9332
9532
  const viewer = c.get("auth");
9333
9533
  const readable = await filterReadableDocsChannels(
@@ -9371,7 +9571,7 @@ function createDocShareListRouter() {
9371
9571
  return app;
9372
9572
  }
9373
9573
  function createDocShareWriteRouter(agent = {}) {
9374
- const app = new Hono13();
9574
+ const app = new Hono14();
9375
9575
  app.use("/:id/docs/share", requireDocsAccess);
9376
9576
  app.use("/:id/docs/share/*", requireDocsAccess);
9377
9577
  app.use("/:id/docs/shares", requireDocsAccess);
@@ -9544,7 +9744,7 @@ function createDocShareWriteRouter(agent = {}) {
9544
9744
  }
9545
9745
 
9546
9746
  // ../api/src/dashboard/search-routes.ts
9547
- import { Hono as Hono14 } from "hono";
9747
+ import { Hono as Hono15 } from "hono";
9548
9748
  function matchScore(q, fields) {
9549
9749
  const terms = q.toLowerCase().split(/\s+/).filter(Boolean);
9550
9750
  if (terms.length === 0) return 0;
@@ -9692,7 +9892,7 @@ function searchAutomations(q) {
9692
9892
  }
9693
9893
  var RESULT_LIMIT = 30;
9694
9894
  function createSearchRouter() {
9695
- const app = new Hono14();
9895
+ const app = new Hono15();
9696
9896
  app.get("/", async (c) => {
9697
9897
  const q = c.req.query("q")?.trim();
9698
9898
  if (!q) return c.json({ results: [] });
@@ -9708,7 +9908,7 @@ function createSearchRouter() {
9708
9908
  }
9709
9909
 
9710
9910
  // ../api/src/dashboard/domain-routes.ts
9711
- import { Hono as Hono15 } from "hono";
9911
+ import { Hono as Hono16 } from "hono";
9712
9912
  var FALLBACK_ORIGIN = "custom.flyspace.ai";
9713
9913
  function isValidCustomHostname(hostname2) {
9714
9914
  if (hostname2.length > 253 || hostname2.endsWith(".flyspace.ai") || hostname2 === "flyspace.ai") {
@@ -9778,7 +9978,7 @@ function view(row, dcv) {
9778
9978
  };
9779
9979
  }
9780
9980
  function createDomainRouter() {
9781
- const app = new Hono15();
9981
+ const app = new Hono16();
9782
9982
  app.use("*", async (c, next) => {
9783
9983
  const auth = c.get("auth");
9784
9984
  if (auth.role !== "admin") return c.json({ error: "admin access required" }, 403);
@@ -9842,17 +10042,15 @@ function createDomainRouter() {
9842
10042
  }
9843
10043
 
9844
10044
  // ../api/src/dashboard/transcribe-routes.ts
9845
- import { Hono as Hono16 } from "hono";
10045
+ import { Hono as Hono17 } from "hono";
9846
10046
  var GROQ_TRANSCRIBE_URL = "https://api.groq.com/openai/v1/audio/transcriptions";
9847
- var MODEL = "whisper-large-v3-turbo";
10047
+ var MODEL2 = "whisper-large-v3-turbo";
9848
10048
  var MAX_AUDIO_BYTES = 5 * 1024 * 1024;
9849
10049
  var MAX_PROMPT_CHARS = 400;
9850
10050
  var NO_SPEECH_THRESHOLD = 0.6;
9851
10051
  function createTranscribeRouter() {
9852
- const app = new Hono16();
10052
+ const app = new Hono17();
9853
10053
  app.post("/transcribe", async (c) => {
9854
- if (!await isFeatureEnabled(c, "dictation"))
9855
- return c.json({ error: "feature not enabled" }, 403);
9856
10054
  const apiKey = process.env["GROQ_API_KEY"];
9857
10055
  if (!apiKey) return c.json({ error: "transcription is not configured" }, 503);
9858
10056
  const body = await c.req.parseBody().catch(() => null);
@@ -9861,7 +10059,7 @@ function createTranscribeRouter() {
9861
10059
  if (file.size > MAX_AUDIO_BYTES) return c.json({ error: "audio segment too large" }, 400);
9862
10060
  const form = new FormData();
9863
10061
  form.append("file", file, file.name || "segment.wav");
9864
- form.append("model", MODEL);
10062
+ form.append("model", MODEL2);
9865
10063
  form.append("temperature", "0");
9866
10064
  form.append("response_format", "verbose_json");
9867
10065
  const prompt = body?.["prompt"];
@@ -9888,21 +10086,19 @@ function createTranscribeRouter() {
9888
10086
  }
9889
10087
 
9890
10088
  // ../api/src/dashboard/autocomplete-routes.ts
9891
- import { Hono as Hono17 } from "hono";
9892
- var GROQ_API_URL4 = "https://api.groq.com/openai/v1/chat/completions";
9893
- var MODEL2 = "openai/gpt-oss-120b";
10089
+ import { Hono as Hono18 } from "hono";
10090
+ var GROQ_API_URL5 = "https://api.groq.com/openai/v1/chat/completions";
10091
+ var MODEL3 = "openai/gpt-oss-120b";
9894
10092
  var MAX_REPLY_CHARS = 4e3;
9895
10093
  var MAX_EARLIER_CHARS = 1500;
9896
10094
  var THREAD_TAIL_REPLIES = 5;
9897
- var RULES = `You predict the next message a user will send in a chat thread, right after the AI agent's last reply, like Claude Code's prompt suggestions. The composer is empty; you suggest the whole message.
10095
+ var RULES2 = `You predict the next message a user will send in a chat thread, right after the AI agent's last reply, like Claude Code's prompt suggestions. The composer is empty; you suggest the whole message.
9898
10096
  Base it on the agent's last reply: answer a question it asked, approve or pick an option it offered, or ask for the obvious next step (commit, deploy, run the tests, check a specific file or feature it named). Use specific nouns from the reply.
9899
10097
  Keep it short (under 15 words), in the language the user writes in. No greetings, thanks or filler.
9900
10098
  Output ONLY the message text, no quotes or explanation. If there is no clear next step, output nothing.`;
9901
10099
  function createAutocompleteRouter() {
9902
- const app = new Hono17();
10100
+ const app = new Hono18();
9903
10101
  app.post("/autocomplete", async (c) => {
9904
- if (!await isFeatureEnabled(c, "autocomplete"))
9905
- return c.json({ error: "feature not enabled" }, 403);
9906
10102
  const apiKey = process.env["GROQ_API_KEY"];
9907
10103
  if (!apiKey) return c.json({ error: "autocomplete is not configured" }, 503);
9908
10104
  const body = await c.req.json().catch(() => null);
@@ -9914,12 +10110,12 @@ function createAutocompleteRouter() {
9914
10110
  const context = `Channel: #${channel.name}${channel.prompt ? `
9915
10111
  Channel instructions: ${channel.prompt.slice(0, 500)}` : ""}
9916
10112
  ${thread}`;
9917
- const res = await fetch(GROQ_API_URL4, {
10113
+ const res = await fetch(GROQ_API_URL5, {
9918
10114
  method: "POST",
9919
10115
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
9920
10116
  signal: AbortSignal.timeout(5e3),
9921
10117
  body: JSON.stringify({
9922
- model: MODEL2,
10118
+ model: MODEL3,
9923
10119
  // gpt-oss reasons first; a newline stop would cut it off before any content.
9924
10120
  max_completion_tokens: 200,
9925
10121
  reasoning_effort: "low",
@@ -9928,8 +10124,8 @@ ${thread}`;
9928
10124
  messages: [
9929
10125
  {
9930
10126
  role: "system",
9931
- content: typeof body.language === "string" && /^[A-Za-z-]{2,16}$/.test(body.language) ? `${RULES}
9932
- The user reads this thread in ${body.language}: write the suggestion in that language (BCP 47 tag).` : RULES
10127
+ content: typeof body.language === "string" && /^[A-Za-z-]{2,16}$/.test(body.language) ? `${RULES2}
10128
+ The user reads this thread in ${body.language}: write the suggestion in that language (BCP 47 tag).` : RULES2
9933
10129
  },
9934
10130
  { role: "user", content: context }
9935
10131
  ]
@@ -9966,9 +10162,220 @@ Agent's last reply:
9966
10162
  ${last.body.slice(-MAX_REPLY_CHARS)}`;
9967
10163
  }
9968
10164
 
10165
+ // ../api/src/dashboard/daily-line-routes.ts
10166
+ import { Hono as Hono19 } from "hono";
10167
+ var GROQ_API_URL6 = "https://api.groq.com/openai/v1/chat/completions";
10168
+ var MODEL4 = "openai/gpt-oss-120b";
10169
+ var DAY_MS = 864e5;
10170
+ var RULES3 = `You write one short line of encouragement shown in the corner of an empty screen, for a founder building a product with a small team.
10171
+ You are given what the team recently built and decided. Draw on its real substance to remind them how far they have come or why the work matters, so they feel like pushing on.
10172
+ Never a task, reminder, instruction or rule (no "remember to", "do X first", "never Y"). Not a summary of the item either.
10173
+ Under 30 Chinese characters or 18 English words. Warm but plain, like a note from a friend: no hype, no exclamation marks, no emoji, no quotes, no cliches.
10174
+ Output ONLY the line.`;
10175
+ var CONTEXT_COUNT = 5;
10176
+ var cache3 = /* @__PURE__ */ new Map();
10177
+ function dayIndex(now = /* @__PURE__ */ new Date()) {
10178
+ const local = new Date(now.toLocaleString("en-US", { timeZone: "Australia/Sydney" }));
10179
+ return Math.floor(Date.UTC(local.getFullYear(), local.getMonth(), local.getDate()) / DAY_MS);
10180
+ }
10181
+ var RECENT_MS = 60 * DAY_MS;
10182
+ function pickMemories(memories, day, now = Date.now()) {
10183
+ const recent = memories.filter((m) => now - Date.parse(m.updatedAt) < RECENT_MS);
10184
+ const pool = (recent.length ? recent : memories).sort(
10185
+ (a, b) => b.updatedAt.localeCompare(a.updatedAt)
10186
+ );
10187
+ if (!pool.length) return [];
10188
+ const start = day % pool.length;
10189
+ return [...pool, ...pool].slice(start, start + Math.min(CONTEXT_COUNT, pool.length));
10190
+ }
10191
+ function createDailyLineRouter() {
10192
+ const app = new Hono19();
10193
+ app.get("/daily-line", async (c) => {
10194
+ if (!await isFeatureEnabled(c, "daily-line"))
10195
+ return c.json({ error: "feature not enabled" }, 403);
10196
+ const apiKey = process.env["GROQ_API_KEY"];
10197
+ if (!apiKey) return c.json({ text: "" });
10198
+ const auth = c.get("auth");
10199
+ const language = c.req.query("language") ?? "en";
10200
+ if (!/^[A-Za-z-]{2,16}$/.test(language)) return c.json({ text: "" });
10201
+ const { data } = await getSupabaseClient().from("memories").select("*").eq("workspace_id", auth.workspaceId).in("scope", ["channel", "workspace"]).in("type", ["decision", "fact"]);
10202
+ const visible = new Set(
10203
+ getChannelRegistry().filter((ch) => canSeeChannel(ch, auth)).map((ch) => ch.id)
10204
+ );
10205
+ const memories = (data ?? []).map(rowToMemory).filter((m) => !m.channelId || visible.has(m.channelId));
10206
+ const day = dayIndex();
10207
+ const picked = pickMemories(memories, day);
10208
+ const memory = picked[0];
10209
+ if (!memory) return c.json({ text: "" });
10210
+ const key = `${day}:${memory.id}:${language}`;
10211
+ let text = cache3.get(key);
10212
+ if (text === void 0) {
10213
+ const res = await fetch(GROQ_API_URL6, {
10214
+ method: "POST",
10215
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
10216
+ signal: AbortSignal.timeout(8e3),
10217
+ body: JSON.stringify({
10218
+ model: MODEL4,
10219
+ max_completion_tokens: 300,
10220
+ reasoning_effort: "low",
10221
+ include_reasoning: false,
10222
+ temperature: 0.7,
10223
+ messages: [
10224
+ {
10225
+ role: "system",
10226
+ content: `${RULES3}
10227
+ Write it in ${language} (BCP 47 tag). For Chinese use Traditional Chinese (Taiwan) with full-width punctuation.`
10228
+ },
10229
+ {
10230
+ role: "user",
10231
+ content: picked.map((m) => `- ${m.description}
10232
+ ${m.body.slice(0, 400)}`).join("\n")
10233
+ }
10234
+ ]
10235
+ })
10236
+ }).catch(() => null);
10237
+ if (!res?.ok) return c.json({ text: "" });
10238
+ const out = await res.json();
10239
+ text = (out.choices?.[0]?.message?.content ?? "").trim().split("\n")[0];
10240
+ if (text) cache3.set(key, text);
10241
+ }
10242
+ return c.json({ text, date: memory.updatedAt, threadId: memory.sourceThreadId });
10243
+ });
10244
+ return app;
10245
+ }
10246
+
10247
+ // ../api/src/dashboard/channel-route.ts
10248
+ import { Hono as Hono20 } from "hono";
10249
+ var GROQ_API_URL7 = "https://api.groq.com/openai/v1/chat/completions";
10250
+ var MODEL5 = "openai/gpt-oss-120b";
10251
+ var MAX_MESSAGE_CHARS2 = 3e3;
10252
+ var MAX_PROMPT_CHARS2 = 300;
10253
+ var TITLES_PER_CHANNEL = 8;
10254
+ var RECENT_THREADS = 600;
10255
+ var TABLE_TTL_MS = 30 * 6e4;
10256
+ var VISION_MODEL = "qwen/qwen3.8-27b";
10257
+ var MAX_IMAGES = 3;
10258
+ var ATTACHMENT_KEY = /\/api\/attachments\/([^)?\s]+)/g;
10259
+ var DESCRIBE = `Describe these screenshots in 2 to 4 short lines so someone can tell which project they belong to: the app or website shown, its visible product, brand, workspace and channel names, and the screen or feature. Quote names exactly as written. No guesses beyond what is visible.`;
10260
+ async function describeImages(text, workspace, apiKey) {
10261
+ if (!workspace) return "";
10262
+ const keys = [...text.matchAll(ATTACHMENT_KEY)].map((m) => decodeURIComponent(m[1])).filter((key) => key.split("/")[1] === workspace).slice(0, MAX_IMAGES);
10263
+ const urls = (await Promise.all(keys.map((k) => presignAttachmentRead(k).catch(() => null)))).filter(
10264
+ (u) => !!u
10265
+ );
10266
+ if (urls.length === 0) return "";
10267
+ const res = await fetch(GROQ_API_URL7, {
10268
+ method: "POST",
10269
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
10270
+ signal: AbortSignal.timeout(1e4),
10271
+ body: JSON.stringify({
10272
+ model: VISION_MODEL,
10273
+ max_completion_tokens: 200,
10274
+ reasoning_effort: "none",
10275
+ temperature: 0,
10276
+ messages: [
10277
+ {
10278
+ role: "user",
10279
+ content: [
10280
+ { type: "text", text: DESCRIBE },
10281
+ ...urls.map((url) => ({ type: "image_url", image_url: { url } }))
10282
+ ]
10283
+ }
10284
+ ]
10285
+ })
10286
+ }).catch(() => null);
10287
+ if (!res?.ok) return "";
10288
+ const data = await res.json();
10289
+ return (data.choices?.[0]?.message?.content ?? "").trim();
10290
+ }
10291
+ var table = null;
10292
+ async function recentTitles(channels) {
10293
+ const key = channels.map((ch) => ch.id).sort().join(",");
10294
+ if (table?.key === key && Date.now() - table.builtAt < TABLE_TTL_MS) return table.titles;
10295
+ const keyOf = /* @__PURE__ */ new Map();
10296
+ for (const ch of channels) {
10297
+ keyOf.set(ch.id, ch.id);
10298
+ if (ch.externalChannelId) keyOf.set(ch.externalChannelId, ch.id);
10299
+ }
10300
+ const { data: threads } = await getSupabaseClient().from("threads").select("channel_id, title, auto_title").in("channel_id", [...keyOf.keys()]).order("created_at", { ascending: false }).limit(RECENT_THREADS);
10301
+ const titles = /* @__PURE__ */ new Map();
10302
+ for (const t of threads ?? []) {
10303
+ const id = keyOf.get(t.channel_id);
10304
+ const title = t.title ?? t.auto_title;
10305
+ if (!id || !title) continue;
10306
+ const list = titles.get(id) ?? [];
10307
+ if (list.length < TITLES_PER_CHANNEL) titles.set(id, [...list, title]);
10308
+ }
10309
+ table = { key, builtAt: Date.now(), titles };
10310
+ return titles;
10311
+ }
10312
+ var RULES4 = `You route a new chat topic to the channel it belongs in. Each channel is a project or area of work; you get its name, instructions and recent topic titles.
10313
+ Pick the single channel whose project the message is about. Prefer a specific project channel over a general one. Match on concrete nouns (product, client, repo, feature names) rather than tone.
10314
+ A topic word that could fit many projects (notification, scrollbar, login, bug) is not evidence: unless the message clearly names another project, pick the channel the user is currently in.
10315
+ When a screenshot description is given, the app and names visible in it are strong evidence of the project.
10316
+ Output ONLY the channel's number and your confidence, e.g. "3 high" or "3 low". Say low when the message could reasonably belong to more than one channel.`;
10317
+ function createChannelRouteRouter() {
10318
+ const app = new Hono20();
10319
+ app.post("/route-channel", async (c) => {
10320
+ if (!await isFeatureEnabled(c, "auto-channel"))
10321
+ return c.json({ error: "feature not enabled" }, 403);
10322
+ const apiKey = process.env["GROQ_API_KEY"];
10323
+ if (!apiKey) return c.json({ error: "channel routing is not configured" }, 503);
10324
+ const body = await c.req.json().catch(() => null);
10325
+ const text = typeof body?.text === "string" ? body.text.trim().slice(0, MAX_MESSAGE_CHARS2) : "";
10326
+ if (!text) return c.json({ channelId: null, confident: false });
10327
+ const auth = c.get("auth");
10328
+ const channels = getChannelRegistry().filter((ch) => !ch.archivedAt && canSeeChannel(ch, auth));
10329
+ if (channels.length <= 1) return c.json({ channelId: channels[0]?.id ?? null, confident: true });
10330
+ const [titles, screenshots] = await Promise.all([
10331
+ recentTitles(getChannelRegistry().filter((ch) => !ch.archivedAt)),
10332
+ describeImages(text, c.req.query("workspace"), apiKey)
10333
+ ]);
10334
+ const current = channels.findIndex((ch) => ch.id === body?.currentChannelId);
10335
+ const listing = channels.map(
10336
+ (ch, i) => [
10337
+ `${i + 1}. ${ch.agentName ? "@" : "#"}${ch.name}`,
10338
+ ch.prompt ? ` Instructions: ${ch.prompt.replace(/\s+/g, " ").slice(0, MAX_PROMPT_CHARS2)}` : "",
10339
+ titles.get(ch.id)?.length ? ` Recent topics: ${titles.get(ch.id).join(" | ")}` : ""
10340
+ ].filter(Boolean).join("\n")
10341
+ ).join("\n");
10342
+ const res = await fetch(GROQ_API_URL7, {
10343
+ method: "POST",
10344
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
10345
+ signal: AbortSignal.timeout(8e3),
10346
+ body: JSON.stringify({
10347
+ model: MODEL5,
10348
+ max_completion_tokens: 400,
10349
+ reasoning_effort: "low",
10350
+ include_reasoning: false,
10351
+ temperature: 0,
10352
+ messages: [
10353
+ { role: "system", content: RULES4 },
10354
+ { role: "user", content: `Channels:
10355
+ ${listing}${current >= 0 ? `
10356
+
10357
+ The user is currently in channel ${current + 1}.` : ""}
10358
+
10359
+ New topic:
10360
+ ${text}${screenshots ? `
10361
+
10362
+ Attached screenshots show:
10363
+ ${screenshots}` : ""}` }
10364
+ ]
10365
+ })
10366
+ }).catch(() => null);
10367
+ if (!res?.ok) return c.json({ channelId: null, confident: false });
10368
+ const data = await res.json();
10369
+ const reply = data.choices?.[0]?.message?.content ?? "";
10370
+ const channelId = channels[Number(reply.match(/\d+/)?.[0]) - 1]?.id ?? null;
10371
+ return c.json({ channelId, confident: !!channelId && /\bhigh\b/i.test(reply) });
10372
+ });
10373
+ return app;
10374
+ }
10375
+
9969
10376
  // ../api/src/dashboard/avatars-routes.ts
9970
10377
  import { createHash as createHash4, randomUUID as randomUUID3 } from "crypto";
9971
- import { Hono as Hono18 } from "hono";
10378
+ import { Hono as Hono21 } from "hono";
9972
10379
  import sharp3 from "sharp";
9973
10380
  import { PutObjectCommand as PutObjectCommand3, DeleteObjectCommand as DeleteObjectCommand2 } from "@aws-sdk/client-s3";
9974
10381
  var AVATAR_SIZE = 192;
@@ -10021,7 +10428,7 @@ function avatarKeyPrefix() {
10021
10428
  return `${KEY_PREFIX2}/${getProfile()}/`;
10022
10429
  }
10023
10430
  function createAvatarsRouter() {
10024
- const app = new Hono18();
10431
+ const app = new Hono21();
10025
10432
  app.get("/avatars/slack", async (c) => {
10026
10433
  const ctx = await resolveAuthContext(c);
10027
10434
  if (!ctx) return c.json({ error: "not signed in" }, 401);
@@ -10070,7 +10477,7 @@ function createAvatarsRouter() {
10070
10477
  }
10071
10478
 
10072
10479
  // ../api/src/dashboard/members-routes.ts
10073
- import { Hono as Hono19 } from "hono";
10480
+ import { Hono as Hono22 } from "hono";
10074
10481
  function inviteLinkFor(c, token) {
10075
10482
  const url = new URL("/auth/invite", callbackUrl(c));
10076
10483
  url.searchParams.set("token", token);
@@ -10078,7 +10485,7 @@ function inviteLinkFor(c, token) {
10078
10485
  }
10079
10486
  var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
10080
10487
  function createMembersRouter() {
10081
- const members = new Hono19();
10488
+ const members = new Hono22();
10082
10489
  members.get("/", async (c) => {
10083
10490
  const ctx = await resolveAuthContext(c);
10084
10491
  if (ctx?.role !== "admin") return c.json({ error: "admin access required" }, 403);
@@ -10301,7 +10708,7 @@ function createMembersRouter() {
10301
10708
  }
10302
10709
 
10303
10710
  // ../api/src/dashboard/notifications-routes.ts
10304
- import { Hono as Hono20 } from "hono";
10711
+ import { Hono as Hono23 } from "hono";
10305
10712
 
10306
10713
  // ../api/src/store/notification-store.ts
10307
10714
  function rowToNotification(row) {
@@ -10553,7 +10960,7 @@ function startPushWatcher() {
10553
10960
 
10554
10961
  // ../api/src/dashboard/notifications-routes.ts
10555
10962
  function createNotificationsRouter() {
10556
- const notifications = new Hono20();
10963
+ const notifications = new Hono23();
10557
10964
  notifications.get("/", async (c) => {
10558
10965
  const auth = c.get("auth");
10559
10966
  const channelIds = getProfileChannelRegistry().filter((ch) => canSeeChannel(ch, auth)).map((ch) => ch.id);
@@ -10580,7 +10987,7 @@ function createNotificationsRouter() {
10580
10987
  return notifications;
10581
10988
  }
10582
10989
  function createThreadReadRouter() {
10583
- const threads = new Hono20();
10990
+ const threads = new Hono23();
10584
10991
  threads.post("/threads/:threadId/read", async (c) => {
10585
10992
  const { userId } = c.get("auth");
10586
10993
  const threadId = c.req.param("threadId");
@@ -10592,9 +10999,9 @@ function createThreadReadRouter() {
10592
10999
  }
10593
11000
 
10594
11001
  // ../api/src/dashboard/push-routes.ts
10595
- import { Hono as Hono21 } from "hono";
11002
+ import { Hono as Hono24 } from "hono";
10596
11003
  function createPushRouter() {
10597
- const push = new Hono21();
11004
+ const push = new Hono24();
10598
11005
  push.get("/key", (c) => c.json({ publicKey: getVapidPublicKey() }));
10599
11006
  push.post("/subscribe", async (c) => {
10600
11007
  const { userId } = c.get("auth");
@@ -10625,7 +11032,7 @@ function createPushRouter() {
10625
11032
  }
10626
11033
 
10627
11034
  // ../api/src/dashboard/mcp-oauth-routes.ts
10628
- import { Hono as Hono22 } from "hono";
11035
+ import { Hono as Hono25 } from "hono";
10629
11036
  var CONNECTIONS_PAGE = "/settings/connections";
10630
11037
  function callbackUri(c) {
10631
11038
  const proto = c.req.header("x-forwarded-proto") ?? "http";
@@ -10640,7 +11047,7 @@ function backToDashboard(c, to, params) {
10640
11047
  return c.redirect(`${target.pathname}${target.search}`);
10641
11048
  }
10642
11049
  function createMcpOAuthRouter() {
10643
- const app = new Hono22();
11050
+ const app = new Hono25();
10644
11051
  app.get("/oauth/:provider/start", async (c) => {
10645
11052
  const auth = c.get("auth");
10646
11053
  if (auth.role !== "admin") return c.json({ error: "admin access required" }, 403);
@@ -10767,7 +11174,7 @@ function createMcpOAuthRouter() {
10767
11174
  }
10768
11175
 
10769
11176
  // ../api/src/dashboard/mcp-routes.ts
10770
- import { Hono as Hono23 } from "hono";
11177
+ import { Hono as Hono26 } from "hono";
10771
11178
 
10772
11179
  // ../api/src/mcp/transport.ts
10773
11180
  var KINDS = ["inherit", "npx", "local", "http", "sse"];
@@ -10897,7 +11304,7 @@ function bindingsByConnection() {
10897
11304
  return map;
10898
11305
  }
10899
11306
  function createMcpRouter() {
10900
- const app = new Hono23();
11307
+ const app = new Hono26();
10901
11308
  app.get("/providers", async (c) => {
10902
11309
  const denied = requireAdmin(c.get("auth"));
10903
11310
  if (denied) return c.json({ error: denied }, 403);
@@ -11341,7 +11748,7 @@ var SYSTEM_PROMPT2 = `You review how an AI coding agent spent money in one chat
11341
11748
  - Only habits the user controls. Never mention billing, pricing, cost accounting or the app's own bugs, even if the transcript discusses them: the thread's topic is not a cost driver. Never suggest switching models; the user does not pick the model per turn.
11342
11749
  - cache_read and context_total are summed over every API call inside one run (turns=N), so a large figure means many steps, not a huge context. Do not call it context size.
11343
11750
  - Be brief: problem at most 6 words, detail one short clause with a number from the data (at most 15 words), fix one short imperative clause (at most 12 words).
11344
- - Write in the language the user writes in the transcript. If it is Traditional Chinese, use Taiwan wording, full-width punctuation, and keep technical terms in English.
11751
+ - Write headline, problem, detail and fix entirely in the output language given in the user message, whatever language the transcript is in. For Traditional Chinese (zh-TW), use Taiwan wording, full-width punctuation, Arabic numerals, and keep technical terms in English.
11345
11752
  - Never use em dashes or en dashes. No Markdown.`;
11346
11753
  function runLine(r, i) {
11347
11754
  const ctx = r.inputTokens + r.cacheReadTokens + r.cacheCreationTokens;
@@ -11379,7 +11786,7 @@ function parseJson(raw) {
11379
11786
  return null;
11380
11787
  }
11381
11788
  }
11382
- async function buildSessionRetro(threadId, complete) {
11789
+ async function buildSessionRetro(threadId, complete, locale = "en") {
11383
11790
  const runs2 = await threadRuns(getProfile(), threadId);
11384
11791
  if (runs2.length === 0) return null;
11385
11792
  const { data, error: error2 } = await getSupabaseClient().from("thread_replies").select("author, body, activities").eq("thread_id", threadId).is("archived_at", null).order("created_at", { ascending: true });
@@ -11399,7 +11806,9 @@ async function buildSessionRetro(threadId, complete) {
11399
11806
  channelId: thread.channel_id,
11400
11807
  tier: "cheap",
11401
11808
  system: SYSTEM_PROMPT2,
11402
- user: `Total: $${costUsd.toFixed(2)} over ${runs2.length} runs.
11809
+ user: `Output language: ${locale}
11810
+
11811
+ Total: $${costUsd.toFixed(2)} over ${runs2.length} runs.
11403
11812
 
11404
11813
  Runs (oldest first):
11405
11814
  ${runs2.map(runLine).join("\n")}
@@ -11425,9 +11834,9 @@ ${transcriptOf(data ?? [])}`
11425
11834
  }
11426
11835
 
11427
11836
  // ../api/src/dashboard/permission-routes.ts
11428
- import { Hono as Hono24 } from "hono";
11837
+ import { Hono as Hono27 } from "hono";
11429
11838
  function createPermissionRequestsRouter() {
11430
- const app = new Hono24();
11839
+ const app = new Hono27();
11431
11840
  app.post("/:id", async (c) => {
11432
11841
  const auth = c.get("auth");
11433
11842
  if (auth.role !== "admin") return c.json({ error: "only an admin can answer this" }, 403);
@@ -11457,7 +11866,7 @@ function createPermissionRequestsRouter() {
11457
11866
  }
11458
11867
 
11459
11868
  // ../api/src/dashboard/channel-greeting.ts
11460
- import { Hono as Hono25 } from "hono";
11869
+ import { Hono as Hono28 } from "hono";
11461
11870
  function eligible(ch) {
11462
11871
  return !!ch && !ch.isDefault && !ch.dmKey && !ch.agentName && !ch.archivedAt;
11463
11872
  }
@@ -11486,7 +11895,7 @@ function introOpening(channelName) {
11486
11895
  return `Welcome to #${channelName}. I'm reading this project's folder, docs, skills and automations to work out how I can help here. Below you'll find a short intro and a few first steps you can click to try.`;
11487
11896
  }
11488
11897
  function createChannelGreetingRouter(agent) {
11489
- const app = new Hono25();
11898
+ const app = new Hono28();
11490
11899
  app.get("/:id/greeting", async (c) => {
11491
11900
  const ctx = await resolveAuthContext(c);
11492
11901
  const ch = findChannelById(c.req.param("id"));
@@ -11544,7 +11953,7 @@ async function ensureIntroThread(ch) {
11544
11953
  }
11545
11954
 
11546
11955
  // ../api/src/dashboard/channel-suggest.ts
11547
- import { Hono as Hono26 } from "hono";
11956
+ import { Hono as Hono29 } from "hono";
11548
11957
  var CATEGORY_MAX_CHARS = 16;
11549
11958
  var CATEGORY_MAX_ITEMS = 30;
11550
11959
  var PROMPT_MAX_CHARS = 4e3;
@@ -11592,7 +12001,7 @@ function parseSuggestion(field, raw) {
11592
12001
  return items2.length ? items2.slice(0, CATEGORY_MAX_ITEMS).join("\n") : null;
11593
12002
  }
11594
12003
  function createChannelSuggestRouter(agent) {
11595
- const router = new Hono26();
12004
+ const router = new Hono29();
11596
12005
  router.post("/:id/suggest", async (c) => {
11597
12006
  const channel = findChannel(c.req.param("id"));
11598
12007
  if (!channel || !canSeeChannel(channel, c.get("auth"))) {
@@ -11630,7 +12039,7 @@ function createChannelSuggestRouter(agent) {
11630
12039
  }
11631
12040
 
11632
12041
  // ../api/src/dashboard/channel-members-routes.ts
11633
- import { Hono as Hono27 } from "hono";
12042
+ import { Hono as Hono30 } from "hono";
11634
12043
  async function isChannelAdmin(ctx, channelId) {
11635
12044
  if (ctx.role === "admin") return true;
11636
12045
  const membership = await getMembershipByUserId(ctx.workspaceId, ctx.userId);
@@ -11639,7 +12048,7 @@ async function isChannelAdmin(ctx, channelId) {
11639
12048
  return members.some((m) => m.membershipId === membership.id && m.role === "channel_admin");
11640
12049
  }
11641
12050
  function createChannelMembersRouter() {
11642
- const router = new Hono27();
12051
+ const router = new Hono30();
11643
12052
  router.get("/:id/members", async (c) => {
11644
12053
  const ctx = await resolveAuthContext(c);
11645
12054
  if (!ctx) return c.json({ error: "workspace access required" }, 403);
@@ -11709,7 +12118,7 @@ function createChannelMembersRouter() {
11709
12118
  }
11710
12119
 
11711
12120
  // ../api/src/dashboard/memories-routes.ts
11712
- import { Hono as Hono28 } from "hono";
12121
+ import { Hono as Hono31 } from "hono";
11713
12122
  async function readPatch(c) {
11714
12123
  const body = await c.req.json().catch(() => ({}));
11715
12124
  const patch = {};
@@ -11737,7 +12146,7 @@ var requireAgentMemory = async (c, next) => {
11737
12146
  await next();
11738
12147
  };
11739
12148
  function createMemoriesRouter() {
11740
- const router = new Hono28();
12149
+ const router = new Hono31();
11741
12150
  for (const path of [
11742
12151
  "/:id/memories",
11743
12152
  "/:id/memories/*",
@@ -11810,7 +12219,7 @@ function createMemoriesRouter() {
11810
12219
  return router;
11811
12220
  }
11812
12221
  function createScopedMemoriesRouter() {
11813
- const router = new Hono28();
12222
+ const router = new Hono31();
11814
12223
  router.use("*", requireAgentMemory);
11815
12224
  const workspace = (c) => ({
11816
12225
  scope: "workspace",
@@ -11870,9 +12279,9 @@ function createScopedMemoriesRouter() {
11870
12279
  }
11871
12280
 
11872
12281
  // ../api/src/dashboard/session-import-routes.ts
11873
- import { Hono as Hono29 } from "hono";
12282
+ import { Hono as Hono32 } from "hono";
11874
12283
  var MAX_FOLDERS2 = 20;
11875
- var DAY_MS = 24 * 60 * 60 * 1e3;
12284
+ var DAY_MS2 = 24 * 60 * 60 * 1e3;
11876
12285
  var IMPORT_RANGES = ["all", "7d", "latest5"];
11877
12286
  async function ask(agent, req) {
11878
12287
  const res = await agent.sessionImportRequest?.(req);
@@ -11889,7 +12298,7 @@ function hostUnavailable2(c, agent) {
11889
12298
  }
11890
12299
  function pickSessions(sessions2, range, now = Date.now()) {
11891
12300
  if (range === "latest5") return sessions2.slice(0, 5);
11892
- if (range === "7d") return sessions2.filter((s) => s.lastUsed >= now - 7 * DAY_MS);
12301
+ if (range === "7d") return sessions2.filter((s) => s.lastUsed >= now - 7 * DAY_MS2);
11893
12302
  return sessions2;
11894
12303
  }
11895
12304
  function channelForFolder(folder, channels) {
@@ -11976,7 +12385,7 @@ async function syncSession(agent, channelId, session, author, existing) {
11976
12385
  return messages.length;
11977
12386
  }
11978
12387
  function createSessionImportRouter(agent) {
11979
- const app = new Hono29();
12388
+ const app = new Hono32();
11980
12389
  const scanFolders = async () => {
11981
12390
  const scan = await ask(agent, { op: "scan", slug: getProfile() });
11982
12391
  return scan && importableFolders(scan.folders, getProfileChannelRegistry());
@@ -12244,7 +12653,7 @@ function registerDataRoutes(api, agent = {}) {
12244
12653
  categoryId: ch.categoryId,
12245
12654
  position: ch.position,
12246
12655
  // A DM is stored as "<a>, <b>"; each side sees the other's handle.
12247
- name: ch.dmKey ? ch.name.split(", ").filter((h) => h !== auth.handle).join(", ") || ch.name : ch.name,
12656
+ name: ch.dmKey && !ch.agentName ? ch.name.split(", ").filter((h) => h !== auth.handle).join(", ") || ch.name : ch.name,
12248
12657
  configured: true,
12249
12658
  cwd: ch.cwd,
12250
12659
  // Surfaces a rotted working directory in the sidebar instead of
@@ -12388,13 +12797,16 @@ function registerDataRoutes(api, agent = {}) {
12388
12797
  if (!await isFeatureEnabled(c, "session-retro")) return c.json({ error: "feature not enabled" }, 403);
12389
12798
  const complete = agent.completeMemoryExtraction;
12390
12799
  if (!complete) return c.json({ error: "host offline" }, 503);
12391
- const retro = await buildSessionRetro(c.req.param("threadTs"), complete);
12800
+ const body = await c.req.json().catch(() => ({}));
12801
+ const locale = typeof body.locale === "string" && /^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(body.locale) ? body.locale : "en";
12802
+ const retro = await buildSessionRetro(c.req.param("threadTs"), complete, locale);
12392
12803
  if (retro === "host-offline") return c.json({ error: "host offline" }, 503);
12393
12804
  if (!retro) return c.json({ error: "could not generate a retro" }, 502);
12394
12805
  return c.json(retro);
12395
12806
  });
12396
12807
  api.route("/automations", createAutomationWriteRouter());
12397
12808
  api.route("/billing", createBillingRouter());
12809
+ api.route("/chat", createContinuousChatRouter());
12398
12810
  api.route("/chat", createChatRouter(agent));
12399
12811
  api.route("/search", createSearchRouter());
12400
12812
  api.use("/tts/*", async (c, next) => {
@@ -12482,6 +12894,8 @@ function registerDataRoutes(api, agent = {}) {
12482
12894
  api.route("/", createUploadsRouter());
12483
12895
  api.route("/", createTranscribeRouter());
12484
12896
  api.route("/", createAutocompleteRouter());
12897
+ api.route("/", createDailyLineRouter());
12898
+ api.route("/", createChannelRouteRouter());
12485
12899
  api.route("/", createAvatarsRouter());
12486
12900
  api.get("/profiles", async (c) => {
12487
12901
  const active = getProfile();
@@ -12491,7 +12905,7 @@ function registerDataRoutes(api, agent = {}) {
12491
12905
  const running2 = new Set(await agent.listRunningProfiles?.() ?? []);
12492
12906
  const auth = c.get("auth");
12493
12907
  const [{ data: memberships }, workspaces] = await Promise.all([
12494
- getSupabaseClient().from("memberships").select("workspace_id").eq("user_id", auth.userId),
12908
+ getSupabaseClient().from("memberships").select("workspace_id").eq("user_id", auth.userId).eq("status", "active").eq("is_support", false),
12495
12909
  listWorkspaces()
12496
12910
  ]);
12497
12911
  const memberOf = new Set(
@@ -12579,7 +12993,7 @@ function registerDataRoutes(api, agent = {}) {
12579
12993
  // ../api/src/dashboard/device-auth-routes.ts
12580
12994
  import { verify } from "crypto";
12581
12995
  import { getConnInfo } from "@hono/node-server/conninfo";
12582
- import { Hono as Hono30 } from "hono";
12996
+ import { Hono as Hono33 } from "hono";
12583
12997
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
12584
12998
  function cleanText(value, max) {
12585
12999
  if (typeof value !== "string") return null;
@@ -12627,7 +13041,7 @@ async function boundWorkspaceIds(publicKey, userId) {
12627
13041
  return new Set(existing ? (await listDeviceWorkspaces(existing)).map((w) => w.id) : []);
12628
13042
  }
12629
13043
  function createDeviceAuthRouter() {
12630
- const app = new Hono30();
13044
+ const app = new Hono33();
12631
13045
  app.post("/code", async (c) => {
12632
13046
  const body = await readBody(c);
12633
13047
  const publicKey = typeof body["public_key"] === "string" ? body["public_key"] : "";
@@ -12946,7 +13360,7 @@ var workspaceRef = () => ({ kind: "workspace" });
12946
13360
  var channelRef = (c) => ({ kind: "channel", channelId: c.req.param("id") });
12947
13361
 
12948
13362
  // ../api/src/dashboard/output-styles-routes.ts
12949
- import { Hono as Hono31 } from "hono";
13363
+ import { Hono as Hono34 } from "hono";
12950
13364
  function requireAdmin3(auth) {
12951
13365
  return auth?.role === "admin" ? null : "admin access required";
12952
13366
  }
@@ -12966,7 +13380,7 @@ function failure(c, err) {
12966
13380
  return c.json({ error: message }, err instanceof OutputStyleConflictError ? 409 : 500);
12967
13381
  }
12968
13382
  function createOutputStylesRouter() {
12969
- const app = new Hono31();
13383
+ const app = new Hono34();
12970
13384
  app.get("/", (c) => {
12971
13385
  const auth = c.get("auth");
12972
13386
  const denied = requireAdmin3(auth);
@@ -13058,7 +13472,7 @@ function createOutputStylesRouter() {
13058
13472
  return app;
13059
13473
  }
13060
13474
  async function handleOutputStylesRequest(req) {
13061
- const app = new Hono31();
13475
+ const app = new Hono34();
13062
13476
  app.use("*", async (c, next) => {
13063
13477
  c.set("auth", { role: "admin" });
13064
13478
  await next();
@@ -13096,7 +13510,7 @@ async function viewerProfile(c, known) {
13096
13510
  return null;
13097
13511
  }
13098
13512
  function createGatedRouter(agent, register) {
13099
- const api = new Hono32();
13513
+ const api = new Hono35();
13100
13514
  api.use("*", async (c, next) => {
13101
13515
  const known = await listKnownWorkspaces();
13102
13516
  const fromHost = profileFromHost(trustedHost(c), known);
@@ -13148,7 +13562,7 @@ import sharp5 from "sharp";
13148
13562
 
13149
13563
  // src/dashboard/channels-routes.ts
13150
13564
  import { existsSync as existsSync20, mkdirSync as mkdirSync9 } from "fs";
13151
- import { Hono as Hono33 } from "hono";
13565
+ import { Hono as Hono36 } from "hono";
13152
13566
  function coerceAccess(raw) {
13153
13567
  if (raw === "open" || raw === "*" || raw === "all") return raw;
13154
13568
  if (Array.isArray(raw) && raw.every((v) => typeof v === "string")) return raw;
@@ -13220,7 +13634,7 @@ function toResponse3(channel) {
13220
13634
  };
13221
13635
  }
13222
13636
  function createChannelWriteRouter() {
13223
- const app = new Hono33();
13637
+ const app = new Hono36();
13224
13638
  app.post("/", async (c) => {
13225
13639
  const body = await c.req.json().catch(() => ({}));
13226
13640
  const name = typeof body["name"] === "string" ? body["name"].trim() : "";
@@ -13349,7 +13763,7 @@ function createChannelWriteRouter() {
13349
13763
  // src/dashboard/skills-routes-host.ts
13350
13764
  import { existsSync as existsSync21, statSync as statSync4 } from "fs";
13351
13765
  import { dirname as dirname8 } from "path";
13352
- import { Hono as Hono34 } from "hono";
13766
+ import { Hono as Hono37 } from "hono";
13353
13767
  function workspaceScope() {
13354
13768
  const claudeConfigDir = profileClaudeConfigDir();
13355
13769
  const cwd = defaultClaudeCwd();
@@ -13455,35 +13869,32 @@ var diskBackend = {
13455
13869
  write: writeSkillAndSync
13456
13870
  };
13457
13871
  function createWorkspaceSkillsRouter() {
13458
- const app = new Hono34();
13872
+ const app = new Hono37();
13459
13873
  mountSkillRoutes(app, "/skills", workspaceRef, diskBackend);
13460
13874
  return app;
13461
13875
  }
13462
13876
  function createChannelSkillsRouter() {
13463
- const app = new Hono34();
13877
+ const app = new Hono37();
13464
13878
  mountSkillRoutes(app, "/:id/skill-files", channelRef, diskBackend);
13465
13879
  return app;
13466
13880
  }
13467
13881
 
13468
13882
  // src/dashboard/agent-identities-host.ts
13469
- async function resolveAgentIdentities() {
13883
+ async function resolveAgentIdentities(viewer) {
13470
13884
  const settings = loadDashboardSettings();
13471
- const { cwd: defaultCwd } = resolveChannelConfig("");
13472
13885
  const main2 = [
13473
13886
  {
13474
13887
  name: BOT_DM_KEY,
13475
13888
  label: BOT_LABEL,
13476
13889
  kind: "main",
13477
- cwd: defaultCwd,
13478
13890
  model: settings.agentProfiles?.[BOT_DM_KEY]?.model,
13479
13891
  ...await loadBotIdentity()
13480
13892
  }
13481
13893
  ];
13482
13894
  return Promise.all(
13483
- main2.map(async ({ cwd, ...agent }) => {
13484
- const dm = await ensureAgentDmChannel(agent.name, {
13485
- name: agent.displayName ?? agent.label,
13486
- cwd
13895
+ main2.map(async (agent) => {
13896
+ const dm = await ensureAgentDmChannel(agent.name, viewer, {
13897
+ name: agent.displayName ?? agent.label
13487
13898
  });
13488
13899
  return { ...agent, channelId: dm.id };
13489
13900
  })
@@ -13500,9 +13911,9 @@ var PROVIDER_LABELS = {
13500
13911
  codex: "Codex"
13501
13912
  };
13502
13913
  var TTL_MS2 = 6e4;
13503
- var cache3 = /* @__PURE__ */ new Map();
13914
+ var cache4 = /* @__PURE__ */ new Map();
13504
13915
  function clearProviderStatusCache() {
13505
- cache3.clear();
13916
+ cache4.clear();
13506
13917
  }
13507
13918
  function binaryOnPath(bin) {
13508
13919
  try {
@@ -13580,11 +13991,11 @@ function withAuthFailure(status) {
13580
13991
  }
13581
13992
  function providerStatuses() {
13582
13993
  const key = getProfile();
13583
- const hit = cache3.get(key);
13994
+ const hit = cache4.get(key);
13584
13995
  let statuses = hit && Date.now() - hit.at < TTL_MS2 ? hit.statuses : void 0;
13585
13996
  if (!statuses) {
13586
13997
  statuses = ["claude", "codex"].map(probe2);
13587
- cache3.set(key, { at: Date.now(), statuses });
13998
+ cache4.set(key, { at: Date.now(), statuses });
13588
13999
  }
13589
14000
  return statuses.map((st) => st.runner === "claude" && st.connected ? withAuthFailure(st) : st);
13590
14001
  }
@@ -13595,7 +14006,7 @@ import { randomUUID as randomUUID4 } from "crypto";
13595
14006
  import { chmodSync, existsSync as existsSync23, mkdirSync as mkdirSync10, readFileSync as readFileSync16, writeFileSync as writeFileSync9 } from "fs";
13596
14007
  import { createRequire } from "module";
13597
14008
  import { dirname as dirname9, join as join15 } from "path";
13598
- import { Hono as Hono35 } from "hono";
14009
+ import { Hono as Hono38 } from "hono";
13599
14010
  var SESSION_TTL_MS = 10 * 6e4;
13600
14011
  var URL_WAIT_MS = 3e4;
13601
14012
  var TOKEN_WAIT_MS = 6e4;
@@ -13754,7 +14165,7 @@ function failure2(c, err) {
13754
14165
  return c.json({ error: err.message }, 500);
13755
14166
  }
13756
14167
  function createProviderLoginRouter() {
13757
- const app = new Hono35();
14168
+ const app = new Hono38();
13758
14169
  app.use("*", async (c, next) => {
13759
14170
  const denied = requireAdmin4(c.get("auth"));
13760
14171
  if (denied) return c.json({ error: denied }, 403);
@@ -13798,7 +14209,7 @@ function createProviderLoginRouter() {
13798
14209
  return app;
13799
14210
  }
13800
14211
  async function handleProviderLoginRequest(req) {
13801
- const app = new Hono35();
14212
+ const app = new Hono38();
13802
14213
  app.use("*", async (c, next) => {
13803
14214
  c.set("auth", { role: "admin" });
13804
14215
  await next();
@@ -13883,7 +14294,11 @@ function registerHostRoutes(api) {
13883
14294
  "/settings/bot",
13884
14295
  async (c) => c.json({ name: BOT_PROFILE_KEY, label: "Workspace Agent", ...await loadBotIdentity() })
13885
14296
  );
13886
- api.get("/settings/agents", async (c) => c.json({ agents: await resolveAgentIdentities() }));
14297
+ api.get("/settings/agents", async (c) => {
14298
+ const viewer = await agentViewer(c);
14299
+ if (!viewer) return c.json({ error: "not signed in" }, 401);
14300
+ return c.json({ agents: await resolveAgentIdentities(viewer) });
14301
+ });
13887
14302
  api.put("/settings/agents/:name", async (c) => {
13888
14303
  const body = await c.req.json().catch(() => ({}));
13889
14304
  const displayName = body["displayName"] === null || typeof body["displayName"] === "string" ? body["displayName"] : void 0;
@@ -14190,13 +14605,13 @@ function handleSessionImportRequest(req) {
14190
14605
  }
14191
14606
 
14192
14607
  // src/dashboard/docs-relay-host.ts
14193
- import { Hono as Hono36 } from "hono";
14608
+ import { Hono as Hono39 } from "hono";
14194
14609
  var RETURNED_HEADERS = ["content-type", "content-disposition", "content-security-policy", "cache-control"];
14195
14610
  async function handleDocsRequest(req) {
14196
14611
  return runRelayed(req, (app) => app.route("/channels", createDocsRouter({ gate: async (_c, next) => next() })));
14197
14612
  }
14198
14613
  async function runRelayed(req, register) {
14199
- const app = new Hono36();
14614
+ const app = new Hono39();
14200
14615
  app.use("*", async (c, next) => {
14201
14616
  c.set("auth", req.auth);
14202
14617
  await next();
@@ -14571,7 +14986,7 @@ function localAgentCallbacks(chatAgent) {
14571
14986
  suggestChannelField: (req) => suggestChannelField(req),
14572
14987
  listMissingCwds: () => auditChannelCwds().map((ch) => ch.id),
14573
14988
  listRunningProfiles: () => listProfiles().filter(isServiceRunning2),
14574
- getAgentIdentities: () => resolveAgentIdentities(),
14989
+ getAgentIdentities: (viewer) => resolveAgentIdentities(viewer),
14575
14990
  readDocShareBundle: (req) => readDocShareBundle(req.channelId ? { ...req, cwd: resolveChannelConfig(req.channelId).cwd } : req),
14576
14991
  listChannelSkills: (args) => {
14577
14992
  const { cwd, claudeConfigDir } = args.channelId ? resolveChannelConfig(args.channelId) : args;
@@ -14790,7 +15205,7 @@ import { join as join18 } from "path";
14790
15205
  import { serveStatic } from "@hono/node-server/serve-static";
14791
15206
 
14792
15207
  // ../api/src/dashboard/app-icon-routes.ts
14793
- import { Hono as Hono37 } from "hono";
15208
+ import { Hono as Hono40 } from "hono";
14794
15209
  var MANIFEST = {
14795
15210
  id: "/",
14796
15211
  name: "Flyspace",
@@ -14824,7 +15239,7 @@ async function resolvedProfileHost(c) {
14824
15239
  return profileFromHost(trustedHost(c), known);
14825
15240
  }
14826
15241
  function createAppIconRouter() {
14827
- const app = new Hono37();
15242
+ const app = new Hono40();
14828
15243
  app.get("/manifest.json", (c) => c.json(MANIFEST));
14829
15244
  app.get("/icons/app/:profile/:file", async (c) => {
14830
15245
  const profile = c.req.param("profile");
@@ -14902,9 +15317,49 @@ The JSON API is live under /api.` : "This install has no bundled Workspace UI.\n
14902
15317
  });
14903
15318
  }
14904
15319
 
15320
+ // src/dashboard/host-log-file.ts
15321
+ import { createWriteStream, fstatSync, mkdirSync as mkdirSync12, statSync as statSync7 } from "fs";
15322
+ import { join as join19 } from "path";
15323
+ var STAMPED = /^\[\d{4}-\d{2}-\d{2}T/;
15324
+ function stamp(text) {
15325
+ const ts2 = (/* @__PURE__ */ new Date()).toISOString();
15326
+ return text.split("\n").map((line, i, all) => i === all.length - 1 && line === "" || STAMPED.test(line) ? line : `[${ts2}] ${line}`).join("\n");
15327
+ }
15328
+ function alreadyRedirected(fd, file) {
15329
+ try {
15330
+ const a = fstatSync(fd);
15331
+ const b = statSync7(file);
15332
+ return a.dev === b.dev && a.ino === b.ino;
15333
+ } catch {
15334
+ return false;
15335
+ }
15336
+ }
15337
+ function tee(stream, fd, file) {
15338
+ if (alreadyRedirected(fd, file)) return;
15339
+ const out = createWriteStream(file, { flags: "a" });
15340
+ out.on("error", () => {
15341
+ });
15342
+ const write = stream.write.bind(stream);
15343
+ stream.write = ((chunk3, ...rest) => {
15344
+ const text = typeof chunk3 === "string" ? chunk3 : Buffer.from(chunk3).toString("utf8");
15345
+ out.write(stamp(text));
15346
+ return write(chunk3, ...rest);
15347
+ });
15348
+ }
15349
+ function ensureHostLogFiles() {
15350
+ try {
15351
+ mkdirSync12(paths.LOG_DIR, { recursive: true });
15352
+ } catch {
15353
+ return;
15354
+ }
15355
+ tee(process.stdout, 1, join19(paths.LOG_DIR, "host.log"));
15356
+ tee(process.stderr, 2, join19(paths.LOG_DIR, "host-error.log"));
15357
+ }
15358
+
14905
15359
  // src/dashboard/host-dashboard.ts
14906
15360
  async function startHostDashboard(preferredPort, host) {
14907
15361
  loadEnvFiles();
15362
+ ensureHostLogFiles();
14908
15363
  let lateCallbacks;
14909
15364
  let onHostConnected;
14910
15365
  const bootCallbacks = new Proxy({}, {
@@ -15024,8 +15479,8 @@ function openBrowser2(url) {
15024
15479
  }
15025
15480
  }
15026
15481
  function ensureWebBuild() {
15027
- if (existsSync28(join19(paths.WEB_ROOT, "dist", "index.html"))) return;
15028
- if (!existsSync28(join19(paths.WEB_ROOT, "package.json"))) return;
15482
+ if (existsSync28(join20(paths.WEB_ROOT, "dist", "index.html"))) return;
15483
+ if (!existsSync28(join20(paths.WEB_ROOT, "package.json"))) return;
15029
15484
  console.log(" packages/ui/dist missing, building the dashboard UI...");
15030
15485
  const result = spawnSync("pnpm", ["build"], {
15031
15486
  cwd: paths.WEB_ROOT,
@@ -15075,7 +15530,7 @@ async function runDashboard(args) {
15075
15530
  }
15076
15531
 
15077
15532
  // src/commands/workspace.ts
15078
- import { existsSync as existsSync29, mkdirSync as mkdirSync12, writeFileSync as writeFileSync10 } from "fs";
15533
+ import { existsSync as existsSync29, mkdirSync as mkdirSync13, writeFileSync as writeFileSync10 } from "fs";
15079
15534
  var USAGE7 = `
15080
15535
  Usage: flyspace workspace <subcommand> [options]
15081
15536
 
@@ -15184,7 +15639,7 @@ async function provisionChannels(specs) {
15184
15639
  }
15185
15640
  const cwd = expandPath(spec.cwd);
15186
15641
  if (!existsSync29(cwd)) {
15187
- mkdirSync12(cwd, { recursive: true });
15642
+ mkdirSync13(cwd, { recursive: true });
15188
15643
  console.log(` created cwd ${cwd}`);
15189
15644
  }
15190
15645
  await createChannel({ name: spec.name, cwd, position: index });
@@ -15261,10 +15716,10 @@ async function runReconcileCmd(args) {
15261
15716
  }
15262
15717
 
15263
15718
  // src/cli.ts
15264
- import { join as join20 } from "path";
15719
+ import { join as join21 } from "path";
15265
15720
  var home = flyspaceHome();
15266
15721
  if (home) {
15267
- const bin = join20(home, "bin");
15722
+ const bin = join21(home, "bin");
15268
15723
  const path = process.env.PATH ?? "";
15269
15724
  if (!path.split(":").includes(bin)) process.env.PATH = path ? `${bin}:${path}` : bin;
15270
15725
  }
@@ -15402,7 +15857,7 @@ async function main() {
15402
15857
  break;
15403
15858
  case "-v":
15404
15859
  case "--version":
15405
- printRaw("0.1.52");
15860
+ printRaw("0.1.53");
15406
15861
  break;
15407
15862
  case "-h":
15408
15863
  case "--help":