@openbkn/bkn-sdk 0.1.1-alpha.13 → 0.1.1-alpha.15
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/LICENSE +132 -201
- package/README.md +34 -24
- package/README.zh.md +11 -10
- package/dist/{chunk-RSX5YMFM.js → chunk-KF3J46WL.js} +26 -3
- package/dist/chunk-KF3J46WL.js.map +1 -0
- package/dist/cli.js +48 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +17 -11
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-RSX5YMFM.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
use,
|
|
38
38
|
whoami,
|
|
39
39
|
writePlatformConfig
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-KF3J46WL.js";
|
|
41
41
|
|
|
42
42
|
// src/cli.ts
|
|
43
43
|
import { Command as Command17 } from "commander";
|
|
@@ -45,10 +45,10 @@ import { Command as Command17 } from "commander";
|
|
|
45
45
|
// package.json
|
|
46
46
|
var package_default = {
|
|
47
47
|
name: "@openbkn/bkn-sdk",
|
|
48
|
-
version: "0.1.1-alpha.
|
|
48
|
+
version: "0.1.1-alpha.15",
|
|
49
49
|
description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
50
50
|
type: "module",
|
|
51
|
-
license: "
|
|
51
|
+
license: "SEE LICENSE IN LICENSE",
|
|
52
52
|
engines: {
|
|
53
53
|
node: ">=18"
|
|
54
54
|
},
|
|
@@ -627,9 +627,7 @@ function authCommand() {
|
|
|
627
627
|
var int = (v) => Number.parseInt(v, 10);
|
|
628
628
|
var DEFAULT_RESET_PASSWORD = "openbkn";
|
|
629
629
|
function adminCommand() {
|
|
630
|
-
const admin = new Command2("admin").description(
|
|
631
|
-
"Operator CLI (kweaver-admin): org, user, role, models, audit"
|
|
632
|
-
);
|
|
630
|
+
const admin = new Command2("admin").description("Operator CLI: org, user, role, models, audit");
|
|
633
631
|
registerAuthLeaves(admin.command("auth").description("Operator authentication"));
|
|
634
632
|
const org = admin.command("org").description("Departments and org structure");
|
|
635
633
|
org.command("list").description("List departments").option("--role <r>", "role qualifier", "super_admin").option("--name <s>", "filter by name").option("--limit <n>", "page size", int, 100).option("--offset <n>", "page offset", int, 0).action(async (opts, cmd) => {
|
|
@@ -1983,6 +1981,12 @@ async function handle(client, reqMsg, res) {
|
|
|
1983
1981
|
// src/commands/model.ts
|
|
1984
1982
|
import { Command as Command11 } from "commander";
|
|
1985
1983
|
var int8 = (v) => Number.parseInt(v, 10);
|
|
1984
|
+
async function resolveLlmModelName(client, model) {
|
|
1985
|
+
if (!/^\d+$/.test(model)) return model;
|
|
1986
|
+
const detail = await client.models.llm.get(model);
|
|
1987
|
+
if (!detail?.model_name) throw new InputError(`No LLM found with id ${model}.`);
|
|
1988
|
+
return detail.model_name;
|
|
1989
|
+
}
|
|
1986
1990
|
function addManagementCommands(parent, kind) {
|
|
1987
1991
|
parent.command("add").description("Register a model (definition JSON via --body / --body-file)").option("--body <json>", "model definition JSON").option("--body-file <path>", "read model definition JSON from a file").action(async (opts, cmd) => {
|
|
1988
1992
|
printJson(await clientFrom(cmd).models[kind].add(readBody(opts)), outputOptions(cmd));
|
|
@@ -1998,7 +2002,9 @@ function addManagementCommands(parent, kind) {
|
|
|
1998
2002
|
});
|
|
1999
2003
|
}
|
|
2000
2004
|
function modelCommand() {
|
|
2001
|
-
const model = new Command11("model").description(
|
|
2005
|
+
const model = new Command11("model").description(
|
|
2006
|
+
"Model factory \u2014 LLM / small-model CRUD, chat / embeddings / rerank, default selection"
|
|
2007
|
+
);
|
|
2002
2008
|
const llm = model.command("llm").description("Large language models");
|
|
2003
2009
|
llm.command("list").description("List LLM models").option("--name <s>", "filter by name").option("--type <t>", "model type filter").option("--limit <n>", "page size", int8, DEFAULT_LIST_LIMIT).option("--page <n>", "page", int8, 1).action(async (opts, cmd) => {
|
|
2004
2010
|
printJson(
|
|
@@ -2014,14 +2020,22 @@ function modelCommand() {
|
|
|
2014
2020
|
llm.command("get <modelId>").description("Get an LLM model").action(async (id, _opts, cmd) => {
|
|
2015
2021
|
printJson(await clientFrom(cmd).models.llm.get(id), outputOptions(cmd));
|
|
2016
2022
|
});
|
|
2017
|
-
llm.command("chat <
|
|
2023
|
+
llm.command("chat <model>").description("OpenAI-compatible chat completion (<model> = model name or numeric id)").requiredOption("-m, --message <text>", "user message").option("--stream", "stream the reply token-by-token to stdout").action(async (model2, opts, cmd) => {
|
|
2024
|
+
const client = clientFrom(cmd);
|
|
2025
|
+
const name = await resolveLlmModelName(client, model2);
|
|
2018
2026
|
const messages = [{ role: "user", content: opts.message }];
|
|
2019
2027
|
if (opts.stream) {
|
|
2020
|
-
await
|
|
2028
|
+
await client.models.llm.chatStream(name, messages, (t) => process.stdout.write(t));
|
|
2021
2029
|
process.stdout.write("\n");
|
|
2022
2030
|
return;
|
|
2023
2031
|
}
|
|
2024
|
-
printJson(await
|
|
2032
|
+
printJson(await client.models.llm.chat(name, messages), outputOptions(cmd));
|
|
2033
|
+
});
|
|
2034
|
+
llm.command("set-default <modelId>").description("Set this LLM as the system default (admin)").action(async (id, _opts, cmd) => {
|
|
2035
|
+
printJson(await clientFrom(cmd).models.llm.setDefault(id, true), outputOptions(cmd));
|
|
2036
|
+
});
|
|
2037
|
+
llm.command("unset-default <modelId>").description("Clear this LLM as the system default (admin)").action(async (id, _opts, cmd) => {
|
|
2038
|
+
printJson(await clientFrom(cmd).models.llm.setDefault(id, false), outputOptions(cmd));
|
|
2025
2039
|
});
|
|
2026
2040
|
addManagementCommands(llm, "llm");
|
|
2027
2041
|
const small = model.command("small").description("Small models (embedding / reranker)");
|
|
@@ -2051,7 +2065,31 @@ function modelCommand() {
|
|
|
2051
2065
|
outputOptions(cmd)
|
|
2052
2066
|
);
|
|
2053
2067
|
});
|
|
2068
|
+
small.command("get-default").description("Show the system default small model for a type").option("--type <t>", "model type: embedding | reranker", "embedding").action(async (opts, cmd) => {
|
|
2069
|
+
printJson(await clientFrom(cmd).models.small.getDefault(opts.type), outputOptions(cmd));
|
|
2070
|
+
});
|
|
2071
|
+
small.command("set-default <modelId>").description("Set this small model as the system default for its type (admin)").action(async (id, _opts, cmd) => {
|
|
2072
|
+
printJson(await clientFrom(cmd).models.small.setDefault(id, true), outputOptions(cmd));
|
|
2073
|
+
});
|
|
2074
|
+
small.command("unset-default <modelId>").description("Clear this small model as the system default (admin)").action(async (id, _opts, cmd) => {
|
|
2075
|
+
printJson(await clientFrom(cmd).models.small.setDefault(id, false), outputOptions(cmd));
|
|
2076
|
+
});
|
|
2054
2077
|
addManagementCommands(small, "small");
|
|
2078
|
+
model.addHelpText(
|
|
2079
|
+
"after",
|
|
2080
|
+
`
|
|
2081
|
+
Identifiers:
|
|
2082
|
+
\u2022 get / set-default / delete take the numeric model id (e.g. 2071747547839467520).
|
|
2083
|
+
\u2022 chat takes a model NAME, but also accepts a numeric id (resolved to its name).
|
|
2084
|
+
|
|
2085
|
+
Examples:
|
|
2086
|
+
$ openbkn model llm list # ids + the 'default' flag
|
|
2087
|
+
$ openbkn model llm chat deepseek_v4_flash -m hi # by name
|
|
2088
|
+
$ openbkn model llm chat 2071747547839467520 -m hi --stream # by id, streamed
|
|
2089
|
+
$ openbkn model llm set-default 2071747547839467520 # system default LLM
|
|
2090
|
+
$ openbkn model small get-default --type embedding # current default
|
|
2091
|
+
$ openbkn model small set-default <id> # default embedding/reranker`
|
|
2092
|
+
);
|
|
2055
2093
|
return group(model, "MODELS & SKILLS");
|
|
2056
2094
|
}
|
|
2057
2095
|
|