flyspace-cli 0.1.66 → 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.
- package/dist/{chunk-DVHYIWIW.js → chunk-GT2SOVPK.js} +477 -1032
- package/dist/{chunk-KPZOOR73.js → chunk-JH66T2SW.js} +784 -23
- package/dist/{chunk-ODQS4YBM.js → chunk-KP64MCSF.js} +333 -14
- package/dist/cli.js +748 -441
- package/dist/index.js +2 -2
- package/dist/{threads-62Y2BIFT.js → threads-B5FBIJLG.js} +31 -2
- package/package.json +1 -1
- package/system.capabilities.md +1 -0
|
@@ -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
|
-
|
|
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(
|
|
11599
|
-
return useNativeURL ? new URL2(
|
|
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(
|
|
13021
|
+
function settle(resolve7, reject, response) {
|
|
12990
13022
|
const validateStatus = response.config.validateStatus;
|
|
12991
13023
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
12992
|
-
|
|
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((
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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((
|
|
14722
|
-
settle(
|
|
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(
|
|
15127
|
-
resolvePromise =
|
|
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((
|
|
15141
|
-
token.subscribe(
|
|
15142
|
-
_resolve =
|
|
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((
|
|
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(
|
|
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((
|
|
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
|
-
|
|
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((
|
|
17655
|
-
axios_1.default.get(_MsEdgeTTS.VOICES_URL).then((res) =>
|
|
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((
|
|
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
|
-
|
|
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((
|
|
17806
|
+
new Promise((resolve7, reject) => {
|
|
17775
17807
|
if (!metadataFilePath) {
|
|
17776
|
-
return
|
|
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
|
-
|
|
17818
|
+
resolve7(metadataFilePath);
|
|
17787
17819
|
} else {
|
|
17788
17820
|
reject(new Error("No metadata received"));
|
|
17789
17821
|
fs.rmSync(metadataFilePath, { force: true });
|
|
@@ -17878,579 +17910,6 @@ var require_dist = __commonJS({
|
|
|
17878
17910
|
// src/index.ts
|
|
17879
17911
|
import { execFile as execFile2, spawn as spawn6 } from "child_process";
|
|
17880
17912
|
|
|
17881
|
-
// ../api/src/channels.ts
|
|
17882
|
-
import { createHash } from "crypto";
|
|
17883
|
-
import { existsSync, mkdirSync, realpathSync, statSync } from "fs";
|
|
17884
|
-
import { homedir } from "os";
|
|
17885
|
-
import { isAbsolute, relative, resolve, sep } from "path";
|
|
17886
|
-
function isPermissionMode(value) {
|
|
17887
|
-
return value === "bypass" || value === "ask";
|
|
17888
|
-
}
|
|
17889
|
-
function isLogicalCwd(p) {
|
|
17890
|
-
return /^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/.test(p);
|
|
17891
|
-
}
|
|
17892
|
-
function logicalRoot() {
|
|
17893
|
-
return process.env["FLYSPACE_ROOT"] || resolve(homedir(), "Flyspace");
|
|
17894
|
-
}
|
|
17895
|
-
var workspaceRoots = /* @__PURE__ */ new Map();
|
|
17896
|
-
var workspacePermissionModes = /* @__PURE__ */ new Map();
|
|
17897
|
-
var workspaceAutoContinueLimits = /* @__PURE__ */ new Map();
|
|
17898
|
-
var DEFAULT_AUTO_CONTINUE_LIMIT = 3;
|
|
17899
|
-
async function refreshWorkspaceAutoContinueLimits() {
|
|
17900
|
-
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, auto_continue_limit");
|
|
17901
|
-
if (error) return;
|
|
17902
|
-
workspaceAutoContinueLimits = new Map(
|
|
17903
|
-
(data ?? []).filter((w) => typeof w.auto_continue_limit === "number").map((w) => [w.slug, w.auto_continue_limit])
|
|
17904
|
-
);
|
|
17905
|
-
}
|
|
17906
|
-
function resolveAutoContinueLimit(channelId) {
|
|
17907
|
-
const channel = channelId ? findChannel(channelId) : void 0;
|
|
17908
|
-
return workspaceAutoContinueLimits.get(channel?.profile ?? getProfile()) ?? DEFAULT_AUTO_CONTINUE_LIMIT;
|
|
17909
|
-
}
|
|
17910
|
-
var workspaceOwnPersona = /* @__PURE__ */ new Set();
|
|
17911
|
-
async function refreshWorkspaceOwnPersona() {
|
|
17912
|
-
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, own_persona");
|
|
17913
|
-
if (error) return;
|
|
17914
|
-
workspaceOwnPersona = new Set(
|
|
17915
|
-
(data ?? []).filter((w) => w.own_persona === true).map((w) => w.slug)
|
|
17916
|
-
);
|
|
17917
|
-
}
|
|
17918
|
-
function resolveOwnPersona(channelId) {
|
|
17919
|
-
const channel = channelId ? findChannel(channelId) : void 0;
|
|
17920
|
-
return workspaceOwnPersona.has(channel?.profile ?? getProfile());
|
|
17921
|
-
}
|
|
17922
|
-
var workspaceAgentDefaults = /* @__PURE__ */ new Map();
|
|
17923
|
-
async function refreshWorkspaceAgentDefaults() {
|
|
17924
|
-
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, default_model, default_effort");
|
|
17925
|
-
if (error) return;
|
|
17926
|
-
workspaceAgentDefaults = new Map(
|
|
17927
|
-
(data ?? []).map((w) => [
|
|
17928
|
-
w.slug,
|
|
17929
|
-
{
|
|
17930
|
-
model: typeof w.default_model === "string" && w.default_model.trim() ? w.default_model.trim() : void 0,
|
|
17931
|
-
effort: typeof w.default_effort === "string" && isEffort(w.default_effort) ? w.default_effort : void 0
|
|
17932
|
-
}
|
|
17933
|
-
])
|
|
17934
|
-
);
|
|
17935
|
-
}
|
|
17936
|
-
function workspaceAgentDefault(profile = getProfile()) {
|
|
17937
|
-
return workspaceAgentDefaults.get(profile) ?? {};
|
|
17938
|
-
}
|
|
17939
|
-
function displayCwd(cwd, hostHome) {
|
|
17940
|
-
const logical = isLogicalCwd(cwd) ? cwd : toLogicalCwd(cwd);
|
|
17941
|
-
let path = cwd;
|
|
17942
|
-
if (isLogicalCwd(logical)) {
|
|
17943
|
-
const [slug, name] = logical.split("/");
|
|
17944
|
-
const root = workspaceRoots.get(slug);
|
|
17945
|
-
path = root ? `${root.replace(/[/\\]+$/, "")}/${name}` : `~/Flyspace/${logical}`;
|
|
17946
|
-
}
|
|
17947
|
-
const home = hostHome?.replace(/[/\\]+$/, "");
|
|
17948
|
-
if (home && (path === home || path.startsWith(`${home}/`) || path.startsWith(`${home}\\`))) {
|
|
17949
|
-
return `~${path.slice(home.length)}`;
|
|
17950
|
-
}
|
|
17951
|
-
return path.replace(/^\/(Users|home)\/[^/]+/, "~").replace(/^\/root(?=\/|$)/, "~").replace(/^[A-Za-z]:\\Users\\[^\\]+/, "~");
|
|
17952
|
-
}
|
|
17953
|
-
async function refreshWorkspacePermissionModes() {
|
|
17954
|
-
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, permission_mode");
|
|
17955
|
-
if (error) return;
|
|
17956
|
-
workspacePermissionModes = new Map(
|
|
17957
|
-
(data ?? []).filter((w) => isPermissionMode(w.permission_mode)).map((w) => [w.slug, w.permission_mode])
|
|
17958
|
-
);
|
|
17959
|
-
}
|
|
17960
|
-
async function refreshWorkspaceRoots() {
|
|
17961
|
-
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, root_path");
|
|
17962
|
-
if (error) return;
|
|
17963
|
-
workspaceRoots = new Map(
|
|
17964
|
-
(data ?? []).filter((w) => w.root_path).map((w) => [w.slug, expandPath(w.root_path)])
|
|
17965
|
-
);
|
|
17966
|
-
}
|
|
17967
|
-
function resolveLogicalCwd(p) {
|
|
17968
|
-
const [slug, name] = p.split("/");
|
|
17969
|
-
const root = workspaceRoots.get(slug);
|
|
17970
|
-
return root ? resolve(root, name) : resolve(logicalRoot(), p);
|
|
17971
|
-
}
|
|
17972
|
-
function isUnderLogicalRoot(cwd) {
|
|
17973
|
-
return [logicalRoot(), ...workspaceRoots.values()].some((r) => cwd.startsWith(r + sep));
|
|
17974
|
-
}
|
|
17975
|
-
function toLogicalCwd(cwd) {
|
|
17976
|
-
const fromRoot = relative(logicalRoot(), cwd).split(sep).join("/");
|
|
17977
|
-
if (isLogicalCwd(fromRoot)) return fromRoot;
|
|
17978
|
-
for (const [slug, root] of workspaceRoots) {
|
|
17979
|
-
const name = relative(root, cwd);
|
|
17980
|
-
if (isLogicalCwd(`${slug}/${name}`)) return `${slug}/${name}`;
|
|
17981
|
-
}
|
|
17982
|
-
return cwd;
|
|
17983
|
-
}
|
|
17984
|
-
function ensureLogicalCwdDir(cwd) {
|
|
17985
|
-
if (!isUnderLogicalRoot(cwd) || existsSync(cwd)) return;
|
|
17986
|
-
mkdirSync(cwd, { recursive: true });
|
|
17987
|
-
}
|
|
17988
|
-
function expandPath(p) {
|
|
17989
|
-
let expanded = p;
|
|
17990
|
-
if (expanded === "~") {
|
|
17991
|
-
expanded = homedir();
|
|
17992
|
-
} else if (expanded.startsWith("~/")) {
|
|
17993
|
-
expanded = resolve(homedir(), expanded.slice(2));
|
|
17994
|
-
}
|
|
17995
|
-
return isAbsolute(expanded) ? expanded : resolve(expanded);
|
|
17996
|
-
}
|
|
17997
|
-
function normaliseMemberEmails(raw) {
|
|
17998
|
-
if (!Array.isArray(raw)) return [];
|
|
17999
|
-
const seen = /* @__PURE__ */ new Set();
|
|
18000
|
-
for (const v of raw) {
|
|
18001
|
-
if (typeof v !== "string") continue;
|
|
18002
|
-
const email = v.trim().toLowerCase();
|
|
18003
|
-
if (email) seen.add(email);
|
|
18004
|
-
}
|
|
18005
|
-
return [...seen];
|
|
18006
|
-
}
|
|
18007
|
-
function canSeeChannel(channel, viewer) {
|
|
18008
|
-
if (channel.visibility === "public") return true;
|
|
18009
|
-
if (viewer?.role === "admin" && !channel.dmKey) return true;
|
|
18010
|
-
const email = viewer?.email?.trim().toLowerCase();
|
|
18011
|
-
return !!email && channel.memberEmails.includes(email);
|
|
18012
|
-
}
|
|
18013
|
-
function rowToChannel(row) {
|
|
18014
|
-
return {
|
|
18015
|
-
id: row.id,
|
|
18016
|
-
name: row.name,
|
|
18017
|
-
categoryId: row.category_id,
|
|
18018
|
-
cwd: isLogicalCwd(row.cwd) ? resolveLogicalCwd(row.cwd) : expandPath(row.cwd),
|
|
18019
|
-
externalChannelId: row.external_channel_id,
|
|
18020
|
-
model: row.model,
|
|
18021
|
-
effort: row.effort && isEffort(row.effort) ? row.effort : null,
|
|
18022
|
-
prompt: row.prompt?.trim() || null,
|
|
18023
|
-
topicCategories: normaliseTopicCategories(row.topic_categories),
|
|
18024
|
-
// A uuid[] arrives as a real array; anything else (an older row read
|
|
18025
|
-
// through a cached client, a hand-edited value) reads as "no MCP", which
|
|
18026
|
-
// is the safe direction for a list that decides which credentials a run
|
|
18027
|
-
// can reach.
|
|
18028
|
-
mcpConnections: Array.isArray(row.mcp_connections) ? row.mcp_connections.filter((id) => typeof id === "string") : [],
|
|
18029
|
-
access: row.access ?? void 0,
|
|
18030
|
-
visibility: row.visibility === "public" ? "public" : "private",
|
|
18031
|
-
memberEmails: normaliseMemberEmails(row.member_emails),
|
|
18032
|
-
// The CHECK constraint (0035, extended by 0070 for 'sandbox') means the
|
|
18033
|
-
// stored value is always one of these three, so this narrowing is
|
|
18034
|
-
// unreachable in practice and exists to satisfy the type. Note it cannot
|
|
18035
|
-
// degrade *safely* the way `mcpConnections` does: an unreadable value here
|
|
18036
|
-
// would drop a channel back to the unisolated runtime, which is why the
|
|
18037
|
-
// constraint is the real guarantee and this is only a type-level
|
|
18038
|
-
// fallback.
|
|
18039
|
-
runtime: row.runtime === "container" ? "container" : row.runtime === "sandbox" ? "sandbox" : "host",
|
|
18040
|
-
// Same shape and same defensive read as `mcpConnections`: anything that
|
|
18041
|
-
// isn't a clean string array reads as "no mounts", which exposes less
|
|
18042
|
-
// rather than more.
|
|
18043
|
-
mounts: Array.isArray(row.mounts) ? row.mounts.filter((p) => typeof p === "string").map(expandPath) : [],
|
|
18044
|
-
permissionMode: isPermissionMode(row.permission_mode) ? row.permission_mode : null,
|
|
18045
|
-
position: row.position,
|
|
18046
|
-
automations: row.automations ?? void 0,
|
|
18047
|
-
agentName: row.agent_name,
|
|
18048
|
-
dmKey: row.dm_key,
|
|
18049
|
-
isDefault: row.is_default === true,
|
|
18050
|
-
profile: row.profile,
|
|
18051
|
-
archivedAt: row.archived_at,
|
|
18052
|
-
greetedAt: row.greeted_at,
|
|
18053
|
-
createdAt: row.created_at,
|
|
18054
|
-
updatedAt: row.updated_at
|
|
18055
|
-
};
|
|
18056
|
-
}
|
|
18057
|
-
var registry = [];
|
|
18058
|
-
var byId = /* @__PURE__ */ new Map();
|
|
18059
|
-
var byExternalId = /* @__PURE__ */ new Map();
|
|
18060
|
-
var changeListeners = /* @__PURE__ */ new Set();
|
|
18061
|
-
var lastSnapshot;
|
|
18062
|
-
function indexRegistry(list) {
|
|
18063
|
-
registry = list;
|
|
18064
|
-
byId = new Map(list.map((c) => [c.id, c]));
|
|
18065
|
-
byExternalId = new Map(
|
|
18066
|
-
list.filter((c) => !!c.externalChannelId).map((c) => [c.externalChannelId, c])
|
|
18067
|
-
);
|
|
18068
|
-
}
|
|
18069
|
-
async function refreshChannelRegistry() {
|
|
18070
|
-
const rootsBefore = JSON.stringify([...workspaceRoots]);
|
|
18071
|
-
await Promise.all([
|
|
18072
|
-
refreshWorkspaceRoots(),
|
|
18073
|
-
refreshWorkspacePermissionModes(),
|
|
18074
|
-
refreshWorkspaceOwnPersona(),
|
|
18075
|
-
refreshWorkspaceAutoContinueLimits(),
|
|
18076
|
-
refreshWorkspaceAgentDefaults()
|
|
18077
|
-
]);
|
|
18078
|
-
if (JSON.stringify([...workspaceRoots]) !== rootsBefore) lastSnapshot = void 0;
|
|
18079
|
-
const { data, error } = await getSupabaseClient().from("channels").select("*").order("position", { ascending: true });
|
|
18080
|
-
if (error) {
|
|
18081
|
-
console.error("[channels] refreshChannelRegistry failed:", error.message);
|
|
18082
|
-
return;
|
|
18083
|
-
}
|
|
18084
|
-
const rows2 = data ?? [];
|
|
18085
|
-
const snapshot2 = JSON.stringify(
|
|
18086
|
-
rows2,
|
|
18087
|
-
(key, value) => key === "updated_at" || key === "created_at" ? void 0 : value
|
|
18088
|
-
);
|
|
18089
|
-
if (snapshot2 === lastSnapshot) return;
|
|
18090
|
-
lastSnapshot = snapshot2;
|
|
18091
|
-
indexRegistry(rows2.map(rowToChannel));
|
|
18092
|
-
for (const cb of changeListeners) {
|
|
18093
|
-
try {
|
|
18094
|
-
cb();
|
|
18095
|
-
} catch (err) {
|
|
18096
|
-
console.error("[channels] onChannelRegistryChange listener failed:", err);
|
|
18097
|
-
}
|
|
18098
|
-
}
|
|
18099
|
-
}
|
|
18100
|
-
function getChannelRegistry() {
|
|
18101
|
-
return registry;
|
|
18102
|
-
}
|
|
18103
|
-
function getProfileChannelRegistry() {
|
|
18104
|
-
const profile = getProfile();
|
|
18105
|
-
return registry.filter((ch) => ch.profile === profile);
|
|
18106
|
-
}
|
|
18107
|
-
function onChannelRegistryChange(cb) {
|
|
18108
|
-
changeListeners.add(cb);
|
|
18109
|
-
return () => changeListeners.delete(cb);
|
|
18110
|
-
}
|
|
18111
|
-
function findChannelById(id) {
|
|
18112
|
-
return byId.get(id);
|
|
18113
|
-
}
|
|
18114
|
-
function findChannelByExternalId(externalId) {
|
|
18115
|
-
return byExternalId.get(externalId);
|
|
18116
|
-
}
|
|
18117
|
-
function agentDmKey(agentName, userId) {
|
|
18118
|
-
return `agent:${agentName}:${userId}`;
|
|
18119
|
-
}
|
|
18120
|
-
function dmCwd(dmKey, profile = getProfile()) {
|
|
18121
|
-
return `${profile}/dm-${createHash("sha256").update(dmKey).digest("hex").slice(0, 24)}`;
|
|
18122
|
-
}
|
|
18123
|
-
function findChannelByAgentName(agentName, userId) {
|
|
18124
|
-
const dmKey = agentDmKey(agentName, userId);
|
|
18125
|
-
return getProfileChannelRegistry().find((c) => c.agentName === agentName && c.dmKey === dmKey);
|
|
18126
|
-
}
|
|
18127
|
-
function findChannel(ref) {
|
|
18128
|
-
if (!ref) return void 0;
|
|
18129
|
-
return byId.get(ref) ?? byExternalId.get(ref) ?? registry.find((c) => c.name === ref || c.name === ref.replace(/^#/, ""));
|
|
18130
|
-
}
|
|
18131
|
-
var DEFAULT_POLL_INTERVAL_MS = 2e4;
|
|
18132
|
-
var pollTimer;
|
|
18133
|
-
var realtimeChannel;
|
|
18134
|
-
function startChannelRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS) {
|
|
18135
|
-
stopChannelRegistryPolling();
|
|
18136
|
-
pollTimer = setInterval(() => void refreshChannelRegistry(), intervalMs);
|
|
18137
|
-
try {
|
|
18138
|
-
realtimeChannel = getSupabaseClient().channel("channels-registry").on(
|
|
18139
|
-
"postgres_changes",
|
|
18140
|
-
{ event: "*", schema: "public", table: "channels" },
|
|
18141
|
-
() => void refreshChannelRegistry()
|
|
18142
|
-
).subscribe();
|
|
18143
|
-
} catch (err) {
|
|
18144
|
-
console.warn(
|
|
18145
|
-
"[channels] realtime subscribe failed \u2014 falling back to polling only:",
|
|
18146
|
-
err.message
|
|
18147
|
-
);
|
|
18148
|
-
}
|
|
18149
|
-
return stopChannelRegistryPolling;
|
|
18150
|
-
}
|
|
18151
|
-
function stopChannelRegistryPolling() {
|
|
18152
|
-
if (pollTimer) clearInterval(pollTimer);
|
|
18153
|
-
pollTimer = void 0;
|
|
18154
|
-
if (realtimeChannel) {
|
|
18155
|
-
void getSupabaseClient().removeChannel(realtimeChannel);
|
|
18156
|
-
realtimeChannel = void 0;
|
|
18157
|
-
}
|
|
18158
|
-
}
|
|
18159
|
-
function isCwdUsable(cwd) {
|
|
18160
|
-
try {
|
|
18161
|
-
return existsSync(cwd) && statSync(cwd).isDirectory();
|
|
18162
|
-
} catch {
|
|
18163
|
-
return false;
|
|
18164
|
-
}
|
|
18165
|
-
}
|
|
18166
|
-
function auditChannelCwds(list = registry) {
|
|
18167
|
-
return list.filter((ch) => ch.cwd && !isCwdUsable(ch.cwd));
|
|
18168
|
-
}
|
|
18169
|
-
function warnOnBrokenChannelCwds(list = registry) {
|
|
18170
|
-
const broken = auditChannelCwds(list);
|
|
18171
|
-
for (const ch of broken) {
|
|
18172
|
-
console.warn(
|
|
18173
|
-
`[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.`
|
|
18174
|
-
);
|
|
18175
|
-
}
|
|
18176
|
-
return broken;
|
|
18177
|
-
}
|
|
18178
|
-
function resolveChannelCwd(channelId) {
|
|
18179
|
-
if (!channelId) return void 0;
|
|
18180
|
-
const entry = findChannel(channelId);
|
|
18181
|
-
if (!entry?.cwd) return void 0;
|
|
18182
|
-
if (!isCwdUsable(entry.cwd)) {
|
|
18183
|
-
console.warn(
|
|
18184
|
-
`[channels] ${channelId}: cwd "${entry.cwd}" does not exist \u2014 falling back to CLAUDE_CWD`
|
|
18185
|
-
);
|
|
18186
|
-
return void 0;
|
|
18187
|
-
}
|
|
18188
|
-
return entry.cwd;
|
|
18189
|
-
}
|
|
18190
|
-
function isChannelAccessAllowed(channelId, userId) {
|
|
18191
|
-
if (!channelId) return false;
|
|
18192
|
-
const access = findChannel(channelId)?.access;
|
|
18193
|
-
if (!access) return false;
|
|
18194
|
-
if (typeof access === "string") {
|
|
18195
|
-
return access === "open" || access === "*" || access === "all";
|
|
18196
|
-
}
|
|
18197
|
-
return !!userId && access.includes(userId);
|
|
18198
|
-
}
|
|
18199
|
-
function resolveCwd(explicitCwd, channelId, fallback) {
|
|
18200
|
-
if (explicitCwd) return explicitCwd;
|
|
18201
|
-
return resolveChannelCwd(channelId) ?? fallback;
|
|
18202
|
-
}
|
|
18203
|
-
function resolveChannelModel(channelId) {
|
|
18204
|
-
if (!channelId) return void 0;
|
|
18205
|
-
return findChannel(channelId)?.model?.trim() || void 0;
|
|
18206
|
-
}
|
|
18207
|
-
function resolveChannelEffort(channelId) {
|
|
18208
|
-
if (!channelId) return void 0;
|
|
18209
|
-
return findChannel(channelId)?.effort ?? void 0;
|
|
18210
|
-
}
|
|
18211
|
-
function resolveChannelPermissionMode(channelId) {
|
|
18212
|
-
const channel = channelId ? findChannel(channelId) : void 0;
|
|
18213
|
-
return channel?.permissionMode ?? workspacePermissionModes.get(channel?.profile ?? getProfile()) ?? "bypass";
|
|
18214
|
-
}
|
|
18215
|
-
function resolveChannelPrompt(channelId) {
|
|
18216
|
-
if (!channelId) return void 0;
|
|
18217
|
-
return findChannel(channelId)?.prompt?.trim() || void 0;
|
|
18218
|
-
}
|
|
18219
|
-
function resolveModel(explicitModel, channelId, fallback) {
|
|
18220
|
-
if (explicitModel?.trim()) return explicitModel.trim();
|
|
18221
|
-
return resolveChannelModel(channelId) ?? fallback;
|
|
18222
|
-
}
|
|
18223
|
-
function resolveEffort(explicitEffort, channelId, fallback) {
|
|
18224
|
-
if (explicitEffort) return explicitEffort;
|
|
18225
|
-
return resolveChannelEffort(channelId) ?? fallback;
|
|
18226
|
-
}
|
|
18227
|
-
function normaliseTopicCategories(value) {
|
|
18228
|
-
if (!Array.isArray(value)) return [];
|
|
18229
|
-
const out = [];
|
|
18230
|
-
for (const v of value) {
|
|
18231
|
-
const t = typeof v === "string" ? v.trim() : "";
|
|
18232
|
-
if (t && !out.includes(t)) out.push(t);
|
|
18233
|
-
}
|
|
18234
|
-
return out;
|
|
18235
|
-
}
|
|
18236
|
-
function toRow(input) {
|
|
18237
|
-
const row = {};
|
|
18238
|
-
if (input.name !== void 0) row["name"] = input.name;
|
|
18239
|
-
if (input.cwd !== void 0) row["cwd"] = isLogicalCwd(input.cwd) ? input.cwd : toLogicalCwd(expandPath(input.cwd));
|
|
18240
|
-
if (input.categoryId !== void 0) row["category_id"] = input.categoryId;
|
|
18241
|
-
if (input.externalChannelId !== void 0) row["external_channel_id"] = input.externalChannelId;
|
|
18242
|
-
if (input.model !== void 0) row["model"] = input.model;
|
|
18243
|
-
if (input.effort !== void 0) row["effort"] = input.effort;
|
|
18244
|
-
if (input.prompt !== void 0) row["prompt"] = input.prompt?.trim() || null;
|
|
18245
|
-
if (input.topicCategories !== void 0) {
|
|
18246
|
-
const list = normaliseTopicCategories(input.topicCategories);
|
|
18247
|
-
row["topic_categories"] = list.length ? list : null;
|
|
18248
|
-
}
|
|
18249
|
-
if (input.access !== void 0) row["access"] = input.access;
|
|
18250
|
-
if (input.visibility !== void 0) row["visibility"] = input.visibility;
|
|
18251
|
-
if (input.memberEmails !== void 0) {
|
|
18252
|
-
row["member_emails"] = normaliseMemberEmails(input.memberEmails);
|
|
18253
|
-
}
|
|
18254
|
-
if (input.runtime !== void 0) row["runtime"] = input.runtime;
|
|
18255
|
-
if (input.mounts !== void 0) {
|
|
18256
|
-
row["mounts"] = input.mounts.map((p) => p.trim()).filter(Boolean).map(expandPath);
|
|
18257
|
-
}
|
|
18258
|
-
if (input.permissionMode !== void 0) row["permission_mode"] = input.permissionMode;
|
|
18259
|
-
if (input.position !== void 0) row["position"] = input.position;
|
|
18260
|
-
if (input.automations !== void 0) row["automations"] = input.automations;
|
|
18261
|
-
if (input.agentName !== void 0) row["agent_name"] = input.agentName;
|
|
18262
|
-
if (input.dmKey !== void 0) row["dm_key"] = input.dmKey;
|
|
18263
|
-
if (input.isDefault !== void 0) row["is_default"] = input.isDefault;
|
|
18264
|
-
if (input.mcpConnections !== void 0) row["mcp_connections"] = input.mcpConnections;
|
|
18265
|
-
if (input.archivedAt !== void 0) row["archived_at"] = input.archivedAt;
|
|
18266
|
-
return row;
|
|
18267
|
-
}
|
|
18268
|
-
var ChannelCwdError = class extends Error {
|
|
18269
|
-
constructor(message) {
|
|
18270
|
-
super(message);
|
|
18271
|
-
this.name = "ChannelCwdError";
|
|
18272
|
-
}
|
|
18273
|
-
};
|
|
18274
|
-
function realpathOrSelf(p) {
|
|
18275
|
-
try {
|
|
18276
|
-
return realpathSync(p);
|
|
18277
|
-
} catch {
|
|
18278
|
-
return p;
|
|
18279
|
-
}
|
|
18280
|
-
}
|
|
18281
|
-
async function assertCwdInWorkspace(profile, cwd) {
|
|
18282
|
-
if (isLogicalCwd(cwd)) {
|
|
18283
|
-
if (cwd.split("/")[0] !== profile) {
|
|
18284
|
-
throw new ChannelCwdError(`Folder "${cwd}" belongs to another workspace.`);
|
|
18285
|
-
}
|
|
18286
|
-
return cwd;
|
|
18287
|
-
}
|
|
18288
|
-
const logical = relative(logicalRoot(), cwd).split(sep).join("/");
|
|
18289
|
-
if (isLogicalCwd(logical)) return assertCwdInWorkspace(profile, logical);
|
|
18290
|
-
const { data, error } = await getSupabaseClient().from("workspaces").select("slug, root_path");
|
|
18291
|
-
if (error) throw new Error(error.message);
|
|
18292
|
-
const workspaces = data ?? [];
|
|
18293
|
-
const ownRoot = workspaces.find((w) => w.slug === profile)?.root_path;
|
|
18294
|
-
const home = ownRoot?.match(/^(\/Users\/[^/]+|\/home\/[^/]+|\/root)(?=\/|$)/)?.[1];
|
|
18295
|
-
const absolute = home && (cwd === "~" || cwd.startsWith("~/")) ? resolve(home, cwd.slice(2)) : expandPath(cwd);
|
|
18296
|
-
const path = realpathOrSelf(absolute);
|
|
18297
|
-
const roots = workspaces.filter((w) => w.root_path).map((w) => ({ slug: w.slug, root: realpathOrSelf(expandPath(w.root_path)) }));
|
|
18298
|
-
const owner = roots.filter(({ root }) => path === root || path.startsWith(root + sep)).sort((a, b) => b.root.length - a.root.length)[0];
|
|
18299
|
-
if (owner ? owner.slug !== profile : roots.some((r) => r.slug === profile)) {
|
|
18300
|
-
throw new ChannelCwdError(
|
|
18301
|
-
owner ? `Folder "${cwd}" belongs to the "${owner.slug}" workspace.` : `Folder "${cwd}" is outside this workspace's folder.`
|
|
18302
|
-
);
|
|
18303
|
-
}
|
|
18304
|
-
return absolute;
|
|
18305
|
-
}
|
|
18306
|
-
async function createChannel(input) {
|
|
18307
|
-
input = { ...input, cwd: await assertCwdInWorkspace(getProfile(), input.cwd) };
|
|
18308
|
-
const { data, error } = await getSupabaseClient().from("channels").insert({ ...toRow(input), profile: getProfile() }).select().single();
|
|
18309
|
-
if (error) throw new Error(error.message);
|
|
18310
|
-
const channel = rowToChannel(data);
|
|
18311
|
-
if (channel.cwd && !isLogicalCwd(input.cwd) && !isCwdUsable(channel.cwd)) {
|
|
18312
|
-
try {
|
|
18313
|
-
mkdirSync(channel.cwd, { recursive: true });
|
|
18314
|
-
} catch (err) {
|
|
18315
|
-
console.error(`[channels] failed to create cwd for "${channel.name}":`, err.message);
|
|
18316
|
-
}
|
|
18317
|
-
}
|
|
18318
|
-
await refreshChannelRegistry();
|
|
18319
|
-
return channel;
|
|
18320
|
-
}
|
|
18321
|
-
var DefaultChannelError = class extends Error {
|
|
18322
|
-
constructor() {
|
|
18323
|
-
super("The default channel must stay public and cannot be renamed or archived.");
|
|
18324
|
-
this.name = "DefaultChannelError";
|
|
18325
|
-
}
|
|
18326
|
-
};
|
|
18327
|
-
async function updateChannelById(id, patch) {
|
|
18328
|
-
const existing = findChannelById(id);
|
|
18329
|
-
if (existing?.isDefault && (patch.visibility === "private" || patch.archivedAt || patch.isDefault === false || patch.name !== void 0 && patch.name.trim() !== existing.name)) {
|
|
18330
|
-
throw new DefaultChannelError();
|
|
18331
|
-
}
|
|
18332
|
-
if (patch.cwd !== void 0 && existing && patch.cwd === existing.cwd) {
|
|
18333
|
-
const { cwd: _unchanged, ...rest } = patch;
|
|
18334
|
-
patch = rest;
|
|
18335
|
-
}
|
|
18336
|
-
if (patch.cwd !== void 0) {
|
|
18337
|
-
patch = { ...patch, cwd: await assertCwdInWorkspace(existing?.profile ?? getProfile(), patch.cwd) };
|
|
18338
|
-
}
|
|
18339
|
-
const { data, error } = await getSupabaseClient().from("channels").update({ ...toRow(patch), updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).select().single();
|
|
18340
|
-
if (error) throw new Error(error.message);
|
|
18341
|
-
await refreshChannelRegistry();
|
|
18342
|
-
return rowToChannel(data);
|
|
18343
|
-
}
|
|
18344
|
-
async function markChannelGreeted(id) {
|
|
18345
|
-
const { data, error } = await getSupabaseClient().from("channels").update({ greeted_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).is("greeted_at", null).select("id");
|
|
18346
|
-
if (error) throw new Error(error.message);
|
|
18347
|
-
await refreshChannelRegistry();
|
|
18348
|
-
return (data ?? []).length > 0;
|
|
18349
|
-
}
|
|
18350
|
-
async function updateChannelsMcpConnections(updates) {
|
|
18351
|
-
if (!updates.length) return;
|
|
18352
|
-
const supabase = getSupabaseClient();
|
|
18353
|
-
for (const update of updates) {
|
|
18354
|
-
const { error } = await supabase.from("channels").update({ mcp_connections: update.mcpConnections, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", update.id);
|
|
18355
|
-
if (error) throw new Error(`Failed to update channel ${update.id}: ${error.message}`);
|
|
18356
|
-
}
|
|
18357
|
-
await refreshChannelRegistry();
|
|
18358
|
-
}
|
|
18359
|
-
function defaultFallbackCwd() {
|
|
18360
|
-
return process.env["CLAUDE_CWD"] ?? process.cwd();
|
|
18361
|
-
}
|
|
18362
|
-
async function ensureChannelProvisioned(externalChannelId, opts = {}) {
|
|
18363
|
-
const existing = findChannelByExternalId(externalChannelId);
|
|
18364
|
-
if (existing) {
|
|
18365
|
-
if (existing.profile !== getProfile()) return null;
|
|
18366
|
-
if (existing.name === externalChannelId && opts.name && opts.name !== externalChannelId) {
|
|
18367
|
-
try {
|
|
18368
|
-
return await updateChannelById(existing.id, { name: opts.name });
|
|
18369
|
-
} catch (err) {
|
|
18370
|
-
console.error(`[channels] failed to heal name for ${externalChannelId}:`, err);
|
|
18371
|
-
return existing;
|
|
18372
|
-
}
|
|
18373
|
-
}
|
|
18374
|
-
return existing;
|
|
18375
|
-
}
|
|
18376
|
-
try {
|
|
18377
|
-
const created = await createChannel({
|
|
18378
|
-
name: opts.name ?? externalChannelId,
|
|
18379
|
-
cwd: opts.fallbackCwd ?? defaultFallbackCwd(),
|
|
18380
|
-
externalChannelId
|
|
18381
|
-
});
|
|
18382
|
-
console.log(`[channels] auto-provisioned a new channel for Slack channel ${externalChannelId}`);
|
|
18383
|
-
return created;
|
|
18384
|
-
} catch (err) {
|
|
18385
|
-
await refreshChannelRegistry();
|
|
18386
|
-
const raced = findChannelByExternalId(externalChannelId);
|
|
18387
|
-
if (raced) return raced.profile === getProfile() ? raced : null;
|
|
18388
|
-
throw err;
|
|
18389
|
-
}
|
|
18390
|
-
}
|
|
18391
|
-
async function ensureAgentDmChannel(agentName, viewer, opts) {
|
|
18392
|
-
const existing = findChannelByAgentName(agentName, viewer.userId);
|
|
18393
|
-
if (existing) {
|
|
18394
|
-
return existing.name === opts.name ? existing : updateChannelById(existing.id, { name: opts.name });
|
|
18395
|
-
}
|
|
18396
|
-
const dmKey = agentDmKey(agentName, viewer.userId);
|
|
18397
|
-
try {
|
|
18398
|
-
return await createChannel({
|
|
18399
|
-
name: opts.name,
|
|
18400
|
-
cwd: dmCwd(dmKey),
|
|
18401
|
-
visibility: "private",
|
|
18402
|
-
memberEmails: [viewer.email],
|
|
18403
|
-
agentName,
|
|
18404
|
-
dmKey
|
|
18405
|
-
});
|
|
18406
|
-
} catch (err) {
|
|
18407
|
-
await refreshChannelRegistry();
|
|
18408
|
-
const raced = findChannelByAgentName(agentName, viewer.userId);
|
|
18409
|
-
if (raced) return raced;
|
|
18410
|
-
throw err;
|
|
18411
|
-
}
|
|
18412
|
-
}
|
|
18413
|
-
async function ensureGeneralChannel() {
|
|
18414
|
-
const find = () => getProfileChannelRegistry().find((c) => c.isDefault);
|
|
18415
|
-
const existing = find();
|
|
18416
|
-
if (existing) return existing;
|
|
18417
|
-
try {
|
|
18418
|
-
return await createChannel({
|
|
18419
|
-
name: "general",
|
|
18420
|
-
cwd: `${getProfile()}/general`,
|
|
18421
|
-
visibility: "public",
|
|
18422
|
-
isDefault: true
|
|
18423
|
-
});
|
|
18424
|
-
} catch (err) {
|
|
18425
|
-
await refreshChannelRegistry();
|
|
18426
|
-
const raced = find();
|
|
18427
|
-
if (raced) return raced;
|
|
18428
|
-
throw err;
|
|
18429
|
-
}
|
|
18430
|
-
}
|
|
18431
|
-
async function ensureMemberDmChannel(a, b) {
|
|
18432
|
-
const dmKey = [a.userId, b.userId].sort().join(":");
|
|
18433
|
-
const find = () => [...getProfileChannelRegistry()].find((c) => c.dmKey === dmKey && c.profile === getProfile());
|
|
18434
|
-
const existing = find();
|
|
18435
|
-
if (existing) return existing;
|
|
18436
|
-
try {
|
|
18437
|
-
return await createChannel({
|
|
18438
|
-
name: `${a.handle}, ${b.handle}`,
|
|
18439
|
-
// Hash the whole key: a prefix of the sorted ids is just the first user's
|
|
18440
|
-
// id, which put every DM that user sorts first in into one shared folder.
|
|
18441
|
-
cwd: dmCwd(dmKey),
|
|
18442
|
-
visibility: "private",
|
|
18443
|
-
memberEmails: [a.email, b.email],
|
|
18444
|
-
dmKey
|
|
18445
|
-
});
|
|
18446
|
-
} catch (err) {
|
|
18447
|
-
await refreshChannelRegistry();
|
|
18448
|
-
const raced = find();
|
|
18449
|
-
if (raced) return raced;
|
|
18450
|
-
throw err;
|
|
18451
|
-
}
|
|
18452
|
-
}
|
|
18453
|
-
|
|
18454
17913
|
// src/dashboard/channel-destroy-sweep.ts
|
|
18455
17914
|
function watchDestroyedChannels(store) {
|
|
18456
17915
|
let known = new Set(getChannelRegistry().map((c) => c.id));
|
|
@@ -19267,8 +18726,8 @@ async function resolveAuthContextUncached(c) {
|
|
|
19267
18726
|
}
|
|
19268
18727
|
|
|
19269
18728
|
// ../api/src/dashboard/settings.ts
|
|
19270
|
-
import { readFileSync, existsSync
|
|
19271
|
-
import { resolve
|
|
18729
|
+
import { readFileSync, existsSync } from "fs";
|
|
18730
|
+
import { resolve } from "path";
|
|
19272
18731
|
|
|
19273
18732
|
// ../api/src/store/workspace-settings-store.ts
|
|
19274
18733
|
var BRANDING_DEFAULTS = {
|
|
@@ -19381,7 +18840,7 @@ function localDefaults() {
|
|
|
19381
18840
|
}
|
|
19382
18841
|
var AUTO_TITLE_PROMPT_MAX = 2e3;
|
|
19383
18842
|
function readSettingsFile() {
|
|
19384
|
-
if (!
|
|
18843
|
+
if (!existsSync(paths.DASHBOARD_SETTINGS_FILE)) return null;
|
|
19385
18844
|
try {
|
|
19386
18845
|
const raw = JSON.parse(readFileSync(paths.DASHBOARD_SETTINGS_FILE, "utf-8"));
|
|
19387
18846
|
return raw && typeof raw === "object" ? raw : null;
|
|
@@ -19430,15 +18889,15 @@ async function saveWorkspaceBranding(patch, profile = getProfile()) {
|
|
|
19430
18889
|
return brandingToSettings(await upsertWorkspaceBranding(profile, next));
|
|
19431
18890
|
}
|
|
19432
18891
|
function defaultPromptPath() {
|
|
19433
|
-
return
|
|
18892
|
+
return resolve(paths.PACKAGE_ROOT, "system.default.md");
|
|
19434
18893
|
}
|
|
19435
18894
|
function readDefaultPrompt() {
|
|
19436
18895
|
const path = defaultPromptPath();
|
|
19437
|
-
return
|
|
18896
|
+
return existsSync(path) ? readFileSync(path, "utf-8").trim() : "";
|
|
19438
18897
|
}
|
|
19439
18898
|
function loadWorkspacePrompt() {
|
|
19440
18899
|
const defaultPrompt = readDefaultPrompt();
|
|
19441
|
-
const custom =
|
|
18900
|
+
const custom = existsSync(paths.PROMPT_FILE);
|
|
19442
18901
|
return {
|
|
19443
18902
|
prompt: custom ? readFileSync(paths.PROMPT_FILE, "utf-8").trim() : defaultPrompt,
|
|
19444
18903
|
defaultPrompt,
|
|
@@ -19472,9 +18931,9 @@ async function agentViewer(c) {
|
|
|
19472
18931
|
|
|
19473
18932
|
// src/claude/agent.ts
|
|
19474
18933
|
import { spawn } from "child_process";
|
|
19475
|
-
import { existsSync as
|
|
19476
|
-
import { resolve as
|
|
19477
|
-
import { homedir as
|
|
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";
|
|
19478
18937
|
import { randomUUID } from "crypto";
|
|
19479
18938
|
|
|
19480
18939
|
// ../api/src/claude/models.ts
|
|
@@ -19581,12 +19040,12 @@ function modelLabel(value) {
|
|
|
19581
19040
|
|
|
19582
19041
|
// src/claude/container.ts
|
|
19583
19042
|
import { execFileSync } from "child_process";
|
|
19584
|
-
import { createHash
|
|
19585
|
-
import { existsSync as
|
|
19043
|
+
import { createHash } from "crypto";
|
|
19044
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2 } from "fs";
|
|
19586
19045
|
import { join as join2 } from "path";
|
|
19587
19046
|
|
|
19588
19047
|
// src/claude/mounts.ts
|
|
19589
|
-
import { existsSync as
|
|
19048
|
+
import { existsSync as existsSync2, lstatSync, mkdirSync, readlinkSync, symlinkSync, unlinkSync } from "fs";
|
|
19590
19049
|
import { basename, join } from "path";
|
|
19591
19050
|
var MOUNTS_DIR = "mounts";
|
|
19592
19051
|
function resolveMounts(paths2) {
|
|
@@ -19611,11 +19070,11 @@ function materialiseMountLinks(cwd, mounts) {
|
|
|
19611
19070
|
if (mounts.length === 0) return [];
|
|
19612
19071
|
const problems = [];
|
|
19613
19072
|
const root = join(cwd, MOUNTS_DIR);
|
|
19614
|
-
|
|
19073
|
+
mkdirSync(root, { recursive: true });
|
|
19615
19074
|
for (const repo of mounts) {
|
|
19616
19075
|
const link = join(root, repo.name);
|
|
19617
19076
|
try {
|
|
19618
|
-
if (
|
|
19077
|
+
if (existsSync2(link) || isBrokenSymlink(link)) {
|
|
19619
19078
|
if (!lstatSync(link).isSymbolicLink()) {
|
|
19620
19079
|
problems.push(`${link} exists and is not a symlink \u2014 leaving it alone`);
|
|
19621
19080
|
continue;
|
|
@@ -19680,7 +19139,7 @@ function memoryLimit() {
|
|
|
19680
19139
|
return process.env["FLYSPACE_AGENT_MEMORY"]?.trim() || "2g";
|
|
19681
19140
|
}
|
|
19682
19141
|
function containerHomeFor(cwd) {
|
|
19683
|
-
const digest =
|
|
19142
|
+
const digest = createHash("sha256").update(cwd).digest("hex").slice(0, 12);
|
|
19684
19143
|
const label = (cwd.split("/").pop() || "channel").replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 32);
|
|
19685
19144
|
return join2(paths.CONTAINER_HOMES_DIR, `${label}-${digest}`);
|
|
19686
19145
|
}
|
|
@@ -19705,7 +19164,7 @@ function rewriteArgsForContainer(args) {
|
|
|
19705
19164
|
function buildContainerSpawn(input) {
|
|
19706
19165
|
const home = containerHomeFor(input.cwd);
|
|
19707
19166
|
for (const dir of [home, paths.SCRATCH_DIR]) {
|
|
19708
|
-
if (!
|
|
19167
|
+
if (!existsSync3(dir)) mkdirSync2(dir, { recursive: true });
|
|
19709
19168
|
}
|
|
19710
19169
|
const containerName = `flyspace-agent-${input.runId}`;
|
|
19711
19170
|
const env = buildContainerEnv(input.hostEnv);
|
|
@@ -19801,21 +19260,21 @@ function userFlags() {
|
|
|
19801
19260
|
|
|
19802
19261
|
// src/claude/sandbox.ts
|
|
19803
19262
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
19804
|
-
import { createHash as
|
|
19805
|
-
import { existsSync as
|
|
19263
|
+
import { createHash as createHash2 } from "crypto";
|
|
19264
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync } from "fs";
|
|
19806
19265
|
import { join as join3 } from "path";
|
|
19807
19266
|
function sandboxRuntimeEntrypoint() {
|
|
19808
19267
|
return join3(paths.PACKAGE_ROOT, "node_modules/@anthropic-ai/sandbox-runtime/dist/cli.js");
|
|
19809
19268
|
}
|
|
19810
19269
|
function sandboxHomeFor(cwd) {
|
|
19811
|
-
const digest =
|
|
19270
|
+
const digest = createHash2("sha256").update(cwd).digest("hex").slice(0, 12);
|
|
19812
19271
|
const label = (cwd.split("/").pop() || "channel").replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 32);
|
|
19813
19272
|
return join3(paths.SANDBOX_HOMES_DIR, `${label}-${digest}`);
|
|
19814
19273
|
}
|
|
19815
19274
|
function buildSandboxSpawn(input) {
|
|
19816
19275
|
const home = sandboxHomeFor(input.cwd);
|
|
19817
19276
|
for (const dir of [home, paths.SCRATCH_DIR]) {
|
|
19818
|
-
if (!
|
|
19277
|
+
if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
|
|
19819
19278
|
}
|
|
19820
19279
|
const claudeBin = process.env["FLYSPACE_CLAUDE_BIN"]?.trim() || execFileSync2("which", ["claude"]).toString().trim();
|
|
19821
19280
|
const allowRead = [input.cwd, home, paths.SCRATCH_DIR, join3(paths.PACKAGE_ROOT, "node_modules")];
|
|
@@ -19860,7 +19319,7 @@ function buildSandboxSpawn(input) {
|
|
|
19860
19319
|
};
|
|
19861
19320
|
}
|
|
19862
19321
|
function sandboxRuntimeStatus() {
|
|
19863
|
-
if (
|
|
19322
|
+
if (existsSync4(sandboxRuntimeEntrypoint())) return { ok: true };
|
|
19864
19323
|
return {
|
|
19865
19324
|
ok: false,
|
|
19866
19325
|
message: `This channel runs its agent in a sandbox, but \`@anthropic-ai/sandbox-runtime\` is not installed.
|
|
@@ -19899,10 +19358,10 @@ var PluginUiSession = class {
|
|
|
19899
19358
|
onEvent(event) {
|
|
19900
19359
|
if (event.type === "control_response") {
|
|
19901
19360
|
const res = event.response;
|
|
19902
|
-
const
|
|
19903
|
-
if (!
|
|
19361
|
+
const resolve7 = res?.request_id ? this.pending.get(res.request_id) : void 0;
|
|
19362
|
+
if (!resolve7 || !res?.request_id) return;
|
|
19904
19363
|
this.pending.delete(res.request_id);
|
|
19905
|
-
|
|
19364
|
+
resolve7(res.subtype === "success" ? res.response?.tree : void 0);
|
|
19906
19365
|
return;
|
|
19907
19366
|
}
|
|
19908
19367
|
const e = event;
|
|
@@ -19921,8 +19380,8 @@ var PluginUiSession = class {
|
|
|
19921
19380
|
}
|
|
19922
19381
|
render(instanceId) {
|
|
19923
19382
|
const requestId = `flyspace-ui-render-${++this.seq}`;
|
|
19924
|
-
return new Promise((
|
|
19925
|
-
this.pending.set(requestId,
|
|
19383
|
+
return new Promise((resolve7) => {
|
|
19384
|
+
this.pending.set(requestId, resolve7);
|
|
19926
19385
|
this.write({
|
|
19927
19386
|
type: "control_request",
|
|
19928
19387
|
request_id: requestId,
|
|
@@ -19943,11 +19402,11 @@ var PluginUiSession = class {
|
|
|
19943
19402
|
*/
|
|
19944
19403
|
async finish() {
|
|
19945
19404
|
if (this.panes.length) {
|
|
19946
|
-
await new Promise((
|
|
19947
|
-
const timer2 = setTimeout(
|
|
19405
|
+
await new Promise((resolve7) => {
|
|
19406
|
+
const timer2 = setTimeout(resolve7, SETTLE_TIMEOUT_MS);
|
|
19948
19407
|
this.onInvalidate = () => {
|
|
19949
19408
|
clearTimeout(timer2);
|
|
19950
|
-
|
|
19409
|
+
resolve7();
|
|
19951
19410
|
};
|
|
19952
19411
|
});
|
|
19953
19412
|
this.onInvalidate = void 0;
|
|
@@ -19956,8 +19415,8 @@ var PluginUiSession = class {
|
|
|
19956
19415
|
this.panes.map(async (p) => ({ ...p, tree: await this.render(p.id) }))
|
|
19957
19416
|
);
|
|
19958
19417
|
let timer;
|
|
19959
|
-
const timeout = new Promise((
|
|
19960
|
-
timer = setTimeout(() =>
|
|
19418
|
+
const timeout = new Promise((resolve7) => {
|
|
19419
|
+
timer = setTimeout(() => resolve7(void 0), RENDER_TIMEOUT_MS);
|
|
19961
19420
|
});
|
|
19962
19421
|
const rendered = await Promise.race([renders, timeout]);
|
|
19963
19422
|
clearTimeout(timer);
|
|
@@ -20002,9 +19461,9 @@ function readMiseEnv(cwd) {
|
|
|
20002
19461
|
}
|
|
20003
19462
|
|
|
20004
19463
|
// ../api/src/store/output-styles-store.ts
|
|
20005
|
-
import { existsSync as
|
|
20006
|
-
import { homedir
|
|
20007
|
-
import { join as join4, resolve as
|
|
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";
|
|
20008
19467
|
var BUILT_IN_OUTPUT_STYLES = [
|
|
20009
19468
|
{ slug: "default", name: "Default", description: "Claude Code\u2019s standard software engineering prompt." },
|
|
20010
19469
|
{ slug: "proactive", name: "Proactive", description: "Works autonomously and makes reasonable calls instead of asking." },
|
|
@@ -20016,16 +19475,16 @@ var OutputStyleConflictError = class extends Error {
|
|
|
20016
19475
|
};
|
|
20017
19476
|
var ID_RE = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
|
|
20018
19477
|
function resolveDir(claudeConfigDir) {
|
|
20019
|
-
return claudeConfigDir || join4(
|
|
19478
|
+
return claudeConfigDir || join4(homedir(), ".claude");
|
|
20020
19479
|
}
|
|
20021
19480
|
function stylesDir(claudeConfigDir) {
|
|
20022
19481
|
return join4(resolveDir(claudeConfigDir), "output-styles");
|
|
20023
19482
|
}
|
|
20024
19483
|
function styleFile(claudeConfigDir, id) {
|
|
20025
19484
|
if (!ID_RE.test(id)) return null;
|
|
20026
|
-
const dir =
|
|
20027
|
-
const file =
|
|
20028
|
-
return file.startsWith(dir +
|
|
19485
|
+
const dir = resolve2(stylesDir(claudeConfigDir));
|
|
19486
|
+
const file = resolve2(dir, `${id}.md`);
|
|
19487
|
+
return file.startsWith(dir + sep) ? file : null;
|
|
20029
19488
|
}
|
|
20030
19489
|
function slugify(name) {
|
|
20031
19490
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -20067,15 +19526,15 @@ ${p.body.trim()}
|
|
|
20067
19526
|
`;
|
|
20068
19527
|
}
|
|
20069
19528
|
function atomicWrite(file, content) {
|
|
20070
|
-
|
|
19529
|
+
mkdirSync4(resolve2(file, ".."), { recursive: true });
|
|
20071
19530
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
20072
19531
|
writeFileSync2(tmp, content);
|
|
20073
19532
|
renameSync(tmp, file);
|
|
20074
19533
|
}
|
|
20075
19534
|
function readStyle(claudeConfigDir, id) {
|
|
20076
19535
|
const file = styleFile(claudeConfigDir, id);
|
|
20077
|
-
if (!file || !
|
|
20078
|
-
const stat =
|
|
19536
|
+
if (!file || !existsSync5(file)) return null;
|
|
19537
|
+
const stat = statSync(file);
|
|
20079
19538
|
const p = parseStyle(readFileSync2(file, "utf8"), id);
|
|
20080
19539
|
return {
|
|
20081
19540
|
id,
|
|
@@ -20088,7 +19547,7 @@ function readStyle(claudeConfigDir, id) {
|
|
|
20088
19547
|
}
|
|
20089
19548
|
function listOutputStyles(claudeConfigDir) {
|
|
20090
19549
|
const dir = stylesDir(claudeConfigDir);
|
|
20091
|
-
if (!
|
|
19550
|
+
if (!existsSync5(dir)) return [];
|
|
20092
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));
|
|
20093
19552
|
}
|
|
20094
19553
|
function assertNameFree(claudeConfigDir, name, exceptId) {
|
|
@@ -20101,7 +19560,7 @@ function createOutputStyle(claudeConfigDir, params) {
|
|
|
20101
19560
|
if (!id) throw new Error("name must contain letters or digits");
|
|
20102
19561
|
assertNameFree(claudeConfigDir, params.name);
|
|
20103
19562
|
const file = styleFile(claudeConfigDir, id);
|
|
20104
|
-
if (
|
|
19563
|
+
if (existsSync5(file) || BUILT_IN_OUTPUT_STYLES.some((s) => s.slug === id)) {
|
|
20105
19564
|
throw new OutputStyleConflictError(`an output style named "${params.name}" already exists`);
|
|
20106
19565
|
}
|
|
20107
19566
|
atomicWrite(file, serialize({ ...params, extra: [] }));
|
|
@@ -20109,7 +19568,7 @@ function createOutputStyle(claudeConfigDir, params) {
|
|
|
20109
19568
|
}
|
|
20110
19569
|
function updateOutputStyle(claudeConfigDir, id, patch) {
|
|
20111
19570
|
const file = styleFile(claudeConfigDir, id);
|
|
20112
|
-
if (!file || !
|
|
19571
|
+
if (!file || !existsSync5(file)) return null;
|
|
20113
19572
|
const current = parseStyle(readFileSync2(file, "utf8"), id);
|
|
20114
19573
|
if (patch.name !== void 0 && patch.name !== current.name) assertNameFree(claudeConfigDir, patch.name, id);
|
|
20115
19574
|
const next = { ...current, ...patch };
|
|
@@ -20121,7 +19580,7 @@ function updateOutputStyle(claudeConfigDir, id, patch) {
|
|
|
20121
19580
|
}
|
|
20122
19581
|
function deleteOutputStyle(claudeConfigDir, id) {
|
|
20123
19582
|
const file = styleFile(claudeConfigDir, id);
|
|
20124
|
-
if (!file || !
|
|
19583
|
+
if (!file || !existsSync5(file)) return false;
|
|
20125
19584
|
const name = parseStyle(readFileSync2(file, "utf8"), id).name;
|
|
20126
19585
|
rmSync(file);
|
|
20127
19586
|
if (readSettings(claudeConfigDir)["outputStyle"] === name) writeDefaultName(claudeConfigDir, void 0);
|
|
@@ -20132,7 +19591,7 @@ function settingsFile(claudeConfigDir) {
|
|
|
20132
19591
|
}
|
|
20133
19592
|
function readSettings(claudeConfigDir) {
|
|
20134
19593
|
const file = settingsFile(claudeConfigDir);
|
|
20135
|
-
if (!
|
|
19594
|
+
if (!existsSync5(file)) return {};
|
|
20136
19595
|
const parsed = JSON.parse(readFileSync2(file, "utf8"));
|
|
20137
19596
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
20138
19597
|
throw new Error(`${file} is not a JSON object`);
|
|
@@ -20554,7 +20013,7 @@ function interpretCliOutcome(result, resumeSessionId, maxBudgetUsd, model, using
|
|
|
20554
20013
|
const errors = (result.errors ?? []).filter(Boolean).join(", ") || "Unknown error";
|
|
20555
20014
|
return { sessionId, text: `Error: ${errors}`, isError: true };
|
|
20556
20015
|
}
|
|
20557
|
-
var DEFAULT_IDLE_TIMEOUT_SECONDS =
|
|
20016
|
+
var DEFAULT_IDLE_TIMEOUT_SECONDS = 900;
|
|
20558
20017
|
var DEFAULT_MAX_DURATION_SECONDS = 600;
|
|
20559
20018
|
var DEFAULT_STREAMING_MAX_DURATION_SECONDS = 7200;
|
|
20560
20019
|
var KILL_GRACE_MS = 1e4;
|
|
@@ -20576,13 +20035,13 @@ function getMaxDurationMs(streaming) {
|
|
|
20576
20035
|
}
|
|
20577
20036
|
function loadSystemPrompt() {
|
|
20578
20037
|
const customPath = paths.PROMPT_FILE;
|
|
20579
|
-
const defaultPath =
|
|
20580
|
-
const filePath =
|
|
20038
|
+
const defaultPath = resolve3(paths.PACKAGE_ROOT, "system.default.md");
|
|
20039
|
+
const filePath = existsSync6(customPath) ? customPath : defaultPath;
|
|
20581
20040
|
return readFileSync3(filePath, "utf-8").trim();
|
|
20582
20041
|
}
|
|
20583
20042
|
function loadPackagePrompt(file) {
|
|
20584
|
-
const filePath =
|
|
20585
|
-
if (!
|
|
20043
|
+
const filePath = resolve3(paths.PACKAGE_ROOT, file);
|
|
20044
|
+
if (!existsSync6(filePath)) return "";
|
|
20586
20045
|
return readFileSync3(filePath, "utf-8").trim();
|
|
20587
20046
|
}
|
|
20588
20047
|
function loadCapabilities(slackBound) {
|
|
@@ -20647,7 +20106,7 @@ function owningServiceLabel(env = process.env) {
|
|
|
20647
20106
|
return /^[A-Za-z0-9._-]+$/.test(label) ? label : void 0;
|
|
20648
20107
|
}
|
|
20649
20108
|
function buildHookSettings(runtime, builtInStyleName) {
|
|
20650
|
-
const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` :
|
|
20109
|
+
const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` : resolve3(paths.PACKAGE_ROOT, "hooks/bash-guard.mjs");
|
|
20651
20110
|
const selfLabel = runtime === "container" ? void 0 : owningServiceLabel();
|
|
20652
20111
|
const guardEnv = selfLabel ? `FLYSPACE_SELF_SERVICE_LABEL='${selfLabel}' ` : "";
|
|
20653
20112
|
return JSON.stringify({
|
|
@@ -20745,10 +20204,10 @@ function recordUsage2(response, options) {
|
|
|
20745
20204
|
}
|
|
20746
20205
|
function pinnedClaudeConfigDir(dir) {
|
|
20747
20206
|
if (!dir) return void 0;
|
|
20748
|
-
return resolvePath(dir.replace(/^~(?=\/|$)/,
|
|
20207
|
+
return resolvePath(dir.replace(/^~(?=\/|$)/, homedir2())) === resolvePath(homedir2(), ".claude") ? void 0 : dir;
|
|
20749
20208
|
}
|
|
20750
20209
|
function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
|
|
20751
|
-
return new Promise((
|
|
20210
|
+
return new Promise((resolve7, reject) => {
|
|
20752
20211
|
const isolated = options.runtime === "container" || options.runtime === "sandbox";
|
|
20753
20212
|
const args = buildArgs(
|
|
20754
20213
|
prompt,
|
|
@@ -20934,7 +20393,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20934
20393
|
console.log(`[agent] stderr: ${stderr.trim()}`);
|
|
20935
20394
|
}
|
|
20936
20395
|
if (cancelled) {
|
|
20937
|
-
|
|
20396
|
+
resolve7({
|
|
20938
20397
|
sessionId: liveSessionId ?? resumeSessionId ?? "",
|
|
20939
20398
|
text: "",
|
|
20940
20399
|
isCancelled: true
|
|
@@ -20943,7 +20402,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20943
20402
|
}
|
|
20944
20403
|
if (timedOut) {
|
|
20945
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.`;
|
|
20946
|
-
|
|
20405
|
+
resolve7({
|
|
20947
20406
|
sessionId: liveSessionId ?? resumeSessionId ?? "",
|
|
20948
20407
|
text,
|
|
20949
20408
|
isError: true,
|
|
@@ -20981,7 +20440,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20981
20440
|
!!claudeCodeOauthToken
|
|
20982
20441
|
);
|
|
20983
20442
|
recordUsage2(response, options);
|
|
20984
|
-
|
|
20443
|
+
resolve7(
|
|
20985
20444
|
response.isError ? {
|
|
20986
20445
|
...response,
|
|
20987
20446
|
failure: {
|
|
@@ -20999,13 +20458,13 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20999
20458
|
);
|
|
21000
20459
|
} catch {
|
|
21001
20460
|
const fallback = onLine ? "" : stdout.trim();
|
|
21002
|
-
|
|
20461
|
+
resolve7({ sessionId: resumeSessionId ?? "", text: fallback || "No response" });
|
|
21003
20462
|
}
|
|
21004
20463
|
});
|
|
21005
20464
|
});
|
|
21006
20465
|
}
|
|
21007
20466
|
async function askClaude(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
|
|
21008
|
-
if (!
|
|
20467
|
+
if (!existsSync6(cwd) || !statSync2(cwd).isDirectory()) {
|
|
21009
20468
|
console.error(`[agent] working directory does not exist: ${cwd}`);
|
|
21010
20469
|
return {
|
|
21011
20470
|
sessionId: resumeSessionId ?? "",
|
|
@@ -21075,131 +20534,6 @@ Fix the channel's working directory in its settings (or recreate the directory),
|
|
|
21075
20534
|
}
|
|
21076
20535
|
}
|
|
21077
20536
|
|
|
21078
|
-
// ../api/src/store/authors.ts
|
|
21079
|
-
var AGENT_AUTHOR = "agent";
|
|
21080
|
-
var SYNCED_BOT_AUTHOR = "Bot";
|
|
21081
|
-
var LEGACY_BOT_AUTHOR = "Custie";
|
|
21082
|
-
var SUPPORT_BOT_AUTHOR = "Flyspace Support";
|
|
21083
|
-
var NON_HUMAN_AUTHORS = new Set(
|
|
21084
|
-
[AGENT_AUTHOR, SYNCED_BOT_AUTHOR, LEGACY_BOT_AUTHOR, SUPPORT_BOT_AUTHOR].map((a) => a.toLowerCase())
|
|
21085
|
-
);
|
|
21086
|
-
function isHumanAuthor(author) {
|
|
21087
|
-
return !NON_HUMAN_AUTHORS.has(author.toLowerCase());
|
|
21088
|
-
}
|
|
21089
|
-
|
|
21090
|
-
// ../api/src/store/thread-title.ts
|
|
21091
|
-
var TITLE_MAX_LENGTH = 80;
|
|
21092
|
-
function deriveThreadTitle(text) {
|
|
21093
|
-
const firstLine = text.split("\n").find((line) => line.trim().length > 0);
|
|
21094
|
-
if (!firstLine) return null;
|
|
21095
|
-
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();
|
|
21096
|
-
if (!cleaned) return null;
|
|
21097
|
-
return cleaned.length > TITLE_MAX_LENGTH ? `${cleaned.slice(0, TITLE_MAX_LENGTH).trim()}\u2026` : cleaned;
|
|
21098
|
-
}
|
|
21099
|
-
|
|
21100
|
-
// src/store/dashboard-sync.ts
|
|
21101
|
-
async function syncPostToDashboard(opts) {
|
|
21102
|
-
const { channelId, ts: ts3, threadTs, text } = opts;
|
|
21103
|
-
if (!databaseReachable()) {
|
|
21104
|
-
console.warn("[dashboard-sync] Supabase not configured \u2014 skipping dashboard sync");
|
|
21105
|
-
return;
|
|
21106
|
-
}
|
|
21107
|
-
try {
|
|
21108
|
-
const supabase = getSupabaseClient();
|
|
21109
|
-
const dashboardChannelId = await resolveDashboardChannelId(supabase, channelId);
|
|
21110
|
-
const threadId = threadTs ? await ensureThreadId(supabase, channelId, dashboardChannelId, threadTs) : await createOwnThread(supabase, channelId, dashboardChannelId, ts3, text);
|
|
21111
|
-
const { error } = await supabase.from("thread_replies").upsert(
|
|
21112
|
-
{
|
|
21113
|
-
thread_id: threadId,
|
|
21114
|
-
// This mirror only ever runs for the bot's own posts (automation
|
|
21115
|
-
// output, `flyspace slack post`), so the author is the agent itself —
|
|
21116
|
-
// labelling it anything else makes the chat agent count it as a
|
|
21117
|
-
// second human and stop replying without an explicit mention.
|
|
21118
|
-
author: AGENT_AUTHOR,
|
|
21119
|
-
body: await uploadLocalImages(text),
|
|
21120
|
-
external_thread_replies_id: `${channelId}:${ts3}`
|
|
21121
|
-
},
|
|
21122
|
-
{ onConflict: "external_thread_replies_id" }
|
|
21123
|
-
);
|
|
21124
|
-
if (error) {
|
|
21125
|
-
console.warn(`[dashboard-sync] failed to write reply: ${error.message}`);
|
|
21126
|
-
}
|
|
21127
|
-
} catch (err) {
|
|
21128
|
-
console.warn(
|
|
21129
|
-
`[dashboard-sync] sync failed: ${err instanceof Error ? err.message : String(err)}`
|
|
21130
|
-
);
|
|
21131
|
-
}
|
|
21132
|
-
}
|
|
21133
|
-
async function resolveDashboardChannelId(supabase, slackChannelId) {
|
|
21134
|
-
const { data, error } = await supabase.from("channels").select("id").eq("external_channel_id", slackChannelId).maybeSingle();
|
|
21135
|
-
if (error || !data) return slackChannelId;
|
|
21136
|
-
return data["id"];
|
|
21137
|
-
}
|
|
21138
|
-
async function createOwnThread(supabase, externalChannelId, dashboardChannelId, ts3, text) {
|
|
21139
|
-
const { data, error } = await supabase.from("threads").upsert(
|
|
21140
|
-
{
|
|
21141
|
-
channel_id: dashboardChannelId,
|
|
21142
|
-
title: deriveThreadTitle(text),
|
|
21143
|
-
author: AGENT_AUTHOR,
|
|
21144
|
-
external_thread_id: `${externalChannelId}:${ts3}`
|
|
21145
|
-
},
|
|
21146
|
-
{ onConflict: "external_thread_id" }
|
|
21147
|
-
).select("id").single();
|
|
21148
|
-
if (error || !data) throw new Error(error?.message ?? "failed to create thread");
|
|
21149
|
-
return data["id"];
|
|
21150
|
-
}
|
|
21151
|
-
async function ensureThreadId(supabase, externalChannelId, dashboardChannelId, parentTs) {
|
|
21152
|
-
const key = `${externalChannelId}:${parentTs}`;
|
|
21153
|
-
const { data: existing, error: selectError } = await supabase.from("threads").select("id").eq("external_thread_id", key).maybeSingle();
|
|
21154
|
-
if (selectError) throw new Error(selectError.message);
|
|
21155
|
-
if (existing) return existing["id"];
|
|
21156
|
-
const { data: created, error: createError } = await supabase.from("threads").upsert(
|
|
21157
|
-
// The unsynced parent could be anyone's message (often another bot's),
|
|
21158
|
-
// so keep the generic non-human placeholder rather than claiming it.
|
|
21159
|
-
{
|
|
21160
|
-
channel_id: dashboardChannelId,
|
|
21161
|
-
title: null,
|
|
21162
|
-
author: SYNCED_BOT_AUTHOR,
|
|
21163
|
-
external_thread_id: key
|
|
21164
|
-
},
|
|
21165
|
-
{ onConflict: "external_thread_id" }
|
|
21166
|
-
).select("id").single();
|
|
21167
|
-
if (createError || !created) {
|
|
21168
|
-
throw new Error(createError?.message ?? "failed to create placeholder thread");
|
|
21169
|
-
}
|
|
21170
|
-
return created["id"];
|
|
21171
|
-
}
|
|
21172
|
-
|
|
21173
|
-
// src/store/dashboard-post.ts
|
|
21174
|
-
async function postToDashboardChannel(opts) {
|
|
21175
|
-
const { channelId, text, threadId, title } = opts;
|
|
21176
|
-
const supabase = getSupabaseClient();
|
|
21177
|
-
if (!threadId && !channelId) {
|
|
21178
|
-
throw new Error("postToDashboardChannel: channelId is required to start a new thread");
|
|
21179
|
-
}
|
|
21180
|
-
const parentId = threadId ?? await createThread(supabase, channelId, text, title);
|
|
21181
|
-
const body = await uploadLocalImages(text);
|
|
21182
|
-
const { data, error } = await supabase.from("thread_replies").insert({ thread_id: parentId, author: AGENT_AUTHOR, body }).select("id").single();
|
|
21183
|
-
if (error || !data) {
|
|
21184
|
-
throw new Error(`failed to write dashboard reply: ${error?.message ?? "no row returned"}`);
|
|
21185
|
-
}
|
|
21186
|
-
return { threadId: parentId, replyId: data["id"] };
|
|
21187
|
-
}
|
|
21188
|
-
async function createThread(supabase, channelId, text, title) {
|
|
21189
|
-
const { data, error } = await supabase.from("threads").insert({
|
|
21190
|
-
channel_id: channelId,
|
|
21191
|
-
// An untitled thread is effectively invisible in the sidebar, so give a
|
|
21192
|
-
// daily report the same first-line-derived title a mirrored post gets,
|
|
21193
|
-
// unless the caller named the thread itself.
|
|
21194
|
-
title: title?.trim().replace(/\\([\\`*_{}[\]()#+\-.!~>|])/g, "$1") || deriveThreadTitle(text),
|
|
21195
|
-
author: AGENT_AUTHOR
|
|
21196
|
-
}).select("id").single();
|
|
21197
|
-
if (error || !data) {
|
|
21198
|
-
throw new Error(`failed to create dashboard thread: ${error?.message ?? "no row returned"}`);
|
|
21199
|
-
}
|
|
21200
|
-
return data["id"];
|
|
21201
|
-
}
|
|
21202
|
-
|
|
21203
20537
|
// src/automations/scheduler.ts
|
|
21204
20538
|
import cron2 from "node-cron";
|
|
21205
20539
|
import { CronExpressionParser } from "cron-parser";
|
|
@@ -21241,8 +20575,8 @@ function automationToRow(type, item, position) {
|
|
|
21241
20575
|
};
|
|
21242
20576
|
}
|
|
21243
20577
|
var rows = [];
|
|
21244
|
-
var
|
|
21245
|
-
var
|
|
20578
|
+
var changeListeners = /* @__PURE__ */ new Set();
|
|
20579
|
+
var lastSnapshot;
|
|
21246
20580
|
async function refreshAutomationRegistry() {
|
|
21247
20581
|
const { data, error } = await getSupabaseClient().from("automations").select("*").order("position", { ascending: true });
|
|
21248
20582
|
if (error) {
|
|
@@ -21251,10 +20585,10 @@ async function refreshAutomationRegistry() {
|
|
|
21251
20585
|
}
|
|
21252
20586
|
const next = data ?? [];
|
|
21253
20587
|
const snapshot2 = JSON.stringify(next, (key, value) => key === "updated_at" ? void 0 : value);
|
|
21254
|
-
if (snapshot2 ===
|
|
21255
|
-
|
|
20588
|
+
if (snapshot2 === lastSnapshot) return;
|
|
20589
|
+
lastSnapshot = snapshot2;
|
|
21256
20590
|
rows = next;
|
|
21257
|
-
for (const cb of
|
|
20591
|
+
for (const cb of changeListeners) {
|
|
21258
20592
|
try {
|
|
21259
20593
|
cb();
|
|
21260
20594
|
} catch (err) {
|
|
@@ -21263,8 +20597,8 @@ async function refreshAutomationRegistry() {
|
|
|
21263
20597
|
}
|
|
21264
20598
|
}
|
|
21265
20599
|
function onAutomationRegistryChange(cb) {
|
|
21266
|
-
|
|
21267
|
-
return () =>
|
|
20600
|
+
changeListeners.add(cb);
|
|
20601
|
+
return () => changeListeners.delete(cb);
|
|
21268
20602
|
}
|
|
21269
20603
|
function profileRows() {
|
|
21270
20604
|
const profile = getProfile();
|
|
@@ -21320,14 +20654,14 @@ async function setAutomationEnabled(name, enabled) {
|
|
|
21320
20654
|
if (error) throw new Error(`Failed to update automation "${name}": ${error.message}`);
|
|
21321
20655
|
await refreshAutomationRegistry();
|
|
21322
20656
|
}
|
|
21323
|
-
var
|
|
21324
|
-
var
|
|
21325
|
-
var
|
|
21326
|
-
function startAutomationRegistryPolling(intervalMs =
|
|
20657
|
+
var DEFAULT_POLL_INTERVAL_MS = 2e4;
|
|
20658
|
+
var pollTimer;
|
|
20659
|
+
var realtimeChannel;
|
|
20660
|
+
function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS) {
|
|
21327
20661
|
stopAutomationRegistryPolling();
|
|
21328
|
-
|
|
20662
|
+
pollTimer = setInterval(() => void refreshAutomationRegistry(), intervalMs);
|
|
21329
20663
|
try {
|
|
21330
|
-
|
|
20664
|
+
realtimeChannel = getSupabaseClient().channel("automations-registry").on(
|
|
21331
20665
|
"postgres_changes",
|
|
21332
20666
|
{ event: "*", schema: "public", table: "automations" },
|
|
21333
20667
|
() => void refreshAutomationRegistry()
|
|
@@ -21341,11 +20675,11 @@ function startAutomationRegistryPolling(intervalMs = DEFAULT_POLL_INTERVAL_MS2)
|
|
|
21341
20675
|
return stopAutomationRegistryPolling;
|
|
21342
20676
|
}
|
|
21343
20677
|
function stopAutomationRegistryPolling() {
|
|
21344
|
-
if (
|
|
21345
|
-
|
|
21346
|
-
if (
|
|
21347
|
-
void getSupabaseClient().removeChannel(
|
|
21348
|
-
|
|
20678
|
+
if (pollTimer) clearInterval(pollTimer);
|
|
20679
|
+
pollTimer = void 0;
|
|
20680
|
+
if (realtimeChannel) {
|
|
20681
|
+
void getSupabaseClient().removeChannel(realtimeChannel);
|
|
20682
|
+
realtimeChannel = void 0;
|
|
21349
20683
|
}
|
|
21350
20684
|
}
|
|
21351
20685
|
|
|
@@ -21790,9 +21124,9 @@ async function runCompanion(config, userId, slot) {
|
|
|
21790
21124
|
|
|
21791
21125
|
// src/commands/persona.ts
|
|
21792
21126
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
21793
|
-
import { createHash as
|
|
21794
|
-
import { existsSync as
|
|
21795
|
-
import { homedir as
|
|
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";
|
|
21796
21130
|
import { basename as basename2, join as join6 } from "path";
|
|
21797
21131
|
import sharp from "sharp";
|
|
21798
21132
|
var USAGE = `
|
|
@@ -21825,8 +21159,8 @@ var PACKS = {
|
|
|
21825
21159
|
}
|
|
21826
21160
|
};
|
|
21827
21161
|
function pluginInstalled() {
|
|
21828
|
-
const claudeDir = process.env["CLAUDE_CONFIG_DIR"] || join6(
|
|
21829
|
-
return
|
|
21162
|
+
const claudeDir = process.env["CLAUDE_CONFIG_DIR"] || join6(homedir3(), ".claude");
|
|
21163
|
+
return existsSync7(join6(claudeDir, "plugins", "cache", "claudecafe", "persona-panel"));
|
|
21830
21164
|
}
|
|
21831
21165
|
function installPack(root, character) {
|
|
21832
21166
|
const pack = PACKS[character];
|
|
@@ -21837,18 +21171,18 @@ function installPack(root, character) {
|
|
|
21837
21171
|
try {
|
|
21838
21172
|
const zip = join6(staging, "pack.zip");
|
|
21839
21173
|
execFileSync4("curl", ["-fsSL", "--max-time", "60", "-o", zip, pack.url]);
|
|
21840
|
-
const digest =
|
|
21174
|
+
const digest = createHash3("sha256").update(readFileSync4(zip)).digest("hex");
|
|
21841
21175
|
if (digest !== pack.sha256) throw new Error(`${character} pack SHA-256 mismatch`);
|
|
21842
21176
|
execFileSync4("unzip", ["-q", zip, "-d", staging]);
|
|
21843
21177
|
const folder = join6(charactersDir, character);
|
|
21844
|
-
if (
|
|
21178
|
+
if (existsSync7(folder)) renameSync2(folder, join6(staging, "previous"));
|
|
21845
21179
|
renameSync2(join6(staging, character), folder);
|
|
21846
21180
|
} finally {
|
|
21847
21181
|
rmSync3(staging, { recursive: true, force: true });
|
|
21848
21182
|
}
|
|
21849
21183
|
}
|
|
21850
21184
|
function cafeRoot() {
|
|
21851
|
-
return join6(process.env["XDG_CONFIG_HOME"] || join6(
|
|
21185
|
+
return join6(process.env["XDG_CONFIG_HOME"] || join6(homedir3(), ".config"), "claudecafe");
|
|
21852
21186
|
}
|
|
21853
21187
|
function configuredCharacter(root) {
|
|
21854
21188
|
try {
|
|
@@ -21880,7 +21214,7 @@ async function syncPersonaAvatars(profile, requested) {
|
|
|
21880
21214
|
const root = cafeRoot();
|
|
21881
21215
|
const character = requested || configuredCharacter(root);
|
|
21882
21216
|
const dir = join6(root, "characters", character, "avatars");
|
|
21883
|
-
if (!
|
|
21217
|
+
if (!existsSync7(dir)) installPack(root, character);
|
|
21884
21218
|
const avatars = {};
|
|
21885
21219
|
for (const file of readdirSync2(dir).filter((f) => f.endsWith(".webp"))) {
|
|
21886
21220
|
const image = await sharp(join6(dir, file)).resize({ width: AVATAR_SIZE, height: AVATAR_SIZE, fit: "cover", position: "top" }).webp({ quality: 80 }).toBuffer();
|
|
@@ -21989,7 +21323,13 @@ var featureFlags = {
|
|
|
21989
21323
|
},
|
|
21990
21324
|
"voice-guide": {
|
|
21991
21325
|
title: "Voice guide",
|
|
21992
|
-
description: "Support walks you through the UI: a Show me button under @support answers that opens the right page and spotlights what to click
|
|
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.',
|
|
21993
21333
|
stage: "beta",
|
|
21994
21334
|
operatorOnly: true
|
|
21995
21335
|
}
|
|
@@ -22387,7 +21727,7 @@ async function buildPrompt(profile, channelId, opts) {
|
|
|
22387
21727
|
}
|
|
22388
21728
|
|
|
22389
21729
|
// src/dashboard/settings-host.ts
|
|
22390
|
-
import { writeFileSync as writeFileSync4, existsSync as
|
|
21730
|
+
import { writeFileSync as writeFileSync4, existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync5, rmSync as rmSync4 } from "fs";
|
|
22391
21731
|
import { dirname } from "path";
|
|
22392
21732
|
|
|
22393
21733
|
// ../api/src/dashboard/auto-title.ts
|
|
@@ -22549,7 +21889,7 @@ function parseAgentProfiles(raw) {
|
|
|
22549
21889
|
return entries2.length > 0 ? Object.fromEntries(entries2) : void 0;
|
|
22550
21890
|
}
|
|
22551
21891
|
function loadDashboardSettings() {
|
|
22552
|
-
if (!
|
|
21892
|
+
if (!existsSync8(paths.DASHBOARD_SETTINGS_FILE)) return localDefaults();
|
|
22553
21893
|
try {
|
|
22554
21894
|
const raw = JSON.parse(readFileSync5(paths.DASHBOARD_SETTINGS_FILE, "utf-8"));
|
|
22555
21895
|
const providers = parseProviders(raw.providers, {
|
|
@@ -22578,7 +21918,7 @@ function withFallbackModel(providers, model) {
|
|
|
22578
21918
|
return [cleared[0], { runner, model }, ...cleared.slice(1).filter((p) => p.runner !== runner)];
|
|
22579
21919
|
}
|
|
22580
21920
|
function writeSettings(next) {
|
|
22581
|
-
|
|
21921
|
+
mkdirSync5(dirname(paths.DASHBOARD_SETTINGS_FILE), { recursive: true });
|
|
22582
21922
|
const merged = { ...readSettingsFile() ?? {}, ...next };
|
|
22583
21923
|
writeFileSync4(paths.DASHBOARD_SETTINGS_FILE, JSON.stringify(merged, null, 2), "utf-8");
|
|
22584
21924
|
return next;
|
|
@@ -22614,7 +21954,7 @@ async function loadFullDashboardSettings(profile = getProfile()) {
|
|
|
22614
21954
|
function saveWorkspacePrompt(prompt) {
|
|
22615
21955
|
const trimmed = prompt.trim();
|
|
22616
21956
|
if (!trimmed || trimmed === loadWorkspacePrompt().defaultPrompt) return resetWorkspacePrompt();
|
|
22617
|
-
|
|
21957
|
+
mkdirSync5(dirname(paths.PROMPT_FILE), { recursive: true });
|
|
22618
21958
|
writeFileSync4(paths.PROMPT_FILE, `${trimmed}
|
|
22619
21959
|
`, "utf-8");
|
|
22620
21960
|
return loadWorkspacePrompt();
|
|
@@ -22645,7 +21985,7 @@ function saveAgentProfile(name, patch) {
|
|
|
22645
21985
|
|
|
22646
21986
|
// ../api/src/codex/agent.ts
|
|
22647
21987
|
import { spawn as spawn2 } from "child_process";
|
|
22648
|
-
import { existsSync as
|
|
21988
|
+
import { existsSync as existsSync9, mkdtempSync as mkdtempSync3, readFileSync as readFileSync6, rmSync as rmSync5, statSync as statSync3 } from "fs";
|
|
22649
21989
|
import { tmpdir as tmpdir2 } from "os";
|
|
22650
21990
|
import { join as join7 } from "path";
|
|
22651
21991
|
var AUTH_ERROR_PATTERNS2 = [
|
|
@@ -22779,7 +22119,7 @@ function getMaxDurationMs2() {
|
|
|
22779
22119
|
function codexAuthAvailable(env = process.env) {
|
|
22780
22120
|
if (env["OPENAI_API_KEY"]?.trim()) return true;
|
|
22781
22121
|
const home = env["CODEX_HOME"]?.trim() || join7(env["HOME"] ?? "", ".codex");
|
|
22782
|
-
return
|
|
22122
|
+
return existsSync9(join7(home, "auth.json"));
|
|
22783
22123
|
}
|
|
22784
22124
|
function applySystemPrompt(prompt, options, resumeSessionId) {
|
|
22785
22125
|
if (resumeSessionId || !options.systemPrompt?.trim()) return prompt;
|
|
@@ -22828,10 +22168,10 @@ function recordCodexUsage(response, options) {
|
|
|
22828
22168
|
});
|
|
22829
22169
|
}
|
|
22830
22170
|
function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
22831
|
-
return new Promise((
|
|
22171
|
+
return new Promise((resolve7, reject) => {
|
|
22832
22172
|
const finish = (response) => {
|
|
22833
22173
|
recordCodexUsage(response, options);
|
|
22834
|
-
|
|
22174
|
+
resolve7(response);
|
|
22835
22175
|
};
|
|
22836
22176
|
const scratch = mkdtempSync3(join7(tmpdir2(), "flyspace-codex-"));
|
|
22837
22177
|
const lastMessageFile = join7(scratch, "last-message.txt");
|
|
@@ -22987,7 +22327,7 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
|
22987
22327
|
});
|
|
22988
22328
|
}
|
|
22989
22329
|
async function askCodex(prompt, cwd, options = {}, resumeSessionId) {
|
|
22990
|
-
if (!
|
|
22330
|
+
if (!existsSync9(cwd) || !statSync3(cwd).isDirectory()) {
|
|
22991
22331
|
console.error(`[codex] working directory does not exist: ${cwd}`);
|
|
22992
22332
|
return {
|
|
22993
22333
|
sessionId: resumeSessionId ?? "",
|
|
@@ -23435,12 +22775,12 @@ function renderAsciiTable(t) {
|
|
|
23435
22775
|
(h, i) => Math.max(h.length, ...rows2.map((r) => (r[i] || "").length))
|
|
23436
22776
|
);
|
|
23437
22777
|
const fmt = (cells) => "| " + cells.map((c, i) => c.padEnd(widths[i])).join(" | ") + " |";
|
|
23438
|
-
const
|
|
23439
|
-
return [fmt(headers),
|
|
22778
|
+
const sep4 = "|" + widths.map((w) => "-".repeat(w + 2)).join("|") + "|";
|
|
22779
|
+
return [fmt(headers), sep4, ...rows2.map(fmt)].join("\n");
|
|
23440
22780
|
}
|
|
23441
22781
|
|
|
23442
22782
|
// src/store/channel-cache.ts
|
|
23443
|
-
import { mkdirSync as
|
|
22783
|
+
import { mkdirSync as mkdirSync6 } from "fs";
|
|
23444
22784
|
|
|
23445
22785
|
// src/store/sqlite.ts
|
|
23446
22786
|
import Database from "better-sqlite3";
|
|
@@ -23464,7 +22804,7 @@ function getDb() {
|
|
|
23464
22804
|
const file = paths.DB_FILE;
|
|
23465
22805
|
const existing = dbs.get(file);
|
|
23466
22806
|
if (existing) return existing;
|
|
23467
|
-
|
|
22807
|
+
mkdirSync6(paths.DATA_DIR, { recursive: true });
|
|
23468
22808
|
const db = openLocalDatabase(file);
|
|
23469
22809
|
if (!db) return null;
|
|
23470
22810
|
db.exec(`
|
|
@@ -23680,7 +23020,7 @@ var DEFAULT_TIMEOUT_MS = 12e4;
|
|
|
23680
23020
|
var KILL_GRACE_MS3 = 5e3;
|
|
23681
23021
|
function runScriptAutomation(opts) {
|
|
23682
23022
|
const { name, script, cwd, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
|
|
23683
|
-
return new Promise((
|
|
23023
|
+
return new Promise((resolve7, reject) => {
|
|
23684
23024
|
const [cmd, args] = isExecutable(script) ? [script, []] : ["/bin/bash", [script]];
|
|
23685
23025
|
const child = spawn3(cmd, args, { cwd, env: resolveMiseEnv(cwd), stdio: ["ignore", "pipe", "pipe"] });
|
|
23686
23026
|
let stdout = "";
|
|
@@ -23716,7 +23056,7 @@ function runScriptAutomation(opts) {
|
|
|
23716
23056
|
} else if (code !== 0) {
|
|
23717
23057
|
reject(new Error(`script exited with code ${code}: ${stderr.trim()}`));
|
|
23718
23058
|
} else {
|
|
23719
|
-
|
|
23059
|
+
resolve7();
|
|
23720
23060
|
}
|
|
23721
23061
|
});
|
|
23722
23062
|
});
|
|
@@ -23990,11 +23330,11 @@ var TriggerEngine = class {
|
|
|
23990
23330
|
};
|
|
23991
23331
|
|
|
23992
23332
|
// src/store/user-cache.ts
|
|
23993
|
-
import { existsSync as
|
|
23333
|
+
import { existsSync as existsSync10, readFileSync as readFileSync7 } from "fs";
|
|
23994
23334
|
import { join as join8 } from "path";
|
|
23995
23335
|
function jsonUserCachePath() {
|
|
23996
23336
|
const file = join8(paths.CONFIG_DIR, "slack_users.json");
|
|
23997
|
-
return
|
|
23337
|
+
return existsSync10(file) ? file : void 0;
|
|
23998
23338
|
}
|
|
23999
23339
|
function readJsonUserCache() {
|
|
24000
23340
|
const file = jsonUserCachePath();
|
|
@@ -24298,15 +23638,19 @@ function initAutomations(slackClient, config, runStore) {
|
|
|
24298
23638
|
for (const schedule of automations.schedules) {
|
|
24299
23639
|
if (!schedule.enabled) continue;
|
|
24300
23640
|
if (schedule.script) {
|
|
24301
|
-
scheduler.register(
|
|
24302
|
-
|
|
24303
|
-
|
|
24304
|
-
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
|
|
24309
|
-
|
|
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
|
+
});
|
|
24310
23654
|
continue;
|
|
24311
23655
|
}
|
|
24312
23656
|
scheduler.register(
|
|
@@ -24354,6 +23698,33 @@ function initAutomations(slackClient, config, runStore) {
|
|
|
24354
23698
|
}
|
|
24355
23699
|
};
|
|
24356
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
|
+
}
|
|
24357
23728
|
|
|
24358
23729
|
// src/slack/app.ts
|
|
24359
23730
|
import { App } from "@slack/bolt";
|
|
@@ -24392,8 +23763,8 @@ var MessageQueue = class {
|
|
|
24392
23763
|
const chains = Array.from(this.chains.values());
|
|
24393
23764
|
if (chains.length === 0) return true;
|
|
24394
23765
|
let timer;
|
|
24395
|
-
const timeout = new Promise((
|
|
24396
|
-
timer = setTimeout(() =>
|
|
23766
|
+
const timeout = new Promise((resolve7) => {
|
|
23767
|
+
timer = setTimeout(() => resolve7(false), timeoutMs);
|
|
24397
23768
|
});
|
|
24398
23769
|
const done = Promise.all(chains).then(() => true);
|
|
24399
23770
|
const result = await Promise.race([done, timeout]);
|
|
@@ -24970,7 +24341,7 @@ async function summariseThreadTranscript(transcript, opts, deps = {}) {
|
|
|
24970
24341
|
}
|
|
24971
24342
|
|
|
24972
24343
|
// src/dashboard/chat-agent.ts
|
|
24973
|
-
import { homedir as
|
|
24344
|
+
import { homedir as homedir8 } from "os";
|
|
24974
24345
|
import { stripVTControlCharacters } from "util";
|
|
24975
24346
|
|
|
24976
24347
|
// src/mcp/config.ts
|
|
@@ -25098,7 +24469,7 @@ function secretsMatch(a, b) {
|
|
|
25098
24469
|
}
|
|
25099
24470
|
|
|
25100
24471
|
// ../api/src/mcp/oauth.ts
|
|
25101
|
-
import { createHash as
|
|
24472
|
+
import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
|
|
25102
24473
|
var RESERVED_AUTHORIZE_PARAMS = /* @__PURE__ */ new Set([
|
|
25103
24474
|
"client_id",
|
|
25104
24475
|
"redirect_uri",
|
|
@@ -25116,7 +24487,7 @@ function createStateToken() {
|
|
|
25116
24487
|
}
|
|
25117
24488
|
function createPkcePair() {
|
|
25118
24489
|
const verifier = base64url(randomBytes2(32));
|
|
25119
|
-
const challenge = base64url(
|
|
24490
|
+
const challenge = base64url(createHash4("sha256").update(verifier).digest());
|
|
25120
24491
|
return { verifier, challenge };
|
|
25121
24492
|
}
|
|
25122
24493
|
function clientEnvName(providerSlug, suffix) {
|
|
@@ -25485,7 +24856,7 @@ function needsRefresh(expiresAt, now = Date.now()) {
|
|
|
25485
24856
|
if (!expiresAt) return false;
|
|
25486
24857
|
return new Date(expiresAt).getTime() - now < REFRESH_SKEW_MS;
|
|
25487
24858
|
}
|
|
25488
|
-
var sleep = (ms) => new Promise((
|
|
24859
|
+
var sleep = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
25489
24860
|
async function refreshConnection(params) {
|
|
25490
24861
|
const { workspaceId, connection, provider } = params;
|
|
25491
24862
|
const deps = params.deps ?? {};
|
|
@@ -25612,12 +24983,12 @@ async function buildMcpConfig(profile, connectionIds) {
|
|
|
25612
24983
|
if (!connectionIds.length) return { config, skipped };
|
|
25613
24984
|
const workspace = await getWorkspaceBySlug(profile);
|
|
25614
24985
|
if (!workspace) return { config, skipped };
|
|
25615
|
-
const
|
|
24986
|
+
const byId = new Map(
|
|
25616
24987
|
(await listMcpConnections(workspace.id)).map((connection) => [connection.id, connection])
|
|
25617
24988
|
);
|
|
25618
24989
|
const workspaceId = workspace.id;
|
|
25619
24990
|
for (const id of connectionIds) {
|
|
25620
|
-
const connection =
|
|
24991
|
+
const connection = byId.get(id);
|
|
25621
24992
|
if (!connection) {
|
|
25622
24993
|
continue;
|
|
25623
24994
|
}
|
|
@@ -25686,7 +25057,7 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
|
|
|
25686
25057
|
|
|
25687
25058
|
// ../api/src/version.ts
|
|
25688
25059
|
import { readFileSync as readFileSync8 } from "fs";
|
|
25689
|
-
var CLI_VERSION = true ? "0.1.
|
|
25060
|
+
var CLI_VERSION = true ? "0.1.67" : devVersion();
|
|
25690
25061
|
function isOlderVersion(a, b) {
|
|
25691
25062
|
const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
|
|
25692
25063
|
const [pa, pb] = [parse2(a), parse2(b)];
|
|
@@ -25709,39 +25080,39 @@ async function latestCliVersion() {
|
|
|
25709
25080
|
}
|
|
25710
25081
|
|
|
25711
25082
|
// src/claude/agents.ts
|
|
25712
|
-
import { existsSync as
|
|
25713
|
-
import { homedir as
|
|
25083
|
+
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
|
|
25084
|
+
import { homedir as homedir6 } from "os";
|
|
25714
25085
|
import { basename as basename4, join as join13 } from "path";
|
|
25715
25086
|
import yaml3 from "js-yaml";
|
|
25716
25087
|
|
|
25717
25088
|
// ../api/src/claude/skills.ts
|
|
25718
|
-
import { existsSync as
|
|
25719
|
-
import { homedir as
|
|
25089
|
+
import { existsSync as existsSync12, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
|
|
25090
|
+
import { homedir as homedir5 } from "os";
|
|
25720
25091
|
import { basename as basename3, dirname as dirname2, join as join12 } from "path";
|
|
25721
25092
|
import yaml2 from "js-yaml";
|
|
25722
25093
|
|
|
25723
25094
|
// ../api/src/claude/skill-files.ts
|
|
25724
25095
|
import {
|
|
25725
|
-
existsSync as
|
|
25726
|
-
mkdirSync as
|
|
25096
|
+
existsSync as existsSync11,
|
|
25097
|
+
mkdirSync as mkdirSync7,
|
|
25727
25098
|
readFileSync as readFileSync9,
|
|
25728
25099
|
readdirSync as readdirSync3,
|
|
25729
25100
|
rmSync as rmSync7,
|
|
25730
|
-
statSync as
|
|
25101
|
+
statSync as statSync4,
|
|
25731
25102
|
writeFileSync as writeFileSync6
|
|
25732
25103
|
} from "fs";
|
|
25733
|
-
import { homedir as
|
|
25734
|
-
import { join as join11, resolve as
|
|
25104
|
+
import { homedir as homedir4 } from "os";
|
|
25105
|
+
import { join as join11, resolve as resolve4, sep as sep2 } from "path";
|
|
25735
25106
|
import yaml from "js-yaml";
|
|
25736
25107
|
var MAX_SKILL_BYTES = 2 * 1024 * 1024;
|
|
25737
25108
|
var SKILL_NAME = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
25738
25109
|
function expandHome(p) {
|
|
25739
|
-
if (p === "~") return
|
|
25740
|
-
if (p.startsWith("~/")) return join11(
|
|
25110
|
+
if (p === "~") return homedir4();
|
|
25111
|
+
if (p.startsWith("~/")) return join11(homedir4(), p.slice(2));
|
|
25741
25112
|
return p;
|
|
25742
25113
|
}
|
|
25743
25114
|
function workspaceSkillsDir(configDir) {
|
|
25744
|
-
return join11(configDir ? expandHome(configDir) : join11(
|
|
25115
|
+
return join11(configDir ? expandHome(configDir) : join11(homedir4(), ".claude"), "skills");
|
|
25745
25116
|
}
|
|
25746
25117
|
function channelSkillsDir(cwd) {
|
|
25747
25118
|
return join11(cwd, ".claude", "skills");
|
|
@@ -25751,8 +25122,8 @@ function isValidSkillName(name) {
|
|
|
25751
25122
|
}
|
|
25752
25123
|
function resolveSkillPath(dir, name) {
|
|
25753
25124
|
if (!isValidSkillName(name)) return null;
|
|
25754
|
-
const abs =
|
|
25755
|
-
if (!abs.startsWith(
|
|
25125
|
+
const abs = resolve4(dir, name, "SKILL.md");
|
|
25126
|
+
if (!abs.startsWith(resolve4(dir) + sep2)) return null;
|
|
25756
25127
|
return abs;
|
|
25757
25128
|
}
|
|
25758
25129
|
function splitFrontmatter(raw) {
|
|
@@ -25789,7 +25160,7 @@ function readMeta(abs) {
|
|
|
25789
25160
|
}
|
|
25790
25161
|
}
|
|
25791
25162
|
function listSkillFiles(dir) {
|
|
25792
|
-
if (!
|
|
25163
|
+
if (!existsSync11(dir)) return [];
|
|
25793
25164
|
let entries2;
|
|
25794
25165
|
try {
|
|
25795
25166
|
entries2 = readdirSync3(dir);
|
|
@@ -25802,7 +25173,7 @@ function listSkillFiles(dir) {
|
|
|
25802
25173
|
const abs = join11(dir, entry, "SKILL.md");
|
|
25803
25174
|
let stat;
|
|
25804
25175
|
try {
|
|
25805
|
-
stat =
|
|
25176
|
+
stat = statSync4(abs);
|
|
25806
25177
|
} catch {
|
|
25807
25178
|
continue;
|
|
25808
25179
|
}
|
|
@@ -25823,7 +25194,7 @@ function readSkillFile(dir, name) {
|
|
|
25823
25194
|
if (!abs) return null;
|
|
25824
25195
|
let stat;
|
|
25825
25196
|
try {
|
|
25826
|
-
stat =
|
|
25197
|
+
stat = statSync4(abs);
|
|
25827
25198
|
} catch {
|
|
25828
25199
|
return null;
|
|
25829
25200
|
}
|
|
@@ -25842,7 +25213,7 @@ function writeSkillFile(dir, name, patch, baseMtime) {
|
|
|
25842
25213
|
if (!abs) return { status: "not-found" };
|
|
25843
25214
|
let stat;
|
|
25844
25215
|
try {
|
|
25845
|
-
stat =
|
|
25216
|
+
stat = statSync4(abs);
|
|
25846
25217
|
} catch {
|
|
25847
25218
|
return { status: "not-found" };
|
|
25848
25219
|
}
|
|
@@ -25854,13 +25225,13 @@ function writeSkillFile(dir, name, patch, baseMtime) {
|
|
|
25854
25225
|
const content = buildSkillFile({ ...fm, name, description: patch.description }, patch.body);
|
|
25855
25226
|
if (Buffer.byteLength(content, "utf8") > MAX_SKILL_BYTES) return { status: "too-large" };
|
|
25856
25227
|
writeFileSync6(abs, content, "utf8");
|
|
25857
|
-
return { status: "ok", mtime:
|
|
25228
|
+
return { status: "ok", mtime: statSync4(abs).mtime.toISOString() };
|
|
25858
25229
|
}
|
|
25859
25230
|
function createSkillFile(dir, name, description) {
|
|
25860
25231
|
const abs = resolveSkillPath(dir, name);
|
|
25861
25232
|
if (!abs) return { status: "bad-name" };
|
|
25862
|
-
if (
|
|
25863
|
-
|
|
25233
|
+
if (existsSync11(abs)) return { status: "exists" };
|
|
25234
|
+
mkdirSync7(join11(dir, name), { recursive: true });
|
|
25864
25235
|
writeFileSync6(
|
|
25865
25236
|
abs,
|
|
25866
25237
|
buildSkillFile(
|
|
@@ -25877,18 +25248,18 @@ Describe what this skill does and when to use it.
|
|
|
25877
25248
|
}
|
|
25878
25249
|
function deleteSkillFile(dir, name) {
|
|
25879
25250
|
const abs = resolveSkillPath(dir, name);
|
|
25880
|
-
if (!abs || !
|
|
25251
|
+
if (!abs || !existsSync11(abs)) return { status: "not-found" };
|
|
25881
25252
|
rmSync7(join11(dir, name), { recursive: true, force: true });
|
|
25882
25253
|
return { status: "ok" };
|
|
25883
25254
|
}
|
|
25884
25255
|
|
|
25885
25256
|
// ../api/src/claude/skills.ts
|
|
25886
25257
|
function defaultConfigDir() {
|
|
25887
|
-
return join12(
|
|
25258
|
+
return join12(homedir5(), ".claude");
|
|
25888
25259
|
}
|
|
25889
25260
|
function expandHome2(p) {
|
|
25890
|
-
if (p === "~") return
|
|
25891
|
-
if (p.startsWith("~/")) return join12(
|
|
25261
|
+
if (p === "~") return homedir5();
|
|
25262
|
+
if (p.startsWith("~/")) return join12(homedir5(), p.slice(2));
|
|
25892
25263
|
return p;
|
|
25893
25264
|
}
|
|
25894
25265
|
function parseFrontmatter(file) {
|
|
@@ -25912,13 +25283,13 @@ function parseFrontmatter(file) {
|
|
|
25912
25283
|
function isSymlinkedDir(root, entry) {
|
|
25913
25284
|
if (!entry.isSymbolicLink()) return false;
|
|
25914
25285
|
try {
|
|
25915
|
-
return
|
|
25286
|
+
return statSync5(join12(root, entry.name)).isDirectory();
|
|
25916
25287
|
} catch {
|
|
25917
25288
|
return false;
|
|
25918
25289
|
}
|
|
25919
25290
|
}
|
|
25920
25291
|
function findSkillFiles(root, maxDepth, out) {
|
|
25921
|
-
if (maxDepth < 0 || !
|
|
25292
|
+
if (maxDepth < 0 || !existsSync12(root)) return;
|
|
25922
25293
|
let entries2;
|
|
25923
25294
|
try {
|
|
25924
25295
|
entries2 = readdirSync4(root, { withFileTypes: true });
|
|
@@ -25971,7 +25342,7 @@ function findPluginMarkdown(pluginsRoot, dirName, maxDepth = 8) {
|
|
|
25971
25342
|
}
|
|
25972
25343
|
}
|
|
25973
25344
|
};
|
|
25974
|
-
if (
|
|
25345
|
+
if (existsSync12(pluginsRoot)) walk(pluginsRoot, maxDepth);
|
|
25975
25346
|
return out;
|
|
25976
25347
|
}
|
|
25977
25348
|
function readdirSafe(dir) {
|
|
@@ -26053,7 +25424,7 @@ function nestedProjectRoots(cwd) {
|
|
|
26053
25424
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
26054
25425
|
if (!entry.isDirectory() && !isSymlinkedDir(cwd, entry)) continue;
|
|
26055
25426
|
const skillsDir = join12(cwd, entry.name, ".claude", "skills");
|
|
26056
|
-
if (
|
|
25427
|
+
if (existsSync12(skillsDir)) roots.push({ dir: skillsDir, prefix: entry.name });
|
|
26057
25428
|
}
|
|
26058
25429
|
return roots;
|
|
26059
25430
|
}
|
|
@@ -26066,7 +25437,7 @@ function listPluginSkillDetails(configDir, cwd) {
|
|
|
26066
25437
|
if (skill.source !== "plugin") continue;
|
|
26067
25438
|
try {
|
|
26068
25439
|
const { body } = splitFrontmatter(readFileSync10(file, "utf-8"));
|
|
26069
|
-
details.push({ ...skill, body, path: file, mtime:
|
|
25440
|
+
details.push({ ...skill, body, path: file, mtime: statSync5(file).mtime.toISOString() });
|
|
26070
25441
|
} catch {
|
|
26071
25442
|
}
|
|
26072
25443
|
}
|
|
@@ -26100,7 +25471,7 @@ function findSkillDetail(configDir, cwd, name, sources) {
|
|
|
26100
25471
|
let mtime;
|
|
26101
25472
|
try {
|
|
26102
25473
|
raw = readFileSync10(file, "utf-8");
|
|
26103
|
-
mtime =
|
|
25474
|
+
mtime = statSync5(file).mtime.toISOString();
|
|
26104
25475
|
} catch {
|
|
26105
25476
|
continue;
|
|
26106
25477
|
}
|
|
@@ -26134,11 +25505,11 @@ ${body.trim()}`;
|
|
|
26134
25505
|
|
|
26135
25506
|
// src/claude/agents.ts
|
|
26136
25507
|
function defaultConfigDir2() {
|
|
26137
|
-
return join13(
|
|
25508
|
+
return join13(homedir6(), ".claude");
|
|
26138
25509
|
}
|
|
26139
25510
|
function expandHome3(p) {
|
|
26140
|
-
if (p === "~") return
|
|
26141
|
-
if (p.startsWith("~/")) return join13(
|
|
25511
|
+
if (p === "~") return homedir6();
|
|
25512
|
+
if (p.startsWith("~/")) return join13(homedir6(), p.slice(2));
|
|
26142
25513
|
return p;
|
|
26143
25514
|
}
|
|
26144
25515
|
function parseFrontmatter2(file) {
|
|
@@ -26160,7 +25531,7 @@ function parseFrontmatter2(file) {
|
|
|
26160
25531
|
}
|
|
26161
25532
|
}
|
|
26162
25533
|
function collectFrom2(root, source) {
|
|
26163
|
-
if (!
|
|
25534
|
+
if (!existsSync13(root)) return [];
|
|
26164
25535
|
let entries2;
|
|
26165
25536
|
try {
|
|
26166
25537
|
entries2 = readdirSync5(root).filter((f) => f.endsWith(".md"));
|
|
@@ -26210,13 +25581,13 @@ function readAgentPersona(configDir, cwd, name) {
|
|
|
26210
25581
|
|
|
26211
25582
|
// src/dashboard/memory-extraction-runner.ts
|
|
26212
25583
|
import { spawn as spawn4 } from "child_process";
|
|
26213
|
-
import { existsSync as
|
|
25584
|
+
import { existsSync as existsSync14, mkdtempSync as mkdtempSync5, readFileSync as readFileSync12, rmSync as rmSync8 } from "fs";
|
|
26214
25585
|
import { tmpdir as tmpdir4 } from "os";
|
|
26215
25586
|
import { join as join15 } from "path";
|
|
26216
25587
|
|
|
26217
25588
|
// ../api/src/dashboard/profile-config.ts
|
|
26218
|
-
import { homedir as
|
|
26219
|
-
import { join as join14, parse, resolve as
|
|
25589
|
+
import { homedir as homedir7 } from "os";
|
|
25590
|
+
import { join as join14, parse, resolve as resolve5 } from "path";
|
|
26220
25591
|
|
|
26221
25592
|
// ../api/src/dashboard/profile-config-cache.ts
|
|
26222
25593
|
var cache3 = /* @__PURE__ */ new Map();
|
|
@@ -26235,7 +25606,7 @@ function profileEnv(key) {
|
|
|
26235
25606
|
function profileClaudeConfigDir() {
|
|
26236
25607
|
const config = cachedProfileConfig();
|
|
26237
25608
|
if (!config) return process.env["CLAUDE_CONFIG_DIR"] || void 0;
|
|
26238
|
-
return config.env["CLAUDE_CONFIG_DIR"]?.trim() || join14(
|
|
25609
|
+
return config.env["CLAUDE_CONFIG_DIR"]?.trim() || join14(homedir7(), ".claude");
|
|
26239
25610
|
}
|
|
26240
25611
|
function profileOauthToken() {
|
|
26241
25612
|
const env = cachedProfileConfig()?.env ?? {};
|
|
@@ -26244,8 +25615,8 @@ function profileOauthToken() {
|
|
|
26244
25615
|
return process.env["CLAUDE_CODE_OAUTH_TOKEN"] || void 0;
|
|
26245
25616
|
}
|
|
26246
25617
|
function isUnsafeCwd(cwd) {
|
|
26247
|
-
const p =
|
|
26248
|
-
return p === parse(p).root || p ===
|
|
25618
|
+
const p = resolve5(cwd);
|
|
25619
|
+
return p === parse(p).root || p === resolve5(homedir7());
|
|
26249
25620
|
}
|
|
26250
25621
|
function defaultClaudeCwd() {
|
|
26251
25622
|
return profileEnv("CLAUDE_CWD") ?? process.cwd();
|
|
@@ -26353,9 +25724,9 @@ ${req.user}`,
|
|
|
26353
25724
|
};
|
|
26354
25725
|
}
|
|
26355
25726
|
function run(inv, cwd) {
|
|
26356
|
-
return new Promise((
|
|
26357
|
-
if (!
|
|
26358
|
-
|
|
25727
|
+
return new Promise((resolve7) => {
|
|
25728
|
+
if (!existsSync14(cwd)) {
|
|
25729
|
+
resolve7({ ok: false, error: `the channel folder ${cwd} does not exist on this Host` });
|
|
26359
25730
|
return;
|
|
26360
25731
|
}
|
|
26361
25732
|
const child = spawn4(inv.command, inv.args, {
|
|
@@ -26373,7 +25744,7 @@ function run(inv, cwd) {
|
|
|
26373
25744
|
child.on("error", (err) => {
|
|
26374
25745
|
clearTimeout(timer);
|
|
26375
25746
|
console.error(`[memory-extraction] ${inv.command} failed to start:`, err.message);
|
|
26376
|
-
|
|
25747
|
+
resolve7({ ok: false, error: `${inv.command} failed to start: ${err.message}` });
|
|
26377
25748
|
});
|
|
26378
25749
|
child.on("close", (code) => {
|
|
26379
25750
|
clearTimeout(timer);
|
|
@@ -26381,7 +25752,7 @@ function run(inv, cwd) {
|
|
|
26381
25752
|
const detail = (stderr || stdout).trim().split("\n").at(-1) ?? "";
|
|
26382
25753
|
const error = `${inv.command} exited ${code ?? "on timeout"}: ${detail.slice(0, 200)}`;
|
|
26383
25754
|
console.error(`[memory-extraction] ${error}`);
|
|
26384
|
-
|
|
25755
|
+
resolve7({ ok: false, error });
|
|
26385
25756
|
return;
|
|
26386
25757
|
}
|
|
26387
25758
|
let raw = stdout;
|
|
@@ -26392,7 +25763,7 @@ function run(inv, cwd) {
|
|
|
26392
25763
|
raw = "";
|
|
26393
25764
|
}
|
|
26394
25765
|
}
|
|
26395
|
-
|
|
25766
|
+
resolve7({ ok: true, raw });
|
|
26396
25767
|
});
|
|
26397
25768
|
child.stdin.end(inv.stdin);
|
|
26398
25769
|
});
|
|
@@ -26592,6 +25963,63 @@ var RATE_CARDS = [
|
|
|
26592
25963
|
cacheWritePer1M: 0.2,
|
|
26593
25964
|
effectiveFrom: EPOCH
|
|
26594
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
|
+
},
|
|
26595
26023
|
{
|
|
26596
26024
|
// Groq's models page, checked 2026-10-30. Our own spend (titles, translation,
|
|
26597
26025
|
// autocomplete, retros), priced so we can account for it. Groq does not
|
|
@@ -27141,7 +26569,7 @@ var UsageStore = class {
|
|
|
27141
26569
|
|
|
27142
26570
|
// src/dashboard/rollover-summary.ts
|
|
27143
26571
|
import { spawn as spawn5 } from "child_process";
|
|
27144
|
-
import { existsSync as
|
|
26572
|
+
import { existsSync as existsSync15, mkdtempSync as mkdtempSync6, readFileSync as readFileSync13, rmSync as rmSync9 } from "fs";
|
|
27145
26573
|
import { tmpdir as tmpdir5 } from "os";
|
|
27146
26574
|
import { join as join16 } from "path";
|
|
27147
26575
|
var HAIKU_MODEL = "haiku";
|
|
@@ -27230,13 +26658,13 @@ ${input}`
|
|
|
27230
26658
|
],
|
|
27231
26659
|
{ ...process.env }
|
|
27232
26660
|
);
|
|
27233
|
-
return
|
|
26661
|
+
return existsSync15(lastMessageFile) ? readFileSync13(lastMessageFile, "utf8").trim() : "";
|
|
27234
26662
|
} finally {
|
|
27235
26663
|
rmSync9(dir, { recursive: true, force: true });
|
|
27236
26664
|
}
|
|
27237
26665
|
}
|
|
27238
26666
|
function runPrint(command, args, env) {
|
|
27239
|
-
return new Promise((
|
|
26667
|
+
return new Promise((resolve7, reject) => {
|
|
27240
26668
|
const child = spawn5(command, args, {
|
|
27241
26669
|
// A stateless rewrite touches no files — tmpdir keeps it that way and
|
|
27242
26670
|
// avoids picking up an unrelated project's own CLAUDE.md/AGENTS.md,
|
|
@@ -27266,7 +26694,7 @@ function runPrint(command, args, env) {
|
|
|
27266
26694
|
reject(new Error(`${command} summary exited with code ${code}: ${stderr.trim()}`));
|
|
27267
26695
|
return;
|
|
27268
26696
|
}
|
|
27269
|
-
|
|
26697
|
+
resolve7(stdout);
|
|
27270
26698
|
});
|
|
27271
26699
|
});
|
|
27272
26700
|
}
|
|
@@ -27564,10 +26992,10 @@ async function downloadChatAttachments(body) {
|
|
|
27564
26992
|
}
|
|
27565
26993
|
|
|
27566
26994
|
// src/dashboard/plugin-ui-store.ts
|
|
27567
|
-
import { createHash as
|
|
26995
|
+
import { createHash as createHash5 } from "crypto";
|
|
27568
26996
|
var INLINE_MAX = 2048;
|
|
27569
26997
|
var uploaded = /* @__PURE__ */ new Map();
|
|
27570
|
-
var sha256 = (s) =>
|
|
26998
|
+
var sha256 = (s) => createHash5("sha256").update(s).digest("hex");
|
|
27571
26999
|
async function offloadSvg(workspace, source) {
|
|
27572
27000
|
const cacheKey2 = `${workspace}:${sha256(source)}`;
|
|
27573
27001
|
const cached = uploaded.get(cacheKey2);
|
|
@@ -27599,27 +27027,27 @@ async function offloadPluginUi(workspace, state) {
|
|
|
27599
27027
|
var pluginUiHash = (state) => sha256(JSON.stringify(state));
|
|
27600
27028
|
|
|
27601
27029
|
// src/dashboard/doc-mention-guard.ts
|
|
27602
|
-
import { existsSync as
|
|
27030
|
+
import { existsSync as existsSync20, statSync as statSync9 } from "fs";
|
|
27603
27031
|
|
|
27604
27032
|
// src/dashboard/docs-routes.ts
|
|
27605
27033
|
import {
|
|
27606
27034
|
closeSync,
|
|
27607
27035
|
createReadStream,
|
|
27608
|
-
existsSync as
|
|
27036
|
+
existsSync as existsSync19,
|
|
27609
27037
|
lstatSync as lstatSync2,
|
|
27610
|
-
mkdirSync as
|
|
27038
|
+
mkdirSync as mkdirSync8,
|
|
27611
27039
|
openSync,
|
|
27612
27040
|
readSync,
|
|
27613
27041
|
readdirSync as readdirSync6,
|
|
27614
27042
|
readFileSync as readFileSync18,
|
|
27615
|
-
realpathSync
|
|
27043
|
+
realpathSync,
|
|
27616
27044
|
renameSync as renameSync3,
|
|
27617
27045
|
rmSync as rmSync10,
|
|
27618
|
-
statSync as
|
|
27046
|
+
statSync as statSync8,
|
|
27619
27047
|
writeFileSync as writeFileSync7
|
|
27620
27048
|
} from "fs";
|
|
27621
27049
|
import { Readable } from "stream";
|
|
27622
|
-
import { basename as basename6, dirname as dirname3, extname as extname3, join as join21, relative
|
|
27050
|
+
import { basename as basename6, dirname as dirname3, extname as extname3, join as join21, relative, resolve as resolve6, sep as sep3 } from "path";
|
|
27623
27051
|
import { Hono as Hono4 } from "hono";
|
|
27624
27052
|
import { streamSSE } from "hono/streaming";
|
|
27625
27053
|
|
|
@@ -27731,7 +27159,7 @@ var requireDocsAccess = async (c, next) => {
|
|
|
27731
27159
|
};
|
|
27732
27160
|
|
|
27733
27161
|
// src/dashboard/docs-watcher.ts
|
|
27734
|
-
import { existsSync as
|
|
27162
|
+
import { existsSync as existsSync16, watch } from "fs";
|
|
27735
27163
|
import { basename as basename5, join as join18 } from "path";
|
|
27736
27164
|
var DEBOUNCE_MS = 200;
|
|
27737
27165
|
var MAX_PENDING = 200;
|
|
@@ -27773,7 +27201,7 @@ function watchDocs(cwd, listener) {
|
|
|
27773
27201
|
const current = entries.get(cwd);
|
|
27774
27202
|
if (!current || filename === null) return;
|
|
27775
27203
|
const rel = filename.split("\\").join("/");
|
|
27776
|
-
if (rel === root && !
|
|
27204
|
+
if (rel === root && !existsSync16(join18(cwd, rel))) return;
|
|
27777
27205
|
if (isIgnoredDocPath(rel)) return;
|
|
27778
27206
|
if (current.pending.size < MAX_PENDING) current.pending.add(rel);
|
|
27779
27207
|
if (current.timer === null) current.timer = setTimeout(() => flush(cwd), DEBOUNCE_MS);
|
|
@@ -27803,7 +27231,7 @@ function closeEntry(cwd) {
|
|
|
27803
27231
|
var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
|
|
27804
27232
|
|
|
27805
27233
|
// src/dashboard/doc-share-publisher.ts
|
|
27806
|
-
import { readFileSync as readFileSync14, statSync as
|
|
27234
|
+
import { readFileSync as readFileSync14, statSync as statSync6 } from "fs";
|
|
27807
27235
|
import { extname as extname2, posix } from "path";
|
|
27808
27236
|
var MAX_ASSET_BYTES = 20 * 1024 * 1024;
|
|
27809
27237
|
var MAX_CONTENT_BYTES = 2 * 1024 * 1024;
|
|
@@ -27860,7 +27288,7 @@ function inlinePreviewImages(cwd, sourcePath, source) {
|
|
|
27860
27288
|
const resolved2 = resolveRawPath(cwd, ref.rel);
|
|
27861
27289
|
if (!resolved2 || !resolved2.contentType.startsWith("image/")) continue;
|
|
27862
27290
|
try {
|
|
27863
|
-
if (
|
|
27291
|
+
if (statSync6(resolved2.abs).size > MAX_PREVIEW_INLINE_BYTES) continue;
|
|
27864
27292
|
const data = readFileSync14(resolved2.abs).toString("base64");
|
|
27865
27293
|
inlined.set(url, `data:${resolved2.contentType};base64,${data}`);
|
|
27866
27294
|
} catch {
|
|
@@ -27930,7 +27358,7 @@ function readDocShareBundle({ cwd, sourcePath }) {
|
|
|
27930
27358
|
if (!kind) return { status: "unsupported" };
|
|
27931
27359
|
let stat;
|
|
27932
27360
|
try {
|
|
27933
|
-
stat =
|
|
27361
|
+
stat = statSync6(abs);
|
|
27934
27362
|
} catch {
|
|
27935
27363
|
return { status: "not-found" };
|
|
27936
27364
|
}
|
|
@@ -28006,7 +27434,7 @@ function readDocShareBundle({ cwd, sourcePath }) {
|
|
|
28006
27434
|
const budget = Math.min(MAX_INLINE_BYTES, MAX_TOTAL_INLINE_BYTES - inlinedBytes);
|
|
28007
27435
|
let text = null;
|
|
28008
27436
|
try {
|
|
28009
|
-
const size =
|
|
27437
|
+
const size = statSync6(docAbs).size;
|
|
28010
27438
|
if (size <= budget) text = readFileSync14(docAbs, "utf8");
|
|
28011
27439
|
} catch {
|
|
28012
27440
|
continue;
|
|
@@ -28023,7 +27451,7 @@ function readDocShareBundle({ cwd, sourcePath }) {
|
|
|
28023
27451
|
if (!resolved2) continue;
|
|
28024
27452
|
let body;
|
|
28025
27453
|
try {
|
|
28026
|
-
if (
|
|
27454
|
+
if (statSync6(resolved2.abs).size > MAX_ASSET_BYTES) continue;
|
|
28027
27455
|
body = readFileSync14(resolved2.abs);
|
|
28028
27456
|
} catch {
|
|
28029
27457
|
continue;
|
|
@@ -28078,7 +27506,7 @@ async function putDocTranslation(input) {
|
|
|
28078
27506
|
}
|
|
28079
27507
|
|
|
28080
27508
|
// ../api/src/dashboard/share-translate.ts
|
|
28081
|
-
import { createHash as
|
|
27509
|
+
import { createHash as createHash6 } from "crypto";
|
|
28082
27510
|
|
|
28083
27511
|
// ../api/src/store/doc-share-store.ts
|
|
28084
27512
|
function rowToKind(value) {
|
|
@@ -28406,7 +27834,7 @@ function languageName(lang) {
|
|
|
28406
27834
|
return BY_CODE.get(lang)?.name ?? null;
|
|
28407
27835
|
}
|
|
28408
27836
|
function translationHash(title, content) {
|
|
28409
|
-
return
|
|
27837
|
+
return createHash6("sha256").update(`${RECIPE_VERSION}
|
|
28410
27838
|
${title}
|
|
28411
27839
|
${content}`).digest("hex");
|
|
28412
27840
|
}
|
|
@@ -28641,7 +28069,7 @@ async function clearStaleDocAudios(channelId, sourcePath, lang, exceptHash) {
|
|
|
28641
28069
|
}
|
|
28642
28070
|
|
|
28643
28071
|
// ../api/src/dashboard/share-audio.ts
|
|
28644
|
-
import { createHash as
|
|
28072
|
+
import { createHash as createHash7 } from "crypto";
|
|
28645
28073
|
import { DeleteObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-sdk/client-s3";
|
|
28646
28074
|
|
|
28647
28075
|
// ../api/src/dashboard/tts-routes.ts
|
|
@@ -28840,7 +28268,7 @@ Pacing \u2014 the engine has NO pause control, so rhythm has to be built into th
|
|
|
28840
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.`;
|
|
28841
28269
|
}
|
|
28842
28270
|
function articleAudioHash(title, content) {
|
|
28843
|
-
return
|
|
28271
|
+
return createHash7("sha256").update(`v${RECIPE_VERSION2}
|
|
28844
28272
|
${title}
|
|
28845
28273
|
|
|
28846
28274
|
${content}`).digest("hex").slice(0, 32);
|
|
@@ -28963,7 +28391,7 @@ function truncationNotice(lang, voice) {
|
|
|
28963
28391
|
if (lang === "en" || lang.startsWith("en-")) return TRUNCATION_NOTICE.en;
|
|
28964
28392
|
return null;
|
|
28965
28393
|
}
|
|
28966
|
-
var sleep2 = (ms) => new Promise((
|
|
28394
|
+
var sleep2 = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
28967
28395
|
async function synthesizeWithRetry(script, voice) {
|
|
28968
28396
|
let lastError;
|
|
28969
28397
|
for (let attempt = 1; attempt <= SYNTH_ATTEMPTS; attempt += 1) {
|
|
@@ -29067,7 +28495,7 @@ function queueShareAudio(share) {
|
|
|
29067
28495
|
var PENDING_STALE_MS = 30 * 60 * 1e3;
|
|
29068
28496
|
var FAILED_RETRY_MS = 10 * 60 * 1e3;
|
|
29069
28497
|
function langAudioHash(title, content, lang) {
|
|
29070
|
-
return
|
|
28498
|
+
return createHash7("sha256").update(`v${RECIPE_VERSION2}
|
|
29071
28499
|
${lang}
|
|
29072
28500
|
${translationHash(title, content)}`).digest("hex").slice(0, 32);
|
|
29073
28501
|
}
|
|
@@ -29384,7 +28812,7 @@ function createFeatureFlagsRouter() {
|
|
|
29384
28812
|
}
|
|
29385
28813
|
|
|
29386
28814
|
// ../api/src/dashboard/public-share-routes.ts
|
|
29387
|
-
import { existsSync as
|
|
28815
|
+
import { existsSync as existsSync18, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
|
|
29388
28816
|
import { join as join20 } from "path";
|
|
29389
28817
|
import { Hono as Hono3 } from "hono";
|
|
29390
28818
|
import { GetObjectCommand as GetObjectCommand3 } from "@aws-sdk/client-s3";
|
|
@@ -29591,12 +29019,12 @@ function injectShareHead(html, head) {
|
|
|
29591
29019
|
}
|
|
29592
29020
|
|
|
29593
29021
|
// ../api/src/dashboard/app-icon.ts
|
|
29594
|
-
import { createHash as
|
|
29595
|
-
import { existsSync as
|
|
29022
|
+
import { createHash as createHash8 } from "crypto";
|
|
29023
|
+
import { existsSync as existsSync17, readFileSync as readFileSync15 } from "fs";
|
|
29596
29024
|
import { join as join19 } from "path";
|
|
29597
29025
|
import sharp3 from "sharp";
|
|
29598
29026
|
var PLATE = "#0A0A0F";
|
|
29599
|
-
var BRAND_DIR =
|
|
29027
|
+
var BRAND_DIR = existsSync17(join19(paths.WEB_ROOT, "public")) ? join19(paths.WEB_ROOT, "public") : join19(paths.PACKAGE_ROOT, "dist", "brand");
|
|
29600
29028
|
var MARK_FILE = join19(BRAND_DIR, "icons", "icon-512.png");
|
|
29601
29029
|
var MARK_SVG_FILE = join19(BRAND_DIR, "favicon.svg");
|
|
29602
29030
|
var LAYOUT = {
|
|
@@ -29670,7 +29098,7 @@ async function renderAppIcon({
|
|
|
29670
29098
|
size,
|
|
29671
29099
|
maskable ? "maskable" : "std",
|
|
29672
29100
|
plain ? "plain" : "badged",
|
|
29673
|
-
logo ?
|
|
29101
|
+
logo ? createHash8("sha1").update(logo).digest("hex").slice(0, 12) : transparent ? "stock-transparent" : "stock"
|
|
29674
29102
|
].join(":");
|
|
29675
29103
|
const hit = cache4.get(key);
|
|
29676
29104
|
if (hit) return hit;
|
|
@@ -29701,7 +29129,7 @@ async function composeIcon(logo, size, maskable, plain) {
|
|
|
29701
29129
|
}
|
|
29702
29130
|
|
|
29703
29131
|
// ../api/src/dashboard/share-og.ts
|
|
29704
|
-
import { createHash as
|
|
29132
|
+
import { createHash as createHash9 } from "crypto";
|
|
29705
29133
|
import sharp4 from "sharp";
|
|
29706
29134
|
var WIDTH = 1200;
|
|
29707
29135
|
var HEIGHT = 630;
|
|
@@ -29879,7 +29307,7 @@ function cacheKey(input) {
|
|
|
29879
29307
|
input.logo ?? "",
|
|
29880
29308
|
input.theme ?? ""
|
|
29881
29309
|
];
|
|
29882
|
-
return
|
|
29310
|
+
return createHash9("sha1").update(parts.join("\0")).digest("hex");
|
|
29883
29311
|
}
|
|
29884
29312
|
async function renderShareOgImage(input) {
|
|
29885
29313
|
const key = cacheKey(input);
|
|
@@ -29894,7 +29322,7 @@ async function renderShareOgImage(input) {
|
|
|
29894
29322
|
}
|
|
29895
29323
|
|
|
29896
29324
|
// ../api/src/dashboard/share-ask.ts
|
|
29897
|
-
import { createHash as
|
|
29325
|
+
import { createHash as createHash10 } from "crypto";
|
|
29898
29326
|
var MAX_ARTICLE_CHARS3 = 24e3;
|
|
29899
29327
|
var MAX_QUESTION_CHARS = 500;
|
|
29900
29328
|
var SUGGESTION_COUNT = 4;
|
|
@@ -29959,7 +29387,7 @@ function parseSuggestions(raw) {
|
|
|
29959
29387
|
var CACHE_LIMIT = 200;
|
|
29960
29388
|
var suggestionCache = /* @__PURE__ */ new Map();
|
|
29961
29389
|
function articleHash(title, content, lang) {
|
|
29962
|
-
return
|
|
29390
|
+
return createHash10("sha256").update(`${lang ?? ""}
|
|
29963
29391
|
${title}
|
|
29964
29392
|
|
|
29965
29393
|
${content}`).digest("hex").slice(0, 32);
|
|
@@ -30213,7 +29641,7 @@ function createPublicShareApiRouter() {
|
|
|
30213
29641
|
var BUILD_PREFIX = "/share/_assets";
|
|
30214
29642
|
var shellCache = null;
|
|
30215
29643
|
function readShell(path) {
|
|
30216
|
-
const { mtimeMs } =
|
|
29644
|
+
const { mtimeMs } = statSync7(path);
|
|
30217
29645
|
if (shellCache?.mtimeMs === mtimeMs) return shellCache.html;
|
|
30218
29646
|
const html = readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
|
|
30219
29647
|
shellCache = { mtimeMs, html };
|
|
@@ -30236,7 +29664,7 @@ function serveBuildFile(c, webDist, dir, name) {
|
|
|
30236
29664
|
return c.text("not found", 404);
|
|
30237
29665
|
}
|
|
30238
29666
|
const path = join20(webDist, dir, name);
|
|
30239
|
-
if (!
|
|
29667
|
+
if (!existsSync18(path)) return c.text("not found", 404);
|
|
30240
29668
|
c.header("Content-Type", type);
|
|
30241
29669
|
c.header("Cache-Control", "public, max-age=31536000, immutable");
|
|
30242
29670
|
if (ext === ".css") {
|
|
@@ -30382,7 +29810,7 @@ ${analytics}` : head);
|
|
|
30382
29810
|
const lang = canonicalLanguage(requested);
|
|
30383
29811
|
if (!isTranslatableLanguage(lang)) return next();
|
|
30384
29812
|
const shell = join20(webDist, "index.html");
|
|
30385
|
-
if (!
|
|
29813
|
+
if (!existsSync18(shell)) return next();
|
|
30386
29814
|
const share = await getDocShare(c.req.param("id"));
|
|
30387
29815
|
if (!share) return next();
|
|
30388
29816
|
if (requested !== lang) return c.redirect(`/share/${share.id}/${lang}`, 302);
|
|
@@ -30418,7 +29846,7 @@ ${analytics}` : head);
|
|
|
30418
29846
|
if (!share) return next();
|
|
30419
29847
|
if (share.kind === "html") return servePublishedHtml(c, share);
|
|
30420
29848
|
const shell = join20(webDist, "index.html");
|
|
30421
|
-
if (!
|
|
29849
|
+
if (!existsSync18(shell)) return next();
|
|
30422
29850
|
return readerPage(
|
|
30423
29851
|
c,
|
|
30424
29852
|
share,
|
|
@@ -30614,7 +30042,7 @@ function entryKind(entry, abs) {
|
|
|
30614
30042
|
if (entry.isFile()) return "file";
|
|
30615
30043
|
if (!entry.isSymbolicLink()) return null;
|
|
30616
30044
|
try {
|
|
30617
|
-
const target =
|
|
30045
|
+
const target = statSync8(abs);
|
|
30618
30046
|
return target.isDirectory() ? "dir" : target.isFile() ? "file" : null;
|
|
30619
30047
|
} catch {
|
|
30620
30048
|
return null;
|
|
@@ -30627,11 +30055,11 @@ function fileNode(root, abs, name) {
|
|
|
30627
30055
|
const lang = CODE_EXTENSIONS[ext];
|
|
30628
30056
|
let stat;
|
|
30629
30057
|
try {
|
|
30630
|
-
stat =
|
|
30058
|
+
stat = statSync8(abs);
|
|
30631
30059
|
} catch {
|
|
30632
30060
|
return null;
|
|
30633
30061
|
}
|
|
30634
|
-
const path =
|
|
30062
|
+
const path = relative(root, abs).split(sep3).join("/");
|
|
30635
30063
|
const mtime = stat.mtime.toISOString();
|
|
30636
30064
|
if (kind) {
|
|
30637
30065
|
return {
|
|
@@ -30684,8 +30112,8 @@ function extractTitle(absPath, kind) {
|
|
|
30684
30112
|
}
|
|
30685
30113
|
function resolveDirPath(root, rel) {
|
|
30686
30114
|
if (rel.includes("\0")) return null;
|
|
30687
|
-
const abs =
|
|
30688
|
-
if (abs !== root && !abs.startsWith(root +
|
|
30115
|
+
const abs = resolve6(root, rel);
|
|
30116
|
+
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30689
30117
|
return abs;
|
|
30690
30118
|
}
|
|
30691
30119
|
function isListableFile(name) {
|
|
@@ -30733,11 +30161,11 @@ function probeDir(absDir, showHidden) {
|
|
|
30733
30161
|
function readGitBranch(dir) {
|
|
30734
30162
|
try {
|
|
30735
30163
|
let gitDir = join21(dir, ".git");
|
|
30736
|
-
if (
|
|
30164
|
+
if (statSync8(gitDir).isFile()) {
|
|
30737
30165
|
const pointer = readFileSync18(gitDir, "utf8").trim();
|
|
30738
30166
|
const match = pointer.match(/^gitdir:\s*(.+)$/);
|
|
30739
30167
|
if (!match) return void 0;
|
|
30740
|
-
gitDir =
|
|
30168
|
+
gitDir = resolve6(dir, match[1]);
|
|
30741
30169
|
}
|
|
30742
30170
|
const head = readFileSync18(join21(gitDir, "HEAD"), "utf8").trim();
|
|
30743
30171
|
const branchMatch = head.match(/^ref:\s*refs\/heads\/(.+)$/);
|
|
@@ -30762,13 +30190,13 @@ function listDocLevel(root, relDir = "", sort = "newest", showHidden = false) {
|
|
|
30762
30190
|
if (dirs.length + docs.length >= MAX_ENTRIES) break;
|
|
30763
30191
|
if (!showHidden && entry.name.startsWith(".")) continue;
|
|
30764
30192
|
const abs = join21(absDir, entry.name);
|
|
30765
|
-
const path =
|
|
30193
|
+
const path = relative(root, abs).split(sep3).join("/");
|
|
30766
30194
|
const kind = entryKind(entry, abs);
|
|
30767
30195
|
if (kind === "dir") {
|
|
30768
30196
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
30769
30197
|
const probe = probeDir(abs, showHidden);
|
|
30770
30198
|
if (!probe.hasDocs && probe.hasOther) continue;
|
|
30771
|
-
const isRepo =
|
|
30199
|
+
const isRepo = existsSync19(join21(abs, ".git"));
|
|
30772
30200
|
dirs.push({
|
|
30773
30201
|
path,
|
|
30774
30202
|
name: entry.name,
|
|
@@ -30824,8 +30252,8 @@ function flatDocs(root, {
|
|
|
30824
30252
|
}
|
|
30825
30253
|
function resolveDocPath(root, rel) {
|
|
30826
30254
|
if (!rel || rel.includes("\0")) return null;
|
|
30827
|
-
const abs =
|
|
30828
|
-
if (abs !== root && !abs.startsWith(root +
|
|
30255
|
+
const abs = resolve6(root, rel);
|
|
30256
|
+
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30829
30257
|
const ext = extname3(abs).toLowerCase();
|
|
30830
30258
|
if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return null;
|
|
30831
30259
|
return abs;
|
|
@@ -30835,7 +30263,7 @@ function writeDocContent(root, rel, content, baseMtime) {
|
|
|
30835
30263
|
if (!abs) return { status: "not-found" };
|
|
30836
30264
|
let stat;
|
|
30837
30265
|
try {
|
|
30838
|
-
stat =
|
|
30266
|
+
stat = statSync8(abs);
|
|
30839
30267
|
} catch {
|
|
30840
30268
|
return { status: "not-found" };
|
|
30841
30269
|
}
|
|
@@ -30847,27 +30275,27 @@ function writeDocContent(root, rel, content, baseMtime) {
|
|
|
30847
30275
|
return { status: "too-large" };
|
|
30848
30276
|
}
|
|
30849
30277
|
writeFileSync7(abs, content, "utf8");
|
|
30850
|
-
return { status: "ok", mtime:
|
|
30278
|
+
return { status: "ok", mtime: statSync8(abs).mtime.toISOString() };
|
|
30851
30279
|
}
|
|
30852
30280
|
function resolveRawPath(root, rel) {
|
|
30853
30281
|
if (!rel || rel.includes("\0")) return null;
|
|
30854
|
-
const abs =
|
|
30855
|
-
if (abs !== root && !abs.startsWith(root +
|
|
30282
|
+
const abs = resolve6(root, rel);
|
|
30283
|
+
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30856
30284
|
const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()];
|
|
30857
30285
|
if (!contentType) return null;
|
|
30858
30286
|
return { abs, contentType };
|
|
30859
30287
|
}
|
|
30860
30288
|
function resolveHtmlPath(root, rel) {
|
|
30861
30289
|
if (!rel || rel.includes("\0")) return null;
|
|
30862
|
-
const abs =
|
|
30863
|
-
if (abs !== root && !abs.startsWith(root +
|
|
30290
|
+
const abs = resolve6(root, rel);
|
|
30291
|
+
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30864
30292
|
if (DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "html") return null;
|
|
30865
30293
|
return abs;
|
|
30866
30294
|
}
|
|
30867
30295
|
function resolveDownloadPath(root, rel) {
|
|
30868
30296
|
if (!rel || rel.includes("\0")) return null;
|
|
30869
|
-
const abs =
|
|
30870
|
-
if (abs !== root && !abs.startsWith(root +
|
|
30297
|
+
const abs = resolve6(root, rel);
|
|
30298
|
+
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30871
30299
|
if (!isListableFile(basename6(abs))) return null;
|
|
30872
30300
|
const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()] ?? "application/octet-stream";
|
|
30873
30301
|
return { abs, contentType };
|
|
@@ -30884,7 +30312,7 @@ function uniqueName(absDir, name) {
|
|
|
30884
30312
|
let candidate = name;
|
|
30885
30313
|
for (let n = 1; n < 1e3; n++) {
|
|
30886
30314
|
try {
|
|
30887
|
-
|
|
30315
|
+
statSync8(join21(absDir, candidate));
|
|
30888
30316
|
} catch {
|
|
30889
30317
|
return candidate;
|
|
30890
30318
|
}
|
|
@@ -30896,7 +30324,7 @@ function saveUploadedFile(root, relDir, name, data) {
|
|
|
30896
30324
|
const absDir = resolveDirPath(root, relDir);
|
|
30897
30325
|
if (absDir === null) return { status: "no-dir" };
|
|
30898
30326
|
try {
|
|
30899
|
-
if (!
|
|
30327
|
+
if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
|
|
30900
30328
|
} catch {
|
|
30901
30329
|
return { status: "no-dir" };
|
|
30902
30330
|
}
|
|
@@ -30908,13 +30336,13 @@ function saveUploadedFile(root, relDir, name, data) {
|
|
|
30908
30336
|
const final = uniqueName(absDir, safe);
|
|
30909
30337
|
const abs = join21(absDir, final);
|
|
30910
30338
|
writeFileSync7(abs, data);
|
|
30911
|
-
return { status: "ok", path:
|
|
30339
|
+
return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: final };
|
|
30912
30340
|
}
|
|
30913
30341
|
function createDocFolder(root, relDir, name) {
|
|
30914
30342
|
const absDir = resolveDirPath(root, relDir);
|
|
30915
30343
|
if (absDir === null) return { status: "no-dir" };
|
|
30916
30344
|
try {
|
|
30917
|
-
if (!
|
|
30345
|
+
if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
|
|
30918
30346
|
} catch {
|
|
30919
30347
|
return { status: "no-dir" };
|
|
30920
30348
|
}
|
|
@@ -30922,18 +30350,18 @@ function createDocFolder(root, relDir, name) {
|
|
|
30922
30350
|
if (!safe) return { status: "bad-name" };
|
|
30923
30351
|
const abs = join21(absDir, safe);
|
|
30924
30352
|
try {
|
|
30925
|
-
|
|
30353
|
+
statSync8(abs);
|
|
30926
30354
|
return { status: "exists" };
|
|
30927
30355
|
} catch {
|
|
30928
30356
|
}
|
|
30929
|
-
|
|
30930
|
-
return { status: "ok", path:
|
|
30357
|
+
mkdirSync8(abs);
|
|
30358
|
+
return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: safe };
|
|
30931
30359
|
}
|
|
30932
30360
|
function createDocFile(root, relDir, name, content) {
|
|
30933
30361
|
const absDir = resolveDirPath(root, relDir);
|
|
30934
30362
|
if (absDir === null) return { status: "no-dir" };
|
|
30935
30363
|
try {
|
|
30936
|
-
if (!
|
|
30364
|
+
if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
|
|
30937
30365
|
} catch {
|
|
30938
30366
|
return { status: "no-dir" };
|
|
30939
30367
|
}
|
|
@@ -30950,22 +30378,22 @@ function createDocFile(root, relDir, name, content) {
|
|
|
30950
30378
|
if (err.code === "EEXIST") return { status: "exists" };
|
|
30951
30379
|
throw err;
|
|
30952
30380
|
}
|
|
30953
|
-
return { status: "ok", path:
|
|
30381
|
+
return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: safe };
|
|
30954
30382
|
}
|
|
30955
30383
|
function moveDocEntry(root, from, to) {
|
|
30956
30384
|
if (!from || !to || from.includes("\0") || to.includes("\0")) return { status: "not-found" };
|
|
30957
|
-
const absFrom =
|
|
30958
|
-
if (!absFrom.startsWith(root +
|
|
30385
|
+
const absFrom = resolve6(root, from);
|
|
30386
|
+
if (!absFrom.startsWith(root + sep3)) return { status: "not-found" };
|
|
30959
30387
|
let stat;
|
|
30960
30388
|
try {
|
|
30961
|
-
stat =
|
|
30389
|
+
stat = statSync8(absFrom);
|
|
30962
30390
|
} catch {
|
|
30963
30391
|
return { status: "not-found" };
|
|
30964
30392
|
}
|
|
30965
30393
|
const isDir = stat.isDirectory();
|
|
30966
30394
|
if (!isDir && !stat.isFile()) return { status: "not-found" };
|
|
30967
|
-
const absTo =
|
|
30968
|
-
if (!absTo.startsWith(root +
|
|
30395
|
+
const absTo = resolve6(root, to);
|
|
30396
|
+
if (!absTo.startsWith(root + sep3)) return { status: "bad-target" };
|
|
30969
30397
|
const name = sanitizeUploadName(basename6(absTo));
|
|
30970
30398
|
if (!name) return { status: "bad-target" };
|
|
30971
30399
|
if (!isDir) {
|
|
@@ -30975,27 +30403,27 @@ function moveDocEntry(root, from, to) {
|
|
|
30975
30403
|
}
|
|
30976
30404
|
}
|
|
30977
30405
|
const absToDir = dirname3(absTo);
|
|
30978
|
-
if (resolveDirPath(root,
|
|
30406
|
+
if (resolveDirPath(root, relative(root, absToDir)) === null) return { status: "bad-target" };
|
|
30979
30407
|
try {
|
|
30980
|
-
if (!
|
|
30408
|
+
if (!statSync8(absToDir).isDirectory()) return { status: "bad-target" };
|
|
30981
30409
|
} catch {
|
|
30982
30410
|
return { status: "bad-target" };
|
|
30983
30411
|
}
|
|
30984
30412
|
const finalAbs = join21(absToDir, name);
|
|
30985
|
-
if (isDir && (finalAbs === absFrom || finalAbs.startsWith(absFrom +
|
|
30413
|
+
if (isDir && (finalAbs === absFrom || finalAbs.startsWith(absFrom + sep3))) {
|
|
30986
30414
|
return { status: "into-self" };
|
|
30987
30415
|
}
|
|
30988
30416
|
try {
|
|
30989
|
-
if (
|
|
30417
|
+
if (realpathSync(finalAbs) !== realpathSync(absFrom)) return { status: "exists" };
|
|
30990
30418
|
} catch {
|
|
30991
30419
|
}
|
|
30992
30420
|
renameSync3(absFrom, finalAbs);
|
|
30993
|
-
return { status: "ok", path:
|
|
30421
|
+
return { status: "ok", path: relative(root, finalAbs).split(sep3).join("/"), name };
|
|
30994
30422
|
}
|
|
30995
30423
|
function deleteDocEntry(root, path) {
|
|
30996
30424
|
if (!path || path.includes("\0")) return { status: "not-found" };
|
|
30997
|
-
const abs =
|
|
30998
|
-
if (!abs.startsWith(root +
|
|
30425
|
+
const abs = resolve6(root, path);
|
|
30426
|
+
if (!abs.startsWith(root + sep3)) return { status: "not-found" };
|
|
30999
30427
|
let stat;
|
|
31000
30428
|
try {
|
|
31001
30429
|
stat = lstatSync2(abs);
|
|
@@ -31007,7 +30435,7 @@ function deleteDocEntry(root, path) {
|
|
|
31007
30435
|
rmSync10(abs, { recursive: isDir });
|
|
31008
30436
|
return {
|
|
31009
30437
|
status: "ok",
|
|
31010
|
-
path:
|
|
30438
|
+
path: relative(root, abs).split(sep3).join("/"),
|
|
31011
30439
|
type: isDir ? "dir" : "file"
|
|
31012
30440
|
};
|
|
31013
30441
|
}
|
|
@@ -31037,7 +30465,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
31037
30465
|
if (!resolved2) return c.json({ error: "not found" }, 404);
|
|
31038
30466
|
let stat;
|
|
31039
30467
|
try {
|
|
31040
|
-
stat =
|
|
30468
|
+
stat = statSync8(resolved2.abs);
|
|
31041
30469
|
} catch {
|
|
31042
30470
|
return c.json({ error: "not found" }, 404);
|
|
31043
30471
|
}
|
|
@@ -31059,7 +30487,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
31059
30487
|
if (!abs) return c.json({ error: "not found" }, 404);
|
|
31060
30488
|
let stat;
|
|
31061
30489
|
try {
|
|
31062
|
-
stat =
|
|
30490
|
+
stat = statSync8(abs);
|
|
31063
30491
|
} catch {
|
|
31064
30492
|
return c.json({ error: "not found" }, 404);
|
|
31065
30493
|
}
|
|
@@ -31184,7 +30612,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
31184
30612
|
if (!abs) return c.json({ error: "not found" }, 404);
|
|
31185
30613
|
let stat;
|
|
31186
30614
|
try {
|
|
31187
|
-
stat =
|
|
30615
|
+
stat = statSync8(abs);
|
|
31188
30616
|
} catch {
|
|
31189
30617
|
return c.json({ error: "not found" }, 404);
|
|
31190
30618
|
}
|
|
@@ -31233,7 +30661,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
31233
30661
|
if (!abs) return c.json({ error: "not found" }, 404);
|
|
31234
30662
|
let stat;
|
|
31235
30663
|
try {
|
|
31236
|
-
stat =
|
|
30664
|
+
stat = statSync8(abs);
|
|
31237
30665
|
} catch {
|
|
31238
30666
|
return c.json({ error: "not found" }, 404);
|
|
31239
30667
|
}
|
|
@@ -31284,7 +30712,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
31284
30712
|
}
|
|
31285
30713
|
let stat;
|
|
31286
30714
|
try {
|
|
31287
|
-
stat =
|
|
30715
|
+
stat = statSync8(abs);
|
|
31288
30716
|
} catch {
|
|
31289
30717
|
return { error: c.json({ error: "not found" }, 404) };
|
|
31290
30718
|
}
|
|
@@ -31352,9 +30780,9 @@ function withDocLinkBridge(html) {
|
|
|
31352
30780
|
var DOC_MENTION_RE = /(?<![\w@/`])@((?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]{1,6})(?::(\d+))?(?![\w-])/g;
|
|
31353
30781
|
function isRealDoc(root, rel) {
|
|
31354
30782
|
const abs = resolveDocPath(root, rel);
|
|
31355
|
-
if (!abs || !
|
|
30783
|
+
if (!abs || !existsSync20(abs)) return false;
|
|
31356
30784
|
try {
|
|
31357
|
-
return
|
|
30785
|
+
return statSync9(abs).isFile();
|
|
31358
30786
|
} catch {
|
|
31359
30787
|
return false;
|
|
31360
30788
|
}
|
|
@@ -31876,7 +31304,7 @@ var BACKGROUND_CHECK_IN_MS = 30 * 6e4;
|
|
|
31876
31304
|
var MISSED_MESSAGE_WINDOW_MS = 24 * 60 * 60 * 1e3;
|
|
31877
31305
|
var MISSED_MESSAGE_THREAD_LIMIT = 100;
|
|
31878
31306
|
var delay = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
31879
|
-
function stripPathPrefixes(label, roots, home =
|
|
31307
|
+
function stripPathPrefixes(label, roots, home = homedir8()) {
|
|
31880
31308
|
let out = label;
|
|
31881
31309
|
for (const root of roots) {
|
|
31882
31310
|
if (root) out = out.replaceAll(`${root.replace(/\/+$/, "")}/`, "");
|
|
@@ -31988,6 +31416,9 @@ var ChatAgent = class {
|
|
|
31988
31416
|
handleMessage(msg) {
|
|
31989
31417
|
if (msg.author === AGENT_AUTHOR) return;
|
|
31990
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
|
+
);
|
|
31991
31422
|
if (!msg.resumed && !msg.woken) {
|
|
31992
31423
|
this.consecutiveWakes.delete(msg.threadId);
|
|
31993
31424
|
this.autoContinues.delete(msg.threadId);
|
|
@@ -32241,7 +31672,10 @@ var ChatAgent = class {
|
|
|
32241
31672
|
await this.run(msg);
|
|
32242
31673
|
return;
|
|
32243
31674
|
}
|
|
32244
|
-
if (mentionsSupport(msg.body))
|
|
31675
|
+
if (mentionsSupport(msg.body)) {
|
|
31676
|
+
console.log(`[chat-agent] @support only, skipped thread=${msg.threadId}`);
|
|
31677
|
+
return;
|
|
31678
|
+
}
|
|
32245
31679
|
const humans = await this.getHumanParticipants(msg.threadId);
|
|
32246
31680
|
if (humans.size <= 1) {
|
|
32247
31681
|
await this.run(msg);
|
|
@@ -32258,7 +31692,10 @@ var ChatAgent = class {
|
|
|
32258
31692
|
}
|
|
32259
31693
|
const transcript = [...recent, { author: msg.author, body: msg.body }];
|
|
32260
31694
|
const respond = await this.shouldAgentRespond(transcript);
|
|
32261
|
-
if (!respond)
|
|
31695
|
+
if (!respond) {
|
|
31696
|
+
console.log(`[chat-agent] classifier skipped thread=${msg.threadId} reply=${msg.replyId}`);
|
|
31697
|
+
return;
|
|
31698
|
+
}
|
|
32262
31699
|
await this.run(msg);
|
|
32263
31700
|
}
|
|
32264
31701
|
/** Whether the body mentions the main agent's per-workspace display name
|
|
@@ -32341,6 +31778,10 @@ var ChatAgent = class {
|
|
|
32341
31778
|
runningThreadIds() {
|
|
32342
31779
|
return [...this.activeRuns.keys()];
|
|
32343
31780
|
}
|
|
31781
|
+
/** Every thread still waiting on a background job it launched. */
|
|
31782
|
+
backgroundThreadIds() {
|
|
31783
|
+
return [...this.watchedTasks.keys()];
|
|
31784
|
+
}
|
|
32344
31785
|
/** Workspace roots for label sanitising, memoised across runs. Best-effort:
|
|
32345
31786
|
* any failure (including a test double without a `workspaces` table) just
|
|
32346
31787
|
* means no stripping this run, retried on the next. */
|
|
@@ -32486,6 +31927,8 @@ var ChatAgent = class {
|
|
|
32486
31927
|
const abort = new AbortController();
|
|
32487
31928
|
this.activeRuns.set(msg.threadId, { activities, abort, msg });
|
|
32488
31929
|
notifyThinking(true);
|
|
31930
|
+
const startedAt = Date.now();
|
|
31931
|
+
console.log(`[chat-agent] turn start thread=${msg.threadId} reply=${msg.replyId}`);
|
|
32489
31932
|
const roots = await this.getWorkspaceRoots();
|
|
32490
31933
|
const onActivity = (raw) => {
|
|
32491
31934
|
const activity = { ...raw, label: stripPathPrefixes(raw.label, roots) };
|
|
@@ -32856,6 +32299,9 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
32856
32299
|
store.close();
|
|
32857
32300
|
this.activeRuns.delete(msg.threadId);
|
|
32858
32301
|
notifyThinking(false);
|
|
32302
|
+
console.log(
|
|
32303
|
+
`[chat-agent] turn end thread=${msg.threadId} reply=${msg.replyId} ms=${Date.now() - startedAt}`
|
|
32304
|
+
);
|
|
32859
32305
|
void this.watchBackgroundTasks(msg.threadId, thread.channel_id, owningProfile);
|
|
32860
32306
|
}
|
|
32861
32307
|
}
|
|
@@ -32879,22 +32325,22 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
32879
32325
|
let ready;
|
|
32880
32326
|
try {
|
|
32881
32327
|
channel = this.supabase().channel(`agent-thinking:${threadId}`);
|
|
32882
|
-
ready = new Promise((
|
|
32328
|
+
ready = new Promise((resolve7) => {
|
|
32883
32329
|
const timeout = setTimeout(() => {
|
|
32884
32330
|
console.error(`[chat-agent] thinking-channel ${threadId}: subscribe timed out after 10s`);
|
|
32885
|
-
|
|
32331
|
+
resolve7(false);
|
|
32886
32332
|
}, 1e4);
|
|
32887
32333
|
channel.subscribe((status, err) => {
|
|
32888
32334
|
if (status === "SUBSCRIBED") {
|
|
32889
32335
|
clearTimeout(timeout);
|
|
32890
|
-
|
|
32336
|
+
resolve7(true);
|
|
32891
32337
|
} else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
|
|
32892
32338
|
console.error(
|
|
32893
32339
|
`[chat-agent] thinking-channel ${threadId}: ${status}`,
|
|
32894
32340
|
err?.message ?? ""
|
|
32895
32341
|
);
|
|
32896
32342
|
clearTimeout(timeout);
|
|
32897
|
-
|
|
32343
|
+
resolve7(false);
|
|
32898
32344
|
}
|
|
32899
32345
|
});
|
|
32900
32346
|
});
|
|
@@ -32941,19 +32387,19 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
32941
32387
|
let ready;
|
|
32942
32388
|
try {
|
|
32943
32389
|
channel = this.supabase().channel("channel-activity");
|
|
32944
|
-
ready = new Promise((
|
|
32390
|
+
ready = new Promise((resolve7) => {
|
|
32945
32391
|
const timeout = setTimeout(() => {
|
|
32946
32392
|
console.error("[chat-agent] channel-activity: subscribe timed out after 10s");
|
|
32947
|
-
|
|
32393
|
+
resolve7(false);
|
|
32948
32394
|
}, 1e4);
|
|
32949
32395
|
channel.subscribe((status, err) => {
|
|
32950
32396
|
if (status === "SUBSCRIBED") {
|
|
32951
32397
|
clearTimeout(timeout);
|
|
32952
|
-
|
|
32398
|
+
resolve7(true);
|
|
32953
32399
|
} else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
|
|
32954
32400
|
console.error(`[chat-agent] channel-activity: ${status}`, err?.message ?? "");
|
|
32955
32401
|
clearTimeout(timeout);
|
|
32956
|
-
|
|
32402
|
+
resolve7(false);
|
|
32957
32403
|
}
|
|
32958
32404
|
});
|
|
32959
32405
|
});
|
|
@@ -33475,6 +32921,7 @@ function parseEffortCommand(text) {
|
|
|
33475
32921
|
}
|
|
33476
32922
|
|
|
33477
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";
|
|
33478
32925
|
var REJECT_MESSAGES = [
|
|
33479
32926
|
"Sorry, I'm a personal assistant and only respond to my owner. :bow:",
|
|
33480
32927
|
"I appreciate the interest, but I'm exclusively dedicated to my owner. :lock:",
|
|
@@ -33709,6 +33156,8 @@ function registerListeners(app, store, reactionStore, config, triggerEngine, men
|
|
|
33709
33156
|
return id;
|
|
33710
33157
|
};
|
|
33711
33158
|
const forkContexts = /* @__PURE__ */ new Map();
|
|
33159
|
+
const autoContinues = /* @__PURE__ */ new Map();
|
|
33160
|
+
const autoContinuing = /* @__PURE__ */ new Set();
|
|
33712
33161
|
let forkCounter = 0;
|
|
33713
33162
|
const registerFork = (ctx) => {
|
|
33714
33163
|
const id = String(++forkCounter);
|
|
@@ -33776,6 +33225,7 @@ function registerListeners(app, store, reactionStore, config, triggerEngine, men
|
|
|
33776
33225
|
return;
|
|
33777
33226
|
}
|
|
33778
33227
|
const threadKey = `${channelId}:${sessionKey}`;
|
|
33228
|
+
if (!autoContinuing.delete(threadKey)) autoContinues.delete(threadKey);
|
|
33779
33229
|
const abortController = new AbortController();
|
|
33780
33230
|
activeRuns.set(threadKey, abortController);
|
|
33781
33231
|
let reacted = false;
|
|
@@ -33825,12 +33275,36 @@ ${trimmedDetail.slice(0, 1500)}
|
|
|
33825
33275
|
};
|
|
33826
33276
|
const offerContinue = async () => {
|
|
33827
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
|
+
}
|
|
33828
33302
|
const retryId = registerRetry({
|
|
33829
33303
|
channelId,
|
|
33830
33304
|
sessionKey,
|
|
33831
33305
|
// Resume instruction, NOT the original prompt — the session already holds
|
|
33832
33306
|
// the original request + partial work, so re-sending it would double up.
|
|
33833
|
-
prompt:
|
|
33307
|
+
prompt: AUTO_CONTINUE_PROMPT,
|
|
33834
33308
|
senderId,
|
|
33835
33309
|
threadTs,
|
|
33836
33310
|
reactTs
|
|
@@ -35433,13 +34907,13 @@ async function recoverStaleReactions(client, reactionStore) {
|
|
|
35433
34907
|
var ts2 = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
35434
34908
|
var POWER_POLL_MS = 3e4;
|
|
35435
34909
|
function isOnACPower() {
|
|
35436
|
-
return new Promise((
|
|
34910
|
+
return new Promise((resolve7) => {
|
|
35437
34911
|
execFile2("pmset", ["-g", "ps"], { timeout: 2e3 }, (err, stdout) => {
|
|
35438
34912
|
if (err) {
|
|
35439
|
-
|
|
34913
|
+
resolve7(true);
|
|
35440
34914
|
return;
|
|
35441
34915
|
}
|
|
35442
|
-
|
|
34916
|
+
resolve7(stdout.includes("'AC Power'"));
|
|
35443
34917
|
});
|
|
35444
34918
|
});
|
|
35445
34919
|
}
|
|
@@ -35590,31 +35064,6 @@ export {
|
|
|
35590
35064
|
resolveUserId,
|
|
35591
35065
|
ensureUsersCached,
|
|
35592
35066
|
useLocalCache,
|
|
35593
|
-
isPermissionMode,
|
|
35594
|
-
isLogicalCwd,
|
|
35595
|
-
displayCwd,
|
|
35596
|
-
isUnderLogicalRoot,
|
|
35597
|
-
expandPath,
|
|
35598
|
-
canSeeChannel,
|
|
35599
|
-
refreshChannelRegistry,
|
|
35600
|
-
getChannelRegistry,
|
|
35601
|
-
getProfileChannelRegistry,
|
|
35602
|
-
findChannelById,
|
|
35603
|
-
findChannel,
|
|
35604
|
-
startChannelRegistryPolling,
|
|
35605
|
-
isCwdUsable,
|
|
35606
|
-
auditChannelCwds,
|
|
35607
|
-
warnOnBrokenChannelCwds,
|
|
35608
|
-
resolveCwd,
|
|
35609
|
-
ChannelCwdError,
|
|
35610
|
-
createChannel,
|
|
35611
|
-
DefaultChannelError,
|
|
35612
|
-
updateChannelById,
|
|
35613
|
-
markChannelGreeted,
|
|
35614
|
-
updateChannelsMcpConnections,
|
|
35615
|
-
ensureAgentDmChannel,
|
|
35616
|
-
ensureGeneralChannel,
|
|
35617
|
-
ensureMemberDmChannel,
|
|
35618
35067
|
getWorkspaceDomain,
|
|
35619
35068
|
insertWorkspaceDomain,
|
|
35620
35069
|
updateWorkspaceDomainStatus,
|
|
@@ -35709,12 +35158,6 @@ export {
|
|
|
35709
35158
|
clearClaudeAuthFailed,
|
|
35710
35159
|
claudeAuthFailed,
|
|
35711
35160
|
pinnedClaudeConfigDir,
|
|
35712
|
-
AGENT_AUTHOR,
|
|
35713
|
-
isHumanAuthor,
|
|
35714
|
-
deriveThreadTitle,
|
|
35715
|
-
syncPostToDashboard,
|
|
35716
|
-
resolveDashboardChannelId,
|
|
35717
|
-
postToDashboardChannel,
|
|
35718
35161
|
refreshAutomationRegistry,
|
|
35719
35162
|
startAutomationRegistryPolling,
|
|
35720
35163
|
DEFAULT_TIMEZONE,
|
|
@@ -35860,6 +35303,8 @@ export {
|
|
|
35860
35303
|
flatDocs,
|
|
35861
35304
|
createDocsRouter,
|
|
35862
35305
|
slackMrkdwnToMarkdown,
|
|
35306
|
+
GUIDE_RULES,
|
|
35307
|
+
extractGuide,
|
|
35863
35308
|
handleSupportMention,
|
|
35864
35309
|
escalateToHuman,
|
|
35865
35310
|
syncSupportReply,
|