@openbkn/bkn-sdk 0.1.1-alpha.15 → 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/LICENSE +117 -34
- package/NOTICE +31 -0
- package/README.md +3 -2
- package/README.zh.md +3 -3
- package/dist/{chunk-KF3J46WL.js → chunk-LCOMMFH7.js} +295 -47
- package/dist/chunk-LCOMMFH7.js.map +1 -0
- package/dist/cli.js +185 -34
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +240 -35
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-KF3J46WL.js.map +0 -1
|
@@ -296,7 +296,11 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
296
296
|
async function request(ctx, path, init = {}) {
|
|
297
297
|
const url = new URL(path.startsWith("http") ? path : `${ctx.baseUrl}${path}`);
|
|
298
298
|
for (const [k, v] of Object.entries(init.query ?? {})) {
|
|
299
|
-
if (
|
|
299
|
+
if (Array.isArray(v)) {
|
|
300
|
+
for (const item of v) url.searchParams.append(k, String(item));
|
|
301
|
+
} else if (v !== void 0) {
|
|
302
|
+
url.searchParams.set(k, String(v));
|
|
303
|
+
}
|
|
300
304
|
}
|
|
301
305
|
applyTls(ctx);
|
|
302
306
|
const hasBody = init.body !== void 0;
|
|
@@ -694,6 +698,43 @@ async function setRolePermissionSafe(ctx, roleId, grant, perm) {
|
|
|
694
698
|
});
|
|
695
699
|
return { ok: true };
|
|
696
700
|
}
|
|
701
|
+
function getLicenseSafe(ctx) {
|
|
702
|
+
return request(ctx, `${ADMIN}/license`);
|
|
703
|
+
}
|
|
704
|
+
async function importLicenseSafe(ctx, licenseText, opts = {}) {
|
|
705
|
+
const text = licenseText.trim();
|
|
706
|
+
if (!text) throw new InputError("license text is empty");
|
|
707
|
+
try {
|
|
708
|
+
return await request(ctx, `${ADMIN}/license/${opts.receipt ? "receipt" : "import"}`, {
|
|
709
|
+
method: "POST",
|
|
710
|
+
body: { license: text }
|
|
711
|
+
});
|
|
712
|
+
} catch (err) {
|
|
713
|
+
if (err instanceof HttpError) {
|
|
714
|
+
const stored = storedImport(err.body);
|
|
715
|
+
if (stored) return stored;
|
|
716
|
+
}
|
|
717
|
+
throw err;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function storedImport(body) {
|
|
721
|
+
try {
|
|
722
|
+
const parsed = JSON.parse(body);
|
|
723
|
+
if (parsed && parsed.stored === true) return parsed;
|
|
724
|
+
} catch {
|
|
725
|
+
}
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
function activateLicenseSafe(ctx) {
|
|
729
|
+
return request(ctx, `${ADMIN}/license/activate`, { method: "POST" });
|
|
730
|
+
}
|
|
731
|
+
async function removeLicenseSafe(ctx) {
|
|
732
|
+
await request(ctx, `${ADMIN}/license`, { method: "DELETE" });
|
|
733
|
+
return { ok: true };
|
|
734
|
+
}
|
|
735
|
+
function getLicenseFingerprintSafe(ctx) {
|
|
736
|
+
return request(ctx, `${ADMIN}/license/fingerprint`);
|
|
737
|
+
}
|
|
697
738
|
|
|
698
739
|
// src/resources/admin.ts
|
|
699
740
|
var DEFAULT_NEW_USER_PASSWORD = "openbkn";
|
|
@@ -754,7 +795,13 @@ function admin(ctx) {
|
|
|
754
795
|
roleUpdate: (roleId, input) => updateRoleSafe(ctx, roleId, input),
|
|
755
796
|
roleDelete: (roleId) => deleteRoleSafe(ctx, roleId),
|
|
756
797
|
rolePermission: (roleId, grant, resourceType, resourceId, operations) => setRolePermissionSafe(ctx, roleId, grant, { resourceType, resourceId, operations }),
|
|
757
|
-
auditList: (_opts) => notOnSafe("audit list")
|
|
798
|
+
auditList: (_opts) => notOnSafe("audit list"),
|
|
799
|
+
// ── license (cluster license hub; weak judgements — display/ops only) ──
|
|
800
|
+
licenseGet: () => getLicenseSafe(ctx),
|
|
801
|
+
licenseImport: (licenseText, opts) => importLicenseSafe(ctx, licenseText, opts),
|
|
802
|
+
licenseActivate: () => activateLicenseSafe(ctx),
|
|
803
|
+
licenseRemove: () => removeLicenseSafe(ctx),
|
|
804
|
+
licenseFingerprint: () => getLicenseFingerprintSafe(ctx)
|
|
758
805
|
};
|
|
759
806
|
}
|
|
760
807
|
|
|
@@ -1148,6 +1195,17 @@ function findSkills(ctx, knId, objectTypeId, topK) {
|
|
|
1148
1195
|
if (topK !== void 0) args.top_k = topK;
|
|
1149
1196
|
return callTool(ctx, knId, "find_skills", args);
|
|
1150
1197
|
}
|
|
1198
|
+
function getKnDetail(ctx, knId, detailLevel) {
|
|
1199
|
+
const args = { response_format: "json" };
|
|
1200
|
+
if (detailLevel) args.detail_level = detailLevel;
|
|
1201
|
+
return callTool(ctx, knId, "get_kn_detail", args);
|
|
1202
|
+
}
|
|
1203
|
+
function getObjectTypes(ctx, knId, ids) {
|
|
1204
|
+
return callTool(ctx, knId, "get_object_types", { ids, response_format: "json" });
|
|
1205
|
+
}
|
|
1206
|
+
function getRelationTypes(ctx, knId, ids) {
|
|
1207
|
+
return callTool(ctx, knId, "get_relation_types", { ids, response_format: "json" });
|
|
1208
|
+
}
|
|
1151
1209
|
function listTools(ctx, knId) {
|
|
1152
1210
|
return callMethod(ctx, knId, "tools/list");
|
|
1153
1211
|
}
|
|
@@ -1182,6 +1240,10 @@ function context(ctx) {
|
|
|
1182
1240
|
searchSchema: (knId, query, opts) => searchSchema(ctx, knId, query, opts),
|
|
1183
1241
|
queryObjectInstance: (knId, args) => queryObjectInstance(ctx, knId, args),
|
|
1184
1242
|
findSkills: (knId, objectTypeId, topK) => findSkills(ctx, knId, objectTypeId, topK),
|
|
1243
|
+
// Progressive schema disclosure: skeleton first (summary), then drill down.
|
|
1244
|
+
knDetail: (knId, detailLevel) => getKnDetail(ctx, knId, detailLevel),
|
|
1245
|
+
objectTypes: (knId, ids) => getObjectTypes(ctx, knId, ids),
|
|
1246
|
+
relationTypes: (knId, ids) => getRelationTypes(ctx, knId, ids),
|
|
1185
1247
|
info: () => mcpInfo(ctx),
|
|
1186
1248
|
tools: (knId) => listTools(ctx, knId),
|
|
1187
1249
|
toolCall: (knId, name, args) => callTool(ctx, knId, name, args),
|
|
@@ -1507,7 +1569,16 @@ function listResources2(ctx, opts = {}) {
|
|
|
1507
1569
|
catalog_id: opts.datasourceId || void 0,
|
|
1508
1570
|
name: opts.name || void 0,
|
|
1509
1571
|
category: opts.category || void 0,
|
|
1510
|
-
|
|
1572
|
+
status: opts.status || void 0,
|
|
1573
|
+
database: opts.database || void 0,
|
|
1574
|
+
limit: opts.limit && opts.limit > 0 ? opts.limit : void 0,
|
|
1575
|
+
offset: opts.offset,
|
|
1576
|
+
sort: opts.sort,
|
|
1577
|
+
direction: opts.direction,
|
|
1578
|
+
include_extensions: opts.includeExtensions === void 0 ? void 0 : String(opts.includeExtensions),
|
|
1579
|
+
include_extension_keys: opts.includeExtensionKeys || void 0,
|
|
1580
|
+
extension_key: opts.extensionPairs?.map((p) => p.key),
|
|
1581
|
+
extension_value: opts.extensionPairs?.map((p) => p.value)
|
|
1511
1582
|
}
|
|
1512
1583
|
});
|
|
1513
1584
|
}
|
|
@@ -1517,18 +1588,103 @@ function getResource(ctx, id) {
|
|
|
1517
1588
|
function createResourceRaw(ctx, body) {
|
|
1518
1589
|
return request(ctx, BASE3, { method: "POST", body });
|
|
1519
1590
|
}
|
|
1520
|
-
function
|
|
1591
|
+
function updateResourceRaw(ctx, id, body) {
|
|
1592
|
+
return request(ctx, `${BASE3}/${encodeURIComponent(id)}`, { method: "PUT", body });
|
|
1593
|
+
}
|
|
1594
|
+
async function updateResource(ctx, id, patch) {
|
|
1595
|
+
const current = firstResource(await getResource(ctx, id));
|
|
1596
|
+
return updateResourceRaw(ctx, id, resourceUpdateBody(id, current, patch));
|
|
1597
|
+
}
|
|
1598
|
+
async function configureResourceIndex(ctx, id, opts) {
|
|
1599
|
+
const current = firstResource(await getResource(ctx, id));
|
|
1600
|
+
const schema = (current.schema_definition ?? []).map((prop) => ({ ...prop }));
|
|
1601
|
+
const indexConfig = {
|
|
1602
|
+
...current.index_config ?? {},
|
|
1603
|
+
...opts.buildKeyFields?.length ? { build_key_fields: opts.buildKeyFields } : {},
|
|
1604
|
+
...opts.embeddingModel ? { default_embedding_model: opts.embeddingModel } : {},
|
|
1605
|
+
...opts.fulltextAnalyzer ? { default_fulltext_analyzer: opts.fulltextAnalyzer } : {}
|
|
1606
|
+
};
|
|
1607
|
+
for (const field of opts.embeddingFields ?? []) {
|
|
1608
|
+
ensureFeature(
|
|
1609
|
+
schema,
|
|
1610
|
+
field,
|
|
1611
|
+
"vector",
|
|
1612
|
+
opts.embeddingModel ? { embedding_model: opts.embeddingModel } : void 0
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
for (const field of opts.fulltextFields ?? []) {
|
|
1616
|
+
ensureFeature(
|
|
1617
|
+
schema,
|
|
1618
|
+
field,
|
|
1619
|
+
"fulltext",
|
|
1620
|
+
opts.fulltextAnalyzer ? { analyzer: opts.fulltextAnalyzer } : void 0
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
return updateResourceRaw(
|
|
1624
|
+
ctx,
|
|
1625
|
+
id,
|
|
1626
|
+
resourceUpdateBody(id, current, { schemaDefinition: schema, indexConfig })
|
|
1627
|
+
);
|
|
1628
|
+
}
|
|
1629
|
+
function resourceUpdateBody(id, current, patch) {
|
|
1521
1630
|
const body = {
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1631
|
+
id,
|
|
1632
|
+
name: patch.name ?? current.name,
|
|
1633
|
+
catalog_id: patch.catalogId ?? current.catalog_id,
|
|
1634
|
+
tags: patch.tags ?? current.tags ?? [],
|
|
1635
|
+
description: patch.description ?? current.description ?? "",
|
|
1636
|
+
category: patch.category ?? current.category,
|
|
1637
|
+
status: patch.status ?? current.status,
|
|
1638
|
+
database: patch.database ?? current.database,
|
|
1639
|
+
source_identifier: patch.sourceIdentifier ?? current.source_identifier,
|
|
1640
|
+
source_metadata: patch.sourceMetadata ?? current.source_metadata,
|
|
1641
|
+
schema_definition: patch.schemaDefinition ?? current.schema_definition,
|
|
1642
|
+
index_config: patch.indexConfig === void 0 ? current.index_config : patch.indexConfig,
|
|
1643
|
+
logic_definition: patch.logicDefinition ?? current.logic_definition
|
|
1526
1644
|
};
|
|
1527
|
-
if (
|
|
1528
|
-
|
|
1645
|
+
if (patch.extensions !== void 0 || current.extensions !== void 0) {
|
|
1646
|
+
body.extensions = patch.extensions ?? current.extensions;
|
|
1647
|
+
}
|
|
1648
|
+
return body;
|
|
1649
|
+
}
|
|
1650
|
+
function ensureFeature(schema, field, featureType, config) {
|
|
1651
|
+
const prop = schema.find((p) => p.name === field);
|
|
1652
|
+
if (!prop) throw new Error(`resource field '${field}' not found in schema_definition`);
|
|
1653
|
+
const features = [...prop.features ?? []];
|
|
1654
|
+
const existing = features.find(
|
|
1655
|
+
(f) => f.feature_type === featureType && (f.ref_property || field) === field
|
|
1656
|
+
);
|
|
1657
|
+
if (existing) {
|
|
1658
|
+
existing.ref_property = existing.ref_property || field;
|
|
1659
|
+
existing.config = { ...existing.config ?? {}, ...config ?? {} };
|
|
1660
|
+
} else {
|
|
1661
|
+
features.push({
|
|
1662
|
+
name: `${field}_${featureType}`,
|
|
1663
|
+
feature_type: featureType,
|
|
1664
|
+
ref_property: field,
|
|
1665
|
+
is_default: false,
|
|
1666
|
+
is_native: false,
|
|
1667
|
+
...config ? { config } : {}
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
prop.features = features;
|
|
1529
1671
|
}
|
|
1530
|
-
function
|
|
1531
|
-
|
|
1672
|
+
function firstResource(result) {
|
|
1673
|
+
if (result && typeof result === "object") {
|
|
1674
|
+
const o = result;
|
|
1675
|
+
if (Array.isArray(o.entries)) return o.entries[0] ?? {};
|
|
1676
|
+
return o;
|
|
1677
|
+
}
|
|
1678
|
+
return {};
|
|
1679
|
+
}
|
|
1680
|
+
function deleteResource(ctx, id, opts = {}) {
|
|
1681
|
+
const ids = Array.isArray(id) ? id : [id];
|
|
1682
|
+
return request(ctx, `${BASE3}/${ids.map(encodeURIComponent).join(",")}`, {
|
|
1683
|
+
method: "DELETE",
|
|
1684
|
+
query: {
|
|
1685
|
+
ignore_missing: opts.ignoreMissing === void 0 ? void 0 : String(opts.ignoreMissing)
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1532
1688
|
}
|
|
1533
1689
|
async function findResource(ctx, name, opts = {}) {
|
|
1534
1690
|
const result = await listResources2(ctx, { name, datasourceId: opts.datasourceId });
|
|
@@ -2860,10 +3016,7 @@ var BuildMode = z.enum(["batch", "streaming"]);
|
|
|
2860
3016
|
var CreateBuildTaskRequest = z.object({
|
|
2861
3017
|
resource_id: z.string().min(1),
|
|
2862
3018
|
mode: BuildMode,
|
|
2863
|
-
|
|
2864
|
-
build_key_fields: z.array(z.string()).optional(),
|
|
2865
|
-
embedding_model: z.string().optional(),
|
|
2866
|
-
model_dimensions: z.number().int().positive().optional()
|
|
3019
|
+
execute_type: z.enum(["incremental", "full"]).optional()
|
|
2867
3020
|
});
|
|
2868
3021
|
var BuildTask = z.object({
|
|
2869
3022
|
id: z.string(),
|
|
@@ -2874,34 +3027,83 @@ var BuildTask = z.object({
|
|
|
2874
3027
|
total_count: z.number().optional(),
|
|
2875
3028
|
synced_count: z.number().optional(),
|
|
2876
3029
|
vectorized_count: z.number().optional(),
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
3030
|
+
index_config: z.unknown().optional(),
|
|
3031
|
+
catalog_id: z.string().optional(),
|
|
3032
|
+
index_health: z.object({
|
|
3033
|
+
embedding: z.string(),
|
|
3034
|
+
fulltext: z.string(),
|
|
3035
|
+
usable: z.boolean()
|
|
3036
|
+
}).passthrough().optional()
|
|
2881
3037
|
}).passthrough();
|
|
2882
3038
|
async function createBuildTask(ctx, req) {
|
|
2883
3039
|
const p = CreateBuildTaskRequest.parse(req);
|
|
2884
3040
|
const body = {
|
|
2885
3041
|
resource_id: p.resource_id,
|
|
2886
3042
|
mode: p.mode,
|
|
2887
|
-
...p.
|
|
2888
|
-
...p.build_key_fields?.length ? { build_key_fields: p.build_key_fields.join(",") } : {},
|
|
2889
|
-
...p.embedding_model ? { embedding_model: p.embedding_model } : {},
|
|
2890
|
-
...p.model_dimensions ? { model_dimensions: p.model_dimensions } : {}
|
|
3043
|
+
...p.execute_type ? { execute_type: p.execute_type } : {}
|
|
2891
3044
|
};
|
|
2892
3045
|
const res = await request(ctx, `${VEGA_BASE}/build-tasks`, { method: "POST", body });
|
|
2893
3046
|
return BuildTask.parse(res);
|
|
2894
3047
|
}
|
|
3048
|
+
function listBuildTasks(ctx, opts = {}) {
|
|
3049
|
+
return request(ctx, `${VEGA_BASE}/build-tasks`, {
|
|
3050
|
+
query: {
|
|
3051
|
+
limit: opts.limit,
|
|
3052
|
+
offset: opts.offset,
|
|
3053
|
+
resource_id: opts.resourceId || void 0,
|
|
3054
|
+
catalog_id: opts.catalogId || void 0,
|
|
3055
|
+
status: Array.isArray(opts.status) ? opts.status.join(",") : opts.status || void 0,
|
|
3056
|
+
active: opts.active === void 0 ? void 0 : String(opts.active),
|
|
3057
|
+
mode: opts.mode,
|
|
3058
|
+
order_by: opts.orderBy,
|
|
3059
|
+
order: opts.order
|
|
3060
|
+
}
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
2895
3063
|
async function getBuildTask(ctx, taskId) {
|
|
2896
3064
|
const res = await request(ctx, `${VEGA_BASE}/build-tasks/${encodeURIComponent(taskId)}`);
|
|
2897
3065
|
return BuildTask.parse(res);
|
|
2898
3066
|
}
|
|
3067
|
+
function deleteBuildTasks(ctx, ids, opts = {}) {
|
|
3068
|
+
return request(ctx, `${VEGA_BASE}/build-tasks/${ids.map(encodeURIComponent).join(",")}`, {
|
|
3069
|
+
method: "DELETE",
|
|
3070
|
+
query: {
|
|
3071
|
+
ignore_missing: opts.ignoreMissing === void 0 ? void 0 : String(opts.ignoreMissing),
|
|
3072
|
+
delete_active_index: opts.deleteActiveIndex === void 0 ? void 0 : String(opts.deleteActiveIndex)
|
|
3073
|
+
}
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
function startBuildTask(ctx, taskId, opts = {}) {
|
|
3077
|
+
return request(ctx, `${VEGA_BASE}/build-tasks/${encodeURIComponent(taskId)}/start`, {
|
|
3078
|
+
method: "POST",
|
|
3079
|
+
body: opts.reset === void 0 ? {} : { reset: opts.reset }
|
|
3080
|
+
});
|
|
3081
|
+
}
|
|
3082
|
+
function stopBuildTask(ctx, taskId) {
|
|
3083
|
+
return request(ctx, `${VEGA_BASE}/build-tasks/${encodeURIComponent(taskId)}/stop`, {
|
|
3084
|
+
method: "POST"
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
2899
3087
|
function runSql(ctx, body) {
|
|
2900
3088
|
return request(ctx, `${VEGA_BASE}/resources/query`, { method: "POST", body });
|
|
2901
3089
|
}
|
|
2902
3090
|
async function listCatalogs(ctx, opts = {}) {
|
|
2903
3091
|
return request(ctx, `${VEGA_BASE}/catalogs`, {
|
|
2904
|
-
query: {
|
|
3092
|
+
query: {
|
|
3093
|
+
limit: opts.limit,
|
|
3094
|
+
offset: opts.offset,
|
|
3095
|
+
name: opts.name || void 0,
|
|
3096
|
+
tag: opts.tag || void 0,
|
|
3097
|
+
type: opts.type || void 0,
|
|
3098
|
+
enabled: opts.enabled === void 0 ? void 0 : String(opts.enabled),
|
|
3099
|
+
health_check_status: opts.healthCheckStatus || void 0,
|
|
3100
|
+
include_extensions: opts.includeExtensions === void 0 ? void 0 : String(opts.includeExtensions),
|
|
3101
|
+
include_extension_keys: opts.includeExtensionKeys || void 0,
|
|
3102
|
+
extension_key: opts.extensionPairs?.map((p) => p.key),
|
|
3103
|
+
extension_value: opts.extensionPairs?.map((p) => p.value),
|
|
3104
|
+
sort: opts.sort,
|
|
3105
|
+
direction: opts.direction
|
|
3106
|
+
}
|
|
2905
3107
|
});
|
|
2906
3108
|
}
|
|
2907
3109
|
function getCatalog(ctx, id) {
|
|
@@ -2911,18 +3113,49 @@ function createCatalog(ctx, req) {
|
|
|
2911
3113
|
return request(ctx, `${VEGA_BASE}/catalogs`, {
|
|
2912
3114
|
method: "POST",
|
|
2913
3115
|
body: {
|
|
3116
|
+
...req.id ? { id: req.id } : {},
|
|
2914
3117
|
name: req.name,
|
|
2915
3118
|
connector_type: req.connectorType,
|
|
2916
3119
|
connector_config: req.connectorConfig,
|
|
2917
3120
|
...req.tags ? { tags: req.tags } : {},
|
|
2918
3121
|
...req.description ? { description: req.description } : {},
|
|
2919
|
-
...req.enabled !== void 0 ? { enabled: req.enabled } : {}
|
|
3122
|
+
...req.enabled !== void 0 ? { enabled: req.enabled } : {},
|
|
3123
|
+
...req.internal !== void 0 ? { internal: req.internal } : {},
|
|
3124
|
+
...req.extensions ? { extensions: req.extensions } : {}
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
function updateCatalog(ctx, id, req) {
|
|
3129
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}`, {
|
|
3130
|
+
method: "PUT",
|
|
3131
|
+
body: {
|
|
3132
|
+
...req.id ? { id: req.id } : {},
|
|
3133
|
+
...req.name ? { name: req.name } : {},
|
|
3134
|
+
...req.connectorType ? { connector_type: req.connectorType } : {},
|
|
3135
|
+
...req.connectorConfig !== void 0 ? { connector_config: req.connectorConfig } : {},
|
|
3136
|
+
...req.tags ? { tags: req.tags } : {},
|
|
3137
|
+
...req.description !== void 0 ? { description: req.description } : {},
|
|
3138
|
+
...req.enabled !== void 0 ? { enabled: req.enabled } : {},
|
|
3139
|
+
...req.extensions ? { extensions: req.extensions } : {}
|
|
2920
3140
|
}
|
|
2921
3141
|
});
|
|
2922
3142
|
}
|
|
2923
3143
|
function enableCatalog(ctx, id) {
|
|
2924
3144
|
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/enable`, { method: "POST" });
|
|
2925
3145
|
}
|
|
3146
|
+
function disableCatalog(ctx, id) {
|
|
3147
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/disable`, {
|
|
3148
|
+
method: "POST"
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
function deleteCatalog(ctx, id) {
|
|
3152
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
3153
|
+
}
|
|
3154
|
+
function testCatalogConnection(ctx, id) {
|
|
3155
|
+
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/test-connection`, {
|
|
3156
|
+
method: "POST"
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
2926
3159
|
function discoverCatalog(ctx, id, wait = true) {
|
|
2927
3160
|
return request(ctx, `${VEGA_BASE}/catalogs/${encodeURIComponent(id)}/discover`, {
|
|
2928
3161
|
method: "POST",
|
|
@@ -3392,7 +3625,7 @@ async function createFromCatalog(ctx, opts) {
|
|
|
3392
3625
|
}
|
|
3393
3626
|
tablePk[t.name] = res.pk;
|
|
3394
3627
|
}
|
|
3395
|
-
log(`
|
|
3628
|
+
log(`Resolving discovered resources for ${targets.length} table(s)...`);
|
|
3396
3629
|
const viewMap = {};
|
|
3397
3630
|
for (const t of targets) {
|
|
3398
3631
|
const found = asArray(
|
|
@@ -3402,13 +3635,9 @@ async function createFromCatalog(ctx, opts) {
|
|
|
3402
3635
|
if (existingId) {
|
|
3403
3636
|
viewMap[t.name] = existingId;
|
|
3404
3637
|
} else {
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
sourceIdentifier: t.name,
|
|
3409
|
-
fields: t.columns.map((c) => ({ name: c.name, type: c.type }))
|
|
3410
|
-
});
|
|
3411
|
-
viewMap[t.name] = String(created.id ?? "");
|
|
3638
|
+
throw new Error(
|
|
3639
|
+
`Table '${t.name}' has no discovered Vega resource. Run catalog discover and retry.`
|
|
3640
|
+
);
|
|
3412
3641
|
}
|
|
3413
3642
|
}
|
|
3414
3643
|
const knCreated = await createKnowledgeNetwork(ctx, { name: opts.name });
|
|
@@ -3440,12 +3669,14 @@ async function createFromCatalog(ctx, opts) {
|
|
|
3440
3669
|
log("Submitting build tasks...");
|
|
3441
3670
|
for (const t of targets) {
|
|
3442
3671
|
const embedding = opts.embeddingFields?.[t.name];
|
|
3672
|
+
await configureResourceIndex(ctx, viewMap[t.name], {
|
|
3673
|
+
buildKeyFields: [tablePk[t.name]],
|
|
3674
|
+
...embedding && embedding.length > 0 ? { embeddingFields: embedding } : {},
|
|
3675
|
+
...opts.embeddingModel ? { embeddingModel: opts.embeddingModel } : {}
|
|
3676
|
+
});
|
|
3443
3677
|
const task = await createBuildTask(ctx, {
|
|
3444
3678
|
resource_id: viewMap[t.name],
|
|
3445
|
-
mode: "batch"
|
|
3446
|
-
build_key_fields: [tablePk[t.name]],
|
|
3447
|
-
...embedding && embedding.length > 0 ? { embedding_fields: embedding } : {},
|
|
3448
|
-
...opts.embeddingModel ? { embedding_model: opts.embeddingModel } : {}
|
|
3679
|
+
mode: "batch"
|
|
3449
3680
|
});
|
|
3450
3681
|
builds.push({ table: t.name, taskId: String(task.id ?? "") });
|
|
3451
3682
|
}
|
|
@@ -3623,12 +3854,19 @@ function kn(ctx) {
|
|
|
3623
3854
|
const targets = collectIndexTargets(dir);
|
|
3624
3855
|
const buildTasks = [];
|
|
3625
3856
|
for (const t of targets) {
|
|
3857
|
+
if (!t.buildKey) {
|
|
3858
|
+
throw new Error(
|
|
3859
|
+
`Object type '${t.objectType}' declares a vector index but no build key; batch Vega builds require resource index_config.build_key_fields.`
|
|
3860
|
+
);
|
|
3861
|
+
}
|
|
3862
|
+
await configureResourceIndex(ctx, t.resourceId, {
|
|
3863
|
+
buildKeyFields: [t.buildKey],
|
|
3864
|
+
embeddingFields: t.embeddingFields,
|
|
3865
|
+
...t.embeddingModel ?? opts.embeddingModel ? { embeddingModel: t.embeddingModel ?? opts.embeddingModel } : {}
|
|
3866
|
+
});
|
|
3626
3867
|
const task = await createBuildTask(ctx, {
|
|
3627
3868
|
resource_id: t.resourceId,
|
|
3628
|
-
mode: "batch"
|
|
3629
|
-
embedding_fields: t.embeddingFields,
|
|
3630
|
-
...t.buildKey ? { build_key_fields: [t.buildKey] } : {},
|
|
3631
|
-
...t.embeddingModel ?? opts.embeddingModel ? { embedding_model: t.embeddingModel ?? opts.embeddingModel } : {}
|
|
3869
|
+
mode: "batch"
|
|
3632
3870
|
});
|
|
3633
3871
|
buildTasks.push({
|
|
3634
3872
|
objectType: t.objectType,
|
|
@@ -3807,6 +4045,8 @@ function resources(ctx) {
|
|
|
3807
4045
|
list: (opts) => listResources2(ctx, opts),
|
|
3808
4046
|
get: (id) => getResource(ctx, id),
|
|
3809
4047
|
delete: (id) => deleteResource(ctx, id),
|
|
4048
|
+
update: (id, patch) => updateResource(ctx, id, patch),
|
|
4049
|
+
configureIndex: (id, opts) => configureResourceIndex(ctx, id, opts),
|
|
3810
4050
|
find: (name, opts) => findResource(ctx, name, opts),
|
|
3811
4051
|
query: (id, opts) => queryResource(ctx, id, opts)
|
|
3812
4052
|
};
|
|
@@ -4219,7 +4459,7 @@ async function getSpansByConversation(ctx, conversationId, opts = {}) {
|
|
|
4219
4459
|
return (spans.hits?.hits ?? []).map((h) => h._source ?? {});
|
|
4220
4460
|
}
|
|
4221
4461
|
|
|
4222
|
-
// src/trace
|
|
4462
|
+
// src/bkn-trace/claude-judge.ts
|
|
4223
4463
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "child_process";
|
|
4224
4464
|
var ClaudeJudgeError = class extends Error {
|
|
4225
4465
|
constructor(message, reason) {
|
|
@@ -4301,7 +4541,7 @@ async function judgeJson(prompt, opts = {}) {
|
|
|
4301
4541
|
return JSON.parse(extractJsonObject(text));
|
|
4302
4542
|
}
|
|
4303
4543
|
|
|
4304
|
-
// src/trace
|
|
4544
|
+
// src/bkn-trace/diagnose.ts
|
|
4305
4545
|
var KIND_MAP = {
|
|
4306
4546
|
chat: "llm",
|
|
4307
4547
|
text_completion: "llm",
|
|
@@ -4695,7 +4935,7 @@ function renderReportMarkdown(r) {
|
|
|
4695
4935
|
return lines.join("\n");
|
|
4696
4936
|
}
|
|
4697
4937
|
|
|
4698
|
-
// src/trace
|
|
4938
|
+
// src/bkn-trace/eval-set.ts
|
|
4699
4939
|
function hashId(s) {
|
|
4700
4940
|
let h = 5381;
|
|
4701
4941
|
for (let i = 0; i < s.length; i++) h = h * 33 ^ s.charCodeAt(i);
|
|
@@ -4959,7 +5199,11 @@ function vega(ctx) {
|
|
|
4959
5199
|
catalogs: (opts) => listCatalogs(ctx, opts),
|
|
4960
5200
|
getCatalog: (id) => getCatalog(ctx, id),
|
|
4961
5201
|
createCatalog: (req) => createCatalog(ctx, req),
|
|
5202
|
+
updateCatalog: (id, req) => updateCatalog(ctx, id, req),
|
|
4962
5203
|
enableCatalog: (id) => enableCatalog(ctx, id),
|
|
5204
|
+
disableCatalog: (id) => disableCatalog(ctx, id),
|
|
5205
|
+
deleteCatalog: (id) => deleteCatalog(ctx, id),
|
|
5206
|
+
testCatalogConnection: (id) => testCatalogConnection(ctx, id),
|
|
4963
5207
|
discoverCatalog: (id, wait = false) => discoverCatalog(ctx, id, wait),
|
|
4964
5208
|
catalogResources: (id, category) => listCatalogResources(ctx, id, category),
|
|
4965
5209
|
catalogHealth: (ids) => catalogHealthStatus(ctx, ids),
|
|
@@ -4973,7 +5217,11 @@ function vega(ctx) {
|
|
|
4973
5217
|
if (!opts.wait) return task;
|
|
4974
5218
|
return pollBuildTask(ctx, task.id, opts.timeoutMs ?? 3e5, opts.intervalMs ?? 2e3);
|
|
4975
5219
|
},
|
|
4976
|
-
buildStatus: (taskId) => getBuildTask(ctx, taskId)
|
|
5220
|
+
buildStatus: (taskId) => getBuildTask(ctx, taskId),
|
|
5221
|
+
buildTasks: (opts) => listBuildTasks(ctx, opts),
|
|
5222
|
+
deleteBuildTasks: (ids, opts) => deleteBuildTasks(ctx, ids, opts),
|
|
5223
|
+
startBuildTask: (taskId, opts) => startBuildTask(ctx, taskId, opts),
|
|
5224
|
+
stopBuildTask: (taskId) => stopBuildTask(ctx, taskId)
|
|
4977
5225
|
};
|
|
4978
5226
|
}
|
|
4979
5227
|
async function pollBuildTask(ctx, taskId, timeoutMs, intervalMs) {
|
|
@@ -5331,4 +5579,4 @@ export {
|
|
|
5331
5579
|
exportCreds,
|
|
5332
5580
|
auth_exports
|
|
5333
5581
|
};
|
|
5334
|
-
//# sourceMappingURL=chunk-
|
|
5582
|
+
//# sourceMappingURL=chunk-LCOMMFH7.js.map
|