@openbkn/bkn-sdk 0.1.5-rc.1 → 0.1.5-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -7
- package/README.zh.md +53 -1
- package/dist/{chunk-WIYRGBAB.js → chunk-3K5GRQWI.js} +3964 -1810
- package/dist/cli.js +2259 -830
- package/dist/index.d.ts +2300 -1032
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,17 +47,40 @@ openbkn admin role list
|
|
|
47
47
|
# Raw passthrough to any endpoint
|
|
48
48
|
openbkn call /api/bkn-backend/v1/knowledge-networks
|
|
49
49
|
|
|
50
|
-
#
|
|
50
|
+
# Return an MCP tool result with its validated BKN Trace receipt
|
|
51
|
+
openbkn --json context tool-call <kn-id> <tool-name> --args '{"k":"v"}' --receipt
|
|
52
|
+
|
|
53
|
+
# Global flags: --base-url, --token, --user, --json/--compact, -k/--insecure,
|
|
51
54
|
# --conversation-id/--interaction-id (BKN Trace correlation; also BKN_CONVERSATION_ID/BKN_INTERACTION_ID)
|
|
52
55
|
# --new-conversation (ignore the remembered conversation for this command)
|
|
53
56
|
openbkn --help # grouped command map
|
|
54
57
|
```
|
|
55
58
|
|
|
56
|
-
On a
|
|
59
|
+
On a deploy with the managed lifecycle, commands continue the conversation the previous one
|
|
57
60
|
opened, so work spanning several commands lands in one thread. `openbkn context conversation` shows which
|
|
58
61
|
is in force and where it came from; `--forget` drops it. An explicit `--token` /
|
|
59
62
|
`BKN_TOKEN` opts out (identity there is the token, not the stored user) — use
|
|
60
63
|
`BKN_CONVERSATION_ID` to thread such a script's commands together.
|
|
64
|
+
`--interaction-id` / `BKN_INTERACTION_ID` can be supplied on its own for
|
|
65
|
+
existing scripts. The SDK follows the automatic lifecycle handshake, but does
|
|
66
|
+
not forward that orphan ID as a business header once it has opened an
|
|
67
|
+
authoritative context; it never invents a matching Conversation ID locally. Use
|
|
68
|
+
the returned receipt to establish the authoritative business context.
|
|
69
|
+
|
|
70
|
+
`context tool-call --receipt` requires `--json` or `--compact` and emits
|
|
71
|
+
`{ value, bkn_receipt }` (`--compact` is the one-line form). It is opt-in; the default command output and SDK
|
|
72
|
+
`context.toolCall()` remain business-value-only. The receipt is validated for this
|
|
73
|
+
call, not a bearer credential; confirm access under the current identity with
|
|
74
|
+
`openbkn trace receipts get <receipt-id>` when authorization evidence is required.
|
|
75
|
+
Check `bkn_receipt.receipt_status`, not whether `value` is `null`: a `pending`
|
|
76
|
+
receipt has no consumable value and must be read back by `receipt_id` rather
|
|
77
|
+
than retried. On a 0.1.5 platform a `completed` receipt carries only
|
|
78
|
+
`receipt_status`, `evidence_durability`, `observed_evidence_refs` and
|
|
79
|
+
`business_refs` (plus `partial_reasons` when set); `receipt_id` and the other
|
|
80
|
+
identity fields come with `pending` and terminal-replay receipts. To read the
|
|
81
|
+
complete record of a completed call, find its `receipt_id` with
|
|
82
|
+
`openbkn trace interactions operations <interaction-id>` and pass it to
|
|
83
|
+
`openbkn trace receipts get`.
|
|
61
84
|
|
|
62
85
|
Tokens are stored per platform/user under `~/.bkn/` (override: `BKN_CONFIG_DIR`).
|
|
63
86
|
|
|
@@ -101,8 +124,8 @@ where each id comes from; `--json` ships the same thing as data.
|
|
|
101
124
|
ecosystem) that lets an AI drive the `openbkn` CLI from natural language. It
|
|
102
125
|
ships a `SKILL.md` (trigger intents, `allowed-tools: Bash(openbkn *)`, a
|
|
103
126
|
command-group map, examples, and cautions) plus per-domain cheat sheets under
|
|
104
|
-
`references/` (auth, bkn, model, vega, resource, context,
|
|
105
|
-
skill, toolbox, function, trace, admin, call) and two how-tos
|
|
127
|
+
`references/` (auth, appkey, bkn, model, vega, resource, context, mcp,
|
|
128
|
+
skill, toolbox, function, osdk, trace, admin, call) and two how-tos
|
|
106
129
|
(build-a-KN, troubleshooting).
|
|
107
130
|
|
|
108
131
|
A second skill, `skills/create-bkn/`, guides an AI through **authoring** a BKN
|
|
@@ -112,12 +135,20 @@ format spec, templates, and a worked example under `references/`. It pairs with
|
|
|
112
135
|
the `openbkn` skill, which then runs `openbkn bkn validate` / `push` on the
|
|
113
136
|
tree it produced.
|
|
114
137
|
|
|
115
|
-
|
|
138
|
+
A third skill, `skills/create-skill/`, guides an AI through **authoring a Skill
|
|
139
|
+
package** for the execution factory — a `SKILL.md` that declares which metrics,
|
|
140
|
+
functions, actions and MCP tools of one knowledge network it uses and how an
|
|
141
|
+
agent should call them — and through writing a sandbox function with
|
|
142
|
+
`bkn-osdk` and registering it as a tool. Templates and a worked example that
|
|
143
|
+
was verified end-to-end live under `assets/` and `references/`.
|
|
144
|
+
|
|
145
|
+
None of the skills is part of the npm package — they're registered separately:
|
|
116
146
|
|
|
117
147
|
```bash
|
|
118
148
|
# Install a skill (globally), then ask in natural language:
|
|
119
|
-
npx skills add openbkn-ai/bkn-sdk@openbkn -g -y
|
|
120
|
-
npx skills add openbkn-ai/bkn-sdk@create-bkn -g -y
|
|
149
|
+
npx skills add openbkn-ai/bkn-sdk@openbkn -g -y # operate the platform
|
|
150
|
+
npx skills add openbkn-ai/bkn-sdk@create-bkn -g -y # author .bkn files
|
|
151
|
+
npx skills add openbkn-ai/bkn-sdk@create-skill -g -y # author a Skill package / function tool
|
|
121
152
|
|
|
122
153
|
# "列出所有知识网络" / "list all knowledge networks"
|
|
123
154
|
# "从 Vega catalog vcat-1 建一个名为 customers 的知识网络并构建索引"
|
package/README.zh.md
CHANGED
|
@@ -41,7 +41,10 @@ openbkn admin role list
|
|
|
41
41
|
# 任意端点的原始透传
|
|
42
42
|
openbkn call /api/bkn-backend/v1/knowledge-networks
|
|
43
43
|
|
|
44
|
-
#
|
|
44
|
+
# 返回 MCP 工具结果及其已校验的 BKN Trace Receipt
|
|
45
|
+
openbkn --json context tool-call <kn-id> <tool-name> --args '{"k":"v"}' --receipt
|
|
46
|
+
|
|
47
|
+
# 全局参数:--base-url --token --user --json/--compact -k/--insecure
|
|
45
48
|
# --conversation-id/--interaction-id(BKN Trace 关联,等价 env:BKN_CONVERSATION_ID/BKN_INTERACTION_ID)
|
|
46
49
|
# --new-conversation(这条命令不沿用记住的 conversation)
|
|
47
50
|
openbkn --help # 分组命令树
|
|
@@ -51,6 +54,19 @@ openbkn --help # 分组命令树
|
|
|
51
54
|
`openbkn context conversation` 显示当前生效的是哪个、来自哪一层;`--forget` 丢掉它。
|
|
52
55
|
显式 `--token` / `BKN_TOKEN` 不参与(那里的身份是 token 本身,不是存下来的用户)——
|
|
53
56
|
这类脚本用 `BKN_CONVERSATION_ID` 把多条命令串起来。
|
|
57
|
+
既有脚本可以单独提供 `--interaction-id` / `BKN_INTERACTION_ID`。SDK 会走自动 lifecycle handshake;
|
|
58
|
+
一旦建立权威上下文,孤立 ID 不会再作为业务 header 透传,也不会在本地伪造对应的 Conversation ID;以返回的
|
|
59
|
+
Receipt 确认权威业务上下文。
|
|
60
|
+
|
|
61
|
+
`context tool-call --receipt` 必须带 `--json` 或 `--compact`,输出 `{ value, bkn_receipt }`(
|
|
62
|
+
`--compact` 即单行形式)。这是显式选择;默认命令输出和 SDK 的 `context.toolCall()` 仍只返回
|
|
63
|
+
业务值。Receipt 仅证明其已通过本次调用的字段校验,不是 bearer credential;需要授权证据时,
|
|
64
|
+
应在当前身份下运行 `openbkn trace receipts get <receipt-id>` 回读确认。
|
|
65
|
+
不要用 `value` 是否为 `null` 判断结果是否可用;应检查 `bkn_receipt.receipt_status`。`pending` 表示
|
|
66
|
+
业务值不可消费,应使用 `receipt_id` 回读,而不是重试业务工具。0.1.5 平台上 `completed` 回执只带
|
|
67
|
+
`receipt_status`、`evidence_durability`、`observed_evidence_refs`、`business_refs`(有 `partial_reasons` 时一并带上),
|
|
68
|
+
没有 `receipt_id`;需要回读完整记录时,用 `openbkn trace interactions operations <interaction-id>` 找到该次调用的
|
|
69
|
+
`receipt_id`,再执行 `openbkn trace receipts get`。`pending` 与终态重放回执仍带身份字段。
|
|
54
70
|
|
|
55
71
|
Token 按平台/用户存于 `~/.bkn/`(可用 `BKN_CONFIG_DIR` 覆盖)。
|
|
56
72
|
|
|
@@ -86,6 +102,42 @@ npm run build # tsup → dist/(库 + openbkn bin)
|
|
|
86
102
|
每个命令、子命令、孙命令都带分组 `--help`,列出各自的参数与位置参数,
|
|
87
103
|
整棵命令树可端到端发现。`openbkn help all` 输出全深度的逐动作签名清单。
|
|
88
104
|
|
|
105
|
+
## Agent 技能
|
|
106
|
+
|
|
107
|
+
`skills/openbkn/` 是一个 Agent 技能(面向 Claude Code / [skills.sh](https://skills.sh)
|
|
108
|
+
生态),让 AI 用自然语言驱动 `openbkn` CLI。它包含一份 `SKILL.md`(触发意图、
|
|
109
|
+
`allowed-tools: Bash(openbkn *)`、命令组地图、示例与注意事项),`references/` 下
|
|
110
|
+
按领域划分的速查表(auth、appkey、bkn、model、vega、resource、context、mcp、
|
|
111
|
+
skill、toolbox、function、osdk、trace、admin、call),以及两篇操作指南
|
|
112
|
+
(建知识网络、排障)。
|
|
113
|
+
|
|
114
|
+
第二个技能 `skills/create-bkn/` 引导 AI **编写** BKN 定义目录(`network.bkn` +
|
|
115
|
+
按类型分目录的 `object_types/` / `relation_types/` / `action_types/` /
|
|
116
|
+
`concept_groups/` 文件,遵循 v2.0.1 规范),`references/` 下附格式规范、模板和
|
|
117
|
+
完整示例。它与 `openbkn` 技能配合:产出的目录再由 `openbkn bkn validate` / `push`
|
|
118
|
+
校验和导入。
|
|
119
|
+
|
|
120
|
+
第三个技能 `skills/create-skill/` 引导 AI 为执行工厂**编写 Skill 包**——一份
|
|
121
|
+
`SKILL.md`,声明它用到某个知识网络的哪些指标、函数、行动和 MCP 工具,以及 Agent
|
|
122
|
+
该如何调用——并用 `bkn-osdk` 编写沙箱函数、注册成工具。`assets/` 与 `references/`
|
|
123
|
+
下有模板和一个端到端验证过的示例。
|
|
124
|
+
|
|
125
|
+
这些技能都不在 npm 包里,需要单独安装:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# 全局安装技能,然后用自然语言提问:
|
|
129
|
+
npx skills add openbkn-ai/bkn-sdk@openbkn -g -y # 操作平台
|
|
130
|
+
npx skills add openbkn-ai/bkn-sdk@create-bkn -g -y # 编写 .bkn 文件
|
|
131
|
+
npx skills add openbkn-ai/bkn-sdk@create-skill -g -y # 编写 Skill 包 / 函数工具
|
|
132
|
+
|
|
133
|
+
# "列出所有知识网络"
|
|
134
|
+
# "从 Vega catalog vcat-1 建一个名为 customers 的知识网络并构建索引"
|
|
135
|
+
# "帮我建一个描述订单域的 BKN 知识网络文件"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`openbkn` 技能假定已安装 `openbkn` CLI(`npm i -g @openbkn/bkn-sdk`)并已登录
|
|
139
|
+
(`openbkn auth login`)。确切参数始终以实时 `openbkn <group> <sub> --help` 为准。
|
|
140
|
+
|
|
89
141
|
## 许可证
|
|
90
142
|
|
|
91
143
|
BKN SDK 是 OpenBKN 项目的一部分,采用 **Apache License, Version 2.0**。
|