flyspace-cli 0.1.58 → 0.1.60
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-44WHW7NK.js → chunk-PXZUNZ4S.js} +54 -2
- package/dist/{chunk-TAUF3WGB.js → chunk-SIR6PTDT.js} +617 -922
- package/dist/{chunk-XACRG7BO.js → chunk-XYS7SVWC.js} +594 -13
- package/dist/cli.js +293 -232
- package/dist/index.js +2 -2
- package/dist/{threads-I52LSA5X.js → threads-QQRWT3OM.js} +23 -2
- package/package.json +1 -1
- package/system.capabilities.md +2 -0
|
@@ -4,6 +4,7 @@ const require = __flyspaceCreateRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
AGENT_AUTHOR,
|
|
6
6
|
DEFAULT_AUTO_CONTINUE_LIMIT,
|
|
7
|
+
DEFAULT_CODEX_MODEL,
|
|
7
8
|
SUPPORT_BOT_AUTHOR,
|
|
8
9
|
SYNCED_BOT_AUTHOR,
|
|
9
10
|
SessionStore,
|
|
@@ -25,15 +26,21 @@ import {
|
|
|
25
26
|
getR2Bucket,
|
|
26
27
|
getR2Client,
|
|
27
28
|
getSupabaseClient,
|
|
28
|
-
hasSupabaseCredentials,
|
|
29
29
|
isChannelAccessAllowed,
|
|
30
30
|
isEffort,
|
|
31
31
|
isHumanAuthor,
|
|
32
32
|
isPermissionMode,
|
|
33
|
+
loadConfig,
|
|
34
|
+
loadEnvFiles,
|
|
35
|
+
mcpStrictConfigEnabled,
|
|
33
36
|
onChannelRegistryChange,
|
|
34
37
|
paths,
|
|
35
38
|
postToDashboardChannel,
|
|
36
39
|
refreshChannelRegistry,
|
|
40
|
+
requestAttachmentUrl,
|
|
41
|
+
requestPluginSvg,
|
|
42
|
+
requestShouldRespond,
|
|
43
|
+
requireSlackBotToken,
|
|
37
44
|
resolveAutoContinueLimit,
|
|
38
45
|
resolveChannelPermissionMode,
|
|
39
46
|
resolveChannelPrompt,
|
|
@@ -45,15 +52,16 @@ import {
|
|
|
45
52
|
resolveModel,
|
|
46
53
|
resolveOwnPersona,
|
|
47
54
|
runWithProfile,
|
|
48
|
-
|
|
55
|
+
sendAgentFailure,
|
|
49
56
|
setSupabaseClientFactory,
|
|
50
57
|
startChannelRegistryPolling,
|
|
51
58
|
sweepScratchDir,
|
|
52
59
|
syncPostToDashboard,
|
|
53
60
|
updateChannelById,
|
|
54
61
|
uploadLocalImages,
|
|
62
|
+
useHostDbWithoutCredentials,
|
|
55
63
|
warnOnBrokenChannelCwds
|
|
56
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-XYS7SVWC.js";
|
|
57
65
|
|
|
58
66
|
// ../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
|
|
59
67
|
var require_delayed_stream = __commonJS({
|
|
@@ -9286,7 +9294,7 @@ var require_sign = __commonJS({
|
|
|
9286
9294
|
"../../node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js"(exports, module) {
|
|
9287
9295
|
"use strict";
|
|
9288
9296
|
var $isNaN = require_isNaN();
|
|
9289
|
-
module.exports = function
|
|
9297
|
+
module.exports = function sign(number) {
|
|
9290
9298
|
if ($isNaN(number) || number === 0) {
|
|
9291
9299
|
return number;
|
|
9292
9300
|
}
|
|
@@ -9650,7 +9658,7 @@ var require_get_intrinsic = __commonJS({
|
|
|
9650
9658
|
var min = require_min();
|
|
9651
9659
|
var pow = require_pow();
|
|
9652
9660
|
var round = require_round();
|
|
9653
|
-
var
|
|
9661
|
+
var sign = require_sign();
|
|
9654
9662
|
var $Function = Function;
|
|
9655
9663
|
var getEvalledConstructor = function(expressionSyntax) {
|
|
9656
9664
|
try {
|
|
@@ -9764,7 +9772,7 @@ var require_get_intrinsic = __commonJS({
|
|
|
9764
9772
|
"%Math.min%": min,
|
|
9765
9773
|
"%Math.pow%": pow,
|
|
9766
9774
|
"%Math.round%": round,
|
|
9767
|
-
"%Math.sign%":
|
|
9775
|
+
"%Math.sign%": sign,
|
|
9768
9776
|
"%Reflect.getPrototypeOf%": $ReflectGPO
|
|
9769
9777
|
};
|
|
9770
9778
|
if (getProto) {
|
|
@@ -10954,7 +10962,7 @@ var require_supports_color = __commonJS({
|
|
|
10954
10962
|
return 1;
|
|
10955
10963
|
}
|
|
10956
10964
|
if ("CI" in env) {
|
|
10957
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((
|
|
10965
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
10958
10966
|
return 1;
|
|
10959
10967
|
}
|
|
10960
10968
|
return min;
|
|
@@ -13009,10 +13017,10 @@ var require_axios = __commonJS({
|
|
|
13009
13017
|
}
|
|
13010
13018
|
};
|
|
13011
13019
|
var CanceledError$1 = CanceledError;
|
|
13012
|
-
function settle(
|
|
13020
|
+
function settle(resolve7, reject, response) {
|
|
13013
13021
|
const validateStatus = response.config.validateStatus;
|
|
13014
13022
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
13015
|
-
|
|
13023
|
+
resolve7(response);
|
|
13016
13024
|
} else {
|
|
13017
13025
|
reject(
|
|
13018
13026
|
new AxiosError$1(
|
|
@@ -13604,7 +13612,7 @@ var require_axios = __commonJS({
|
|
|
13604
13612
|
}
|
|
13605
13613
|
var isHttpAdapterSupported = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
|
|
13606
13614
|
var wrapAsync = (asyncExecutor) => {
|
|
13607
|
-
return new Promise((
|
|
13615
|
+
return new Promise((resolve7, reject) => {
|
|
13608
13616
|
let onDone;
|
|
13609
13617
|
let isDone;
|
|
13610
13618
|
const done = (value, isRejected) => {
|
|
@@ -13614,7 +13622,7 @@ var require_axios = __commonJS({
|
|
|
13614
13622
|
};
|
|
13615
13623
|
const _resolve = (value) => {
|
|
13616
13624
|
done(value);
|
|
13617
|
-
|
|
13625
|
+
resolve7(value);
|
|
13618
13626
|
};
|
|
13619
13627
|
const _reject = (reason) => {
|
|
13620
13628
|
done(reason, true);
|
|
@@ -13661,7 +13669,7 @@ var require_axios = __commonJS({
|
|
|
13661
13669
|
}
|
|
13662
13670
|
};
|
|
13663
13671
|
var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config) {
|
|
13664
|
-
return wrapAsync(async function dispatchHttpRequest(
|
|
13672
|
+
return wrapAsync(async function dispatchHttpRequest(resolve7, reject, onDone) {
|
|
13665
13673
|
let { data, lookup: lookup2, family, httpVersion = 1, http2Options } = config;
|
|
13666
13674
|
const { responseType, responseEncoding } = config;
|
|
13667
13675
|
const method = config.method.toUpperCase();
|
|
@@ -13751,7 +13759,7 @@ var require_axios = __commonJS({
|
|
|
13751
13759
|
}
|
|
13752
13760
|
let convertedData;
|
|
13753
13761
|
if (method !== "GET") {
|
|
13754
|
-
return settle(
|
|
13762
|
+
return settle(resolve7, reject, {
|
|
13755
13763
|
status: 405,
|
|
13756
13764
|
statusText: "method not allowed",
|
|
13757
13765
|
headers: {},
|
|
@@ -13773,7 +13781,7 @@ var require_axios = __commonJS({
|
|
|
13773
13781
|
} else if (responseType === "stream") {
|
|
13774
13782
|
convertedData = stream__default["default"].Readable.from(convertedData);
|
|
13775
13783
|
}
|
|
13776
|
-
return settle(
|
|
13784
|
+
return settle(resolve7, reject, {
|
|
13777
13785
|
data: convertedData,
|
|
13778
13786
|
status: 200,
|
|
13779
13787
|
statusText: "OK",
|
|
@@ -14014,7 +14022,7 @@ var require_axios = __commonJS({
|
|
|
14014
14022
|
};
|
|
14015
14023
|
if (responseType === "stream") {
|
|
14016
14024
|
response.data = responseStream;
|
|
14017
|
-
settle(
|
|
14025
|
+
settle(resolve7, reject, response);
|
|
14018
14026
|
} else {
|
|
14019
14027
|
const responseBuffer = [];
|
|
14020
14028
|
let totalResponseBytes = 0;
|
|
@@ -14064,7 +14072,7 @@ var require_axios = __commonJS({
|
|
|
14064
14072
|
} catch (err) {
|
|
14065
14073
|
return reject(AxiosError$1.from(err, null, config, response.request, response));
|
|
14066
14074
|
}
|
|
14067
|
-
settle(
|
|
14075
|
+
settle(resolve7, reject, response);
|
|
14068
14076
|
});
|
|
14069
14077
|
}
|
|
14070
14078
|
abortEmitter.once("abort", (err) => {
|
|
@@ -14314,7 +14322,7 @@ var require_axios = __commonJS({
|
|
|
14314
14322
|
};
|
|
14315
14323
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
14316
14324
|
var xhrAdapter = isXHRAdapterSupported && function(config) {
|
|
14317
|
-
return new Promise(function dispatchXhrRequest(
|
|
14325
|
+
return new Promise(function dispatchXhrRequest(resolve7, reject) {
|
|
14318
14326
|
const _config = resolveConfig(config);
|
|
14319
14327
|
let requestData = _config.data;
|
|
14320
14328
|
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
@@ -14349,7 +14357,7 @@ var require_axios = __commonJS({
|
|
|
14349
14357
|
};
|
|
14350
14358
|
settle(
|
|
14351
14359
|
function _resolve(value) {
|
|
14352
|
-
|
|
14360
|
+
resolve7(value);
|
|
14353
14361
|
done();
|
|
14354
14362
|
},
|
|
14355
14363
|
function _reject(err) {
|
|
@@ -14568,8 +14576,8 @@ var require_axios = __commonJS({
|
|
|
14568
14576
|
};
|
|
14569
14577
|
var DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
14570
14578
|
var { isFunction } = utils$1;
|
|
14571
|
-
var globalFetchAPI = (({ Request
|
|
14572
|
-
Request
|
|
14579
|
+
var globalFetchAPI = (({ Request, Response: Response2 }) => ({
|
|
14580
|
+
Request,
|
|
14573
14581
|
Response: Response2
|
|
14574
14582
|
}))(utils$1.global);
|
|
14575
14583
|
var { ReadableStream: ReadableStream$1, TextEncoder: TextEncoder$1 } = utils$1.global;
|
|
@@ -14588,18 +14596,18 @@ var require_axios = __commonJS({
|
|
|
14588
14596
|
globalFetchAPI,
|
|
14589
14597
|
env
|
|
14590
14598
|
);
|
|
14591
|
-
const { fetch: envFetch, Request
|
|
14599
|
+
const { fetch: envFetch, Request, Response: Response2 } = env;
|
|
14592
14600
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === "function";
|
|
14593
|
-
const isRequestSupported = isFunction(
|
|
14601
|
+
const isRequestSupported = isFunction(Request);
|
|
14594
14602
|
const isResponseSupported = isFunction(Response2);
|
|
14595
14603
|
if (!isFetchSupported) {
|
|
14596
14604
|
return false;
|
|
14597
14605
|
}
|
|
14598
14606
|
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
14599
|
-
const encodeText = isFetchSupported && (typeof TextEncoder$1 === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder$1()) : async (str) => new Uint8Array(await new
|
|
14607
|
+
const encodeText = isFetchSupported && (typeof TextEncoder$1 === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder$1()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
14600
14608
|
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
14601
14609
|
let duplexAccessed = false;
|
|
14602
|
-
const hasContentType = new
|
|
14610
|
+
const hasContentType = new Request(platform.origin, {
|
|
14603
14611
|
body: new ReadableStream$1(),
|
|
14604
14612
|
method: "POST",
|
|
14605
14613
|
get duplex() {
|
|
@@ -14636,7 +14644,7 @@ var require_axios = __commonJS({
|
|
|
14636
14644
|
return body.size;
|
|
14637
14645
|
}
|
|
14638
14646
|
if (utils$1.isSpecCompliantForm(body)) {
|
|
14639
|
-
const _request = new
|
|
14647
|
+
const _request = new Request(platform.origin, {
|
|
14640
14648
|
method: "POST",
|
|
14641
14649
|
body
|
|
14642
14650
|
});
|
|
@@ -14684,7 +14692,7 @@ var require_axios = __commonJS({
|
|
|
14684
14692
|
let requestContentLength;
|
|
14685
14693
|
try {
|
|
14686
14694
|
if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
14687
|
-
let _request = new
|
|
14695
|
+
let _request = new Request(url2, {
|
|
14688
14696
|
method: "POST",
|
|
14689
14697
|
body: data,
|
|
14690
14698
|
duplex: "half"
|
|
@@ -14704,7 +14712,7 @@ var require_axios = __commonJS({
|
|
|
14704
14712
|
if (!utils$1.isString(withCredentials)) {
|
|
14705
14713
|
withCredentials = withCredentials ? "include" : "omit";
|
|
14706
14714
|
}
|
|
14707
|
-
const isCredentialsSupported = isRequestSupported && "credentials" in
|
|
14715
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
14708
14716
|
const resolvedOptions = {
|
|
14709
14717
|
...fetchOptions,
|
|
14710
14718
|
signal: composedSignal,
|
|
@@ -14714,7 +14722,7 @@ var require_axios = __commonJS({
|
|
|
14714
14722
|
duplex: "half",
|
|
14715
14723
|
credentials: isCredentialsSupported ? withCredentials : void 0
|
|
14716
14724
|
};
|
|
14717
|
-
request = isRequestSupported && new
|
|
14725
|
+
request = isRequestSupported && new Request(url2, resolvedOptions);
|
|
14718
14726
|
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
|
|
14719
14727
|
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
14720
14728
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
@@ -14741,8 +14749,8 @@ var require_axios = __commonJS({
|
|
|
14741
14749
|
config
|
|
14742
14750
|
);
|
|
14743
14751
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
14744
|
-
return await new Promise((
|
|
14745
|
-
settle(
|
|
14752
|
+
return await new Promise((resolve7, reject) => {
|
|
14753
|
+
settle(resolve7, reject, {
|
|
14746
14754
|
data: responseData,
|
|
14747
14755
|
headers: AxiosHeaders$1.from(response.headers),
|
|
14748
14756
|
status: response.status,
|
|
@@ -14774,8 +14782,8 @@ var require_axios = __commonJS({
|
|
|
14774
14782
|
var seedCache = /* @__PURE__ */ new Map();
|
|
14775
14783
|
var getFetch = (config) => {
|
|
14776
14784
|
let env = config && config.env || {};
|
|
14777
|
-
const { fetch: fetch2, Request
|
|
14778
|
-
const seeds = [
|
|
14785
|
+
const { fetch: fetch2, Request, Response: Response2 } = env;
|
|
14786
|
+
const seeds = [Request, Response2, fetch2];
|
|
14779
14787
|
let len = seeds.length, i = len, seed, target, map = seedCache;
|
|
14780
14788
|
while (i--) {
|
|
14781
14789
|
seed = seeds[i];
|
|
@@ -15146,8 +15154,8 @@ var require_axios = __commonJS({
|
|
|
15146
15154
|
throw new TypeError("executor must be a function.");
|
|
15147
15155
|
}
|
|
15148
15156
|
let resolvePromise;
|
|
15149
|
-
this.promise = new Promise(function promiseExecutor(
|
|
15150
|
-
resolvePromise =
|
|
15157
|
+
this.promise = new Promise(function promiseExecutor(resolve7) {
|
|
15158
|
+
resolvePromise = resolve7;
|
|
15151
15159
|
});
|
|
15152
15160
|
const token = this;
|
|
15153
15161
|
this.promise.then((cancel) => {
|
|
@@ -15160,9 +15168,9 @@ var require_axios = __commonJS({
|
|
|
15160
15168
|
});
|
|
15161
15169
|
this.promise.then = (onfulfilled) => {
|
|
15162
15170
|
let _resolve;
|
|
15163
|
-
const promise = new Promise((
|
|
15164
|
-
token.subscribe(
|
|
15165
|
-
_resolve =
|
|
15171
|
+
const promise = new Promise((resolve7) => {
|
|
15172
|
+
token.subscribe(resolve7);
|
|
15173
|
+
_resolve = resolve7;
|
|
15166
15174
|
}).then(onfulfilled);
|
|
15167
15175
|
promise.cancel = function reject() {
|
|
15168
15176
|
token.unsubscribe(_resolve);
|
|
@@ -17448,7 +17456,7 @@ var require_MsEdgeTTS = __commonJS({
|
|
|
17448
17456
|
};
|
|
17449
17457
|
const ws = this._ws = this._isBrowser ? new isomorphic_ws_1.default(synthUrl) : new isomorphic_ws_1.default(synthUrl, { ...options, agent: this._agent });
|
|
17450
17458
|
ws.binaryType = "arraybuffer";
|
|
17451
|
-
return new Promise((
|
|
17459
|
+
return new Promise((resolve7, reject) => {
|
|
17452
17460
|
let connecting = true;
|
|
17453
17461
|
const connectionTimeout = this._connectionTimeoutMs ? setTimeout(() => {
|
|
17454
17462
|
connecting = false;
|
|
@@ -17491,7 +17499,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
|
|
|
17491
17499
|
}
|
|
17492
17500
|
}
|
|
17493
17501
|
}
|
|
17494
|
-
`, void 0, ws).then(
|
|
17502
|
+
`, void 0, ws).then(resolve7, (error) => {
|
|
17495
17503
|
this._closeSocket(ws);
|
|
17496
17504
|
reject(error);
|
|
17497
17505
|
});
|
|
@@ -17633,12 +17641,12 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
|
|
|
17633
17641
|
this._log("<-", message);
|
|
17634
17642
|
return;
|
|
17635
17643
|
}
|
|
17636
|
-
await new Promise((
|
|
17644
|
+
await new Promise((resolve7, reject) => {
|
|
17637
17645
|
socket.send(message, (error) => {
|
|
17638
17646
|
if (error)
|
|
17639
17647
|
return reject(error);
|
|
17640
17648
|
this._log("<-", message);
|
|
17641
|
-
|
|
17649
|
+
resolve7();
|
|
17642
17650
|
});
|
|
17643
17651
|
});
|
|
17644
17652
|
}
|
|
@@ -17674,8 +17682,8 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
|
|
|
17674
17682
|
* 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).
|
|
17675
17683
|
*/
|
|
17676
17684
|
getVoices() {
|
|
17677
|
-
return new Promise((
|
|
17678
|
-
axios_1.default.get(_MsEdgeTTS.VOICES_URL).then((res) =>
|
|
17685
|
+
return new Promise((resolve7, reject) => {
|
|
17686
|
+
axios_1.default.get(_MsEdgeTTS.VOICES_URL).then((res) => resolve7(res.data)).catch(reject);
|
|
17679
17687
|
});
|
|
17680
17688
|
}
|
|
17681
17689
|
/**
|
|
@@ -17778,7 +17786,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
|
|
|
17778
17786
|
const metadataFilePath = !!metadataStream ? (0, utils_1.joinPath)(dirPath, "metadata.json") : null;
|
|
17779
17787
|
try {
|
|
17780
17788
|
await Promise.all([
|
|
17781
|
-
new Promise((
|
|
17789
|
+
new Promise((resolve7, reject) => {
|
|
17782
17790
|
const writableAudioFile = audioStream.pipe(fs.createWriteStream(audioFilePath));
|
|
17783
17791
|
audioStream.once("error", (e) => {
|
|
17784
17792
|
writableAudioFile.destroy();
|
|
@@ -17786,7 +17794,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
|
|
|
17786
17794
|
});
|
|
17787
17795
|
writableAudioFile.once("close", async () => {
|
|
17788
17796
|
if (writableAudioFile.bytesWritten > 0) {
|
|
17789
|
-
|
|
17797
|
+
resolve7(audioFilePath);
|
|
17790
17798
|
} else {
|
|
17791
17799
|
reject(new Error("No audio data received"));
|
|
17792
17800
|
fs.rmSync(audioFilePath, { force: true });
|
|
@@ -17794,9 +17802,9 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
|
|
|
17794
17802
|
});
|
|
17795
17803
|
writableAudioFile.once("error", reject);
|
|
17796
17804
|
}),
|
|
17797
|
-
new Promise((
|
|
17805
|
+
new Promise((resolve7, reject) => {
|
|
17798
17806
|
if (!metadataFilePath) {
|
|
17799
|
-
return
|
|
17807
|
+
return resolve7(null);
|
|
17800
17808
|
}
|
|
17801
17809
|
const metadataItems = { Metadata: [] };
|
|
17802
17810
|
metadataStream.on("data", (chunk) => {
|
|
@@ -17806,7 +17814,7 @@ Path:${messageTypes.SPEECH_CONFIG}${_MsEdgeTTS.JSON_XML_DELIM}
|
|
|
17806
17814
|
metadataStream.once("close", () => {
|
|
17807
17815
|
if (metadataItems.Metadata.length > 0) {
|
|
17808
17816
|
fs.writeFileSync(metadataFilePath, JSON.stringify(metadataItems, null, 2));
|
|
17809
|
-
|
|
17817
|
+
resolve7(metadataFilePath);
|
|
17810
17818
|
} else {
|
|
17811
17819
|
reject(new Error("No metadata received"));
|
|
17812
17820
|
fs.rmSync(metadataFilePath, { force: true });
|
|
@@ -18484,12 +18492,12 @@ async function setAgentPaused(workspaceId, paused) {
|
|
|
18484
18492
|
|
|
18485
18493
|
// ../api/src/dashboard/auth-context.ts
|
|
18486
18494
|
function onboardingPending(ctx) {
|
|
18487
|
-
const
|
|
18488
|
-
if (!ctx.onboarded && !ctx.passwordSet)
|
|
18489
|
-
if (!ctx.onboarded)
|
|
18490
|
-
if (ctx.role === "admin" && !ctx.agentConnectedAt)
|
|
18491
|
-
if (ctx.role === "admin" && !ctx.projectsSetupAt)
|
|
18492
|
-
return
|
|
18495
|
+
const pending = [];
|
|
18496
|
+
if (!ctx.onboarded && !ctx.passwordSet) pending.push("account");
|
|
18497
|
+
if (!ctx.onboarded) pending.push("profile");
|
|
18498
|
+
if (ctx.role === "admin" && !ctx.agentConnectedAt) pending.push("agent");
|
|
18499
|
+
if (ctx.role === "admin" && !ctx.projectsSetupAt) pending.push("projects");
|
|
18500
|
+
return pending;
|
|
18493
18501
|
}
|
|
18494
18502
|
var inFlight = /* @__PURE__ */ new Map();
|
|
18495
18503
|
var CACHE_TTL_MS2 = 3e4;
|
|
@@ -18790,8 +18798,8 @@ async function agentViewer(c) {
|
|
|
18790
18798
|
|
|
18791
18799
|
// src/claude/agent.ts
|
|
18792
18800
|
import { spawn } from "child_process";
|
|
18793
|
-
import { existsSync as
|
|
18794
|
-
import { resolve as
|
|
18801
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
|
|
18802
|
+
import { resolve as resolve3, resolve as resolvePath } from "path";
|
|
18795
18803
|
import { homedir as homedir2 } from "os";
|
|
18796
18804
|
import { randomUUID } from "crypto";
|
|
18797
18805
|
|
|
@@ -19186,6 +19194,111 @@ Nothing was run. Channels on the \`host\` runtime are unaffected.`
|
|
|
19186
19194
|
};
|
|
19187
19195
|
}
|
|
19188
19196
|
|
|
19197
|
+
// src/claude/plugin-ui.ts
|
|
19198
|
+
var SURFACE = "desktop";
|
|
19199
|
+
var CLIENT_ID = "flyspace";
|
|
19200
|
+
var RENDER_TIMEOUT_MS = 5e3;
|
|
19201
|
+
var SETTLE_TIMEOUT_MS = 2e3;
|
|
19202
|
+
var PluginUiSession = class {
|
|
19203
|
+
constructor(stdin) {
|
|
19204
|
+
this.stdin = stdin;
|
|
19205
|
+
}
|
|
19206
|
+
panes = [];
|
|
19207
|
+
status = {};
|
|
19208
|
+
pending = /* @__PURE__ */ new Map();
|
|
19209
|
+
seq = 0;
|
|
19210
|
+
onInvalidate;
|
|
19211
|
+
write(obj) {
|
|
19212
|
+
if (this.stdin.writable) this.stdin.write(`${JSON.stringify(obj)}
|
|
19213
|
+
`);
|
|
19214
|
+
}
|
|
19215
|
+
/** Attach as a surface, then send the user's prompt. */
|
|
19216
|
+
start(prompt) {
|
|
19217
|
+
this.write({
|
|
19218
|
+
type: "control_request",
|
|
19219
|
+
request_id: "flyspace-ui-attach",
|
|
19220
|
+
request: { subtype: "ui_attach", surface: SURFACE, client_id: CLIENT_ID }
|
|
19221
|
+
});
|
|
19222
|
+
this.write({ type: "user", message: { role: "user", content: prompt } });
|
|
19223
|
+
}
|
|
19224
|
+
/** Feed every parsed stdout event through here. */
|
|
19225
|
+
onEvent(event) {
|
|
19226
|
+
if (event.type === "control_response") {
|
|
19227
|
+
const res = event.response;
|
|
19228
|
+
const resolve7 = res?.request_id ? this.pending.get(res.request_id) : void 0;
|
|
19229
|
+
if (!resolve7 || !res?.request_id) return;
|
|
19230
|
+
this.pending.delete(res.request_id);
|
|
19231
|
+
resolve7(res.subtype === "success" ? res.response?.tree : void 0);
|
|
19232
|
+
return;
|
|
19233
|
+
}
|
|
19234
|
+
const e = event;
|
|
19235
|
+
if (e.type !== "system") return;
|
|
19236
|
+
if (e.subtype === "ui_invalidate") this.onInvalidate?.();
|
|
19237
|
+
if (e.subtype === "ui_panes" && Array.isArray(e.panes)) {
|
|
19238
|
+
this.panes = e.panes.filter((p) => typeof p?.id === "string").map((p) => ({
|
|
19239
|
+
id: p.id,
|
|
19240
|
+
title: p.title ?? p.id,
|
|
19241
|
+
...p.plugin ? { plugin: p.plugin } : {}
|
|
19242
|
+
}));
|
|
19243
|
+
} else if (e.subtype === "ui_status" && e.plugin) {
|
|
19244
|
+
if (e.text) this.status[e.plugin] = e.text;
|
|
19245
|
+
else delete this.status[e.plugin];
|
|
19246
|
+
}
|
|
19247
|
+
}
|
|
19248
|
+
render(instanceId) {
|
|
19249
|
+
const requestId = `flyspace-ui-render-${++this.seq}`;
|
|
19250
|
+
return new Promise((resolve7) => {
|
|
19251
|
+
this.pending.set(requestId, resolve7);
|
|
19252
|
+
this.write({
|
|
19253
|
+
type: "control_request",
|
|
19254
|
+
request_id: requestId,
|
|
19255
|
+
request: {
|
|
19256
|
+
subtype: "ui_render",
|
|
19257
|
+
surface: SURFACE,
|
|
19258
|
+
client_id: CLIENT_ID,
|
|
19259
|
+
component: "Pane",
|
|
19260
|
+
instance_id: instanceId,
|
|
19261
|
+
props: {}
|
|
19262
|
+
}
|
|
19263
|
+
});
|
|
19264
|
+
});
|
|
19265
|
+
}
|
|
19266
|
+
/**
|
|
19267
|
+
* Render every open pane, then close stdin so the CLI exits. Resolves with
|
|
19268
|
+
* the snapshot; panes whose render failed or timed out keep no tree.
|
|
19269
|
+
*/
|
|
19270
|
+
async finish() {
|
|
19271
|
+
if (this.panes.length) {
|
|
19272
|
+
await new Promise((resolve7) => {
|
|
19273
|
+
const timer2 = setTimeout(resolve7, SETTLE_TIMEOUT_MS);
|
|
19274
|
+
this.onInvalidate = () => {
|
|
19275
|
+
clearTimeout(timer2);
|
|
19276
|
+
resolve7();
|
|
19277
|
+
};
|
|
19278
|
+
});
|
|
19279
|
+
this.onInvalidate = void 0;
|
|
19280
|
+
}
|
|
19281
|
+
const renders = Promise.all(
|
|
19282
|
+
this.panes.map(async (p) => ({ ...p, tree: await this.render(p.id) }))
|
|
19283
|
+
);
|
|
19284
|
+
let timer;
|
|
19285
|
+
const timeout = new Promise((resolve7) => {
|
|
19286
|
+
timer = setTimeout(() => resolve7(void 0), RENDER_TIMEOUT_MS);
|
|
19287
|
+
});
|
|
19288
|
+
const rendered = await Promise.race([renders, timeout]);
|
|
19289
|
+
clearTimeout(timer);
|
|
19290
|
+
this.pending.clear();
|
|
19291
|
+
this.close();
|
|
19292
|
+
return {
|
|
19293
|
+
panes: rendered ?? this.panes,
|
|
19294
|
+
...Object.keys(this.status).length ? { status: { ...this.status } } : {}
|
|
19295
|
+
};
|
|
19296
|
+
}
|
|
19297
|
+
close() {
|
|
19298
|
+
if (this.stdin.writable) this.stdin.end();
|
|
19299
|
+
}
|
|
19300
|
+
};
|
|
19301
|
+
|
|
19189
19302
|
// src/claude/model-aliases.ts
|
|
19190
19303
|
var MODEL_ALIASES = {
|
|
19191
19304
|
fable: "claude-fable-5"
|
|
@@ -19194,88 +19307,6 @@ function resolveModelAlias(model) {
|
|
|
19194
19307
|
return MODEL_ALIASES[model.toLowerCase()] ?? model;
|
|
19195
19308
|
}
|
|
19196
19309
|
|
|
19197
|
-
// ../api/src/config.ts
|
|
19198
|
-
import dotenv from "dotenv";
|
|
19199
|
-
import { existsSync as existsSync5 } from "fs";
|
|
19200
|
-
import { resolve as resolve2 } from "path";
|
|
19201
|
-
var DEFAULT_CODEX_MODEL = "";
|
|
19202
|
-
function mcpStrictConfigEnabled() {
|
|
19203
|
-
return process.env["MCP_STRICT_CONFIG"]?.trim() === "true";
|
|
19204
|
-
}
|
|
19205
|
-
function loadEnvFiles() {
|
|
19206
|
-
if (existsSync5(paths.CONFIG_FILE)) {
|
|
19207
|
-
dotenv.config({ path: paths.CONFIG_FILE, override: true, quiet: true });
|
|
19208
|
-
}
|
|
19209
|
-
const candidates = [resolve2(paths.PACKAGE_ROOT, ".env"), resolve2(process.cwd(), ".env")];
|
|
19210
|
-
for (const path of new Set(candidates)) {
|
|
19211
|
-
if (existsSync5(path)) {
|
|
19212
|
-
dotenv.config({ path, override: false, quiet: true });
|
|
19213
|
-
}
|
|
19214
|
-
}
|
|
19215
|
-
}
|
|
19216
|
-
function parseBudget(raw) {
|
|
19217
|
-
if (raw === void 0) return 10;
|
|
19218
|
-
const n = Number.parseFloat(raw);
|
|
19219
|
-
if (!Number.isFinite(n) || n <= 0) return void 0;
|
|
19220
|
-
return n;
|
|
19221
|
-
}
|
|
19222
|
-
function parseEffort(raw) {
|
|
19223
|
-
const trimmed = raw?.trim().toLowerCase();
|
|
19224
|
-
return trimmed && isEffort(trimmed) ? trimmed : void 0;
|
|
19225
|
-
}
|
|
19226
|
-
var SLACK_ENV = ["SLACK_BOT_TOKEN", "SLACK_APP_TOKEN", "SLACK_SIGNING_SECRET"];
|
|
19227
|
-
function slackConfigured(env = process.env) {
|
|
19228
|
-
return SLACK_ENV.some((name) => env[name]?.trim());
|
|
19229
|
-
}
|
|
19230
|
-
function requireSlackBotToken(config) {
|
|
19231
|
-
if (!config.slackBotToken) {
|
|
19232
|
-
throw new Error("Slack is not configured: set SLACK_BOT_TOKEN to use Slack commands");
|
|
19233
|
-
}
|
|
19234
|
-
return config.slackBotToken;
|
|
19235
|
-
}
|
|
19236
|
-
function requireEnv(name) {
|
|
19237
|
-
const value = process.env[name];
|
|
19238
|
-
if (!value) {
|
|
19239
|
-
throw new Error(`Missing required environment variable: ${name}`);
|
|
19240
|
-
}
|
|
19241
|
-
return value;
|
|
19242
|
-
}
|
|
19243
|
-
function loadConfig() {
|
|
19244
|
-
const ownerUserId = process.env["OWNER_USER_ID"] || void 0;
|
|
19245
|
-
const allowedUserIds = new Set(
|
|
19246
|
-
(process.env["ALLOWED_USER_IDS"] ?? "").split(",").map((s) => s.trim()).filter(Boolean)
|
|
19247
|
-
);
|
|
19248
|
-
if (ownerUserId && allowedUserIds.size > 0) {
|
|
19249
|
-
allowedUserIds.add(ownerUserId);
|
|
19250
|
-
}
|
|
19251
|
-
const autoRespondChannelIds = new Set(
|
|
19252
|
-
(process.env["AUTO_RESPOND_CHANNEL_IDS"] ?? "").split(",").map((s) => s.trim()).filter(Boolean)
|
|
19253
|
-
);
|
|
19254
|
-
const slackEnglishOnlyExemptChannelIds = new Set(
|
|
19255
|
-
(process.env["SLACK_ENGLISH_ONLY_EXEMPT_CHANNEL_IDS"] ?? "").split(",").map((s) => s.trim()).filter(Boolean)
|
|
19256
|
-
);
|
|
19257
|
-
const slack = slackConfigured();
|
|
19258
|
-
return {
|
|
19259
|
-
slackBotToken: slack ? requireEnv("SLACK_BOT_TOKEN") : void 0,
|
|
19260
|
-
slackAppToken: slack ? requireEnv("SLACK_APP_TOKEN") : void 0,
|
|
19261
|
-
slackSigningSecret: slack ? requireEnv("SLACK_SIGNING_SECRET") : void 0,
|
|
19262
|
-
claudeCwd: process.env["CLAUDE_CWD"] ?? process.cwd(),
|
|
19263
|
-
claudeConfigDir: process.env["CLAUDE_CONFIG_DIR"] || void 0,
|
|
19264
|
-
claudeCodeOauthToken: process.env["CLAUDE_CODE_OAUTH_TOKEN"] || void 0,
|
|
19265
|
-
botName: process.env["BOT_NAME"] ?? "Bot",
|
|
19266
|
-
allowedUserIds,
|
|
19267
|
-
maxTurns: parseInt(process.env["MAX_TURNS"] ?? "10", 10),
|
|
19268
|
-
model: process.env["CUSTIE_MODEL"]?.trim() || "sonnet",
|
|
19269
|
-
effort: parseEffort(process.env["CUSTIE_EFFORT"]),
|
|
19270
|
-
maxBudgetUsd: parseBudget(process.env["MAX_BUDGET_USD"]),
|
|
19271
|
-
ownerUserId,
|
|
19272
|
-
autoRespondChannelIds,
|
|
19273
|
-
codexModel: process.env["CUSTIE_CODEX_MODEL"]?.trim() || DEFAULT_CODEX_MODEL,
|
|
19274
|
-
slackEnglishOnly: process.env["SLACK_ENGLISH_ONLY"] === "true",
|
|
19275
|
-
slackEnglishOnlyExemptChannelIds
|
|
19276
|
-
};
|
|
19277
|
-
}
|
|
19278
|
-
|
|
19279
19310
|
// ../api/src/utils/mise-env.ts
|
|
19280
19311
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
19281
19312
|
function resolveMiseEnv(cwd) {
|
|
@@ -19297,9 +19328,9 @@ function readMiseEnv(cwd) {
|
|
|
19297
19328
|
}
|
|
19298
19329
|
|
|
19299
19330
|
// ../api/src/store/output-styles-store.ts
|
|
19300
|
-
import { existsSync as
|
|
19331
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readdirSync, readFileSync as readFileSync2, renameSync, rmSync, statSync, writeFileSync as writeFileSync2 } from "fs";
|
|
19301
19332
|
import { homedir } from "os";
|
|
19302
|
-
import { join as join4, resolve as
|
|
19333
|
+
import { join as join4, resolve as resolve2, sep } from "path";
|
|
19303
19334
|
var BUILT_IN_OUTPUT_STYLES = [
|
|
19304
19335
|
{ slug: "default", name: "Default", description: "Claude Code\u2019s standard software engineering prompt." },
|
|
19305
19336
|
{ slug: "proactive", name: "Proactive", description: "Works autonomously and makes reasonable calls instead of asking." },
|
|
@@ -19318,8 +19349,8 @@ function stylesDir(claudeConfigDir) {
|
|
|
19318
19349
|
}
|
|
19319
19350
|
function styleFile(claudeConfigDir, id) {
|
|
19320
19351
|
if (!ID_RE.test(id)) return null;
|
|
19321
|
-
const dir =
|
|
19322
|
-
const file =
|
|
19352
|
+
const dir = resolve2(stylesDir(claudeConfigDir));
|
|
19353
|
+
const file = resolve2(dir, `${id}.md`);
|
|
19323
19354
|
return file.startsWith(dir + sep) ? file : null;
|
|
19324
19355
|
}
|
|
19325
19356
|
function slugify(name) {
|
|
@@ -19362,14 +19393,14 @@ ${p.body.trim()}
|
|
|
19362
19393
|
`;
|
|
19363
19394
|
}
|
|
19364
19395
|
function atomicWrite(file, content) {
|
|
19365
|
-
mkdirSync4(
|
|
19396
|
+
mkdirSync4(resolve2(file, ".."), { recursive: true });
|
|
19366
19397
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
19367
19398
|
writeFileSync2(tmp, content);
|
|
19368
19399
|
renameSync(tmp, file);
|
|
19369
19400
|
}
|
|
19370
19401
|
function readStyle(claudeConfigDir, id) {
|
|
19371
19402
|
const file = styleFile(claudeConfigDir, id);
|
|
19372
|
-
if (!file || !
|
|
19403
|
+
if (!file || !existsSync5(file)) return null;
|
|
19373
19404
|
const stat = statSync(file);
|
|
19374
19405
|
const p = parseStyle(readFileSync2(file, "utf8"), id);
|
|
19375
19406
|
return {
|
|
@@ -19383,7 +19414,7 @@ function readStyle(claudeConfigDir, id) {
|
|
|
19383
19414
|
}
|
|
19384
19415
|
function listOutputStyles(claudeConfigDir) {
|
|
19385
19416
|
const dir = stylesDir(claudeConfigDir);
|
|
19386
|
-
if (!
|
|
19417
|
+
if (!existsSync5(dir)) return [];
|
|
19387
19418
|
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));
|
|
19388
19419
|
}
|
|
19389
19420
|
function assertNameFree(claudeConfigDir, name, exceptId) {
|
|
@@ -19396,7 +19427,7 @@ function createOutputStyle(claudeConfigDir, params) {
|
|
|
19396
19427
|
if (!id) throw new Error("name must contain letters or digits");
|
|
19397
19428
|
assertNameFree(claudeConfigDir, params.name);
|
|
19398
19429
|
const file = styleFile(claudeConfigDir, id);
|
|
19399
|
-
if (
|
|
19430
|
+
if (existsSync5(file) || BUILT_IN_OUTPUT_STYLES.some((s) => s.slug === id)) {
|
|
19400
19431
|
throw new OutputStyleConflictError(`an output style named "${params.name}" already exists`);
|
|
19401
19432
|
}
|
|
19402
19433
|
atomicWrite(file, serialize({ ...params, extra: [] }));
|
|
@@ -19404,7 +19435,7 @@ function createOutputStyle(claudeConfigDir, params) {
|
|
|
19404
19435
|
}
|
|
19405
19436
|
function updateOutputStyle(claudeConfigDir, id, patch) {
|
|
19406
19437
|
const file = styleFile(claudeConfigDir, id);
|
|
19407
|
-
if (!file || !
|
|
19438
|
+
if (!file || !existsSync5(file)) return null;
|
|
19408
19439
|
const current = parseStyle(readFileSync2(file, "utf8"), id);
|
|
19409
19440
|
if (patch.name !== void 0 && patch.name !== current.name) assertNameFree(claudeConfigDir, patch.name, id);
|
|
19410
19441
|
const next = { ...current, ...patch };
|
|
@@ -19416,7 +19447,7 @@ function updateOutputStyle(claudeConfigDir, id, patch) {
|
|
|
19416
19447
|
}
|
|
19417
19448
|
function deleteOutputStyle(claudeConfigDir, id) {
|
|
19418
19449
|
const file = styleFile(claudeConfigDir, id);
|
|
19419
|
-
if (!file || !
|
|
19450
|
+
if (!file || !existsSync5(file)) return false;
|
|
19420
19451
|
const name = parseStyle(readFileSync2(file, "utf8"), id).name;
|
|
19421
19452
|
rmSync(file);
|
|
19422
19453
|
if (readSettings(claudeConfigDir)["outputStyle"] === name) writeDefaultName(claudeConfigDir, void 0);
|
|
@@ -19427,7 +19458,7 @@ function settingsFile(claudeConfigDir) {
|
|
|
19427
19458
|
}
|
|
19428
19459
|
function readSettings(claudeConfigDir) {
|
|
19429
19460
|
const file = settingsFile(claudeConfigDir);
|
|
19430
|
-
if (!
|
|
19461
|
+
if (!existsSync5(file)) return {};
|
|
19431
19462
|
const parsed = JSON.parse(readFileSync2(file, "utf8"));
|
|
19432
19463
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19433
19464
|
throw new Error(`${file} is not a JSON object`);
|
|
@@ -19674,7 +19705,9 @@ var KILLED_TOOL_RE = /exit code (137|143)\b|command timed out after/i;
|
|
|
19674
19705
|
function hasKilledToolResult(event) {
|
|
19675
19706
|
if (event.type !== "user") return false;
|
|
19676
19707
|
return (event.message?.content ?? []).some(
|
|
19677
|
-
(block) => block.type === "tool_result" && block.is_error === true && KILLED_TOOL_RE.test(
|
|
19708
|
+
(block) => block.type === "tool_result" && block.is_error === true && KILLED_TOOL_RE.test(
|
|
19709
|
+
typeof block.content === "string" ? block.content : JSON.stringify(block.content ?? "")
|
|
19710
|
+
)
|
|
19678
19711
|
);
|
|
19679
19712
|
}
|
|
19680
19713
|
function extractActivities(event) {
|
|
@@ -19869,13 +19902,13 @@ function getMaxDurationMs(streaming) {
|
|
|
19869
19902
|
}
|
|
19870
19903
|
function loadSystemPrompt() {
|
|
19871
19904
|
const customPath = paths.PROMPT_FILE;
|
|
19872
|
-
const defaultPath =
|
|
19873
|
-
const filePath =
|
|
19905
|
+
const defaultPath = resolve3(paths.PACKAGE_ROOT, "system.default.md");
|
|
19906
|
+
const filePath = existsSync6(customPath) ? customPath : defaultPath;
|
|
19874
19907
|
return readFileSync3(filePath, "utf-8").trim();
|
|
19875
19908
|
}
|
|
19876
19909
|
function loadPackagePrompt(file) {
|
|
19877
|
-
const filePath =
|
|
19878
|
-
if (!
|
|
19910
|
+
const filePath = resolve3(paths.PACKAGE_ROOT, file);
|
|
19911
|
+
if (!existsSync6(filePath)) return "";
|
|
19879
19912
|
return readFileSync3(filePath, "utf-8").trim();
|
|
19880
19913
|
}
|
|
19881
19914
|
function loadCapabilities(slackBound) {
|
|
@@ -19940,7 +19973,7 @@ function owningServiceLabel(env = process.env) {
|
|
|
19940
19973
|
return /^[A-Za-z0-9._-]+$/.test(label) ? label : void 0;
|
|
19941
19974
|
}
|
|
19942
19975
|
function buildHookSettings(runtime, builtInStyleName) {
|
|
19943
|
-
const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` :
|
|
19976
|
+
const guardScript = runtime === "container" ? `${CONTAINER_PATHS.hooks}/bash-guard.mjs` : resolve3(paths.PACKAGE_ROOT, "hooks/bash-guard.mjs");
|
|
19944
19977
|
const selfLabel = runtime === "container" ? void 0 : owningServiceLabel();
|
|
19945
19978
|
const guardEnv = selfLabel ? `FLYSPACE_SELF_SERVICE_LABEL='${selfLabel}' ` : "";
|
|
19946
19979
|
return JSON.stringify({
|
|
@@ -19959,6 +19992,9 @@ function isModelForGateway(model, pinned) {
|
|
|
19959
19992
|
if (!pinned) return true;
|
|
19960
19993
|
return model.split("-")[0].toLowerCase() === pinned.split("-")[0].toLowerCase();
|
|
19961
19994
|
}
|
|
19995
|
+
function usesPluginUi(options) {
|
|
19996
|
+
return Boolean(options.onPluginUi && options.onActivity) && (options.runtime ?? "host") === "host";
|
|
19997
|
+
}
|
|
19962
19998
|
function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
|
|
19963
19999
|
const args = [
|
|
19964
20000
|
"--print",
|
|
@@ -19966,6 +20002,7 @@ function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
|
|
|
19966
20002
|
// activity); plain json emits one blob on completion. stream-json with
|
|
19967
20003
|
// --print requires --verbose.
|
|
19968
20004
|
...options.onActivity ? ["--output-format", "stream-json", "--verbose"] : ["--output-format", "json"],
|
|
20005
|
+
...usesPluginUi(options) ? ["--input-format", "stream-json"] : [],
|
|
19969
20006
|
...permissionArgs(options.permissionMode, options.permissionPromptTool),
|
|
19970
20007
|
"--no-chrome",
|
|
19971
20008
|
// `=` form: the flag is variadic and would otherwise swallow the next token.
|
|
@@ -20019,7 +20056,7 @@ function buildArgs(prompt, botName, options, resumeSessionId, isolatedStyle) {
|
|
|
20019
20056
|
if (resumeSessionId) {
|
|
20020
20057
|
args.push("--resume", resumeSessionId);
|
|
20021
20058
|
}
|
|
20022
|
-
args.push(prompt);
|
|
20059
|
+
if (!usesPluginUi(options)) args.push(prompt);
|
|
20023
20060
|
return args;
|
|
20024
20061
|
}
|
|
20025
20062
|
function recordUsage2(response, options) {
|
|
@@ -20037,7 +20074,7 @@ function pinnedClaudeConfigDir(dir) {
|
|
|
20037
20074
|
return resolvePath(dir.replace(/^~(?=\/|$)/, homedir2())) === resolvePath(homedir2(), ".claude") ? void 0 : dir;
|
|
20038
20075
|
}
|
|
20039
20076
|
function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
|
|
20040
|
-
return new Promise((
|
|
20077
|
+
return new Promise((resolve7, reject) => {
|
|
20041
20078
|
const isolated = options.runtime === "container" || options.runtime === "sandbox";
|
|
20042
20079
|
const args = buildArgs(
|
|
20043
20080
|
prompt,
|
|
@@ -20048,7 +20085,8 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20048
20085
|
);
|
|
20049
20086
|
const env = resolveMiseEnv(cwd);
|
|
20050
20087
|
env["FLYSPACE_SCRATCH_DIR"] = paths.SCRATCH_DIR;
|
|
20051
|
-
if (options.permissionPromptTool && !env["MCP_TOOL_TIMEOUT"])
|
|
20088
|
+
if (options.permissionPromptTool && !env["MCP_TOOL_TIMEOUT"])
|
|
20089
|
+
env["MCP_TOOL_TIMEOUT"] = "360000";
|
|
20052
20090
|
env["CLAUDE_CODE_ARTIFACT"] = "1";
|
|
20053
20091
|
if (options.disableAutoMemory) env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"] = "1";
|
|
20054
20092
|
else delete env["CLAUDE_CODE_DISABLE_AUTO_MEMORY"];
|
|
@@ -20091,7 +20129,11 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20091
20129
|
env: plan.env,
|
|
20092
20130
|
stdio: ["pipe", "pipe", "pipe"]
|
|
20093
20131
|
});
|
|
20094
|
-
child.stdin
|
|
20132
|
+
const pluginUi = usesPluginUi(options) ? new PluginUiSession(child.stdin) : void 0;
|
|
20133
|
+
child.stdin.on("error", () => {
|
|
20134
|
+
});
|
|
20135
|
+
if (pluginUi) pluginUi.start(prompt);
|
|
20136
|
+
else child.stdin.end();
|
|
20095
20137
|
let stdout = "";
|
|
20096
20138
|
let stderr = "";
|
|
20097
20139
|
let timedOut = false;
|
|
@@ -20161,6 +20203,17 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20161
20203
|
}
|
|
20162
20204
|
if (event.session_id) liveSessionId = event.session_id;
|
|
20163
20205
|
if (event.type === "result") streamResultLine = line;
|
|
20206
|
+
if (pluginUi) {
|
|
20207
|
+
pluginUi.onEvent(event);
|
|
20208
|
+
if (event.type === "result") {
|
|
20209
|
+
void pluginUi.finish().then((state) => {
|
|
20210
|
+
try {
|
|
20211
|
+
options.onPluginUi?.(state);
|
|
20212
|
+
} catch {
|
|
20213
|
+
}
|
|
20214
|
+
});
|
|
20215
|
+
}
|
|
20216
|
+
}
|
|
20164
20217
|
if (hasKilledToolResult(event)) killedTool = true;
|
|
20165
20218
|
if (event.type === "assistant" && !event.parent_tool_use_id) {
|
|
20166
20219
|
for (const block of event.message?.content ?? []) {
|
|
@@ -20203,7 +20256,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20203
20256
|
console.log(`[agent] stderr: ${stderr.trim()}`);
|
|
20204
20257
|
}
|
|
20205
20258
|
if (cancelled) {
|
|
20206
|
-
|
|
20259
|
+
resolve7({
|
|
20207
20260
|
sessionId: liveSessionId ?? resumeSessionId ?? "",
|
|
20208
20261
|
text: "",
|
|
20209
20262
|
isCancelled: true
|
|
@@ -20212,7 +20265,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20212
20265
|
}
|
|
20213
20266
|
if (timedOut) {
|
|
20214
20267
|
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.`;
|
|
20215
|
-
|
|
20268
|
+
resolve7({
|
|
20216
20269
|
sessionId: liveSessionId ?? resumeSessionId ?? "",
|
|
20217
20270
|
text,
|
|
20218
20271
|
isError: true,
|
|
@@ -20250,7 +20303,7 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20250
20303
|
!!claudeCodeOauthToken
|
|
20251
20304
|
);
|
|
20252
20305
|
recordUsage2(response, options);
|
|
20253
|
-
|
|
20306
|
+
resolve7(
|
|
20254
20307
|
response.isError ? {
|
|
20255
20308
|
...response,
|
|
20256
20309
|
failure: {
|
|
@@ -20264,13 +20317,13 @@ function runCli(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId,
|
|
|
20264
20317
|
);
|
|
20265
20318
|
} catch {
|
|
20266
20319
|
const fallback = onLine ? "" : stdout.trim();
|
|
20267
|
-
|
|
20320
|
+
resolve7({ sessionId: resumeSessionId ?? "", text: fallback || "No response" });
|
|
20268
20321
|
}
|
|
20269
20322
|
});
|
|
20270
20323
|
});
|
|
20271
20324
|
}
|
|
20272
20325
|
async function askClaude(prompt, cwd, botName, options, claudeConfigDir, resumeSessionId, claudeCodeOauthToken) {
|
|
20273
|
-
if (!
|
|
20326
|
+
if (!existsSync6(cwd) || !statSync2(cwd).isDirectory()) {
|
|
20274
20327
|
console.error(`[agent] working directory does not exist: ${cwd}`);
|
|
20275
20328
|
return {
|
|
20276
20329
|
sessionId: resumeSessionId ?? "",
|
|
@@ -20929,434 +20982,12 @@ async function runCompanion(config, userId, slot) {
|
|
|
20929
20982
|
}
|
|
20930
20983
|
|
|
20931
20984
|
// src/commands/persona.ts
|
|
20932
|
-
import { execFileSync as
|
|
20985
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
20933
20986
|
import { createHash as createHash3 } from "crypto";
|
|
20934
|
-
import { existsSync as
|
|
20987
|
+
import { existsSync as existsSync7, mkdtempSync as mkdtempSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
20935
20988
|
import { homedir as homedir3 } from "os";
|
|
20936
|
-
import { basename as basename2, join as
|
|
20989
|
+
import { basename as basename2, join as join6 } from "path";
|
|
20937
20990
|
import sharp from "sharp";
|
|
20938
|
-
|
|
20939
|
-
// src/auth/device-auth.ts
|
|
20940
|
-
import { createPrivateKey, createPublicKey, generateKeyPairSync, sign } from "crypto";
|
|
20941
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync4, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
20942
|
-
import { dirname, join as join6 } from "path";
|
|
20943
|
-
var DEFAULT_API_URL = "https://app.flyspace.ai";
|
|
20944
|
-
var EXPIRY_SKEW_MS = 6e4;
|
|
20945
|
-
var AuthApiError = class extends Error {
|
|
20946
|
-
constructor(message, status) {
|
|
20947
|
-
super(message);
|
|
20948
|
-
this.status = status;
|
|
20949
|
-
this.name = "AuthApiError";
|
|
20950
|
-
}
|
|
20951
|
-
};
|
|
20952
|
-
function apiUrl() {
|
|
20953
|
-
return (process.env["FLYSPACE_API_URL"] || DEFAULT_API_URL).replace(/\/+$/, "");
|
|
20954
|
-
}
|
|
20955
|
-
function deviceKeyPath() {
|
|
20956
|
-
return join6(paths.BASE_CONFIG_DIR, "device.key");
|
|
20957
|
-
}
|
|
20958
|
-
function credentialsPath() {
|
|
20959
|
-
return join6(paths.BASE_CONFIG_DIR, "credentials.json");
|
|
20960
|
-
}
|
|
20961
|
-
function ensureDeviceKey(path = deviceKeyPath()) {
|
|
20962
|
-
let created = false;
|
|
20963
|
-
if (!existsSync8(path)) {
|
|
20964
|
-
const { privateKey: privateKey2 } = generateKeyPairSync("ed25519");
|
|
20965
|
-
mkdirSync5(dirname(path), { recursive: true });
|
|
20966
|
-
writeFileSync3(path, privateKey2.export({ type: "pkcs8", format: "pem" }), { mode: 384 });
|
|
20967
|
-
created = true;
|
|
20968
|
-
}
|
|
20969
|
-
const privateKey = createPrivateKey(readFileSync4(path, "utf8"));
|
|
20970
|
-
const publicKeyBase64 = createPublicKey(privateKey).export({ type: "spki", format: "der" }).toString(
|
|
20971
|
-
"base64"
|
|
20972
|
-
);
|
|
20973
|
-
return { privateKey, publicKeyBase64, created };
|
|
20974
|
-
}
|
|
20975
|
-
function loadCredentials(path = credentialsPath()) {
|
|
20976
|
-
if (!existsSync8(path)) return null;
|
|
20977
|
-
try {
|
|
20978
|
-
return JSON.parse(readFileSync4(path, "utf8"));
|
|
20979
|
-
} catch {
|
|
20980
|
-
return null;
|
|
20981
|
-
}
|
|
20982
|
-
}
|
|
20983
|
-
function saveCredentials(creds, path = credentialsPath()) {
|
|
20984
|
-
mkdirSync5(dirname(path), { recursive: true });
|
|
20985
|
-
writeFileSync3(path, `${JSON.stringify(creds, null, 2)}
|
|
20986
|
-
`, { mode: 384 });
|
|
20987
|
-
}
|
|
20988
|
-
function clearLocalAuth() {
|
|
20989
|
-
rmSync3(credentialsPath(), { force: true });
|
|
20990
|
-
rmSync3(deviceKeyPath(), { force: true });
|
|
20991
|
-
}
|
|
20992
|
-
async function post(base, path, body, token) {
|
|
20993
|
-
return fetch(`${base}${path}`, {
|
|
20994
|
-
method: "POST",
|
|
20995
|
-
headers: {
|
|
20996
|
-
"content-type": "application/json",
|
|
20997
|
-
...token ? { authorization: `Bearer ${token}` } : {}
|
|
20998
|
-
},
|
|
20999
|
-
body: JSON.stringify(body)
|
|
21000
|
-
});
|
|
21001
|
-
}
|
|
21002
|
-
async function readJson(res) {
|
|
21003
|
-
try {
|
|
21004
|
-
return await res.json();
|
|
21005
|
-
} catch {
|
|
21006
|
-
return {};
|
|
21007
|
-
}
|
|
21008
|
-
}
|
|
21009
|
-
async function expectOk(res, what) {
|
|
21010
|
-
const json = await readJson(res);
|
|
21011
|
-
if (!res.ok) {
|
|
21012
|
-
const reason = typeof json["error"] === "string" ? json["error"] : res.statusText;
|
|
21013
|
-
throw new AuthApiError(`${what} failed (${res.status}): ${reason}`, res.status);
|
|
21014
|
-
}
|
|
21015
|
-
return json;
|
|
21016
|
-
}
|
|
21017
|
-
function toSlugs(value) {
|
|
21018
|
-
return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
|
|
21019
|
-
}
|
|
21020
|
-
function toGrant(json) {
|
|
21021
|
-
const user = json["user"] ?? {};
|
|
21022
|
-
return {
|
|
21023
|
-
accessToken: String(json["access_token"]),
|
|
21024
|
-
expiresIn: Number(json["expires_in"]),
|
|
21025
|
-
deviceId: String(json["device_id"]),
|
|
21026
|
-
userEmail: String(user["email"] ?? ""),
|
|
21027
|
-
workspaces: toSlugs(json["workspaces"])
|
|
21028
|
-
};
|
|
21029
|
-
}
|
|
21030
|
-
async function requestDeviceCode(base, input) {
|
|
21031
|
-
const res = await post(base, "/api/auth/device/code", {
|
|
21032
|
-
public_key: input.publicKey,
|
|
21033
|
-
name: input.name,
|
|
21034
|
-
platform: input.platform
|
|
21035
|
-
});
|
|
21036
|
-
const json = await expectOk(res, "Requesting a device code");
|
|
21037
|
-
return {
|
|
21038
|
-
deviceCode: String(json["device_code"]),
|
|
21039
|
-
userCode: String(json["user_code"]),
|
|
21040
|
-
verificationUri: String(json["verification_uri"]),
|
|
21041
|
-
expiresIn: Number(json["expires_in"]),
|
|
21042
|
-
interval: Number(json["interval"] ?? 5)
|
|
21043
|
-
};
|
|
21044
|
-
}
|
|
21045
|
-
async function pollDeviceToken(base, deviceCode) {
|
|
21046
|
-
const res = await post(base, "/api/auth/device/token", { device_code: deviceCode });
|
|
21047
|
-
const json = await readJson(res);
|
|
21048
|
-
if (res.ok) return { status: "approved", grant: toGrant(json) };
|
|
21049
|
-
switch (json["error"]) {
|
|
21050
|
-
case "authorization_pending":
|
|
21051
|
-
return { status: "pending" };
|
|
21052
|
-
case "slow_down":
|
|
21053
|
-
return { status: "slow_down" };
|
|
21054
|
-
case "access_denied":
|
|
21055
|
-
return { status: "denied" };
|
|
21056
|
-
case "expired_token":
|
|
21057
|
-
return { status: "expired" };
|
|
21058
|
-
default:
|
|
21059
|
-
throw new AuthApiError(`Polling for approval failed (${res.status}): ${String(json["error"] ?? res.statusText)}`, res.status);
|
|
21060
|
-
}
|
|
21061
|
-
}
|
|
21062
|
-
async function refreshAccessToken(creds, privateKey) {
|
|
21063
|
-
const challenge = await expectOk(
|
|
21064
|
-
await post(creds.apiUrl, "/api/auth/device/challenge", { device_id: creds.deviceId }),
|
|
21065
|
-
"Requesting a refresh challenge"
|
|
21066
|
-
);
|
|
21067
|
-
const nonce = String(challenge["nonce"]);
|
|
21068
|
-
const signature = sign(null, Buffer.from(nonce), privateKey).toString("base64");
|
|
21069
|
-
const json = await expectOk(
|
|
21070
|
-
await post(creds.apiUrl, "/api/auth/device/refresh", { device_id: creds.deviceId, nonce, signature }),
|
|
21071
|
-
"Refreshing the access token"
|
|
21072
|
-
);
|
|
21073
|
-
return {
|
|
21074
|
-
...creds,
|
|
21075
|
-
accessToken: String(json["access_token"]),
|
|
21076
|
-
accessTokenExpiresAt: Date.now() + Number(json["expires_in"]) * 1e3
|
|
21077
|
-
};
|
|
21078
|
-
}
|
|
21079
|
-
async function fetchWhoAmI(base, token) {
|
|
21080
|
-
const res = await fetch(`${base}/api/auth/device/me`, { headers: { authorization: `Bearer ${token}` } });
|
|
21081
|
-
const json = await expectOk(res, "Checking the session");
|
|
21082
|
-
const user = json["user"] ?? {};
|
|
21083
|
-
const device = json["device"] ?? {};
|
|
21084
|
-
return {
|
|
21085
|
-
userEmail: String(user["email"] ?? ""),
|
|
21086
|
-
deviceId: String(device["id"] ?? ""),
|
|
21087
|
-
deviceName: String(device["name"] ?? ""),
|
|
21088
|
-
workspaces: toSlugs(json["workspaces"])
|
|
21089
|
-
};
|
|
21090
|
-
}
|
|
21091
|
-
async function boundWorkspaces() {
|
|
21092
|
-
const creds = loadCredentials();
|
|
21093
|
-
if (!creds) return null;
|
|
21094
|
-
try {
|
|
21095
|
-
const me = await fetchWhoAmI(creds.apiUrl, await getAccessToken());
|
|
21096
|
-
saveCredentials({ ...loadCredentials() ?? creds, workspaces: me.workspaces });
|
|
21097
|
-
return { workspaces: me.workspaces, fresh: true };
|
|
21098
|
-
} catch {
|
|
21099
|
-
return { workspaces: creds.workspaces ?? [], fresh: false };
|
|
21100
|
-
}
|
|
21101
|
-
}
|
|
21102
|
-
async function revokeDevice(base, token) {
|
|
21103
|
-
await expectOk(await post(base, "/api/auth/device/revoke", {}, token), "Revoking this device");
|
|
21104
|
-
}
|
|
21105
|
-
async function getAccessToken() {
|
|
21106
|
-
const fromEnv = process.env["FLYSPACE_TOKEN"];
|
|
21107
|
-
if (fromEnv) return fromEnv;
|
|
21108
|
-
const creds = loadCredentials();
|
|
21109
|
-
if (!creds) return null;
|
|
21110
|
-
if (creds.accessTokenExpiresAt - EXPIRY_SKEW_MS > Date.now()) return creds.accessToken;
|
|
21111
|
-
const { privateKey } = ensureDeviceKey();
|
|
21112
|
-
const refreshed = await refreshAccessToken(creds, privateKey);
|
|
21113
|
-
saveCredentials(refreshed);
|
|
21114
|
-
return refreshed.accessToken;
|
|
21115
|
-
}
|
|
21116
|
-
|
|
21117
|
-
// src/dashboard/host-db-client.ts
|
|
21118
|
-
import { createClient } from "@supabase/supabase-js";
|
|
21119
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
21120
|
-
|
|
21121
|
-
// src/dashboard/host-lock.ts
|
|
21122
|
-
import { execFileSync as execFileSync4 } from "child_process";
|
|
21123
|
-
import { randomBytes } from "crypto";
|
|
21124
|
-
import { mkdirSync as mkdirSync6, readFileSync as readFileSync5, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
21125
|
-
import { join as join7 } from "path";
|
|
21126
|
-
function hostLockPath() {
|
|
21127
|
-
return join7(paths.BASE_DATA_DIR, "host.lock");
|
|
21128
|
-
}
|
|
21129
|
-
function isLiveFlyspace(pid) {
|
|
21130
|
-
try {
|
|
21131
|
-
process.kill(pid, 0);
|
|
21132
|
-
const command = execFileSync4("ps", ["-p", String(pid), "-o", "command="], {
|
|
21133
|
-
encoding: "utf8"
|
|
21134
|
-
});
|
|
21135
|
-
return command.includes("flyspace") || command.includes("host-server");
|
|
21136
|
-
} catch {
|
|
21137
|
-
return false;
|
|
21138
|
-
}
|
|
21139
|
-
}
|
|
21140
|
-
function readLockPid(path) {
|
|
21141
|
-
try {
|
|
21142
|
-
const pid = Number(JSON.parse(readFileSync5(path, "utf8")).pid);
|
|
21143
|
-
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
21144
|
-
} catch {
|
|
21145
|
-
return null;
|
|
21146
|
-
}
|
|
21147
|
-
}
|
|
21148
|
-
function acquireHostLock() {
|
|
21149
|
-
const path = hostLockPath();
|
|
21150
|
-
mkdirSync6(paths.BASE_DATA_DIR, { recursive: true });
|
|
21151
|
-
const body = JSON.stringify({
|
|
21152
|
-
pid: process.pid,
|
|
21153
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21154
|
-
execPath: process.argv[1] ?? ""
|
|
21155
|
-
});
|
|
21156
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
21157
|
-
try {
|
|
21158
|
-
writeFileSync4(path, body, { flag: "wx", mode: 384 });
|
|
21159
|
-
const release = () => {
|
|
21160
|
-
if (readLockPid(path) === process.pid) rmSync4(path, { force: true });
|
|
21161
|
-
};
|
|
21162
|
-
process.once("exit", release);
|
|
21163
|
-
return release;
|
|
21164
|
-
} catch (err) {
|
|
21165
|
-
if (err.code !== "EEXIST") throw err;
|
|
21166
|
-
const holder = readLockPid(path);
|
|
21167
|
-
if (holder === process.pid) return () => {
|
|
21168
|
-
};
|
|
21169
|
-
if (holder && isLiveFlyspace(holder)) {
|
|
21170
|
-
throw new Error(
|
|
21171
|
-
`Another Flyspace Host is already running on this machine (pid ${holder}). Stop it first, or check for a second CLI install (\`which -a flyspace\`). Two Hosts overwrite each other's skill mirror.`
|
|
21172
|
-
);
|
|
21173
|
-
}
|
|
21174
|
-
rmSync4(path, { force: true });
|
|
21175
|
-
}
|
|
21176
|
-
}
|
|
21177
|
-
throw new Error(`Could not take the Host lock at ${path}`);
|
|
21178
|
-
}
|
|
21179
|
-
function publishHostEndpoint(port) {
|
|
21180
|
-
const path = hostLockPath();
|
|
21181
|
-
if (readLockPid(path) !== process.pid) return null;
|
|
21182
|
-
const token = randomBytes(32).toString("hex");
|
|
21183
|
-
const lock = JSON.parse(readFileSync5(path, "utf8"));
|
|
21184
|
-
writeFileSync4(path, JSON.stringify({ ...lock, port, token }), { mode: 384 });
|
|
21185
|
-
return token;
|
|
21186
|
-
}
|
|
21187
|
-
function readHostEndpoint() {
|
|
21188
|
-
try {
|
|
21189
|
-
const { pid, port, token } = JSON.parse(readFileSync5(hostLockPath(), "utf8"));
|
|
21190
|
-
if (pid === process.pid || !Number.isInteger(port) || typeof token !== "string") return null;
|
|
21191
|
-
return { port, token };
|
|
21192
|
-
} catch {
|
|
21193
|
-
return null;
|
|
21194
|
-
}
|
|
21195
|
-
}
|
|
21196
|
-
|
|
21197
|
-
// src/dashboard/host-db-client.ts
|
|
21198
|
-
var REQUEST_TIMEOUT_MS2 = 3e4;
|
|
21199
|
-
var pending = /* @__PURE__ */ new Map();
|
|
21200
|
-
var sender = null;
|
|
21201
|
-
var onSender = [];
|
|
21202
|
-
function setHostDbSender(fn) {
|
|
21203
|
-
sender = fn;
|
|
21204
|
-
if (!fn) return;
|
|
21205
|
-
const waiting = onSender;
|
|
21206
|
-
onSender = [];
|
|
21207
|
-
for (const wake of waiting) wake();
|
|
21208
|
-
}
|
|
21209
|
-
function sendAgentFailure(report) {
|
|
21210
|
-
sender?.({ type: "agent-failure", ...report });
|
|
21211
|
-
}
|
|
21212
|
-
function handleHostDbResult(id, res) {
|
|
21213
|
-
const p = pending.get(id);
|
|
21214
|
-
if (!p) return;
|
|
21215
|
-
pending.delete(id);
|
|
21216
|
-
clearTimeout(p.timer);
|
|
21217
|
-
p.resolve(res);
|
|
21218
|
-
}
|
|
21219
|
-
function whenConnected() {
|
|
21220
|
-
if (sender) return Promise.resolve(sender);
|
|
21221
|
-
return new Promise((resolve8, reject) => {
|
|
21222
|
-
const timer = setTimeout(() => {
|
|
21223
|
-
onSender = onSender.filter((w) => w !== wake);
|
|
21224
|
-
reject(new Error("Host is not connected to the Data API"));
|
|
21225
|
-
}, REQUEST_TIMEOUT_MS2);
|
|
21226
|
-
const wake = () => {
|
|
21227
|
-
clearTimeout(timer);
|
|
21228
|
-
resolve8(sender);
|
|
21229
|
-
};
|
|
21230
|
-
onSender.push(wake);
|
|
21231
|
-
});
|
|
21232
|
-
}
|
|
21233
|
-
async function requestHostDb(req) {
|
|
21234
|
-
const send = await whenConnected();
|
|
21235
|
-
const id = randomUUID2();
|
|
21236
|
-
return new Promise((resolve8, reject) => {
|
|
21237
|
-
const timer = setTimeout(() => {
|
|
21238
|
-
pending.delete(id);
|
|
21239
|
-
reject(new Error("Data API did not answer in time"));
|
|
21240
|
-
}, REQUEST_TIMEOUT_MS2);
|
|
21241
|
-
pending.set(id, { resolve: resolve8, reject, timer });
|
|
21242
|
-
send({ type: "db", id, req });
|
|
21243
|
-
});
|
|
21244
|
-
}
|
|
21245
|
-
var pendingUrls = /* @__PURE__ */ new Map();
|
|
21246
|
-
function handleAttachmentUrlResult(id, url) {
|
|
21247
|
-
pendingUrls.get(id)?.(url);
|
|
21248
|
-
pendingUrls.delete(id);
|
|
21249
|
-
}
|
|
21250
|
-
async function requestAttachmentUrl(key) {
|
|
21251
|
-
const send = await whenConnected();
|
|
21252
|
-
const id = randomUUID2();
|
|
21253
|
-
return new Promise((resolve8, reject) => {
|
|
21254
|
-
const timer = setTimeout(() => {
|
|
21255
|
-
pendingUrls.delete(id);
|
|
21256
|
-
reject(new Error("Data API did not answer in time"));
|
|
21257
|
-
}, REQUEST_TIMEOUT_MS2);
|
|
21258
|
-
pendingUrls.set(id, (url) => {
|
|
21259
|
-
clearTimeout(timer);
|
|
21260
|
-
resolve8(url);
|
|
21261
|
-
});
|
|
21262
|
-
send({ type: "attachment-url", id, key });
|
|
21263
|
-
});
|
|
21264
|
-
}
|
|
21265
|
-
var pendingRespond = /* @__PURE__ */ new Map();
|
|
21266
|
-
function handleShouldRespondResult(id, respond) {
|
|
21267
|
-
pendingRespond.get(id)?.(respond);
|
|
21268
|
-
pendingRespond.delete(id);
|
|
21269
|
-
}
|
|
21270
|
-
async function requestShouldRespond(transcript) {
|
|
21271
|
-
const send = await whenConnected().catch(() => null);
|
|
21272
|
-
if (!send) return false;
|
|
21273
|
-
const id = randomUUID2();
|
|
21274
|
-
return new Promise((resolve8) => {
|
|
21275
|
-
const timer = setTimeout(() => {
|
|
21276
|
-
pendingRespond.delete(id);
|
|
21277
|
-
resolve8(false);
|
|
21278
|
-
}, REQUEST_TIMEOUT_MS2);
|
|
21279
|
-
pendingRespond.set(id, (respond) => {
|
|
21280
|
-
clearTimeout(timer);
|
|
21281
|
-
resolve8(respond);
|
|
21282
|
-
});
|
|
21283
|
-
send({ type: "should-respond", id, transcript });
|
|
21284
|
-
});
|
|
21285
|
-
}
|
|
21286
|
-
var BODYLESS_STATUS = /* @__PURE__ */ new Set([101, 204, 205, 304]);
|
|
21287
|
-
function dbFetch(send) {
|
|
21288
|
-
return async (input, init) => {
|
|
21289
|
-
const req = new Request(input, init);
|
|
21290
|
-
const url = new URL(req.url);
|
|
21291
|
-
const method = req.method.toUpperCase();
|
|
21292
|
-
const res = await send({
|
|
21293
|
-
method,
|
|
21294
|
-
path: `${url.pathname}${url.search}`,
|
|
21295
|
-
headers: Object.fromEntries(req.headers.entries()),
|
|
21296
|
-
body: method === "GET" || method === "HEAD" ? void 0 : await req.text()
|
|
21297
|
-
});
|
|
21298
|
-
const noBody = method === "HEAD" || BODYLESS_STATUS.has(res.status);
|
|
21299
|
-
return new Response(noBody ? null : res.body, { status: res.status, headers: res.headers });
|
|
21300
|
-
};
|
|
21301
|
-
}
|
|
21302
|
-
var hostDbFetch = dbFetch(requestHostDb);
|
|
21303
|
-
var LOCAL_DB_PATH = "/internal/db";
|
|
21304
|
-
async function requestViaLocalHost(req) {
|
|
21305
|
-
const deadline = Date.now() + REQUEST_TIMEOUT_MS2;
|
|
21306
|
-
let endpoint = readHostEndpoint();
|
|
21307
|
-
while (!endpoint && Date.now() < deadline) {
|
|
21308
|
-
await new Promise((r) => setTimeout(r, 1e3));
|
|
21309
|
-
endpoint = readHostEndpoint();
|
|
21310
|
-
}
|
|
21311
|
-
if (!endpoint) throw new Error("No local Host to reach the Data API through");
|
|
21312
|
-
const res = await fetch(`http://127.0.0.1:${endpoint.port}${LOCAL_DB_PATH}`, {
|
|
21313
|
-
method: "POST",
|
|
21314
|
-
headers: { authorization: `Bearer ${endpoint.token}`, "content-type": "application/json" },
|
|
21315
|
-
body: JSON.stringify(req),
|
|
21316
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2 + 5e3)
|
|
21317
|
-
});
|
|
21318
|
-
if (!res.ok) throw new Error(`Local Host DB relay answered ${res.status}`);
|
|
21319
|
-
return await res.json();
|
|
21320
|
-
}
|
|
21321
|
-
function relayChannel(topic) {
|
|
21322
|
-
const channel = {
|
|
21323
|
-
on: () => channel,
|
|
21324
|
-
subscribe: (callback) => {
|
|
21325
|
-
queueMicrotask(() => callback?.("SUBSCRIBED"));
|
|
21326
|
-
return channel;
|
|
21327
|
-
},
|
|
21328
|
-
send: async (msg) => {
|
|
21329
|
-
if (msg.type !== "broadcast" || !sender) return "error";
|
|
21330
|
-
sender({ type: "db-broadcast", topic, event: msg.event, payload: msg.payload ?? {} });
|
|
21331
|
-
return "ok";
|
|
21332
|
-
},
|
|
21333
|
-
unsubscribe: async () => "ok"
|
|
21334
|
-
};
|
|
21335
|
-
return channel;
|
|
21336
|
-
}
|
|
21337
|
-
function createHostDbClient(via = "socket") {
|
|
21338
|
-
const client = createClient("https://host-db.invalid", "host-device", {
|
|
21339
|
-
auth: { persistSession: false, autoRefreshToken: false },
|
|
21340
|
-
global: { fetch: via === "socket" ? hostDbFetch : dbFetch(requestViaLocalHost) }
|
|
21341
|
-
});
|
|
21342
|
-
return new Proxy(client, {
|
|
21343
|
-
get(target, prop) {
|
|
21344
|
-
if (prop === "channel") return relayChannel;
|
|
21345
|
-
if (prop === "removeChannel") return async () => "ok";
|
|
21346
|
-
const value = Reflect.get(target, prop, target);
|
|
21347
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
21348
|
-
}
|
|
21349
|
-
});
|
|
21350
|
-
}
|
|
21351
|
-
|
|
21352
|
-
// src/commands/supabase-via-host.ts
|
|
21353
|
-
function useHostDbWithoutCredentials() {
|
|
21354
|
-
const viaHost = !!loadCredentials() && (!hasSupabaseCredentials() || !!readHostEndpoint());
|
|
21355
|
-
if (viaHost) setSupabaseClient(createHostDbClient("local-host"));
|
|
21356
|
-
return viaHost;
|
|
21357
|
-
}
|
|
21358
|
-
|
|
21359
|
-
// src/commands/persona.ts
|
|
21360
20991
|
var USAGE = `
|
|
21361
20992
|
Usage: flyspace persona avatars [--character <id>] [--clear]
|
|
21362
20993
|
|
|
@@ -21387,34 +21018,34 @@ var PACKS = {
|
|
|
21387
21018
|
}
|
|
21388
21019
|
};
|
|
21389
21020
|
function pluginInstalled() {
|
|
21390
|
-
const claudeDir = process.env["CLAUDE_CONFIG_DIR"] ||
|
|
21391
|
-
return
|
|
21021
|
+
const claudeDir = process.env["CLAUDE_CONFIG_DIR"] || join6(homedir3(), ".claude");
|
|
21022
|
+
return existsSync7(join6(claudeDir, "plugins", "cache", "claudecafe", "persona-panel"));
|
|
21392
21023
|
}
|
|
21393
21024
|
function installPack(root, character) {
|
|
21394
21025
|
const pack = PACKS[character];
|
|
21395
21026
|
if (!pack) throw new Error(`No published pack for "${character}".`);
|
|
21396
|
-
const charactersDir =
|
|
21397
|
-
|
|
21398
|
-
const staging = mkdtempSync2(
|
|
21027
|
+
const charactersDir = join6(root, "characters");
|
|
21028
|
+
execFileSync4("mkdir", ["-p", charactersDir]);
|
|
21029
|
+
const staging = mkdtempSync2(join6(charactersDir, `.${character}-`));
|
|
21399
21030
|
try {
|
|
21400
|
-
const zip =
|
|
21401
|
-
|
|
21402
|
-
const digest = createHash3("sha256").update(
|
|
21031
|
+
const zip = join6(staging, "pack.zip");
|
|
21032
|
+
execFileSync4("curl", ["-fsSL", "--max-time", "60", "-o", zip, pack.url]);
|
|
21033
|
+
const digest = createHash3("sha256").update(readFileSync4(zip)).digest("hex");
|
|
21403
21034
|
if (digest !== pack.sha256) throw new Error(`${character} pack SHA-256 mismatch`);
|
|
21404
|
-
|
|
21405
|
-
const folder =
|
|
21406
|
-
if (
|
|
21407
|
-
renameSync2(
|
|
21035
|
+
execFileSync4("unzip", ["-q", zip, "-d", staging]);
|
|
21036
|
+
const folder = join6(charactersDir, character);
|
|
21037
|
+
if (existsSync7(folder)) renameSync2(folder, join6(staging, "previous"));
|
|
21038
|
+
renameSync2(join6(staging, character), folder);
|
|
21408
21039
|
} finally {
|
|
21409
|
-
|
|
21040
|
+
rmSync3(staging, { recursive: true, force: true });
|
|
21410
21041
|
}
|
|
21411
21042
|
}
|
|
21412
21043
|
function cafeRoot() {
|
|
21413
|
-
return
|
|
21044
|
+
return join6(process.env["XDG_CONFIG_HOME"] || join6(homedir3(), ".config"), "claudecafe");
|
|
21414
21045
|
}
|
|
21415
21046
|
function configuredCharacter(root) {
|
|
21416
21047
|
try {
|
|
21417
|
-
const config = JSON.parse(
|
|
21048
|
+
const config = JSON.parse(readFileSync4(join6(root, "config.json"), "utf8"));
|
|
21418
21049
|
if (config.character && config.character !== "none") return config.character;
|
|
21419
21050
|
} catch {
|
|
21420
21051
|
}
|
|
@@ -21441,11 +21072,11 @@ var DEFAULT_BOT_NAMES = /* @__PURE__ */ new Set(["Bot", "Workspace Agent"]);
|
|
|
21441
21072
|
async function syncPersonaAvatars(profile, requested) {
|
|
21442
21073
|
const root = cafeRoot();
|
|
21443
21074
|
const character = requested || configuredCharacter(root);
|
|
21444
|
-
const dir =
|
|
21445
|
-
if (!
|
|
21075
|
+
const dir = join6(root, "characters", character, "avatars");
|
|
21076
|
+
if (!existsSync7(dir)) installPack(root, character);
|
|
21446
21077
|
const avatars = {};
|
|
21447
21078
|
for (const file of readdirSync2(dir).filter((f) => f.endsWith(".webp"))) {
|
|
21448
|
-
const image = await sharp(
|
|
21079
|
+
const image = await sharp(join6(dir, file)).resize({ width: AVATAR_SIZE, height: AVATAR_SIZE, fit: "cover", position: "top" }).webp({ quality: 80 }).toBuffer();
|
|
21449
21080
|
avatars[basename2(file, ".webp")] = `data:image/webp;base64,${image.toString("base64")}`;
|
|
21450
21081
|
}
|
|
21451
21082
|
if (!Object.keys(avatars).length) throw new Error(`No .webp avatars in ${dir}.`);
|
|
@@ -21463,14 +21094,14 @@ async function autoSyncPersonaAvatars(profile) {
|
|
|
21463
21094
|
const root = cafeRoot();
|
|
21464
21095
|
const character = configuredCharacter(root);
|
|
21465
21096
|
const stamp = `${character}@${PACKS[character]?.version ?? "local"}`;
|
|
21466
|
-
const marker =
|
|
21097
|
+
const marker = join6(root, `.flyspace-avatars-${profile}`);
|
|
21467
21098
|
try {
|
|
21468
|
-
if (
|
|
21099
|
+
if (readFileSync4(marker, "utf8") === stamp) return;
|
|
21469
21100
|
} catch {
|
|
21470
21101
|
}
|
|
21471
21102
|
try {
|
|
21472
21103
|
const { count } = await syncPersonaAvatars(profile, character);
|
|
21473
|
-
|
|
21104
|
+
writeFileSync3(marker, stamp);
|
|
21474
21105
|
console.log(`[persona] synced ${count} ${character} avatars`);
|
|
21475
21106
|
} catch (err) {
|
|
21476
21107
|
console.warn(`[persona] avatar sync skipped: ${err.message}`);
|
|
@@ -21927,24 +21558,24 @@ async function loadAgentMemory(profile, channelId, opts = {}) {
|
|
|
21927
21558
|
async function buildPrompt(profile, channelId, opts) {
|
|
21928
21559
|
const workspace = await getWorkspaceBySlug(profile);
|
|
21929
21560
|
const handle = opts.senderHandle?.toLowerCase();
|
|
21930
|
-
const
|
|
21561
|
+
const sender = workspace && handle ? (await listMemberships(workspace.id)).find(
|
|
21931
21562
|
(m) => m.userId && m.handle.toLowerCase() === handle
|
|
21932
21563
|
) : void 0;
|
|
21933
21564
|
const [channel, shared, own] = await Promise.all([
|
|
21934
21565
|
listMemories({ scope: "channel", channelId }),
|
|
21935
21566
|
workspace ? listMemories({ scope: "workspace", workspaceId: workspace.id }) : [],
|
|
21936
|
-
workspace &&
|
|
21567
|
+
workspace && sender ? listMemories({ scope: "user", workspaceId: workspace.id, userId: sender.userId }) : []
|
|
21937
21568
|
]);
|
|
21938
21569
|
const extras = {
|
|
21939
21570
|
workspace: shared,
|
|
21940
|
-
...
|
|
21571
|
+
...sender ? { user: { userId: sender.userId, handle: sender.handle, memories: own } } : {}
|
|
21941
21572
|
};
|
|
21942
21573
|
return formatMemoryPrompt(channelId, channel, extras);
|
|
21943
21574
|
}
|
|
21944
21575
|
|
|
21945
21576
|
// src/dashboard/settings-host.ts
|
|
21946
|
-
import { writeFileSync as
|
|
21947
|
-
import { dirname
|
|
21577
|
+
import { writeFileSync as writeFileSync4, existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync5, rmSync as rmSync4 } from "fs";
|
|
21578
|
+
import { dirname } from "path";
|
|
21948
21579
|
|
|
21949
21580
|
// ../api/src/dashboard/auto-title.ts
|
|
21950
21581
|
var GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions";
|
|
@@ -22105,9 +21736,9 @@ function parseAgentProfiles(raw) {
|
|
|
22105
21736
|
return entries2.length > 0 ? Object.fromEntries(entries2) : void 0;
|
|
22106
21737
|
}
|
|
22107
21738
|
function loadDashboardSettings() {
|
|
22108
|
-
if (!
|
|
21739
|
+
if (!existsSync8(paths.DASHBOARD_SETTINGS_FILE)) return localDefaults();
|
|
22109
21740
|
try {
|
|
22110
|
-
const raw = JSON.parse(
|
|
21741
|
+
const raw = JSON.parse(readFileSync5(paths.DASHBOARD_SETTINGS_FILE, "utf-8"));
|
|
22111
21742
|
const providers = parseProviders(raw.providers, {
|
|
22112
21743
|
agent: normalizeDefaultModel(raw.agent, localDefaults().agent),
|
|
22113
21744
|
fallbackModel: typeof raw.fallbackModel === "string" && isAllowedModel(raw.fallbackModel) ? raw.fallbackModel : void 0
|
|
@@ -22134,9 +21765,9 @@ function withFallbackModel(providers, model) {
|
|
|
22134
21765
|
return [cleared[0], { runner, model }, ...cleared.slice(1).filter((p) => p.runner !== runner)];
|
|
22135
21766
|
}
|
|
22136
21767
|
function writeSettings(next) {
|
|
22137
|
-
|
|
21768
|
+
mkdirSync5(dirname(paths.DASHBOARD_SETTINGS_FILE), { recursive: true });
|
|
22138
21769
|
const merged = { ...readSettingsFile() ?? {}, ...next };
|
|
22139
|
-
|
|
21770
|
+
writeFileSync4(paths.DASHBOARD_SETTINGS_FILE, JSON.stringify(merged, null, 2), "utf-8");
|
|
22140
21771
|
return next;
|
|
22141
21772
|
}
|
|
22142
21773
|
function saveDashboardSettings(patch) {
|
|
@@ -22170,13 +21801,13 @@ async function loadFullDashboardSettings(profile = getProfile()) {
|
|
|
22170
21801
|
function saveWorkspacePrompt(prompt) {
|
|
22171
21802
|
const trimmed = prompt.trim();
|
|
22172
21803
|
if (!trimmed || trimmed === loadWorkspacePrompt().defaultPrompt) return resetWorkspacePrompt();
|
|
22173
|
-
|
|
22174
|
-
|
|
21804
|
+
mkdirSync5(dirname(paths.PROMPT_FILE), { recursive: true });
|
|
21805
|
+
writeFileSync4(paths.PROMPT_FILE, `${trimmed}
|
|
22175
21806
|
`, "utf-8");
|
|
22176
21807
|
return loadWorkspacePrompt();
|
|
22177
21808
|
}
|
|
22178
21809
|
function resetWorkspacePrompt() {
|
|
22179
|
-
|
|
21810
|
+
rmSync4(paths.PROMPT_FILE, { force: true });
|
|
22180
21811
|
return loadWorkspacePrompt();
|
|
22181
21812
|
}
|
|
22182
21813
|
function saveAgentProfile(name, patch) {
|
|
@@ -22201,9 +21832,9 @@ function saveAgentProfile(name, patch) {
|
|
|
22201
21832
|
|
|
22202
21833
|
// ../api/src/codex/agent.ts
|
|
22203
21834
|
import { spawn as spawn2 } from "child_process";
|
|
22204
|
-
import { existsSync as
|
|
21835
|
+
import { existsSync as existsSync9, mkdtempSync as mkdtempSync3, readFileSync as readFileSync6, rmSync as rmSync5, statSync as statSync3 } from "fs";
|
|
22205
21836
|
import { tmpdir as tmpdir2 } from "os";
|
|
22206
|
-
import { join as
|
|
21837
|
+
import { join as join7 } from "path";
|
|
22207
21838
|
var AUTH_ERROR_PATTERNS2 = [
|
|
22208
21839
|
/401 unauthorized/i,
|
|
22209
21840
|
/missing bearer or basic authentication/i,
|
|
@@ -22334,8 +21965,8 @@ function getMaxDurationMs2() {
|
|
|
22334
21965
|
}
|
|
22335
21966
|
function codexAuthAvailable(env = process.env) {
|
|
22336
21967
|
if (env["OPENAI_API_KEY"]?.trim()) return true;
|
|
22337
|
-
const home = env["CODEX_HOME"]?.trim() ||
|
|
22338
|
-
return
|
|
21968
|
+
const home = env["CODEX_HOME"]?.trim() || join7(env["HOME"] ?? "", ".codex");
|
|
21969
|
+
return existsSync9(join7(home, "auth.json"));
|
|
22339
21970
|
}
|
|
22340
21971
|
function applySystemPrompt(prompt, options, resumeSessionId) {
|
|
22341
21972
|
if (resumeSessionId || !options.systemPrompt?.trim()) return prompt;
|
|
@@ -22384,13 +22015,13 @@ function recordCodexUsage(response, options) {
|
|
|
22384
22015
|
});
|
|
22385
22016
|
}
|
|
22386
22017
|
function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
22387
|
-
return new Promise((
|
|
22018
|
+
return new Promise((resolve7, reject) => {
|
|
22388
22019
|
const finish = (response) => {
|
|
22389
22020
|
recordCodexUsage(response, options);
|
|
22390
|
-
|
|
22021
|
+
resolve7(response);
|
|
22391
22022
|
};
|
|
22392
|
-
const scratch = mkdtempSync3(
|
|
22393
|
-
const lastMessageFile =
|
|
22023
|
+
const scratch = mkdtempSync3(join7(tmpdir2(), "flyspace-codex-"));
|
|
22024
|
+
const lastMessageFile = join7(scratch, "last-message.txt");
|
|
22394
22025
|
const args = buildArgs2(prompt, options, lastMessageFile, resumeSessionId);
|
|
22395
22026
|
console.log(`[codex] spawning codex CLI in ${cwd}`);
|
|
22396
22027
|
console.log(`[codex] args: ${args.slice(0, -1).join(" ")}`);
|
|
@@ -22403,7 +22034,7 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
|
22403
22034
|
let stderr = "";
|
|
22404
22035
|
let timedOut = false;
|
|
22405
22036
|
let cancelled = false;
|
|
22406
|
-
let
|
|
22037
|
+
let pending = "";
|
|
22407
22038
|
const seenItemIds = /* @__PURE__ */ new Set();
|
|
22408
22039
|
const onActivity = options.onActivity;
|
|
22409
22040
|
const consumeLine = (raw) => {
|
|
@@ -22460,7 +22091,7 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
|
22460
22091
|
const cleanup = () => {
|
|
22461
22092
|
clearTimeout(timeoutHandle);
|
|
22462
22093
|
if (signal) signal.removeEventListener("abort", onAbort);
|
|
22463
|
-
|
|
22094
|
+
rmSync5(scratch, { recursive: true, force: true });
|
|
22464
22095
|
};
|
|
22465
22096
|
child.stdout.setEncoding("utf8");
|
|
22466
22097
|
child.stderr.setEncoding("utf8");
|
|
@@ -22468,9 +22099,9 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
|
22468
22099
|
const chunk = data.toString();
|
|
22469
22100
|
stdout += chunk;
|
|
22470
22101
|
if (!onActivity) return;
|
|
22471
|
-
|
|
22472
|
-
const lines =
|
|
22473
|
-
|
|
22102
|
+
pending += chunk;
|
|
22103
|
+
const lines = pending.split("\n");
|
|
22104
|
+
pending = lines.pop() ?? "";
|
|
22474
22105
|
for (const line of lines) consumeLine(line);
|
|
22475
22106
|
});
|
|
22476
22107
|
child.stderr.on("data", (data) => {
|
|
@@ -22489,7 +22120,7 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
|
22489
22120
|
child.on("close", (code, signal2) => {
|
|
22490
22121
|
let lastMessage = "";
|
|
22491
22122
|
try {
|
|
22492
|
-
lastMessage =
|
|
22123
|
+
lastMessage = readFileSync6(lastMessageFile, "utf8").trim();
|
|
22493
22124
|
} catch {
|
|
22494
22125
|
lastMessage = "";
|
|
22495
22126
|
}
|
|
@@ -22543,7 +22174,7 @@ function runCodexCli(prompt, cwd, options, resumeSessionId) {
|
|
|
22543
22174
|
});
|
|
22544
22175
|
}
|
|
22545
22176
|
async function askCodex(prompt, cwd, options = {}, resumeSessionId) {
|
|
22546
|
-
if (!
|
|
22177
|
+
if (!existsSync9(cwd) || !statSync3(cwd).isDirectory()) {
|
|
22547
22178
|
console.error(`[codex] working directory does not exist: ${cwd}`);
|
|
22548
22179
|
return {
|
|
22549
22180
|
sessionId: resumeSessionId ?? "",
|
|
@@ -22804,11 +22435,11 @@ function walkBlock(token, out) {
|
|
|
22804
22435
|
}
|
|
22805
22436
|
function walkList(list, indent, out) {
|
|
22806
22437
|
const style = list.ordered ? "ordered" : "bullet";
|
|
22807
|
-
let
|
|
22438
|
+
let pending = [];
|
|
22808
22439
|
const flush2 = () => {
|
|
22809
|
-
if (
|
|
22810
|
-
out.push({ type: "rich_text_list", style, indent, elements:
|
|
22811
|
-
|
|
22440
|
+
if (pending.length > 0) {
|
|
22441
|
+
out.push({ type: "rich_text_list", style, indent, elements: pending });
|
|
22442
|
+
pending = [];
|
|
22812
22443
|
}
|
|
22813
22444
|
};
|
|
22814
22445
|
for (const item of list.items) {
|
|
@@ -22832,7 +22463,7 @@ function walkList(list, indent, out) {
|
|
|
22832
22463
|
}
|
|
22833
22464
|
}
|
|
22834
22465
|
}
|
|
22835
|
-
|
|
22466
|
+
pending.push({
|
|
22836
22467
|
type: "rich_text_section",
|
|
22837
22468
|
elements: inline.length > 0 ? mergeAdjacentText(inline) : [{ type: "text", text: "" }]
|
|
22838
22469
|
});
|
|
@@ -22996,7 +22627,7 @@ function renderAsciiTable(t) {
|
|
|
22996
22627
|
}
|
|
22997
22628
|
|
|
22998
22629
|
// src/store/channel-cache.ts
|
|
22999
|
-
import { mkdirSync as
|
|
22630
|
+
import { mkdirSync as mkdirSync6 } from "fs";
|
|
23000
22631
|
|
|
23001
22632
|
// src/store/sqlite.ts
|
|
23002
22633
|
import Database from "better-sqlite3";
|
|
@@ -23020,7 +22651,7 @@ function getDb() {
|
|
|
23020
22651
|
const file = paths.DB_FILE;
|
|
23021
22652
|
const existing = dbs.get(file);
|
|
23022
22653
|
if (existing) return existing;
|
|
23023
|
-
|
|
22654
|
+
mkdirSync6(paths.DATA_DIR, { recursive: true });
|
|
23024
22655
|
const db = openLocalDatabase(file);
|
|
23025
22656
|
if (!db) return null;
|
|
23026
22657
|
db.exec(`
|
|
@@ -23235,7 +22866,7 @@ var DEFAULT_TIMEOUT_MS = 12e4;
|
|
|
23235
22866
|
var KILL_GRACE_MS3 = 5e3;
|
|
23236
22867
|
function runScriptAutomation(opts) {
|
|
23237
22868
|
const { name, script, cwd, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
|
|
23238
|
-
return new Promise((
|
|
22869
|
+
return new Promise((resolve7, reject) => {
|
|
23239
22870
|
const child = spawn3("/bin/bash", [script], { cwd, env: resolveMiseEnv(cwd), stdio: ["ignore", "pipe", "pipe"] });
|
|
23240
22871
|
let stdout = "";
|
|
23241
22872
|
let stderr = "";
|
|
@@ -23270,7 +22901,7 @@ function runScriptAutomation(opts) {
|
|
|
23270
22901
|
} else if (code !== 0) {
|
|
23271
22902
|
reject(new Error(`script exited with code ${code}: ${stderr.trim()}`));
|
|
23272
22903
|
} else {
|
|
23273
|
-
|
|
22904
|
+
resolve7();
|
|
23274
22905
|
}
|
|
23275
22906
|
});
|
|
23276
22907
|
});
|
|
@@ -23536,17 +23167,17 @@ var TriggerEngine = class {
|
|
|
23536
23167
|
};
|
|
23537
23168
|
|
|
23538
23169
|
// src/store/user-cache.ts
|
|
23539
|
-
import { existsSync as
|
|
23540
|
-
import { join as
|
|
23170
|
+
import { existsSync as existsSync10, readFileSync as readFileSync7 } from "fs";
|
|
23171
|
+
import { join as join8 } from "path";
|
|
23541
23172
|
function jsonUserCachePath() {
|
|
23542
|
-
const file =
|
|
23543
|
-
return
|
|
23173
|
+
const file = join8(paths.CONFIG_DIR, "slack_users.json");
|
|
23174
|
+
return existsSync10(file) ? file : void 0;
|
|
23544
23175
|
}
|
|
23545
23176
|
function readJsonUserCache() {
|
|
23546
23177
|
const file = jsonUserCachePath();
|
|
23547
23178
|
if (!file) return void 0;
|
|
23548
23179
|
try {
|
|
23549
|
-
const parsed = JSON.parse(
|
|
23180
|
+
const parsed = JSON.parse(readFileSync7(file, "utf8"));
|
|
23550
23181
|
return parsed.users;
|
|
23551
23182
|
} catch {
|
|
23552
23183
|
return void 0;
|
|
@@ -23938,8 +23569,8 @@ var MessageQueue = class {
|
|
|
23938
23569
|
const chains = Array.from(this.chains.values());
|
|
23939
23570
|
if (chains.length === 0) return true;
|
|
23940
23571
|
let timer;
|
|
23941
|
-
const timeout = new Promise((
|
|
23942
|
-
timer = setTimeout(() =>
|
|
23572
|
+
const timeout = new Promise((resolve7) => {
|
|
23573
|
+
timer = setTimeout(() => resolve7(false), timeoutMs);
|
|
23943
23574
|
});
|
|
23944
23575
|
const done = Promise.all(chains).then(() => true);
|
|
23945
23576
|
const result = await Promise.race([done, timeout]);
|
|
@@ -23953,7 +23584,7 @@ var MessageQueue = class {
|
|
|
23953
23584
|
|
|
23954
23585
|
// src/slack/file-downloader.ts
|
|
23955
23586
|
import { writeFile } from "fs/promises";
|
|
23956
|
-
import { join as
|
|
23587
|
+
import { join as join9, extname } from "path";
|
|
23957
23588
|
var debug3 = process.env["DEBUG"] === "true";
|
|
23958
23589
|
var SUPPORTED_IMAGE_MIMETYPES = /* @__PURE__ */ new Set([
|
|
23959
23590
|
"image/png",
|
|
@@ -24053,7 +23684,7 @@ async function downloadOne(file, botToken) {
|
|
|
24053
23684
|
const ext = extname(originalName) || `.${file.filetype ?? "bin"}`;
|
|
24054
23685
|
const safeName = sanitizeFilename(originalName.replace(ext, ""));
|
|
24055
23686
|
const filename = `${Date.now()}-${file.id ?? "unnamed"}-${safeName}${ext}`;
|
|
24056
|
-
const localPath =
|
|
23687
|
+
const localPath = join9(paths.UPLOADS_DIR, filename);
|
|
24057
23688
|
await writeFile(localPath, buffer);
|
|
24058
23689
|
if (debug3)
|
|
24059
23690
|
console.log(`[file-downloader] saved ${file.id} -> ${localPath} (${buffer.length} bytes)`);
|
|
@@ -24505,12 +24136,12 @@ import { homedir as homedir8 } from "os";
|
|
|
24505
24136
|
import { stripVTControlCharacters } from "util";
|
|
24506
24137
|
|
|
24507
24138
|
// src/mcp/config.ts
|
|
24508
|
-
import { mkdtempSync as mkdtempSync4, rmSync as
|
|
24139
|
+
import { mkdtempSync as mkdtempSync4, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
24509
24140
|
import { tmpdir as tmpdir3 } from "os";
|
|
24510
|
-
import { join as
|
|
24141
|
+
import { join as join10 } from "path";
|
|
24511
24142
|
|
|
24512
24143
|
// ../api/src/mcp/crypto.ts
|
|
24513
|
-
import { createCipheriv, createDecipheriv, randomBytes
|
|
24144
|
+
import { createCipheriv, createDecipheriv, randomBytes, timingSafeEqual } from "crypto";
|
|
24514
24145
|
var ALGORITHM = "aes-256-gcm";
|
|
24515
24146
|
var KEY_BYTES = 32;
|
|
24516
24147
|
var IV_BYTES = 12;
|
|
@@ -24543,7 +24174,7 @@ function currentKeyVersion() {
|
|
|
24543
24174
|
);
|
|
24544
24175
|
}
|
|
24545
24176
|
function encrypt(key, purpose, plaintext) {
|
|
24546
|
-
const iv =
|
|
24177
|
+
const iv = randomBytes(IV_BYTES);
|
|
24547
24178
|
const cipher = createCipheriv(ALGORITHM, key, iv);
|
|
24548
24179
|
cipher.setAAD(Buffer.from(purpose, "utf8"));
|
|
24549
24180
|
const ciphertext = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
@@ -24563,7 +24194,7 @@ function decrypt(key, purpose, blob) {
|
|
|
24563
24194
|
}
|
|
24564
24195
|
function createEnvelope() {
|
|
24565
24196
|
const keyVersion = currentKeyVersion();
|
|
24566
|
-
const key =
|
|
24197
|
+
const key = randomBytes(KEY_BYTES);
|
|
24567
24198
|
const wrappedDek = encrypt(
|
|
24568
24199
|
readMasterKey(keyVersion),
|
|
24569
24200
|
purposeForDek(keyVersion),
|
|
@@ -24629,7 +24260,7 @@ function secretsMatch(a, b) {
|
|
|
24629
24260
|
}
|
|
24630
24261
|
|
|
24631
24262
|
// ../api/src/mcp/oauth.ts
|
|
24632
|
-
import { createHash as createHash4, randomBytes as
|
|
24263
|
+
import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
|
|
24633
24264
|
var RESERVED_AUTHORIZE_PARAMS = /* @__PURE__ */ new Set([
|
|
24634
24265
|
"client_id",
|
|
24635
24266
|
"redirect_uri",
|
|
@@ -24643,10 +24274,10 @@ function base64url(buffer) {
|
|
|
24643
24274
|
return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
24644
24275
|
}
|
|
24645
24276
|
function createStateToken() {
|
|
24646
|
-
return base64url(
|
|
24277
|
+
return base64url(randomBytes2(32));
|
|
24647
24278
|
}
|
|
24648
24279
|
function createPkcePair() {
|
|
24649
|
-
const verifier = base64url(
|
|
24280
|
+
const verifier = base64url(randomBytes2(32));
|
|
24650
24281
|
const challenge = base64url(createHash4("sha256").update(verifier).digest());
|
|
24651
24282
|
return { verifier, challenge };
|
|
24652
24283
|
}
|
|
@@ -24767,7 +24398,7 @@ async function exchangeCode(params) {
|
|
|
24767
24398
|
);
|
|
24768
24399
|
return { ...tokens, scopes: tokens.scopes.length ? tokens.scopes : provider.defaultScopes };
|
|
24769
24400
|
}
|
|
24770
|
-
async function
|
|
24401
|
+
async function refreshAccessToken(params) {
|
|
24771
24402
|
const { provider, client, refreshToken } = params;
|
|
24772
24403
|
return requestToken(
|
|
24773
24404
|
provider,
|
|
@@ -25016,7 +24647,7 @@ function needsRefresh(expiresAt, now = Date.now()) {
|
|
|
25016
24647
|
if (!expiresAt) return false;
|
|
25017
24648
|
return new Date(expiresAt).getTime() - now < REFRESH_SKEW_MS;
|
|
25018
24649
|
}
|
|
25019
|
-
var sleep = (ms) => new Promise((
|
|
24650
|
+
var sleep = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
25020
24651
|
async function refreshConnection(params) {
|
|
25021
24652
|
const { workspaceId, connection, provider } = params;
|
|
25022
24653
|
const deps = params.deps ?? {};
|
|
@@ -25053,7 +24684,7 @@ async function renew(workspaceId, connection, provider, deps) {
|
|
|
25053
24684
|
}
|
|
25054
24685
|
let tokens;
|
|
25055
24686
|
try {
|
|
25056
|
-
tokens = await
|
|
24687
|
+
tokens = await refreshAccessToken({
|
|
25057
24688
|
provider,
|
|
25058
24689
|
client: readOAuthClient(provider.slug),
|
|
25059
24690
|
refreshToken,
|
|
@@ -25193,12 +24824,12 @@ async function buildMcpConfig(profile, connectionIds) {
|
|
|
25193
24824
|
return { config, skipped };
|
|
25194
24825
|
}
|
|
25195
24826
|
function writeMcpConfigFile(config) {
|
|
25196
|
-
const dir = mkdtempSync4(
|
|
25197
|
-
const path =
|
|
25198
|
-
|
|
24827
|
+
const dir = mkdtempSync4(join10(tmpdir3(), "flyspace-mcp-"));
|
|
24828
|
+
const path = join10(dir, "mcp-config.json");
|
|
24829
|
+
writeFileSync5(path, JSON.stringify(config), { mode: 384 });
|
|
25199
24830
|
return {
|
|
25200
24831
|
path,
|
|
25201
|
-
cleanup: () =>
|
|
24832
|
+
cleanup: () => rmSync6(dir, { recursive: true, force: true })
|
|
25202
24833
|
};
|
|
25203
24834
|
}
|
|
25204
24835
|
async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
|
|
@@ -25216,8 +24847,8 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
|
|
|
25216
24847
|
}
|
|
25217
24848
|
|
|
25218
24849
|
// ../api/src/version.ts
|
|
25219
|
-
import { readFileSync as
|
|
25220
|
-
var CLI_VERSION = true ? "0.1.
|
|
24850
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
24851
|
+
var CLI_VERSION = true ? "0.1.60" : devVersion();
|
|
25221
24852
|
function isOlderVersion(a, b) {
|
|
25222
24853
|
const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
|
|
25223
24854
|
const [pa, pb] = [parse2(a), parse2(b)];
|
|
@@ -25225,7 +24856,7 @@ function isOlderVersion(a, b) {
|
|
|
25225
24856
|
for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] < pb[i];
|
|
25226
24857
|
return false;
|
|
25227
24858
|
}
|
|
25228
|
-
var LATEST_TTL_MS =
|
|
24859
|
+
var LATEST_TTL_MS = 5 * 6e4;
|
|
25229
24860
|
var latest = null;
|
|
25230
24861
|
async function latestCliVersion() {
|
|
25231
24862
|
if (latest && Date.now() - latest.at < LATEST_TTL_MS) return latest.version;
|
|
@@ -25240,50 +24871,50 @@ async function latestCliVersion() {
|
|
|
25240
24871
|
}
|
|
25241
24872
|
|
|
25242
24873
|
// src/claude/agents.ts
|
|
25243
|
-
import { existsSync as
|
|
24874
|
+
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
|
|
25244
24875
|
import { homedir as homedir6 } from "os";
|
|
25245
|
-
import { basename as basename4, join as
|
|
24876
|
+
import { basename as basename4, join as join13 } from "path";
|
|
25246
24877
|
import yaml3 from "js-yaml";
|
|
25247
24878
|
|
|
25248
24879
|
// ../api/src/claude/skills.ts
|
|
25249
|
-
import { existsSync as
|
|
24880
|
+
import { existsSync as existsSync12, readdirSync as readdirSync4, readFileSync as readFileSync10, statSync as statSync5 } from "fs";
|
|
25250
24881
|
import { homedir as homedir5 } from "os";
|
|
25251
|
-
import { basename as basename3, dirname as
|
|
24882
|
+
import { basename as basename3, dirname as dirname2, join as join12 } from "path";
|
|
25252
24883
|
import yaml2 from "js-yaml";
|
|
25253
24884
|
|
|
25254
24885
|
// ../api/src/claude/skill-files.ts
|
|
25255
24886
|
import {
|
|
25256
|
-
existsSync as
|
|
25257
|
-
mkdirSync as
|
|
25258
|
-
readFileSync as
|
|
24887
|
+
existsSync as existsSync11,
|
|
24888
|
+
mkdirSync as mkdirSync7,
|
|
24889
|
+
readFileSync as readFileSync9,
|
|
25259
24890
|
readdirSync as readdirSync3,
|
|
25260
|
-
rmSync as
|
|
24891
|
+
rmSync as rmSync7,
|
|
25261
24892
|
statSync as statSync4,
|
|
25262
|
-
writeFileSync as
|
|
24893
|
+
writeFileSync as writeFileSync6
|
|
25263
24894
|
} from "fs";
|
|
25264
24895
|
import { homedir as homedir4 } from "os";
|
|
25265
|
-
import { join as
|
|
24896
|
+
import { join as join11, resolve as resolve4, sep as sep2 } from "path";
|
|
25266
24897
|
import yaml from "js-yaml";
|
|
25267
24898
|
var MAX_SKILL_BYTES = 2 * 1024 * 1024;
|
|
25268
24899
|
var SKILL_NAME = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
25269
24900
|
function expandHome(p) {
|
|
25270
24901
|
if (p === "~") return homedir4();
|
|
25271
|
-
if (p.startsWith("~/")) return
|
|
24902
|
+
if (p.startsWith("~/")) return join11(homedir4(), p.slice(2));
|
|
25272
24903
|
return p;
|
|
25273
24904
|
}
|
|
25274
24905
|
function workspaceSkillsDir(configDir) {
|
|
25275
|
-
return
|
|
24906
|
+
return join11(configDir ? expandHome(configDir) : join11(homedir4(), ".claude"), "skills");
|
|
25276
24907
|
}
|
|
25277
24908
|
function channelSkillsDir(cwd) {
|
|
25278
|
-
return
|
|
24909
|
+
return join11(cwd, ".claude", "skills");
|
|
25279
24910
|
}
|
|
25280
24911
|
function isValidSkillName(name) {
|
|
25281
24912
|
return SKILL_NAME.test(name);
|
|
25282
24913
|
}
|
|
25283
24914
|
function resolveSkillPath(dir, name) {
|
|
25284
24915
|
if (!isValidSkillName(name)) return null;
|
|
25285
|
-
const abs =
|
|
25286
|
-
if (!abs.startsWith(
|
|
24916
|
+
const abs = resolve4(dir, name, "SKILL.md");
|
|
24917
|
+
if (!abs.startsWith(resolve4(dir) + sep2)) return null;
|
|
25287
24918
|
return abs;
|
|
25288
24919
|
}
|
|
25289
24920
|
function splitFrontmatter(raw) {
|
|
@@ -25310,7 +24941,7 @@ ${body.replace(/^\n+/, "").trimEnd()}
|
|
|
25310
24941
|
}
|
|
25311
24942
|
function readMeta(abs) {
|
|
25312
24943
|
try {
|
|
25313
|
-
const { fm } = splitFrontmatter(
|
|
24944
|
+
const { fm } = splitFrontmatter(readFileSync9(abs, "utf-8"));
|
|
25314
24945
|
return {
|
|
25315
24946
|
name: typeof fm["name"] === "string" ? fm["name"] : void 0,
|
|
25316
24947
|
description: typeof fm["description"] === "string" ? fm["description"] : void 0
|
|
@@ -25320,7 +24951,7 @@ function readMeta(abs) {
|
|
|
25320
24951
|
}
|
|
25321
24952
|
}
|
|
25322
24953
|
function listSkillFiles(dir) {
|
|
25323
|
-
if (!
|
|
24954
|
+
if (!existsSync11(dir)) return [];
|
|
25324
24955
|
let entries2;
|
|
25325
24956
|
try {
|
|
25326
24957
|
entries2 = readdirSync3(dir);
|
|
@@ -25330,7 +24961,7 @@ function listSkillFiles(dir) {
|
|
|
25330
24961
|
const rows2 = [];
|
|
25331
24962
|
for (const entry of entries2) {
|
|
25332
24963
|
if (!isValidSkillName(entry)) continue;
|
|
25333
|
-
const abs =
|
|
24964
|
+
const abs = join11(dir, entry, "SKILL.md");
|
|
25334
24965
|
let stat;
|
|
25335
24966
|
try {
|
|
25336
24967
|
stat = statSync4(abs);
|
|
@@ -25359,7 +24990,7 @@ function readSkillFile(dir, name) {
|
|
|
25359
24990
|
return null;
|
|
25360
24991
|
}
|
|
25361
24992
|
if (!stat.isFile() || stat.size > MAX_SKILL_BYTES) return null;
|
|
25362
|
-
const { fm, body } = splitFrontmatter(
|
|
24993
|
+
const { fm, body } = splitFrontmatter(readFileSync9(abs, "utf-8"));
|
|
25363
24994
|
return {
|
|
25364
24995
|
name,
|
|
25365
24996
|
description: typeof fm["description"] === "string" ? fm["description"].trim() : "",
|
|
@@ -25381,18 +25012,18 @@ function writeSkillFile(dir, name, patch, baseMtime) {
|
|
|
25381
25012
|
if (baseMtime && stat.mtime.toISOString() !== baseMtime) {
|
|
25382
25013
|
return { status: "conflict", mtime: stat.mtime.toISOString() };
|
|
25383
25014
|
}
|
|
25384
|
-
const { fm } = splitFrontmatter(
|
|
25015
|
+
const { fm } = splitFrontmatter(readFileSync9(abs, "utf-8"));
|
|
25385
25016
|
const content = buildSkillFile({ ...fm, name, description: patch.description }, patch.body);
|
|
25386
25017
|
if (Buffer.byteLength(content, "utf8") > MAX_SKILL_BYTES) return { status: "too-large" };
|
|
25387
|
-
|
|
25018
|
+
writeFileSync6(abs, content, "utf8");
|
|
25388
25019
|
return { status: "ok", mtime: statSync4(abs).mtime.toISOString() };
|
|
25389
25020
|
}
|
|
25390
25021
|
function createSkillFile(dir, name, description) {
|
|
25391
25022
|
const abs = resolveSkillPath(dir, name);
|
|
25392
25023
|
if (!abs) return { status: "bad-name" };
|
|
25393
|
-
if (
|
|
25394
|
-
|
|
25395
|
-
|
|
25024
|
+
if (existsSync11(abs)) return { status: "exists" };
|
|
25025
|
+
mkdirSync7(join11(dir, name), { recursive: true });
|
|
25026
|
+
writeFileSync6(
|
|
25396
25027
|
abs,
|
|
25397
25028
|
buildSkillFile(
|
|
25398
25029
|
{ name, description },
|
|
@@ -25408,24 +25039,24 @@ Describe what this skill does and when to use it.
|
|
|
25408
25039
|
}
|
|
25409
25040
|
function deleteSkillFile(dir, name) {
|
|
25410
25041
|
const abs = resolveSkillPath(dir, name);
|
|
25411
|
-
if (!abs || !
|
|
25412
|
-
|
|
25042
|
+
if (!abs || !existsSync11(abs)) return { status: "not-found" };
|
|
25043
|
+
rmSync7(join11(dir, name), { recursive: true, force: true });
|
|
25413
25044
|
return { status: "ok" };
|
|
25414
25045
|
}
|
|
25415
25046
|
|
|
25416
25047
|
// ../api/src/claude/skills.ts
|
|
25417
25048
|
function defaultConfigDir() {
|
|
25418
|
-
return
|
|
25049
|
+
return join12(homedir5(), ".claude");
|
|
25419
25050
|
}
|
|
25420
25051
|
function expandHome2(p) {
|
|
25421
25052
|
if (p === "~") return homedir5();
|
|
25422
|
-
if (p.startsWith("~/")) return
|
|
25053
|
+
if (p.startsWith("~/")) return join12(homedir5(), p.slice(2));
|
|
25423
25054
|
return p;
|
|
25424
25055
|
}
|
|
25425
25056
|
function parseFrontmatter(file) {
|
|
25426
25057
|
let content;
|
|
25427
25058
|
try {
|
|
25428
|
-
content =
|
|
25059
|
+
content = readFileSync10(file, "utf-8");
|
|
25429
25060
|
} catch {
|
|
25430
25061
|
return {};
|
|
25431
25062
|
}
|
|
@@ -25443,13 +25074,13 @@ function parseFrontmatter(file) {
|
|
|
25443
25074
|
function isSymlinkedDir(root, entry) {
|
|
25444
25075
|
if (!entry.isSymbolicLink()) return false;
|
|
25445
25076
|
try {
|
|
25446
|
-
return statSync5(
|
|
25077
|
+
return statSync5(join12(root, entry.name)).isDirectory();
|
|
25447
25078
|
} catch {
|
|
25448
25079
|
return false;
|
|
25449
25080
|
}
|
|
25450
25081
|
}
|
|
25451
25082
|
function findSkillFiles(root, maxDepth, out) {
|
|
25452
|
-
if (maxDepth < 0 || !
|
|
25083
|
+
if (maxDepth < 0 || !existsSync12(root)) return;
|
|
25453
25084
|
let entries2;
|
|
25454
25085
|
try {
|
|
25455
25086
|
entries2 = readdirSync4(root, { withFileTypes: true });
|
|
@@ -25458,24 +25089,24 @@ function findSkillFiles(root, maxDepth, out) {
|
|
|
25458
25089
|
}
|
|
25459
25090
|
for (const entry of entries2) {
|
|
25460
25091
|
if (entry.isFile()) {
|
|
25461
|
-
if (entry.name === "SKILL.md") out.push(
|
|
25092
|
+
if (entry.name === "SKILL.md") out.push(join12(root, entry.name));
|
|
25462
25093
|
} else if (entry.isDirectory() || isSymlinkedDir(root, entry)) {
|
|
25463
25094
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
25464
|
-
findSkillFiles(
|
|
25095
|
+
findSkillFiles(join12(root, entry.name), maxDepth - 1, out);
|
|
25465
25096
|
}
|
|
25466
25097
|
}
|
|
25467
25098
|
}
|
|
25468
25099
|
function pluginNameFor(file, root) {
|
|
25469
|
-
let dir =
|
|
25470
|
-
while (dir.startsWith(root) && dir !==
|
|
25100
|
+
let dir = dirname2(file);
|
|
25101
|
+
while (dir.startsWith(root) && dir !== dirname2(dir)) {
|
|
25471
25102
|
try {
|
|
25472
25103
|
const manifest = JSON.parse(
|
|
25473
|
-
|
|
25104
|
+
readFileSync10(join12(dir, ".claude-plugin", "plugin.json"), "utf-8")
|
|
25474
25105
|
);
|
|
25475
25106
|
if (typeof manifest.name === "string" && manifest.name.trim()) return manifest.name.trim();
|
|
25476
25107
|
} catch {
|
|
25477
25108
|
}
|
|
25478
|
-
dir =
|
|
25109
|
+
dir = dirname2(dir);
|
|
25479
25110
|
}
|
|
25480
25111
|
return void 0;
|
|
25481
25112
|
}
|
|
@@ -25492,17 +25123,17 @@ function findPluginMarkdown(pluginsRoot, dirName, maxDepth = 8) {
|
|
|
25492
25123
|
for (const entry of entries2) {
|
|
25493
25124
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
25494
25125
|
if (!entry.isDirectory() && !isSymlinkedDir(dir, entry)) continue;
|
|
25495
|
-
const child =
|
|
25126
|
+
const child = join12(dir, entry.name);
|
|
25496
25127
|
if (entry.name === dirName) {
|
|
25497
25128
|
for (const f of readdirSafe(child)) {
|
|
25498
|
-
if (f.endsWith(".md")) out.push({ file:
|
|
25129
|
+
if (f.endsWith(".md")) out.push({ file: join12(child, f), plugin: pluginNameFor(join12(child, f), pluginsRoot) });
|
|
25499
25130
|
}
|
|
25500
25131
|
} else {
|
|
25501
25132
|
walk(child, depth - 1);
|
|
25502
25133
|
}
|
|
25503
25134
|
}
|
|
25504
25135
|
};
|
|
25505
|
-
if (
|
|
25136
|
+
if (existsSync12(pluginsRoot)) walk(pluginsRoot, maxDepth);
|
|
25506
25137
|
return out;
|
|
25507
25138
|
}
|
|
25508
25139
|
function readdirSafe(dir) {
|
|
@@ -25516,14 +25147,14 @@ function listCommands(configDir, cwd) {
|
|
|
25516
25147
|
const base = configDir ? expandHome2(configDir) : defaultConfigDir();
|
|
25517
25148
|
const local = (dir, source) => readdirSafe(dir).filter((f) => f.endsWith(".md")).map((f) => ({
|
|
25518
25149
|
name: basename3(f, ".md"),
|
|
25519
|
-
description: (parseFrontmatter(
|
|
25150
|
+
description: (parseFrontmatter(join12(dir, f)).description ?? "").trim(),
|
|
25520
25151
|
source,
|
|
25521
25152
|
kind: "command"
|
|
25522
25153
|
}));
|
|
25523
25154
|
const collected = [
|
|
25524
|
-
...local(
|
|
25525
|
-
...local(
|
|
25526
|
-
...findPluginMarkdown(
|
|
25155
|
+
...local(join12(cwd, ".claude", "commands"), "project"),
|
|
25156
|
+
...local(join12(base, "commands"), "user"),
|
|
25157
|
+
...findPluginMarkdown(join12(base, "plugins"), "commands").map(({ file, plugin }) => ({
|
|
25527
25158
|
name: plugin ? `${plugin}:${basename3(file, ".md")}` : basename3(file, ".md"),
|
|
25528
25159
|
description: (parseFrontmatter(file).description ?? "").trim(),
|
|
25529
25160
|
source: "plugin",
|
|
@@ -25545,7 +25176,7 @@ function collectFrom(root, source, maxDepth, namePrefix) {
|
|
|
25545
25176
|
findSkillFiles(root, maxDepth, files);
|
|
25546
25177
|
return files.map((file) => {
|
|
25547
25178
|
const fm = parseFrontmatter(file);
|
|
25548
|
-
const name = fm.name?.trim() || basename3(
|
|
25179
|
+
const name = fm.name?.trim() || basename3(dirname2(file));
|
|
25549
25180
|
const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
|
|
25550
25181
|
const prefix = namePrefix ?? plugin;
|
|
25551
25182
|
return {
|
|
@@ -25561,10 +25192,10 @@ function collectFrom(root, source, maxDepth, namePrefix) {
|
|
|
25561
25192
|
function collectAll(configDir, cwd) {
|
|
25562
25193
|
const base = configDir ? expandHome2(configDir) : defaultConfigDir();
|
|
25563
25194
|
const collected = [
|
|
25564
|
-
...collectFrom(
|
|
25195
|
+
...collectFrom(join12(cwd, ".claude", "skills"), "project", 2),
|
|
25565
25196
|
...nestedProjectRoots(cwd).flatMap(({ dir, prefix }) => collectFrom(dir, "project", 2, prefix)),
|
|
25566
|
-
...collectFrom(
|
|
25567
|
-
...collectFrom(
|
|
25197
|
+
...collectFrom(join12(base, "skills"), "user", 2),
|
|
25198
|
+
...collectFrom(join12(base, "plugins"), "plugin", 8)
|
|
25568
25199
|
];
|
|
25569
25200
|
const byName = /* @__PURE__ */ new Map();
|
|
25570
25201
|
for (const skill of collected) {
|
|
@@ -25583,8 +25214,8 @@ function nestedProjectRoots(cwd) {
|
|
|
25583
25214
|
for (const entry of entries2) {
|
|
25584
25215
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
25585
25216
|
if (!entry.isDirectory() && !isSymlinkedDir(cwd, entry)) continue;
|
|
25586
|
-
const skillsDir =
|
|
25587
|
-
if (
|
|
25217
|
+
const skillsDir = join12(cwd, entry.name, ".claude", "skills");
|
|
25218
|
+
if (existsSync12(skillsDir)) roots.push({ dir: skillsDir, prefix: entry.name });
|
|
25588
25219
|
}
|
|
25589
25220
|
return roots;
|
|
25590
25221
|
}
|
|
@@ -25596,7 +25227,7 @@ function listPluginSkillDetails(configDir, cwd) {
|
|
|
25596
25227
|
for (const { file, ...skill } of collectAll(configDir, cwd)) {
|
|
25597
25228
|
if (skill.source !== "plugin") continue;
|
|
25598
25229
|
try {
|
|
25599
|
-
const { body } = splitFrontmatter(
|
|
25230
|
+
const { body } = splitFrontmatter(readFileSync10(file, "utf-8"));
|
|
25600
25231
|
details.push({ ...skill, body, path: file, mtime: statSync5(file).mtime.toISOString() });
|
|
25601
25232
|
} catch {
|
|
25602
25233
|
}
|
|
@@ -25606,15 +25237,15 @@ function listPluginSkillDetails(configDir, cwd) {
|
|
|
25606
25237
|
function findSkillDetail(configDir, cwd, name, sources) {
|
|
25607
25238
|
const base = configDir ? expandHome2(configDir) : defaultConfigDir();
|
|
25608
25239
|
const roots = [
|
|
25609
|
-
[
|
|
25240
|
+
[join12(cwd, ".claude", "skills"), "project", 2],
|
|
25610
25241
|
...nestedProjectRoots(cwd).map(({ dir, prefix }) => [
|
|
25611
25242
|
dir,
|
|
25612
25243
|
"project",
|
|
25613
25244
|
2,
|
|
25614
25245
|
prefix
|
|
25615
25246
|
]),
|
|
25616
|
-
[
|
|
25617
|
-
[
|
|
25247
|
+
[join12(base, "skills"), "user", 2],
|
|
25248
|
+
[join12(base, "plugins"), "plugin", 8]
|
|
25618
25249
|
];
|
|
25619
25250
|
for (const [root, source, maxDepth, namePrefix] of roots) {
|
|
25620
25251
|
if (!sources.includes(source)) continue;
|
|
@@ -25622,7 +25253,7 @@ function findSkillDetail(configDir, cwd, name, sources) {
|
|
|
25622
25253
|
findSkillFiles(root, maxDepth, files);
|
|
25623
25254
|
for (const file of files) {
|
|
25624
25255
|
const fm = parseFrontmatter(file);
|
|
25625
|
-
const rawName = fm.name?.trim() || basename3(
|
|
25256
|
+
const rawName = fm.name?.trim() || basename3(dirname2(file));
|
|
25626
25257
|
const plugin = source === "plugin" ? pluginNameFor(file, root) : void 0;
|
|
25627
25258
|
const prefix = namePrefix ?? plugin;
|
|
25628
25259
|
const skillName = prefix ? `${prefix}:${rawName}` : rawName;
|
|
@@ -25630,7 +25261,7 @@ function findSkillDetail(configDir, cwd, name, sources) {
|
|
|
25630
25261
|
let raw;
|
|
25631
25262
|
let mtime;
|
|
25632
25263
|
try {
|
|
25633
|
-
raw =
|
|
25264
|
+
raw = readFileSync10(file, "utf-8");
|
|
25634
25265
|
mtime = statSync5(file).mtime.toISOString();
|
|
25635
25266
|
} catch {
|
|
25636
25267
|
continue;
|
|
@@ -25658,24 +25289,24 @@ function expandSkillCommand(configDir, cwd, text) {
|
|
|
25658
25289
|
const body = skill.body.includes("$ARGUMENTS") ? skill.body.replaceAll("$ARGUMENTS", args) : skill.body + (args ? `
|
|
25659
25290
|
|
|
25660
25291
|
ARGUMENTS: ${args}` : "");
|
|
25661
|
-
return `[the user ran the /${skill.name} skill; its instructions follow. Base directory for this skill: ${
|
|
25292
|
+
return `[the user ran the /${skill.name} skill; its instructions follow. Base directory for this skill: ${dirname2(skill.path)}]
|
|
25662
25293
|
|
|
25663
25294
|
${body.trim()}`;
|
|
25664
25295
|
}
|
|
25665
25296
|
|
|
25666
25297
|
// src/claude/agents.ts
|
|
25667
25298
|
function defaultConfigDir2() {
|
|
25668
|
-
return
|
|
25299
|
+
return join13(homedir6(), ".claude");
|
|
25669
25300
|
}
|
|
25670
25301
|
function expandHome3(p) {
|
|
25671
25302
|
if (p === "~") return homedir6();
|
|
25672
|
-
if (p.startsWith("~/")) return
|
|
25303
|
+
if (p.startsWith("~/")) return join13(homedir6(), p.slice(2));
|
|
25673
25304
|
return p;
|
|
25674
25305
|
}
|
|
25675
25306
|
function parseFrontmatter2(file) {
|
|
25676
25307
|
let content;
|
|
25677
25308
|
try {
|
|
25678
|
-
content =
|
|
25309
|
+
content = readFileSync11(file, "utf-8");
|
|
25679
25310
|
} catch {
|
|
25680
25311
|
return {};
|
|
25681
25312
|
}
|
|
@@ -25691,7 +25322,7 @@ function parseFrontmatter2(file) {
|
|
|
25691
25322
|
}
|
|
25692
25323
|
}
|
|
25693
25324
|
function collectFrom2(root, source) {
|
|
25694
|
-
if (!
|
|
25325
|
+
if (!existsSync13(root)) return [];
|
|
25695
25326
|
let entries2;
|
|
25696
25327
|
try {
|
|
25697
25328
|
entries2 = readdirSync5(root).filter((f) => f.endsWith(".md"));
|
|
@@ -25699,7 +25330,7 @@ function collectFrom2(root, source) {
|
|
|
25699
25330
|
return [];
|
|
25700
25331
|
}
|
|
25701
25332
|
return entries2.map((file) => {
|
|
25702
|
-
const path =
|
|
25333
|
+
const path = join13(root, file);
|
|
25703
25334
|
const fm = parseFrontmatter2(path);
|
|
25704
25335
|
const name = fm.name?.trim() || basename4(file, ".md");
|
|
25705
25336
|
return { name, description: (fm.description ?? "").trim(), source, path };
|
|
@@ -25708,10 +25339,10 @@ function collectFrom2(root, source) {
|
|
|
25708
25339
|
function listAgents(configDir, cwd) {
|
|
25709
25340
|
const base = configDir ? expandHome3(configDir) : defaultConfigDir2();
|
|
25710
25341
|
const collected = [
|
|
25711
|
-
...collectFrom2(
|
|
25712
|
-
...collectFrom2(
|
|
25342
|
+
...collectFrom2(join13(cwd, ".claude", "agents"), "project"),
|
|
25343
|
+
...collectFrom2(join13(base, "agents"), "user"),
|
|
25713
25344
|
// Plugin agents, namespaced `plugin:agent` the way the CLI lists them.
|
|
25714
|
-
...findPluginMarkdown(
|
|
25345
|
+
...findPluginMarkdown(join13(base, "plugins"), "agents").map(({ file, plugin }) => {
|
|
25715
25346
|
const fm = parseFrontmatter2(file);
|
|
25716
25347
|
const name = fm.name?.trim() || basename4(file, ".md");
|
|
25717
25348
|
return {
|
|
@@ -25732,7 +25363,7 @@ function readAgentPersona(configDir, cwd, name) {
|
|
|
25732
25363
|
const agent = listAgents(configDir, cwd).find((a) => a.name === name);
|
|
25733
25364
|
if (!agent) return void 0;
|
|
25734
25365
|
try {
|
|
25735
|
-
const content =
|
|
25366
|
+
const content = readFileSync11(agent.path, "utf-8");
|
|
25736
25367
|
return content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").trim();
|
|
25737
25368
|
} catch {
|
|
25738
25369
|
return void 0;
|
|
@@ -25741,13 +25372,13 @@ function readAgentPersona(configDir, cwd, name) {
|
|
|
25741
25372
|
|
|
25742
25373
|
// src/dashboard/memory-extraction-runner.ts
|
|
25743
25374
|
import { spawn as spawn4 } from "child_process";
|
|
25744
|
-
import { existsSync as
|
|
25375
|
+
import { existsSync as existsSync14, mkdtempSync as mkdtempSync5, readFileSync as readFileSync12, rmSync as rmSync8 } from "fs";
|
|
25745
25376
|
import { tmpdir as tmpdir4 } from "os";
|
|
25746
|
-
import { join as
|
|
25377
|
+
import { join as join15 } from "path";
|
|
25747
25378
|
|
|
25748
25379
|
// ../api/src/dashboard/profile-config.ts
|
|
25749
25380
|
import { homedir as homedir7 } from "os";
|
|
25750
|
-
import { join as
|
|
25381
|
+
import { join as join14, parse, resolve as resolve5 } from "path";
|
|
25751
25382
|
|
|
25752
25383
|
// ../api/src/dashboard/profile-config-cache.ts
|
|
25753
25384
|
var cache3 = /* @__PURE__ */ new Map();
|
|
@@ -25766,7 +25397,7 @@ function profileEnv(key) {
|
|
|
25766
25397
|
function profileClaudeConfigDir() {
|
|
25767
25398
|
const config = cachedProfileConfig();
|
|
25768
25399
|
if (!config) return process.env["CLAUDE_CONFIG_DIR"] || void 0;
|
|
25769
|
-
return config.env["CLAUDE_CONFIG_DIR"]?.trim() ||
|
|
25400
|
+
return config.env["CLAUDE_CONFIG_DIR"]?.trim() || join14(homedir7(), ".claude");
|
|
25770
25401
|
}
|
|
25771
25402
|
function profileOauthToken() {
|
|
25772
25403
|
const env = cachedProfileConfig()?.env ?? {};
|
|
@@ -25775,8 +25406,8 @@ function profileOauthToken() {
|
|
|
25775
25406
|
return process.env["CLAUDE_CODE_OAUTH_TOKEN"] || void 0;
|
|
25776
25407
|
}
|
|
25777
25408
|
function isUnsafeCwd(cwd) {
|
|
25778
|
-
const p =
|
|
25779
|
-
return p === parse(p).root || p ===
|
|
25409
|
+
const p = resolve5(cwd);
|
|
25410
|
+
return p === parse(p).root || p === resolve5(homedir7());
|
|
25780
25411
|
}
|
|
25781
25412
|
function defaultClaudeCwd() {
|
|
25782
25413
|
return profileEnv("CLAUDE_CWD") ?? process.cwd();
|
|
@@ -25827,7 +25458,7 @@ var SUGGEST_TOOLS = "Read,Glob,Grep";
|
|
|
25827
25458
|
function buildInvocation(runner, req, dir, auth, baseEnv = process.env, tools = "") {
|
|
25828
25459
|
const env = { ...baseEnv, CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" };
|
|
25829
25460
|
if (runner === "codex") {
|
|
25830
|
-
const outputFile =
|
|
25461
|
+
const outputFile = join15(dir, "last-message.txt");
|
|
25831
25462
|
return {
|
|
25832
25463
|
command: "codex",
|
|
25833
25464
|
args: [
|
|
@@ -25882,9 +25513,9 @@ ${req.user}`,
|
|
|
25882
25513
|
};
|
|
25883
25514
|
}
|
|
25884
25515
|
function run(inv, cwd) {
|
|
25885
|
-
return new Promise((
|
|
25886
|
-
if (!
|
|
25887
|
-
|
|
25516
|
+
return new Promise((resolve7) => {
|
|
25517
|
+
if (!existsSync14(cwd)) {
|
|
25518
|
+
resolve7({ ok: false, error: `the channel folder ${cwd} does not exist on this Host` });
|
|
25888
25519
|
return;
|
|
25889
25520
|
}
|
|
25890
25521
|
const child = spawn4(inv.command, inv.args, {
|
|
@@ -25902,7 +25533,7 @@ function run(inv, cwd) {
|
|
|
25902
25533
|
child.on("error", (err) => {
|
|
25903
25534
|
clearTimeout(timer);
|
|
25904
25535
|
console.error(`[memory-extraction] ${inv.command} failed to start:`, err.message);
|
|
25905
|
-
|
|
25536
|
+
resolve7({ ok: false, error: `${inv.command} failed to start: ${err.message}` });
|
|
25906
25537
|
});
|
|
25907
25538
|
child.on("close", (code) => {
|
|
25908
25539
|
clearTimeout(timer);
|
|
@@ -25910,18 +25541,18 @@ function run(inv, cwd) {
|
|
|
25910
25541
|
const detail = (stderr || stdout).trim().split("\n").at(-1) ?? "";
|
|
25911
25542
|
const error = `${inv.command} exited ${code ?? "on timeout"}: ${detail.slice(0, 200)}`;
|
|
25912
25543
|
console.error(`[memory-extraction] ${error}`);
|
|
25913
|
-
|
|
25544
|
+
resolve7({ ok: false, error });
|
|
25914
25545
|
return;
|
|
25915
25546
|
}
|
|
25916
25547
|
let raw = stdout;
|
|
25917
25548
|
if (inv.outputFile) {
|
|
25918
25549
|
try {
|
|
25919
|
-
raw =
|
|
25550
|
+
raw = readFileSync12(inv.outputFile, "utf-8");
|
|
25920
25551
|
} catch {
|
|
25921
25552
|
raw = "";
|
|
25922
25553
|
}
|
|
25923
25554
|
}
|
|
25924
|
-
|
|
25555
|
+
resolve7({ ok: true, raw });
|
|
25925
25556
|
});
|
|
25926
25557
|
child.stdin.end(inv.stdin);
|
|
25927
25558
|
});
|
|
@@ -25929,7 +25560,7 @@ function run(inv, cwd) {
|
|
|
25929
25560
|
async function complete(req, tools = "", cwd) {
|
|
25930
25561
|
const runner = runnerForModel(loadDashboardSettings().agent);
|
|
25931
25562
|
const config = resolveChannelConfig(req.channelId);
|
|
25932
|
-
const dir = mkdtempSync5(
|
|
25563
|
+
const dir = mkdtempSync5(join15(tmpdir4(), "flyspace-memory-"));
|
|
25933
25564
|
try {
|
|
25934
25565
|
const inv = buildInvocation(
|
|
25935
25566
|
runner,
|
|
@@ -25944,7 +25575,7 @@ async function complete(req, tools = "", cwd) {
|
|
|
25944
25575
|
);
|
|
25945
25576
|
return await run(inv, cwd ?? dir);
|
|
25946
25577
|
} finally {
|
|
25947
|
-
|
|
25578
|
+
rmSync8(dir, { recursive: true, force: true });
|
|
25948
25579
|
}
|
|
25949
25580
|
}
|
|
25950
25581
|
function completeMemoryExtraction(req) {
|
|
@@ -25957,7 +25588,7 @@ function suggestChannelField(req) {
|
|
|
25957
25588
|
}
|
|
25958
25589
|
|
|
25959
25590
|
// src/store/usage-store.ts
|
|
25960
|
-
import { randomUUID as
|
|
25591
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
25961
25592
|
import Database2 from "better-sqlite3";
|
|
25962
25593
|
|
|
25963
25594
|
// ../api/src/store/rate-cards.ts
|
|
@@ -26298,7 +25929,7 @@ var UsageStore = class {
|
|
|
26298
25929
|
if (ids.length === 0) return;
|
|
26299
25930
|
const update = this.db.prepare("UPDATE agent_usage SET row_uid = ? WHERE id = ?");
|
|
26300
25931
|
this.db.transaction(() => {
|
|
26301
|
-
for (const { id } of ids) update.run(
|
|
25932
|
+
for (const { id } of ids) update.run(randomUUID2(), id);
|
|
26302
25933
|
})();
|
|
26303
25934
|
}
|
|
26304
25935
|
/**
|
|
@@ -26336,7 +25967,7 @@ var UsageStore = class {
|
|
|
26336
25967
|
cost_usd, duration_ms, num_turns, is_error
|
|
26337
25968
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
26338
25969
|
).run(
|
|
26339
|
-
|
|
25970
|
+
randomUUID2(),
|
|
26340
25971
|
ranAt.toISOString(),
|
|
26341
25972
|
entry.source,
|
|
26342
25973
|
entry.channelId ?? null,
|
|
@@ -26644,9 +26275,9 @@ var UsageStore = class {
|
|
|
26644
26275
|
|
|
26645
26276
|
// src/dashboard/rollover-summary.ts
|
|
26646
26277
|
import { spawn as spawn5 } from "child_process";
|
|
26647
|
-
import { existsSync as
|
|
26278
|
+
import { existsSync as existsSync15, mkdtempSync as mkdtempSync6, readFileSync as readFileSync13, rmSync as rmSync9 } from "fs";
|
|
26648
26279
|
import { tmpdir as tmpdir5 } from "os";
|
|
26649
|
-
import { join as
|
|
26280
|
+
import { join as join16 } from "path";
|
|
26650
26281
|
var HAIKU_MODEL = "haiku";
|
|
26651
26282
|
var CJK_PATTERN = /[ -〿-ヿ㐀-䶿一-鿿豈--]/;
|
|
26652
26283
|
function estimateTokens(text) {
|
|
@@ -26709,8 +26340,8 @@ function runSummaryPrint(input, options) {
|
|
|
26709
26340
|
return runPrint("claude", args, env).then((out) => out.trim());
|
|
26710
26341
|
}
|
|
26711
26342
|
async function runCodexSummary(input) {
|
|
26712
|
-
const dir = mkdtempSync6(
|
|
26713
|
-
const lastMessageFile =
|
|
26343
|
+
const dir = mkdtempSync6(join16(tmpdir5(), "rollover-"));
|
|
26344
|
+
const lastMessageFile = join16(dir, "last-message.txt");
|
|
26714
26345
|
try {
|
|
26715
26346
|
await runPrint(
|
|
26716
26347
|
"codex",
|
|
@@ -26733,13 +26364,13 @@ ${input}`
|
|
|
26733
26364
|
],
|
|
26734
26365
|
{ ...process.env }
|
|
26735
26366
|
);
|
|
26736
|
-
return
|
|
26367
|
+
return existsSync15(lastMessageFile) ? readFileSync13(lastMessageFile, "utf8").trim() : "";
|
|
26737
26368
|
} finally {
|
|
26738
|
-
|
|
26369
|
+
rmSync9(dir, { recursive: true, force: true });
|
|
26739
26370
|
}
|
|
26740
26371
|
}
|
|
26741
26372
|
function runPrint(command, args, env) {
|
|
26742
|
-
return new Promise((
|
|
26373
|
+
return new Promise((resolve7, reject) => {
|
|
26743
26374
|
const child = spawn5(command, args, {
|
|
26744
26375
|
// A stateless rewrite touches no files — tmpdir keeps it that way and
|
|
26745
26376
|
// avoids picking up an unrelated project's own CLAUDE.md/AGENTS.md,
|
|
@@ -26769,7 +26400,7 @@ function runPrint(command, args, env) {
|
|
|
26769
26400
|
reject(new Error(`${command} summary exited with code ${code}: ${stderr.trim()}`));
|
|
26770
26401
|
return;
|
|
26771
26402
|
}
|
|
26772
|
-
|
|
26403
|
+
resolve7(stdout);
|
|
26773
26404
|
});
|
|
26774
26405
|
});
|
|
26775
26406
|
}
|
|
@@ -26975,7 +26606,7 @@ async function scanBackgroundTasks() {
|
|
|
26975
26606
|
|
|
26976
26607
|
// src/dashboard/attachment-downloader.ts
|
|
26977
26608
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
26978
|
-
import { join as
|
|
26609
|
+
import { join as join17 } from "path";
|
|
26979
26610
|
import { GetObjectCommand } from "@aws-sdk/client-s3";
|
|
26980
26611
|
var debug4 = process.env["DEBUG"] === "true";
|
|
26981
26612
|
var ATTACHMENT_LINK = /\]\((?:https:\/\/[a-z0-9-]+\.flyspace\.ai)?\/api\/attachments\/([^)?\s]+)(?:\?[^)\s]*)?\)/g;
|
|
@@ -27042,7 +26673,7 @@ async function downloadOne2(key) {
|
|
|
27042
26673
|
if (bytes.length > sizeLimit) {
|
|
27043
26674
|
return { kind: "skip", skipped: { name, mimetype, reason: "too_large" } };
|
|
27044
26675
|
}
|
|
27045
|
-
const localPath =
|
|
26676
|
+
const localPath = join17(paths.UPLOADS_DIR, lastSegment);
|
|
27046
26677
|
await writeFile2(localPath, bytes);
|
|
27047
26678
|
if (debug4)
|
|
27048
26679
|
console.log(`[attachment-downloader] saved ${key} -> ${localPath} (${bytes.length} bytes)`);
|
|
@@ -27066,28 +26697,63 @@ async function downloadChatAttachments(body) {
|
|
|
27066
26697
|
return { succeeded, skipped };
|
|
27067
26698
|
}
|
|
27068
26699
|
|
|
26700
|
+
// src/dashboard/plugin-ui-store.ts
|
|
26701
|
+
import { createHash as createHash5 } from "crypto";
|
|
26702
|
+
var INLINE_MAX = 2048;
|
|
26703
|
+
var uploaded = /* @__PURE__ */ new Map();
|
|
26704
|
+
var sha256 = (s) => createHash5("sha256").update(s).digest("hex");
|
|
26705
|
+
async function offloadSvg(workspace, source) {
|
|
26706
|
+
const cacheKey2 = `${workspace}:${sha256(source)}`;
|
|
26707
|
+
const cached = uploaded.get(cacheKey2);
|
|
26708
|
+
if (cached) return cached;
|
|
26709
|
+
const url = await requestPluginSvg(workspace, source);
|
|
26710
|
+
if (url) uploaded.set(cacheKey2, url);
|
|
26711
|
+
return url;
|
|
26712
|
+
}
|
|
26713
|
+
async function offloadNode(workspace, node) {
|
|
26714
|
+
const children = node.children ? await Promise.all(node.children.map((c) => typeof c === "string" ? c : offloadNode(workspace, c))) : void 0;
|
|
26715
|
+
const source = node.props?.["source"];
|
|
26716
|
+
if (node.type !== "Svg" || typeof source !== "string" || source.length <= INLINE_MAX) {
|
|
26717
|
+
return children ? { ...node, children } : node;
|
|
26718
|
+
}
|
|
26719
|
+
const src = await offloadSvg(workspace, source).catch((err) => {
|
|
26720
|
+
console.error(`[plugin-ui-store] SVG upload failed: ${err.message}`);
|
|
26721
|
+
return null;
|
|
26722
|
+
});
|
|
26723
|
+
if (!src) return children ? { ...node, children } : node;
|
|
26724
|
+
const { source: _, ...props } = node.props;
|
|
26725
|
+
return { ...node, props: { ...props, src }, ...children ? { children } : {} };
|
|
26726
|
+
}
|
|
26727
|
+
async function offloadPluginUi(workspace, state) {
|
|
26728
|
+
const panes = await Promise.all(
|
|
26729
|
+
state.panes.map(async (p) => p.tree ? { ...p, tree: await offloadNode(workspace, p.tree) } : p)
|
|
26730
|
+
);
|
|
26731
|
+
return { ...state, panes };
|
|
26732
|
+
}
|
|
26733
|
+
var pluginUiHash = (state) => sha256(JSON.stringify(state));
|
|
26734
|
+
|
|
27069
26735
|
// src/dashboard/doc-mention-guard.ts
|
|
27070
|
-
import { existsSync as
|
|
26736
|
+
import { existsSync as existsSync20, statSync as statSync8 } from "fs";
|
|
27071
26737
|
|
|
27072
26738
|
// src/dashboard/docs-routes.ts
|
|
27073
26739
|
import {
|
|
27074
26740
|
closeSync,
|
|
27075
26741
|
createReadStream,
|
|
27076
|
-
existsSync as
|
|
26742
|
+
existsSync as existsSync19,
|
|
27077
26743
|
lstatSync as lstatSync2,
|
|
27078
|
-
mkdirSync as
|
|
26744
|
+
mkdirSync as mkdirSync8,
|
|
27079
26745
|
openSync,
|
|
27080
26746
|
readSync,
|
|
27081
26747
|
readdirSync as readdirSync6,
|
|
27082
|
-
readFileSync as
|
|
26748
|
+
readFileSync as readFileSync17,
|
|
27083
26749
|
realpathSync,
|
|
27084
26750
|
renameSync as renameSync3,
|
|
27085
|
-
rmSync as
|
|
26751
|
+
rmSync as rmSync10,
|
|
27086
26752
|
statSync as statSync7,
|
|
27087
|
-
writeFileSync as
|
|
26753
|
+
writeFileSync as writeFileSync7
|
|
27088
26754
|
} from "fs";
|
|
27089
26755
|
import { Readable } from "stream";
|
|
27090
|
-
import { basename as basename6, dirname as
|
|
26756
|
+
import { basename as basename6, dirname as dirname3, extname as extname2, join as join21, relative, resolve as resolve6, sep as sep3 } from "path";
|
|
27091
26757
|
import { Hono as Hono4 } from "hono";
|
|
27092
26758
|
import { streamSSE } from "hono/streaming";
|
|
27093
26759
|
|
|
@@ -27199,8 +26865,8 @@ var requireDocsAccess = async (c, next) => {
|
|
|
27199
26865
|
};
|
|
27200
26866
|
|
|
27201
26867
|
// src/dashboard/docs-watcher.ts
|
|
27202
|
-
import { existsSync as
|
|
27203
|
-
import { basename as basename5, join as
|
|
26868
|
+
import { existsSync as existsSync16, watch } from "fs";
|
|
26869
|
+
import { basename as basename5, join as join18 } from "path";
|
|
27204
26870
|
var DEBOUNCE_MS = 200;
|
|
27205
26871
|
var MAX_PENDING = 200;
|
|
27206
26872
|
var IGNORED_SEGMENTS = /* @__PURE__ */ new Set([
|
|
@@ -27241,7 +26907,7 @@ function watchDocs(cwd, listener) {
|
|
|
27241
26907
|
const current = entries.get(cwd);
|
|
27242
26908
|
if (!current || filename === null) return;
|
|
27243
26909
|
const rel = filename.split("\\").join("/");
|
|
27244
|
-
if (rel === root && !
|
|
26910
|
+
if (rel === root && !existsSync16(join18(cwd, rel))) return;
|
|
27245
26911
|
if (isIgnoredDocPath(rel)) return;
|
|
27246
26912
|
if (current.pending.size < MAX_PENDING) current.pending.add(rel);
|
|
27247
26913
|
if (current.timer === null) current.timer = setTimeout(() => flush(cwd), DEBOUNCE_MS);
|
|
@@ -27295,7 +26961,7 @@ async function putDocTranslation(input) {
|
|
|
27295
26961
|
}
|
|
27296
26962
|
|
|
27297
26963
|
// ../api/src/dashboard/share-translate.ts
|
|
27298
|
-
import { createHash as
|
|
26964
|
+
import { createHash as createHash6 } from "crypto";
|
|
27299
26965
|
|
|
27300
26966
|
// ../api/src/store/doc-share-store.ts
|
|
27301
26967
|
function rowToKind(value) {
|
|
@@ -27605,7 +27271,7 @@ function languageName(lang) {
|
|
|
27605
27271
|
return BY_CODE.get(lang)?.name ?? null;
|
|
27606
27272
|
}
|
|
27607
27273
|
function translationHash(title, content) {
|
|
27608
|
-
return
|
|
27274
|
+
return createHash6("sha256").update(`${RECIPE_VERSION}
|
|
27609
27275
|
${title}
|
|
27610
27276
|
${content}`).digest("hex");
|
|
27611
27277
|
}
|
|
@@ -27840,7 +27506,7 @@ async function clearStaleDocAudios(channelId, sourcePath, lang, exceptHash) {
|
|
|
27840
27506
|
}
|
|
27841
27507
|
|
|
27842
27508
|
// ../api/src/dashboard/share-audio.ts
|
|
27843
|
-
import { createHash as
|
|
27509
|
+
import { createHash as createHash7 } from "crypto";
|
|
27844
27510
|
import { DeleteObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-sdk/client-s3";
|
|
27845
27511
|
|
|
27846
27512
|
// ../api/src/dashboard/tts-routes.ts
|
|
@@ -28039,7 +27705,7 @@ Pacing \u2014 the engine has NO pause control, so rhythm has to be built into th
|
|
|
28039
27705
|
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.`;
|
|
28040
27706
|
}
|
|
28041
27707
|
function articleAudioHash(title, content) {
|
|
28042
|
-
return
|
|
27708
|
+
return createHash7("sha256").update(`v${RECIPE_VERSION2}
|
|
28043
27709
|
${title}
|
|
28044
27710
|
|
|
28045
27711
|
${content}`).digest("hex").slice(0, 32);
|
|
@@ -28162,7 +27828,7 @@ function truncationNotice(lang, voice) {
|
|
|
28162
27828
|
if (lang === "en" || lang.startsWith("en-")) return TRUNCATION_NOTICE.en;
|
|
28163
27829
|
return null;
|
|
28164
27830
|
}
|
|
28165
|
-
var sleep2 = (ms) => new Promise((
|
|
27831
|
+
var sleep2 = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
28166
27832
|
async function synthesizeWithRetry(script, voice) {
|
|
28167
27833
|
let lastError;
|
|
28168
27834
|
for (let attempt = 1; attempt <= SYNTH_ATTEMPTS; attempt += 1) {
|
|
@@ -28266,7 +27932,7 @@ function queueShareAudio(share) {
|
|
|
28266
27932
|
var PENDING_STALE_MS = 30 * 60 * 1e3;
|
|
28267
27933
|
var FAILED_RETRY_MS = 10 * 60 * 1e3;
|
|
28268
27934
|
function langAudioHash(title, content, lang) {
|
|
28269
|
-
return
|
|
27935
|
+
return createHash7("sha256").update(`v${RECIPE_VERSION2}
|
|
28270
27936
|
${lang}
|
|
28271
27937
|
${translationHash(title, content)}`).digest("hex").slice(0, 32);
|
|
28272
27938
|
}
|
|
@@ -28553,8 +28219,8 @@ function createFeatureFlagsRouter() {
|
|
|
28553
28219
|
}
|
|
28554
28220
|
|
|
28555
28221
|
// ../api/src/dashboard/public-share-routes.ts
|
|
28556
|
-
import { existsSync as
|
|
28557
|
-
import { join as
|
|
28222
|
+
import { existsSync as existsSync18, readFileSync as readFileSync15, statSync as statSync6 } from "fs";
|
|
28223
|
+
import { join as join20 } from "path";
|
|
28558
28224
|
import { Hono as Hono3 } from "hono";
|
|
28559
28225
|
import { GetObjectCommand as GetObjectCommand3 } from "@aws-sdk/client-s3";
|
|
28560
28226
|
import { getSignedUrl as getSignedUrl2 } from "@aws-sdk/s3-request-presigner";
|
|
@@ -28760,14 +28426,14 @@ function injectShareHead(html, head) {
|
|
|
28760
28426
|
}
|
|
28761
28427
|
|
|
28762
28428
|
// ../api/src/dashboard/app-icon.ts
|
|
28763
|
-
import { createHash as
|
|
28764
|
-
import { existsSync as
|
|
28765
|
-
import { join as
|
|
28429
|
+
import { createHash as createHash8 } from "crypto";
|
|
28430
|
+
import { existsSync as existsSync17, readFileSync as readFileSync14 } from "fs";
|
|
28431
|
+
import { join as join19 } from "path";
|
|
28766
28432
|
import sharp3 from "sharp";
|
|
28767
28433
|
var PLATE = "#0A0A0F";
|
|
28768
|
-
var BRAND_DIR =
|
|
28769
|
-
var MARK_FILE =
|
|
28770
|
-
var MARK_SVG_FILE =
|
|
28434
|
+
var BRAND_DIR = existsSync17(join19(paths.WEB_ROOT, "public")) ? join19(paths.WEB_ROOT, "public") : join19(paths.PACKAGE_ROOT, "dist", "brand");
|
|
28435
|
+
var MARK_FILE = join19(BRAND_DIR, "icons", "icon-512.png");
|
|
28436
|
+
var MARK_SVG_FILE = join19(BRAND_DIR, "favicon.svg");
|
|
28771
28437
|
var LAYOUT = {
|
|
28772
28438
|
standard: { logo: 0.7, logoCx: 0.5, logoCy: 0.48, badge: 0.27, badgeCx: 0.22, badgeCy: 0.76 },
|
|
28773
28439
|
maskable: { logo: 0.56, logoCx: 0.5, logoCy: 0.48, badge: 0.23, badgeCx: 0.33, badgeCy: 0.66 }
|
|
@@ -28790,7 +28456,7 @@ function roundedPlate(size, fill = PLATE) {
|
|
|
28790
28456
|
}
|
|
28791
28457
|
async function renderBadge(box) {
|
|
28792
28458
|
const transparent = { r: 0, g: 0, b: 0, alpha: 0 };
|
|
28793
|
-
const raster = await sharp3(
|
|
28459
|
+
const raster = await sharp3(readFileSync14(MARK_SVG_FILE)).resize(512, 512, { fit: "contain", background: transparent }).png().toBuffer();
|
|
28794
28460
|
return sharp3(raster).trim().resize(box, box, { fit: "contain", background: transparent }).png().toBuffer();
|
|
28795
28461
|
}
|
|
28796
28462
|
async function sampleBackground(logo) {
|
|
@@ -28839,13 +28505,13 @@ async function renderAppIcon({
|
|
|
28839
28505
|
size,
|
|
28840
28506
|
maskable ? "maskable" : "std",
|
|
28841
28507
|
plain ? "plain" : "badged",
|
|
28842
|
-
logo ?
|
|
28508
|
+
logo ? createHash8("sha1").update(logo).digest("hex").slice(0, 12) : transparent ? "stock-transparent" : "stock"
|
|
28843
28509
|
].join(":");
|
|
28844
28510
|
const hit = cache4.get(key);
|
|
28845
28511
|
if (hit) return hit;
|
|
28846
28512
|
const out = logo && await composeIcon(logo, size, maskable, plain).catch(() => null) || // No workspace logo to lead with — the stock mark is still the best icon,
|
|
28847
28513
|
// either on its usual dark plate or, for a favicon, trimmed and bare.
|
|
28848
|
-
(transparent ? await renderBadge(size) : await sharp3(
|
|
28514
|
+
(transparent ? await renderBadge(size) : await sharp3(readFileSync14(MARK_FILE)).resize(size, size, { fit: "cover" }).png().toBuffer());
|
|
28849
28515
|
cache4.set(key, out);
|
|
28850
28516
|
return out;
|
|
28851
28517
|
}
|
|
@@ -28870,7 +28536,7 @@ async function composeIcon(logo, size, maskable, plain) {
|
|
|
28870
28536
|
}
|
|
28871
28537
|
|
|
28872
28538
|
// ../api/src/dashboard/share-og.ts
|
|
28873
|
-
import { createHash as
|
|
28539
|
+
import { createHash as createHash9 } from "crypto";
|
|
28874
28540
|
import sharp4 from "sharp";
|
|
28875
28541
|
var WIDTH = 1200;
|
|
28876
28542
|
var HEIGHT = 630;
|
|
@@ -29048,7 +28714,7 @@ function cacheKey(input) {
|
|
|
29048
28714
|
input.logo ?? "",
|
|
29049
28715
|
input.theme ?? ""
|
|
29050
28716
|
];
|
|
29051
|
-
return
|
|
28717
|
+
return createHash9("sha1").update(parts.join("\0")).digest("hex");
|
|
29052
28718
|
}
|
|
29053
28719
|
async function renderShareOgImage(input) {
|
|
29054
28720
|
const key = cacheKey(input);
|
|
@@ -29063,7 +28729,7 @@ async function renderShareOgImage(input) {
|
|
|
29063
28729
|
}
|
|
29064
28730
|
|
|
29065
28731
|
// ../api/src/dashboard/share-ask.ts
|
|
29066
|
-
import { createHash as
|
|
28732
|
+
import { createHash as createHash10 } from "crypto";
|
|
29067
28733
|
var MAX_ARTICLE_CHARS3 = 24e3;
|
|
29068
28734
|
var MAX_QUESTION_CHARS = 500;
|
|
29069
28735
|
var SUGGESTION_COUNT = 4;
|
|
@@ -29128,7 +28794,7 @@ function parseSuggestions(raw) {
|
|
|
29128
28794
|
var CACHE_LIMIT = 200;
|
|
29129
28795
|
var suggestionCache = /* @__PURE__ */ new Map();
|
|
29130
28796
|
function articleHash(title, content, lang) {
|
|
29131
|
-
return
|
|
28797
|
+
return createHash10("sha256").update(`${lang ?? ""}
|
|
29132
28798
|
${title}
|
|
29133
28799
|
|
|
29134
28800
|
${content}`).digest("hex").slice(0, 32);
|
|
@@ -29384,7 +29050,7 @@ var shellCache = null;
|
|
|
29384
29050
|
function readShell(path) {
|
|
29385
29051
|
const { mtimeMs } = statSync6(path);
|
|
29386
29052
|
if (shellCache?.mtimeMs === mtimeMs) return shellCache.html;
|
|
29387
|
-
const html =
|
|
29053
|
+
const html = readFileSync15(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
|
|
29388
29054
|
shellCache = { mtimeMs, html };
|
|
29389
29055
|
return html;
|
|
29390
29056
|
}
|
|
@@ -29404,17 +29070,17 @@ function serveBuildFile(c, webDist, dir, name) {
|
|
|
29404
29070
|
if (!type || !/^[A-Za-z0-9._-]+$/.test(name) || name.includes("..")) {
|
|
29405
29071
|
return c.text("not found", 404);
|
|
29406
29072
|
}
|
|
29407
|
-
const path =
|
|
29408
|
-
if (!
|
|
29073
|
+
const path = join20(webDist, dir, name);
|
|
29074
|
+
if (!existsSync18(path)) return c.text("not found", 404);
|
|
29409
29075
|
c.header("Content-Type", type);
|
|
29410
29076
|
c.header("Cache-Control", "public, max-age=31536000, immutable");
|
|
29411
29077
|
if (ext === ".css") {
|
|
29412
|
-
return c.body(
|
|
29078
|
+
return c.body(readFileSync15(path, "utf8").replaceAll("url(/fonts/", `url(${BUILD_PREFIX}/fonts/`));
|
|
29413
29079
|
}
|
|
29414
29080
|
if (ext === ".js") {
|
|
29415
|
-
return c.body(
|
|
29081
|
+
return c.body(readFileSync15(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`));
|
|
29416
29082
|
}
|
|
29417
|
-
return c.body(new Uint8Array(
|
|
29083
|
+
return c.body(new Uint8Array(readFileSync15(path)));
|
|
29418
29084
|
}
|
|
29419
29085
|
var HTML_SHARE_CSP = "sandbox allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox";
|
|
29420
29086
|
function servePublishedHtml(c, share) {
|
|
@@ -29550,8 +29216,8 @@ ${analytics}` : head);
|
|
|
29550
29216
|
const requested = c.req.param("lang");
|
|
29551
29217
|
const lang = canonicalLanguage(requested);
|
|
29552
29218
|
if (!isTranslatableLanguage(lang)) return next();
|
|
29553
|
-
const shell =
|
|
29554
|
-
if (!
|
|
29219
|
+
const shell = join20(webDist, "index.html");
|
|
29220
|
+
if (!existsSync18(shell)) return next();
|
|
29555
29221
|
const share = await getDocShare(c.req.param("id"));
|
|
29556
29222
|
if (!share) return next();
|
|
29557
29223
|
if (requested !== lang) return c.redirect(`/share/${share.id}/${lang}`, 302);
|
|
@@ -29586,8 +29252,8 @@ ${analytics}` : head);
|
|
|
29586
29252
|
const share = await getDocShare(c.req.param("id"));
|
|
29587
29253
|
if (!share) return next();
|
|
29588
29254
|
if (share.kind === "html") return servePublishedHtml(c, share);
|
|
29589
|
-
const shell =
|
|
29590
|
-
if (!
|
|
29255
|
+
const shell = join20(webDist, "index.html");
|
|
29256
|
+
if (!existsSync18(shell)) return next();
|
|
29591
29257
|
return readerPage(
|
|
29592
29258
|
c,
|
|
29593
29259
|
share,
|
|
@@ -29612,7 +29278,7 @@ ${analytics}` : head);
|
|
|
29612
29278
|
}
|
|
29613
29279
|
|
|
29614
29280
|
// src/dashboard/artifact-export.ts
|
|
29615
|
-
import { readFileSync as
|
|
29281
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
29616
29282
|
async function exportDocAsArtifact(channelId, docPath) {
|
|
29617
29283
|
const owningProfile = findOwningProfile(channelId);
|
|
29618
29284
|
const channelConfig = await runWithProfile(
|
|
@@ -29621,7 +29287,7 @@ async function exportDocAsArtifact(channelId, docPath) {
|
|
|
29621
29287
|
);
|
|
29622
29288
|
const abs = resolveDocPath(channelConfig.cwd, docPath);
|
|
29623
29289
|
if (!abs) throw new Error(`doc not found: ${docPath}`);
|
|
29624
|
-
const content =
|
|
29290
|
+
const content = readFileSync16(abs, "utf8");
|
|
29625
29291
|
const title = extractTitle(abs, "md");
|
|
29626
29292
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
29627
29293
|
const prompt = `Publish the document at \`${docPath}\` (already read below) as a Claude Artifact, then record the result as a stub file under this channel's \`docs/artifacts/\` folder (create the folder if it doesn't exist).
|
|
@@ -29853,7 +29519,7 @@ function extractTitle(absPath, kind) {
|
|
|
29853
29519
|
}
|
|
29854
29520
|
function resolveDirPath(root, rel) {
|
|
29855
29521
|
if (rel.includes("\0")) return null;
|
|
29856
|
-
const abs =
|
|
29522
|
+
const abs = resolve6(root, rel);
|
|
29857
29523
|
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
29858
29524
|
return abs;
|
|
29859
29525
|
}
|
|
@@ -29881,7 +29547,7 @@ function probeDir(absDir, showHidden) {
|
|
|
29881
29547
|
return false;
|
|
29882
29548
|
}
|
|
29883
29549
|
if (!showHidden && entry.name.startsWith(".")) continue;
|
|
29884
|
-
const abs =
|
|
29550
|
+
const abs = join21(dir, entry.name);
|
|
29885
29551
|
const kind = entryKind(entry, abs);
|
|
29886
29552
|
if (kind === "dir") {
|
|
29887
29553
|
if (SKIP_DIRS.has(entry.name)) hasOther = true;
|
|
@@ -29901,14 +29567,14 @@ function probeDir(absDir, showHidden) {
|
|
|
29901
29567
|
}
|
|
29902
29568
|
function readGitBranch(dir) {
|
|
29903
29569
|
try {
|
|
29904
|
-
let gitDir =
|
|
29570
|
+
let gitDir = join21(dir, ".git");
|
|
29905
29571
|
if (statSync7(gitDir).isFile()) {
|
|
29906
|
-
const pointer =
|
|
29572
|
+
const pointer = readFileSync17(gitDir, "utf8").trim();
|
|
29907
29573
|
const match = pointer.match(/^gitdir:\s*(.+)$/);
|
|
29908
29574
|
if (!match) return void 0;
|
|
29909
|
-
gitDir =
|
|
29575
|
+
gitDir = resolve6(dir, match[1]);
|
|
29910
29576
|
}
|
|
29911
|
-
const head =
|
|
29577
|
+
const head = readFileSync17(join21(gitDir, "HEAD"), "utf8").trim();
|
|
29912
29578
|
const branchMatch = head.match(/^ref:\s*refs\/heads\/(.+)$/);
|
|
29913
29579
|
if (branchMatch) return branchMatch[1];
|
|
29914
29580
|
return /^[0-9a-f]{7,40}$/i.test(head) ? head.slice(0, 7) : void 0;
|
|
@@ -29930,14 +29596,14 @@ function listDocLevel(root, relDir = "", sort = "newest", showHidden = false) {
|
|
|
29930
29596
|
for (const entry of entries2) {
|
|
29931
29597
|
if (dirs.length + docs.length >= MAX_ENTRIES) break;
|
|
29932
29598
|
if (!showHidden && entry.name.startsWith(".")) continue;
|
|
29933
|
-
const abs =
|
|
29599
|
+
const abs = join21(absDir, entry.name);
|
|
29934
29600
|
const path = relative(root, abs).split(sep3).join("/");
|
|
29935
29601
|
const kind = entryKind(entry, abs);
|
|
29936
29602
|
if (kind === "dir") {
|
|
29937
29603
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
29938
29604
|
const probe = probeDir(abs, showHidden);
|
|
29939
29605
|
if (!probe.hasDocs && probe.hasOther) continue;
|
|
29940
|
-
const isRepo =
|
|
29606
|
+
const isRepo = existsSync19(join21(abs, ".git"));
|
|
29941
29607
|
dirs.push({
|
|
29942
29608
|
path,
|
|
29943
29609
|
name: entry.name,
|
|
@@ -29973,7 +29639,7 @@ function flatDocs(root, {
|
|
|
29973
29639
|
for (const entry of entries2) {
|
|
29974
29640
|
if (hits.length >= MAX_FLAT_DOCS) return;
|
|
29975
29641
|
if (!showHidden && entry.name.startsWith(".")) continue;
|
|
29976
|
-
const abs =
|
|
29642
|
+
const abs = join21(dir, entry.name);
|
|
29977
29643
|
const kind = entryKind(entry, abs);
|
|
29978
29644
|
if (kind === "dir") {
|
|
29979
29645
|
if (!SKIP_DIRS.has(entry.name)) walk(abs, depth + 1);
|
|
@@ -29993,7 +29659,7 @@ function flatDocs(root, {
|
|
|
29993
29659
|
}
|
|
29994
29660
|
function resolveDocPath(root, rel) {
|
|
29995
29661
|
if (!rel || rel.includes("\0")) return null;
|
|
29996
|
-
const abs =
|
|
29662
|
+
const abs = resolve6(root, rel);
|
|
29997
29663
|
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
29998
29664
|
const ext = extname2(abs).toLowerCase();
|
|
29999
29665
|
if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return null;
|
|
@@ -30015,12 +29681,12 @@ function writeDocContent(root, rel, content, baseMtime) {
|
|
|
30015
29681
|
if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES) {
|
|
30016
29682
|
return { status: "too-large" };
|
|
30017
29683
|
}
|
|
30018
|
-
|
|
29684
|
+
writeFileSync7(abs, content, "utf8");
|
|
30019
29685
|
return { status: "ok", mtime: statSync7(abs).mtime.toISOString() };
|
|
30020
29686
|
}
|
|
30021
29687
|
function resolveRawPath(root, rel) {
|
|
30022
29688
|
if (!rel || rel.includes("\0")) return null;
|
|
30023
|
-
const abs =
|
|
29689
|
+
const abs = resolve6(root, rel);
|
|
30024
29690
|
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30025
29691
|
const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()];
|
|
30026
29692
|
if (!contentType) return null;
|
|
@@ -30028,14 +29694,14 @@ function resolveRawPath(root, rel) {
|
|
|
30028
29694
|
}
|
|
30029
29695
|
function resolveHtmlPath(root, rel) {
|
|
30030
29696
|
if (!rel || rel.includes("\0")) return null;
|
|
30031
|
-
const abs =
|
|
29697
|
+
const abs = resolve6(root, rel);
|
|
30032
29698
|
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30033
29699
|
if (DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "html") return null;
|
|
30034
29700
|
return abs;
|
|
30035
29701
|
}
|
|
30036
29702
|
function resolveDownloadPath(root, rel) {
|
|
30037
29703
|
if (!rel || rel.includes("\0")) return null;
|
|
30038
|
-
const abs =
|
|
29704
|
+
const abs = resolve6(root, rel);
|
|
30039
29705
|
if (abs !== root && !abs.startsWith(root + sep3)) return null;
|
|
30040
29706
|
if (!isListableFile(basename6(abs))) return null;
|
|
30041
29707
|
const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()] ?? "application/octet-stream";
|
|
@@ -30053,7 +29719,7 @@ function uniqueName(absDir, name) {
|
|
|
30053
29719
|
let candidate = name;
|
|
30054
29720
|
for (let n = 1; n < 1e3; n++) {
|
|
30055
29721
|
try {
|
|
30056
|
-
statSync7(
|
|
29722
|
+
statSync7(join21(absDir, candidate));
|
|
30057
29723
|
} catch {
|
|
30058
29724
|
return candidate;
|
|
30059
29725
|
}
|
|
@@ -30075,8 +29741,8 @@ function saveUploadedFile(root, relDir, name, data) {
|
|
|
30075
29741
|
if (!(ext in DOC_EXTENSIONS) && !ASSET_LIST_EXTENSIONS.has(ext)) return { status: "bad-type" };
|
|
30076
29742
|
if (data.byteLength > MAX_UPLOAD_BYTES) return { status: "too-large" };
|
|
30077
29743
|
const final = uniqueName(absDir, safe);
|
|
30078
|
-
const abs =
|
|
30079
|
-
|
|
29744
|
+
const abs = join21(absDir, final);
|
|
29745
|
+
writeFileSync7(abs, data);
|
|
30080
29746
|
return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: final };
|
|
30081
29747
|
}
|
|
30082
29748
|
function createDocFolder(root, relDir, name) {
|
|
@@ -30089,13 +29755,13 @@ function createDocFolder(root, relDir, name) {
|
|
|
30089
29755
|
}
|
|
30090
29756
|
const safe = sanitizeUploadName(name);
|
|
30091
29757
|
if (!safe) return { status: "bad-name" };
|
|
30092
|
-
const abs =
|
|
29758
|
+
const abs = join21(absDir, safe);
|
|
30093
29759
|
try {
|
|
30094
29760
|
statSync7(abs);
|
|
30095
29761
|
return { status: "exists" };
|
|
30096
29762
|
} catch {
|
|
30097
29763
|
}
|
|
30098
|
-
|
|
29764
|
+
mkdirSync8(abs);
|
|
30099
29765
|
return { status: "ok", path: relative(root, abs).split(sep3).join("/"), name: safe };
|
|
30100
29766
|
}
|
|
30101
29767
|
function createDocFile(root, relDir, name, content) {
|
|
@@ -30112,9 +29778,9 @@ function createDocFile(root, relDir, name, content) {
|
|
|
30112
29778
|
if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return { status: "bad-name" };
|
|
30113
29779
|
if (SKIP_FILES.has(safe)) return { status: "bad-name" };
|
|
30114
29780
|
if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES) return { status: "too-large" };
|
|
30115
|
-
const abs =
|
|
29781
|
+
const abs = join21(absDir, safe);
|
|
30116
29782
|
try {
|
|
30117
|
-
|
|
29783
|
+
writeFileSync7(abs, content, { encoding: "utf8", flag: "wx" });
|
|
30118
29784
|
} catch (err) {
|
|
30119
29785
|
if (err.code === "EEXIST") return { status: "exists" };
|
|
30120
29786
|
throw err;
|
|
@@ -30123,7 +29789,7 @@ function createDocFile(root, relDir, name, content) {
|
|
|
30123
29789
|
}
|
|
30124
29790
|
function moveDocEntry(root, from, to) {
|
|
30125
29791
|
if (!from || !to || from.includes("\0") || to.includes("\0")) return { status: "not-found" };
|
|
30126
|
-
const absFrom =
|
|
29792
|
+
const absFrom = resolve6(root, from);
|
|
30127
29793
|
if (!absFrom.startsWith(root + sep3)) return { status: "not-found" };
|
|
30128
29794
|
let stat;
|
|
30129
29795
|
try {
|
|
@@ -30133,7 +29799,7 @@ function moveDocEntry(root, from, to) {
|
|
|
30133
29799
|
}
|
|
30134
29800
|
const isDir = stat.isDirectory();
|
|
30135
29801
|
if (!isDir && !stat.isFile()) return { status: "not-found" };
|
|
30136
|
-
const absTo =
|
|
29802
|
+
const absTo = resolve6(root, to);
|
|
30137
29803
|
if (!absTo.startsWith(root + sep3)) return { status: "bad-target" };
|
|
30138
29804
|
const name = sanitizeUploadName(basename6(absTo));
|
|
30139
29805
|
if (!name) return { status: "bad-target" };
|
|
@@ -30143,14 +29809,14 @@ function moveDocEntry(root, from, to) {
|
|
|
30143
29809
|
return { status: "bad-target" };
|
|
30144
29810
|
}
|
|
30145
29811
|
}
|
|
30146
|
-
const absToDir =
|
|
29812
|
+
const absToDir = dirname3(absTo);
|
|
30147
29813
|
if (resolveDirPath(root, relative(root, absToDir)) === null) return { status: "bad-target" };
|
|
30148
29814
|
try {
|
|
30149
29815
|
if (!statSync7(absToDir).isDirectory()) return { status: "bad-target" };
|
|
30150
29816
|
} catch {
|
|
30151
29817
|
return { status: "bad-target" };
|
|
30152
29818
|
}
|
|
30153
|
-
const finalAbs =
|
|
29819
|
+
const finalAbs = join21(absToDir, name);
|
|
30154
29820
|
if (isDir && (finalAbs === absFrom || finalAbs.startsWith(absFrom + sep3))) {
|
|
30155
29821
|
return { status: "into-self" };
|
|
30156
29822
|
}
|
|
@@ -30163,7 +29829,7 @@ function moveDocEntry(root, from, to) {
|
|
|
30163
29829
|
}
|
|
30164
29830
|
function deleteDocEntry(root, path) {
|
|
30165
29831
|
if (!path || path.includes("\0")) return { status: "not-found" };
|
|
30166
|
-
const abs =
|
|
29832
|
+
const abs = resolve6(root, path);
|
|
30167
29833
|
if (!abs.startsWith(root + sep3)) return { status: "not-found" };
|
|
30168
29834
|
let stat;
|
|
30169
29835
|
try {
|
|
@@ -30173,7 +29839,7 @@ function deleteDocEntry(root, path) {
|
|
|
30173
29839
|
}
|
|
30174
29840
|
const isDir = stat.isDirectory();
|
|
30175
29841
|
if (!isDir && !stat.isFile() && !stat.isSymbolicLink()) return { status: "not-found" };
|
|
30176
|
-
|
|
29842
|
+
rmSync10(abs, { recursive: isDir });
|
|
30177
29843
|
return {
|
|
30178
29844
|
status: "ok",
|
|
30179
29845
|
path: relative(root, abs).split(sep3).join("/"),
|
|
@@ -30234,7 +29900,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30234
29900
|
}
|
|
30235
29901
|
if (!stat.isFile()) return c.json({ error: "not found" }, 404);
|
|
30236
29902
|
if (stat.size > MAX_RAW_BYTES) return c.json({ error: "file too large" }, 413);
|
|
30237
|
-
return c.body(withDocLinkBridge(
|
|
29903
|
+
return c.body(withDocLinkBridge(readFileSync17(abs, "utf8")), 200, {
|
|
30238
29904
|
"Content-Type": "text/html; charset=utf-8",
|
|
30239
29905
|
"Content-Security-Policy": HTML_SHARE_CSP,
|
|
30240
29906
|
"X-Content-Type-Options": "nosniff",
|
|
@@ -30249,7 +29915,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30249
29915
|
const dir = typeof form.get("path") === "string" ? form.get("path") : "";
|
|
30250
29916
|
const files = form.getAll("file").filter((f) => f instanceof File);
|
|
30251
29917
|
if (files.length === 0) return c.json({ error: "missing file" }, 400);
|
|
30252
|
-
const
|
|
29918
|
+
const uploaded2 = [];
|
|
30253
29919
|
const failed = [];
|
|
30254
29920
|
for (const file of files) {
|
|
30255
29921
|
if (file.size > MAX_UPLOAD_BYTES) {
|
|
@@ -30262,7 +29928,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30262
29928
|
const result = saveUploadedFile(cwd, dir, file.name, Buffer.from(await file.arrayBuffer()));
|
|
30263
29929
|
switch (result.status) {
|
|
30264
29930
|
case "ok":
|
|
30265
|
-
|
|
29931
|
+
uploaded2.push({ path: result.path, name: result.name });
|
|
30266
29932
|
break;
|
|
30267
29933
|
case "no-dir":
|
|
30268
29934
|
return c.json({ error: "folder not found" }, 404);
|
|
@@ -30276,7 +29942,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30276
29942
|
failed.push({ name: file.name, error: "invalid filename" });
|
|
30277
29943
|
}
|
|
30278
29944
|
}
|
|
30279
|
-
return c.json({ path: dir, uploaded, failed },
|
|
29945
|
+
return c.json({ path: dir, uploaded: uploaded2, failed }, uploaded2.length > 0 ? 201 : 400);
|
|
30280
29946
|
});
|
|
30281
29947
|
app.post("/:id/docs/folder", async (c) => {
|
|
30282
29948
|
const { cwd } = resolveChannelConfig(c.req.param("id"));
|
|
@@ -30419,7 +30085,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30419
30085
|
title: kind ? extractTitle(abs, kind) : basename6(abs),
|
|
30420
30086
|
mtime: stat.mtime.toISOString(),
|
|
30421
30087
|
tooLarge: tooLarge || void 0,
|
|
30422
|
-
content: tooLarge ? "" :
|
|
30088
|
+
content: tooLarge ? "" : readFileSync17(abs, "utf8")
|
|
30423
30089
|
});
|
|
30424
30090
|
});
|
|
30425
30091
|
app.put("/:id/docs/content", async (c) => {
|
|
@@ -30462,7 +30128,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
|
|
|
30462
30128
|
channel,
|
|
30463
30129
|
rel,
|
|
30464
30130
|
title: extractTitle(abs, "md"),
|
|
30465
|
-
content:
|
|
30131
|
+
content: readFileSync17(abs, "utf8")
|
|
30466
30132
|
};
|
|
30467
30133
|
};
|
|
30468
30134
|
app.get("/:id/docs/translation/:lang", async (c) => {
|
|
@@ -30520,7 +30186,7 @@ function withDocLinkBridge(html) {
|
|
|
30520
30186
|
var DOC_MENTION_RE = /(?<![\w@/`])@((?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]{1,6})(?::(\d+))?(?![\w-])/g;
|
|
30521
30187
|
function isRealDoc(root, rel) {
|
|
30522
30188
|
const abs = resolveDocPath(root, rel);
|
|
30523
|
-
if (!abs || !
|
|
30189
|
+
if (!abs || !existsSync20(abs)) return false;
|
|
30524
30190
|
try {
|
|
30525
30191
|
return statSync8(abs).isFile();
|
|
30526
30192
|
} catch {
|
|
@@ -31124,7 +30790,9 @@ var ChatAgent = class {
|
|
|
31124
30790
|
async wake(threadId, replyId, text) {
|
|
31125
30791
|
const wakes = this.consecutiveWakes.get(threadId) ?? 0;
|
|
31126
30792
|
if (wakes >= MAX_CONSECUTIVE_WAKES) {
|
|
31127
|
-
console.log(
|
|
30793
|
+
console.log(
|
|
30794
|
+
`[chat-agent] wake refused, cap of ${MAX_CONSECUTIVE_WAKES} reached. thread=${threadId}`
|
|
30795
|
+
);
|
|
31128
30796
|
return false;
|
|
31129
30797
|
}
|
|
31130
30798
|
const { data } = await this.supabase().from("thread_replies").select("author").eq("thread_id", threadId).is("archived_at", null).order("created_at", { ascending: false }).limit(50);
|
|
@@ -31166,7 +30834,8 @@ var ChatAgent = class {
|
|
|
31166
30834
|
* background.
|
|
31167
30835
|
*/
|
|
31168
30836
|
async continueAfterKilledTool(threadId, channelId, profile, topic, reply) {
|
|
31169
|
-
if (!await this.shouldResume(topic, [{ author: AGENT_AUTHOR, body: reply }], "killed-tool"))
|
|
30837
|
+
if (!await this.shouldResume(topic, [{ author: AGENT_AUTHOR, body: reply }], "killed-tool"))
|
|
30838
|
+
return;
|
|
31170
30839
|
const slot = this.claimAutoContinue(threadId, channelId);
|
|
31171
30840
|
if (!slot) return;
|
|
31172
30841
|
await this.autoContinue(
|
|
@@ -31189,7 +30858,10 @@ var ChatAgent = class {
|
|
|
31189
30858
|
if (tasks.length === 0) return;
|
|
31190
30859
|
this.watchedTasks.set(threadId, { profile, channelId, firstSeen: Date.now(), tasks });
|
|
31191
30860
|
this.channelActivityNotifier()("background", { channelId, threadId, on: true });
|
|
31192
|
-
this.backgroundSweep ??= setInterval(
|
|
30861
|
+
this.backgroundSweep ??= setInterval(
|
|
30862
|
+
() => void this.sweepBackgroundTasks(),
|
|
30863
|
+
BACKGROUND_SWEEP_MS
|
|
30864
|
+
);
|
|
31193
30865
|
this.backgroundSweep.unref?.();
|
|
31194
30866
|
}
|
|
31195
30867
|
async sweepBackgroundTasks() {
|
|
@@ -31198,7 +30870,11 @@ var ChatAgent = class {
|
|
|
31198
30870
|
const tasks = live.get(threadId);
|
|
31199
30871
|
if (tasks?.length) {
|
|
31200
30872
|
watched.tasks = tasks;
|
|
31201
|
-
this.channelActivityNotifier()("background", {
|
|
30873
|
+
this.channelActivityNotifier()("background", {
|
|
30874
|
+
channelId: watched.channelId,
|
|
30875
|
+
threadId,
|
|
30876
|
+
on: true
|
|
30877
|
+
});
|
|
31202
30878
|
const oldest = Math.min(...tasks.map((t) => t.startedAt));
|
|
31203
30879
|
if (!watched.checkedIn && Date.now() - oldest >= BACKGROUND_CHECK_IN_MS) {
|
|
31204
30880
|
watched.checkedIn = true;
|
|
@@ -31207,19 +30883,27 @@ var ChatAgent = class {
|
|
|
31207
30883
|
await runWithProfile(watched.profile, async () => {
|
|
31208
30884
|
const { replyId } = await postToDashboardChannel({ threadId, text: text2 });
|
|
31209
30885
|
await this.wake(threadId, replyId, text2);
|
|
31210
|
-
}).catch(
|
|
30886
|
+
}).catch(
|
|
30887
|
+
(err) => console.error("[chat-agent] background check-in failed:", err.message)
|
|
30888
|
+
);
|
|
31211
30889
|
}
|
|
31212
30890
|
continue;
|
|
31213
30891
|
}
|
|
31214
30892
|
this.watchedTasks.delete(threadId);
|
|
31215
|
-
this.channelActivityNotifier()("background", {
|
|
30893
|
+
this.channelActivityNotifier()("background", {
|
|
30894
|
+
channelId: watched.channelId,
|
|
30895
|
+
threadId,
|
|
30896
|
+
on: false
|
|
30897
|
+
});
|
|
31216
30898
|
if ((this.lastWakeAt.get(threadId) ?? 0) >= watched.firstSeen) continue;
|
|
31217
30899
|
console.log(`[chat-agent] background task ended without waking. thread=${threadId}`);
|
|
31218
30900
|
const text = "Background task ended without reporting a result (it may have been killed or the machine restarted).";
|
|
31219
30901
|
await runWithProfile(watched.profile, async () => {
|
|
31220
30902
|
const { replyId } = await postToDashboardChannel({ threadId, text });
|
|
31221
30903
|
await this.wake(threadId, replyId, text);
|
|
31222
|
-
}).catch(
|
|
30904
|
+
}).catch(
|
|
30905
|
+
(err) => console.error("[chat-agent] background wake failed:", err.message)
|
|
30906
|
+
);
|
|
31223
30907
|
}
|
|
31224
30908
|
if (this.watchedTasks.size === 0 && this.backgroundSweep) {
|
|
31225
30909
|
clearInterval(this.backgroundSweep);
|
|
@@ -31351,10 +31035,9 @@ var ChatAgent = class {
|
|
|
31351
31035
|
const { data: thread } = await this.supabase().from("threads").select("channel_id").eq("id", threadId).single();
|
|
31352
31036
|
if (!thread?.channel_id) return false;
|
|
31353
31037
|
const { data } = await this.supabase().from("workspaces").select("agent_paused, plan_status").eq("slug", findOwningProfile(thread.channel_id));
|
|
31354
|
-
const paused = (data ?? []).some(
|
|
31355
|
-
|
|
31356
|
-
|
|
31357
|
-
if (paused) console.log(`[chat-agent] agent paused or plan locked, not answering thread=${threadId}`);
|
|
31038
|
+
const paused = (data ?? []).some((r) => r.agent_paused === true || isLockedPlan(r.plan_status ?? null));
|
|
31039
|
+
if (paused)
|
|
31040
|
+
console.log(`[chat-agent] agent paused or plan locked, not answering thread=${threadId}`);
|
|
31358
31041
|
return paused;
|
|
31359
31042
|
} catch (err) {
|
|
31360
31043
|
console.error(`[chat-agent] pause check failed for thread=${threadId}:`, err);
|
|
@@ -31618,12 +31301,16 @@ var ChatAgent = class {
|
|
|
31618
31301
|
...isHumanAuthor(msg.author) ? { requesterHandle: msg.author } : {},
|
|
31619
31302
|
slackBound: !!channelRow?.external_channel_id
|
|
31620
31303
|
};
|
|
31621
|
-
if (memory.memoryPrompt)
|
|
31304
|
+
if (memory.memoryPrompt)
|
|
31305
|
+
channelConfig = { ...channelConfig, memoryPrompt: memory.memoryPrompt };
|
|
31622
31306
|
const store = this.openSessionStore();
|
|
31623
31307
|
try {
|
|
31624
31308
|
const channelKey = `chat:${thread.channel_id}`;
|
|
31625
31309
|
const session = store.getSession(channelKey, msg.threadId);
|
|
31626
|
-
const docsNote = docsAccessPromptNote(
|
|
31310
|
+
const docsNote = docsAccessPromptNote(
|
|
31311
|
+
channelConfig.docsAccess,
|
|
31312
|
+
channelConfig.docsAccessUnverified
|
|
31313
|
+
);
|
|
31627
31314
|
const header = (docsNote ? `[access: ${docsNote}]
|
|
31628
31315
|
|
|
31629
31316
|
` : "") + `[context: chat channel=${thread.channel_id}, thread_id=${thread.id}` + (thread.title ? `, thread="${thread.title}"` : "") + `, sender=${msg.author}. This is the Flyspace dashboard, not Slack \u2014 it renders full Markdown, so use normal paragraphs, line breaks, and real Markdown lists instead of Slack-style single-line replies. When you name a file that lives in this channel's folder, write it as @ + its cwd-relative path (@docs/spec.md, @web/src/App.tsx) as plain text, never inside backticks or a Markdown link \u2014 the dashboard turns that into a chip the reader clicks to open the file. A trailing line number (@src/app.ts:120) is fine. Paths outside the cwd stay in backticks.]
|
|
@@ -31735,7 +31422,13 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
31735
31422
|
if (!response2 || response2.isError) {
|
|
31736
31423
|
await this.postReply(
|
|
31737
31424
|
msg.threadId,
|
|
31738
|
-
this.failureReply(
|
|
31425
|
+
this.failureReply(
|
|
31426
|
+
owningProfile,
|
|
31427
|
+
thread.channel_id,
|
|
31428
|
+
msg.threadId,
|
|
31429
|
+
"codex",
|
|
31430
|
+
response2?.failure
|
|
31431
|
+
)
|
|
31739
31432
|
);
|
|
31740
31433
|
return;
|
|
31741
31434
|
}
|
|
@@ -31814,7 +31507,13 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
31814
31507
|
if (!response || this.isTransientFailure(response)) {
|
|
31815
31508
|
await this.postReply(
|
|
31816
31509
|
msg.threadId,
|
|
31817
|
-
this.failureReply(
|
|
31510
|
+
this.failureReply(
|
|
31511
|
+
owningProfile,
|
|
31512
|
+
thread.channel_id,
|
|
31513
|
+
msg.threadId,
|
|
31514
|
+
"claude",
|
|
31515
|
+
response?.failure
|
|
31516
|
+
)
|
|
31818
31517
|
);
|
|
31819
31518
|
return;
|
|
31820
31519
|
}
|
|
@@ -31826,14 +31525,17 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
31826
31525
|
if (response.isTimeout) {
|
|
31827
31526
|
const slot = response.sessionId ? this.claimAutoContinue(msg.threadId, thread.channel_id) : null;
|
|
31828
31527
|
if (slot) {
|
|
31829
|
-
if (response.partialText)
|
|
31528
|
+
if (response.partialText)
|
|
31529
|
+
await this.postReply(msg.threadId, response.partialText, activities);
|
|
31830
31530
|
const idle = response.timeoutKind === "idle";
|
|
31831
31531
|
void this.autoContinue(
|
|
31832
31532
|
msg.threadId,
|
|
31833
31533
|
owningProfile,
|
|
31834
31534
|
`This turn hit its time limit, continuing automatically (${slot.n}/${slot.limit}).`,
|
|
31835
31535
|
(idle ? "Your last turn was stopped after several minutes with no output, most likely a command that never exited or ran too long. Run long or open-ended commands in the background with a `flyspace chat wake` callback instead." : "Your last turn was stopped because it ran past the time limit for a single turn.") + " Check what already got done, then carry on with what is left."
|
|
31836
|
-
).catch(
|
|
31536
|
+
).catch(
|
|
31537
|
+
(err) => console.error("[chat-agent] timeout continue failed:", err.message)
|
|
31538
|
+
);
|
|
31837
31539
|
return;
|
|
31838
31540
|
}
|
|
31839
31541
|
if (response.sessionId) {
|
|
@@ -31924,22 +31626,22 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
31924
31626
|
let ready;
|
|
31925
31627
|
try {
|
|
31926
31628
|
channel = this.supabase().channel(`agent-thinking:${threadId}`);
|
|
31927
|
-
ready = new Promise((
|
|
31629
|
+
ready = new Promise((resolve7) => {
|
|
31928
31630
|
const timeout = setTimeout(() => {
|
|
31929
31631
|
console.error(`[chat-agent] thinking-channel ${threadId}: subscribe timed out after 10s`);
|
|
31930
|
-
|
|
31632
|
+
resolve7(false);
|
|
31931
31633
|
}, 1e4);
|
|
31932
31634
|
channel.subscribe((status, err) => {
|
|
31933
31635
|
if (status === "SUBSCRIBED") {
|
|
31934
31636
|
clearTimeout(timeout);
|
|
31935
|
-
|
|
31637
|
+
resolve7(true);
|
|
31936
31638
|
} else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
|
|
31937
31639
|
console.error(
|
|
31938
31640
|
`[chat-agent] thinking-channel ${threadId}: ${status}`,
|
|
31939
31641
|
err?.message ?? ""
|
|
31940
31642
|
);
|
|
31941
31643
|
clearTimeout(timeout);
|
|
31942
|
-
|
|
31644
|
+
resolve7(false);
|
|
31943
31645
|
}
|
|
31944
31646
|
});
|
|
31945
31647
|
});
|
|
@@ -31949,9 +31651,9 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
31949
31651
|
}, activity: () => {
|
|
31950
31652
|
} };
|
|
31951
31653
|
}
|
|
31952
|
-
let
|
|
31654
|
+
let pending = ready;
|
|
31953
31655
|
const send = (event, payload, last = false) => {
|
|
31954
|
-
|
|
31656
|
+
pending = pending.then(async (subscribed) => {
|
|
31955
31657
|
if (subscribed) {
|
|
31956
31658
|
const res = await channel.send({ type: "broadcast", event, payload }).catch((err) => err.message);
|
|
31957
31659
|
if (res !== "ok") {
|
|
@@ -31961,7 +31663,7 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
31961
31663
|
return subscribed;
|
|
31962
31664
|
}).catch(() => false);
|
|
31963
31665
|
if (last) {
|
|
31964
|
-
void
|
|
31666
|
+
void pending.finally(() => void this.supabase().removeChannel(channel));
|
|
31965
31667
|
}
|
|
31966
31668
|
};
|
|
31967
31669
|
return {
|
|
@@ -31986,19 +31688,19 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
31986
31688
|
let ready;
|
|
31987
31689
|
try {
|
|
31988
31690
|
channel = this.supabase().channel("channel-activity");
|
|
31989
|
-
ready = new Promise((
|
|
31691
|
+
ready = new Promise((resolve7) => {
|
|
31990
31692
|
const timeout = setTimeout(() => {
|
|
31991
31693
|
console.error("[chat-agent] channel-activity: subscribe timed out after 10s");
|
|
31992
|
-
|
|
31694
|
+
resolve7(false);
|
|
31993
31695
|
}, 1e4);
|
|
31994
31696
|
channel.subscribe((status, err) => {
|
|
31995
31697
|
if (status === "SUBSCRIBED") {
|
|
31996
31698
|
clearTimeout(timeout);
|
|
31997
|
-
|
|
31699
|
+
resolve7(true);
|
|
31998
31700
|
} else if (status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED") {
|
|
31999
31701
|
console.error(`[chat-agent] channel-activity: ${status}`, err?.message ?? "");
|
|
32000
31702
|
clearTimeout(timeout);
|
|
32001
|
-
|
|
31703
|
+
resolve7(false);
|
|
32002
31704
|
}
|
|
32003
31705
|
});
|
|
32004
31706
|
});
|
|
@@ -32008,9 +31710,9 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
32008
31710
|
};
|
|
32009
31711
|
return this.channelActivitySend;
|
|
32010
31712
|
}
|
|
32011
|
-
let
|
|
31713
|
+
let pending = ready;
|
|
32012
31714
|
this.channelActivitySend = (event, payload) => {
|
|
32013
|
-
|
|
31715
|
+
pending = pending.then(async (subscribed) => {
|
|
32014
31716
|
if (subscribed) {
|
|
32015
31717
|
const res = await channel.send({ type: "broadcast", event, payload }).catch((err) => err.message);
|
|
32016
31718
|
if (res !== "ok") {
|
|
@@ -32085,6 +31787,9 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
32085
31787
|
ownPersona: channelConfig.ownPersona,
|
|
32086
31788
|
slackBound: channelConfig.slackBound,
|
|
32087
31789
|
onActivity,
|
|
31790
|
+
...channelConfig.permissionThread ? {
|
|
31791
|
+
onPluginUi: (state) => void this.savePluginUi(channelConfig.profile, channelConfig.permissionThread.threadId, state)
|
|
31792
|
+
} : {},
|
|
32088
31793
|
signal,
|
|
32089
31794
|
mcpConfigPath,
|
|
32090
31795
|
...usageContext ? { usageContext } : {},
|
|
@@ -32105,6 +31810,27 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
|
|
|
32105
31810
|
return failure ? { sessionId: sessionId ?? "", text: "", isError: true, isTransientError: true, failure } : null;
|
|
32106
31811
|
}
|
|
32107
31812
|
}
|
|
31813
|
+
pluginUiHashes = /* @__PURE__ */ new Map();
|
|
31814
|
+
/**
|
|
31815
|
+
* Keep the latest mod UI snapshot for a thread (0129). One row per thread,
|
|
31816
|
+
* overwritten only when it changed. Large SVGs go to R2 via the Data API (plugin-ui-store),
|
|
31817
|
+
* so the row stays a few KB. A turn with no panes clears the row, so a mod that closed its pane stops showing.
|
|
31818
|
+
*/
|
|
31819
|
+
async savePluginUi(workspace, threadId, raw) {
|
|
31820
|
+
const empty = !raw.panes.length && !raw.status;
|
|
31821
|
+
const state = empty ? raw : await offloadPluginUi(workspace, raw);
|
|
31822
|
+
const hash = empty ? "" : pluginUiHash(state);
|
|
31823
|
+
if (this.pluginUiHashes.get(threadId) === hash) return;
|
|
31824
|
+
const table = this.supabase().from("thread_plugin_ui");
|
|
31825
|
+
const { error } = !empty ? await table.upsert({
|
|
31826
|
+
thread_id: threadId,
|
|
31827
|
+
panes: state.panes,
|
|
31828
|
+
status: state.status ?? null,
|
|
31829
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
31830
|
+
}) : await table.delete().eq("thread_id", threadId);
|
|
31831
|
+
if (error) console.error(`[chat-agent] save plugin UI ${threadId}: ${error.message}`);
|
|
31832
|
+
else this.pluginUiHashes.set(threadId, hash);
|
|
31833
|
+
}
|
|
32108
31834
|
async tryAskCodex(channelConfig, prompt, sessionId, signal, onActivity, usageContext) {
|
|
32109
31835
|
const name = subAgentName(channelConfig.agentName);
|
|
32110
31836
|
const agentPersona = name ? readAgentPersona(channelConfig.claudeConfigDir, channelConfig.cwd, name) : void 0;
|
|
@@ -33905,7 +33631,7 @@ ${matched.prompt}`,
|
|
|
33905
33631
|
|
|
33906
33632
|
// src/store/automation-run-store.ts
|
|
33907
33633
|
import Database3 from "better-sqlite3";
|
|
33908
|
-
import { randomUUID as
|
|
33634
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
33909
33635
|
var LOG_RETENTION = 2e3;
|
|
33910
33636
|
var AutomationRunStore = class {
|
|
33911
33637
|
db;
|
|
@@ -33968,7 +33694,7 @@ var AutomationRunStore = class {
|
|
|
33968
33694
|
if (ids.length === 0) return;
|
|
33969
33695
|
const update = this.db.prepare("UPDATE automation_run_log SET row_uid = ? WHERE id = ?");
|
|
33970
33696
|
this.db.transaction(() => {
|
|
33971
|
-
for (const { id } of ids) update.run(
|
|
33697
|
+
for (const { id } of ids) update.run(randomUUID3(), id);
|
|
33972
33698
|
})();
|
|
33973
33699
|
}
|
|
33974
33700
|
getLastRun(name) {
|
|
@@ -34013,7 +33739,7 @@ var AutomationRunStore = class {
|
|
|
34013
33739
|
).run(name, when.toISOString(), status);
|
|
34014
33740
|
this.db.prepare(
|
|
34015
33741
|
"INSERT INTO automation_run_log (row_uid, name, run_at, status, duration_ms) VALUES (?, ?, ?, ?, ?)"
|
|
34016
|
-
).run(
|
|
33742
|
+
).run(randomUUID3(), name, when.toISOString(), status, durationMs ?? null);
|
|
34017
33743
|
const guard = this.holdUnsynced ? " AND synced_at IS NOT NULL" : "";
|
|
34018
33744
|
this.db.prepare(
|
|
34019
33745
|
`DELETE FROM automation_run_log
|
|
@@ -34286,18 +34012,18 @@ var ReactionStore = class {
|
|
|
34286
34012
|
};
|
|
34287
34013
|
|
|
34288
34014
|
// ../api/src/store/supabase-direct.ts
|
|
34289
|
-
import { createClient
|
|
34290
|
-
var
|
|
34015
|
+
import { createClient } from "@supabase/supabase-js";
|
|
34016
|
+
var REQUEST_TIMEOUT_MS2 = 15e3;
|
|
34291
34017
|
function createDirectSupabaseClient() {
|
|
34292
34018
|
const url = process.env["SUPABASE_URL"];
|
|
34293
34019
|
const key = process.env["SUPABASE_SECRET_KEY"];
|
|
34294
34020
|
if (!url || !key) {
|
|
34295
34021
|
throw new Error("SUPABASE_URL / SUPABASE_SECRET_KEY not set \u2014 check .env");
|
|
34296
34022
|
}
|
|
34297
|
-
return
|
|
34023
|
+
return createClient(url, key, {
|
|
34298
34024
|
auth: { persistSession: false },
|
|
34299
34025
|
global: {
|
|
34300
|
-
fetch: (input, init) => fetch(input, { ...init, signal: init?.signal ?? AbortSignal.timeout(
|
|
34026
|
+
fetch: (input, init) => fetch(input, { ...init, signal: init?.signal ?? AbortSignal.timeout(REQUEST_TIMEOUT_MS2) })
|
|
34301
34027
|
}
|
|
34302
34028
|
});
|
|
34303
34029
|
}
|
|
@@ -34397,12 +34123,12 @@ function startWatchdog(opts) {
|
|
|
34397
34123
|
// src/index.ts
|
|
34398
34124
|
var DRAIN_TIMEOUT_MS = 15e3;
|
|
34399
34125
|
async function recoverStaleReactions(client, reactionStore) {
|
|
34400
|
-
const
|
|
34401
|
-
if (
|
|
34126
|
+
const pending = reactionStore.listAll();
|
|
34127
|
+
if (pending.length === 0) return;
|
|
34402
34128
|
console.log(
|
|
34403
|
-
`[${ts2()}] [flyspace] clearing ${
|
|
34129
|
+
`[${ts2()}] [flyspace] clearing ${pending.length} stale reaction(s) from previous run`
|
|
34404
34130
|
);
|
|
34405
|
-
for (const r of
|
|
34131
|
+
for (const r of pending) {
|
|
34406
34132
|
try {
|
|
34407
34133
|
await client.reactions.remove({
|
|
34408
34134
|
channel: r.channelId,
|
|
@@ -34417,13 +34143,13 @@ async function recoverStaleReactions(client, reactionStore) {
|
|
|
34417
34143
|
var ts2 = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
34418
34144
|
var POWER_POLL_MS = 3e4;
|
|
34419
34145
|
function isOnACPower() {
|
|
34420
|
-
return new Promise((
|
|
34146
|
+
return new Promise((resolve7) => {
|
|
34421
34147
|
execFile2("pmset", ["-g", "ps"], { timeout: 2e3 }, (err, stdout) => {
|
|
34422
34148
|
if (err) {
|
|
34423
|
-
|
|
34149
|
+
resolve7(true);
|
|
34424
34150
|
return;
|
|
34425
34151
|
}
|
|
34426
|
-
|
|
34152
|
+
resolve7(stdout.includes("'AC Power'"));
|
|
34427
34153
|
});
|
|
34428
34154
|
});
|
|
34429
34155
|
}
|
|
@@ -34532,8 +34258,8 @@ async function startServer() {
|
|
|
34532
34258
|
const shutdown = async (signal) => {
|
|
34533
34259
|
if (shuttingDown) return;
|
|
34534
34260
|
shuttingDown = true;
|
|
34535
|
-
const
|
|
34536
|
-
console.log(`[${ts2()}] [flyspace] shutting down (${signal}, ${
|
|
34261
|
+
const pending = slackRuntime?.listeners.pendingCount() ?? 0;
|
|
34262
|
+
console.log(`[${ts2()}] [flyspace] shutting down (${signal}, ${pending} thread queue(s))`);
|
|
34537
34263
|
if (slackRuntime) {
|
|
34538
34264
|
const drained = await slackRuntime.listeners.drain(DRAIN_TIMEOUT_MS);
|
|
34539
34265
|
if (!drained) {
|
|
@@ -34573,11 +34299,6 @@ export {
|
|
|
34573
34299
|
resolveUserId,
|
|
34574
34300
|
ensureUsersCached,
|
|
34575
34301
|
useLocalCache,
|
|
34576
|
-
loadEnvFiles,
|
|
34577
|
-
SLACK_ENV,
|
|
34578
|
-
slackConfigured,
|
|
34579
|
-
requireSlackBotToken,
|
|
34580
|
-
loadConfig,
|
|
34581
34302
|
getWorkspaceDomain,
|
|
34582
34303
|
insertWorkspaceDomain,
|
|
34583
34304
|
updateWorkspaceDomainStatus,
|
|
@@ -34665,32 +34386,6 @@ export {
|
|
|
34665
34386
|
DEFAULT_TIMEZONE,
|
|
34666
34387
|
loadAutomations,
|
|
34667
34388
|
loadEffectiveAutomations,
|
|
34668
|
-
DEFAULT_API_URL,
|
|
34669
|
-
AuthApiError,
|
|
34670
|
-
apiUrl,
|
|
34671
|
-
deviceKeyPath,
|
|
34672
|
-
credentialsPath,
|
|
34673
|
-
ensureDeviceKey,
|
|
34674
|
-
loadCredentials,
|
|
34675
|
-
saveCredentials,
|
|
34676
|
-
clearLocalAuth,
|
|
34677
|
-
requestDeviceCode,
|
|
34678
|
-
pollDeviceToken,
|
|
34679
|
-
fetchWhoAmI,
|
|
34680
|
-
boundWorkspaces,
|
|
34681
|
-
revokeDevice,
|
|
34682
|
-
getAccessToken,
|
|
34683
|
-
acquireHostLock,
|
|
34684
|
-
publishHostEndpoint,
|
|
34685
|
-
readHostEndpoint,
|
|
34686
|
-
setHostDbSender,
|
|
34687
|
-
handleHostDbResult,
|
|
34688
|
-
requestHostDb,
|
|
34689
|
-
handleAttachmentUrlResult,
|
|
34690
|
-
handleShouldRespondResult,
|
|
34691
|
-
LOCAL_DB_PATH,
|
|
34692
|
-
createHostDbClient,
|
|
34693
|
-
useHostDbWithoutCredentials,
|
|
34694
34389
|
runPersonaCmd,
|
|
34695
34390
|
MEMORY_TYPES,
|
|
34696
34391
|
isMemoryType,
|