@kweaver-ai/kweaver-sdk 0.6.1 → 0.6.3
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 +25 -2
- package/README.zh.md +28 -0
- package/dist/api/skills.d.ts +6 -6
- package/dist/api/skills.js +23 -9
- package/dist/api/vega.d.ts +10 -0
- package/dist/api/vega.js +23 -10
- package/dist/cli.js +2 -1
- package/dist/commands/agent-chat.js +1 -1
- package/dist/commands/agent.d.ts +9 -0
- package/dist/commands/agent.js +44 -4
- package/dist/commands/bkn-schema.js +6 -1
- package/dist/commands/dataflow.js +49 -7
- package/dist/commands/skill.js +4 -4
- package/dist/commands/vega.js +101 -2
- package/dist/resources/vega.d.ts +2 -0
- package/dist/resources/vega.js +6 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -126,9 +126,18 @@ const result = await client.dataflows.execute({
|
|
|
126
126
|
steps: [{ id: "s1", title: "load", operator: "csv_import", parameters: {} }],
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
// Vega observability
|
|
129
|
+
// Vega — observability and query
|
|
130
130
|
const catalogs = await client.vega.listCatalogs();
|
|
131
131
|
const health = await client.vega.health();
|
|
132
|
+
// Structured query — POST /api/vega-backend/v1/query/execute (JSON string body)
|
|
133
|
+
const structured = await client.vega.executeQuery(
|
|
134
|
+
JSON.stringify({ tables: [{ resource_id: "res-1" }], output_fields: ["*"], limit: 20 }),
|
|
135
|
+
);
|
|
136
|
+
// Direct SQL or OpenSearch DSL — POST /api/vega-backend/v1/resources/query
|
|
137
|
+
// Use {{resource_id}} placeholders so vega-backend routes to the correct catalog connector.
|
|
138
|
+
const rows = await client.vega.sqlQuery(
|
|
139
|
+
JSON.stringify({ query: "SELECT * FROM {{res-1}} LIMIT 5", resource_type: "mysql" }),
|
|
140
|
+
);
|
|
132
141
|
|
|
133
142
|
// Context Loader (semantic search over a BKN via MCP)
|
|
134
143
|
const cl = client.contextLoader(mcpUrl, "bkn-id");
|
|
@@ -164,7 +173,7 @@ kweaver bkn action-execution get
|
|
|
164
173
|
kweaver bkn action-log list/get/cancel
|
|
165
174
|
kweaver agent list/get/create/update/delete/chat/sessions/history/publish/unpublish
|
|
166
175
|
kweaver skill list/market/get/register/status/delete/content/read-file/download/install
|
|
167
|
-
kweaver vega health/stats/inspect/catalog/resource/connector-type
|
|
176
|
+
kweaver vega health/stats/inspect/sql/catalog/resource/connector-type
|
|
168
177
|
kweaver context-loader config set/use/list/show
|
|
169
178
|
kweaver context-loader kn-search/query-object-instance/...
|
|
170
179
|
kweaver call <path> [-X METHOD] [-d BODY] [-H header]
|
|
@@ -184,6 +193,20 @@ kweaver dataflow logs <dagId> <instanceId> --detail
|
|
|
184
193
|
|
|
185
194
|
`kweaver dataflow runs --since` filters one local natural day. If the value cannot be parsed by `new Date(...)`, the CLI falls back to the most recent 20 runs. `kweaver dataflow logs` defaults to summary output; add `--detail` to print indented `input` and `output` payloads.
|
|
186
195
|
|
|
196
|
+
### Vega `sql` CLI examples
|
|
197
|
+
|
|
198
|
+
Direct SQL against catalog-backed resources (`POST /api/vega-backend/v1/resources/query`). In SQL, use **`{{<resource_id>}}`** or **`{{.<resource_id>}}`** (Vega resource id from `vega resource list` / `get`) so the backend resolves the physical table and connector. `--resource-type` accepts the connector type of the target data source (run `kweaver vega connector-type list` to see available types). In simple mode, **quote the entire `--query` value** so the shell does not treat `{` / `}` specially.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Simple mode (recommended): avoid JSON-escaping the query string
|
|
202
|
+
kweaver vega sql --resource-type mysql --query "SELECT * FROM {{res-1}} LIMIT 5"
|
|
203
|
+
|
|
204
|
+
# Advanced mode: full JSON body (optional fields like query_timeout, stream_size, OpenSearch DSL object)
|
|
205
|
+
kweaver vega sql -d '{"resource_type":"mysql","query":"SELECT * FROM {{res-1}} LIMIT 5"}'
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
If both `-d` and `--query` / `--resource-type` are present, **only `-d` is used**.
|
|
209
|
+
|
|
187
210
|
**No-auth platforms:** If OAuth is not enabled, use `kweaver auth <url> --no-auth` (or run a normal `auth login`; a **404** on `POST /oauth2/clients` switches to no-auth automatically). Credentials are still saved under `~/.kweaver/` and work with `auth use` / `auth list`. Optional: `KWEAVER_NO_AUTH=1` with `KWEAVER_BASE_URL` when no token env is set. SDK: `new KWeaverClient({ baseUrl, auth: false })` or `kweaver.configure({ baseUrl, auth: false })`.
|
|
188
211
|
|
|
189
212
|
## Environment Variables
|
package/README.zh.md
CHANGED
|
@@ -119,6 +119,19 @@ const queryRows = await client.dataviews.query(viewId, {
|
|
|
119
119
|
needTotal: true,
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
+
// Vega — 可观测性与查询
|
|
123
|
+
const catalogs = await client.vega.listCatalogs();
|
|
124
|
+
const health = await client.vega.health();
|
|
125
|
+
// 结构化查询 — POST /api/vega-backend/v1/query/execute(body 为 JSON 字符串)
|
|
126
|
+
const structured = await client.vega.executeQuery(
|
|
127
|
+
JSON.stringify({ tables: [{ resource_id: "res-1" }], output_fields: ["*"], limit: 20 }),
|
|
128
|
+
);
|
|
129
|
+
// 直连 SQL 或 OpenSearch DSL — POST /api/vega-backend/v1/resources/query
|
|
130
|
+
// 使用 {{resource_id}} 占位符以路由到正确的 catalog connector
|
|
131
|
+
const rows = await client.vega.sqlQuery(
|
|
132
|
+
JSON.stringify({ query: "SELECT * FROM {{res-1}} LIMIT 5", resource_type: "mysql" }),
|
|
133
|
+
);
|
|
134
|
+
|
|
122
135
|
// Context Loader(通过 MCP 对 BKN 做语义搜索)
|
|
123
136
|
const cl = client.contextLoader(mcpUrl, "bkn-id");
|
|
124
137
|
const results = await cl.search({ query: "高血压 治疗" });
|
|
@@ -149,6 +162,7 @@ kweaver bkn action-execution get
|
|
|
149
162
|
kweaver bkn action-log list/get/cancel
|
|
150
163
|
kweaver agent list/get/chat/sessions/history
|
|
151
164
|
kweaver skill list/market/get/register/status/delete/content/read-file/download/install
|
|
165
|
+
kweaver vega health|stats|inspect|sql|catalog|resource|connector-type
|
|
152
166
|
kweaver context-loader config set/use/list/show
|
|
153
167
|
kweaver context-loader kn-search/query-object-instance/...
|
|
154
168
|
kweaver call <path> [-X METHOD] [-d BODY] [-H header]
|
|
@@ -168,6 +182,20 @@ kweaver dataflow logs <dagId> <instanceId> --detail
|
|
|
168
182
|
|
|
169
183
|
`kweaver dataflow runs --since` 会按本地自然日过滤;如果参数无法被 `new Date(...)` 解析,CLI 会回退到最近 20 条运行记录。`kweaver dataflow logs` 默认输出摘要;加上 `--detail` 会打印带缩进的 `input` 和 `output` 载荷。
|
|
170
184
|
|
|
185
|
+
### Vega `sql` CLI 示例
|
|
186
|
+
|
|
187
|
+
对 Catalog 资源执行直连 SQL(`POST /api/vega-backend/v1/resources/query`)。SQL 中使用 **`{{<resource_id>}}`** 或 **`{{.<resource_id>}}`**(资源 id 来自 `vega resource list` / `get`),后端据此解析物理表与 connector。`--resource-type` 为目标数据源的连接器类型,可通过 `kweaver vega connector-type list` 查看。简单模式下请**用引号包住整个 `--query` 参数**,避免 shell 对花括号做特殊处理。
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# 简单模式(推荐):避免在 JSON 里转义整段 SQL
|
|
191
|
+
kweaver vega sql --resource-type mysql --query "SELECT * FROM {{res-1}} LIMIT 5"
|
|
192
|
+
|
|
193
|
+
# 高级模式:完整 JSON(可带 query_timeout、stream_size,或 OpenSearch DSL 对象等)
|
|
194
|
+
kweaver vega sql -d '{"resource_type":"mysql","query":"SELECT * FROM {{res-1}} LIMIT 5"}'
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
若同时提供 `-d` 与 `--query` / `--resource-type`,**仅以 `-d` 为准**。
|
|
198
|
+
|
|
171
199
|
**无 OAuth 的平台:** 使用 `kweaver auth <url> --no-auth`,或照常 `auth login`;若 `POST /oauth2/clients` 返回 **404**,CLI 会提示并自动保存为 no-auth。凭据仍在 `~/.kweaver/`,可用 `auth use` / `auth list` 切换。可选环境变量 `KWEAVER_NO_AUTH=1`(未设置 `KWEAVER_TOKEN` 时)配合 `KWEAVER_BASE_URL`。SDK:`new KWeaverClient({ baseUrl, auth: false })` 或 `kweaver.configure({ baseUrl, auth: false })`。
|
|
172
200
|
|
|
173
201
|
## 环境变量
|
package/dist/api/skills.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type SkillStatus = "unpublish" | "published" | "offline";
|
|
2
2
|
export type SkillFileType = "zip" | "content";
|
|
3
3
|
export interface SkillSummary {
|
|
4
|
-
|
|
4
|
+
id: string;
|
|
5
5
|
name: string;
|
|
6
6
|
description?: string;
|
|
7
7
|
version?: string;
|
|
@@ -26,20 +26,20 @@ export interface SkillFileSummary {
|
|
|
26
26
|
mime_type?: string;
|
|
27
27
|
}
|
|
28
28
|
export interface SkillContentIndex {
|
|
29
|
-
|
|
29
|
+
id: string;
|
|
30
30
|
url: string;
|
|
31
31
|
files: SkillFileSummary[];
|
|
32
32
|
status?: SkillStatus;
|
|
33
33
|
}
|
|
34
34
|
export interface SkillFileReadResult {
|
|
35
|
-
|
|
35
|
+
id: string;
|
|
36
36
|
rel_path: string;
|
|
37
37
|
url: string;
|
|
38
38
|
mime_type?: string;
|
|
39
39
|
file_type?: string;
|
|
40
40
|
}
|
|
41
41
|
export interface RegisterSkillResult {
|
|
42
|
-
|
|
42
|
+
id: string;
|
|
43
43
|
name: string;
|
|
44
44
|
description?: string;
|
|
45
45
|
version?: string;
|
|
@@ -47,11 +47,11 @@ export interface RegisterSkillResult {
|
|
|
47
47
|
files?: string[];
|
|
48
48
|
}
|
|
49
49
|
export interface DeleteSkillResult {
|
|
50
|
-
|
|
50
|
+
id: string;
|
|
51
51
|
deleted: boolean;
|
|
52
52
|
}
|
|
53
53
|
export interface UpdateSkillStatusResult {
|
|
54
|
-
|
|
54
|
+
id: string;
|
|
55
55
|
status: SkillStatus;
|
|
56
56
|
}
|
|
57
57
|
export interface SkillListResult {
|
package/dist/api/skills.js
CHANGED
|
@@ -18,6 +18,20 @@ function unwrapEnvelope(raw) {
|
|
|
18
18
|
}
|
|
19
19
|
return parsed;
|
|
20
20
|
}
|
|
21
|
+
/** Rename `skill_id` → `id` for consistent output with other modules. */
|
|
22
|
+
function normalizeSkillId(obj) {
|
|
23
|
+
if (!obj || typeof obj !== "object")
|
|
24
|
+
return obj;
|
|
25
|
+
if (Array.isArray(obj))
|
|
26
|
+
return obj.map(normalizeSkillId);
|
|
27
|
+
const record = obj;
|
|
28
|
+
const out = {};
|
|
29
|
+
for (const [key, value] of Object.entries(record)) {
|
|
30
|
+
const newKey = key === "skill_id" ? "id" : key;
|
|
31
|
+
out[newKey] = typeof value === "object" ? normalizeSkillId(value) : value;
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
21
35
|
function appendCommonListParams(url, opts) {
|
|
22
36
|
if (opts.page !== undefined)
|
|
23
37
|
url.searchParams.set("page", String(opts.page));
|
|
@@ -60,23 +74,23 @@ export async function listSkills(options) {
|
|
|
60
74
|
if (options.createUser)
|
|
61
75
|
url.searchParams.set("create_user", options.createUser);
|
|
62
76
|
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
63
|
-
return unwrapEnvelope(body);
|
|
77
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
64
78
|
}
|
|
65
79
|
export async function listSkillMarket(options) {
|
|
66
80
|
const url = new URL(buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/market`));
|
|
67
81
|
appendCommonListParams(url, options);
|
|
68
82
|
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
69
|
-
return unwrapEnvelope(body);
|
|
83
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
70
84
|
}
|
|
71
85
|
export async function getSkill(options) {
|
|
72
86
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}`);
|
|
73
87
|
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
74
|
-
return unwrapEnvelope(body);
|
|
88
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
75
89
|
}
|
|
76
90
|
export async function deleteSkill(options) {
|
|
77
91
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}`);
|
|
78
92
|
const { body } = await fetchTextOrThrow(url, { method: "DELETE", headers: baseHeaders(options) });
|
|
79
|
-
return unwrapEnvelope(body);
|
|
93
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
80
94
|
}
|
|
81
95
|
export async function updateSkillStatus(options) {
|
|
82
96
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/status`);
|
|
@@ -85,7 +99,7 @@ export async function updateSkillStatus(options) {
|
|
|
85
99
|
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
86
100
|
body: JSON.stringify({ status: options.status }),
|
|
87
101
|
});
|
|
88
|
-
return unwrapEnvelope(body);
|
|
102
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
89
103
|
}
|
|
90
104
|
export async function registerSkillContent(options) {
|
|
91
105
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills`);
|
|
@@ -102,7 +116,7 @@ export async function registerSkillContent(options) {
|
|
|
102
116
|
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
103
117
|
body: JSON.stringify(payload),
|
|
104
118
|
});
|
|
105
|
-
return unwrapEnvelope(body);
|
|
119
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
106
120
|
}
|
|
107
121
|
export async function registerSkillZip(options) {
|
|
108
122
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills`);
|
|
@@ -118,12 +132,12 @@ export async function registerSkillZip(options) {
|
|
|
118
132
|
headers: baseHeaders(options),
|
|
119
133
|
body: form,
|
|
120
134
|
});
|
|
121
|
-
return unwrapEnvelope(body);
|
|
135
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
122
136
|
}
|
|
123
137
|
export async function getSkillContentIndex(options) {
|
|
124
138
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/content`);
|
|
125
139
|
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
126
|
-
return unwrapEnvelope(body);
|
|
140
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
127
141
|
}
|
|
128
142
|
export async function fetchSkillContent(options) {
|
|
129
143
|
const index = await getSkillContentIndex(options);
|
|
@@ -137,7 +151,7 @@ export async function readSkillFile(options) {
|
|
|
137
151
|
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
138
152
|
body: JSON.stringify({ rel_path: options.relPath }),
|
|
139
153
|
});
|
|
140
|
-
return unwrapEnvelope(body);
|
|
154
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
141
155
|
}
|
|
142
156
|
export async function fetchSkillFile(options) {
|
|
143
157
|
const file = await readSkillFile(options);
|
package/dist/api/vega.d.ts
CHANGED
|
@@ -220,6 +220,14 @@ export interface ExecuteVegaQueryOptions {
|
|
|
220
220
|
businessDomain?: string;
|
|
221
221
|
}
|
|
222
222
|
export declare function executeVegaQuery(options: ExecuteVegaQueryOptions): Promise<string>;
|
|
223
|
+
export interface VegaSQLQueryOptions {
|
|
224
|
+
baseUrl: string;
|
|
225
|
+
accessToken: string;
|
|
226
|
+
body: string;
|
|
227
|
+
businessDomain?: string;
|
|
228
|
+
}
|
|
229
|
+
/** POST /api/vega-backend/v1/resources/query — direct SQL (or OpenSearch DSL) against catalog-backed resources. */
|
|
230
|
+
export declare function vegaSQLQuery(options: VegaSQLQueryOptions): Promise<string>;
|
|
223
231
|
export interface ListAllVegaResourcesOptions {
|
|
224
232
|
baseUrl: string;
|
|
225
233
|
accessToken: string;
|
|
@@ -227,4 +235,6 @@ export interface ListAllVegaResourcesOptions {
|
|
|
227
235
|
offset?: number;
|
|
228
236
|
businessDomain?: string;
|
|
229
237
|
}
|
|
238
|
+
/** List all Vega resources (no catalog filter). Uses GET /resources — not /resources/list, which
|
|
239
|
+
* conflicts with GET /resources/{id} on some gateways (path segment "list" is treated as an id). */
|
|
230
240
|
export declare function listAllVegaResources(options: ListAllVegaResourcesOptions): Promise<string>;
|
package/dist/api/vega.js
CHANGED
|
@@ -458,20 +458,33 @@ export async function executeVegaQuery(options) {
|
|
|
458
458
|
throw new HttpError(response.status, response.statusText, body);
|
|
459
459
|
return body;
|
|
460
460
|
}
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
/** POST /api/vega-backend/v1/resources/query — direct SQL (or OpenSearch DSL) against catalog-backed resources. */
|
|
462
|
+
export async function vegaSQLQuery(options) {
|
|
463
|
+
const { baseUrl, accessToken, body: requestBody, businessDomain = "bd_public" } = options;
|
|
463
464
|
const base = baseUrl.replace(/\/+$/, "");
|
|
464
|
-
const url =
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
465
|
+
const url = `${base}${VEGA_BASE}/resources/query`;
|
|
466
|
+
const response = await fetch(url, {
|
|
467
|
+
method: "POST",
|
|
468
|
+
headers: {
|
|
469
|
+
...buildHeaders(accessToken, businessDomain),
|
|
470
|
+
"content-type": "application/json",
|
|
471
|
+
},
|
|
472
|
+
body: requestBody,
|
|
472
473
|
});
|
|
473
474
|
const body = await response.text();
|
|
474
475
|
if (!response.ok)
|
|
475
476
|
throw new HttpError(response.status, response.statusText, body);
|
|
476
477
|
return body;
|
|
477
478
|
}
|
|
479
|
+
/** List all Vega resources (no catalog filter). Uses GET /resources — not /resources/list, which
|
|
480
|
+
* conflicts with GET /resources/{id} on some gateways (path segment "list" is treated as an id). */
|
|
481
|
+
export async function listAllVegaResources(options) {
|
|
482
|
+
const { baseUrl, accessToken, limit, offset, businessDomain = "bd_public" } = options;
|
|
483
|
+
return listVegaResources({
|
|
484
|
+
baseUrl,
|
|
485
|
+
accessToken,
|
|
486
|
+
limit,
|
|
487
|
+
offset,
|
|
488
|
+
businessDomain,
|
|
489
|
+
});
|
|
490
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -102,6 +102,7 @@ Usage:
|
|
|
102
102
|
kweaver vega health|stats|inspect
|
|
103
103
|
kweaver vega catalog list|get|health|test-connection|discover|resources [options]
|
|
104
104
|
kweaver vega resource list|get|query [options]
|
|
105
|
+
kweaver vega query execute|sql [options]
|
|
105
106
|
kweaver vega connector-type list|get [options]
|
|
106
107
|
|
|
107
108
|
kweaver context-loader config set|use|list|remove|show [options]
|
|
@@ -128,7 +129,7 @@ Commands:
|
|
|
128
129
|
object-type, relation-type, subgraph, action-type, action-execution, action-log)
|
|
129
130
|
config Per-platform configuration (business domain)
|
|
130
131
|
skill Skill registry and market (register, search, progressive read, download/install)
|
|
131
|
-
vega Vega observability (catalog, resource, connector-type, health/stats/inspect)
|
|
132
|
+
vega Vega observability (catalog, resource, query/sql, connector-type, health/stats/inspect)
|
|
132
133
|
context-loader Context-loader MCP (config, tools, resources, prompts, kn-search, query-*, etc.)
|
|
133
134
|
help Show this message`);
|
|
134
135
|
}
|
package/dist/commands/agent.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/** Build llm_config with valid defaults for fields that mf-model-api validates. */
|
|
2
|
+
export declare function buildLlmConfig(id: string, name: string, maxTokens: number): Record<string, unknown>;
|
|
3
|
+
/** Resolve LLM model name from mf-model-manager API by model ID. Falls back to llmId on failure. */
|
|
4
|
+
export declare function resolveLlmName(options: {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
accessToken: string;
|
|
7
|
+
llmId: string;
|
|
8
|
+
businessDomain?: string;
|
|
9
|
+
}): Promise<string>;
|
|
1
10
|
export interface AgentListOptions {
|
|
2
11
|
name: string;
|
|
3
12
|
offset: number;
|
package/dist/commands/agent.js
CHANGED
|
@@ -7,6 +7,44 @@ import { formatCallOutput } from "./call.js";
|
|
|
7
7
|
import { resolveBusinessDomain } from "../config/store.js";
|
|
8
8
|
import { promises as fs } from "fs";
|
|
9
9
|
import { join, dirname, basename, extname } from "path";
|
|
10
|
+
import { buildHeaders } from "../api/headers.js";
|
|
11
|
+
/** Build llm_config with valid defaults for fields that mf-model-api validates. */
|
|
12
|
+
export function buildLlmConfig(id, name, maxTokens) {
|
|
13
|
+
return {
|
|
14
|
+
id,
|
|
15
|
+
name,
|
|
16
|
+
max_tokens: maxTokens,
|
|
17
|
+
temperature: 0.7,
|
|
18
|
+
top_p: 1,
|
|
19
|
+
top_k: 1,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Resolve LLM model name from mf-model-manager API by model ID. Falls back to llmId on failure. */
|
|
23
|
+
export async function resolveLlmName(options) {
|
|
24
|
+
const { baseUrl, accessToken, llmId, businessDomain = "bd_public" } = options;
|
|
25
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
26
|
+
const url = `${base}/api/mf-model-manager/v1/llm/list?page=1&size=50`;
|
|
27
|
+
try {
|
|
28
|
+
const response = await fetch(url, {
|
|
29
|
+
method: "GET",
|
|
30
|
+
headers: buildHeaders(accessToken, businessDomain),
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok)
|
|
33
|
+
return llmId;
|
|
34
|
+
const body = (await response.json());
|
|
35
|
+
const items = (body.data ?? body.entries ?? []);
|
|
36
|
+
const match = items.find((m) => String(m.model_id ?? m.id) === llmId);
|
|
37
|
+
if (match) {
|
|
38
|
+
const name = match.model_name ?? match.name;
|
|
39
|
+
if (typeof name === "string" && name)
|
|
40
|
+
return name;
|
|
41
|
+
}
|
|
42
|
+
return llmId;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return llmId;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
10
48
|
/**
|
|
11
49
|
* 生成带时间戳的文件路径
|
|
12
50
|
* @param path 用户提供的路径
|
|
@@ -480,7 +518,7 @@ Subcommands:
|
|
|
480
518
|
chat <agent_id> -m "message" Send a single message (non-interactive)
|
|
481
519
|
sessions <agent_id> List all conversations for an agent
|
|
482
520
|
history <agent_id> <conversation_id> Show message history for a conversation
|
|
483
|
-
trace <conversation_id>
|
|
521
|
+
trace <agent_id> <conversation_id> Get trace data for a conversation`);
|
|
484
522
|
return Promise.resolve(0);
|
|
485
523
|
}
|
|
486
524
|
const dispatch = async () => {
|
|
@@ -1144,9 +1182,6 @@ Optional:
|
|
|
1144
1182
|
output: { default_format: "markdown" },
|
|
1145
1183
|
system_prompt: systemPrompt,
|
|
1146
1184
|
};
|
|
1147
|
-
if (llmId) {
|
|
1148
|
-
config.llms = [{ is_default: true, llm_config: { id: llmId, name: llmId, max_tokens: llmMaxTokens } }];
|
|
1149
|
-
}
|
|
1150
1185
|
}
|
|
1151
1186
|
const payload = {
|
|
1152
1187
|
name,
|
|
@@ -1161,6 +1196,11 @@ Optional:
|
|
|
1161
1196
|
payload.key = key;
|
|
1162
1197
|
try {
|
|
1163
1198
|
const token = await ensureValidToken();
|
|
1199
|
+
// Resolve LLM model name from model-factory before creating agent
|
|
1200
|
+
if (llmId && !configStr) {
|
|
1201
|
+
const llmName = await resolveLlmName({ baseUrl: token.baseUrl, accessToken: token.accessToken, llmId, businessDomain });
|
|
1202
|
+
config.llms = [{ is_default: true, llm_config: buildLlmConfig(llmId, llmName, llmMaxTokens) }];
|
|
1203
|
+
}
|
|
1164
1204
|
const body = await createAgent({
|
|
1165
1205
|
baseUrl: token.baseUrl,
|
|
1166
1206
|
accessToken: token.accessToken,
|
|
@@ -1185,8 +1185,13 @@ query/execute: Query or execute actions. execute has side effects - only use whe
|
|
|
1185
1185
|
console.error("Usage: kweaver bkn action-type create <kn-id> '<json>'");
|
|
1186
1186
|
return 1;
|
|
1187
1187
|
}
|
|
1188
|
+
// Wrap in {"entries": [...]} if needed (ontology-manager expects this envelope)
|
|
1189
|
+
const entry = JSON.parse(bodyJson);
|
|
1190
|
+
const wrapped = entry && typeof entry === "object" && "entries" in entry
|
|
1191
|
+
? bodyJson
|
|
1192
|
+
: JSON.stringify({ entries: Array.isArray(entry) ? entry : [entry] });
|
|
1188
1193
|
const token = await ensureValidToken();
|
|
1189
|
-
const result = await createActionTypes({ baseUrl: token.baseUrl, accessToken: token.accessToken, knId, body:
|
|
1194
|
+
const result = await createActionTypes({ baseUrl: token.baseUrl, accessToken: token.accessToken, knId, body: wrapped, businessDomain: parsed.businessDomain });
|
|
1190
1195
|
console.log(formatCallOutput(result, parsed.pretty));
|
|
1191
1196
|
return 0;
|
|
1192
1197
|
}
|
|
@@ -6,6 +6,7 @@ import yargs from "yargs";
|
|
|
6
6
|
import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/oauth.js";
|
|
7
7
|
import { resolveBusinessDomain } from "../config/store.js";
|
|
8
8
|
import { getDataflowLogsPage, listDataflowRuns, listDataflows, runDataflowWithFile, runDataflowWithRemoteUrl, } from "../api/dataflow2.js";
|
|
9
|
+
import { createDataflow } from "../api/dataflow.js";
|
|
9
10
|
function renderTable(rows) {
|
|
10
11
|
if (rows.length === 0)
|
|
11
12
|
return "";
|
|
@@ -101,16 +102,47 @@ export async function runDataflowCommand(args) {
|
|
|
101
102
|
.fail((message, error) => {
|
|
102
103
|
throw error ?? new Error(message);
|
|
103
104
|
})
|
|
104
|
-
.command("
|
|
105
|
+
.command("create <json>", "Create a new dataflow (DAG) from a JSON definition", (command) => command
|
|
106
|
+
.positional("json", {
|
|
107
|
+
type: "string",
|
|
108
|
+
describe: "JSON body string or @file-path to read from file",
|
|
109
|
+
})
|
|
110
|
+
.option("biz-domain", { alias: "bd", type: "string" }), async (argv) => {
|
|
111
|
+
exitCode = await with401RefreshRetry(async () => {
|
|
112
|
+
const base = await requireTokenAndBusinessDomain(argv.bizDomain);
|
|
113
|
+
let raw = argv.json;
|
|
114
|
+
if (raw.startsWith("@")) {
|
|
115
|
+
const filePath = raw.slice(1);
|
|
116
|
+
await access(filePath, constants.R_OK);
|
|
117
|
+
raw = (await readFile(filePath, "utf8")).toString();
|
|
118
|
+
}
|
|
119
|
+
const body = JSON.parse(raw);
|
|
120
|
+
const dagId = await createDataflow({ ...base, body });
|
|
121
|
+
console.log(JSON.stringify({ id: dagId }, null, 2));
|
|
122
|
+
return 0;
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
.command("list", "List all dataflows", (command) => command
|
|
126
|
+
.option("biz-domain", {
|
|
105
127
|
alias: "bd",
|
|
106
128
|
type: "string",
|
|
129
|
+
})
|
|
130
|
+
.option("table", {
|
|
131
|
+
type: "boolean",
|
|
132
|
+
default: false,
|
|
133
|
+
describe: "Output as human-readable table instead of JSON",
|
|
107
134
|
}), async (argv) => {
|
|
108
135
|
exitCode = await with401RefreshRetry(async () => {
|
|
109
136
|
const base = await requireTokenAndBusinessDomain(argv.bizDomain);
|
|
110
137
|
const body = await listDataflows(base);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
138
|
+
if (argv.table) {
|
|
139
|
+
const table = renderTable(buildListTableRows(body.dags));
|
|
140
|
+
if (table) {
|
|
141
|
+
console.log(table);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.log(JSON.stringify(body, null, 2));
|
|
114
146
|
}
|
|
115
147
|
return 0;
|
|
116
148
|
});
|
|
@@ -160,6 +192,11 @@ export async function runDataflowCommand(args) {
|
|
|
160
192
|
.command("runs <dagId>", "List run records for one dataflow", (command) => command
|
|
161
193
|
.positional("dagId", { type: "string" })
|
|
162
194
|
.option("since", { type: "string" })
|
|
195
|
+
.option("table", {
|
|
196
|
+
type: "boolean",
|
|
197
|
+
default: false,
|
|
198
|
+
describe: "Output as human-readable table instead of JSON",
|
|
199
|
+
})
|
|
163
200
|
.option("biz-domain", { alias: "bd", type: "string" }), async (argv) => {
|
|
164
201
|
exitCode = await with401RefreshRetry(async () => {
|
|
165
202
|
const base = await requireTokenAndBusinessDomain(argv.bizDomain);
|
|
@@ -203,9 +240,14 @@ export async function runDataflowCommand(args) {
|
|
|
203
240
|
results = results.concat(next.results);
|
|
204
241
|
}
|
|
205
242
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
243
|
+
if (argv.table) {
|
|
244
|
+
const table = renderTable(buildRunTableRows(results));
|
|
245
|
+
if (table) {
|
|
246
|
+
console.log(table);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
console.log(JSON.stringify(results, null, 2));
|
|
209
251
|
}
|
|
210
252
|
return 0;
|
|
211
253
|
});
|
package/dist/commands/skill.js
CHANGED
|
@@ -23,8 +23,8 @@ function printSkillHelp(subcommand) {
|
|
|
23
23
|
[--source src] [--extend-info json] [-bd value] [--pretty|--compact]`);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
if (subcommand === "status") {
|
|
27
|
-
console.log("kweaver skill status <skill-id> <unpublish|published|offline> [-bd value] [--pretty|--compact]");
|
|
26
|
+
if (subcommand === "set-status" || subcommand === "status") {
|
|
27
|
+
console.log("kweaver skill set-status <skill-id> <unpublish|published|offline> [-bd value] [--pretty|--compact]");
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
if (subcommand === "delete") {
|
|
@@ -54,7 +54,7 @@ Subcommands:
|
|
|
54
54
|
market [--name kw] [--source src] [--page N] [--page-size N] [-bd value]
|
|
55
55
|
get <skill-id> [-bd value]
|
|
56
56
|
register --content-file <path> | --zip-file <path> [--source src] [--extend-info json]
|
|
57
|
-
status <skill-id> <unpublish|published|offline> [-bd value]
|
|
57
|
+
set-status <skill-id> <unpublish|published|offline> [-bd value]
|
|
58
58
|
delete <skill-id> [-y] [-bd value]
|
|
59
59
|
content <skill-id> [--raw] [--output file] [-bd value]
|
|
60
60
|
read-file <skill-id> <rel-path> [--raw] [--output file] [-bd value]
|
|
@@ -419,7 +419,7 @@ export async function runSkillCommand(args) {
|
|
|
419
419
|
return 0;
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
if (subcommand === "status") {
|
|
422
|
+
if (subcommand === "set-status" || subcommand === "status") {
|
|
423
423
|
const opts = parseStatusArgs(rest);
|
|
424
424
|
const result = await updateSkillStatus({ ...token, ...opts });
|
|
425
425
|
console.log(format(result, opts.pretty));
|
package/dist/commands/vega.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createInterface } from "node:readline";
|
|
2
2
|
import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/oauth.js";
|
|
3
|
-
import { vegaHealth, listVegaCatalogs, getVegaCatalog, createVegaCatalog, updateVegaCatalog, deleteVegaCatalogs, vegaCatalogHealthStatus, testVegaCatalogConnection, discoverVegaCatalog, listVegaCatalogResources, listVegaResources, getVegaResource, queryVegaResourceData, createVegaResource, updateVegaResource, deleteVegaResources, listVegaConnectorTypes, getVegaConnectorType, registerVegaConnectorType, updateVegaConnectorType, deleteVegaConnectorType, setVegaConnectorTypeEnabled, createVegaDatasetDocs, updateVegaDatasetDocs, deleteVegaDatasetDocs, deleteVegaDatasetDocsQuery, buildVegaDataset, getVegaDatasetBuildStatus, executeVegaQuery, listAllVegaResources, } from "../api/vega.js";
|
|
3
|
+
import { vegaHealth, listVegaCatalogs, getVegaCatalog, createVegaCatalog, updateVegaCatalog, deleteVegaCatalogs, vegaCatalogHealthStatus, testVegaCatalogConnection, discoverVegaCatalog, listVegaCatalogResources, listVegaResources, getVegaResource, queryVegaResourceData, createVegaResource, updateVegaResource, deleteVegaResources, listVegaConnectorTypes, getVegaConnectorType, registerVegaConnectorType, updateVegaConnectorType, deleteVegaConnectorType, setVegaConnectorTypeEnabled, createVegaDatasetDocs, updateVegaDatasetDocs, deleteVegaDatasetDocs, deleteVegaDatasetDocsQuery, buildVegaDataset, getVegaDatasetBuildStatus, executeVegaQuery, vegaSQLQuery, listAllVegaResources, } from "../api/vega.js";
|
|
4
4
|
import { formatCallOutput } from "./call.js";
|
|
5
5
|
import { resolveBusinessDomain } from "../config/store.js";
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
@@ -35,7 +35,9 @@ Subcommands:
|
|
|
35
35
|
dataset delete-docs-query <resource-id> -d <filter-json>
|
|
36
36
|
dataset build <resource-id> [--mode full|incremental|realtime]
|
|
37
37
|
dataset build-status <resource-id> <task-id>
|
|
38
|
-
query execute -d <json>
|
|
38
|
+
query execute -d <json> Structured query (tables, joins, filters)
|
|
39
|
+
sql --resource-type <t> --query <sql> Direct SQL / DSL; use {{<resource_id>}} in SQL (quoted)
|
|
40
|
+
sql -d <json> Same API with full JSON body (advanced)
|
|
39
41
|
connector-type list List connector types
|
|
40
42
|
connector-type get <type> Get connector type details
|
|
41
43
|
connector-type register -d <json> Register a new connector type
|
|
@@ -103,6 +105,8 @@ export async function runVegaCommand(args) {
|
|
|
103
105
|
return runVegaDatasetCommand(rest);
|
|
104
106
|
if (subcommand === "query")
|
|
105
107
|
return runVegaQueryCommand(rest);
|
|
108
|
+
if (subcommand === "sql")
|
|
109
|
+
return runVegaSql(rest);
|
|
106
110
|
if (subcommand === "connector-type")
|
|
107
111
|
return runVegaConnectorTypeCommand(rest);
|
|
108
112
|
return Promise.resolve(-1);
|
|
@@ -1321,6 +1325,101 @@ Options:
|
|
|
1321
1325
|
return 0;
|
|
1322
1326
|
}
|
|
1323
1327
|
// ---------------------------------------------------------------------------
|
|
1328
|
+
// sql (POST /resources/query)
|
|
1329
|
+
// ---------------------------------------------------------------------------
|
|
1330
|
+
async function runVegaSql(args) {
|
|
1331
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
1332
|
+
console.log(`kweaver vega sql --resource-type <type> --query "<sql-or-dsl>"
|
|
1333
|
+
kweaver vega sql -d <json>
|
|
1334
|
+
|
|
1335
|
+
POST /api/vega-backend/v1/resources/query — execute SQL (MySQL/MariaDB/PostgreSQL) or OpenSearch DSL.
|
|
1336
|
+
|
|
1337
|
+
Simple mode (no JSON escaping for query + type):
|
|
1338
|
+
--resource-type <t> Required with --query unless using -d
|
|
1339
|
+
--query <string> One shell argument: the full SQL (or DSL string). Always quote it.
|
|
1340
|
+
|
|
1341
|
+
Advanced mode (full request body, optional fields):
|
|
1342
|
+
-d, --data <json> Raw JSON body. When present, this mode is used and any --query / --resource-type are ignored.
|
|
1343
|
+
|
|
1344
|
+
Resource placeholders (how to reference Vega tables in SQL):
|
|
1345
|
+
{{<resource_id>}} Required token form: double braces around the Vega resource id (from vega resource list / get).
|
|
1346
|
+
{{.<resource_id>}} Alternate form with a dot after {{ ; same replacement and routing.
|
|
1347
|
+
|
|
1348
|
+
The backend swaps each placeholder for that resource's physical SourceIdentifier and picks the catalog connector.
|
|
1349
|
+
Without at least one placeholder, queries often fail (e.g. connector config is incomplete) unless a default connector exists.
|
|
1350
|
+
|
|
1351
|
+
Shell (simple mode) — wrap the whole SQL so braces are not interpreted by the shell:
|
|
1352
|
+
kweaver vega sql --resource-type mysql --query "SELECT * FROM {{abc123xyz}} LIMIT 5"
|
|
1353
|
+
|
|
1354
|
+
Shell (-d mode) — placeholders live inside the JSON string value; use single quotes around the JSON so inner double quotes work:
|
|
1355
|
+
kweaver vega sql -d '{"resource_type":"mysql","query":"SELECT * FROM {{abc123xyz}} LIMIT 5"}'
|
|
1356
|
+
|
|
1357
|
+
Body fields (JSON / simple mode mapping):
|
|
1358
|
+
query (required) SQL string or OpenSearch DSL object
|
|
1359
|
+
resource_type (required) e.g. mysql, mariadb, postgresql, opensearch (see vega connector-type list)
|
|
1360
|
+
stream_size optional batch size for streaming (100–10000, default 10000)
|
|
1361
|
+
query_timeout optional seconds (1–3600, default 60)
|
|
1362
|
+
query_id optional cursor session id
|
|
1363
|
+
|
|
1364
|
+
Do not use --type; use --resource-type.
|
|
1365
|
+
|
|
1366
|
+
Common flags:
|
|
1367
|
+
-bd, --biz-domain <s> Business domain (default: bd_public)
|
|
1368
|
+
--pretty Pretty-print JSON (default)`);
|
|
1369
|
+
return 0;
|
|
1370
|
+
}
|
|
1371
|
+
let data;
|
|
1372
|
+
let query;
|
|
1373
|
+
let resourceType;
|
|
1374
|
+
const { remaining, businessDomain, pretty } = parseCommonFlags(args);
|
|
1375
|
+
for (let i = 0; i < remaining.length; i += 1) {
|
|
1376
|
+
const arg = remaining[i];
|
|
1377
|
+
if (arg === "--type") {
|
|
1378
|
+
console.error("Use --resource-type instead of --type (e.g. --resource-type mysql).");
|
|
1379
|
+
return 1;
|
|
1380
|
+
}
|
|
1381
|
+
if ((arg === "-d" || arg === "--data") && remaining[i + 1]) {
|
|
1382
|
+
data = remaining[++i];
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1385
|
+
if (arg === "--query" && remaining[i + 1]) {
|
|
1386
|
+
query = remaining[++i];
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
if (arg === "--resource-type" && remaining[i + 1]) {
|
|
1390
|
+
resourceType = remaining[++i];
|
|
1391
|
+
continue;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
let requestBody;
|
|
1395
|
+
if (data !== undefined) {
|
|
1396
|
+
try {
|
|
1397
|
+
JSON.parse(data);
|
|
1398
|
+
}
|
|
1399
|
+
catch {
|
|
1400
|
+
console.error(`Invalid JSON: ${data}`);
|
|
1401
|
+
return 1;
|
|
1402
|
+
}
|
|
1403
|
+
requestBody = data;
|
|
1404
|
+
}
|
|
1405
|
+
else {
|
|
1406
|
+
if (!query || !resourceType) {
|
|
1407
|
+
console.error("Usage: kweaver vega sql --resource-type <type> --query \"<sql-or-dsl>\"\n kweaver vega sql -d <json>");
|
|
1408
|
+
return 1;
|
|
1409
|
+
}
|
|
1410
|
+
requestBody = JSON.stringify({ query, resource_type: resourceType });
|
|
1411
|
+
}
|
|
1412
|
+
const token = await ensureValidToken();
|
|
1413
|
+
const body = await vegaSQLQuery({
|
|
1414
|
+
baseUrl: token.baseUrl,
|
|
1415
|
+
accessToken: token.accessToken,
|
|
1416
|
+
body: requestBody,
|
|
1417
|
+
businessDomain,
|
|
1418
|
+
});
|
|
1419
|
+
console.log(formatCallOutput(body, pretty));
|
|
1420
|
+
return 0;
|
|
1421
|
+
}
|
|
1422
|
+
// ---------------------------------------------------------------------------
|
|
1324
1423
|
// Connector-type router
|
|
1325
1424
|
// ---------------------------------------------------------------------------
|
|
1326
1425
|
async function runVegaConnectorTypeCommand(args) {
|
package/dist/resources/vega.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare class VegaResource {
|
|
|
47
47
|
buildDataset(id: string, mode?: string): Promise<unknown>;
|
|
48
48
|
getDatasetBuildStatus(id: string, taskId: string): Promise<unknown>;
|
|
49
49
|
executeQuery(body: string): Promise<unknown>;
|
|
50
|
+
/** POST /resources/query — direct SQL or OpenSearch DSL (see kweaver vega sql --help). */
|
|
51
|
+
sqlQuery(body: string): Promise<unknown>;
|
|
50
52
|
listAllResources(opts?: {
|
|
51
53
|
limit?: number;
|
|
52
54
|
offset?: number;
|
package/dist/resources/vega.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { vegaHealth, listVegaCatalogs, getVegaCatalog, createVegaCatalog, updateVegaCatalog, deleteVegaCatalogs, vegaCatalogHealthStatus, testVegaCatalogConnection, discoverVegaCatalog, listVegaCatalogResources, listVegaResources, getVegaResource, queryVegaResourceData, createVegaResource, updateVegaResource, deleteVegaResources, createVegaDatasetDocs, updateVegaDatasetDocs, deleteVegaDatasetDocs, deleteVegaDatasetDocsQuery, buildVegaDataset, getVegaDatasetBuildStatus, executeVegaQuery, listAllVegaResources, listVegaConnectorTypes, getVegaConnectorType, registerVegaConnectorType, updateVegaConnectorType, deleteVegaConnectorType, setVegaConnectorTypeEnabled, } from "../api/vega.js";
|
|
1
|
+
import { vegaHealth, listVegaCatalogs, getVegaCatalog, createVegaCatalog, updateVegaCatalog, deleteVegaCatalogs, vegaCatalogHealthStatus, testVegaCatalogConnection, discoverVegaCatalog, listVegaCatalogResources, listVegaResources, getVegaResource, queryVegaResourceData, createVegaResource, updateVegaResource, deleteVegaResources, createVegaDatasetDocs, updateVegaDatasetDocs, deleteVegaDatasetDocs, deleteVegaDatasetDocsQuery, buildVegaDataset, getVegaDatasetBuildStatus, executeVegaQuery, vegaSQLQuery, listAllVegaResources, listVegaConnectorTypes, getVegaConnectorType, registerVegaConnectorType, updateVegaConnectorType, deleteVegaConnectorType, setVegaConnectorTypeEnabled, } from "../api/vega.js";
|
|
2
2
|
function unwrapArray(raw) {
|
|
3
3
|
const parsed = JSON.parse(raw);
|
|
4
4
|
if (Array.isArray(parsed))
|
|
@@ -114,6 +114,11 @@ export class VegaResource {
|
|
|
114
114
|
const raw = await executeVegaQuery({ ...this.ctx.base(), body });
|
|
115
115
|
return JSON.parse(raw);
|
|
116
116
|
}
|
|
117
|
+
/** POST /resources/query — direct SQL or OpenSearch DSL (see kweaver vega sql --help). */
|
|
118
|
+
async sqlQuery(body) {
|
|
119
|
+
const raw = await vegaSQLQuery({ ...this.ctx.base(), body });
|
|
120
|
+
return JSON.parse(raw);
|
|
121
|
+
}
|
|
117
122
|
// ── Resource List All ──────────────────────────────────────────────────────
|
|
118
123
|
async listAllResources(opts = {}) {
|
|
119
124
|
const raw = await listAllVegaResources({ ...this.ctx.base(), ...opts });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kweaver-ai/kweaver-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "KWeaver TypeScript SDK — CLI tool and programmatic API for knowledge networks and Decision Agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"lint": "tsc --noEmit -p tsconfig.json",
|
|
30
30
|
"test": "node --import tsx --test test/*.test.ts",
|
|
31
31
|
"test:e2e": "node --import tsx --test test/e2e/*.test.ts",
|
|
32
|
-
"test:e2e:live": "KWEAVER_BASE_URL=${KWEAVER_BASE_URL:-https://43.129.210.161} KWEAVER_NO_AUTH=1 KWEAVER_TLS_INSECURE=1 node --import tsx --test test/e2e/*.test.ts",
|
|
33
32
|
"prepublishOnly": "npm run build"
|
|
34
33
|
},
|
|
35
34
|
"keywords": [
|