@the-ai-company/cbio-node-runtime 1.57.0 → 1.59.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.
Files changed (140) hide show
  1. package/README.md +53 -30
  2. package/dist/clients/agent/client.d.ts +3 -1
  3. package/dist/clients/agent/client.js +41 -11
  4. package/dist/clients/agent/client.js.map +1 -1
  5. package/dist/clients/agent/contracts.d.ts +5 -2
  6. package/dist/clients/owner/client.d.ts +8 -10
  7. package/dist/clients/owner/client.js +45 -38
  8. package/dist/clients/owner/client.js.map +1 -1
  9. package/dist/clients/owner/contracts.d.ts +11 -25
  10. package/dist/clients/owner/index.d.ts +1 -1
  11. package/dist/runtime/index.d.ts +1 -1
  12. package/dist/runtime/index.js.map +1 -1
  13. package/dist/vault-core/contracts.d.ts +133 -46
  14. package/dist/vault-core/contracts.js +4 -3
  15. package/dist/vault-core/contracts.js.map +1 -1
  16. package/dist/vault-core/core.d.ts +10 -5
  17. package/dist/vault-core/core.js +315 -160
  18. package/dist/vault-core/core.js.map +1 -1
  19. package/dist/vault-core/defaults.d.ts +8 -4
  20. package/dist/vault-core/defaults.js +37 -70
  21. package/dist/vault-core/defaults.js.map +1 -1
  22. package/dist/vault-core/index.d.ts +1 -1
  23. package/dist/vault-core/index.js.map +1 -1
  24. package/dist/vault-core/persistence.d.ts +11 -2
  25. package/dist/vault-core/persistence.js +37 -1
  26. package/dist/vault-core/persistence.js.map +1 -1
  27. package/dist/vault-core/ports.d.ts +7 -2
  28. package/dist/vault-core/tool-metadata.js +25 -8
  29. package/dist/vault-core/tool-metadata.js.map +1 -1
  30. package/dist/vault-ingress/defaults.d.ts +2 -0
  31. package/dist/vault-ingress/defaults.js +6 -0
  32. package/dist/vault-ingress/defaults.js.map +1 -1
  33. package/dist/vault-ingress/index.d.ts +39 -10
  34. package/dist/vault-ingress/index.js +142 -56
  35. package/dist/vault-ingress/index.js.map +1 -1
  36. package/dist/vault-ingress/remote-transport.d.ts +2 -0
  37. package/dist/vault-ingress/remote-transport.js +33 -4
  38. package/dist/vault-ingress/remote-transport.js.map +1 -1
  39. package/docs/ARCHITECTURE.md +1 -1
  40. package/docs/REFERENCE.md +36 -27
  41. package/docs/WORKS_WITH_CUSTOM_FETCH.md +2 -2
  42. package/docs/api/README.md +2 -4
  43. package/docs/api/classes/IdentityError.md +1 -1
  44. package/docs/api/classes/OwnerClientError.md +1 -1
  45. package/docs/api/classes/VaultCore.md +81 -33
  46. package/docs/api/classes/VaultCoreError.md +1 -1
  47. package/docs/api/enumerations/IdentityErrorCode.md +1 -1
  48. package/docs/api/enumerations/OwnerClientErrorCode.md +1 -1
  49. package/docs/api/functions/createAgentClient.md +1 -1
  50. package/docs/api/functions/createIdentity.md +1 -1
  51. package/docs/api/functions/createOwnerHttpFlowBoundary.md +1 -1
  52. package/docs/api/functions/createOwnerSession.md +1 -1
  53. package/docs/api/functions/createPersistentVaultCoreDependencies.md +1 -1
  54. package/docs/api/functions/createStandardAcquireBoundary.md +1 -1
  55. package/docs/api/functions/createStandardDispatchBoundary.md +1 -1
  56. package/docs/api/functions/createVault.md +1 -1
  57. package/docs/api/functions/createVaultClient.md +1 -1
  58. package/docs/api/functions/createVaultCore.md +1 -1
  59. package/docs/api/functions/createVaultCoreDependencies.md +1 -1
  60. package/docs/api/functions/createVaultService.md +1 -1
  61. package/docs/api/functions/createWorkspaceStorage.md +1 -1
  62. package/docs/api/functions/deriveIdentityId.md +1 -1
  63. package/docs/api/functions/deriveVaultWorkingKeyFromPassword.md +1 -1
  64. package/docs/api/functions/getDefaultWorkspaceDir.md +1 -1
  65. package/docs/api/functions/handleVaultAgentControlHttp.md +1 -1
  66. package/docs/api/functions/handleVaultHttpDispatch.md +1 -1
  67. package/docs/api/functions/initializeVaultCustody.md +1 -1
  68. package/docs/api/functions/listVaults.md +1 -1
  69. package/docs/api/functions/readVaultProfile.md +1 -1
  70. package/docs/api/functions/recoverVault.md +1 -1
  71. package/docs/api/functions/recoverVaultWorkingKey.md +1 -1
  72. package/docs/api/functions/restoreIdentity.md +1 -1
  73. package/docs/api/functions/updateVaultMetadata.md +1 -1
  74. package/docs/api/functions/wrapVaultCoreAsVaultService.md +1 -1
  75. package/docs/api/functions/writeVaultProfile.md +1 -1
  76. package/docs/api/interfaces/AgentClient.md +27 -1
  77. package/docs/api/interfaces/AgentDispatchIntent.md +1 -1
  78. package/docs/api/interfaces/AgentDispatchTransport.md +33 -1
  79. package/docs/api/interfaces/AgentIdentity.md +1 -1
  80. package/docs/api/interfaces/AgentSigner.md +1 -1
  81. package/docs/api/interfaces/AgentSubmitCapabilityRequestInput.md +9 -9
  82. package/docs/api/interfaces/CbioRuntime.md +1 -1
  83. package/docs/api/interfaces/CreateAgentClientOptions.md +1 -1
  84. package/docs/api/interfaces/CreateIdentityOptions.md +1 -1
  85. package/docs/api/interfaces/CreateOwnerSessionOptions.md +1 -1
  86. package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +1 -1
  87. package/docs/api/interfaces/CreateVaultClientOptions.md +1 -1
  88. package/docs/api/interfaces/CreateVaultOptions.md +1 -1
  89. package/docs/api/interfaces/CreatedVault.md +1 -1
  90. package/docs/api/interfaces/DefaultPolicyEngineOptions.md +1 -1
  91. package/docs/api/interfaces/IStorageProvider.md +1 -1
  92. package/docs/api/interfaces/InitializeVaultCustodyOptions.md +1 -1
  93. package/docs/api/interfaces/InitializedVaultCustody.md +1 -1
  94. package/docs/api/interfaces/OwnerAgentProvisionResult.md +1 -1
  95. package/docs/api/interfaces/OwnerSensitiveActionConfirmation.md +1 -1
  96. package/docs/api/interfaces/OwnerSensitiveActionContext.md +1 -1
  97. package/docs/api/interfaces/OwnerSession.md +1 -1
  98. package/docs/api/interfaces/OwnerStoreSecretInput.md +1 -1
  99. package/docs/api/interfaces/OwnerWriteSecretInput.md +1 -7
  100. package/docs/api/interfaces/RecoverVaultOptions.md +1 -1
  101. package/docs/api/interfaces/RecoveredVault.md +1 -1
  102. package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
  103. package/docs/api/interfaces/Signer.md +1 -1
  104. package/docs/api/interfaces/VaultApproveCapabilityRequestInput.md +1 -1
  105. package/docs/api/interfaces/VaultApproveDispatchInput.md +1 -1
  106. package/docs/api/interfaces/VaultAuditQueryInput.md +1 -1
  107. package/docs/api/interfaces/VaultClient.md +58 -44
  108. package/docs/api/interfaces/VaultCoreDependenciesOptions.md +1 -1
  109. package/docs/api/interfaces/VaultCreateAgentInput.md +1 -1
  110. package/docs/api/interfaces/VaultDeleteSecretInput.md +1 -1
  111. package/docs/api/interfaces/VaultExportSecretInput.md +1 -1
  112. package/docs/api/interfaces/VaultGrantCapabilityInput.md +9 -21
  113. package/docs/api/interfaces/VaultGrantCapabilityRequest.md +1 -1
  114. package/docs/api/interfaces/VaultIdentity.md +1 -1
  115. package/docs/api/interfaces/VaultImportAgentInput.md +1 -1
  116. package/docs/api/interfaces/VaultIssueSessionTokenInput.md +1 -1
  117. package/docs/api/interfaces/VaultListAgentsInput.md +1 -1
  118. package/docs/api/interfaces/VaultListCapabilitiesInput.md +1 -1
  119. package/docs/api/interfaces/VaultListSecretsInput.md +1 -1
  120. package/docs/api/interfaces/VaultMetadata.md +1 -1
  121. package/docs/api/interfaces/VaultObject.md +1 -1
  122. package/docs/api/interfaces/VaultProfile.md +1 -1
  123. package/docs/api/interfaces/VaultReadAgentPrivateKeyInput.md +1 -1
  124. package/docs/api/interfaces/VaultReadSecretPlaintextInput.md +1 -1
  125. package/docs/api/interfaces/VaultRegisterFlowInput.md +1 -1
  126. package/docs/api/interfaces/VaultRevokeCapabilityInput.md +1 -1
  127. package/docs/api/interfaces/VaultRevokeSessionTokenInput.md +1 -1
  128. package/docs/api/interfaces/VaultSigner.md +1 -1
  129. package/docs/api/interfaces/VaultSubmitCapabilityRequestInput.md +11 -17
  130. package/docs/api/interfaces/VaultUpdateAgentInput.md +1 -1
  131. package/docs/api/type-aliases/AgentCapabilityEnvelope.md +1 -1
  132. package/docs/api/type-aliases/AgentVisibleSecretRecord.md +1 -1
  133. package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
  134. package/docs/api/type-aliases/OwnerGrantCapabilityInput.md +1 -1
  135. package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +1 -1
  136. package/docs/zh/README.md +26 -16
  137. package/examples/process-isolation.ts +7 -5
  138. package/package.json +1 -1
  139. package/docs/api/interfaces/OwnerDefineSecretTargetsInput.md +0 -23
  140. package/docs/api/interfaces/OwnerSecretTargetBinding.md +0 -35
