@moxt-ai/cli 0.2.1 → 0.3.2

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/README.md CHANGED
@@ -123,6 +123,33 @@ moxt file mkdir -w <workspace-id> -s <teamspace-name> -p <path> [-r]
123
123
  # Delete a file or empty directory
124
124
  moxt file del -w <workspace-id> -p <path>
125
125
  moxt file del -w <workspace-id> -s <teamspace-name> -p <path>
126
+
127
+ # Search files across accessible spaces (omit selectors to search every space you can access)
128
+ moxt file search -w <workspace-id> <query>
129
+
130
+ # Search inside a single space
131
+ moxt file search -w <workspace-id> --personal <query>
132
+ moxt file search -w <workspace-id> -s <teamspace-name> <query>
133
+ moxt file search -w <workspace-id> --team-space-id <teamSpaceId> <query>
134
+ moxt file search -w <workspace-id> --teammate-id <teammateId> <query>
135
+
136
+ # Tune the result set (defaults: --limit 30, --mode any; max --limit 80)
137
+ moxt file search -w <workspace-id> -l 50 --mode all <query>
138
+ ```
139
+
140
+ ### memory
141
+
142
+ Search archived agent memory (past chat conversations indexed for recall).
143
+
144
+ ```bash
145
+ # Search the personal assistant's memory (default)
146
+ moxt memory search -w <workspace-id> <query>
147
+
148
+ # Search a managed AI teammate's memory
149
+ moxt memory search -w <workspace-id> --teammate-id <teammateId> <query>
150
+
151
+ # Tune the result set (default: --limit 5; max --limit 10)
152
+ moxt memory search -w <workspace-id> -l 10 <query>
126
153
  ```
127
154
 
128
155
  #### File command options
@@ -151,7 +178,64 @@ Set the following environment variables:
151
178
  | Variable | Description |
152
179
  |----------|-------------|
153
180
  | `MOXT_API_KEY` | Your Moxt API key |
154
- | `MOXT_API_URL` | API endpoint (default: `https://api.moxt.ai`) |
181
+ | `MOXT_HOST` | API hostname (default: `api.moxt.ai`) |
182
+ | `MOXT_TELEMETRY_DISABLED` | Set to `1` to disable anonymous usage telemetry |
183
+ | `DO_NOT_TRACK` | Set to `1` to disable anonymous usage telemetry (community standard) |
184
+
185
+ ## Telemetry
186
+
187
+ Moxt CLI collects **anonymous usage data** by default to help us understand how the tool
188
+ is used, prioritize features, and catch regressions. Telemetry is easy to turn off.
189
+
190
+ ### What we collect
191
+
192
+ Every invocation of a Moxt CLI command may record:
193
+
194
+ | Field | Example | Purpose |
195
+ |-------|---------|---------|
196
+ | `command` / `subcommand` | `workspace` / `list` | Which command was invoked |
197
+ | `cli_version` | `1.2.3` | Distribution of CLI versions in use |
198
+ | `node_version` | `20.11.0` | Minimum-supported runtime planning |
199
+ | `os` | `darwin` / `linux` / `win32` | OS support prioritization |
200
+ | `arch` | `arm64` / `x64` | Architecture support prioritization |
201
+ | `status` | `success` / `error` | Success and error rates |
202
+ | `error_code` | `uncaught_exception` | Error classification (best-effort; may be dropped on crash) |
203
+ | `is_ci` | `true` / `false` | Separate CI traffic from human usage |
204
+ | Duration | `0.42` seconds | Performance tracking |
205
+
206
+ User identification: telemetry is only sent while you are authenticated with a Moxt API
207
+ key. Your **user ID is attached server-side** so that product decisions reflect real
208
+ usage patterns.
209
+
210
+ ### What we do NOT collect
211
+
212
+ - Command argument values (file paths, workspace IDs, emails, etc.)
213
+ - File contents, directory names, or any data from your workspace
214
+ - Environment variables
215
+ - Standard output, standard error, or error messages
216
+
217
+ ### How to opt out
218
+
219
+ Any one of the following disables all telemetry:
220
+
221
+ ```bash
222
+ # Environment variable (recommended for CI)
223
+ export MOXT_TELEMETRY_DISABLED=1
224
+
225
+ # Or the community-standard variable
226
+ export DO_NOT_TRACK=1
227
+
228
+ # Or persist the choice
229
+ moxt telemetry disable
230
+ ```
231
+
232
+ Check current status with `moxt telemetry status`. Re-enable with `moxt telemetry enable`.
233
+
234
+ ### Where the data is sent
235
+
236
+ Metrics are sent to `POST /openapi/v1/cli-metrics` on Moxt's API endpoint, authenticated
237
+ with your API key. They are stored in Datadog and used to produce aggregated dashboards
238
+ and reliability monitors.
155
239
 
156
240
  ## License
157
241
 
package/dist/index.js CHANGED
@@ -46,10 +46,10 @@ function resolveSpaceSelector(options) {
46
46
  }
47
47
  return {};
48
48
  }
