@openbkn/bkn-sdk 0.1.1-alpha.16 → 0.1.1-alpha.18

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,7 +37,7 @@ import {
37
37
  use,
38
38
  whoami,
39
39
  writePlatformConfig
40
- } from "./chunk-SH2KLES5.js";
40
+ } from "./chunk-LCOMMFH7.js";
41
41
 
42
42
  // src/cli.ts
43
43
  import { Command as Command17 } from "commander";
@@ -45,7 +45,7 @@ import { Command as Command17 } from "commander";
45
45
  // package.json
46
46
  var package_default = {
47
47
  name: "@openbkn/bkn-sdk",
48
- version: "0.1.1-alpha.16",
48
+ version: "0.1.1-alpha.18",
49
49
  description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
50
50
  type: "module",
51
51
  license: "SEE LICENSE IN LICENSE",
@@ -104,6 +104,7 @@ var package_default = {
104
104
  };
105
105
 
106
106
  // src/commands/admin.ts
107
+ import { readFileSync as readFileSync2 } from "fs";
107
108
  import { Command as Command2 } from "commander";
108
109
 
109
110
  // src/help/grouped-help.ts
@@ -626,6 +627,12 @@ function authCommand() {
626
627
  // src/commands/admin.ts
627
628
  var int = (v) => Number.parseInt(v, 10);
628
629
  var DEFAULT_RESET_PASSWORD = "openbkn";
630
+ async function importLicenseFile(cmd, file, receipt) {
631
+ const text = readFileSync2(file, "utf8");
632
+ const res = await clientFrom(cmd).admin.licenseImport(text, { receipt });
633
+ printJson(res, outputOptions(cmd));
634
+ if ("stored" in res && res.stored) process.exitCode = 1;
635
+ }
629
636
  function adminCommand() {
630
637
  const admin = new Command2("admin").description("Operator CLI: org, user, role, models, audit");
631
638
  registerAuthLeaves(admin.command("auth").description("Operator authentication"));
@@ -911,6 +918,27 @@ function adminCommand() {
911
918
  );
912
919
  });
913
920
  }
