@mosse-ai/cli 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/dist/index.js +304 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22626,9 +22626,9 @@ var InboxWaitTool = {
22626
22626
  summary: "Wait quietly for a realtime Inbox event for the signed-in user's ID (server checks ownership). Read Inbox before waiting and after every result, including timeout/reconnect, to recover missed events. Timeout is normal: do not send a chat update for it. This bounded call does not wake an idle host or schedule another turn. Coalesce new notifications; do not repeatedly report already handled items.",
22627
22627
  input: external_exports.strictObject({ userId: external_exports.uuid(), timeoutMs: external_exports.number().int().min(1e3).max(25e3).default(25e3) }),
22628
22628
  effect: "read",
22629
- transport: { kind: "stream" },
22629
+ transport: { kind: "rest", method: "GET", path: "/api/inbox/wait" },
22630
22630
  mcpName: "inbox_wait",
22631
- cliOmitted: "long-poll needs a streaming endpoint; MD-461 \u672C\u8F6E\u4E0D\u7ED9 CLI(MD-462 \u4E4B\u540E\u53E6\u8BAE)"
22631
+ cli: { path: ["inbox", "wait"], example: "mosse inbox wait --timeout-ms 25000 --json" }
22632
22632
  };
22633
22633
  var SESSION_TOOLS = [
22634
22634
  WorkspaceListTool,
@@ -23159,7 +23159,7 @@ function buildCommandTree(options = {}) {
23159
23159
  }
23160
23160
 
23161
23161
  // src/api.ts
23162
- var CLI_VERSION = true ? "0.1.0" : "0.0.0";
23162
+ var CLI_VERSION = true ? "0.1.1" : "0.0.0";
23163
23163
  var CLI_USER_AGENT = `mosse-cli/${CLI_VERSION}`;
23164
23164
  async function callApi(request) {
23165
23165
  const headers = {
@@ -23615,9 +23615,144 @@ function packagedSkillMd(version3 = CLI_VERSION) {
23615
23615
  return renderSkillMd(buildCommandTree({ sessionTools: SESSION_TOOLS }), version3);
23616
23616
  }
23617
23617
 
23618
+ // src/completions.ts
23619
+ var COMPLETION_SHELLS = ["bash", "zsh", "fish"];
23620
+ var LOCAL_COMMANDS = [
23621
+ "auth login",
23622
+ "auth logout",
23623
+ "auth status",
23624
+ "auth token",
23625
+ "auth whoami",
23626
+ "skill",
23627
+ "skill install",
23628
+ "skill status",
23629
+ "skill upgrade",
23630
+ "doctor",
23631
+ "completions",
23632
+ "inbox list",
23633
+ "inbox read",
23634
+ "workspace list"
23635
+ ];
23636
+ var GLOBAL_FLAGS = [
23637
+ "--json",
23638
+ "--format",
23639
+ "--workspace",
23640
+ "--dry-run",
23641
+ "--yes",
23642
+ "--help",
23643
+ "--version",
23644
+ "--api-url",
23645
+ "--token"
23646
+ ];
23647
+ function completionWords(tree) {
23648
+ const words = new Set(LOCAL_COMMANDS);
23649
+ for (const command of tree.commands) {
23650
+ for (let length = 1; length <= command.path.length; length += 1) words.add(command.path.slice(0, length).join(" "));
23651
+ }
23652
+ for (const flag of GLOBAL_FLAGS) words.add(flag);
23653
+ return [...words].sort((a, b) => a.localeCompare(b));
23654
+ }
23655
+ var quote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
23656
+ function bashScript(words) {
23657
+ const list = words.map(quote).join(" ");
23658
+ return `# bash completion for mosse (generated by \`mosse completions bash\`)
23659
+ _mosse_complete() {
23660
+ local cur prefix candidate rest next i
23661
+ cur="\${COMP_WORDS[COMP_CWORD]}"
23662
+ prefix=""
23663
+ for ((i = 1; i < COMP_CWORD; i++)); do
23664
+ prefix+="\${COMP_WORDS[i]} "
23665
+ done
23666
+ prefix="\${prefix% }"
23667
+ COMPREPLY=()
23668
+ for candidate in ${list}; do
23669
+ if [[ -z "$prefix" ]]; then
23670
+ rest="$candidate"
23671
+ else
23672
+ [[ "$candidate" == "$prefix "* ]] || continue
23673
+ rest="\${candidate#"$prefix "}"
23674
+ fi
23675
+ next="\${rest%% *}"
23676
+ [[ -z "$next" ]] && continue
23677
+ if [[ "$next" == "$cur"* ]]; then
23678
+ COMPREPLY+=("$next")
23679
+ fi
23680
+ done
23681
+ # \u53BB\u91CD(\u540C\u4E00\u5C42\u53EF\u80FD\u6765\u81EA\u591A\u6761\u547D\u4EE4)
23682
+ if ((\${#COMPREPLY[@]} > 0)); then
23683
+ COMPREPLY=($(printf '%s\\n' "\${COMPREPLY[@]}" | sort -u))
23684
+ fi
23685
+ }
23686
+ complete -o nosort -F _mosse_complete mosse
23687
+ `;
23688
+ }
23689
+ function zshScript(words) {
23690
+ const list = words.map(quote).join(" ");
23691
+ return `#compdef mosse (generated by \`mosse completions zsh\`)
23692
+ _mosse() {
23693
+ local -a candidates
23694
+ candidates=(${list})
23695
+ local prefix rest next cur
23696
+ cur="\${words[CURRENT]}"
23697
+ prefix=""
23698
+ local i
23699
+ for ((i = 2; i < CURRENT; i++)); do
23700
+ prefix+="\${words[i]} "
23701
+ done
23702
+ prefix="\${prefix% }"
23703
+ if [[ -z "$prefix" ]]; then
23704
+ _describe -t commands 'mosse command' candidates
23705
+ return
23706
+ fi
23707
+ local -a matches
23708
+ for candidate in "\${candidates[@]}"; do
23709
+ [[ "$candidate" == "$prefix "* ]] || continue
23710
+ rest="\${candidate#"$prefix "}"
23711
+ next="\${rest%% *}"
23712
+ [[ -z "$next" ]] && continue
23713
+ matches+=("$next")
23714
+ done
23715
+ if ((\${#matches[@]} > 0)); then
23716
+ compadd -a matches
23717
+ fi
23718
+ }
23719
+ _mosse "$@"
23720
+ `;
23721
+ }
23722
+ function fishScript(words) {
23723
+ const list = words.map(quote).join(" ");
23724
+ return `# fish completion for mosse (generated by \`mosse completions fish\`)
23725
+ function __mosse_complete
23726
+ set -l tokens (commandline -opc)
23727
+ set -e tokens[1]
23728
+ set -l prefix (string join " " $tokens)
23729
+ for candidate in ${list}
23730
+ if test -n "$prefix"
23731
+ string match -q -- "$prefix *" $candidate; or continue
23732
+ set -l rest (string replace -- "$prefix " "" $candidate)
23733
+ set -l next (string split -m 1 " " $rest)[1]
23734
+ echo $next
23735
+ else
23736
+ echo (string split -m 1 " " $candidate)[1]
23737
+ end
23738
+ end | sort -u
23739
+ end
23740
+ complete -c mosse -f -a '(__mosse_complete)'
23741
+ `;
23742
+ }
23743
+ function renderCompletions(tree, shell) {
23744
+ const words = completionWords(tree);
23745
+ if (shell === "bash") return bashScript(words);
23746
+ if (shell === "zsh") return zshScript(words);
23747
+ return fishScript(words);
23748
+ }
23749
+
23618
23750
  // src/cli.ts
23619
23751
  var EXIT_USAGE = 2;
23620
23752
  var EXIT_AUTH = 3;
23753
+ var EXIT_NOT_FOUND = 4;
23754
+ var INBOX_WAIT_DEFAULT_MS = 25e3;
23755
+ var INBOX_WAIT_MAX_MS = 25e3;
23621
23756
  var UsageError = class extends Error {
23622
23757
  };
23623
23758
  function fullTree() {
@@ -23897,11 +24032,25 @@ async function runCli(argv, deps) {
23897
24032
  }
23898
24033
  const envWorkspace = deps.env.MOSSE_WORKSPACE?.trim();
23899
24034
  const workspaceOf = () => globals.workspace ?? envWorkspace;
23900
- const { head, tail } = splitHead(rest);
24035
+ const effective = rest[0] === "workspace" && rest[1] === "list" ? ["auth", "whoami"].concat(rest.slice(2)) : rest;
24036
+ if (rest[0] === "workspace" && rest.length === 1) {
24037
+ deps.stdout(workspaceHelp(tree));
24038
+ return 0;
24039
+ }
24040
+ const { head, tail } = splitHead(effective);
23901
24041
  if (!head.length) {
23902
- deps.stdout(tree.rootHelp);
24042
+ deps.stdout(`${tree.rootHelp}
24043
+ Local commands:
24044
+ auth <login|logout|status|token> credentials (not part of the tool surface)
24045
+ skill [install|status|upgrade] agent cheatsheet (mosse skill for the one-pager)
24046
+ doctor local environment check
24047
+ completions <bash|zsh|fish> shell completion script
24048
+ workspace list list workspaces (alias of auth whoami)
24049
+ `);
23903
24050
  return 0;
23904
24051
  }
24052
+ if (head[0] === "inbox" && head[1] === "wait") return handleInboxWait(rest.slice(2), deps, config2, globals);
24053
+ if (head[0] === "completions") return handleCompletions(rest.slice(1), deps, tree, globals);
23905
24054
  if (head[0] === "skill") return handleSkill(rest.slice(1), deps, configPath, config2, tree, globals);
23906
24055
  if (head[0] === "doctor") return handleDoctor(deps, config2, globals);
23907
24056
  if (head[0] === "auth" && (head[1] === void 0 || AUTH_SUBCOMMANDS.has(head[1])))
@@ -24075,6 +24224,156 @@ function sessionPath(tool, input2) {
24075
24224
  return encodeURIComponent(String(value));
24076
24225
  });
24077
24226
  }
24227
+ async function handleInboxWait(args, deps, config2, globals) {
24228
+ if (args[0] === "--help" || args[0] === "-h") {
24229
+ deps.stdout(
24230
+ [
24231
+ "mosse inbox wait [options]",
24232
+ "",
24233
+ "\u957F\u8F6E\u8BE2\u7B49\u4E00\u6761\u6536\u4EF6\u7BB1\u901A\u77E5(\u4E0E MCP \u7684 inbox_wait \u540C\u4E00\u8BED\u4E49)\u3002",
24234
+ "",
24235
+ "Options:",
24236
+ " --timeout-ms <ms> \u7B49\u5F85\u4E0A\u9650 1000\u201325000(\u9ED8\u8BA4 25000;--timeout \u662F\u522B\u540D)",
24237
+ " --user-id <uuid> token \u6240\u6709\u8005(\u7F3A\u7701\u81EA\u52A8\u4ECE token \u89E3\u6790)",
24238
+ " --workspace <id> \u5DE5\u4F5C\u533A(\u7F3A\u7701\u6309 token \u552F\u4E00 workspace \u63A8\u65AD)",
24239
+ "",
24240
+ "\u9000\u51FA\u7801:0 \u6536\u5230\u901A\u77E5 \xB7 2 \u7528\u6CD5 \xB7 3 \u8BA4\u8BC1/\u6743\u9650 \xB7 4 \u8D85\u65F6(\u672A\u6536\u5230\u901A\u77E5)",
24241
+ ""
24242
+ ].join("\n")
24243
+ );
24244
+ return 0;
24245
+ }
24246
+ let timeoutMs = INBOX_WAIT_DEFAULT_MS;
24247
+ let userId;
24248
+ for (let i = 0; i < args.length; i += 1) {
24249
+ const arg = args[i];
24250
+ if (arg === "--timeout-ms" || arg === "--timeout") {
24251
+ const raw = args[i + 1];
24252
+ i += 1;
24253
+ timeoutMs = Number(raw);
24254
+ if (!Number.isInteger(timeoutMs) || timeoutMs < 1e3 || timeoutMs > INBOX_WAIT_MAX_MS)
24255
+ return waitUsage(deps, globals, `--timeout-ms must be an integer between 1000 and ${INBOX_WAIT_MAX_MS}`);
24256
+ } else if (arg === "--user-id") {
24257
+ userId = args[i + 1];
24258
+ i += 1;
24259
+ if (!userId) return waitUsage(deps, globals, "--user-id needs a value");
24260
+ } else {
24261
+ return waitUsage(deps, globals, `unknown flag: ${arg}`);
24262
+ }
24263
+ }
24264
+ const apiUrl = globals.apiUrl ?? deps.env.MOSSE_API_URL?.trim() ?? config2.apiUrl ?? DEFAULT_API_URL;
24265
+ const token = globals.token ?? deps.env.MOSSE_TOKEN?.trim() ?? hostConfigOf(config2, apiUrl).token;
24266
+ if (!token) {
24267
+ deps.stderr(structuredError(globals, EXIT_AUTH, "unauthenticated", "run `mosse auth login` (or set MOSSE_TOKEN)"));
24268
+ return EXIT_AUTH;
24269
+ }
24270
+ let workspaceId = globals.workspace?.trim() || deps.env.MOSSE_WORKSPACE?.trim() || void 0;
24271
+ if (!userId || !workspaceId) {
24272
+ const listed = await callApi({ fetchImpl: deps.fetch, apiUrl, method: "GET", path: "/api/me/workspaces", token });
24273
+ if (!listed.ok) {
24274
+ const exit = exitCodeForStatus(listed.status);
24275
+ deps.stderr(structuredError(globals, exit, listed.error, withHttpHint(listed.message)));
24276
+ return exit;
24277
+ }
24278
+ const body = listed.body;
24279
+ userId = userId ?? body.userId;
24280
+ if (!userId) {
24281
+ deps.stderr(structuredError(globals, 1, "internal", "token lookup returned no userId"));
24282
+ return 1;
24283
+ }
24284
+ const workspaces = body.workspaces ?? [];
24285
+ if (!workspaceId) {
24286
+ if (workspaces.length === 1) workspaceId = workspaces[0].id;
24287
+ else if (workspaces.length === 0) {
24288
+ deps.stderr(structuredError(globals, EXIT_AUTH, "no_workspace", "this token cannot use any workspace"));
24289
+ return EXIT_AUTH;
24290
+ } else {
24291
+ const list = workspaces.map((workspace) => `${workspace.id} (${workspace.name})`).join(", ");
24292
+ deps.stderr(
24293
+ structuredError(
24294
+ globals,
24295
+ EXIT_USAGE,
24296
+ "workspace_required",
24297
+ `this token covers several workspaces; pass --workspace. Available: ${list}`
24298
+ )
24299
+ );
24300
+ return EXIT_USAGE;
24301
+ }
24302
+ }
24303
+ }
24304
+ const result = await callApi({
24305
+ fetchImpl: deps.fetch,
24306
+ apiUrl,
24307
+ method: "GET",
24308
+ path: `/api/inbox/wait?timeoutMs=${timeoutMs}`,
24309
+ token,
24310
+ ...workspaceId ? { workspaceId } : {}
24311
+ });
24312
+ if (!result.ok) {
24313
+ const exit = exitCodeForStatus(result.status);
24314
+ deps.stderr(structuredError(globals, exit, result.error, withHttpHint(result.message)));
24315
+ return exit;
24316
+ }
24317
+ const status = result.body.status;
24318
+ if (globals.json !== void 0) deps.stdout(renderOutput(result.body, outputOptions(globals)));
24319
+ else deps.stdout(status === "notification" ? "notification" : "timeout");
24320
+ if (status === "timeout") {
24321
+ deps.stderr("inbox wait timed out (no notification)");
24322
+ return EXIT_NOT_FOUND;
24323
+ }
24324
+ return 0;
24325
+ }
24326
+ function waitUsage(deps, globals, message) {
24327
+ deps.stderr(structuredError(globals, EXIT_USAGE, "usage", message));
24328
+ return EXIT_USAGE;
24329
+ }
24330
+ function workspaceHelp(tree) {
24331
+ const whoami2 = tree.byPath.get("auth whoami");
24332
+ return [
24333
+ "mosse workspace \u2014 workspaces available to this token",
24334
+ "",
24335
+ " mosse workspace list [--json] list workspaces (alias of `mosse auth whoami`)",
24336
+ "",
24337
+ whoami2 ? whoami2.help.trim() : "",
24338
+ ""
24339
+ ].join("\n");
24340
+ }
24341
+ async function handleCompletions(args, deps, tree, globals) {
24342
+ const shell = args[0];
24343
+ if (!shell || shell === "--help" || shell === "-h") {
24344
+ deps.stdout(
24345
+ [
24346
+ "mosse completions <shell>",
24347
+ "",
24348
+ "\u6253\u5370 shell \u8865\u5168\u811A\u672C(\u547D\u4EE4\u8BCD\u8868\u4E0E help / skill \u540C\u6E90)\u3002",
24349
+ "",
24350
+ `Shells: ${COMPLETION_SHELLS.join(", ")}`,
24351
+ "",
24352
+ " # zsh",
24353
+ ' mosse completions zsh > "${fpath[1]}/_mosse"',
24354
+ " # bash",
24355
+ " mosse completions bash > /etc/bash_completion.d/mosse",
24356
+ " # fish",
24357
+ " mosse completions fish > ~/.config/fish/completions/mosse.fish",
24358
+ ""
24359
+ ].join("\n")
24360
+ );
24361
+ return 0;
24362
+ }
24363
+ if (!COMPLETION_SHELLS.includes(shell)) {
24364
+ deps.stderr(
24365
+ structuredError(
24366
+ globals,
24367
+ EXIT_USAGE,
24368
+ "usage",
24369
+ `unknown shell: ${shell} (expected ${COMPLETION_SHELLS.join("|")})`
24370
+ )
24371
+ );
24372
+ return EXIT_USAGE;
24373
+ }
24374
+ deps.stdout(renderCompletions(tree, shell));
24375
+ return 0;
24376
+ }
24078
24377
  async function handleSkill(tokens, deps, configPath, _config, tree, globals) {
24079
24378
  const flagValue = (name) => {
24080
24379
  for (let i = 0; i < tokens.length; i += 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosse-ai/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mosse": "./dist/index.js"