@kweaver-ai/kweaver-sdk 0.4.1 → 0.4.2
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/api/agent-list.d.ts +44 -0
- package/dist/api/agent-list.js +104 -14
- package/dist/api/bkn-backend.d.ts +16 -0
- package/dist/api/bkn-backend.js +46 -0
- package/dist/api/ontology-query.d.ts +1 -1
- package/dist/api/ontology-query.js +1 -0
- package/dist/api/vega.d.ts +110 -0
- package/dist/api/vega.js +251 -0
- package/dist/auth/oauth.d.ts +3 -1
- package/dist/auth/oauth.js +12 -9
- package/dist/cli.js +6 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.js +76 -13
- package/dist/commands/agent.js +292 -14
- package/dist/commands/bkn.d.ts +16 -0
- package/dist/commands/bkn.js +259 -4
- package/dist/commands/call.js +20 -1
- package/dist/commands/vega.d.ts +1 -0
- package/dist/commands/vega.js +663 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/resources/agents.d.ts +83 -9
- package/dist/resources/agents.js +46 -10
- package/dist/resources/knowledge-networks.js +2 -3
- package/package.json +2 -1
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
import { ensureValidToken, formatHttpError } from "../auth/oauth.js";
|
|
2
|
+
import { vegaHealth, listVegaCatalogs, getVegaCatalog, vegaCatalogHealthStatus, testVegaCatalogConnection, discoverVegaCatalog, listVegaCatalogResources, listVegaResources, getVegaResource, queryVegaResourceData, previewVegaResource, listVegaConnectorTypes, getVegaConnectorType, listVegaDiscoverTasks, } from "../api/vega.js";
|
|
3
|
+
import { formatCallOutput } from "./call.js";
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Help
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
function printVegaHelp() {
|
|
8
|
+
console.log(`kweaver vega
|
|
9
|
+
|
|
10
|
+
Subcommands:
|
|
11
|
+
health Check Vega service health
|
|
12
|
+
stats Show catalog statistics
|
|
13
|
+
inspect Health + catalog summary + running tasks
|
|
14
|
+
catalog list [--status X] [--limit N] [--offset N]
|
|
15
|
+
catalog get <id>
|
|
16
|
+
catalog health <ids...> | --all Health-check catalogs
|
|
17
|
+
catalog test-connection <id> Test catalog connectivity
|
|
18
|
+
catalog discover <id> [--wait] Trigger discovery
|
|
19
|
+
catalog resources <id> [--category X] [--limit N]
|
|
20
|
+
resource list [--catalog-id X] [--category X] [--status X] [--limit N] [--offset N]
|
|
21
|
+
resource get <id>
|
|
22
|
+
resource query <id> -d <json-body> Query resource data
|
|
23
|
+
resource preview <id> [--limit N] Preview resource data
|
|
24
|
+
connector-type list List connector types
|
|
25
|
+
connector-type get <type> Get connector type details
|
|
26
|
+
|
|
27
|
+
Common flags:
|
|
28
|
+
-bd, --biz-domain <s> Business domain (default: bd_public)
|
|
29
|
+
--pretty Pretty-print JSON (default)`);
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Common flag parser
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
function parseCommonFlags(args) {
|
|
35
|
+
let businessDomain = "bd_public";
|
|
36
|
+
let pretty = true;
|
|
37
|
+
const remaining = [];
|
|
38
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
39
|
+
const arg = args[i];
|
|
40
|
+
if ((arg === "-bd" || arg === "--biz-domain") && args[i + 1]) {
|
|
41
|
+
businessDomain = args[++i];
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (arg === "--pretty") {
|
|
45
|
+
pretty = true;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
remaining.push(arg);
|
|
49
|
+
}
|
|
50
|
+
return { remaining, businessDomain, pretty };
|
|
51
|
+
}
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// Main router
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
export async function runVegaCommand(args) {
|
|
56
|
+
const [subcommand, ...rest] = args;
|
|
57
|
+
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
58
|
+
printVegaHelp();
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
if (subcommand === "health")
|
|
63
|
+
return await runVegaHealthCommand(rest);
|
|
64
|
+
if (subcommand === "stats")
|
|
65
|
+
return await runVegaStatsCommand(rest);
|
|
66
|
+
if (subcommand === "inspect")
|
|
67
|
+
return await runVegaInspectCommand(rest);
|
|
68
|
+
if (subcommand === "catalog")
|
|
69
|
+
return await runVegaCatalogCommand(rest);
|
|
70
|
+
if (subcommand === "resource")
|
|
71
|
+
return await runVegaResourceCommand(rest);
|
|
72
|
+
if (subcommand === "connector-type")
|
|
73
|
+
return await runVegaConnectorTypeCommand(rest);
|
|
74
|
+
console.error(`Unknown vega subcommand: ${subcommand}`);
|
|
75
|
+
return 1;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error(formatHttpError(error));
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Top-level: health
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
async function runVegaHealthCommand(args) {
|
|
86
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
87
|
+
console.log("kweaver vega health\n\nCheck Vega service health.");
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
const { businessDomain, pretty } = parseCommonFlags(args);
|
|
91
|
+
const token = await ensureValidToken();
|
|
92
|
+
const body = await vegaHealth({
|
|
93
|
+
baseUrl: token.baseUrl,
|
|
94
|
+
accessToken: token.accessToken,
|
|
95
|
+
businessDomain,
|
|
96
|
+
});
|
|
97
|
+
console.log(formatCallOutput(body, pretty));
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// Top-level: stats
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
async function runVegaStatsCommand(args) {
|
|
104
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
105
|
+
console.log("kweaver vega stats\n\nShow catalog statistics.");
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
const { businessDomain, pretty } = parseCommonFlags(args);
|
|
109
|
+
const token = await ensureValidToken();
|
|
110
|
+
const body = await listVegaCatalogs({
|
|
111
|
+
baseUrl: token.baseUrl,
|
|
112
|
+
accessToken: token.accessToken,
|
|
113
|
+
limit: 100,
|
|
114
|
+
businessDomain,
|
|
115
|
+
});
|
|
116
|
+
const parsed = JSON.parse(body);
|
|
117
|
+
const entries = Array.isArray(parsed) ? parsed : (parsed.entries ?? parsed.data ?? parsed.items ?? parsed.catalogs ?? []);
|
|
118
|
+
const count = Array.isArray(entries) ? entries.length : 0;
|
|
119
|
+
const stats = { catalog_count: count };
|
|
120
|
+
console.log(pretty ? JSON.stringify(stats, null, 2) : JSON.stringify(stats));
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Top-level: inspect
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
async function runVegaInspectCommand(args) {
|
|
127
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
128
|
+
console.log("kweaver vega inspect\n\nHealth + catalog summary + running discover tasks.");
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
const { businessDomain, pretty } = parseCommonFlags(args);
|
|
132
|
+
const token = await ensureValidToken();
|
|
133
|
+
const base = { baseUrl: token.baseUrl, accessToken: token.accessToken, businessDomain };
|
|
134
|
+
const result = {};
|
|
135
|
+
// Health — best-effort
|
|
136
|
+
try {
|
|
137
|
+
const healthBody = await vegaHealth(base);
|
|
138
|
+
result.health = JSON.parse(healthBody);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
console.error(`warn: health check failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
142
|
+
result.health = null;
|
|
143
|
+
}
|
|
144
|
+
// Catalogs — best-effort
|
|
145
|
+
try {
|
|
146
|
+
const catalogsBody = await listVegaCatalogs({ ...base, limit: 100 });
|
|
147
|
+
const parsed = JSON.parse(catalogsBody);
|
|
148
|
+
const entries = Array.isArray(parsed) ? parsed : (parsed.entries ?? parsed.data ?? parsed.items ?? parsed.catalogs ?? []);
|
|
149
|
+
result.catalog_count = Array.isArray(entries) ? entries.length : 0;
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
console.error(`warn: catalog list failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
153
|
+
result.catalog_count = null;
|
|
154
|
+
}
|
|
155
|
+
// Running discover tasks — best-effort
|
|
156
|
+
try {
|
|
157
|
+
const tasksBody = await listVegaDiscoverTasks({ ...base, status: "running" });
|
|
158
|
+
const parsed = JSON.parse(tasksBody);
|
|
159
|
+
const entries = Array.isArray(parsed) ? parsed : (parsed.entries ?? parsed.data ?? parsed.items ?? parsed.tasks ?? []);
|
|
160
|
+
result.running_discover_tasks = Array.isArray(entries) ? entries.length : 0;
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
console.error(`warn: discover tasks query failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
164
|
+
result.running_discover_tasks = null;
|
|
165
|
+
}
|
|
166
|
+
console.log(pretty ? JSON.stringify(result, null, 2) : JSON.stringify(result));
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
// Catalog router
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
async function runVegaCatalogCommand(args) {
|
|
173
|
+
const [sub, ...rest] = args;
|
|
174
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
175
|
+
console.log(`kweaver vega catalog
|
|
176
|
+
|
|
177
|
+
Subcommands:
|
|
178
|
+
list [--status X] [--limit N] [--offset N]
|
|
179
|
+
get <id>
|
|
180
|
+
health <ids...> | --all
|
|
181
|
+
test-connection <id>
|
|
182
|
+
discover <id> [--wait]
|
|
183
|
+
resources <id> [--category X] [--limit N]`);
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
if (sub === "list")
|
|
187
|
+
return await runCatalogList(rest);
|
|
188
|
+
if (sub === "get")
|
|
189
|
+
return await runCatalogGet(rest);
|
|
190
|
+
if (sub === "health")
|
|
191
|
+
return await runCatalogHealth(rest);
|
|
192
|
+
if (sub === "test-connection")
|
|
193
|
+
return await runCatalogTestConnection(rest);
|
|
194
|
+
if (sub === "discover")
|
|
195
|
+
return await runCatalogDiscover(rest);
|
|
196
|
+
if (sub === "resources")
|
|
197
|
+
return await runCatalogResources(rest);
|
|
198
|
+
console.error(`Unknown catalog subcommand: ${sub}`);
|
|
199
|
+
return 1;
|
|
200
|
+
}
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
// catalog list
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
async function runCatalogList(args) {
|
|
205
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
206
|
+
console.log(`kweaver vega catalog list [options]
|
|
207
|
+
|
|
208
|
+
Options:
|
|
209
|
+
--status <s> Filter by status
|
|
210
|
+
--limit <n> Max results
|
|
211
|
+
--offset <n> Offset
|
|
212
|
+
-bd, --biz-domain Business domain (default: bd_public)
|
|
213
|
+
--pretty Pretty-print JSON (default)`);
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
let status;
|
|
217
|
+
let limit;
|
|
218
|
+
let offset;
|
|
219
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
220
|
+
for (let i = 0; i < remaining.length; i += 1) {
|
|
221
|
+
const arg = remaining[i];
|
|
222
|
+
if (arg === "--status" && remaining[i + 1]) {
|
|
223
|
+
status = remaining[++i];
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (arg === "--limit" && remaining[i + 1]) {
|
|
227
|
+
limit = parseInt(remaining[++i], 10);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (arg === "--offset" && remaining[i + 1]) {
|
|
231
|
+
offset = parseInt(remaining[++i], 10);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const token = await ensureValidToken();
|
|
236
|
+
const body = await listVegaCatalogs({
|
|
237
|
+
baseUrl: token.baseUrl,
|
|
238
|
+
accessToken: token.accessToken,
|
|
239
|
+
status,
|
|
240
|
+
limit,
|
|
241
|
+
offset,
|
|
242
|
+
businessDomain,
|
|
243
|
+
});
|
|
244
|
+
console.log(formatCallOutput(body, pretty));
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
// ---------------------------------------------------------------------------
|
|
248
|
+
// catalog get
|
|
249
|
+
// ---------------------------------------------------------------------------
|
|
250
|
+
async function runCatalogGet(args) {
|
|
251
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
252
|
+
console.log("kweaver vega catalog get <id>");
|
|
253
|
+
return 0;
|
|
254
|
+
}
|
|
255
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
256
|
+
const id = remaining.find((a) => !a.startsWith("-"));
|
|
257
|
+
if (!id) {
|
|
258
|
+
console.error("Usage: kweaver vega catalog get <id>");
|
|
259
|
+
return 1;
|
|
260
|
+
}
|
|
261
|
+
const token = await ensureValidToken();
|
|
262
|
+
const body = await getVegaCatalog({
|
|
263
|
+
baseUrl: token.baseUrl,
|
|
264
|
+
accessToken: token.accessToken,
|
|
265
|
+
id,
|
|
266
|
+
businessDomain,
|
|
267
|
+
});
|
|
268
|
+
console.log(formatCallOutput(body, pretty));
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// catalog health
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
async function runCatalogHealth(args) {
|
|
275
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
276
|
+
console.log(`kweaver vega catalog health <ids...> | --all
|
|
277
|
+
|
|
278
|
+
Options:
|
|
279
|
+
--all Check health of all catalogs`);
|
|
280
|
+
return 0;
|
|
281
|
+
}
|
|
282
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
283
|
+
const useAll = remaining.includes("--all");
|
|
284
|
+
const positionalIds = remaining.filter((a) => !a.startsWith("-"));
|
|
285
|
+
const token = await ensureValidToken();
|
|
286
|
+
const base = { baseUrl: token.baseUrl, accessToken: token.accessToken, businessDomain };
|
|
287
|
+
let ids;
|
|
288
|
+
if (useAll) {
|
|
289
|
+
const catalogsBody = await listVegaCatalogs({ ...base, limit: 100 });
|
|
290
|
+
const parsed = JSON.parse(catalogsBody);
|
|
291
|
+
const entries = Array.isArray(parsed) ? parsed : (parsed.entries ?? parsed.data ?? parsed.items ?? parsed.catalogs ?? []);
|
|
292
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
293
|
+
console.error("No catalogs found.");
|
|
294
|
+
return 1;
|
|
295
|
+
}
|
|
296
|
+
ids = entries
|
|
297
|
+
.map((e) => String(e.id ?? e.catalog_id ?? ""))
|
|
298
|
+
.filter(Boolean)
|
|
299
|
+
.join(",");
|
|
300
|
+
}
|
|
301
|
+
else if (positionalIds.length > 0) {
|
|
302
|
+
ids = positionalIds.join(",");
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
console.error("Usage: kweaver vega catalog health <ids...> | --all");
|
|
306
|
+
return 1;
|
|
307
|
+
}
|
|
308
|
+
const body = await vegaCatalogHealthStatus({ ...base, ids });
|
|
309
|
+
console.log(formatCallOutput(body, pretty));
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
// ---------------------------------------------------------------------------
|
|
313
|
+
// catalog test-connection
|
|
314
|
+
// ---------------------------------------------------------------------------
|
|
315
|
+
async function runCatalogTestConnection(args) {
|
|
316
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
317
|
+
console.log("kweaver vega catalog test-connection <id>");
|
|
318
|
+
return 0;
|
|
319
|
+
}
|
|
320
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
321
|
+
const id = remaining.find((a) => !a.startsWith("-"));
|
|
322
|
+
if (!id) {
|
|
323
|
+
console.error("Usage: kweaver vega catalog test-connection <id>");
|
|
324
|
+
return 1;
|
|
325
|
+
}
|
|
326
|
+
const token = await ensureValidToken();
|
|
327
|
+
const body = await testVegaCatalogConnection({
|
|
328
|
+
baseUrl: token.baseUrl,
|
|
329
|
+
accessToken: token.accessToken,
|
|
330
|
+
id,
|
|
331
|
+
businessDomain,
|
|
332
|
+
});
|
|
333
|
+
console.log(formatCallOutput(body, pretty));
|
|
334
|
+
return 0;
|
|
335
|
+
}
|
|
336
|
+
// ---------------------------------------------------------------------------
|
|
337
|
+
// catalog discover
|
|
338
|
+
// ---------------------------------------------------------------------------
|
|
339
|
+
async function runCatalogDiscover(args) {
|
|
340
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
341
|
+
console.log(`kweaver vega catalog discover <id> [--wait]
|
|
342
|
+
|
|
343
|
+
Options:
|
|
344
|
+
--wait Wait for discovery to complete`);
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
348
|
+
const wait = remaining.includes("--wait");
|
|
349
|
+
const id = remaining.find((a) => !a.startsWith("-"));
|
|
350
|
+
if (!id) {
|
|
351
|
+
console.error("Usage: kweaver vega catalog discover <id> [--wait]");
|
|
352
|
+
return 1;
|
|
353
|
+
}
|
|
354
|
+
const token = await ensureValidToken();
|
|
355
|
+
const body = await discoverVegaCatalog({
|
|
356
|
+
baseUrl: token.baseUrl,
|
|
357
|
+
accessToken: token.accessToken,
|
|
358
|
+
id,
|
|
359
|
+
wait: wait ? true : undefined,
|
|
360
|
+
businessDomain,
|
|
361
|
+
});
|
|
362
|
+
console.log(formatCallOutput(body, pretty));
|
|
363
|
+
return 0;
|
|
364
|
+
}
|
|
365
|
+
// ---------------------------------------------------------------------------
|
|
366
|
+
// catalog resources
|
|
367
|
+
// ---------------------------------------------------------------------------
|
|
368
|
+
async function runCatalogResources(args) {
|
|
369
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
370
|
+
console.log(`kweaver vega catalog resources <id> [options]
|
|
371
|
+
|
|
372
|
+
Options:
|
|
373
|
+
--category <s> Filter by category
|
|
374
|
+
--limit <n> Max results`);
|
|
375
|
+
return 0;
|
|
376
|
+
}
|
|
377
|
+
let category;
|
|
378
|
+
let limit;
|
|
379
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
380
|
+
const positionals = [];
|
|
381
|
+
for (let i = 0; i < remaining.length; i += 1) {
|
|
382
|
+
const arg = remaining[i];
|
|
383
|
+
if (arg === "--category" && remaining[i + 1]) {
|
|
384
|
+
category = remaining[++i];
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (arg === "--limit" && remaining[i + 1]) {
|
|
388
|
+
limit = parseInt(remaining[++i], 10);
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (!arg.startsWith("-")) {
|
|
392
|
+
positionals.push(arg);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const id = positionals[0];
|
|
396
|
+
if (!id) {
|
|
397
|
+
console.error("Usage: kweaver vega catalog resources <id> [--category X] [--limit N]");
|
|
398
|
+
return 1;
|
|
399
|
+
}
|
|
400
|
+
const token = await ensureValidToken();
|
|
401
|
+
const body = await listVegaCatalogResources({
|
|
402
|
+
baseUrl: token.baseUrl,
|
|
403
|
+
accessToken: token.accessToken,
|
|
404
|
+
id,
|
|
405
|
+
category,
|
|
406
|
+
limit,
|
|
407
|
+
businessDomain,
|
|
408
|
+
});
|
|
409
|
+
console.log(formatCallOutput(body, pretty));
|
|
410
|
+
return 0;
|
|
411
|
+
}
|
|
412
|
+
// ---------------------------------------------------------------------------
|
|
413
|
+
// Resource router
|
|
414
|
+
// ---------------------------------------------------------------------------
|
|
415
|
+
async function runVegaResourceCommand(args) {
|
|
416
|
+
const [sub, ...rest] = args;
|
|
417
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
418
|
+
console.log(`kweaver vega resource
|
|
419
|
+
|
|
420
|
+
Subcommands:
|
|
421
|
+
list [--catalog-id X] [--category X] [--status X] [--limit N] [--offset N]
|
|
422
|
+
get <id>
|
|
423
|
+
query <id> -d <json-body>
|
|
424
|
+
preview <id> [--limit N]`);
|
|
425
|
+
return 0;
|
|
426
|
+
}
|
|
427
|
+
if (sub === "list")
|
|
428
|
+
return await runResourceList(rest);
|
|
429
|
+
if (sub === "get")
|
|
430
|
+
return await runResourceGet(rest);
|
|
431
|
+
if (sub === "query")
|
|
432
|
+
return await runResourceQuery(rest);
|
|
433
|
+
if (sub === "preview")
|
|
434
|
+
return await runResourcePreview(rest);
|
|
435
|
+
console.error(`Unknown resource subcommand: ${sub}`);
|
|
436
|
+
return 1;
|
|
437
|
+
}
|
|
438
|
+
// ---------------------------------------------------------------------------
|
|
439
|
+
// resource list
|
|
440
|
+
// ---------------------------------------------------------------------------
|
|
441
|
+
async function runResourceList(args) {
|
|
442
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
443
|
+
console.log(`kweaver vega resource list [options]
|
|
444
|
+
|
|
445
|
+
Options:
|
|
446
|
+
--catalog-id <s> Filter by catalog
|
|
447
|
+
--category <s> Filter by category
|
|
448
|
+
--status <s> Filter by status
|
|
449
|
+
--limit <n> Max results
|
|
450
|
+
--offset <n> Offset
|
|
451
|
+
-bd, --biz-domain Business domain (default: bd_public)
|
|
452
|
+
--pretty Pretty-print JSON (default)`);
|
|
453
|
+
return 0;
|
|
454
|
+
}
|
|
455
|
+
let catalogId;
|
|
456
|
+
let category;
|
|
457
|
+
let status;
|
|
458
|
+
let limit;
|
|
459
|
+
let offset;
|
|
460
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
461
|
+
for (let i = 0; i < remaining.length; i += 1) {
|
|
462
|
+
const arg = remaining[i];
|
|
463
|
+
if (arg === "--catalog-id" && remaining[i + 1]) {
|
|
464
|
+
catalogId = remaining[++i];
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
if (arg === "--category" && remaining[i + 1]) {
|
|
468
|
+
category = remaining[++i];
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (arg === "--status" && remaining[i + 1]) {
|
|
472
|
+
status = remaining[++i];
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (arg === "--limit" && remaining[i + 1]) {
|
|
476
|
+
limit = parseInt(remaining[++i], 10);
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if (arg === "--offset" && remaining[i + 1]) {
|
|
480
|
+
offset = parseInt(remaining[++i], 10);
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const token = await ensureValidToken();
|
|
485
|
+
const body = await listVegaResources({
|
|
486
|
+
baseUrl: token.baseUrl,
|
|
487
|
+
accessToken: token.accessToken,
|
|
488
|
+
catalogId,
|
|
489
|
+
category,
|
|
490
|
+
status,
|
|
491
|
+
limit,
|
|
492
|
+
offset,
|
|
493
|
+
businessDomain,
|
|
494
|
+
});
|
|
495
|
+
console.log(formatCallOutput(body, pretty));
|
|
496
|
+
return 0;
|
|
497
|
+
}
|
|
498
|
+
// ---------------------------------------------------------------------------
|
|
499
|
+
// resource get
|
|
500
|
+
// ---------------------------------------------------------------------------
|
|
501
|
+
async function runResourceGet(args) {
|
|
502
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
503
|
+
console.log("kweaver vega resource get <id>");
|
|
504
|
+
return 0;
|
|
505
|
+
}
|
|
506
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
507
|
+
const id = remaining.find((a) => !a.startsWith("-"));
|
|
508
|
+
if (!id) {
|
|
509
|
+
console.error("Usage: kweaver vega resource get <id>");
|
|
510
|
+
return 1;
|
|
511
|
+
}
|
|
512
|
+
const token = await ensureValidToken();
|
|
513
|
+
const body = await getVegaResource({
|
|
514
|
+
baseUrl: token.baseUrl,
|
|
515
|
+
accessToken: token.accessToken,
|
|
516
|
+
id,
|
|
517
|
+
businessDomain,
|
|
518
|
+
});
|
|
519
|
+
console.log(formatCallOutput(body, pretty));
|
|
520
|
+
return 0;
|
|
521
|
+
}
|
|
522
|
+
// ---------------------------------------------------------------------------
|
|
523
|
+
// resource query
|
|
524
|
+
// ---------------------------------------------------------------------------
|
|
525
|
+
async function runResourceQuery(args) {
|
|
526
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
527
|
+
console.log(`kweaver vega resource query <id> -d <json-body>
|
|
528
|
+
|
|
529
|
+
Options:
|
|
530
|
+
-d, --data <json> Request body (JSON string)`);
|
|
531
|
+
return 0;
|
|
532
|
+
}
|
|
533
|
+
let data;
|
|
534
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
535
|
+
const positionals = [];
|
|
536
|
+
for (let i = 0; i < remaining.length; i += 1) {
|
|
537
|
+
const arg = remaining[i];
|
|
538
|
+
if ((arg === "-d" || arg === "--data") && remaining[i + 1]) {
|
|
539
|
+
data = remaining[++i];
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
if (!arg.startsWith("-")) {
|
|
543
|
+
positionals.push(arg);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
const id = positionals[0];
|
|
547
|
+
if (!id || !data) {
|
|
548
|
+
console.error("Usage: kweaver vega resource query <id> -d <json-body>");
|
|
549
|
+
return 1;
|
|
550
|
+
}
|
|
551
|
+
const token = await ensureValidToken();
|
|
552
|
+
const body = await queryVegaResourceData({
|
|
553
|
+
baseUrl: token.baseUrl,
|
|
554
|
+
accessToken: token.accessToken,
|
|
555
|
+
id,
|
|
556
|
+
body: data,
|
|
557
|
+
businessDomain,
|
|
558
|
+
});
|
|
559
|
+
console.log(formatCallOutput(body, pretty));
|
|
560
|
+
return 0;
|
|
561
|
+
}
|
|
562
|
+
// ---------------------------------------------------------------------------
|
|
563
|
+
// resource preview
|
|
564
|
+
// ---------------------------------------------------------------------------
|
|
565
|
+
async function runResourcePreview(args) {
|
|
566
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
567
|
+
console.log(`kweaver vega resource preview <id> [--limit N]
|
|
568
|
+
|
|
569
|
+
Options:
|
|
570
|
+
--limit <n> Number of rows to preview (default: 10)`);
|
|
571
|
+
return 0;
|
|
572
|
+
}
|
|
573
|
+
let limit;
|
|
574
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
575
|
+
const positionals = [];
|
|
576
|
+
for (let i = 0; i < remaining.length; i += 1) {
|
|
577
|
+
const arg = remaining[i];
|
|
578
|
+
if (arg === "--limit" && remaining[i + 1]) {
|
|
579
|
+
limit = parseInt(remaining[++i], 10);
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
if (!arg.startsWith("-")) {
|
|
583
|
+
positionals.push(arg);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const id = positionals[0];
|
|
587
|
+
if (!id) {
|
|
588
|
+
console.error("Usage: kweaver vega resource preview <id> [--limit N]");
|
|
589
|
+
return 1;
|
|
590
|
+
}
|
|
591
|
+
const token = await ensureValidToken();
|
|
592
|
+
const body = await previewVegaResource({
|
|
593
|
+
baseUrl: token.baseUrl,
|
|
594
|
+
accessToken: token.accessToken,
|
|
595
|
+
id,
|
|
596
|
+
limit,
|
|
597
|
+
businessDomain,
|
|
598
|
+
});
|
|
599
|
+
console.log(formatCallOutput(body, pretty));
|
|
600
|
+
return 0;
|
|
601
|
+
}
|
|
602
|
+
// ---------------------------------------------------------------------------
|
|
603
|
+
// Connector-type router
|
|
604
|
+
// ---------------------------------------------------------------------------
|
|
605
|
+
async function runVegaConnectorTypeCommand(args) {
|
|
606
|
+
const [sub, ...rest] = args;
|
|
607
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
608
|
+
console.log(`kweaver vega connector-type
|
|
609
|
+
|
|
610
|
+
Subcommands:
|
|
611
|
+
list List connector types
|
|
612
|
+
get <type> Get connector type details`);
|
|
613
|
+
return 0;
|
|
614
|
+
}
|
|
615
|
+
if (sub === "list")
|
|
616
|
+
return await runConnectorTypeList(rest);
|
|
617
|
+
if (sub === "get")
|
|
618
|
+
return await runConnectorTypeGet(rest);
|
|
619
|
+
console.error(`Unknown connector-type subcommand: ${sub}`);
|
|
620
|
+
return 1;
|
|
621
|
+
}
|
|
622
|
+
// ---------------------------------------------------------------------------
|
|
623
|
+
// connector-type list
|
|
624
|
+
// ---------------------------------------------------------------------------
|
|
625
|
+
async function runConnectorTypeList(args) {
|
|
626
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
627
|
+
console.log("kweaver vega connector-type list");
|
|
628
|
+
return 0;
|
|
629
|
+
}
|
|
630
|
+
const { businessDomain, pretty } = parseCommonFlags(args);
|
|
631
|
+
const token = await ensureValidToken();
|
|
632
|
+
const body = await listVegaConnectorTypes({
|
|
633
|
+
baseUrl: token.baseUrl,
|
|
634
|
+
accessToken: token.accessToken,
|
|
635
|
+
businessDomain,
|
|
636
|
+
});
|
|
637
|
+
console.log(formatCallOutput(body, pretty));
|
|
638
|
+
return 0;
|
|
639
|
+
}
|
|
640
|
+
// ---------------------------------------------------------------------------
|
|
641
|
+
// connector-type get
|
|
642
|
+
// ---------------------------------------------------------------------------
|
|
643
|
+
async function runConnectorTypeGet(args) {
|
|
644
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
645
|
+
console.log("kweaver vega connector-type get <type>");
|
|
646
|
+
return 0;
|
|
647
|
+
}
|
|
648
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
649
|
+
const type = remaining.find((a) => !a.startsWith("-"));
|
|
650
|
+
if (!type) {
|
|
651
|
+
console.error("Usage: kweaver vega connector-type get <type>");
|
|
652
|
+
return 1;
|
|
653
|
+
}
|
|
654
|
+
const token = await ensureValidToken();
|
|
655
|
+
const body = await getVegaConnectorType({
|
|
656
|
+
baseUrl: token.baseUrl,
|
|
657
|
+
accessToken: token.accessToken,
|
|
658
|
+
type,
|
|
659
|
+
businessDomain,
|
|
660
|
+
});
|
|
661
|
+
console.log(formatCallOutput(body, pretty));
|
|
662
|
+
return 0;
|
|
663
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export type { OntologyQueryBaseOptions, ObjectTypeQueryOptions, ObjectTypeProper
|
|
|
31
31
|
export { objectTypeQuery, objectTypeProperties, subgraph, actionTypeQuery, actionTypeExecute, actionExecutionGet, actionLogsList, actionLogGet, actionLogCancel, } from "./api/ontology-query.js";
|
|
32
32
|
export type { SendChatRequestOptions, SendChatRequestStreamCallbacks, ChatResult, ProgressItem, AgentInfo, } from "./api/agent-chat.js";
|
|
33
33
|
export { sendChatRequest, sendChatRequestStream, fetchAgentInfo, buildChatUrl, buildAgentInfoUrl, extractText, } from "./api/agent-chat.js";
|
|
34
|
-
export type { ListAgentsOptions } from "./api/agent-list.js";
|
|
35
|
-
export { listAgents } from "./api/agent-list.js";
|
|
34
|
+
export type { ListAgentsOptions, GetAgentOptions, GetAgentByKeyOptions, CreateAgentOptions, UpdateAgentOptions, DeleteAgentOptions, PublishAgentOptions, UnpublishAgentOptions, } from "./api/agent-list.js";
|
|
35
|
+
export { listAgents, getAgent, getAgentByKey, createAgent, updateAgent, deleteAgent, publishAgent, unpublishAgent, } from "./api/agent-list.js";
|
|
36
36
|
export type { ListConversationsOptions, ListMessagesOptions } from "./api/conversations.js";
|
|
37
37
|
export { listConversations, listMessages } from "./api/conversations.js";
|
|
38
38
|
export type { SemanticSearchOptions } from "./api/semantic-search.js";
|
|
@@ -45,6 +45,7 @@ export type { KWeaverClientOptions, ClientContext } from "./client.js";
|
|
|
45
45
|
export { KWeaverClient } from "./client.js";
|
|
46
46
|
export { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
|
|
47
47
|
export { AgentsResource } from "./resources/agents.js";
|
|
48
|
+
export type { AgentConfig, AgentInput, AgentInputField, AgentOutput, AgentLlmConfig, AgentLlmItem, CreateAgentBody, UpdateAgentBody, } from "./resources/agents.js";
|
|
48
49
|
export { BknResource } from "./resources/bkn.js";
|
|
49
50
|
export { ConversationsResource } from "./resources/conversations.js";
|
|
50
51
|
export { ContextLoaderResource } from "./resources/context-loader.js";
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
export { listKnowledgeNetworks, getKnowledgeNetwork, createKnowledgeNetwork, updateKnowledgeNetwork, deleteKnowledgeNetwork, listObjectTypes, listRelationTypes, listActionTypes, } from "./api/knowledge-networks.js";
|
|
29
29
|
export { objectTypeQuery, objectTypeProperties, subgraph, actionTypeQuery, actionTypeExecute, actionExecutionGet, actionLogsList, actionLogGet, actionLogCancel, } from "./api/ontology-query.js";
|
|
30
30
|
export { sendChatRequest, sendChatRequestStream, fetchAgentInfo, buildChatUrl, buildAgentInfoUrl, extractText, } from "./api/agent-chat.js";
|
|
31
|
-
export { listAgents } from "./api/agent-list.js";
|
|
31
|
+
export { listAgents, getAgent, getAgentByKey, createAgent, updateAgent, deleteAgent, publishAgent, unpublishAgent, } from "./api/agent-list.js";
|
|
32
32
|
export { listConversations, listMessages } from "./api/conversations.js";
|
|
33
33
|
export { semanticSearch } from "./api/semantic-search.js";
|
|
34
34
|
export { knSearch, knSchemaSearch, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, formatMissingInputParamsHint, validateCondition, validateInstanceIdentity, validateInstanceIdentities, } from "./api/context-loader.js";
|