@kweaver-ai/kweaver-sdk 0.6.10 → 0.7.1

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 CHANGED
@@ -143,15 +143,20 @@ const rows = await client.vega.sqlQuery(
143
143
  JSON.stringify({ query: "SELECT * FROM {{res-1}} LIMIT 5", resource_type: "mysql" }),
144
144
  );
145
145
 
146
- // Context Loader (semantic search over a BKN via MCP)
146
+ // Context Loader (MCP search_schema plus generic tools/call)
147
147
  const cl = client.contextLoader(mcpUrl, "bkn-id");
148
- const results = await cl.search({ query: "hypertension treatment" });
148
+ const schema = await cl.searchSchema({ query: "hypertension treatment" });
149
+ const rawTool = await cl.callTool("search_schema", { query: "hypertension treatment" });
149
150
 
150
151
  // Skills (registry + market + progressive read)
151
152
  const skills = await client.skills.market({ name: "kweaver" });
152
153
  const skillMd = await client.skills.fetchContent("skill-id");
153
154
  ```
154
155
 
156
+ `searchSchema()` is the typed wrapper for the Context Loader MCP `search_schema` tool. It defaults `response_format` to `json` and accepts `query`, `response_format`, `search_scope`, `max_concepts`, `schema_brief`, and `enable_rerank`. The parsed response may contain `object_types`, `relation_types`, `action_types`, and `metric_types`.
157
+
158
+ Use `callTool(name, args)` when you need native MCP `tools/call` access for newly added server tools before the SDK adds a typed wrapper. Arguments are passed through unchanged.
159
+
155
160
  ## CLI Reference
156
161
 
157
162
  ```
@@ -184,7 +189,7 @@ kweaver agent list/get/create/update/delete/chat/sessions/history/publish/unpubl
184
189
  kweaver skill list/market/get/register/status/delete/content/read-file/download/install
185
190
  kweaver vega health/stats/inspect/sql/catalog/resource/connector-type
186
191
  kweaver context-loader config set/use/list/show
187
- kweaver context-loader kn-search/query-object-instance/...
192
+ kweaver context-loader search-schema/tool-call/kn-search/query-object-instance/find-skills/...
188
193
  kweaver toolbox create/list/publish/unpublish/delete
189
194
  kweaver tool upload/list/enable/disable
190
195
  kweaver call <path> [-X METHOD] [-d BODY] [-H header] [-F key=value]
package/README.zh.md CHANGED
@@ -136,15 +136,20 @@ const rows = await client.vega.sqlQuery(
136
136
  JSON.stringify({ query: "SELECT * FROM {{res-1}} LIMIT 5", resource_type: "mysql" }),
137
137
  );
138
138
 
139
- // Context Loader(通过 MCP BKN 做语义搜索)
139
+ // Context LoaderMCP search_schema + 通用 tools/call)
140
140
  const cl = client.contextLoader(mcpUrl, "bkn-id");
141
- const results = await cl.search({ query: "高血压 治疗" });
141
+ const schema = await cl.searchSchema({ query: "高血压 治疗" });
142
+ const rawTool = await cl.callTool("search_schema", { query: "高血压 治疗" });
142
143
 
143
144
  // Skill(注册表/市场/渐进式读取)
144
145
  const skills = await client.skills.market({ name: "kweaver" });
145
146
  const skillMd = await client.skills.fetchContent("skill-id");
146
147
  ```
147
148
 
149
+ `searchSchema()` 是 Context Loader MCP `search_schema` 的类型化封装,默认 `response_format` 为 `json`,支持 `query`、`response_format`、`search_scope`、`max_concepts`、`schema_brief`、`enable_rerank`。解析后的返回结果可能包含 `object_types`、`relation_types`、`action_types`、`metric_types`。
150
+
151
+ 需要直接使用 MCP 原生 `tools/call` 时,使用 `callTool(name, args)`。这适用于服务端新增工具但 SDK 尚未提供类型化封装的场景,参数会原样透传。
152
+
148
153
  ## 命令速查
149
154
 
150
155
  ```
@@ -172,7 +177,7 @@ kweaver agent list/get/chat/sessions/history
172
177
  kweaver skill list/market/get/register/status/delete/content/read-file/download/install
173
178
  kweaver vega health|stats|inspect|sql|catalog|resource|connector-type
174
179
  kweaver context-loader config set/use/list/show
175
- kweaver context-loader kn-search/query-object-instance/...
180
+ kweaver context-loader search-schema/tool-call/kn-search/query-object-instance/find-skills/...
176
181
  kweaver call <path> [-X METHOD] [-d BODY] [-H header]
