flyspace-cli 0.1.64 → 0.1.66
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-FNKFJQB7.js → chunk-DVHYIWIW.js} +244 -14
- package/dist/{chunk-O7OYNQND.js → chunk-KPZOOR73.js} +14 -8
- package/dist/{chunk-WFUR2BYO.js → chunk-ODQS4YBM.js} +29 -1
- package/dist/cli.js +494 -234
- package/dist/index.js +2 -2
- package/dist/{threads-VOXFIRD6.js → threads-62Y2BIFT.js} +22 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
SHARE_ASSET_PLACEHOLDER,
|
|
26
26
|
SKIP_SUBTYPES,
|
|
27
27
|
SUPPORT_AVATAR_URL,
|
|
28
|
+
SUPPORT_GRANT_HOURS,
|
|
28
29
|
TRANSLATION_LANGUAGES,
|
|
29
30
|
TRIAL_DAYS,
|
|
30
31
|
UsageStore,
|
|
@@ -59,6 +60,7 @@ import {
|
|
|
59
60
|
createRequestSupabaseClient,
|
|
60
61
|
createSkillFile,
|
|
61
62
|
createStateToken,
|
|
63
|
+
createSupportGrant,
|
|
62
64
|
createTtsRouter,
|
|
63
65
|
createWorkspace,
|
|
64
66
|
crossOriginShell,
|
|
@@ -77,6 +79,7 @@ import {
|
|
|
77
79
|
deriveConnectionSlug,
|
|
78
80
|
deriveThreadTitle,
|
|
79
81
|
detectSourceLanguage,
|
|
82
|
+
displayCwd,
|
|
80
83
|
displayNameFor,
|
|
81
84
|
dropShareAudio,
|
|
82
85
|
dropShareLangAudioKeys,
|
|
@@ -97,6 +100,7 @@ import {
|
|
|
97
100
|
findOwningProfile,
|
|
98
101
|
findSkillDetail,
|
|
99
102
|
flatDocs,
|
|
103
|
+
getActiveSupportGrant,
|
|
100
104
|
getAgentPaused,
|
|
101
105
|
getAllowGuestAccess,
|
|
102
106
|
getChannelDocsMemberAccess,
|
|
@@ -121,6 +125,7 @@ import {
|
|
|
121
125
|
getWorkspaceOwnPersona,
|
|
122
126
|
getWorkspacePermissionMode,
|
|
123
127
|
getWorkspacePlanStatus,
|
|
128
|
+
grantSupportMembership,
|
|
124
129
|
handleSupportMention,
|
|
125
130
|
insertMcpConnection,
|
|
126
131
|
insertWorkspaceDomain,
|
|
@@ -164,6 +169,8 @@ import {
|
|
|
164
169
|
listSkillFiles,
|
|
165
170
|
listSkills,
|
|
166
171
|
listSlashItems,
|
|
172
|
+
listSupportLog,
|
|
173
|
+
listSupportWorkspaceIds,
|
|
167
174
|
listThreadMemoryEvents,
|
|
168
175
|
listWorkspaceSummaries,
|
|
169
176
|
listWorkspaces,
|
|
@@ -176,6 +183,7 @@ import {
|
|
|
176
183
|
loadWorkspaceBranding,
|
|
177
184
|
loadWorkspacePrompt,
|
|
178
185
|
localDefaults,
|
|
186
|
+
logSupportAction,
|
|
179
187
|
markChannelGreeted,
|
|
180
188
|
markInviteResent,
|
|
181
189
|
markMemoryUsed,
|
|
@@ -185,6 +193,7 @@ import {
|
|
|
185
193
|
mentionedUserIds,
|
|
186
194
|
onboardingPending,
|
|
187
195
|
pinnedClaudeConfigDir,
|
|
196
|
+
platformAdminEmails,
|
|
188
197
|
postToDashboardChannel,
|
|
189
198
|
profileClaudeConfigDir,
|
|
190
199
|
profileEnv,
|
|
@@ -203,6 +212,7 @@ import {
|
|
|
203
212
|
removeChannelMember,
|
|
204
213
|
renderAppIcon,
|
|
205
214
|
requireDocsAccess,
|
|
215
|
+
requirePlatformOperator,
|
|
206
216
|
resetWorkspaceOnboarding,
|
|
207
217
|
resetWorkspacePrompt,
|
|
208
218
|
resolveAuthContext,
|
|
@@ -214,6 +224,8 @@ import {
|
|
|
214
224
|
resolveRateCard,
|
|
215
225
|
resolveUserId,
|
|
216
226
|
revokeDocShare,
|
|
227
|
+
revokeSupportGrants,
|
|
228
|
+
revokeSupportMembership,
|
|
217
229
|
rowToMemory,
|
|
218
230
|
runAutomation,
|
|
219
231
|
runPersonaCmd,
|
|
@@ -241,6 +253,7 @@ import {
|
|
|
241
253
|
setMemoryAutoPaused,
|
|
242
254
|
setOutputStyleDefault,
|
|
243
255
|
setProfileConfigCache,
|
|
256
|
+
setWorkspaceAgentDefaults,
|
|
244
257
|
setWorkspaceArchived,
|
|
245
258
|
setWorkspaceAutoContinueLimit,
|
|
246
259
|
setWorkspaceOwnPersona,
|
|
@@ -282,7 +295,7 @@ import {
|
|
|
282
295
|
workspaceHostname,
|
|
283
296
|
workspaceSkillsDir,
|
|
284
297
|
writeSkillFile
|
|
285
|
-
} from "./chunk-
|
|
298
|
+
} from "./chunk-DVHYIWIW.js";
|
|
286
299
|
import {
|
|
287
300
|
checkPermissionAction,
|
|
288
301
|
createThreadAction,
|
|
@@ -294,14 +307,16 @@ import {
|
|
|
294
307
|
listThreads,
|
|
295
308
|
moveThread,
|
|
296
309
|
moveThreadAction,
|
|
310
|
+
openDocAction,
|
|
297
311
|
postReplyAction,
|
|
298
312
|
readThreadAction,
|
|
299
313
|
requestPermissionAction,
|
|
300
314
|
resolveChannel,
|
|
301
315
|
runDocsCmd,
|
|
302
316
|
searchThreadsAction,
|
|
317
|
+
setUiZoomAction,
|
|
303
318
|
shareDocAction
|
|
304
|
-
} from "./chunk-
|
|
319
|
+
} from "./chunk-ODQS4YBM.js";
|
|
305
320
|
import {
|
|
306
321
|
AuthApiError,
|
|
307
322
|
DEFAULT_API_URL,
|
|
@@ -353,7 +368,7 @@ import {
|
|
|
353
368
|
slackConfigured,
|
|
354
369
|
sumR2PrefixBytes,
|
|
355
370
|
useHostDbWithoutCredentials
|
|
356
|
-
} from "./chunk-
|
|
371
|
+
} from "./chunk-KPZOOR73.js";
|
|
357
372
|
|
|
358
373
|
// ../core/src/logger.ts
|
|
359
374
|
var ALREADY_STAMPED = /^\[\d{4}-\d{2}-\d{2}T/;
|
|
@@ -1248,9 +1263,15 @@ function assertLinkable(target) {
|
|
|
1248
1263
|
const root = existsSync5(flyspaceRoot()) ? realpathSync2(flyspaceRoot()) : flyspaceRoot();
|
|
1249
1264
|
const denied = [join5(home2, ".ssh"), join5(home2, "Library"), join5(home2, ".config"), join5(home2, ".gnupg")];
|
|
1250
1265
|
if (target === home2 || target === "/" || target === root || target.startsWith(`${root}/`)) {
|
|
1251
|
-
throw new Error(`cannot link ${target}`);
|
|
1266
|
+
throw new Error(`cannot link ${target}: this folder can't be a channel folder, pick a project folder instead`);
|
|
1267
|
+
}
|
|
1268
|
+
const hit = denied.find((d) => target === d || target.startsWith(`${d}/`));
|
|
1269
|
+
if (hit) {
|
|
1270
|
+
const shown = hit.replace(home2, "~");
|
|
1271
|
+
throw new Error(
|
|
1272
|
+
`cannot link ${target}: ${shown} is blocked for security reasons, copy or move the folder outside ${shown}`
|
|
1273
|
+
);
|
|
1252
1274
|
}
|
|
1253
|
-
if (denied.some((d) => target === d || target.startsWith(`${d}/`))) throw new Error(`cannot link ${target}`);
|
|
1254
1275
|
}
|
|
1255
1276
|
function linkProjectFolders(slug, items2) {
|
|
1256
1277
|
if (!SLUG_RE.test(slug)) throw new Error(`invalid workspace slug: ${slug}`);
|
|
@@ -2210,7 +2231,7 @@ function npmEnv(target) {
|
|
|
2210
2231
|
return nodeBin ? { ...process.env, PATH: `${nodeBin}:${process.env.PATH ?? ""}` } : process.env;
|
|
2211
2232
|
}
|
|
2212
2233
|
async function runUpgrade() {
|
|
2213
|
-
const current = "0.1.
|
|
2234
|
+
const current = "0.1.66";
|
|
2214
2235
|
console.log(`Current version: ${current}`);
|
|
2215
2236
|
console.log("Checking for updates...\n");
|
|
2216
2237
|
try {
|
|
@@ -6162,7 +6183,7 @@ async function runMcpCmd(args) {
|
|
|
6162
6183
|
useHostDbWithoutCredentials();
|
|
6163
6184
|
switch (server) {
|
|
6164
6185
|
case "threads": {
|
|
6165
|
-
const { startThreadsServer } = await import("./threads-
|
|
6186
|
+
const { startThreadsServer } = await import("./threads-62Y2BIFT.js");
|
|
6166
6187
|
await startThreadsServer();
|
|
6167
6188
|
return;
|
|
6168
6189
|
}
|
|
@@ -6243,7 +6264,7 @@ async function ensureServices() {
|
|
|
6243
6264
|
}
|
|
6244
6265
|
|
|
6245
6266
|
// ../api/src/dashboard/api.ts
|
|
6246
|
-
import { Hono as
|
|
6267
|
+
import { Hono as Hono38 } from "hono";
|
|
6247
6268
|
|
|
6248
6269
|
// ../api/src/dashboard/guest-routes.ts
|
|
6249
6270
|
import { Hono as Hono4 } from "hono";
|
|
@@ -6671,7 +6692,9 @@ function createUploadsRouter() {
|
|
|
6671
6692
|
);
|
|
6672
6693
|
});
|
|
6673
6694
|
app.get("/attachments/:key{.+}", async (c) => {
|
|
6674
|
-
const
|
|
6695
|
+
const key = c.req.param("key");
|
|
6696
|
+
if (key.split("/")[1] !== getProfile()) return c.json({ error: "not found" }, 404);
|
|
6697
|
+
const url = await presignAttachmentRead(key);
|
|
6675
6698
|
if (!url) return c.json({ error: "not found" }, 404);
|
|
6676
6699
|
c.header("Cache-Control", `private, max-age=${PRESIGN_TTL_SECONDS - 60}`);
|
|
6677
6700
|
return c.redirect(url, 302);
|
|
@@ -7109,6 +7132,33 @@ var shareDoc = async (input2, ctx) => {
|
|
|
7109
7132
|
if (!res.url) throw new ActionError(`Share failed: ${res.error ?? "unknown error"}`);
|
|
7110
7133
|
return { url: res.url };
|
|
7111
7134
|
};
|
|
7135
|
+
var openDoc = async (input2, ctx) => {
|
|
7136
|
+
const channel = await channelInScope(ctx, input2.channel_id);
|
|
7137
|
+
const { threadId } = ctx.requester;
|
|
7138
|
+
if (!threadId) throw new ActionError("No thread to open the doc in.");
|
|
7139
|
+
await threadInScope(ctx, threadId);
|
|
7140
|
+
const targetUserId = await requesterUserId(ctx);
|
|
7141
|
+
if (!targetUserId) throw new ActionError("No requester to open the doc for.");
|
|
7142
|
+
const res = await getSupabaseClient().channel(`agent-thinking:${threadId}`).httpSend("open-doc", {
|
|
7143
|
+
channelId: channel.id,
|
|
7144
|
+
path: input2.path,
|
|
7145
|
+
...input2.line ? { line: input2.line } : {},
|
|
7146
|
+
targetUserId
|
|
7147
|
+
});
|
|
7148
|
+
if (!res.success) throw new Error(`broadcast failed: ${res.error}`);
|
|
7149
|
+
return { opened: true };
|
|
7150
|
+
};
|
|
7151
|
+
var setUiZoom = async (input2, ctx) => {
|
|
7152
|
+
const { threadId } = ctx.requester;
|
|
7153
|
+
if (!threadId) throw new ActionError("No thread to reach the requester through.");
|
|
7154
|
+
await threadInScope(ctx, threadId);
|
|
7155
|
+
const targetUserId = await requesterUserId(ctx);
|
|
7156
|
+
if (!targetUserId) throw new ActionError("No requester to set the zoom for.");
|
|
7157
|
+
const zoom = Math.round(input2.percent / 10) / 10;
|
|
7158
|
+
const res = await getSupabaseClient().channel(`agent-thinking:${threadId}`).httpSend("set-ui-zoom", { zoom, targetUserId });
|
|
7159
|
+
if (!res.success) throw new Error(`broadcast failed: ${res.error}`);
|
|
7160
|
+
return { zoom };
|
|
7161
|
+
};
|
|
7112
7162
|
var listAutoUpdateShares = async (_input, ctx) => ({
|
|
7113
7163
|
shares: (await listAutoUpdateDocShares(ctx.scope)).map((s) => ({
|
|
7114
7164
|
channel_id: s.channelId,
|
|
@@ -7184,6 +7234,8 @@ var HANDLERS = {
|
|
|
7184
7234
|
[postReplyAction.name]: postReply,
|
|
7185
7235
|
[moveThreadAction.name]: moveThread2,
|
|
7186
7236
|
[shareDocAction.name]: shareDoc,
|
|
7237
|
+
[openDocAction.name]: openDoc,
|
|
7238
|
+
[setUiZoomAction.name]: setUiZoom,
|
|
7187
7239
|
[listAutoUpdateSharesAction.name]: listAutoUpdateShares,
|
|
7188
7240
|
[requestPermissionAction.name]: requestPermission,
|
|
7189
7241
|
[checkPermissionAction.name]: checkPermission
|
|
@@ -7613,27 +7665,6 @@ async function ensureGreetingThread(workspaceId, channelId, ownerName) {
|
|
|
7613
7665
|
return error2?.code === "23505" ? (await existing()).data?.id ?? null : null;
|
|
7614
7666
|
}
|
|
7615
7667
|
|
|
7616
|
-
// ../api/src/dashboard/admin-middleware.ts
|
|
7617
|
-
function platformAdminEmails() {
|
|
7618
|
-
const raw = process.env["PLATFORM_ADMIN_EMAILS"] ?? "";
|
|
7619
|
-
return new Set(
|
|
7620
|
-
raw.split(",").map((e) => e.trim().toLowerCase()).filter(Boolean)
|
|
7621
|
-
);
|
|
7622
|
-
}
|
|
7623
|
-
var requirePlatformOperator = async (c, next) => {
|
|
7624
|
-
const supabase = createRequestSupabaseClient(c);
|
|
7625
|
-
const {
|
|
7626
|
-
data: { user }
|
|
7627
|
-
} = await supabase.auth.getUser();
|
|
7628
|
-
if (!user?.email) return c.json({ error: "not signed in" }, 401);
|
|
7629
|
-
const email = user.email.trim().toLowerCase();
|
|
7630
|
-
if (!platformAdminEmails().has(email)) {
|
|
7631
|
-
return c.json({ error: "platform operator access required" }, 403);
|
|
7632
|
-
}
|
|
7633
|
-
c.set("platformOperator", { userId: user.id, email });
|
|
7634
|
-
return next();
|
|
7635
|
-
};
|
|
7636
|
-
|
|
7637
7668
|
// ../api/src/dashboard/auth-routes.ts
|
|
7638
7669
|
function createAuthRouter() {
|
|
7639
7670
|
const auth = new Hono7();
|
|
@@ -7712,70 +7743,19 @@ function createAuthRouter() {
|
|
|
7712
7743
|
return auth;
|
|
7713
7744
|
}
|
|
7714
7745
|
|
|
7715
|
-
// ../api/src/store/support-store.ts
|
|
7716
|
-
var SUPPORT_HANDLE = "flyspace-support";
|
|
7717
|
-
async function logSupportAction(entry) {
|
|
7718
|
-
const { error: error2 } = await getSupabaseClient().from("support_access_log").insert({
|
|
7719
|
-
workspace_id: entry.workspaceId,
|
|
7720
|
-
staff_user_id: entry.staffUserId,
|
|
7721
|
-
staff_email: entry.staffEmail,
|
|
7722
|
-
action: entry.action,
|
|
7723
|
-
detail: entry.detail ?? null
|
|
7724
|
-
});
|
|
7725
|
-
if (error2) throw new Error(`logSupportAction(${entry.action}): ${error2.message}`);
|
|
7726
|
-
}
|
|
7727
|
-
async function listSupportWorkspaceIds(userId) {
|
|
7728
|
-
const { data, error: error2 } = await getSupabaseClient().from("memberships").select("workspace_id").eq("user_id", userId).eq("is_support", true);
|
|
7729
|
-
if (error2) throw new Error(`listSupportWorkspaceIds: ${error2.message}`);
|
|
7730
|
-
return new Set((data ?? []).map((r) => r.workspace_id));
|
|
7731
|
-
}
|
|
7732
|
-
async function grantSupportMembership(params) {
|
|
7733
|
-
const db = getSupabaseClient();
|
|
7734
|
-
const { data: existing, error: readError } = await db.from("memberships").select("is_support").eq("workspace_id", params.workspaceId).eq("user_id", params.userId).maybeSingle();
|
|
7735
|
-
if (readError) throw new Error(`grantSupportMembership: ${readError.message}`);
|
|
7736
|
-
if (existing) {
|
|
7737
|
-
if (existing.is_support === true) return "existing";
|
|
7738
|
-
throw new Error("already a regular member of this workspace");
|
|
7739
|
-
}
|
|
7740
|
-
const { data: taken } = await db.from("memberships").select("id").eq("workspace_id", params.workspaceId).eq("handle", SUPPORT_HANDLE).maybeSingle();
|
|
7741
|
-
const handle = taken ? `${SUPPORT_HANDLE}-${params.userId.slice(0, 8)}` : SUPPORT_HANDLE;
|
|
7742
|
-
const { error: error2 } = await db.from("memberships").insert({
|
|
7743
|
-
workspace_id: params.workspaceId,
|
|
7744
|
-
user_id: params.userId,
|
|
7745
|
-
email: params.email,
|
|
7746
|
-
handle,
|
|
7747
|
-
role: "admin",
|
|
7748
|
-
status: "active",
|
|
7749
|
-
is_support: true,
|
|
7750
|
-
accepted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7751
|
-
});
|
|
7752
|
-
if (error2) throw new Error(`grantSupportMembership: ${error2.message}`);
|
|
7753
|
-
return "granted";
|
|
7754
|
-
}
|
|
7755
|
-
async function revokeSupportMembership(workspaceId, userId) {
|
|
7756
|
-
const { data, error: error2 } = await getSupabaseClient().from("memberships").delete().eq("workspace_id", workspaceId).eq("user_id", userId).eq("is_support", true).select("id");
|
|
7757
|
-
if (error2) throw new Error(`revokeSupportMembership: ${error2.message}`);
|
|
7758
|
-
return (data ?? []).length > 0;
|
|
7759
|
-
}
|
|
7760
|
-
async function listSupportLog(filter) {
|
|
7761
|
-
let query = getSupabaseClient().from("support_access_log").select("*").order("created_at", { ascending: false }).limit(Math.min(filter.limit ?? 200, 1e3));
|
|
7762
|
-
if (filter.workspaceId) query = query.eq("workspace_id", filter.workspaceId);
|
|
7763
|
-
const { data, error: error2 } = await query;
|
|
7764
|
-
if (error2) throw new Error(`listSupportLog: ${error2.message}`);
|
|
7765
|
-
return (data ?? []).map((r) => ({
|
|
7766
|
-
id: r.id,
|
|
7767
|
-
workspaceId: r.workspace_id,
|
|
7768
|
-
staffUserId: r.staff_user_id,
|
|
7769
|
-
staffEmail: r.staff_email,
|
|
7770
|
-
action: r.action,
|
|
7771
|
-
detail: r.detail ?? null,
|
|
7772
|
-
createdAt: r.created_at
|
|
7773
|
-
}));
|
|
7774
|
-
}
|
|
7775
|
-
|
|
7776
7746
|
// ../api/src/dashboard/auth-middleware.ts
|
|
7777
7747
|
var ENTER_WINDOW_MS = 8 * 60 * 60 * 1e3;
|
|
7778
7748
|
var lastEnter = /* @__PURE__ */ new Map();
|
|
7749
|
+
var READ_DEDUPE_MS = 60 * 1e3;
|
|
7750
|
+
var lastRead = /* @__PURE__ */ new Map();
|
|
7751
|
+
function shouldLogRead(key, now) {
|
|
7752
|
+
if ((lastRead.get(key) ?? 0) + READ_DEDUPE_MS > now) return false;
|
|
7753
|
+
lastRead.set(key, now);
|
|
7754
|
+
if (lastRead.size > 5e3) {
|
|
7755
|
+
for (const [k, t] of lastRead) if (t + READ_DEDUPE_MS < now) lastRead.delete(k);
|
|
7756
|
+
}
|
|
7757
|
+
return true;
|
|
7758
|
+
}
|
|
7779
7759
|
function auditSupport(ctx, action, detail) {
|
|
7780
7760
|
logSupportAction({
|
|
7781
7761
|
workspaceId: ctx.workspaceId,
|
|
@@ -7797,7 +7777,11 @@ var requireWorkspaceMembership = async (c, next) => {
|
|
|
7797
7777
|
auditSupport(ctx, "enter");
|
|
7798
7778
|
}
|
|
7799
7779
|
await next();
|
|
7800
|
-
if (
|
|
7780
|
+
if (c.req.method === "GET") {
|
|
7781
|
+
if (shouldLogRead(`${key}:${c.req.path}`, Date.now())) {
|
|
7782
|
+
auditSupport(ctx, "read", { path: c.req.path, status: c.res.status });
|
|
7783
|
+
}
|
|
7784
|
+
} else if (!["HEAD", "OPTIONS"].includes(c.req.method)) {
|
|
7801
7785
|
auditSupport(ctx, "write", { method: c.req.method, path: c.req.path, status: c.res.status });
|
|
7802
7786
|
}
|
|
7803
7787
|
};
|
|
@@ -8019,6 +8003,9 @@ function createAdminRouter() {
|
|
|
8019
8003
|
const operator = c.get("platformOperator");
|
|
8020
8004
|
const workspaceId = c.req.param("id");
|
|
8021
8005
|
let result;
|
|
8006
|
+
if (!await getActiveSupportGrant(workspaceId)) {
|
|
8007
|
+
return c.json({ error: "workspace has not granted support access" }, 403);
|
|
8008
|
+
}
|
|
8022
8009
|
try {
|
|
8023
8010
|
result = await grantSupportMembership({
|
|
8024
8011
|
workspaceId,
|
|
@@ -8079,8 +8066,132 @@ function createAdminRouter() {
|
|
|
8079
8066
|
import { existsSync as existsSync17 } from "fs";
|
|
8080
8067
|
import sharp4 from "sharp";
|
|
8081
8068
|
|
|
8082
|
-
// ../api/src/dashboard/
|
|
8069
|
+
// ../api/src/dashboard/channel-agent-routes.ts
|
|
8070
|
+
import { Hono as Hono11 } from "hono";
|
|
8071
|
+
|
|
8072
|
+
// ../api/src/dashboard/channel-members-routes.ts
|
|
8083
8073
|
import { Hono as Hono10 } from "hono";
|
|
8074
|
+
async function isChannelAdmin(ctx, channelId) {
|
|
8075
|
+
if (ctx.role === "admin") return true;
|
|
8076
|
+
const membership = await getMembershipByUserId(ctx.workspaceId, ctx.userId);
|
|
8077
|
+
if (!membership) return false;
|
|
8078
|
+
const members = await listChannelMembers(channelId);
|
|
8079
|
+
return members.some((m) => m.membershipId === membership.id && m.role === "channel_admin");
|
|
8080
|
+
}
|
|
8081
|
+
function createChannelMembersRouter() {
|
|
8082
|
+
const router = new Hono10();
|
|
8083
|
+
router.get("/:id/members", async (c) => {
|
|
8084
|
+
const ctx = await resolveAuthContext(c);
|
|
8085
|
+
if (!ctx) return c.json({ error: "workspace access required" }, 403);
|
|
8086
|
+
const members = await listChannelMembers(c.req.param("id"));
|
|
8087
|
+
return c.json({ members });
|
|
8088
|
+
});
|
|
8089
|
+
router.put("/:id/members/:membershipId", async (c) => {
|
|
8090
|
+
const ctx = await resolveAuthContext(c);
|
|
8091
|
+
if (!ctx) return c.json({ error: "workspace access required" }, 403);
|
|
8092
|
+
const channelId = c.req.param("id");
|
|
8093
|
+
if (!await isChannelAdmin(ctx, channelId)) {
|
|
8094
|
+
return c.json({ error: "channel admin access required" }, 403);
|
|
8095
|
+
}
|
|
8096
|
+
const body = await c.req.json().catch(() => ({}));
|
|
8097
|
+
if (body.role !== "channel_admin" && body.role !== "channel_member") {
|
|
8098
|
+
return c.json({ error: "role must be 'channel_admin' or 'channel_member'" }, 400);
|
|
8099
|
+
}
|
|
8100
|
+
const member = await upsertChannelMember({
|
|
8101
|
+
channelId,
|
|
8102
|
+
membershipId: c.req.param("membershipId"),
|
|
8103
|
+
role: body.role
|
|
8104
|
+
});
|
|
8105
|
+
return c.json({ member });
|
|
8106
|
+
});
|
|
8107
|
+
router.delete("/:id/members/:membershipId", async (c) => {
|
|
8108
|
+
const ctx = await resolveAuthContext(c);
|
|
8109
|
+
if (!ctx) return c.json({ error: "workspace access required" }, 403);
|
|
8110
|
+
const channelId = c.req.param("id");
|
|
8111
|
+
if (!await isChannelAdmin(ctx, channelId)) {
|
|
8112
|
+
return c.json({ error: "channel admin access required" }, 403);
|
|
8113
|
+
}
|
|
8114
|
+
const removed = await removeChannelMember(channelId, c.req.param("membershipId"));
|
|
8115
|
+
if (!removed) return c.json({ error: "no such channel member" }, 404);
|
|
8116
|
+
return c.body(null, 204);
|
|
8117
|
+
});
|
|
8118
|
+
router.get("/:id/docs-access/me", async (c) => {
|
|
8119
|
+
const ctx = await resolveAuthContext(c);
|
|
8120
|
+
if (!ctx) return c.json({ error: "workspace access required" }, 403);
|
|
8121
|
+
return c.json({ access: await resolveDocsAccess(ctx, c.req.param("id")) });
|
|
8122
|
+
});
|
|
8123
|
+
router.get("/:id/docs-access", async (c) => {
|
|
8124
|
+
const ctx = await resolveAuthContext(c);
|
|
8125
|
+
if (!ctx) return c.json({ error: "workspace access required" }, 403);
|
|
8126
|
+
const channelId = c.req.param("id");
|
|
8127
|
+
if (!await isChannelAdmin(ctx, channelId)) {
|
|
8128
|
+
return c.json({ error: "channel admin access required" }, 403);
|
|
8129
|
+
}
|
|
8130
|
+
return c.json({ memberAccess: await getChannelDocsMemberAccess(channelId) });
|
|
8131
|
+
});
|
|
8132
|
+
router.put("/:id/docs-access", async (c) => {
|
|
8133
|
+
const ctx = await resolveAuthContext(c);
|
|
8134
|
+
if (!ctx) return c.json({ error: "workspace access required" }, 403);
|
|
8135
|
+
const channelId = c.req.param("id");
|
|
8136
|
+
if (!await isChannelAdmin(ctx, channelId)) {
|
|
8137
|
+
return c.json({ error: "channel admin access required" }, 403);
|
|
8138
|
+
}
|
|
8139
|
+
const body = await c.req.json().catch(() => ({}));
|
|
8140
|
+
if (!isDocsAccess(body.memberAccess)) {
|
|
8141
|
+
return c.json({ error: "memberAccess must be 'none', 'read' or 'write'" }, 400);
|
|
8142
|
+
}
|
|
8143
|
+
if (!await setChannelDocsMemberAccess(channelId, body.memberAccess)) {
|
|
8144
|
+
return c.json({ error: "no such channel" }, 404);
|
|
8145
|
+
}
|
|
8146
|
+
return c.json({ memberAccess: body.memberAccess });
|
|
8147
|
+
});
|
|
8148
|
+
return router;
|
|
8149
|
+
}
|
|
8150
|
+
|
|
8151
|
+
// ../api/src/dashboard/channel-agent-routes.ts
|
|
8152
|
+
function coerce(body, key, valid) {
|
|
8153
|
+
if (!(key in body)) return void 0;
|
|
8154
|
+
const raw = body[key];
|
|
8155
|
+
if (raw === null || raw === "") return null;
|
|
8156
|
+
if (typeof raw !== "string") return "invalid";
|
|
8157
|
+
const value = raw.trim();
|
|
8158
|
+
return valid(value) ? value : "invalid";
|
|
8159
|
+
}
|
|
8160
|
+
function createChannelAgentRouter() {
|
|
8161
|
+
const router = new Hono11();
|
|
8162
|
+
router.patch("/:id", async (c, next) => {
|
|
8163
|
+
const body = await c.req.raw.clone().json().catch(() => null);
|
|
8164
|
+
if (!body || typeof body !== "object" || !("model" in body || "effort" in body)) return next();
|
|
8165
|
+
const auth = await resolveAuthContext(c);
|
|
8166
|
+
if (!auth) return c.json({ error: "workspace access required" }, 403);
|
|
8167
|
+
const id = c.req.param("id");
|
|
8168
|
+
const channel = findChannelById(id);
|
|
8169
|
+
if (!channel || channel.profile !== getProfile()) return c.json({ error: "not found" }, 404);
|
|
8170
|
+
if (!await isChannelAdmin(auth, id)) {
|
|
8171
|
+
return c.json({ error: "channel admin access required" }, 403);
|
|
8172
|
+
}
|
|
8173
|
+
const model = coerce(body, "model", isAllowedModel);
|
|
8174
|
+
const effort = coerce(body, "effort", isEffort);
|
|
8175
|
+
if (model === "invalid") return c.json({ error: "unknown model" }, 400);
|
|
8176
|
+
if (effort === "invalid") {
|
|
8177
|
+
return c.json({ error: "effort must be low, medium, high, xhigh or max" }, 400);
|
|
8178
|
+
}
|
|
8179
|
+
if (Object.keys(body).some((k) => k !== "model" && k !== "effort")) return next();
|
|
8180
|
+
try {
|
|
8181
|
+
const updated = await updateChannelById(id, {
|
|
8182
|
+
...model !== void 0 ? { model } : {},
|
|
8183
|
+
...effort !== void 0 ? { effort } : {}
|
|
8184
|
+
});
|
|
8185
|
+
return c.json({ id: updated.id, model: updated.model ?? null, effort: updated.effort ?? null });
|
|
8186
|
+
} catch (err) {
|
|
8187
|
+
return c.json({ error: err.message }, 500);
|
|
8188
|
+
}
|
|
8189
|
+
});
|
|
8190
|
+
return router;
|
|
8191
|
+
}
|
|
8192
|
+
|
|
8193
|
+
// ../api/src/dashboard/automations-routes.ts
|
|
8194
|
+
import { Hono as Hono12 } from "hono";
|
|
8084
8195
|
var TYPES2 = ["schedule", "trigger", "mention-trigger"];
|
|
8085
8196
|
function isType(t) {
|
|
8086
8197
|
return TYPES2.includes(t);
|
|
@@ -8097,7 +8208,7 @@ function statusFor(message) {
|
|
|
8097
8208
|
return 400;
|
|
8098
8209
|
}
|
|
8099
8210
|
function createAutomationWriteRouter() {
|
|
8100
|
-
const app = new
|
|
8211
|
+
const app = new Hono12();
|
|
8101
8212
|
const manager = () => new AutomationManager();
|
|
8102
8213
|
app.get("/:type/:name", (c) => {
|
|
8103
8214
|
const item = manager().get(c.req.param("name"));
|
|
@@ -8153,9 +8264,9 @@ function createAutomationWriteRouter() {
|
|
|
8153
8264
|
}
|
|
8154
8265
|
|
|
8155
8266
|
// ../api/src/dashboard/categories-routes.ts
|
|
8156
|
-
import { Hono as
|
|
8267
|
+
import { Hono as Hono13 } from "hono";
|
|
8157
8268
|
function createCategoryWriteRouter() {
|
|
8158
|
-
const app = new
|
|
8269
|
+
const app = new Hono13();
|
|
8159
8270
|
app.get("/", async (c) => {
|
|
8160
8271
|
const { data, error: error2 } = await getSupabaseClient().from("categories").select("*").eq("profile", getProfile()).order("position", { ascending: true });
|
|
8161
8272
|
if (error2) return c.json({ error: error2.message }, 500);
|
|
@@ -8209,7 +8320,7 @@ function createCategoryWriteRouter() {
|
|
|
8209
8320
|
}
|
|
8210
8321
|
|
|
8211
8322
|
// ../api/src/dashboard/chat-routes.ts
|
|
8212
|
-
import { Hono as
|
|
8323
|
+
import { Hono as Hono15 } from "hono";
|
|
8213
8324
|
|
|
8214
8325
|
// ../api/src/dashboard/fork-summary.ts
|
|
8215
8326
|
var MAX_INPUT_CHARS = 6e4;
|
|
@@ -8254,7 +8365,7 @@ async function relevantThreadsPage(supabase, handle, channelIds, opts) {
|
|
|
8254
8365
|
}
|
|
8255
8366
|
|
|
8256
8367
|
// ../api/src/dashboard/continuous-chat.ts
|
|
8257
|
-
import { Hono as
|
|
8368
|
+
import { Hono as Hono14 } from "hono";
|
|
8258
8369
|
var GROQ_API_URL2 = "https://api.groq.com/openai/v1/chat/completions";
|
|
8259
8370
|
var MODEL = "openai/gpt-oss-120b";
|
|
8260
8371
|
var STREAM_DAYS = 30;
|
|
@@ -8362,7 +8473,7 @@ function tagStoredReply(c, args) {
|
|
|
8362
8473
|
}
|
|
8363
8474
|
var backfilling = /* @__PURE__ */ new Set();
|
|
8364
8475
|
function createContinuousChatRouter() {
|
|
8365
|
-
const app = new
|
|
8476
|
+
const app = new Hono14();
|
|
8366
8477
|
app.get("/channels/:channelId/continuous", async (c) => {
|
|
8367
8478
|
if (!await isFeatureEnabled(c, "continuous-chat"))
|
|
8368
8479
|
return c.json({ error: "feature not enabled" }, 403);
|
|
@@ -9044,7 +9155,7 @@ async function generateAutoTitle(threadId, channelId, body) {
|
|
|
9044
9155
|
await supabase.from("threads").update({ auto_title: autoTitle }).eq("id", threadId).is("title", null);
|
|
9045
9156
|
}
|
|
9046
9157
|
function createChatRouter(agent = {}) {
|
|
9047
|
-
const app = new
|
|
9158
|
+
const app = new Hono15();
|
|
9048
9159
|
const {
|
|
9049
9160
|
onChatMessage: onMessage,
|
|
9050
9161
|
isAgentThinking,
|
|
@@ -9775,7 +9886,7 @@ function createChatRouter(agent = {}) {
|
|
|
9775
9886
|
}
|
|
9776
9887
|
|
|
9777
9888
|
// ../api/src/dashboard/doc-shares-routes.ts
|
|
9778
|
-
import { Hono as
|
|
9889
|
+
import { Hono as Hono16 } from "hono";
|
|
9779
9890
|
|
|
9780
9891
|
// ../api/src/dashboard/share-tags.ts
|
|
9781
9892
|
var MAX_TAGS = 10;
|
|
@@ -9864,7 +9975,7 @@ function resolveChannel2(c) {
|
|
|
9864
9975
|
}
|
|
9865
9976
|
var LIST_LIMIT = 500;
|
|
9866
9977
|
function createDocShareListRouter() {
|
|
9867
|
-
const app = new
|
|
9978
|
+
const app = new Hono16();
|
|
9868
9979
|
app.get("/shares", async (c) => {
|
|
9869
9980
|
const viewer = c.get("auth");
|
|
9870
9981
|
const readable = await filterReadableDocsChannels(
|
|
@@ -9909,7 +10020,7 @@ function createDocShareListRouter() {
|
|
|
9909
10020
|
return app;
|
|
9910
10021
|
}
|
|
9911
10022
|
function createDocShareWriteRouter(agent = {}) {
|
|
9912
|
-
const app = new
|
|
10023
|
+
const app = new Hono16();
|
|
9913
10024
|
app.use("/:id/docs/share", requireDocsAccess);
|
|
9914
10025
|
app.use("/:id/docs/share/*", requireDocsAccess);
|
|
9915
10026
|
app.use("/:id/docs/shares", requireDocsAccess);
|
|
@@ -10091,7 +10202,7 @@ function createDocShareWriteRouter(agent = {}) {
|
|
|
10091
10202
|
}
|
|
10092
10203
|
|
|
10093
10204
|
// ../api/src/dashboard/search-routes.ts
|
|
10094
|
-
import { Hono as
|
|
10205
|
+
import { Hono as Hono17 } from "hono";
|
|
10095
10206
|
function matchScore(q, fields) {
|
|
10096
10207
|
const terms = q.toLowerCase().split(/\s+/).filter(Boolean);
|
|
10097
10208
|
if (terms.length === 0) return 0;
|
|
@@ -10239,7 +10350,7 @@ function searchAutomations(q) {
|
|
|
10239
10350
|
}
|
|
10240
10351
|
var RESULT_LIMIT = 30;
|
|
10241
10352
|
function createSearchRouter() {
|
|
10242
|
-
const app = new
|
|
10353
|
+
const app = new Hono17();
|
|
10243
10354
|
app.get("/", async (c) => {
|
|
10244
10355
|
const q = c.req.query("q")?.trim();
|
|
10245
10356
|
if (!q) return c.json({ results: [] });
|
|
@@ -10255,7 +10366,7 @@ function createSearchRouter() {
|
|
|
10255
10366
|
}
|
|
10256
10367
|
|
|
10257
10368
|
// ../api/src/dashboard/domain-routes.ts
|
|
10258
|
-
import { Hono as
|
|
10369
|
+
import { Hono as Hono18 } from "hono";
|
|
10259
10370
|
var FALLBACK_ORIGIN = "custom.flyspace.ai";
|
|
10260
10371
|
function isValidCustomHostname(hostname2) {
|
|
10261
10372
|
if (hostname2.length > 253 || hostname2.endsWith(".flyspace.ai") || hostname2 === "flyspace.ai") {
|
|
@@ -10325,7 +10436,7 @@ function view(row, dcv) {
|
|
|
10325
10436
|
};
|
|
10326
10437
|
}
|
|
10327
10438
|
function createDomainRouter() {
|
|
10328
|
-
const app = new
|
|
10439
|
+
const app = new Hono18();
|
|
10329
10440
|
app.use("*", async (c, next) => {
|
|
10330
10441
|
const auth = c.get("auth");
|
|
10331
10442
|
if (auth.role !== "admin") return c.json({ error: "admin access required" }, 403);
|
|
@@ -10388,15 +10499,100 @@ function createDomainRouter() {
|
|
|
10388
10499
|
return app;
|
|
10389
10500
|
}
|
|
10390
10501
|
|
|
10502
|
+
// ../api/src/dashboard/support-grant-routes.ts
|
|
10503
|
+
import { Hono as Hono19 } from "hono";
|
|
10504
|
+
function createSupportGrantRouter() {
|
|
10505
|
+
const app = new Hono19();
|
|
10506
|
+
app.use("*", async (c, next) => {
|
|
10507
|
+
const auth = c.get("auth");
|
|
10508
|
+
if (auth.role !== "admin" || auth.isSupport) {
|
|
10509
|
+
return c.json({ error: "workspace admin access required" }, 403);
|
|
10510
|
+
}
|
|
10511
|
+
await next();
|
|
10512
|
+
});
|
|
10513
|
+
app.get("/", async (c) => {
|
|
10514
|
+
return c.json({ grant: await getActiveSupportGrant(c.get("auth").workspaceId) });
|
|
10515
|
+
});
|
|
10516
|
+
app.get("/activity", async (c) => {
|
|
10517
|
+
const limit = Number(c.req.query("limit")) || 200;
|
|
10518
|
+
return c.json({ entries: await listSupportLog({ workspaceId: c.get("auth").workspaceId, limit }) });
|
|
10519
|
+
});
|
|
10520
|
+
app.post("/", async (c) => {
|
|
10521
|
+
const auth = c.get("auth");
|
|
10522
|
+
const body = await c.req.json().catch(() => ({}));
|
|
10523
|
+
const hours = Number(body.hours);
|
|
10524
|
+
if (!SUPPORT_GRANT_HOURS.includes(hours)) {
|
|
10525
|
+
return c.json({ error: `hours must be one of ${SUPPORT_GRANT_HOURS.join(", ")}` }, 400);
|
|
10526
|
+
}
|
|
10527
|
+
const reason = typeof body.reason === "string" ? body.reason.trim().slice(0, 500) : "";
|
|
10528
|
+
const grant = await createSupportGrant({
|
|
10529
|
+
workspaceId: auth.workspaceId,
|
|
10530
|
+
userId: auth.userId,
|
|
10531
|
+
email: auth.email,
|
|
10532
|
+
hours,
|
|
10533
|
+
...reason ? { reason } : {}
|
|
10534
|
+
});
|
|
10535
|
+
await logSupportAction({
|
|
10536
|
+
workspaceId: auth.workspaceId,
|
|
10537
|
+
staffUserId: auth.userId,
|
|
10538
|
+
staffEmail: auth.email,
|
|
10539
|
+
action: "granted",
|
|
10540
|
+
detail: { hours, expiresAt: grant.expiresAt, ...reason ? { reason } : {} }
|
|
10541
|
+
});
|
|
10542
|
+
invalidateAuthContextCache();
|
|
10543
|
+
return c.json({ grant });
|
|
10544
|
+
});
|
|
10545
|
+
app.delete("/", async (c) => {
|
|
10546
|
+
const auth = c.get("auth");
|
|
10547
|
+
if (await revokeSupportGrants(auth.workspaceId, auth.userId) > 0) {
|
|
10548
|
+
await logSupportAction({
|
|
10549
|
+
workspaceId: auth.workspaceId,
|
|
10550
|
+
staffUserId: auth.userId,
|
|
10551
|
+
staffEmail: auth.email,
|
|
10552
|
+
action: "revoked"
|
|
10553
|
+
});
|
|
10554
|
+
}
|
|
10555
|
+
invalidateAuthContextCache();
|
|
10556
|
+
return c.json({ grant: null });
|
|
10557
|
+
});
|
|
10558
|
+
return app;
|
|
10559
|
+
}
|
|
10560
|
+
|
|
10391
10561
|
// ../api/src/dashboard/transcribe-routes.ts
|
|
10392
|
-
import { Hono as
|
|
10562
|
+
import { Hono as Hono20 } from "hono";
|
|
10393
10563
|
var GROQ_TRANSCRIBE_URL = "https://api.groq.com/openai/v1/audio/transcriptions";
|
|
10394
10564
|
var MODEL2 = "whisper-large-v3-turbo";
|
|
10395
10565
|
var MAX_AUDIO_BYTES = 25 * 1024 * 1024;
|
|
10396
10566
|
var MAX_PROMPT_CHARS = 400;
|
|
10567
|
+
var MAX_TAIL_CHARS = 200;
|
|
10568
|
+
var MAX_GLOSSARY_CHARS = 150;
|
|
10569
|
+
var STYLE_SEEDS = {
|
|
10570
|
+
"zh-Hant": "\u9019\u662F\u7E41\u9AD4\u4E2D\u6587\u7684\u53E3\u8FF0\uFF0C\u4E2D\u9593\u593E\u96DC English \u8853\u8A9E\uFF0C\u4F8B\u5982 component\u3001API\u3001deploy\u3002",
|
|
10571
|
+
"zh-Hans": "\u8FD9\u662F\u7B80\u4F53\u4E2D\u6587\u7684\u53E3\u8FF0\uFF0C\u4E2D\u95F4\u5939\u6742 English \u672F\u8BED\uFF0C\u4F8B\u5982 component\u3001API\u3001deploy\u3002"
|
|
10572
|
+
};
|
|
10573
|
+
var HALLUCINATIONS = [
|
|
10574
|
+
/^(謝謝|感謝)(大家|您|你)?(的)?(收看|觀看|收聽|觀賞)[。!!.]?$/,
|
|
10575
|
+
/^請不吝點讚.*$/,
|
|
10576
|
+
/^字幕(由|製作|提供).{0,20}$/,
|
|
10577
|
+
/^(thank you|thanks)( (so much|very much))?( for watching)?[.!]?$/i,
|
|
10578
|
+
/^(you|bye)[.!]?$/i
|
|
10579
|
+
];
|
|
10580
|
+
function isHallucination(text) {
|
|
10581
|
+
const t = text.trim();
|
|
10582
|
+
return HALLUCINATIONS.some((re) => re.test(t));
|
|
10583
|
+
}
|
|
10584
|
+
function buildPrompt(terms, tail, locale) {
|
|
10585
|
+
let glossary = "";
|
|
10586
|
+
for (const term of terms) {
|
|
10587
|
+
const next = glossary ? `${glossary}\u3001${term}` : term;
|
|
10588
|
+
if (next.length > MAX_GLOSSARY_CHARS) break;
|
|
10589
|
+
glossary = next;
|
|
10590
|
+
}
|
|
10591
|
+
return [glossary && `${glossary}.`, locale && STYLE_SEEDS[locale], tail.slice(-MAX_TAIL_CHARS)].filter(Boolean).join(" ").slice(-MAX_PROMPT_CHARS);
|
|
10592
|
+
}
|
|
10397
10593
|
var NO_SPEECH_THRESHOLD = 0.6;
|
|
10398
10594
|
function createTranscribeRouter() {
|
|
10399
|
-
const app = new
|
|
10595
|
+
const app = new Hono20();
|
|
10400
10596
|
app.post("/transcribe", async (c) => {
|
|
10401
10597
|
const apiKey = process.env["GROQ_API_KEY"];
|
|
10402
10598
|
if (!apiKey) return c.json({ error: "transcription is not configured" }, 503);
|
|
@@ -10409,9 +10605,19 @@ function createTranscribeRouter() {
|
|
|
10409
10605
|
form.append("model", MODEL2);
|
|
10410
10606
|
form.append("temperature", "0");
|
|
10411
10607
|
form.append("response_format", "verbose_json");
|
|
10412
|
-
const
|
|
10413
|
-
|
|
10414
|
-
|
|
10608
|
+
const tail = typeof body?.["prompt"] === "string" ? body["prompt"] : "";
|
|
10609
|
+
const channelId = body?.["channelId"];
|
|
10610
|
+
let terms = [];
|
|
10611
|
+
if (typeof channelId === "string" && channelId) {
|
|
10612
|
+
const visible = await globalChannelMeta(c).catch(() => /* @__PURE__ */ new Map());
|
|
10613
|
+
if (visible.has(channelId)) {
|
|
10614
|
+
const glossary = await getChannelGlossaries([channelId]).catch(() => /* @__PURE__ */ new Map());
|
|
10615
|
+
terms = (glossary.get(channelId)?.terms ?? []).map((t) => t.term);
|
|
10616
|
+
}
|
|
10617
|
+
}
|
|
10618
|
+
const locale = typeof body?.["locale"] === "string" ? body["locale"] : void 0;
|
|
10619
|
+
const prompt = buildPrompt(terms, tail, locale);
|
|
10620
|
+
if (prompt) form.append("prompt", prompt);
|
|
10415
10621
|
const language = body?.["language"];
|
|
10416
10622
|
if (typeof language === "string" && /^[a-z]{2}$/.test(language)) {
|
|
10417
10623
|
form.append("language", language);
|
|
@@ -10427,13 +10633,14 @@ function createTranscribeRouter() {
|
|
|
10427
10633
|
if (segments.length > 0 && segments.every((s) => (s.no_speech_prob ?? 0) > NO_SPEECH_THRESHOLD)) {
|
|
10428
10634
|
return c.json({ text: "" });
|
|
10429
10635
|
}
|
|
10430
|
-
|
|
10636
|
+
const text = (data.text ?? "").trim();
|
|
10637
|
+
return c.json({ text: isHallucination(text) ? "" : text });
|
|
10431
10638
|
});
|
|
10432
10639
|
return app;
|
|
10433
10640
|
}
|
|
10434
10641
|
|
|
10435
10642
|
// ../api/src/dashboard/autocomplete-routes.ts
|
|
10436
|
-
import { Hono as
|
|
10643
|
+
import { Hono as Hono21 } from "hono";
|
|
10437
10644
|
var GROQ_API_URL4 = "https://api.groq.com/openai/v1/chat/completions";
|
|
10438
10645
|
var MODEL3 = "openai/gpt-oss-120b";
|
|
10439
10646
|
var MAX_REPLY_CHARS = 4e3;
|
|
@@ -10444,7 +10651,7 @@ Base it on the agent's last reply: answer a question it asked, approve or pick a
|
|
|
10444
10651
|
Keep it short (under 15 words), in the language the user writes in. No greetings, thanks or filler.
|
|
10445
10652
|
Output ONLY the message text, no quotes or explanation. If there is no clear next step, output nothing.`;
|
|
10446
10653
|
function createAutocompleteRouter() {
|
|
10447
|
-
const app = new
|
|
10654
|
+
const app = new Hono21();
|
|
10448
10655
|
app.post("/autocomplete", async (c) => {
|
|
10449
10656
|
const apiKey = process.env["GROQ_API_KEY"];
|
|
10450
10657
|
if (!apiKey) return c.json({ error: "autocomplete is not configured" }, 503);
|
|
@@ -10510,7 +10717,7 @@ ${last.body.slice(-MAX_REPLY_CHARS)}`;
|
|
|
10510
10717
|
}
|
|
10511
10718
|
|
|
10512
10719
|
// ../api/src/dashboard/daily-line-routes.ts
|
|
10513
|
-
import { Hono as
|
|
10720
|
+
import { Hono as Hono22 } from "hono";
|
|
10514
10721
|
var GROQ_API_URL5 = "https://api.groq.com/openai/v1/chat/completions";
|
|
10515
10722
|
var MODEL4 = "openai/gpt-oss-120b";
|
|
10516
10723
|
var DAY_MS = 864e5;
|
|
@@ -10536,7 +10743,7 @@ function pickMemories(memories, day, now = Date.now()) {
|
|
|
10536
10743
|
return [...pool, ...pool].slice(start, start + Math.min(CONTEXT_COUNT, pool.length));
|
|
10537
10744
|
}
|
|
10538
10745
|
function createDailyLineRouter() {
|
|
10539
|
-
const app = new
|
|
10746
|
+
const app = new Hono22();
|
|
10540
10747
|
app.get("/daily-line", async (c) => {
|
|
10541
10748
|
if (!await isFeatureEnabled(c, "daily-line"))
|
|
10542
10749
|
return c.json({ error: "feature not enabled" }, 403);
|
|
@@ -10592,7 +10799,7 @@ Write it in ${language} (BCP 47 tag). For Chinese use Traditional Chinese (Taiwa
|
|
|
10592
10799
|
}
|
|
10593
10800
|
|
|
10594
10801
|
// ../api/src/dashboard/channel-route.ts
|
|
10595
|
-
import { Hono as
|
|
10802
|
+
import { Hono as Hono23 } from "hono";
|
|
10596
10803
|
var GROQ_API_URL6 = "https://api.groq.com/openai/v1/chat/completions";
|
|
10597
10804
|
var MODEL5 = "openai/gpt-oss-120b";
|
|
10598
10805
|
var MAX_MESSAGE_CHARS2 = 3e3;
|
|
@@ -10662,7 +10869,7 @@ A topic word that could fit many projects (notification, scrollbar, login, bug)
|
|
|
10662
10869
|
When a screenshot description is given, the app and names visible in it are strong evidence of the project.
|
|
10663
10870
|
Output ONLY the channel's number and your confidence, e.g. "3 high" or "3 low". Say low when the message could reasonably belong to more than one channel.`;
|
|
10664
10871
|
function createChannelRouteRouter() {
|
|
10665
|
-
const app = new
|
|
10872
|
+
const app = new Hono23();
|
|
10666
10873
|
app.post("/route-channel", async (c) => {
|
|
10667
10874
|
if (!await isFeatureEnabled(c, "auto-channel"))
|
|
10668
10875
|
return c.json({ error: "feature not enabled" }, 403);
|
|
@@ -10722,7 +10929,7 @@ ${screenshots}` : ""}` }
|
|
|
10722
10929
|
|
|
10723
10930
|
// ../api/src/dashboard/avatars-routes.ts
|
|
10724
10931
|
import { createHash as createHash5, randomUUID as randomUUID3 } from "crypto";
|
|
10725
|
-
import { Hono as
|
|
10932
|
+
import { Hono as Hono24 } from "hono";
|
|
10726
10933
|
import sharp3 from "sharp";
|
|
10727
10934
|
import { PutObjectCommand as PutObjectCommand3, DeleteObjectCommand as DeleteObjectCommand2 } from "@aws-sdk/client-s3";
|
|
10728
10935
|
var AVATAR_SIZE = 192;
|
|
@@ -10775,7 +10982,7 @@ function avatarKeyPrefix() {
|
|
|
10775
10982
|
return `${KEY_PREFIX2}/${getProfile()}/`;
|
|
10776
10983
|
}
|
|
10777
10984
|
function createAvatarsRouter() {
|
|
10778
|
-
const app = new
|
|
10985
|
+
const app = new Hono24();
|
|
10779
10986
|
app.get("/avatars/slack", async (c) => {
|
|
10780
10987
|
const ctx = await resolveAuthContext(c);
|
|
10781
10988
|
if (!ctx) return c.json({ error: "not signed in" }, 401);
|
|
@@ -10824,7 +11031,7 @@ function createAvatarsRouter() {
|
|
|
10824
11031
|
}
|
|
10825
11032
|
|
|
10826
11033
|
// ../api/src/dashboard/members-routes.ts
|
|
10827
|
-
import { Hono as
|
|
11034
|
+
import { Hono as Hono25 } from "hono";
|
|
10828
11035
|
function inviteLinkFor(c, token) {
|
|
10829
11036
|
const url = new URL("/auth/invite", callbackUrl(c));
|
|
10830
11037
|
url.searchParams.set("token", token);
|
|
@@ -10832,7 +11039,7 @@ function inviteLinkFor(c, token) {
|
|
|
10832
11039
|
}
|
|
10833
11040
|
var EMAIL_RE2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
10834
11041
|
function createMembersRouter() {
|
|
10835
|
-
const members = new
|
|
11042
|
+
const members = new Hono25();
|
|
10836
11043
|
members.get("/", async (c) => {
|
|
10837
11044
|
const ctx = await resolveAuthContext(c);
|
|
10838
11045
|
if (ctx?.role !== "admin") return c.json({ error: "admin access required" }, 403);
|
|
@@ -11055,7 +11262,7 @@ function createMembersRouter() {
|
|
|
11055
11262
|
}
|
|
11056
11263
|
|
|
11057
11264
|
// ../api/src/dashboard/notifications-routes.ts
|
|
11058
|
-
import { Hono as
|
|
11265
|
+
import { Hono as Hono26 } from "hono";
|
|
11059
11266
|
|
|
11060
11267
|
// ../api/src/store/push-store.ts
|
|
11061
11268
|
function rowToSubscription(row) {
|
|
@@ -11240,7 +11447,7 @@ function startPushWatcher() {
|
|
|
11240
11447
|
|
|
11241
11448
|
// ../api/src/dashboard/notifications-routes.ts
|
|
11242
11449
|
function createNotificationsRouter() {
|
|
11243
|
-
const notifications = new
|
|
11450
|
+
const notifications = new Hono26();
|
|
11244
11451
|
notifications.get("/", async (c) => {
|
|
11245
11452
|
const auth = c.get("auth");
|
|
11246
11453
|
const channelIds = getProfileChannelRegistry().filter((ch) => canSeeChannel(ch, auth)).map((ch) => ch.id);
|
|
@@ -11267,7 +11474,7 @@ function createNotificationsRouter() {
|
|
|
11267
11474
|
return notifications;
|
|
11268
11475
|
}
|
|
11269
11476
|
function createThreadReadRouter() {
|
|
11270
|
-
const threads = new
|
|
11477
|
+
const threads = new Hono26();
|
|
11271
11478
|
threads.post("/threads/:threadId/read", async (c) => {
|
|
11272
11479
|
const { userId } = c.get("auth");
|
|
11273
11480
|
const threadId = c.req.param("threadId");
|
|
@@ -11291,9 +11498,9 @@ function createThreadReadRouter() {
|
|
|
11291
11498
|
}
|
|
11292
11499
|
|
|
11293
11500
|
// ../api/src/dashboard/push-routes.ts
|
|
11294
|
-
import { Hono as
|
|
11501
|
+
import { Hono as Hono27 } from "hono";
|
|
11295
11502
|
function createPushRouter() {
|
|
11296
|
-
const push = new
|
|
11503
|
+
const push = new Hono27();
|
|
11297
11504
|
push.get("/key", (c) => c.json({ publicKey: getVapidPublicKey() }));
|
|
11298
11505
|
push.post("/subscribe", async (c) => {
|
|
11299
11506
|
const { userId } = c.get("auth");
|
|
@@ -11324,7 +11531,7 @@ function createPushRouter() {
|
|
|
11324
11531
|
}
|
|
11325
11532
|
|
|
11326
11533
|
// ../api/src/dashboard/mcp-oauth-routes.ts
|
|
11327
|
-
import { Hono as
|
|
11534
|
+
import { Hono as Hono28 } from "hono";
|
|
11328
11535
|
var CONNECTIONS_PAGE = "/settings/connections";
|
|
11329
11536
|
function callbackUri(c) {
|
|
11330
11537
|
const proto = c.req.header("x-forwarded-proto") ?? "http";
|
|
@@ -11339,7 +11546,7 @@ function backToDashboard(c, to, params) {
|
|
|
11339
11546
|
return c.redirect(`${target.pathname}${target.search}`);
|
|
11340
11547
|
}
|
|
11341
11548
|
function createMcpOAuthRouter() {
|
|
11342
|
-
const app = new
|
|
11549
|
+
const app = new Hono28();
|
|
11343
11550
|
app.get("/oauth/:provider/start", async (c) => {
|
|
11344
11551
|
const auth = c.get("auth");
|
|
11345
11552
|
if (auth.role !== "admin") return c.json({ error: "admin access required" }, 403);
|
|
@@ -11466,7 +11673,7 @@ function createMcpOAuthRouter() {
|
|
|
11466
11673
|
}
|
|
11467
11674
|
|
|
11468
11675
|
// ../api/src/dashboard/mcp-routes.ts
|
|
11469
|
-
import { Hono as
|
|
11676
|
+
import { Hono as Hono29 } from "hono";
|
|
11470
11677
|
|
|
11471
11678
|
// ../api/src/mcp/transport.ts
|
|
11472
11679
|
var KINDS = ["inherit", "npx", "local", "http", "sse"];
|
|
@@ -11596,7 +11803,7 @@ function bindingsByConnection() {
|
|
|
11596
11803
|
return map;
|
|
11597
11804
|
}
|
|
11598
11805
|
function createMcpRouter() {
|
|
11599
|
-
const app = new
|
|
11806
|
+
const app = new Hono29();
|
|
11600
11807
|
app.get("/providers", async (c) => {
|
|
11601
11808
|
const denied = requireAdmin(c.get("auth"));
|
|
11602
11809
|
if (denied) return c.json({ error: denied }, 403);
|
|
@@ -12126,9 +12333,9 @@ ${transcriptOf(data ?? [])}`
|
|
|
12126
12333
|
}
|
|
12127
12334
|
|
|
12128
12335
|
// ../api/src/dashboard/permission-routes.ts
|
|
12129
|
-
import { Hono as
|
|
12336
|
+
import { Hono as Hono30 } from "hono";
|
|
12130
12337
|
function createPermissionRequestsRouter() {
|
|
12131
|
-
const app = new
|
|
12338
|
+
const app = new Hono30();
|
|
12132
12339
|
app.post("/:id", async (c) => {
|
|
12133
12340
|
const auth = c.get("auth");
|
|
12134
12341
|
if (auth.role !== "admin") return c.json({ error: "only an admin can answer this" }, 403);
|
|
@@ -12158,7 +12365,7 @@ function createPermissionRequestsRouter() {
|
|
|
12158
12365
|
}
|
|
12159
12366
|
|
|
12160
12367
|
// ../api/src/dashboard/channel-greeting.ts
|
|
12161
|
-
import { Hono as
|
|
12368
|
+
import { Hono as Hono31 } from "hono";
|
|
12162
12369
|
function eligible(ch) {
|
|
12163
12370
|
return !!ch && !ch.isDefault && !ch.dmKey && !ch.agentName && !ch.archivedAt;
|
|
12164
12371
|
}
|
|
@@ -12187,7 +12394,7 @@ function introOpening(channelName) {
|
|
|
12187
12394
|
return `Welcome to #${channelName}. I'm reading this project's folder, docs, skills and automations to work out how I can help here. Below you'll find a short intro and a few first steps you can click to try.`;
|
|
12188
12395
|
}
|
|
12189
12396
|
function createChannelGreetingRouter(agent) {
|
|
12190
|
-
const app = new
|
|
12397
|
+
const app = new Hono31();
|
|
12191
12398
|
app.get("/:id/greeting", async (c) => {
|
|
12192
12399
|
const ctx = await resolveAuthContext(c);
|
|
12193
12400
|
const ch = findChannelById(c.req.param("id"));
|
|
@@ -12245,7 +12452,7 @@ async function ensureIntroThread(ch) {
|
|
|
12245
12452
|
}
|
|
12246
12453
|
|
|
12247
12454
|
// ../api/src/dashboard/channel-suggest.ts
|
|
12248
|
-
import { Hono as
|
|
12455
|
+
import { Hono as Hono32 } from "hono";
|
|
12249
12456
|
var CATEGORY_MAX_CHARS = 16;
|
|
12250
12457
|
var CATEGORY_MAX_ITEMS = 30;
|
|
12251
12458
|
var PROMPT_MAX_CHARS = 4e3;
|
|
@@ -12293,7 +12500,7 @@ function parseSuggestion(field, raw) {
|
|
|
12293
12500
|
return items2.length ? items2.slice(0, CATEGORY_MAX_ITEMS).join("\n") : null;
|
|
12294
12501
|
}
|
|
12295
12502
|
function createChannelSuggestRouter(agent) {
|
|
12296
|
-
const router = new
|
|
12503
|
+
const router = new Hono32();
|
|
12297
12504
|
router.post("/:id/suggest", async (c) => {
|
|
12298
12505
|
const channel = findChannel(c.req.param("id"));
|
|
12299
12506
|
if (!channel || !canSeeChannel(channel, c.get("auth"))) {
|
|
@@ -12330,87 +12537,104 @@ function createChannelSuggestRouter(agent) {
|
|
|
12330
12537
|
return router;
|
|
12331
12538
|
}
|
|
12332
12539
|
|
|
12333
|
-
// ../api/src/dashboard/channel-
|
|
12334
|
-
import { Hono as
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
const
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
const
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12540
|
+
// ../api/src/dashboard/channel-destroy-routes.ts
|
|
12541
|
+
import { Hono as Hono33 } from "hono";
|
|
12542
|
+
import { DeleteObjectCommand as DeleteObjectCommand3, ListObjectsV2Command } from "@aws-sdk/client-s3";
|
|
12543
|
+
function createChannelDestroyRouter() {
|
|
12544
|
+
const router = new Hono33();
|
|
12545
|
+
const gate = async (c) => {
|
|
12546
|
+
const auth = await resolveAuthContext(c);
|
|
12547
|
+
if (!auth || auth.role !== "admin" || auth.isSupport) return null;
|
|
12548
|
+
return auth;
|
|
12549
|
+
};
|
|
12550
|
+
const loadChannel = async (id) => {
|
|
12551
|
+
const { data } = await getSupabaseClient().from("channels").select(
|
|
12552
|
+
"id, name, cwd, profile, archived_at, is_default, dm_key, agent_name, external_channel_id"
|
|
12553
|
+
).eq("id", id).maybeSingle();
|
|
12554
|
+
return data && data.profile === getProfile() ? data : null;
|
|
12555
|
+
};
|
|
12556
|
+
const refusal = (ch) => ch.is_default || ch.dm_key || ch.agent_name || ch.id === process.env["SUPPORT_TICKET_CHANNEL_ID"];
|
|
12557
|
+
router.get("/:id/destroy-preview", async (c) => {
|
|
12558
|
+
if (!await gate(c)) return c.json({ error: "workspace admin only" }, 403);
|
|
12559
|
+
const ch = await loadChannel(c.req.param("id"));
|
|
12560
|
+
if (!ch) return c.json({ error: "channel not found" }, 404);
|
|
12561
|
+
const { data, error: error2 } = await getSupabaseClient().rpc("destroy_channel_preview", {
|
|
12562
|
+
p_channel_id: ch.id,
|
|
12563
|
+
p_profile: ch.profile
|
|
12564
|
+
});
|
|
12565
|
+
if (error2) return c.json({ error: error2.message }, 500);
|
|
12566
|
+
return c.json({
|
|
12567
|
+
name: ch.name,
|
|
12568
|
+
cwd: ch.cwd,
|
|
12569
|
+
cwdDisplay: displayCwd(ch.cwd, cachedProfileConfig()?.home),
|
|
12570
|
+
slackBound: !!ch.external_channel_id,
|
|
12571
|
+
counts: data
|
|
12572
|
+
});
|
|
12349
12573
|
});
|
|
12350
|
-
router.
|
|
12351
|
-
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
if (!
|
|
12355
|
-
|
|
12356
|
-
}
|
|
12574
|
+
router.delete("/:id", async (c) => {
|
|
12575
|
+
if (!await gate(c)) return c.json({ error: "workspace admin only" }, 403);
|
|
12576
|
+
const ch = await loadChannel(c.req.param("id"));
|
|
12577
|
+
if (!ch) return c.json({ error: "channel not found" }, 404);
|
|
12578
|
+
if (!ch.archived_at) return c.json({ error: "archive the channel first" }, 409);
|
|
12579
|
+
if (refusal(ch)) return c.json({ error: "this channel cannot be destroyed" }, 400);
|
|
12357
12580
|
const body = await c.req.json().catch(() => ({}));
|
|
12358
|
-
if (body.
|
|
12359
|
-
return c.json({ error: "
|
|
12360
|
-
}
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
membershipId: c.req.param("membershipId"),
|
|
12364
|
-
role: body.role
|
|
12581
|
+
if (typeof body.confirmName !== "string" || body.confirmName.trim() !== ch.name)
|
|
12582
|
+
return c.json({ error: "confirmName does not match" }, 400);
|
|
12583
|
+
const { data, error: error2 } = await getSupabaseClient().rpc("destroy_channel", {
|
|
12584
|
+
p_channel_id: ch.id,
|
|
12585
|
+
p_profile: ch.profile
|
|
12365
12586
|
});
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
|
|
12371
|
-
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12375
|
-
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12382
|
-
|
|
12383
|
-
|
|
12384
|
-
|
|
12385
|
-
const ctx = await resolveAuthContext(c);
|
|
12386
|
-
if (!ctx) return c.json({ error: "workspace access required" }, 403);
|
|
12387
|
-
const channelId = c.req.param("id");
|
|
12388
|
-
if (!await isChannelAdmin(ctx, channelId)) {
|
|
12389
|
-
return c.json({ error: "channel admin access required" }, 403);
|
|
12390
|
-
}
|
|
12391
|
-
return c.json({ memberAccess: await getChannelDocsMemberAccess(channelId) });
|
|
12587
|
+
if (error2) {
|
|
12588
|
+
const status = error2.code === "P0002" ? 404 : error2.code === "55000" ? 409 : error2.code === "22023" ? 400 : 500;
|
|
12589
|
+
return c.json({ error: error2.message }, status);
|
|
12590
|
+
}
|
|
12591
|
+
const {
|
|
12592
|
+
shareIds = [],
|
|
12593
|
+
audioKeys = [],
|
|
12594
|
+
attachmentKeys = [],
|
|
12595
|
+
...deleted
|
|
12596
|
+
} = data;
|
|
12597
|
+
const r2 = await purgeR2(shareIds, [
|
|
12598
|
+
...audioKeys,
|
|
12599
|
+
...attachmentKeys.flatMap(
|
|
12600
|
+
(k) => k.endsWith(".webp") ? [k, k.replace(/\.webp$/, ".thumb.webp")] : [k]
|
|
12601
|
+
)
|
|
12602
|
+
]);
|
|
12603
|
+
await refreshChannelRegistry().catch(() => {
|
|
12604
|
+
});
|
|
12605
|
+
return c.json({ ok: true, deleted, r2 });
|
|
12392
12606
|
});
|
|
12393
|
-
router
|
|
12394
|
-
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12607
|
+
return router;
|
|
12608
|
+
}
|
|
12609
|
+
async function purgeR2(shareIds, keys) {
|
|
12610
|
+
let deleted = 0;
|
|
12611
|
+
let failed2 = 0;
|
|
12612
|
+
const del = async (key) => {
|
|
12613
|
+
try {
|
|
12614
|
+
await getR2Client().send(new DeleteObjectCommand3({ Bucket: getR2Bucket(), Key: key }));
|
|
12615
|
+
deleted++;
|
|
12616
|
+
} catch (err) {
|
|
12617
|
+
failed2++;
|
|
12618
|
+
console.error(`[channel-destroy] R2 delete failed for ${key}:`, err);
|
|
12403
12619
|
}
|
|
12404
|
-
|
|
12405
|
-
|
|
12620
|
+
};
|
|
12621
|
+
for (const id of shareIds) {
|
|
12622
|
+
try {
|
|
12623
|
+
const list = await getR2Client().send(
|
|
12624
|
+
new ListObjectsV2Command({ Bucket: getR2Bucket(), Prefix: `share/${id}/` })
|
|
12625
|
+
);
|
|
12626
|
+
for (const o of list.Contents ?? []) if (o.Key) await del(o.Key);
|
|
12627
|
+
} catch (err) {
|
|
12628
|
+
failed2++;
|
|
12629
|
+
console.error(`[channel-destroy] R2 list failed for share/${id}/:`, err);
|
|
12406
12630
|
}
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
return
|
|
12631
|
+
}
|
|
12632
|
+
for (const key of keys) await del(key);
|
|
12633
|
+
return { deleted, failed: failed2 };
|
|
12410
12634
|
}
|
|
12411
12635
|
|
|
12412
12636
|
// ../api/src/dashboard/memories-routes.ts
|
|
12413
|
-
import { Hono as
|
|
12637
|
+
import { Hono as Hono34 } from "hono";
|
|
12414
12638
|
async function readPatch(c) {
|
|
12415
12639
|
const body = await c.req.json().catch(() => ({}));
|
|
12416
12640
|
const patch = {};
|
|
@@ -12438,7 +12662,7 @@ var requireAgentMemory = async (c, next) => {
|
|
|
12438
12662
|
await next();
|
|
12439
12663
|
};
|
|
12440
12664
|
function createMemoriesRouter() {
|
|
12441
|
-
const router = new
|
|
12665
|
+
const router = new Hono34();
|
|
12442
12666
|
for (const path of [
|
|
12443
12667
|
"/:id/memories",
|
|
12444
12668
|
"/:id/memories/*",
|
|
@@ -12511,7 +12735,7 @@ function createMemoriesRouter() {
|
|
|
12511
12735
|
return router;
|
|
12512
12736
|
}
|
|
12513
12737
|
function createScopedMemoriesRouter() {
|
|
12514
|
-
const router = new
|
|
12738
|
+
const router = new Hono34();
|
|
12515
12739
|
router.use("*", requireAgentMemory);
|
|
12516
12740
|
const workspace = (c) => ({
|
|
12517
12741
|
scope: "workspace",
|
|
@@ -12571,7 +12795,7 @@ function createScopedMemoriesRouter() {
|
|
|
12571
12795
|
}
|
|
12572
12796
|
|
|
12573
12797
|
// ../api/src/dashboard/session-import-routes.ts
|
|
12574
|
-
import { Hono as
|
|
12798
|
+
import { Hono as Hono35 } from "hono";
|
|
12575
12799
|
var MAX_FOLDERS2 = 20;
|
|
12576
12800
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
12577
12801
|
var IMPORT_RANGES = ["all", "7d", "latest5"];
|
|
@@ -12678,7 +12902,7 @@ async function syncSession(agent, channelId, session, author, existing) {
|
|
|
12678
12902
|
return messages.length;
|
|
12679
12903
|
}
|
|
12680
12904
|
function createSessionImportRouter(agent) {
|
|
12681
|
-
const app = new
|
|
12905
|
+
const app = new Hono35();
|
|
12682
12906
|
const scanFolders = async () => {
|
|
12683
12907
|
const scan = await ask(agent, { op: "scan", slug: getProfile() });
|
|
12684
12908
|
return scan && importableFolders(scan.folders, getProfileChannelRegistry());
|
|
@@ -12940,6 +13164,7 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
12940
13164
|
const auth = c.get("auth");
|
|
12941
13165
|
const channels = getProfileChannelRegistry().filter((ch) => canSeeChannel(ch, auth));
|
|
12942
13166
|
const missingCwds = await agent.listMissingCwds?.();
|
|
13167
|
+
const hostHome = cachedProfileConfig()?.home;
|
|
12943
13168
|
const list = channels.map((ch) => ({
|
|
12944
13169
|
id: ch.id,
|
|
12945
13170
|
externalChannelId: ch.externalChannelId,
|
|
@@ -12949,6 +13174,8 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
12949
13174
|
name: ch.dmKey && !ch.agentName ? ch.name.split(", ").filter((h) => h !== auth.handle).join(", ") || ch.name : ch.name,
|
|
12950
13175
|
configured: true,
|
|
12951
13176
|
cwd: ch.cwd,
|
|
13177
|
+
// What the UI shows: never a full absolute path (see displayCwd).
|
|
13178
|
+
cwdDisplay: displayCwd(ch.cwd, hostHome),
|
|
12952
13179
|
// Surfaces a rotted working directory in the sidebar instead of
|
|
12953
13180
|
// waiting for the next @agent mention to fail (see auditChannelCwds).
|
|
12954
13181
|
cwdMissing: missingCwds ? missingCwds.includes(ch.id) : void 0,
|
|
@@ -12986,6 +13213,8 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
12986
13213
|
api.route("/channels", createChannelGreetingRouter(agent));
|
|
12987
13214
|
api.route("/channels", createChannelSuggestRouter(agent));
|
|
12988
13215
|
api.route("/channels", createChannelMembersRouter());
|
|
13216
|
+
api.route("/channels", createChannelAgentRouter());
|
|
13217
|
+
api.route("/channels", createChannelDestroyRouter());
|
|
12989
13218
|
api.route("/channels", createMemoriesRouter());
|
|
12990
13219
|
api.route("/memories", createScopedMemoriesRouter());
|
|
12991
13220
|
api.route("/docs", createDocShareListRouter());
|
|
@@ -13109,6 +13338,7 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
13109
13338
|
api.route("/tts", createTtsRouter());
|
|
13110
13339
|
api.route("/feature-flags", createFeatureFlagsRouter());
|
|
13111
13340
|
api.route("/domain", createDomainRouter());
|
|
13341
|
+
api.route("/support-access", createSupportGrantRouter());
|
|
13112
13342
|
api.route("/members", createMembersRouter());
|
|
13113
13343
|
api.route("/notifications", createNotificationsRouter());
|
|
13114
13344
|
api.route("/push", createPushRouter());
|
|
@@ -13141,6 +13371,18 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
13141
13371
|
await setWorkspacePermissionMode(auth.workspaceId, body.permissionMode);
|
|
13142
13372
|
return c.json({ permissionMode: body.permissionMode });
|
|
13143
13373
|
});
|
|
13374
|
+
api.put("/default-effort", async (c) => {
|
|
13375
|
+
const auth = c.get("auth");
|
|
13376
|
+
if (auth.role !== "admin") return c.json({ error: "admin access required" }, 403);
|
|
13377
|
+
const { defaultEffort: raw } = await c.req.json().catch(() => ({}));
|
|
13378
|
+
const value = raw === null || raw === "" ? null : typeof raw === "string" && isEffort(raw) ? raw : void 0;
|
|
13379
|
+
if (value === void 0) {
|
|
13380
|
+
return c.json({ error: "defaultEffort must be low, medium, high, xhigh, max or null" }, 400);
|
|
13381
|
+
}
|
|
13382
|
+
await setWorkspaceAgentDefaults(auth.workspaceId, { defaultEffort: value });
|
|
13383
|
+
await refreshChannelRegistry();
|
|
13384
|
+
return c.json({ defaultEffort: value });
|
|
13385
|
+
});
|
|
13144
13386
|
api.get("/own-persona", async (c) => {
|
|
13145
13387
|
const auth = c.get("auth");
|
|
13146
13388
|
return c.json({ enabled: await getWorkspaceOwnPersona(auth.workspaceId) });
|
|
@@ -13303,7 +13545,7 @@ function registerDataRoutes(api, agent = {}) {
|
|
|
13303
13545
|
// ../api/src/dashboard/device-auth-routes.ts
|
|
13304
13546
|
import { verify } from "crypto";
|
|
13305
13547
|
import { getConnInfo } from "@hono/node-server/conninfo";
|
|
13306
|
-
import { Hono as
|
|
13548
|
+
import { Hono as Hono36 } from "hono";
|
|
13307
13549
|
var UUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
13308
13550
|
function cleanText(value, max) {
|
|
13309
13551
|
if (typeof value !== "string") return null;
|
|
@@ -13351,7 +13593,7 @@ async function boundWorkspaceIds(publicKey, userId) {
|
|
|
13351
13593
|
return new Set(existing ? (await listDeviceWorkspaces(existing)).map((w) => w.id) : []);
|
|
13352
13594
|
}
|
|
13353
13595
|
function createDeviceAuthRouter() {
|
|
13354
|
-
const app = new
|
|
13596
|
+
const app = new Hono36();
|
|
13355
13597
|
app.post("/code", async (c) => {
|
|
13356
13598
|
const body = await readBody(c);
|
|
13357
13599
|
const publicKey = typeof body["public_key"] === "string" ? body["public_key"] : "";
|
|
@@ -13670,7 +13912,7 @@ var workspaceRef = () => ({ kind: "workspace" });
|
|
|
13670
13912
|
var channelRef = (c) => ({ kind: "channel", channelId: c.req.param("id") });
|
|
13671
13913
|
|
|
13672
13914
|
// ../api/src/dashboard/output-styles-routes.ts
|
|
13673
|
-
import { Hono as
|
|
13915
|
+
import { Hono as Hono37 } from "hono";
|
|
13674
13916
|
function requireAdmin3(auth) {
|
|
13675
13917
|
return auth?.role === "admin" ? null : "admin access required";
|
|
13676
13918
|
}
|
|
@@ -13690,7 +13932,7 @@ function failure(c, err) {
|
|
|
13690
13932
|
return c.json({ error: message }, err instanceof OutputStyleConflictError ? 409 : 500);
|
|
13691
13933
|
}
|
|
13692
13934
|
function createOutputStylesRouter() {
|
|
13693
|
-
const app = new
|
|
13935
|
+
const app = new Hono37();
|
|
13694
13936
|
app.get("/", (c) => {
|
|
13695
13937
|
const auth = c.get("auth");
|
|
13696
13938
|
const denied = requireAdmin3(auth);
|
|
@@ -13782,7 +14024,7 @@ function createOutputStylesRouter() {
|
|
|
13782
14024
|
return app;
|
|
13783
14025
|
}
|
|
13784
14026
|
async function handleOutputStylesRequest(req) {
|
|
13785
|
-
const app = new
|
|
14027
|
+
const app = new Hono37();
|
|
13786
14028
|
app.use("*", async (c, next) => {
|
|
13787
14029
|
c.set("auth", { role: "admin" });
|
|
13788
14030
|
await next();
|
|
@@ -13821,7 +14063,7 @@ async function viewerProfile(c, known) {
|
|
|
13821
14063
|
return candidates[0]?.w.slug ?? null;
|
|
13822
14064
|
}
|
|
13823
14065
|
function createGatedRouter(agent, register) {
|
|
13824
|
-
const api = new
|
|
14066
|
+
const api = new Hono38();
|
|
13825
14067
|
api.use("*", async (c, next) => {
|
|
13826
14068
|
const known = await listKnownWorkspaces();
|
|
13827
14069
|
const fromHost = profileFromHost(trustedHost(c), known);
|
|
@@ -13873,7 +14115,7 @@ import sharp5 from "sharp";
|
|
|
13873
14115
|
|
|
13874
14116
|
// src/dashboard/channels-routes.ts
|
|
13875
14117
|
import { existsSync as existsSync19, mkdirSync as mkdirSync8 } from "fs";
|
|
13876
|
-
import { Hono as
|
|
14118
|
+
import { Hono as Hono39 } from "hono";
|
|
13877
14119
|
function coerceAccess(raw) {
|
|
13878
14120
|
if (raw === "open" || raw === "*" || raw === "all") return raw;
|
|
13879
14121
|
if (Array.isArray(raw) && raw.every((v) => typeof v === "string")) return raw;
|
|
@@ -13945,7 +14187,7 @@ function toResponse3(channel) {
|
|
|
13945
14187
|
};
|
|
13946
14188
|
}
|
|
13947
14189
|
function createChannelWriteRouter() {
|
|
13948
|
-
const app = new
|
|
14190
|
+
const app = new Hono39();
|
|
13949
14191
|
app.post("/", async (c) => {
|
|
13950
14192
|
const body = await c.req.json().catch(() => ({}));
|
|
13951
14193
|
const name = typeof body["name"] === "string" ? body["name"].trim() : "";
|
|
@@ -14074,7 +14316,7 @@ function createChannelWriteRouter() {
|
|
|
14074
14316
|
// src/dashboard/skills-routes-host.ts
|
|
14075
14317
|
import { existsSync as existsSync20, statSync as statSync4 } from "fs";
|
|
14076
14318
|
import { dirname as dirname7 } from "path";
|
|
14077
|
-
import { Hono as
|
|
14319
|
+
import { Hono as Hono40 } from "hono";
|
|
14078
14320
|
function workspaceScope() {
|
|
14079
14321
|
const claudeConfigDir = profileClaudeConfigDir();
|
|
14080
14322
|
const cwd = defaultClaudeCwd();
|
|
@@ -14180,12 +14422,12 @@ var diskBackend = {
|
|
|
14180
14422
|
write: writeSkillAndSync
|
|
14181
14423
|
};
|
|
14182
14424
|
function createWorkspaceSkillsRouter() {
|
|
14183
|
-
const app = new
|
|
14425
|
+
const app = new Hono40();
|
|
14184
14426
|
mountSkillRoutes(app, "/skills", workspaceRef, diskBackend);
|
|
14185
14427
|
return app;
|
|
14186
14428
|
}
|
|
14187
14429
|
function createChannelSkillsRouter() {
|
|
14188
|
-
const app = new
|
|
14430
|
+
const app = new Hono40();
|
|
14189
14431
|
mountSkillRoutes(app, "/:id/skill-files", channelRef, diskBackend);
|
|
14190
14432
|
return app;
|
|
14191
14433
|
}
|
|
@@ -14317,7 +14559,7 @@ import { randomUUID as randomUUID4 } from "crypto";
|
|
|
14317
14559
|
import { chmodSync, existsSync as existsSync22, mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync8 } from "fs";
|
|
14318
14560
|
import { createRequire } from "module";
|
|
14319
14561
|
import { dirname as dirname8, join as join14 } from "path";
|
|
14320
|
-
import { Hono as
|
|
14562
|
+
import { Hono as Hono41 } from "hono";
|
|
14321
14563
|
var SESSION_TTL_MS = 10 * 6e4;
|
|
14322
14564
|
var URL_WAIT_MS = 3e4;
|
|
14323
14565
|
var TOKEN_WAIT_MS = 6e4;
|
|
@@ -14476,7 +14718,7 @@ function failure2(c, err) {
|
|
|
14476
14718
|
return c.json({ error: err.message }, 500);
|
|
14477
14719
|
}
|
|
14478
14720
|
function createProviderLoginRouter() {
|
|
14479
|
-
const app = new
|
|
14721
|
+
const app = new Hono41();
|
|
14480
14722
|
app.use("*", async (c, next) => {
|
|
14481
14723
|
const denied = requireAdmin4(c.get("auth"));
|
|
14482
14724
|
if (denied) return c.json({ error: denied }, 403);
|
|
@@ -14520,7 +14762,7 @@ function createProviderLoginRouter() {
|
|
|
14520
14762
|
return app;
|
|
14521
14763
|
}
|
|
14522
14764
|
async function handleProviderLoginRequest(req) {
|
|
14523
|
-
const app = new
|
|
14765
|
+
const app = new Hono41();
|
|
14524
14766
|
app.use("*", async (c, next) => {
|
|
14525
14767
|
c.set("auth", { role: "admin" });
|
|
14526
14768
|
await next();
|
|
@@ -14675,6 +14917,7 @@ function createHostApiRouter(agent = {}) {
|
|
|
14675
14917
|
}
|
|
14676
14918
|
|
|
14677
14919
|
// src/dashboard/agent-bridge-host.ts
|
|
14920
|
+
import { homedir as homedir9 } from "os";
|
|
14678
14921
|
import { sign as signRaw, timingSafeEqual } from "crypto";
|
|
14679
14922
|
import { existsSync as existsSync25, readFileSync as readFileSync19 } from "fs";
|
|
14680
14923
|
import dotenv2 from "dotenv";
|
|
@@ -14923,13 +15166,13 @@ function handleSessionImportRequest(req) {
|
|
|
14923
15166
|
}
|
|
14924
15167
|
|
|
14925
15168
|
// src/dashboard/docs-relay-host.ts
|
|
14926
|
-
import { Hono as
|
|
15169
|
+
import { Hono as Hono42 } from "hono";
|
|
14927
15170
|
var RETURNED_HEADERS = ["content-type", "content-disposition", "content-security-policy", "cache-control"];
|
|
14928
15171
|
async function handleDocsRequest(req) {
|
|
14929
15172
|
return runRelayed(req, (app) => app.route("/channels", createDocsRouter({ gate: async (_c, next) => next() })));
|
|
14930
15173
|
}
|
|
14931
15174
|
async function runRelayed(req, register) {
|
|
14932
|
-
const app = new
|
|
15175
|
+
const app = new Hono42();
|
|
14933
15176
|
app.use("*", async (c, next) => {
|
|
14934
15177
|
c.set("auth", req.auth);
|
|
14935
15178
|
await next();
|
|
@@ -15112,7 +15355,8 @@ function buildHostConfigSnapshot() {
|
|
|
15112
15355
|
env: existsSync25(paths.CONFIG_FILE) ? dotenv2.parse(readFileSync19(paths.CONFIG_FILE, "utf-8")) : {},
|
|
15113
15356
|
// Only a model someone actually saved: before that it is just the Claude
|
|
15114
15357
|
// default, which would show the wrong agent in admin for a Codex user.
|
|
15115
|
-
agentModel: existsSync25(paths.DASHBOARD_SETTINGS_FILE) ? loadDashboardSettings().agent : void 0
|
|
15358
|
+
agentModel: existsSync25(paths.DASHBOARD_SETTINGS_FILE) ? loadDashboardSettings().agent : void 0,
|
|
15359
|
+
home: homedir9()
|
|
15116
15360
|
}));
|
|
15117
15361
|
}
|
|
15118
15362
|
return snapshot2;
|
|
@@ -15314,7 +15558,7 @@ import { join as join17 } from "path";
|
|
|
15314
15558
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
15315
15559
|
|
|
15316
15560
|
// ../api/src/dashboard/app-icon-routes.ts
|
|
15317
|
-
import { Hono as
|
|
15561
|
+
import { Hono as Hono43 } from "hono";
|
|
15318
15562
|
var MANIFEST = {
|
|
15319
15563
|
id: "/",
|
|
15320
15564
|
name: "Flyspace",
|
|
@@ -15348,7 +15592,7 @@ async function resolvedProfileHost(c) {
|
|
|
15348
15592
|
return profileFromHost(trustedHost(c), known);
|
|
15349
15593
|
}
|
|
15350
15594
|
function createAppIconRouter() {
|
|
15351
|
-
const app = new
|
|
15595
|
+
const app = new Hono43();
|
|
15352
15596
|
app.get("/manifest.json", (c) => c.json(MANIFEST));
|
|
15353
15597
|
app.get("/icons/app/:profile/:file", async (c) => {
|
|
15354
15598
|
const profile = c.req.param("profile");
|
|
@@ -15934,6 +16178,7 @@ async function runDesktopCmd(args) {
|
|
|
15934
16178
|
|
|
15935
16179
|
// src/cli.ts
|
|
15936
16180
|
import { join as join20 } from "path";
|
|
16181
|
+
import { existsSync as existsSync29, readdirSync as readdirSync5 } from "fs";
|
|
15937
16182
|
var home = flyspaceHome();
|
|
15938
16183
|
if (home) {
|
|
15939
16184
|
const bin = join20(home, "bin");
|
|
@@ -15992,12 +16237,27 @@ function extractProfileFlag(argv) {
|
|
|
15992
16237
|
}
|
|
15993
16238
|
return { profile, args };
|
|
15994
16239
|
}
|
|
16240
|
+
function soleNamedProfile() {
|
|
16241
|
+
if (existsSync29(paths.CONFIG_FILE)) return void 0;
|
|
16242
|
+
let names;
|
|
16243
|
+
try {
|
|
16244
|
+
names = readdirSync5(paths.PROFILES_DIR).filter(
|
|
16245
|
+
(n) => existsSync29(join20(paths.PROFILES_DIR, n, "config.env"))
|
|
16246
|
+
);
|
|
16247
|
+
} catch {
|
|
16248
|
+
return void 0;
|
|
16249
|
+
}
|
|
16250
|
+
return names.length === 1 ? names[0] : void 0;
|
|
16251
|
+
}
|
|
15995
16252
|
async function main() {
|
|
15996
16253
|
useDirectSupabase();
|
|
15997
16254
|
useLocalCache();
|
|
15998
16255
|
const { profile, args } = extractProfileFlag(process.argv.slice(2));
|
|
15999
16256
|
if (profile) {
|
|
16000
16257
|
process.env["FLYSPACE_WORKSPACE"] = profile;
|
|
16258
|
+
} else if (!process.env["FLYSPACE_WORKSPACE"]) {
|
|
16259
|
+
const sole = soleNamedProfile();
|
|
16260
|
+
if (sole) process.env["FLYSPACE_WORKSPACE"] = sole;
|
|
16001
16261
|
}
|
|
16002
16262
|
getProfile();
|
|
16003
16263
|
const command = args[0];
|
|
@@ -16086,7 +16346,7 @@ async function main() {
|
|
|
16086
16346
|
break;
|
|
16087
16347
|
case "-v":
|
|
16088
16348
|
case "--version":
|
|
16089
|
-
printRaw("0.1.
|
|
16349
|
+
printRaw("0.1.66");
|
|
16090
16350
|
break;
|
|
16091
16351
|
case "-h":
|
|
16092
16352
|
case "--help":
|