@kweaver-ai/kweaver-sdk 0.6.9 → 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
 
@@ -12,11 +12,24 @@ export async function listAgents(options) {
12
12
  custom_space_id,
13
13
  is_to_square,
14
14
  });
15
- const response = await fetchWithRetry(url, {
15
+ // Some deployments (observed on dip-poc.aishu.cn) return an empty entries
16
+ // array when this endpoint is called with `application/json`; the same
17
+ // payload sent as `text/plain` works. Other deployments only accept
18
+ // `application/json` (and reject text/plain with 4xx). Try text/plain first
19
+ // and fall back to application/json on 4xx so both platform variants work
20
+ // out of the box.
21
+ const tryPost = async (contentType) => fetchWithRetry(url, {
16
22
  method: "POST",
17
- headers: buildHeaders(accessToken, businessDomain),
23
+ headers: {
24
+ ...buildHeaders(accessToken, businessDomain),
25
+ "content-type": contentType,
26
+ },
18
27
  body,
19
28
  });
29
+ let response = await tryPost("text/plain;charset=UTF-8");
30
+ if (!response.ok && response.status >= 400 && response.status < 500) {
31
+ response = await tryPost("application/json");
32
+ }
20
33
  const responseBody = await response.text();
21
34
  if (!response.ok) {
22
35
  throw new HttpError(response.status, response.statusText, responseBody);
@@ -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 } : {});
@@ -44,11 +44,40 @@ export declare function actionTypeQuery(options: ActionTypeQueryOptions): Promis
44
44
  /**
45
45
  * Action-type execute: POST (has side effects).
46
46
  *
47
- * The request body must include `_instance_identities`an array of objects
48
- * identifying which instances the action operates on:
47
+ * The request body must use the envelope shape below top-level scalar fields
48
+ * (other than `trigger_type` and `_instance_identities`) are silently dropped
49
+ * by the backend, which causes downstream tools to receive `null` parameters
50
+ * (and typically respond with 401 token expired or 500 type errors).
51
+ *
49
52
  * ```json
50
- * {"_instance_identities": [{"<primary_key>": "<value>"}], ...otherParams}
53
+ * {
54
+ * "trigger_type": "manual",
55
+ * "_instance_identities": [{"<primary_key>": "<value>"}],
56
+ * "dynamic_params": {
57
+ * "<param_name>": "<value>",
58
+ * "Authorization": "Bearer <token>"
59
+ * }
60
+ * }
51
61
  * ```
62
+ *
63
+ * - `_instance_identities` may be `[]` for "create"-style actions.
64
+ * - Each ActionType parameter has a `value_from` discriminator:
65
+ * • `input` — caller MUST supply via `dynamic_params`. Includes
66
+ * `source: header` params (e.g. `Authorization`/`token`),
67
+ * which are usually credentials for the DOWNSTREAM system
68
+ * the action calls — NOT the platform session token. The
69
+ * SDK never auto-forwards its session token.
70
+ * • `const` — frozen in the ActionType snapshot; values in body are
71
+ * silently ignored. Edit the ActionType definition to
72
+ * `input` first if you need caller override.
73
+ * • `property` — auto-populated from the resolved instance's property;
74
+ * do not (and cannot) supply via body.
75
+ *
76
+ * Practical recipe: query the ActionType, filter parameters where
77
+ * `value_from == "input"`, put exactly those names into `dynamic_params`.
78
+ *
79
+ * See `skills/kweaver-core/references/bkn.md` ("action-type execute 请求体契约")
80
+ * for the full contract and troubleshooting table.
52
81
  */
53
82
  export interface ActionTypeExecuteOptions extends OntologyQueryBaseOptions {
54
83
  atId: string;
@@ -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,4 +44,32 @@ 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>;
59
+ export interface InvokeToolOptions extends BaseOpts {
60
+ boxId: string;
61
+ toolId: string;
62
+ /** Optional headers to forward to the downstream tool (e.g. Authorization). */
63
+ header?: Record<string, unknown>;
64
+ /** Optional query params to forward. */
65
+ query?: Record<string, unknown>;
66
+ /** JSON body forwarded to the downstream tool. */
67
+ body?: unknown;
68
+ /** Per-call timeout in seconds; backend default applies when omitted. */
69
+ timeout?: number;
70
+ }
71
+ /** Execute a published+enabled tool through the toolbox proxy. */
72
+ export declare function executeTool(opts: InvokeToolOptions): Promise<string>;
73
+ /** Debug a tool through the toolbox proxy (works on draft/disabled tools too). */
74
+ export declare function debugTool(opts: InvokeToolOptions): Promise<string>;
47
75
  export {};
@@ -1,19 +1,28 @@
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
  //
7
7
  // Verified against kweaver/examples/03-action-lifecycle/run.sh (lines 78–197):
8
- // POST /tool-box create
9
- // DELETE /tool-box/{id} delete
10
- // POST /tool-box/{id}/status publish/draft
11
- // POST /tool-box/{id}/tool upload tool (multipart)
12
- // POST /tool-box/{id}/tools/status enable/disable (batch)
8
+ // POST /tool-box create
9
+ // DELETE /tool-box/{id} delete
10
+ // POST /tool-box/{id}/status publish/draft
11
+ // POST /tool-box/{id}/tool upload tool (multipart)
12
+ // POST /tool-box/{id}/tools/status enable/disable (batch)
13
13
  //
14
14
  // Verified during Task 8 e2e against the live backend (2026-04-18):
15
15
  // GET /tool-box/list?keyword=&limit=&offset= list toolboxes
16
16
  // GET /tool-box/{id}/tools/list list tools
17
+ //
18
+ // Verified live on 2026-04-23 against dip-poc.aishu.cn:
19
+ // POST /tool-box/{box}/proxy/{tool} execute tool (envelope JSON)
20
+ // POST /tool-box/{box}/tool/{tool}/debug debug tool (envelope JSON)
21
+ //
22
+ // Envelope shape required by /proxy and /debug:
23
+ // { "timeout": <s>, "header": {...}, "query": {...}, "body": {...} }
24
+ // Flat-shape requests cause the forwarder to drop downstream Authorization
25
+ // headers, which manifests as 401 "token expired" from the underlying tool.
17
26
  const PATH = "/api/agent-operator-integration/v1/tool-box";
18
27
  function url(base, suffix = "") {
19
28
  return `${base.replace(/\/+$/, "")}${PATH}${suffix}`;
@@ -88,3 +97,70 @@ export async function listTools(opts) {
88
97
  });
89
98
  return body;
90
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
+ }
142
+ function buildEnvelope(opts) {
143
+ const envelope = {};
144
+ if (opts.timeout !== undefined)
145
+ envelope.timeout = opts.timeout;
146
+ envelope.header = opts.header ?? {};
147
+ envelope.query = opts.query ?? {};
148
+ envelope.body = opts.body ?? {};
149
+ return JSON.stringify(envelope);
150
+ }
151
+ async function invokeTool(opts, suffix) {
152
+ const { body } = await fetchTextOrThrow(url(opts.baseUrl, suffix), {
153
+ method: "POST",
154
+ headers: { ...buildHeaders(opts.accessToken, opts.businessDomain ?? "bd_public"), "content-type": "application/json" },
155
+ body: buildEnvelope(opts),
156
+ });
157
+ return body;
158
+ }
159
+ /** Execute a published+enabled tool through the toolbox proxy. */
160
+ export async function executeTool(opts) {
161
+ return invokeTool(opts, `/${encodeURIComponent(opts.boxId)}/proxy/${encodeURIComponent(opts.toolId)}`);
162
+ }
163
+ /** Debug a tool through the toolbox proxy (works on draft/disabled tools too). */
164
+ export async function debugTool(opts) {
165
+ return invokeTool(opts, `/${encodeURIComponent(opts.boxId)}/tool/${encodeURIComponent(opts.toolId)}/debug`);
166
+ }
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]
@@ -88,7 +88,8 @@ Usage:
88
88
  kweaver bkn object-type list|get|create|update|delete|query|properties <kn-id> ...