177
182
  ```
178
183
 
@@ -4,15 +4,28 @@ export interface ContextLoaderCallOptions {
4
4
  knId: string;
5
5
  accessToken: string;
6
6
  }
7
- /** Layer 1: kn_search arguments. */
8
- export interface KnSearchArgs {
9
- query: string;
10
- only_schema?: boolean;
7
+ export interface SearchSchemaScope {
8
+ include_object_types?: boolean;
9
+ include_relation_types?: boolean;
10
+ include_action_types?: boolean;
11
+ include_metric_types?: boolean;
11
12
  }
12
- /** Layer 1: kn_schema_search arguments. */
13
- export interface KnSchemaSearchArgs {
13
+ /** Layer 1: search_schema arguments. */
14
+ export interface SearchSchemaArgs {
14
15
  query: string;
16
+ response_format?: "json" | "toon";
17
+ search_scope?: SearchSchemaScope;
15
18
  max_concepts?: number;
19
+ schema_brief?: boolean;
20
+ enable_rerank?: boolean;
21
+ }
22
+ /** Layer 1: search_schema result. */
23
+ export interface SearchSchemaResult {
24
+ object_types?: unknown[];
25
+ relation_types?: unknown[];
26
+ action_types?: unknown[];
27
+ metric_types?: unknown[];
28
+ raw?: string;
16
29
  }
17
30
  /** Condition for query_object_instance and query_instance_subgraph. */
18
31
  export interface ConditionSpec {
@@ -60,6 +73,24 @@ export interface GetActionInfoArgs {
60
73
  at_id: string;
61
74
  _instance_identity: Record<string, string>;
62
75
  }
76
+ /** Layer 3: find_skills arguments (object_type_id is required). */
77
+ export interface FindSkillsArgs {
78
+ object_type_id: string;
79
+ response_format?: "json" | "toon";
80
+ instance_identities?: Record<string, unknown>[];
81
+ skill_query?: string;
82
+ /** 1..20, default 10 on the server side. */
83
+ top_k?: number;
84
+ }
85
+ /** Layer 3: find_skills result. */
86
+ export interface FindSkillsResult {
87
+ entries: Array<{
88
+ skill_id: string;
89
+ name: string;
90
+ description?: string;
91
+ }>;
92
+ message?: string;
93
+ }
63
94
  /** Error when get_logic_properties_values returns MISSING_INPUT_PARAMS. */
64
95
  export interface MissingInputParamsError {
65
96
  error_code: "MISSING_INPUT_PARAMS";
@@ -81,10 +112,9 @@ export declare function validateCondition(condition: unknown): void;
81
112
  export declare function validateInstanceIdentity(v: unknown, label: string): void;
82
113
  /** Guardrail: _instance_identities must be array of plain objects from Layer 2. */
83
114
  export declare function validateInstanceIdentities(v: unknown): void;
84
- /** Layer 1: kn_search. Returns object_types, relation_types, action_types. */
85
- export declare function knSearch(options: ContextLoaderCallOptions, args: KnSearchArgs): Promise<unknown>;
86
- /** Layer 1: kn_schema_search. Returns concepts (candidate discovery only). */
87
- export declare function knSchemaSearch(options: ContextLoaderCallOptions, args: KnSchemaSearchArgs): Promise<unknown>;
115
+ export declare function callTool(options: ContextLoaderCallOptions, toolName: string, args: Record<string, unknown>): Promise<unknown>;
116
+ /** Layer 1: search_schema. Returns object_types, relation_types, action_types, metric_types. */
117
+ export declare function searchSchema(options: ContextLoaderCallOptions, args: SearchSchemaArgs): Promise<SearchSchemaResult>;
88
118
  /** Layer 2: query_object_instance. Returns datas with _instance_identity. */
89
119
  export declare function queryObjectInstance(options: ContextLoaderCallOptions, args: QueryObjectInstanceArgs): Promise<unknown>;
90
120
  /** Layer 2: query_instance_subgraph. Returns entries with nested _instance_identity. */
@@ -93,6 +123,11 @@ export declare function queryInstanceSubgraph(options: ContextLoaderCallOptions,
93
123
  export declare function getLogicPropertiesValues(options: ContextLoaderCallOptions, args: GetLogicPropertiesValuesArgs): Promise<unknown>;
94
124
  /** Layer 3: get_action_info. Returns _dynamic_tools. */
95
125
  export declare function getActionInfo(options: ContextLoaderCallOptions, args: GetActionInfoArgs): Promise<unknown>;
126
+ /**
127
+ * Layer 3: find_skills. Recall skills attached to an object type or
128
+ * (optionally) narrowed to specific instances.
129
+ */
130
+ export declare function findSkills(options: ContextLoaderCallOptions, args: FindSkillsArgs): Promise<FindSkillsResult>;
96
131
  /** MCP tools/list. Returns list of available tools. */
97
132
  export declare function listTools(options: ContextLoaderCallOptions, params?: {
98
133
  cursor?: string;
@@ -149,7 +149,7 @@ async function callMcpMethod(options, method, params = {}) {
149
149
  }
150
150
  throw new Error("Context-loader returned no result");
151
151
  }
152
- async function callTool(options, toolName, args) {
152
+ export async function callTool(options, toolName, args) {
153
153
  const sessionId = await ensureSession(options);
154
154
  const id = (requestId += 1);
155
155
  const body = JSON.stringify({
@@ -208,13 +208,21 @@ async function callTool(options, toolName, args) {
208
208
  }
209
209
  throw new Error("Context-loader returned no result");
210
210
  }
211
- /** Layer 1: kn_search. Returns object_types, relation_types, action_types. */
212
- export async function knSearch(options, args) {
213
- return callTool(options, "kn_search", { ...args });
214
- }
215
- /** Layer 1: kn_schema_search. Returns concepts (candidate discovery only). */
216
- export async function knSchemaSearch(options, args) {
217
- return callTool(options, "kn_schema_search", { ...args });
211
+ /** Layer 1: search_schema. Returns object_types, relation_types, action_types, metric_types. */
212
+ export async function searchSchema(options, args) {
213
+ const toolArgs = {
214
+ query: args.query,
215
+ response_format: args.response_format ?? "json",
216
+ };
217
+ if (args.search_scope !== undefined)
218
+ toolArgs.search_scope = args.search_scope;
219
+ if (args.max_concepts !== undefined)
220
+ toolArgs.max_concepts = args.max_concepts;
221
+ if (args.schema_brief !== undefined)
222
+ toolArgs.schema_brief = args.schema_brief;
223
+ if (args.enable_rerank !== undefined)
224
+ toolArgs.enable_rerank = args.enable_rerank;
225
+ return (await callTool(options, "search_schema", toolArgs));
218
226
  }
219
227
  /** Layer 2: query_object_instance. Returns datas with _instance_identity. */
220
228
  export async function queryObjectInstance(options, args) {
@@ -240,6 +248,33 @@ export async function getActionInfo(options, args) {
240
248
  validateInstanceIdentity(args._instance_identity, "_instance_identity");
241
249
  return callTool(options, "get_action_info", { ...args });
242
250
  }
251
+ /**
252
+ * Layer 3: find_skills. Recall skills attached to an object type or
253
+ * (optionally) narrowed to specific instances.
254
+ */
255
+ export async function findSkills(options, args) {
256
+ if (!args.object_type_id || typeof args.object_type_id !== "string") {
257
+ throw new Error("find_skills: object_type_id is required.");
258
+ }
259
+ if (args.top_k !== undefined && (args.top_k < 1 || args.top_k > 20)) {
260
+ throw new Error("find_skills: top_k must be between 1 and 20.");
261
+ }
262
+ if (args.instance_identities !== undefined) {
263
+ validateInstanceIdentities(args.instance_identities);
264
+ }
265
+ const toolArgs = {
266
+ object_type_id: args.object_type_id,
267
+ };
268
+ if (args.response_format !== undefined)
269
+ toolArgs.response_format = args.response_format;
270
+ if (args.instance_identities !== undefined)
271
+ toolArgs.instance_identities = args.instance_identities;
272
+ if (args.skill_query !== undefined)
273
+ toolArgs.skill_query = args.skill_query;
274
+ if (args.top_k !== undefined)
275
+ toolArgs.top_k = args.top_k;
276
+ return (await callTool(options, "find_skills", toolArgs));
277
+ }
243
278
  /** MCP tools/list. Returns list of available tools. */
244
279
  export async function listTools(options, params) {
245
280
  return callMcpMethod(options, "tools/list", params ? { cursor: params.cursor } : {});
@@ -10,3 +10,12 @@ export interface SemanticSearchOptions {
10
10
  returnQueryUnderstanding?: boolean;
11
11
  }
12
12
  export declare function semanticSearch(options: SemanticSearchOptions): Promise<string>;
13
+ export interface KnSearchHttpOptions {
14
+ baseUrl: string;
15
+ accessToken: string;
16
+ knId: string;
17
+ query: string;
18
+ businessDomain?: string;
19
+ onlySchema?: boolean;
20
+ }
21
+ export declare function knSearchHttp(options: KnSearchHttpOptions): Promise<string>;
@@ -22,3 +22,22 @@ export async function semanticSearch(options) {
22
22
  }
23
23
  return body;
24
24
  }
25
+ export async function knSearchHttp(options) {
26
+ const { baseUrl, accessToken, knId, query, businessDomain = "bd_public", onlySchema = false, } = options;
27
+ const base = baseUrl.replace(/\/+$/, "");
28
+ const url = `${base}/api/agent-retrieval/v1/kn/kn_search`;
29
+ const response = await fetch(url, {
30
+ method: "POST",
31
+ headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
32
+ body: JSON.stringify({
33
+ kn_id: knId,
34
+ query,
35
+ only_schema: onlySchema,
36
+ }),
37
+ });
38
+ const body = await response.text();
39
+ if (!response.ok) {
40
+ throw new HttpError(response.status, response.statusText, body);
41
+ }
42
+ return body;
43
+ }
@@ -44,6 +44,18 @@ export interface ListToolsOptions extends BaseOpts {
44
44
  boxId: string;
45
45
  }
46
46
  export declare function listTools(opts: ListToolsOptions): Promise<string>;
47
+ export type ImpexType = "toolbox" | "mcp" | "operator";
48
+ export interface ExportConfigOptions extends BaseOpts {
49
+ id: string;
50
+ type?: ImpexType;
51
+ }
52
+ export declare function exportConfig(opts: ExportConfigOptions): Promise<Uint8Array>;
53
+ export interface ImportConfigOptions extends BaseOpts {
54
+ /** Path to a previously exported `.adp` JSON file. */
55
+ filePath: string;
56
+ type?: ImpexType;
57
+ }
58
+ export declare function importConfig(opts: ImportConfigOptions): Promise<string>;
47
59
  export interface InvokeToolOptions extends BaseOpts {
48
60
  boxId: string;
49
61
  toolId: string;
@@ -1,6 +1,6 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { basename } from "node:path";
3
- import { fetchTextOrThrow } from "../utils/http.js";
3
+ import { HttpError, fetchTextOrThrow, fetchWithRetry } from "../utils/http.js";
4
4
  import { buildHeaders } from "./headers.js";
5
5
  // Backend endpoints under /api/agent-operator-integration/v1/tool-box.
6
6
  //
@@ -97,6 +97,48 @@ export async function listTools(opts) {
97
97
  });
98
98
  return body;
99
99
  }
100
+ // ── impex (export / import) ──────────────────────────────────────────────────
101
+ //
102
+ // Backend mounts the impex endpoints on the same service but under a different
103
+ // path:
104
+ //
105
+ // GET /api/agent-operator-integration/v1/impex/export/{type}/{id}
106
+ // POST /api/agent-operator-integration/v1/impex/import/{type} (multipart, field "data")
107
+ //
108
+ // Supported {type} values today: "toolbox" | "mcp" | "operator".
109
+ //
110
+ // Export response is the raw JSON config (Content-Type: application/json) plus
111
+ // a `Content-Disposition: attachment; filename=<type>_export_<ts>.adp` header.
112
+ const IMPEX_PATH = "/api/agent-operator-integration/v1/impex";
113
+ export async function exportConfig(opts) {
114
+ const t = opts.type ?? "toolbox";
115
+ const target = `${opts.baseUrl.replace(/\/+$/, "")}${IMPEX_PATH}/export/${encodeURIComponent(t)}/${encodeURIComponent(opts.id)}`;
116
+ // Use raw bytes (not text) so we never lose precision on non-ASCII payloads
117
+ // and stay symmetric with the Python SDK's `export_config -> bytes`.
118
+ const response = await fetchWithRetry(target, {
119
+ method: "GET",
120
+ headers: buildHeaders(opts.accessToken, opts.businessDomain ?? "bd_public"),
121
+ });
122
+ const buf = new Uint8Array(await response.arrayBuffer());
123
+ if (!response.ok) {
124
+ const text = new TextDecoder("utf-8").decode(buf);
125
+ throw new HttpError(response.status, response.statusText, text);
126
+ }
127
+ return buf;
128
+ }
129
+ export async function importConfig(opts) {
130
+ const buf = await readFile(opts.filePath);
131
+ const t = opts.type ?? "toolbox";
132
+ const form = new FormData();
133
+ form.append("data", new Blob([buf]), basename(opts.filePath));
134
+ const target = `${opts.baseUrl.replace(/\/+$/, "")}${IMPEX_PATH}/import/${encodeURIComponent(t)}`;
135
+ const { body } = await fetchTextOrThrow(target, {
136
+ method: "POST",
137
+ headers: buildHeaders(opts.accessToken, opts.businessDomain ?? "bd_public"),
138
+ body: form,
139
+ });
140
+ return body;
141
+ }
100
142
  function buildEnvelope(opts) {
101
143
  const envelope = {};
102
144
  if (opts.timeout !== undefined)
package/dist/cli.js CHANGED
@@ -39,26 +39,26 @@ Usage:
39
39
  kweaver token
40
40
 
41
41
  kweaver call <url> [-X METHOD] [-H "Name: value"] [-d BODY] [--data-raw BODY]
42
- [--url URL] [--pretty] [--verbose] [-bd value]
42
+ [--url URL] [--verbose] [-bd value]
43
43
  (alias: kweaver curl ...)
44
44
 
45
45
  kweaver agent chat <agent_id> [-m "message"] [--version value] [--conversation-id id]
46
46
  [--stream] [--no-stream] [--verbose] [-bd value]
47
- kweaver agent list [--name X] [--limit N] [--offset N] [-bd value] [--pretty]
48
- kweaver agent get <agent_id> [-bd value] [--pretty]
49
- kweaver agent get-by-key <key> [-bd value] [--pretty]
50
- kweaver agent sessions <agent_id> [-bd value] [--limit N] [--pretty]
51
- kweaver agent history <conversation_id> [-bd value] [--limit N] [--pretty]
47
+ kweaver agent list [--name X] [--limit N] [--offset N] [-bd value]
48
+ kweaver agent get <agent_id> [-bd value]
49
+ kweaver agent get-by-key <key> [-bd value]
50
+ kweaver agent sessions <agent_id> [-bd value] [--limit N]
51
+ kweaver agent history <conversation_id> [-bd value] [--limit N]
52
52
  kweaver agent create [options]
53
53
  kweaver agent update <agent_id> [options]
54
54
  kweaver agent delete <agent_id> [-bd value]
55
55
  kweaver agent publish <agent_id> [-bd value]
56
56
  kweaver agent unpublish <agent_id> [-bd value]
57
57
 
58
- kweaver ds list [--keyword X] [--type T] [-bd value] [--pretty]
58
+ kweaver ds list [--keyword X] [--type T] [-bd value]
59
59
  kweaver ds get <id>
60
60
  kweaver ds delete <id> [-y]
61
- kweaver ds tables <id> [--keyword X] [--pretty]
61
+ kweaver ds tables <id> [--keyword X]
62
62
  kweaver ds connect <db_type> <host> <port> <database> --account X --password Y [--schema S] [--name N]
63
63
 
64
64
  kweaver dataflow list [-bd value]
@@ -66,15 +66,15 @@ Usage:
66
66
  kweaver dataflow runs <dagId> [--since <date-like>] [-bd value]
67
67
  kweaver dataflow logs <dagId> <instanceId> [--detail] [-bd value]
68
68
 
69
- kweaver dataview list [--datasource-id id] [--type atomic|custom] [--limit n] [-bd value] [--pretty]
70
- kweaver dataview find --name <name> [--exact] [--datasource-id id] [--wait] [--timeout ms] [-bd value] [--pretty]
71
- kweaver dataview get <id> [-bd value] [--pretty]
72
- kweaver dataview query <id> [--sql sql] [--limit n] [--offset n] [--need-total] [--raw-sql] [-bd value] [--pretty]
69
+ kweaver dataview list [--datasource-id id] [--type atomic|custom] [--limit n] [-bd value]
70
+ kweaver dataview find --name <name> [--exact] [--datasource-id id] [--wait] [--timeout ms] [-bd value]
71
+ kweaver dataview get <id> [-bd value]
72
+ kweaver dataview query <id> [--sql sql] [--limit n] [--offset n] [--need-total] [--raw-sql] [-bd value]
73
73
  kweaver dataview delete <id> [-y] [-bd value]
74
74
 
75
75
  kweaver bkn list [options]
76
76
  kweaver bkn get <kn-id> [options]
77
- kweaver bkn search <kn-id> <query> [--max-concepts N] [--mode M] [--pretty] [-bd value]
77
+ kweaver bkn search <kn-id> <query> [--max-concepts N] [--mode M] [-bd value]
78
78
  kweaver bkn create [options]
79
79
  kweaver bkn create-from-ds [options]
80
80
  kweaver bkn update <kn-id> [options]
@@ -107,6 +107,8 @@ Usage:
107
107
  kweaver toolbox list [--keyword X] [--limit N] [--offset N] [-bd value]
108
108
  kweaver toolbox publish|unpublish <box-id> [-bd value]
109
109
  kweaver toolbox delete <box-id> [-y] [-bd value]
110
+ kweaver toolbox export <box-id> [-o <file>|-] [--type toolbox|mcp|operator]
111
+ kweaver toolbox import <file> [--type toolbox|mcp|operator]
110
112
 
111
113
  kweaver tool upload --toolbox <box-id> <openapi-spec-path> [--metadata-type openapi]
112
114
  kweaver tool list --toolbox <box-id> [-bd value]
@@ -125,13 +127,18 @@ Usage:
125
127
  kweaver context-loader tools|resources|templates|prompts [--cursor]
126
128
  kweaver context-loader resource <uri>
127
129
  kweaver context-loader prompt <name> [--args json]
128
- kweaver context-loader kn-search <query> [--only-schema]
129
- kweaver context-loader kn-schema-search <query> [--max N]
130
- kweaver context-loader query-object-instance|query-instance-subgraph|get-logic-properties|get-action-info ...
130
+ kweaver context-loader search-schema <query> [--scope object,relation,action,metric] [--max N]
131
+ kweaver context-loader tool-call <name> --args '<json>'
132
+ kweaver context-loader kn-search <query> [--only-schema] (compat HTTP)
133
+ kweaver context-loader kn-schema-search <query> [--max N] (compat HTTP)
134
+ kweaver context-loader query-object-instance|query-instance-subgraph|get-logic-properties|get-action-info|find-skills ...
131
135
  (alias: kweaver context ...)
132
136
 
133
137
  Global options:
134
138
  --user <id|name> Use a specific user's credentials for this command (env: KWEAVER_USER)
139
+ --pretty / --compact
140
+ Toggle pretty-printed JSON output. Supported by every
141
+ command that prints a JSON payload (default: pretty).
135
142
 
136
143
  Commands:
137
144
  auth Login, list, inspect, and switch saved platform auth profiles
@@ -145,10 +152,10 @@ Commands:
145
152
  object-type, relation-type, subgraph, action-type, action-execution, action-log)
146
153
  config Per-platform configuration (business domain)
147
154
  skill Skill registry and market (register, search, progressive read, download/install)
148
- toolbox Agent toolbox lifecycle (create, list, publish, delete)
155
+ toolbox Agent toolbox lifecycle (create, list, publish, delete, export, import)
149
156
  tool Tools inside a toolbox (upload OpenAPI spec, list, enable/disable)
150
157
  vega Vega observability (catalog, resource, query/sql, connector-type, health/stats/inspect)
151
- context-loader Context-loader MCP (config, tools, resources, prompts, kn-search, query-*, etc.)
158
+ context-loader Context-loader MCP/HTTP (config, tools, resources, search-schema, tool-call, query-*, etc.)
152
159
  help Show this message`);