49
- function buildFileQueryString(path, spaceParams) {
49
+ function buildFileQueryString(path2, spaceParams) {
50
50
  const params = new URLSearchParams();
51
- if (path != null && path !== "") {
52
- params.set("path", path);
51
+ if (path2 != null && path2 !== "") {
52
+ params.set("path", path2);
53
53
  }
54
54
  if (spaceParams.space) {
55
55
  params.set("space", spaceParams.space);
@@ -63,10 +63,10 @@ function buildFileQueryString(path, spaceParams) {
63
63
  const qs = params.toString();
64
64
  return qs ? `?${qs}` : "";
65
65
  }
66
- function isBinaryContent(buffer) {
67
- const sampleSize = Math.min(buffer.length, 8192);
66
+ function isBinaryContent(buffer2) {
67
+ const sampleSize = Math.min(buffer2.length, 8192);
68
68
  for (let i = 0; i < sampleSize; i++) {
69
- const byte = buffer[i];
69
+ const byte = buffer2[i];
70
70
  if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
71
71
  return true;
72
72
  }
@@ -141,14 +141,17 @@ function getApiKey() {
141
141
  }
142
142
  return apiKey;
143
143
  }
144
+ function getApiKeyOrUndefined() {
145
+ return process.env.MOXT_API_KEY;
146
+ }
144
147
 
145
148
  // src/utils/http.ts
146
149
  function getUserAgent() {
147
- return `moxt-cli/${"0.2.1"} (${platform()}/${arch()}) node/${process.versions.node}`;
150
+ return `moxt-cli/${"0.3.2"} (${platform()}/${arch()}) node/${process.versions.node}`;
148
151
  }
149
- async function request(method, path, body) {
152
+ async function fetchApi(method, path2, body) {
150
153
  const apiKey = getApiKey();
151
- const url = `${getApiBaseUrl()}${path}`;
154
+ const url = `${getApiBaseUrl()}${path2}`;
152
155
  const response = await fetch(url, {
153
156
  method,
154
157
  headers: {
@@ -158,35 +161,43 @@ async function request(method, path, body) {
158
161
  },
159
162
  body: body ? JSON.stringify(body) : void 0
160
163
  });
161
- let data;
162
- const contentType = response.headers.get("content-type");
163
- if (contentType?.includes("application/json")) {
164
- data = await response.json();
165
- } else {
166
- data = await response.text();
167
- }
168
164
  if (response.status === 401) {
169
165
  console.error("Authentication failed. Check your MOXT_API_KEY.");
170
166
  console.error("Get a new key at: https://moxt.ai");
171
167
  process.exit(1);
172
168
  }
169
+ return response;
170
+ }
171
+ async function request(method, path2, body) {
172
+ const response = await fetchApi(method, path2, body);
173
+ const contentType = response.headers.get("content-type");
174
+ const data = contentType?.includes("application/json") ? await response.json() : await response.text();
173
175
  return {
174
176
  ok: response.ok,
175
177
  status: response.status,
176
178
  data
177
179
  };
178
180
  }
179
- async function httpGet(path) {
180
- return request("GET", path);
181
+ async function httpGet(path2) {
182
+ return request("GET", path2);
181
183
  }
182
- async function httpPut(path, body) {
183
- return request("PUT", path, body);
184
+ async function httpPut(path2, body) {
185
+ return request("PUT", path2, body);
184
186
  }
185
- async function httpPost(path, body) {
186
- return request("POST", path, body);
187
+ async function httpPost(path2, body) {
188
+ return request("POST", path2, body);
187
189
  }
188
- async function httpDelete(path, body) {
189
- return request("DELETE", path, body);
190
+ async function httpDelete(path2, body) {
191
+ return request("DELETE", path2, body);
192
+ }
193
+ async function httpRaw(method, path2, body) {
194
+ const response = await fetchApi(method, path2, body);
195
+ return {
196
+ ok: response.ok,
197
+ status: response.status,
198
+ text: await response.text(),
199
+ contentType: response.headers.get("content-type")
200
+ };
190
201
  }
191
202
 
192
203
  // src/utils/output.ts
@@ -206,6 +217,59 @@ function printError(message) {
206
217
  console.error(`${colors.red}${message}${colors.reset}`);
207
218
  }
208
219
 
220
+ // src/utils/search-options.ts
221
+ var SearchOptionsError = class extends Error {
222
+ constructor(message) {
223
+ super(message);
224
+ this.name = "SearchOptionsError";
225
+ }
226
+ };
227
+ function parseSearchLimit(raw, defaultValue, max) {
228
+ if (raw == null || raw === "") {
229
+ return defaultValue;
230
+ }
231
+ const parsed = Number.parseInt(raw, 10);
232
+ if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {
233
+ throw new SearchOptionsError(`Error: --limit must be a positive integer, got "${raw}".`);
234
+ }
235
+ if (parsed > max) {
236
+ throw new SearchOptionsError(`Error: --limit must be less than or equal to ${max}.`);
237
+ }
238
+ return parsed;
239
+ }
240
+ function parseSearchMode(raw) {
241
+ if (raw == null || raw === "") {
242
+ return "any";
243
+ }
244
+ if (raw === "all" || raw === "any") {
245
+ return raw;
246
+ }
247
+ throw new SearchOptionsError(`Error: --mode must be "any" or "all", got "${raw}".`);
248
+ }
249
+ function parseTeammateId(raw) {
250
+ if (raw == null || raw === "") {
251
+ return void 0;
252
+ }
253
+ const parsed = Number.parseInt(raw, 10);
254
+ if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {
255
+ throw new SearchOptionsError(`Error: --teammate-id must be a positive integer, got "${raw}".`);
256
+ }
257
+ return parsed;
258
+ }
259
+
260
+ // src/utils/run-or-exit.ts
261
+ function runOrExit(fn) {
262
+ try {
263
+ return fn();
264
+ } catch (err) {
265
+ if (err instanceof SpaceOptionsError || err instanceof SearchOptionsError) {
266
+ printError(err.message);
267
+ process.exit(1);
268
+ }
269
+ throw err;
270
+ }
271
+ }
272
+
209
273
  // src/utils/spinner.ts
210
274
  var frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
211
275
  var intervalId = null;
@@ -229,22 +293,48 @@ function stopSpinner(success, message) {
229
293
  }
230
294
 
231
295
  // src/commands/file.ts
232
- function runOrExit(fn) {
233
- try {
234
- return fn();
235
- } catch (err) {
236
- if (err instanceof SpaceOptionsError) {
237
- printError(err.message);
238
- process.exit(1);
239
- }
240
- throw err;
241
- }
242
- }
243
296
  function addSpaceOptions(cmd) {
244
297
  return cmd.requiredOption("-w, --workspace <workspaceId>", "Workspace ID").option("-s, --space <name>", "Space name (personal or teamspace name)").option("--personal", "Use personal space (default)").option("--team-space-id <teamSpaceId>", "Team space ID").option("--teammate-id <teammateId>", "Teammate ID (teammate space)");
245
298
  }
246
299
  function registerFileCommand(program2) {
247
300
  const file = program2.command("file").description("File operations");
301
+ addSpaceOptions(
302
+ file.command("search").description("Search files in accessible spaces").argument("<query>", "Search query").option("-l, --limit <limit>", "Maximum number of files to return", "30").option("--mode <mode>", "Keyword matching mode: any or all", "any")
303
+ ).action(async (query, options) => {
304
+ const spaceParams = runOrExit(() => resolveSpaceSelector(options));
305
+ const limit = runOrExit(() => parseSearchLimit(options.limit, 30, 80));
306
+ const mode = runOrExit(() => parseSearchMode(options.mode));
307
+ startSpinner("Searching files...");
308
+ const response = await httpPost(
309
+ `/workspaces/${options.workspace}/files/search`,
310
+ {
311
+ query,
312
+ limit,
313
+ mode,
314
+ ...spaceParams
315
+ }
316
+ );
317
+ if (!response.ok) {
318
+ stopSpinner(false, "Failed");
319
+ printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`);
320
+ process.exit(1);
321
+ }
322
+ const { items } = response.data;
323
+ if (items.length === 0) {
324
+ stopSpinner(true, "No files found.");
325
+ return;
326
+ }
327
+ stopSpinner(true, `Found ${items.length} file(s)`);
328
+ for (const item of items) {
329
+ print(`${colors.bold}${item.rank}. ${item.filePath}${colors.reset}`);
330
+ print(`${colors.dim}repo=${item.repoId} file=${item.fileId}${colors.reset}`);
331
+ const snippet = item.contentHighlight?.text ?? item.semanticSnippets[0]?.content;
332
+ if (snippet) {
333
+ print(snippet);
334
+ }
335
+ print("");
336
+ }
337
+ });
248
338
  addSpaceOptions(
249
339
  file.command("get-url").description("Resolve the shareable browser URL for a file").requiredOption("-p, --path <path>", "File path")
250
340
  ).action(async (options) => {
@@ -286,12 +376,12 @@ function registerFileCommand(program2) {
286
376
  }
287
377
  process.exit(1);
288
378
  }
289
- const { path, entries } = response.data;
379
+ const { path: path2, entries } = response.data;
290
380
  if (!entries || entries.length === 0) {
291
- stopSpinner(true, `${path}: empty directory`);
381
+ stopSpinner(true, `${path2}: empty directory`);
292
382
  return;
293
383
  }
294
- stopSpinner(true, path);
384
+ stopSpinner(true, path2);
295
385
  for (const entry of entries) {
296
386
  if (entry.type === "directory") {
297
387
  print(`${colors.blue}${entry.name}/${colors.reset}`);
@@ -353,12 +443,12 @@ function registerFileCommand(program2) {
353
443
  print(`${colors.red}\u2620 File too large (max 10MB): ${options.localPath}${colors.reset}`);
354
444
  process.exit(1);
355
445
  }
356
- const buffer = fs.readFileSync(options.localPath);
357
- if (isBinaryContent(buffer)) {
446
+ const buffer2 = fs.readFileSync(options.localPath);
447
+ if (isBinaryContent(buffer2)) {
358
448
  print(`${colors.red}\u2620 Binary files are not allowed. Only text files can be uploaded.${colors.reset}`);
359
449
  process.exit(1);
360
450
  }
361
- const content = buffer.toString("utf8");
451
+ const content = buffer2.toString("utf8");
362
452
  startSpinner("Uploading...");
363
453
  let response;
364
454
  let displayPath;
@@ -458,6 +548,268 @@ function registerFileCommand(program2) {
458
548
  );
459
549
  }
460
550
 
551
+ // src/commands/memory.ts
552
+ function registerMemoryCommand(program2) {
553
+ const memory = program2.command("memory").description("Memory operations");
554
+ memory.command("search").description("Search archived agent memory").requiredOption("-w, --workspace <workspaceId>", "Workspace ID").option("--teammate-id <teammateId>", "Search a managed AI teammate memory").option("-l, --limit <limit>", "Maximum number of memory chunks to return", "5").argument("<query>", "Search query").action(
555
+ async (query, options) => {
556
+ const limit = runOrExit(() => parseSearchLimit(options.limit, 5, 10));
557
+ const teammateId = runOrExit(() => parseTeammateId(options.teammateId));
558
+ startSpinner("Searching memory...");
559
+ const response = await httpPost(
560
+ `/workspaces/${options.workspace}/memory/search`,
561
+ {
562
+ query,
563
+ limit,
564
+ ...teammateId !== void 0 ? { agentId: teammateId } : {}
565
+ }
566
+ );
567
+ if (!response.ok) {
568
+ stopSpinner(false, "Failed");
569
+ printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`);
570
+ process.exit(1);
571
+ }
572
+ const { items } = response.data;
573
+ if (items.length === 0) {
574
+ stopSpinner(true, "No memory found.");
575
+ return;
576
+ }
577
+ stopSpinner(true, `Found ${items.length} memory chunk(s)`);
578
+ for (const item of items) {
579
+ print(`${colors.bold}${item.rank}. pipeline=${item.pipelineId} chunk=${item.chunkIndex}${colors.reset}`);
580
+ print(`${colors.dim}chunkId=${item.chunkId}${item.contentTruncated ? " truncated=true" : ""}${colors.reset}`);
581
+ print(item.content);
582
+ print("");
583
+ }
584
+ }
585
+ );
586
+ }
587
+
588
+ // src/utils/miniapp-db.ts
589
+ var MiniappDbOptionsError = class extends Error {
590
+ constructor(message) {
591
+ super(message);
592
+ this.name = "MiniappDbOptionsError";
593
+ }
594
+ };
595
+ var NON_FILTER_QUERY_PARAMS = /* @__PURE__ */ new Set([
596
+ "select",
597
+ "order",
598
+ "limit",
599
+ "offset",
600
+ "range",
601
+ "range-unit"
602
+ ]);
603
+ var ALLOWED_MINIAPP_DB_EMAIL_DOMAINS = ["@paraflow.com", "@moxt.ai", "@kanyun.com"];
604
+ function normalizePostgrestPath(path2) {
605
+ const trimmed = path2.trim();
606
+ if (!trimmed) {
607
+ throw new MiniappDbOptionsError("Error: PostgREST path is required.");
608
+ }
609
+ return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
610
+ }
611
+ function buildMiniappDbDataPath(workspaceId, appId, postgrestPath) {
612
+ return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/data${normalizePostgrestPath(postgrestPath)}`;
613
+ }
614
+ function buildMiniappDbSchemaPath(workspaceId, appId) {
615
+ return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/schema`;
616
+ }
617
+ function parseJsonBody(raw) {
618
+ let parsed;
619
+ try {
620
+ parsed = JSON.parse(raw);
621
+ } catch (error) {
622
+ const detail = error instanceof Error ? error.message : String(error);
623
+ throw new MiniappDbOptionsError(`Error: --body must be valid JSON. ${detail}`);
624
+ }
625
+ if (parsed === null || typeof parsed !== "object" && !Array.isArray(parsed)) {
626
+ throw new MiniappDbOptionsError("Error: --body must be a JSON object or array.");
627
+ }
628
+ return parsed;
629
+ }
630
+ function hasPostgrestFilter(postgrestPath) {
631
+ const normalizedPath = normalizePostgrestPath(postgrestPath);
632
+ const parsed = new URL(normalizedPath, "https://postgrest.local");
633
+ for (const [name] of parsed.searchParams.entries()) {
634
+ if (!NON_FILTER_QUERY_PARAMS.has(name.toLowerCase())) {
635
+ return true;
636
+ }
637
+ }
638
+ return false;
639
+ }
640
+ function assertPostgrestFilter(postgrestPath, method) {
641
+ if (!hasPostgrestFilter(postgrestPath)) {
642
+ throw new MiniappDbOptionsError(
643
+ `Error: ${method.toLowerCase()} requires at least one PostgREST filter query parameter.`
644
+ );
645
+ }
646
+ }
647
+ function formatRawResponse(text, pretty) {
648
+ if (!pretty || !text) {
649
+ return text;
650
+ }
651
+ try {
652
+ return JSON.stringify(JSON.parse(text), null, 2);
653
+ } catch {
654
+ return text;
655
+ }
656
+ }
657
+ function isAllowedMiniappDbUserEmail(email) {
658
+ const normalized = email.trim().toLowerCase();
659
+ return ALLOWED_MINIAPP_DB_EMAIL_DOMAINS.some((domain) => normalized.endsWith(domain));
660
+ }
661
+
662
+ // src/commands/miniapp.ts
663
+ function runOrExit2(fn) {
664
+ try {
665
+ return fn();
666
+ } catch (err) {
667
+ if (err instanceof MiniappDbOptionsError) {
668
+ printError(err.message);
669
+ process.exit(1);
670
+ }
671
+ throw err;
672
+ }
673
+ }
674
+ function addMiniappDbTargetOptions(command) {
675
+ return command.requiredOption("-w, --workspace <workspaceId>", "Workspace ID").requiredOption("--app-id <appId>", "Miniapp app ID");
676
+ }
677
+ function handleRawResponse(response, pretty) {
678
+ if (!response.ok) {
679
+ printError(`Error [${response.status}]: ${response.text}`);
680
+ process.exit(1);
681
+ }
682
+ print(formatRawResponse(response.text, pretty));
683
+ }
684
+ async function ensureAllowedMiniappDbUser() {
685
+ const response = await httpGet("/users/whoami");
686
+ if (!response.ok) {
687
+ printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`);
688
+ process.exit(1);
689
+ }
690
+ if (!isAllowedMiniappDbUserEmail(response.data.email)) {
691
+ printError("Error: miniapp db commands are only available to @paraflow.com, @moxt.ai, or @kanyun.com users.");
692
+ process.exit(1);
693
+ }
694
+ }
695
+ async function requestDataApi(method, postgrestPath, options, body) {
696
+ await ensureAllowedMiniappDbUser();
697
+ const path2 = buildMiniappDbDataPath(options.workspace, options.appId, postgrestPath);
698
+ const response = await httpRaw(method, path2, body);
699
+ handleRawResponse(response, options.pretty);
700
+ }
701
+ function registerMiniappCommand(program2) {
702
+ const miniapp = program2.command("miniapp", { hidden: true }).description("Miniapp operations");
703
+ const db = miniapp.command("db").description("Miniapp database operations");
704
+ addMiniappDbTargetOptions(
705
+ db.command("schema").description("Print the miniapp database schema SQL")
706
+ ).action(async (options) => {
707
+ await ensureAllowedMiniappDbUser();
708
+ const response = await httpGet(buildMiniappDbSchemaPath(options.workspace, options.appId));
709
+ if (!response.ok) {
710
+ printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`);
711
+ process.exit(1);
712
+ }
713
+ print(response.data.sql);
714
+ });
715
+ addMiniappDbTargetOptions(
716
+ db.command("get").description("Read miniapp data through PostgREST").argument("<path>", "PostgREST path, for example /todos?select=*").option("--pretty", "Pretty-print JSON responses")
717
+ ).action(async (postgrestPath, options) => {
718
+ await requestDataApi("GET", postgrestPath, options);
719
+ });
720
+ addMiniappDbTargetOptions(
721
+ db.command("post").description("Create miniapp data through PostgREST").argument("<path>", "PostgREST path, for example /todos").requiredOption("--body <json>", "JSON object or array request body").option("--pretty", "Pretty-print JSON responses")
722
+ ).action(async (postgrestPath, options) => {
723
+ const body = runOrExit2(() => parseJsonBody(options.body ?? ""));
724
+ await requestDataApi("POST", postgrestPath, options, body);
725
+ });
726
+ addMiniappDbTargetOptions(
727
+ db.command("patch").description("Update miniapp data through PostgREST").argument("<path>", "PostgREST path with a filter, for example /todos?id=eq.1").requiredOption("--body <json>", "JSON object or array request body").option("--pretty", "Pretty-print JSON responses")
728
+ ).action(async (postgrestPath, options) => {
729
+ runOrExit2(() => assertPostgrestFilter(postgrestPath, "PATCH"));
730
+ const body = runOrExit2(() => parseJsonBody(options.body ?? ""));
731
+ await requestDataApi("PATCH", postgrestPath, options, body);
732
+ });
733
+ addMiniappDbTargetOptions(
734
+ db.command("delete").description("Delete miniapp data through PostgREST").argument("<path>", "PostgREST path with a filter, for example /todos?id=eq.1").option("--yes", "Confirm the delete operation").option("--pretty", "Pretty-print JSON responses")
735
+ ).action(async (postgrestPath, options) => {
736
+ if (options.yes !== true) {
737
+ printError("Error: delete requires --yes.");
738
+ process.exit(1);
739
+ }
740
+ runOrExit2(() => assertPostgrestFilter(postgrestPath, "DELETE"));
741
+ await requestDataApi("DELETE", postgrestPath, options);
742
+ });
743
+ }
744
+
745
+ // src/telemetry/config.ts
746
+ import * as fs2 from "fs";
747
+ import * as os from "os";
748
+ import * as path from "path";
749
+ function getConfigPath() {
750
+ return path.join(os.homedir(), ".moxt", "config.json");
751
+ }
752
+ function readTelemetryConfig() {
753
+ try {
754
+ const raw = fs2.readFileSync(getConfigPath(), "utf8");
755
+ const parsed = JSON.parse(raw);
756
+ return parsed.telemetry ?? {};
757
+ } catch {
758
+ return {};
759
+ }
760
+ }
761
+ function writeTelemetryConfig(update) {
762
+ const configPath = getConfigPath();
763
+ let existing = {};
764
+ try {
765
+ existing = JSON.parse(fs2.readFileSync(configPath, "utf8"));
766
+ } catch {
767
+ existing = {};
768
+ }
769
+ const currentTelemetry = existing.telemetry ?? {};
770
+ const next = { ...existing, telemetry: { ...currentTelemetry, ...update } };
771
+ fs2.mkdirSync(path.dirname(configPath), { recursive: true });
772
+ fs2.writeFileSync(configPath, JSON.stringify(next, null, 2));
773
+ }
774
+
775
+ // src/telemetry/opt-out.ts
776
+ function isCiEnvironment() {
777
+ return process.env.CI === "true" || process.env.CI === "1";
778
+ }
779
+ function isTelemetryDisabled() {
780
+ if (process.env.MOXT_TELEMETRY_DISABLED === "1" || process.env.MOXT_TELEMETRY_DISABLED === "true") {
781
+ return true;
782
+ }
783
+ if (process.env.DO_NOT_TRACK === "1" || process.env.DO_NOT_TRACK === "true") {
784
+ return true;
785
+ }
786
+ return readTelemetryConfig().disabled === true;
787
+ }
788
+
789
+ // src/commands/telemetry.ts
790
+ function registerTelemetryCommand(program2) {
791
+ const telemetry = program2.command("telemetry").description("Manage Moxt CLI telemetry");
792
+ telemetry.command("status").description("Show telemetry status").action(() => {
793
+ const cfg = readTelemetryConfig();
794
+ const envOverride = process.env.MOXT_TELEMETRY_DISABLED === "1" || process.env.MOXT_TELEMETRY_DISABLED === "true" || process.env.DO_NOT_TRACK === "1" || process.env.DO_NOT_TRACK === "true";
795
+ const state = isTelemetryDisabled() ? "disabled" : "enabled";
796
+ print(`telemetry: ${state}`);
797
+ if (envOverride) {
798
+ print("(disabled via environment variable)");
799
+ } else if (cfg.disabled) {
800
+ print("(disabled via config file)");
801
+ }
802
+ });
803
+ telemetry.command("enable").description("Enable telemetry").action(() => {
804
+ writeTelemetryConfig({ disabled: false });
805
+ print("telemetry: enabled");
806
+ });
807
+ telemetry.command("disable").description("Disable telemetry").action(() => {
808
+ writeTelemetryConfig({ disabled: true });
809
+ print("telemetry: disabled");
810
+ });
811
+ }
812
+
461
813
  // src/commands/whoami.ts
462
814
  function registerWhoamiCommand(program2) {
463
815
  program2.command("whoami").description("Show current user information").action(async () => {
@@ -587,19 +939,219 @@ function registerWorkspaceCommand(program2) {
587
939
  });
588
940
  }
589
941
 
942
+ // src/telemetry/client.ts
943
+ import { arch as arch2, platform as platform2 } from "os";
944
+ var buffer = [];
945
+ var FLUSH_TIMEOUT_MS = 3e3;
946
+ var MAX_BATCH_SIZE = 100;
947
+ function commonLabels() {
948
+ return {
949
+ cli_version: "0.3.2",
950
+ node_version: process.versions.node,
951
+ os: platform2(),
952
+ arch: arch2(),
953
+ is_ci: isCiEnvironment() ? "true" : "false"
954
+ };
955
+ }
956
+ function record(metric) {
957
+ if (isTelemetryDisabled()) {
958
+ debugLog(`record: disabled, dropping ${metric.metric_id}`);
959
+ return;
960
+ }
961
+ if (!getApiKeyOrUndefined()) {
962
+ debugLog(`record: no API key, dropping ${metric.metric_id}`);
963
+ return;
964
+ }
965
+ buffer.push({
966
+ ...metric,
967
+ extra_label_name_2_value: {
968
+ ...commonLabels(),
969
+ ...metric.extra_label_name_2_value ?? {}
970
+ }
971
+ });
972
+ debugLog(`record: buffered ${metric.metric_id} (buffer=${buffer.length})`);
973
+ }
974
+ function isDebug() {
975
+ return process.env.MOXT_TELEMETRY_DEBUG === "1" || process.env.MOXT_TELEMETRY_DEBUG === "true";
976
+ }
977
+ function debugLog(msg, detail) {
978
+ if (!isDebug()) return;
979
+ process.stderr.write(`[telemetry] ${msg}${detail !== void 0 ? ` ${JSON.stringify(detail)}` : ""}
980
+ `);
981
+ }
982
+ async function flush() {
983
+ if (buffer.length === 0) {
984
+ debugLog("flush: buffer empty, skipping");
985
+ return;
986
+ }
987
+ const apiKey = getApiKeyOrUndefined();
988
+ if (!apiKey) {
989
+ debugLog("flush: no API key, dropping buffer");
990
+ buffer.length = 0;
991
+ return;
992
+ }
993
+ const batch = buffer.splice(0, MAX_BATCH_SIZE);
994
+ const payload = {
995
+ release_id: "0.3.2",
996
+ client_type: "cli",
997
+ metric_data_list: batch.map((m) => ({
998
+ profile: "cli",
999
+ metric_id: m.metric_id,
1000
+ metric_type: m.metric_type,
1001
+ value: m.value,
1002
+ extra_label_name_2_value: m.extra_label_name_2_value
1003
+ }))
1004
+ };
1005
+ const url = `${getApiBaseUrl()}/cli-metrics`;
1006
+ debugLog(`flush: POST ${url} with ${batch.length} metrics`, payload);
1007
+ try {
1008
+ const controller = new AbortController();
1009
+ const timeout = setTimeout(() => {
1010
+ controller.abort();
1011
+ }, FLUSH_TIMEOUT_MS);
1012
+ try {
1013
+ const res = await fetch(url, {
1014
+ method: "POST",
1015
+ headers: {
1016
+ "Content-Type": "application/json",
1017
+ Authorization: `Bearer ${apiKey}`
1018
+ },
1019
+ body: JSON.stringify(payload),
1020
+ signal: controller.signal
1021
+ });
1022
+ debugLog(`flush: response status=${res.status}`);
1023
+ } finally {
1024
+ clearTimeout(timeout);
1025
+ }
1026
+ } catch (err) {
1027
+ debugLog("flush: failed", err instanceof Error ? err.message : String(err));
1028
+ }
1029
+ }
1030
+
1031
+ // src/telemetry/notice.ts
1032
+ var NOTICE = [
1033
+ "",
1034
+ "Attention: Moxt CLI now collects anonymous telemetry regarding usage.",
1035
+ "This information is used to shape Moxt CLI's roadmap and prioritize features.",
1036
+ "",
1037
+ "You may opt out by setting MOXT_TELEMETRY_DISABLED=1 in your env",
1038
+ "or by running `moxt telemetry disable`.",
1039
+ "Details: https://www.npmjs.com/package/@moxt-ai/cli#telemetry",
1040
+ ""
1041
+ ];
1042
+ function maybeShowTelemetryNotice() {
1043
+ if (isTelemetryDisabled()) return;
1044
+ if (isCiEnvironment()) return;
1045
+ if (readTelemetryConfig().noticeShown) return;
1046
+ for (const line of NOTICE) {
1047
+ process.stderr.write(`${line}
1048
+ `);
1049
+ }
1050
+ try {
1051
+ writeTelemetryConfig({ noticeShown: true });
1052
+ } catch {
1053
+ }
1054
+ }
1055
+
1056
+ // src/telemetry/instrument.ts
1057
+ var current = null;
1058
+ function commandPath(cmd) {
1059
+ const names = [];
1060
+ let node = cmd;
1061
+ while (node && node.parent) {
1062
+ names.unshift(node.name());
1063
+ node = node.parent;
1064
+ }
1065
+ if (names.length === 0) return { command: "unknown" };
1066
+ if (names.length === 1) return { command: names[0] };
1067
+ return { command: names[0], subcommand: names.slice(1).join(" ") };
1068
+ }
1069
+ function instrumentProgram(program2) {
1070
+ program2.hook("preAction", (_thisCommand, actionCommand) => {
1071
+ const { command, subcommand } = commandPath(actionCommand);
1072
+ if (command !== "telemetry") {
1073
+ maybeShowTelemetryNotice();
1074
+ }
1075
+ current = { name: command, subcommand, startedAt: Date.now() };
1076
+ record({
1077
+ metric_id: "client.cli.command_invocation.count",
1078
+ metric_type: "counter",
1079
+ value: 1,
1080
+ extra_label_name_2_value: {
1081
+ command,
1082
+ ...subcommand ? { subcommand } : {},
1083
+ status: "started"
1084
+ }
1085
+ });
1086
+ });
1087
+ program2.hook("postAction", async () => {
1088
+ await reportOutcome("success");
1089
+ });
1090
+ }
1091
+ async function reportOutcome(status, errorCode) {
1092
+ if (!current) return;
1093
+ const { name, subcommand, startedAt } = current;
1094
+ const durationSeconds = (Date.now() - startedAt) / 1e3;
1095
+ record({
1096
+ metric_id: "client.cli.command_duration_seconds",
1097
+ metric_type: "histogram",
1098
+ value: durationSeconds,
1099
+ extra_label_name_2_value: {
1100
+ command: name,
1101
+ ...subcommand ? { subcommand } : {},
1102
+ status
1103
+ }
1104
+ });
1105
+ if (status === "error") {
1106
+ record({
1107
+ metric_id: "client.cli.command_error.count",
1108
+ metric_type: "counter",
1109
+ value: 1,
1110
+ extra_label_name_2_value: {
1111
+ command: name,
1112
+ ...subcommand ? { subcommand } : {},
1113
+ ...errorCode ? { error_code: errorCode } : {}
1114
+ }
1115
+ });
1116
+ }
1117
+ current = null;
1118
+ await flush();
1119
+ }
1120
+ function installExitHandler() {
1121
+ const handleError = (errorCode) => {
1122
+ void reportOutcome("error", errorCode);
1123
+ };
1124
+ process.on("uncaughtException", () => {
1125
+ handleError("uncaught_exception");
1126
+ process.exit(1);
1127
+ });
1128
+ process.on("unhandledRejection", () => {
1129
+ handleError("unhandled_rejection");
1130
+ process.exit(1);
1131
+ });
1132
+ }
1133
+
590
1134
  // src/index.ts
591
1135
  updateNotifier({
592
- pkg: { name: "@moxt-ai/cli", version: "0.2.1" }
1136
+ pkg: { name: "@moxt-ai/cli", version: "0.3.2" }
593
1137
  }).notify();
594
1138
  var program = new Command();
595
- program.name("moxt").description("Moxt CLI - AI Workspace").version("0.2.1").action(() => {
1139
+ program.name("moxt").description("Moxt CLI - AI Workspace").version("0.3.2").action(() => {
596
1140
  program.help();
597
1141
  });
1142
+ instrumentProgram(program);
1143
+ installExitHandler();
598
1144
  registerWhoamiCommand(program);
599
1145
  registerWorkspaceCommand(program);
600
1146
  registerFileCommand(program);
601
- program.parseAsync(process.argv).catch((err) => {
1147
+ registerMemoryCommand(program);
1148
+ registerMiniappCommand(program);
1149
+ registerTelemetryCommand(program);
1150
+ program.parseAsync(process.argv).then(async () => {
1151
+ await flush();
1152
+ }).catch(async (err) => {
602
1153
  console.error("CLI Error:", err);
1154
+ await flush();
603
1155
  process.exit(1);
604
1156
  });
605
1157
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/commands/file.ts","../src/utils/file-selector.ts","../src/utils/http.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/spinner.ts","../src/commands/whoami.ts","../src/commands/workspace.ts"],"sourcesContent":["import { Command } from 'commander'\nimport updateNotifier from 'update-notifier'\nimport { registerFileCommand } from './commands/file.js'\nimport { registerWhoamiCommand } from './commands/whoami.js'\nimport { registerWorkspaceCommand } from './commands/workspace.js'\n\ndeclare const __CLI_VERSION__: string\n\nupdateNotifier({\n pkg: { name: '@moxt-ai/cli', version: __CLI_VERSION__ },\n}).notify()\n\nconst program = new Command()\n\nprogram\n .name('moxt')\n .description('Moxt CLI - AI Workspace')\n .version(__CLI_VERSION__)\n .action(() => {\n program.help()\n })\n\nregisterWhoamiCommand(program)\nregisterWorkspaceCommand(program)\nregisterFileCommand(program)\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n console.error('CLI Error:', err)\n process.exit(1)\n})\n","import * as fs from 'node:fs'\nimport { Command } from 'commander'\nimport {\n buildFileQueryString,\n isBinaryContent,\n resolveReadMode,\n resolveSpaceSelector,\n resolveWriteMode,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpDelete, httpGet, httpPost, httpPut } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\n/**\n * Call a pure resolver that may throw SpaceOptionsError; on error, print the\n * message and exit(1). This keeps the CLI's user-facing contract (stderr +\n * exit code 1) identical to the previous inlined implementation, while the\n * resolver itself stays pure and unit-testable.\n */\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof SpaceOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\ninterface FileEntry {\n name: string\n type: 'file' | 'directory'\n size: number | null\n}\n\ninterface FileReadResponse {\n path: string\n type: 'file' | 'directory'\n entries: FileEntry[] | null\n content: string | null\n}\n\ninterface FileWriteResponse {\n path: string\n created: boolean\n}\n\ninterface MkdirResponse {\n path: string\n created: boolean\n}\n\ninterface DeleteResponse {\n path: string\n}\n\ninterface FileUrlResponse {\n path: string\n url: string\n}\n\nfunction addSpaceOptions(cmd: Command): Command {\n return cmd\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n}\n\nexport function registerFileCommand(program: Command): void {\n const file = program.command('file').description('File operations')\n\n addSpaceOptions(\n file.command('get-url')\n .description('Resolve the shareable browser URL for a file')\n .requiredOption('-p, --path <path>', 'File path'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Resolving URL...')\n const response = await httpGet<FileUrlResponse>(\n `/workspaces/${options.workspace}/files/url${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, response.data.path)\n print(`${colors.cyan}${response.data.url}${colors.reset}`)\n })\n\n addSpaceOptions(\n file.command('list')\n .description('List directory contents')\n .option('-p, --path <path>', 'Directory path', '/'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Listing files...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/list${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { path, entries } = response.data\n\n if (!entries || entries.length === 0) {\n stopSpinner(true, `${path}: empty directory`)\n return\n }\n\n stopSpinner(true, path)\n for (const entry of entries) {\n if (entry.type === 'directory') {\n print(`${colors.blue}${entry.name}/${colors.reset}`)\n } else {\n print(entry.name)\n }\n }\n })\n\n file.command('read')\n .description('Read file content')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'File path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .action(async (options: Partial<SpaceOptions> & { path?: string; url?: string }) => {\n const mode = runOrExit(() => resolveReadMode(options))\n\n startSpinner('Reading file...')\n\n let response: { ok: boolean; status: number; data: FileReadResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpGet<FileReadResponse>(\n `/files/read-by-url?url=${encodeURIComponent(mode.url)}`,\n )\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n const qs = buildFileQueryString(mode.path, spaceParams)\n response = await httpGet<FileReadResponse>(\n `/workspaces/${mode.workspace}/files/read${qs}`,\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { type, content } = response.data\n\n if (type === 'directory') {\n stopSpinner(false, 'Failed')\n print(`${colors.red}☠ ${displayPath} is a directory${colors.reset}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Done')\n print(content ?? '')\n })\n\n file.command('put')\n .description('Upload a file')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'Remote file path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .requiredOption('-l, --local-path <localPath>', 'Local file path')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: Partial<SpaceOptions> & {\n path?: string\n url?: string\n localPath: string\n recursive?: boolean\n }) => {\n const mode = runOrExit(() => resolveWriteMode(options))\n\n // check local file exists\n if (!fs.existsSync(options.localPath)) {\n print(`${colors.red}☠ Local file not found: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // check it is a file, not a directory\n const stats = fs.statSync(options.localPath)\n if (!stats.isFile()) {\n print(`${colors.red}☠ Not a file: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // check file size (10MB limit)\n const maxSize = 10 * 1024 * 1024\n if (stats.size > maxSize) {\n print(`${colors.red}☠ File too large (max 10MB): ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // read file and check for binary content\n const buffer = fs.readFileSync(options.localPath)\n if (isBinaryContent(buffer)) {\n print(`${colors.red}☠ Binary files are not allowed. Only text files can be uploaded.${colors.reset}`)\n process.exit(1)\n }\n\n const content = buffer.toString('utf8')\n\n startSpinner('Uploading...')\n\n let response: { ok: boolean; status: number; data: FileWriteResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpPut<FileWriteResponse>('/files/write-by-url', {\n url: mode.url,\n content,\n })\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n response = await httpPut<FileWriteResponse>(\n `/workspaces/${mode.workspace}/files/write`,\n {\n path: mode.path,\n content,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n if (mode.kind === 'by-url') {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n }\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Updated'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('mkdir')\n .description('Create a directory')\n .requiredOption('-p, --path <path>', 'Directory path')\n .option('-r, --recursive', 'Create parent directories if needed'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n recursive?: boolean\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Creating directory...')\n const response = await httpPost<MkdirResponse>(\n `/workspaces/${options.workspace}/files/mkdir`,\n {\n path: options.path,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Already exists'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('del')\n .description('Delete a file or empty directory')\n .requiredOption('-p, --path <path>', 'File or directory path'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Deleting...')\n const response = await httpDelete<DeleteResponse>(\n `/workspaces/${options.workspace}/files/delete`,\n {\n path: options.path,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Path not found: ${options.path}${colors.reset}`)\n } else if (response.status === 400) {\n print(`${colors.red}☠ Cannot delete non-empty directory${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, `Deleted: ${response.data.path}`)\n },\n )\n}\n","/**\n * Pure logic for resolving file-command space selectors and building request URLs.\n *\n * These functions are extracted from commands/file.ts so they can be unit tested\n * without spawning the CLI or mocking process.exit. All error conditions are\n * surfaced as thrown Errors; action handlers are responsible for turning them\n * into user-facing output and exit codes.\n */\n\nexport interface SpaceOptions {\n workspace: string\n space?: string\n personal?: boolean\n teamSpaceId?: string\n teammateId?: string\n}\n\nexport interface SpaceParams {\n space?: string\n teamSpaceId?: string\n agentId?: number\n}\n\n/**\n * Error thrown when selector options violate a contract (mutually exclusive,\n * wrong format, etc). Action handlers catch this and print the message before\n * exiting with code 1.\n */\nexport class SpaceOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SpaceOptionsError'\n }\n}\n\n/**\n * Resolve mutually-exclusive space selector flags into normalized request params.\n *\n * Priority (only one must be set): --team-space-id > --teammate-id > --personal > -s <name>.\n * When none is set, returns empty params (server treats this as personal space).\n */\nexport function resolveSpaceSelector(options: SpaceOptions): SpaceParams {\n // Destructure first so TypeScript's control-flow analysis can narrow each\n // field through the subsequent non-null / non-empty checks without having\n // to re-read options.* at the point of use (which would lose narrowing).\n const { space, teamSpaceId, teammateId } = options\n const personalIsSet = options.personal === true\n\n // Count \"user-set\" selectors explicitly so the mutual-exclusion check\n // reflects intent (\"which flags did the user pass?\") rather than a\n // generic truthiness filter. This keeps the mutual-exclusion check\n // cleanly separated from the downstream format validation (e.g.\n // `parsed <= 0` for teammateId).\n const spaceIsSet = space != null && space !== ''\n const teamSpaceIdIsSet = teamSpaceId != null && teamSpaceId !== ''\n const teammateIdIsSet = teammateId != null && teammateId !== ''\n const selectorCount =\n (spaceIsSet ? 1 : 0) + (personalIsSet ? 1 : 0) + (teamSpaceIdIsSet ? 1 : 0) + (teammateIdIsSet ? 1 : 0)\n if (selectorCount > 1) {\n throw new SpaceOptionsError(\n 'Error: -s, --personal, --team-space-id, and --teammate-id are mutually exclusive.',\n )\n }\n\n // Dispatch via the underlying field checks (not `*IsSet`) so TypeScript\n // narrows each local to `string`, letting us return without `!`.\n if (teamSpaceId != null && teamSpaceId !== '') {\n return { teamSpaceId }\n }\n if (teammateId != null && teammateId !== '') {\n const parsed = Number.parseInt(teammateId, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== teammateId) {\n throw new SpaceOptionsError(\n `Error: --teammate-id must be a positive integer, got \"${teammateId}\".`,\n )\n }\n return { agentId: parsed }\n }\n if (personalIsSet) {\n return { space: 'personal' }\n }\n if (space != null && space !== '') {\n return { space }\n }\n return {}\n}\n\n/**\n * Build the `?path=...&space=...` query string for file endpoints.\n * Returns empty string when no params are set (caller should not append `?`).\n * Values are URL-encoded via URLSearchParams.\n *\n * An empty-string `path` is treated as \"not provided\" and omitted from the query;\n * callers should pass `undefined` rather than `\"\"` when no path is intended.\n */\nexport function buildFileQueryString(path: string | undefined, spaceParams: SpaceParams): string {\n const params = new URLSearchParams()\n if (path != null && path !== '') {\n params.set('path', path)\n }\n if (spaceParams.space) {\n params.set('space', spaceParams.space)\n }\n if (spaceParams.teamSpaceId) {\n params.set('teamSpaceId', spaceParams.teamSpaceId)\n }\n if (spaceParams.agentId != null) {\n params.set('agentId', String(spaceParams.agentId))\n }\n const qs = params.toString()\n return qs ? `?${qs}` : ''\n}\n\n/**\n * Detect if a Buffer contains binary content by sampling the first 8192 bytes.\n * Control characters other than tab (9), LF (10), and CR (13) are treated as binary.\n */\nexport function isBinaryContent(buffer: Buffer): boolean {\n const sampleSize = Math.min(buffer.length, 8192)\n\n for (let i = 0; i < sampleSize; i++) {\n const byte = buffer[i]\n if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Validate `file read` command's top-level mutually-exclusive options (-u vs -w/-p).\n * Returns the resolved mode ('by-url' or 'by-path'). Throws SpaceOptionsError on conflict.\n *\n * Empty strings are treated as \"not provided\" (commander never passes empty strings\n * for optional flags, but callers outside the CLI context should pass undefined instead\n * of \"\" to avoid unexpected branch behaviour).\n */\nexport type ReadMode = { kind: 'by-url'; url: string } | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveReadMode(options: {\n url?: string\n workspace?: string\n path?: string\n}): ReadMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n // At this point both workspace and path are guaranteed non-empty by the guards\n // above. Use explicit checks so TypeScript narrows the types without needing `!`.\n if (!options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n return { kind: 'by-path', workspace: options.workspace, path: options.path }\n}\n\n/**\n * Validate `file put` command's top-level mutually-exclusive options (-u vs -w/-p).\n *\n * By-URL puts overwrite an existing file (the URL already identifies it), so\n * `--recursive` is meaningless in that mode and is rejected outright to keep the\n * user's intent unambiguous.\n */\nexport type WriteMode =\n | { kind: 'by-url'; url: string }\n | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveWriteMode(options: {\n url?: string\n workspace?: string\n path?: string\n recursive?: boolean\n}): WriteMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (options.url && options.recursive) {\n throw new SpaceOptionsError('Error: --recursive cannot be used with --url (the file must already exist)')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n return { kind: 'by-path', workspace: options.workspace!, path: options.path! }\n}\n","import { arch, platform } from 'os'\nimport { getApiBaseUrl, getApiKey } from './config.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport interface ApiResponse<T> {\n ok: boolean\n status: number\n data: T\n}\n\nfunction getUserAgent(): string {\n return `moxt-cli/${__CLI_VERSION__} (${platform()}/${arch()}) node/${process.versions.node}`\n}\n\nasync function request<T>(method: string, path: string, body?: unknown): Promise<ApiResponse<T>> {\n const apiKey = getApiKey()\n const url = `${getApiBaseUrl()}${path}`\n\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n 'User-Agent': getUserAgent(),\n },\n body: body ? JSON.stringify(body) : undefined,\n })\n\n let data: T\n const contentType = response.headers.get('content-type')\n if (contentType?.includes('application/json')) {\n data = (await response.json()) as T\n } else {\n data = (await response.text()) as T\n }\n\n if (response.status === 401) {\n console.error('Authentication failed. Check your MOXT_API_KEY.')\n console.error('Get a new key at: https://moxt.ai')\n process.exit(1)\n }\n\n return {\n ok: response.ok,\n status: response.status,\n data,\n }\n}\n\nexport async function httpGet<T>(path: string): Promise<ApiResponse<T>> {\n return request<T>('GET', path)\n}\n\nexport async function httpPut<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PUT', path, body)\n}\n\nexport async function httpPost<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('POST', path, body)\n}\n\nexport async function httpDelete<T>(path: string, body?: unknown): Promise<ApiResponse<T>> {\n return request<T>('DELETE', path, body)\n}\n","const DEFAULT_HOST = 'api.moxt.ai'\n\nexport function getApiBaseUrl(): string {\n const host = process.env.MOXT_HOST ?? DEFAULT_HOST\n return `https://${host}/openapi/v1`\n}\n\nexport function getApiKey(): string {\n const apiKey = process.env.MOXT_API_KEY\n\n if (!apiKey) {\n console.error('MOXT_API_KEY environment variable is not set.')\n console.error('')\n console.error('Get your API key at: https://moxt.ai')\n console.error('')\n console.error('Then set it:')\n console.error(' export MOXT_API_KEY=moxt_...')\n process.exit(1)\n }\n\n return apiKey\n}\n","// ANSI colors\nexport const colors = {\n bold: '\\x1b[1m',\n blue: '\\x1b[1;34m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n cyan: '\\x1b[36m',\n dim: '\\x1b[2m',\n reset: '\\x1b[0m',\n}\n\nexport function print(message: string): void {\n console.log(message)\n}\n\nexport function printError(message: string): void {\n console.error(`${colors.red}${message}${colors.reset}`)\n}\n","const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']\n\nlet intervalId: ReturnType<typeof setInterval> | null = null\nlet frameIndex = 0\n\nexport function startSpinner(message: string): void {\n frameIndex = 0\n process.stdout.write(`${frames[frameIndex]} ${message}`)\n\n intervalId = setInterval(() => {\n frameIndex = (frameIndex + 1) % frames.length\n process.stdout.write(`\\r${frames[frameIndex]} ${message}`)\n }, 80)\n}\n\nexport function stopSpinner(success: boolean, message?: string): void {\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = null\n }\n\n const symbol = success ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m'\n // \\x1b[2K 清除整行,\\r 回到行首\n process.stdout.write(`\\x1b[2K\\r${symbol} ${message ?? ''}\\n`)\n}\n","import { Command } from 'commander'\nimport { httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WhoamiResponse {\n nickname: string\n email: string\n}\n\nexport function registerWhoamiCommand(program: Command): void {\n program\n .command('whoami')\n .description('Show current user information')\n .action(async () => {\n startSpinner('Fetching user info...')\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n\n if (response.ok) {\n stopSpinner(true, 'Done')\n print(`${colors.bold}Nickname${colors.reset}: ${response.data.nickname}`)\n print(`${colors.bold}Email${colors.reset}: ${response.data.email}`)\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { httpGet, httpDelete } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WorkspaceItem {\n workspaceId: string\n name: string\n}\n\ninterface WorkspaceListResponse {\n workspaces: WorkspaceItem[]\n}\n\ninterface MemberItem {\n userId: number\n email: string\n displayName: string | null\n role: string\n}\n\ninterface MembersResponse {\n members: MemberItem[]\n}\n\ninterface SpaceItem {\n type: 'personal' | 'team' | 'teammate'\n name: string\n teamSpaceId: string | null\n agentId: number | null\n}\n\n// Email regex (same as web/src/utils/email.ts)\nconst emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\n\nfunction isValidEmail(email: string): boolean {\n return emailRegex.test(email)\n}\n\nexport function registerWorkspaceCommand(program: Command): void {\n const workspace = program.command('workspace').description('Workspace management')\n\n workspace\n .command('list')\n .description('List all workspaces you belong to')\n .action(async () => {\n startSpinner('Fetching workspaces...')\n const response = await httpGet<WorkspaceListResponse>('/workspaces')\n\n if (response.ok) {\n const { workspaces } = response.data\n if (workspaces.length === 0) {\n stopSpinner(true, 'No workspaces found.')\n return\n }\n\n stopSpinner(true, `Found ${workspaces.length} workspace(s)`)\n\n for (const ws of workspaces) {\n print(`${colors.bold}${ws.workspaceId}${colors.reset}\\t${ws.name}`)\n }\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n\n const members = program.command('members').description('Manage workspace members')\n\n members\n .command('list')\n .description('List all members in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching workspace members...')\n const response = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { members } = response.data\n if (members.length === 0) {\n stopSpinner(true, 'No members found.')\n return\n }\n\n stopSpinner(true, `Found ${members.length} member(s)`)\n\n for (const member of members) {\n const name = member.displayName || '-'\n print(`${colors.bold}${member.email}${colors.reset}\\t${name}\\t${member.role}`)\n }\n })\n\n members\n .command('remove')\n .description('Remove members from a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .argument('<emails>', 'Emails to remove (comma-separated)')\n .action(async (emailsArg: string, options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n const emails = emailsArg.split(',').map((e) => e.trim()).filter(Boolean)\n if (emails.length === 0) {\n printError('No valid emails provided')\n process.exit(1)\n }\n\n // Validate email format\n const invalidEmails = emails.filter((e) => !isValidEmail(e))\n if (invalidEmails.length > 0) {\n for (const email of invalidEmails) {\n printError(`Invalid email format: ${email}`)\n }\n process.exit(1)\n }\n\n // Fetch members to get userId by email\n startSpinner('Fetching workspace members...')\n const membersResponse = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!membersResponse.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${membersResponse.status}]: ${JSON.stringify(membersResponse.data)}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Members fetched')\n\n const { members } = membersResponse.data\n const emailToMember = new Map(members.map((m) => [m.email.toLowerCase(), m]))\n\n // Remove each member\n for (const email of emails) {\n const member = emailToMember.get(email.toLowerCase())\n if (!member) {\n print(`${colors.red}✗${colors.reset} ${email} - not found in workspace`)\n continue\n }\n\n const deleteResponse = await httpDelete(`/workspaces/${workspaceId}/members/${member.userId}`)\n\n if (deleteResponse.ok) {\n print(`${colors.green}✓${colors.reset} ${email} - removed`)\n } else {\n print(`${colors.red}✗${colors.reset} ${email} - failed: ${JSON.stringify(deleteResponse.data)}`)\n }\n }\n })\n\n const space = program.command('space').description('Manage spaces')\n\n space\n .command('list')\n .description('List accessible spaces in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching spaces...')\n const response = await httpGet<{ spaces: SpaceItem[] }>(`/workspaces/${workspaceId}/spaces`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch spaces')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { spaces } = response.data\n if (spaces.length === 0) {\n stopSpinner(true, 'No spaces found.')\n return\n }\n\n stopSpinner(true, `Found ${spaces.length} space(s)`)\n\n print(\n `${colors.bold}TYPE${colors.reset}\\t${colors.bold}TEAM_SPACE_ID${colors.reset}\\t${colors.bold}TEAMMATE_ID${colors.reset}\\t${colors.bold}NAME${colors.reset}`,\n )\n for (const s of spaces) {\n const teamSpaceId = s.teamSpaceId ?? ''\n const teammateId = s.agentId != null ? String(s.agentId) : ''\n print(`${s.type}\\t${teamSpaceId}\\t${teammateId}\\t${s.name}`)\n }\n })\n\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,oBAAoB;;;ACD3B,YAAY,QAAQ;;;AC4Bb,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC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AAO,OAAO,KAAK,IAAK,OAAO,IAAI,gBAAgB,OAAO,KAAK,IAAK,OAAO,IAAI,cAAc,OAAO,KAAK,IAAK,OAAO,IAAI,OAAO,OAAO,KAAK;AAAA,IAC9J;AACA,eAAW,KAAK,QAAQ;AACpB,YAAM,cAAc,EAAE,eAAe;AACrC,YAAM,aAAa,EAAE,WAAW,OAAO,OAAO,EAAE,OAAO,IAAI;AAC3D,YAAM,GAAG,EAAE,IAAI,IAAK,WAAW,IAAK,UAAU,IAAK,EAAE,IAAI,EAAE;AAAA,IAC/D;AAAA,EACJ,CAAC;AAET;;;ARxLA,eAAe;AAAA,EACX,KAAK,EAAE,MAAM,gBAAgB,SAAS,QAAgB;AAC1D,CAAC,EAAE,OAAO;AAEV,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACK,KAAK,MAAM,EACX,YAAY,yBAAyB,EACrC,QAAQ,OAAe,EACvB,OAAO,MAAM;AACV,UAAQ,KAAK;AACjB,CAAC;AAEL,sBAAsB,OAAO;AAC7B,yBAAyB,OAAO;AAChC,oBAAoB,OAAO;AAE3B,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACrD,UAAQ,MAAM,cAAc,GAAG;AAC/B,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["program","program","program","members"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/file.ts","../src/utils/file-selector.ts","../src/utils/http.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/search-options.ts","../src/utils/run-or-exit.ts","../src/utils/spinner.ts","../src/commands/memory.ts","../src/utils/miniapp-db.ts","../src/commands/miniapp.ts","../src/telemetry/config.ts","../src/telemetry/opt-out.ts","../src/commands/telemetry.ts","../src/commands/whoami.ts","../src/commands/workspace.ts","../src/telemetry/client.ts","../src/telemetry/notice.ts","../src/telemetry/instrument.ts"],"sourcesContent":["import { Command } from 'commander'\nimport updateNotifier from 'update-notifier'\nimport { registerFileCommand } from './commands/file.js'\nimport { registerMemoryCommand } from './commands/memory.js'\nimport { registerMiniappCommand } from './commands/miniapp.js'\nimport { registerTelemetryCommand } from './commands/telemetry.js'\nimport { registerWhoamiCommand } from './commands/whoami.js'\nimport { registerWorkspaceCommand } from './commands/workspace.js'\nimport { flush } from './telemetry/client.js'\nimport { installExitHandler, instrumentProgram } from './telemetry/instrument.js'\n\ndeclare const __CLI_VERSION__: string\n\nupdateNotifier({\n pkg: { name: '@moxt-ai/cli', version: __CLI_VERSION__ },\n}).notify()\n\nconst program = new Command()\n\nprogram\n .name('moxt')\n .description('Moxt CLI - AI Workspace')\n .version(__CLI_VERSION__)\n .action(() => {\n program.help()\n })\n\ninstrumentProgram(program)\ninstallExitHandler()\n\nregisterWhoamiCommand(program)\nregisterWorkspaceCommand(program)\nregisterFileCommand(program)\nregisterMemoryCommand(program)\nregisterMiniappCommand(program)\nregisterTelemetryCommand(program)\n\nprogram\n .parseAsync(process.argv)\n .then(async () => {\n await flush()\n })\n .catch(async (err: unknown) => {\n console.error('CLI Error:', err)\n await flush()\n process.exit(1)\n })\n","import * as fs from 'node:fs'\nimport { Command } from 'commander'\nimport {\n buildFileQueryString,\n isBinaryContent,\n resolveReadMode,\n resolveSpaceSelector,\n resolveWriteMode,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpDelete, httpGet, httpPost, httpPut } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { runOrExit } from '../utils/run-or-exit.js'\nimport { parseSearchLimit, parseSearchMode } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface FileEntry {\n name: string\n type: 'file' | 'directory'\n size: number | null\n}\n\ninterface FileReadResponse {\n path: string\n type: 'file' | 'directory'\n entries: FileEntry[] | null\n content: string | null\n}\n\ninterface FileWriteResponse {\n path: string\n created: boolean\n}\n\ninterface MkdirResponse {\n path: string\n created: boolean\n}\n\ninterface DeleteResponse {\n path: string\n}\n\ninterface FileUrlResponse {\n path: string\n url: string\n}\n\ninterface FieldHighlight {\n text: string\n}\n\ninterface SemanticSnippet {\n content: string\n}\n\ninterface FileSearchItem {\n repoId: string\n fileId: string\n filePath: string\n rank: number\n contentHighlight?: FieldHighlight\n filePathHighlight?: FieldHighlight\n semanticSnippets: SemanticSnippet[]\n}\n\ninterface FileSearchResponse {\n items: FileSearchItem[]\n}\n\nfunction addSpaceOptions(cmd: Command): Command {\n return cmd\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n}\n\nexport function registerFileCommand(program: Command): void {\n const file = program.command('file').description('File operations')\n\n addSpaceOptions(\n file.command('search')\n .description('Search files in accessible spaces')\n .argument('<query>', 'Search query')\n .option('-l, --limit <limit>', 'Maximum number of files to return', '30')\n .option('--mode <mode>', 'Keyword matching mode: any or all', 'any'),\n ).action(async (query: string, options: SpaceOptions & { limit?: string; mode?: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const limit = runOrExit(() => parseSearchLimit(options.limit, 30, 80))\n const mode = runOrExit(() => parseSearchMode(options.mode))\n\n startSpinner('Searching files...')\n const response = await httpPost<FileSearchResponse>(\n `/workspaces/${options.workspace}/files/search`,\n {\n query,\n limit,\n mode,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { items } = response.data\n if (items.length === 0) {\n stopSpinner(true, 'No files found.')\n return\n }\n\n stopSpinner(true, `Found ${items.length} file(s)`)\n for (const item of items) {\n print(`${colors.bold}${item.rank}. ${item.filePath}${colors.reset}`)\n print(`${colors.dim}repo=${item.repoId} file=${item.fileId}${colors.reset}`)\n const snippet = item.contentHighlight?.text ?? item.semanticSnippets[0]?.content\n if (snippet) {\n print(snippet)\n }\n print('')\n }\n })\n\n addSpaceOptions(\n file.command('get-url')\n .description('Resolve the shareable browser URL for a file')\n .requiredOption('-p, --path <path>', 'File path'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Resolving URL...')\n const response = await httpGet<FileUrlResponse>(\n `/workspaces/${options.workspace}/files/url${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, response.data.path)\n print(`${colors.cyan}${response.data.url}${colors.reset}`)\n })\n\n addSpaceOptions(\n file.command('list')\n .description('List directory contents')\n .option('-p, --path <path>', 'Directory path', '/'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Listing files...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/list${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { path, entries } = response.data\n\n if (!entries || entries.length === 0) {\n stopSpinner(true, `${path}: empty directory`)\n return\n }\n\n stopSpinner(true, path)\n for (const entry of entries) {\n if (entry.type === 'directory') {\n print(`${colors.blue}${entry.name}/${colors.reset}`)\n } else {\n print(entry.name)\n }\n }\n })\n\n file.command('read')\n .description('Read file content')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'File path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .action(async (options: Partial<SpaceOptions> & { path?: string; url?: string }) => {\n const mode = runOrExit(() => resolveReadMode(options))\n\n startSpinner('Reading file...')\n\n let response: { ok: boolean; status: number; data: FileReadResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpGet<FileReadResponse>(\n `/files/read-by-url?url=${encodeURIComponent(mode.url)}`,\n )\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n const qs = buildFileQueryString(mode.path, spaceParams)\n response = await httpGet<FileReadResponse>(\n `/workspaces/${mode.workspace}/files/read${qs}`,\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { type, content } = response.data\n\n if (type === 'directory') {\n stopSpinner(false, 'Failed')\n print(`${colors.red}☠ ${displayPath} is a directory${colors.reset}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Done')\n print(content ?? '')\n })\n\n file.command('put')\n .description('Upload a file')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'Remote file path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .requiredOption('-l, --local-path <localPath>', 'Local file path')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: Partial<SpaceOptions> & {\n path?: string\n url?: string\n localPath: string\n recursive?: boolean\n }) => {\n const mode = runOrExit(() => resolveWriteMode(options))\n\n // check local file exists\n if (!fs.existsSync(options.localPath)) {\n print(`${colors.red}☠ Local file not found: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // check it is a file, not a directory\n const stats = fs.statSync(options.localPath)\n if (!stats.isFile()) {\n print(`${colors.red}☠ Not a file: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // check file size (10MB limit)\n const maxSize = 10 * 1024 * 1024\n if (stats.size > maxSize) {\n print(`${colors.red}☠ File too large (max 10MB): ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // read file and check for binary content\n const buffer = fs.readFileSync(options.localPath)\n if (isBinaryContent(buffer)) {\n print(`${colors.red}☠ Binary files are not allowed. Only text files can be uploaded.${colors.reset}`)\n process.exit(1)\n }\n\n const content = buffer.toString('utf8')\n\n startSpinner('Uploading...')\n\n let response: { ok: boolean; status: number; data: FileWriteResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpPut<FileWriteResponse>('/files/write-by-url', {\n url: mode.url,\n content,\n })\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n response = await httpPut<FileWriteResponse>(\n `/workspaces/${mode.workspace}/files/write`,\n {\n path: mode.path,\n content,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n if (mode.kind === 'by-url') {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n }\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Updated'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('mkdir')\n .description('Create a directory')\n .requiredOption('-p, --path <path>', 'Directory path')\n .option('-r, --recursive', 'Create parent directories if needed'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n recursive?: boolean\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Creating directory...')\n const response = await httpPost<MkdirResponse>(\n `/workspaces/${options.workspace}/files/mkdir`,\n {\n path: options.path,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Already exists'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('del')\n .description('Delete a file or empty directory')\n .requiredOption('-p, --path <path>', 'File or directory path'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Deleting...')\n const response = await httpDelete<DeleteResponse>(\n `/workspaces/${options.workspace}/files/delete`,\n {\n path: options.path,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Path not found: ${options.path}${colors.reset}`)\n } else if (response.status === 400) {\n print(`${colors.red}☠ Cannot delete non-empty directory${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, `Deleted: ${response.data.path}`)\n },\n )\n}\n","/**\n * Pure logic for resolving file-command space selectors and building request URLs.\n *\n * These functions are extracted from commands/file.ts so they can be unit tested\n * without spawning the CLI or mocking process.exit. All error conditions are\n * surfaced as thrown Errors; action handlers are responsible for turning them\n * into user-facing output and exit codes.\n */\n\nexport interface SpaceOptions {\n workspace: string\n space?: string\n personal?: boolean\n teamSpaceId?: string\n teammateId?: string\n}\n\nexport interface SpaceParams {\n space?: string\n teamSpaceId?: string\n agentId?: number\n}\n\n/**\n * Error thrown when selector options violate a contract (mutually exclusive,\n * wrong format, etc). Action handlers catch this and print the message before\n * exiting with code 1.\n */\nexport class SpaceOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SpaceOptionsError'\n }\n}\n\n/**\n * Resolve mutually-exclusive space selector flags into normalized request params.\n *\n * Priority (only one must be set): --team-space-id > --teammate-id > --personal > -s <name>.\n * When none is set, returns empty params (server treats this as personal space).\n */\nexport function resolveSpaceSelector(options: SpaceOptions): SpaceParams {\n // Destructure first so TypeScript's control-flow analysis can narrow each\n // field through the subsequent non-null / non-empty checks without having\n // to re-read options.* at the point of use (which would lose narrowing).\n const { space, teamSpaceId, teammateId } = options\n const personalIsSet = options.personal === true\n\n // Count \"user-set\" selectors explicitly so the mutual-exclusion check\n // reflects intent (\"which flags did the user pass?\") rather than a\n // generic truthiness filter. This keeps the mutual-exclusion check\n // cleanly separated from the downstream format validation (e.g.\n // `parsed <= 0` for teammateId).\n const spaceIsSet = space != null && space !== ''\n const teamSpaceIdIsSet = teamSpaceId != null && teamSpaceId !== ''\n const teammateIdIsSet = teammateId != null && teammateId !== ''\n const selectorCount =\n (spaceIsSet ? 1 : 0) + (personalIsSet ? 1 : 0) + (teamSpaceIdIsSet ? 1 : 0) + (teammateIdIsSet ? 1 : 0)\n if (selectorCount > 1) {\n throw new SpaceOptionsError(\n 'Error: -s, --personal, --team-space-id, and --teammate-id are mutually exclusive.',\n )\n }\n\n // Dispatch via the underlying field checks (not `*IsSet`) so TypeScript\n // narrows each local to `string`, letting us return without `!`.\n if (teamSpaceId != null && teamSpaceId !== '') {\n return { teamSpaceId }\n }\n if (teammateId != null && teammateId !== '') {\n const parsed = Number.parseInt(teammateId, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== teammateId) {\n throw new SpaceOptionsError(\n `Error: --teammate-id must be a positive integer, got \"${teammateId}\".`,\n )\n }\n return { agentId: parsed }\n }\n if (personalIsSet) {\n return { space: 'personal' }\n }\n if (space != null && space !== '') {\n return { space }\n }\n return {}\n}\n\n/**\n * Build the `?path=...&space=...` query string for file endpoints.\n * Returns empty string when no params are set (caller should not append `?`).\n * Values are URL-encoded via URLSearchParams.\n *\n * An empty-string `path` is treated as \"not provided\" and omitted from the query;\n * callers should pass `undefined` rather than `\"\"` when no path is intended.\n */\nexport function buildFileQueryString(path: string | undefined, spaceParams: SpaceParams): string {\n const params = new URLSearchParams()\n if (path != null && path !== '') {\n params.set('path', path)\n }\n if (spaceParams.space) {\n params.set('space', spaceParams.space)\n }\n if (spaceParams.teamSpaceId) {\n params.set('teamSpaceId', spaceParams.teamSpaceId)\n }\n if (spaceParams.agentId != null) {\n params.set('agentId', String(spaceParams.agentId))\n }\n const qs = params.toString()\n return qs ? `?${qs}` : ''\n}\n\n/**\n * Detect if a Buffer contains binary content by sampling the first 8192 bytes.\n * Control characters other than tab (9), LF (10), and CR (13) are treated as binary.\n */\nexport function isBinaryContent(buffer: Buffer): boolean {\n const sampleSize = Math.min(buffer.length, 8192)\n\n for (let i = 0; i < sampleSize; i++) {\n const byte = buffer[i]\n if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Validate `file read` command's top-level mutually-exclusive options (-u vs -w/-p).\n * Returns the resolved mode ('by-url' or 'by-path'). Throws SpaceOptionsError on conflict.\n *\n * Empty strings are treated as \"not provided\" (commander never passes empty strings\n * for optional flags, but callers outside the CLI context should pass undefined instead\n * of \"\" to avoid unexpected branch behaviour).\n */\nexport type ReadMode = { kind: 'by-url'; url: string } | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveReadMode(options: {\n url?: string\n workspace?: string\n path?: string\n}): ReadMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n // At this point both workspace and path are guaranteed non-empty by the guards\n // above. Use explicit checks so TypeScript narrows the types without needing `!`.\n if (!options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n return { kind: 'by-path', workspace: options.workspace, path: options.path }\n}\n\n/**\n * Validate `file put` command's top-level mutually-exclusive options (-u vs -w/-p).\n *\n * By-URL puts overwrite an existing file (the URL already identifies it), so\n * `--recursive` is meaningless in that mode and is rejected outright to keep the\n * user's intent unambiguous.\n */\nexport type WriteMode =\n | { kind: 'by-url'; url: string }\n | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveWriteMode(options: {\n url?: string\n workspace?: string\n path?: string\n recursive?: boolean\n}): WriteMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (options.url && options.recursive) {\n throw new SpaceOptionsError('Error: --recursive cannot be used with --url (the file must already exist)')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n return { kind: 'by-path', workspace: options.workspace!, path: options.path! }\n}\n","import { arch, platform } from 'os'\nimport { getApiBaseUrl, getApiKey } from './config.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport interface ApiResponse<T> {\n ok: boolean\n status: number\n data: T\n}\n\nexport interface RawApiResponse {\n ok: boolean\n status: number\n text: string\n contentType: string | null\n}\n\nfunction getUserAgent(): string {\n return `moxt-cli/${__CLI_VERSION__} (${platform()}/${arch()}) node/${process.versions.node}`\n}\n\nasync function fetchApi(method: string, path: string, body?: unknown): Promise<Response> {\n const apiKey = getApiKey()\n const url = `${getApiBaseUrl()}${path}`\n\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n 'User-Agent': getUserAgent(),\n },\n body: body ? JSON.stringify(body) : undefined,\n })\n\n if (response.status === 401) {\n console.error('Authentication failed. Check your MOXT_API_KEY.')\n console.error('Get a new key at: https://moxt.ai')\n process.exit(1)\n }\n\n return response\n}\n\nasync function request<T>(method: string, path: string, body?: unknown): Promise<ApiResponse<T>> {\n const response = await fetchApi(method, path, body)\n const contentType = response.headers.get('content-type')\n const data = contentType?.includes('application/json') ? ((await response.json()) as T) : ((await response.text()) as T)\n\n return {\n ok: response.ok,\n status: response.status,\n data,\n }\n}\n\nexport async function httpGet<T>(path: string): Promise<ApiResponse<T>> {\n return request<T>('GET', path)\n}\n\nexport async function httpPut<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PUT', path, body)\n}\n\nexport async function httpPost<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('POST', path, body)\n}\n\nexport async function httpDelete<T>(path: string, body?: unknown): Promise<ApiResponse<T>> {\n return request<T>('DELETE', path, body)\n}\n\nexport async function httpRaw(method: 'GET' | 'POST' | 'PATCH' | 'DELETE', path: string, body?: unknown): Promise<RawApiResponse> {\n const response = await fetchApi(method, path, body)\n return {\n ok: response.ok,\n status: response.status,\n text: await response.text(),\n contentType: response.headers.get('content-type'),\n }\n}\n","const DEFAULT_HOST = 'api.moxt.ai'\n\nexport function getApiBaseUrl(): string {\n const host = process.env.MOXT_HOST ?? DEFAULT_HOST\n return `https://${host}/openapi/v1`\n}\n\nexport function getApiKey(): string {\n const apiKey = process.env.MOXT_API_KEY\n\n if (!apiKey) {\n console.error('MOXT_API_KEY environment variable is not set.')\n console.error('')\n console.error('Get your API key at: https://moxt.ai')\n console.error('')\n console.error('Then set it:')\n console.error(' export MOXT_API_KEY=moxt_...')\n process.exit(1)\n }\n\n return apiKey\n}\n\nexport function getApiKeyOrUndefined(): string | undefined {\n return process.env.MOXT_API_KEY\n}\n","// ANSI colors\nexport const colors = {\n bold: '\\x1b[1m',\n blue: '\\x1b[1;34m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n cyan: '\\x1b[36m',\n dim: '\\x1b[2m',\n reset: '\\x1b[0m',\n}\n\nexport function print(message: string): void {\n console.log(message)\n}\n\nexport function printError(message: string): void {\n console.error(`${colors.red}${message}${colors.reset}`)\n}\n","export class SearchOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SearchOptionsError'\n }\n}\n\nexport function parseSearchLimit(raw: string | undefined, defaultValue: number, max: number): number {\n if (raw == null || raw === '') {\n return defaultValue\n }\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new SearchOptionsError(`Error: --limit must be a positive integer, got \"${raw}\".`)\n }\n if (parsed > max) {\n throw new SearchOptionsError(`Error: --limit must be less than or equal to ${max}.`)\n }\n return parsed\n}\n\nexport function parseSearchMode(raw: string | undefined): 'all' | 'any' {\n if (raw == null || raw === '') {\n return 'any'\n }\n if (raw === 'all' || raw === 'any') {\n return raw\n }\n throw new SearchOptionsError(`Error: --mode must be \"any\" or \"all\", got \"${raw}\".`)\n}\n\nexport function parseTeammateId(raw: string | undefined): number | undefined {\n if (raw == null || raw === '') {\n return undefined\n }\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new SearchOptionsError(`Error: --teammate-id must be a positive integer, got \"${raw}\".`)\n }\n return parsed\n}\n","import { SpaceOptionsError } from './file-selector.js'\nimport { printError } from './output.js'\nimport { SearchOptionsError } from './search-options.js'\n\n/**\n * Call a pure resolver that may throw a known CLI option error; on error,\n * print the message and exit(1). This keeps the user-facing contract\n * (stderr + exit code 1) consistent across subcommands while letting the\n * resolvers stay pure and unit-testable.\n */\nexport function runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof SpaceOptionsError || err instanceof SearchOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n","const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']\n\nlet intervalId: ReturnType<typeof setInterval> | null = null\nlet frameIndex = 0\n\nexport function startSpinner(message: string): void {\n frameIndex = 0\n process.stdout.write(`${frames[frameIndex]} ${message}`)\n\n intervalId = setInterval(() => {\n frameIndex = (frameIndex + 1) % frames.length\n process.stdout.write(`\\r${frames[frameIndex]} ${message}`)\n }, 80)\n}\n\nexport function stopSpinner(success: boolean, message?: string): void {\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = null\n }\n\n const symbol = success ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m'\n // \\x1b[2K 清除整行,\\r 回到行首\n process.stdout.write(`\\x1b[2K\\r${symbol} ${message ?? ''}\\n`)\n}\n","import { Command } from 'commander'\nimport { httpPost } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { runOrExit } from '../utils/run-or-exit.js'\nimport { parseSearchLimit, parseTeammateId } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface MemorySearchItem {\n rank: number\n pipelineId: string\n chunkId: string\n chunkIndex: number\n content: string\n contentTruncated: boolean\n}\n\ninterface MemorySearchResponse {\n items: MemorySearchItem[]\n}\n\nexport function registerMemoryCommand(program: Command): void {\n const memory = program.command('memory').description('Memory operations')\n\n memory.command('search')\n .description('Search archived agent memory')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('--teammate-id <teammateId>', 'Search a managed AI teammate memory')\n .option('-l, --limit <limit>', 'Maximum number of memory chunks to return', '5')\n .argument('<query>', 'Search query')\n .action(\n async (\n query: string,\n options: {\n workspace: string\n teammateId?: string\n limit?: string\n },\n ) => {\n const limit = runOrExit(() => parseSearchLimit(options.limit, 5, 10))\n const teammateId = runOrExit(() => parseTeammateId(options.teammateId))\n\n startSpinner('Searching memory...')\n const response = await httpPost<MemorySearchResponse>(\n `/workspaces/${options.workspace}/memory/search`,\n {\n query,\n limit,\n ...(teammateId !== undefined ? { agentId: teammateId } : {}),\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { items } = response.data\n if (items.length === 0) {\n stopSpinner(true, 'No memory found.')\n return\n }\n\n stopSpinner(true, `Found ${items.length} memory chunk(s)`)\n for (const item of items) {\n print(`${colors.bold}${item.rank}. pipeline=${item.pipelineId} chunk=${item.chunkIndex}${colors.reset}`)\n print(`${colors.dim}chunkId=${item.chunkId}${item.contentTruncated ? ' truncated=true' : ''}${colors.reset}`)\n print(item.content)\n print('')\n }\n },\n )\n}\n","export class MiniappDbOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'MiniappDbOptionsError'\n }\n}\n\nconst NON_FILTER_QUERY_PARAMS = new Set([\n 'select',\n 'order',\n 'limit',\n 'offset',\n 'range',\n 'range-unit',\n])\n\nconst ALLOWED_MINIAPP_DB_EMAIL_DOMAINS = ['@paraflow.com', '@moxt.ai', '@kanyun.com']\n\nexport function normalizePostgrestPath(path: string): string {\n const trimmed = path.trim()\n if (!trimmed) {\n throw new MiniappDbOptionsError('Error: PostgREST path is required.')\n }\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`\n}\n\nexport function buildMiniappDbDataPath(workspaceId: string, appId: string, postgrestPath: string): string {\n return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/data${normalizePostgrestPath(postgrestPath)}`\n}\n\nexport function buildMiniappDbSchemaPath(workspaceId: string, appId: string): string {\n return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/schema`\n}\n\nexport function parseJsonBody(raw: string): unknown {\n let parsed: unknown\n try {\n parsed = JSON.parse(raw)\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error)\n throw new MiniappDbOptionsError(`Error: --body must be valid JSON. ${detail}`)\n }\n\n if (parsed === null || (typeof parsed !== 'object' && !Array.isArray(parsed))) {\n throw new MiniappDbOptionsError('Error: --body must be a JSON object or array.')\n }\n return parsed\n}\n\nexport function hasPostgrestFilter(postgrestPath: string): boolean {\n const normalizedPath = normalizePostgrestPath(postgrestPath)\n const parsed = new URL(normalizedPath, 'https://postgrest.local')\n for (const [name] of parsed.searchParams.entries()) {\n if (!NON_FILTER_QUERY_PARAMS.has(name.toLowerCase())) {\n return true\n }\n }\n return false\n}\n\nexport function assertPostgrestFilter(postgrestPath: string, method: 'PATCH' | 'DELETE'): void {\n if (!hasPostgrestFilter(postgrestPath)) {\n throw new MiniappDbOptionsError(\n `Error: ${method.toLowerCase()} requires at least one PostgREST filter query parameter.`,\n )\n }\n}\n\nexport function formatRawResponse(text: string, pretty?: boolean): string {\n if (!pretty || !text) {\n return text\n }\n try {\n return JSON.stringify(JSON.parse(text), null, 2)\n } catch {\n return text\n }\n}\n\nexport function isAllowedMiniappDbUserEmail(email: string): boolean {\n const normalized = email.trim().toLowerCase()\n return ALLOWED_MINIAPP_DB_EMAIL_DOMAINS.some((domain) => normalized.endsWith(domain))\n}\n","import { Command } from 'commander'\nimport {\n assertPostgrestFilter,\n buildMiniappDbDataPath,\n buildMiniappDbSchemaPath,\n formatRawResponse,\n isAllowedMiniappDbUserEmail,\n MiniappDbOptionsError,\n parseJsonBody,\n} from '../utils/miniapp-db.js'\nimport { httpGet, httpRaw } from '../utils/http.js'\nimport { print, printError } from '../utils/output.js'\n\ninterface MiniappDbOptions {\n workspace: string\n appId: string\n pretty?: boolean\n body?: string\n yes?: boolean\n}\n\ninterface MiniappDbSchemaResponse {\n sql: string\n}\n\ninterface WhoamiResponse {\n email: string\n}\n\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof MiniappDbOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\nfunction addMiniappDbTargetOptions(command: Command): Command {\n return command\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .requiredOption('--app-id <appId>', 'Miniapp app ID')\n}\n\nfunction handleRawResponse(response: Awaited<ReturnType<typeof httpRaw>>, pretty?: boolean): void {\n if (!response.ok) {\n printError(`Error [${response.status}]: ${response.text}`)\n process.exit(1)\n }\n print(formatRawResponse(response.text, pretty))\n}\n\nasync function ensureAllowedMiniappDbUser(): Promise<void> {\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n if (!response.ok) {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n if (!isAllowedMiniappDbUserEmail(response.data.email)) {\n printError('Error: miniapp db commands are only available to @paraflow.com, @moxt.ai, or @kanyun.com users.')\n process.exit(1)\n }\n}\n\nasync function requestDataApi(\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE',\n postgrestPath: string,\n options: MiniappDbOptions,\n body?: unknown,\n): Promise<void> {\n await ensureAllowedMiniappDbUser()\n const path = buildMiniappDbDataPath(options.workspace, options.appId, postgrestPath)\n const response = await httpRaw(method, path, body)\n handleRawResponse(response, options.pretty)\n}\n\nexport function registerMiniappCommand(program: Command): void {\n const miniapp = program.command('miniapp', { hidden: true }).description('Miniapp operations')\n const db = miniapp.command('db').description('Miniapp database operations')\n\n addMiniappDbTargetOptions(\n db.command('schema').description('Print the miniapp database schema SQL'),\n ).action(async (options: MiniappDbOptions) => {\n await ensureAllowedMiniappDbUser()\n const response = await httpGet<MiniappDbSchemaResponse>(buildMiniappDbSchemaPath(options.workspace, options.appId))\n\n if (!response.ok) {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n print(response.data.sql)\n })\n\n addMiniappDbTargetOptions(\n db.command('get')\n .description('Read miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path, for example /todos?select=*')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n await requestDataApi('GET', postgrestPath, options)\n })\n\n addMiniappDbTargetOptions(\n db.command('post')\n .description('Create miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path, for example /todos')\n .requiredOption('--body <json>', 'JSON object or array request body')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n const body = runOrExit(() => parseJsonBody(options.body ?? ''))\n await requestDataApi('POST', postgrestPath, options, body)\n })\n\n addMiniappDbTargetOptions(\n db.command('patch')\n .description('Update miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path with a filter, for example /todos?id=eq.1')\n .requiredOption('--body <json>', 'JSON object or array request body')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n runOrExit(() => assertPostgrestFilter(postgrestPath, 'PATCH'))\n const body = runOrExit(() => parseJsonBody(options.body ?? ''))\n await requestDataApi('PATCH', postgrestPath, options, body)\n })\n\n addMiniappDbTargetOptions(\n db.command('delete')\n .description('Delete miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path with a filter, for example /todos?id=eq.1')\n .option('--yes', 'Confirm the delete operation')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n if (options.yes !== true) {\n printError('Error: delete requires --yes.')\n process.exit(1)\n }\n runOrExit(() => assertPostgrestFilter(postgrestPath, 'DELETE'))\n await requestDataApi('DELETE', postgrestPath, options)\n })\n}\n","import * as fs from 'node:fs'\nimport * as os from 'node:os'\nimport * as path from 'node:path'\n\nexport interface TelemetryConfig {\n disabled?: boolean\n noticeShown?: boolean\n}\n\nfunction getConfigPath(): string {\n return path.join(os.homedir(), '.moxt', 'config.json')\n}\n\nexport function readTelemetryConfig(): TelemetryConfig {\n try {\n const raw = fs.readFileSync(getConfigPath(), 'utf8')\n const parsed = JSON.parse(raw) as { telemetry?: TelemetryConfig }\n return parsed.telemetry ?? {}\n } catch {\n return {}\n }\n}\n\nexport function writeTelemetryConfig(update: Partial<TelemetryConfig>): void {\n const configPath = getConfigPath()\n let existing: Record<string, unknown> = {}\n try {\n existing = JSON.parse(fs.readFileSync(configPath, 'utf8')) as Record<string, unknown>\n } catch {\n existing = {}\n }\n const currentTelemetry = (existing.telemetry as TelemetryConfig | undefined) ?? {}\n const next = { ...existing, telemetry: { ...currentTelemetry, ...update } }\n fs.mkdirSync(path.dirname(configPath), { recursive: true })\n fs.writeFileSync(configPath, JSON.stringify(next, null, 2))\n}\n","import { readTelemetryConfig } from './config.js'\n\nexport function isCiEnvironment(): boolean {\n return process.env.CI === 'true' || process.env.CI === '1'\n}\n\nexport function isTelemetryDisabled(): boolean {\n if (process.env.MOXT_TELEMETRY_DISABLED === '1' || process.env.MOXT_TELEMETRY_DISABLED === 'true') {\n return true\n }\n if (process.env.DO_NOT_TRACK === '1' || process.env.DO_NOT_TRACK === 'true') {\n return true\n }\n return readTelemetryConfig().disabled === true\n}\n","import { Command } from 'commander'\nimport { readTelemetryConfig, writeTelemetryConfig } from '../telemetry/config.js'\nimport { isTelemetryDisabled } from '../telemetry/opt-out.js'\nimport { print } from '../utils/output.js'\n\nexport function registerTelemetryCommand(program: Command): void {\n const telemetry = program.command('telemetry').description('Manage Moxt CLI telemetry')\n\n telemetry\n .command('status')\n .description('Show telemetry status')\n .action(() => {\n const cfg = readTelemetryConfig()\n const envOverride =\n process.env.MOXT_TELEMETRY_DISABLED === '1' ||\n process.env.MOXT_TELEMETRY_DISABLED === 'true' ||\n process.env.DO_NOT_TRACK === '1' ||\n process.env.DO_NOT_TRACK === 'true'\n\n const state = isTelemetryDisabled() ? 'disabled' : 'enabled'\n print(`telemetry: ${state}`)\n if (envOverride) {\n print('(disabled via environment variable)')\n } else if (cfg.disabled) {\n print('(disabled via config file)')\n }\n })\n\n telemetry\n .command('enable')\n .description('Enable telemetry')\n .action(() => {\n writeTelemetryConfig({ disabled: false })\n print('telemetry: enabled')\n })\n\n telemetry\n .command('disable')\n .description('Disable telemetry')\n .action(() => {\n writeTelemetryConfig({ disabled: true })\n print('telemetry: disabled')\n })\n}\n","import { Command } from 'commander'\nimport { httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WhoamiResponse {\n nickname: string\n email: string\n}\n\nexport function registerWhoamiCommand(program: Command): void {\n program\n .command('whoami')\n .description('Show current user information')\n .action(async () => {\n startSpinner('Fetching user info...')\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n\n if (response.ok) {\n stopSpinner(true, 'Done')\n print(`${colors.bold}Nickname${colors.reset}: ${response.data.nickname}`)\n print(`${colors.bold}Email${colors.reset}: ${response.data.email}`)\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { httpGet, httpDelete } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WorkspaceItem {\n workspaceId: string\n name: string\n}\n\ninterface WorkspaceListResponse {\n workspaces: WorkspaceItem[]\n}\n\ninterface MemberItem {\n userId: number\n email: string\n displayName: string | null\n role: string\n}\n\ninterface MembersResponse {\n members: MemberItem[]\n}\n\ninterface SpaceItem {\n type: 'personal' | 'team' | 'teammate'\n name: string\n teamSpaceId: string | null\n agentId: number | null\n}\n\n// Email regex (same as web/src/utils/email.ts)\nconst emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\n\nfunction isValidEmail(email: string): boolean {\n return emailRegex.test(email)\n}\n\nexport function registerWorkspaceCommand(program: Command): void {\n const workspace = program.command('workspace').description('Workspace management')\n\n workspace\n .command('list')\n .description('List all workspaces you belong to')\n .action(async () => {\n startSpinner('Fetching workspaces...')\n const response = await httpGet<WorkspaceListResponse>('/workspaces')\n\n if (response.ok) {\n const { workspaces } = response.data\n if (workspaces.length === 0) {\n stopSpinner(true, 'No workspaces found.')\n return\n }\n\n stopSpinner(true, `Found ${workspaces.length} workspace(s)`)\n\n for (const ws of workspaces) {\n print(`${colors.bold}${ws.workspaceId}${colors.reset}\\t${ws.name}`)\n }\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n\n const members = program.command('members').description('Manage workspace members')\n\n members\n .command('list')\n .description('List all members in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching workspace members...')\n const response = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { members } = response.data\n if (members.length === 0) {\n stopSpinner(true, 'No members found.')\n return\n }\n\n stopSpinner(true, `Found ${members.length} member(s)`)\n\n for (const member of members) {\n const name = member.displayName || '-'\n print(`${colors.bold}${member.email}${colors.reset}\\t${name}\\t${member.role}`)\n }\n })\n\n members\n .command('remove')\n .description('Remove members from a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .argument('<emails>', 'Emails to remove (comma-separated)')\n .action(async (emailsArg: string, options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n const emails = emailsArg.split(',').map((e) => e.trim()).filter(Boolean)\n if (emails.length === 0) {\n printError('No valid emails provided')\n process.exit(1)\n }\n\n // Validate email format\n const invalidEmails = emails.filter((e) => !isValidEmail(e))\n if (invalidEmails.length > 0) {\n for (const email of invalidEmails) {\n printError(`Invalid email format: ${email}`)\n }\n process.exit(1)\n }\n\n // Fetch members to get userId by email\n startSpinner('Fetching workspace members...')\n const membersResponse = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!membersResponse.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${membersResponse.status}]: ${JSON.stringify(membersResponse.data)}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Members fetched')\n\n const { members } = membersResponse.data\n const emailToMember = new Map(members.map((m) => [m.email.toLowerCase(), m]))\n\n // Remove each member\n for (const email of emails) {\n const member = emailToMember.get(email.toLowerCase())\n if (!member) {\n print(`${colors.red}✗${colors.reset} ${email} - not found in workspace`)\n continue\n }\n\n const deleteResponse = await httpDelete(`/workspaces/${workspaceId}/members/${member.userId}`)\n\n if (deleteResponse.ok) {\n print(`${colors.green}✓${colors.reset} ${email} - removed`)\n } else {\n print(`${colors.red}✗${colors.reset} ${email} - failed: ${JSON.stringify(deleteResponse.data)}`)\n }\n }\n })\n\n const space = program.command('space').description('Manage spaces')\n\n space\n .command('list')\n .description('List accessible spaces in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching spaces...')\n const response = await httpGet<{ spaces: SpaceItem[] }>(`/workspaces/${workspaceId}/spaces`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch spaces')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { spaces } = response.data\n if (spaces.length === 0) {\n stopSpinner(true, 'No spaces found.')\n return\n }\n\n stopSpinner(true, `Found ${spaces.length} space(s)`)\n\n print(\n `${colors.bold}TYPE${colors.reset}\\t${colors.bold}TEAM_SPACE_ID${colors.reset}\\t${colors.bold}TEAMMATE_ID${colors.reset}\\t${colors.bold}NAME${colors.reset}`,\n )\n for (const s of spaces) {\n const teamSpaceId = s.teamSpaceId ?? ''\n const teammateId = s.agentId != null ? String(s.agentId) : ''\n print(`${s.type}\\t${teamSpaceId}\\t${teammateId}\\t${s.name}`)\n }\n })\n\n}\n","import { arch, platform } from 'node:os'\nimport { getApiBaseUrl, getApiKeyOrUndefined } from '../utils/config.js'\nimport { isCiEnvironment, isTelemetryDisabled } from './opt-out.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport type MetricType = 'counter' | 'gauge' | 'histogram'\n\nexport interface MetricRecord {\n metric_id: string\n metric_type: MetricType\n value: number\n extra_label_name_2_value?: Record<string, string>\n}\n\nconst buffer: MetricRecord[] = []\nconst FLUSH_TIMEOUT_MS = 3000\nconst MAX_BATCH_SIZE = 100\n\nfunction commonLabels(): Record<string, string> {\n return {\n cli_version: __CLI_VERSION__,\n node_version: process.versions.node,\n os: platform(),\n arch: arch(),\n is_ci: isCiEnvironment() ? 'true' : 'false',\n }\n}\n\nexport function record(metric: MetricRecord): void {\n if (isTelemetryDisabled()) {\n debugLog(`record: disabled, dropping ${metric.metric_id}`)\n return\n }\n if (!getApiKeyOrUndefined()) {\n debugLog(`record: no API key, dropping ${metric.metric_id}`)\n return\n }\n buffer.push({\n ...metric,\n extra_label_name_2_value: {\n ...commonLabels(),\n ...(metric.extra_label_name_2_value ?? {}),\n },\n })\n debugLog(`record: buffered ${metric.metric_id} (buffer=${buffer.length})`)\n}\n\nfunction isDebug(): boolean {\n return process.env.MOXT_TELEMETRY_DEBUG === '1' || process.env.MOXT_TELEMETRY_DEBUG === 'true'\n}\n\nfunction debugLog(msg: string, detail?: unknown): void {\n if (!isDebug()) return\n process.stderr.write(`[telemetry] ${msg}${detail !== undefined ? ` ${JSON.stringify(detail)}` : ''}\\n`)\n}\n\nexport async function flush(): Promise<void> {\n if (buffer.length === 0) {\n debugLog('flush: buffer empty, skipping')\n return\n }\n const apiKey = getApiKeyOrUndefined()\n if (!apiKey) {\n debugLog('flush: no API key, dropping buffer')\n buffer.length = 0\n return\n }\n\n const batch = buffer.splice(0, MAX_BATCH_SIZE)\n const payload = {\n release_id: __CLI_VERSION__,\n client_type: 'cli',\n metric_data_list: batch.map((m) => ({\n profile: 'cli',\n metric_id: m.metric_id,\n metric_type: m.metric_type,\n value: m.value,\n extra_label_name_2_value: m.extra_label_name_2_value,\n })),\n }\n\n const url = `${getApiBaseUrl()}/cli-metrics`\n debugLog(`flush: POST ${url} with ${batch.length} metrics`, payload)\n\n try {\n const controller = new AbortController()\n const timeout = setTimeout(() => {\n controller.abort()\n }, FLUSH_TIMEOUT_MS)\n try {\n const res = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(payload),\n signal: controller.signal,\n })\n debugLog(`flush: response status=${res.status}`)\n } finally {\n clearTimeout(timeout)\n }\n } catch (err) {\n debugLog('flush: failed', err instanceof Error ? err.message : String(err))\n // fire-and-forget — never surface telemetry failures to the user\n }\n}\n","import { readTelemetryConfig, writeTelemetryConfig } from './config.js'\nimport { isCiEnvironment, isTelemetryDisabled } from './opt-out.js'\n\nconst NOTICE = [\n '',\n 'Attention: Moxt CLI now collects anonymous telemetry regarding usage.',\n \"This information is used to shape Moxt CLI's roadmap and prioritize features.\",\n '',\n 'You may opt out by setting MOXT_TELEMETRY_DISABLED=1 in your env',\n 'or by running `moxt telemetry disable`.',\n 'Details: https://www.npmjs.com/package/@moxt-ai/cli#telemetry',\n '',\n]\n\nexport function maybeShowTelemetryNotice(): void {\n if (isTelemetryDisabled()) return\n if (isCiEnvironment()) return\n if (readTelemetryConfig().noticeShown) return\n\n for (const line of NOTICE) {\n process.stderr.write(`${line}\\n`)\n }\n\n try {\n writeTelemetryConfig({ noticeShown: true })\n } catch {\n // persistence failure is not user-visible — we'll just show the notice again next run\n }\n}\n","import type { Command } from 'commander'\nimport { flush, record } from './client.js'\nimport { maybeShowTelemetryNotice } from './notice.js'\n\ninterface RunningCommand {\n name: string\n subcommand?: string\n startedAt: number\n}\n\nlet current: RunningCommand | null = null\n\nfunction commandPath(cmd: Command): { command: string; subcommand?: string } {\n const names: string[] = []\n let node: Command | null = cmd\n while (node && node.parent) {\n names.unshift(node.name())\n node = node.parent\n }\n if (names.length === 0) return { command: 'unknown' }\n if (names.length === 1) return { command: names[0] }\n return { command: names[0], subcommand: names.slice(1).join(' ') }\n}\n\nexport function instrumentProgram(program: Command): void {\n program.hook('preAction', (_thisCommand, actionCommand) => {\n const { command, subcommand } = commandPath(actionCommand)\n if (command !== 'telemetry') {\n maybeShowTelemetryNotice()\n }\n current = { name: command, subcommand, startedAt: Date.now() }\n record({\n metric_id: 'client.cli.command_invocation.count',\n metric_type: 'counter',\n value: 1,\n extra_label_name_2_value: {\n command,\n ...(subcommand ? { subcommand } : {}),\n status: 'started',\n },\n })\n })\n\n program.hook('postAction', async () => {\n await reportOutcome('success')\n })\n}\n\nasync function reportOutcome(status: 'success' | 'error', errorCode?: string): Promise<void> {\n if (!current) return\n const { name, subcommand, startedAt } = current\n const durationSeconds = (Date.now() - startedAt) / 1000\n\n record({\n metric_id: 'client.cli.command_duration_seconds',\n metric_type: 'histogram',\n value: durationSeconds,\n extra_label_name_2_value: {\n command: name,\n ...(subcommand ? { subcommand } : {}),\n status,\n },\n })\n\n if (status === 'error') {\n record({\n metric_id: 'client.cli.command_error.count',\n metric_type: 'counter',\n value: 1,\n extra_label_name_2_value: {\n command: name,\n ...(subcommand ? { subcommand } : {}),\n ...(errorCode ? { error_code: errorCode } : {}),\n },\n })\n }\n\n current = null\n await flush()\n}\n\n/**\n * Wire a final error/exit hook. Call before program.parseAsync so we can capture\n * failures routed through process.exit or unhandled rejections.\n *\n * Best-effort only: `reportOutcome` is fire-and-forget, and the subsequent\n * `process.exit(1)` terminates the process before `flush()` can complete — so\n * the error metric recorded here will typically be dropped. Reliable crash\n * reporting belongs to Sentry/APM, not this telemetry path.\n */\nexport function installExitHandler(): void {\n const handleError = (errorCode: string): void => {\n void reportOutcome('error', errorCode)\n }\n\n process.on('uncaughtException', () => {\n handleError('uncaught_exception')\n process.exit(1)\n })\n process.on('unhandledRejection', () => {\n handleError('unhandled_rejection')\n process.exit(1)\n })\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,oBAAoB;;;ACD3B,YAAY,QAAQ;;;AC4Bb,IAAM,oBAAN,cAAgC,MAAM;AAAA,EACzC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAQO,SAAS,qBAAqB,SAAoC;AAIrE,QAAM,EAAE,OAAO,aAAa,WAAW,IAAI;AAC3C,QAAM,gBAAgB,QAAQ,aAAa;AAO3C,QAAM,aAAa,SAAS,QAAQ,UAAU;AAC9C,QAAM,mBAAmB,eAAe,QAAQ,gBAAgB;AAChE,QAAM,kBAAkB,cAAc,QAAQ,eAAe;AAC7D,QAAM,iBACD,aAAa,IAAI,MAAM,gBAAgB,IAAI,MAAM,mBAAmB,IAAI,MAAM,kBAAkB,IAAI;AACzG,MAAI,gBAAgB,GAAG;AACnB,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAIA,MAAI,eAAe,QAAQ,gBAAgB,IAAI;AAC3C,WAAO,EAAE,YAAY;AAAA,EACzB;AACA,MAAI,cAAc,QAAQ,eAAe,IAAI;AACzC,UAAM,SAAS,OAAO,SAAS,YAAY,EAAE;AAC7C,QAAI,CAAC,OAAO,UAAU,MAAM,KAAK,UAAU,KAAK,OAAO,MAAM,MAAM,YAAY;AAC3E,YAAM,IAAI;AAAA,QACN,yDAAyD,UAAU;AAAA,MACvE;AAAA,IACJ;AACA,WAAO,EAAE,SAAS,OAAO;AAAA,EAC7B;AACA,MAAI,eAAe;AACf,WAAO,EAAE,OAAO,WAAW;AAAA,EAC/B;AACA,MAAI,SAAS,QAAQ,UAAU,IAAI;AAC/B,WAAO,EAAE,MAAM;AAAA,EACn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AAM;AACZ,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["path","buffer","path","program","path","buffer","program","path","runOrExit","path","program","fs","program","program","program","members","arch","platform","platform","arch","program"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxt-ai/cli",
3
- "version": "0.2.1",
3
+ "version": "0.3.2",
4
4
  "description": "Moxt - The Agent-Native Workspace",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,6 +28,11 @@
28
28
  "author": "Moxt",
29
29
  "license": "MIT",
30
30
  "homepage": "https://moxt.ai",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/paraflow-hq/moxt.git",
34
+ "directory": "moxt-cli"
35
+ },
31
36
  "engines": {
32
37
  "node": ">=18"
33
38
  },
@@ -40,7 +45,8 @@
40
45
  "@types/update-notifier": "^6.0.8",
41
46
  "tsup": "^8.5.0",
42
47
  "tsx": "^4.0.0",
43
- "typescript": "^5.8.0",
44
- "vitest": "^3.2.0"
48
+ "typescript": "^6.0.3",
49
+ "vite": "^8.0.12",
50
+ "vitest": "^4.1.6"
45
51
  }
46
52
  }