flyspace-cli 0.1.65 → 0.1.67

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,35 +2,67 @@
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,
5
7
  DEFAULT_CODEX_MODEL,
8
+ SUPPORT_BOT_AUTHOR,
9
+ SYNCED_BOT_AUTHOR,
6
10
  SessionStore,
7
11
  __commonJS,
8
12
  __require,
9
13
  __toESM,
10
14
  databaseReachable,
15
+ dmCwd,
16
+ ensureAgentDmChannel,
17
+ ensureChannelProvisioned,
11
18
  ensureDirs,
19
+ ensureLogicalCwdDir,
20
+ expandPath,
21
+ findChannel,
22
+ findChannelById,
23
+ getChannelRegistry,
12
24
  getProfile,
25
+ getProfileChannelRegistry,
13
26
  getR2Bucket,
14
27
  getR2Client,
15
28
  getSupabaseClient,
29
+ isChannelAccessAllowed,
16
30
  isEffort,
31
+ isHumanAuthor,
32
+ isPermissionMode,
17
33
  loadConfig,
18
34
  loadEnvFiles,
19
35
  mcpStrictConfigEnabled,
36
+ onChannelRegistryChange,
20
37
  paths,
38
+ postToDashboardChannel,
39
+ refreshChannelRegistry,
21
40
  requestAttachmentUrl,
22
41
  requestPluginSvg,
23
42
  requestShouldRespond,
24
43
  requireSlackBotToken,
44
+ resolveAutoContinueLimit,
45
+ resolveChannelPermissionMode,
46
+ resolveChannelPrompt,
25
47
  resolveClaudeEffort,
26
48
  resolveCodexEffort,
49
+ resolveCwd,
50
+ resolveEffort,
51
+ resolveLogicalCwd,
52
+ resolveModel,
53
+ resolveOwnPersona,
27
54
  runWithProfile,
28
55
  sendAgentFailure,
29
56
  setSupabaseClientFactory,
57
+ startChannelRegistryPolling,
30
58
  sweepScratchDir,
59
+ syncPostToDashboard,
60
+ updateChannelById,
31
61
  uploadLocalImages,
32
- useHostDbWithoutCredentials
33
- } from "./chunk-O7OYNQND.js";
62
+ useHostDbWithoutCredentials,
63
+ warnOnBrokenChannelCwds,
64
+ workspaceAgentDefault
65
+ } from "./chunk-JH66T2SW.js";
34
66
 
35
67
  // ../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