89
89
  kweaver bkn relation-type list|get|create|update|delete <kn-id> ...
90
90
  kweaver bkn subgraph <kn-id> <body-json>
91
- kweaver bkn action-type list|query|execute <kn-id> ... [--wait] [--no-wait] [--timeout N]
91
+ kweaver bkn action-type list|query|inputs|execute <kn-id> ... [--wait] [--no-wait] [--timeout N]
92
+ kweaver bkn action-type execute <kn-id> <at-id> [<envelope-json>|--dynamic-params '<json>' --instance '<json>' --trigger-type <v>]
92
93
  kweaver bkn action-execution get <kn-id> <execution-id>
93
94
  kweaver bkn action-log list|get|cancel <kn-id> ...
94
95
 
@@ -106,10 +107,15 @@ Usage:
106
107
  kweaver toolbox list [--keyword X] [--limit N] [--offset N] [-bd value]
107
108
  kweaver toolbox publish|unpublish <box-id> [-bd value]
108
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]
109
112
 
110
113
  kweaver tool upload --toolbox <box-id> <openapi-spec-path> [--metadata-type openapi]
111
114
  kweaver tool list --toolbox <box-id> [-bd value]
112
115
  kweaver tool enable|disable --toolbox <box-id> <tool-id>... [-bd value]