921
+ const license = admin.command("license").description("Cluster license management");
922
+ license.command("show").description("Current license detail (state/edition/expiry/features)").action(async (_opts, cmd) => {
923
+ printJson(await clientFrom(cmd).admin.licenseGet(), outputOptions(cmd));
924
+ });
925
+ license.command("import <file>").description("Import a .lic license file (online deployments auto-activate)").action(async (file, _opts, cmd) => {
926
+ await importLicenseFile(cmd, file, false);
927
+ });
928
+ license.command("receipt <file>").description("Import an offline activation receipt (.lic from the license portal)").action(async (file, _opts, cmd) => {
929
+ await importLicenseFile(cmd, file, true);
930
+ });
931
+ license.command("activate").description("Report the installed license to the issuer (online deployments)").action(async (_opts, cmd) => {
932
+ printJson(await clientFrom(cmd).admin.licenseActivate(), outputOptions(cmd));
933
+ });
934
+ license.command("remove").description("Remove the installed license (back to unactivated)").action(async (_opts, cmd) => {
935
+ printJson(await clientFrom(cmd).admin.licenseRemove(), outputOptions(cmd));
936
+ });
937
+ license.command("fingerprint").description(
938
+ "This cluster's machine code (paste into the license portal for offline activation)"
939
+ ).action(async (_opts, cmd) => {
940
+ printJson(await clientFrom(cmd).admin.licenseFingerprint(), outputOptions(cmd));
941
+ });
914
942
  admin.command("audit").description("Audit log queries").command("list").description("List login audit events").option("--user <name>", "filter by user").option("--start <time>", "start time").option("--end <time>", "end time").option("--page <n>", "page", int, 1).option("--size <n>", "page size", int, 30).action(async (opts, cmd) => {
915
943
  printJson(
916
944
  await clientFrom(cmd).admin.auditList({
@@ -1151,7 +1179,7 @@ function appkeyCommand() {
1151
1179
  import { Command as Command5 } from "commander";
1152
1180
 
1153
1181
  // src/utils/bkn-validate.ts
1154
- import { existsSync, readFileSync as readFileSync2, readdirSync, statSync } from "fs";
1182
+ import { existsSync, readFileSync as readFileSync3, readdirSync, statSync } from "fs";
1155
1183
  import { join, resolve } from "path";
1156
1184
  var BKN_OBJECT_NAME_MAX_LENGTH = 40;
1157
1185
  function parseFrontmatter(text) {
@@ -1204,7 +1232,7 @@ function validateBknDirectory(dirPath) {
1204
1232
  if (!existsSync(networkPath)) {
1205
1233
  errors.push("Missing network.bkn at the BKN root.");
1206
1234
  } else {
1207
- const fm = parseFrontmatter(readFileSync2(networkPath, "utf8"));
1235
+ const fm = parseFrontmatter(readFileSync3(networkPath, "utf8"));
1208
1236
  if (!fm) errors.push("network.bkn has no frontmatter block.");
1209
1237
  else {
1210
1238
  if (fm.type !== "knowledge_network")
@@ -1216,7 +1244,7 @@ function validateBknDirectory(dirPath) {
1216
1244
  const otIds = /* @__PURE__ */ new Set();
1217
1245
  const otFiles = bknFiles(join(dir, "object_types"));
1218
1246
  for (const file of otFiles) {
1219
- const fm = parseFrontmatter(readFileSync2(file, "utf8"));
1247
+ const fm = parseFrontmatter(readFileSync3(file, "utf8"));
1220
1248
  const rel = file.slice(dir.length + 1);
1221
1249
  if (!fm || fm.type !== "object_type") {
1222
1250
  errors.push(`${rel}: not a valid object_type (missing/wrong frontmatter type).`);
@@ -1236,7 +1264,7 @@ function validateBknDirectory(dirPath) {
1236
1264
  }
1237
1265
  const rtFiles = bknFiles(join(dir, "relation_types"));
1238
1266
  for (const file of rtFiles) {
1239
- const text = readFileSync2(file, "utf8");
1267
+ const text = readFileSync3(file, "utf8");
1240
1268
  const fm = parseFrontmatter(text);
1241
1269
  const rel = file.slice(dir.length + 1);
1242
1270
  if (!fm || fm.type !== "relation_type") {
@@ -2106,13 +2134,29 @@ Examples:
2106
2134
  // src/commands/resource.ts
2107
2135
  import { Command as Command12 } from "commander";
2108
2136
  var int9 = (v) => Number.parseInt(v, 10);
2137
+ var parsePairs = (raw) => {
2138
+ if (!raw) return void 0;
2139
+ return raw.split(",").map((part) => {
2140
+ const idx = part.indexOf("=");
2141
+ if (idx < 1) throw new Error("--extension must be key=value[,key=value]");
2142
+ return { key: part.slice(0, idx).trim(), value: part.slice(idx + 1).trim() };
2143
+ }).filter((p) => p.key.length > 0);
2144
+ };
2109
2145
  function resourceCommand() {
2110
2146
  const cmd = new Command12("resource").alias("res").description("Resources \u2014 list, find, get, query, delete");
2111
- 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) => {
2147
+ 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("--status <status>", "filter by status").option("--database <name>", "filter by database").option("--limit <n>", "page size", int9, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int9, 0).option("--include-extensions", "include all extension key/value pairs").option("--include-extension-keys <keys>", "include selected extension keys").option("--extension <k=v,...>", "filter by extension key/value pairs").option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (opts, cmd2) => {
2112
2148
  const data = await clientFrom(cmd2).resource.list({
2113
2149
  datasourceId: opts.catalogId ?? opts.datasourceId,
2114
2150
  category: opts.category ?? opts.type,
2115
- limit: opts.limit
2151
+ status: opts.status,
2152
+ database: opts.database,
2153
+ limit: opts.limit,
2154
+ offset: opts.offset,
2155
+ includeExtensions: opts.includeExtensions,
2156
+ includeExtensionKeys: opts.includeExtensionKeys,
2157
+ extensionPairs: parsePairs(opts.extension),
2158
+ sort: opts.sort,
2159
+ direction: opts.direction
2116
2160
  });
2117
2161
  printJson(data, outputOptions(cmd2));
2118
2162
  });
@@ -2334,11 +2378,11 @@ function toolCommand() {
2334
2378
  }
2335
2379
 
2336
2380
  // src/commands/trace.ts
2337
- import { readFileSync as readFileSync4, writeFileSync } from "fs";
2381
+ import { readFileSync as readFileSync5, writeFileSync } from "fs";
2338
2382
  import { Command as Command15 } from "commander";
2339
2383
 
2340
- // src/trace-ai/schema-validate.ts
2341
- import { readFileSync as readFileSync3 } from "fs";
2384
+ // src/bkn-trace/schema-validate.ts
2385
+ import { readFileSync as readFileSync4 } from "fs";
2342
2386
  import { extname } from "path";
2343
2387
  import yaml from "js-yaml";
2344
2388
  import { z } from "zod";
@@ -2375,7 +2419,7 @@ var DiagnosisRule = z.object({
2375
2419
  params: z.record(z.string(), z.unknown()).optional()
2376
2420
  });
2377
2421
  function parseFile(file) {
2378
- const text = readFileSync3(file, "utf8");
2422
+ const text = readFileSync4(file, "utf8");
2379
2423
  const ext = extname(file).toLowerCase();
2380
2424
  if (ext === ".yaml" || ext === ".yml") return yaml.load(text);
2381
2425
  return JSON.parse(text);
@@ -2414,7 +2458,7 @@ function validateSchemaFile(file, kind) {
2414
2458
  // src/commands/trace.ts
2415
2459
  function traceCommand() {
2416
2460
  const cmd = new Command15("trace").description(
2417
- "Trace AI \u2014 fetch spans, diagnose (symbolic + LLM rubric), scan, eval-set, schema validate"
2461
+ "BKN Trace \u2014 fetch spans, diagnose (symbolic + LLM rubric), scan, eval-set, schema validate"
2418
2462
  );
2419
2463
  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) => {
2420
2464
  printJson(
@@ -2442,7 +2486,7 @@ function traceCommand() {
2442
2486
  });
2443
2487
  const evalSet = cmd.command("eval-set").description("Build + run trace eval sets");
2444
2488
  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) => {
2445
- const raw = JSON.parse(readFileSync4(queriesFile, "utf8"));
2489
+ const raw = JSON.parse(readFileSync5(queriesFile, "utf8"));
2446
2490
  const cases = clientFrom(cmd2).trace.evalSetBuild(raw);
2447
2491
  if (opts.out) {
2448
2492
  writeFileSync(opts.out, JSON.stringify({ cases }, null, 2));
@@ -2452,7 +2496,7 @@ function traceCommand() {
2452
2496
  }
2453
2497
  });
2454
2498
  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) => {
2455
- const raw = JSON.parse(readFileSync4(casesFile, "utf8"));
2499
+ const raw = JSON.parse(readFileSync5(casesFile, "utf8"));
2456
2500
  const cases = clientFrom(cmd2).trace.evalSetBuild(raw);
2457
2501
  const result = await clientFrom(cmd2).trace.evalSetTest(opts.agent, cases, {
2458
2502
  version: opts.version,
@@ -2473,14 +2517,35 @@ function traceCommand() {
2473
2517
  // src/commands/vega.ts
2474
2518
  import { Command as Command16 } from "commander";
2475
2519
  var int12 = (v) => Number.parseInt(v, 10);
2520
+ var parsePairs2 = (raw) => {
2521
+ if (!raw) return void 0;
2522
+ return raw.split(",").map((part) => {
2523
+ const idx = part.indexOf("=");
2524
+ if (idx < 1) throw new InputError("--extension must be key=value[,key=value]");
2525
+ return { key: part.slice(0, idx).trim(), value: part.slice(idx + 1).trim() };
2526
+ }).filter((p) => p.key.length > 0);
2527
+ };
2476
2528
  function vegaCommand() {
2477
2529
  const vega = new Command16("vega").description(
2478
2530
  "Vega observability \u2014 catalog, resources, index build tasks"
2479
2531
  );
2480
2532
  const catalog = vega.command("catalog").description("Catalog entries");
2481
- catalog.command("list").description("List catalog entries").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", (v) => Number.parseInt(v, 10), 0).action(async (_opts, cmd) => {
2533
+ catalog.command("list").description("List catalog entries").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", (v) => Number.parseInt(v, 10), 0).option("--name <s>", "filter by name").option("--tag <s>", "filter by tag").option("--type <type>", "filter by catalog type: physical | logical").option("--enabled <bool>", "filter by enabled state").option("--health-check-status <s>", "filter by health status").option("--include-extensions", "include all extension key/value pairs").option("--include-extension-keys <keys>", "include selected extension keys").option("--extension <k=v,...>", "filter by extension key/value pairs").option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (_opts, cmd) => {
2482
2534
  const o = cmd.optsWithGlobals();
2483
- const data = await clientFrom(cmd).vega.catalogs({ limit: o.limit, offset: o.offset });
2535
+ const data = await clientFrom(cmd).vega.catalogs({
2536
+ limit: o.limit,
2537
+ offset: o.offset,
2538
+ name: o.name,
2539
+ tag: o.tag,
2540
+ type: o.type,
2541
+ enabled: o.enabled === void 0 ? void 0 : o.enabled === "true",
2542
+ healthCheckStatus: o.healthCheckStatus,
2543
+ includeExtensions: o.includeExtensions,
2544
+ includeExtensionKeys: o.includeExtensionKeys,
2545
+ extensionPairs: parsePairs2(o.extension),
2546
+ sort: o.sort,
2547
+ direction: o.direction
2548
+ });
2484
2549
  printJson(data, outputOptions(cmd));
2485
2550
  });
2486
2551
  catalog.command("get <id>").description("Get a catalog by id").action(async (id, _opts, cmd) => {
@@ -2492,21 +2557,41 @@ function vegaCommand() {
2492
2557
  catalog.command("health <ids...>").description("Health-status for one or more catalogs").action(async (ids, _opts, cmd) => {
2493
2558
  printJson(await clientFrom(cmd).vega.catalogHealth(ids), outputOptions(cmd));
2494
2559
  });
2495
- 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("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").option("--enabled", "create enabled (default: disabled)").action(async (opts, cmd) => {
2560
+ 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("--extensions <json>", "extension key/value JSON object").action(async (opts, cmd) => {
2496
2561
  let connectorConfig;
2497
2562
  try {
2498
2563
  connectorConfig = JSON.parse(opts.connectorConfig);
2499
2564
  } catch {
2500
2565
  throw new Error("--connector-config must be valid JSON");
2501
2566
  }
2567
+ const extensions = opts.extensions ? JSON.parse(opts.extensions) : void 0;
2502
2568
  printJson(
2503
2569
  await clientFrom(cmd).vega.createCatalog({
2570
+ id: opts.id,
2571
+ name: opts.name,
2572
+ connectorType: opts.connectorType,
2573
+ connectorConfig,
2574
+ tags: opts.tags ? String(opts.tags).split(",").map((t) => t.trim()).filter(Boolean) : void 0,
2575
+ description: opts.description,
2576
+ enabled: opts.enabled ? true : void 0,
2577
+ internal: opts.internal ? true : void 0,
2578
+ extensions
2579
+ }),
2580
+ outputOptions(cmd)
2581
+ );
2582
+ });
2583
+ catalog.command("update <id>").description("Update a catalog").option("--name <s>", "catalog name").option("--connector-type <s>", "connector type").option("--connector-config <json>", "connector config JSON").option("--tags <t1,t2>", "comma-separated tags").option("--description <s>", "description").option("--enabled <bool>", "enabled state").option("--extensions <json>", "extension key/value JSON object").action(async (id, opts, cmd) => {
2584
+ const connectorConfig = opts.connectorConfig ? JSON.parse(opts.connectorConfig) : void 0;
2585
+ const extensions = opts.extensions ? JSON.parse(opts.extensions) : void 0;
2586
+ printJson(
2587
+ await clientFrom(cmd).vega.updateCatalog(id, {
2504
2588
  name: opts.name,
2505
2589
  connectorType: opts.connectorType,
2506
2590
  connectorConfig,
2507
2591
  tags: opts.tags ? String(opts.tags).split(",").map((t) => t.trim()).filter(Boolean) : void 0,
2508
2592
  description: opts.description,
2509
- enabled: opts.enabled ? true : void 0
2593
+ enabled: opts.enabled === void 0 ? void 0 : opts.enabled === "true",
2594
+ extensions
2510
2595
  }),
2511
2596
  outputOptions(cmd)
2512
2597
  );
@@ -2514,6 +2599,15 @@ function vegaCommand() {
2514
2599
  catalog.command("enable <id>").description("Enable a catalog (required before discovery)").action(async (id, _opts, cmd) => {
2515
2600
  printJson(await clientFrom(cmd).vega.enableCatalog(id), outputOptions(cmd));
2516
2601
  });
2602
+ catalog.command("disable <id>").description("Disable a catalog").action(async (id, _opts, cmd) => {
2603
+ printJson(await clientFrom(cmd).vega.disableCatalog(id), outputOptions(cmd));
2604
+ });
2605
+ catalog.command("delete <id>").description("Delete a catalog").action(async (id, _opts, cmd) => {
2606
+ printJson(await clientFrom(cmd).vega.deleteCatalog(id), outputOptions(cmd));
2607
+ });
2608
+ catalog.command("test-connection <id>").description("Test a catalog connection").action(async (id, _opts, cmd) => {
2609
+ printJson(await clientFrom(cmd).vega.testCatalogConnection(id), outputOptions(cmd));
2610
+ });
2517
2611
  catalog.command("discover <id>").description("Trigger catalog resource discovery").option("--wait", "wait for discovery to complete").action(async (id, opts, cmd) => {
2518
2612
  printJson(
2519
2613
  await clientFrom(cmd).vega.discoverCatalog(id, Boolean(opts.wait)),
@@ -2527,10 +2621,7 @@ function vegaCommand() {
2527
2621
  connector.command("get <type>").description("Get a connector type").action(async (type, _opts, cmd) => {
2528
2622
  printJson(await clientFrom(cmd).vega.connectorType(type), outputOptions(cmd));
2529
2623
  });
2530
- vega.command("sql").description("Run SQL / OpenSearch DSL directly against a vega-backend data source").option(
2531
- "--resource-type <type>",
2532
- "source type (mysql | postgresql | opensearch | \u2026); optional \u2014 inferred from the {{<id>}} placeholder"
2533
- ).option(
2624
+ vega.command("sql").description("Run SQL / OpenSearch DSL directly against a vega-backend data source").requiredOption("--resource-type <type>", "source type (mysql | postgresql | opensearch | \u2026)").option("--query-type <type>", "query mode: standard | stream").option(
2534
2625
  "--query <sql>",
2535
2626
  "SQL string; reference a resource with a {{<resource-id>}} placeholder"
2536
2627
  ).option("--stream-size <n>", "streaming batch size (100\u201310000)", int12).option("--query-timeout <s>", "query timeout in seconds (1\u20133600)", int12).option(
@@ -2550,9 +2641,8 @@ function vegaCommand() {
2550
2641
  }
2551
2642
  body = {
2552
2643
  query: opts.query,
2553
- // Optional — the backend infers the type from the {{<id>}} placeholder's
2554
- // catalog connector when omitted.
2555
- ...opts.resourceType ? { resource_type: opts.resourceType } : {},
2644
+ resource_type: opts.resourceType,
2645
+ ...opts.queryType ? { query_type: opts.queryType } : {},
2556
2646
  ...opts.streamSize !== void 0 ? { stream_size: opts.streamSize } : {},
2557
2647
  ...opts.queryTimeout !== void 0 ? { query_timeout: opts.queryTimeout } : {}
2558
2648
  };
@@ -2560,12 +2650,20 @@ function vegaCommand() {
2560
2650
  printJson(await clientFrom(cmd).vega.sql(body), outputOptions(cmd));
2561
2651
  });
2562
2652
  const resource = vega.command("resource").description("Vega-backend resources");
2563
- 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) => {
2653
+ 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("--status <status>", "filter by status").option("--database <name>", "filter by database").option("--limit <n>", "page size", (v) => Number.parseInt(v, 10), DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int12, 0).option("--include-extensions", "include all extension key/value pairs").option("--include-extension-keys <keys>", "include selected extension keys").option("--extension <k=v,...>", "filter by extension key/value pairs").option("--sort <field>", "sort field: name | create_time | update_time").option("--direction <dir>", "sort direction: asc | desc").action(async (opts, cmd) => {
2564
2654
  printJson(
2565
2655
  await clientFrom(cmd).resource.list({
2566
2656
  datasourceId: opts.datasourceId ?? opts.catalogId,
2567
2657
  category: opts.type ?? opts.category,
2568
- limit: opts.limit
2658
+ status: opts.status,
2659
+ database: opts.database,
2660
+ limit: opts.limit,
2661
+ offset: opts.offset,
2662
+ includeExtensions: opts.includeExtensions,
2663
+ includeExtensionKeys: opts.includeExtensionKeys,
2664
+ extensionPairs: parsePairs2(opts.extension),
2665
+ sort: opts.sort,
2666
+ direction: opts.direction
2569
2667
  }),
2570
2668
  outputOptions(cmd)
2571
2669
  );
@@ -2583,16 +2681,25 @@ function vegaCommand() {
2583
2681
  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(
2584
2682
  "--build-key-fields <list>",
2585
2683
  "comma-separated key fields (batch: time; streaming: row id)"
2586
- ).option("--embedding-model <id>", "embedding model id (default if omitted)").option("--model-dimensions <n>", "vector dimensions", (v) => Number.parseInt(v, 10)).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) => {
2684
+ ).option("--embedding-model <id>", "default embedding model name/id").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) => {
2587
2685
  const o = cmd.optsWithGlobals();
2686
+ const embeddingFields = csv(o.embeddingFields);
2687
+ const buildKeyFields = csv(o.buildKeyFields);
2688
+ const fulltextFields = csv(o.fulltextFields);
2689
+ if (embeddingFields || buildKeyFields || o.embeddingModel || fulltextFields || o.fulltextAnalyzer) {
2690
+ await clientFrom(cmd).resource.configureIndex(resourceId, {
2691
+ embeddingFields,
2692
+ buildKeyFields,
2693
+ embeddingModel: o.embeddingModel,
2694
+ fulltextFields,
2695
+ fulltextAnalyzer: o.fulltextAnalyzer
2696
+ });
2697
+ }
2588
2698
  const task = await clientFrom(cmd).vega.build(
2589
2699
  {
2590
2700
  resource_id: resourceId,
2591
2701
  mode: o.mode,
2592
- embedding_fields: csv(o.embeddingFields),
2593
- build_key_fields: csv(o.buildKeyFields),
2594
- embedding_model: o.embeddingModel,
2595
- model_dimensions: o.modelDimensions
2702
+ execute_type: o.executeType
2596
2703
  },
2597
2704
  { wait: Boolean(o.wait), timeoutMs: o.timeout * 1e3 }
2598
2705
  );
@@ -2602,6 +2709,40 @@ function vegaCommand() {
2602
2709
  const task = await clientFrom(cmd).vega.buildStatus(taskId);
2603
2710
  printJson(task, outputOptions(cmd));
2604
2711
  });
2712
+ dataset.command("build-list").description("List BuildTasks").option("--limit <n>", "page size", int12, DEFAULT_LIST_LIMIT).option("--offset <n>", "page offset", int12, 0).option("--resource-id <id>", "filter by resource id").option("--catalog-id <id>", "filter by catalog id").option("--status <status>", "comma-separated statuses").option("--active", "only running/init tasks").option("--mode <mode>", "filter by mode: batch | streaming").option("--order-by <field>", "default | created_at | updated_at | status | mode").option("--order <dir>", "asc | desc").action(async (opts, cmd) => {
2713
+ printJson(
2714
+ await clientFrom(cmd).vega.buildTasks({
2715
+ limit: opts.limit,
2716
+ offset: opts.offset,
2717
+ resourceId: opts.resourceId,
2718
+ catalogId: opts.catalogId,
2719
+ status: opts.status,
2720
+ active: opts.active,
2721
+ mode: opts.mode,
2722
+ orderBy: opts.orderBy,
2723
+ order: opts.order
2724
+ }),
2725
+ outputOptions(cmd)
2726
+ );
2727
+ });
2728
+ dataset.command("build-start <task-id>").description("Start a BuildTask").option("--reset", "restart from the beginning").action(async (taskId, opts, cmd) => {
2729
+ printJson(
2730
+ await clientFrom(cmd).vega.startBuildTask(taskId, { reset: opts.reset }),
2731
+ outputOptions(cmd)
2732
+ );
2733
+ });
2734
+ dataset.command("build-stop <task-id>").description("Stop a BuildTask").action(async (taskId, _opts, cmd) => {
2735
+ printJson(await clientFrom(cmd).vega.stopBuildTask(taskId), outputOptions(cmd));
2736
+ });
2737
+ dataset.command("build-delete <ids...>").description("Delete one or more BuildTasks").option("--ignore-missing", "ignore missing task ids").option("--delete-active-index", "delete active indexes too").action(async (ids, opts, cmd) => {
2738
+ printJson(
2739
+ await clientFrom(cmd).vega.deleteBuildTasks(ids, {
2740
+ ignoreMissing: opts.ignoreMissing,
2741
+ deleteActiveIndex: opts.deleteActiveIndex
2742
+ }),
2743
+ outputOptions(cmd)
2744
+ );
2745
+ });
2605
2746
  return group(vega, "AI DATA PLATFORM");
2606
2747
  }
2607
2748