flyspace-cli 0.1.58 → 0.1.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import { createRequire as __flyspaceCreateRequire } from 'node:module';
3
3
  const require = __flyspaceCreateRequire(import.meta.url);
4
4
  import {
5
- AuthApiError,
6
5
  AutomationManager,
7
6
  BOT_DM_KEY,
8
7
  BOT_LABEL,
@@ -11,30 +10,24 @@ import {
11
10
  BUILT_IN_OUTPUT_STYLES,
12
11
  CLI_VERSION,
13
12
  ChatAgent,
14
- DEFAULT_API_URL,
15
13
  DEFAULT_TIMEZONE,
16
14
  DocShareSlugTakenError,
17
15
  HANDLE_PATTERN,
18
16
  HandleTakenError,
19
17
  InvalidTransferError,
20
- LOCAL_DB_PATH,
21
18
  LastAdminError,
22
19
  MEMORY_TYPES,
23
20
  OutputStyleConflictError,
24
21
  PLATE,
25
22
  SKIP_SUBTYPES,
26
- SLACK_ENV,
27
23
  SUPPORT_AVATAR_URL,
28
24
  TRANSLATION_LANGUAGES,
29
25
  TRIAL_DAYS,
30
26
  UsageStore,
31
- acquireHostLock,
32
27
  agentViewer,
33
- apiUrl,
34
28
  authorFor,
35
29
  blockToFallbackText,
36
30
  bodyTextFor,
37
- boundWorkspaces,
38
31
  buildAuthorizeUrl,
39
32
  buildAutoTitle,
40
33
  cachedProfileConfig,
@@ -42,7 +35,6 @@ import {
42
35
  channelSkillsDir,
43
36
  claudeAuthFailed,
44
37
  clearClaudeAuthFailed,
45
- clearLocalAuth,
46
38
  clientKey,
47
39
  codexAuthAvailable,
48
40
  consumeOAuthState,
@@ -50,7 +42,6 @@ import {
50
42
  createDocShare,
51
43
  createDocsRouter,
52
44
  createFeatureFlagsRouter,
53
- createHostDbClient,
54
45
  createMembership,
55
46
  createOAuthState,
56
47
  createOutputStyle,
@@ -62,7 +53,6 @@ import {
62
53
  createStateToken,
63
54
  createTtsRouter,
64
55
  createWorkspace,
65
- credentialsPath,
66
56
  crossOriginShell,
67
57
  defaultClaudeCwd,
68
58
  defaultEffort,
@@ -78,25 +68,21 @@ import {
78
68
  deleteWorkspaceDomain,
79
69
  deriveConnectionSlug,
80
70
  detectSourceLanguage,
81
- deviceKeyPath,
82
71
  displayNameFor,
83
72
  dropShareAudio,
84
73
  dropShareLangAudioKeys,
85
74
  effectiveModel,
86
- ensureDeviceKey,
87
75
  ensureUsersCached,
88
76
  escalateToHuman,
89
77
  exchangeCode,
90
78
  explainCost,
91
79
  extractCategories,
92
80
  extractTitle,
93
- fetchWhoAmI,
94
81
  filterReadableDocsChannels,
95
82
  findDocShareBySource,
96
83
  findOwningProfile,
97
84
  findSkillDetail,
98
85
  flatDocs,
99
- getAccessToken,
100
86
  getAgentPaused,
101
87
  getAllowGuestAccess,
102
88
  getChannelDocsMemberAccess,
@@ -119,9 +105,6 @@ import {
119
105
  getWorkspaceOwnPersona,
120
106
  getWorkspacePermissionMode,
121
107
  getWorkspacePlanStatus,
122
- handleAttachmentUrlResult,
123
- handleHostDbResult,
124
- handleShouldRespondResult,
125
108
  handleSupportMention,
126
109
  highlightLanguageOf,
127
110
  insertMcpConnection,
@@ -165,11 +148,8 @@ import {
165
148
  loadAutomations,
166
149
  loadBotIdentity,
167
150
  loadChatAgentConfig,
168
- loadConfig,
169
- loadCredentials,
170
151
  loadDashboardSettings,
171
152
  loadEffectiveAutomations,
172
- loadEnvFiles,
173
153
  loadFullDashboardSettings,
174
154
  loadWorkspaceBranding,
175
155
  loadWorkspacePrompt,
@@ -181,15 +161,12 @@ import {
181
161
  mentionedUserIds,
182
162
  onboardingPending,
183
163
  pinnedClaudeConfigDir,
184
- pollDeviceToken,
185
164
  profileClaudeConfigDir,
186
165
  profileEnv,
187
166
  profileFromHost,
188
167
  profileOauthToken,
189
168
  promoteChannelMemory,
190
- publishHostEndpoint,
191
169
  queueShareAudio,
192
- readHostEndpoint,
193
170
  readOAuthClient,
194
171
  readSkillFile,
195
172
  recentRunsForWorkspace,
@@ -198,10 +175,7 @@ import {
198
175
  refreshUserCache,
199
176
  removeChannelMember,
200
177
  renderAppIcon,
201
- requestDeviceCode,
202
- requestHostDb,
203
178
  requireDocsAccess,
204
- requireSlackBotToken,
205
179
  resetWorkspaceOnboarding,
206
180
  resetWorkspacePrompt,
207
181
  resolveAuthContext,
@@ -212,7 +186,6 @@ import {
212
186
  resolveRateCard,
213
187
  resolveRawPath,
214
188
  resolveUserId,
215
- revokeDevice,
216
189
  revokeDocShare,
217
190
  rowToMemory,
218
191
  runAutomation,
@@ -223,7 +196,6 @@ import {
223
196
  saveAgentProfile,
224
197
  saveBotIdentity,
225
198
  saveChannelMemory,
226
- saveCredentials,
227
199
  saveDashboardSettings,
228
200
  saveMemory,
229
201
  saveWorkspaceBranding,
@@ -236,7 +208,6 @@ import {
236
208
  setChannelDocsMemberAccess,
237
209
  setDocShareSlug,
238
210
  setDocShareTags,
239
- setHostDbSender,
240
211
  setMcpConnectionApiKey,
241
212
  setMembershipHandle,
242
213
  setMemoryAutoPaused,
@@ -247,7 +218,6 @@ import {
247
218
  setWorkspaceOwnPersona,
248
219
  setWorkspacePermissionMode,
249
220
  setWorkspaceStripeSubscription,
250
- slackConfigured,
251
221
  slackMrkdwnToMarkdown,
252
222
  startAutomationRegistryPolling,
253
223
  startServer,
@@ -273,13 +243,12 @@ import {
273
243
  usageLimitedModels,
274
244
  usageLimitedUntil,
275
245
  useDirectSupabase,
276
- useHostDbWithoutCredentials,
277
246
  useLocalCache,
278
247
  validateMemoryInput,
279
248
  workspaceHostname,
280
249
  workspaceSkillsDir,
281
250
  writeSkillFile
282
- } from "./chunk-TAUF3WGB.js";
251
+ } from "./chunk-SIR6PTDT.js";
283
252
  import {
284
253
  canReadThread,
285
254
  firstReplyBody,
@@ -288,53 +257,89 @@ import {
288
257
  listThreads,
289
258
  moveThreadFully,
290
259
  resolveChannel,
291
- resolveThreadOwner
292
- } from "./chunk-44WHW7NK.js";
260
+ resolveThreadOwner,
261
+ runDocsCmd
262
+ } from "./chunk-PXZUNZ4S.js";
293
263
  import {
294
264
  AGENT_AUTHOR,
265
+ AuthApiError,
295
266
  ChannelCwdError,
267
+ DEFAULT_API_URL,
296
268
  DEFAULT_PROFILE,
297
269
  DefaultChannelError,
270
+ LOCAL_DB_PATH,
271
+ LOCAL_DOC_SHARE_PATH,
298
272
  SCRATCH_PREFIX,
273
+ SLACK_ENV,
299
274
  SessionStore,
275
+ acquireHostLock,
276
+ apiUrl,
300
277
  auditChannelCwds,
278
+ boundWorkspaces,
301
279
  canSeeChannel,
280
+ clearLocalAuth,
302
281
  createChannel,
282
+ createHostDbClient,
283
+ credentialsPath,
303
284
  databaseReachable,
285
+ deviceKeyPath,
304
286
  ensureAgentDmChannel,
287
+ ensureDeviceKey,
305
288
  ensureDirs,
306
289
  ensureGeneralChannel,
307
290
  ensureMemberDmChannel,
308
291
  expandPath,
292
+ fetchWhoAmI,
309
293
  findChannel,
310
294
  findChannelById,
295
+ getAccessToken,
311
296
  getChannelRegistry,
312
297
  getProfile,
313
298
  getProfileChannelRegistry,
314
299
  getR2Bucket,
315
300
  getR2Client,
316
301
  getSupabaseClient,
302
+ handleAttachmentUrlResult,
303
+ handleDocShareResult,
304
+ handleHostDbResult,
305
+ handlePluginSvgResult,
306
+ handleShouldRespondResult,
317
307
  isCwdUsable,
318
308
  isEffort,
319
309
  isHumanAuthor,
320
310
  isLogicalCwd,
321
311
  isPermissionMode,
322
312
  isUnderLogicalRoot,
313
+ loadConfig,
314
+ loadCredentials,
315
+ loadEnvFiles,
323
316
  markChannelGreeted,
324
317
  paths,
318
+ pollDeviceToken,
325
319
  postToDashboardChannel,
320
+ publishHostEndpoint,
321
+ readHostEndpoint,
326
322
  refreshChannelRegistry,
323
+ requestDeviceCode,
324
+ requestDocShare,
325
+ requestHostDb,
326
+ requireSlackBotToken,
327
327
  resolveCwd,
328
328
  resolveDashboardChannelId,
329
+ revokeDevice,
329
330
  runWithProfile,
331
+ saveCredentials,
332
+ setHostDbSender,
330
333
  setSupabaseClient,
334
+ slackConfigured,
331
335
  startChannelRegistryPolling,
332
336
  sumR2PrefixBytes,
333
337
  syncPostToDashboard,
334
338
  updateChannelById,
335
339
  updateChannelsMcpConnections,
340
+ useHostDbWithoutCredentials,
336
341
  warnOnBrokenChannelCwds
337
- } from "./chunk-XACRG7BO.js";
342
+ } from "./chunk-XYS7SVWC.js";
338
343
 
339
344
  // ../core/src/logger.ts
340
345
  var ALREADY_STAMPED = /^\[\d{4}-\d{2}-\d{2}T/;
@@ -2191,7 +2196,7 @@ function npmEnv(target) {
2191
2196
  return nodeBin ? { ...process.env, PATH: `${nodeBin}:${process.env.PATH ?? ""}` } : process.env;
2192
2197
  }
2193
2198
  async function runUpgrade() {
2194
- const current = "0.1.58";
2199
+ const current = "0.1.60";
2195
2200
  console.log(`Current version: ${current}`);
2196
2201
  console.log("Checking for updates...\n");
2197
2202
  try {
@@ -6103,7 +6108,7 @@ Usage: flyspace mcp <server>
6103
6108
  Servers:
6104
6109
  threads Search, read, and write this workspace's chat threads
6105
6110
  (search_threads, read_thread, list_channels, create_thread,
6106
- post_reply, move_thread)
6111
+ post_reply, move_thread, share_doc)
6107
6112
 
6108
6113
  Try it by hand (type a JSON-RPC line, or pipe one in):
6109
6114
  flyspace mcp threads
@@ -6119,7 +6124,7 @@ async function runMcpCmd(args) {
6119
6124
  useHostDbWithoutCredentials();
6120
6125
  switch (server) {
6121
6126
  case "threads": {
6122
- const { startThreadsServer } = await import("./threads-I52LSA5X.js");
6127
+ const { startThreadsServer } = await import("./threads-QQRWT3OM.js");
6123
6128
  await startThreadsServer();
6124
6129
  return;
6125
6130
  }
@@ -6536,7 +6541,7 @@ async function userEmail(userId) {
6536
6541
  }
6537
6542
 
6538
6543
  // ../api/src/dashboard/agent-bridge-data.ts
6539
- import { randomBytes as randomBytes4, randomUUID as randomUUID2, verify as verifyRaw } from "crypto";
6544
+ import { randomBytes as randomBytes5, randomUUID as randomUUID2, verify as verifyRaw } from "crypto";
6540
6545
  import { WebSocket, WebSocketServer } from "ws";
6541
6546
 
6542
6547
  // ../api/src/dashboard/host-identity.ts
@@ -6556,7 +6561,7 @@ function loadHostPrivateKey(path = hostPrivateKeyPath()) {
6556
6561
  }
6557
6562
 
6558
6563
  // ../api/src/dashboard/uploads-routes.ts
6559
- import { randomUUID } from "crypto";
6564
+ import { createHash as createHash3, randomUUID } from "crypto";
6560
6565
  import { Hono as Hono5 } from "hono";
6561
6566
  import sharp2 from "sharp";
6562
6567
  import { PutObjectCommand, GetObjectCommand as GetObjectCommand2 } from "@aws-sdk/client-s3";
@@ -6564,6 +6569,7 @@ import { getSignedUrl as getSignedUrl2 } from "@aws-sdk/s3-request-presigner";
6564
6569
  var MAX_FILE_BYTES = 10 * 1024 * 1024;
6565
6570
  var PRESIGN_TTL_SECONDS = 300;
6566
6571
  var KEY_PREFIX = "chat";
6572
+ var PLUGIN_UI_PREFIX = "plugin-ui";
6567
6573
  var RESIZABLE = /* @__PURE__ */ new Set(["image/jpeg", "image/png", "image/webp", "image/avif"]);
6568
6574
  var FULL_EDGE = 2560;
6569
6575
  var THUMB_EDGE = 480;
@@ -6571,7 +6577,8 @@ var WEBP_QUALITY = 80;
6571
6577
  function toWebp(input2, edge) {
6572
6578
  return sharp2(input2).rotate().resize({ width: edge, height: edge, fit: "inside", withoutEnlargement: true }).webp({ quality: WEBP_QUALITY }).toBuffer();
6573
6579
  }
6574
- var READABLE_PREFIXES = [KEY_PREFIX, SCRATCH_PREFIX];
6580
+ var READABLE_PREFIXES = [KEY_PREFIX, SCRATCH_PREFIX, PLUGIN_UI_PREFIX];
6581
+ var MAX_PLUGIN_SVG_BYTES = 1024 * 1024;
6575
6582
  function sanitizeFilename(name) {
6576
6583
  const cleaned = name.replace(/[/\\]/g, "_").replace(/\s+/g, "-").replace(/[^\w.-]/g, "").trim();
6577
6584
  return (cleaned || "file").slice(-100);
@@ -6634,6 +6641,187 @@ function createUploadsRouter() {
6634
6641
  return app;
6635
6642
  }
6636
6643
 
6644
+ // ../api/src/dashboard/doc-share-publish.ts
6645
+ import { randomBytes as randomBytes4 } from "crypto";
6646
+ import { CopyObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-sdk/client-s3";
6647
+
6648
+ // ../api/src/dashboard/bridge-types.ts
6649
+ var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
6650
+
6651
+ // ../api/src/dashboard/doc-share-features.ts
6652
+ import { DeleteObjectCommand } from "@aws-sdk/client-s3";
6653
+ var DEFAULT_FEATURES = {
6654
+ audioEnabled: false,
6655
+ askEnabled: true,
6656
+ socialEnabled: false,
6657
+ brandingEnabled: true,
6658
+ translationEnabled: false,
6659
+ translationLangs: []
6660
+ };
6661
+ var HTML_FEATURES = {
6662
+ audioEnabled: false,
6663
+ askEnabled: false,
6664
+ socialEnabled: false,
6665
+ brandingEnabled: false,
6666
+ translationEnabled: false,
6667
+ translationLangs: []
6668
+ };
6669
+ function resolveFeatures(requested, existing) {
6670
+ const base = existing ?? DEFAULT_FEATURES;
6671
+ return {
6672
+ audioEnabled: requested?.audio ?? base.audioEnabled,
6673
+ askEnabled: requested?.ask ?? base.askEnabled,
6674
+ socialEnabled: requested?.social ?? base.socialEnabled,
6675
+ brandingEnabled: requested?.branding ?? base.brandingEnabled,
6676
+ translationEnabled: requested?.translation ?? base.translationEnabled,
6677
+ // Replaced wholesale, not merged: the allowlist IS the answer to "which
6678
+ // languages does this link offer", and a merge would make removing one
6679
+ // impossible.
6680
+ translationLangs: requested?.translationLangs ?? base.translationLangs
6681
+ };
6682
+ }
6683
+ async function deleteShareAssets(keys) {
6684
+ const client2 = getR2Client();
6685
+ const bucket = getR2Bucket();
6686
+ for (const key of keys) {
6687
+ try {
6688
+ await client2.send(new DeleteObjectCommand({ Bucket: bucket, Key: key }));
6689
+ } catch {
6690
+ }
6691
+ }
6692
+ }
6693
+ async function updateShareFeatures(share, requested) {
6694
+ if (share.kind === "html") return share;
6695
+ if (share.kind === "excalidraw") {
6696
+ if (requested.branding === void 0) return share;
6697
+ return updateDocShareFeatures(share.id, { ...share, brandingEnabled: requested.branding });
6698
+ }
6699
+ const features = resolveFeatures(requested, share);
6700
+ const updated = await updateDocShareFeatures(share.id, features);
6701
+ if (!updated) return null;
6702
+ if (features.audioEnabled) void queueShareAudio(updated);
6703
+ else if (share.audioEnabled) await dropShareAudio(share);
6704
+ return updated;
6705
+ }
6706
+
6707
+ // ../api/src/dashboard/doc-share-publish.ts
6708
+ var SHARE_KEY_PREFIX = "share";
6709
+ function generateShareId() {
6710
+ return randomBytes4(9).toString("base64url");
6711
+ }
6712
+ async function publishDocShare(input2, readBundle) {
6713
+ const bundle = await readBundle({ channelId: input2.channelId, cwd: input2.cwd, sourcePath: input2.sourcePath });
6714
+ if (bundle.status !== "ok") return bundle;
6715
+ const existing = await findDocShareBySource(input2.workspaceId, input2.channelId, input2.sourcePath);
6716
+ const shareId = existing?.id ?? generateShareId();
6717
+ const client2 = getR2Client();
6718
+ const bucket = getR2Bucket();
6719
+ const assetKeys = [];
6720
+ for (const asset of bundle.assets) {
6721
+ const key = `${SHARE_KEY_PREFIX}/${shareId}/${asset.name}`;
6722
+ if ("copyFrom" in asset) {
6723
+ await client2.send(
6724
+ new CopyObjectCommand({
6725
+ Bucket: bucket,
6726
+ Key: key,
6727
+ CopySource: `${bucket}/${asset.copyFrom}`.split("/").map(encodeURIComponent).join("/")
6728
+ })
6729
+ );
6730
+ } else {
6731
+ await client2.send(
6732
+ new PutObjectCommand2({
6733
+ Bucket: bucket,
6734
+ Key: key,
6735
+ Body: Buffer.from(asset.data, "base64"),
6736
+ ContentType: asset.contentType
6737
+ })
6738
+ );
6739
+ }
6740
+ assetKeys.push(key);
6741
+ }
6742
+ const built = {
6743
+ kind: bundle.kind,
6744
+ title: bundle.title,
6745
+ content: bundle.content.split(SHARE_ASSET_PLACEHOLDER).join(`/share/${shareId}/assets/`),
6746
+ assetKeys
6747
+ };
6748
+ const html = built.kind !== "markdown";
6749
+ const features = built.kind === "excalidraw" ? {
6750
+ ...HTML_FEATURES,
6751
+ brandingEnabled: resolveFeatures(input2.features, existing).brandingEnabled
6752
+ } : html ? HTML_FEATURES : resolveFeatures(input2.features, existing);
6753
+ const snapshot2 = {
6754
+ ...built,
6755
+ sourceLang: html ? null : await detectSourceLanguage(built.title, built.content)
6756
+ };
6757
+ const slug = input2.slug === void 0 ? existing?.slug ?? null : input2.slug;
6758
+ if (existing) {
6759
+ if (slug !== (existing.slug ?? null)) {
6760
+ const renamed = await setDocShareSlug(existing.id, slug);
6761
+ if (!renamed) return { status: "not-found" };
6762
+ }
6763
+ const share2 = await updateDocShareSnapshot(existing.id, snapshot2, features);
6764
+ const stale = existing.assetKeys.filter((key) => !snapshot2.assetKeys.includes(key));
6765
+ await deleteShareAssets(stale);
6766
+ if (!features.audioEnabled && existing.audioEnabled) await dropShareAudio(existing);
6767
+ void queueShareAudio(share2);
6768
+ return { status: "ok", share: share2 };
6769
+ }
6770
+ const share = await createDocShare({
6771
+ id: shareId,
6772
+ slug,
6773
+ workspaceId: input2.workspaceId,
6774
+ profile: input2.profile,
6775
+ channelId: input2.channelId,
6776
+ sourcePath: input2.sourcePath,
6777
+ createdBy: input2.createdBy,
6778
+ ...snapshot2,
6779
+ ...features
6780
+ });
6781
+ void queueShareAudio(share);
6782
+ return { status: "ok", share };
6783
+ }
6784
+
6785
+ // ../api/src/dashboard/share-slug.ts
6786
+ var MIN_SLUG = 2;
6787
+ var MAX_SLUG = 64;
6788
+ var SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6789
+ var RESERVED2 = /* @__PURE__ */ new Set([
6790
+ "admin",
6791
+ "api",
6792
+ "assets",
6793
+ "audio",
6794
+ "auth",
6795
+ "favicon",
6796
+ "login",
6797
+ "new",
6798
+ "og",
6799
+ "robots",
6800
+ "share",
6801
+ "sitemap",
6802
+ "static"
6803
+ ]);
6804
+ function normalizeSlug(raw) {
6805
+ const slug = raw.trim().toLowerCase();
6806
+ if (slug.length < MIN_SLUG) return { error: "too-short" };
6807
+ if (slug.length > MAX_SLUG) return { error: "too-long" };
6808
+ if (!SLUG_SHAPE.test(slug)) return { error: "shape" };
6809
+ if (RESERVED2.has(slug)) return { error: "reserved" };
6810
+ return { slug };
6811
+ }
6812
+ function slugErrorMessage(err) {
6813
+ switch (err) {
6814
+ case "too-short":
6815
+ return `Use at least ${MIN_SLUG} characters.`;
6816
+ case "too-long":
6817
+ return `Keep it under ${MAX_SLUG} characters.`;
6818
+ case "reserved":
6819
+ return "That word is reserved. Try something more specific.";
6820
+ default:
6821
+ return "Use lowercase letters, numbers and hyphens.";
6822
+ }
6823
+ }
6824
+
6637
6825
  // ../api/src/dashboard/agent-bridge-data.ts
6638
6826
  var hosts = /* @__PURE__ */ new Map();
6639
6827
  var hostStatusListeners = /* @__PURE__ */ new Set();
@@ -7729,7 +7917,7 @@ function createContinuousChatRouter() {
7729
7917
  }
7730
7918
 
7731
7919
  // ../api/src/dashboard/thread-translate.ts
7732
- import { createHash as createHash3 } from "crypto";
7920
+ import { createHash as createHash4 } from "crypto";
7733
7921
 
7734
7922
  // ../api/src/store/thread-translation-store.ts
7735
7923
  var TABLES = {
@@ -7811,7 +7999,7 @@ function isTranslatableLanguage2(lang) {
7811
7999
  return BY_CODE.has(lang);
7812
8000
  }
7813
8001
  function translationHash(author, body) {
7814
- return createHash3("sha256").update(`${RECIPE_VERSION}
8002
+ return createHash4("sha256").update(`${RECIPE_VERSION}
7815
8003
  ${author}
7816
8004
  ${body}`).digest("hex");
7817
8005
  }
@@ -7923,7 +8111,7 @@ async function translateCached(lang, scope, messages, contextFor) {
7923
8111
  if (!BY_CODE.has(lang)) throw new Error(`unsupported translation language: ${lang}`);
7924
8112
  if (messages.length === 0) return [];
7925
8113
  const keyed = messages.map((m) => ({ ...m, hash: translationHash(m.author, m.body) }));
7926
- const shape = createHash3("sha256").update(keyed.map((m) => `${m.kind}:${m.id}:${m.hash}`).join("\n")).digest("hex");
8114
+ const shape = createHash4("sha256").update(keyed.map((m) => `${m.kind}:${m.id}:${m.hash}`).join("\n")).digest("hex");
7927
8115
  const key = `${lang}:${shape}`;
7928
8116
  const running2 = inFlight.get(key);
7929
8117
  if (running2) return running2;
@@ -8414,11 +8602,28 @@ function createChatRouter(agent = {}) {
8414
8602
  const limit = Number.isFinite(requestedLimit) && requestedLimit > 0 ? Math.min(requestedLimit, BOARD_PAGE_SIZE_MAX) : BOARD_PAGE_SIZE;
8415
8603
  const before = c.req.query("before");
8416
8604
  const meta = c.req.query("scope") === "all" ? await globalChannelMeta(c) : null;
8605
+ const listParam = (name) => (c.req.query(name) ?? "").split(",").filter(Boolean);
8606
+ const channelFilter = new Set(listParam("channel"));
8607
+ const authors = listParam("author").filter((a) => /^[\w.-]+$/.test(a));
8608
+ const instant = (name) => {
8609
+ const raw = c.req.query(name);
8610
+ const ms = raw ? Date.parse(raw) : NaN;
8611
+ return Number.isNaN(ms) ? void 0 : new Date(ms).toISOString();
8612
+ };
8613
+ const since2 = instant("since");
8614
+ const until = instant("until");
8615
+ const cursor = until && (!before || Date.parse(until) < Date.parse(before)) ? until : before;
8616
+ const channelIds = (meta ? [...meta.keys()] : [...ownChannelIds(c)]).filter(
8617
+ (id) => !channelFilter.size || channelFilter.has(id)
8618
+ );
8619
+ if (channelIds.length === 0) return c.json({ threads: [], nextCursor: null });
8417
8620
  const supabase = getSupabaseClient();
8418
- let query = supabase.from("threads").select("*").in("channel_id", meta ? [...meta.keys()] : [...ownChannelIds(c)]);
8621
+ let query = supabase.from("threads").select("*").in("channel_id", channelIds);
8419
8622
  query = column === NO_STATUS_COLUMN ? query.is("board_status", null) : query.eq("board_status", column);
8420
8623
  query = query.is("archived_at", null).order("updated_at", { ascending: false }).limit(limit);
8421
- if (before) query = query.lt("updated_at", before);
8624
+ if (cursor) query = query.lt("updated_at", cursor);
8625
+ if (since2) query = query.gte("updated_at", since2);
8626
+ if (authors.length) query = query.or(authors.map((a) => `author.ilike.${a}`).join(","));
8422
8627
  const { data: threads, error: error2 } = await query;
8423
8628
  if (error2) return c.json({ error: error2.message }, 500);
8424
8629
  if (!threads || threads.length === 0) return c.json({ threads: [], nextCursor: null });
@@ -8592,6 +8797,18 @@ function createChatRouter(agent = {}) {
8592
8797
  nextCursor
8593
8798
  });
8594
8799
  });
8800
+ app.get("/threads/:id/plugin-ui", async (c) => {
8801
+ const id = c.req.param("id");
8802
+ const supabase = getSupabaseClient();
8803
+ const { data: thread } = await supabase.from("threads").select("channel_id").eq("id", id).maybeSingle();
8804
+ const channelId = thread?.channel_id;
8805
+ if (!channelId || !(await globalChannelMeta(c)).has(channelId)) {
8806
+ return c.json({ error: "not found" }, 404);
8807
+ }
8808
+ const { data, error: error2 } = await supabase.from("thread_plugin_ui").select("panes, status, updated_at").eq("thread_id", id).maybeSingle();
8809
+ if (error2) return c.json({ error: error2.message }, 500);
8810
+ return c.json(data ?? { panes: [], status: null, updated_at: null });
8811
+ });
8595
8812
  app.post("/threads/:id/translation/:lang", async (c) => {
8596
8813
  const id = c.req.param("id");
8597
8814
  const lang = canonicalLanguage(c.req.param("lang"));
@@ -9000,147 +9217,6 @@ function createChatRouter(agent = {}) {
9000
9217
  // ../api/src/dashboard/doc-shares-routes.ts
9001
9218
  import { Hono as Hono14 } from "hono";
9002
9219
 
9003
- // ../api/src/dashboard/doc-share-features.ts
9004
- import { DeleteObjectCommand } from "@aws-sdk/client-s3";
9005
- var DEFAULT_FEATURES = {
9006
- audioEnabled: false,
9007
- askEnabled: true,
9008
- socialEnabled: false,
9009
- brandingEnabled: true,
9010
- translationEnabled: false,
9011
- translationLangs: []
9012
- };
9013
- var HTML_FEATURES = {
9014
- audioEnabled: false,
9015
- askEnabled: false,
9016
- socialEnabled: false,
9017
- brandingEnabled: false,
9018
- translationEnabled: false,
9019
- translationLangs: []
9020
- };
9021
- function resolveFeatures(requested, existing) {
9022
- const base = existing ?? DEFAULT_FEATURES;
9023
- return {
9024
- audioEnabled: requested?.audio ?? base.audioEnabled,
9025
- askEnabled: requested?.ask ?? base.askEnabled,
9026
- socialEnabled: requested?.social ?? base.socialEnabled,
9027
- brandingEnabled: requested?.branding ?? base.brandingEnabled,
9028
- translationEnabled: requested?.translation ?? base.translationEnabled,
9029
- // Replaced wholesale, not merged: the allowlist IS the answer to "which
9030
- // languages does this link offer", and a merge would make removing one
9031
- // impossible.
9032
- translationLangs: requested?.translationLangs ?? base.translationLangs
9033
- };
9034
- }
9035
- async function deleteShareAssets(keys) {
9036
- const client2 = getR2Client();
9037
- const bucket = getR2Bucket();
9038
- for (const key of keys) {
9039
- try {
9040
- await client2.send(new DeleteObjectCommand({ Bucket: bucket, Key: key }));
9041
- } catch {
9042
- }
9043
- }
9044
- }
9045
- async function updateShareFeatures(share, requested) {
9046
- if (share.kind === "html") return share;
9047
- if (share.kind === "excalidraw") {
9048
- if (requested.branding === void 0) return share;
9049
- return updateDocShareFeatures(share.id, { ...share, brandingEnabled: requested.branding });
9050
- }
9051
- const features = resolveFeatures(requested, share);
9052
- const updated = await updateDocShareFeatures(share.id, features);
9053
- if (!updated) return null;
9054
- if (features.audioEnabled) void queueShareAudio(updated);
9055
- else if (share.audioEnabled) await dropShareAudio(share);
9056
- return updated;
9057
- }
9058
-
9059
- // ../api/src/dashboard/doc-share-publish.ts
9060
- import { randomBytes as randomBytes5 } from "crypto";
9061
- import { CopyObjectCommand, PutObjectCommand as PutObjectCommand2 } from "@aws-sdk/client-s3";
9062
-
9063
- // ../api/src/dashboard/bridge-types.ts
9064
- var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
9065
-
9066
- // ../api/src/dashboard/doc-share-publish.ts
9067
- var SHARE_KEY_PREFIX = "share";
9068
- function generateShareId() {
9069
- return randomBytes5(9).toString("base64url");
9070
- }
9071
- async function publishDocShare(input2, readBundle) {
9072
- const bundle = await readBundle({ channelId: input2.channelId, cwd: input2.cwd, sourcePath: input2.sourcePath });
9073
- if (bundle.status !== "ok") return bundle;
9074
- const existing = await findDocShareBySource(input2.workspaceId, input2.channelId, input2.sourcePath);
9075
- const shareId = existing?.id ?? generateShareId();
9076
- const client2 = getR2Client();
9077
- const bucket = getR2Bucket();
9078
- const assetKeys = [];
9079
- for (const asset of bundle.assets) {
9080
- const key = `${SHARE_KEY_PREFIX}/${shareId}/${asset.name}`;
9081
- if ("copyFrom" in asset) {
9082
- await client2.send(
9083
- new CopyObjectCommand({
9084
- Bucket: bucket,
9085
- Key: key,
9086
- CopySource: `${bucket}/${asset.copyFrom}`.split("/").map(encodeURIComponent).join("/")
9087
- })
9088
- );
9089
- } else {
9090
- await client2.send(
9091
- new PutObjectCommand2({
9092
- Bucket: bucket,
9093
- Key: key,
9094
- Body: Buffer.from(asset.data, "base64"),
9095
- ContentType: asset.contentType
9096
- })
9097
- );
9098
- }
9099
- assetKeys.push(key);
9100
- }
9101
- const built = {
9102
- kind: bundle.kind,
9103
- title: bundle.title,
9104
- content: bundle.content.split(SHARE_ASSET_PLACEHOLDER).join(`/share/${shareId}/assets/`),
9105
- assetKeys
9106
- };
9107
- const html = built.kind !== "markdown";
9108
- const features = built.kind === "excalidraw" ? {
9109
- ...HTML_FEATURES,
9110
- brandingEnabled: resolveFeatures(input2.features, existing).brandingEnabled
9111
- } : html ? HTML_FEATURES : resolveFeatures(input2.features, existing);
9112
- const snapshot2 = {
9113
- ...built,
9114
- sourceLang: html ? null : await detectSourceLanguage(built.title, built.content)
9115
- };
9116
- const slug = input2.slug === void 0 ? existing?.slug ?? null : input2.slug;
9117
- if (existing) {
9118
- if (slug !== (existing.slug ?? null)) {
9119
- const renamed = await setDocShareSlug(existing.id, slug);
9120
- if (!renamed) return { status: "not-found" };
9121
- }
9122
- const share2 = await updateDocShareSnapshot(existing.id, snapshot2, features);
9123
- const stale = existing.assetKeys.filter((key) => !snapshot2.assetKeys.includes(key));
9124
- await deleteShareAssets(stale);
9125
- if (!features.audioEnabled && existing.audioEnabled) await dropShareAudio(existing);
9126
- void queueShareAudio(share2);
9127
- return { status: "ok", share: share2 };
9128
- }
9129
- const share = await createDocShare({
9130
- id: shareId,
9131
- slug,
9132
- workspaceId: input2.workspaceId,
9133
- profile: input2.profile,
9134
- channelId: input2.channelId,
9135
- sourcePath: input2.sourcePath,
9136
- createdBy: input2.createdBy,
9137
- ...snapshot2,
9138
- ...features
9139
- });
9140
- void queueShareAudio(share);
9141
- return { status: "ok", share };
9142
- }
9143
-
9144
9220
  // ../api/src/dashboard/share-tags.ts
9145
9221
  var MAX_TAGS = 10;
9146
9222
  var MAX_TAG_LENGTH = 30;
@@ -9160,46 +9236,6 @@ function normalizeTags(raw) {
9160
9236
  return [...tags];
9161
9237
  }
9162
9238
 
9163
- // ../api/src/dashboard/share-slug.ts
9164
- var MIN_SLUG = 2;
9165
- var MAX_SLUG = 64;
9166
- var SLUG_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
9167
- var RESERVED2 = /* @__PURE__ */ new Set([
9168
- "admin",
9169
- "api",
9170
- "assets",
9171
- "audio",
9172
- "auth",
9173
- "favicon",
9174
- "login",
9175
- "new",
9176
- "og",
9177
- "robots",
9178
- "share",
9179
- "sitemap",
9180
- "static"
9181
- ]);
9182
- function normalizeSlug(raw) {
9183
- const slug = raw.trim().toLowerCase();
9184
- if (slug.length < MIN_SLUG) return { error: "too-short" };
9185
- if (slug.length > MAX_SLUG) return { error: "too-long" };
9186
- if (!SLUG_SHAPE.test(slug)) return { error: "shape" };
9187
- if (RESERVED2.has(slug)) return { error: "reserved" };
9188
- return { slug };
9189
- }
9190
- function slugErrorMessage(err) {
9191
- switch (err) {
9192
- case "too-short":
9193
- return `Use at least ${MIN_SLUG} characters.`;
9194
- case "too-long":
9195
- return `Keep it under ${MAX_SLUG} characters.`;
9196
- case "reserved":
9197
- return "That word is reserved. Try something more specific.";
9198
- default:
9199
- return "Use lowercase letters, numbers and hyphens.";
9200
- }
9201
- }
9202
-
9203
9239
  // ../api/src/dashboard/doc-shares-routes.ts
9204
9240
  function shareUrl(c, ref) {
9205
9241
  const proto = c.req.header("x-forwarded-proto") ?? "http";
@@ -10114,7 +10150,7 @@ ${screenshots}` : ""}` }
10114
10150
  }
10115
10151
 
10116
10152
  // ../api/src/dashboard/avatars-routes.ts
10117
- import { createHash as createHash4, randomUUID as randomUUID3 } from "crypto";
10153
+ import { createHash as createHash5, randomUUID as randomUUID3 } from "crypto";
10118
10154
  import { Hono as Hono21 } from "hono";
10119
10155
  import sharp3 from "sharp";
10120
10156
  import { PutObjectCommand as PutObjectCommand3, DeleteObjectCommand as DeleteObjectCommand2 } from "@aws-sdk/client-s3";
@@ -10124,7 +10160,7 @@ var AVATAR_MIME_TYPES = ["image/png", "image/jpeg"];
10124
10160
  var KEY_PREFIX2 = "avatar";
10125
10161
  var GRAVATAR_TIMEOUT_MS = 5e3;
10126
10162
  async function fetchGravatar(email) {
10127
- const hash = createHash4("sha256").update(email.trim().toLowerCase()).digest("hex");
10163
+ const hash = createHash5("sha256").update(email.trim().toLowerCase()).digest("hex");
10128
10164
  const res = await fetch(`https://gravatar.com/avatar/${hash}?s=${AVATAR_SIZE}&d=404`, {
10129
10165
  signal: AbortSignal.timeout(GRAVATAR_TIMEOUT_MS)
10130
10166
  }).catch(() => null);
@@ -12910,7 +12946,7 @@ function createDeviceAuthRouter() {
12910
12946
  import { dirname as dirname6 } from "path";
12911
12947
 
12912
12948
  // ../api/src/dashboard/skill-mirror.ts
12913
- import { createHash as createHash5 } from "crypto";
12949
+ import { createHash as createHash6 } from "crypto";
12914
12950
  import { existsSync as existsSync18, statSync as statSync3 } from "fs";
12915
12951
  var SYNC_INTERVAL_MS = 6e4;
12916
12952
  var UPSERT_BATCH = 50;
@@ -12958,7 +12994,7 @@ function snapshot(scopes) {
12958
12994
  return rows;
12959
12995
  }
12960
12996
  function hashOf(row) {
12961
- return createHash5("sha1").update(JSON.stringify([row.description, row.body, row.path, row.plugin, row.mtime])).digest("hex");
12997
+ return createHash6("sha1").update(JSON.stringify([row.description, row.body, row.path, row.plugin, row.mtime])).digest("hex");
12962
12998
  }
12963
12999
  async function pushSkillScopes(scopes) {
12964
13000
  if (!databaseReachable()) return;
@@ -14813,6 +14849,14 @@ function connectHostSocket(url, callbacks, onAuthenticated, onWorkspaces) {
14813
14849
  handleHostDbResult(msg.id, msg.res);
14814
14850
  return;
14815
14851
  }
14852
+ if (msg.type === "plugin-svg-result") {
14853
+ handlePluginSvgResult(msg.id, msg.url);
14854
+ return;
14855
+ }
14856
+ if (msg.type === "doc-share-result") {
14857
+ handleDocShareResult(msg.id, { url: msg.url, error: msg.error });
14858
+ return;
14859
+ }
14816
14860
  if (msg.type === "attachment-url-result") {
14817
14861
  handleAttachmentUrlResult(msg.id, msg.url);
14818
14862
  return;
@@ -15113,6 +15157,19 @@ async function startHostDashboard(preferredPort, host) {
15113
15157
  }
15114
15158
  });
15115
15159
  }
15160
+ app.post(LOCAL_DOC_SHARE_PATH, async (c) => {
15161
+ if (!relayAuthorized(c.req.raw, relayToken)) return c.json({ error: "unauthorized" }, 401);
15162
+ const body = await c.req.json().catch(() => null);
15163
+ if (!body || typeof body.channelId !== "string" || typeof body.path !== "string") {
15164
+ return c.json({ error: "bad request" }, 400);
15165
+ }
15166
+ try {
15167
+ const res = await requestDocShare(body.channelId, body.path, typeof body.slug === "string" ? body.slug : void 0);
15168
+ return c.json(res, res.url ? 200 : 400);
15169
+ } catch (err) {
15170
+ return c.json({ error: err.message }, 503);
15171
+ }
15172
+ });
15116
15173
  mountSpa(app);
15117
15174
  const { server, port, url } = await listen(app, preferredPort, host);
15118
15175
  relayToken = publishHostEndpoint(port);
@@ -15483,6 +15540,7 @@ var USAGE10 = `
15483
15540
  usage Show agent token usage and cost for this workspace
15484
15541
  chat Inspect dashboard chat channels and move threads between them
15485
15542
  memory Read and write a channel's persistent agent memory
15543
+ docs Publish a channel doc as a public link (docs share)
15486
15544
  persona Use a claudecafe character's faces as the bot's avatars
15487
15545
  profiles List local profiles (bound here? scheduler?) or remove one
15488
15546
  workspace Provision a workspace (Supabase rows + local profile dirs)
@@ -15586,6 +15644,9 @@ async function main() {
15586
15644
  case "memory":
15587
15645
  await runMemoryCmd(args.slice(1));
15588
15646
  break;
15647
+ case "docs":
15648
+ await runDocsCmd(args.slice(1));
15649
+ break;
15589
15650
  case "persona":
15590
15651
  await runPersonaCmd(args.slice(1));
15591
15652
  break;
@@ -15604,7 +15665,7 @@ async function main() {
15604
15665
  break;
15605
15666
  case "-v":
15606
15667
  case "--version":
15607
- printRaw("0.1.58");
15668
+ printRaw("0.1.60");
15608
15669
  break;
15609
15670
  case "-h":
15610
15671
  case "--help":