153
160
  }
154
161
  export async function run(argv) {
@@ -31,13 +31,18 @@ Query subgraph via ontology-query API. JSON body format see references/json-form
31
31
  return 1;
32
32
  }
33
33
  try {
34
- // Auto-detect query_type=relation_path when body contains source_object_type_id
34
+ // Map body shape to ontology-query subgraph query_type:
35
+ // - relation_type_paths mode → ?query_type=relation_path
36
+ // - source_object_type_id mode → omit query_type (default path; do not send relation_path)
35
37
  let queryType;
36
38
  try {
37
39
  const parsedBody = JSON.parse(body);
38
- if (parsedBody.source_object_type_id) {
40
+ if (Array.isArray(parsedBody.relation_type_paths)) {
39
41
  queryType = "relation_path";
40
42
  }
43
+ else if (parsedBody.source_object_type_id) {
44
+ queryType = "";
45
+ }
41
46
  }
42
47
  catch {
43
48
  // Not valid JSON — let the API return the error
@@ -1,6 +1,7 @@
1
1
  import { ensureValidToken, formatHttpError, resolveActivePlatform, with401RefreshRetry } from "../auth/oauth.js";
2
- import { knSearch, knSchemaSearch, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, listTools, listResources, readResource, listResourceTemplates, listPrompts, getPrompt, } from "../api/context-loader.js";
3
- import { addContextLoaderEntry, getCurrentContextLoaderKn, loadContextLoaderConfig, removeContextLoaderEntry, setCurrentContextLoader, } from "../config/store.js";
2
+ import { callTool, searchSchema, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, findSkills, listTools, listResources, readResource, listResourceTemplates, listPrompts, getPrompt, } from "../api/context-loader.js";
3
+ import { knSearchHttp, semanticSearch } from "../api/semantic-search.js";
4
+ import { addContextLoaderEntry, getCurrentContextLoaderKn, loadContextLoaderConfig, removeContextLoaderEntry, resolveBusinessDomain, setCurrentContextLoader, } from "../config/store.js";
4
5
  const MCP_NOT_CONFIGURED = "Context-loader MCP is not configured. Run: kweaver context-loader config set --kn-id <kn-id>";
5
6
  function ensureContextLoaderConfig() {
6
7
  const active = resolveActivePlatform();
@@ -12,9 +13,11 @@ function ensureContextLoaderConfig() {
12
13
  throw new Error(MCP_NOT_CONFIGURED);
13
14
  }
14
15
  return {
16
+ baseUrl: active.url,
15
17
  mcpUrl: kn.mcpUrl,
16
18
  knId: kn.knId,
17
19
  accessToken: "", // filled by caller after ensureValidToken
20
+ businessDomain: resolveBusinessDomain(active.url),
18
21
  };
19
22
  }
20
23
  function formatOutput(value, pretty) {
@@ -38,16 +41,21 @@ Subcommands:
38
41
  templates resources/templates/list - list resource templates
39
42
  prompts prompts/list - list prompts
40
43
  prompt <name> [--args json] prompts/get - get prompt by name
41
- kn-search <query> [--only-schema] Layer 1: Search schema (object_types, relation_types, action_types)
42
- kn-schema-search <query> [--max N] Layer 1: Discover candidate concepts
44
+ search-schema <query> [options] MCP search_schema (object/relation/action/metric types)
45
+ tool-call <name> --args '<json>' MCP tools/call for any server tool
46
+ kn-search <query> [--only-schema] Compatibility: HTTP kn_search
47
+ kn-schema-search <query> [--max N] Compatibility: HTTP semantic-search
43
48
  query-object-instance <json> Layer 2: Query instances (args as JSON)
44
49
  query-instance-subgraph <json> Layer 2: Query subgraph (args as JSON)
45
50
  get-logic-properties <json> Layer 3: Get logic property values (args as JSON)
46
51
  get-action-info <json> Layer 3: Get action info (args as JSON)
52
+ find-skills <ot_id> [options] Layer 3: Recall skills for an object type
47
53
 
48
54
  Examples:
49
55
  kweaver context-loader config set --kn-id d5iv6c9818p72mpje8pg
50
56
  kweaver context-loader config set --kn-id xyz123 --name project-a
57
+ kweaver context-loader search-schema "利润率" --scope object,metric --max 5
58
+ kweaver context-loader tool-call search_schema --args '{"query":"利润率"}'
51
59
  kweaver context-loader kn-search "高血压 治疗 药品" --only-schema --pretty`);
52
60
  return 0;
53
61
  }
@@ -76,6 +84,10 @@ Examples:
76
84
  return runListPrompts(options, rest, pretty);
77
85
  if (subcommand === "prompt")
78
86
  return runGetPrompt(options, rest, pretty);
87
+ if (subcommand === "search-schema")
88
+ return runSearchSchema(options, rest, pretty);
89
+ if (subcommand === "tool-call")
90
+ return runToolCall(options, rest, pretty);
79
91
  if (subcommand === "kn-search")
80
92
  return runKnSearch(options, rest, pretty);
81
93
  if (subcommand === "kn-schema-search")
@@ -88,6 +100,8 @@ Examples:
88
100
  return runGetLogicProperties(options, rest, pretty);
89
101
  if (subcommand === "get-action-info")
90
102
  return runGetActionInfo(options, rest, pretty);
103
+ if (subcommand === "find-skills")
104
+ return runFindSkills(options, rest, pretty);
91
105
  return -1;
92
106
  };
93
107
  try {
@@ -279,6 +293,145 @@ async function runGetPrompt(options, args, pretty) {
279
293
  console.log(formatOutput(result, pretty));
280
294
  return 0;
281
295
  }
296
+ function parseResponseText(text) {
297
+ try {
298
+ return JSON.parse(text);
299
+ }
300
+ catch {
301
+ return { raw: text };
302
+ }
303
+ }
304
+ function parseSearchSchemaScope(raw) {
305
+ const scope = {
306
+ include_object_types: false,
307
+ include_relation_types: false,
308
+ include_action_types: false,
309
+ include_metric_types: false,
310
+ };
311
+ const aliases = {
312
+ object: "include_object_types",
313
+ objects: "include_object_types",
314
+ object_type: "include_object_types",
315
+ object_types: "include_object_types",
316
+ relation: "include_relation_types",
317
+ relations: "include_relation_types",
318
+ relation_type: "include_relation_types",
319
+ relation_types: "include_relation_types",
320
+ action: "include_action_types",
321
+ actions: "include_action_types",
322
+ action_type: "include_action_types",
323
+ action_types: "include_action_types",
324
+ metric: "include_metric_types",
325
+ metrics: "include_metric_types",
326
+ metric_type: "include_metric_types",
327
+ metric_types: "include_metric_types",
328
+ };
329
+ for (const item of raw.split(",")) {
330
+ const key = item.trim().toLowerCase();
331
+ if (!key)
332
+ continue;
333
+ const field = aliases[key];
334
+ if (!field) {
335
+ throw new Error(`Invalid --scope value: ${item}`);
336
+ }
337
+ scope[field] = true;
338
+ }
339
+ return scope;
340
+ }
341
+ async function runSearchSchema(options, args, pretty) {
342
+ let query;
343
+ let responseFormat;
344
+ let searchScope;
345
+ let maxConcepts;
346
+ let schemaBrief;
347
+ let enableRerank;
348
+ for (let i = 0; i < args.length; i += 1) {
349
+ const arg = args[i];
350
+ if ((arg === "--format" || arg === "-f") && args[i + 1]) {
351
+ const value = args[i + 1];
352
+ if (value !== "json" && value !== "toon") {
353
+ console.error("Usage: kweaver context-loader search-schema <query> [--format json|toon] [--scope object,relation,action,metric] [--max N] [--brief] [--no-rerank]");
354
+ return 1;
355
+ }
356
+ responseFormat = value;
357
+ i += 1;
358
+ }
359
+ else if ((arg === "--scope" || arg === "-s") && args[i + 1]) {
360
+ try {
361
+ searchScope = parseSearchSchemaScope(args[i + 1]);
362
+ }
363
+ catch (error) {
364
+ console.error(error instanceof Error ? error.message : String(error));
365
+ return 1;
366
+ }
367
+ i += 1;
368
+ }
369
+ else if ((arg === "--max" || arg === "-n") && args[i + 1]) {
370
+ maxConcepts = parseInt(args[i + 1], 10);
371
+ if (!Number.isFinite(maxConcepts)) {
372
+ console.error("Usage: kweaver context-loader search-schema <query> [--max N]");
373
+ return 1;
374
+ }
375
+ i += 1;
376
+ }
377
+ else if (arg === "--brief") {
378
+ schemaBrief = true;
379
+ }
380
+ else if (arg === "--no-rerank") {
381
+ enableRerank = false;
382
+ }
383
+ else if (!arg.startsWith("-") && !query) {
384
+ query = arg;
385
+ }
386
+ }
387
+ if (!query) {
388
+ console.error("Usage: kweaver context-loader search-schema <query> [--format json|toon] [--scope object,relation,action,metric] [--max N] [--brief] [--no-rerank]");
389
+ return 1;
390
+ }
391
+ const result = await searchSchema(options, {
392
+ query,
393
+ response_format: responseFormat,
394
+ search_scope: searchScope,
395
+ max_concepts: maxConcepts,
396
+ schema_brief: schemaBrief,
397
+ enable_rerank: enableRerank,
398
+ });
399
+ console.log(formatOutput(result, pretty));
400
+ return 0;
401
+ }
402
+ async function runToolCall(options, args, pretty) {
403
+ let toolName;
404
+ let rawArgs;
405
+ for (let i = 0; i < args.length; i += 1) {
406
+ const arg = args[i];
407
+ if ((arg === "--args" || arg === "-a") && args[i + 1]) {
408
+ rawArgs = args[i + 1];
409
+ i += 1;
410
+ }
411
+ else if (!arg.startsWith("-") && !toolName) {
412
+ toolName = arg;
413
+ }
414
+ }
415
+ if (!toolName || rawArgs === undefined) {
416
+ console.error("Usage: kweaver context-loader tool-call <name> --args '<json>'");
417
+ return 1;
418
+ }
419
+ let parsedArgs;
420
+ try {
421
+ parsedArgs = JSON.parse(rawArgs);
422
+ }
423
+ catch {
424
+ console.error("Invalid --args JSON");
425
+ return 1;
426
+ }
427
+ if (parsedArgs === null || typeof parsedArgs !== "object" || Array.isArray(parsedArgs)) {
428
+ console.error("--args must be a JSON object");
429
+ return 1;
430
+ }
431
+ const result = await callTool(options, toolName, parsedArgs);
432
+ console.log(formatOutput(result, pretty));
433
+ return 0;
434
+ }
282
435
  async function runKnSearch(options, args, pretty) {
283
436
  let query;
284
437
  let onlySchema = false;
@@ -300,8 +453,15 @@ async function runKnSearch(options, args, pretty) {
300
453
  console.error("Usage: kweaver context-loader kn-search <query> [--kn-id <id>] [--only-schema]");
301
454
  return 1;
302
455
  }
303
- const effectiveOptions = knIdOverride ? { ...options, knId: knIdOverride } : options;
304
- const result = await knSearch(effectiveOptions, { query, only_schema: onlySchema });
456
+ const raw = await knSearchHttp({
457
+ baseUrl: options.baseUrl,
458
+ accessToken: options.accessToken,
459
+ businessDomain: options.businessDomain,
460
+ knId: knIdOverride ?? options.knId,
461
+ query,
462
+ onlySchema,
463
+ });
464
+ const result = parseResponseText(raw);
305
465
  console.log(formatOutput(result, pretty));
306
466
  return 0;
307
467
  }
@@ -322,10 +482,15 @@ async function runKnSchemaSearch(options, args, pretty) {
322
482
  console.error("Usage: kweaver context-loader kn-schema-search <query> [--max N]");
323
483
  return 1;
324
484
  }
325
- const result = await knSchemaSearch(options, {
485
+ const raw = await semanticSearch({
486
+ baseUrl: options.baseUrl,
487
+ accessToken: options.accessToken,
488
+ businessDomain: options.businessDomain,
489
+ knId: options.knId,
326
490
  query,
327
- max_concepts: maxConcepts,
491
+ maxConcepts,
328
492
  });
493
+ const result = parseResponseText(raw);
329
494
  console.log(formatOutput(result, pretty));
330
495
  return 0;
331
496
  }
@@ -385,3 +550,66 @@ async function runGetActionInfo(options, args, pretty) {
385
550
  console.log(formatOutput(result, pretty));
386
551
  return 0;
387
552
  }
553
+ async function runFindSkills(options, args, pretty) {
554
+ const usage = "Usage: kweaver context-loader find-skills <object_type_id> " +
555
+ "[--query <text>] [--top-k N] [--instance-identities <json>] [--format json|toon]";
556
+ let objectTypeId;
557
+ let skillQuery;
558
+ let topK;
559
+ let instanceIdentities;
560
+ let responseFormat;
561
+ for (let i = 0; i < args.length; i += 1) {
562
+ const arg = args[i];
563
+ if ((arg === "--query" || arg === "-q") && args[i + 1]) {
564
+ skillQuery = args[i + 1];
565
+ i += 1;
566
+ }
567
+ else if ((arg === "--top-k" || arg === "-n") && args[i + 1]) {
568
+ topK = parseInt(args[i + 1], 10);
569
+ if (!Number.isFinite(topK)) {
570
+ console.error(usage);
571
+ return 1;
572
+ }
573
+ i += 1;
574
+ }
575
+ else if ((arg === "--instance-identities" || arg === "-i") && args[i + 1]) {
576
+ try {
577
+ const parsed = JSON.parse(args[i + 1]);
578
+ if (!Array.isArray(parsed)) {
579
+ throw new Error("--instance-identities must be a JSON array");
580
+ }
581
+ instanceIdentities = parsed;
582
+ }
583
+ catch (error) {
584
+ console.error(error instanceof Error ? error.message : String(error));
585
+ return 1;
586
+ }
587
+ i += 1;
588
+ }
589
+ else if ((arg === "--format" || arg === "-f") && args[i + 1]) {
590
+ const value = args[i + 1];
591
+ if (value !== "json" && value !== "toon") {
592
+ console.error(usage);
593
+ return 1;
594
+ }
595
+ responseFormat = value;
596
+ i += 1;
597
+ }
598
+ else if (!arg.startsWith("-") && !objectTypeId) {
599
+ objectTypeId = arg;
600
+ }
601
+ }
602
+ if (!objectTypeId) {
603
+ console.error(usage);
604
+ return 1;
605
+ }
606
+ const result = await findSkills(options, {
607
+ object_type_id: objectTypeId,
608
+ skill_query: skillQuery,
609
+ top_k: topK,
610
+ instance_identities: instanceIdentities,
611
+ response_format: responseFormat,
612
+ });
613
+ console.log(formatOutput(result, pretty));
614
+ return 0;
615
+ }
@@ -1,3 +1,4 @@
1
+ import { type ImpexType } from "../api/toolboxes.js";
1
2
  export declare function runToolboxCommand(args: string[]): Promise<number>;
2
3
  export interface ToolboxCreateOptions {
3
4
  name: string;
@@ -12,3 +13,17 @@ export interface ToolboxSetStatusOptions {
12
13
  businessDomain: string;
13
14
  }
14
15
  export declare function parseToolboxSetStatusArgs(args: string[]): ToolboxSetStatusOptions;
16
+ export interface ToolboxExportOptions {
17
+ boxId: string;
18
+ output: string;
19
+ type: ImpexType;
20
+ businessDomain: string;
21
+ }
22
+ export declare function parseToolboxExportArgs(args: string[]): ToolboxExportOptions;
23
+ export interface ToolboxImportOptions {
24
+ filePath: string;
25
+ type: ImpexType;
26
+ businessDomain: string;
27
+ pretty: boolean;
28
+ }
29
+ export declare function parseToolboxImportArgs(args: string[]): ToolboxImportOptions;
@@ -1,8 +1,10 @@
1
+ import { writeFile } from "node:fs/promises";
1
2
  import { createInterface } from "node:readline";
2
3
  import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/oauth.js";
3
- import { createToolbox, deleteToolbox, listToolboxes, setToolboxStatus } from "../api/toolboxes.js";
4
+ import { createToolbox, deleteToolbox, exportConfig, importConfig, listToolboxes, setToolboxStatus, } from "../api/toolboxes.js";
4
5
  import { formatCallOutput } from "./call.js";
5
6
  import { resolveBusinessDomain } from "../config/store.js";
7
+ const VALID_IMPEX_TYPES = new Set(["toolbox", "mcp", "operator"]);
6
8
  const HELP = `kweaver toolbox
7
9
 
8
10
  Subcommands:
@@ -11,6 +13,8 @@ Subcommands:
11
13
  publish <box-id> Publish a toolbox (status=published)
12
14
  unpublish <box-id> Unpublish (status=draft)
13
15
  delete <box-id> [-y|--yes] Delete a toolbox
16
+ export <box-id> [-o <file>|-] [--type toolbox|mcp|operator] Export toolbox config (.adp JSON)
17
+ import <file> [--type toolbox|mcp|operator] Import a previously exported config
14
18
 
15
19
  Options:
16
20
  -bd, --biz-domain <s> Business domain (default: bd_public)
@@ -33,6 +37,10 @@ export async function runToolboxCommand(args) {
33
37
  return runToolboxSetStatus(rest, "draft");
34
38
  if (subcommand === "delete")
35
39
  return runToolboxDelete(rest);
40
+ if (subcommand === "export")
41
+ return runToolboxExport(rest);
42
+ if (subcommand === "import")
43
+ return runToolboxImport(rest);
36
44
  return Promise.resolve(-1);
37
45
  };
38
46
  try {
@@ -254,3 +262,125 @@ async function runToolboxDelete(args) {
254
262
  console.error(`Deleted toolbox ${boxId}`);
255
263
  return 0;
256
264
  }
265
+ export function parseToolboxExportArgs(args) {
266
+ let boxId = "";
267
+ let output = "";
268
+ let type = "toolbox";
269
+ let businessDomain = "";
270
+ for (let i = 0; i < args.length; i += 1) {
271
+ const a = args[i];
272
+ if ((a === "-o" || a === "--output") && args[i + 1] !== undefined) {
273
+ output = args[++i];
274
+ continue;
275
+ }
276
+ if (a === "--type" && args[i + 1]) {
277
+ const v = args[++i];
278
+ if (!VALID_IMPEX_TYPES.has(v)) {
279
+ throw new Error(`--type must be one of: ${[...VALID_IMPEX_TYPES].join(", ")}`);
280
+ }
281
+ type = v;
282
+ continue;
283
+ }
284
+ if ((a === "-bd" || a === "--biz-domain") && args[i + 1]) {
285
+ businessDomain = args[++i];
286
+ continue;
287
+ }
288
+ if (!a.startsWith("-")) {
289
+ boxId = a;
290
+ continue;
291
+ }
292
+ }
293
+ if (!boxId)
294
+ throw new Error("Missing required argument: <box-id>");
295
+ if (!businessDomain)
296
+ businessDomain = resolveBusinessDomain();
297
+ return { boxId, output, type, businessDomain };
298
+ }
299
+ async function runToolboxExport(args) {
300
+ let opts;
301
+ try {
302
+ opts = parseToolboxExportArgs(args);
303
+ }
304
+ catch (e) {
305
+ console.error(e instanceof Error ? e.message : String(e));
306
+ console.error("Usage: kweaver toolbox export <box-id> [-o <file>|-] [--type toolbox|mcp|operator]");
307
+ return 1;
308
+ }
309
+ const token = await ensureValidToken();
310
+ const buf = await exportConfig({
311
+ baseUrl: token.baseUrl,
312
+ accessToken: token.accessToken,
313
+ businessDomain: opts.businessDomain,
314
+ id: opts.boxId,
315
+ type: opts.type,
316
+ });
317
+ if (opts.output === "-") {
318
+ process.stdout.write(buf);
319
+ if (buf.length === 0 || buf[buf.length - 1] !== 0x0a)
320
+ process.stdout.write("\n");
321
+ return 0;
322
+ }
323
+ const target = opts.output || `${opts.type}_${opts.boxId}.adp`;
324
+ await writeFile(target, buf);
325
+ console.error(`Exported ${opts.type} ${opts.boxId} → ${target} (${buf.byteLength} bytes)`);
326
+ return 0;
327
+ }
328
+ export function parseToolboxImportArgs(args) {
329
+ let filePath = "";
330
+ let type = "toolbox";
331
+ let businessDomain = "";
332
+ let pretty = true;
333
+ for (let i = 0; i < args.length; i += 1) {
334
+ const a = args[i];
335
+ if (a === "--type" && args[i + 1]) {
336
+ const v = args[++i];
337
+ if (!VALID_IMPEX_TYPES.has(v)) {
338
+ throw new Error(`--type must be one of: ${[...VALID_IMPEX_TYPES].join(", ")}`);
339
+ }
340
+ type = v;
341
+ continue;
342
+ }
343
+ if ((a === "-bd" || a === "--biz-domain") && args[i + 1]) {
344
+ businessDomain = args[++i];
345
+ continue;
346
+ }
347
+ if (a === "--pretty") {
348
+ pretty = true;
349
+ continue;
350
+ }
351
+ if (a === "--compact") {
352
+ pretty = false;
353
+ continue;
354
+ }
355
+ if (!a.startsWith("-")) {
356
+ filePath = a;
357
+ continue;
358
+ }
359
+ }
360
+ if (!filePath)
361
+ throw new Error("Missing required argument: <file>");
362
+ if (!businessDomain)
363
+ businessDomain = resolveBusinessDomain();
364
+ return { filePath, type, businessDomain, pretty };
365
+ }
366
+ async function runToolboxImport(args) {
367
+ let opts;
368
+ try {
369
+ opts = parseToolboxImportArgs(args);
370
+ }
371
+ catch (e) {
372
+ console.error(e instanceof Error ? e.message : String(e));
373
+ console.error("Usage: kweaver toolbox import <file> [--type toolbox|mcp|operator]");
374
+ return 1;
375
+ }
376
+ const token = await ensureValidToken();
377
+ const body = await importConfig({
378
+ baseUrl: token.baseUrl,
379
+ accessToken: token.accessToken,
380
+ businessDomain: opts.businessDomain,
381
+ filePath: opts.filePath,
382
+ type: opts.type,
383
+ });
384
+ console.log(formatCallOutput(body, opts.pretty));
385
+ return 0;
386
+ }
@@ -783,8 +783,13 @@ export async function autoSelectBusinessDomain(baseUrl, accessToken, options) {
783
783
  return selected;
784
784
  }
785
785
  catch (error) {
786
- const message = error instanceof Error ? error.message : String(error);
787
- console.warn(`Could not fetch business domains: ${message}. Using bd_public.`);
786
+ // Endpoint may be unavailable on this deployment or for this account
787
+ // type fall back silently. Set KWEAVER_DEBUG=1 to surface the
788
+ // underlying error during diagnostics.
789
+ if (process.env.KWEAVER_DEBUG) {
790
+ const message = error instanceof Error ? error.message : String(error);
791
+ console.warn(`Business domain list unavailable (${message}); defaulting to bd_public.`);
792
+ }
788
793
  return "bd_public";
789
794
  }
790
795
  }
package/dist/index.d.ts CHANGED
@@ -35,10 +35,10 @@ export type { ListAgentsOptions, GetAgentOptions, GetAgentByKeyOptions, CreateAg
35
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
- export type { SemanticSearchOptions } from "./api/semantic-search.js";
39
- export { semanticSearch } from "./api/semantic-search.js";
40
- export type { ContextLoaderCallOptions, KnSearchArgs, KnSchemaSearchArgs, ConditionSpec, QueryObjectInstanceArgs, RelationTypePath, QueryInstanceSubgraphArgs, GetLogicPropertiesValuesArgs, GetActionInfoArgs, MissingInputParamsError, } from "./api/context-loader.js";
41
- export { knSearch, knSchemaSearch, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, formatMissingInputParamsHint, validateCondition, validateInstanceIdentity, validateInstanceIdentities, } from "./api/context-loader.js";
38
+ export type { SemanticSearchOptions, KnSearchHttpOptions } from "./api/semantic-search.js";
39
+ export { semanticSearch, knSearchHttp } from "./api/semantic-search.js";
40
+ export type { ContextLoaderCallOptions, SearchSchemaArgs, SearchSchemaScope, SearchSchemaResult, ConditionSpec, QueryObjectInstanceArgs, RelationTypePath, QueryInstanceSubgraphArgs, GetLogicPropertiesValuesArgs, GetActionInfoArgs, FindSkillsArgs, FindSkillsResult, MissingInputParamsError, } from "./api/context-loader.js";
41
+ export { callTool, searchSchema, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, findSkills, formatMissingInputParamsHint, validateCondition, validateInstanceIdentity, validateInstanceIdentities, } from "./api/context-loader.js";
42
42
  export type { ConfigureOptions } from "./kweaver.js";
43
43
  export { configure, search, agents, chat, bkns, weaver, getClient } from "./kweaver.js";
44
44
  export type { KWeaverClientOptions, ClientContext } from "./client.js";
package/dist/index.js CHANGED
@@ -30,8 +30,8 @@ export { objectTypeQuery, objectTypeProperties, subgraph, actionTypeQuery, actio
30
30
  export { sendChatRequest, sendChatRequestStream, fetchAgentInfo, buildChatUrl, buildAgentInfoUrl, extractText, } from "./api/agent-chat.js";
31
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
- export { semanticSearch } from "./api/semantic-search.js";
34
- export { knSearch, knSchemaSearch, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, formatMissingInputParamsHint, validateCondition, validateInstanceIdentity, validateInstanceIdentities, } from "./api/context-loader.js";
33
+ export { semanticSearch, knSearchHttp } from "./api/semantic-search.js";
34
+ export { callTool, searchSchema, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, findSkills, formatMissingInputParamsHint, validateCondition, validateInstanceIdentity, validateInstanceIdentities, } from "./api/context-loader.js";
35
35
  export { configure, search, agents, chat, bkns, weaver, getClient } from "./kweaver.js";
36
36
  export { KWeaverClient } from "./client.js";
37
37
  export { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
@@ -48,7 +48,7 @@ export declare class BknResource {
48
48
  cancelActionLog(knId: string, logId: string): Promise<unknown>;
49
49
  /**
50
50
  * Search KN schema — finds matching object types, relation types, and action types.
51
- * Uses MCP protocol via the context-loader (public endpoint).
51
+ * Uses the public agent-retrieval HTTP compatibility endpoint.
52
52
  */
53
53
  knSearch(knId: string, query: string, opts?: {
54
54
  onlySchema?: boolean;
@@ -56,6 +56,7 @@ export declare class BknResource {
56
56
  object_types?: unknown[];
57
57
  relation_types?: unknown[];
58
58
  action_types?: unknown[];
59
+ metric_types?: unknown[];
59
60
  nodes?: unknown[];
60
61
  }>;
61
62
  }
@@ -1,4 +1,5 @@
1
1
  import { buildHeaders } from "../api/headers.js";
2
+ import { knSearchHttp } from "../api/semantic-search.js";
2
3
  import { objectTypeQuery, objectTypeProperties, subgraph, actionTypeQuery, actionTypeExecute, actionExecutionGet, actionLogsList, actionLogGet, actionLogCancel, } from "../api/ontology-query.js";
3
4
  import { fetchTextOrThrow } from "../utils/http.js";
4
5
  /** BKN engine resource — instance queries, subgraph, action execution and logs. */
@@ -88,14 +89,25 @@ export class BknResource {
88
89
  }
89
90
  /**
90
91
  * Search KN schema — finds matching object types, relation types, and action types.
91
- * Uses MCP protocol via the context-loader (public endpoint).
92
+ * Uses the public agent-retrieval HTTP compatibility endpoint.
92
93
  */
93
94
  async knSearch(knId, query, opts = {}) {
94
- const { ContextLoaderResource } = await import("./context-loader.js");
95
- const { baseUrl } = this.ctx.base();
96
- const mcpUrl = `${baseUrl}/api/agent-retrieval/v1/mcp`;
97
- const cl = new ContextLoaderResource(this.ctx, mcpUrl, knId);
98
- const result = await cl.search({ query, only_schema: opts.onlySchema ?? false });
99
- return result;
95
+ const raw = await knSearchHttp({
96
+ ...this.ctx.base(),
97
+ knId,
98
+ query,
99
+ onlySchema: opts.onlySchema ?? false,
100
+ });
101
+ let parsed;
102
+ try {
103
+ parsed = JSON.parse(raw);
104
+ }
105
+ catch {
106
+ throw new Error(`kn_search returned non-JSON body (first 200 chars): ${raw.slice(0, 200)}`);
107
+ }
108
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
109
+ throw new Error(`kn_search returned unexpected JSON shape (first 200 chars): ${raw.slice(0, 200)}`);
110
+ }
111
+ return parsed;
100
112
  }
101
113
  }
@@ -1,4 +1,4 @@
1
- import type { KnSearchArgs, KnSchemaSearchArgs, QueryObjectInstanceArgs, QueryInstanceSubgraphArgs, GetLogicPropertiesValuesArgs, GetActionInfoArgs } from "../api/context-loader.js";
1
+ import type { SearchSchemaArgs, QueryObjectInstanceArgs, QueryInstanceSubgraphArgs, GetLogicPropertiesValuesArgs, GetActionInfoArgs, FindSkillsArgs, FindSkillsResult } from "../api/context-loader.js";
2
2
  import type { ClientContext } from "../client.js";
3
3
  export declare class ContextLoaderResource {
4
4
  private readonly ctx;
@@ -6,10 +6,11 @@ export declare class ContextLoaderResource {
6
6
  private readonly knId;
7
7
  constructor(ctx: ClientContext, mcpUrl: string, knId: string);
8
8
  private opts;
9
- search(args: KnSearchArgs): Promise<unknown>;
10
- schemaSearch(args: KnSchemaSearchArgs): Promise<unknown>;
9
+ callTool(toolName: string, args: Record<string, unknown>): Promise<unknown>;
10
+ searchSchema(args: SearchSchemaArgs): Promise<unknown>;
11
11
  queryInstances(args: QueryObjectInstanceArgs): Promise<unknown>;
12
12
  querySubgraph(args: QueryInstanceSubgraphArgs): Promise<unknown>;
13
13
  getLogicProperties(args: GetLogicPropertiesValuesArgs): Promise<unknown>;
14
14
  getActionInfo(args: GetActionInfoArgs): Promise<unknown>;
15
+ findSkills(args: FindSkillsArgs): Promise<FindSkillsResult>;
15
16
  }
@@ -1,4 +1,4 @@
1
- import { knSearch, knSchemaSearch, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, } from "../api/context-loader.js";
1
+ import { callTool, searchSchema, queryObjectInstance, queryInstanceSubgraph, getLogicPropertiesValues, getActionInfo, findSkills, } from "../api/context-loader.js";
2
2
  export class ContextLoaderResource {
3
3
  ctx;
4
4
  mcpUrl;
@@ -11,11 +11,11 @@ export class ContextLoaderResource {
11
11
  opts() {
12
12
  return { mcpUrl: this.mcpUrl, knId: this.knId, accessToken: this.ctx.base().accessToken };
13
13
  }
14
- async search(args) {
15
- return knSearch(this.opts(), args);
14
+ async callTool(toolName, args) {
15
+ return callTool(this.opts(), toolName, args);
16
16
  }
17
- async schemaSearch(args) {
18
- return knSchemaSearch(this.opts(), args);
17
+ async searchSchema(args) {
18
+ return searchSchema(this.opts(), args);
19
19
  }
20
20
  async queryInstances(args) {
21
21
  return queryObjectInstance(this.opts(), args);
@@ -29,4 +29,7 @@ export class ContextLoaderResource {
29
29
  async getActionInfo(args) {
30
30
  return getActionInfo(this.opts(), args);
31
31
  }
32
+ async findSkills(args) {
33
+ return findSkills(this.opts(), args);
34
+ }
32
35
  }
@@ -1,4 +1,5 @@
1
1
  import type { ClientContext } from "../client.js";
2
+ import { type ImpexType } from "../api/toolboxes.js";
2
3
  export interface InvokeToolArgs {
3
4
  /** Optional headers to forward to the downstream tool. Authorization is
4
5
  * auto-injected from the client's access token when omitted; pass `{}` to
@@ -35,5 +36,19 @@ export declare class ToolboxesResource {
35
36
  execute(boxId: string, toolId: string, args?: InvokeToolArgs): Promise<string>;
36
37
  /** Debug a tool through the toolbox proxy (works on draft/disabled tools too). */
37
38
  debug(boxId: string, toolId: string, args?: InvokeToolArgs): Promise<string>;
39
+ /**
40
+ * Export a toolbox/mcp/operator config (.adp JSON) as raw bytes.
41
+ *
42
+ * Returned bytes are usually UTF-8 JSON; mirrors the Python SDK's
43
+ * `export_config -> bytes`. Use `new TextDecoder().decode(buf)` if you
44
+ * need a string.
45
+ */
46
+ exportConfig(id: string, opts?: {
47
+ type?: ImpexType;
48
+ }): Promise<Uint8Array>;
49
+ /** Import a previously exported config from disk. */
50
+ importConfig(filePath: string, opts?: {
51
+ type?: ImpexType;
52
+ }): Promise<string>;
38
53
  private injectAuth;
39
54
  }
@@ -1,4 +1,4 @@
1
- import { debugTool, executeTool, listTools, listToolboxes, setToolStatuses, uploadTool, } from "../api/toolboxes.js";
1
+ import { debugTool, executeTool, exportConfig, importConfig, listTools, listToolboxes, setToolStatuses, uploadTool, } from "../api/toolboxes.js";
2
2
  /** Toolbox / tool management on the agent-operator-integration service. */
3
3
  export class ToolboxesResource {
4
4
  ctx;
@@ -40,6 +40,20 @@ export class ToolboxesResource {
40
40
  ...this.injectAuth(args),
41
41
  });
42
42
  }
43
+ /**
44
+ * Export a toolbox/mcp/operator config (.adp JSON) as raw bytes.
45
+ *
46
+ * Returned bytes are usually UTF-8 JSON; mirrors the Python SDK's
47
+ * `export_config -> bytes`. Use `new TextDecoder().decode(buf)` if you
48
+ * need a string.
49
+ */
50
+ async exportConfig(id, opts = {}) {
51
+ return exportConfig({ ...this.ctx.base(), id, type: opts.type });
52
+ }
53
+ /** Import a previously exported config from disk. */
54
+ async importConfig(filePath, opts = {}) {
55
+ return importConfig({ ...this.ctx.base(), filePath, type: opts.type });
56
+ }
43
57
  // The forwarder requires every header the downstream tool expects to be set
44
58
  // explicitly under `header`; most published tools declare an Authorization
45
59
  // parameter and would otherwise see no token. Auto-inject the active
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kweaver-ai/kweaver-sdk",
3
- "version": "0.6.10",
3
+ "version": "0.7.1",
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",