@nextxai/cli 0.3.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/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/dist/auth/mcp-oauth.js +2 -3
- package/dist/commands/tools.js +3 -3
- package/dist/core/brand.js +8 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/dist/auth/mcp-oauth.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// MCP resource (RFC 8707): public client identified by its metadata document URL, PKCE + loopback, one consent
|
|
3
3
|
// in the browser, then refresh tokens.
|
|
4
4
|
import { fetch } from "undici";
|
|
5
|
-
import { brand } from "../core/brand.js";
|
|
5
|
+
import { brand, visibleModule } from "../core/brand.js";
|
|
6
6
|
import { context } from "../core/context.js";
|
|
7
7
|
import { CliError, Exit } from "../core/errors.js";
|
|
8
8
|
import { tr } from "../core/i18n.js";
|
|
@@ -54,8 +54,7 @@ async function discover() {
|
|
|
54
54
|
export const cliClientId = () => `${context().endpoints.docs}/cli/oauth-client.json`;
|
|
55
55
|
/** Scopes to ask for: everything the server offers, limited to the brand's modules. */
|
|
56
56
|
function wantedScopes(offered) {
|
|
57
|
-
|
|
58
|
-
return offered.filter((s) => !mods || mods.includes(s.split(":")[0])).join(" ");
|
|
57
|
+
return offered.filter((s) => visibleModule(s)).join(" ");
|
|
59
58
|
}
|
|
60
59
|
export async function authorizeMcp(opts = {}) {
|
|
61
60
|
const { resource, as, asUrl } = await discover();
|
package/dist/commands/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option } from "commander";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import { brand, envVar } from "../core/brand.js";
|
|
3
|
+
import { brand, envVar, visibleModule } from "../core/brand.js";
|
|
4
4
|
import { CliError, Exit } from "../core/errors.js";
|
|
5
5
|
import { currentLang, tr } from "../core/i18n.js";
|
|
6
6
|
import { c, emit, info, json, ok, table } from "../core/output.js";
|
|
@@ -12,7 +12,7 @@ import { browserAvailable } from "./auth.js";
|
|
|
12
12
|
let publicCache;
|
|
13
13
|
export async function publicTools() {
|
|
14
14
|
publicCache ??= (await loadPublicTools())
|
|
15
|
-
.filter((t) =>
|
|
15
|
+
.filter((t) => visibleModule(t.module));
|
|
16
16
|
return publicCache;
|
|
17
17
|
}
|
|
18
18
|
async function loadPublicTools() {
|
|
@@ -93,7 +93,7 @@ export function registerTools(program) {
|
|
|
93
93
|
});
|
|
94
94
|
tools.command("list", { isDefault: true })
|
|
95
95
|
.description(tr("danh sách công cụ", "list tools"))
|
|
96
|
-
.option("--module <m>", tr(
|
|
96
|
+
.option("--module <m>", tr(`lọc theo phân hệ (${brand().examples.modules})`, `filter by module (${brand().examples.modules})`))
|
|
97
97
|
.addOption(new Option("--kind <k>", tr("lọc theo loại", "filter by kind")).choices(["read", "proposal", "export"]))
|
|
98
98
|
.option("--public", tr("danh mục công khai (không cần đăng nhập)", "public catalog (no login)"))
|
|
99
99
|
.action(async (o) => {
|
package/dist/core/brand.js
CHANGED
|
@@ -10,11 +10,12 @@ const NEXTX = {
|
|
|
10
10
|
clientId: "nextx-cli",
|
|
11
11
|
envPrefix: "NEXTX",
|
|
12
12
|
mobileApp: "NextX",
|
|
13
|
-
examples: { scopes: "crm.contacts.view,sales.orders.view", ciKinds: "crm.tasks.create" },
|
|
13
|
+
examples: { scopes: "crm.contacts.view,sales.orders.view", ciKinds: "crm.tasks.create", modules: "crm, sales, dms…" },
|
|
14
14
|
example: { vi: "doanh thu hôm qua", en: "yesterday's revenue" },
|
|
15
15
|
apiExample: "GET /crm/contacts -f q=Minh",
|
|
16
16
|
ciSettings: { vi: "Thiết lập › Ứng dụng & API › CI", en: "Settings › Apps & API › CI" },
|
|
17
17
|
modules: null,
|
|
18
|
+
hiddenModules: ["gym", "golf"],
|
|
18
19
|
env: {
|
|
19
20
|
prod: {
|
|
20
21
|
api: "https://api.nextx.vn",
|
|
@@ -52,3 +53,9 @@ export function envVar(name) {
|
|
|
52
53
|
const v = process.env[`${current.envPrefix}_${name}`];
|
|
53
54
|
return v === undefined || v === "" ? undefined : v;
|
|
54
55
|
}
|
|
56
|
+
/** Whether a module (or `module:scope`, `module.resource.action`) is shown by the current brand. */
|
|
57
|
+
export function visibleModule(code) {
|
|
58
|
+
const m = code.split(/[.:]/)[0].toLowerCase();
|
|
59
|
+
const b = brand();
|
|
60
|
+
return !b.hiddenModules.includes(m) && (!b.modules || b.modules.includes(m));
|
|
61
|
+
}
|