@the-ai-company/cbio-node-runtime 1.55.0 → 1.56.0
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 +48 -11
- package/dist/clients/agent/client.d.ts +5 -0
- package/dist/clients/agent/client.js +11 -0
- package/dist/clients/agent/client.js.map +1 -1
- package/dist/clients/agent/contracts.d.ts +1 -0
- package/dist/clients/owner/client.d.ts +2 -2
- package/dist/clients/owner/client.js +52 -11
- package/dist/clients/owner/client.js.map +1 -1
- package/dist/clients/owner/contracts.d.ts +15 -2
- package/dist/clients/owner/index.d.ts +1 -1
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/owner-session.d.ts +26 -0
- package/dist/runtime/owner-session.js +89 -0
- package/dist/runtime/owner-session.js.map +1 -0
- package/dist/vault-core/contracts.d.ts +31 -0
- package/dist/vault-core/contracts.js.map +1 -1
- package/dist/vault-core/core.d.ts +3 -1
- package/dist/vault-core/core.js +92 -10
- package/dist/vault-core/core.js.map +1 -1
- package/dist/vault-core/defaults.js +3 -2
- package/dist/vault-core/defaults.js.map +1 -1
- package/dist/vault-core/index.d.ts +1 -1
- package/dist/vault-core/index.js.map +1 -1
- package/dist/vault-core/persistence.js +3 -3
- package/dist/vault-core/persistence.js.map +1 -1
- package/dist/vault-core/tool-metadata.d.ts +6 -0
- package/dist/vault-core/tool-metadata.js +59 -0
- package/dist/vault-core/tool-metadata.js.map +1 -0
- package/dist/vault-ingress/defaults.d.ts +1 -0
- package/dist/vault-ingress/defaults.js +3 -0
- package/dist/vault-ingress/defaults.js.map +1 -1
- package/dist/vault-ingress/index.d.ts +8 -0
- package/dist/vault-ingress/index.js +5 -0
- package/dist/vault-ingress/index.js.map +1 -1
- package/dist/vault-ingress/remote-transport.d.ts +1 -0
- package/dist/vault-ingress/remote-transport.js +11 -0
- package/dist/vault-ingress/remote-transport.js.map +1 -1
- package/docs/MIGRATION-1.51.md +3 -0
- package/docs/REFERENCE.md +19 -2
- package/docs/api/README.md +7 -2
- package/docs/api/classes/IdentityError.md +1 -1
- package/docs/api/classes/OwnerClientError.md +1 -1
- package/docs/api/classes/VaultCore.md +17 -1
- package/docs/api/classes/VaultCoreError.md +1 -1
- package/docs/api/enumerations/IdentityErrorCode.md +1 -1
- package/docs/api/enumerations/OwnerClientErrorCode.md +1 -1
- package/docs/api/functions/createAgentClient.md +1 -1
- package/docs/api/functions/createIdentity.md +1 -1
- package/docs/api/functions/createOwnerHttpFlowBoundary.md +1 -1
- package/docs/api/functions/createOwnerSession.md +37 -0
- package/docs/api/functions/createPersistentVaultCoreDependencies.md +1 -1
- package/docs/api/functions/createStandardAcquireBoundary.md +1 -1
- package/docs/api/functions/createStandardDispatchBoundary.md +1 -1
- package/docs/api/functions/createVault.md +1 -1
- package/docs/api/functions/createVaultClient.md +1 -1
- package/docs/api/functions/createVaultCore.md +1 -1
- package/docs/api/functions/createVaultCoreDependencies.md +1 -1
- package/docs/api/functions/createVaultService.md +1 -1
- package/docs/api/functions/createWorkspaceStorage.md +1 -1
- package/docs/api/functions/deriveIdentityId.md +1 -1
- package/docs/api/functions/deriveVaultWorkingKeyFromPassword.md +1 -1
- package/docs/api/functions/getDefaultWorkspaceDir.md +1 -1
- package/docs/api/functions/handleVaultAgentControlHttp.md +1 -1
- package/docs/api/functions/handleVaultHttpDispatch.md +1 -1
- package/docs/api/functions/initializeVaultCustody.md +1 -1
- package/docs/api/functions/listVaults.md +1 -1
- package/docs/api/functions/readVaultProfile.md +1 -1
- package/docs/api/functions/recoverVault.md +1 -1
- package/docs/api/functions/recoverVaultWorkingKey.md +1 -1
- package/docs/api/functions/restoreIdentity.md +1 -1
- package/docs/api/functions/updateVaultMetadata.md +1 -1
- package/docs/api/functions/wrapVaultCoreAsVaultService.md +1 -1
- package/docs/api/functions/writeVaultProfile.md +1 -1
- package/docs/api/interfaces/AgentClient.md +14 -1
- package/docs/api/interfaces/AgentDispatchIntent.md +1 -1
- package/docs/api/interfaces/AgentDispatchTransport.md +17 -1
- package/docs/api/interfaces/AgentIdentity.md +1 -1
- package/docs/api/interfaces/AgentSigner.md +1 -1
- package/docs/api/interfaces/AgentSubmitCapabilityRequestInput.md +1 -1
- package/docs/api/interfaces/CbioRuntime.md +39 -1
- package/docs/api/interfaces/CreateAgentClientOptions.md +1 -1
- package/docs/api/interfaces/CreateIdentityOptions.md +1 -1
- package/docs/api/interfaces/CreateOwnerSessionOptions.md +245 -0
- package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +1 -1
- package/docs/api/interfaces/CreateVaultClientOptions.md +1 -1
- package/docs/api/interfaces/CreateVaultOptions.md +1 -1
- package/docs/api/interfaces/CreatedVault.md +1 -1
- package/docs/api/interfaces/DefaultPolicyEngineOptions.md +1 -1
- package/docs/api/interfaces/IStorageProvider.md +1 -1
- package/docs/api/interfaces/InitializeVaultCustodyOptions.md +1 -1
- package/docs/api/interfaces/InitializedVaultCustody.md +1 -1
- package/docs/api/interfaces/OwnerAgentProvisionResult.md +1 -1
- package/docs/api/interfaces/OwnerDefineSecretTargetsInput.md +1 -1
- package/docs/api/interfaces/OwnerSecretTargetBinding.md +1 -1
- package/docs/api/interfaces/OwnerSensitiveActionConfirmation.md +1 -1
- package/docs/api/interfaces/OwnerSensitiveActionContext.md +2 -2
- package/docs/api/interfaces/OwnerSession.md +95 -0
- package/docs/api/interfaces/OwnerStoreSecretInput.md +1 -1
- package/docs/api/interfaces/OwnerWriteSecretInput.md +1 -1
- package/docs/api/interfaces/RecoverVaultOptions.md +5 -1
- package/docs/api/interfaces/RecoveredVault.md +1 -1
- package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
- package/docs/api/interfaces/Signer.md +1 -1
- package/docs/api/interfaces/VaultApproveCapabilityRequestInput.md +1 -1
- package/docs/api/interfaces/VaultApproveDispatchInput.md +1 -1
- package/docs/api/interfaces/VaultAuditQueryInput.md +1 -1
- package/docs/api/interfaces/VaultClient.md +2 -2
- package/docs/api/interfaces/VaultCoreDependenciesOptions.md +1 -1
- package/docs/api/interfaces/VaultCreateAgentInput.md +1 -1
- package/docs/api/interfaces/VaultDeleteSecretInput.md +13 -1
- package/docs/api/interfaces/VaultExportSecretInput.md +1 -1
- package/docs/api/interfaces/VaultGrantCapabilityInput.md +25 -1
- package/docs/api/interfaces/VaultGrantCapabilityRequest.md +23 -0
- package/docs/api/interfaces/VaultIdentity.md +1 -1
- package/docs/api/interfaces/VaultImportAgentInput.md +1 -1
- package/docs/api/interfaces/VaultIssueSessionTokenInput.md +1 -1
- package/docs/api/interfaces/VaultListAgentsInput.md +1 -1
- package/docs/api/interfaces/VaultListCapabilitiesInput.md +1 -1
- package/docs/api/interfaces/VaultListSecretsInput.md +1 -1
- package/docs/api/interfaces/VaultMetadata.md +1 -1
- package/docs/api/interfaces/VaultObject.md +1 -1
- package/docs/api/interfaces/VaultProfile.md +1 -1
- package/docs/api/interfaces/VaultReadAgentPrivateKeyInput.md +1 -1
- package/docs/api/interfaces/VaultReadSecretPlaintextInput.md +1 -1
- package/docs/api/interfaces/VaultRegisterFlowInput.md +1 -1
- package/docs/api/interfaces/VaultRevokeCapabilityInput.md +1 -1
- package/docs/api/interfaces/VaultRevokeSessionTokenInput.md +1 -1
- package/docs/api/interfaces/VaultSigner.md +1 -1
- package/docs/api/interfaces/VaultSubmitCapabilityRequestInput.md +1 -1
- package/docs/api/interfaces/VaultUpdateAgentInput.md +1 -1
- package/docs/api/type-aliases/AgentCapabilityEnvelope.md +1 -1
- package/docs/api/type-aliases/AgentVisibleSecretRecord.md +1 -1
- package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
- package/docs/api/type-aliases/OwnerGrantCapabilityInput.md +7 -0
- package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +1 -1
- package/docs/es/README.md +6 -9
- package/docs/fr/README.md +6 -10
- package/docs/ja/README.md +6 -9
- package/docs/ko/README.md +6 -9
- package/docs/pt/README.md +6 -9
- package/docs/zh/README.md +89 -42
- package/package.json +1 -1
package/docs/zh/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# cbio Vault Runtime
|
|
1
|
+
# cbio Vault Runtime(中文文档)
|
|
2
2
|
|
|
3
|
-
cbio
|
|
3
|
+
cbio Vault Runtime 采用 **Sovereign Vault(主权保险箱)** 架构:管理权限扎根于主密码,Agent 身份与机密材料由保险箱加密托管。
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -9,7 +9,8 @@ cbio 权限核心运行时:采用 **Sovereign Vault(主权保险箱)** 架
|
|
|
9
9
|
- **库优先**:纯 JavaScript/TypeScript 库,无 CLI 或 TUI。
|
|
10
10
|
- **权限中心化**:管理权限绑定于保险箱主密码,而非外部身份密钥。
|
|
11
11
|
- **Agent 身份托管**:支持在保险箱内直接生成并加密存储 Agent 私钥。
|
|
12
|
-
-
|
|
12
|
+
- **Agent Session Token**:为 Agent 发放可撤销的 session token,避免在消费进程中持有原始私钥。
|
|
13
|
+
- **进程隔离**:安全进程(Security Process)与 Agent 进程(Consumer Process)物理分离。
|
|
13
14
|
- **零泄露发现**:保险箱元数据全加密,未解锁前对外部完全透明。
|
|
14
15
|
|
|
15
16
|
## 安装
|
|
@@ -24,41 +25,76 @@ npm install @the-ai-company/cbio-node-runtime
|
|
|
24
25
|
|
|
25
26
|
### 1. 初始化保险箱
|
|
26
27
|
|
|
27
|
-
主权保险箱仅需存储提供者(Storage Provider)和主密码。
|
|
28
|
-
|
|
29
28
|
```ts
|
|
30
29
|
import { createVault, FsStorageProvider } from '@the-ai-company/cbio-node-runtime';
|
|
31
30
|
|
|
32
31
|
const storage = new FsStorageProvider('./my-vaults');
|
|
33
32
|
|
|
34
33
|
const myVault = await createVault(storage, {
|
|
35
|
-
vaultId: 'main-vault',
|
|
36
34
|
password: 'your-secure-password',
|
|
37
35
|
nickname: '生产环境保险箱'
|
|
38
36
|
});
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
### 2.
|
|
39
|
+
### 2. 恢复已存在的保险箱
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { recoverVault } from '@the-ai-company/cbio-node-runtime';
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
const vault = await recoverVault(storage, {
|
|
45
|
+
vaultId: myVault.core.vaultId.value,
|
|
46
|
+
password: 'your-secure-password'
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 3. GUI 的 Owner Session
|
|
51
|
+
|
|
52
|
+
对于 GUI 这类长生命周期进程,应该持有 `OwnerSession`,而不是长期缓存裸 `VaultClient`。
|
|
53
|
+
|
|
54
|
+
`createVaultClient(...)` 只负责基于当前 runtime 创建 owner client;它不应该跨 HMR、模块重载或 runtime 替换被长期复用。`OwnerSession` 会提供稳定的 SDK 句柄,并按需重新创建 owner client。
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { createOwnerSession } from '@the-ai-company/cbio-node-runtime';
|
|
58
|
+
|
|
59
|
+
const session = createOwnerSession(storage, {
|
|
60
|
+
vaultId: myVault.core.vaultId.value,
|
|
61
|
+
password: 'your-secure-password',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const createdAgent = await session.withClient((client) =>
|
|
65
|
+
client.ownerCreateAgent({ nickname: '后台处理插件' })
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const ownerClient = await session.client();
|
|
69
|
+
const agents = await ownerClient.ownerListAgents();
|
|
70
|
+
|
|
71
|
+
session.invalidate();
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
如果你写的是一次性脚本,`recoverVault(...)` 配合 `createVaultClient(...)` 仍然是合适的。
|
|
75
|
+
|
|
76
|
+
### 4. 托管 Agent 身份
|
|
44
77
|
|
|
45
78
|
```ts
|
|
46
79
|
import { createVaultClient } from '@the-ai-company/cbio-node-runtime';
|
|
47
80
|
|
|
48
|
-
const client = createVaultClient({
|
|
81
|
+
const client = createVaultClient({
|
|
82
|
+
vault: vault.vault,
|
|
83
|
+
passwordVerifier: vault.verifyPassword,
|
|
84
|
+
});
|
|
49
85
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
agentId: 'worker-1',
|
|
53
|
-
nickname: '后台处理插件'
|
|
86
|
+
const createdAgent = await client.ownerCreateAgent({
|
|
87
|
+
nickname: '后台处理插件',
|
|
54
88
|
});
|
|
89
|
+
|
|
90
|
+
const agentId = createdAgent.agent.agentId;
|
|
91
|
+
const sessionToken = createdAgent.sessionToken;
|
|
55
92
|
```
|
|
56
93
|
|
|
57
|
-
###
|
|
94
|
+
### 5. 机密管理
|
|
58
95
|
|
|
59
96
|
```ts
|
|
60
|
-
|
|
61
|
-
const record = await client.writeSecret({
|
|
97
|
+
const record = await client.ownerWriteSecret({
|
|
62
98
|
alias: 'api-token',
|
|
63
99
|
plaintext: 'secret-value',
|
|
64
100
|
targetBindings: [{
|
|
@@ -68,40 +104,51 @@ const record = await client.writeSecret({
|
|
|
68
104
|
methods: ['POST']
|
|
69
105
|
}]
|
|
70
106
|
});
|
|
107
|
+
|
|
108
|
+
await client.ownerGrantCapability({
|
|
109
|
+
agentId,
|
|
110
|
+
secretAliases: ['api-token'],
|
|
111
|
+
scope: 'https://api.example.com/*',
|
|
112
|
+
methods: ['POST']
|
|
113
|
+
});
|
|
71
114
|
```
|
|
72
115
|
|
|
73
|
-
|
|
116
|
+
### 6. Agent 消费机密
|
|
74
117
|
|
|
75
|
-
|
|
118
|
+
```ts
|
|
119
|
+
import { createAgentClient } from '@the-ai-company/cbio-node-runtime';
|
|
76
120
|
|
|
77
|
-
|
|
121
|
+
const agent = createAgentClient({
|
|
122
|
+
agentIdentity: { agentId },
|
|
123
|
+
capability: myCapability,
|
|
124
|
+
token: sessionToken.token,
|
|
125
|
+
vault: vault.vault
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const result = await agent.agentDispatch({ ... });
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Agent 进程不会直接使用原始私钥执行请求。即使 Agent 拥有身份材料,也应先换取 session token,再进行 dispatch。
|
|
132
|
+
|
|
133
|
+
### 7. 人机协同(HITL)工作流
|
|
134
|
+
|
|
135
|
+
系统采用 **“发现优先(Discovery-first)”** 模型。如果 Agent 尝试执行的动作不在白名单内,dispatch 会自动进入 `PENDING`,等待 Owner 审批。
|
|
78
136
|
|
|
79
137
|
```ts
|
|
80
|
-
|
|
81
|
-
const result = await agent.dispatch({ ... });
|
|
138
|
+
const result = await agent.agentDispatch({ ... });
|
|
82
139
|
if (result.status === 'PENDING') {
|
|
83
|
-
console.log(
|
|
140
|
+
console.log('触发发现流程:等待所有者审批...');
|
|
84
141
|
}
|
|
85
142
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
console.log("收到新请求:", req.requestId);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// 或者:启动时自动发牌 (v1.48.4+ 默认行为)
|
|
92
|
-
const client = createVaultClient({
|
|
93
|
-
vault,
|
|
94
|
-
ownerIdentity: { identityId: 'owner-1' }
|
|
95
|
-
// skipWarmup: true // 如果不想自动发牌,请传入此参数
|
|
143
|
+
client.ownerOnPendingDispatch((req) => {
|
|
144
|
+
console.log('收到新请求:', req.requestId);
|
|
96
145
|
});
|
|
97
146
|
|
|
98
|
-
|
|
99
|
-
const pending = await client.listPendingDispatches();
|
|
147
|
+
const pending = await client.ownerListPendingDispatches();
|
|
100
148
|
if (pending.length > 0) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
permanent: true
|
|
149
|
+
await client.ownerApproveDispatch({
|
|
150
|
+
requestId: pending[0].requestId,
|
|
151
|
+
permanent: true
|
|
105
152
|
});
|
|
106
153
|
}
|
|
107
154
|
```
|
|
@@ -110,12 +157,12 @@ if (pending.length > 0) {
|
|
|
110
157
|
|
|
111
158
|
## 详细文档
|
|
112
159
|
|
|
113
|
-
- [
|
|
114
|
-
- [根目录 README
|
|
160
|
+
- [进程隔离(A/B 架构)](../PROCESS_ISOLATION.md)
|
|
161
|
+
- [根目录 README(英文)](../../README.md)
|
|
115
162
|
|
|
116
163
|
## 架构原则
|
|
117
164
|
|
|
118
165
|
1. **机密隔离**:机密明文绝不离开安全进程。
|
|
119
166
|
2. **密码即权限**:主密码是唯一的管理授权来源。
|
|
120
|
-
3.
|
|
121
|
-
4.
|
|
167
|
+
3. **可审计性**:所有管理动作均记录为 `vault-master` 或对应的 Agent 身份。
|
|
168
|
+
4. **二元状态**:保险箱要么被解锁并可见,要么只是磁盘上一组加密碎片。
|