package/docs/zh/README.md CHANGED
@@ -96,20 +96,17 @@ const sessionToken = createdAgent.sessionToken;
96
96
  ```ts
97
97
  const record = await client.ownerWriteSecret({
98
98
  alias: 'api-token',
99
- plaintext: 'secret-value',
100
- targetBindings: [{
101
- kind: 'site',
102
- targetId: 'my-api',
103
- targetUrl: 'https://api.example.com/endpoint',
104
- methods: ['POST']
105
- }]
99
+ plaintext: 'secret-value'
106
100
  });
107
101
 
108
102
  await client.ownerGrantCapability({
109
103
  agentId,
110
- secretAliases: ['api-token'],
111
- scope: 'https://api.example.com/*',
112
- methods: ['POST']
104
+ write: {
105
+ secretIds: [record.secretId.value],
106
+ scope: 'https://api.example.com/*',
107
+ methods: ['POST']
108
+ },
109
+ read: { mode: 'full' }
113
110
  });
114
111
  ```
115
112
 
@@ -126,24 +123,31 @@ const agent = createAgentClient({
126
123
  });
127
124
 
128
125
  const result = await agent.agentDispatch({ ... });
126
+ const requests = await agent.agentListRequests();
127
+ const request = await agent.agentGetRequest(result.requestId);
129
128
  ```
130
129
 
131
130
  Agent 进程不会直接使用原始私钥执行请求。即使 Agent 拥有身份材料,也应先换取 session token,再进行 dispatch。
132
131
 
132
+ 给 LLM 的直白规则:
133
+ - `agentDispatch(...)` = 立刻尝试执行真实任务
134
+ - `agentSubmitCapabilityRequest(...)` = 只申请权限,不会执行任务
135
+ - `agentListRequests()` / `agentGetRequest(...)` = 在请求执行后查看异步结果
136
+
133
137
  ```ts
