flyspace-cli 0.1.60 → 0.1.62

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.
@@ -2,66 +2,35 @@
2
2
  import { createRequire as __flyspaceCreateRequire } from 'node:module';
3
3
  const require = __flyspaceCreateRequire(import.meta.url);
4
4
  import {
5
- AGENT_AUTHOR,
6
- DEFAULT_AUTO_CONTINUE_LIMIT,
7
5
  DEFAULT_CODEX_MODEL,
8
- SUPPORT_BOT_AUTHOR,
9
- SYNCED_BOT_AUTHOR,
10
6
  SessionStore,
11
7
  __commonJS,
12
8
  __require,
13
9
  __toESM,
14
10
  databaseReachable,
15
- dmCwd,
16
- ensureAgentDmChannel,
17
- ensureChannelProvisioned,
18
11
  ensureDirs,
19
- ensureLogicalCwdDir,
20
- expandPath,
21
- findChannel,
22
- findChannelById,
23
- getChannelRegistry,
24
12
  getProfile,
25
- getProfileChannelRegistry,
26
13
  getR2Bucket,
27
14
  getR2Client,
28
15
  getSupabaseClient,
29
- isChannelAccessAllowed,
30
16
  isEffort,
31
- isHumanAuthor,
32
- isPermissionMode,
33
17
  loadConfig,
34
18
  loadEnvFiles,
35
19
  mcpStrictConfigEnabled,
36
- onChannelRegistryChange,
37
20
  paths,
38
- postToDashboardChannel,
39
- refreshChannelRegistry,
40
21
  requestAttachmentUrl,
41
22
  requestPluginSvg,
42
23
  requestShouldRespond,
43
24
  requireSlackBotToken,
44
- resolveAutoContinueLimit,
45
- resolveChannelPermissionMode,
46
- resolveChannelPrompt,
47
25
  resolveClaudeEffort,
48
26
  resolveCodexEffort,
49
- resolveCwd,
50
- resolveEffort,
51
- resolveLogicalCwd,
52
- resolveModel,
53
- resolveOwnPersona,
54
27
  runWithProfile,
55
28
  sendAgentFailure,
56
29
  setSupabaseClientFactory,
57
- startChannelRegistryPolling,
58
30
  sweepScratchDir,
59
- syncPostToDashboard,
60
- updateChannelById,
61
31
  uploadLocalImages,
62
- useHostDbWithoutCredentials,
63
- warnOnBrokenChannelCwds
64
- } from "./chunk-XYS7SVWC.js";
32
+ useHostDbWithoutCredentials
33
+ } from "./chunk-UZMHXV4D.js";
65
34
 
66
35
  // ../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
