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.
@@ -2,11 +2,15 @@
2
2
  import { createRequire as __flyspaceCreateRequire } from 'node:module';
3
3
  const require = __flyspaceCreateRequire(import.meta.url);
4
4
  import {
5
+ LOCAL_DOC_SHARE_PATH,
5
6
  SessionStore,
6
7
  canSeeChannel,
7
8
  getSupabaseClient,
8
- paths
9
- } from "./chunk-XACRG7BO.js";
9
+ loadEnvFiles,
10
+ paths,
11
+ readHostEndpoint,
12
+ useHostDbWithoutCredentials
13
+ } from "./chunk-XYS7SVWC.js";
10
14
 
11
15
  // src/store/chat-admin-store.ts
12
16
  async function listChannels(profile) {
@@ -88,6 +92,52 @@ async function moveThreadFully(threadId, toChannelId) {
88
92
  }
89
93
  }
90
94
 
95
+ // src/commands/docs.ts
96
+ import { isAbsolute, normalize, relative } from "path";
97
+ var USAGE = `
98
+ Usage: flyspace docs share <path> --channel <name-or-id> [--slug <name>]
99
+
100
+ Publish a channel doc (Markdown or HTML) as a public link and print its URL,
101
+ the same as "Copy public link" in the Docs pane. Re-sharing keeps the URL.
102
+
103
+ <path> Relative to the channel folder (absolute paths are read
104
+ relative to the current directory, which the agent runs in)
105
+ --slug <name> Custom URL: /share/<name>
106
+ `;
107
+ function getArg(args, flag) {
108
+ const idx = args.indexOf(flag);
109
+ return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : void 0;
110
+ }
111
+ async function runDocsCmd(args) {
112
+ const [sub, rawPath] = args;
113
+ if (sub !== "share" || !rawPath || rawPath.startsWith("--")) {
114
+ console.log(USAGE);
115
+ if (sub && sub !== "-h" && sub !== "--help") process.exitCode = 1;
116
+ return;
117
+ }
118
+ const channelRef = getArg(args, "--channel");
119
+ if (!channelRef) throw new Error("--channel is required");
120
+ loadEnvFiles();
121
+ useHostDbWithoutCredentials();
122
+ const channel = await resolveChannel(channelRef);
123
+ console.log(await shareDoc(channel.id, rawPath, getArg(args, "--slug")));
124
+ }
125
+ async function shareDoc(channelId, rawPath, slug) {
126
+ const path = normalize(isAbsolute(rawPath) ? relative(process.cwd(), rawPath) : rawPath);
127
+ if (path.startsWith("..") || isAbsolute(path)) throw new Error(`${rawPath} is outside the channel folder`);
128
+ const endpoint = readHostEndpoint();
129
+ if (!endpoint) throw new Error("No Flyspace Host is running on this machine.");
130
+ const res = await fetch(`http://127.0.0.1:${endpoint.port}${LOCAL_DOC_SHARE_PATH}`, {
131
+ method: "POST",
132
+ headers: { authorization: `Bearer ${endpoint.token}`, "content-type": "application/json" },
133
+ body: JSON.stringify({ channelId, path, ...slug ? { slug } : {} }),
134
+ signal: AbortSignal.timeout(18e4)
135
+ });
136
+ const body = await res.json().catch(() => ({}));
137
+ if (!body.url) throw new Error(`Share failed: ${body.error ?? `Host answered ${res.status}`}`);
138
+ return body.url;
139
+ }
140
+
91
141
  // ../api/src/dashboard/thread-access.ts
92
142
  var ON_BEHALF_HEADER = "x-flyspace-on-behalf-of";
93
143
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -170,6 +220,8 @@ export {
170
220
  getThread,
171
221
  firstReplyBody,
172
222
  moveThreadFully,
223
+ runDocsCmd,
224
+ shareDoc,
173
225
  ON_BEHALF_HEADER,
174
226
  parseThreadRef,
175
227
  resolveThreadOwner,