134
138
  const manifest = await agent.agentIntrospect();
135
139
 
136
140
  console.log(manifest.agent.agentId);
137
141
  console.log(manifest.agent.identityId);
138
142
  console.log(manifest.agent.nickname);
139
- console.log(manifest.capabilities); // 同一张能力状态表里同时包含 GRANTED 和 PENDING
143
+ console.log(manifest.capabilities); // 同一组能力载体里包含 write/read 动作状态
140
144
  ```
141
145
 
142
- `agentListCapabilities()` 现在返回的也是同一张统一能力状态表,因此调度器或 Agent 重启后,不需要分别拼“已授权能力”和“待审批能力”。
146
+ `agentListCapabilities()` 返回能力载体视图,`agentListRequests()` / `agentGetRequest()` 则负责暴露请求历史和按权限裁剪后的结果。
143
147
 
144
148
  ### 7. 人机协同(HITL)工作流
145
149
 
146
- 系统采用统一的 **能力状态(capability state)** 模型。如果 Agent 尝试执行的动作不在白名单内,dispatch 会返回 `PENDING`,同时运行时会写入一条 `PENDING` 能力状态,等待 Owner 审批。
150
+ 如果 Agent 尝试执行的动作不在白名单内,dispatch 会返回 `PENDING`,同时运行时会写入一条能力载体记录,其 `write` 动作等待 Owner 审批。
147
151
 
148
152
  ```ts