67
36
  var require_delayed_stream = __commonJS({
@@ -11626,8 +11595,8 @@ var require_follow_redirects = __commonJS({
11626
11595
  }
11627
11596
  return parsed;
11628
11597
  }
11629
- function resolveUrl(relative2, base) {
11630
- return useNativeURL ? new URL2(relative2, base) : parseUrl(url.resolve(base, relative2));
11598
+ function resolveUrl(relative3, base) {
11599
+ return useNativeURL ? new URL2(relative3, base) : parseUrl(url.resolve(base, relative3));
11631
11600
  }
11632
11601
  function validateUrl(input) {
11633
11602
  if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
@@ -13017,10 +12986,10 @@ var require_axios = __commonJS({
13017
12986
  }
13018
12987
  };
13019
12988
  var CanceledError$1 = CanceledError;
13020
- function settle(resolve7, reject, response) {
12989
+ function settle(resolve8, reject, response) {
13021
12990
  const validateStatus = response.config.validateStatus;
13022
12991
  if (!response.status || !validateStatus || validateStatus(response.status)) {
13023
- resolve7(response);
12992
+ resolve8(response);
13024
12993
  } else {
13025
12994
  reject(
13026
12995
  new AxiosError$1(
@@ -13612,7 +13581,7 @@ var require_axios = __commonJS({
13612
13581
  }
13613
13582
  var isHttpAdapterSupported = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
13614
13583
  var wrapAsync = (asyncExecutor) => {
13615
- return new Promise((resolve7, reject) => {
13584
+ return new Promise((resolve8, reject) => {
13616
13585
  let onDone;
13617
13586
  let isDone;
13618
13587
  const done = (value, isRejected) => {
@@ -13622,7 +13591,7 @@ var require_axios = __commonJS({
13622
13591
  };
13623
13592
  const _resolve = (value) => {
13624
13593
  done(value);
13625
- resolve7(value);
13594
+ resolve8(value);
13626
13595
  };
13627
13596
  const _reject = (reason) => {
13628
13597
  done(reason, true);
@@ -13669,7 +13638,7 @@ var require_axios = __commonJS({
13669
13638
  }
13670
13639
  };
13671
13640
  var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config) {
13672
- return wrapAsync(async function dispatchHttpRequest(resolve7, reject, onDone) {
13641
+ return wrapAsync(async function dispatchHttpRequest(resolve8, reject, onDone) {
13673
13642
  let { data, lookup: lookup2, family, httpVersion = 1, http2Options } = config;
13674
13643
  const { responseType, responseEncoding } = config;
13675
13644
  const method = config.method.toUpperCase();
@@ -13759,7 +13728,7 @@ var require_axios = __commonJS({
13759
13728
  }
13760
13729
  let convertedData;
13761
13730
  if (method !== "GET") {
13762
- return settle(resolve7, reject, {
13731
+ return settle(resolve8, reject, {
13763
13732
  status: 405,
13764
13733
  statusText: "method not allowed",
13765
13734
  headers: {},
@@ -13781,7 +13750,7 @@ var require_axios = __commonJS({
13781
13750
  } else if (responseType === "stream") {
13782
13751
  convertedData = stream__default["default"].Readable.from(convertedData);
13783
13752
  }
13784
- return settle(resolve7, reject, {
13753
+ return settle(resolve8, reject, {
13785
13754
  data: convertedData,
13786
13755
  status: 200,
13787
13756
  statusText: "OK",
@@ -14022,7 +13991,7 @@ var require_axios = __commonJS({
14022
13991
  };
14023
13992
  if (responseType === "stream") {
14024
13993
  response.data = responseStream;
14025
- settle(resolve7, reject, response);
13994
+ settle(resolve8, reject, response);
14026
13995
  } else {
14027
13996
  const responseBuffer = [];
14028
13997
  let totalResponseBytes = 0;
@@ -14072,7 +14041,7 @@ var require_axios = __commonJS({
14072
14041
  } catch (err) {
14073
14042
  return reject(AxiosError$1.from(err, null, config, response.request, response));
14074
14043
  }
14075
- settle(resolve7, reject, response);
14044
+ settle(resolve8, reject, response);
14076
14045
  });
14077
14046
  }
14078
14047
  abortEmitter.once("abort", (err) => {
@@ -14322,7 +14291,7 @@ var require_axios = __commonJS({
14322
14291
  };
14323
14292
  var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
14324
14293
  var xhrAdapter = isXHRAdapterSupported && function(config) {
14325
- return new Promise(function dispatchXhrRequest(resolve7, reject) {
14294
+ return new Promise(function dispatchXhrRequest(resolve8, reject) {
14326
14295
  const _config = resolveConfig(config);
14327
14296
  let requestData = _config.data;
14328
14297
  const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
@@ -14357,7 +14326,7 @@ var require_axios = __commonJS({
14357
14326
  };
14358
14327
  settle(
14359
14328
  function _resolve(value) {
14360
- resolve7(value);
14329
+ resolve8(value);
14361
14330
  done();
14362
14331
  },
14363
14332
  function _reject(err) {
@@ -14749,8 +14718,8 @@ var require_axios = __commonJS({
14749
14718
  config
14750
14719
  );
14751
14720
  !isStreamResponse && unsubscribe && unsubscribe();
14752
- return await new Promise((resolve7, reject) => {
14753
- settle(resolve7, reject, {
14721
+ return await new Promise((resolve8, reject) => {
14722
+ settle(resolve8, reject, {
14754
14723
  data: responseData,
14755
14724
  headers: AxiosHeaders$1.from(response.headers),
14756
14725
  status: response.status,
@@ -15154,8 +15123,8 @@ var require_axios = __commonJS({
15154
15123
  throw new TypeError("executor must be a function.");
15155
15124
  }
15156
15125
  let resolvePromise;
15157
- this.promise = new Promise(function promiseExecutor(resolve7) {
15158
- resolvePromise = resolve7;
15126
+ this.promise = new Promise(function promiseExecutor(resolve8) {
15127
+ resolvePromise = resolve8;
15159
15128
  });
15160
15129
  const token = this;
15161
15130
  this.promise.then((cancel) => {
@@ -15168,9 +15137,9 @@ var require_axios = __commonJS({
15168
15137
  });
15169
15138
  this.promise.then = (onfulfilled) => {
15170
15139
  let _resolve;
15171
- const promise = new Promise((resolve7) => {
15172
- token.subscribe(resolve7);
15173
- _resolve = resolve7;
15140
+ const promise = new Promise((resolve8) => {
15141
+ token.subscribe(resolve8);
15142
+ _resolve = resolve8;
15174
15143
  }).then(onfulfilled);
15175
15144
  promise.cancel = function reject() {
15176
15145
  token.unsubscribe(_resolve);
@@ -17456,7 +17425,7 @@ var require_MsEdgeTTS = __commonJS({
17456
17425
  };
17457
17426
  const ws = this._ws = this._isBrowser ? new isomorphic_ws_1.default(synthUrl) : new isomorphic_ws_1.default(synthUrl, { ...options, agent: this._agent });
17458
17427
  ws.binaryType = "arraybuffer";
17459
- return new Promise((resolve7, reject) => {
17428
+ return new Promise((resolve8, reject) => {
17460
17429
  let connecting = true;
17461
17430
  const connectionTimeout = this._connectionTimeoutMs ? setTimeout(() => {
17462
17431
  connecting = false;
@@ -17499,7 +17468,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17499
17468
  }
17500
17469
  }
17501
17470
  }
17502
- `, void 0, ws).then(resolve7, (error) => {
17471
+ `, void 0, ws).then(resolve8, (error) => {
17503
17472
  this._closeSocket(ws);
17504
17473
  reject(error);
17505
17474
  });
@@ -17641,12 +17610,12 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17641
17610
  this._log("<-", message);
17642
17611
  return;
17643
17612
  }
17644
- await new Promise((resolve7, reject) => {
17613
+ await new Promise((resolve8, reject) => {
17645
17614
  socket.send(message, (error) => {
17646
17615
  if (error)
17647
17616
  return reject(error);
17648
17617
  this._log("<-", message);
17649
- resolve7();
17618
+ resolve8();
17650
17619
  });
17651
17620
  });
17652
17621
  }
@@ -17682,8 +17651,8 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17682
17651
  * These, however, are not all. The complete list of voices supported by this module [can be found here](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support) (neural, standard, and preview).
17683
17652
  */
17684
17653
  getVoices() {
17685
- return new Promise((resolve7, reject) => {
17686
- axios_1.default.get(_MsEdgeTTS.VOICES_URL).then((res) => resolve7(res.data)).catch(reject);
17654
+ return new Promise((resolve8, reject) => {
17655
+ axios_1.default.get(_MsEdgeTTS.VOICES_URL).then((res) => resolve8(res.data)).catch(reject);
17687
17656
  });
17688
17657
  }
17689
17658
  /**
@@ -17786,7 +17755,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17786
17755
  const metadataFilePath = !!metadataStream ? (0, utils_1.joinPath)(dirPath, "metadata.json") : null;
17787
17756
  try {
17788
17757
  await Promise.all([
17789
- new Promise((resolve7, reject) => {
17758
+ new Promise((resolve8, reject) => {
17790
17759
  const writableAudioFile = audioStream.pipe(fs.createWriteStream(audioFilePath));
17791
17760
  audioStream.once("error", (e) => {
17792
17761
  writableAudioFile.destroy();
@@ -17794,7 +17763,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17794
17763
  });
17795
17764
  writableAudioFile.once("close", async () => {
17796
17765
  if (writableAudioFile.bytesWritten > 0) {
17797
- resolve7(audioFilePath);
17766
+ resolve8(audioFilePath);
17798
17767
  } else {
17799
17768
  reject(new Error("No audio data received"));
17800
17769
  fs.rmSync(audioFilePath, { force: true });
@@ -17802,9 +17771,9 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17802
17771
  });
17803
17772
  writableAudioFile.once("error", reject);
17804
17773
  }),
17805
- new Promise((resolve7, reject) => {
17774
+ new Promise((resolve8, reject) => {
17806
17775
  if (!metadataFilePath) {
17807
- return resolve7(null);
17776
+ return resolve8(null);
17808
17777
  }
17809
17778
  const metadataItems = { Metadata: [] };
17810
17779
  metadataStream.on("data", (chunk) => {
@@ -17814,7 +17783,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17814
17783
  metadataStream.once("close", () => {
17815
17784
  if (metadataItems.Metadata.length > 0) {
17816
17785
  fs.writeFileSync(metadataFilePath, JSON.stringify(metadataItems, null, 2));
17817
- resolve7(metadataFilePath);
17786
+ resolve8(metadataFilePath);
17818
17787
  } else {
17819
17788
  reject(new Error("No metadata received"));
17820
17789
  fs.rmSync(metadataFilePath, { force: true });
@@ -17914,6 +17883,547 @@ import { mkdtempSync, rmSync as rmSync2 } from "fs";
17914
17883
  import { tmpdir } from "os";
17915
17884
  import { join as join5 } from "path";
17916
17885
 
17886
+ // ../api/src/channels.ts
17887
+ import { createHash } from "crypto";
17888
+ import { existsSync, mkdirSync, realpathSync, statSync } from "fs";
17889
+ import { homedir } from "os";
17890
+ import { isAbsolute, relative, resolve, sep } from "path";
17891
+ function isPermissionMode(value) {
17892
+ return value === "bypass" || value === "ask";
17893
+ }
17894
+ function isLogicalCwd(p) {
17895
+ return /^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/.test(p);
17896
+ }
17897
+ function logicalRoot() {
17898
+ return process.env["FLYSPACE_ROOT"] || resolve(homedir(), "Flyspace");
17899
+ }
17900
+ var workspaceRoots = /* @__PURE__ */ new Map();
17901
+ var workspacePermissionModes = /* @__PURE__ */ new Map();
17902
+ var workspaceAutoContinueLimits = /* @__PURE__ */ new Map();
17903
+ var DEFAULT_AUTO_CONTINUE_LIMIT = 3;
17904
+ async function refreshWorkspaceAutoContinueLimits() {
17905
+ const { data, error } = await getSupabaseClient().from("workspaces").select("slug, auto_continue_limit");
17906
+ if (error) return;
17907
+ workspaceAutoContinueLimits = new Map(
17908
+ (data ?? []).filter((w) => typeof w.auto_continue_limit === "number").map((w) => [w.slug, w.auto_continue_limit])
17909
+ );
17910
+ }
17911
+ function resolveAutoContinueLimit(channelId) {
17912
+ const channel = channelId ? findChannel(channelId) : void 0;
17913
+ return workspaceAutoContinueLimits.get(channel?.profile ?? getProfile()) ?? DEFAULT_AUTO_CONTINUE_LIMIT;
17914
+ }
17915
+ var workspaceOwnPersona = /* @__PURE__ */ new Set();
17916
+ async function refreshWorkspaceOwnPersona() {
17917
+ const { data, error } = await getSupabaseClient().from("workspaces").select("slug, own_persona");
17918
+ if (error) return;
17919
+ workspaceOwnPersona = new Set(
17920
+ (data ?? []).filter((w) => w.own_persona === true).map((w) => w.slug)
17921
+ );
17922
+ }
17923
+ function resolveOwnPersona(channelId) {
17924
+ const channel = channelId ? findChannel(channelId) : void 0;
17925
+ return workspaceOwnPersona.has(channel?.profile ?? getProfile());
17926
+ }
17927
+ async function refreshWorkspacePermissionModes() {
17928
+ const { data, error } = await getSupabaseClient().from("workspaces").select("slug, permission_mode");
17929
+ if (error) return;
17930
+ workspacePermissionModes = new Map(
17931
+ (data ?? []).filter((w) => isPermissionMode(w.permission_mode)).map((w) => [w.slug, w.permission_mode])
17932
+ );
17933
+ }
17934
+ async function refreshWorkspaceRoots() {
17935
+ const { data, error } = await getSupabaseClient().from("workspaces").select("slug, root_path");
17936
+ if (error) return;
17937
+ workspaceRoots = new Map(
17938
+ (data ?? []).filter((w) => w.root_path).map((w) => [w.slug, expandPath(w.root_path)])
17939
+ );
17940
+ }
17941
+ function resolveLogicalCwd(p) {
17942
+ const [slug, name] = p.split("/");
17943
+ const root = workspaceRoots.get(slug);
17944
+ return root ? resolve(root, name) : resolve(logicalRoot(), p);
17945
+ }
17946
+ function isUnderLogicalRoot(cwd) {
17947
+ return [logicalRoot(), ...workspaceRoots.values()].some((r) => cwd.startsWith(r + sep));
17948
+ }
17949
+ function toLogicalCwd(cwd) {
17950
+ const fromRoot = relative(logicalRoot(), cwd).split(sep).join("/");
17951
+ if (isLogicalCwd(fromRoot)) return fromRoot;
17952
+ for (const [slug, root] of workspaceRoots) {
17953
+ const name = relative(root, cwd);
17954
+ if (isLogicalCwd(`${slug}/${name}`)) return `${slug}/${name}`;
17955
+ }
17956
+ return cwd;
17957
+ }
17958
+ function ensureLogicalCwdDir(cwd) {
17959
+ if (!isUnderLogicalRoot(cwd) || existsSync(cwd)) return;
17960
+ mkdirSync(cwd, { recursive: true });
17961
+ }
17962
+ function expandPath(p) {
17963
+ let expanded = p;
17964
+ if (expanded === "~") {
17965
+ expanded = homedir();
17966
+ } else if (expanded.startsWith("~/")) {
17967
+ expanded = resolve(homedir(), expanded.slice(2));
17968
+ }
17969
+ return isAbsolute(expanded) ? expanded : resolve(expanded);
17970
+ }
17971
+ function normaliseMemberEmails(raw) {
17972
+ if (!Array.isArray(raw)) return [];
17973
+ const seen = /* @__PURE__ */ new Set();
17974
+ for (const v of raw) {
17975
+ if (typeof v !== "string") continue;
17976
+ const email = v.trim().toLowerCase();
17977
+ if (email) seen.add(email);
17978
+ }
17979
+ return [...seen];
17980
+ }
17981
+ function canSeeChannel(channel, viewer) {
17982
+ if (channel.visibility === "public") return true;
17983
+ if (viewer?.role === "admin" && !channel.dmKey) return true;
17984
+ const email = viewer?.email?.trim().toLowerCase();
17985
+ return !!email && channel.memberEmails.includes(email);
17986
+ }
17987
+ function rowToChannel(row) {
17988
+ return {
17989
+ id: row.id,
17990
+ name: row.name,
17991
+ categoryId: row.category_id,
17992
+ cwd: isLogicalCwd(row.cwd) ? resolveLogicalCwd(row.cwd) : expandPath(row.cwd),
17993
+ externalChannelId: row.external_channel_id,
17994
+ model: row.model,
17995
+ effort: row.effort && isEffort(row.effort) ? row.effort : null,
17996
+ prompt: row.prompt?.trim() || null,
17997
+ topicCategories: normaliseTopicCategories(row.topic_categories),
17998
+ // A uuid[] arrives as a real array; anything else (an older row read
17999
+ // through a cached client, a hand-edited value) reads as "no MCP", which
18000
+ // is the safe direction for a list that decides which credentials a run
18001
+ // can reach.
18002
+ mcpConnections: Array.isArray(row.mcp_connections) ? row.mcp_connections.filter((id) => typeof id === "string") : [],
18003
+ access: row.access ?? void 0,
18004
+ visibility: row.visibility === "public" ? "public" : "private",
18005
+ memberEmails: normaliseMemberEmails(row.member_emails),
18006
+ // The CHECK constraint (0035, extended by 0070 for 'sandbox') means the
18007
+ // stored value is always one of these three, so this narrowing is
18008
+ // unreachable in practice and exists to satisfy the type. Note it cannot
18009
+ // degrade *safely* the way `mcpConnections` does: an unreadable value here
18010
+ // would drop a channel back to the unisolated runtime, which is why the
18011
+ // constraint is the real guarantee and this is only a type-level
18012
+ // fallback.
18013
+ runtime: row.runtime === "container" ? "container" : row.runtime === "sandbox" ? "sandbox" : "host",
18014
+ // Same shape and same defensive read as `mcpConnections`: anything that
18015
+ // isn't a clean string array reads as "no mounts", which exposes less
18016
+ // rather than more.
18017
+ mounts: Array.isArray(row.mounts) ? row.mounts.filter((p) => typeof p === "string").map(expandPath) : [],
18018
+ permissionMode: isPermissionMode(row.permission_mode) ? row.permission_mode : null,
18019
+ position: row.position,
18020
+ automations: row.automations ?? void 0,
18021
+ agentName: row.agent_name,
18022
+ dmKey: row.dm_key,
18023
+ isDefault: row.is_default === true,
18024
+ profile: row.profile,
18025
+ archivedAt: row.archived_at,
18026
+ greetedAt: row.greeted_at,
18027
+ createdAt: row.created_at,
18028
+ updatedAt: row.updated_at
18029
+ };
18030
+ }
18031
+ var registry = [];
18032
+ var byId = /* @__PURE__ */ new Map();
18033
+ var byExternalId = /* @__PURE__ */ new Map();
18034
+ var changeListeners = /* @__PURE__ */ new Set();
18035
+ var lastSnapshot;
18036
+ function indexRegistry(list) {
18037
+ registry = list;
18038
+ byId = new Map(list.map((c) => [c.id, c]));
18039
+ byExternalId = new Map(
18040
+ list.filter((c) => !!c.externalChannelId).map((c) => [c.externalChannelId, c])
18041
+ );
18042
+ }
18043
+ async function refreshChannelRegistry() {
18044
+ const rootsBefore = JSON.stringify([...workspaceRoots]);
18045
+ await Promise.all([
18046
+ refreshWorkspaceRoots(),
18047
+ refreshWorkspacePermissionModes(),
18048
+ refreshWorkspaceOwnPersona(),
18049
+ refreshWorkspaceAutoContinueLimits()
18050
+ ]);
18051
+ if (JSON.stringify([...workspaceRoots]) !== rootsBefore) lastSnapshot = void 0;
18052
+ const { data, error } = await getSupabaseClient().from("channels").select("*").order("position", { ascending: true });
18053
+ if (error) {
18054
+ console.error("[channels] refreshChannelRegistry failed:", error.message);
18055
+ return;
18056
+ }
18057
+ const rows2 = data ?? [];
18058
+ const snapshot2 = JSON.stringify(
18059
+ rows2,
18060
+ (key, value) => key === "updated_at" || key === "created_at" ? void 0 : value
18061
+ );
18062
+ if (snapshot2 === lastSnapshot) return;
18063
+ lastSnapshot = snapshot2;
18064
+ indexRegistry(rows2.map(rowToChannel));
18065
+ for (const cb of changeListeners) {
18066
+ try {
18067
+ cb();
18068
+ } catch (err) {
18069
+ console.error("[channels] onChannelRegistryChange listener failed:", err);
18070
+ }
18071
+ }
18072
+ }
18073
+ function getChannelRegistry() {
18074
+ return registry;
18075
+ }
18076
+ function getProfileChannelRegistry() {
18077
+ const profile = getProfile();
18078
+ return registry.filter((ch) => ch.profile === profile);
18079
+ }
18080
+ function onChannelRegistryChange(cb) {
18081
+ changeListeners.add(cb);
18082
+ return () => changeListeners.delete(cb);
18083
+ }
18084
+ function findChannelById(id) {
18085
+ return byId.get(id);
18086
+ }
18087
+ function findChannelByExternalId(externalId) {
18088
+ return byExternalId.get(externalId);
18089
+ }
18090
+ function agentDmKey(agentName, userId) {
18091
+ return `agent:${agentName}:${userId}`;
18092
+ }
18093
+ function dmCwd(dmKey, profile = getProfile()) {
18094
+ return `${profile}/dm-${createHash("sha256").update(dmKey).digest("hex").slice(0, 24)}`;
18095
+ }
18096
+ function findChannelByAgentName(agentName, userId) {
18097
+ const dmKey = agentDmKey(agentName, userId);
18098
+ return getProfileChannelRegistry().find((c) => c.agentName === agentName && c.dmKey === dmKey);
18099
+ }
18100
+ function findChannel(ref) {
18101
+ if (!ref) return void 0;
18102
+ return byId.get(ref) ?? byExternalId.get(ref) ?? registry.find((c) => c.name === ref || c.name === ref.replace(/^#/, ""));
18103
+ }
18104
+ var DEFAULT_POLL_INTERVAL_MS = 2e4;
18105
+ var pollTimer;
18106
+ var realtimeChannel;
18107
+ function startChannelRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS) {
18108
+ stopChannelRegistryPolling();
18109
+ pollTimer = setInterval(() => void refreshChannelRegistry(), intervalMs);
18110
+ try {
18111
+ realtimeChannel = getSupabaseClient().channel("channels-registry").on(
18112
+ "postgres_changes",
18113
+ { event: "*", schema: "public", table: "channels" },
18114
+ () => void refreshChannelRegistry()
18115
+ ).subscribe();
18116
+ } catch (err) {
18117
+ console.warn(
18118
+ "[channels] realtime subscribe failed \u2014 falling back to polling only:",
18119
+ err.message
18120
+ );
18121
+ }
18122
+ return stopChannelRegistryPolling;
18123
+ }
18124
+ function stopChannelRegistryPolling() {
18125
+ if (pollTimer) clearInterval(pollTimer);
18126
+ pollTimer = void 0;
18127
+ if (realtimeChannel) {
18128
+ void getSupabaseClient().removeChannel(realtimeChannel);
18129
+ realtimeChannel = void 0;
18130
+ }
18131
+ }
18132
+ function isCwdUsable(cwd) {
18133
+ try {
18134
+ return existsSync(cwd) && statSync(cwd).isDirectory();
18135
+ } catch {
18136
+ return false;
18137
+ }
18138
+ }
18139
+ function auditChannelCwds(list = registry) {
18140
+ return list.filter((ch) => ch.cwd && !isCwdUsable(ch.cwd));
18141
+ }
18142
+ function warnOnBrokenChannelCwds(list = registry) {
18143
+ const broken = auditChannelCwds(list);
18144
+ for (const ch of broken) {
18145
+ console.warn(
18146
+ `[channels] "${ch.name}" (${ch.id}): cwd "${ch.cwd}" does not exist \u2014 the agent will fall back to CLAUDE_CWD. Fix it in the channel's settings.`
18147
+ );
18148
+ }
18149
+ return broken;
18150
+ }
18151
+ function resolveChannelCwd(channelId) {
18152
+ if (!channelId) return void 0;
18153
+ const entry = findChannel(channelId);
18154
+ if (!entry?.cwd) return void 0;
18155
+ if (!isCwdUsable(entry.cwd)) {
18156
+ console.warn(
18157
+ `[channels] ${channelId}: cwd "${entry.cwd}" does not exist \u2014 falling back to CLAUDE_CWD`
18158
+ );
18159
+ return void 0;
18160
+ }
18161
+ return entry.cwd;
18162
+ }
18163
+ function isChannelAccessAllowed(channelId, userId) {
18164
+ if (!channelId) return false;
18165
+ const access = findChannel(channelId)?.access;
18166
+ if (!access) return false;
18167
+ if (typeof access === "string") {
18168
+ return access === "open" || access === "*" || access === "all";
18169
+ }
18170
+ return !!userId && access.includes(userId);
18171
+ }
18172
+ function resolveCwd(explicitCwd, channelId, fallback) {
18173
+ if (explicitCwd) return explicitCwd;
18174
+ return resolveChannelCwd(channelId) ?? fallback;
18175
+ }
18176
+ function resolveChannelModel(channelId) {
18177
+ if (!channelId) return void 0;
18178
+ return findChannel(channelId)?.model?.trim() || void 0;
18179
+ }
18180
+ function resolveChannelEffort(channelId) {
18181
+ if (!channelId) return void 0;
18182
+ return findChannel(channelId)?.effort ?? void 0;
18183
+ }
18184
+ function resolveChannelPermissionMode(channelId) {
18185
+ const channel = channelId ? findChannel(channelId) : void 0;
18186
+ return channel?.permissionMode ?? workspacePermissionModes.get(channel?.profile ?? getProfile()) ?? "bypass";
18187
+ }
18188
+ function resolveChannelPrompt(channelId) {
18189
+ if (!channelId) return void 0;
18190
+ return findChannel(channelId)?.prompt?.trim() || void 0;
18191
+ }
18192
+ function resolveModel(explicitModel, channelId, fallback) {
18193
+ if (explicitModel?.trim()) return explicitModel.trim();
18194
+ return resolveChannelModel(channelId) ?? fallback;
18195
+ }
18196
+ function resolveEffort(explicitEffort, channelId, fallback) {
18197
+ if (explicitEffort) return explicitEffort;
18198
+ return resolveChannelEffort(channelId) ?? fallback;
18199
+ }
18200
+ function normaliseTopicCategories(value) {
18201
+ if (!Array.isArray(value)) return [];
18202
+ const out = [];
18203
+ for (const v of value) {
18204
+ const t = typeof v === "string" ? v.trim() : "";
18205
+ if (t && !out.includes(t)) out.push(t);
18206
+ }
18207
+ return out;
18208
+ }
18209
+ function toRow(input) {
18210
+ const row = {};
18211
+ if (input.name !== void 0) row["name"] = input.name;
18212
+ if (input.cwd !== void 0) row["cwd"] = isLogicalCwd(input.cwd) ? input.cwd : toLogicalCwd(expandPath(input.cwd));
18213
+ if (input.categoryId !== void 0) row["category_id"] = input.categoryId;
18214
+ if (input.externalChannelId !== void 0) row["external_channel_id"] = input.externalChannelId;
18215
+ if (input.model !== void 0) row["model"] = input.model;
18216
+ if (input.effort !== void 0) row["effort"] = input.effort;
18217
+ if (input.prompt !== void 0) row["prompt"] = input.prompt?.trim() || null;
18218
+ if (input.topicCategories !== void 0) {
18219
+ const list = normaliseTopicCategories(input.topicCategories);
18220
+ row["topic_categories"] = list.length ? list : null;
18221
+ }
18222
+ if (input.access !== void 0) row["access"] = input.access;
18223
+ if (input.visibility !== void 0) row["visibility"] = input.visibility;
18224
+ if (input.memberEmails !== void 0) {
18225
+ row["member_emails"] = normaliseMemberEmails(input.memberEmails);
18226
+ }
18227
+ if (input.runtime !== void 0) row["runtime"] = input.runtime;
18228
+ if (input.mounts !== void 0) {
18229
+ row["mounts"] = input.mounts.map((p) => p.trim()).filter(Boolean).map(expandPath);
18230
+ }
18231
+ if (input.permissionMode !== void 0) row["permission_mode"] = input.permissionMode;
18232
+ if (input.position !== void 0) row["position"] = input.position;
18233
+ if (input.automations !== void 0) row["automations"] = input.automations;
18234
+ if (input.agentName !== void 0) row["agent_name"] = input.agentName;
18235
+ if (input.dmKey !== void 0) row["dm_key"] = input.dmKey;
18236
+ if (input.isDefault !== void 0) row["is_default"] = input.isDefault;
18237
+ if (input.mcpConnections !== void 0) row["mcp_connections"] = input.mcpConnections;
18238
+ if (input.archivedAt !== void 0) row["archived_at"] = input.archivedAt;
18239
+ return row;
18240
+ }
18241
+ var ChannelCwdError = class extends Error {
18242
+ constructor(message) {
18243
+ super(message);
18244
+ this.name = "ChannelCwdError";
18245
+ }
18246
+ };
18247
+ function realpathOrSelf(p) {
18248
+ try {
18249
+ return realpathSync(p);
18250
+ } catch {
18251
+ return p;
18252
+ }
18253
+ }
18254
+ async function assertCwdInWorkspace(profile, cwd) {
18255
+ if (isLogicalCwd(cwd)) {
18256
+ if (cwd.split("/")[0] !== profile) {
18257
+ throw new ChannelCwdError(`Folder "${cwd}" belongs to another workspace.`);
18258
+ }
18259
+ return cwd;
18260
+ }
18261
+ const logical = relative(logicalRoot(), cwd).split(sep).join("/");
18262
+ if (isLogicalCwd(logical)) return assertCwdInWorkspace(profile, logical);
18263
+ const { data, error } = await getSupabaseClient().from("workspaces").select("slug, root_path");
18264
+ if (error) throw new Error(error.message);
18265
+ const workspaces = data ?? [];
18266
+ const ownRoot = workspaces.find((w) => w.slug === profile)?.root_path;
18267
+ const home = ownRoot?.match(/^(\/Users\/[^/]+|\/home\/[^/]+|\/root)(?=\/|$)/)?.[1];
18268
+ const absolute = home && (cwd === "~" || cwd.startsWith("~/")) ? resolve(home, cwd.slice(2)) : expandPath(cwd);
18269
+ const path = realpathOrSelf(absolute);
18270
+ const roots = workspaces.filter((w) => w.root_path).map((w) => ({ slug: w.slug, root: realpathOrSelf(expandPath(w.root_path)) }));
18271
+ const owner = roots.filter(({ root }) => path === root || path.startsWith(root + sep)).sort((a, b) => b.root.length - a.root.length)[0];
18272
+ if (owner ? owner.slug !== profile : roots.some((r) => r.slug === profile)) {
18273
+ throw new ChannelCwdError(
18274
+ owner ? `Folder "${cwd}" belongs to the "${owner.slug}" workspace.` : `Folder "${cwd}" is outside this workspace's folder.`
18275
+ );
18276
+ }
18277
+ return absolute;
18278
+ }
18279
+ async function createChannel(input) {
18280
+ input = { ...input, cwd: await assertCwdInWorkspace(getProfile(), input.cwd) };
18281
+ const { data, error } = await getSupabaseClient().from("channels").insert({ ...toRow(input), profile: getProfile() }).select().single();
18282
+ if (error) throw new Error(error.message);
18283
+ const channel = rowToChannel(data);
18284
+ if (channel.cwd && !isLogicalCwd(input.cwd) && !isCwdUsable(channel.cwd)) {
18285
+ try {
18286
+ mkdirSync(channel.cwd, { recursive: true });
18287
+ } catch (err) {
18288
+ console.error(`[channels] failed to create cwd for "${channel.name}":`, err.message);
18289
+ }
18290
+ }
18291
+ await refreshChannelRegistry();
18292
+ return channel;
18293
+ }
18294
+ var DefaultChannelError = class extends Error {
18295
+ constructor() {
18296
+ super("The default channel must stay public and cannot be renamed or archived.");
18297
+ this.name = "DefaultChannelError";
18298
+ }
18299
+ };
18300
+ async function updateChannelById(id, patch) {
18301
+ const existing = findChannelById(id);
18302
+ if (existing?.isDefault && (patch.visibility === "private" || patch.archivedAt || patch.isDefault === false || patch.name !== void 0 && patch.name.trim() !== existing.name)) {
18303
+ throw new DefaultChannelError();
18304
+ }
18305
+ if (patch.cwd !== void 0 && existing && patch.cwd === existing.cwd) {
18306
+ const { cwd: _unchanged, ...rest } = patch;
18307
+ patch = rest;
18308
+ }
18309
+ if (patch.cwd !== void 0) {
18310
+ patch = { ...patch, cwd: await assertCwdInWorkspace(existing?.profile ?? getProfile(), patch.cwd) };
18311
+ }
18312
+ const { data, error } = await getSupabaseClient().from("channels").update({ ...toRow(patch), updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).select().single();
18313
+ if (error) throw new Error(error.message);
18314
+ await refreshChannelRegistry();
18315
+ return rowToChannel(data);
18316
+ }
18317
+ async function markChannelGreeted(id) {
18318
+ const { data, error } = await getSupabaseClient().from("channels").update({ greeted_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).is("greeted_at", null).select("id");
18319
+ if (error) throw new Error(error.message);
18320
+ await refreshChannelRegistry();
18321
+ return (data ?? []).length > 0;
18322
+ }
18323
+ async function updateChannelsMcpConnections(updates) {
18324
+ if (!updates.length) return;
18325
+ const supabase = getSupabaseClient();
18326
+ for (const update of updates) {
18327
+ const { error } = await supabase.from("channels").update({ mcp_connections: update.mcpConnections, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", update.id);
18328
+ if (error) throw new Error(`Failed to update channel ${update.id}: ${error.message}`);
18329
+ }
18330
+ await refreshChannelRegistry();
18331
+ }
18332
+ function defaultFallbackCwd() {
18333
+ return process.env["CLAUDE_CWD"] ?? process.cwd();
18334
+ }
18335
+ async function ensureChannelProvisioned(externalChannelId, opts = {}) {
18336
+ const existing = findChannelByExternalId(externalChannelId);
18337
+ if (existing) {
18338
+ if (existing.profile !== getProfile()) return null;
18339
+ if (existing.name === externalChannelId && opts.name && opts.name !== externalChannelId) {
18340
+ try {
18341
+ return await updateChannelById(existing.id, { name: opts.name });
18342
+ } catch (err) {
18343
+ console.error(`[channels] failed to heal name for ${externalChannelId}:`, err);
18344
+ return existing;
18345
+ }
18346
+ }
18347
+ return existing;
18348
+ }
18349
+ try {
18350
+ const created = await createChannel({
18351
+ name: opts.name ?? externalChannelId,
18352
+ cwd: opts.fallbackCwd ?? defaultFallbackCwd(),
18353
+ externalChannelId
18354
+ });
18355
+ console.log(`[channels] auto-provisioned a new channel for Slack channel ${externalChannelId}`);
18356
+ return created;
18357
+ } catch (err) {
18358
+ await refreshChannelRegistry();
18359
+ const raced = findChannelByExternalId(externalChannelId);
18360
+ if (raced) return raced.profile === getProfile() ? raced : null;
18361
+ throw err;
18362
+ }
18363
+ }
18364
+ async function ensureAgentDmChannel(agentName, viewer, opts) {
18365
+ const existing = findChannelByAgentName(agentName, viewer.userId);
18366
+ if (existing) {
18367
+ return existing.name === opts.name ? existing : updateChannelById(existing.id, { name: opts.name });
18368
+ }
18369
+ const dmKey = agentDmKey(agentName, viewer.userId);
18370
+ try {
18371
+ return await createChannel({
18372
+ name: opts.name,
18373
+ cwd: dmCwd(dmKey),
18374
+ visibility: "private",
18375
+ memberEmails: [viewer.email],
18376
+ agentName,
18377
+ dmKey
18378
+ });
18379
+ } catch (err) {
18380
+ await refreshChannelRegistry();
18381
+ const raced = findChannelByAgentName(agentName, viewer.userId);
18382
+ if (raced) return raced;
18383
+ throw err;
18384
+ }
18385
+ }
18386
+ async function ensureGeneralChannel() {
18387
+ const find = () => getProfileChannelRegistry().find((c) => c.isDefault);
18388
+ const existing = find();
18389
+ if (existing) return existing;
18390
+ try {
18391
+ return await createChannel({
18392
+ name: "general",
18393
+ cwd: `${getProfile()}/general`,
18394
+ visibility: "public",
18395
+ isDefault: true
18396
+ });
18397
+ } catch (err) {
18398
+ await refreshChannelRegistry();
18399
+ const raced = find();
18400
+ if (raced) return raced;
18401
+ throw err;
18402
+ }
18403
+ }
18404
+ async function ensureMemberDmChannel(a, b) {
18405
+ const dmKey = [a.userId, b.userId].sort().join(":");
18406
+ const find = () => [...getProfileChannelRegistry()].find((c) => c.dmKey === dmKey && c.profile === getProfile());
18407
+ const existing = find();
18408
+ if (existing) return existing;
18409
+ try {
18410
+ return await createChannel({
18411
+ name: `${a.handle}, ${b.handle}`,
18412
+ // Hash the whole key: a prefix of the sorted ids is just the first user's
18413
+ // id, which put every DM that user sorts first in into one shared folder.
18414
+ cwd: dmCwd(dmKey),
18415
+ visibility: "private",
18416
+ memberEmails: [a.email, b.email],
18417
+ dmKey
18418
+ });
18419
+ } catch (err) {
18420
+ await refreshChannelRegistry();
18421
+ const raced = find();
18422
+ if (raced) return raced;
18423
+ throw err;
18424
+ }
18425
+ }
18426
+
17917
18427
  // ../api/src/dashboard/auth-context.ts
17918
18428
  import { HTTPException } from "hono/http-exception";
17919
18429
  import { isAuthApiError, isAuthRetryableFetchError } from "@supabase/supabase-js";
@@ -18593,8 +19103,8 @@ async function resolveAuthContextUncached(c) {
18593
19103
  }
18594
19104
 
18595
19105
  // ../api/src/dashboard/settings.ts
18596
- import { readFileSync, existsSync } from "fs";
18597
- import { resolve } from "path";
19106
+ import { readFileSync, existsSync as existsSync2 } from "fs";
19107
+ import { resolve as resolve2 } from "path";
18598
19108
 
18599
19109
  // ../api/src/store/workspace-settings-store.ts
18600
19110
  var BRANDING_DEFAULTS = {
@@ -18707,7 +19217,7 @@ function localDefaults() {
18707
19217
  }
18708
19218
  var AUTO_TITLE_PROMPT_MAX = 2e3;
18709
19219
  function readSettingsFile() {
18710
- if (!existsSync(paths.DASHBOARD_SETTINGS_FILE)) return null;
19220
+ if (!existsSync2(paths.DASHBOARD_SETTINGS_FILE)) return null;
18711
19221
  try {
18712
19222
  const raw = JSON.parse(readFileSync(paths.DASHBOARD_SETTINGS_FILE, "utf-8"));
18713
19223
  return raw && typeof raw === "object" ? raw : null;
@@ -18756,15 +19266,15 @@ async function saveWorkspaceBranding(patch, profile = getProfile()) {
18756
19266
  return brandingToSettings(await upsertWorkspaceBranding(profile, next));
18757
19267
  }
18758
19268
  function defaultPromptPath() {
18759
- return resolve(paths.PACKAGE_ROOT, "system.default.md");
19269
+ return resolve2(paths.PACKAGE_ROOT, "system.default.md");
18760
19270
  }
18761
19271
  function readDefaultPrompt() {
18762
19272
  const path = defaultPromptPath();
18763
- return existsSync(path) ? readFileSync(path, "utf-8").trim() : "";
19273
+ return existsSync2(path) ? readFileSync(path, "utf-8").trim() : "";
18764
19274
  }
18765
19275
  function loadWorkspacePrompt() {
18766
19276
  const defaultPrompt = readDefaultPrompt();
18767
- const custom = existsSync(paths.PROMPT_FILE);
19277
+ const custom = existsSync2(paths.PROMPT_FILE);
18768
19278
  return {
18769
19279
  prompt: custom ? readFileSync(paths.PROMPT_FILE, "utf-8").trim() : defaultPrompt,
18770
19280
  defaultPrompt,
@@ -18798,9 +19308,9 @@ async function agentViewer(c) {
18798
19308
 
18799
19309
  // src/claude/agent.ts
18800
19310
  import { spawn } from "child_process";
18801
- import { existsSync as existsSync6, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
18802
- import { resolve as resolve3, resolve as resolvePath } from "path";
18803
- import { homedir as homedir2 } from "os";
19311
+ import { existsSync as existsSync7, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
19312
+ import { resolve as resolve4, resolve as resolvePath } from "path";
19313
+ import { homedir as homedir3 } from "os";
18804
19314
  import { randomUUID } from "crypto";
18805
19315
 
18806
19316
  // ../api/src/claude/models.ts
@@ -18907,12 +19417,12 @@ function modelLabel(value) {
18907
19417
 
18908
19418
  // src/claude/container.ts
18909
19419
  import { execFileSync } from "child_process";
18910
- import { createHash } from "crypto";
18911
- import { existsSync as existsSync3, mkdirSync as mkdirSync2 } from "fs";
19420
+ import { createHash as createHash2 } from "crypto";
19421
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3 } from "fs";
18912
19422
  import { join as join2 } from "path";
18913
19423
 
18914
19424
  // src/claude/mounts.ts
18915
- import { existsSync as existsSync2, lstatSync, mkdirSync, readlinkSync, symlinkSync, unlinkSync } from "fs";
19425
+ import { existsSync as existsSync3, lstatSync, mkdirSync as mkdirSync2, readlinkSync, symlinkSync, unlinkSync } from "fs";
18916
19426
  import { basename, join } from "path";
18917
19427
  var MOUNTS_DIR = "mounts";
18918
19428
  function resolveMounts(paths2) {
@@ -18937,11 +19447,11 @@ function materialiseMountLinks(cwd, mounts) {
18937
19447
  if (mounts.length === 0) return [];
18938
19448
  const problems = [];
18939
19449
  const root = join(cwd, MOUNTS_DIR);
18940
- mkdirSync(root, { recursive: true });
19450
+ mkdirSync2(root, { recursive: true });
18941
19451
  for (const repo of mounts) {
18942
19452
  const link = join(root, repo.name);
18943
19453
  try {
18944
- if (existsSync2(link) || isBrokenSymlink(link)) {
19454
+ if (existsSync3(link) || isBrokenSymlink(link)) {
18945
19455
  if (!lstatSync(link).isSymbolicLink()) {
18946
19456
  problems.push(`${link} exists and is not a symlink \u2014 leaving it alone`);
18947
19457
  continue;
@@ -19006,7 +19516,7 @@ function memoryLimit() {
19006
19516
  return process.env["FLYSPACE_AGENT_MEMORY"]?.trim() || "2g";
19007
19517
  }
19008
19518
  function containerHomeFor(cwd) {
19009
- const digest = createHash("sha256").update(cwd).digest("hex").slice(0, 12);
19519
+ const digest = createHash2("sha256").update(cwd).digest("hex").slice(0, 12);
19010
19520
  const label = (cwd.split("/").pop() || "channel").replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 32);
19011
19521
  return join2(paths.CONTAINER_HOMES_DIR, `${label}-${digest}`);
19012
19522
  }
@@ -19031,7 +19541,7 @@ function rewriteArgsForContainer(args) {
19031
19541
  function buildContainerSpawn(input) {
19032
19542
  const home = containerHomeFor(input.cwd);
19033
19543
  for (const dir of [home, paths.SCRATCH_DIR]) {
19034
- if (!existsSync3(dir)) mkdirSync2(dir, { recursive: true });
19544
+ if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
19035
19545
  }
19036
19546
  const containerName = `flyspace-agent-${input.runId}`;
19037
19547
  const env = buildContainerEnv(input.hostEnv);
@@ -19127,21 +19637,21 @@ function userFlags() {
19127
19637
 
19128
19638
  // src/claude/sandbox.ts
19129
19639
  import { execFileSync as execFileSync2 } from "child_process";
19130
- import { createHash as createHash2 } from "crypto";
19131
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync } from "fs";
19640
+ import { createHash as createHash3 } from "crypto";
19641
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, writeFileSync } from "fs";
19132
19642
  import { join as join3 } from "path";
19133
19643
  function sandboxRuntimeEntrypoint() {
19134
19644
  return join3(paths.PACKAGE_ROOT, "node_modules/@anthropic-ai/sandbox-runtime/dist/cli.js");
19135
19645
  }
19136
19646
  function sandboxHomeFor(cwd) {
19137
- const digest = createHash2("sha256").update(cwd).digest("hex").slice(0, 12);
19647
+ const digest = createHash3("sha256").update(cwd).digest("hex").slice(0, 12);
19138
19648
  const label = (cwd.split("/").pop() || "channel").replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 32);
19139
19649
  return join3(paths.SANDBOX_HOMES_DIR, `${label}-${digest}`);
19140
19650
  }
19141
19651
  function buildSandboxSpawn(input) {
19142
19652
  const home = sandboxHomeFor(input.cwd);
19143
19653
  for (const dir of [home, paths.SCRATCH_DIR]) {
19144
- if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
19654
+ if (!existsSync5(dir)) mkdirSync4(dir, { recursive: true });
19145
19655
  }
19146
19656
  const claudeBin = process.env["FLYSPACE_CLAUDE_BIN"]?.trim() || execFileSync2("which", ["claude"]).toString().trim();
19147
19657
  const allowRead = [input.cwd, home, paths.SCRATCH_DIR, join3(paths.PACKAGE_ROOT, "node_modules")];
@@ -19186,7 +19696,7 @@ function buildSandboxSpawn(input) {
19186
19696
  };
19187
19697
  }
19188
19698
  function sandboxRuntimeStatus() {
19189
- if (existsSync4(sandboxRuntimeEntrypoint())) return { ok: true };
19699
+ if (existsSync5(sandboxRuntimeEntrypoint())) return { ok: true };
19190
19700
  return {
19191
19701
  ok: false,
19192
19702
  message: `This channel runs its agent in a sandbox, but \`@anthropic-ai/sandbox-runtime\` is not installed.
@@ -19225,10 +19735,10 @@ var PluginUiSession = class {
19225
19735
  onEvent(event) {
19226
19736
  if (event.type === "control_response") {
19227
19737
  const res = event.response;
19228
- const resolve7 = res?.request_id ? this.pending.get(res.request_id) : void 0;
19229
- if (!resolve7 || !res?.request_id) return;
19738
+ const resolve8 = res?.request_id ? this.pending.get(res.request_id) : void 0;
19739
+ if (!resolve8 || !res?.request_id) return;
19230
19740
  this.pending.delete(res.request_id);
19231
- resolve7(res.subtype === "success" ? res.response?.tree : void 0);
19741
+ resolve8(res.subtype === "success" ? res.response?.tree : void 0);
19232
19742
  return;
19233
19743
  }
19234
19744
  const e = event;
@@ -19247,8 +19757,8 @@ var PluginUiSession = class {
19247
19757
  }
19248
19758
  render(instanceId) {
19249
19759
  const requestId = `flyspace-ui-render-${++this.seq}`;
19250
- return new Promise((resolve7) => {
19251
- this.pending.set(requestId, resolve7);
19760
+ return new Promise((resolve8) => {
19761
+ this.pending.set(requestId, resolve8);
19252
19762
  this.write({
19253
19763
  type: "control_request",
19254
19764
  request_id: requestId,
@@ -19269,11 +19779,11 @@ var PluginUiSession = class {
19269
19779
  */
19270
19780
  async finish() {
19271
19781
  if (this.panes.length) {
19272
- await new Promise((resolve7) => {
19273
- const timer2 = setTimeout(resolve7, SETTLE_TIMEOUT_MS);
19782
+ await new Promise((resolve8) => {
19783
+ const timer2 = setTimeout(resolve8, SETTLE_TIMEOUT_MS);
19274
19784
  this.onInvalidate = () => {
19275
19785
  clearTimeout(timer2);
19276
- resolve7();
19786
+ resolve8();
19277
19787
  };
19278
19788
  });
19279
19789
  this.onInvalidate = void 0;
@@ -19282,8 +19792,8 @@ var PluginUiSession = class {
19282
19792
  this.panes.map(async (p) => ({ ...p, tree: await this.render(p.id) }))
19283
19793
  );
19284
19794
  let timer;
19285
- const timeout = new Promise((resolve7) => {
19286
- timer = setTimeout(() => resolve7(void 0), RENDER_TIMEOUT_MS);
19795
+ const timeout = new Promise((resolve8) => {
19796
+ timer = setTimeout(() => resolve8(void 0), RENDER_TIMEOUT_MS);
19287
19797
  });
19288
19798
  const rendered = await Promise.race([renders, timeout]);
19289
19799
  clearTimeout(timer);
@@ -19328,9 +19838,9 @@ function readMiseEnv(cwd) {
19328
19838
  }
19329
19839
 
19330
19840
  // ../api/src/store/output-styles-store.ts
19331
- import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync, readFileSync as readFileSync2, renameSync, rmSync, statSync, writeFileSync as writeFileSync2 } from "fs";
19332
- import { homedir } from "os";
19333
- import { join as join4, resolve as resolve2, sep } from "path";
19841
+ import { existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync, readFileSync as readFileSync2, renameSync, rmSync, statSync as statSync2, writeFileSync as writeFileSync2 } from "fs";
19842
+ import { homedir as homedir2 } from "os";
19843
+ import { join as join4, resolve as resolve3, sep as sep2 } from "path";
19334
19844
  var BUILT_IN_OUTPUT_STYLES = [
19335
19845
  { slug: "default", name: "Default", description: "Claude Code\u2019s standard software engineering prompt." },
19336
19846
  { slug: "proactive", name: "Proactive", description: "Works autonomously and makes reasonable calls instead of asking." },
@@ -19342,16 +19852,16 @@ var OutputStyleConflictError = class extends Error {
19342
19852
  };
19343
19853
  var ID_RE = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
19344
19854
  function resolveDir(claudeConfigDir) {
19345
- return claudeConfigDir || join4(homedir(), ".claude");
19855
+ return claudeConfigDir || join4(homedir2(), ".claude");
19346
19856
  }
19347
19857
  function stylesDir(claudeConfigDir) {
19348
19858
  return join4(resolveDir(claudeConfigDir), "output-styles");
19349
19859
  }
19350
19860
  function styleFile(claudeConfigDir, id) {
19351
19861
  if (!ID_RE.test(id)) return null;
19352
- const dir = resolve2(stylesDir(claudeConfigDir));
19353
- const file = resolve2(dir, `${id}.md`);
19354
- return file.startsWith(dir + sep) ? file : null;
19862
+ const dir = resolve3(stylesDir(claudeConfigDir));
19863
+ const file = resolve3(dir, `${id}.md`);
19864
+ return file.startsWith(dir + sep2) ? file : null;
19355
19865
  }
19356
19866
  function slugify(name) {
19357
19867
  return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -19393,15 +19903,15 @@ ${p.body.trim()}
19393
19903
  `;
19394
19904
  }
19395
19905
  function atomicWrite(file, content) {
19396
- mkdirSync4(resolve2(file, ".."), { recursive: true });
19906
+ mkdirSync5(resolve3(file, ".."), { recursive: true });
19397
19907
  const tmp = `${file}.${process.pid}.tmp`;
19398
19908
  writeFileSync2(tmp, content);
19399
19909
  renameSync(tmp, file);
19400
19910
  }
19401
19911
  function readStyle(claudeConfigDir, id) {
19402
19912
  const file = styleFile(claudeConfigDir, id);
19403
- if (!file || !existsSync5(file)) return null;
19404
- const stat = statSync(file);
19913
+ if (!file || !existsSync6(file)) return null;
19914
+ const stat = statSync2(file);
19405
19915
  const p = parseStyle(readFileSync2(file, "utf8"), id);
19406
19916
  return {
19407
19917
  id,
@@ -19414,7 +19924,7 @@ function readStyle(claudeConfigDir, id) {
19414
19924
  }
19415
19925
  function listOutputStyles(claudeConfigDir) {
19416
19926
  const dir = stylesDir(claudeConfigDir);
19417
- if (!existsSync5(dir)) return [];
19927
+ if (!existsSync6(dir)) return [];
19418
19928
  return readdirSync(dir).filter((f) => f.endsWith(".md")).map((f) => readStyle(claudeConfigDir, f.slice(0, -3))).filter((s) => !!s).sort((a, b) => a.name.localeCompare(b.name));
19419
19929
  }
19420
19930
  function assertNameFree(claudeConfigDir, name, exceptId) {
@@ -19427,7 +19937,7 @@ function createOutputStyle(claudeConfigDir, params) {
19427
19937
  if (!id) throw new Error("name must contain letters or digits");
19428
19938
  assertNameFree(claudeConfigDir, params.name);
19429
19939
  const file = styleFile(claudeConfigDir, id);
19430
- if (existsSync5(file) || BUILT_IN_OUTPUT_STYLES.some((s) => s.slug === id)) {
19940
+ if (existsSync6(file) || BUILT_IN_OUTPUT_STYLES.some((s) => s.slug === id)) {
19431
19941
  throw new OutputStyleConflictError(`an output style named "${params.name}" already exists`);
19432
19942
  }
19433
19943
  atomicWrite(file, serialize({ ...params, extra: [] }));
@@ -19435,7 +19945,7 @@ function createOutputStyle(claudeConfigDir, params) {
19435
19945
  }
19436
19946
  function updateOutputStyle(claudeConfigDir, id, patch) {
19437
19947
  const file = styleFile(claudeConfigDir, id);
19438
- if (!file || !existsSync5(file)) return null;
19948
+ if (!file || !existsSync6(file)) return null;
19439
19949
  const current = parseStyle(readFileSync2(file, "utf8"), id);
19440
19950
  if (patch.name !== void 0 && patch.name !== current.name) assertNameFree(claudeConfigDir, patch.name, id);
19441
19951
  const next = { ...current, ...patch };
@@ -19447,7 +19957,7 @@ function updateOutputStyle(claudeConfigDir, id, patch) {
19447
19957
  }
19448
19958
  function deleteOutputStyle(claudeConfigDir, id) {
19449
19959
  const file = styleFile(claudeConfigDir, id);
19450
- if (!file || !existsSync5(file)) return false;
19960
+ if (!file || !existsSync6(file)) return false;
19451
19961
  const name = parseStyle(readFileSync2(file, "utf8"), id).name;
19452
19962
  rmSync(file);
19453
19963
  if (readSettings(claudeConfigDir)["outputStyle"] === name) writeDefaultName(claudeConfigDir, void 0);
@@ -19458,7 +19968,7 @@ function settingsFile(claudeConfigDir) {
19458
19968
  }
19459
19969
  function readSettings(claudeConfigDir) {
19460
19970
  const file = settingsFile(claudeConfigDir);
19461
- if (!existsSync5(file)) return {};
19971
+ if (!existsSync6(file)) return {};
19462
19972
  const parsed = JSON.parse(readFileSync2(file, "utf8"));
19463
19973
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
19464
19974
  throw new Error(`${file} is not a JSON object`);
@@ -19902,13 +20412,13 @@ function getMaxDurationMs(streaming) {
19902
20412
  }
19903
20413
  function loadSystemPrompt() {
19904
20414
  const customPath = paths.PROMPT_FILE;
19905
- const defaultPath = resolve3(paths.PACKAGE_ROOT, "system.default.md");
19906
- const filePath = existsSync6(customPath) ? customPath : defaultPath;
20415
+ const defaultPath = resolve4(paths.PACKAGE_ROOT, "system.default.md");
20416
+ const filePath = existsSync7(customPath) ? customPath : defaultPath;
19907
20417
  return readFileSync3(filePath, "utf-8").trim();
19908
20418
  }
19909
20419
  function loadPackagePrompt(file) {
19910
- const filePath = resolve3(paths.PACKAGE_ROOT, file);
19911
- if (!existsSync6(filePath)) return "";
20420
+ const filePath = resolve4(paths.PACKAGE_ROOT, file);
20421
+ if (!existsSync7(filePath)) return "";
19912
20422
  return readFileSync3(filePath, "utf-8").trim();
19913
20423
  }
19914
20424
  function loadCapabilities(slackBound) {
@@ -19973,7 +20483,7 @@ function owningServiceLabel(env = process.env) {
19973
20483
  return /^[A-Za-z0-9._-]+$/.test(label) ? label : void 0;
19974
20484
  }
19975
20485
  function buildHookSettings(runtime, builtInStyleName) {
19976
- const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` : resolve3(paths.PACKAGE_ROOT, "hooks/bash-guard.mjs");
20486
+ const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` : resolve4(paths.PACKAGE_ROOT, "hooks/bash-guard.mjs");
19977
20487
  const selfLabel = runtime === "container" ? void 0 : owningServiceLabel();
19978
20488
  const guardEnv = selfLabel ? `FLYSPACE_SELF_SERVICE_LABEL='${selfLabel}' ` : "";
19979
20489
  return JSON.stringify({
@@ -20071,10 +20581,10 @@ function recordUsage2(response, options) {
20071
20581
  }
20072
20582
  function pinnedClaudeConfigDir(dir) {
20073
20583
  if (!dir) return void 0;
20074
- return resolvePath(dir.replace(/^~(?=\/|$)/, homedir2())) === resolvePath(homedir2(), ".claude") ? void 0 : dir;
20584
+ return resolvePath(dir.replace(/^~(?=\/|$)/, homedir3())) === resolvePath(homedir3(), ".claude") ? void 0 : dir;
20075
20585
  }
20076
20586
  function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
20077
- return new Promise((resolve7, reject) => {
20587
+ return new Promise((resolve8, reject) => {
20078
20588
  const isolated = options.runtime === "container" || options.runtime === "sandbox";
20079
20589
  const args = buildArgs(
20080
20590
  prompt,
@@ -20256,7 +20766,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20256
20766
  console.log(`[agent] stderr: ${stderr.trim()}`);
20257
20767
  }
20258
20768
  if (cancelled) {
20259
- resolve7({
20769
+ resolve8({
20260
20770
  sessionId: liveSessionId ?? resumeSessionId ?? "",
20261
20771
  text: "",
20262
20772
  isCancelled: true
@@ -20265,7 +20775,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20265
20775
  }
20266
20776
  if (timedOut) {
20267
20777
  const text = timeoutKind === "wall-clock" && streaming ? `This task ran for over ${Math.round(maxDurationMs / 6e4)} minutes in total, so I was terminated as a runaway backstop. I was still making progress \u2014 the task is just too big for one turn. Consider splitting it into smaller steps, or continue and I'll pick up where I left off.` : `I got stuck for over ${Math.round((timeoutKind === "idle" ? idleTimeoutMs : maxDurationMs) / 6e4)} minutes with no activity and had to be terminated. Most likely cause: a Bash tool call to a long-running process (dev server, watcher, \`tail -f\`, etc.) that never exits. If you wanted to start a server, ask me to run it in the background (\`nohup ... > /tmp/log 2>&1 & disown\`) and I'll come back with the PID.`;
20268
- resolve7({
20778
+ resolve8({
20269
20779
  sessionId: liveSessionId ?? resumeSessionId ?? "",
20270
20780
  text,
20271
20781
  isError: true,
@@ -20303,7 +20813,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20303
20813
  !!claudeCodeOauthToken
20304
20814
  );
20305
20815
  recordUsage2(response, options);
20306
- resolve7(
20816
+ resolve8(
20307
20817
  response.isError ? {
20308
20818
  ...response,
20309
20819
  failure: {
@@ -20317,13 +20827,13 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20317
20827
  );
20318
20828
  } catch {
20319
20829
  const fallback = onLine ? "" : stdout.trim();
20320
- resolve7({ sessionId: resumeSessionId ?? "", text: fallback || "No response" });
20830
+ resolve8({ sessionId: resumeSessionId ?? "", text: fallback || "No response" });
20321
20831
  }
20322
20832
  });
20323
20833
  });
20324
20834
  }
20325
20835
  async function askClaude(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
20326
- if (!existsSync6(cwd) || !statSync2(cwd).isDirectory()) {
20836
+ if (!existsSync7(cwd) || !statSync3(cwd).isDirectory()) {
20327
20837
  console.error(`[agent] working directory does not exist: ${cwd}`);
20328
20838
  return {
20329
20839
  sessionId: resumeSessionId ?? "",
@@ -20393,6 +20903,131 @@ Fix the channel's working directory in its settings (or recreate the directory),
20393
20903
  }
20394
20904
  }
20395
20905
 
20906
+ // ../api/src/store/authors.ts
20907
+ var AGENT_AUTHOR = "agent";
20908
+ var SYNCED_BOT_AUTHOR = "Bot";
20909
+ var LEGACY_BOT_AUTHOR = "Custie";
20910
+ var SUPPORT_BOT_AUTHOR = "Flyspace Support";
20911
+ var NON_HUMAN_AUTHORS = new Set(
20912
+ [AGENT_AUTHOR, SYNCED_BOT_AUTHOR, LEGACY_BOT_AUTHOR, SUPPORT_BOT_AUTHOR].map((a) => a.toLowerCase())
20913
+ );
20914
+ function isHumanAuthor(author) {
20915
+ return !NON_HUMAN_AUTHORS.has(author.toLowerCase());
20916
+ }
20917
+
20918
+ // ../api/src/store/thread-title.ts
20919
+ var TITLE_MAX_LENGTH = 80;
20920
+ function deriveThreadTitle(text) {
20921
+ const firstLine = text.split("\n").find((line) => line.trim().length > 0);
20922
+ if (!firstLine) return null;
20923
+ const cleaned = firstLine.replace(/^\s*(?::[a-z0-9_+-]+:\s*)+/i, "").replace(/^\s*\p{Extended_Pictographic}[️‍]*\s*/u, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/(^|\s)_([^_\n]+)_(?=\s|$|[.,:;,。、:])/g, "$1$2").replace(/`([^`]+)`/g, "$1").replace(/\s+/g, " ").trim();
20924
+ if (!cleaned) return null;
20925
+ return cleaned.length > TITLE_MAX_LENGTH ? `${cleaned.slice(0, TITLE_MAX_LENGTH).trim()}\u2026` : cleaned;
20926
+ }
20927
+
20928
+ // src/store/dashboard-sync.ts
20929
+ async function syncPostToDashboard(opts) {
20930
+ const { channelId, ts: ts3, threadTs, text } = opts;
20931
+ if (!databaseReachable()) {
20932
+ console.warn("[dashboard-sync] Supabase not configured \u2014 skipping dashboard sync");
20933
+ return;
20934
+ }
20935
+ try {
20936
+ const supabase = getSupabaseClient();
20937
+ const dashboardChannelId = await resolveDashboardChannelId(supabase, channelId);
20938
+ const threadId = threadTs ? await ensureThreadId(supabase, channelId, dashboardChannelId, threadTs) : await createOwnThread(supabase, channelId, dashboardChannelId, ts3, text);
20939
+ const { error } = await supabase.from("thread_replies").upsert(
20940
+ {
20941
+ thread_id: threadId,
20942
+ // This mirror only ever runs for the bot's own posts (automation
20943
+ // output, `flyspace slack post`), so the author is the agent itself —
20944
+ // labelling it anything else makes the chat agent count it as a
20945
+ // second human and stop replying without an explicit mention.
20946
+ author: AGENT_AUTHOR,
20947
+ body: await uploadLocalImages(text),
20948
+ external_thread_replies_id: `${channelId}:${ts3}`
20949
+ },
20950
+ { onConflict: "external_thread_replies_id" }
20951
+ );
20952
+ if (error) {
20953
+ console.warn(`[dashboard-sync] failed to write reply: ${error.message}`);
20954
+ }
20955
+ } catch (err) {
20956
+ console.warn(
20957
+ `[dashboard-sync] sync failed: ${err instanceof Error ? err.message : String(err)}`
20958
+ );
20959
+ }
20960
+ }
20961
+ async function resolveDashboardChannelId(supabase, slackChannelId) {
20962
+ const { data, error } = await supabase.from("channels").select("id").eq("external_channel_id", slackChannelId).maybeSingle();
20963
+ if (error || !data) return slackChannelId;
20964
+ return data["id"];
20965
+ }
20966
+ async function createOwnThread(supabase, externalChannelId, dashboardChannelId, ts3, text) {
20967
+ const { data, error } = await supabase.from("threads").upsert(
20968
+ {
20969
+ channel_id: dashboardChannelId,
20970
+ title: deriveThreadTitle(text),
20971
+ author: AGENT_AUTHOR,
20972
+ external_thread_id: `${externalChannelId}:${ts3}`
20973
+ },
20974
+ { onConflict: "external_thread_id" }
20975
+ ).select("id").single();
20976
+ if (error || !data) throw new Error(error?.message ?? "failed to create thread");
20977
+ return data["id"];
20978
+ }
20979
+ async function ensureThreadId(supabase, externalChannelId, dashboardChannelId, parentTs) {
20980
+ const key = `${externalChannelId}:${parentTs}`;
20981
+ const { data: existing, error: selectError } = await supabase.from("threads").select("id").eq("external_thread_id", key).maybeSingle();
20982
+ if (selectError) throw new Error(selectError.message);
20983
+ if (existing) return existing["id"];
20984
+ const { data: created, error: createError } = await supabase.from("threads").upsert(
20985
+ // The unsynced parent could be anyone's message (often another bot's),
20986
+ // so keep the generic non-human placeholder rather than claiming it.
20987
+ {
20988
+ channel_id: dashboardChannelId,
20989
+ title: null,
20990
+ author: SYNCED_BOT_AUTHOR,
20991
+ external_thread_id: key
20992
+ },
20993
+ { onConflict: "external_thread_id" }
20994
+ ).select("id").single();
20995
+ if (createError || !created) {
20996
+ throw new Error(createError?.message ?? "failed to create placeholder thread");
20997
+ }
20998
+ return created["id"];
20999
+ }
21000
+
21001
+ // src/store/dashboard-post.ts
21002
+ async function postToDashboardChannel(opts) {
21003
+ const { channelId, text, threadId, title } = opts;
21004
+ const supabase = getSupabaseClient();
21005
+ if (!threadId && !channelId) {
21006
+ throw new Error("postToDashboardChannel: channelId is required to start a new thread");
21007
+ }
21008
+ const parentId = threadId ?? await createThread(supabase, channelId, text, title);
21009
+ const body = await uploadLocalImages(text);
21010
+ const { data, error } = await supabase.from("thread_replies").insert({ thread_id: parentId, author: AGENT_AUTHOR, body }).select("id").single();
21011
+ if (error || !data) {
21012
+ throw new Error(`failed to write dashboard reply: ${error?.message ?? "no row returned"}`);
21013
+ }
21014
+ return { threadId: parentId, replyId: data["id"] };
21015
+ }
21016
+ async function createThread(supabase, channelId, text, title) {
21017
+ const { data, error } = await supabase.from("threads").insert({
21018
+ channel_id: channelId,
21019
+ // An untitled thread is effectively invisible in the sidebar, so give a
21020
+ // daily report the same first-line-derived title a mirrored post gets,
21021
+ // unless the caller named the thread itself.
21022
+ title: title?.trim().replace(/\\([\\`*_{}[\]()#+\-.!~>|])/g, "$1") || deriveThreadTitle(text),
21023
+ author: AGENT_AUTHOR
21024
+ }).select("id").single();
21025
+ if (error || !data) {
21026
+ throw new Error(`failed to create dashboard thread: ${error?.message ?? "no row returned"}`);
21027
+ }
21028
+ return data["id"];
21029
+ }
21030
+
20396
21031
  // src/automations/scheduler.ts
20397
21032
  import cron2 from "node-cron";
20398
21033
  import { CronExpressionParser } from "cron-parser";
@@ -20434,8 +21069,8 @@ function automationToRow(type, item, position) {
20434
21069
  };
20435
21070
  }
20436
21071
  var rows = [];
20437
- var changeListeners = /* @__PURE__ */ new Set();
20438
- var lastSnapshot;
21072
+ var changeListeners2 = /* @__PURE__ */ new Set();
21073
+ var lastSnapshot2;
20439
21074
  async function refreshAutomationRegistry() {
20440
21075
  const { data, error } = await getSupabaseClient().from("automations").select("*").order("position", { ascending: true });
20441
21076
  if (error) {
@@ -20444,10 +21079,10 @@ async function refreshAutomationRegistry() {
20444
21079
  }
20445
21080
  const next = data ?? [];
20446
21081
  const snapshot2 = JSON.stringify(next, (key, value) => key === "updated_at" ? void 0 : value);
20447
- if (snapshot2 === lastSnapshot) return;
20448
- lastSnapshot = snapshot2;
21082
+ if (snapshot2 === lastSnapshot2) return;
21083
+ lastSnapshot2 = snapshot2;
20449
21084
  rows = next;
20450
- for (const cb of changeListeners) {
21085
+ for (const cb of changeListeners2) {
20451
21086
  try {
20452
21087
  cb();
20453
21088
  } catch (err) {
@@ -20456,8 +21091,8 @@ async function refreshAutomationRegistry() {
20456
21091
  }
20457
21092
  }
20458
21093
  function onAutomationRegistryChange(cb) {
20459
- changeListeners.add(cb);
20460
- return () => changeListeners.delete(cb);
21094
+ changeListeners2.add(cb);
21095
+ return () => changeListeners2.delete(cb);
20461
21096
  }
20462
21097
  function profileRows() {
20463
21098
  const profile = getProfile();
@@ -20513,14 +21148,14 @@ async function setAutomationEnabled(name, enabled) {
20513
21148
  if (error) throw new Error(`Failed to update automation "${name}": ${error.message}`);
20514
21149
  await refreshAutomationRegistry();
20515
21150
  }
20516
- var DEFAULT_POLL_INTERVAL_MS = 2e4;
20517
- var pollTimer;
20518
- var realtimeChannel;
20519
- function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS) {
21151
+ var DEFAULT_POLL_INTERVAL_MS2 = 2e4;
21152
+ var pollTimer2;
21153
+ var realtimeChannel2;
21154
+ function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS2) {
20520
21155
  stopAutomationRegistryPolling();
20521
- pollTimer = setInterval(() => void refreshAutomationRegistry(), intervalMs);
21156
+ pollTimer2 = setInterval(() => void refreshAutomationRegistry(), intervalMs);
20522
21157
  try {
20523
- realtimeChannel = getSupabaseClient().channel("automations-registry").on(
21158
+ realtimeChannel2 = getSupabaseClient().channel("automations-registry").on(
20524
21159
  "postgres_changes",
20525
21160
  { event: "*", schema: "public", table: "automations" },
20526
21161
  () => void refreshAutomationRegistry()
@@ -20534,11 +21169,11 @@ function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS) {
20534
21169
  return stopAutomationRegistryPolling;
20535
21170
  }
20536
21171
  function stopAutomationRegistryPolling() {
20537
- if (pollTimer) clearInterval(pollTimer);
20538
- pollTimer = void 0;
20539
- if (realtimeChannel) {
20540
- void getSupabaseClient().removeChannel(realtimeChannel);
20541
- realtimeChannel = void 0;
21172
+ if (pollTimer2) clearInterval(pollTimer2);
21173
+ pollTimer2 = void 0;
21174
+ if (realtimeChannel2) {
21175
+ void getSupabaseClient().removeChannel(realtimeChannel2);
21176
+ realtimeChannel2 = void 0;
20542
21177
  }
20543
21178
  }
20544
21179
 
@@ -20983,9 +21618,9 @@ async function runCompanion(config, userId, slot) {
20983
21618
 
20984
21619
  // src/commands/persona.ts
20985
21620
  import { execFileSync as execFileSync4 } from "child_process";
20986
- import { createHash as createHash3 } from "crypto";
20987
- import { existsSync as existsSync7, mkdtempSync as mkdtempSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
20988
- import { homedir as homedir3 } from "os";
21621
+ import { createHash as createHash4 } from "crypto";
21622
+ import { existsSync as existsSync8, mkdtempSync as mkdtempSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
21623
+ import { homedir as homedir4 } from "os";
20989
21624
  import { basename as basename2, join as join6 } from "path";
20990
21625
  import sharp from "sharp";
20991
21626
  var USAGE = `
@@ -21018,8 +21653,8 @@ var PACKS = {
21018
21653
  }
21019
21654
  };
21020
21655
  function pluginInstalled() {
21021
- const claudeDir = process.env["CLAUDE_CONFIG_DIR"] || join6(homedir3(), ".claude");
21022
- return existsSync7(join6(claudeDir, "plugins", "cache", "claudecafe", "persona-panel"));
21656
+ const claudeDir = process.env["CLAUDE_CONFIG_DIR"] || join6(homedir4(), ".claude");
21657
+ return existsSync8(join6(claudeDir, "plugins", "cache", "claudecafe", "persona-panel"));
21023
21658
  }
21024
21659
  function installPack(root, character) {
21025
21660
  const pack = PACKS[character];
@@ -21030,18 +21665,18 @@ function installPack(root, character) {
21030
21665
  try {
21031
21666
  const zip = join6(staging, "pack.zip");
21032
21667
  execFileSync4("curl", ["-fsSL", "--max-time", "60", "-o", zip, pack.url]);
21033
- const digest = createHash3("sha256").update(readFileSync4(zip)).digest("hex");
21668
+ const digest = createHash4("sha256").update(readFileSync4(zip)).digest("hex");
21034
21669
  if (digest !== pack.sha256) throw new Error(`${character} pack SHA-256 mismatch`);
21035
21670
  execFileSync4("unzip", ["-q", zip, "-d", staging]);
21036
21671
  const folder = join6(charactersDir, character);
21037
- if (existsSync7(folder)) renameSync2(folder, join6(staging, "previous"));
21672
+ if (existsSync8(folder)) renameSync2(folder, join6(staging, "previous"));
21038
21673
  renameSync2(join6(staging, character), folder);
21039
21674
  } finally {
21040
21675
  rmSync3(staging, { recursive: true, force: true });
21041
21676
  }
21042
21677
  }
21043
21678
  function cafeRoot() {
21044
- return join6(process.env["XDG_CONFIG_HOME"] || join6(homedir3(), ".config"), "claudecafe");
21679
+ return join6(process.env["XDG_CONFIG_HOME"] || join6(homedir4(), ".config"), "claudecafe");
21045
21680
  }
21046
21681
  function configuredCharacter(root) {
21047
21682
  try {
@@ -21073,7 +21708,7 @@ async function syncPersonaAvatars(profile, requested) {
21073
21708
  const root = cafeRoot();
21074
21709
  const character = requested || configuredCharacter(root);
21075
21710
  const dir = join6(root, "characters", character, "avatars");
21076
- if (!existsSync7(dir)) installPack(root, character);
21711
+ if (!existsSync8(dir)) installPack(root, character);
21077
21712
  const avatars = {};
21078
21713
  for (const file of readdirSync2(dir).filter((f) => f.endsWith(".webp"))) {
21079
21714
  const image = await sharp(join6(dir, file)).resize({ width: AVATAR_SIZE, height: AVATAR_SIZE, fit: "cover", position: "top" }).webp({ quality: 80 }).toBuffer();
@@ -21574,7 +22209,7 @@ async function buildPrompt(profile, channelId, opts) {
21574
22209
  }
21575
22210
 
21576
22211
  // src/dashboard/settings-host.ts
21577
- import { writeFileSync as writeFileSync4, existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync5, rmSync as rmSync4 } from "fs";
22212
+ import { writeFileSync as writeFileSync4, existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync5, rmSync as rmSync4 } from "fs";
21578
22213
  import { dirname } from "path";
21579
22214
 
21580
22215
  // ../api/src/dashboard/auto-title.ts
@@ -21736,7 +22371,7 @@ function parseAgentProfiles(raw) {
21736
22371
  return entries2.length > 0 ? Object.fromEntries(entries2) : void 0;
21737
22372
  }
21738
22373
  function loadDashboardSettings() {
21739
- if (!existsSync8(paths.DASHBOARD_SETTINGS_FILE)) return localDefaults();
22374
+ if (!existsSync9(paths.DASHBOARD_SETTINGS_FILE)) return localDefaults();
21740
22375
  try {
21741
22376
  const raw = JSON.parse(readFileSync5(paths.DASHBOARD_SETTINGS_FILE, "utf-8"));
21742
22377
  const providers = parseProviders(raw.providers, {
@@ -21765,7 +22400,7 @@ function withFallbackModel(providers, model) {
21765
22400
  return [cleared[0], { runner, model }, ...cleared.slice(1).filter((p) => p.runner !== runner)];
21766
22401
  }
21767
22402
  function writeSettings(next) {
21768
- mkdirSync5(dirname(paths.DASHBOARD_SETTINGS_FILE), { recursive: true });
22403
+ mkdirSync6(dirname(paths.DASHBOARD_SETTINGS_FILE), { recursive: true });
21769
22404
  const merged = { ...readSettingsFile() ?? {}, ...next };
21770
22405
  writeFileSync4(paths.DASHBOARD_SETTINGS_FILE, JSON.stringify(merged, null, 2), "utf-8");
21771
22406
  return next;
@@ -21801,7 +22436,7 @@ async function loadFullDashboardSettings(profile = getProfile()) {
21801
22436
  function saveWorkspacePrompt(prompt) {
21802
22437
  const trimmed = prompt.trim();
21803
22438
  if (!trimmed || trimmed === loadWorkspacePrompt().defaultPrompt) return resetWorkspacePrompt();
21804
- mkdirSync5(dirname(paths.PROMPT_FILE), { recursive: true });
22439
+ mkdirSync6(dirname(paths.PROMPT_FILE), { recursive: true });
21805
22440
  writeFileSync4(paths.PROMPT_FILE, `${trimmed}
21806
22441
  `, "utf-8");
21807
22442
  return loadWorkspacePrompt();
@@ -21832,7 +22467,7 @@ function saveAgentProfile(name, patch) {
21832
22467
 
21833
22468
  // ../api/src/codex/agent.ts
21834
22469
  import { spawn as spawn2 } from "child_process";
21835
- import { existsSync as existsSync9, mkdtempSync as mkdtempSync3, readFileSync as readFileSync6, rmSync as rmSync5, statSync as statSync3 } from "fs";
22470
+ import { existsSync as existsSync10, mkdtempSync as mkdtempSync3, readFileSync as readFileSync6, rmSync as rmSync5, statSync as statSync4 } from "fs";
21836
22471
  import { tmpdir as tmpdir2 } from "os";
21837
22472
  import { join as join7 } from "path";
21838
22473
  var AUTH_ERROR_PATTERNS2 = [
@@ -21966,7 +22601,7 @@ function getMaxDurationMs2() {
21966
22601
  function codexAuthAvailable(env = process.env) {
21967
22602
  if (env["OPENAI_API_KEY"]?.trim()) return true;
21968
22603
  const home = env["CODEX_HOME"]?.trim() || join7(env["HOME"] ?? "", ".codex");
21969
- return existsSync9(join7(home, "auth.json"));
22604
+ return existsSync10(join7(home, "auth.json"));
21970
22605
  }
21971
22606
  function applySystemPrompt(prompt, options, resumeSessionId) {
21972
22607
  if (resumeSessionId || !options.systemPrompt?.trim()) return prompt;
@@ -22015,10 +22650,10 @@ function recordCodexUsage(response, options) {
22015
22650
  });
22016
22651
  }
22017
22652
  function runCodexCli(prompt, cwd, options, resumeSessionId) {
22018
- return new Promise((resolve7, reject) => {
22653
+ return new Promise((resolve8, reject) => {
22019
22654
  const finish = (response) => {
22020
22655
  recordCodexUsage(response, options);
22021
- resolve7(response);
22656
+ resolve8(response);
22022
22657
  };
22023
22658
  const scratch = mkdtempSync3(join7(tmpdir2(), "flyspace-codex-"));
22024
22659
  const lastMessageFile = join7(scratch, "last-message.txt");
@@ -22174,7 +22809,7 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
22174
22809
  });
22175
22810
  }
22176
22811
  async function askCodex(prompt, cwd, options = {}, resumeSessionId) {
22177
- if (!existsSync9(cwd) || !statSync3(cwd).isDirectory()) {
22812
+ if (!existsSync10(cwd) || !statSync4(cwd).isDirectory()) {
22178
22813
  console.error(`[codex] working directory does not exist: ${cwd}`);
22179
22814
  return {
22180
22815
  sessionId: resumeSessionId ?? "",
@@ -22622,12 +23257,12 @@ function renderAsciiTable(t) {
22622
23257
  (h, i) => Math.max(h.length, ...rows2.map((r) => (r[i] || "").length))
22623
23258
  );
22624
23259
  const fmt = (cells) => "| " + cells.map((c, i) => c.padEnd(widths[i])).join(" | ") + " |";
22625
- const sep4 = "|" + widths.map((w) => "-".repeat(w + 2)).join("|") + "|";
22626
- return [fmt(headers), sep4, ...rows2.map(fmt)].join("\n");
23260
+ const sep5 = "|" + widths.map((w) => "-".repeat(w + 2)).join("|") + "|";
23261
+ return [fmt(headers), sep5, ...rows2.map(fmt)].join("\n");
22627
23262
  }
22628
23263
 
22629
23264
  // src/store/channel-cache.ts
22630
- import { mkdirSync as mkdirSync6 } from "fs";
23265
+ import { mkdirSync as mkdirSync7 } from "fs";
22631
23266
 
22632
23267
  // src/store/sqlite.ts
22633
23268
  import Database from "better-sqlite3";
@@ -22651,7 +23286,7 @@ function getDb() {
22651
23286
  const file = paths.DB_FILE;
22652
23287
  const existing = dbs.get(file);
22653
23288
  if (existing) return existing;
22654
- mkdirSync6(paths.DATA_DIR, { recursive: true });
23289
+ mkdirSync7(paths.DATA_DIR, { recursive: true });
22655
23290
  const db = openLocalDatabase(file);
22656
23291
  if (!db) return null;
22657
23292
  db.exec(`
@@ -22866,7 +23501,7 @@ var DEFAULT_TIMEOUT_MS = 12e4;
22866
23501
  var KILL_GRACE_MS3 = 5e3;
22867
23502
  function runScriptAutomation(opts) {
22868
23503
  const { name, script, cwd, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
22869
- return new Promise((resolve7, reject) => {
23504
+ return new Promise((resolve8, reject) => {
22870
23505
  const child = spawn3("/bin/bash", [script], { cwd, env: resolveMiseEnv(cwd), stdio: ["ignore", "pipe", "pipe"] });
22871
23506
  let stdout = "";
22872
23507
  let stderr = "";
@@ -22901,7 +23536,7 @@ function runScriptAutomation(opts) {
22901
23536
  } else if (code !== 0) {
22902
23537
  reject(new Error(`script exited with code ${code}: ${stderr.trim()}`));
22903
23538
  } else {
22904
- resolve7();
23539
+ resolve8();
22905
23540
  }
22906
23541
  });
22907
23542
  });
@@ -23167,11 +23802,11 @@ var TriggerEngine = class {
23167
23802
  };
23168
23803
 
23169
23804
  // src/store/user-cache.ts
23170
- import { existsSync as existsSync10, readFileSync as readFileSync7 } from "fs";
23805
+ import { existsSync as existsSync11, readFileSync as readFileSync7 } from "fs";
23171
23806
  import { join as join8 } from "path";
23172
23807
  function jsonUserCachePath() {
23173
23808
  const file = join8(paths.CONFIG_DIR, "slack_users.json");
23174
- return existsSync10(file) ? file : void 0;
23809
+ return existsSync11(file) ? file : void 0;
23175
23810
  }
23176
23811
  function readJsonUserCache() {
23177
23812
  const file = jsonUserCachePath();
@@ -23569,8 +24204,8 @@ var MessageQueue = class {
23569
24204
  const chains = Array.from(this.chains.values());
23570
24205
  if (chains.length === 0) return true;
23571
24206
  let timer;
23572
- const timeout = new Promise((resolve7) => {
23573
- timer = setTimeout(() => resolve7(false), timeoutMs);
24207
+ const timeout = new Promise((resolve8) => {
24208
+ timer = setTimeout(() => resolve8(false), timeoutMs);
23574
24209
  });
23575
24210
  const done = Promise.all(chains).then(() => true);
23576
24211
  const result = await Promise.race([done, timeout]);
@@ -24132,7 +24767,7 @@ async function summariseThreadTranscript(transcript, opts, deps = {}) {
24132
24767
  }
24133
24768
 
24134
24769
  // src/dashboard/chat-agent.ts
24135
- import { homedir as homedir8 } from "os";
24770
+ import { homedir as homedir9 } from "os";
24136
24771
  import { stripVTControlCharacters } from "util";
24137
24772
 
24138
24773
  // src/mcp/config.ts
@@ -24260,7 +24895,7 @@ function secretsMatch(a, b) {
24260
24895
  }
24261
24896
 
24262
24897
  // ../api/src/mcp/oauth.ts
24263
- import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
24898
+ import { createHash as createHash5, randomBytes as randomBytes2 } from "crypto";
24264
24899
  var RESERVED_AUTHORIZE_PARAMS = /* @__PURE__ */ new Set([
24265
24900
  "client_id",
24266
24901
  "redirect_uri",
@@ -24278,7 +24913,7 @@ function createStateToken() {
24278
24913
  }
24279
24914
  function createPkcePair() {
24280
24915
  const verifier = base64url(randomBytes2(32));
24281
- const challenge = base64url(createHash4("sha256").update(verifier).digest());
24916
+ const challenge = base64url(createHash5("sha256").update(verifier).digest());
24282
24917
  return { verifier, challenge };
24283
24918
  }
24284
24919
  function clientEnvName(providerSlug, suffix) {
@@ -24647,7 +25282,7 @@ function needsRefresh(expiresAt, now = Date.now()) {
24647
25282
  if (!expiresAt) return false;
24648
25283
  return new Date(expiresAt).getTime() - now < REFRESH_SKEW_MS;
24649
25284
  }
24650
- var sleep = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
25285
+ var sleep = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
24651
25286
  async function refreshConnection(params) {
24652
25287
  const { workspaceId, connection, provider } = params;
24653
25288
  const deps = params.deps ?? {};
@@ -24774,12 +25409,12 @@ async function buildMcpConfig(profile, connectionIds) {
24774
25409
  if (!connectionIds.length) return { config, skipped };
24775
25410
  const workspace = await getWorkspaceBySlug(profile);
24776
25411
  if (!workspace) return { config, skipped };
24777
- const byId = new Map(
25412
+ const byId2 = new Map(
24778
25413
  (await listMcpConnections(workspace.id)).map((connection) => [connection.id, connection])
24779
25414
  );
24780
25415
  const workspaceId = workspace.id;
24781
25416
  for (const id of connectionIds) {
24782
- const connection = byId.get(id);
25417
+ const connection = byId2.get(id);
24783
25418
  if (!connection) {
24784
25419
  continue;
24785
25420
  }
@@ -24848,7 +25483,7 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
24848
25483
 
24849
25484
  // ../api/src/version.ts
24850
25485
  import { readFileSync as readFileSync8 } from "fs";
24851
- var CLI_VERSION = true ? "0.1.60" : devVersion();
25486
+ var CLI_VERSION = true ? "0.1.62" : devVersion();
24852
25487
  function isOlderVersion(a, b) {
24853
25488
  const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
24854
25489
  const [pa, pb] = [parse2(a), parse2(b)];
@@ -24871,39 +25506,39 @@ async function latestCliVersion() {
24871
25506
  }
24872
25507
 
24873
25508
  // src/claude/agents.ts
24874
- import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
24875
- import { homedir as homedir6 } from "os";
25509
+ import { existsSync as existsSync14, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
25510
+ import { homedir as homedir7 } from "os";
24876
25511
  import { basename as basename4, join as join13 } from "path";
24877
25512
  import yaml3 from "js-yaml";
24878
25513
 
24879
25514
  // ../api/src/claude/skills.ts
24880
- import { existsSync as existsSync12, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
24881
- import { homedir as homedir5 } from "os";
25515
+ import { existsSync as existsSync13, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
25516
+ import { homedir as homedir6 } from "os";
24882
25517
  import { basename as basename3, dirname as dirname2, join as join12 } from "path";
24883
25518
  import yaml2 from "js-yaml";
24884
25519
 
24885
25520
  // ../api/src/claude/skill-files.ts
24886
25521
  import {
24887
- existsSync as existsSync11,
24888
- mkdirSync as mkdirSync7,
25522
+ existsSync as existsSync12,
25523
+ mkdirSync as mkdirSync8,
24889
25524
  readFileSync as readFileSync9,
24890
25525
  readdirSync as readdirSync3,
24891
25526
  rmSync as rmSync7,
24892
- statSync as statSync4,
25527
+ statSync as statSync5,
24893
25528
  writeFileSync as writeFileSync6
24894
25529
  } from "fs";
24895
- import { homedir as homedir4 } from "os";
24896
- import { join as join11, resolve as resolve4, sep as sep2 } from "path";
25530
+ import { homedir as homedir5 } from "os";
25531
+ import { join as join11, resolve as resolve5, sep as sep3 } from "path";
24897
25532
  import yaml from "js-yaml";
24898
25533
  var MAX_SKILL_BYTES = 2 * 1024 * 1024;
24899
25534
  var SKILL_NAME = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
24900
25535
  function expandHome(p) {
24901
- if (p === "~") return homedir4();
24902
- if (p.startsWith("~/")) return join11(homedir4(), p.slice(2));
25536
+ if (p === "~") return homedir5();
25537
+ if (p.startsWith("~/")) return join11(homedir5(), p.slice(2));
24903
25538
  return p;
24904
25539
  }
24905
25540
  function workspaceSkillsDir(configDir) {
24906
- return join11(configDir ? expandHome(configDir) : join11(homedir4(), ".claude"), "skills");
25541
+ return join11(configDir ? expandHome(configDir) : join11(homedir5(), ".claude"), "skills");
24907
25542
  }
24908
25543
  function channelSkillsDir(cwd) {
24909
25544
  return join11(cwd, ".claude", "skills");
@@ -24913,8 +25548,8 @@ function isValidSkillName(name) {
24913
25548
  }
24914
25549
  function resolveSkillPath(dir, name) {
24915
25550
  if (!isValidSkillName(name)) return null;
24916
- const abs = resolve4(dir, name, "SKILL.md");
24917
- if (!abs.startsWith(resolve4(dir) + sep2)) return null;
25551
+ const abs = resolve5(dir, name, "SKILL.md");
25552
+ if (!abs.startsWith(resolve5(dir) + sep3)) return null;
24918
25553
  return abs;
24919
25554
  }
24920
25555
  function splitFrontmatter(raw) {
@@ -24951,7 +25586,7 @@ function readMeta(abs) {
24951
25586
  }
24952
25587
  }
24953
25588
  function listSkillFiles(dir) {
24954
- if (!existsSync11(dir)) return [];
25589
+ if (!existsSync12(dir)) return [];
24955
25590
  let entries2;
24956
25591
  try {
24957
25592
  entries2 = readdirSync3(dir);
@@ -24964,7 +25599,7 @@ function listSkillFiles(dir) {
24964
25599
  const abs = join11(dir, entry, "SKILL.md");
24965
25600
  let stat;
24966
25601
  try {
24967
- stat = statSync4(abs);
25602
+ stat = statSync5(abs);
24968
25603
  } catch {
24969
25604
  continue;
24970
25605
  }
@@ -24985,7 +25620,7 @@ function readSkillFile(dir, name) {
24985
25620
  if (!abs) return null;
24986
25621
  let stat;
24987
25622
  try {
24988
- stat = statSync4(abs);
25623
+ stat = statSync5(abs);
24989
25624
  } catch {
24990
25625
  return null;
24991
25626
  }
@@ -25004,7 +25639,7 @@ function writeSkillFile(dir, name, patch, baseMtime) {
25004
25639
  if (!abs) return { status: "not-found" };
25005
25640
  let stat;
25006
25641
  try {
25007
- stat = statSync4(abs);
25642
+ stat = statSync5(abs);
25008
25643
  } catch {
25009
25644
  return { status: "not-found" };
25010
25645
  }
@@ -25016,13 +25651,13 @@ function writeSkillFile(dir, name, patch, baseMtime) {
25016
25651
  const content = buildSkillFile({ ...fm, name, description: patch.description }, patch.body);
25017
25652
  if (Buffer.byteLength(content, "utf8") > MAX_SKILL_BYTES) return { status: "too-large" };
25018
25653
  writeFileSync6(abs, content, "utf8");
25019
- return { status: "ok", mtime: statSync4(abs).mtime.toISOString() };
25654
+ return { status: "ok", mtime: statSync5(abs).mtime.toISOString() };
25020
25655
  }
25021
25656
  function createSkillFile(dir, name, description) {
25022
25657
  const abs = resolveSkillPath(dir, name);
25023
25658
  if (!abs) return { status: "bad-name" };
25024
- if (existsSync11(abs)) return { status: "exists" };
25025
- mkdirSync7(join11(dir, name), { recursive: true });
25659
+ if (existsSync12(abs)) return { status: "exists" };
25660
+ mkdirSync8(join11(dir, name), { recursive: true });
25026
25661
  writeFileSync6(
25027
25662
  abs,
25028
25663
  buildSkillFile(
@@ -25039,18 +25674,18 @@ Describe what this skill does and when to use it.
25039
25674
  }
25040
25675
  function deleteSkillFile(dir, name) {
25041
25676
  const abs = resolveSkillPath(dir, name);
25042
- if (!abs || !existsSync11(abs)) return { status: "not-found" };
25677
+ if (!abs || !existsSync12(abs)) return { status: "not-found" };
25043
25678
  rmSync7(join11(dir, name), { recursive: true, force: true });
25044
25679
  return { status: "ok" };
25045
25680
  }
25046
25681
 
25047
25682
  // ../api/src/claude/skills.ts
25048
25683
  function defaultConfigDir() {
25049
- return join12(homedir5(), ".claude");
25684
+ return join12(homedir6(), ".claude");
25050
25685
  }
25051
25686
  function expandHome2(p) {
25052
- if (p === "~") return homedir5();
25053
- if (p.startsWith("~/")) return join12(homedir5(), p.slice(2));
25687
+ if (p === "~") return homedir6();
25688
+ if (p.startsWith("~/")) return join12(homedir6(), p.slice(2));
25054
25689
  return p;
25055
25690
  }
25056
25691
  function parseFrontmatter(file) {
@@ -25074,13 +25709,13 @@ function parseFrontmatter(file) {
25074
25709
  function isSymlinkedDir(root, entry) {
25075
25710
  if (!entry.isSymbolicLink()) return false;
25076
25711
  try {
25077
- return statSync5(join12(root, entry.name)).isDirectory();
25712
+ return statSync6(join12(root, entry.name)).isDirectory();
25078
25713
  } catch {
25079
25714
  return false;
25080
25715
  }
25081
25716
  }
25082
25717
  function findSkillFiles(root, maxDepth, out) {
25083
- if (maxDepth < 0 || !existsSync12(root)) return;
25718
+ if (maxDepth < 0 || !existsSync13(root)) return;
25084
25719
  let entries2;
25085
25720
  try {
25086
25721
  entries2 = readdirSync4(root, { withFileTypes: true });
@@ -25133,7 +25768,7 @@ function findPluginMarkdown(pluginsRoot, dirName, maxDepth = 8) {
25133
25768
  }
25134
25769
  }
25135
25770
  };
25136
- if (existsSync12(pluginsRoot)) walk(pluginsRoot, maxDepth);
25771
+ if (existsSync13(pluginsRoot)) walk(pluginsRoot, maxDepth);
25137
25772
  return out;
25138
25773
  }
25139
25774
  function readdirSafe(dir) {
@@ -25215,7 +25850,7 @@ function nestedProjectRoots(cwd) {
25215
25850
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
25216
25851
  if (!entry.isDirectory() && !isSymlinkedDir(cwd, entry)) continue;
25217
25852
  const skillsDir = join12(cwd, entry.name, ".claude", "skills");
25218
- if (existsSync12(skillsDir)) roots.push({ dir: skillsDir, prefix: entry.name });
25853
+ if (existsSync13(skillsDir)) roots.push({ dir: skillsDir, prefix: entry.name });
25219
25854
  }
25220
25855
  return roots;
25221
25856
  }
@@ -25228,7 +25863,7 @@ function listPluginSkillDetails(configDir, cwd) {
25228
25863
  if (skill.source !== "plugin") continue;
25229
25864
  try {
25230
25865
  const { body } = splitFrontmatter(readFileSync10(file, "utf-8"));
25231
- details.push({ ...skill, body, path: file, mtime: statSync5(file).mtime.toISOString() });
25866
+ details.push({ ...skill, body, path: file, mtime: statSync6(file).mtime.toISOString() });
25232
25867
  } catch {
25233
25868
  }
25234
25869
  }
@@ -25262,7 +25897,7 @@ function findSkillDetail(configDir, cwd, name, sources) {
25262
25897
  let mtime;
25263
25898
  try {
25264
25899
  raw = readFileSync10(file, "utf-8");
25265
- mtime = statSync5(file).mtime.toISOString();
25900
+ mtime = statSync6(file).mtime.toISOString();
25266
25901
  } catch {
25267
25902
  continue;
25268
25903
  }
@@ -25296,11 +25931,11 @@ ${body.trim()}`;
25296
25931
 
25297
25932
  // src/claude/agents.ts
25298
25933
  function defaultConfigDir2() {
25299
- return join13(homedir6(), ".claude");
25934
+ return join13(homedir7(), ".claude");
25300
25935
  }
25301
25936
  function expandHome3(p) {
25302
- if (p === "~") return homedir6();
25303
- if (p.startsWith("~/")) return join13(homedir6(), p.slice(2));
25937
+ if (p === "~") return homedir7();
25938
+ if (p.startsWith("~/")) return join13(homedir7(), p.slice(2));
25304
25939
  return p;
25305
25940
  }
25306
25941
  function parseFrontmatter2(file) {
@@ -25322,7 +25957,7 @@ function parseFrontmatter2(file) {
25322
25957
  }
25323
25958
  }
25324
25959
  function collectFrom2(root, source) {
25325
- if (!existsSync13(root)) return [];
25960
+ if (!existsSync14(root)) return [];
25326
25961
  let entries2;
25327
25962
  try {
25328
25963
  entries2 = readdirSync5(root).filter((f) => f.endsWith(".md"));
@@ -25372,13 +26007,13 @@ function readAgentPersona(configDir, cwd, name) {
25372
26007
 
25373
26008
  // src/dashboard/memory-extraction-runner.ts
25374
26009
  import { spawn as spawn4 } from "child_process";
25375
- import { existsSync as existsSync14, mkdtempSync as mkdtempSync5, readFileSync as readFileSync12, rmSync as rmSync8 } from "fs";
26010
+ import { existsSync as existsSync15, mkdtempSync as mkdtempSync5, readFileSync as readFileSync12, rmSync as rmSync8 } from "fs";
25376
26011
  import { tmpdir as tmpdir4 } from "os";
25377
26012
  import { join as join15 } from "path";
25378
26013
 
25379
26014
  // ../api/src/dashboard/profile-config.ts
25380
- import { homedir as homedir7 } from "os";
25381
- import { join as join14, parse, resolve as resolve5 } from "path";
26015
+ import { homedir as homedir8 } from "os";
26016
+ import { join as join14, parse, resolve as resolve6 } from "path";
25382
26017
 
25383
26018
  // ../api/src/dashboard/profile-config-cache.ts
25384
26019
  var cache3 = /* @__PURE__ */ new Map();
@@ -25397,7 +26032,7 @@ function profileEnv(key) {
25397
26032
  function profileClaudeConfigDir() {
25398
26033
  const config = cachedProfileConfig();
25399
26034
  if (!config) return process.env["CLAUDE_CONFIG_DIR"] || void 0;
25400
- return config.env["CLAUDE_CONFIG_DIR"]?.trim() || join14(homedir7(), ".claude");
26035
+ return config.env["CLAUDE_CONFIG_DIR"]?.trim() || join14(homedir8(), ".claude");
25401
26036
  }
25402
26037
  function profileOauthToken() {
25403
26038
  const env = cachedProfileConfig()?.env ?? {};
@@ -25406,8 +26041,8 @@ function profileOauthToken() {
25406
26041
  return process.env["CLAUDE_CODE_OAUTH_TOKEN"] || void 0;
25407
26042
  }
25408
26043
  function isUnsafeCwd(cwd) {
25409
- const p = resolve5(cwd);
25410
- return p === parse(p).root || p === resolve5(homedir7());
26044
+ const p = resolve6(cwd);
26045
+ return p === parse(p).root || p === resolve6(homedir8());
25411
26046
  }
25412
26047
  function defaultClaudeCwd() {
25413
26048
  return profileEnv("CLAUDE_CWD") ?? process.cwd();
@@ -25513,9 +26148,9 @@ ${req.user}`,
25513
26148
  };
25514
26149
  }
25515
26150
  function run(inv, cwd) {
25516
- return new Promise((resolve7) => {
25517
- if (!existsSync14(cwd)) {
25518
- resolve7({ ok: false, error: `the channel folder ${cwd} does not exist on this Host` });
26151
+ return new Promise((resolve8) => {
26152
+ if (!existsSync15(cwd)) {
26153
+ resolve8({ ok: false, error: `the channel folder ${cwd} does not exist on this Host` });
25519
26154
  return;
25520
26155
  }
25521
26156
  const child = spawn4(inv.command, inv.args, {
@@ -25533,7 +26168,7 @@ function run(inv, cwd) {
25533
26168
  child.on("error", (err) => {
25534
26169
  clearTimeout(timer);
25535
26170
  console.error(`[memory-extraction] ${inv.command} failed to start:`, err.message);
25536
- resolve7({ ok: false, error: `${inv.command} failed to start: ${err.message}` });
26171
+ resolve8({ ok: false, error: `${inv.command} failed to start: ${err.message}` });
25537
26172
  });
25538
26173
  child.on("close", (code) => {
25539
26174
  clearTimeout(timer);
@@ -25541,7 +26176,7 @@ function run(inv, cwd) {
25541
26176
  const detail = (stderr || stdout).trim().split("\n").at(-1) ?? "";
25542
26177
  const error = `${inv.command} exited ${code ?? "on timeout"}: ${detail.slice(0, 200)}`;
25543
26178
  console.error(`[memory-extraction] ${error}`);
25544
- resolve7({ ok: false, error });
26179
+ resolve8({ ok: false, error });
25545
26180
  return;
25546
26181
  }
25547
26182
  let raw = stdout;
@@ -25552,7 +26187,7 @@ function run(inv, cwd) {
25552
26187
  raw = "";
25553
26188
  }
25554
26189
  }
25555
- resolve7({ ok: true, raw });
26190
+ resolve8({ ok: true, raw });
25556
26191
  });
25557
26192
  child.stdin.end(inv.stdin);
25558
26193
  });
@@ -25629,6 +26264,20 @@ var RATE_CARDS = [
25629
26264
  cacheWritePer1M: 3.75,
25630
26265
  effectiveFrom: "2026-09-01"
25631
26266
  },
26267
+ {
26268
+ // Anthropic's pricing page, checked 2026-11-09: the scheduled rise to $3/$15
26269
+ // never happened and $2/$10 became the standard price. Rows recorded since
26270
+ // 2026-09-01 still point at the card above and were overpriced by 50%.
26271
+ id: "anthropic:sonnet-5@2026-11-09",
26272
+ provider: "anthropic",
26273
+ model: "Claude Sonnet 5",
26274
+ matches: ["sonnet", "claude-sonnet"],
26275
+ inputPer1M: 2,
26276
+ outputPer1M: 10,
26277
+ cacheReadPer1M: 0.2,
26278
+ cacheWritePer1M: 2.5,
26279
+ effectiveFrom: "2026-11-09"
26280
+ },
25632
26281
  {
25633
26282
  id: "anthropic:opus-5@launch",
25634
26283
  provider: "anthropic",
@@ -25704,6 +26353,18 @@ var RATE_CARDS = [
25704
26353
  cacheWritePer1M: 5,
25705
26354
  effectiveFrom: EPOCH
25706
26355
  },
26356
+ {
26357
+ // OpenAI's pricing page, checked 2026-11-09: GPT-5.6 Sol dropped to $4/$20.
26358
+ id: "openai:gpt-5.6-sol@2026-11-09",
26359
+ provider: "openai",
26360
+ model: "GPT-5.6 Sol",
26361
+ matches: ["gpt-5.6-sol"],
26362
+ inputPer1M: 4,
26363
+ outputPer1M: 20,
26364
+ cacheReadPer1M: 0.4,
26365
+ cacheWritePer1M: 4,
26366
+ effectiveFrom: "2026-11-09"
26367
+ },
25707
26368
  {
25708
26369
  id: "openai:gpt-5.6-terra@0730",
25709
26370
  provider: "openai",
@@ -26275,7 +26936,7 @@ var UsageStore = class {
26275
26936
 
26276
26937
  // src/dashboard/rollover-summary.ts
26277
26938
  import { spawn as spawn5 } from "child_process";
26278
- import { existsSync as existsSync15, mkdtempSync as mkdtempSync6, readFileSync as readFileSync13, rmSync as rmSync9 } from "fs";
26939
+ import { existsSync as existsSync16, mkdtempSync as mkdtempSync6, readFileSync as readFileSync13, rmSync as rmSync9 } from "fs";
26279
26940
  import { tmpdir as tmpdir5 } from "os";
26280
26941
  import { join as join16 } from "path";
26281
26942
  var HAIKU_MODEL = "haiku";
@@ -26364,13 +27025,13 @@ ${input}`
26364
27025
  ],
26365
27026
  { ...process.env }
26366
27027
  );
26367
- return existsSync15(lastMessageFile) ? readFileSync13(lastMessageFile, "utf8").trim() : "";
27028
+ return existsSync16(lastMessageFile) ? readFileSync13(lastMessageFile, "utf8").trim() : "";
26368
27029
  } finally {
26369
27030
  rmSync9(dir, { recursive: true, force: true });
26370
27031
  }
26371
27032
  }
26372
27033
  function runPrint(command, args, env) {
26373
- return new Promise((resolve7, reject) => {
27034
+ return new Promise((resolve8, reject) => {
26374
27035
  const child = spawn5(command, args, {
26375
27036
  // A stateless rewrite touches no files — tmpdir keeps it that way and
26376
27037
  // avoids picking up an unrelated project's own CLAUDE.md/AGENTS.md,
@@ -26400,7 +27061,7 @@ function runPrint(command, args, env) {
26400
27061
  reject(new Error(`${command} summary exited with code ${code}: ${stderr.trim()}`));
26401
27062
  return;
26402
27063
  }
26403
- resolve7(stdout);
27064
+ resolve8(stdout);
26404
27065
  });
26405
27066
  });
26406
27067
  }
@@ -26698,10 +27359,10 @@ async function downloadChatAttachments(body) {
26698
27359
  }
26699
27360
 
26700
27361
  // src/dashboard/plugin-ui-store.ts
26701
- import { createHash as createHash5 } from "crypto";
27362
+ import { createHash as createHash6 } from "crypto";
26702
27363
  var INLINE_MAX = 2048;
26703
27364
  var uploaded = /* @__PURE__ */ new Map();
26704
- var sha256 = (s) => createHash5("sha256").update(s).digest("hex");
27365
+ var sha256 = (s) => createHash6("sha256").update(s).digest("hex");
26705
27366
  async function offloadSvg(workspace, source) {
26706
27367
  const cacheKey2 = `${workspace}:${sha256(source)}`;
26707
27368
  const cached = uploaded.get(cacheKey2);
@@ -26733,27 +27394,27 @@ async function offloadPluginUi(workspace, state) {
26733
27394
  var pluginUiHash = (state) => sha256(JSON.stringify(state));
26734
27395
 
26735
27396
  // src/dashboard/doc-mention-guard.ts
26736
- import { existsSync as existsSync20, statSync as statSync8 } from "fs";
27397
+ import { existsSync as existsSync21, statSync as statSync9 } from "fs";
26737
27398
 
26738
27399
  // src/dashboard/docs-routes.ts
26739
27400
  import {
26740
27401
  closeSync,
26741
27402
  createReadStream,
26742
- existsSync as existsSync19,
27403
+ existsSync as existsSync20,
26743
27404
  lstatSync as lstatSync2,
26744
- mkdirSync as mkdirSync8,
27405
+ mkdirSync as mkdirSync9,
26745
27406
  openSync,
26746
27407
  readSync,
26747
27408
  readdirSync as readdirSync6,
26748
27409
  readFileSync as readFileSync17,
26749
- realpathSync,
27410
+ realpathSync as realpathSync2,
26750
27411
  renameSync as renameSync3,
26751
27412
  rmSync as rmSync10,
26752
- statSync as statSync7,
27413
+ statSync as statSync8,
26753
27414
  writeFileSync as writeFileSync7
26754
27415
  } from "fs";
26755
27416
  import { Readable } from "stream";
26756
- import { basename as basename6, dirname as dirname3, extname as extname2, join as join21, relative, resolve as resolve6, sep as sep3 } from "path";
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";
26757
27418
  import { Hono as Hono4 } from "hono";
26758
27419
  import { streamSSE } from "hono/streaming";
26759
27420
 
@@ -26865,7 +27526,7 @@ var requireDocsAccess = async (c, next) => {
26865
27526
  };
26866
27527
 
26867
27528
  // src/dashboard/docs-watcher.ts
26868
- import { existsSync as existsSync16, watch } from "fs";
27529
+ import { existsSync as existsSync17, watch } from "fs";
26869
27530
  import { basename as basename5, join as join18 } from "path";
26870
27531
  var DEBOUNCE_MS = 200;
26871
27532
  var MAX_PENDING = 200;
@@ -26907,7 +27568,7 @@ function watchDocs(cwd, listener) {
26907
27568
  const current = entries.get(cwd);
26908
27569
  if (!current || filename === null) return;
26909
27570
  const rel = filename.split("\\").join("/");
26910
- if (rel === root && !existsSync16(join18(cwd, rel))) return;
27571
+ if (rel === root && !existsSync17(join18(cwd, rel))) return;
26911
27572
  if (isIgnoredDocPath(rel)) return;
26912
27573
  if (current.pending.size < MAX_PENDING) current.pending.add(rel);
26913
27574
  if (current.timer === null) current.timer = setTimeout(() => flush(cwd), DEBOUNCE_MS);
@@ -26961,7 +27622,7 @@ async function putDocTranslation(input) {
26961
27622
  }
26962
27623
 
26963
27624
  // ../api/src/dashboard/share-translate.ts
26964
- import { createHash as createHash6 } from "crypto";
27625
+ import { createHash as createHash7 } from "crypto";
26965
27626
 
26966
27627
  // ../api/src/store/doc-share-store.ts
26967
27628
  function rowToKind(value) {
@@ -27271,7 +27932,7 @@ function languageName(lang) {
27271
27932
  return BY_CODE.get(lang)?.name ?? null;
27272
27933
  }
27273
27934
  function translationHash(title, content) {
27274
- return createHash6("sha256").update(`${RECIPE_VERSION}
27935
+ return createHash7("sha256").update(`${RECIPE_VERSION}
27275
27936
  ${title}
27276
27937
  ${content}`).digest("hex");
27277
27938
  }
@@ -27506,7 +28167,7 @@ async function clearStaleDocAudios(channelId, sourcePath, lang, exceptHash) {
27506
28167
  }
27507
28168
 
27508
28169
  // ../api/src/dashboard/share-audio.ts
27509
- import { createHash as createHash7 } from "crypto";
28170
+ import { createHash as createHash8 } from "crypto";
27510
28171
  import { DeleteObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-sdk/client-s3";
27511
28172
 
27512
28173
  // ../api/src/dashboard/tts-routes.ts
@@ -27705,7 +28366,7 @@ Pacing \u2014 the engine has NO pause control, so rhythm has to be built into th
27705
28366
  Output plain text ONLY. No tags of any kind, no angle brackets, no Markdown, no quotation wrapping. Any tag you emit will be deleted before synthesis, so it buys nothing and costs meaning.`;
27706
28367
  }
27707
28368
  function articleAudioHash(title, content) {
27708
- return createHash7("sha256").update(`v${RECIPE_VERSION2}
28369
+ return createHash8("sha256").update(`v${RECIPE_VERSION2}
27709
28370
  ${title}
27710
28371
 
27711
28372
  ${content}`).digest("hex").slice(0, 32);
@@ -27828,7 +28489,7 @@ function truncationNotice(lang, voice) {
27828
28489
  if (lang === "en" || lang.startsWith("en-")) return TRUNCATION_NOTICE.en;
27829
28490
  return null;
27830
28491
  }
27831
- var sleep2 = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
28492
+ var sleep2 = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
27832
28493
  async function synthesizeWithRetry(script, voice) {
27833
28494
  let lastError;
27834
28495
  for (let attempt = 1; attempt <= SYNTH_ATTEMPTS; attempt += 1) {
@@ -27932,7 +28593,7 @@ function queueShareAudio(share) {
27932
28593
  var PENDING_STALE_MS = 30 * 60 * 1e3;
27933
28594
  var FAILED_RETRY_MS = 10 * 60 * 1e3;
27934
28595
  function langAudioHash(title, content, lang) {
27935
- return createHash7("sha256").update(`v${RECIPE_VERSION2}
28596
+ return createHash8("sha256").update(`v${RECIPE_VERSION2}
27936
28597
  ${lang}
27937
28598
  ${translationHash(title, content)}`).digest("hex").slice(0, 32);
27938
28599
  }
@@ -28219,7 +28880,7 @@ function createFeatureFlagsRouter() {
28219
28880
  }
28220
28881
 
28221
28882
  // ../api/src/dashboard/public-share-routes.ts
28222
- import { existsSync as existsSync18, readFileSync as readFileSync15, statSync as statSync6 } from "fs";
28883
+ import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "fs";
28223
28884
  import { join as join20 } from "path";
28224
28885
  import { Hono as Hono3 } from "hono";
28225
28886
  import { GetObjectCommand as GetObjectCommand3 } from "@aws-sdk/client-s3";
@@ -28426,12 +29087,12 @@ function injectShareHead(html, head) {
28426
29087
  }
28427
29088
 
28428
29089
  // ../api/src/dashboard/app-icon.ts
28429
- import { createHash as createHash8 } from "crypto";
28430
- import { existsSync as existsSync17, readFileSync as readFileSync14 } from "fs";
29090
+ import { createHash as createHash9 } from "crypto";
29091
+ import { existsSync as existsSync18, readFileSync as readFileSync14 } from "fs";
28431
29092
  import { join as join19 } from "path";
28432
29093
  import sharp3 from "sharp";
28433
29094
  var PLATE = "#0A0A0F";
28434
- var BRAND_DIR = existsSync17(join19(paths.WEB_ROOT, "public")) ? join19(paths.WEB_ROOT, "public") : join19(paths.PACKAGE_ROOT, "dist", "brand");
29095
+ var BRAND_DIR = existsSync18(join19(paths.WEB_ROOT, "public")) ? join19(paths.WEB_ROOT, "public") : join19(paths.PACKAGE_ROOT, "dist", "brand");
28435
29096
  var MARK_FILE = join19(BRAND_DIR, "icons", "icon-512.png");
28436
29097
  var MARK_SVG_FILE = join19(BRAND_DIR, "favicon.svg");
28437
29098
  var LAYOUT = {
@@ -28505,7 +29166,7 @@ async function renderAppIcon({
28505
29166
  size,
28506
29167
  maskable ? "maskable" : "std",
28507
29168
  plain ? "plain" : "badged",
28508
- logo ? createHash8("sha1").update(logo).digest("hex").slice(0, 12) : transparent ? "stock-transparent" : "stock"
29169
+ logo ? createHash9("sha1").update(logo).digest("hex").slice(0, 12) : transparent ? "stock-transparent" : "stock"
28509
29170
  ].join(":");
28510
29171
  const hit = cache4.get(key);
28511
29172
  if (hit) return hit;
@@ -28536,7 +29197,7 @@ async function composeIcon(logo, size, maskable, plain) {
28536
29197
  }
28537
29198
 
28538
29199
  // ../api/src/dashboard/share-og.ts
28539
- import { createHash as createHash9 } from "crypto";
29200
+ import { createHash as createHash10 } from "crypto";
28540
29201
  import sharp4 from "sharp";
28541
29202
  var WIDTH = 1200;
28542
29203
  var HEIGHT = 630;
@@ -28714,7 +29375,7 @@ function cacheKey(input) {
28714
29375
  input.logo ?? "",
28715
29376
  input.theme ?? ""
28716
29377
  ];
28717
- return createHash9("sha1").update(parts.join("\0")).digest("hex");
29378
+ return createHash10("sha1").update(parts.join("\0")).digest("hex");
28718
29379
  }
28719
29380
  async function renderShareOgImage(input) {
28720
29381
  const key = cacheKey(input);
@@ -28729,7 +29390,7 @@ async function renderShareOgImage(input) {
28729
29390
  }
28730
29391
 
28731
29392
  // ../api/src/dashboard/share-ask.ts
28732
- import { createHash as createHash10 } from "crypto";
29393
+ import { createHash as createHash11 } from "crypto";
28733
29394
  var MAX_ARTICLE_CHARS3 = 24e3;
28734
29395
  var MAX_QUESTION_CHARS = 500;
28735
29396
  var SUGGESTION_COUNT = 4;
@@ -28794,7 +29455,7 @@ function parseSuggestions(raw) {
28794
29455
  var CACHE_LIMIT = 200;
28795
29456
  var suggestionCache = /* @__PURE__ */ new Map();
28796
29457
  function articleHash(title, content, lang) {
28797
- return createHash10("sha256").update(`${lang ?? ""}
29458
+ return createHash11("sha256").update(`${lang ?? ""}
28798
29459
  ${title}
28799
29460
 
28800
29461
  ${content}`).digest("hex").slice(0, 32);
@@ -29048,7 +29709,7 @@ function createPublicShareApiRouter() {
29048
29709
  var BUILD_PREFIX = "/share/_assets";
29049
29710
  var shellCache = null;
29050
29711
  function readShell(path) {
29051
- const { mtimeMs } = statSync6(path);
29712
+ const { mtimeMs } = statSync7(path);
29052
29713
  if (shellCache?.mtimeMs === mtimeMs) return shellCache.html;
29053
29714
  const html = readFileSync15(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
29054
29715
  shellCache = { mtimeMs, html };
@@ -29071,7 +29732,7 @@ function serveBuildFile(c, webDist, dir, name) {
29071
29732
  return c.text("not found", 404);
29072
29733
  }
29073
29734
  const path = join20(webDist, dir, name);
29074
- if (!existsSync18(path)) return c.text("not found", 404);
29735
+ if (!existsSync19(path)) return c.text("not found", 404);
29075
29736
  c.header("Content-Type", type);
29076
29737
  c.header("Cache-Control", "public, max-age=31536000, immutable");
29077
29738
  if (ext === ".css") {
@@ -29217,7 +29878,7 @@ ${analytics}` : head);
29217
29878
  const lang = canonicalLanguage(requested);
29218
29879
  if (!isTranslatableLanguage(lang)) return next();
29219
29880
  const shell = join20(webDist, "index.html");
29220
- if (!existsSync18(shell)) return next();
29881
+ if (!existsSync19(shell)) return next();
29221
29882
  const share = await getDocShare(c.req.param("id"));
29222
29883
  if (!share) return next();
29223
29884
  if (requested !== lang) return c.redirect(`/share/${share.id}/${lang}`, 302);
@@ -29253,7 +29914,7 @@ ${analytics}` : head);
29253
29914
  if (!share) return next();
29254
29915
  if (share.kind === "html") return servePublishedHtml(c, share);
29255
29916
  const shell = join20(webDist, "index.html");
29256
- if (!existsSync18(shell)) return next();
29917
+ if (!existsSync19(shell)) return next();
29257
29918
  return readerPage(
29258
29919
  c,
29259
29920
  share,
@@ -29449,7 +30110,7 @@ function entryKind(entry, abs) {
29449
30110
  if (entry.isFile()) return "file";
29450
30111
  if (!entry.isSymbolicLink()) return null;
29451
30112
  try {
29452
- const target = statSync7(abs);
30113
+ const target = statSync8(abs);
29453
30114
  return target.isDirectory() ? "dir" : target.isFile() ? "file" : null;
29454
30115
  } catch {
29455
30116
  return null;
@@ -29462,11 +30123,11 @@ function fileNode(root, abs, name) {
29462
30123
  const lang = CODE_EXTENSIONS[ext];
29463
30124
  let stat;
29464
30125
  try {
29465
- stat = statSync7(abs);
30126
+ stat = statSync8(abs);
29466
30127
  } catch {
29467
30128
  return null;
29468
30129
  }
29469
- const path = relative(root, abs).split(sep3).join("/");
30130
+ const path = relative2(root, abs).split(sep4).join("/");
29470
30131
  const mtime = stat.mtime.toISOString();
29471
30132
  if (kind) {
29472
30133
  return {
@@ -29519,8 +30180,8 @@ function extractTitle(absPath, kind) {
29519
30180
  }
29520
30181
  function resolveDirPath(root, rel) {
29521
30182
  if (rel.includes("\0")) return null;
29522
- const abs = resolve6(root, rel);
29523
- if (abs !== root && !abs.startsWith(root + sep3)) return null;
30183
+ const abs = resolve7(root, rel);
30184
+ if (abs !== root && !abs.startsWith(root + sep4)) return null;
29524
30185
  return abs;
29525
30186
  }
29526
30187
  function isListableFile(name) {
@@ -29568,11 +30229,11 @@ function probeDir(absDir, showHidden) {
29568
30229
  function readGitBranch(dir) {
29569
30230
  try {
29570
30231
  let gitDir = join21(dir, ".git");
29571
- if (statSync7(gitDir).isFile()) {
30232
+ if (statSync8(gitDir).isFile()) {
29572
30233
  const pointer = readFileSync17(gitDir, "utf8").trim();
29573
30234
  const match = pointer.match(/^gitdir:\s*(.+)$/);
29574
30235
  if (!match) return void 0;
29575
- gitDir = resolve6(dir, match[1]);
30236
+ gitDir = resolve7(dir, match[1]);
29576
30237
  }
29577
30238
  const head = readFileSync17(join21(gitDir, "HEAD"), "utf8").trim();
29578
30239
  const branchMatch = head.match(/^ref:\s*refs\/heads\/(.+)$/);
@@ -29597,13 +30258,13 @@ function listDocLevel(root, relDir = "", sort = "newest", showHidden = false) {
29597
30258
  if (dirs.length + docs.length >= MAX_ENTRIES) break;
29598
30259
  if (!showHidden && entry.name.startsWith(".")) continue;
29599
30260
  const abs = join21(absDir, entry.name);
29600
- const path = relative(root, abs).split(sep3).join("/");
30261
+ const path = relative2(root, abs).split(sep4).join("/");
29601
30262
  const kind = entryKind(entry, abs);
29602
30263
  if (kind === "dir") {
29603
30264
  if (SKIP_DIRS.has(entry.name)) continue;
29604
30265
  const probe = probeDir(abs, showHidden);
29605
30266
  if (!probe.hasDocs && probe.hasOther) continue;
29606
- const isRepo = existsSync19(join21(abs, ".git"));
30267
+ const isRepo = existsSync20(join21(abs, ".git"));
29607
30268
  dirs.push({
29608
30269
  path,
29609
30270
  name: entry.name,
@@ -29659,8 +30320,8 @@ function flatDocs(root, {
29659
30320
  }
29660
30321
  function resolveDocPath(root, rel) {
29661
30322
  if (!rel || rel.includes("\0")) return null;
29662
- const abs = resolve6(root, rel);
29663
- if (abs !== root && !abs.startsWith(root + sep3)) return null;
30323
+ const abs = resolve7(root, rel);
30324
+ if (abs !== root && !abs.startsWith(root + sep4)) return null;
29664
30325
  const ext = extname2(abs).toLowerCase();
29665
30326
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return null;
29666
30327
  return abs;
@@ -29670,7 +30331,7 @@ function writeDocContent(root, rel, content, baseMtime) {
29670
30331
  if (!abs) return { status: "not-found" };
29671
30332
  let stat;
29672
30333
  try {
29673
- stat = statSync7(abs);
30334
+ stat = statSync8(abs);
29674
30335
  } catch {
29675
30336
  return { status: "not-found" };
29676
30337
  }
@@ -29682,27 +30343,27 @@ function writeDocContent(root, rel, content, baseMtime) {
29682
30343
  return { status: "too-large" };
29683
30344
  }
29684
30345
  writeFileSync7(abs, content, "utf8");
29685
- return { status: "ok", mtime: statSync7(abs).mtime.toISOString() };
30346
+ return { status: "ok", mtime: statSync8(abs).mtime.toISOString() };
29686
30347
  }
29687
30348
  function resolveRawPath(root, rel) {
29688
30349
  if (!rel || rel.includes("\0")) return null;
29689
- const abs = resolve6(root, rel);
29690
- if (abs !== root && !abs.startsWith(root + sep3)) return null;
30350
+ const abs = resolve7(root, rel);
30351
+ if (abs !== root && !abs.startsWith(root + sep4)) return null;
29691
30352
  const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()];
29692
30353
  if (!contentType) return null;
29693
30354
  return { abs, contentType };
29694
30355
  }
29695
30356
  function resolveHtmlPath(root, rel) {
29696
30357
  if (!rel || rel.includes("\0")) return null;
29697
- const abs = resolve6(root, rel);
29698
- if (abs !== root && !abs.startsWith(root + sep3)) return null;
30358
+ const abs = resolve7(root, rel);
30359
+ if (abs !== root && !abs.startsWith(root + sep4)) return null;
29699
30360
  if (DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "html") return null;
29700
30361
  return abs;
29701
30362
  }
29702
30363
  function resolveDownloadPath(root, rel) {
29703
30364
  if (!rel || rel.includes("\0")) return null;
29704
- const abs = resolve6(root, rel);
29705
- if (abs !== root && !abs.startsWith(root + sep3)) return null;
30365
+ const abs = resolve7(root, rel);
30366
+ if (abs !== root && !abs.startsWith(root + sep4)) return null;
29706
30367
  if (!isListableFile(basename6(abs))) return null;
29707
30368
  const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()] ?? "application/octet-stream";
29708
30369
  return { abs, contentType };
@@ -29719,7 +30380,7 @@ function uniqueName(absDir, name) {
29719
30380
  let candidate = name;
29720
30381
  for (let n = 1; n < 1e3; n++) {
29721
30382
  try {
29722
- statSync7(join21(absDir, candidate));
30383
+ statSync8(join21(absDir, candidate));
29723
30384
  } catch {
29724
30385
  return candidate;
29725
30386
  }
@@ -29731,7 +30392,7 @@ function saveUploadedFile(root, relDir, name, data) {
29731
30392
  const absDir = resolveDirPath(root, relDir);
29732
30393
  if (absDir === null) return { status: "no-dir" };
29733
30394
  try {
29734
- if (!statSync7(absDir).isDirectory()) return { status: "no-dir" };
30395
+ if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
29735
30396
  } catch {
29736
30397
  return { status: "no-dir" };
29737
30398
  }
@@ -29743,13 +30404,13 @@ function saveUploadedFile(root, relDir, name, data) {
29743
30404
  const final = uniqueName(absDir, safe);
29744
30405
  const abs = join21(absDir, final);
29745
30406
  writeFileSync7(abs, data);
29746
- return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: final };
30407
+ return { status: "ok", path: relative2(root, abs).split(sep4).join("/"), name: final };
29747
30408
  }
29748
30409
  function createDocFolder(root, relDir, name) {
29749
30410
  const absDir = resolveDirPath(root, relDir);
29750
30411
  if (absDir === null) return { status: "no-dir" };
29751
30412
  try {
29752
- if (!statSync7(absDir).isDirectory()) return { status: "no-dir" };
30413
+ if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
29753
30414
  } catch {
29754
30415
  return { status: "no-dir" };
29755
30416
  }
@@ -29757,18 +30418,18 @@ function createDocFolder(root, relDir, name) {
29757
30418
  if (!safe) return { status: "bad-name" };
29758
30419
  const abs = join21(absDir, safe);
29759
30420
  try {
29760
- statSync7(abs);
30421
+ statSync8(abs);
29761
30422
  return { status: "exists" };
29762
30423
  } catch {
29763
30424
  }
29764
- mkdirSync8(abs);
29765
- return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: safe };
30425
+ mkdirSync9(abs);
30426
+ return { status: "ok", path: relative2(root, abs).split(sep4).join("/"), name: safe };
29766
30427
  }
29767
30428
  function createDocFile(root, relDir, name, content) {
29768
30429
  const absDir = resolveDirPath(root, relDir);
29769
30430
  if (absDir === null) return { status: "no-dir" };
29770
30431
  try {
29771
- if (!statSync7(absDir).isDirectory()) return { status: "no-dir" };
30432
+ if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
29772
30433
  } catch {
29773
30434
  return { status: "no-dir" };
29774
30435
  }
@@ -29785,22 +30446,22 @@ function createDocFile(root, relDir, name, content) {
29785
30446
  if (err.code === "EEXIST") return { status: "exists" };
29786
30447
  throw err;
29787
30448
  }
29788
- return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: safe };
30449
+ return { status: "ok", path: relative2(root, abs).split(sep4).join("/"), name: safe };
29789
30450
  }
29790
30451
  function moveDocEntry(root, from, to) {
29791
30452
  if (!from || !to || from.includes("\0") || to.includes("\0")) return { status: "not-found" };
29792
- const absFrom = resolve6(root, from);
29793
- if (!absFrom.startsWith(root + sep3)) return { status: "not-found" };
30453
+ const absFrom = resolve7(root, from);
30454
+ if (!absFrom.startsWith(root + sep4)) return { status: "not-found" };
29794
30455
  let stat;
29795
30456
  try {
29796
- stat = statSync7(absFrom);
30457
+ stat = statSync8(absFrom);
29797
30458
  } catch {
29798
30459
  return { status: "not-found" };
29799
30460
  }
29800
30461
  const isDir = stat.isDirectory();
29801
30462
  if (!isDir && !stat.isFile()) return { status: "not-found" };
29802
- const absTo = resolve6(root, to);
29803
- if (!absTo.startsWith(root + sep3)) return { status: "bad-target" };
30463
+ const absTo = resolve7(root, to);
30464
+ if (!absTo.startsWith(root + sep4)) return { status: "bad-target" };
29804
30465
  const name = sanitizeUploadName(basename6(absTo));
29805
30466
  if (!name) return { status: "bad-target" };
29806
30467
  if (!isDir) {
@@ -29810,27 +30471,27 @@ function moveDocEntry(root, from, to) {
29810
30471
  }
29811
30472
  }
29812
30473
  const absToDir = dirname3(absTo);
29813
- if (resolveDirPath(root, relative(root, absToDir)) === null) return { status: "bad-target" };
30474
+ if (resolveDirPath(root, relative2(root, absToDir)) === null) return { status: "bad-target" };
29814
30475
  try {
29815
- if (!statSync7(absToDir).isDirectory()) return { status: "bad-target" };
30476
+ if (!statSync8(absToDir).isDirectory()) return { status: "bad-target" };
29816
30477
  } catch {
29817
30478
  return { status: "bad-target" };
29818
30479
  }
29819
30480
  const finalAbs = join21(absToDir, name);
29820
- if (isDir && (finalAbs === absFrom || finalAbs.startsWith(absFrom + sep3))) {
30481
+ if (isDir && (finalAbs === absFrom || finalAbs.startsWith(absFrom + sep4))) {
29821
30482
  return { status: "into-self" };
29822
30483
  }
29823
30484
  try {
29824
- if (realpathSync(finalAbs) !== realpathSync(absFrom)) return { status: "exists" };
30485
+ if (realpathSync2(finalAbs) !== realpathSync2(absFrom)) return { status: "exists" };
29825
30486
  } catch {
29826
30487
  }
29827
30488
  renameSync3(absFrom, finalAbs);
29828
- return { status: "ok", path: relative(root, finalAbs).split(sep3).join("/"), name };
30489
+ return { status: "ok", path: relative2(root, finalAbs).split(sep4).join("/"), name };
29829
30490
  }
29830
30491
  function deleteDocEntry(root, path) {
29831
30492
  if (!path || path.includes("\0")) return { status: "not-found" };
29832
- const abs = resolve6(root, path);
29833
- if (!abs.startsWith(root + sep3)) return { status: "not-found" };
30493
+ const abs = resolve7(root, path);
30494
+ if (!abs.startsWith(root + sep4)) return { status: "not-found" };
29834
30495
  let stat;
29835
30496
  try {
29836
30497
  stat = lstatSync2(abs);
@@ -29842,7 +30503,7 @@ function deleteDocEntry(root, path) {
29842
30503
  rmSync10(abs, { recursive: isDir });
29843
30504
  return {
29844
30505
  status: "ok",
29845
- path: relative(root, abs).split(sep3).join("/"),
30506
+ path: relative2(root, abs).split(sep4).join("/"),
29846
30507
  type: isDir ? "dir" : "file"
29847
30508
  };
29848
30509
  }
@@ -29872,7 +30533,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
29872
30533
  if (!resolved2) return c.json({ error: "not found" }, 404);
29873
30534
  let stat;
29874
30535
  try {
29875
- stat = statSync7(resolved2.abs);
30536
+ stat = statSync8(resolved2.abs);
29876
30537
  } catch {
29877
30538
  return c.json({ error: "not found" }, 404);
29878
30539
  }
@@ -29894,7 +30555,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
29894
30555
  if (!abs) return c.json({ error: "not found" }, 404);
29895
30556
  let stat;
29896
30557
  try {
29897
- stat = statSync7(abs);
30558
+ stat = statSync8(abs);
29898
30559
  } catch {
29899
30560
  return c.json({ error: "not found" }, 404);
29900
30561
  }
@@ -30018,7 +30679,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30018
30679
  if (!abs) return c.json({ error: "not found" }, 404);
30019
30680
  let stat;
30020
30681
  try {
30021
- stat = statSync7(abs);
30682
+ stat = statSync8(abs);
30022
30683
  } catch {
30023
30684
  return c.json({ error: "not found" }, 404);
30024
30685
  }
@@ -30067,7 +30728,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30067
30728
  if (!abs) return c.json({ error: "not found" }, 404);
30068
30729
  let stat;
30069
30730
  try {
30070
- stat = statSync7(abs);
30731
+ stat = statSync8(abs);
30071
30732
  } catch {
30072
30733
  return c.json({ error: "not found" }, 404);
30073
30734
  }
@@ -30118,7 +30779,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30118
30779
  }
30119
30780
  let stat;
30120
30781
  try {
30121
- stat = statSync7(abs);
30782
+ stat = statSync8(abs);
30122
30783
  } catch {
30123
30784
  return { error: c.json({ error: "not found" }, 404) };
30124
30785
  }
@@ -30186,9 +30847,9 @@ function withDocLinkBridge(html) {
30186
30847
  var DOC_MENTION_RE = /(?<![\w@/`])@((?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]{1,6})(?::(\d+))?(?![\w-])/g;
30187
30848
  function isRealDoc(root, rel) {
30188
30849
  const abs = resolveDocPath(root, rel);
30189
- if (!abs || !existsSync20(abs)) return false;
30850
+ if (!abs || !existsSync21(abs)) return false;
30190
30851
  try {
30191
- return statSync8(abs).isFile();
30852
+ return statSync9(abs).isFile();
30192
30853
  } catch {
30193
30854
  return false;
30194
30855
  }
@@ -30627,7 +31288,7 @@ var BACKGROUND_CHECK_IN_MS = 30 * 6e4;
30627
31288
  var MISSED_MESSAGE_WINDOW_MS = 24 * 60 * 60 * 1e3;
30628
31289
  var MISSED_MESSAGE_THREAD_LIMIT = 100;
30629
31290
  var delay = (ms) => new Promise((r) => setTimeout(r, ms));
30630
- function stripPathPrefixes(label, roots, home = homedir8()) {
31291
+ function stripPathPrefixes(label, roots, home = homedir9()) {
30631
31292
  let out = label;
30632
31293
  for (const root of roots) {
30633
31294
  if (root) out = out.replaceAll(`${root.replace(/\/+$/, "")}/`, "");
@@ -31626,22 +32287,22 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
31626
32287
  let ready;
31627
32288
  try {
31628
32289
  channel = this.supabase().channel(`agent-thinking:${threadId}`);
31629
- ready = new Promise((resolve7) => {
32290
+ ready = new Promise((resolve8) => {
31630
32291
  const timeout = setTimeout(() => {
31631
32292
  console.error(`[chat-agent] thinking-channel ${threadId}: subscribe timed out after 10s`);
31632
- resolve7(false);
32293
+ resolve8(false);
31633
32294
  }, 1e4);
31634
32295
  channel.subscribe((status, err) => {
31635
32296
  if (status === "SUBSCRIBED") {
31636
32297
  clearTimeout(timeout);
31637
- resolve7(true);
32298
+ resolve8(true);
31638
32299
  } else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
31639
32300
  console.error(
31640
32301
  `[chat-agent] thinking-channel ${threadId}: ${status}`,
31641
32302
  err?.message ?? ""
31642
32303
  );
31643
32304
  clearTimeout(timeout);
31644
- resolve7(false);
32305
+ resolve8(false);
31645
32306
  }
31646
32307
  });
31647
32308
  });
@@ -31688,19 +32349,19 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
31688
32349
  let ready;
31689
32350
  try {
31690
32351
  channel = this.supabase().channel("channel-activity");
31691
- ready = new Promise((resolve7) => {
32352
+ ready = new Promise((resolve8) => {
31692
32353
  const timeout = setTimeout(() => {
31693
32354
  console.error("[chat-agent] channel-activity: subscribe timed out after 10s");
31694
- resolve7(false);
32355
+ resolve8(false);
31695
32356
  }, 1e4);
31696
32357
  channel.subscribe((status, err) => {
31697
32358
  if (status === "SUBSCRIBED") {
31698
32359
  clearTimeout(timeout);
31699
- resolve7(true);
32360
+ resolve8(true);
31700
32361
  } else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
31701
32362
  console.error(`[chat-agent] channel-activity: ${status}`, err?.message ?? "");
31702
32363
  clearTimeout(timeout);
31703
- resolve7(false);
32364
+ resolve8(false);
31704
32365
  }
31705
32366
  });
31706
32367
  });
@@ -31767,42 +32428,49 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
31767
32428
  } : {};
31768
32429
  const permissionServer = channelConfig.runtime === "host" && permission;
31769
32430
  try {
31770
- return await withMcpConfig(
32431
+ return await runWithProfile(
31771
32432
  channelConfig.profile,
31772
- channelConfig.mcpConnections,
31773
- (mcpConfigPath) => this.ask(
31774
- prompt,
31775
- channelConfig.cwd,
31776
- this.config.botName,
31777
- {
31778
- model: channelConfig.model,
31779
- effort: channelConfig.effort,
31780
- runtime: channelConfig.runtime,
31781
- mounts: channelConfig.mounts,
31782
- permissionMode: channelConfig.permissionMode,
31783
- ...permissionServer ? { permissionPromptTool: PERMISSION_PROMPT_TOOL } : {},
31784
- maxBudgetUsd: this.config.maxBudgetUsd,
31785
- agentPersona,
31786
- channelPrompt: channelConfig.prompt,
31787
- ownPersona: channelConfig.ownPersona,
31788
- slackBound: channelConfig.slackBound,
31789
- onActivity,
31790
- ...channelConfig.permissionThread ? {
31791
- onPluginUi: (state) => void this.savePluginUi(channelConfig.profile, channelConfig.permissionThread.threadId, state)
31792
- } : {},
31793
- signal,
31794
- mcpConfigPath,
31795
- ...usageContext ? { usageContext } : {},
31796
- ...channelConfig.docsAccess ? { docsAccess: channelConfig.docsAccess } : {},
31797
- ...channelConfig.docsAccessUnverified ? { docsAccessUnverified: true } : {},
31798
- ...channelConfig.memoryPrompt ? { memoryPrompt: channelConfig.memoryPrompt } : {},
31799
- ...channelConfig.disableAutoMemory ? { disableAutoMemory: true } : {}
31800
- },
31801
- channelConfig.claudeConfigDir,
31802
- sessionId,
31803
- channelConfig.claudeCodeOauthToken
31804
- ),
31805
- ownServers
32433
+ () => withMcpConfig(
32434
+ channelConfig.profile,
32435
+ channelConfig.mcpConnections,
32436
+ (mcpConfigPath) => this.ask(
32437
+ prompt,
32438
+ channelConfig.cwd,
32439
+ this.config.botName,
32440
+ {
32441
+ model: channelConfig.model,
32442
+ effort: channelConfig.effort,
32443
+ runtime: channelConfig.runtime,
32444
+ mounts: channelConfig.mounts,
32445
+ permissionMode: channelConfig.permissionMode,
32446
+ ...permissionServer ? { permissionPromptTool: PERMISSION_PROMPT_TOOL } : {},
32447
+ maxBudgetUsd: this.config.maxBudgetUsd,
32448
+ agentPersona,
32449
+ channelPrompt: channelConfig.prompt,
32450
+ ownPersona: channelConfig.ownPersona,
32451
+ slackBound: channelConfig.slackBound,
32452
+ onActivity,
32453
+ ...channelConfig.permissionThread ? {
32454
+ onPluginUi: (state) => void this.savePluginUi(
32455
+ channelConfig.profile,
32456
+ channelConfig.permissionThread.threadId,
32457
+ state
32458
+ )
32459
+ } : {},
32460
+ signal,
32461
+ mcpConfigPath,
32462
+ ...usageContext ? { usageContext } : {},
32463
+ ...channelConfig.docsAccess ? { docsAccess: channelConfig.docsAccess } : {},
32464
+ ...channelConfig.docsAccessUnverified ? { docsAccessUnverified: true } : {},
32465
+ ...channelConfig.memoryPrompt ? { memoryPrompt: channelConfig.memoryPrompt } : {},
32466
+ ...channelConfig.disableAutoMemory ? { disableAutoMemory: true } : {}
32467
+ },
32468
+ channelConfig.claudeConfigDir,
32469
+ sessionId,
32470
+ channelConfig.claudeCodeOauthToken
32471
+ ),
32472
+ ownServers
32473
+ )
31806
32474
  );
31807
32475
  } catch (err) {
31808
32476
  console.error("[chat-agent] ask failed:", err.message);
@@ -31835,40 +32503,43 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
31835
32503
  const name = subAgentName(channelConfig.agentName);
31836
32504
  const agentPersona = name ? readAgentPersona(channelConfig.claudeConfigDir, channelConfig.cwd, name) : void 0;
31837
32505
  try {
31838
- return await askCodex(
31839
- prompt,
31840
- channelConfig.cwd,
31841
- {
31842
- // A channel (or the composer) can name a Codex model in the same
31843
- // `model` field Claude uses — whichever runner recognises the value
31844
- // owns it. Falling back to CUSTIE_CODEX_MODEL, then to whatever
31845
- // Codex's own config.toml says.
31846
- ...isCodexModel(channelConfig.model) ? { model: channelConfig.model } : channelConfig.codexModel ? { model: channelConfig.codexModel } : {},
31847
- ...channelConfig.effort ? { effort: channelConfig.effort } : {},
31848
- // Codex has no --append-system-prompt, so the workspace persona and
31849
- // the channel's own instructions ride in with the prompt. Without
31850
- // this a Codex turn answers as a generic coding agent: no house
31851
- // language rules, no Slack/dashboard conventions, no channel prompt.
31852
- systemPrompt: [
31853
- buildSystemPrompt(
31854
- this.config.botName,
31855
- agentPersona,
31856
- channelConfig.prompt,
31857
- resolveSelectedOutputStyle(channelConfig.claudeConfigDir)?.body,
31858
- channelConfig.slackBound
31859
- ),
31860
- channelConfig.memoryPrompt,
31861
- docsAccessPromptNote(channelConfig.docsAccess, channelConfig.docsAccessUnverified)
31862
- ].filter(Boolean).join("\n\n---\n\n"),
31863
- // Codex has no per-tool deny list, so any restricted requester gets
31864
- // its read-only sandbox (no file writes). It can still read: see the
31865
- // residual-gap note in docs/features/user-roles.md.
31866
- ...channelConfig.docsAccess === "read" || channelConfig.docsAccess === "none" ? { sandbox: "read-only" } : {},
31867
- ...onActivity ? { onActivity } : {},
31868
- ...signal ? { signal } : {},
31869
- ...usageContext ? { usageContext } : {}
31870
- },
31871
- sessionId
32506
+ return await runWithProfile(
32507
+ channelConfig.profile,
32508
+ () => askCodex(
32509
+ prompt,
32510
+ channelConfig.cwd,
32511
+ {
32512
+ // A channel (or the composer) can name a Codex model in the same
32513
+ // `model` field Claude uses — whichever runner recognises the value
32514
+ // owns it. Falling back to CUSTIE_CODEX_MODEL, then to whatever
32515
+ // Codex's own config.toml says.
32516
+ ...isCodexModel(channelConfig.model) ? { model: channelConfig.model } : channelConfig.codexModel ? { model: channelConfig.codexModel } : {},
32517
+ ...channelConfig.effort ? { effort: channelConfig.effort } : {},
32518
+ // Codex has no --append-system-prompt, so the workspace persona and
32519
+ // the channel's own instructions ride in with the prompt. Without
32520
+ // this a Codex turn answers as a generic coding agent: no house
32521
+ // language rules, no Slack/dashboard conventions, no channel prompt.
32522
+ systemPrompt: [
32523
+ buildSystemPrompt(
32524
+ this.config.botName,
32525
+ agentPersona,
32526
+ channelConfig.prompt,
32527
+ resolveSelectedOutputStyle(channelConfig.claudeConfigDir)?.body,
32528
+ channelConfig.slackBound
32529
+ ),
32530
+ channelConfig.memoryPrompt,
32531
+ docsAccessPromptNote(channelConfig.docsAccess, channelConfig.docsAccessUnverified)
32532
+ ].filter(Boolean).join("\n\n---\n\n"),
32533
+ // Codex has no per-tool deny list, so any restricted requester gets
32534
+ // its read-only sandbox (no file writes). It can still read: see the
32535
+ // residual-gap note in docs/features/user-roles.md.
32536
+ ...channelConfig.docsAccess === "read" || channelConfig.docsAccess === "none" ? { sandbox: "read-only" } : {},
32537
+ ...onActivity ? { onActivity } : {},
32538
+ ...signal ? { signal } : {},
32539
+ ...usageContext ? { usageContext } : {}
32540
+ },
32541
+ sessionId
32542
+ )
31872
32543
  );
31873
32544
  } catch (err) {
31874
32545
  console.error("[chat-agent] ask codex failed:", err.message);
@@ -34143,13 +34814,13 @@ async function recoverStaleReactions(client, reactionStore) {
34143
34814
  var ts2 = () => (/* @__PURE__ */ new Date()).toISOString();
34144
34815
  var POWER_POLL_MS = 3e4;
34145
34816
  function isOnACPower() {
34146
- return new Promise((resolve7) => {
34817
+ return new Promise((resolve8) => {
34147
34818
  execFile2("pmset", ["-g", "ps"], { timeout: 2e3 }, (err, stdout) => {
34148
34819
  if (err) {
34149
- resolve7(true);
34820
+ resolve8(true);
34150
34821
  return;
34151
34822
  }
34152
- resolve7(stdout.includes("'AC Power'"));
34823
+ resolve8(stdout.includes("'AC Power'"));
34153
34824
  });
34154
34825
  });
34155
34826
  }
@@ -34299,10 +34970,35 @@ export {
34299
34970
  resolveUserId,
34300
34971
  ensureUsersCached,
34301
34972
  useLocalCache,
34973
+ isPermissionMode,
34974
+ isLogicalCwd,
34975
+ isUnderLogicalRoot,
34976
+ expandPath,
34977
+ canSeeChannel,
34978
+ refreshChannelRegistry,
34979
+ getChannelRegistry,
34980
+ getProfileChannelRegistry,
34981
+ findChannelById,
34982
+ findChannel,
34983
+ startChannelRegistryPolling,
34984
+ isCwdUsable,
34985
+ auditChannelCwds,
34986
+ warnOnBrokenChannelCwds,
34987
+ resolveCwd,
34988
+ ChannelCwdError,
34989
+ createChannel,
34990
+ DefaultChannelError,
34991
+ updateChannelById,
34992
+ markChannelGreeted,
34993
+ updateChannelsMcpConnections,
34994
+ ensureAgentDmChannel,
34995
+ ensureGeneralChannel,
34996
+ ensureMemberDmChannel,
34302
34997
  getWorkspaceDomain,
34303
34998
  insertWorkspaceDomain,
34304
34999
  updateWorkspaceDomainStatus,
34305
35000
  deleteWorkspaceDomain,
35001
+ allowedOrigins,
34306
35002
  crossOriginShell,
34307
35003
  corsForShell,
34308
35004
  createRequestSupabaseClient,
@@ -34356,6 +35052,7 @@ export {
34356
35052
  BRANDING_DEFAULTS,
34357
35053
  getWorkspaceBranding,
34358
35054
  upsertWorkspaceBranding,
35055
+ localDefaults,
34359
35056
  loadWorkspaceBranding,
34360
35057
  saveWorkspaceBranding,
34361
35058
  loadWorkspacePrompt,
@@ -34381,6 +35078,12 @@ export {
34381
35078
  clearClaudeAuthFailed,
34382
35079
  claudeAuthFailed,
34383
35080
  pinnedClaudeConfigDir,
35081
+ AGENT_AUTHOR,
35082
+ isHumanAuthor,
35083
+ deriveThreadTitle,
35084
+ syncPostToDashboard,
35085
+ resolveDashboardChannelId,
35086
+ postToDashboardChannel,
34384
35087
  refreshAutomationRegistry,
34385
35088
  startAutomationRegistryPolling,
34386
35089
  DEFAULT_TIMEZONE,
@@ -34498,6 +35201,7 @@ export {
34498
35201
  TRANSLATION_LANGUAGES,
34499
35202
  canonicalLanguage,
34500
35203
  isTranslatableLanguage,
35204
+ isSourceLanguage,
34501
35205
  detectSourceLanguage,
34502
35206
  createTtsRouter,
34503
35207
  dropShareAudio,