36
68
  var require_delayed_stream = __commonJS({
@@ -11595,8 +11627,8 @@ var require_follow_redirects = __commonJS({
11595
11627
  }
11596
11628
  return parsed;
11597
11629
  }
11598
- function resolveUrl(relative3, base) {
11599
- return useNativeURL ? new URL2(relative3, base) : parseUrl(url.resolve(base, relative3));
11630
+ function resolveUrl(relative2, base) {
11631
+ return useNativeURL ? new URL2(relative2, base) : parseUrl(url.resolve(base, relative2));
11600
11632
  }
11601
11633
  function validateUrl(input) {
11602
11634
  if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
@@ -12986,10 +13018,10 @@ var require_axios = __commonJS({
12986
13018
  }
12987
13019
  };
12988
13020
  var CanceledError$1 = CanceledError;
12989
- function settle(resolve8, reject, response) {
13021
+ function settle(resolve7, reject, response) {
12990
13022
  const validateStatus = response.config.validateStatus;
12991
13023
  if (!response.status || !validateStatus || validateStatus(response.status)) {
12992
- resolve8(response);
13024
+ resolve7(response);
12993
13025
  } else {
12994
13026
  reject(
12995
13027
  new AxiosError$1(
@@ -13581,7 +13613,7 @@ var require_axios = __commonJS({
13581
13613
  }
13582
13614
  var isHttpAdapterSupported = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
13583
13615
  var wrapAsync = (asyncExecutor) => {
13584
- return new Promise((resolve8, reject) => {
13616
+ return new Promise((resolve7, reject) => {
13585
13617
  let onDone;
13586
13618
  let isDone;
13587
13619
  const done = (value, isRejected) => {
@@ -13591,7 +13623,7 @@ var require_axios = __commonJS({
13591
13623
  };
13592
13624
  const _resolve = (value) => {
13593
13625
  done(value);
13594
- resolve8(value);
13626
+ resolve7(value);
13595
13627
  };
13596
13628
  const _reject = (reason) => {
13597
13629
  done(reason, true);
@@ -13638,7 +13670,7 @@ var require_axios = __commonJS({
13638
13670
  }
13639
13671
  };
13640
13672
  var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config) {
13641
- return wrapAsync(async function dispatchHttpRequest(resolve8, reject, onDone) {
13673
+ return wrapAsync(async function dispatchHttpRequest(resolve7, reject, onDone) {
13642
13674
  let { data, lookup: lookup2, family, httpVersion = 1, http2Options } = config;
13643
13675
  const { responseType, responseEncoding } = config;
13644
13676
  const method = config.method.toUpperCase();
@@ -13728,7 +13760,7 @@ var require_axios = __commonJS({
13728
13760
  }
13729
13761
  let convertedData;
13730
13762
  if (method !== "GET") {
13731
- return settle(resolve8, reject, {
13763
+ return settle(resolve7, reject, {
13732
13764
  status: 405,
13733
13765
  statusText: "method not allowed",
13734
13766
  headers: {},
@@ -13750,7 +13782,7 @@ var require_axios = __commonJS({
13750
13782
  } else if (responseType === "stream") {
13751
13783
  convertedData = stream__default["default"].Readable.from(convertedData);
13752
13784
  }
13753
- return settle(resolve8, reject, {
13785
+ return settle(resolve7, reject, {
13754
13786
  data: convertedData,
13755
13787
  status: 200,
13756
13788
  statusText: "OK",
@@ -13991,7 +14023,7 @@ var require_axios = __commonJS({
13991
14023
  };
13992
14024
  if (responseType === "stream") {
13993
14025
  response.data = responseStream;
13994
- settle(resolve8, reject, response);
14026
+ settle(resolve7, reject, response);
13995
14027
  } else {
13996
14028
  const responseBuffer = [];
13997
14029
  let totalResponseBytes = 0;
@@ -14041,7 +14073,7 @@ var require_axios = __commonJS({
14041
14073
  } catch (err) {
14042
14074
  return reject(AxiosError$1.from(err, null, config, response.request, response));
14043
14075
  }
14044
- settle(resolve8, reject, response);
14076
+ settle(resolve7, reject, response);
14045
14077
  });
14046
14078
  }
14047
14079
  abortEmitter.once("abort", (err) => {
@@ -14291,7 +14323,7 @@ var require_axios = __commonJS({
14291
14323
  };
14292
14324
  var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
14293
14325
  var xhrAdapter = isXHRAdapterSupported && function(config) {
14294
- return new Promise(function dispatchXhrRequest(resolve8, reject) {
14326
+ return new Promise(function dispatchXhrRequest(resolve7, reject) {
14295
14327
  const _config = resolveConfig(config);
14296
14328
  let requestData = _config.data;
14297
14329
  const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
@@ -14326,7 +14358,7 @@ var require_axios = __commonJS({
14326
14358
  };
14327
14359
  settle(
14328
14360
  function _resolve(value) {
14329
- resolve8(value);
14361
+ resolve7(value);
14330
14362
  done();
14331
14363
  },
14332
14364
  function _reject(err) {
@@ -14718,8 +14750,8 @@ var require_axios = __commonJS({
14718
14750
  config
14719
14751
  );
14720
14752
  !isStreamResponse && unsubscribe && unsubscribe();
14721
- return await new Promise((resolve8, reject) => {
14722
- settle(resolve8, reject, {
14753
+ return await new Promise((resolve7, reject) => {
14754
+ settle(resolve7, reject, {
14723
14755
  data: responseData,
14724
14756
  headers: AxiosHeaders$1.from(response.headers),
14725
14757
  status: response.status,
@@ -15123,8 +15155,8 @@ var require_axios = __commonJS({
15123
15155
  throw new TypeError("executor must be a function.");
15124
15156
  }
15125
15157
  let resolvePromise;
15126
- this.promise = new Promise(function promiseExecutor(resolve8) {
15127
- resolvePromise = resolve8;
15158
+ this.promise = new Promise(function promiseExecutor(resolve7) {
15159
+ resolvePromise = resolve7;
15128
15160
  });
15129
15161
  const token = this;
15130
15162
  this.promise.then((cancel) => {
@@ -15137,9 +15169,9 @@ var require_axios = __commonJS({
15137
15169
  });
15138
15170
  this.promise.then = (onfulfilled) => {
15139
15171
  let _resolve;
15140
- const promise = new Promise((resolve8) => {
15141
- token.subscribe(resolve8);
15142
- _resolve = resolve8;
15172
+ const promise = new Promise((resolve7) => {
15173
+ token.subscribe(resolve7);
15174
+ _resolve = resolve7;
15143
15175
  }).then(onfulfilled);
15144
15176
  promise.cancel = function reject() {
15145
15177
  token.unsubscribe(_resolve);
@@ -17425,7 +17457,7 @@ var require_MsEdgeTTS = __commonJS({
17425
17457
  };
17426
17458
  const ws = this._ws = this._isBrowser ? new isomorphic_ws_1.default(synthUrl) : new isomorphic_ws_1.default(synthUrl, { ...options, agent: this._agent });
17427
17459
  ws.binaryType = "arraybuffer";
17428
- return new Promise((resolve8, reject) => {
17460
+ return new Promise((resolve7, reject) => {
17429
17461
  let connecting = true;
17430
17462
  const connectionTimeout = this._connectionTimeoutMs ? setTimeout(() => {
17431
17463
  connecting = false;
@@ -17468,7 +17500,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17468
17500
  }
17469
17501
  }
17470
17502
  }
17471
- `, void 0, ws).then(resolve8, (error) => {
17503
+ `, void 0, ws).then(resolve7, (error) => {
17472
17504
  this._closeSocket(ws);
17473
17505
  reject(error);
17474
17506
  });
@@ -17610,12 +17642,12 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17610
17642
  this._log("<-", message);
17611
17643
  return;
17612
17644
  }
17613
- await new Promise((resolve8, reject) => {
17645
+ await new Promise((resolve7, reject) => {
17614
17646
  socket.send(message, (error) => {
17615
17647
  if (error)
17616
17648
  return reject(error);
17617
17649
  this._log("<-", message);
17618
- resolve8();
17650
+ resolve7();
17619
17651
  });
17620
17652
  });
17621
17653
  }
@@ -17651,8 +17683,8 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17651
17683
  * 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).
17652
17684
  */
17653
17685
  getVoices() {
17654
- return new Promise((resolve8, reject) => {
17655
- axios_1.default.get(_MsEdgeTTS.VOICES_URL).then((res) => resolve8(res.data)).catch(reject);
17686
+ return new Promise((resolve7, reject) => {
17687
+ axios_1.default.get(_MsEdgeTTS.VOICES_URL).then((res) => resolve7(res.data)).catch(reject);
17656
17688
  });
17657
17689
  }
17658
17690
  /**
@@ -17755,7 +17787,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17755
17787
  const metadataFilePath = !!metadataStream ? (0, utils_1.joinPath)(dirPath, "metadata.json") : null;
17756
17788
  try {
17757
17789
  await Promise.all([
17758
- new Promise((resolve8, reject) => {
17790
+ new Promise((resolve7, reject) => {
17759
17791
  const writableAudioFile = audioStream.pipe(fs.createWriteStream(audioFilePath));
17760
17792
  audioStream.once("error", (e) => {
17761
17793
  writableAudioFile.destroy();
@@ -17763,7 +17795,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17763
17795
  });
17764
17796
  writableAudioFile.once("close", async () => {
17765
17797
  if (writableAudioFile.bytesWritten > 0) {
17766
- resolve8(audioFilePath);
17798
+ resolve7(audioFilePath);
17767
17799
  } else {
17768
17800
  reject(new Error("No audio data received"));
17769
17801
  fs.rmSync(audioFilePath, { force: true });
@@ -17771,9 +17803,9 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17771
17803
  });
17772
17804
  writableAudioFile.once("error", reject);
17773
17805
  }),
17774
- new Promise((resolve8, reject) => {
17806
+ new Promise((resolve7, reject) => {
17775
17807
  if (!metadataFilePath) {
17776
- return resolve8(null);
17808
+ return resolve7(null);
17777
17809
  }
17778
17810
  const metadataItems = { Metadata: [] };
17779
17811
  metadataStream.on("data", (chunk) => {
@@ -17783,7 +17815,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
17783
17815
  metadataStream.once("close", () => {
17784
17816
  if (metadataItems.Metadata.length > 0) {
17785
17817
  fs.writeFileSync(metadataFilePath, JSON.stringify(metadataItems, null, 2));
17786
- resolve8(metadataFilePath);
17818
+ resolve7(metadataFilePath);
17787
17819
  } else {
17788
17820
  reject(new Error("No metadata received"));
17789
17821
  fs.rmSync(metadataFilePath, { force: true });
@@ -17878,552 +17910,28 @@ var require_dist = __commonJS({
17878
17910
  // src/index.ts
17879
17911
  import { execFile as execFile2, spawn as spawn6 } from "child_process";
17880
17912
 
17913
+ // src/dashboard/channel-destroy-sweep.ts
17914
+ function watchDestroyedChannels(store) {
17915
+ let known = new Set(getChannelRegistry().map((c) => c.id));
17916
+ return onChannelRegistryChange(() => {
17917
+ const now = new Set(getChannelRegistry().map((c) => c.id));
17918
+ if (now.size === 0) return;
17919
+ for (const id of known) {
17920
+ if (now.has(id)) continue;
17921
+ const removed = store.forgetChannel(id);
17922
+ console.log(
17923
+ `[channels] channel ${id} destroyed: forgot ${removed} cached row(s), local folder untouched`
17924
+ );
17925
+ }
17926
+ known = now;
17927
+ });
17928
+ }
17929
+
17881
17930
  // src/companion/index.ts
17882
17931
  import { mkdtempSync, rmSync as rmSync2 } from "fs";
17883
17932
  import { tmpdir } from "os";
17884
17933
  import { join as join5 } from "path";
17885
17934
 
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
-
18427
17935
  // ../api/src/dashboard/auth-context.ts
18428
17936
  import { HTTPException } from "hono/http-exception";
18429
17937
  import { isAuthApiError, isAuthRetryableFetchError } from "@supabase/supabase-js";
@@ -18993,6 +18501,14 @@ async function setWorkspaceOwnPersona(workspaceId, enabled) {
18993
18501
  const { error } = await getSupabaseClient().from("workspaces").update({ own_persona: enabled }).eq("id", workspaceId);
18994
18502
  if (error) throw new Error(`setWorkspaceOwnPersona(${workspaceId}): ${error.message}`);
18995
18503
  }
18504
+ async function setWorkspaceAgentDefaults(workspaceId, patch) {
18505
+ const row = {};
18506
+ if (patch.defaultModel !== void 0) row["default_model"] = patch.defaultModel;
18507
+ if (patch.defaultEffort !== void 0) row["default_effort"] = patch.defaultEffort;
18508
+ if (!Object.keys(row).length) return;
18509
+ const { error } = await getSupabaseClient().from("workspaces").update(row).eq("id", workspaceId);
18510
+ if (error) throw new Error(`setWorkspaceAgentDefaults(${workspaceId}): ${error.message}`);
18511
+ }
18996
18512
  async function setWorkspacePermissionMode(workspaceId, mode) {
18997
18513
  const { error } = await getSupabaseClient().from("workspaces").update({ permission_mode: mode }).eq("id", workspaceId);
18998
18514
  if (error) throw new Error(`setWorkspacePermissionMode(${workspaceId}): ${error.message}`);
@@ -19007,6 +18523,105 @@ async function setAgentPaused(workspaceId, paused) {
19007
18523
  if (error) throw new Error(`setAgentPaused(${workspaceId}): ${error.message}`);
19008
18524
  }
19009
18525
 
18526
+ // ../api/src/store/support-store.ts
18527
+ var SUPPORT_HANDLE = "flyspace-support";
18528
+ async function logSupportAction(entry) {
18529
+ const { error } = await getSupabaseClient().from("support_access_log").insert({
18530
+ workspace_id: entry.workspaceId,
18531
+ staff_user_id: entry.staffUserId,
18532
+ staff_email: entry.staffEmail,
18533
+ action: entry.action,
18534
+ detail: entry.detail ?? null
18535
+ });
18536
+ if (error) throw new Error(`logSupportAction(${entry.action}): ${error.message}`);
18537
+ }
18538
+ async function listSupportWorkspaceIds(userId) {
18539
+ const { data, error } = await getSupabaseClient().from("memberships").select("workspace_id").eq("user_id", userId).eq("is_support", true);
18540
+ if (error) throw new Error(`listSupportWorkspaceIds: ${error.message}`);
18541
+ return new Set((data ?? []).map((r) => r.workspace_id));
18542
+ }
18543
+ async function grantSupportMembership(params) {
18544
+ const db = getSupabaseClient();
18545
+ const { data: existing, error: readError } = await db.from("memberships").select("is_support").eq("workspace_id", params.workspaceId).eq("user_id", params.userId).maybeSingle();
18546
+ if (readError) throw new Error(`grantSupportMembership: ${readError.message}`);
18547
+ if (existing) {
18548
+ if (existing.is_support === true) return "existing";
18549
+ throw new Error("already a regular member of this workspace");
18550
+ }
18551
+ const { data: taken } = await db.from("memberships").select("id").eq("workspace_id", params.workspaceId).eq("handle", SUPPORT_HANDLE).maybeSingle();
18552
+ const handle = taken ? `${SUPPORT_HANDLE}-${params.userId.slice(0, 8)}` : SUPPORT_HANDLE;
18553
+ const { error } = await db.from("memberships").insert({
18554
+ workspace_id: params.workspaceId,
18555
+ user_id: params.userId,
18556
+ email: params.email,
18557
+ handle,
18558
+ role: "admin",
18559
+ status: "active",
18560
+ is_support: true,
18561
+ accepted_at: (/* @__PURE__ */ new Date()).toISOString()
18562
+ });
18563
+ if (error) throw new Error(`grantSupportMembership: ${error.message}`);
18564
+ return "granted";
18565
+ }
18566
+ async function revokeSupportMembership(workspaceId, userId) {
18567
+ const { data, error } = await getSupabaseClient().from("memberships").delete().eq("workspace_id", workspaceId).eq("user_id", userId).eq("is_support", true).select("id");
18568
+ if (error) throw new Error(`revokeSupportMembership: ${error.message}`);
18569
+ return (data ?? []).length > 0;
18570
+ }
18571
+ async function listSupportLog(filter) {
18572
+ let query = getSupabaseClient().from("support_access_log").select("*").order("created_at", { ascending: false }).limit(Math.min(filter.limit ?? 200, 1e3));
18573
+ if (filter.workspaceId) query = query.eq("workspace_id", filter.workspaceId);
18574
+ const { data, error } = await query;
18575
+ if (error) throw new Error(`listSupportLog: ${error.message}`);
18576
+ return (data ?? []).map((r) => ({
18577
+ id: r.id,
18578
+ workspaceId: r.workspace_id,
18579
+ staffUserId: r.staff_user_id,
18580
+ staffEmail: r.staff_email,
18581
+ action: r.action,
18582
+ detail: r.detail ?? null,
18583
+ createdAt: r.created_at
18584
+ }));
18585
+ }
18586
+ var SUPPORT_GRANT_HOURS = [1, 24, 168, 720, 0];
18587
+ var SUPPORT_GRANT_FOREVER = "9999-12-31T00:00:00.000Z";
18588
+ async function getActiveSupportGrant(workspaceId) {
18589
+ const { data, error } = await getSupabaseClient().from("support_access_grants").select("id, granted_by_email, reason, expires_at, created_at").eq("workspace_id", workspaceId).is("revoked_at", null).gt("expires_at", (/* @__PURE__ */ new Date()).toISOString()).order("expires_at", { ascending: false }).limit(1).maybeSingle();
18590
+ if (error) throw new Error(`getActiveSupportGrant: ${error.message}`);
18591
+ if (!data) return null;
18592
+ return {
18593
+ id: data.id,
18594
+ grantedByEmail: data.granted_by_email,
18595
+ reason: data.reason ?? null,
18596
+ expiresAt: data.expires_at,
18597
+ createdAt: data.created_at
18598
+ };
18599
+ }
18600
+ async function createSupportGrant(params) {
18601
+ await revokeSupportGrants(params.workspaceId, params.userId);
18602
+ const expiresAt = params.hours === 0 ? SUPPORT_GRANT_FOREVER : new Date(Date.now() + params.hours * 36e5).toISOString();
18603
+ const { data, error } = await getSupabaseClient().from("support_access_grants").insert({
18604
+ workspace_id: params.workspaceId,
18605
+ granted_by: params.userId,
18606
+ granted_by_email: params.email,
18607
+ reason: params.reason ?? null,
18608
+ expires_at: expiresAt
18609
+ }).select("id, granted_by_email, reason, expires_at, created_at").single();
18610
+ if (error) throw new Error(`createSupportGrant: ${error.message}`);
18611
+ return {
18612
+ id: data.id,
18613
+ grantedByEmail: data.granted_by_email,
18614
+ reason: data.reason ?? null,
18615
+ expiresAt: data.expires_at,
18616
+ createdAt: data.created_at
18617
+ };
18618
+ }
18619
+ async function revokeSupportGrants(workspaceId, userId) {
18620
+ const { data, error } = await getSupabaseClient().from("support_access_grants").update({ revoked_at: (/* @__PURE__ */ new Date()).toISOString(), revoked_by: userId }).eq("workspace_id", workspaceId).is("revoked_at", null).gt("expires_at", (/* @__PURE__ */ new Date()).toISOString()).select("id");
18621
+ if (error) throw new Error(`revokeSupportGrants: ${error.message}`);
18622
+ return (data ?? []).length;
18623
+ }
18624
+
19010
18625
  // ../api/src/dashboard/auth-context.ts
19011
18626
  function onboardingPending(ctx) {
19012
18627
  const pending = [];
@@ -19087,6 +18702,7 @@ async function resolveAuthContextUncached(c) {
19087
18702
  if (!workspace) return null;
19088
18703
  const membership = await getMembershipByEmail(workspace.id, user.email);
19089
18704
  if (!membership) return null;
18705
+ if (membership.isSupport && !await getActiveSupportGrant(workspace.id)) return null;
19090
18706
  if (membership.status === "invited") {
19091
18707
  await activateMembership(workspace.id, user.email);
19092
18708
  }
@@ -19110,8 +18726,8 @@ async function resolveAuthContextUncached(c) {
19110
18726
  }
19111
18727
 
19112
18728
  // ../api/src/dashboard/settings.ts
19113
- import { readFileSync, existsSync as existsSync2 } from "fs";
19114
- import { resolve as resolve2 } from "path";
18729
+ import { readFileSync, existsSync } from "fs";
18730
+ import { resolve } from "path";
19115
18731
 
19116
18732
  // ../api/src/store/workspace-settings-store.ts
19117
18733
  var BRANDING_DEFAULTS = {
@@ -19224,7 +18840,7 @@ function localDefaults() {
19224
18840
  }
19225
18841
  var AUTO_TITLE_PROMPT_MAX = 2e3;
19226
18842
  function readSettingsFile() {
19227
- if (!existsSync2(paths.DASHBOARD_SETTINGS_FILE)) return null;
18843
+ if (!existsSync(paths.DASHBOARD_SETTINGS_FILE)) return null;
19228
18844
  try {
19229
18845
  const raw = JSON.parse(readFileSync(paths.DASHBOARD_SETTINGS_FILE, "utf-8"));
19230
18846
  return raw && typeof raw === "object" ? raw : null;
@@ -19273,15 +18889,15 @@ async function saveWorkspaceBranding(patch, profile = getProfile()) {
19273
18889
  return brandingToSettings(await upsertWorkspaceBranding(profile, next));
19274
18890
  }
19275
18891
  function defaultPromptPath() {
19276
- return resolve2(paths.PACKAGE_ROOT, "system.default.md");
18892
+ return resolve(paths.PACKAGE_ROOT, "system.default.md");
19277
18893
  }
19278
18894
  function readDefaultPrompt() {
19279
18895
  const path = defaultPromptPath();
19280
- return existsSync2(path) ? readFileSync(path, "utf-8").trim() : "";
18896
+ return existsSync(path) ? readFileSync(path, "utf-8").trim() : "";
19281
18897
  }
19282
18898
  function loadWorkspacePrompt() {
19283
18899
  const defaultPrompt = readDefaultPrompt();
19284
- const custom = existsSync2(paths.PROMPT_FILE);
18900
+ const custom = existsSync(paths.PROMPT_FILE);
19285
18901
  return {
19286
18902
  prompt: custom ? readFileSync(paths.PROMPT_FILE, "utf-8").trim() : defaultPrompt,
19287
18903
  defaultPrompt,
@@ -19315,9 +18931,9 @@ async function agentViewer(c) {
19315
18931
 
19316
18932
  // src/claude/agent.ts
19317
18933
  import { spawn } from "child_process";
19318
- import { existsSync as existsSync7, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
19319
- import { resolve as resolve4, resolve as resolvePath } from "path";
19320
- import { homedir as homedir3 } from "os";
18934
+ import { existsSync as existsSync6, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
18935
+ import { resolve as resolve3, resolve as resolvePath } from "path";
18936
+ import { homedir as homedir2 } from "os";
19321
18937
  import { randomUUID } from "crypto";
19322
18938
 
19323
18939
  // ../api/src/claude/models.ts
@@ -19424,12 +19040,12 @@ function modelLabel(value) {
19424
19040
 
19425
19041
  // src/claude/container.ts
19426
19042
  import { execFileSync } from "child_process";
19427
- import { createHash as createHash2 } from "crypto";
19428
- import { existsSync as existsSync4, mkdirSync as mkdirSync3 } from "fs";
19043
+ import { createHash } from "crypto";
19044
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2 } from "fs";
19429
19045
  import { join as join2 } from "path";
19430
19046
 
19431
19047
  // src/claude/mounts.ts
19432
- import { existsSync as existsSync3, lstatSync, mkdirSync as mkdirSync2, readlinkSync, symlinkSync, unlinkSync } from "fs";
19048
+ import { existsSync as existsSync2, lstatSync, mkdirSync, readlinkSync, symlinkSync, unlinkSync } from "fs";
19433
19049
  import { basename, join } from "path";
19434
19050
  var MOUNTS_DIR = "mounts";
19435
19051
  function resolveMounts(paths2) {
@@ -19454,11 +19070,11 @@ function materialiseMountLinks(cwd, mounts) {
19454
19070
  if (mounts.length === 0) return [];
19455
19071
  const problems = [];
19456
19072
  const root = join(cwd, MOUNTS_DIR);
19457
- mkdirSync2(root, { recursive: true });
19073
+ mkdirSync(root, { recursive: true });
19458
19074
  for (const repo of mounts) {
19459
19075
  const link = join(root, repo.name);
19460
19076
  try {
19461
- if (existsSync3(link) || isBrokenSymlink(link)) {
19077
+ if (existsSync2(link) || isBrokenSymlink(link)) {
19462
19078
  if (!lstatSync(link).isSymbolicLink()) {
19463
19079
  problems.push(`${link} exists and is not a symlink \u2014 leaving it alone`);
19464
19080
  continue;
@@ -19523,7 +19139,7 @@ function memoryLimit() {
19523
19139
  return process.env["FLYSPACE_AGENT_MEMORY"]?.trim() || "2g";
19524
19140
  }
19525
19141
  function containerHomeFor(cwd) {
19526
- const digest = createHash2("sha256").update(cwd).digest("hex").slice(0, 12);
19142
+ const digest = createHash("sha256").update(cwd).digest("hex").slice(0, 12);
19527
19143
  const label = (cwd.split("/").pop() || "channel").replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 32);
19528
19144
  return join2(paths.CONTAINER_HOMES_DIR, `${label}-${digest}`);
19529
19145
  }
@@ -19548,7 +19164,7 @@ function rewriteArgsForContainer(args) {
19548
19164
  function buildContainerSpawn(input) {
19549
19165
  const home = containerHomeFor(input.cwd);
19550
19166
  for (const dir of [home, paths.SCRATCH_DIR]) {
19551
- if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
19167
+ if (!existsSync3(dir)) mkdirSync2(dir, { recursive: true });
19552
19168
  }
19553
19169
  const containerName = `flyspace-agent-${input.runId}`;
19554
19170
  const env = buildContainerEnv(input.hostEnv);
@@ -19644,21 +19260,21 @@ function userFlags() {
19644
19260
 
19645
19261
  // src/claude/sandbox.ts
19646
19262
  import { execFileSync as execFileSync2 } from "child_process";
19647
- import { createHash as createHash3 } from "crypto";
19648
- import { existsSync as existsSync5, mkdirSync as mkdirSync4, writeFileSync } from "fs";
19263
+ import { createHash as createHash2 } from "crypto";
19264
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync } from "fs";
19649
19265
  import { join as join3 } from "path";
19650
19266
  function sandboxRuntimeEntrypoint() {
19651
19267
  return join3(paths.PACKAGE_ROOT, "node_modules/@anthropic-ai/sandbox-runtime/dist/cli.js");
19652
19268
  }
19653
19269
  function sandboxHomeFor(cwd) {
19654
- const digest = createHash3("sha256").update(cwd).digest("hex").slice(0, 12);
19270
+ const digest = createHash2("sha256").update(cwd).digest("hex").slice(0, 12);
19655
19271
  const label = (cwd.split("/").pop() || "channel").replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 32);
19656
19272
  return join3(paths.SANDBOX_HOMES_DIR, `${label}-${digest}`);
19657
19273
  }
19658
19274
  function buildSandboxSpawn(input) {
19659
19275
  const home = sandboxHomeFor(input.cwd);
19660
19276
  for (const dir of [home, paths.SCRATCH_DIR]) {
19661
- if (!existsSync5(dir)) mkdirSync4(dir, { recursive: true });
19277
+ if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
19662
19278
  }
19663
19279
  const claudeBin = process.env["FLYSPACE_CLAUDE_BIN"]?.trim() || execFileSync2("which", ["claude"]).toString().trim();
19664
19280
  const allowRead = [input.cwd, home, paths.SCRATCH_DIR, join3(paths.PACKAGE_ROOT, "node_modules")];
@@ -19703,7 +19319,7 @@ function buildSandboxSpawn(input) {
19703
19319
  };
19704
19320
  }
19705
19321
  function sandboxRuntimeStatus() {
19706
- if (existsSync5(sandboxRuntimeEntrypoint())) return { ok: true };
19322
+ if (existsSync4(sandboxRuntimeEntrypoint())) return { ok: true };
19707
19323
  return {
19708
19324
  ok: false,
19709
19325
  message: `This channel runs its agent in a sandbox, but \`@anthropic-ai/sandbox-runtime\` is not installed.
@@ -19742,10 +19358,10 @@ var PluginUiSession = class {
19742
19358
  onEvent(event) {
19743
19359
  if (event.type === "control_response") {
19744
19360
  const res = event.response;
19745
- const resolve8 = res?.request_id ? this.pending.get(res.request_id) : void 0;
19746
- if (!resolve8 || !res?.request_id) return;
19361
+ const resolve7 = res?.request_id ? this.pending.get(res.request_id) : void 0;
19362
+ if (!resolve7 || !res?.request_id) return;
19747
19363
  this.pending.delete(res.request_id);
19748
- resolve8(res.subtype === "success" ? res.response?.tree : void 0);
19364
+ resolve7(res.subtype === "success" ? res.response?.tree : void 0);
19749
19365
  return;
19750
19366
  }
19751
19367
  const e = event;
@@ -19764,8 +19380,8 @@ var PluginUiSession = class {
19764
19380
  }
19765
19381
  render(instanceId) {
19766
19382
  const requestId = `flyspace-ui-render-${++this.seq}`;
19767
- return new Promise((resolve8) => {
19768
- this.pending.set(requestId, resolve8);
19383
+ return new Promise((resolve7) => {
19384
+ this.pending.set(requestId, resolve7);
19769
19385
  this.write({
19770
19386
  type: "control_request",
19771
19387
  request_id: requestId,
@@ -19786,11 +19402,11 @@ var PluginUiSession = class {
19786
19402
  */
19787
19403
  async finish() {
19788
19404
  if (this.panes.length) {
19789
- await new Promise((resolve8) => {
19790
- const timer2 = setTimeout(resolve8, SETTLE_TIMEOUT_MS);
19405
+ await new Promise((resolve7) => {
19406
+ const timer2 = setTimeout(resolve7, SETTLE_TIMEOUT_MS);
19791
19407
  this.onInvalidate = () => {
19792
19408
  clearTimeout(timer2);
19793
- resolve8();
19409
+ resolve7();
19794
19410
  };
19795
19411
  });
19796
19412
  this.onInvalidate = void 0;
@@ -19799,8 +19415,8 @@ var PluginUiSession = class {
19799
19415
  this.panes.map(async (p) => ({ ...p, tree: await this.render(p.id) }))
19800
19416
  );
19801
19417
  let timer;
19802
- const timeout = new Promise((resolve8) => {
19803
- timer = setTimeout(() => resolve8(void 0), RENDER_TIMEOUT_MS);
19418
+ const timeout = new Promise((resolve7) => {
19419
+ timer = setTimeout(() => resolve7(void 0), RENDER_TIMEOUT_MS);
19804
19420
  });
19805
19421
  const rendered = await Promise.race([renders, timeout]);
19806
19422
  clearTimeout(timer);
@@ -19845,9 +19461,9 @@ function readMiseEnv(cwd) {
19845
19461
  }
19846
19462
 
19847
19463
  // ../api/src/store/output-styles-store.ts
19848
- import { existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync, readFileSync as readFileSync2, renameSync, rmSync, statSync as statSync2, writeFileSync as writeFileSync2 } from "fs";
19849
- import { homedir as homedir2 } from "os";
19850
- import { join as join4, resolve as resolve3, sep as sep2 } from "path";
19464
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync, readFileSync as readFileSync2, renameSync, rmSync, statSync, writeFileSync as writeFileSync2 } from "fs";
19465
+ import { homedir } from "os";
19466
+ import { join as join4, resolve as resolve2, sep } from "path";
19851
19467
  var BUILT_IN_OUTPUT_STYLES = [
19852
19468
  { slug: "default", name: "Default", description: "Claude Code\u2019s standard software engineering prompt." },
19853
19469
  { slug: "proactive", name: "Proactive", description: "Works autonomously and makes reasonable calls instead of asking." },
@@ -19859,16 +19475,16 @@ var OutputStyleConflictError = class extends Error {
19859
19475
  };
19860
19476
  var ID_RE = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
19861
19477
  function resolveDir(claudeConfigDir) {
19862
- return claudeConfigDir || join4(homedir2(), ".claude");
19478
+ return claudeConfigDir || join4(homedir(), ".claude");
19863
19479
  }
19864
19480
  function stylesDir(claudeConfigDir) {
19865
19481
  return join4(resolveDir(claudeConfigDir), "output-styles");
19866
19482
  }
19867
19483
  function styleFile(claudeConfigDir, id) {
19868
19484
  if (!ID_RE.test(id)) return null;
19869
- const dir = resolve3(stylesDir(claudeConfigDir));
19870
- const file = resolve3(dir, `${id}.md`);
19871
- return file.startsWith(dir + sep2) ? file : null;
19485
+ const dir = resolve2(stylesDir(claudeConfigDir));
19486
+ const file = resolve2(dir, `${id}.md`);
19487
+ return file.startsWith(dir + sep) ? file : null;
19872
19488
  }
19873
19489
  function slugify(name) {
19874
19490
  return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -19910,15 +19526,15 @@ ${p.body.trim()}
19910
19526
  `;
19911
19527
  }
19912
19528
  function atomicWrite(file, content) {
19913
- mkdirSync5(resolve3(file, ".."), { recursive: true });
19529
+ mkdirSync4(resolve2(file, ".."), { recursive: true });
19914
19530
  const tmp = `${file}.${process.pid}.tmp`;
19915
19531
  writeFileSync2(tmp, content);
19916
19532
  renameSync(tmp, file);
19917
19533
  }
19918
19534
  function readStyle(claudeConfigDir, id) {
19919
19535
  const file = styleFile(claudeConfigDir, id);
19920
- if (!file || !existsSync6(file)) return null;
19921
- const stat = statSync2(file);
19536
+ if (!file || !existsSync5(file)) return null;
19537
+ const stat = statSync(file);
19922
19538
  const p = parseStyle(readFileSync2(file, "utf8"), id);
19923
19539
  return {
19924
19540
  id,
@@ -19931,7 +19547,7 @@ function readStyle(claudeConfigDir, id) {
19931
19547
  }
19932
19548
  function listOutputStyles(claudeConfigDir) {
19933
19549
  const dir = stylesDir(claudeConfigDir);
19934
- if (!existsSync6(dir)) return [];
19550
+ if (!existsSync5(dir)) return [];
19935
19551
  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));
19936
19552
  }
19937
19553
  function assertNameFree(claudeConfigDir, name, exceptId) {
@@ -19944,7 +19560,7 @@ function createOutputStyle(claudeConfigDir, params) {
19944
19560
  if (!id) throw new Error("name must contain letters or digits");
19945
19561
  assertNameFree(claudeConfigDir, params.name);
19946
19562
  const file = styleFile(claudeConfigDir, id);
19947
- if (existsSync6(file) || BUILT_IN_OUTPUT_STYLES.some((s) => s.slug === id)) {
19563
+ if (existsSync5(file) || BUILT_IN_OUTPUT_STYLES.some((s) => s.slug === id)) {
19948
19564
  throw new OutputStyleConflictError(`an output style named "${params.name}" already exists`);
19949
19565
  }
19950
19566
  atomicWrite(file, serialize({ ...params, extra: [] }));
@@ -19952,7 +19568,7 @@ function createOutputStyle(claudeConfigDir, params) {
19952
19568
  }
19953
19569
  function updateOutputStyle(claudeConfigDir, id, patch) {
19954
19570
  const file = styleFile(claudeConfigDir, id);
19955
- if (!file || !existsSync6(file)) return null;
19571
+ if (!file || !existsSync5(file)) return null;
19956
19572
  const current = parseStyle(readFileSync2(file, "utf8"), id);
19957
19573
  if (patch.name !== void 0 && patch.name !== current.name) assertNameFree(claudeConfigDir, patch.name, id);
19958
19574
  const next = { ...current, ...patch };
@@ -19964,7 +19580,7 @@ function updateOutputStyle(claudeConfigDir, id, patch) {
19964
19580
  }
19965
19581
  function deleteOutputStyle(claudeConfigDir, id) {
19966
19582
  const file = styleFile(claudeConfigDir, id);
19967
- if (!file || !existsSync6(file)) return false;
19583
+ if (!file || !existsSync5(file)) return false;
19968
19584
  const name = parseStyle(readFileSync2(file, "utf8"), id).name;
19969
19585
  rmSync(file);
19970
19586
  if (readSettings(claudeConfigDir)["outputStyle"] === name) writeDefaultName(claudeConfigDir, void 0);
@@ -19975,7 +19591,7 @@ function settingsFile(claudeConfigDir) {
19975
19591
  }
19976
19592
  function readSettings(claudeConfigDir) {
19977
19593
  const file = settingsFile(claudeConfigDir);
19978
- if (!existsSync6(file)) return {};
19594
+ if (!existsSync5(file)) return {};
19979
19595
  const parsed = JSON.parse(readFileSync2(file, "utf8"));
19980
19596
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
19981
19597
  throw new Error(`${file} is not a JSON object`);
@@ -20397,7 +20013,7 @@ function interpretCliOutcome(result, resumeSessionId, maxBudgetUsd, model, using
20397
20013
  const errors = (result.errors ?? []).filter(Boolean).join(", ") || "Unknown error";
20398
20014
  return { sessionId, text: `Error: ${errors}`, isError: true };
20399
20015
  }
20400
- var DEFAULT_IDLE_TIMEOUT_SECONDS = 300;
20016
+ var DEFAULT_IDLE_TIMEOUT_SECONDS = 900;
20401
20017
  var DEFAULT_MAX_DURATION_SECONDS = 600;
20402
20018
  var DEFAULT_STREAMING_MAX_DURATION_SECONDS = 7200;
20403
20019
  var KILL_GRACE_MS = 1e4;
@@ -20419,13 +20035,13 @@ function getMaxDurationMs(streaming) {
20419
20035
  }
20420
20036
  function loadSystemPrompt() {
20421
20037
  const customPath = paths.PROMPT_FILE;
20422
- const defaultPath = resolve4(paths.PACKAGE_ROOT, "system.default.md");
20423
- const filePath = existsSync7(customPath) ? customPath : defaultPath;
20038
+ const defaultPath = resolve3(paths.PACKAGE_ROOT, "system.default.md");
20039
+ const filePath = existsSync6(customPath) ? customPath : defaultPath;
20424
20040
  return readFileSync3(filePath, "utf-8").trim();
20425
20041
  }
20426
20042
  function loadPackagePrompt(file) {
20427
- const filePath = resolve4(paths.PACKAGE_ROOT, file);
20428
- if (!existsSync7(filePath)) return "";
20043
+ const filePath = resolve3(paths.PACKAGE_ROOT, file);
20044
+ if (!existsSync6(filePath)) return "";
20429
20045
  return readFileSync3(filePath, "utf-8").trim();
20430
20046
  }
20431
20047
  function loadCapabilities(slackBound) {
@@ -20490,7 +20106,7 @@ function owningServiceLabel(env = process.env) {
20490
20106
  return /^[A-Za-z0-9._-]+$/.test(label) ? label : void 0;
20491
20107
  }
20492
20108
  function buildHookSettings(runtime, builtInStyleName) {
20493
- const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` : resolve4(paths.PACKAGE_ROOT, "hooks/bash-guard.mjs");
20109
+ const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` : resolve3(paths.PACKAGE_ROOT, "hooks/bash-guard.mjs");
20494
20110
  const selfLabel = runtime === "container" ? void 0 : owningServiceLabel();
20495
20111
  const guardEnv = selfLabel ? `FLYSPACE_SELF_SERVICE_LABEL='${selfLabel}' ` : "";
20496
20112
  return JSON.stringify({
@@ -20588,10 +20204,10 @@ function recordUsage2(response, options) {
20588
20204
  }
20589
20205
  function pinnedClaudeConfigDir(dir) {
20590
20206
  if (!dir) return void 0;
20591
- return resolvePath(dir.replace(/^~(?=\/|$)/, homedir3())) === resolvePath(homedir3(), ".claude") ? void 0 : dir;
20207
+ return resolvePath(dir.replace(/^~(?=\/|$)/, homedir2())) === resolvePath(homedir2(), ".claude") ? void 0 : dir;
20592
20208
  }
20593
20209
  function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
20594
- return new Promise((resolve8, reject) => {
20210
+ return new Promise((resolve7, reject) => {
20595
20211
  const isolated = options.runtime === "container" || options.runtime === "sandbox";
20596
20212
  const args = buildArgs(
20597
20213
  prompt,
@@ -20777,7 +20393,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20777
20393
  console.log(`[agent] stderr: ${stderr.trim()}`);
20778
20394
  }
20779
20395
  if (cancelled) {
20780
- resolve8({
20396
+ resolve7({
20781
20397
  sessionId: liveSessionId ?? resumeSessionId ?? "",
20782
20398
  text: "",
20783
20399
  isCancelled: true
@@ -20786,7 +20402,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20786
20402
  }
20787
20403
  if (timedOut) {
20788
20404
  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.`;
20789
- resolve8({
20405
+ resolve7({
20790
20406
  sessionId: liveSessionId ?? resumeSessionId ?? "",
20791
20407
  text,
20792
20408
  isError: true,
@@ -20824,7 +20440,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20824
20440
  !!claudeCodeOauthToken
20825
20441
  );
20826
20442
  recordUsage2(response, options);
20827
- resolve8(
20443
+ resolve7(
20828
20444
  response.isError ? {
20829
20445
  ...response,
20830
20446
  failure: {
@@ -20842,13 +20458,13 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
20842
20458
  );
20843
20459
  } catch {
20844
20460
  const fallback = onLine ? "" : stdout.trim();
20845
- resolve8({ sessionId: resumeSessionId ?? "", text: fallback || "No response" });
20461
+ resolve7({ sessionId: resumeSessionId ?? "", text: fallback || "No response" });
20846
20462
  }
20847
20463
  });
20848
20464
  });
20849
20465
  }
20850
20466
  async function askClaude(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
20851
- if (!existsSync7(cwd) || !statSync3(cwd).isDirectory()) {
20467
+ if (!existsSync6(cwd) || !statSync2(cwd).isDirectory()) {
20852
20468
  console.error(`[agent] working directory does not exist: ${cwd}`);
20853
20469
  return {
20854
20470
  sessionId: resumeSessionId ?? "",
@@ -20918,131 +20534,6 @@ Fix the channel's working directory in its settings (or recreate the directory),
20918
20534
  }
20919
20535
  }
20920
20536
 
20921
- // ../api/src/store/authors.ts
20922
- var AGENT_AUTHOR = "agent";
20923
- var SYNCED_BOT_AUTHOR = "Bot";
20924
- var LEGACY_BOT_AUTHOR = "Custie";
20925
- var SUPPORT_BOT_AUTHOR = "Flyspace Support";
20926
- var NON_HUMAN_AUTHORS = new Set(
20927
- [AGENT_AUTHOR, SYNCED_BOT_AUTHOR, LEGACY_BOT_AUTHOR, SUPPORT_BOT_AUTHOR].map((a) => a.toLowerCase())
20928
- );
20929
- function isHumanAuthor(author) {
20930
- return !NON_HUMAN_AUTHORS.has(author.toLowerCase());
20931
- }
20932
-
20933
- // ../api/src/store/thread-title.ts
20934
- var TITLE_MAX_LENGTH = 80;
20935
- function deriveThreadTitle(text) {
20936
- const firstLine = text.split("\n").find((line) => line.trim().length > 0);
20937
- if (!firstLine) return null;
20938
- 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();
20939
- if (!cleaned) return null;
20940
- return cleaned.length > TITLE_MAX_LENGTH ? `${cleaned.slice(0, TITLE_MAX_LENGTH).trim()}\u2026` : cleaned;
20941
- }
20942
-
20943
- // src/store/dashboard-sync.ts
20944
- async function syncPostToDashboard(opts) {
20945
- const { channelId, ts: ts3, threadTs, text } = opts;
20946
- if (!databaseReachable()) {
20947
- console.warn("[dashboard-sync] Supabase not configured \u2014 skipping dashboard sync");
20948
- return;
20949
- }
20950
- try {
20951
- const supabase = getSupabaseClient();
20952
- const dashboardChannelId = await resolveDashboardChannelId(supabase, channelId);
20953
- const threadId = threadTs ? await ensureThreadId(supabase, channelId, dashboardChannelId, threadTs) : await createOwnThread(supabase, channelId, dashboardChannelId, ts3, text);
20954
- const { error } = await supabase.from("thread_replies").upsert(
20955
- {
20956
- thread_id: threadId,
20957
- // This mirror only ever runs for the bot's own posts (automation
20958
- // output, `flyspace slack post`), so the author is the agent itself —
20959
- // labelling it anything else makes the chat agent count it as a
20960
- // second human and stop replying without an explicit mention.
20961
- author: AGENT_AUTHOR,
20962
- body: await uploadLocalImages(text),
20963
- external_thread_replies_id: `${channelId}:${ts3}`
20964
- },
20965
- { onConflict: "external_thread_replies_id" }
20966
- );
20967
- if (error) {
20968
- console.warn(`[dashboard-sync] failed to write reply: ${error.message}`);
20969
- }
20970
- } catch (err) {
20971
- console.warn(
20972
- `[dashboard-sync] sync failed: ${err instanceof Error ? err.message : String(err)}`
20973
- );
20974
- }
20975
- }
20976
- async function resolveDashboardChannelId(supabase, slackChannelId) {
20977
- const { data, error } = await supabase.from("channels").select("id").eq("external_channel_id", slackChannelId).maybeSingle();
20978
- if (error || !data) return slackChannelId;
20979
- return data["id"];
20980
- }
20981
- async function createOwnThread(supabase, externalChannelId, dashboardChannelId, ts3, text) {
20982
- const { data, error } = await supabase.from("threads").upsert(
20983
- {
20984
- channel_id: dashboardChannelId,
20985
- title: deriveThreadTitle(text),
20986
- author: AGENT_AUTHOR,
20987
- external_thread_id: `${externalChannelId}:${ts3}`
20988
- },
20989
- { onConflict: "external_thread_id" }
20990
- ).select("id").single();
20991
- if (error || !data) throw new Error(error?.message ?? "failed to create thread");
20992
- return data["id"];
20993
- }
20994
- async function ensureThreadId(supabase, externalChannelId, dashboardChannelId, parentTs) {
20995
- const key = `${externalChannelId}:${parentTs}`;
20996
- const { data: existing, error: selectError } = await supabase.from("threads").select("id").eq("external_thread_id", key).maybeSingle();
20997
- if (selectError) throw new Error(selectError.message);
20998
- if (existing) return existing["id"];
20999
- const { data: created, error: createError } = await supabase.from("threads").upsert(
21000
- // The unsynced parent could be anyone's message (often another bot's),
21001
- // so keep the generic non-human placeholder rather than claiming it.
21002
- {
21003
- channel_id: dashboardChannelId,
21004
- title: null,
21005
- author: SYNCED_BOT_AUTHOR,
21006
- external_thread_id: key
21007
- },
21008
- { onConflict: "external_thread_id" }
21009
- ).select("id").single();
21010
- if (createError || !created) {
21011
- throw new Error(createError?.message ?? "failed to create placeholder thread");
21012
- }
21013
- return created["id"];
21014
- }
21015
-
21016
- // src/store/dashboard-post.ts
21017
- async function postToDashboardChannel(opts) {
21018
- const { channelId, text, threadId, title } = opts;
21019
- const supabase = getSupabaseClient();
21020
- if (!threadId && !channelId) {
21021
- throw new Error("postToDashboardChannel: channelId is required to start a new thread");
21022
- }
21023
- const parentId = threadId ?? await createThread(supabase, channelId, text, title);
21024
- const body = await uploadLocalImages(text);
21025
- const { data, error } = await supabase.from("thread_replies").insert({ thread_id: parentId, author: AGENT_AUTHOR, body }).select("id").single();
21026
- if (error || !data) {
21027
- throw new Error(`failed to write dashboard reply: ${error?.message ?? "no row returned"}`);
21028
- }
21029
- return { threadId: parentId, replyId: data["id"] };
21030
- }
21031
- async function createThread(supabase, channelId, text, title) {
21032
- const { data, error } = await supabase.from("threads").insert({
21033
- channel_id: channelId,
21034
- // An untitled thread is effectively invisible in the sidebar, so give a
21035
- // daily report the same first-line-derived title a mirrored post gets,
21036
- // unless the caller named the thread itself.
21037
- title: title?.trim().replace(/\\([\\`*_{}[\]()#+\-.!~>|])/g, "$1") || deriveThreadTitle(text),
21038
- author: AGENT_AUTHOR
21039
- }).select("id").single();
21040
- if (error || !data) {
21041
- throw new Error(`failed to create dashboard thread: ${error?.message ?? "no row returned"}`);
21042
- }
21043
- return data["id"];
21044
- }
21045
-
21046
20537
  // src/automations/scheduler.ts
21047
20538
  import cron2 from "node-cron";
21048
20539
  import { CronExpressionParser } from "cron-parser";
@@ -21084,8 +20575,8 @@ function automationToRow(type, item, position) {
21084
20575
  };
21085
20576
  }
21086
20577
  var rows = [];
21087
- var changeListeners2 = /* @__PURE__ */ new Set();
21088
- var lastSnapshot2;
20578
+ var changeListeners = /* @__PURE__ */ new Set();
20579
+ var lastSnapshot;
21089
20580
  async function refreshAutomationRegistry() {
21090
20581
  const { data, error } = await getSupabaseClient().from("automations").select("*").order("position", { ascending: true });
21091
20582
  if (error) {
@@ -21094,10 +20585,10 @@ async function refreshAutomationRegistry() {
21094
20585
  }
21095
20586
  const next = data ?? [];
21096
20587
  const snapshot2 = JSON.stringify(next, (key, value) => key === "updated_at" ? void 0 : value);
21097
- if (snapshot2 === lastSnapshot2) return;
21098
- lastSnapshot2 = snapshot2;
20588
+ if (snapshot2 === lastSnapshot) return;
20589
+ lastSnapshot = snapshot2;
21099
20590
  rows = next;
21100
- for (const cb of changeListeners2) {
20591
+ for (const cb of changeListeners) {
21101
20592
  try {
21102
20593
  cb();
21103
20594
  } catch (err) {
@@ -21106,8 +20597,8 @@ async function refreshAutomationRegistry() {
21106
20597
  }
21107
20598
  }
21108
20599
  function onAutomationRegistryChange(cb) {
21109
- changeListeners2.add(cb);
21110
- return () => changeListeners2.delete(cb);
20600
+ changeListeners.add(cb);
20601
+ return () => changeListeners.delete(cb);
21111
20602
  }
21112
20603
  function profileRows() {
21113
20604
  const profile = getProfile();
@@ -21163,14 +20654,14 @@ async function setAutomationEnabled(name, enabled) {
21163
20654
  if (error) throw new Error(`Failed to update automation "${name}": ${error.message}`);
21164
20655
  await refreshAutomationRegistry();
21165
20656
  }
21166
- var DEFAULT_POLL_INTERVAL_MS2 = 2e4;
21167
- var pollTimer2;
21168
- var realtimeChannel2;
21169
- function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS2) {
20657
+ var DEFAULT_POLL_INTERVAL_MS = 2e4;
20658
+ var pollTimer;
20659
+ var realtimeChannel;
20660
+ function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS) {
21170
20661
  stopAutomationRegistryPolling();
21171
- pollTimer2 = setInterval(() => void refreshAutomationRegistry(), intervalMs);
20662
+ pollTimer = setInterval(() => void refreshAutomationRegistry(), intervalMs);
21172
20663
  try {
21173
- realtimeChannel2 = getSupabaseClient().channel("automations-registry").on(
20664
+ realtimeChannel = getSupabaseClient().channel("automations-registry").on(
21174
20665
  "postgres_changes",
21175
20666
  { event: "*", schema: "public", table: "automations" },
21176
20667
  () => void refreshAutomationRegistry()
@@ -21184,11 +20675,11 @@ function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS2)
21184
20675
  return stopAutomationRegistryPolling;
21185
20676
  }
21186
20677
  function stopAutomationRegistryPolling() {
21187
- if (pollTimer2) clearInterval(pollTimer2);
21188
- pollTimer2 = void 0;
21189
- if (realtimeChannel2) {
21190
- void getSupabaseClient().removeChannel(realtimeChannel2);
21191
- realtimeChannel2 = void 0;
20678
+ if (pollTimer) clearInterval(pollTimer);
20679
+ pollTimer = void 0;
20680
+ if (realtimeChannel) {
20681
+ void getSupabaseClient().removeChannel(realtimeChannel);
20682
+ realtimeChannel = void 0;
21192
20683
  }
21193
20684
  }
21194
20685
 
@@ -21633,9 +21124,9 @@ async function runCompanion(config, userId, slot) {
21633
21124
 
21634
21125
  // src/commands/persona.ts
21635
21126
  import { execFileSync as execFileSync4 } from "child_process";
21636
- import { createHash as createHash4 } from "crypto";
21637
- import { existsSync as existsSync8, mkdtempSync as mkdtempSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
21638
- import { homedir as homedir4 } from "os";
21127
+ import { createHash as createHash3 } from "crypto";
21128
+ import { existsSync as existsSync7, mkdtempSync as mkdtempSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
21129
+ import { homedir as homedir3 } from "os";
21639
21130
  import { basename as basename2, join as join6 } from "path";
21640
21131
  import sharp from "sharp";
21641
21132
  var USAGE = `
@@ -21668,8 +21159,8 @@ var PACKS = {
21668
21159
  }
21669
21160
  };
21670
21161
  function pluginInstalled() {
21671
- const claudeDir = process.env["CLAUDE_CONFIG_DIR"] || join6(homedir4(), ".claude");
21672
- return existsSync8(join6(claudeDir, "plugins", "cache", "claudecafe", "persona-panel"));
21162
+ const claudeDir = process.env["CLAUDE_CONFIG_DIR"] || join6(homedir3(), ".claude");
21163
+ return existsSync7(join6(claudeDir, "plugins", "cache", "claudecafe", "persona-panel"));
21673
21164
  }
21674
21165
  function installPack(root, character) {
21675
21166
  const pack = PACKS[character];
@@ -21680,18 +21171,18 @@ function installPack(root, character) {
21680
21171
  try {
21681
21172
  const zip = join6(staging, "pack.zip");
21682
21173
  execFileSync4("curl", ["-fsSL", "--max-time", "60", "-o", zip, pack.url]);
21683
- const digest = createHash4("sha256").update(readFileSync4(zip)).digest("hex");
21174
+ const digest = createHash3("sha256").update(readFileSync4(zip)).digest("hex");
21684
21175
  if (digest !== pack.sha256) throw new Error(`${character} pack SHA-256 mismatch`);
21685
21176
  execFileSync4("unzip", ["-q", zip, "-d", staging]);
21686
21177
  const folder = join6(charactersDir, character);
21687
- if (existsSync8(folder)) renameSync2(folder, join6(staging, "previous"));
21178
+ if (existsSync7(folder)) renameSync2(folder, join6(staging, "previous"));
21688
21179
  renameSync2(join6(staging, character), folder);
21689
21180
  } finally {
21690
21181
  rmSync3(staging, { recursive: true, force: true });
21691
21182
  }
21692
21183
  }
21693
21184
  function cafeRoot() {
21694
- return join6(process.env["XDG_CONFIG_HOME"] || join6(homedir4(), ".config"), "claudecafe");
21185
+ return join6(process.env["XDG_CONFIG_HOME"] || join6(homedir3(), ".config"), "claudecafe");
21695
21186
  }
21696
21187
  function configuredCharacter(root) {
21697
21188
  try {
@@ -21723,7 +21214,7 @@ async function syncPersonaAvatars(profile, requested) {
21723
21214
  const root = cafeRoot();
21724
21215
  const character = requested || configuredCharacter(root);
21725
21216
  const dir = join6(root, "characters", character, "avatars");
21726
- if (!existsSync8(dir)) installPack(root, character);
21217
+ if (!existsSync7(dir)) installPack(root, character);
21727
21218
  const avatars = {};
21728
21219
  for (const file of readdirSync2(dir).filter((f) => f.endsWith(".webp"))) {
21729
21220
  const image = await sharp(join6(dir, file)).resize({ width: AVATAR_SIZE, height: AVATAR_SIZE, fit: "cover", position: "top" }).webp({ quality: 80 }).toBuffer();
@@ -21832,7 +21323,13 @@ var featureFlags = {
21832
21323
  },
21833
21324
  "voice-guide": {
21834
21325
  title: "Voice guide",
21835
- description: "Support walks you through the UI: a Show me button under @support answers that opens the right page and spotlights what to click, and later a Talk mode that answers out loud. Speech is sent to OpenAI.",
21326
+ description: "Support walks you through the UI: a Show me button under @support answers that opens the right page and spotlights what to click.",
21327
+ stage: "beta",
21328
+ operatorOnly: true
21329
+ },
21330
+ "voice-chat": {
21331
+ title: "Voice chat",
21332
+ description: 'A Talk button in the thread composer: speak to the agent and hear a short answer back, while the full answer is posted in the thread. Hands-free mode starts it when you say "Hey Custie". Speech is sent to OpenAI and Groq.',
21836
21333
  stage: "beta",
21837
21334
  operatorOnly: true
21838
21335
  }
@@ -22230,7 +21727,7 @@ async function buildPrompt(profile, channelId, opts) {
22230
21727
  }
22231
21728
 
22232
21729
  // src/dashboard/settings-host.ts
22233
- import { writeFileSync as writeFileSync4, existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync5, rmSync as rmSync4 } from "fs";
21730
+ import { writeFileSync as writeFileSync4, existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync5, rmSync as rmSync4 } from "fs";
22234
21731
  import { dirname } from "path";
22235
21732
 
22236
21733
  // ../api/src/dashboard/auto-title.ts
@@ -22392,7 +21889,7 @@ function parseAgentProfiles(raw) {
22392
21889
  return entries2.length > 0 ? Object.fromEntries(entries2) : void 0;
22393
21890
  }
22394
21891
  function loadDashboardSettings() {
22395
- if (!existsSync9(paths.DASHBOARD_SETTINGS_FILE)) return localDefaults();
21892
+ if (!existsSync8(paths.DASHBOARD_SETTINGS_FILE)) return localDefaults();
22396
21893
  try {
22397
21894
  const raw = JSON.parse(readFileSync5(paths.DASHBOARD_SETTINGS_FILE, "utf-8"));
22398
21895
  const providers = parseProviders(raw.providers, {
@@ -22421,7 +21918,7 @@ function withFallbackModel(providers, model) {
22421
21918
  return [cleared[0], { runner, model }, ...cleared.slice(1).filter((p) => p.runner !== runner)];
22422
21919
  }
22423
21920
  function writeSettings(next) {
22424
- mkdirSync6(dirname(paths.DASHBOARD_SETTINGS_FILE), { recursive: true });
21921
+ mkdirSync5(dirname(paths.DASHBOARD_SETTINGS_FILE), { recursive: true });
22425
21922
  const merged = { ...readSettingsFile() ?? {}, ...next };
22426
21923
  writeFileSync4(paths.DASHBOARD_SETTINGS_FILE, JSON.stringify(merged, null, 2), "utf-8");
22427
21924
  return next;
@@ -22457,7 +21954,7 @@ async function loadFullDashboardSettings(profile = getProfile()) {
22457
21954
  function saveWorkspacePrompt(prompt) {
22458
21955
  const trimmed = prompt.trim();
22459
21956
  if (!trimmed || trimmed === loadWorkspacePrompt().defaultPrompt) return resetWorkspacePrompt();
22460
- mkdirSync6(dirname(paths.PROMPT_FILE), { recursive: true });
21957
+ mkdirSync5(dirname(paths.PROMPT_FILE), { recursive: true });
22461
21958
  writeFileSync4(paths.PROMPT_FILE, `${trimmed}
22462
21959
  `, "utf-8");
22463
21960
  return loadWorkspacePrompt();
@@ -22488,7 +21985,7 @@ function saveAgentProfile(name, patch) {
22488
21985
 
22489
21986
  // ../api/src/codex/agent.ts
22490
21987
  import { spawn as spawn2 } from "child_process";
22491
- import { existsSync as existsSync10, mkdtempSync as mkdtempSync3, readFileSync as readFileSync6, rmSync as rmSync5, statSync as statSync4 } from "fs";
21988
+ import { existsSync as existsSync9, mkdtempSync as mkdtempSync3, readFileSync as readFileSync6, rmSync as rmSync5, statSync as statSync3 } from "fs";
22492
21989
  import { tmpdir as tmpdir2 } from "os";
22493
21990
  import { join as join7 } from "path";
22494
21991
  var AUTH_ERROR_PATTERNS2 = [
@@ -22622,7 +22119,7 @@ function getMaxDurationMs2() {
22622
22119
  function codexAuthAvailable(env = process.env) {
22623
22120
  if (env["OPENAI_API_KEY"]?.trim()) return true;
22624
22121
  const home = env["CODEX_HOME"]?.trim() || join7(env["HOME"] ?? "", ".codex");
22625
- return existsSync10(join7(home, "auth.json"));
22122
+ return existsSync9(join7(home, "auth.json"));
22626
22123
  }
22627
22124
  function applySystemPrompt(prompt, options, resumeSessionId) {
22628
22125
  if (resumeSessionId || !options.systemPrompt?.trim()) return prompt;
@@ -22671,10 +22168,10 @@ function recordCodexUsage(response, options) {
22671
22168
  });
22672
22169
  }
22673
22170
  function runCodexCli(prompt, cwd, options, resumeSessionId) {
22674
- return new Promise((resolve8, reject) => {
22171
+ return new Promise((resolve7, reject) => {
22675
22172
  const finish = (response) => {
22676
22173
  recordCodexUsage(response, options);
22677
- resolve8(response);
22174
+ resolve7(response);
22678
22175
  };
22679
22176
  const scratch = mkdtempSync3(join7(tmpdir2(), "flyspace-codex-"));
22680
22177
  const lastMessageFile = join7(scratch, "last-message.txt");
@@ -22830,7 +22327,7 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
22830
22327
  });
22831
22328
  }
22832
22329
  async function askCodex(prompt, cwd, options = {}, resumeSessionId) {
22833
- if (!existsSync10(cwd) || !statSync4(cwd).isDirectory()) {
22330
+ if (!existsSync9(cwd) || !statSync3(cwd).isDirectory()) {
22834
22331
  console.error(`[codex] working directory does not exist: ${cwd}`);
22835
22332
  return {
22836
22333
  sessionId: resumeSessionId ?? "",
@@ -23278,12 +22775,12 @@ function renderAsciiTable(t) {
23278
22775
  (h, i) => Math.max(h.length, ...rows2.map((r) => (r[i] || "").length))
23279
22776
  );
23280
22777
  const fmt = (cells) => "| " + cells.map((c, i) => c.padEnd(widths[i])).join(" | ") + " |";
23281
- const sep5 = "|" + widths.map((w) => "-".repeat(w + 2)).join("|") + "|";
23282
- return [fmt(headers), sep5, ...rows2.map(fmt)].join("\n");
22778
+ const sep4 = "|" + widths.map((w) => "-".repeat(w + 2)).join("|") + "|";
22779
+ return [fmt(headers), sep4, ...rows2.map(fmt)].join("\n");
23283
22780
  }
23284
22781
 
23285
22782
  // src/store/channel-cache.ts
23286
- import { mkdirSync as mkdirSync7 } from "fs";
22783
+ import { mkdirSync as mkdirSync6 } from "fs";
23287
22784
 
23288
22785
  // src/store/sqlite.ts
23289
22786
  import Database from "better-sqlite3";
@@ -23307,7 +22804,7 @@ function getDb() {
23307
22804
  const file = paths.DB_FILE;
23308
22805
  const existing = dbs.get(file);
23309
22806
  if (existing) return existing;
23310
- mkdirSync7(paths.DATA_DIR, { recursive: true });
22807
+ mkdirSync6(paths.DATA_DIR, { recursive: true });
23311
22808
  const db = openLocalDatabase(file);
23312
22809
  if (!db) return null;
23313
22810
  db.exec(`
@@ -23523,7 +23020,7 @@ var DEFAULT_TIMEOUT_MS = 12e4;
23523
23020
  var KILL_GRACE_MS3 = 5e3;
23524
23021
  function runScriptAutomation(opts) {
23525
23022
  const { name, script, cwd, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
23526
- return new Promise((resolve8, reject) => {
23023
+ return new Promise((resolve7, reject) => {
23527
23024
  const [cmd, args] = isExecutable(script) ? [script, []] : ["/bin/bash", [script]];
23528
23025
  const child = spawn3(cmd, args, { cwd, env: resolveMiseEnv(cwd), stdio: ["ignore", "pipe", "pipe"] });
23529
23026
  let stdout = "";
@@ -23559,7 +23056,7 @@ function runScriptAutomation(opts) {
23559
23056
  } else if (code !== 0) {
23560
23057
  reject(new Error(`script exited with code ${code}: ${stderr.trim()}`));
23561
23058
  } else {
23562
- resolve8();
23059
+ resolve7();
23563
23060
  }
23564
23061
  });
23565
23062
  });
@@ -23833,11 +23330,11 @@ var TriggerEngine = class {
23833
23330
  };
23834
23331
 
23835
23332
  // src/store/user-cache.ts
23836
- import { existsSync as existsSync11, readFileSync as readFileSync7 } from "fs";
23333
+ import { existsSync as existsSync10, readFileSync as readFileSync7 } from "fs";
23837
23334
  import { join as join8 } from "path";
23838
23335
  function jsonUserCachePath() {
23839
23336
  const file = join8(paths.CONFIG_DIR, "slack_users.json");
23840
- return existsSync11(file) ? file : void 0;
23337
+ return existsSync10(file) ? file : void 0;
23841
23338
  }
23842
23339
  function readJsonUserCache() {
23843
23340
  const file = jsonUserCachePath();
@@ -24141,15 +23638,19 @@ function initAutomations(slackClient, config, runStore) {
24141
23638
  for (const schedule of automations.schedules) {
24142
23639
  if (!schedule.enabled) continue;
24143
23640
  if (schedule.script) {
24144
- scheduler.register(
24145
- schedule,
24146
- () => runScriptAutomation({
24147
- name: schedule.name,
24148
- script: expandPath(schedule.script),
24149
- cwd: resolveCwd(schedule.cwd, schedule.channel, config.claudeCwd),
24150
- timeoutMs: schedule.timeoutMs
24151
- })
24152
- );
23641
+ scheduler.register(schedule, async () => {
23642
+ try {
23643
+ await runScriptAutomation({
23644
+ name: schedule.name,
23645
+ script: expandPath(schedule.script),
23646
+ cwd: resolveCwd(schedule.cwd, schedule.channel, config.claudeCwd),
23647
+ timeoutMs: schedule.timeoutMs
23648
+ });
23649
+ } catch (err) {
23650
+ await notifyScriptFailure(slackClient, schedule.channel, schedule.name, err);
23651
+ throw err;
23652
+ }
23653
+ });
24153
23654
  continue;
24154
23655
  }
24155
23656
  scheduler.register(
@@ -24197,6 +23698,33 @@ function initAutomations(slackClient, config, runStore) {
24197
23698
  }
24198
23699
  };
24199
23700
  }
23701
+ var FAILURE_DETAIL_MAX = 1500;
23702
+ async function notifyScriptFailure(slackClient, channel, name, err) {
23703
+ if (!channel) return;
23704
+ const message = err instanceof Error ? err.message : String(err);
23705
+ const detail = message.length > FAILURE_DETAIL_MAX ? `...${message.slice(-FAILURE_DETAIL_MAX)}` : message;
23706
+ const text = `\u274C Automation "${name}" failed
23707
+
23708
+ \`\`\`
23709
+ ${detail}
23710
+ \`\`\``;
23711
+ try {
23712
+ const target = await resolveAutomationPostTarget(slackClient, channel);
23713
+ if (target.kind === "dashboard") {
23714
+ await postToDashboardChannel({
23715
+ channelId: target.channelId,
23716
+ text,
23717
+ title: `Automation "${name}" failed`
23718
+ });
23719
+ } else {
23720
+ const result = await slackClient.chat.postMessage({ channel: target.slackChannelId, text });
23721
+ if (result.ts)
23722
+ await syncPostToDashboard({ channelId: target.slackChannelId, ts: result.ts, text });
23723
+ }
23724
+ } catch (postErr) {
23725
+ console.error(`[automation] ${name}: could not post failure notice:`, postErr);
23726
+ }
23727
+ }
24200
23728
 
24201
23729
  // src/slack/app.ts
24202
23730
  import { App } from "@slack/bolt";
@@ -24235,8 +23763,8 @@ var MessageQueue = class {
24235
23763
  const chains = Array.from(this.chains.values());
24236
23764
  if (chains.length === 0) return true;
24237
23765
  let timer;
24238
- const timeout = new Promise((resolve8) => {
24239
- timer = setTimeout(() => resolve8(false), timeoutMs);
23766
+ const timeout = new Promise((resolve7) => {
23767
+ timer = setTimeout(() => resolve7(false), timeoutMs);
24240
23768
  });
24241
23769
  const done = Promise.all(chains).then(() => true);
24242
23770
  const result = await Promise.race([done, timeout]);
@@ -24813,7 +24341,7 @@ async function summariseThreadTranscript(transcript, opts, deps = {}) {
24813
24341
  }
24814
24342
 
24815
24343
  // src/dashboard/chat-agent.ts
24816
- import { homedir as homedir9 } from "os";
24344
+ import { homedir as homedir8 } from "os";
24817
24345
  import { stripVTControlCharacters } from "util";
24818
24346
 
24819
24347
  // src/mcp/config.ts
@@ -24941,7 +24469,7 @@ function secretsMatch(a, b) {
24941
24469
  }
24942
24470
 
24943
24471
  // ../api/src/mcp/oauth.ts
24944
- import { createHash as createHash5, randomBytes as randomBytes2 } from "crypto";
24472
+ import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
24945
24473
  var RESERVED_AUTHORIZE_PARAMS = /* @__PURE__ */ new Set([
24946
24474
  "client_id",
24947
24475
  "redirect_uri",
@@ -24959,7 +24487,7 @@ function createStateToken() {
24959
24487
  }
24960
24488
  function createPkcePair() {
24961
24489
  const verifier = base64url(randomBytes2(32));
24962
- const challenge = base64url(createHash5("sha256").update(verifier).digest());
24490
+ const challenge = base64url(createHash4("sha256").update(verifier).digest());
24963
24491
  return { verifier, challenge };
24964
24492
  }
24965
24493
  function clientEnvName(providerSlug, suffix) {
@@ -25328,7 +24856,7 @@ function needsRefresh(expiresAt, now = Date.now()) {
25328
24856
  if (!expiresAt) return false;
25329
24857
  return new Date(expiresAt).getTime() - now < REFRESH_SKEW_MS;
25330
24858
  }
25331
- var sleep = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
24859
+ var sleep = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
25332
24860
  async function refreshConnection(params) {
25333
24861
  const { workspaceId, connection, provider } = params;
25334
24862
  const deps = params.deps ?? {};
@@ -25455,12 +24983,12 @@ async function buildMcpConfig(profile, connectionIds) {
25455
24983
  if (!connectionIds.length) return { config, skipped };
25456
24984
  const workspace = await getWorkspaceBySlug(profile);
25457
24985
  if (!workspace) return { config, skipped };
25458
- const byId2 = new Map(
24986
+ const byId = new Map(
25459
24987
  (await listMcpConnections(workspace.id)).map((connection) => [connection.id, connection])
25460
24988
  );
25461
24989
  const workspaceId = workspace.id;
25462
24990
  for (const id of connectionIds) {
25463
- const connection = byId2.get(id);
24991
+ const connection = byId.get(id);
25464
24992
  if (!connection) {
25465
24993
  continue;
25466
24994
  }
@@ -25529,7 +25057,7 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
25529
25057
 
25530
25058
  // ../api/src/version.ts
25531
25059
  import { readFileSync as readFileSync8 } from "fs";
25532
- var CLI_VERSION = true ? "0.1.65" : devVersion();
25060
+ var CLI_VERSION = true ? "0.1.67" : devVersion();
25533
25061
  function isOlderVersion(a, b) {
25534
25062
  const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
25535
25063
  const [pa, pb] = [parse2(a), parse2(b)];
@@ -25552,39 +25080,39 @@ async function latestCliVersion() {
25552
25080
  }
25553
25081
 
25554
25082
  // src/claude/agents.ts
25555
- import { existsSync as existsSync14, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
25556
- import { homedir as homedir7 } from "os";
25083
+ import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
25084
+ import { homedir as homedir6 } from "os";
25557
25085
  import { basename as basename4, join as join13 } from "path";
25558
25086
  import yaml3 from "js-yaml";
25559
25087
 
25560
25088
  // ../api/src/claude/skills.ts
25561
- import { existsSync as existsSync13, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
25562
- import { homedir as homedir6 } from "os";
25089
+ import { existsSync as existsSync12, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
25090
+ import { homedir as homedir5 } from "os";
25563
25091
  import { basename as basename3, dirname as dirname2, join as join12 } from "path";
25564
25092
  import yaml2 from "js-yaml";
25565
25093
 
25566
25094
  // ../api/src/claude/skill-files.ts
25567
25095
  import {
25568
- existsSync as existsSync12,
25569
- mkdirSync as mkdirSync8,
25096
+ existsSync as existsSync11,
25097
+ mkdirSync as mkdirSync7,
25570
25098
  readFileSync as readFileSync9,
25571
25099
  readdirSync as readdirSync3,
25572
25100
  rmSync as rmSync7,
25573
- statSync as statSync5,
25101
+ statSync as statSync4,
25574
25102
  writeFileSync as writeFileSync6
25575
25103
  } from "fs";
25576
- import { homedir as homedir5 } from "os";
25577
- import { join as join11, resolve as resolve5, sep as sep3 } from "path";
25104
+ import { homedir as homedir4 } from "os";
25105
+ import { join as join11, resolve as resolve4, sep as sep2 } from "path";
25578
25106
  import yaml from "js-yaml";
25579
25107
  var MAX_SKILL_BYTES = 2 * 1024 * 1024;
25580
25108
  var SKILL_NAME = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
25581
25109
  function expandHome(p) {
25582
- if (p === "~") return homedir5();
25583
- if (p.startsWith("~/")) return join11(homedir5(), p.slice(2));
25110
+ if (p === "~") return homedir4();
25111
+ if (p.startsWith("~/")) return join11(homedir4(), p.slice(2));
25584
25112
  return p;
25585
25113
  }
25586
25114
  function workspaceSkillsDir(configDir) {
25587
- return join11(configDir ? expandHome(configDir) : join11(homedir5(), ".claude"), "skills");
25115
+ return join11(configDir ? expandHome(configDir) : join11(homedir4(), ".claude"), "skills");
25588
25116
  }
25589
25117
  function channelSkillsDir(cwd) {
25590
25118
  return join11(cwd, ".claude", "skills");
@@ -25594,8 +25122,8 @@ function isValidSkillName(name) {
25594
25122
  }
25595
25123
  function resolveSkillPath(dir, name) {
25596
25124
  if (!isValidSkillName(name)) return null;
25597
- const abs = resolve5(dir, name, "SKILL.md");
25598
- if (!abs.startsWith(resolve5(dir) + sep3)) return null;
25125
+ const abs = resolve4(dir, name, "SKILL.md");
25126
+ if (!abs.startsWith(resolve4(dir) + sep2)) return null;
25599
25127
  return abs;
25600
25128
  }
25601
25129
  function splitFrontmatter(raw) {
@@ -25632,7 +25160,7 @@ function readMeta(abs) {
25632
25160
  }
25633
25161
  }
25634
25162
  function listSkillFiles(dir) {
25635
- if (!existsSync12(dir)) return [];
25163
+ if (!existsSync11(dir)) return [];
25636
25164
  let entries2;
25637
25165
  try {
25638
25166
  entries2 = readdirSync3(dir);
@@ -25645,7 +25173,7 @@ function listSkillFiles(dir) {
25645
25173
  const abs = join11(dir, entry, "SKILL.md");
25646
25174
  let stat;
25647
25175
  try {
25648
- stat = statSync5(abs);
25176
+ stat = statSync4(abs);
25649
25177
  } catch {
25650
25178
  continue;
25651
25179
  }
@@ -25666,7 +25194,7 @@ function readSkillFile(dir, name) {
25666
25194
  if (!abs) return null;
25667
25195
  let stat;
25668
25196
  try {
25669
- stat = statSync5(abs);
25197
+ stat = statSync4(abs);
25670
25198
  } catch {
25671
25199
  return null;
25672
25200
  }
@@ -25685,7 +25213,7 @@ function writeSkillFile(dir, name, patch, baseMtime) {
25685
25213
  if (!abs) return { status: "not-found" };
25686
25214
  let stat;
25687
25215
  try {
25688
- stat = statSync5(abs);
25216
+ stat = statSync4(abs);
25689
25217
  } catch {
25690
25218
  return { status: "not-found" };
25691
25219
  }
@@ -25697,13 +25225,13 @@ function writeSkillFile(dir, name, patch, baseMtime) {
25697
25225
  const content = buildSkillFile({ ...fm, name, description: patch.description }, patch.body);
25698
25226
  if (Buffer.byteLength(content, "utf8") > MAX_SKILL_BYTES) return { status: "too-large" };
25699
25227
  writeFileSync6(abs, content, "utf8");
25700
- return { status: "ok", mtime: statSync5(abs).mtime.toISOString() };
25228
+ return { status: "ok", mtime: statSync4(abs).mtime.toISOString() };
25701
25229
  }
25702
25230
  function createSkillFile(dir, name, description) {
25703
25231
  const abs = resolveSkillPath(dir, name);
25704
25232
  if (!abs) return { status: "bad-name" };
25705
- if (existsSync12(abs)) return { status: "exists" };
25706
- mkdirSync8(join11(dir, name), { recursive: true });
25233
+ if (existsSync11(abs)) return { status: "exists" };
25234
+ mkdirSync7(join11(dir, name), { recursive: true });
25707
25235
  writeFileSync6(
25708
25236
  abs,
25709
25237
  buildSkillFile(
@@ -25720,18 +25248,18 @@ Describe what this skill does and when to use it.
25720
25248
  }
25721
25249
  function deleteSkillFile(dir, name) {
25722
25250
  const abs = resolveSkillPath(dir, name);
25723
- if (!abs || !existsSync12(abs)) return { status: "not-found" };
25251
+ if (!abs || !existsSync11(abs)) return { status: "not-found" };
25724
25252
  rmSync7(join11(dir, name), { recursive: true, force: true });
25725
25253
  return { status: "ok" };
25726
25254
  }
25727
25255
 
25728
25256
  // ../api/src/claude/skills.ts
25729
25257
  function defaultConfigDir() {
25730
- return join12(homedir6(), ".claude");
25258
+ return join12(homedir5(), ".claude");
25731
25259
  }
25732
25260
  function expandHome2(p) {
25733
- if (p === "~") return homedir6();
25734
- if (p.startsWith("~/")) return join12(homedir6(), p.slice(2));
25261
+ if (p === "~") return homedir5();
25262
+ if (p.startsWith("~/")) return join12(homedir5(), p.slice(2));
25735
25263
  return p;
25736
25264
  }
25737
25265
  function parseFrontmatter(file) {
@@ -25755,13 +25283,13 @@ function parseFrontmatter(file) {
25755
25283
  function isSymlinkedDir(root, entry) {
25756
25284
  if (!entry.isSymbolicLink()) return false;
25757
25285
  try {
25758
- return statSync6(join12(root, entry.name)).isDirectory();
25286
+ return statSync5(join12(root, entry.name)).isDirectory();
25759
25287
  } catch {
25760
25288
  return false;
25761
25289
  }
25762
25290
  }
25763
25291
  function findSkillFiles(root, maxDepth, out) {
25764
- if (maxDepth < 0 || !existsSync13(root)) return;
25292
+ if (maxDepth < 0 || !existsSync12(root)) return;
25765
25293
  let entries2;
25766
25294
  try {
25767
25295
  entries2 = readdirSync4(root, { withFileTypes: true });
@@ -25814,7 +25342,7 @@ function findPluginMarkdown(pluginsRoot, dirName, maxDepth = 8) {
25814
25342
  }
25815
25343
  }
25816
25344
  };
25817
- if (existsSync13(pluginsRoot)) walk(pluginsRoot, maxDepth);
25345
+ if (existsSync12(pluginsRoot)) walk(pluginsRoot, maxDepth);
25818
25346
  return out;
25819
25347
  }
25820
25348
  function readdirSafe(dir) {
@@ -25896,7 +25424,7 @@ function nestedProjectRoots(cwd) {
25896
25424
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
25897
25425
  if (!entry.isDirectory() && !isSymlinkedDir(cwd, entry)) continue;
25898
25426
  const skillsDir = join12(cwd, entry.name, ".claude", "skills");
25899
- if (existsSync13(skillsDir)) roots.push({ dir: skillsDir, prefix: entry.name });
25427
+ if (existsSync12(skillsDir)) roots.push({ dir: skillsDir, prefix: entry.name });
25900
25428
  }
25901
25429
  return roots;
25902
25430
  }
@@ -25909,7 +25437,7 @@ function listPluginSkillDetails(configDir, cwd) {
25909
25437
  if (skill.source !== "plugin") continue;
25910
25438
  try {
25911
25439
  const { body } = splitFrontmatter(readFileSync10(file, "utf-8"));
25912
- details.push({ ...skill, body, path: file, mtime: statSync6(file).mtime.toISOString() });
25440
+ details.push({ ...skill, body, path: file, mtime: statSync5(file).mtime.toISOString() });
25913
25441
  } catch {
25914
25442
  }
25915
25443
  }
@@ -25943,7 +25471,7 @@ function findSkillDetail(configDir, cwd, name, sources) {
25943
25471
  let mtime;
25944
25472
  try {
25945
25473
  raw = readFileSync10(file, "utf-8");
25946
- mtime = statSync6(file).mtime.toISOString();
25474
+ mtime = statSync5(file).mtime.toISOString();
25947
25475
  } catch {
25948
25476
  continue;
25949
25477
  }
@@ -25977,11 +25505,11 @@ ${body.trim()}`;
25977
25505
 
25978
25506
  // src/claude/agents.ts
25979
25507
  function defaultConfigDir2() {
25980
- return join13(homedir7(), ".claude");
25508
+ return join13(homedir6(), ".claude");
25981
25509
  }
25982
25510
  function expandHome3(p) {
25983
- if (p === "~") return homedir7();
25984
- if (p.startsWith("~/")) return join13(homedir7(), p.slice(2));
25511
+ if (p === "~") return homedir6();
25512
+ if (p.startsWith("~/")) return join13(homedir6(), p.slice(2));
25985
25513
  return p;
25986
25514
  }
25987
25515
  function parseFrontmatter2(file) {
@@ -26003,7 +25531,7 @@ function parseFrontmatter2(file) {
26003
25531
  }
26004
25532
  }
26005
25533
  function collectFrom2(root, source) {
26006
- if (!existsSync14(root)) return [];
25534
+ if (!existsSync13(root)) return [];
26007
25535
  let entries2;
26008
25536
  try {
26009
25537
  entries2 = readdirSync5(root).filter((f) => f.endsWith(".md"));
@@ -26053,13 +25581,13 @@ function readAgentPersona(configDir, cwd, name) {
26053
25581
 
26054
25582
  // src/dashboard/memory-extraction-runner.ts
26055
25583
  import { spawn as spawn4 } from "child_process";
26056
- import { existsSync as existsSync15, mkdtempSync as mkdtempSync5, readFileSync as readFileSync12, rmSync as rmSync8 } from "fs";
25584
+ import { existsSync as existsSync14, mkdtempSync as mkdtempSync5, readFileSync as readFileSync12, rmSync as rmSync8 } from "fs";
26057
25585
  import { tmpdir as tmpdir4 } from "os";
26058
25586
  import { join as join15 } from "path";
26059
25587
 
26060
25588
  // ../api/src/dashboard/profile-config.ts
26061
- import { homedir as homedir8 } from "os";
26062
- import { join as join14, parse, resolve as resolve6 } from "path";
25589
+ import { homedir as homedir7 } from "os";
25590
+ import { join as join14, parse, resolve as resolve5 } from "path";
26063
25591
 
26064
25592
  // ../api/src/dashboard/profile-config-cache.ts
26065
25593
  var cache3 = /* @__PURE__ */ new Map();
@@ -26078,7 +25606,7 @@ function profileEnv(key) {
26078
25606
  function profileClaudeConfigDir() {
26079
25607
  const config = cachedProfileConfig();
26080
25608
  if (!config) return process.env["CLAUDE_CONFIG_DIR"] || void 0;
26081
- return config.env["CLAUDE_CONFIG_DIR"]?.trim() || join14(homedir8(), ".claude");
25609
+ return config.env["CLAUDE_CONFIG_DIR"]?.trim() || join14(homedir7(), ".claude");
26082
25610
  }
26083
25611
  function profileOauthToken() {
26084
25612
  const env = cachedProfileConfig()?.env ?? {};
@@ -26087,16 +25615,18 @@ function profileOauthToken() {
26087
25615
  return process.env["CLAUDE_CODE_OAUTH_TOKEN"] || void 0;
26088
25616
  }
26089
25617
  function isUnsafeCwd(cwd) {
26090
- const p = resolve6(cwd);
26091
- return p === parse(p).root || p === resolve6(homedir8());
25618
+ const p = resolve5(cwd);
25619
+ return p === parse(p).root || p === resolve5(homedir7());
26092
25620
  }
26093
25621
  function defaultClaudeCwd() {
26094
25622
  return profileEnv("CLAUDE_CWD") ?? process.cwd();
26095
25623
  }
26096
25624
  function defaultModel() {
26097
- return cachedProfileConfig()?.agentModel || profileEnv("CUSTIE_MODEL")?.trim() || "sonnet";
25625
+ return cachedProfileConfig()?.agentModel || workspaceAgentDefault().model || profileEnv("CUSTIE_MODEL")?.trim() || "sonnet";
26098
25626
  }
26099
25627
  function defaultEffort() {
25628
+ const stored = workspaceAgentDefault().effort;
25629
+ if (stored) return stored;
26100
25630
  const raw = profileEnv("CUSTIE_EFFORT")?.trim().toLowerCase();
26101
25631
  return raw && isEffort(raw) ? raw : void 0;
26102
25632
  }
@@ -26194,9 +25724,9 @@ ${req.user}`,
26194
25724
  };
26195
25725
  }
26196
25726
  function run(inv, cwd) {
26197
- return new Promise((resolve8) => {
26198
- if (!existsSync15(cwd)) {
26199
- resolve8({ ok: false, error: `the channel folder ${cwd} does not exist on this Host` });
25727
+ return new Promise((resolve7) => {
25728
+ if (!existsSync14(cwd)) {
25729
+ resolve7({ ok: false, error: `the channel folder ${cwd} does not exist on this Host` });
26200
25730
  return;
26201
25731
  }
26202
25732
  const child = spawn4(inv.command, inv.args, {
@@ -26214,7 +25744,7 @@ function run(inv, cwd) {
26214
25744
  child.on("error", (err) => {
26215
25745
  clearTimeout(timer);
26216
25746
  console.error(`[memory-extraction] ${inv.command} failed to start:`, err.message);
26217
- resolve8({ ok: false, error: `${inv.command} failed to start: ${err.message}` });
25747
+ resolve7({ ok: false, error: `${inv.command} failed to start: ${err.message}` });
26218
25748
  });
26219
25749
  child.on("close", (code) => {
26220
25750
  clearTimeout(timer);
@@ -26222,7 +25752,7 @@ function run(inv, cwd) {
26222
25752
  const detail = (stderr || stdout).trim().split("\n").at(-1) ?? "";
26223
25753
  const error = `${inv.command} exited ${code ?? "on timeout"}: ${detail.slice(0, 200)}`;
26224
25754
  console.error(`[memory-extraction] ${error}`);
26225
- resolve8({ ok: false, error });
25755
+ resolve7({ ok: false, error });
26226
25756
  return;
26227
25757
  }
26228
25758
  let raw = stdout;
@@ -26233,7 +25763,7 @@ function run(inv, cwd) {
26233
25763
  raw = "";
26234
25764
  }
26235
25765
  }
26236
- resolve8({ ok: true, raw });
25766
+ resolve7({ ok: true, raw });
26237
25767
  });
26238
25768
  child.stdin.end(inv.stdin);
26239
25769
  });
@@ -26433,6 +25963,63 @@ var RATE_CARDS = [
26433
25963
  cacheWritePer1M: 0.2,
26434
25964
  effectiveFrom: EPOCH
26435
25965
  },
25966
+ {
25967
+ // OpenAI's pricing page (standard tier, short context), checked 2026-11-16.
25968
+ // GPT-6 launched after the 5.6 cards; no write premium, as for 5.6.
25969
+ id: "openai:gpt-6-astra@2026-11-16",
25970
+ provider: "openai",
25971
+ model: "GPT-6 Astra",
25972
+ matches: ["gpt-6-astra"],
25973
+ inputPer1M: 10,
25974
+ outputPer1M: 50,
25975
+ cacheReadPer1M: 1,
25976
+ cacheWritePer1M: 10,
25977
+ effectiveFrom: EPOCH
25978
+ },
25979
+ {
25980
+ id: "openai:gpt-6.1-sol@2026-11-16",
25981
+ provider: "openai",
25982
+ model: "GPT-6.1 Sol",
25983
+ matches: ["gpt-6.1-sol"],
25984
+ inputPer1M: 2,
25985
+ outputPer1M: 10,
25986
+ cacheReadPer1M: 0.1,
25987
+ cacheWritePer1M: 2,
25988
+ effectiveFrom: EPOCH
25989
+ },
25990
+ {
25991
+ id: "openai:gpt-6.1-terra@2026-11-16",
25992
+ provider: "openai",
25993
+ model: "GPT-6.1 Terra",
25994
+ matches: ["gpt-6.1-terra"],
25995
+ inputPer1M: 1,
25996
+ outputPer1M: 5,
25997
+ cacheReadPer1M: 0.05,
25998
+ cacheWritePer1M: 1,
25999
+ effectiveFrom: EPOCH
26000
+ },
26001
+ {
26002
+ id: "openai:gpt-6-luna@2026-11-16",
26003
+ provider: "openai",
26004
+ model: "GPT-6 Luna",
26005
+ matches: ["gpt-6-luna"],
26006
+ inputPer1M: 0.1,
26007
+ outputPer1M: 0.5,
26008
+ cacheReadPer1M: 0.01,
26009
+ cacheWritePer1M: 0.1,
26010
+ effectiveFrom: EPOCH
26011
+ },
26012
+ {
26013
+ id: "openai:gpt-6-sol@2026-11-16",
26014
+ provider: "openai",
26015
+ model: "GPT-6 Sol",
26016
+ matches: ["gpt-6-sol"],
26017
+ inputPer1M: 2,
26018
+ outputPer1M: 10,
26019
+ cacheReadPer1M: 0.2,
26020
+ cacheWritePer1M: 2,
26021
+ effectiveFrom: EPOCH
26022
+ },
26436
26023
  {
26437
26024
  // Groq's models page, checked 2026-10-30. Our own spend (titles, translation,
26438
26025
  // autocomplete, retros), priced so we can account for it. Groq does not
@@ -26982,7 +26569,7 @@ var UsageStore = class {
26982
26569
 
26983
26570
  // src/dashboard/rollover-summary.ts
26984
26571
  import { spawn as spawn5 } from "child_process";
26985
- import { existsSync as existsSync16, mkdtempSync as mkdtempSync6, readFileSync as readFileSync13, rmSync as rmSync9 } from "fs";
26572
+ import { existsSync as existsSync15, mkdtempSync as mkdtempSync6, readFileSync as readFileSync13, rmSync as rmSync9 } from "fs";
26986
26573
  import { tmpdir as tmpdir5 } from "os";
26987
26574
  import { join as join16 } from "path";
26988
26575
  var HAIKU_MODEL = "haiku";
@@ -27071,13 +26658,13 @@ ${input}`
27071
26658
  ],
27072
26659
  { ...process.env }
27073
26660
  );
27074
- return existsSync16(lastMessageFile) ? readFileSync13(lastMessageFile, "utf8").trim() : "";
26661
+ return existsSync15(lastMessageFile) ? readFileSync13(lastMessageFile, "utf8").trim() : "";
27075
26662
  } finally {
27076
26663
  rmSync9(dir, { recursive: true, force: true });
27077
26664
  }
27078
26665
  }
27079
26666
  function runPrint(command, args, env) {
27080
- return new Promise((resolve8, reject) => {
26667
+ return new Promise((resolve7, reject) => {
27081
26668
  const child = spawn5(command, args, {
27082
26669
  // A stateless rewrite touches no files — tmpdir keeps it that way and
27083
26670
  // avoids picking up an unrelated project's own CLAUDE.md/AGENTS.md,
@@ -27107,7 +26694,7 @@ function runPrint(command, args, env) {
27107
26694
  reject(new Error(`${command} summary exited with code ${code}: ${stderr.trim()}`));
27108
26695
  return;
27109
26696
  }
27110
- resolve8(stdout);
26697
+ resolve7(stdout);
27111
26698
  });
27112
26699
  });
27113
26700
  }
@@ -27405,10 +26992,10 @@ async function downloadChatAttachments(body) {
27405
26992
  }
27406
26993
 
27407
26994
  // src/dashboard/plugin-ui-store.ts
27408
- import { createHash as createHash6 } from "crypto";
26995
+ import { createHash as createHash5 } from "crypto";
27409
26996
  var INLINE_MAX = 2048;
27410
26997
  var uploaded = /* @__PURE__ */ new Map();
27411
- var sha256 = (s) => createHash6("sha256").update(s).digest("hex");
26998
+ var sha256 = (s) => createHash5("sha256").update(s).digest("hex");
27412
26999
  async function offloadSvg(workspace, source) {
27413
27000
  const cacheKey2 = `${workspace}:${sha256(source)}`;
27414
27001
  const cached = uploaded.get(cacheKey2);
@@ -27440,27 +27027,27 @@ async function offloadPluginUi(workspace, state) {
27440
27027
  var pluginUiHash = (state) => sha256(JSON.stringify(state));
27441
27028
 
27442
27029
  // src/dashboard/doc-mention-guard.ts
27443
- import { existsSync as existsSync21, statSync as statSync10 } from "fs";
27030
+ import { existsSync as existsSync20, statSync as statSync9 } from "fs";
27444
27031
 
27445
27032
  // src/dashboard/docs-routes.ts
27446
27033
  import {
27447
27034
  closeSync,
27448
27035
  createReadStream,
27449
- existsSync as existsSync20,
27036
+ existsSync as existsSync19,
27450
27037
  lstatSync as lstatSync2,
27451
- mkdirSync as mkdirSync9,
27038
+ mkdirSync as mkdirSync8,
27452
27039
  openSync,
27453
27040
  readSync,
27454
27041
  readdirSync as readdirSync6,
27455
27042
  readFileSync as readFileSync18,
27456
- realpathSync as realpathSync2,
27043
+ realpathSync,
27457
27044
  renameSync as renameSync3,
27458
27045
  rmSync as rmSync10,
27459
- statSync as statSync9,
27046
+ statSync as statSync8,
27460
27047
  writeFileSync as writeFileSync7
27461
27048
  } from "fs";
27462
27049
  import { Readable } from "stream";
27463
- import { basename as basename6, dirname as dirname3, extname as extname3, join as join21, relative as relative2, resolve as resolve7, sep as sep4 } from "path";
27050
+ import { basename as basename6, dirname as dirname3, extname as extname3, join as join21, relative, resolve as resolve6, sep as sep3 } from "path";
27464
27051
  import { Hono as Hono4 } from "hono";
27465
27052
  import { streamSSE } from "hono/streaming";
27466
27053
 
@@ -27572,7 +27159,7 @@ var requireDocsAccess = async (c, next) => {
27572
27159
  };
27573
27160
 
27574
27161
  // src/dashboard/docs-watcher.ts
27575
- import { existsSync as existsSync17, watch } from "fs";
27162
+ import { existsSync as existsSync16, watch } from "fs";
27576
27163
  import { basename as basename5, join as join18 } from "path";
27577
27164
  var DEBOUNCE_MS = 200;
27578
27165
  var MAX_PENDING = 200;
@@ -27614,7 +27201,7 @@ function watchDocs(cwd, listener) {
27614
27201
  const current = entries.get(cwd);
27615
27202
  if (!current || filename === null) return;
27616
27203
  const rel = filename.split("\\").join("/");
27617
- if (rel === root && !existsSync17(join18(cwd, rel))) return;
27204
+ if (rel === root && !existsSync16(join18(cwd, rel))) return;
27618
27205
  if (isIgnoredDocPath(rel)) return;
27619
27206
  if (current.pending.size < MAX_PENDING) current.pending.add(rel);
27620
27207
  if (current.timer === null) current.timer = setTimeout(() => flush(cwd), DEBOUNCE_MS);
@@ -27644,7 +27231,7 @@ function closeEntry(cwd) {
27644
27231
  var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
27645
27232
 
27646
27233
  // src/dashboard/doc-share-publisher.ts
27647
- import { readFileSync as readFileSync14, statSync as statSync7 } from "fs";
27234
+ import { readFileSync as readFileSync14, statSync as statSync6 } from "fs";
27648
27235
  import { extname as extname2, posix } from "path";
27649
27236
  var MAX_ASSET_BYTES = 20 * 1024 * 1024;
27650
27237
  var MAX_CONTENT_BYTES = 2 * 1024 * 1024;
@@ -27701,7 +27288,7 @@ function inlinePreviewImages(cwd, sourcePath, source) {
27701
27288
  const resolved2 = resolveRawPath(cwd, ref.rel);
27702
27289
  if (!resolved2 || !resolved2.contentType.startsWith("image/")) continue;
27703
27290
  try {
27704
- if (statSync7(resolved2.abs).size > MAX_PREVIEW_INLINE_BYTES) continue;
27291
+ if (statSync6(resolved2.abs).size > MAX_PREVIEW_INLINE_BYTES) continue;
27705
27292
  const data = readFileSync14(resolved2.abs).toString("base64");
27706
27293
  inlined.set(url, `data:${resolved2.contentType};base64,${data}`);
27707
27294
  } catch {
@@ -27771,7 +27358,7 @@ function readDocShareBundle({ cwd, sourcePath }) {
27771
27358
  if (!kind) return { status: "unsupported" };
27772
27359
  let stat;
27773
27360
  try {
27774
- stat = statSync7(abs);
27361
+ stat = statSync6(abs);
27775
27362
  } catch {
27776
27363
  return { status: "not-found" };
27777
27364
  }
@@ -27847,7 +27434,7 @@ function readDocShareBundle({ cwd, sourcePath }) {
27847
27434
  const budget = Math.min(MAX_INLINE_BYTES, MAX_TOTAL_INLINE_BYTES - inlinedBytes);
27848
27435
  let text = null;
27849
27436
  try {
27850
- const size = statSync7(docAbs).size;
27437
+ const size = statSync6(docAbs).size;
27851
27438
  if (size <= budget) text = readFileSync14(docAbs, "utf8");
27852
27439
  } catch {
27853
27440
  continue;
@@ -27864,7 +27451,7 @@ function readDocShareBundle({ cwd, sourcePath }) {
27864
27451
  if (!resolved2) continue;
27865
27452
  let body;
27866
27453
  try {
27867
- if (statSync7(resolved2.abs).size > MAX_ASSET_BYTES) continue;
27454
+ if (statSync6(resolved2.abs).size > MAX_ASSET_BYTES) continue;
27868
27455
  body = readFileSync14(resolved2.abs);
27869
27456
  } catch {
27870
27457
  continue;
@@ -27919,7 +27506,7 @@ async function putDocTranslation(input) {
27919
27506
  }
27920
27507
 
27921
27508
  // ../api/src/dashboard/share-translate.ts
27922
- import { createHash as createHash7 } from "crypto";
27509
+ import { createHash as createHash6 } from "crypto";
27923
27510
 
27924
27511
  // ../api/src/store/doc-share-store.ts
27925
27512
  function rowToKind(value) {
@@ -28247,7 +27834,7 @@ function languageName(lang) {
28247
27834
  return BY_CODE.get(lang)?.name ?? null;
28248
27835
  }
28249
27836
  function translationHash(title, content) {
28250
- return createHash7("sha256").update(`${RECIPE_VERSION}
27837
+ return createHash6("sha256").update(`${RECIPE_VERSION}
28251
27838
  ${title}
28252
27839
  ${content}`).digest("hex");
28253
27840
  }
@@ -28482,7 +28069,7 @@ async function clearStaleDocAudios(channelId, sourcePath, lang, exceptHash) {
28482
28069
  }
28483
28070
 
28484
28071
  // ../api/src/dashboard/share-audio.ts
28485
- import { createHash as createHash8 } from "crypto";
28072
+ import { createHash as createHash7 } from "crypto";
28486
28073
  import { DeleteObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-sdk/client-s3";
28487
28074
 
28488
28075
  // ../api/src/dashboard/tts-routes.ts
@@ -28681,7 +28268,7 @@ Pacing \u2014 the engine has NO pause control, so rhythm has to be built into th
28681
28268
  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.`;
28682
28269
  }
28683
28270
  function articleAudioHash(title, content) {
28684
- return createHash8("sha256").update(`v${RECIPE_VERSION2}
28271
+ return createHash7("sha256").update(`v${RECIPE_VERSION2}
28685
28272
  ${title}
28686
28273
 
28687
28274
  ${content}`).digest("hex").slice(0, 32);
@@ -28804,7 +28391,7 @@ function truncationNotice(lang, voice) {
28804
28391
  if (lang === "en" || lang.startsWith("en-")) return TRUNCATION_NOTICE.en;
28805
28392
  return null;
28806
28393
  }
28807
- var sleep2 = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
28394
+ var sleep2 = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
28808
28395
  async function synthesizeWithRetry(script, voice) {
28809
28396
  let lastError;
28810
28397
  for (let attempt = 1; attempt <= SYNTH_ATTEMPTS; attempt += 1) {
@@ -28908,7 +28495,7 @@ function queueShareAudio(share) {
28908
28495
  var PENDING_STALE_MS = 30 * 60 * 1e3;
28909
28496
  var FAILED_RETRY_MS = 10 * 60 * 1e3;
28910
28497
  function langAudioHash(title, content, lang) {
28911
- return createHash8("sha256").update(`v${RECIPE_VERSION2}
28498
+ return createHash7("sha256").update(`v${RECIPE_VERSION2}
28912
28499
  ${lang}
28913
28500
  ${translationHash(title, content)}`).digest("hex").slice(0, 32);
28914
28501
  }
@@ -29225,7 +28812,7 @@ function createFeatureFlagsRouter() {
29225
28812
  }
29226
28813
 
29227
28814
  // ../api/src/dashboard/public-share-routes.ts
29228
- import { existsSync as existsSync19, readFileSync as readFileSync16, statSync as statSync8 } from "fs";
28815
+ import { existsSync as existsSync18, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
29229
28816
  import { join as join20 } from "path";
29230
28817
  import { Hono as Hono3 } from "hono";
29231
28818
  import { GetObjectCommand as GetObjectCommand3 } from "@aws-sdk/client-s3";
@@ -29432,12 +29019,12 @@ function injectShareHead(html, head) {
29432
29019
  }
29433
29020
 
29434
29021
  // ../api/src/dashboard/app-icon.ts
29435
- import { createHash as createHash9 } from "crypto";
29436
- import { existsSync as existsSync18, readFileSync as readFileSync15 } from "fs";
29022
+ import { createHash as createHash8 } from "crypto";
29023
+ import { existsSync as existsSync17, readFileSync as readFileSync15 } from "fs";
29437
29024
  import { join as join19 } from "path";
29438
29025
  import sharp3 from "sharp";
29439
29026
  var PLATE = "#0A0A0F";
29440
- var BRAND_DIR = existsSync18(join19(paths.WEB_ROOT, "public")) ? join19(paths.WEB_ROOT, "public") : join19(paths.PACKAGE_ROOT, "dist", "brand");
29027
+ var BRAND_DIR = existsSync17(join19(paths.WEB_ROOT, "public")) ? join19(paths.WEB_ROOT, "public") : join19(paths.PACKAGE_ROOT, "dist", "brand");
29441
29028
  var MARK_FILE = join19(BRAND_DIR, "icons", "icon-512.png");
29442
29029
  var MARK_SVG_FILE = join19(BRAND_DIR, "favicon.svg");
29443
29030
  var LAYOUT = {
@@ -29511,7 +29098,7 @@ async function renderAppIcon({
29511
29098
  size,
29512
29099
  maskable ? "maskable" : "std",
29513
29100
  plain ? "plain" : "badged",
29514
- logo ? createHash9("sha1").update(logo).digest("hex").slice(0, 12) : transparent ? "stock-transparent" : "stock"
29101
+ logo ? createHash8("sha1").update(logo).digest("hex").slice(0, 12) : transparent ? "stock-transparent" : "stock"
29515
29102
  ].join(":");
29516
29103
  const hit = cache4.get(key);
29517
29104
  if (hit) return hit;
@@ -29542,7 +29129,7 @@ async function composeIcon(logo, size, maskable, plain) {
29542
29129
  }
29543
29130
 
29544
29131
  // ../api/src/dashboard/share-og.ts
29545
- import { createHash as createHash10 } from "crypto";
29132
+ import { createHash as createHash9 } from "crypto";
29546
29133
  import sharp4 from "sharp";
29547
29134
  var WIDTH = 1200;
29548
29135
  var HEIGHT = 630;
@@ -29720,7 +29307,7 @@ function cacheKey(input) {
29720
29307
  input.logo ?? "",
29721
29308
  input.theme ?? ""
29722
29309
  ];
29723
- return createHash10("sha1").update(parts.join("\0")).digest("hex");
29310
+ return createHash9("sha1").update(parts.join("\0")).digest("hex");
29724
29311
  }
29725
29312
  async function renderShareOgImage(input) {
29726
29313
  const key = cacheKey(input);
@@ -29735,7 +29322,7 @@ async function renderShareOgImage(input) {
29735
29322
  }
29736
29323
 
29737
29324
  // ../api/src/dashboard/share-ask.ts
29738
- import { createHash as createHash11 } from "crypto";
29325
+ import { createHash as createHash10 } from "crypto";
29739
29326
  var MAX_ARTICLE_CHARS3 = 24e3;
29740
29327
  var MAX_QUESTION_CHARS = 500;
29741
29328
  var SUGGESTION_COUNT = 4;
@@ -29800,7 +29387,7 @@ function parseSuggestions(raw) {
29800
29387
  var CACHE_LIMIT = 200;
29801
29388
  var suggestionCache = /* @__PURE__ */ new Map();
29802
29389
  function articleHash(title, content, lang) {
29803
- return createHash11("sha256").update(`${lang ?? ""}
29390
+ return createHash10("sha256").update(`${lang ?? ""}
29804
29391
  ${title}
29805
29392
 
29806
29393
  ${content}`).digest("hex").slice(0, 32);
@@ -30054,7 +29641,7 @@ function createPublicShareApiRouter() {
30054
29641
  var BUILD_PREFIX = "/share/_assets";
30055
29642
  var shellCache = null;
30056
29643
  function readShell(path) {
30057
- const { mtimeMs } = statSync8(path);
29644
+ const { mtimeMs } = statSync7(path);
30058
29645
  if (shellCache?.mtimeMs === mtimeMs) return shellCache.html;
30059
29646
  const html = readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
30060
29647
  shellCache = { mtimeMs, html };
@@ -30077,7 +29664,7 @@ function serveBuildFile(c, webDist, dir, name) {
30077
29664
  return c.text("not found", 404);
30078
29665
  }
30079
29666
  const path = join20(webDist, dir, name);
30080
- if (!existsSync19(path)) return c.text("not found", 404);
29667
+ if (!existsSync18(path)) return c.text("not found", 404);
30081
29668
  c.header("Content-Type", type);
30082
29669
  c.header("Cache-Control", "public, max-age=31536000, immutable");
30083
29670
  if (ext === ".css") {
@@ -30223,7 +29810,7 @@ ${analytics}` : head);
30223
29810
  const lang = canonicalLanguage(requested);
30224
29811
  if (!isTranslatableLanguage(lang)) return next();
30225
29812
  const shell = join20(webDist, "index.html");
30226
- if (!existsSync19(shell)) return next();
29813
+ if (!existsSync18(shell)) return next();
30227
29814
  const share = await getDocShare(c.req.param("id"));
30228
29815
  if (!share) return next();
30229
29816
  if (requested !== lang) return c.redirect(`/share/${share.id}/${lang}`, 302);
@@ -30259,7 +29846,7 @@ ${analytics}` : head);
30259
29846
  if (!share) return next();
30260
29847
  if (share.kind === "html") return servePublishedHtml(c, share);
30261
29848
  const shell = join20(webDist, "index.html");
30262
- if (!existsSync19(shell)) return next();
29849
+ if (!existsSync18(shell)) return next();
30263
29850
  return readerPage(
30264
29851
  c,
30265
29852
  share,
@@ -30455,7 +30042,7 @@ function entryKind(entry, abs) {
30455
30042
  if (entry.isFile()) return "file";
30456
30043
  if (!entry.isSymbolicLink()) return null;
30457
30044
  try {
30458
- const target = statSync9(abs);
30045
+ const target = statSync8(abs);
30459
30046
  return target.isDirectory() ? "dir" : target.isFile() ? "file" : null;
30460
30047
  } catch {
30461
30048
  return null;
@@ -30468,11 +30055,11 @@ function fileNode(root, abs, name) {
30468
30055
  const lang = CODE_EXTENSIONS[ext];
30469
30056
  let stat;
30470
30057
  try {
30471
- stat = statSync9(abs);
30058
+ stat = statSync8(abs);
30472
30059
  } catch {
30473
30060
  return null;
30474
30061
  }
30475
- const path = relative2(root, abs).split(sep4).join("/");
30062
+ const path = relative(root, abs).split(sep3).join("/");
30476
30063
  const mtime = stat.mtime.toISOString();
30477
30064
  if (kind) {
30478
30065
  return {
@@ -30525,8 +30112,8 @@ function extractTitle(absPath, kind) {
30525
30112
  }
30526
30113
  function resolveDirPath(root, rel) {
30527
30114
  if (rel.includes("\0")) return null;
30528
- const abs = resolve7(root, rel);
30529
- if (abs !== root && !abs.startsWith(root + sep4)) return null;
30115
+ const abs = resolve6(root, rel);
30116
+ if (abs !== root && !abs.startsWith(root + sep3)) return null;
30530
30117
  return abs;
30531
30118
  }
30532
30119
  function isListableFile(name) {
@@ -30574,11 +30161,11 @@ function probeDir(absDir, showHidden) {
30574
30161
  function readGitBranch(dir) {
30575
30162
  try {
30576
30163
  let gitDir = join21(dir, ".git");
30577
- if (statSync9(gitDir).isFile()) {
30164
+ if (statSync8(gitDir).isFile()) {
30578
30165
  const pointer = readFileSync18(gitDir, "utf8").trim();
30579
30166
  const match = pointer.match(/^gitdir:\s*(.+)$/);
30580
30167
  if (!match) return void 0;
30581
- gitDir = resolve7(dir, match[1]);
30168
+ gitDir = resolve6(dir, match[1]);
30582
30169
  }
30583
30170
  const head = readFileSync18(join21(gitDir, "HEAD"), "utf8").trim();
30584
30171
  const branchMatch = head.match(/^ref:\s*refs\/heads\/(.+)$/);
@@ -30603,13 +30190,13 @@ function listDocLevel(root, relDir = "", sort = "newest", showHidden = false) {
30603
30190
  if (dirs.length + docs.length >= MAX_ENTRIES) break;
30604
30191
  if (!showHidden && entry.name.startsWith(".")) continue;
30605
30192
  const abs = join21(absDir, entry.name);
30606
- const path = relative2(root, abs).split(sep4).join("/");
30193
+ const path = relative(root, abs).split(sep3).join("/");
30607
30194
  const kind = entryKind(entry, abs);
30608
30195
  if (kind === "dir") {
30609
30196
  if (SKIP_DIRS.has(entry.name)) continue;
30610
30197
  const probe = probeDir(abs, showHidden);
30611
30198
  if (!probe.hasDocs && probe.hasOther) continue;
30612
- const isRepo = existsSync20(join21(abs, ".git"));
30199
+ const isRepo = existsSync19(join21(abs, ".git"));
30613
30200
  dirs.push({
30614
30201
  path,
30615
30202
  name: entry.name,
@@ -30665,8 +30252,8 @@ function flatDocs(root, {
30665
30252
  }
30666
30253
  function resolveDocPath(root, rel) {
30667
30254
  if (!rel || rel.includes("\0")) return null;
30668
- const abs = resolve7(root, rel);
30669
- if (abs !== root && !abs.startsWith(root + sep4)) return null;
30255
+ const abs = resolve6(root, rel);
30256
+ if (abs !== root && !abs.startsWith(root + sep3)) return null;
30670
30257
  const ext = extname3(abs).toLowerCase();
30671
30258
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return null;
30672
30259
  return abs;
@@ -30676,7 +30263,7 @@ function writeDocContent(root, rel, content, baseMtime) {
30676
30263
  if (!abs) return { status: "not-found" };
30677
30264
  let stat;
30678
30265
  try {
30679
- stat = statSync9(abs);
30266
+ stat = statSync8(abs);
30680
30267
  } catch {
30681
30268
  return { status: "not-found" };
30682
30269
  }
@@ -30688,27 +30275,27 @@ function writeDocContent(root, rel, content, baseMtime) {
30688
30275
  return { status: "too-large" };
30689
30276
  }
30690
30277
  writeFileSync7(abs, content, "utf8");
30691
- return { status: "ok", mtime: statSync9(abs).mtime.toISOString() };
30278
+ return { status: "ok", mtime: statSync8(abs).mtime.toISOString() };
30692
30279
  }
30693
30280
  function resolveRawPath(root, rel) {
30694
30281
  if (!rel || rel.includes("\0")) return null;
30695
- const abs = resolve7(root, rel);
30696
- if (abs !== root && !abs.startsWith(root + sep4)) return null;
30282
+ const abs = resolve6(root, rel);
30283
+ if (abs !== root && !abs.startsWith(root + sep3)) return null;
30697
30284
  const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()];
30698
30285
  if (!contentType) return null;
30699
30286
  return { abs, contentType };
30700
30287
  }
30701
30288
  function resolveHtmlPath(root, rel) {
30702
30289
  if (!rel || rel.includes("\0")) return null;
30703
- const abs = resolve7(root, rel);
30704
- if (abs !== root && !abs.startsWith(root + sep4)) return null;
30290
+ const abs = resolve6(root, rel);
30291
+ if (abs !== root && !abs.startsWith(root + sep3)) return null;
30705
30292
  if (DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "html") return null;
30706
30293
  return abs;
30707
30294
  }
30708
30295
  function resolveDownloadPath(root, rel) {
30709
30296
  if (!rel || rel.includes("\0")) return null;
30710
- const abs = resolve7(root, rel);
30711
- if (abs !== root && !abs.startsWith(root + sep4)) return null;
30297
+ const abs = resolve6(root, rel);
30298
+ if (abs !== root && !abs.startsWith(root + sep3)) return null;
30712
30299
  if (!isListableFile(basename6(abs))) return null;
30713
30300
  const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()] ?? "application/octet-stream";
30714
30301
  return { abs, contentType };
@@ -30725,7 +30312,7 @@ function uniqueName(absDir, name) {
30725
30312
  let candidate = name;
30726
30313
  for (let n = 1; n < 1e3; n++) {
30727
30314
  try {
30728
- statSync9(join21(absDir, candidate));
30315
+ statSync8(join21(absDir, candidate));
30729
30316
  } catch {
30730
30317
  return candidate;
30731
30318
  }
@@ -30737,7 +30324,7 @@ function saveUploadedFile(root, relDir, name, data) {
30737
30324
  const absDir = resolveDirPath(root, relDir);
30738
30325
  if (absDir === null) return { status: "no-dir" };
30739
30326
  try {
30740
- if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30327
+ if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30741
30328
  } catch {
30742
30329
  return { status: "no-dir" };
30743
30330
  }
@@ -30749,13 +30336,13 @@ function saveUploadedFile(root, relDir, name, data) {
30749
30336
  const final = uniqueName(absDir, safe);
30750
30337
  const abs = join21(absDir, final);
30751
30338
  writeFileSync7(abs, data);
30752
- return { status: "ok", path: relative2(root, abs).split(sep4).join("/"), name: final };
30339
+ return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: final };
30753
30340
  }
30754
30341
  function createDocFolder(root, relDir, name) {
30755
30342
  const absDir = resolveDirPath(root, relDir);
30756
30343
  if (absDir === null) return { status: "no-dir" };
30757
30344
  try {
30758
- if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30345
+ if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30759
30346
  } catch {
30760
30347
  return { status: "no-dir" };
30761
30348
  }
@@ -30763,18 +30350,18 @@ function createDocFolder(root, relDir, name) {
30763
30350
  if (!safe) return { status: "bad-name" };
30764
30351
  const abs = join21(absDir, safe);
30765
30352
  try {
30766
- statSync9(abs);
30353
+ statSync8(abs);
30767
30354
  return { status: "exists" };
30768
30355
  } catch {
30769
30356
  }
30770
- mkdirSync9(abs);
30771
- return { status: "ok", path: relative2(root, abs).split(sep4).join("/"), name: safe };
30357
+ mkdirSync8(abs);
30358
+ return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: safe };
30772
30359
  }
30773
30360
  function createDocFile(root, relDir, name, content) {
30774
30361
  const absDir = resolveDirPath(root, relDir);
30775
30362
  if (absDir === null) return { status: "no-dir" };
30776
30363
  try {
30777
- if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30364
+ if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30778
30365
  } catch {
30779
30366
  return { status: "no-dir" };
30780
30367
  }
@@ -30791,22 +30378,22 @@ function createDocFile(root, relDir, name, content) {
30791
30378
  if (err.code === "EEXIST") return { status: "exists" };
30792
30379
  throw err;
30793
30380
  }
30794
- return { status: "ok", path: relative2(root, abs).split(sep4).join("/"), name: safe };
30381
+ return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: safe };
30795
30382
  }
30796
30383
  function moveDocEntry(root, from, to) {
30797
30384
  if (!from || !to || from.includes("\0") || to.includes("\0")) return { status: "not-found" };
30798
- const absFrom = resolve7(root, from);
30799
- if (!absFrom.startsWith(root + sep4)) return { status: "not-found" };
30385
+ const absFrom = resolve6(root, from);
30386
+ if (!absFrom.startsWith(root + sep3)) return { status: "not-found" };
30800
30387
  let stat;
30801
30388
  try {
30802
- stat = statSync9(absFrom);
30389
+ stat = statSync8(absFrom);
30803
30390
  } catch {
30804
30391
  return { status: "not-found" };
30805
30392
  }
30806
30393
  const isDir = stat.isDirectory();
30807
30394
  if (!isDir && !stat.isFile()) return { status: "not-found" };
30808
- const absTo = resolve7(root, to);
30809
- if (!absTo.startsWith(root + sep4)) return { status: "bad-target" };
30395
+ const absTo = resolve6(root, to);
30396
+ if (!absTo.startsWith(root + sep3)) return { status: "bad-target" };
30810
30397
  const name = sanitizeUploadName(basename6(absTo));
30811
30398
  if (!name) return { status: "bad-target" };
30812
30399
  if (!isDir) {
@@ -30816,27 +30403,27 @@ function moveDocEntry(root, from, to) {
30816
30403
  }
30817
30404
  }
30818
30405
  const absToDir = dirname3(absTo);
30819
- if (resolveDirPath(root, relative2(root, absToDir)) === null) return { status: "bad-target" };
30406
+ if (resolveDirPath(root, relative(root, absToDir)) === null) return { status: "bad-target" };
30820
30407
  try {
30821
- if (!statSync9(absToDir).isDirectory()) return { status: "bad-target" };
30408
+ if (!statSync8(absToDir).isDirectory()) return { status: "bad-target" };
30822
30409
  } catch {
30823
30410
  return { status: "bad-target" };
30824
30411
  }
30825
30412
  const finalAbs = join21(absToDir, name);
30826
- if (isDir && (finalAbs === absFrom || finalAbs.startsWith(absFrom + sep4))) {
30413
+ if (isDir && (finalAbs === absFrom || finalAbs.startsWith(absFrom + sep3))) {
30827
30414
  return { status: "into-self" };
30828
30415
  }
30829
30416
  try {
30830
- if (realpathSync2(finalAbs) !== realpathSync2(absFrom)) return { status: "exists" };
30417
+ if (realpathSync(finalAbs) !== realpathSync(absFrom)) return { status: "exists" };
30831
30418
  } catch {
30832
30419
  }
30833
30420
  renameSync3(absFrom, finalAbs);
30834
- return { status: "ok", path: relative2(root, finalAbs).split(sep4).join("/"), name };
30421
+ return { status: "ok", path: relative(root, finalAbs).split(sep3).join("/"), name };
30835
30422
  }
30836
30423
  function deleteDocEntry(root, path) {
30837
30424
  if (!path || path.includes("\0")) return { status: "not-found" };
30838
- const abs = resolve7(root, path);
30839
- if (!abs.startsWith(root + sep4)) return { status: "not-found" };
30425
+ const abs = resolve6(root, path);
30426
+ if (!abs.startsWith(root + sep3)) return { status: "not-found" };
30840
30427
  let stat;
30841
30428
  try {
30842
30429
  stat = lstatSync2(abs);
@@ -30848,7 +30435,7 @@ function deleteDocEntry(root, path) {
30848
30435
  rmSync10(abs, { recursive: isDir });
30849
30436
  return {
30850
30437
  status: "ok",
30851
- path: relative2(root, abs).split(sep4).join("/"),
30438
+ path: relative(root, abs).split(sep3).join("/"),
30852
30439
  type: isDir ? "dir" : "file"
30853
30440
  };
30854
30441
  }
@@ -30878,7 +30465,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30878
30465
  if (!resolved2) return c.json({ error: "not found" }, 404);
30879
30466
  let stat;
30880
30467
  try {
30881
- stat = statSync9(resolved2.abs);
30468
+ stat = statSync8(resolved2.abs);
30882
30469
  } catch {
30883
30470
  return c.json({ error: "not found" }, 404);
30884
30471
  }
@@ -30900,7 +30487,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30900
30487
  if (!abs) return c.json({ error: "not found" }, 404);
30901
30488
  let stat;
30902
30489
  try {
30903
- stat = statSync9(abs);
30490
+ stat = statSync8(abs);
30904
30491
  } catch {
30905
30492
  return c.json({ error: "not found" }, 404);
30906
30493
  }
@@ -31025,7 +30612,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
31025
30612
  if (!abs) return c.json({ error: "not found" }, 404);
31026
30613
  let stat;
31027
30614
  try {
31028
- stat = statSync9(abs);
30615
+ stat = statSync8(abs);
31029
30616
  } catch {
31030
30617
  return c.json({ error: "not found" }, 404);
31031
30618
  }
@@ -31074,7 +30661,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
31074
30661
  if (!abs) return c.json({ error: "not found" }, 404);
31075
30662
  let stat;
31076
30663
  try {
31077
- stat = statSync9(abs);
30664
+ stat = statSync8(abs);
31078
30665
  } catch {
31079
30666
  return c.json({ error: "not found" }, 404);
31080
30667
  }
@@ -31125,7 +30712,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
31125
30712
  }
31126
30713
  let stat;
31127
30714
  try {
31128
- stat = statSync9(abs);
30715
+ stat = statSync8(abs);
31129
30716
  } catch {
31130
30717
  return { error: c.json({ error: "not found" }, 404) };
31131
30718
  }
@@ -31193,9 +30780,9 @@ function withDocLinkBridge(html) {
31193
30780
  var DOC_MENTION_RE = /(?<![\w@/`])@((?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]{1,6})(?::(\d+))?(?![\w-])/g;
31194
30781
  function isRealDoc(root, rel) {
31195
30782
  const abs = resolveDocPath(root, rel);
31196
- if (!abs || !existsSync21(abs)) return false;
30783
+ if (!abs || !existsSync20(abs)) return false;
31197
30784
  try {
31198
- return statSync10(abs).isFile();
30785
+ return statSync9(abs).isFile();
31199
30786
  } catch {
31200
30787
  return false;
31201
30788
  }
@@ -31281,7 +30868,6 @@ var SETTINGS_SECTIONS = [
31281
30868
  "activity",
31282
30869
  "channels",
31283
30870
  "domain",
31284
- "workspaces",
31285
30871
  "usage",
31286
30872
  "sessions",
31287
30873
  "mcp-servers",
@@ -31718,7 +31304,7 @@ var BACKGROUND_CHECK_IN_MS = 30 * 6e4;
31718
31304
  var MISSED_MESSAGE_WINDOW_MS = 24 * 60 * 60 * 1e3;
31719
31305
  var MISSED_MESSAGE_THREAD_LIMIT = 100;
31720
31306
  var delay = (ms) => new Promise((r) => setTimeout(r, ms));
31721
- function stripPathPrefixes(label, roots, home = homedir9()) {
31307
+ function stripPathPrefixes(label, roots, home = homedir8()) {
31722
31308
  let out = label;
31723
31309
  for (const root of roots) {
31724
31310
  if (root) out = out.replaceAll(`${root.replace(/\/+$/, "")}/`, "");
@@ -31830,6 +31416,9 @@ var ChatAgent = class {
31830
31416
  handleMessage(msg) {
31831
31417
  if (msg.author === AGENT_AUTHOR) return;
31832
31418
  this.seenReplies.add(msg.replyId);
31419
+ console.log(
31420
+ `[chat-agent] received thread=${msg.threadId} reply=${msg.replyId} author=${msg.author} body=${JSON.stringify(msg.body.slice(0, 80))}`
31421
+ );
31833
31422
  if (!msg.resumed && !msg.woken) {
31834
31423
  this.consecutiveWakes.delete(msg.threadId);
31835
31424
  this.autoContinues.delete(msg.threadId);
@@ -32083,7 +31672,10 @@ var ChatAgent = class {
32083
31672
  await this.run(msg);
32084
31673
  return;
32085
31674
  }
32086
- if (mentionsSupport(msg.body)) return;
31675
+ if (mentionsSupport(msg.body)) {
31676
+ console.log(`[chat-agent] @support only, skipped thread=${msg.threadId}`);
31677
+ return;
31678
+ }
32087
31679
  const humans = await this.getHumanParticipants(msg.threadId);
32088
31680
  if (humans.size <= 1) {
32089
31681
  await this.run(msg);
@@ -32100,7 +31692,10 @@ var ChatAgent = class {
32100
31692
  }
32101
31693
  const transcript = [...recent, { author: msg.author, body: msg.body }];
32102
31694
  const respond = await this.shouldAgentRespond(transcript);
32103
- if (!respond) return;
31695
+ if (!respond) {
31696
+ console.log(`[chat-agent] classifier skipped thread=${msg.threadId} reply=${msg.replyId}`);
31697
+ return;
31698
+ }
32104
31699
  await this.run(msg);
32105
31700
  }
32106
31701
  /** Whether the body mentions the main agent's per-workspace display name
@@ -32183,6 +31778,10 @@ var ChatAgent = class {
32183
31778
  runningThreadIds() {
32184
31779
  return [...this.activeRuns.keys()];
32185
31780
  }
31781
+ /** Every thread still waiting on a background job it launched. */
31782
+ backgroundThreadIds() {
31783
+ return [...this.watchedTasks.keys()];
31784
+ }
32186
31785
  /** Workspace roots for label sanitising, memoised across runs. Best-effort:
32187
31786
  * any failure (including a test double without a `workspaces` table) just
32188
31787
  * means no stripping this run, retried on the next. */
@@ -32328,6 +31927,8 @@ var ChatAgent = class {
32328
31927
  const abort = new AbortController();
32329
31928
  this.activeRuns.set(msg.threadId, { activities, abort, msg });
32330
31929
  notifyThinking(true);
31930
+ const startedAt = Date.now();
31931
+ console.log(`[chat-agent] turn start thread=${msg.threadId} reply=${msg.replyId}`);
32331
31932
  const roots = await this.getWorkspaceRoots();
32332
31933
  const onActivity = (raw) => {
32333
31934
  const activity = { ...raw, label: stripPathPrefixes(raw.label, roots) };
@@ -32698,6 +32299,9 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
32698
32299
  store.close();
32699
32300
  this.activeRuns.delete(msg.threadId);
32700
32301
  notifyThinking(false);
32302
+ console.log(
32303
+ `[chat-agent] turn end thread=${msg.threadId} reply=${msg.replyId} ms=${Date.now() - startedAt}`
32304
+ );
32701
32305
  void this.watchBackgroundTasks(msg.threadId, thread.channel_id, owningProfile);
32702
32306
  }
32703
32307
  }
@@ -32721,22 +32325,22 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
32721
32325
  let ready;
32722
32326
  try {
32723
32327
  channel = this.supabase().channel(`agent-thinking:${threadId}`);
32724
- ready = new Promise((resolve8) => {
32328
+ ready = new Promise((resolve7) => {
32725
32329
  const timeout = setTimeout(() => {
32726
32330
  console.error(`[chat-agent] thinking-channel ${threadId}: subscribe timed out after 10s`);
32727
- resolve8(false);
32331
+ resolve7(false);
32728
32332
  }, 1e4);
32729
32333
  channel.subscribe((status, err) => {
32730
32334
  if (status === "SUBSCRIBED") {
32731
32335
  clearTimeout(timeout);
32732
- resolve8(true);
32336
+ resolve7(true);
32733
32337
  } else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
32734
32338
  console.error(
32735
32339
  `[chat-agent] thinking-channel ${threadId}: ${status}`,
32736
32340
  err?.message ?? ""
32737
32341
  );
32738
32342
  clearTimeout(timeout);
32739
- resolve8(false);
32343
+ resolve7(false);
32740
32344
  }
32741
32345
  });
32742
32346
  });
@@ -32783,19 +32387,19 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
32783
32387
  let ready;
32784
32388
  try {
32785
32389
  channel = this.supabase().channel("channel-activity");
32786
- ready = new Promise((resolve8) => {
32390
+ ready = new Promise((resolve7) => {
32787
32391
  const timeout = setTimeout(() => {
32788
32392
  console.error("[chat-agent] channel-activity: subscribe timed out after 10s");
32789
- resolve8(false);
32393
+ resolve7(false);
32790
32394
  }, 1e4);
32791
32395
  channel.subscribe((status, err) => {
32792
32396
  if (status === "SUBSCRIBED") {
32793
32397
  clearTimeout(timeout);
32794
- resolve8(true);
32398
+ resolve7(true);
32795
32399
  } else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
32796
32400
  console.error(`[chat-agent] channel-activity: ${status}`, err?.message ?? "");
32797
32401
  clearTimeout(timeout);
32798
- resolve8(false);
32402
+ resolve7(false);
32799
32403
  }
32800
32404
  });
32801
32405
  });
@@ -33317,6 +32921,7 @@ function parseEffortCommand(text) {
33317
32921
  }
33318
32922
 
33319
32923
  // src/slack/listeners.ts
32924
+ var AUTO_CONTINUE_PROMPT = "\uFF08\u7CFB\u7D71\u8A0A\u606F\uFF09\u4F60\u525B\u624D\u7684\u56DE\u61C9\u56E0\u70BA\u57F7\u884C\u6642\u9593\u904E\u9577\u88AB\u81EA\u52D5\u4E2D\u65B7\u4E86\u3002\u8ACB\u5F9E\u4E0A\u6B21\u4E2D\u65B7\u7684\u5730\u65B9\u63A5\u8457\u5B8C\u6210\uFF0C\u4E0D\u8981\u5F9E\u982D\u91CD\u505A\u3002\u5982\u679C\u525B\u624D\u5361\u5728\u67D0\u500B\u6307\u4EE4\u4E0A\uFF0C\u6539\u7528\u8F03\u77ED\u7684\u7BC4\u570D\u6216\u80CC\u666F\u57F7\u884C\u7684\u65B9\u5F0F\u518D\u8A66\u4E00\u6B21\u3002";
33320
32925
  var REJECT_MESSAGES = [
33321
32926
  "Sorry, I'm a personal assistant and only respond to my owner. :bow:",
33322
32927
  "I appreciate the interest, but I'm exclusively dedicated to my owner. :lock:",
@@ -33551,6 +33156,8 @@ function registerListeners(app, store, reactionStore, config, triggerEngine, men
33551
33156
  return id;
33552
33157
  };
33553
33158
  const forkContexts = /* @__PURE__ */ new Map();
33159
+ const autoContinues = /* @__PURE__ */ new Map();
33160
+ const autoContinuing = /* @__PURE__ */ new Set();
33554
33161
  let forkCounter = 0;
33555
33162
  const registerFork = (ctx) => {
33556
33163
  const id = String(++forkCounter);
@@ -33618,6 +33225,7 @@ function registerListeners(app, store, reactionStore, config, triggerEngine, men
33618
33225
  return;
33619
33226
  }
33620
33227
  const threadKey = `${channelId}:${sessionKey}`;
33228
+ if (!autoContinuing.delete(threadKey)) autoContinues.delete(threadKey);
33621
33229
  const abortController = new AbortController();
33622
33230
  activeRuns.set(threadKey, abortController);
33623
33231
  let reacted = false;
@@ -33667,12 +33275,36 @@ ${trimmedDetail.slice(0, 1500)}
33667
33275
  };
33668
33276
  const offerContinue = async () => {
33669
33277
  await clearReaction();
33278
+ const n = (autoContinues.get(threadKey) ?? 0) + 1;
33279
+ const limit = resolveAutoContinueLimit(channelId);
33280
+ if (n <= limit) {
33281
+ autoContinues.set(threadKey, n);
33282
+ await say({
33283
+ text: `This turn hit its time limit, continuing automatically (${n}/${limit}).`,
33284
+ ...threadTs ? { thread_ts: threadTs } : {}
33285
+ });
33286
+ autoContinuing.add(threadKey);
33287
+ queue.enqueue(threadKey, async () => {
33288
+ await handleMessage(
33289
+ client,
33290
+ say,
33291
+ channelId,
33292
+ sessionKey,
33293
+ AUTO_CONTINUE_PROMPT,
33294
+ senderId,
33295
+ store.getSession(channelId, sessionKey)?.sessionId,
33296
+ threadTs,
33297
+ reactTs
33298
+ );
33299
+ });
33300
+ return;
33301
+ }
33670
33302
  const retryId = registerRetry({
33671
33303
  channelId,
33672
33304
  sessionKey,
33673
33305
  // Resume instruction, NOT the original prompt — the session already holds
33674
33306
  // the original request + partial work, so re-sending it would double up.
33675
- prompt: "\uFF08\u7CFB\u7D71\u8A0A\u606F\uFF09\u4F60\u525B\u624D\u7684\u56DE\u61C9\u56E0\u70BA\u57F7\u884C\u6642\u9593\u904E\u9577\u88AB\u81EA\u52D5\u4E2D\u65B7\u4E86\u3002\u8ACB\u5F9E\u4E0A\u6B21\u4E2D\u65B7\u7684\u5730\u65B9\u63A5\u8457\u5B8C\u6210\uFF0C\u4E0D\u8981\u5F9E\u982D\u91CD\u505A\u3002\u5982\u679C\u525B\u624D\u5361\u5728\u67D0\u500B\u6307\u4EE4\u4E0A\uFF0C\u6539\u7528\u8F03\u77ED\u7684\u7BC4\u570D\u6216\u80CC\u666F\u57F7\u884C\u7684\u65B9\u5F0F\u518D\u8A66\u4E00\u6B21\u3002",
33307
+ prompt: AUTO_CONTINUE_PROMPT,
33676
33308
  senderId,
33677
33309
  threadTs,
33678
33310
  reactTs
@@ -35275,13 +34907,13 @@ async function recoverStaleReactions(client, reactionStore) {
35275
34907
  var ts2 = () => (/* @__PURE__ */ new Date()).toISOString();
35276
34908
  var POWER_POLL_MS = 3e4;
35277
34909
  function isOnACPower() {
35278
- return new Promise((resolve8) => {
34910
+ return new Promise((resolve7) => {
35279
34911
  execFile2("pmset", ["-g", "ps"], { timeout: 2e3 }, (err, stdout) => {
35280
34912
  if (err) {
35281
- resolve8(true);
34913
+ resolve7(true);
35282
34914
  return;
35283
34915
  }
35284
- resolve8(stdout.includes("'AC Power'"));
34916
+ resolve7(stdout.includes("'AC Power'"));
35285
34917
  });
35286
34918
  });
35287
34919
  }
@@ -35366,6 +34998,7 @@ async function startServer() {
35366
34998
  const caffeinate = startCaffeinate();
35367
34999
  const config = loadConfig();
35368
35000
  const store = new SessionStore(paths.DB_FILE);
35001
+ watchDestroyedChannels(store);
35369
35002
  const runStore = new AutomationRunStore(paths.DB_FILE);
35370
35003
  installUsageRecording();
35371
35004
  const stopRunSync = databaseReachable() ? startAutomationRunSync(runStore, getProfile(), {
@@ -35431,30 +35064,6 @@ export {
35431
35064
  resolveUserId,
35432
35065
  ensureUsersCached,
35433
35066
  useLocalCache,
35434
- isPermissionMode,
35435
- isLogicalCwd,
35436
- isUnderLogicalRoot,
35437
- expandPath,
35438
- canSeeChannel,
35439
- refreshChannelRegistry,
35440
- getChannelRegistry,
35441
- getProfileChannelRegistry,
35442
- findChannelById,
35443
- findChannel,
35444
- startChannelRegistryPolling,
35445
- isCwdUsable,
35446
- auditChannelCwds,
35447
- warnOnBrokenChannelCwds,
35448
- resolveCwd,
35449
- ChannelCwdError,
35450
- createChannel,
35451
- DefaultChannelError,
35452
- updateChannelById,
35453
- markChannelGreeted,
35454
- updateChannelsMcpConnections,
35455
- ensureAgentDmChannel,
35456
- ensureGeneralChannel,
35457
- ensureMemberDmChannel,
35458
35067
  getWorkspaceDomain,
35459
35068
  insertWorkspaceDomain,
35460
35069
  updateWorkspaceDomainStatus,
@@ -35503,9 +35112,19 @@ export {
35503
35112
  setWorkspaceAutoContinueLimit,
35504
35113
  getWorkspaceOwnPersona,
35505
35114
  setWorkspaceOwnPersona,
35115
+ setWorkspaceAgentDefaults,
35506
35116
  setWorkspacePermissionMode,
35507
35117
  getAgentPaused,
35508
35118
  setAgentPaused,
35119
+ logSupportAction,
35120
+ listSupportWorkspaceIds,
35121
+ grantSupportMembership,
35122
+ revokeSupportMembership,
35123
+ listSupportLog,
35124
+ SUPPORT_GRANT_HOURS,
35125
+ getActiveSupportGrant,
35126
+ createSupportGrant,
35127
+ revokeSupportGrants,
35509
35128
  onboardingPending,
35510
35129
  invalidateAuthContextCache,
35511
35130
  SUPPORT_AVATAR_URL,
@@ -35539,12 +35158,6 @@ export {
35539
35158
  clearClaudeAuthFailed,
35540
35159
  claudeAuthFailed,
35541
35160
  pinnedClaudeConfigDir,
35542
- AGENT_AUTHOR,
35543
- isHumanAuthor,
35544
- deriveThreadTitle,
35545
- syncPostToDashboard,
35546
- resolveDashboardChannelId,
35547
- postToDashboardChannel,
35548
35161
  refreshAutomationRegistry,
35549
35162
  startAutomationRegistryPolling,
35550
35163
  DEFAULT_TIMEZONE,
@@ -35690,6 +35303,8 @@ export {
35690
35303
  flatDocs,
35691
35304
  createDocsRouter,
35692
35305
  slackMrkdwnToMarkdown,
35306
+ GUIDE_RULES,
35307
+ extractGuide,
35693
35308
  handleSupportMention,
35694
35309
  escalateToHuman,
35695
35310
  syncSupportReply,