149
153
  const result = await agent.agentDispatch({ ... });
@@ -152,14 +156,20 @@ if (result.status === 'PENDING') {
152
156
  }
153
157
 
154
158
  client.ownerOnCapabilityState((state) => {
155
- if (state.status === 'PENDING') {
159
+ if (state.actions.write.status === 'PENDING') {
156
160
  console.log('收到新的待审批能力状态:', state.requestId);
157
161
  }
158
162
  });
159
163
 
160
- const pending = await client.ownerListCapabilityStates({ status: 'PENDING' });
164
+ const pending = await client.ownerListCapabilityStates({ writeStatus: 'PENDING' });
161
165
  if (pending.length > 0) {
162
- await client.ownerExecuteCapabilityStateAndGrant({
166
+ await client.ownerApproveCapabilityWrite({
167
+ requestId: pending[0].requestId
168
+ });
169
+ await client.ownerAllowAlways({
170
+ requestId: pending[0].requestId
171
+ });
172
+ await client.ownerApproveCapabilityRead({
163
173
  requestId: pending[0].requestId
164
174
  });
165
175
  }
@@ -120,7 +120,7 @@ async function main() {
120
120
  owner: { kind: "owner", id: ownerIdentity.identityId },
121
121
  alias: "api-token",
122
122
  plaintext: "SK-PROD-12345",
123
- targetBindings: [{ kind: "site", targetId: "httpbin.org", targetUrl: "https://httpbin.org/post", methods: ["POST"] }],
123
+ source: { kind: "manual" },
124
124
  requestedAt: new Date().toISOString(),
125
125
  });
126
126
 
@@ -128,11 +128,13 @@ async function main() {
128
128
  vaultId: vault.vaultId,
129
129
  capabilityId: "cap-llm-1",
130
130
  agentId: agentIdentity.identityId,
131
- secretIds: [secret.secretId.value],
132
- secretAliases: ["api-token"],
133
131
  operation: "dispatch_http" as const,
134
- scope: "https://httpbin.org/post",
135
- methods: ["POST"],
132
+ write: {
133
+ secretIds: [secret.secretId.value],
134
+ scope: "https://httpbin.org/post",
135
+ methods: ["POST"],
136
+ },
137
+ read: { mode: "full" },
136
138
  issuedAt: new Date().toISOString(),
137
139
  };
138
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-ai-company/cbio-node-runtime",
3
- "version": "1.57.0",
3
+ "version": "1.59.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,23 +0,0 @@
1
- [**CBIO Node Runtime Agent API v1.57.0**](../README.md)
2
-
3
- ***
4
-
5
- # Interface: OwnerDefineSecretTargetsInput
6
-
7
- ## Properties
8
-
9
- ### alias
10
-
11
- > **alias**: `string`
12
-
13
- ***
14
-
15
- ### requestedAt?
16
-
17
- > `optional` **requestedAt?**: `string`
18
-
19
- ***
20
-
21
- ### targetBindings
22
-
23
- > **targetBindings**: readonly [`OwnerSecretTargetBinding`](OwnerSecretTargetBinding.md)[]
@@ -1,35 +0,0 @@
1
- [**CBIO Node Runtime Agent API v1.57.0**](../README.md)
2
-
3
- ***
4
-
5
- # Interface: OwnerSecretTargetBinding
6
-
7
- ## Properties
8
-
9
- ### kind
10
-
11
- > **kind**: `"owner"` \| `"site"`
12
-
13
- ***
14
-
15
- ### methods?
16
-
17
- > `optional` **methods?**: readonly `string`[]
18
-
19
- ***
20
-
21
- ### paths?
22
-
23
- > `optional` **paths?**: readonly `string`[]
24
-
25
- ***
26
-
27
- ### targetId
28
-
29
- > **targetId**: `string`
30
-
31
- ***
32
-
33
- ### targetUrl?
34
-
35
- > `optional` **targetUrl?**: `string`