116
+ kweaver tool execute|debug --toolbox <box-id> <tool-id>
117
+ [--body '<json>'|--body-file <path>]
118
+ [--header '<json>'] [--query '<json>'] [--timeout <s>]
113
119
 
114
120
  kweaver vega health|stats|inspect
115
121
  kweaver vega catalog list|get|health|test-connection|discover|resources [options]
@@ -121,13 +127,18 @@ Usage:
121
127
  kweaver context-loader tools|resources|templates|prompts [--cursor]
122
128
  kweaver context-loader resource <uri>
123
129
  kweaver context-loader prompt <name> [--args json]
124
- kweaver context-loader kn-search <query> [--only-schema]
125
- kweaver context-loader kn-schema-search <query> [--max N]
126
- 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 ...
127
135
  (alias: kweaver context ...)
128
136
 
129
137
  Global options:
130
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).
131
142
 
132
143
  Commands:
133
144
  auth Login, list, inspect, and switch saved platform auth profiles
@@ -141,10 +152,10 @@ Commands:
141
152
  object-type, relation-type, subgraph, action-type, action-execution, action-log)
142
153
  config Per-platform configuration (business domain)
143
154
  skill Skill registry and market (register, search, progressive read, download/install)
144
- toolbox Agent toolbox lifecycle (create, list, publish, delete)
155
+ toolbox Agent toolbox lifecycle (create, list, publish, delete, export, import)
145
156
  tool Tools inside a toolbox (upload OpenAPI spec, list, enable/disable)
146
157
  vega Vega observability (catalog, resource, query/sql, connector-type, health/stats/inspect)
147
- 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.)
148
159
  help Show this message`);
149
160
  }
150
161
  export async function run(argv) {
package/dist/client.d.ts CHANGED
@@ -7,6 +7,7 @@ import { DataViewsResource } from "./resources/dataviews.js";
7
7
  import { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
8
8
  import { BknResource } from "./resources/bkn.js";
9
9
  import { SkillsResource } from "./resources/skills.js";
10
+ import { ToolboxesResource } from "./resources/toolboxes.js";
10
11
  import { VegaResource } from "./resources/vega.js";
11
12
  /**
12
13
  * Shared credentials passed to every resource method.
@@ -102,6 +103,8 @@ export declare class KWeaverClient implements ClientContext {
102
103
  readonly vega: VegaResource;
103
104
  /** ADP/KWeaver skill registry, market, progressive read, and install helpers. */
104
105
  readonly skills: SkillsResource;
106
+ /** Toolbox / tool management plus execute & debug invocation. */
107
+ readonly toolboxes: ToolboxesResource;
105
108
  constructor(opts?: KWeaverClientOptions);
106
109
  /**
107
110
  * Async factory that auto-refreshes expired or revoked tokens.
package/dist/client.js CHANGED
@@ -12,6 +12,7 @@ import { DataViewsResource } from "./resources/dataviews.js";
12
12
  import { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
13
13
  import { BknResource } from "./resources/bkn.js";
14
14
  import { SkillsResource } from "./resources/skills.js";
15
+ import { ToolboxesResource } from "./resources/toolboxes.js";
15
16
  import { VegaResource } from "./resources/vega.js";
16
17
  // ── KWeaverClient ─────────────────────────────────────────────────────────────
17
18
  /**
@@ -64,6 +65,8 @@ export class KWeaverClient {
64
65
  vega;
65
66
  /** ADP/KWeaver skill registry, market, progressive read, and install helpers. */
66
67
  skills;
68
+ /** Toolbox / tool management plus execute & debug invocation. */
69
+ toolboxes;
67
70
  constructor(opts = {}) {
68
71
  const envDomain = process.env.KWEAVER_BUSINESS_DOMAIN;
69
72
  if (opts.auth === false && opts.config) {
@@ -97,6 +100,7 @@ export class KWeaverClient {
97
100
  this.dataviews = new DataViewsResource(this);
98
101
  this.vega = new VegaResource(this);
99
102
  this.skills = new SkillsResource(this);
103
+ this.toolboxes = new ToolboxesResource(this);
100
104
  return;
101
105
  }
102
106
  if (opts.config) {
@@ -151,6 +155,7 @@ export class KWeaverClient {
151
155
  this.dataviews = new DataViewsResource(this);
152
156
  this.vega = new VegaResource(this);
153
157
  this.skills = new SkillsResource(this);
158
+ this.toolboxes = new ToolboxesResource(this);
154
159
  }
155
160
  /**
156
161
  * Async factory that auto-refreshes expired or revoked tokens.