@openbkn/bkn-sdk 0.1.3 → 0.1.4
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 +13 -3
- package/README.zh.md +11 -2
- package/dist/{chunk-PC2F54XD.js → chunk-Z2NRTUB3.js} +1856 -2090
- package/dist/cli.js +634 -241
- package/dist/index.d.ts +7346 -689
- package/dist/index.js +7 -3
- package/package.json +6 -3
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
BuildTaskSort,
|
|
4
|
+
BuildTaskStatus,
|
|
3
5
|
DEFAULT_BUSINESS_DOMAIN,
|
|
4
6
|
DEFAULT_LIST_LIMIT,
|
|
5
7
|
DEFAULT_QUERY_LIMIT,
|
|
8
|
+
DiscoverScheduleSort,
|
|
9
|
+
DiscoverStrategy,
|
|
10
|
+
DiscoverTaskSort,
|
|
11
|
+
DiscoverTaskTriggerType,
|
|
6
12
|
HttpError,
|
|
7
13
|
InputError,
|
|
14
|
+
SemanticUnderstandingApplyMode,
|
|
15
|
+
SemanticUnderstandingScope,
|
|
16
|
+
SemanticUnderstandingTaskSort,
|
|
17
|
+
SortDirection,
|
|
18
|
+
VegaTaskStatus,
|
|
8
19
|
activePlatform,
|
|
9
20
|
attachToken,
|
|
10
21
|
changePasswordSafe,
|
|
@@ -25,6 +36,7 @@ import {
|
|
|
25
36
|
listPlatforms,
|
|
26
37
|
logout,
|
|
27
38
|
openBrowser,
|
|
39
|
+
parseBigIntJSON,
|
|
28
40
|
parseEmbeddingFields,
|
|
29
41
|
parsePkMap,
|
|
30
42
|
rawCall,
|
|
@@ -35,26 +47,27 @@ import {
|
|
|
35
47
|
resolveContext,
|
|
36
48
|
setActivePlatform,
|
|
37
49
|
status,
|
|
50
|
+
stringifyBigIntJSON,
|
|
38
51
|
switchUser,
|
|
39
52
|
toExitCode,
|
|
53
|
+
updatePlatformConfig,
|
|
40
54
|
use,
|
|
41
55
|
validateFixturePath,
|
|
42
|
-
whoami
|
|
43
|
-
|
|
44
|
-
} from "./chunk-PC2F54XD.js";
|
|
56
|
+
whoami
|
|
57
|
+
} from "./chunk-Z2NRTUB3.js";
|
|
45
58
|
|
|
46
59
|
// src/cli.ts
|
|
47
|
-
import { Command as
|
|
60
|
+
import { Command as Command16 } from "commander";
|
|
48
61
|
|
|
49
62
|
// package.json
|
|
50
63
|
var package_default = {
|
|
51
64
|
name: "@openbkn/bkn-sdk",
|
|
52
|
-
version: "0.1.
|
|
65
|
+
version: "0.1.4",
|
|
53
66
|
description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
54
67
|
type: "module",
|
|
55
68
|
license: "Apache-2.0",
|
|
56
69
|
engines: {
|
|
57
|
-
node: ">=
|
|
70
|
+
node: ">=24.19.0"
|
|
58
71
|
},
|
|
59
72
|
bin: {
|
|
60
73
|
openbkn: "./dist/cli.js"
|
|
@@ -85,6 +98,9 @@ var package_default = {
|
|
|
85
98
|
format: "biome format --write .",
|
|
86
99
|
test: "vitest run",
|
|
87
100
|
"test:e2e:trace-business": "npm run build && node test/e2e/bkn-trace-business-interaction.mjs",
|
|
101
|
+
"test:e2e:smoke": "npm run build && test/e2e/live-smoke.sh",
|
|
102
|
+
"test:e2e:suite": "npm run build && test/e2e/live-suite.sh",
|
|
103
|
+
"test:e2e:write": "npm run build && test/e2e/live-write.sh",
|
|
88
104
|
"test:cover": "vitest run --coverage",
|
|
89
105
|
ci: "npm run lint && npm test",
|
|
90
106
|
prepublishOnly: "npm run ci && npm run build"
|
|
@@ -102,7 +118,7 @@ var package_default = {
|
|
|
102
118
|
devDependencies: {
|
|
103
119
|
"@biomejs/biome": "^1.9.4",
|
|
104
120
|
"@types/js-yaml": "^4.0.9",
|
|
105
|
-
"@types/node": "^
|
|
121
|
+
"@types/node": "^24.0.0",
|
|
106
122
|
tsup: "^8.4.0",
|
|
107
123
|
typescript: "^5.8.0",
|
|
108
124
|
vitest: "^3.0.0"
|
|
@@ -181,7 +197,7 @@ function renderOrgTree(nodes, prefix = "") {
|
|
|
181
197
|
// src/utils/output.ts
|
|
182
198
|
function printJson(value, opts = {}) {
|
|
183
199
|
if (opts.json || opts.compact) {
|
|
184
|
-
const json =
|
|
200
|
+
const json = stringifyBigIntJSON(value === void 0 ? null : value, opts.compact ? 0 : 2);
|
|
185
201
|
process.stdout.write(`${json}
|
|
186
202
|
`);
|
|
187
203
|
return;
|
|
@@ -208,7 +224,7 @@ function printJson(value, opts = {}) {
|
|
|
208
224
|
process.stdout.write("(no results)\n");
|
|
209
225
|
return;
|
|
210
226
|
}
|
|
211
|
-
process.stdout.write(`${
|
|
227
|
+
process.stdout.write(`${stringifyBigIntJSON(value, 2)}
|
|
212
228
|
`);
|
|
213
229
|
}
|
|
214
230
|
function isEmptyEnvelope(value) {
|
|
@@ -307,7 +323,7 @@ function pad(s, width) {
|
|
|
307
323
|
}
|
|
308
324
|
function stringifyCell(v) {
|
|
309
325
|
if (v === null || v === void 0) return "";
|
|
310
|
-
const raw = Array.isArray(v) && v.every((x) => x === null || typeof x !== "object") ? v.join(",") : typeof v === "object" ?
|
|
326
|
+
const raw = Array.isArray(v) && v.every((x) => x === null || typeof x !== "object") ? v.join(",") : typeof v === "object" ? stringifyBigIntJSON(v) : String(v);
|
|
311
327
|
const s = raw.replace(/\s+/g, " ").trim();
|
|
312
328
|
return s.length > CELL_MAX ? `${s.slice(0, CELL_MAX - 1)}\u2026` : s;
|
|
313
329
|
}
|
|
@@ -333,8 +349,26 @@ function promptLine(query, hidden = false) {
|
|
|
333
349
|
|
|
334
350
|
// src/commands/_shared.ts
|
|
335
351
|
import { readFileSync } from "fs";
|
|
352
|
+
function platformOf(o) {
|
|
353
|
+
const baseUrl = (typeof o.baseUrl === "string" ? o.baseUrl : void 0) ?? process.env.BKN_BASE_URL ?? activePlatform();
|
|
354
|
+
return baseUrl?.replace(/\/+$/, "");
|
|
355
|
+
}
|
|
356
|
+
function transientIdentity(o) {
|
|
357
|
+
return Boolean(o.user || process.env.BKN_USER || o.token || process.env.BKN_TOKEN);
|
|
358
|
+
}
|
|
359
|
+
function conversationSource(o) {
|
|
360
|
+
const flag = typeof o.conversationId === "string" ? o.conversationId : void 0;
|
|
361
|
+
if (flag) return { id: flag, source: "flag" };
|
|
362
|
+
const env = process.env.BKN_CONVERSATION_ID;
|
|
363
|
+
if (env) return { id: env, source: "env" };
|
|
364
|
+
if (o.newConversation || transientIdentity(o)) return { source: "none" };
|
|
365
|
+
const baseUrl = platformOf(o);
|
|
366
|
+
const stored = baseUrl ? readPlatformConfig(baseUrl).conversationId : void 0;
|
|
367
|
+
return stored ? { id: stored, source: "stored" } : { source: "none" };
|
|
368
|
+
}
|
|
336
369
|
function traceOptionsFrom(o) {
|
|
337
|
-
const
|
|
370
|
+
const found = conversationSource(o);
|
|
371
|
+
const conversationId = found.source === "stored" ? void 0 : found.id;
|
|
338
372
|
const interactionId = (typeof o.interactionId === "string" ? o.interactionId : void 0) ?? process.env.BKN_INTERACTION_ID;
|
|
339
373
|
if (!conversationId && !interactionId) return void 0;
|
|
340
374
|
return {
|
|
@@ -345,14 +379,36 @@ function traceOptionsFrom(o) {
|
|
|
345
379
|
function clientFrom(cmd) {
|
|
346
380
|
const o = cmd.optsWithGlobals();
|
|
347
381
|
const trace = traceOptionsFrom(o);
|
|
348
|
-
|
|
382
|
+
const storeBaseUrl = platformOf(o);
|
|
383
|
+
const remembered = conversationSource(o);
|
|
384
|
+
const client = createClient({
|
|
349
385
|
baseUrl: o.baseUrl,
|
|
350
386
|
token: o.token,
|
|
351
387
|
user: o.user,
|
|
352
388
|
businessDomain: o.bizDomain,
|
|
353
389
|
insecure: o.insecure,
|
|
354
|
-
...trace ? { trace } : {}
|
|
390
|
+
...trace ? { trace } : {},
|
|
391
|
+
...remembered.source === "stored" && remembered.id ? { rememberedConversationId: remembered.id } : {},
|
|
392
|
+
// Remember a conversation this run opens, so the next command continues the
|
|
393
|
+
// same thread instead of starting a new one. Only for the active identity —
|
|
394
|
+
// `transientIdentity` explains which identities are left out.
|
|
395
|
+
// `--new-conversation` says "for this command", so it must not replace what
|
|
396
|
+
// it declined to use — otherwise one run with the flag would silently end
|
|
397
|
+
// the thread every other run was continuing.
|
|
398
|
+
...transientIdentity(o) || o.newConversation ? {} : {
|
|
399
|
+
onConversationOpened: (conversationId) => {
|
|
400
|
+
if (!storeBaseUrl) return;
|
|
401
|
+
try {
|
|
402
|
+
updatePlatformConfig(storeBaseUrl, {
|
|
403
|
+
conversationId,
|
|
404
|
+
conversationOpenedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
405
|
+
});
|
|
406
|
+
} catch {
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
355
410
|
});
|
|
411
|
+
return client;
|
|
356
412
|
}
|
|
357
413
|
function outputOptions(cmd) {
|
|
358
414
|
const o = cmd.optsWithGlobals();
|
|
@@ -366,7 +422,7 @@ function readBody(opts) {
|
|
|
366
422
|
const raw = opts.bodyFile ? readFileSync(opts.bodyFile, "utf8") : opts.body;
|
|
367
423
|
if (!raw) throw new InputError("Provide --body '<json>' or --body-file <path>.");
|
|
368
424
|
try {
|
|
369
|
-
return
|
|
425
|
+
return parseBigIntJSON(raw);
|
|
370
426
|
} catch {
|
|
371
427
|
throw new InputError("Request body is not valid JSON.");
|
|
372
428
|
}
|
|
@@ -967,7 +1023,7 @@ function adminCommand() {
|
|
|
967
1023
|
);
|
|
968
1024
|
const out = outputOptions(cmd);
|
|
969
1025
|
try {
|
|
970
|
-
printJson(
|
|
1026
|
+
printJson(parseBigIntJSON(res.body), out);
|
|
971
1027
|
} catch {
|
|
972
1028
|
process.stdout.write(res.body.endsWith("\n") ? res.body : `${res.body}
|
|
973
1029
|
`);
|
|
@@ -1500,8 +1556,8 @@ function bknCommand() {
|
|
|
1500
1556
|
printJson(await clientFrom(cmd).kn.actionScheduleDelete(knId, ids), outputOptions(cmd));
|
|
1501
1557
|
});
|
|
1502
1558
|
bkn.command("push <directory>").description("Pack a BKN directory into a tar and import it as a knowledge network").option("--branch <name>", "target branch", "main").option("--build", "submit a Vega build task for each object type declaring a vector index").option(
|
|
1503
|
-
"--embedding-model <id>",
|
|
1504
|
-
"
|
|
1559
|
+
"--embedding-model <name-or-id>",
|
|
1560
|
+
"small-model name (or numeric ID, resolved to its name) for declared vector indexes (with --build)"
|
|
1505
1561
|
).action(async (dir, opts, cmd) => {
|
|
1506
1562
|
printJson(
|
|
1507
1563
|
await clientFrom(cmd).kn.push(dir, {
|
|
@@ -1530,7 +1586,10 @@ function bknCommand() {
|
|
|
1530
1586
|
bkn.command("create-from-catalog <catalog-id>").description("Build a knowledge network from a Vega catalog's tables").requiredOption("--name <name>", "knowledge network name").option("--tables <list>", "comma-separated table names (default: all)").option("--pk-map <map>", "explicit primary keys: '<table>:<col>[,<table>:<col>...]'").option("--build", "submit a Vega build task per resource after creation").option(
|
|
1531
1587
|
"--embedding-fields <map>",
|
|
1532
1588
|
"columns to vectorize per table (with --build): '<table>:<col>[+<col>...][,...]'"
|
|
1533
|
-
).option(
|
|
1589
|
+
).option(
|
|
1590
|
+
"--embedding-model <name-or-id>",
|
|
1591
|
+
"small-model name (or numeric ID, resolved to its name) for the vector index (with --build)"
|
|
1592
|
+
).option("--no-rollback", "keep a partially-created KN on failure").action(async (catalogId, opts, cmd) => {
|
|
1534
1593
|
printJson(
|
|
1535
1594
|
await clientFrom(cmd).kn.createFromCatalog({
|
|
1536
1595
|
catalogId,
|
|
@@ -1551,28 +1610,6 @@ function bknCommand() {
|
|
|
1551
1610
|
printJson(result, outputOptions(cmd));
|
|
1552
1611
|
if (!result.valid) process.exitCode = 1;
|
|
1553
1612
|
});
|
|
1554
|
-
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(
|
|
1555
|
-
"--embedding-fields <map>",
|
|
1556
|
-
"columns to vectorize per table (with --build): '<table>:<col>[+<col>...][,...]'"
|
|
1557
|
-
).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) => {
|
|
1558
|
-
printJson(
|
|
1559
|
-
await clientFrom(cmd).kn.createFromCsv({
|
|
1560
|
-
catalogId,
|
|
1561
|
-
name: opts.name,
|
|
1562
|
-
files: opts.files,
|
|
1563
|
-
tablePrefix: opts.tablePrefix,
|
|
1564
|
-
batchSize: opts.batchSize,
|
|
1565
|
-
tables: csv(opts.tables),
|
|
1566
|
-
pkMap: opts.pkMap ? parsePkMap(opts.pkMap) : void 0,
|
|
1567
|
-
build: Boolean(opts.build),
|
|
1568
|
-
embeddingFields: opts.embeddingFields ? parseEmbeddingFields(opts.embeddingFields) : void 0,
|
|
1569
|
-
embeddingModel: opts.embeddingModel,
|
|
1570
|
-
noRollback: opts.rollback === false,
|
|
1571
|
-
onProgress: (m) => console.error(m)
|
|
1572
|
-
}),
|
|
1573
|
-
outputOptions(cmd)
|
|
1574
|
-
);
|
|
1575
|
-
});
|
|
1576
1613
|
return group(bkn, "AI DATA PLATFORM");
|
|
1577
1614
|
}
|
|
1578
1615
|
|
|
@@ -1609,7 +1646,7 @@ function callCommand() {
|
|
|
1609
1646
|
});
|
|
1610
1647
|
const out = outputOptions(cmd2);
|
|
1611
1648
|
try {
|
|
1612
|
-
printJson(
|
|
1649
|
+
printJson(parseBigIntJSON(res.body), out);
|
|
1613
1650
|
} catch {
|
|
1614
1651
|
process.stdout.write(res.body.endsWith("\n") ? res.body : `${res.body}
|
|
1615
1652
|
`);
|
|
@@ -1646,7 +1683,7 @@ function configCommand() {
|
|
|
1646
1683
|
if (key === "baseUrl") {
|
|
1647
1684
|
setActivePlatform(value.replace(/\/+$/, ""));
|
|
1648
1685
|
} else if (key === "businessDomain") {
|
|
1649
|
-
|
|
1686
|
+
updatePlatformConfig(requireActive(), { businessDomain: value });
|
|
1650
1687
|
} else {
|
|
1651
1688
|
throw new InputError(`Unknown config key: ${key} (expected baseUrl | businessDomain)`);
|
|
1652
1689
|
}
|
|
@@ -1654,7 +1691,7 @@ function configCommand() {
|
|
|
1654
1691
|
});
|
|
1655
1692
|
config.command("set-bd <value>").description("Set the default business domain for the active platform").action((value, _opts, cmd) => {
|
|
1656
1693
|
const baseUrl = requireActive();
|
|
1657
|
-
|
|
1694
|
+
updatePlatformConfig(baseUrl, { businessDomain: value });
|
|
1658
1695
|
printJson({ baseUrl, businessDomain: value }, outputOptions(cmd));
|
|
1659
1696
|
});
|
|
1660
1697
|
config.command("list-bd").description("List business domains (requires login)").action(() => {
|
|
@@ -1674,7 +1711,7 @@ function buildArgs(opts) {
|
|
|
1674
1711
|
let out = {};
|
|
1675
1712
|
if (opts.args) {
|
|
1676
1713
|
try {
|
|
1677
|
-
out =
|
|
1714
|
+
out = parseBigIntJSON(opts.args);
|
|
1678
1715
|
} catch {
|
|
1679
1716
|
throw new InputError("--args must be valid JSON");
|
|
1680
1717
|
}
|
|
@@ -1685,7 +1722,7 @@ function buildArgs(opts) {
|
|
|
1685
1722
|
const key = pair.slice(0, idx);
|
|
1686
1723
|
const raw = pair.slice(idx + 1);
|
|
1687
1724
|
try {
|
|
1688
|
-
out[key] =
|
|
1725
|
+
out[key] = parseBigIntJSON(raw);
|
|
1689
1726
|
} catch {
|
|
1690
1727
|
out[key] = raw;
|
|
1691
1728
|
}
|
|
@@ -1723,7 +1760,7 @@ function contextCommand() {
|
|
|
1723
1760
|
cmd.command("query-object-instance <kn-id>").description("Query object instances (provide --args as JSON)").requiredOption("--args <json>", "tool arguments as JSON").action(async (knId, opts, cmd2) => {
|
|
1724
1761
|
let args;
|
|
1725
1762
|
try {
|
|
1726
|
-
args =
|
|
1763
|
+
args = parseBigIntJSON(opts.args);
|
|
1727
1764
|
} catch {
|
|
1728
1765
|
throw new InputError("--args must be valid JSON");
|
|
1729
1766
|
}
|
|
@@ -1745,6 +1782,36 @@ function contextCommand() {
|
|
|
1745
1782
|
cmd.command("relation-types <kn-id> <ids...>").description("Full definitions for the given relation-type ids (unmatched \u2192 `missing`)").action(async (knId, ids, _opts, cmd2) => {
|
|
1746
1783
|
printJson(await clientFrom(cmd2).context.relationTypes(knId, ids), outputOptions(cmd2));
|
|
1747
1784
|
});
|
|
1785
|
+
cmd.command("conversation").description("Show the remembered conversation, or forget it with --forget").option(
|
|
1786
|
+
"--forget",
|
|
1787
|
+
"drop it, so the next command opens a fresh conversation (acts on this machine's store for the active user, whatever identity the request would use)"
|
|
1788
|
+
).action((opts, cmd2) => {
|
|
1789
|
+
const o = cmd2.optsWithGlobals();
|
|
1790
|
+
const baseUrl = platformOf(o);
|
|
1791
|
+
if (!baseUrl) throw new InputError("No platform. Run `openbkn auth login` first.");
|
|
1792
|
+
const forgot = opts.forget ? readPlatformConfig(baseUrl).conversationId : void 0;
|
|
1793
|
+
if (opts.forget) {
|
|
1794
|
+
updatePlatformConfig(baseUrl, {
|
|
1795
|
+
conversationId: void 0,
|
|
1796
|
+
conversationOpenedAt: void 0
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
const { id, source } = conversationSource(o);
|
|
1800
|
+
const stored = readPlatformConfig(baseUrl);
|
|
1801
|
+
printJson(
|
|
1802
|
+
{
|
|
1803
|
+
baseUrl,
|
|
1804
|
+
conversationId: id ?? null,
|
|
1805
|
+
source,
|
|
1806
|
+
...stored.conversationOpenedAt ? { storedOpenedAt: stored.conversationOpenedAt } : {},
|
|
1807
|
+
// What is on disk, even when something outranks it — otherwise
|
|
1808
|
+
// `--forget` looks like a no-op to whoever just ran this.
|
|
1809
|
+
...stored.conversationId && stored.conversationId !== id ? { storedConversationId: stored.conversationId } : {},
|
|
1810
|
+
...opts.forget ? { forgot: forgot ?? null } : {}
|
|
1811
|
+
},
|
|
1812
|
+
outputOptions(cmd2)
|
|
1813
|
+
);
|
|
1814
|
+
});
|
|
1748
1815
|
cmd.command("info").description("List the deploy's MCP tool catalog (global \u2014 no KN needed)").action(async (_opts, cmd2) => {
|
|
1749
1816
|
printToolList(await clientFrom(cmd2).context.info(), outputOptions(cmd2));
|
|
1750
1817
|
});
|
|
@@ -1791,7 +1858,7 @@ function contextCommand() {
|
|
|
1791
1858
|
let args;
|
|
1792
1859
|
if (opts.args) {
|
|
1793
1860
|
try {
|
|
1794
|
-
args =
|
|
1861
|
+
args = parseBigIntJSON(opts.args);
|
|
1795
1862
|
} catch {
|
|
1796
1863
|
throw new InputError("--args must be valid JSON");
|
|
1797
1864
|
}
|
|
@@ -1800,7 +1867,7 @@ function contextCommand() {
|
|
|
1800
1867
|
});
|
|
1801
1868
|
const jsonArgs = (raw) => {
|
|
1802
1869
|
try {
|
|
1803
|
-
return
|
|
1870
|
+
return parseBigIntJSON(raw);
|
|
1804
1871
|
} catch {
|
|
1805
1872
|
throw new InputError("--args must be valid JSON");
|
|
1806
1873
|
}
|
|
@@ -1826,88 +1893,10 @@ function contextCommand() {
|
|
|
1826
1893
|
return group(cmd, "AI DATA PLATFORM");
|
|
1827
1894
|
}
|
|
1828
1895
|
|
|
1829
|
-
// src/commands/dataflow.ts
|
|
1830
|
-
import { Command as Command9 } from "commander";
|
|
1831
|
-
var int6 = (v) => Number.parseInt(v, 10);
|
|
1832
|
-
function dataflowCommand() {
|
|
1833
|
-
const cmd = new Command9("dataflow").description("Dataflow document workflows \u2014 list, runs, logs");
|
|
1834
|
-
cmd.command("list").description("List all dataflows").action(async (_opts, cmd2) => {
|
|
1835
|
-
printJson(await clientFrom(cmd2).dataflows.list(), outputOptions(cmd2));
|
|
1836
|
-
});
|
|
1837
|
-
cmd.command("runs <dagId>").description("List run records for one dataflow").option("--since <date>", "filter runs since a date").option("--limit <n>", "page size (backend default 20)", int6).option("--page <n>", "page (0-based; backend default 0)", int6).action(async (dagId, opts, cmd2) => {
|
|
1838
|
-
printJson(
|
|
1839
|
-
await clientFrom(cmd2).dataflows.runs(dagId, {
|
|
1840
|
-
since: opts.since,
|
|
1841
|
-
page: opts.page,
|
|
1842
|
-
limit: opts.limit
|
|
1843
|
-
}),
|
|
1844
|
-
outputOptions(cmd2)
|
|
1845
|
-
);
|
|
1846
|
-
});
|
|
1847
|
-
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) => {
|
|
1848
|
-
printJson(
|
|
1849
|
-
await clientFrom(cmd2).dataflows.logs(dagId, instanceId, {
|
|
1850
|
-
page: opts.page,
|
|
1851
|
-
limit: opts.limit
|
|
1852
|
-
}),
|
|
1853
|
-
outputOptions(cmd2)
|
|
1854
|
-
);
|
|
1855
|
-
});
|
|
1856
|
-
cmd.command("run <dagId>").description("Trigger a dataflow run from a remote file URL").requiredOption("--url <url>", "remote file URL").requiredOption("--name <name>", "file name").action(async (dagId, opts, cmd2) => {
|
|
1857
|
-
printJson(
|
|
1858
|
-
await clientFrom(cmd2).dataflows.run(dagId, opts.url, opts.name),
|
|
1859
|
-
outputOptions(cmd2)
|
|
1860
|
-
);
|
|
1861
|
-
});
|
|
1862
|
-
cmd.command("create").description("Create a dataflow (DAG) from a full document body (--body / --body-file)").option("--body <json>", "dataflow document JSON").option("--body-file <path>", "read the dataflow document JSON from a file").action(async (opts, cmd2) => {
|
|
1863
|
-
printJson(await clientFrom(cmd2).dataflows.create(readBody(opts)), outputOptions(cmd2));
|
|
1864
|
-
});
|
|
1865
|
-
const parseSet = (pairs) => {
|
|
1866
|
-
const out = {};
|
|
1867
|
-
for (const item of pairs ?? []) {
|
|
1868
|
-
const i = item.indexOf("=");
|
|
1869
|
-
if (i > 0) out[item.slice(0, i)] = item.slice(i + 1);
|
|
1870
|
-
}
|
|
1871
|
-
return out;
|
|
1872
|
-
};
|
|
1873
|
-
cmd.command("templates").description("List available dataset/bkn/dataflow templates").action(async (_opts, cmd2) => {
|
|
1874
|
-
printJson(clientFrom(cmd2).dataflows.templates(), outputOptions(cmd2));
|
|
1875
|
-
});
|
|
1876
|
-
cmd.command("create-dataset").description("Create a dataset from a template (--template <name> --set k=v ...)").requiredOption("--template <name>", "template name").option(
|
|
1877
|
-
"--set <kv...>",
|
|
1878
|
-
"set a template argument (key=value); repeatable",
|
|
1879
|
-
(v, acc) => {
|
|
1880
|
-
acc.push(v);
|
|
1881
|
-
return acc;
|
|
1882
|
-
},
|
|
1883
|
-
[]
|
|
1884
|
-
).action(async (opts, cmd2) => {
|
|
1885
|
-
printJson(
|
|
1886
|
-
await clientFrom(cmd2).dataflows.createDataset(opts.template, parseSet(opts.set)),
|
|
1887
|
-
outputOptions(cmd2)
|
|
1888
|
-
);
|
|
1889
|
-
});
|
|
1890
|
-
cmd.command("create-bkn").description("Create a knowledge network from a template (--template <name> --set k=v ...)").requiredOption("--template <name>", "template name").option(
|
|
1891
|
-
"--set <kv...>",
|
|
1892
|
-
"set a template argument (key=value); repeatable",
|
|
1893
|
-
(v, acc) => {
|
|
1894
|
-
acc.push(v);
|
|
1895
|
-
return acc;
|
|
1896
|
-
},
|
|
1897
|
-
[]
|
|
1898
|
-
).action(async (opts, cmd2) => {
|
|
1899
|
-
printJson(
|
|
1900
|
-
await clientFrom(cmd2).dataflows.createBkn(opts.template, parseSet(opts.set)),
|
|
1901
|
-
outputOptions(cmd2)
|
|
1902
|
-
);
|
|
1903
|
-
});
|
|
1904
|
-
return group(cmd, "AI DATA PLATFORM");
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
1896
|
// src/commands/explore.ts
|
|
1908
1897
|
import { createServer } from "http";
|
|
1909
|
-
import { Command as
|
|
1910
|
-
var
|
|
1898
|
+
import { Command as Command9 } from "commander";
|
|
1899
|
+
var int6 = (v) => Number.parseInt(v, 10);
|
|
1911
1900
|
var ROUTES = {
|
|
1912
1901
|
"GET /api/bkn/meta": (c, q) => c.kn.get(req(q, "knId")),
|
|
1913
1902
|
"POST /api/bkn/search": (c, _q, b) => c.kn.search(str(b.knId), str(b.query), {
|
|
@@ -1938,7 +1927,7 @@ function readBody2(reqMsg) {
|
|
|
1938
1927
|
reqMsg.on("end", () => {
|
|
1939
1928
|
if (!data.trim()) return resolve2({});
|
|
1940
1929
|
try {
|
|
1941
|
-
resolve2(
|
|
1930
|
+
resolve2(parseBigIntJSON(data));
|
|
1942
1931
|
} catch {
|
|
1943
1932
|
reject(new Error("invalid JSON body"));
|
|
1944
1933
|
}
|
|
@@ -1951,10 +1940,10 @@ var INDEX = `<!doctype html><meta charset="utf-8"><title>openbkn explore</title>
|
|
|
1951
1940
|
<p>Read-only JSON endpoints for bkn + vega:</p>
|
|
1952
1941
|
<ul>${Object.keys(ROUTES).map((r) => `<li><code>${r}</code></li>`).join("")}</ul>`;
|
|
1953
1942
|
function exploreCommand() {
|
|
1954
|
-
const cmd = new
|
|
1943
|
+
const cmd = new Command9("explore").description(
|
|
1955
1944
|
"Start a local web server with read-only bkn + vega JSON endpoints"
|
|
1956
1945
|
);
|
|
1957
|
-
cmd.option("--port <n>", "port to listen on",
|
|
1946
|
+
cmd.option("--port <n>", "port to listen on", int6, 7777).option("--host <h>", "host to bind", "127.0.0.1").action(async (opts, command) => {
|
|
1958
1947
|
const client = clientFrom(command);
|
|
1959
1948
|
const server = createServer((reqMsg, res) => {
|
|
1960
1949
|
void handle(client, reqMsg, res);
|
|
@@ -1984,7 +1973,7 @@ async function handle(client, reqMsg, res) {
|
|
|
1984
1973
|
const body = method === "GET" ? {} : await readBody2(reqMsg);
|
|
1985
1974
|
const data = await handler(client, url.searchParams, body);
|
|
1986
1975
|
res.writeHead(200, { "content-type": "application/json" });
|
|
1987
|
-
res.end(
|
|
1976
|
+
res.end(stringifyBigIntJSON(data ?? null));
|
|
1988
1977
|
} catch (err) {
|
|
1989
1978
|
res.writeHead(500, { "content-type": "application/json" });
|
|
1990
1979
|
res.end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }));
|
|
@@ -1992,8 +1981,8 @@ async function handle(client, reqMsg, res) {
|
|
|
1992
1981
|
}
|
|
1993
1982
|
|
|
1994
1983
|
// src/commands/model.ts
|
|
1995
|
-
import { Command as
|
|
1996
|
-
var
|
|
1984
|
+
import { Command as Command10 } from "commander";
|
|
1985
|
+
var int7 = (v) => Number.parseInt(v, 10);
|
|
1997
1986
|
async function resolveLlmModelName(client, model) {
|
|
1998
1987
|
if (!/^\d+$/.test(model)) return model;
|
|
1999
1988
|
const detail = await client.models.llm.get(model);
|
|
@@ -2015,11 +2004,11 @@ function addManagementCommands(parent, kind) {
|
|
|
2015
2004
|
});
|
|
2016
2005
|
}
|
|
2017
2006
|
function modelCommand() {
|
|
2018
|
-
const model = new
|
|
2007
|
+
const model = new Command10("model").description(
|
|
2019
2008
|
"Model factory \u2014 LLM / small-model CRUD, chat / embeddings / rerank, default selection"
|
|
2020
2009
|
);
|
|
2021
2010
|
const llm = model.command("llm").description("Large language models");
|
|
2022
|
-
llm.command("list").description("List LLM models").option("--name <s>", "filter by name").option("--type <t>", "model type filter").option("--limit <n>", "page size",
|
|
2011
|
+
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) => {
|
|
2023
2012
|
printJson(
|
|
2024
2013
|
await clientFrom(cmd).models.llm.list({
|
|
2025
2014
|
name: opts.name,
|
|
@@ -2052,7 +2041,7 @@ function modelCommand() {
|
|
|
2052
2041
|
});
|
|
2053
2042
|
addManagementCommands(llm, "llm");
|
|
2054
2043
|
const small = model.command("small").description("Small models (embedding / reranker)");
|
|
2055
|
-
small.command("list").description("List small models").option("--name <s>", "filter by name").option("--type <t>", "model type filter").option("--limit <n>", "page size",
|
|
2044
|
+
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) => {
|
|
2056
2045
|
printJson(
|
|
2057
2046
|
await clientFrom(cmd).models.small.list({
|
|
2058
2047
|
name: opts.name,
|
|
@@ -2066,13 +2055,13 @@ function modelCommand() {
|
|
|
2066
2055
|
small.command("get <modelId>").description("Get a small model").action(async (id, _opts, cmd) => {
|
|
2067
2056
|
printJson(await clientFrom(cmd).models.small.get(id), outputOptions(cmd));
|
|
2068
2057
|
});
|
|
2069
|
-
small.command("embeddings <
|
|
2058
|
+
small.command("embeddings <model>").description("Compute embeddings (<model> = model name or numeric id)").requiredOption("-i, --input <text>", "comma-separated input texts").action(async (id, opts, cmd) => {
|
|
2070
2059
|
printJson(
|
|
2071
2060
|
await clientFrom(cmd).models.small.embeddings(id, csv(opts.input) ?? []),
|
|
2072
2061
|
outputOptions(cmd)
|
|
2073
2062
|
);
|
|
2074
2063
|
});
|
|
2075
|
-
small.command("rerank <
|
|
2064
|
+
small.command("rerank <model>").description("Rerank documents against a query (<model> = model name or numeric id)").requiredOption("-q, --query <text>", "query").requiredOption("-d, --documents <list>", "comma-separated documents").action(async (id, opts, cmd) => {
|
|
2076
2065
|
printJson(
|
|
2077
2066
|
await clientFrom(cmd).models.small.rerank(id, opts.query, csv(opts.documents) ?? []),
|
|
2078
2067
|
outputOptions(cmd)
|
|
@@ -2107,38 +2096,27 @@ Examples:
|
|
|
2107
2096
|
}
|
|
2108
2097
|
|
|
2109
2098
|
// src/commands/resource.ts
|
|
2110
|
-
import { Command as
|
|
2111
|
-
var
|
|
2112
|
-
var parsePairs = (raw) => {
|
|
2113
|
-
if (!raw) return void 0;
|
|
2114
|
-
return raw.split(",").map((part) => {
|
|
2115
|
-
const idx = part.indexOf("=");
|
|
2116
|
-
if (idx < 1) throw new Error("--extension must be key=value[,key=value]");
|
|
2117
|
-
return { key: part.slice(0, idx).trim(), value: part.slice(idx + 1).trim() };
|
|
2118
|
-
}).filter((p) => p.key.length > 0);
|
|
2119
|
-
};
|
|
2099
|
+
import { Command as Command11 } from "commander";
|
|
2100
|
+
var int8 = (v) => Number.parseInt(v, 10);
|
|
2120
2101
|
function resourceCommand() {
|
|
2121
|
-
const cmd = new
|
|
2122
|
-
cmd.command("list").description("List resources under a catalog").option("--catalog-id <id>", "filter by catalog id").option("--
|
|
2102
|
+
const cmd = new Command11("resource").alias("res").description("Resources \u2014 list, find, get, query, delete");
|
|
2103
|
+
cmd.command("list").description("List resources under a catalog").option("--catalog-id <id>", "filter by catalog id").option("--category <c>", "resource category (table | logicview | dataset)").option("--type <c>", "alias of --category").option("--status <status>", "filter by status").option("--schema <name>", "filter by source schema").option("--limit <n>", "page size", int8, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int8, 0).option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (opts, cmd2) => {
|
|
2123
2104
|
const data = await clientFrom(cmd2).resource.list({
|
|
2124
|
-
|
|
2105
|
+
catalogId: opts.catalogId,
|
|
2125
2106
|
category: opts.category ?? opts.type,
|
|
2126
2107
|
status: opts.status,
|
|
2127
|
-
|
|
2108
|
+
schema: opts.schema,
|
|
2128
2109
|
limit: opts.limit,
|
|
2129
2110
|
offset: opts.offset,
|
|
2130
|
-
includeExtensions: opts.includeExtensions,
|
|
2131
|
-
includeExtensionKeys: opts.includeExtensionKeys,
|
|
2132
|
-
extensionPairs: parsePairs(opts.extension),
|
|
2133
2111
|
sort: opts.sort,
|
|
2134
2112
|
direction: opts.direction
|
|
2135
2113
|
});
|
|
2136
2114
|
printJson(data, outputOptions(cmd2));
|
|
2137
2115
|
});
|
|
2138
|
-
cmd.command("find").description("Search resources by name (fuzzy; --exact for strict)").requiredOption("--name <name>", "resource name to search").option("--exact", "exact name match").option("--catalog-id <id>", "limit to a catalog").option("--
|
|
2116
|
+
cmd.command("find").description("Search resources by name (fuzzy; --exact for strict)").requiredOption("--name <name>", "resource name to search").option("--exact", "exact name match").option("--catalog-id <id>", "limit to a catalog").option("--limit <n>", "rows to scan before filtering", int8, DEFAULT_LIST_LIMIT).action(async (opts, cmd2) => {
|
|
2139
2117
|
const data = await clientFrom(cmd2).resource.find(opts.name, {
|
|
2140
2118
|
exact: opts.exact,
|
|
2141
|
-
|
|
2119
|
+
catalogId: opts.catalogId,
|
|
2142
2120
|
limit: opts.limit
|
|
2143
2121
|
});
|
|
2144
2122
|
printJson(data, outputOptions(cmd2));
|
|
@@ -2146,7 +2124,7 @@ function resourceCommand() {
|
|
|
2146
2124
|
cmd.command("get <id>").description("Get resource details").action(async (id, _opts, cmd2) => {
|
|
2147
2125
|
printJson(await clientFrom(cmd2).resource.get(id), outputOptions(cmd2));
|
|
2148
2126
|
});
|
|
2149
|
-
cmd.command("query <id>").description("Fetch data rows from a resource").option("--limit <n>", "row limit",
|
|
2127
|
+
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("--paging-mode <mode>", "paging mode: single | cursor").option("--keep-alive-sec <s>", "cursor keep-alive in seconds (60\u20133600)", int8).option("--cursor <cursor>", "opaque cursor returned by the previous page").option("--need-total", "include total count").action(async (id, opts, cmd2) => {
|
|
2150
2128
|
const data = await clientFrom(cmd2).resource.query(id, {
|
|
2151
2129
|
limit: opts.limit,
|
|
2152
2130
|
offset: opts.offset,
|
|
@@ -2164,8 +2142,8 @@ function resourceCommand() {
|
|
|
2164
2142
|
}
|
|
2165
2143
|
|
|
2166
2144
|
// src/commands/skill.ts
|
|
2167
|
-
import { Command as
|
|
2168
|
-
var
|
|
2145
|
+
import { Command as Command12 } from "commander";
|
|
2146
|
+
var int9 = (v) => Number.parseInt(v, 10);
|
|
2169
2147
|
var positiveInt = (flag) => (v) => {
|
|
2170
2148
|
if (!/^\d+$/.test(v)) {
|
|
2171
2149
|
throw new InputError(`${flag} must be a positive integer (got '${v}')`);
|
|
@@ -2190,8 +2168,8 @@ function checkSource(source) {
|
|
|
2190
2168
|
}
|
|
2191
2169
|
var draftOption = (c) => c.option("--draft", "read the draft (management) version instead of the published one");
|
|
2192
2170
|
function skillCommand() {
|
|
2193
|
-
const cmd = new
|
|
2194
|
-
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",
|
|
2171
|
+
const cmd = new Command12("skill").description("Skill registry and market");
|
|
2172
|
+
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);
|
|
2195
2173
|
listOpts(cmd.command("list").description("List skills")).option("--create-user <s>", "filter by creator").action(async (opts, cmd2) => {
|
|
2196
2174
|
printJson(
|
|
2197
2175
|
await clientFrom(cmd2).skills.list({
|
|
@@ -2329,7 +2307,7 @@ ${files.length} files, ${bytes} B
|
|
|
2329
2307
|
);
|
|
2330
2308
|
});
|
|
2331
2309
|
cmd.command("register <directory>").description("Zip a local skill directory and register it").option("--source <s>", `source tag: ${SKILL_SOURCES.join(" | ")}`, "custom").option("--extend-info <json>", "extra metadata as JSON").action(async (dir, opts, cmd2) => {
|
|
2332
|
-
const extendInfo = opts.extendInfo ?
|
|
2310
|
+
const extendInfo = opts.extendInfo ? parseBigIntJSON(opts.extendInfo) : void 0;
|
|
2333
2311
|
printJson(
|
|
2334
2312
|
await clientFrom(cmd2).skills.register(dir, {
|
|
2335
2313
|
source: checkSource(opts.source),
|
|
@@ -2369,11 +2347,11 @@ ${files.length} files, ${bytes} B
|
|
|
2369
2347
|
}
|
|
2370
2348
|
|
|
2371
2349
|
// src/commands/toolbox.ts
|
|
2372
|
-
import { Command as
|
|
2373
|
-
var
|
|
2350
|
+
import { Command as Command13 } from "commander";
|
|
2351
|
+
var int10 = (v) => Number.parseInt(v, 10);
|
|
2374
2352
|
function toolboxCommand() {
|
|
2375
|
-
const cmd = new
|
|
2376
|
-
cmd.command("list").description("List toolboxes").option("--keyword <s>", "filter by keyword").option("--limit <n>", "page size",
|
|
2353
|
+
const cmd = new Command13("toolbox").description("Agent toolbox lifecycle");
|
|
2354
|
+
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) => {
|
|
2377
2355
|
printJson(
|
|
2378
2356
|
await clientFrom(cmd2).toolboxes.list({
|
|
2379
2357
|
keyword: opts.keyword,
|
|
@@ -2414,8 +2392,8 @@ function toolboxCommand() {
|
|
|
2414
2392
|
return group(cmd, "DECISION AGENT");
|
|
2415
2393
|
}
|
|
2416
2394
|
function toolCommand() {
|
|
2417
|
-
const cmd = new
|
|
2418
|
-
cmd.command("list").description("List tools in a toolbox").requiredOption("--toolbox <box-id>", "toolbox id").option("--limit <n>", "page size (backend default 10, max 100)",
|
|
2395
|
+
const cmd = new Command13("tool").description("Tools inside a toolbox");
|
|
2396
|
+
cmd.command("list").description("List tools in a toolbox").requiredOption("--toolbox <box-id>", "toolbox id").option("--limit <n>", "page size (backend default 10, max 100)", int10).option("--page <n>", "page (1-based; backend default 1)", int10).option("--all", "return every tool, ignoring page size").action(async (opts, cmd2) => {
|
|
2419
2397
|
printJson(
|
|
2420
2398
|
await clientFrom(cmd2).toolboxes.tools(opts.toolbox, {
|
|
2421
2399
|
page: opts.page,
|
|
@@ -2437,17 +2415,17 @@ function toolCommand() {
|
|
|
2437
2415
|
outputOptions(cmd2)
|
|
2438
2416
|
);
|
|
2439
2417
|
});
|
|
2440
|
-
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",
|
|
2418
|
+
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);
|
|
2441
2419
|
const parseJson = (s, label) => {
|
|
2442
2420
|
if (!s) return void 0;
|
|
2443
2421
|
try {
|
|
2444
|
-
return
|
|
2422
|
+
return parseBigIntJSON(s);
|
|
2445
2423
|
} catch {
|
|
2446
2424
|
throw new InputError(`--${label} must be valid JSON`);
|
|
2447
2425
|
}
|
|
2448
2426
|
};
|
|
2449
2427
|
const buildEnvelope = (opts) => ({
|
|
2450
|
-
body: opts.body ?
|
|
2428
|
+
body: opts.body ? parseBigIntJSON(opts.body) : void 0,
|
|
2451
2429
|
header: parseJson(opts.header, "header"),
|
|
2452
2430
|
query: parseJson(opts.query, "query"),
|
|
2453
2431
|
path: parseJson(opts.path, "path"),
|
|
@@ -2480,7 +2458,7 @@ function toolCommand() {
|
|
|
2480
2458
|
|
|
2481
2459
|
// src/commands/trace.ts
|
|
2482
2460
|
import { readFileSync as readFileSync5, writeFileSync } from "fs";
|
|
2483
|
-
import { Command as
|
|
2461
|
+
import { Command as Command14 } from "commander";
|
|
2484
2462
|
|
|
2485
2463
|
// src/bkn-trace/schema-validate.ts
|
|
2486
2464
|
import { readFileSync as readFileSync4 } from "fs";
|
|
@@ -2523,7 +2501,7 @@ function parseFile(file) {
|
|
|
2523
2501
|
const text = readFileSync4(file, "utf8");
|
|
2524
2502
|
const ext = extname(file).toLowerCase();
|
|
2525
2503
|
if (ext === ".yaml" || ext === ".yml") return yaml.load(text);
|
|
2526
|
-
return
|
|
2504
|
+
return parseBigIntJSON(text);
|
|
2527
2505
|
}
|
|
2528
2506
|
function inferKind(data) {
|
|
2529
2507
|
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
@@ -2557,8 +2535,43 @@ function validateSchemaFile(file, kind) {
|
|
|
2557
2535
|
}
|
|
2558
2536
|
|
|
2559
2537
|
// src/commands/trace.ts
|
|
2538
|
+
function renderPayload(payload) {
|
|
2539
|
+
if (!payload) return "-";
|
|
2540
|
+
if (payload.mode === "inline") return stringifyBigIntJSON(payload.inline);
|
|
2541
|
+
if (payload.mode === "referenced") return `[referenced] ${payload.ref ?? "-"}`;
|
|
2542
|
+
return `[omitted] ${payload.omitted_reason ?? "unknown"}`;
|
|
2543
|
+
}
|
|
2544
|
+
function renderTechnicalTraceDetail(detail) {
|
|
2545
|
+
const lines = [
|
|
2546
|
+
`Trace: ${detail.summary.trace_id}`,
|
|
2547
|
+
`Status: ${detail.summary.status}`,
|
|
2548
|
+
`Request: ${detail.summary.request_id || "-"}`,
|
|
2549
|
+
`Question: ${detail.summary.question_preview || "-"}`,
|
|
2550
|
+
`Result: ${detail.summary.result_preview || "-"}`,
|
|
2551
|
+
`Service: ${detail.summary.root_service || "-"}`,
|
|
2552
|
+
`Spans: ${detail.graph?.data.nodes.length ?? 0}`
|
|
2553
|
+
];
|
|
2554
|
+
if (detail.partial) {
|
|
2555
|
+
lines.push(`Partial: ${(detail.partial_reasons ?? []).join(", ") || "yes"}`);
|
|
2556
|
+
}
|
|
2557
|
+
for (const operation of detail.operations) {
|
|
2558
|
+
lines.push(
|
|
2559
|
+
"",
|
|
2560
|
+
`${operation.fact.tool_name} \xB7 ${operation.fact.operation_id} \xB7 attempt ${operation.fact.attempt} \xB7 ${operation.state}`,
|
|
2561
|
+
`Source: ${operation.fact.protocol}/${operation.fact.source_module}`,
|
|
2562
|
+
`Input: ${renderPayload(operation.fact.input)}`
|
|
2563
|
+
);
|
|
2564
|
+
if (operation.fact.output) lines.push(`Output: ${renderPayload(operation.fact.output)}`);
|
|
2565
|
+
if (operation.fact.error) lines.push(`Error: ${renderPayload(operation.fact.error)}`);
|
|
2566
|
+
if (operation.partial_reasons?.length) {
|
|
2567
|
+
lines.push(`Partial: ${operation.partial_reasons.join(", ")}`);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
return `${lines.join("\n")}
|
|
2571
|
+
`;
|
|
2572
|
+
}
|
|
2560
2573
|
function traceCommand() {
|
|
2561
|
-
const cmd = new
|
|
2574
|
+
const cmd = new Command14("trace").description(
|
|
2562
2575
|
"BKN Trace \u2014 fetch spans, diagnose (symbolic + LLM rubric), scan, eval-set, schema validate"
|
|
2563
2576
|
);
|
|
2564
2577
|
cmd.command("graph <trace-id>").description("Fetch normalized trace graph by trace id").action(async (traceId, _opts, cmd2) => {
|
|
@@ -2633,6 +2646,12 @@ function traceCommand() {
|
|
|
2633
2646
|
outputOptions(cmd2)
|
|
2634
2647
|
);
|
|
2635
2648
|
});
|
|
2649
|
+
interactions.command("operations <interaction-id>").description("List the exact Operation call facts for one interaction").action(async (interactionId, _opts, cmd2) => {
|
|
2650
|
+
printJson(
|
|
2651
|
+
await clientFrom(cmd2).trace.lifecycle.listInteractionOperations(interactionId),
|
|
2652
|
+
outputOptions(cmd2)
|
|
2653
|
+
);
|
|
2654
|
+
});
|
|
2636
2655
|
for (const action of ["complete", "fail", "cancel", "handoff"]) {
|
|
2637
2656
|
interactions.command(`${action} <interaction-id>`).description(`${action} a managed interaction using a 3.0 completion manifest`).requiredOption("--body-file <path>", "read completion manifest JSON from a protected file").action(async (interactionId, opts, cmd2) => {
|
|
2638
2657
|
const input = readBody(opts);
|
|
@@ -2653,6 +2672,16 @@ function traceCommand() {
|
|
|
2653
2672
|
outputOptions(cmd2)
|
|
2654
2673
|
);
|
|
2655
2674
|
});
|
|
2675
|
+
operations.command("attempt <operation-id> <attempt>").description("Get one exact Operation attempt call fact").action(async (operationId, attempt, _opts, cmd2) => {
|
|
2676
|
+
if (!/^[1-9]\d*$/.test(attempt)) {
|
|
2677
|
+
throw new InputError("attempt must be a positive integer");
|
|
2678
|
+
}
|
|
2679
|
+
const ordinal = Number.parseInt(attempt, 10);
|
|
2680
|
+
printJson(
|
|
2681
|
+
await clientFrom(cmd2).trace.lifecycle.getOperationAttempt(operationId, ordinal),
|
|
2682
|
+
outputOptions(cmd2)
|
|
2683
|
+
);
|
|
2684
|
+
});
|
|
2656
2685
|
operations.command("retry <operation-id>").description("Create the next retry attempt for an eligible failed operation").requiredOption("--body-file <path>", "read retry request JSON from a protected file").action(async (operationId, opts, cmd2) => {
|
|
2657
2686
|
printJson(
|
|
2658
2687
|
await clientFrom(cmd2).trace.lifecycle.retryOperationAttempt(
|
|
@@ -2666,14 +2695,41 @@ function traceCommand() {
|
|
|
2666
2695
|
receipts.command("get <receipt-id>").description("Get an authorized operation receipt").action(async (receiptId, _opts, cmd2) => {
|
|
2667
2696
|
printJson(await clientFrom(cmd2).trace.lifecycle.getReceipt(receiptId), outputOptions(cmd2));
|
|
2668
2697
|
});
|
|
2669
|
-
cmd.command("get <conversation-id>").description("Fetch
|
|
2698
|
+
cmd.command("get <conversation-id>").description("Fetch normalized spans for a conversation").option("--max-spans <n>", "max spans", (v) => Number.parseInt(v, 10)).action(async (conversationId, opts, cmd2) => {
|
|
2670
2699
|
printJson(
|
|
2671
2700
|
await clientFrom(cmd2).trace.spans(conversationId, { maxSpans: opts.maxSpans }),
|
|
2672
2701
|
outputOptions(cmd2)
|
|
2673
2702
|
);
|
|
2674
2703
|
});
|
|
2675
|
-
cmd.command("
|
|
2676
|
-
|
|
2704
|
+
cmd.command("detail <trace-id>").description("Get one typed technical trace with Span and Operation facts").action(async (traceId, _opts, cmd2) => {
|
|
2705
|
+
const detail = await clientFrom(cmd2).trace.get(traceId);
|
|
2706
|
+
const output = outputOptions(cmd2);
|
|
2707
|
+
if (output.json || output.compact) printJson(detail, output);
|
|
2708
|
+
else process.stdout.write(renderTechnicalTraceDetail(detail));
|
|
2709
|
+
});
|
|
2710
|
+
cmd.command("spans <conversation-id>").description("Fetch normalized spans for a conversation").option("--max-spans <n>", "max spans", (v) => Number.parseInt(v, 10)).action(async (conversationId, opts, cmd2) => {
|
|
2711
|
+
printJson(
|
|
2712
|
+
await clientFrom(cmd2).trace.spans(conversationId, { maxSpans: opts.maxSpans }),
|
|
2713
|
+
outputOptions(cmd2)
|
|
2714
|
+
);
|
|
2715
|
+
});
|
|
2716
|
+
cmd.command("search").description("List authorized technical traces").option("--limit <n>", "page size, 1..200", (value) => Number.parseInt(value, 10)).option("--cursor <cursor>", "opaque pagination cursor").option("--from <time>", "started at or after this RFC3339 timestamp").option("--to <time>", "started at or before this RFC3339 timestamp").option("--status <status>", "execution status").option("--service <service>", "exact producing service").option("--tool <tool>", "exact root tool").option("--trace-id <id>", "exact Trace ID").option("--error-keyword <text>", "case-insensitive error text").option("--conversation-id <id>", "exact conversation ID").option("--interaction-id <id>", "exact interaction ID").action(async (opts, cmd2) => {
|
|
2717
|
+
printJson(
|
|
2718
|
+
await clientFrom(cmd2).trace.search({
|
|
2719
|
+
limit: opts.limit,
|
|
2720
|
+
cursor: opts.cursor,
|
|
2721
|
+
from: opts.from,
|
|
2722
|
+
to: opts.to,
|
|
2723
|
+
status: opts.status,
|
|
2724
|
+
service: opts.service,
|
|
2725
|
+
tool: opts.tool,
|
|
2726
|
+
traceId: opts.traceId,
|
|
2727
|
+
errorKeyword: opts.errorKeyword,
|
|
2728
|
+
conversationId: opts.conversationId,
|
|
2729
|
+
interactionId: opts.interactionId
|
|
2730
|
+
}),
|
|
2731
|
+
outputOptions(cmd2)
|
|
2732
|
+
);
|
|
2677
2733
|
});
|
|
2678
2734
|
cmd.command("diagnose <conversation-id>").description("Diagnose a conversation's trace (symbolic rules; --llm adds rubric judging)").option("--llm", "also run LLM-judged rubric rules via the local `claude` CLI").action(async (conversationId, opts, cmd2) => {
|
|
2679
2735
|
const report = await clientFrom(cmd2).trace.diagnose(conversationId, {
|
|
@@ -2692,17 +2748,17 @@ function traceCommand() {
|
|
|
2692
2748
|
});
|
|
2693
2749
|
const evalSet = cmd.command("eval-set").description("Build + run trace eval sets");
|
|
2694
2750
|
evalSet.command("build <queries-file>").description("Build eval cases from a queries JSON file").option("--out <file>", "write the cases JSON here (default: stdout)").action(async (queriesFile, opts, cmd2) => {
|
|
2695
|
-
const raw =
|
|
2751
|
+
const raw = parseBigIntJSON(readFileSync5(queriesFile, "utf8"));
|
|
2696
2752
|
const cases = clientFrom(cmd2).trace.evalSetBuild(raw);
|
|
2697
2753
|
if (opts.out) {
|
|
2698
|
-
writeFileSync(opts.out,
|
|
2754
|
+
writeFileSync(opts.out, stringifyBigIntJSON({ cases }, 2));
|
|
2699
2755
|
printJson({ out: opts.out, cases: cases.length }, outputOptions(cmd2));
|
|
2700
2756
|
} else {
|
|
2701
2757
|
printJson({ cases }, outputOptions(cmd2));
|
|
2702
2758
|
}
|
|
2703
2759
|
});
|
|
2704
2760
|
evalSet.command("test <cases-file>").description("Run an eval set against an agent (--llm enables semantic_match)").requiredOption("--agent <id>", "agent id to run the queries against").option("--version <v>", "agent version", "v0").option("--llm", "enable semantic_match assertions via the local `claude` CLI").action(async (casesFile, opts, cmd2) => {
|
|
2705
|
-
const raw =
|
|
2761
|
+
const raw = parseBigIntJSON(readFileSync5(casesFile, "utf8"));
|
|
2706
2762
|
const cases = clientFrom(cmd2).trace.evalSetBuild(raw);
|
|
2707
2763
|
const result = await clientFrom(cmd2).trace.evalSetTest(opts.agent, cases, {
|
|
2708
2764
|
version: opts.version,
|
|
@@ -2726,8 +2782,28 @@ function traceCommand() {
|
|
|
2726
2782
|
}
|
|
2727
2783
|
|
|
2728
2784
|
// src/commands/vega.ts
|
|
2729
|
-
import { Command as
|
|
2730
|
-
var
|
|
2785
|
+
import { Command as Command15 } from "commander";
|
|
2786
|
+
var int11 = (value) => {
|
|
2787
|
+
const parsed = Number(value);
|
|
2788
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
2789
|
+
throw new InputError(`expected an integer, received "${value}"`);
|
|
2790
|
+
}
|
|
2791
|
+
return parsed;
|
|
2792
|
+
};
|
|
2793
|
+
var expectedUpdateTime = (value) => {
|
|
2794
|
+
const parsed = Number(value);
|
|
2795
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
2796
|
+
throw new InputError("--expected-update-time must be a positive integer timestamp");
|
|
2797
|
+
}
|
|
2798
|
+
return parsed;
|
|
2799
|
+
};
|
|
2800
|
+
var confidenceThreshold = (value) => {
|
|
2801
|
+
const parsed = Number(value);
|
|
2802
|
+
if (!Number.isFinite(parsed) || parsed < 0 || parsed > 1) {
|
|
2803
|
+
throw new InputError("--confidence-threshold must be a number between 0 and 1");
|
|
2804
|
+
}
|
|
2805
|
+
return parsed;
|
|
2806
|
+
};
|
|
2731
2807
|
var bool = (value) => {
|
|
2732
2808
|
if (value === "true") return true;
|
|
2733
2809
|
if (value === "false") return false;
|
|
@@ -2736,7 +2812,7 @@ var bool = (value) => {
|
|
|
2736
2812
|
var parseJsonObject = (value, flag) => {
|
|
2737
2813
|
let parsed;
|
|
2738
2814
|
try {
|
|
2739
|
-
parsed =
|
|
2815
|
+
parsed = parseBigIntJSON(value);
|
|
2740
2816
|
} catch {
|
|
2741
2817
|
throw new InputError(`${flag} must be valid JSON`);
|
|
2742
2818
|
}
|
|
@@ -2745,10 +2821,15 @@ var parseJsonObject = (value, flag) => {
|
|
|
2745
2821
|
}
|
|
2746
2822
|
return parsed;
|
|
2747
2823
|
};
|
|
2748
|
-
var
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2824
|
+
var parseJsonArray = (value, flag) => {
|
|
2825
|
+
let parsed;
|
|
2826
|
+
try {
|
|
2827
|
+
parsed = parseBigIntJSON(value);
|
|
2828
|
+
} catch {
|
|
2829
|
+
throw new InputError(`${flag} must be valid JSON`);
|
|
2830
|
+
}
|
|
2831
|
+
if (!Array.isArray(parsed) || parsed.some((item) => typeof item !== "object" || item === null || Array.isArray(item))) {
|
|
2832
|
+
throw new InputError(`${flag} must be a JSON array of objects`);
|
|
2752
2833
|
}
|
|
2753
2834
|
return parsed;
|
|
2754
2835
|
};
|
|
@@ -2771,20 +2852,133 @@ var healthCheckSchedule = (mode, cronExpr) => {
|
|
|
2771
2852
|
}
|
|
2772
2853
|
throw new InputError("health-check mode must be inherit, enabled, or disabled");
|
|
2773
2854
|
};
|
|
2774
|
-
var
|
|
2775
|
-
if (
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2855
|
+
var buildTaskStatuses = (raw) => {
|
|
2856
|
+
if (raw === void 0) return void 0;
|
|
2857
|
+
const statuses = csv(raw);
|
|
2858
|
+
if (!statuses?.length) {
|
|
2859
|
+
throw new InputError("--status must include at least one build status");
|
|
2860
|
+
}
|
|
2861
|
+
return statuses.map((status2) => {
|
|
2862
|
+
const parsed = BuildTaskStatus.safeParse(status2);
|
|
2863
|
+
if (!parsed.success) {
|
|
2864
|
+
throw new InputError(
|
|
2865
|
+
`invalid build status "${status2}"; expected one of ${BuildTaskStatus.options.join(", ")}`
|
|
2866
|
+
);
|
|
2867
|
+
}
|
|
2868
|
+
return parsed.data;
|
|
2869
|
+
});
|
|
2870
|
+
};
|
|
2871
|
+
var buildTaskSort = (raw) => {
|
|
2872
|
+
if (raw === void 0) return void 0;
|
|
2873
|
+
const parsed = BuildTaskSort.safeParse(raw);
|
|
2874
|
+
if (!parsed.success) {
|
|
2875
|
+
throw new InputError(
|
|
2876
|
+
`invalid build task sort "${raw}"; expected one of ${BuildTaskSort.options.join(", ")}`
|
|
2877
|
+
);
|
|
2878
|
+
}
|
|
2879
|
+
return parsed.data;
|
|
2880
|
+
};
|
|
2881
|
+
var discoverStrategy = (raw) => {
|
|
2882
|
+
if (raw === void 0) return void 0;
|
|
2883
|
+
const parsed = DiscoverStrategy.safeParse(raw);
|
|
2884
|
+
if (!parsed.success) {
|
|
2885
|
+
throw new InputError(
|
|
2886
|
+
`invalid discover strategy "${raw}"; expected one of ${DiscoverStrategy.options.join(", ")}`
|
|
2887
|
+
);
|
|
2888
|
+
}
|
|
2889
|
+
return parsed.data;
|
|
2890
|
+
};
|
|
2891
|
+
var requiredDiscoverStrategy = (raw) => discoverStrategy(raw);
|
|
2892
|
+
var taskStatuses = (raw) => {
|
|
2893
|
+
if (raw === void 0) return void 0;
|
|
2894
|
+
const values = csv(raw);
|
|
2895
|
+
if (!values?.length) throw new InputError("--status must include at least one task status");
|
|
2896
|
+
return values.map((value) => {
|
|
2897
|
+
const parsed = VegaTaskStatus.safeParse(value);
|
|
2898
|
+
if (!parsed.success) {
|
|
2899
|
+
throw new InputError(
|
|
2900
|
+
`invalid task status "${value}"; expected one of ${VegaTaskStatus.options.join(", ")}`
|
|
2901
|
+
);
|
|
2902
|
+
}
|
|
2903
|
+
return parsed.data;
|
|
2904
|
+
});
|
|
2905
|
+
};
|
|
2906
|
+
var semanticScope = (raw) => {
|
|
2907
|
+
if (raw === void 0) return void 0;
|
|
2908
|
+
const parsed = SemanticUnderstandingScope.safeParse(raw);
|
|
2909
|
+
if (!parsed.success) {
|
|
2910
|
+
throw new InputError(
|
|
2911
|
+
`invalid semantic task scope "${raw}"; expected one of ${SemanticUnderstandingScope.options.join(", ")}`
|
|
2912
|
+
);
|
|
2913
|
+
}
|
|
2914
|
+
return parsed.data;
|
|
2915
|
+
};
|
|
2916
|
+
var semanticApplyMode = (raw) => {
|
|
2917
|
+
if (raw === void 0) return void 0;
|
|
2918
|
+
const parsed = SemanticUnderstandingApplyMode.safeParse(raw);
|
|
2919
|
+
if (!parsed.success) {
|
|
2920
|
+
throw new InputError(
|
|
2921
|
+
`invalid semantic apply mode "${raw}"; expected one of ${SemanticUnderstandingApplyMode.options.join(", ")}`
|
|
2922
|
+
);
|
|
2923
|
+
}
|
|
2924
|
+
return parsed.data;
|
|
2925
|
+
};
|
|
2926
|
+
var discoverScheduleSort = (raw) => {
|
|
2927
|
+
if (raw === void 0) return void 0;
|
|
2928
|
+
const parsed = DiscoverScheduleSort.safeParse(raw);
|
|
2929
|
+
if (!parsed.success) {
|
|
2930
|
+
throw new InputError(
|
|
2931
|
+
`invalid discover schedule sort "${raw}"; expected one of ${DiscoverScheduleSort.options.join(", ")}`
|
|
2932
|
+
);
|
|
2933
|
+
}
|
|
2934
|
+
return parsed.data;
|
|
2935
|
+
};
|
|
2936
|
+
var discoverTaskSort = (raw) => {
|
|
2937
|
+
if (raw === void 0) return void 0;
|
|
2938
|
+
const parsed = DiscoverTaskSort.safeParse(raw);
|
|
2939
|
+
if (!parsed.success) {
|
|
2940
|
+
throw new InputError(
|
|
2941
|
+
`invalid discover task sort "${raw}"; expected one of ${DiscoverTaskSort.options.join(", ")}`
|
|
2942
|
+
);
|
|
2943
|
+
}
|
|
2944
|
+
return parsed.data;
|
|
2945
|
+
};
|
|
2946
|
+
var discoverTaskTriggerType = (raw) => {
|
|
2947
|
+
if (raw === void 0) return void 0;
|
|
2948
|
+
const parsed = DiscoverTaskTriggerType.safeParse(raw);
|
|
2949
|
+
if (!parsed.success) {
|
|
2950
|
+
throw new InputError(
|
|
2951
|
+
`invalid discover task trigger type "${raw}"; expected one of ${DiscoverTaskTriggerType.options.join(", ")}`
|
|
2952
|
+
);
|
|
2953
|
+
}
|
|
2954
|
+
return parsed.data;
|
|
2955
|
+
};
|
|
2956
|
+
var semanticTaskSort = (raw) => {
|
|
2957
|
+
if (raw === void 0) return void 0;
|
|
2958
|
+
const parsed = SemanticUnderstandingTaskSort.safeParse(raw);
|
|
2959
|
+
if (!parsed.success) {
|
|
2960
|
+
throw new InputError(
|
|
2961
|
+
`invalid semantic task sort "${raw}"; expected one of ${SemanticUnderstandingTaskSort.options.join(", ")}`
|
|
2962
|
+
);
|
|
2963
|
+
}
|
|
2964
|
+
return parsed.data;
|
|
2965
|
+
};
|
|
2966
|
+
var sortDirection = (raw) => {
|
|
2967
|
+
if (raw === void 0) return void 0;
|
|
2968
|
+
const parsed = SortDirection.safeParse(raw);
|
|
2969
|
+
if (!parsed.success) {
|
|
2970
|
+
throw new InputError(
|
|
2971
|
+
`invalid sort direction "${raw}"; expected one of ${SortDirection.options.join(", ")}`
|
|
2972
|
+
);
|
|
2973
|
+
}
|
|
2974
|
+
return parsed.data;
|
|
2781
2975
|
};
|
|
2782
2976
|
function vegaCommand() {
|
|
2783
|
-
const vega = new
|
|
2977
|
+
const vega = new Command15("vega").description(
|
|
2784
2978
|
"Vega observability \u2014 catalog, resources, index build tasks"
|
|
2785
2979
|
);
|
|
2786
2980
|
const catalog = vega.command("catalog").description("Catalog entries");
|
|
2787
|
-
catalog.command("list").description("List catalog entries").option("--limit <n>", "page size",
|
|
2981
|
+
catalog.command("list").description("List catalog entries").option("--limit <n>", "page size", int11, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int11, 0).option("--name <s>", "filter by name").option("--tag <s>", "filter by tag").option("--type <type>", "filter by catalog type: physical | logical").option("--connector-type <type>", "filter by connector type").option("--enabled <bool>", "filter by enabled state").option("--health-check-status <s>", "filter by health status").option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (_opts, cmd) => {
|
|
2788
2982
|
const o = cmd.optsWithGlobals();
|
|
2789
2983
|
const data = await clientFrom(cmd).vega.catalogs({
|
|
2790
2984
|
limit: o.limit,
|
|
@@ -2792,11 +2986,9 @@ function vegaCommand() {
|
|
|
2792
2986
|
name: o.name,
|
|
2793
2987
|
tag: o.tag,
|
|
2794
2988
|
type: o.type,
|
|
2989
|
+
connectorType: o.connectorType,
|
|
2795
2990
|
enabled: o.enabled === void 0 ? void 0 : o.enabled === "true",
|
|
2796
2991
|
healthCheckStatus: o.healthCheckStatus,
|
|
2797
|
-
includeExtensions: o.includeExtensions,
|
|
2798
|
-
includeExtensionKeys: o.includeExtensionKeys,
|
|
2799
|
-
extensionPairs: parsePairs2(o.extension),
|
|
2800
2992
|
sort: o.sort,
|
|
2801
2993
|
direction: o.direction
|
|
2802
2994
|
});
|
|
@@ -2805,7 +2997,7 @@ function vegaCommand() {
|
|
|
2805
2997
|
catalog.command("get <id>").description("Get a catalog by id").action(async (id, _opts, cmd) => {
|
|
2806
2998
|
printJson(await clientFrom(cmd).vega.getCatalog(id), outputOptions(cmd));
|
|
2807
2999
|
});
|
|
2808
|
-
catalog.command("resources <id>").description("List resources under a catalog").option("--category <c>", "filter by category (e.g. table)").option("--limit <n>", "page size (
|
|
3000
|
+
catalog.command("resources <id>").description("List resources under a catalog").option("--category <c>", "filter by category (e.g. table)").option("--limit <n>", "page size (default 30, max 1000; -1 = all)", int11).option("--offset <n>", "page offset", int11, 0).action(async (id, opts, cmd) => {
|
|
2809
3001
|
printJson(
|
|
2810
3002
|
await clientFrom(cmd).vega.catalogResources(id, opts.category, opts.limit, opts.offset),
|
|
2811
3003
|
outputOptions(cmd)
|
|
@@ -2814,9 +3006,8 @@ function vegaCommand() {
|
|
|
2814
3006
|
catalog.command("health <id>").description("Health-status for a catalog").action(async (id, _opts, cmd) => {
|
|
2815
3007
|
printJson(await clientFrom(cmd).vega.catalogHealth(id), outputOptions(cmd));
|
|
2816
3008
|
});
|
|
2817
|
-
catalog.command("create").description("Create a catalog (data source)").requiredOption("--name <s>", "catalog name").requiredOption("--connector-type <s>", "connector type (e.g. mysql)").requiredOption("--connector-config <json>", "connector config JSON").option("--id <id>", "explicit catalog id").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").option("--enabled", "create enabled (default: disabled)").option("--internal", "create an internal catalog").option("--
|
|
3009
|
+
catalog.command("create").description("Create a catalog (data source)").requiredOption("--name <s>", "catalog name").requiredOption("--connector-type <s>", "connector type (e.g. mysql)").requiredOption("--connector-config <json>", "connector config JSON").option("--id <id>", "explicit catalog id").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").option("--enabled", "create enabled (default: disabled)").option("--internal", "create an internal catalog").option("--allow-unhealthy", "save the catalog when its connection test fails").option("--health-check-mode <mode>", "health schedule: inherit | enabled | disabled").option("--health-check-cron <expr>", "cron expression for enabled health checks").action(async (opts, cmd) => {
|
|
2818
3010
|
const connectorConfig = parseJsonObject(opts.connectorConfig, "--connector-config");
|
|
2819
|
-
const extensions = opts.extensions ? parseStringRecord(opts.extensions, "--extensions") : void 0;
|
|
2820
3011
|
printJson(
|
|
2821
3012
|
await clientFrom(cmd).vega.createCatalog(
|
|
2822
3013
|
{
|
|
@@ -2828,7 +3019,6 @@ function vegaCommand() {
|
|
|
2828
3019
|
description: opts.description,
|
|
2829
3020
|
enabled: opts.enabled ? true : void 0,
|
|
2830
3021
|
internal: opts.internal ? true : void 0,
|
|
2831
|
-
extensions,
|
|
2832
3022
|
healthCheckSchedule: healthCheckSchedule(opts.healthCheckMode, opts.healthCheckCron)
|
|
2833
3023
|
},
|
|
2834
3024
|
{ allowUnhealthy: opts.allowUnhealthy ? true : void 0 }
|
|
@@ -2836,9 +3026,12 @@ function vegaCommand() {
|
|
|
2836
3026
|
outputOptions(cmd)
|
|
2837
3027
|
);
|
|
2838
3028
|
});
|
|
2839
|
-
catalog.command("update <id>").description("Fully update a catalog").requiredOption("--name <s>", "catalog name").requiredOption("--connector-type <s>", "connector type").requiredOption("--enabled <bool>", "current enabled state", bool).option("--connector-config <json>", "connector config JSON").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").
|
|
3029
|
+
catalog.command("update <id>").description("Fully update a catalog").requiredOption("--name <s>", "catalog name").requiredOption("--connector-type <s>", "connector type").requiredOption("--enabled <bool>", "current enabled state", bool).option("--connector-config <json>", "connector config JSON").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").requiredOption(
|
|
3030
|
+
"--expected-update-time <ms>",
|
|
3031
|
+
"optimistic-lock update time",
|
|
3032
|
+
expectedUpdateTime
|
|
3033
|
+
).option("--allow-unhealthy", "save the update when its connection test fails").action(async (id, opts, cmd) => {
|
|
2840
3034
|
const connectorConfig = opts.connectorConfig ? parseJsonObject(opts.connectorConfig, "--connector-config") : void 0;
|
|
2841
|
-
const extensions = opts.extensions ? parseStringRecord(opts.extensions, "--extensions") : void 0;
|
|
2842
3035
|
printJson(
|
|
2843
3036
|
await clientFrom(cmd).vega.updateCatalog(
|
|
2844
3037
|
id,
|
|
@@ -2849,7 +3042,7 @@ function vegaCommand() {
|
|
|
2849
3042
|
tags: opts.tags ? String(opts.tags).split(",").map((t) => t.trim()).filter(Boolean) : void 0,
|
|
2850
3043
|
description: opts.description,
|
|
2851
3044
|
enabled: opts.enabled,
|
|
2852
|
-
|
|
3045
|
+
expectedUpdateTime: opts.expectedUpdateTime
|
|
2853
3046
|
},
|
|
2854
3047
|
{ allowUnhealthy: opts.allowUnhealthy ? true : void 0 }
|
|
2855
3048
|
),
|
|
@@ -2862,8 +3055,9 @@ function vegaCommand() {
|
|
|
2862
3055
|
catalog.command("disable <id>").description("Disable a catalog").action(async (id, _opts, cmd) => {
|
|
2863
3056
|
printJson(await clientFrom(cmd).vega.disableCatalog(id), outputOptions(cmd));
|
|
2864
3057
|
});
|
|
2865
|
-
catalog.command("delete <id>").description("Delete a catalog").action(async (id,
|
|
2866
|
-
|
|
3058
|
+
catalog.command("delete <id>").description("Delete a catalog").option("--dry-run", "preview deletion impact without changing data").action(async (id, opts, cmd) => {
|
|
3059
|
+
const result = opts.dryRun ? await clientFrom(cmd).vega.deleteCatalog(id, { dryRun: true }) : await clientFrom(cmd).vega.deleteCatalog(id);
|
|
3060
|
+
printJson(result, outputOptions(cmd));
|
|
2867
3061
|
});
|
|
2868
3062
|
catalog.command("test-connection <id>").description("Test a catalog connection").action(async (id, _opts, cmd) => {
|
|
2869
3063
|
printJson(await clientFrom(cmd).vega.testCatalogConnection(id), outputOptions(cmd));
|
|
@@ -2880,17 +3074,182 @@ function vegaCommand() {
|
|
|
2880
3074
|
catalog.command("health-check-schedule <id>").description("Get a catalog health-check schedule").action(async (id, _opts, cmd) => {
|
|
2881
3075
|
printJson(await clientFrom(cmd).vega.catalogHealthCheckSchedule(id), outputOptions(cmd));
|
|
2882
3076
|
});
|
|
2883
|
-
catalog.command("set-health-check-schedule <id>").description("Update a catalog health-check schedule").requiredOption("--mode <mode>", "health schedule: inherit | enabled | disabled").option("--cron <expr>", "cron expression for enabled health checks").
|
|
3077
|
+
catalog.command("set-health-check-schedule <id>").description("Update a catalog health-check schedule").requiredOption("--mode <mode>", "health schedule: inherit | enabled | disabled").option("--cron <expr>", "cron expression for enabled health checks").requiredOption(
|
|
3078
|
+
"--expected-update-time <ms>",
|
|
3079
|
+
"optimistic-lock update time",
|
|
3080
|
+
expectedUpdateTime
|
|
3081
|
+
).action(async (id, opts, cmd) => {
|
|
2884
3082
|
const schedule = healthCheckSchedule(opts.mode, opts.cron);
|
|
2885
3083
|
if (!schedule) throw new InputError("--mode is required");
|
|
2886
3084
|
printJson(
|
|
2887
|
-
await clientFrom(cmd).vega.updateCatalogHealthCheckSchedule(id,
|
|
3085
|
+
await clientFrom(cmd).vega.updateCatalogHealthCheckSchedule(id, {
|
|
3086
|
+
...schedule,
|
|
3087
|
+
expectedUpdateTime: opts.expectedUpdateTime
|
|
3088
|
+
}),
|
|
3089
|
+
outputOptions(cmd)
|
|
3090
|
+
);
|
|
3091
|
+
});
|
|
3092
|
+
catalog.command("discover <id>").description("Trigger catalog resource discovery").option("--strategy <strategy>", `strategy: ${DiscoverStrategy.options.join(" | ")}`).action(async (id, opts, cmd) => {
|
|
3093
|
+
printJson(
|
|
3094
|
+
await clientFrom(cmd).vega.discoverCatalog(id, {
|
|
3095
|
+
strategy: discoverStrategy(opts.strategy)
|
|
3096
|
+
}),
|
|
3097
|
+
outputOptions(cmd)
|
|
3098
|
+
);
|
|
3099
|
+
});
|
|
3100
|
+
const discoverSchedule = vega.command("discover-schedule").description("Resource discovery schedules");
|
|
3101
|
+
discoverSchedule.command("list").description("List discovery schedules").option("--name <s>", "filter by name").option("--catalog-id <id>", "filter by catalog id").option("--enabled <bool>", "filter by enabled state", bool).option("--limit <n>", "page size", int11, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int11, 0).option("--sort <field>", "name | create_time | update_time | next_run").option("--direction <dir>", "asc | desc").action(async (opts, cmd) => {
|
|
3102
|
+
printJson(
|
|
3103
|
+
await clientFrom(cmd).vega.discoverSchedules({
|
|
3104
|
+
name: opts.name,
|
|
3105
|
+
catalogId: opts.catalogId,
|
|
3106
|
+
enabled: opts.enabled,
|
|
3107
|
+
limit: opts.limit,
|
|
3108
|
+
offset: opts.offset,
|
|
3109
|
+
sort: discoverScheduleSort(opts.sort),
|
|
3110
|
+
direction: sortDirection(opts.direction)
|
|
3111
|
+
}),
|
|
3112
|
+
outputOptions(cmd)
|
|
3113
|
+
);
|
|
3114
|
+
});
|
|
3115
|
+
discoverSchedule.command("get <id>").description("Get a discovery schedule").action(async (id, _opts, cmd) => {
|
|
3116
|
+
printJson(await clientFrom(cmd).vega.getDiscoverSchedule(id), outputOptions(cmd));
|
|
3117
|
+
});
|
|
3118
|
+
discoverSchedule.command("create").description("Create a discovery schedule").requiredOption("--name <s>", "schedule name").requiredOption("--catalog-id <id>", "catalog id").requiredOption("--cron <expr>", "five-field cron expression").option("--start-time <ms>", "start time", int11).option("--end-time <ms>", "end time", int11).option("--enabled", "create enabled").option("--strategy <strategy>", `strategy: ${DiscoverStrategy.options.join(" | ")}`).action(async (opts, cmd) => {
|
|
3119
|
+
printJson(
|
|
3120
|
+
await clientFrom(cmd).vega.createDiscoverSchedule({
|
|
3121
|
+
name: opts.name,
|
|
3122
|
+
catalogId: opts.catalogId,
|
|
3123
|
+
cronExpr: opts.cron,
|
|
3124
|
+
startTime: opts.startTime,
|
|
3125
|
+
endTime: opts.endTime,
|
|
3126
|
+
enabled: opts.enabled ? true : void 0,
|
|
3127
|
+
strategy: discoverStrategy(opts.strategy)
|
|
3128
|
+
}),
|
|
2888
3129
|
outputOptions(cmd)
|
|
2889
3130
|
);
|
|
2890
3131
|
});
|
|
2891
|
-
|
|
3132
|
+
discoverSchedule.command("update <id>").description("Fully update a discovery schedule").requiredOption("--name <s>", "schedule name").requiredOption("--catalog-id <id>", "current catalog id").requiredOption("--cron <expr>", "five-field cron expression").requiredOption("--enabled <bool>", "current enabled state", bool).requiredOption("--start-time <ms>", "start time (0 = no lower bound)", int11).requiredOption("--end-time <ms>", "end time (0 = no upper bound)", int11).requiredOption("--strategy <strategy>", `strategy: ${DiscoverStrategy.options.join(" | ")}`).requiredOption(
|
|
3133
|
+
"--expected-update-time <ms>",
|
|
3134
|
+
"optimistic-lock update time",
|
|
3135
|
+
expectedUpdateTime
|
|
3136
|
+
).action(async (id, opts, cmd) => {
|
|
2892
3137
|
printJson(
|
|
2893
|
-
await clientFrom(cmd).vega.
|
|
3138
|
+
await clientFrom(cmd).vega.updateDiscoverSchedule(id, {
|
|
3139
|
+
name: opts.name,
|
|
3140
|
+
catalogId: opts.catalogId,
|
|
3141
|
+
cronExpr: opts.cron,
|
|
3142
|
+
enabled: opts.enabled,
|
|
3143
|
+
startTime: opts.startTime,
|
|
3144
|
+
endTime: opts.endTime,
|
|
3145
|
+
strategy: requiredDiscoverStrategy(opts.strategy),
|
|
3146
|
+
expectedUpdateTime: opts.expectedUpdateTime
|
|
3147
|
+
}),
|
|
3148
|
+
outputOptions(cmd)
|
|
3149
|
+
);
|
|
3150
|
+
});
|
|
3151
|
+
for (const action of ["enable", "disable", "delete"]) {
|
|
3152
|
+
discoverSchedule.command(`${action} <id>`).description(`${action[0]?.toUpperCase()}${action.slice(1)} a discovery schedule`).action(async (id, _opts, cmd) => {
|
|
3153
|
+
const api = clientFrom(cmd).vega;
|
|
3154
|
+
const result = action === "enable" ? await api.enableDiscoverSchedule(id) : action === "disable" ? await api.disableDiscoverSchedule(id) : await api.deleteDiscoverSchedule(id);
|
|
3155
|
+
printJson(result, outputOptions(cmd));
|
|
3156
|
+
});
|
|
3157
|
+
}
|
|
3158
|
+
const discoverTask = vega.command("discover-task").description("Resource discovery tasks");
|
|
3159
|
+
discoverTask.command("list").description("List discovery tasks").option("--catalog-id <id>", "filter by catalog id").option("--schedule-id <id>", "filter by schedule id").option("--status <status>", `comma-separated: ${VegaTaskStatus.options.join(" | ")}`).option("--strategy <strategy>", `strategy: ${DiscoverStrategy.options.join(" | ")}`).option("--trigger-type <type>", "manual | scheduled").option("--limit <n>", "page size", int11, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int11, 0).option("--sort <field>", "create_time | start_time | finish_time | last_progress_time").option("--direction <dir>", "asc | desc").action(async (opts, cmd) => {
|
|
3160
|
+
printJson(
|
|
3161
|
+
await clientFrom(cmd).vega.discoverTasks({
|
|
3162
|
+
catalogId: opts.catalogId,
|
|
3163
|
+
scheduleId: opts.scheduleId,
|
|
3164
|
+
status: taskStatuses(opts.status),
|
|
3165
|
+
strategy: discoverStrategy(opts.strategy),
|
|
3166
|
+
triggerType: discoverTaskTriggerType(opts.triggerType),
|
|
3167
|
+
limit: opts.limit,
|
|
3168
|
+
offset: opts.offset,
|
|
3169
|
+
sort: discoverTaskSort(opts.sort),
|
|
3170
|
+
direction: sortDirection(opts.direction)
|
|
3171
|
+
}),
|
|
3172
|
+
outputOptions(cmd)
|
|
3173
|
+
);
|
|
3174
|
+
});
|
|
3175
|
+
discoverTask.command("get <id>").description("Get a discovery task").action(async (id, _opts, cmd) => {
|
|
3176
|
+
printJson(await clientFrom(cmd).vega.getDiscoverTask(id), outputOptions(cmd));
|
|
3177
|
+
});
|
|
3178
|
+
discoverTask.command("delete <ids...>").description("Delete completed discovery tasks").option("--ignore-missing", "ignore missing task ids").action(async (ids, opts, cmd) => {
|
|
3179
|
+
printJson(
|
|
3180
|
+
await clientFrom(cmd).vega.deleteDiscoverTasks(ids, {
|
|
3181
|
+
ignoreMissing: opts.ignoreMissing
|
|
3182
|
+
}),
|
|
3183
|
+
outputOptions(cmd)
|
|
3184
|
+
);
|
|
3185
|
+
});
|
|
3186
|
+
const semanticTask = vega.command("semantic-task").description("Semantic-understanding tasks");
|
|
3187
|
+
semanticTask.command("list").description("List semantic-understanding tasks").option("--scope <scope>", `scope: ${SemanticUnderstandingScope.options.join(" | ")}`).option("--catalog-id <id>", "filter by catalog id").option("--resource-id <id>", "filter by resource id").option("--status <status>", `comma-separated: ${VegaTaskStatus.options.join(" | ")}`).option(
|
|
3188
|
+
"--apply-mode <mode>",
|
|
3189
|
+
`apply mode: ${SemanticUnderstandingApplyMode.options.join(" | ")}`
|
|
3190
|
+
).option("--applied <bool>", "filter by applied state", bool).option("--limit <n>", "page size", int11, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int11, 0).option("--sort <field>", "create_time | start_time | finish_time").option("--direction <dir>", "asc | desc").action(async (opts, cmd) => {
|
|
3191
|
+
printJson(
|
|
3192
|
+
await clientFrom(cmd).vega.semanticUnderstandingTasks({
|
|
3193
|
+
scope: semanticScope(opts.scope),
|
|
3194
|
+
catalogId: opts.catalogId,
|
|
3195
|
+
resourceId: opts.resourceId,
|
|
3196
|
+
status: taskStatuses(opts.status),
|
|
3197
|
+
applyMode: semanticApplyMode(opts.applyMode),
|
|
3198
|
+
applied: opts.applied,
|
|
3199
|
+
limit: opts.limit,
|
|
3200
|
+
offset: opts.offset,
|
|
3201
|
+
sort: semanticTaskSort(opts.sort),
|
|
3202
|
+
direction: sortDirection(opts.direction)
|
|
3203
|
+
}),
|
|
3204
|
+
outputOptions(cmd)
|
|
3205
|
+
);
|
|
3206
|
+
});
|
|
3207
|
+
semanticTask.command("create").description("Create a semantic-understanding task").requiredOption("--scope <scope>", "resource | catalog").option("--catalog-id <id>", "catalog id").option("--resource-id <id>", "resource id").option("--apply-mode <mode>", "dry_run | fill_empty | force").option("--confidence-threshold <n>", "minimum confidence (0..1)", confidenceThreshold).option("--include-sample-rows", "include resource sample rows").option("--sample-max-rows <n>", "sample row limit", int11).action(async (opts, cmd) => {
|
|
3208
|
+
const scope = semanticScope(opts.scope);
|
|
3209
|
+
if (!scope) throw new InputError("--scope is required");
|
|
3210
|
+
const applyMode = semanticApplyMode(opts.applyMode);
|
|
3211
|
+
if (scope === "catalog" && !opts.catalogId) {
|
|
3212
|
+
throw new InputError("--catalog-id is required for catalog scope");
|
|
3213
|
+
}
|
|
3214
|
+
if (scope === "resource" && !opts.resourceId) {
|
|
3215
|
+
throw new InputError("--resource-id is required for resource scope");
|
|
3216
|
+
}
|
|
3217
|
+
if (scope === "catalog" && (opts.includeSampleRows || opts.sampleMaxRows !== void 0)) {
|
|
3218
|
+
throw new InputError("sample row options are only valid for resource scope");
|
|
3219
|
+
}
|
|
3220
|
+
if (scope === "resource" && opts.includeSampleRows && opts.sampleMaxRows === void 0) {
|
|
3221
|
+
throw new InputError("--sample-max-rows is required with --include-sample-rows");
|
|
3222
|
+
}
|
|
3223
|
+
if (scope === "resource" && !opts.includeSampleRows && opts.sampleMaxRows !== void 0) {
|
|
3224
|
+
throw new InputError("--sample-max-rows requires --include-sample-rows");
|
|
3225
|
+
}
|
|
3226
|
+
if (opts.sampleMaxRows !== void 0 && (opts.sampleMaxRows < 1 || opts.sampleMaxRows > 20)) {
|
|
3227
|
+
throw new InputError("--sample-max-rows must be between 1 and 20");
|
|
3228
|
+
}
|
|
3229
|
+
const common = {
|
|
3230
|
+
applyMode,
|
|
3231
|
+
confidenceThreshold: opts.confidenceThreshold
|
|
3232
|
+
};
|
|
3233
|
+
const request = scope === "catalog" ? { scope: "catalog", catalogId: opts.catalogId, ...common } : {
|
|
3234
|
+
scope: "resource",
|
|
3235
|
+
resourceId: opts.resourceId,
|
|
3236
|
+
includeSampleRows: opts.includeSampleRows ? true : void 0,
|
|
3237
|
+
samplePolicy: opts.sampleMaxRows === void 0 ? void 0 : { masked: false, maxRows: opts.sampleMaxRows },
|
|
3238
|
+
...common
|
|
3239
|
+
};
|
|
3240
|
+
printJson(
|
|
3241
|
+
await clientFrom(cmd).vega.createSemanticUnderstandingTask(request),
|
|
3242
|
+
outputOptions(cmd)
|
|
3243
|
+
);
|
|
3244
|
+
});
|
|
3245
|
+
semanticTask.command("get <id>").description("Get a semantic-understanding task").action(async (id, _opts, cmd) => {
|
|
3246
|
+
printJson(await clientFrom(cmd).vega.getSemanticUnderstandingTask(id), outputOptions(cmd));
|
|
3247
|
+
});
|
|
3248
|
+
semanticTask.command("delete <ids...>").description("Delete completed semantic-understanding tasks").option("--ignore-missing", "ignore missing task ids").action(async (ids, opts, cmd) => {
|
|
3249
|
+
printJson(
|
|
3250
|
+
await clientFrom(cmd).vega.deleteSemanticUnderstandingTasks(ids, {
|
|
3251
|
+
ignoreMissing: opts.ignoreMissing
|
|
3252
|
+
}),
|
|
2894
3253
|
outputOptions(cmd)
|
|
2895
3254
|
);
|
|
2896
3255
|
});
|
|
@@ -2904,14 +3263,14 @@ function vegaCommand() {
|
|
|
2904
3263
|
vega.command("sql").description("Run SQL / OpenSearch DSL directly against a vega-backend data source").option(
|
|
2905
3264
|
"--query <sql>",
|
|
2906
3265
|
"SQL string; reference a resource with a {{<resource-id>}} placeholder"
|
|
2907
|
-
).option("--input-dialect <dialect>", "SQL input dialect: postgres | mysql | trino | duckdb").option("--paging-mode <mode>", "paging mode: single | cursor").option("--limit <n>", "page size (cursor mode requires it)",
|
|
3266
|
+
).option("--input-dialect <dialect>", "SQL input dialect: postgres | mysql | trino | duckdb").option("--paging-mode <mode>", "paging mode: single | cursor").option("--limit <n>", "page size (cursor mode requires it)", int11).option("--offset <n>", "first-page offset", int11).option("--keep-alive-sec <s>", "cursor keep-alive in seconds (60\u20133600)", int11).option("--cursor <cursor>", "opaque cursor returned by the previous page").option("--need-total", "include the complete total count").option("--query-timeout-sec <s>", "query timeout in seconds (1\u20133600)", int11).option(
|
|
2908
3267
|
"-d, --data <json>",
|
|
2909
3268
|
"full request body as JSON (advanced; wins over individual query flags)"
|
|
2910
3269
|
).action(async (opts, cmd) => {
|
|
2911
3270
|
let body;
|
|
2912
3271
|
if (opts.data) {
|
|
2913
3272
|
try {
|
|
2914
|
-
body =
|
|
3273
|
+
body = parseBigIntJSON(opts.data);
|
|
2915
3274
|
} catch {
|
|
2916
3275
|
throw new InputError("--data must be valid JSON");
|
|
2917
3276
|
}
|
|
@@ -2948,18 +3307,15 @@ function vegaCommand() {
|
|
|
2948
3307
|
printJson(await clientFrom(cmd).vega.sql(body), outputOptions(cmd));
|
|
2949
3308
|
});
|
|
2950
3309
|
const resource = vega.command("resource").description("Vega-backend resources");
|
|
2951
|
-
resource.command("list").description("List resources").option("--
|
|
3310
|
+
resource.command("list").description("List resources").option("--catalog-id <id>", "filter by catalog id").option("--type <category>", "resource category").option("--category <category>", "alias of --type").option("--status <status>", "filter by status").option("--schema <name>", "filter by source schema").option("--limit <n>", "page size", int11, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int11, 0).option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (opts, cmd) => {
|
|
2952
3311
|
printJson(
|
|
2953
3312
|
await clientFrom(cmd).resource.list({
|
|
2954
|
-
|
|
3313
|
+
catalogId: opts.catalogId,
|
|
2955
3314
|
category: opts.type ?? opts.category,
|
|
2956
3315
|
status: opts.status,
|
|
2957
|
-
|
|
3316
|
+
schema: opts.schema,
|
|
2958
3317
|
limit: opts.limit,
|
|
2959
3318
|
offset: opts.offset,
|
|
2960
|
-
includeExtensions: opts.includeExtensions,
|
|
2961
|
-
includeExtensionKeys: opts.includeExtensionKeys,
|
|
2962
|
-
extensionPairs: parsePairs2(opts.extension),
|
|
2963
3319
|
sort: opts.sort,
|
|
2964
3320
|
direction: opts.direction
|
|
2965
3321
|
}),
|
|
@@ -2969,17 +3325,59 @@ function vegaCommand() {
|
|
|
2969
3325
|
resource.command("get <id>").description("Get a resource").action(async (id, _opts, cmd) => {
|
|
2970
3326
|
printJson(await clientFrom(cmd).resource.get(id), outputOptions(cmd));
|
|
2971
3327
|
});
|
|
2972
|
-
resource.command("query <id>").description("Fetch data rows from a resource").option("--limit <n>", "row limit",
|
|
3328
|
+
resource.command("query <id>").description("Fetch data rows from a resource").option("--limit <n>", "row limit", int11, 50).option("--offset <n>", "row offset", int11, 0).action(async (id, opts, cmd) => {
|
|
2973
3329
|
printJson(
|
|
2974
3330
|
await clientFrom(cmd).resource.query(id, { limit: opts.limit, offset: opts.offset }),
|
|
2975
3331
|
outputOptions(cmd)
|
|
2976
3332
|
);
|
|
2977
3333
|
});
|
|
3334
|
+
resource.command("document-get <resource-id> <document-id>").description("Get one dataset document").action(async (resourceId, documentId, _opts, cmd) => {
|
|
3335
|
+
printJson(
|
|
3336
|
+
await clientFrom(cmd).resource.getDocument(resourceId, documentId),
|
|
3337
|
+
outputOptions(cmd)
|
|
3338
|
+
);
|
|
3339
|
+
});
|
|
3340
|
+
resource.command("document-create <resource-id>").description("Create dataset documents").requiredOption("--data <json>", "JSON array of documents").action(async (resourceId, opts, cmd) => {
|
|
3341
|
+
printJson(
|
|
3342
|
+
await clientFrom(cmd).resource.createDocuments(
|
|
3343
|
+
resourceId,
|
|
3344
|
+
parseJsonArray(opts.data, "--data")
|
|
3345
|
+
),
|
|
3346
|
+
outputOptions(cmd)
|
|
3347
|
+
);
|
|
3348
|
+
});
|
|
3349
|
+
resource.command("document-upsert <resource-id>").description("Upsert dataset documents; every document must have an id").requiredOption("--data <json>", "JSON array of documents").action(async (resourceId, opts, cmd) => {
|
|
3350
|
+
const documents = parseJsonArray(opts.data, "--data");
|
|
3351
|
+
if (documents.some((document) => typeof document.id !== "string")) {
|
|
3352
|
+
throw new InputError("every document in --data must have a string id");
|
|
3353
|
+
}
|
|
3354
|
+
printJson(
|
|
3355
|
+
await clientFrom(cmd).resource.upsertDocuments(resourceId, documents),
|
|
3356
|
+
outputOptions(cmd)
|
|
3357
|
+
);
|
|
3358
|
+
});
|
|
3359
|
+
resource.command("document-delete <resource-id> <document-ids...>").description("Delete dataset documents by id").action(async (resourceId, documentIds, _opts, cmd) => {
|
|
3360
|
+
printJson(
|
|
3361
|
+
await clientFrom(cmd).resource.deleteDocuments(resourceId, documentIds),
|
|
3362
|
+
outputOptions(cmd)
|
|
3363
|
+
);
|
|
3364
|
+
});
|
|
3365
|
+
resource.command("document-delete-filter <resource-id>").description("Delete dataset documents by a non-empty filter").requiredOption("--filter <json>", "filter_condition JSON object").action(async (resourceId, opts, cmd) => {
|
|
3366
|
+
const filter = parseJsonObject(opts.filter, "--filter");
|
|
3367
|
+
if (!Object.keys(filter).length) throw new InputError("--filter must not be empty");
|
|
3368
|
+
printJson(
|
|
3369
|
+
await clientFrom(cmd).resource.deleteDocumentsByFilter(resourceId, filter),
|
|
3370
|
+
outputOptions(cmd)
|
|
3371
|
+
);
|
|
3372
|
+
});
|
|
2978
3373
|
const dataset = vega.command("dataset").description("Dataset index build tasks");
|
|
2979
3374
|
dataset.command("build <resource-id>").description("Build a resource's index (creates a BuildTask)").requiredOption("--mode <mode>", "build mode: batch | streaming").option("--embedding-fields <list>", "comma-separated fields to vectorize").option(
|
|
2980
3375
|
"--build-key-fields <list>",
|
|
2981
3376
|
"comma-separated key fields (batch: time; streaming: row id)"
|
|
2982
|
-
).option(
|
|
3377
|
+
).option(
|
|
3378
|
+
"--embedding-model <name-or-id>",
|
|
3379
|
+
"default small-model name (a numeric ID is resolved to its name)"
|
|
3380
|
+
).option("--fulltext-fields <list>", "comma-separated fields for fulltext index").option("--fulltext-analyzer <name>", "fulltext analyzer").option("--execute-type <type>", "batch execution type: incremental | full").option("--wait", "poll until the build reaches a terminal state").option("--timeout <s>", "wait timeout in seconds", (v) => Number.parseInt(v, 10), 300).action(async (resourceId, _opts, cmd) => {
|
|
2983
3381
|
const o = cmd.optsWithGlobals();
|
|
2984
3382
|
const embeddingFields = csv(o.embeddingFields);
|
|
2985
3383
|
const buildKeyFields = csv(o.buildKeyFields);
|
|
@@ -3007,28 +3405,22 @@ function vegaCommand() {
|
|
|
3007
3405
|
const task = await clientFrom(cmd).vega.buildStatus(taskId);
|
|
3008
3406
|
printJson(task, outputOptions(cmd));
|
|
3009
3407
|
});
|
|
3010
|
-
dataset.command("build-list").description("List BuildTasks").option("--limit <n>", "page size",
|
|
3011
|
-
if (opts.orderBy === "default") {
|
|
3012
|
-
throw new InputError(
|
|
3013
|
-
'--order-by default is no longer supported; use "created_at" or "updated_at"'
|
|
3014
|
-
);
|
|
3015
|
-
}
|
|
3408
|
+
dataset.command("build-list").description("List BuildTasks").option("--limit <n>", "page size", int11, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int11, 0).option("--resource-id <id>", "filter by resource id").option("--catalog-id <id>", "filter by catalog id").option("--status <status>", `comma-separated statuses: ${BuildTaskStatus.options.join(" | ")}`).option("--mode <mode>", "filter by mode: batch | streaming").option("--sort <field>", `sort field: ${BuildTaskSort.options.join(" | ")}`).option("--direction <dir>", `sort direction: ${SortDirection.options.join(" | ")}`).action(async (opts, cmd) => {
|
|
3016
3409
|
printJson(
|
|
3017
3410
|
await clientFrom(cmd).vega.buildTasks({
|
|
3018
3411
|
limit: opts.limit,
|
|
3019
3412
|
offset: opts.offset,
|
|
3020
3413
|
resourceId: opts.resourceId,
|
|
3021
3414
|
catalogId: opts.catalogId,
|
|
3022
|
-
status: opts.status,
|
|
3023
|
-
active: opts.active,
|
|
3415
|
+
status: buildTaskStatuses(opts.status),
|
|
3024
3416
|
mode: opts.mode,
|
|
3025
|
-
|
|
3026
|
-
|
|
3417
|
+
sort: buildTaskSort(opts.sort),
|
|
3418
|
+
direction: sortDirection(opts.direction)
|
|
3027
3419
|
}),
|
|
3028
3420
|
outputOptions(cmd)
|
|
3029
3421
|
);
|
|
3030
3422
|
});
|
|
3031
|
-
dataset.command("build-start <task-id>").description("Start a BuildTask").option("--reset", "restart a full task from the beginning (
|
|
3423
|
+
dataset.command("build-start <task-id>").description("Start a BuildTask").option("--reset", "restart a full task from the beginning (rejected for incremental tasks)").action(async (taskId, opts, cmd) => {
|
|
3032
3424
|
printJson(
|
|
3033
3425
|
await clientFrom(cmd).vega.startBuildTask(taskId, { reset: opts.reset }),
|
|
3034
3426
|
outputOptions(cmd)
|
|
@@ -3037,11 +3429,10 @@ function vegaCommand() {
|
|
|
3037
3429
|
dataset.command("build-stop <task-id>").description("Stop a BuildTask").action(async (taskId, _opts, cmd) => {
|
|
3038
3430
|
printJson(await clientFrom(cmd).vega.stopBuildTask(taskId), outputOptions(cmd));
|
|
3039
3431
|
});
|
|
3040
|
-
dataset.command("build-delete <ids...>").description("Delete one or more BuildTasks").option("--ignore-missing", "ignore missing task ids").
|
|
3432
|
+
dataset.command("build-delete <ids...>").description("Delete one or more BuildTasks").option("--ignore-missing", "ignore missing task ids").action(async (ids, opts, cmd) => {
|
|
3041
3433
|
printJson(
|
|
3042
3434
|
await clientFrom(cmd).vega.deleteBuildTasks(ids, {
|
|
3043
|
-
ignoreMissing: opts.ignoreMissing
|
|
3044
|
-
deleteActiveIndex: opts.deleteActiveIndex
|
|
3435
|
+
ignoreMissing: opts.ignoreMissing
|
|
3045
3436
|
}),
|
|
3046
3437
|
outputOptions(cmd)
|
|
3047
3438
|
);
|
|
@@ -3050,8 +3441,11 @@ function vegaCommand() {
|
|
|
3050
3441
|
}
|
|
3051
3442
|
|
|
3052
3443
|
// src/cli.ts
|
|
3053
|
-
var program = new
|
|
3054
|
-
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("--conversation-id <id>", "BKN Trace conversation id (env: BKN_CONVERSATION_ID)").option("--interaction-id <id>", "BKN Trace interaction id (env: BKN_INTERACTION_ID)").option(
|
|
3444
|
+
var program = new Command16();
|
|
3445
|
+
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("--conversation-id <id>", "BKN Trace conversation id (env: BKN_CONVERSATION_ID)").option("--interaction-id <id>", "BKN Trace interaction id (env: BKN_INTERACTION_ID)").option(
|
|
3446
|
+
"--new-conversation",
|
|
3447
|
+
"ignore the remembered conversation for this command (see `openbkn context conversation`)"
|
|
3448
|
+
).option("-k, --insecure", "skip TLS verification (dev / self-signed only)").showHelpAfterError();
|
|
3055
3449
|
program.addCommand(authCommand());
|
|
3056
3450
|
program.addCommand(callCommand());
|
|
3057
3451
|
program.addCommand(configCommand());
|
|
@@ -3059,7 +3453,6 @@ program.addCommand(appkeyCommand());
|
|
|
3059
3453
|
program.addCommand(vegaCommand());
|
|
3060
3454
|
program.addCommand(bknCommand());
|
|
3061
3455
|
program.addCommand(resourceCommand());
|
|
3062
|
-
program.addCommand(dataflowCommand());
|
|
3063
3456
|
program.addCommand(contextCommand());
|
|
3064
3457
|
program.addCommand(agentCommand());
|
|
3065
3458
|
program.addCommand(modelCommand());
|