@openbkn/bkn-sdk 0.1.1-alpha.10 → 0.1.1-alpha.12

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/dist/cli.js CHANGED
@@ -37,15 +37,15 @@ import {
37
37
  use,
38
38
  whoami,
39
39
  writePlatformConfig
40
- } from "./chunk-GNL6Z5VF.js";
40
+ } from "./chunk-3FVB6VFQ.js";
41
41
 
42
42
  // src/cli.ts
43
- import { Command as Command16 } from "commander";
43
+ import { Command as Command17 } from "commander";
44
44
 
45
45
  // package.json
46
46
  var package_default = {
47
47
  name: "@openbkn/bkn-sdk",
48
- version: "0.1.1-alpha.10",
48
+ version: "0.1.1-alpha.12",
49
49
  description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
50
50
  type: "module",
51
51
  license: "Apache-2.0",
@@ -215,7 +215,8 @@ var ROW_ENVELOPES = [
215
215
  "users",
216
216
  "roles",
217
217
  "departments",
218
- "members"
218
+ "members",
219
+ "keys"
219
220
  ];
220
221
  function toRows(value) {
221
222
  const isRowArray = (v) => Array.isArray(v) && v.length > 0 && v.every((x) => x !== null && typeof x === "object" && !Array.isArray(x));
@@ -1074,8 +1075,75 @@ function agentCommand() {
1074
1075
  return group(cmd, "DECISION AGENT");
1075
1076
  }
1076
1077
 
1077
- // src/commands/bkn.ts
1078
+ // src/commands/appkey.ts
1078
1079
  import { Command as Command4 } from "commander";
1080
+ var int3 = (v) => Number.parseInt(v, 10);
1081
+ var DAY_MS = 864e5;
1082
+ function printNewKey(created, out) {
1083
+ if (out.json || out.compact) {
1084
+ printJson(created, out);
1085
+ return;
1086
+ }
1087
+ process.stderr.write(
1088
+ "\u26A0\uFE0F Copy this key now \u2014 the plaintext is shown only once and cannot be retrieved again.\n\n"
1089
+ );
1090
+ const fields = [
1091
+ ["key", created.key],
1092
+ ["name", created.name],
1093
+ ["id", `${created.id} (use this to revoke/regenerate)`],
1094
+ ["key_id", created.key_id],
1095
+ ["expires_at", created.expires_at ?? "never"]
1096
+ ];
1097
+ const w = Math.max(...fields.map(([k]) => k.length));
1098
+ for (const [k, v] of fields) process.stdout.write(` ${k.padEnd(w)} ${v}
1099
+ `);
1100
+ }
1101
+ function appkeyCommand() {
1102
+ const appkey = new Command4("appkey").description(
1103
+ "AppKeys \u2014 user-issued long-lived credentials (bak_) for the Context Loader"
1104
+ );
1105
+ appkey.command("list").description("List your own AppKeys (no secrets)").action(async (_opts, cmd) => {
1106
+ printJson(await clientFrom(cmd).appKeys.list(), outputOptions(cmd));
1107
+ });
1108
+ appkey.command("create").description("Issue an AppKey \u2014 the plaintext key is shown ONCE, on create").requiredOption("--name <s>", "display name (to tell keys apart)").option("--expires-at <rfc3339>", "expiry as RFC3339 (e.g. 2027-01-01T00:00:00Z)").option("--expire-days <n>", "expiry in N days from now (alternative to --expires-at)", int3).option("--never-expire", "never expire (wins over --expires-at/--expire-days)").action(async (opts, cmd) => {
1109
+ let expiresAt = opts.expiresAt;
1110
+ if (opts.expireDays !== void 0) {
1111
+ if (!Number.isFinite(opts.expireDays) || opts.expireDays <= 0) {
1112
+ throw new InputError("--expire-days must be a positive integer.");
1113
+ }
1114
+ if (expiresAt) {
1115
+ throw new InputError("Use either --expires-at or --expire-days, not both.");
1116
+ }
1117
+ expiresAt = new Date(Date.now() + opts.expireDays * DAY_MS).toISOString();
1118
+ }
1119
+ const created = await clientFrom(cmd).appKeys.create({
1120
+ name: opts.name,
1121
+ expiresAt,
1122
+ neverExpire: Boolean(opts.neverExpire)
1123
+ });
1124
+ printNewKey(created, outputOptions(cmd));
1125
+ });
1126
+ appkey.command("regenerate <id>").alias("rotate").description("Rotate a key in place \u2014 mints a new plaintext; the old bak_ dies immediately").action(async (id, _opts, cmd) => {
1127
+ const created = await clientFrom(cmd).appKeys.regenerate(id);
1128
+ printNewKey(created, outputOptions(cmd));
1129
+ });
1130
+ appkey.command("revoke <id>").alias("delete").alias("rm").description("Revoke one of your AppKeys (immediate; use the `id`, not `key_id`)").action(async (id, _opts, cmd) => {
1131
+ await clientFrom(cmd).appKeys.revoke(id);
1132
+ printJson({ revoked: id }, outputOptions(cmd));
1133
+ });
1134
+ const admin = appkey.command("admin").description("Admin governance over all AppKeys");
1135
+ admin.command("list").description("List all AppKeys, or one owner's (adds owner_user_id)").option("--owner-id <id>", "filter to a single owner").action(async (opts, cmd) => {
1136
+ printJson(await clientFrom(cmd).appKeys.adminList(opts.ownerId), outputOptions(cmd));
1137
+ });
1138
+ admin.command("revoke <id>").alias("delete").alias("rm").description("Revoke any AppKey by id").action(async (id, _opts, cmd) => {
1139
+ await clientFrom(cmd).appKeys.adminRevoke(id);
1140
+ printJson({ revoked: id }, outputOptions(cmd));
1141
+ });
1142
+ return group(appkey, "AUTHENTICATION & CONFIG");
1143
+ }
1144
+
1145
+ // src/commands/bkn.ts
1146
+ import { Command as Command5 } from "commander";
1079
1147
 
1080
1148
  // src/utils/bkn-validate.ts
1081
1149
  import { existsSync, readFileSync as readFileSync2, readdirSync, statSync } from "fs";
@@ -1193,10 +1261,10 @@ function validateBknDirectory(dirPath) {
1193
1261
  }
1194
1262
 
1195
1263
  // src/commands/bkn.ts
1196
- var int3 = (v) => Number.parseInt(v, 10);
1264
+ var int4 = (v) => Number.parseInt(v, 10);
1197
1265
  function bknCommand() {
1198
- const bkn = new Command4("bkn").description("Knowledge networks \u2014 list, query, schema, instances");
1199
- bkn.command("list").description("List knowledge networks").option("--limit <n>", "page size", int3, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int3, 0).option("--name-pattern <s>", "filter by name pattern").option("--tag <s>", "filter by tag").option("--sort <field>", "sort field", "update_time").option("--direction <dir>", "asc | desc", "desc").action(async (_opts, cmd) => {
1266
+ const bkn = new Command5("bkn").description("Knowledge networks \u2014 list, query, schema, instances");
1267
+ bkn.command("list").description("List knowledge networks").option("--limit <n>", "page size", int4, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int4, 0).option("--name-pattern <s>", "filter by name pattern").option("--tag <s>", "filter by tag").option("--sort <field>", "sort field", "update_time").option("--direction <dir>", "asc | desc", "desc").action(async (_opts, cmd) => {
1200
1268
  const o = cmd.optsWithGlobals();
1201
1269
  const data = await clientFrom(cmd).kn.list({
1202
1270
  limit: o.limit,
@@ -1215,7 +1283,7 @@ function bknCommand() {
1215
1283
  });
1216
1284
  printJson(data, outputOptions(cmd));
1217
1285
  });
1218
- bkn.command("search <kn-id> <query>").description("Semantic search within a knowledge network").option("--max-concepts <n>", "max concepts to return", int3, 10).option("--mode <mode>", "retrieval mode", "keyword_vector_retrieval").action(async (knId, query, opts, cmd) => {
1286
+ bkn.command("search <kn-id> <query>").description("Semantic search within a knowledge network").option("--max-concepts <n>", "max concepts to return", int4, 10).option("--mode <mode>", "retrieval mode", "keyword_vector_retrieval").action(async (knId, query, opts, cmd) => {
1219
1287
  const data = await clientFrom(cmd).kn.search(knId, query, {
1220
1288
  maxConcepts: opts.maxConcepts,
1221
1289
  mode: opts.mode
@@ -1304,7 +1372,7 @@ function bknCommand() {
1304
1372
  printJson(await clientFrom(cmd).kn.subgraph(knId, readBody(opts)), outputOptions(cmd));
1305
1373
  });
1306
1374
  const actionLog = bkn.command("action-log").description("Action logs \u2014 list/get/cancel");
1307
- actionLog.command("list <kn-id>").description("List action logs").option("--status <s>", "filter by status").option("--action-type-id <id>", "filter by action type").option("--limit <n>", "page size", int3, DEFAULT_LIST_LIMIT).action(async (knId, opts, cmd) => {
1375
+ actionLog.command("list <kn-id>").description("List action logs").option("--status <s>", "filter by status").option("--action-type-id <id>", "filter by action type").option("--limit <n>", "page size", int4, DEFAULT_LIST_LIMIT).action(async (knId, opts, cmd) => {
1308
1376
  printJson(
1309
1377
  await clientFrom(cmd).kn.actionLogs(knId, {
1310
1378
  status: opts.status,
@@ -1484,7 +1552,7 @@ function bknCommand() {
1484
1552
  printJson(result, outputOptions(cmd));
1485
1553
  if (!result.valid) process.exitCode = 1;
1486
1554
  });
1487
- bkn.command("create-from-csv <catalog-id>").description("Import CSV files into a Vega catalog, then build a KN from them").requiredOption("--files <glob>", "CSV paths (comma-separated or glob)").requiredOption("--name <name>", "knowledge network name").option("--table-prefix <s>", "prefix for derived table names", "").option("--batch-size <n>", "rows per insert batch", int3, 500).option("--tables <list>", "subset of imported tables to include in the KN").option("--pk-map <map>", "explicit primary keys: '<table>:<col>[,...]'").option("--build", "submit a Vega build task per resource after creation").option(
1555
+ bkn.command("create-from-csv <catalog-id>").description("Import CSV files into a Vega catalog, then build a KN from them").requiredOption("--files <glob>", "CSV paths (comma-separated or glob)").requiredOption("--name <name>", "knowledge network name").option("--table-prefix <s>", "prefix for derived table names", "").option("--batch-size <n>", "rows per insert batch", int4, 500).option("--tables <list>", "subset of imported tables to include in the KN").option("--pk-map <map>", "explicit primary keys: '<table>:<col>[,...]'").option("--build", "submit a Vega build task per resource after creation").option(
1488
1556
  "--embedding-fields <map>",
1489
1557
  "columns to vectorize per table (with --build): '<table>:<col>[+<col>...][,...]'"
1490
1558
  ).option("--embedding-model <id>", "embedding model id for the vector index (with --build)").option("--no-rollback", "keep a partially-created KN on failure").action(async (catalogId, opts, cmd) => {
@@ -1510,13 +1578,13 @@ function bknCommand() {
1510
1578
  }
1511
1579
 
1512
1580
  // src/commands/call.ts
1513
- import { Command as Command5 } from "commander";
1581
+ import { Command as Command6 } from "commander";
1514
1582
  function collect(value, prev) {
1515
1583
  prev.push(value);
1516
1584
  return prev;
1517
1585
  }
1518
1586
  function callCommand() {
1519
- const cmd = new Command5("call").alias("curl").description("Call an API with curl-style flags and auto-injected auth headers").argument("<url>", "API path (e.g. /api/...) or absolute URL").option("-X, --request <method>", "HTTP method").option("-H, --header <header>", 'extra header "Name: value" (repeatable)', collect, []).option("-d, --data <body>", "request body (sets JSON content-type if unset)").option("--data-raw <body>", "alias for --data").option(
1587
+ const cmd = new Command6("call").alias("curl").description("Call an API with curl-style flags and auto-injected auth headers").argument("<url>", "API path (e.g. /api/...) or absolute URL").option("-X, --request <method>", "HTTP method").option("-H, --header <header>", 'extra header "Name: value" (repeatable)', collect, []).option("-d, --data <body>", "request body (sets JSON content-type if unset)").option("--data-raw <body>", "alias for --data").option(
1520
1588
  "-F, --form <field>",
1521
1589
  "multipart field key=value or key=@file (repeatable)",
1522
1590
  collect,
@@ -1551,14 +1619,14 @@ function callCommand() {
1551
1619
  }
1552
1620
 
1553
1621
  // src/commands/config.ts
1554
- import { Command as Command6 } from "commander";
1622
+ import { Command as Command7 } from "commander";
1555
1623
  function requireActive() {
1556
1624
  const baseUrl = activePlatform();
1557
1625
  if (!baseUrl) throw new InputError("No active platform. Run `openbkn auth login <url>` first.");
1558
1626
  return baseUrl;
1559
1627
  }
1560
1628
  function configCommand() {
1561
- const config = new Command6("config").description("Per-platform CLI configuration");
1629
+ const config = new Command7("config").description("Per-platform CLI configuration");
1562
1630
  config.command("show").description("Show the active platform and business domain").action((_opts, cmd) => {
1563
1631
  const baseUrl = activePlatform();
1564
1632
  printJson(
@@ -1591,8 +1659,8 @@ function configCommand() {
1591
1659
  }
1592
1660
 
1593
1661
  // src/commands/context.ts
1594
- import { Command as Command7 } from "commander";
1595
- var int4 = (v) => Number.parseInt(v, 10);
1662
+ import { Command as Command8 } from "commander";
1663
+ var int5 = (v) => Number.parseInt(v, 10);
1596
1664
  var collectArg = (v, prev) => {
1597
1665
  prev.push(v);
1598
1666
  return prev;
@@ -1637,10 +1705,10 @@ function printToolList(res, out) {
1637
1705
  printJson(rows, out);
1638
1706
  }
1639
1707
  function contextCommand() {
1640
- const cmd = new Command7("context").description(
1708
+ const cmd = new Command8("context").description(
1641
1709
  "Context loader (MCP) \u2014 schema discovery, instance query, skill recall"
1642
1710
  );
1643
- cmd.command("search-schema <kn-id> <query>").description("Search object/relation/action/metric schemas").option("--scope <list>", "comma-separated scopes (object,relation,action,metric)").option("--max <n>", "max concepts", int4).action(async (knId, query, opts, cmd2) => {
1711
+ cmd.command("search-schema <kn-id> <query>").description("Search object/relation/action/metric schemas").option("--scope <list>", "comma-separated scopes (object,relation,action,metric)").option("--max <n>", "max concepts", int5).action(async (knId, query, opts, cmd2) => {
1644
1712
  const data = await clientFrom(cmd2).context.searchSchema(knId, query, {
1645
1713
  searchScope: opts.scope ? String(opts.scope).split(",") : void 0,
1646
1714
  maxConcepts: opts.max
@@ -1656,7 +1724,7 @@ function contextCommand() {
1656
1724
  }
1657
1725
  printJson(await clientFrom(cmd2).context.queryObjectInstance(knId, args), outputOptions(cmd2));
1658
1726
  });
1659
- cmd.command("find-skills <kn-id> <object-type-id>").description("Recall skills for an object type").option("--top-k <n>", "max skills (1-20)", int4).action(async (knId, otId, opts, cmd2) => {
1727
+ cmd.command("find-skills <kn-id> <object-type-id>").description("Recall skills for an object type").option("--top-k <n>", "max skills (1-20)", int5).action(async (knId, otId, opts, cmd2) => {
1660
1728
  printJson(
1661
1729
  await clientFrom(cmd2).context.findSkills(knId, otId, opts.topK),
1662
1730
  outputOptions(cmd2)
@@ -1744,10 +1812,10 @@ function contextCommand() {
1744
1812
  }
1745
1813
 
1746
1814
  // src/commands/dataflow.ts
1747
- import { Command as Command8 } from "commander";
1748
- var int5 = (v) => Number.parseInt(v, 10);
1815
+ import { Command as Command9 } from "commander";
1816
+ var int6 = (v) => Number.parseInt(v, 10);
1749
1817
  function dataflowCommand() {
1750
- const cmd = new Command8("dataflow").description("Dataflow document workflows \u2014 list, runs, logs");
1818
+ const cmd = new Command9("dataflow").description("Dataflow document workflows \u2014 list, runs, logs");
1751
1819
  cmd.command("list").description("List all dataflows").action(async (_opts, cmd2) => {
1752
1820
  printJson(await clientFrom(cmd2).dataflows.list(), outputOptions(cmd2));
1753
1821
  });
@@ -1757,7 +1825,7 @@ function dataflowCommand() {
1757
1825
  outputOptions(cmd2)
1758
1826
  );
1759
1827
  });
1760
- cmd.command("logs <dagId> <instanceId>").description("Show logs for one run").option("--page <n>", "page", int5, 0).option("--limit <n>", "page size", int5, DEFAULT_LIST_LIMIT).action(async (dagId, instanceId, opts, cmd2) => {
1828
+ cmd.command("logs <dagId> <instanceId>").description("Show logs for one run").option("--page <n>", "page", int6, 0).option("--limit <n>", "page size", int6, DEFAULT_LIST_LIMIT).action(async (dagId, instanceId, opts, cmd2) => {
1761
1829
  printJson(
1762
1830
  await clientFrom(cmd2).dataflows.logs(dagId, instanceId, {
1763
1831
  page: opts.page,
@@ -1819,8 +1887,8 @@ function dataflowCommand() {
1819
1887
 
1820
1888
  // src/commands/explore.ts
1821
1889
  import { createServer } from "http";
1822
- import { Command as Command9 } from "commander";
1823
- var int6 = (v) => Number.parseInt(v, 10);
1890
+ import { Command as Command10 } from "commander";
1891
+ var int7 = (v) => Number.parseInt(v, 10);
1824
1892
  var ROUTES = {
1825
1893
  "GET /api/bkn/meta": (c, q) => c.kn.get(req(q, "knId")),
1826
1894
  "POST /api/bkn/search": (c, _q, b) => c.kn.search(str(b.knId), str(b.query), {
@@ -1865,10 +1933,10 @@ var INDEX = `<!doctype html><meta charset="utf-8"><title>openbkn explore</title>
1865
1933
  <p>Read-only JSON endpoints for bkn + vega:</p>
1866
1934
  <ul>${Object.keys(ROUTES).map((r) => `<li><code>${r}</code></li>`).join("")}</ul>`;
1867
1935
  function exploreCommand() {
1868
- const cmd = new Command9("explore").description(
1936
+ const cmd = new Command10("explore").description(
1869
1937
  "Start a local web server with read-only bkn + vega JSON endpoints"
1870
1938
  );
1871
- cmd.option("--port <n>", "port to listen on", int6, 7777).option("--host <h>", "host to bind", "127.0.0.1").action(async (opts, command) => {
1939
+ cmd.option("--port <n>", "port to listen on", int7, 7777).option("--host <h>", "host to bind", "127.0.0.1").action(async (opts, command) => {
1872
1940
  const client = clientFrom(command);
1873
1941
  const server = createServer((reqMsg, res) => {
1874
1942
  void handle(client, reqMsg, res);
@@ -1906,8 +1974,8 @@ async function handle(client, reqMsg, res) {
1906
1974
  }
1907
1975
 
1908
1976
  // src/commands/model.ts
1909
- import { Command as Command10 } from "commander";
1910
- var int7 = (v) => Number.parseInt(v, 10);
1977
+ import { Command as Command11 } from "commander";
1978
+ var int8 = (v) => Number.parseInt(v, 10);
1911
1979
  function addManagementCommands(parent, kind) {
1912
1980
  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) => {
1913
1981
  printJson(await clientFrom(cmd).models[kind].add(readBody(opts)), outputOptions(cmd));
@@ -1923,9 +1991,9 @@ function addManagementCommands(parent, kind) {
1923
1991
  });
1924
1992
  }
1925
1993
  function modelCommand() {
1926
- const model = new Command10("model").description("Model factory \u2014 LLM / small-model CRUD + chat");
1994
+ const model = new Command11("model").description("Model factory \u2014 LLM / small-model CRUD + chat");
1927
1995
  const llm = model.command("llm").description("Large language models");
1928
- llm.command("list").description("List LLM models").option("--name <s>", "filter by name").option("--type <t>", "model type filter").option("--limit <n>", "page size", int7, DEFAULT_LIST_LIMIT).option("--page <n>", "page", int7, 1).action(async (opts, cmd) => {
1996
+ 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) => {
1929
1997
  printJson(
1930
1998
  await clientFrom(cmd).models.llm.list({
1931
1999
  name: opts.name,
@@ -1950,7 +2018,7 @@ function modelCommand() {
1950
2018
  });
1951
2019
  addManagementCommands(llm, "llm");
1952
2020
  const small = model.command("small").description("Small models (embedding / reranker)");
1953
- small.command("list").description("List small models").option("--name <s>", "filter by name").option("--type <t>", "model type filter").option("--limit <n>", "page size", int7, DEFAULT_LIST_LIMIT).option("--page <n>", "page", int7, 1).action(async (opts, cmd) => {
2021
+ small.command("list").description("List small 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) => {
1954
2022
  printJson(
1955
2023
  await clientFrom(cmd).models.small.list({
1956
2024
  name: opts.name,
@@ -1981,11 +2049,11 @@ function modelCommand() {
1981
2049
  }
1982
2050
 
1983
2051
  // src/commands/resource.ts
1984
- import { Command as Command11 } from "commander";
1985
- var int8 = (v) => Number.parseInt(v, 10);
2052
+ import { Command as Command12 } from "commander";
2053
+ var int9 = (v) => Number.parseInt(v, 10);
1986
2054
  function resourceCommand() {
1987
- const cmd = new Command11("resource").alias("res").description("Resources \u2014 list, find, get, query, delete");
1988
- cmd.command("list").description("List resources under a catalog").option("--catalog-id <id>", "filter by catalog id").option("--datasource-id <id>", "alias of --catalog-id").option("--category <c>", "resource category (table | logicview | dataset)").option("--type <c>", "alias of --category").option("--limit <n>", "page size", int8, DEFAULT_LIST_LIMIT).action(async (opts, cmd2) => {
2055
+ const cmd = new Command12("resource").alias("res").description("Resources \u2014 list, find, get, query, delete");
2056
+ cmd.command("list").description("List resources under a catalog").option("--catalog-id <id>", "filter by catalog id").option("--datasource-id <id>", "alias of --catalog-id").option("--category <c>", "resource category (table | logicview | dataset)").option("--type <c>", "alias of --category").option("--limit <n>", "page size", int9, DEFAULT_LIST_LIMIT).action(async (opts, cmd2) => {
1989
2057
  const data = await clientFrom(cmd2).resource.list({
1990
2058
  datasourceId: opts.catalogId ?? opts.datasourceId,
1991
2059
  category: opts.category ?? opts.type,
@@ -2003,7 +2071,7 @@ function resourceCommand() {
2003
2071
  cmd.command("get <id>").description("Get resource details").action(async (id, _opts, cmd2) => {
2004
2072
  printJson(await clientFrom(cmd2).resource.get(id), outputOptions(cmd2));
2005
2073
  });
2006
- cmd.command("query <id>").description("Fetch data rows from a resource").option("--limit <n>", "row limit", int8, DEFAULT_QUERY_LIMIT).option("--offset <n>", "row offset", int8, 0).option("--need-total", "include total count").action(async (id, opts, cmd2) => {
2074
+ cmd.command("query <id>").description("Fetch data rows from a resource").option("--limit <n>", "row limit", int9, DEFAULT_QUERY_LIMIT).option("--offset <n>", "row offset", int9, 0).option("--need-total", "include total count").action(async (id, opts, cmd2) => {
2007
2075
  const data = await clientFrom(cmd2).resource.query(id, {
2008
2076
  limit: opts.limit,
2009
2077
  offset: opts.offset,
@@ -2018,11 +2086,11 @@ function resourceCommand() {
2018
2086
  }
2019
2087
 
2020
2088
  // src/commands/skill.ts
2021
- import { Command as Command12 } from "commander";
2022
- var int9 = (v) => Number.parseInt(v, 10);
2089
+ import { Command as Command13 } from "commander";
2090
+ var int10 = (v) => Number.parseInt(v, 10);
2023
2091
  function skillCommand() {
2024
- const cmd = new Command12("skill").description("Skill registry and market");
2025
- const listOpts = (c) => c.option("--name <s>", "filter by name").option("--source <s>", "filter by source").option("--status <s>", "filter by status").option("--limit <n>", "page size", int9, DEFAULT_LIST_LIMIT).option("--page <n>", "page", int9, 1);
2092
+ const cmd = new Command13("skill").description("Skill registry and market");
2093
+ const listOpts = (c) => c.option("--name <s>", "filter by name").option("--source <s>", "filter by source").option("--status <s>", "filter by status").option("--limit <n>", "page size", int10, DEFAULT_LIST_LIMIT).option("--page <n>", "page", int10, 1);
2026
2094
  listOpts(cmd.command("list").description("List skills")).option("--create-user <s>", "filter by creator").action(async (opts, cmd2) => {
2027
2095
  printJson(
2028
2096
  await clientFrom(cmd2).skills.list({
@@ -2108,11 +2176,11 @@ function skillCommand() {
2108
2176
  }
2109
2177
 
2110
2178
  // src/commands/toolbox.ts
2111
- import { Command as Command13 } from "commander";
2112
- var int10 = (v) => Number.parseInt(v, 10);
2179
+ import { Command as Command14 } from "commander";
2180
+ var int11 = (v) => Number.parseInt(v, 10);
2113
2181
  function toolboxCommand() {
2114
- const cmd = new Command13("toolbox").description("Agent toolbox lifecycle");
2115
- cmd.command("list").description("List toolboxes").option("--keyword <s>", "filter by keyword").option("--limit <n>", "page size", int10, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int10, 0).action(async (opts, cmd2) => {
2182
+ const cmd = new Command14("toolbox").description("Agent toolbox lifecycle");
2183
+ cmd.command("list").description("List toolboxes").option("--keyword <s>", "filter by keyword").option("--limit <n>", "page size", int11, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int11, 0).action(async (opts, cmd2) => {
2116
2184
  printJson(
2117
2185
  await clientFrom(cmd2).toolboxes.list({
2118
2186
  keyword: opts.keyword,
@@ -2153,7 +2221,7 @@ function toolboxCommand() {
2153
2221
  return group(cmd, "DECISION AGENT");
2154
2222
  }
2155
2223
  function toolCommand() {
2156
- const cmd = new Command13("tool").description("Tools inside a toolbox");
2224
+ const cmd = new Command14("tool").description("Tools inside a toolbox");
2157
2225
  cmd.command("list").description("List tools in a toolbox").requiredOption("--toolbox <box-id>", "toolbox id").action(async (opts, cmd2) => {
2158
2226
  printJson(await clientFrom(cmd2).toolboxes.tools(opts.toolbox), outputOptions(cmd2));
2159
2227
  });
@@ -2169,7 +2237,7 @@ function toolCommand() {
2169
2237
  outputOptions(cmd2)
2170
2238
  );
2171
2239
  });
2172
- const invokeOpts = (c) => c.requiredOption("--toolbox <box-id>", "toolbox id").option("--body <json>", "request body JSON").option("--header <json>", "headers map JSON").option("--query <json>", "query params JSON").option("--path <json>", "path params JSON").option("--timeout <s>", "per-call timeout seconds", int10);
2240
+ const invokeOpts = (c) => c.requiredOption("--toolbox <box-id>", "toolbox id").option("--body <json>", "request body JSON").option("--header <json>", "headers map JSON").option("--query <json>", "query params JSON").option("--path <json>", "path params JSON").option("--timeout <s>", "per-call timeout seconds", int11);
2173
2241
  const parseJson = (s, label) => {
2174
2242
  if (!s) return void 0;
2175
2243
  try {
@@ -2212,7 +2280,7 @@ function toolCommand() {
2212
2280
 
2213
2281
  // src/commands/trace.ts
2214
2282
  import { readFileSync as readFileSync4, writeFileSync } from "fs";
2215
- import { Command as Command14 } from "commander";
2283
+ import { Command as Command15 } from "commander";
2216
2284
 
2217
2285
  // src/trace-ai/schema-validate.ts
2218
2286
  import { readFileSync as readFileSync3 } from "fs";
@@ -2290,7 +2358,7 @@ function validateSchemaFile(file, kind) {
2290
2358
 
2291
2359
  // src/commands/trace.ts
2292
2360
  function traceCommand() {
2293
- const cmd = new Command14("trace").description(
2361
+ const cmd = new Command15("trace").description(
2294
2362
  "Trace AI \u2014 fetch spans, diagnose (symbolic + LLM rubric), scan, eval-set, schema validate"
2295
2363
  );
2296
2364
  cmd.command("get <conversation-id>").description("Fetch all trace spans for a conversation").option("--max-spans <n>", "max spans", (v) => Number.parseInt(v, 10)).action(async (conversationId, opts, cmd2) => {
@@ -2348,9 +2416,10 @@ function traceCommand() {
2348
2416
  }
2349
2417
 
2350
2418
  // src/commands/vega.ts
2351
- import { Command as Command15 } from "commander";
2419
+ import { Command as Command16 } from "commander";
2420
+ var int12 = (v) => Number.parseInt(v, 10);
2352
2421
  function vegaCommand() {
2353
- const vega = new Command15("vega").description(
2422
+ const vega = new Command16("vega").description(
2354
2423
  "Vega observability \u2014 catalog, resources, index build tasks"
2355
2424
  );
2356
2425
  const catalog = vega.command("catalog").description("Catalog entries");
@@ -2403,6 +2472,38 @@ function vegaCommand() {
2403
2472
  connector.command("get <type>").description("Get a connector type").action(async (type, _opts, cmd) => {
2404
2473
  printJson(await clientFrom(cmd).vega.connectorType(type), outputOptions(cmd));
2405
2474
  });
2475
+ vega.command("sql").description("Run SQL / OpenSearch DSL directly against a vega-backend data source").option(
2476
+ "--resource-type <type>",
2477
+ "source type (mysql | postgresql | opensearch | \u2026); optional \u2014 inferred from the {{<id>}} placeholder"
2478
+ ).option(
2479
+ "--query <sql>",
2480
+ "SQL string; reference a resource with a {{<resource-id>}} placeholder"
2481
+ ).option("--stream-size <n>", "streaming batch size (100\u201310000)", int12).option("--query-timeout <s>", "query timeout in seconds (1\u20133600)", int12).option(
2482
+ "-d, --data <json>",
2483
+ "full request body as JSON (advanced; wins over --query/--resource-type)"
2484
+ ).action(async (opts, cmd) => {
2485
+ let body;
2486
+ if (opts.data) {
2487
+ try {
2488
+ body = JSON.parse(opts.data);
2489
+ } catch {
2490
+ throw new InputError("--data must be valid JSON");
2491
+ }
2492
+ } else {
2493
+ if (!opts.query) {
2494
+ throw new InputError("Provide --query (and optionally --resource-type), or --data.");
2495
+ }
2496
+ body = {
2497
+ query: opts.query,
2498
+ // Optional — the backend infers the type from the {{<id>}} placeholder's
2499
+ // catalog connector when omitted.
2500
+ ...opts.resourceType ? { resource_type: opts.resourceType } : {},
2501
+ ...opts.streamSize !== void 0 ? { stream_size: opts.streamSize } : {},
2502
+ ...opts.queryTimeout !== void 0 ? { query_timeout: opts.queryTimeout } : {}
2503
+ };
2504
+ }
2505
+ printJson(await clientFrom(cmd).vega.sql(body), outputOptions(cmd));
2506
+ });
2406
2507
  const resource = vega.command("resource").description("Vega-backend resources");
2407
2508
  resource.command("list").description("List resources").option("--datasource-id <id>", "filter by catalog/datasource id").option("--catalog-id <id>", "alias of --datasource-id").option("--type <category>", "resource category").option("--category <category>", "alias of --type").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).action(async (opts, cmd) => {
2408
2509
  printJson(
@@ -2450,11 +2551,12 @@ function vegaCommand() {
2450
2551
  }
2451
2552
 
2452
2553
  // src/cli.ts
2453
- var program = new Command16();
2554
+ var program = new Command17();
2454
2555
  program.name("openbkn").description("Operate the BKN platform from the CLI").version(package_default.version, "-V, --version", "output the version number").option("--base-url <url>", "platform base URL (env: BKN_BASE_URL)").option("--token <value>", "access token (env: BKN_TOKEN)").option("--user <id|name>", "use specific user credentials (env: BKN_USER)").option("--json", "machine-readable JSON output").option("--compact", "single-line JSON output").option("--full", "human view: show all columns (default trims to the key ones)").option("--biz-domain <s>", "business domain (alias: -bd)").option("-k, --insecure", "skip TLS verification (dev / self-signed only)").showHelpAfterError();
2455
2556
  program.addCommand(authCommand());
2456
2557
  program.addCommand(callCommand());
2457
2558
  program.addCommand(configCommand());
2559
+ program.addCommand(appkeyCommand());
2458
2560
  program.addCommand(vegaCommand());
2459
2561
  program.addCommand(bknCommand());
2460
2562
  program.addCommand(resourceCommand());