flyspace-cli 0.1.62 → 0.1.64
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-BDUA5N6B.js → chunk-FNKFJQB7.js} +480 -76
- package/dist/{chunk-UZMHXV4D.js → chunk-O7OYNQND.js} +46 -15
- package/dist/{chunk-PLLJ7M62.js → chunk-WFUR2BYO.js} +12 -1
- package/dist/cli.js +120 -254
- package/dist/index.js +2 -2
- package/dist/{threads-BFRTS4EB.js → threads-VOXFIRD6.js} +4 -3
- package/package.json +1 -1
- package/system.capabilities.md +2 -1
package/dist/cli.js
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
MEMORY_TYPES,
|
|
23
23
|
OutputStyleConflictError,
|
|
24
24
|
PLATE,
|
|
25
|
+
SHARE_ASSET_PLACEHOLDER,
|
|
25
26
|
SKIP_SUBTYPES,
|
|
26
27
|
SUPPORT_AVATAR_URL,
|
|
27
28
|
TRANSLATION_LANGUAGES,
|
|
@@ -89,7 +90,6 @@ import {
|
|
|
89
90
|
expandPath,
|
|
90
91
|
explainCost,
|
|
91
92
|
extractCategories,
|
|
92
|
-
extractTitle,
|
|
93
93
|
filterReadableDocsChannels,
|
|
94
94
|
findChannel,
|
|
95
95
|
findChannelById,
|
|
@@ -122,7 +122,6 @@ import {
|
|
|
122
122
|
getWorkspacePermissionMode,
|
|
123
123
|
getWorkspacePlanStatus,
|
|
124
124
|
handleSupportMention,
|
|
125
|
-
highlightLanguageOf,
|
|
126
125
|
insertMcpConnection,
|
|
127
126
|
insertWorkspaceDomain,
|
|
128
127
|
installUsageRecording,
|
|
@@ -149,6 +148,7 @@ import {
|
|
|
149
148
|
latestCliVersion,
|
|
150
149
|
listActiveUsers,
|
|
151
150
|
listAgents,
|
|
151
|
+
listAutoUpdateDocShares,
|
|
152
152
|
listChannelMembers,
|
|
153
153
|
listChannelMemories,
|
|
154
154
|
listLiveDocShares,
|
|
@@ -192,6 +192,7 @@ import {
|
|
|
192
192
|
profileOauthToken,
|
|
193
193
|
promoteChannelMemory,
|
|
194
194
|
queueShareAudio,
|
|
195
|
+
readDocShareBundle,
|
|
195
196
|
readOAuthClient,
|
|
196
197
|
readSkillFile,
|
|
197
198
|
recentRunsForWorkspace,
|
|
@@ -209,10 +210,8 @@ import {
|
|
|
209
210
|
resolveChannelId,
|
|
210
211
|
resolveCwd,
|
|
211
212
|
resolveDashboardChannelId,
|
|
212
|
-
resolveDocPath,
|
|
213
213
|
resolveDocsAccess,
|
|
214
214
|
resolveRateCard,
|
|
215
|
-
resolveRawPath,
|
|
216
215
|
resolveUserId,
|
|
217
216
|
revokeDocShare,
|
|
218
217
|
rowToMemory,
|
|
@@ -234,6 +233,7 @@ import {
|
|
|
234
233
|
setAgentPaused,
|
|
235
234
|
setAllowGuestAccess,
|
|
236
235
|
setChannelDocsMemberAccess,
|
|
236
|
+
setDocShareAutoUpdate,
|
|
237
237
|
setDocShareSlug,
|
|
238
238
|
setDocShareTags,
|
|
239
239
|
setMcpConnectionApiKey,
|
|
@@ -278,15 +278,17 @@ import {
|
|
|
278
278
|
useLocalCache,
|
|
279
279
|
validateMemoryInput,
|
|
280
280
|
warnOnBrokenChannelCwds,
|
|
281
|
+
watchDocs,
|
|
281
282
|
workspaceHostname,
|
|
282
283
|
workspaceSkillsDir,
|
|
283
284
|
writeSkillFile
|
|
284
|
-
} from "./chunk-
|
|
285
|
+
} from "./chunk-FNKFJQB7.js";
|
|
285
286
|
import {
|
|
286
287
|
checkPermissionAction,
|
|
287
288
|
createThreadAction,
|
|
288
289
|
firstReplyBody,
|
|
289
290
|
getThread,
|
|
291
|
+
listAutoUpdateSharesAction,
|
|
290
292
|
listChannels,
|
|
291
293
|
listChannelsAction,
|
|
292
294
|
listThreads,
|
|
@@ -299,7 +301,7 @@ import {
|
|
|
299
301
|
runDocsCmd,
|
|
300
302
|
searchThreadsAction,
|
|
301
303
|
shareDocAction
|
|
302
|
-
} from "./chunk-
|
|
304
|
+
} from "./chunk-WFUR2BYO.js";
|
|
303
305
|
import {
|
|
304
306
|
AuthApiError,
|
|
305
307
|
DEFAULT_API_URL,
|
|
@@ -329,6 +331,7 @@ import {
|
|
|
329
331
|
handleAttachmentUrlResult,
|
|
330
332
|
handleHostDbResult,
|
|
331
333
|
handlePluginSvgResult,
|
|
334
|
+
handleScratchImageResult,
|
|
332
335
|
handleShouldRespondResult,
|
|
333
336
|
isEffort,
|
|
334
337
|
loadConfig,
|
|
@@ -350,7 +353,7 @@ import {
|
|
|
350
353
|
slackConfigured,
|
|
351
354
|
sumR2PrefixBytes,
|
|
352
355
|
useHostDbWithoutCredentials
|
|
353
|
-
} from "./chunk-
|
|
356
|
+
} from "./chunk-O7OYNQND.js";
|
|
354
357
|
|
|
355
358
|
// ../core/src/logger.ts
|
|
356
359
|
var ALREADY_STAMPED = /^\[\d{4}-\d{2}-\d{2}T/;
|
|
@@ -2207,7 +2210,7 @@ function npmEnv(target) {
|
|
|
2207
2210
|
return nodeBin ? { ...process.env, PATH: `${nodeBin}:${process.env.PATH ?? ""}` } : process.env;
|
|
2208
2211
|
}
|
|
2209
2212
|
async function runUpgrade() {
|
|
2210
|
-
const current = "0.1.
|
|
2213
|
+
const current = "0.1.64";
|
|
2211
2214
|
console.log(`Current version: ${current}`);
|
|
2212
2215
|
console.log("Checking for updates...\n");
|
|
2213
2216
|
try {
|
|
@@ -6159,7 +6162,7 @@ async function runMcpCmd(args) {
|
|
|
6159
6162
|
useHostDbWithoutCredentials();
|
|
6160
6163
|
switch (server) {
|
|
6161
6164
|
case "threads": {
|
|
6162
|
-
const { startThreadsServer } = await import("./threads-
|
|
6165
|
+
const { startThreadsServer } = await import("./threads-VOXFIRD6.js");
|
|
6163
6166
|
await startThreadsServer();
|
|
6164
6167
|
return;
|
|
6165
6168
|
}
|
|
@@ -6755,9 +6758,6 @@ function threadPath(workspace, channelId, threadId) {
|
|
|
6755
6758
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
6756
6759
|
import { CopyObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-sdk/client-s3";
|
|
6757
6760
|
|
|
6758
|
-
// ../api/src/dashboard/bridge-types.ts
|
|
6759
|
-
var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
|
|
6760
|
-
|
|
6761
6761
|
// ../api/src/dashboard/doc-share-features.ts
|
|
6762
6762
|
import { DeleteObjectCommand } from "@aws-sdk/client-s3";
|
|
6763
6763
|
var DEFAULT_FEATURES = {
|
|
@@ -7109,6 +7109,12 @@ var shareDoc = async (input2, ctx) => {
|
|
|
7109
7109
|
if (!res.url) throw new ActionError(`Share failed: ${res.error ?? "unknown error"}`);
|
|
7110
7110
|
return { url: res.url };
|
|
7111
7111
|
};
|
|
7112
|
+
var listAutoUpdateShares = async (_input, ctx) => ({
|
|
7113
|
+
shares: (await listAutoUpdateDocShares(ctx.scope)).map((s) => ({
|
|
7114
|
+
channel_id: s.channelId,
|
|
7115
|
+
path: s.sourcePath
|
|
7116
|
+
}))
|
|
7117
|
+
});
|
|
7112
7118
|
function describeToolInput(input2) {
|
|
7113
7119
|
const pick = input2["command"] ?? input2["file_path"] ?? input2["path"] ?? input2["url"];
|
|
7114
7120
|
const text = typeof pick === "string" ? pick : JSON.stringify(input2, null, 2);
|
|
@@ -7178,6 +7184,7 @@ var HANDLERS = {
|
|
|
7178
7184
|
[postReplyAction.name]: postReply,
|
|
7179
7185
|
[moveThreadAction.name]: moveThread2,
|
|
7180
7186
|
[shareDocAction.name]: shareDoc,
|
|
7187
|
+
[listAutoUpdateSharesAction.name]: listAutoUpdateShares,
|
|
7181
7188
|
[requestPermissionAction.name]: requestPermission,
|
|
7182
7189
|
[checkPermissionAction.name]: checkPermission
|
|
7183
7190
|
};
|
|
@@ -9813,7 +9820,8 @@ function shareJson(c, share) {
|
|
|
9813
9820
|
social: share.socialEnabled,
|
|
9814
9821
|
branding: share.brandingEnabled,
|
|
9815
9822
|
translation: share.translationEnabled,
|
|
9816
|
-
translationLangs: share.translationLangs
|
|
9823
|
+
translationLangs: share.translationLangs,
|
|
9824
|
+
autoUpdate: share.autoUpdate
|
|
9817
9825
|
};
|
|
9818
9826
|
}
|
|
9819
9827
|
function readFeatures(body) {
|
|
@@ -9888,6 +9896,7 @@ function createDocShareListRouter() {
|
|
|
9888
9896
|
branding: s.brandingEnabled,
|
|
9889
9897
|
translation: s.translationEnabled,
|
|
9890
9898
|
translationLangs: s.translationLangs,
|
|
9899
|
+
autoUpdate: s.autoUpdate,
|
|
9891
9900
|
audioStatus: s.audioStatus,
|
|
9892
9901
|
channelId: s.channelId,
|
|
9893
9902
|
// `channels` is what produced the id filter, so this always hits — the
|
|
@@ -9998,8 +10007,11 @@ function createDocShareWriteRouter(agent = {}) {
|
|
|
9998
10007
|
},
|
|
9999
10008
|
503
|
|
10000
10009
|
);
|
|
10001
|
-
default:
|
|
10002
|
-
|
|
10010
|
+
default: {
|
|
10011
|
+
const autoUpdate = body["autoUpdate"];
|
|
10012
|
+
const share = typeof autoUpdate === "boolean" && autoUpdate !== result.share.autoUpdate ? await setDocShareAutoUpdate(result.share.id, autoUpdate) ?? result.share : result.share;
|
|
10013
|
+
return c.json(shareJson(c, share), 201);
|
|
10014
|
+
}
|
|
10003
10015
|
}
|
|
10004
10016
|
});
|
|
10005
10017
|
app.patch("/:id/docs/share", async (c) => {
|
|
@@ -10014,10 +10026,11 @@ function createDocShareWriteRouter(agent = {}) {
|
|
|
10014
10026
|
return c.json({ error: slugErrorMessage(slug.invalid), field: "slug" }, 400);
|
|
10015
10027
|
const features = readFeatures(body);
|
|
10016
10028
|
const tags = normalizeTags(body["tags"]);
|
|
10017
|
-
|
|
10029
|
+
const autoUpdate = typeof body["autoUpdate"] === "boolean" ? body["autoUpdate"] : void 0;
|
|
10030
|
+
if (!("slug" in slug) && tags === null && autoUpdate === void 0 && features.audio === void 0 && features.ask === void 0 && features.social === void 0 && features.branding === void 0 && features.translation === void 0 && features.translationLangs === void 0) {
|
|
10018
10031
|
return c.json(
|
|
10019
10032
|
{
|
|
10020
|
-
error: "slug, tags, audio, ask, social, branding, translation or translationLangs is required"
|
|
10033
|
+
error: "slug, tags, autoUpdate, audio, ask, social, branding, translation or translationLangs is required"
|
|
10021
10034
|
},
|
|
10022
10035
|
400
|
|
10023
10036
|
);
|
|
@@ -10045,6 +10058,11 @@ function createDocShareWriteRouter(agent = {}) {
|
|
|
10045
10058
|
if (!next) return c.json({ error: "not shared" }, 404);
|
|
10046
10059
|
tagged = next;
|
|
10047
10060
|
}
|
|
10061
|
+
if (autoUpdate !== void 0 && autoUpdate !== tagged.autoUpdate) {
|
|
10062
|
+
const next = await setDocShareAutoUpdate(tagged.id, autoUpdate);
|
|
10063
|
+
if (!next) return c.json({ error: "not shared" }, 404);
|
|
10064
|
+
tagged = next;
|
|
10065
|
+
}
|
|
10048
10066
|
const updated = await updateShareFeatures(tagged, features);
|
|
10049
10067
|
if (!updated) return c.json({ error: "not shared" }, 404);
|
|
10050
10068
|
return c.json(shareJson(c, updated));
|
|
@@ -12895,7 +12913,7 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
12895
12913
|
const paused = await getAgentPaused(auth.workspaceId);
|
|
12896
12914
|
const cliVersion = agent.getHostCliVersion?.(getProfile()) ?? null;
|
|
12897
12915
|
const latest = cliVersion ? await latestCliVersion() : null;
|
|
12898
|
-
const outdated = !!(cliVersion && latest && isOlderVersion(cliVersion, latest));
|
|
12916
|
+
const outdated = !!(cliVersion && !cliVersion.endsWith("-dev") && latest && isOlderVersion(cliVersion, latest));
|
|
12899
12917
|
const selfUpgrade = !!cliVersion && !isOlderVersion(cliVersion, SELF_UPGRADE_MIN_VERSION);
|
|
12900
12918
|
return c.json({
|
|
12901
12919
|
online: !paused,
|
|
@@ -14658,7 +14676,7 @@ function createHostApiRouter(agent = {}) {
|
|
|
14658
14676
|
|
|
14659
14677
|
// src/dashboard/agent-bridge-host.ts
|
|
14660
14678
|
import { sign as signRaw, timingSafeEqual } from "crypto";
|
|
14661
|
-
import { existsSync as existsSync25, readFileSync as
|
|
14679
|
+
import { existsSync as existsSync25, readFileSync as readFileSync19 } from "fs";
|
|
14662
14680
|
import dotenv2 from "dotenv";
|
|
14663
14681
|
import { WebSocket as WebSocket2 } from "ws";
|
|
14664
14682
|
|
|
@@ -14933,243 +14951,13 @@ async function handleHostRequest(req) {
|
|
|
14933
14951
|
return runRelayed(req, (app) => registerHostRoutes(app));
|
|
14934
14952
|
}
|
|
14935
14953
|
|
|
14936
|
-
// src/dashboard/doc-share-publisher.ts
|
|
14937
|
-
import { readFileSync as readFileSync19, statSync as statSync6 } from "fs";
|
|
14938
|
-
import { extname, posix } from "path";
|
|
14939
|
-
var MAX_ASSET_BYTES = 20 * 1024 * 1024;
|
|
14940
|
-
var MAX_CONTENT_BYTES = 2 * 1024 * 1024;
|
|
14941
|
-
var MAX_ASSETS = 50;
|
|
14942
|
-
var MAX_BUNDLE_ASSET_BYTES = 48 * 1024 * 1024;
|
|
14943
|
-
var MAX_INLINE_BYTES = 200 * 1024;
|
|
14944
|
-
var MAX_TOTAL_INLINE_BYTES = 1024 * 1024;
|
|
14945
|
-
var MD_LINK = /(!?\[[^\]]*\]\()\s*(<[^>]+>|[^)\s]+)/g;
|
|
14946
|
-
var MD_LINK_FULL = /(!?)\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)((?:\s+"[^"]*"|\s+'[^']*'|\s+\([^)]*\))?)\s*\)/g;
|
|
14947
|
-
var HTML_URL_ATTR = /\b(src|href|poster)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
14948
|
-
var HTML_CSS_URL = /\burl\(\s*("[^"]*"|'[^']*'|[^)'"\s]+)\s*\)/gi;
|
|
14949
|
-
var HTML_URL_PATTERNS = [
|
|
14950
|
-
{ re: HTML_URL_ATTR, group: 2 },
|
|
14951
|
-
{ re: HTML_CSS_URL, group: 1 }
|
|
14952
|
-
];
|
|
14953
|
-
function unquote2(value) {
|
|
14954
|
-
const q = value[0];
|
|
14955
|
-
if ((q === '"' || q === "'") && value.length >= 2 && value.endsWith(q)) {
|
|
14956
|
-
return { quote: q, url: value.slice(1, -1) };
|
|
14957
|
-
}
|
|
14958
|
-
return { quote: "", url: value };
|
|
14959
|
-
}
|
|
14960
|
-
function htmlUrls(source) {
|
|
14961
|
-
const seen = /* @__PURE__ */ new Set();
|
|
14962
|
-
const out = [];
|
|
14963
|
-
for (const { re, group } of HTML_URL_PATTERNS) {
|
|
14964
|
-
for (const match of source.matchAll(re)) {
|
|
14965
|
-
const { url } = unquote2(match[group]);
|
|
14966
|
-
if (!url || seen.has(url)) continue;
|
|
14967
|
-
seen.add(url);
|
|
14968
|
-
out.push(url);
|
|
14969
|
-
}
|
|
14970
|
-
}
|
|
14971
|
-
return out;
|
|
14972
|
-
}
|
|
14973
|
-
function rewriteHtml(source, rewritten) {
|
|
14974
|
-
return source.replace(HTML_URL_ATTR, (whole, attr, value) => {
|
|
14975
|
-
const { quote, url } = unquote2(value);
|
|
14976
|
-
const next = rewritten.get(url);
|
|
14977
|
-
return next ? `${attr}=${quote || '"'}${next}${quote || '"'}` : whole;
|
|
14978
|
-
}).replace(HTML_CSS_URL, (whole, value) => {
|
|
14979
|
-
const { quote, url } = unquote2(value);
|
|
14980
|
-
const next = rewritten.get(url);
|
|
14981
|
-
return next ? `url(${quote || '"'}${next}${quote || '"'})` : whole;
|
|
14982
|
-
});
|
|
14983
|
-
}
|
|
14984
|
-
function shareKindOf(absPath) {
|
|
14985
|
-
const ext = extname(absPath).toLowerCase();
|
|
14986
|
-
if (ext === ".md" || ext === ".markdown") return "markdown";
|
|
14987
|
-
if (ext === ".html" || ext === ".htm") return "html";
|
|
14988
|
-
if (ext === ".excalidraw") return "excalidraw";
|
|
14989
|
-
return null;
|
|
14990
|
-
}
|
|
14991
|
-
function isExternalHref(href) {
|
|
14992
|
-
return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("#");
|
|
14993
|
-
}
|
|
14994
|
-
function sanitizeAssetName(name) {
|
|
14995
|
-
const base = name.split(/[/\\]/).pop() ?? "";
|
|
14996
|
-
const cleaned = base.replace(/\s+/g, "-").replace(/[^\w.-]/g, "").trim();
|
|
14997
|
-
return (cleaned || "file").slice(-100);
|
|
14998
|
-
}
|
|
14999
|
-
function renderAttachments(files) {
|
|
15000
|
-
if (files.length === 0) return "";
|
|
15001
|
-
const blocks = files.map((f) => {
|
|
15002
|
-
const longest = Math.max(0, ...[...f.text.matchAll(/`{3,}/g)].map((m) => m[0].length));
|
|
15003
|
-
const fence = "`".repeat(Math.max(3, longest + 1));
|
|
15004
|
-
const label2 = f.path.replace(/["\r\n]/g, "");
|
|
15005
|
-
return `${fence}${f.lang} file="${label2}" id=${f.anchor}
|
|
15006
|
-
${f.text.replace(/\s+$/, "")}
|
|
15007
|
-
${fence}`;
|
|
15008
|
-
});
|
|
15009
|
-
return `
|
|
15010
|
-
|
|
15011
|
-
---
|
|
15012
|
-
|
|
15013
|
-
${blocks.join("\n\n")}
|
|
15014
|
-
`;
|
|
15015
|
-
}
|
|
15016
|
-
function classifyHref(cwd, docDir, rawHref) {
|
|
15017
|
-
const href = rawHref.startsWith("<") && rawHref.endsWith(">") ? rawHref.slice(1, -1) : rawHref;
|
|
15018
|
-
if (!href) return null;
|
|
15019
|
-
const attachment = href.match(/^\/api\/attachments\/(.+)$/);
|
|
15020
|
-
if (attachment) {
|
|
15021
|
-
const key = attachment[1].split("/").map((s) => {
|
|
15022
|
-
try {
|
|
15023
|
-
return decodeURIComponent(s);
|
|
15024
|
-
} catch {
|
|
15025
|
-
return s;
|
|
15026
|
-
}
|
|
15027
|
-
}).join("/");
|
|
15028
|
-
return key.startsWith("chat/") ? { kind: "attachment", key } : null;
|
|
15029
|
-
}
|
|
15030
|
-
if (isExternalHref(href)) return null;
|
|
15031
|
-
const pathPart = href.split(/[?#]/)[0];
|
|
15032
|
-
if (!pathPart) return null;
|
|
15033
|
-
if (pathPart.startsWith("/")) {
|
|
15034
|
-
if (pathPart !== cwd && !pathPart.startsWith(`${cwd}/`)) return null;
|
|
15035
|
-
return { kind: "local", rel: pathPart.slice(cwd.length).replace(/^\/+/, "") };
|
|
15036
|
-
}
|
|
15037
|
-
return { kind: "local", rel: posix.normalize(docDir ? `${docDir}/${pathPart}` : pathPart) };
|
|
15038
|
-
}
|
|
15039
|
-
function readDocShareBundle({ cwd, sourcePath }) {
|
|
15040
|
-
const abs = resolveDocPath(cwd, sourcePath);
|
|
15041
|
-
if (!abs) return { status: "not-found" };
|
|
15042
|
-
const kind = shareKindOf(abs);
|
|
15043
|
-
if (!kind) return { status: "unsupported" };
|
|
15044
|
-
let stat;
|
|
15045
|
-
try {
|
|
15046
|
-
stat = statSync6(abs);
|
|
15047
|
-
} catch {
|
|
15048
|
-
return { status: "not-found" };
|
|
15049
|
-
}
|
|
15050
|
-
if (!stat.isFile()) return { status: "not-found" };
|
|
15051
|
-
if (stat.size > MAX_CONTENT_BYTES) return { status: "too-large" };
|
|
15052
|
-
const source = readFileSync19(abs, "utf8");
|
|
15053
|
-
const title = extractTitle(abs, kind === "markdown" ? "md" : kind);
|
|
15054
|
-
if (kind === "excalidraw") {
|
|
15055
|
-
try {
|
|
15056
|
-
const parsed = JSON.parse(source);
|
|
15057
|
-
if (!parsed || typeof parsed !== "object") return { status: "unsupported" };
|
|
15058
|
-
} catch {
|
|
15059
|
-
return { status: "unsupported" };
|
|
15060
|
-
}
|
|
15061
|
-
return { status: "ok", kind, title, content: source, assets: [] };
|
|
15062
|
-
}
|
|
15063
|
-
const docDir = sourcePath.includes("/") ? sourcePath.slice(0, sourcePath.lastIndexOf("/")) : "";
|
|
15064
|
-
const rewritten = /* @__PURE__ */ new Map();
|
|
15065
|
-
const usedNames = /* @__PURE__ */ new Set();
|
|
15066
|
-
const usedAnchors = /* @__PURE__ */ new Set();
|
|
15067
|
-
const assets = [];
|
|
15068
|
-
let assetBytes = 0;
|
|
15069
|
-
const attachments = [];
|
|
15070
|
-
let inlinedBytes = 0;
|
|
15071
|
-
const claimName = (candidate) => {
|
|
15072
|
-
const safe = sanitizeAssetName(candidate);
|
|
15073
|
-
if (!usedNames.has(safe)) {
|
|
15074
|
-
usedNames.add(safe);
|
|
15075
|
-
return safe;
|
|
15076
|
-
}
|
|
15077
|
-
const ext = extname(safe);
|
|
15078
|
-
const stem = safe.slice(0, safe.length - ext.length);
|
|
15079
|
-
for (let n = 2; ; n += 1) {
|
|
15080
|
-
const next = `${stem}-${n}${ext}`;
|
|
15081
|
-
if (!usedNames.has(next)) {
|
|
15082
|
-
usedNames.add(next);
|
|
15083
|
-
return next;
|
|
15084
|
-
}
|
|
15085
|
-
}
|
|
15086
|
-
};
|
|
15087
|
-
const claimAnchor = (rel) => {
|
|
15088
|
-
const stem = sanitizeAssetName(rel).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
15089
|
-
const base = `file-${stem || "attachment"}`;
|
|
15090
|
-
if (!usedAnchors.has(base)) {
|
|
15091
|
-
usedAnchors.add(base);
|
|
15092
|
-
return base;
|
|
15093
|
-
}
|
|
15094
|
-
for (let n = 2; ; n += 1) {
|
|
15095
|
-
const next = `${base}-${n}`;
|
|
15096
|
-
if (!usedAnchors.has(next)) {
|
|
15097
|
-
usedAnchors.add(next);
|
|
15098
|
-
return next;
|
|
15099
|
-
}
|
|
15100
|
-
}
|
|
15101
|
-
};
|
|
15102
|
-
const refs = [];
|
|
15103
|
-
const hrefs = kind === "html" ? htmlUrls(source) : [...source.matchAll(MD_LINK)].map((m) => m[2]);
|
|
15104
|
-
for (const href of hrefs) {
|
|
15105
|
-
if (rewritten.has(href) || refs.some((r) => r.href === href)) continue;
|
|
15106
|
-
const ref = classifyHref(cwd, docDir, href);
|
|
15107
|
-
if (ref) refs.push({ href, ref });
|
|
15108
|
-
}
|
|
15109
|
-
for (const { href, ref } of refs.slice(0, MAX_ASSETS)) {
|
|
15110
|
-
if (ref.kind === "attachment") {
|
|
15111
|
-
const name2 = claimName(ref.key.split("/").pop() ?? "file");
|
|
15112
|
-
assets.push({ name: name2, copyFrom: ref.key });
|
|
15113
|
-
rewritten.set(href, `${SHARE_ASSET_PLACEHOLDER}${name2}`);
|
|
15114
|
-
continue;
|
|
15115
|
-
}
|
|
15116
|
-
const docAbs = kind === "markdown" ? resolveDocPath(cwd, ref.rel) : null;
|
|
15117
|
-
const lang = docAbs ? highlightLanguageOf(docAbs) : null;
|
|
15118
|
-
if (docAbs && lang) {
|
|
15119
|
-
const budget = Math.min(MAX_INLINE_BYTES, MAX_TOTAL_INLINE_BYTES - inlinedBytes);
|
|
15120
|
-
let text = null;
|
|
15121
|
-
try {
|
|
15122
|
-
const size = statSync6(docAbs).size;
|
|
15123
|
-
if (size <= budget) text = readFileSync19(docAbs, "utf8");
|
|
15124
|
-
} catch {
|
|
15125
|
-
continue;
|
|
15126
|
-
}
|
|
15127
|
-
if (text !== null) {
|
|
15128
|
-
const anchor = claimAnchor(ref.rel);
|
|
15129
|
-
inlinedBytes += Buffer.byteLength(text);
|
|
15130
|
-
attachments.push({ anchor, path: ref.rel, lang, text });
|
|
15131
|
-
rewritten.set(href, `#${anchor}`);
|
|
15132
|
-
continue;
|
|
15133
|
-
}
|
|
15134
|
-
}
|
|
15135
|
-
const resolved = resolveRawPath(cwd, ref.rel) ?? (docAbs ? { abs: docAbs, contentType: "text/plain; charset=utf-8" } : null);
|
|
15136
|
-
if (!resolved) continue;
|
|
15137
|
-
let body;
|
|
15138
|
-
try {
|
|
15139
|
-
if (statSync6(resolved.abs).size > MAX_ASSET_BYTES) continue;
|
|
15140
|
-
body = readFileSync19(resolved.abs);
|
|
15141
|
-
} catch {
|
|
15142
|
-
continue;
|
|
15143
|
-
}
|
|
15144
|
-
assetBytes += body.length;
|
|
15145
|
-
if (assetBytes > MAX_BUNDLE_ASSET_BYTES) return { status: "too-large" };
|
|
15146
|
-
const name = claimName(ref.rel.split("/").pop() ?? "file");
|
|
15147
|
-
assets.push({ name, contentType: resolved.contentType, data: body.toString("base64") });
|
|
15148
|
-
rewritten.set(href, `${SHARE_ASSET_PLACEHOLDER}${name}`);
|
|
15149
|
-
}
|
|
15150
|
-
if (kind === "html") {
|
|
15151
|
-
return { status: "ok", kind, title, content: rewriteHtml(source, rewritten), assets };
|
|
15152
|
-
}
|
|
15153
|
-
const content = source.replace(
|
|
15154
|
-
MD_LINK_FULL,
|
|
15155
|
-
(whole, bang, label2, href, title2) => {
|
|
15156
|
-
const replacement = rewritten.get(href);
|
|
15157
|
-
if (replacement?.startsWith("#") && bang) return label2;
|
|
15158
|
-
if (replacement) return `${bang}[${label2}](${replacement}${title2})`;
|
|
15159
|
-
if (classifyHref(cwd, docDir, href)?.kind === "local") return label2;
|
|
15160
|
-
return whole;
|
|
15161
|
-
}
|
|
15162
|
-
);
|
|
15163
|
-
return { status: "ok", kind, title, content: content + renderAttachments(attachments), assets };
|
|
15164
|
-
}
|
|
15165
|
-
|
|
15166
14954
|
// src/dashboard/host-upgrade.ts
|
|
15167
14955
|
import { spawn as spawn5 } from "child_process";
|
|
15168
14956
|
import { mkdirSync as mkdirSync10, openSync as openSync3 } from "fs";
|
|
15169
14957
|
import { join as join16 } from "path";
|
|
15170
14958
|
var running = false;
|
|
15171
14959
|
function startHostUpgrade() {
|
|
15172
|
-
if (running) return { started: false };
|
|
14960
|
+
if (running || CLI_VERSION?.endsWith("-dev")) return { started: false };
|
|
15173
14961
|
if (process.env.FLY_MACHINE_ID) {
|
|
15174
14962
|
running = true;
|
|
15175
14963
|
setTimeout(() => process.exit(0), 1e3);
|
|
@@ -15321,7 +15109,7 @@ function buildHostConfigSnapshot() {
|
|
|
15321
15109
|
const snapshot2 = {};
|
|
15322
15110
|
for (const profile of listProfiles()) {
|
|
15323
15111
|
snapshot2[profile] = runWithProfile(profile, () => ({
|
|
15324
|
-
env: existsSync25(paths.CONFIG_FILE) ? dotenv2.parse(
|
|
15112
|
+
env: existsSync25(paths.CONFIG_FILE) ? dotenv2.parse(readFileSync19(paths.CONFIG_FILE, "utf-8")) : {},
|
|
15325
15113
|
// Only a model someone actually saved: before that it is just the Claude
|
|
15326
15114
|
// default, which would show the wrong agent in admin for a Codex user.
|
|
15327
15115
|
agentModel: existsSync25(paths.DASHBOARD_SETTINGS_FILE) ? loadDashboardSettings().agent : void 0
|
|
@@ -15411,6 +15199,10 @@ function connectHostSocket(url, callbacks, onAuthenticated, onWorkspaces) {
|
|
|
15411
15199
|
handlePluginSvgResult(msg.id, msg.url);
|
|
15412
15200
|
return;
|
|
15413
15201
|
}
|
|
15202
|
+
if (msg.type === "scratch-image-result") {
|
|
15203
|
+
handleScratchImageResult(msg.id, msg.url);
|
|
15204
|
+
return;
|
|
15205
|
+
}
|
|
15414
15206
|
if (msg.type === "action-result") {
|
|
15415
15207
|
handleActionResult(msg.id, { value: msg.value, error: msg.error });
|
|
15416
15208
|
return;
|
|
@@ -15635,7 +15427,7 @@ The JSON API is live under /api.` : "This install has no bundled Workspace UI.\n
|
|
|
15635
15427
|
}
|
|
15636
15428
|
|
|
15637
15429
|
// src/dashboard/host-log-file.ts
|
|
15638
|
-
import { createWriteStream, fstatSync, mkdirSync as mkdirSync11, statSync as
|
|
15430
|
+
import { createWriteStream, fstatSync, mkdirSync as mkdirSync11, statSync as statSync6 } from "fs";
|
|
15639
15431
|
import { join as join18 } from "path";
|
|
15640
15432
|
var STAMPED = /^\[\d{4}-\d{2}-\d{2}T/;
|
|
15641
15433
|
function stamp(text) {
|
|
@@ -15645,7 +15437,7 @@ function stamp(text) {
|
|
|
15645
15437
|
function alreadyRedirected(fd, file) {
|
|
15646
15438
|
try {
|
|
15647
15439
|
const a = fstatSync(fd);
|
|
15648
|
-
const b =
|
|
15440
|
+
const b = statSync6(file);
|
|
15649
15441
|
return a.dev === b.dev && a.ino === b.ino;
|
|
15650
15442
|
} catch {
|
|
15651
15443
|
return false;
|
|
@@ -15673,6 +15465,77 @@ function ensureHostLogFiles() {
|
|
|
15673
15465
|
tee(process.stderr, 2, join18(paths.LOG_DIR, "host-error.log"));
|
|
15674
15466
|
}
|
|
15675
15467
|
|
|
15468
|
+
// src/dashboard/doc-share-auto-update.ts
|
|
15469
|
+
var REFRESH_MS = 6e4;
|
|
15470
|
+
var QUIET_MS = 5e3;
|
|
15471
|
+
function startDocShareAutoUpdate() {
|
|
15472
|
+
const watched = /* @__PURE__ */ new Map();
|
|
15473
|
+
const timers = /* @__PURE__ */ new Map();
|
|
15474
|
+
const publish = (channelId, path) => {
|
|
15475
|
+
void requestAction(shareDocAction.name, { channel_id: channelId, path }).then((res) => {
|
|
15476
|
+
if (res.error !== void 0) console.error(`[doc-share-auto] ${path}: ${res.error}`);
|
|
15477
|
+
});
|
|
15478
|
+
};
|
|
15479
|
+
const refresh = async () => {
|
|
15480
|
+
const res = await requestAction(listAutoUpdateSharesAction.name, {});
|
|
15481
|
+
if (res.error !== void 0) return;
|
|
15482
|
+
const parsed = listAutoUpdateSharesAction.output.safeParse(res.value);
|
|
15483
|
+
if (!parsed.success) return;
|
|
15484
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
15485
|
+
for (const s of parsed.data.shares) {
|
|
15486
|
+
const set = wanted.get(s.channel_id) ?? /* @__PURE__ */ new Set();
|
|
15487
|
+
set.add(s.path);
|
|
15488
|
+
wanted.set(s.channel_id, set);
|
|
15489
|
+
}
|
|
15490
|
+
for (const [channelId, entry] of watched) {
|
|
15491
|
+
if (!wanted.has(channelId)) {
|
|
15492
|
+
entry.off();
|
|
15493
|
+
watched.delete(channelId);
|
|
15494
|
+
}
|
|
15495
|
+
}
|
|
15496
|
+
for (const [channelId, paths2] of wanted) {
|
|
15497
|
+
const existing = watched.get(channelId);
|
|
15498
|
+
if (existing) {
|
|
15499
|
+
existing.paths = paths2;
|
|
15500
|
+
continue;
|
|
15501
|
+
}
|
|
15502
|
+
let off;
|
|
15503
|
+
try {
|
|
15504
|
+
off = watchDocs(resolveChannelConfig(channelId).cwd, (changed) => {
|
|
15505
|
+
const entry = watched.get(channelId);
|
|
15506
|
+
if (!entry) return;
|
|
15507
|
+
for (const path of changed) {
|
|
15508
|
+
if (!entry.paths.has(path)) continue;
|
|
15509
|
+
const key = `${channelId}:${path}`;
|
|
15510
|
+
clearTimeout(timers.get(key));
|
|
15511
|
+
timers.set(
|
|
15512
|
+
key,
|
|
15513
|
+
setTimeout(() => {
|
|
15514
|
+
timers.delete(key);
|
|
15515
|
+
publish(channelId, path);
|
|
15516
|
+
}, QUIET_MS)
|
|
15517
|
+
);
|
|
15518
|
+
}
|
|
15519
|
+
});
|
|
15520
|
+
} catch {
|
|
15521
|
+
continue;
|
|
15522
|
+
}
|
|
15523
|
+
watched.set(channelId, { paths: paths2, off });
|
|
15524
|
+
}
|
|
15525
|
+
};
|
|
15526
|
+
const tick = () => void refresh().catch((err) => console.error("[doc-share-auto] refresh failed:", err.message));
|
|
15527
|
+
tick();
|
|
15528
|
+
const interval = setInterval(tick, REFRESH_MS);
|
|
15529
|
+
interval.unref();
|
|
15530
|
+
return () => {
|
|
15531
|
+
clearInterval(interval);
|
|
15532
|
+
for (const t of timers.values()) clearTimeout(t);
|
|
15533
|
+
timers.clear();
|
|
15534
|
+
for (const entry of watched.values()) entry.off();
|
|
15535
|
+
watched.clear();
|
|
15536
|
+
};
|
|
15537
|
+
}
|
|
15538
|
+
|
|
15676
15539
|
// src/dashboard/host-dashboard.ts
|
|
15677
15540
|
async function startHostDashboard(preferredPort, host) {
|
|
15678
15541
|
loadEnvFiles();
|
|
@@ -15696,6 +15559,8 @@ async function startHostDashboard(preferredPort, host) {
|
|
|
15696
15559
|
onHostConnected = () => void chatAgent.recoverMissed().catch((err) => console.error("[chat-agent] recoverMissed failed:", err.message));
|
|
15697
15560
|
if (earlyHostSocket) onHostConnected();
|
|
15698
15561
|
const stopSkillSync = installSkillSync(listProfiles());
|
|
15562
|
+
const stopDocShareAutoUpdate = earlyHostSocket ? startDocShareAutoUpdate() : () => {
|
|
15563
|
+
};
|
|
15699
15564
|
const app = createBaseApp();
|
|
15700
15565
|
app.route("/api", createHostApiRouter(agent));
|
|
15701
15566
|
mountDataRootRoutes(app);
|
|
@@ -15740,6 +15605,7 @@ async function startHostDashboard(preferredPort, host) {
|
|
|
15740
15605
|
stopServiceWatch();
|
|
15741
15606
|
stopPushWatcher();
|
|
15742
15607
|
stopSkillSync();
|
|
15608
|
+
stopDocShareAutoUpdate();
|
|
15743
15609
|
hostSocketClient.stop();
|
|
15744
15610
|
server.close();
|
|
15745
15611
|
}
|
|
@@ -16220,7 +16086,7 @@ async function main() {
|
|
|
16220
16086
|
break;
|
|
16221
16087
|
case "-v":
|
|
16222
16088
|
case "--version":
|
|
16223
|
-
printRaw("0.1.
|
|
16089
|
+
printRaw("0.1.64");
|
|
16224
16090
|
break;
|
|
16225
16091
|
case "-h":
|
|
16226
16092
|
case "--help":
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { createRequire as __flyspaceCreateRequire } from 'node:module';
|
|
|
3
3
|
const require = __flyspaceCreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
startServer
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-FNKFJQB7.js";
|
|
7
|
+
import "./chunk-O7OYNQND.js";
|
|
8
8
|
export {
|
|
9
9
|
startServer
|
|
10
10
|
};
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
callAction,
|
|
8
8
|
checkPermissionAction,
|
|
9
9
|
createThreadAction,
|
|
10
|
+
listAutoUpdateSharesAction,
|
|
10
11
|
listChannelsAction,
|
|
11
12
|
moveThreadAction,
|
|
12
13
|
postReplyAction,
|
|
@@ -15,12 +16,12 @@ import {
|
|
|
15
16
|
searchThreadsAction,
|
|
16
17
|
shareDoc,
|
|
17
18
|
shareDocAction
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WFUR2BYO.js";
|
|
19
20
|
import {
|
|
20
21
|
SessionStore,
|
|
21
22
|
paths,
|
|
22
23
|
uploadLocalImages
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-O7OYNQND.js";
|
|
24
25
|
|
|
25
26
|
// src/mcp/servers/threads.ts
|
|
26
27
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -100,7 +101,7 @@ async function readThread(ref) {
|
|
|
100
101
|
${formatThread({ ...thread, body: opening?.body ?? null }, rest)}`;
|
|
101
102
|
}
|
|
102
103
|
var TOOLS = ACTIONS.filter(
|
|
103
|
-
(a) => a !== checkPermissionAction && a !== requestPermissionAction
|
|
104
|
+
(a) => a !== checkPermissionAction && a !== requestPermissionAction && a !== listAutoUpdateSharesAction
|
|
104
105
|
).map(toTool);
|
|
105
106
|
var PERMISSION_TOOL = toTool(requestPermissionAction);
|
|
106
107
|
function toTool(action) {
|
package/package.json
CHANGED
package/system.capabilities.md
CHANGED
|
@@ -51,10 +51,11 @@ Some background tasks DO finish on their own: a build, a deploy, a test suite, a
|
|
|
51
51
|
Instead, bake the notification into the command itself so the task pushes the result back when it finishes. You already know the current channel ID and thread id from the `[context: ...]` header at the top of the message — use those literal values, and pick the right command for where you are: `flyspace chat wake --thread <THREAD_ID>` when the context says `chat channel=...` (a Workspace/dashboard thread — see Flyspace Workspace Tools below), or `flyspace slack post --channel <CHANNEL_ID> --thread <THREAD_TS>` when it's a Slack thread:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
nohup bash -c 'if pnpm build; then S="✅ build 好了"; else S="❌ build
|
|
54
|
+
nohup bash -c 'export LANG=en_US.UTF-8; if pnpm build; then S="✅ build 好了"; else rc=$?; S="❌ build 失敗(exit ${rc}),看 /tmp/build.log"; fi; flyspace chat wake --thread <THREAD_ID> --about "pnpm build" --text "$S"' > /tmp/build.log 2>&1 & disown
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
- The task does not need to know Flyspace exists. YOU append the callback to the command you launch. The `--thread` value routes it back to this exact thread; multiple concurrent tasks each carry their own destination, so they never collide.
|
|
58
|
+
- Always brace shell variables inside `--text` (`${rc}`, `${dir}`, never `$rc`), and start the command with `export LANG=en_US.UTF-8`. Otherwise a variable followed directly by a CJK character (`$rc,`) swallows part of that character, expands to nothing and posts garbled `��` text.
|
|
58
59
|
- Report both success and failure — capture the exit status and post a different message for each. Include the log path on failure.
|
|
59
60
|
- `chat wake` (Workspace threads only) posts the result AND starts a new turn for you in this thread with the result as its prompt, resuming this session, so you can carry on with the next step (fix the failure, continue the plan) without the user coming back. Write the `--text` so your future self can act on it: what finished, pass or fail, and where the log is. Slack threads have no wake: `flyspace slack post` only posts. Wakes are capped at 5 in a row without a human message.
|
|
60
61
|
- Always pass `--about "<what it waits for>"` (a few words, in the user's language, no quotes inside): the thread shows it as "Waiting on: <about>" while the job runs. Every `chat wake` in the same job uses the same `--about`.
|