@the-ai-company/cbio-node-runtime 1.42.0 → 1.45.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.
Files changed (232) hide show
  1. package/README.md +1 -0
  2. package/dist/clients/agent/client.d.ts +35 -0
  3. package/dist/clients/agent/client.js +15 -0
  4. package/dist/clients/agent/client.js.map +1 -1
  5. package/dist/clients/owner/client.d.ts +60 -0
  6. package/dist/clients/owner/client.js +14 -0
  7. package/dist/clients/owner/client.js.map +1 -1
  8. package/dist/clients/owner/index.d.ts +1 -1
  9. package/dist/runtime/bootstrap.d.ts +43 -7
  10. package/dist/runtime/bootstrap.js +12 -1
  11. package/dist/runtime/bootstrap.js.map +1 -1
  12. package/dist/runtime/identity.d.ts +47 -0
  13. package/dist/runtime/identity.js +25 -0
  14. package/dist/runtime/identity.js.map +1 -1
  15. package/dist/runtime/index.d.ts +9 -11
  16. package/dist/runtime/index.js +2 -0
  17. package/dist/runtime/index.js.map +1 -1
  18. package/dist/runtime/private-vault.d.ts +1 -2
  19. package/dist/vault-core/contracts.d.ts +32 -4
  20. package/dist/vault-core/contracts.js +31 -1
  21. package/dist/vault-core/contracts.js.map +1 -1
  22. package/dist/vault-core/core.js +28 -27
  23. package/dist/vault-core/core.js.map +1 -1
  24. package/dist/vault-core/defaults.js +3 -2
  25. package/dist/vault-core/defaults.js.map +1 -1
  26. package/dist/vault-core/index.d.ts +1 -0
  27. package/dist/vault-core/index.js +1 -0
  28. package/dist/vault-core/index.js.map +1 -1
  29. package/dist/vault-ingress/index.d.ts +2 -0
  30. package/dist/vault-ingress/index.js +4 -2
  31. package/dist/vault-ingress/index.js.map +1 -1
  32. package/dist/vault-ingress/remote-transport.d.ts +12 -0
  33. package/dist/vault-ingress/remote-transport.js +45 -0
  34. package/dist/vault-ingress/remote-transport.js.map +1 -0
  35. package/dist/vault-ingress/server-utils.d.ts +10 -0
  36. package/dist/vault-ingress/server-utils.js +18 -0
  37. package/dist/vault-ingress/server-utils.js.map +1 -0
  38. package/docs/ARCHITECTURE.md +8 -0
  39. package/docs/PROCESS_ISOLATION.md +56 -0
  40. package/docs/api/README.md +211 -0
  41. package/docs/api/classes/AgentDispatchHttpTransport.md +52 -0
  42. package/docs/api/classes/DefaultPolicyEngine.md +117 -0
  43. package/docs/api/classes/DefaultVaultCore.md +405 -0
  44. package/docs/api/classes/FsStorageProvider.md +192 -0
  45. package/docs/api/classes/HttpDispatchExecutor.md +63 -0
  46. package/docs/api/classes/IdentityError.md +62 -0
  47. package/docs/api/classes/InMemoryAgentIdentityRegistry.md +83 -0
  48. package/docs/api/classes/InMemoryAuditLog.md +59 -0
  49. package/docs/api/classes/InMemoryCapabilityRegistry.md +91 -0
  50. package/docs/api/classes/InMemoryCapabilityRevocationRegistry.md +75 -0
  51. package/docs/api/classes/InMemoryCustomHttpFlowRegistry.md +63 -0
  52. package/docs/api/classes/InMemoryOwnerIdentityRegistry.md +83 -0
  53. package/docs/api/classes/InMemoryRateLimitStore.md +51 -0
  54. package/docs/api/classes/InMemoryReplayGuard.md +45 -0
  55. package/docs/api/classes/InMemorySecretCustody.md +83 -0
  56. package/docs/api/classes/InMemorySecretRepository.md +99 -0
  57. package/docs/api/classes/LocalSigner.md +59 -0
  58. package/docs/api/classes/LocalVaultTransport.md +45 -0
  59. package/docs/api/classes/MemoryStorageProvider.md +160 -0
  60. package/docs/api/classes/PersistentVaultAgentIdentityRegistry.md +101 -0
  61. package/docs/api/classes/PersistentVaultAuditLog.md +73 -0
  62. package/docs/api/classes/PersistentVaultCapabilityRegistry.md +109 -0
  63. package/docs/api/classes/PersistentVaultCapabilityRevocationRegistry.md +93 -0
  64. package/docs/api/classes/PersistentVaultCustomHttpFlowRegistry.md +81 -0
  65. package/docs/api/classes/PersistentVaultOwnerIdentityRegistry.md +101 -0
  66. package/docs/api/classes/PersistentVaultRateLimitStore.md +69 -0
  67. package/docs/api/classes/PersistentVaultReplayGuard.md +61 -0
  68. package/docs/api/classes/PersistentVaultSecretCustody.md +97 -0
  69. package/docs/api/classes/PersistentVaultSecretRepository.md +117 -0
  70. package/docs/api/classes/RandomIdGenerator.md +65 -0
  71. package/docs/api/classes/SignatureAgentProofVerifier.md +49 -0
  72. package/docs/api/classes/SignatureOwnerProofVerifier.md +249 -0
  73. package/docs/api/classes/SystemClock.md +33 -0
  74. package/docs/api/classes/VaultCoreError.md +39 -0
  75. package/docs/api/enumerations/AuditAction.md +95 -0
  76. package/docs/api/enumerations/AuditOutcome.md +29 -0
  77. package/docs/api/enumerations/DispatchStatus.md +23 -0
  78. package/docs/api/enumerations/IdentityErrorCode.md +121 -0
  79. package/docs/api/functions/createAgentClient.md +33 -0
  80. package/docs/api/functions/createChildIdentity.md +25 -0
  81. package/docs/api/functions/createDefaultVaultCoreDependencies.md +77 -0
  82. package/docs/api/functions/createIdentity.md +30 -0
  83. package/docs/api/functions/createOwnerHttpFlowBoundary.md +17 -0
  84. package/docs/api/functions/createPersistentVaultCoreDependencies.md +85 -0
  85. package/docs/api/functions/createStandardAcquireBoundary.md +31 -0
  86. package/docs/api/functions/createStandardDispatchBoundary.md +23 -0
  87. package/docs/api/functions/createVault.md +58 -0
  88. package/docs/api/functions/createVaultClient.md +32 -0
  89. package/docs/api/functions/createVaultCore.md +17 -0
  90. package/docs/api/functions/createVaultService.md +31 -0
  91. package/docs/api/functions/createWorkspaceStorage.md +17 -0
  92. package/docs/api/functions/deriveChildIdentity.md +41 -0
  93. package/docs/api/functions/deriveIdentityId.md +17 -0
  94. package/docs/api/functions/ensureIdentityPrivateVault.md +21 -0
  95. package/docs/api/functions/getDefaultWorkspaceDir.md +11 -0
  96. package/docs/api/functions/handleVaultHttpDispatch.md +30 -0
  97. package/docs/api/functions/identityPrivateVaultChildrenKey.md +17 -0
  98. package/docs/api/functions/identityPrivateVaultPrefix.md +17 -0
  99. package/docs/api/functions/identityPrivateVaultProfileKey.md +17 -0
  100. package/docs/api/functions/identityPrivateVaultPublicSealedKey.md +17 -0
  101. package/docs/api/functions/initializeVaultCustody.md +21 -0
  102. package/docs/api/functions/listIdentities.md +19 -0
  103. package/docs/api/functions/listVaults.md +23 -0
  104. package/docs/api/functions/readIdentityMetadata.md +29 -0
  105. package/docs/api/functions/readIdentityPrivateVaultChildrenState.md +21 -0
  106. package/docs/api/functions/readIdentityPrivateVaultProfile.md +21 -0
  107. package/docs/api/functions/readVaultProfile.md +25 -0
  108. package/docs/api/functions/readVaultPublicMetadata.md +23 -0
  109. package/docs/api/functions/recoverVault.md +58 -0
  110. package/docs/api/functions/recoverVaultWorkingKey.md +25 -0
  111. package/docs/api/functions/restoreIdentity.md +35 -0
  112. package/docs/api/functions/toOwnerHttpFlowBoundary.md +17 -0
  113. package/docs/api/functions/updateVaultMetadata.md +33 -0
  114. package/docs/api/functions/wrapVaultCoreAsVaultService.md +31 -0
  115. package/docs/api/functions/writeVaultProfile.md +29 -0
  116. package/docs/api/interfaces/AgentCapability.md +103 -0
  117. package/docs/api/interfaces/AgentClient.md +41 -0
  118. package/docs/api/interfaces/AgentDispatchIntent.md +41 -0
  119. package/docs/api/interfaces/AgentDispatchTransport.md +21 -0
  120. package/docs/api/interfaces/AgentIdentity.md +11 -0
  121. package/docs/api/interfaces/AgentIdentityRecord.md +23 -0
  122. package/docs/api/interfaces/AgentIdentityRegistry.md +57 -0
  123. package/docs/api/interfaces/AgentProof.md +29 -0
  124. package/docs/api/interfaces/AgentProofVerifier.md +21 -0
  125. package/docs/api/interfaces/AgentSigner.md +21 -0
  126. package/docs/api/interfaces/AuditEntry.md +89 -0
  127. package/docs/api/interfaces/AuditLog.md +37 -0
  128. package/docs/api/interfaces/AuditQuery.md +29 -0
  129. package/docs/api/interfaces/CapabilityRegistry.md +65 -0
  130. package/docs/api/interfaces/CapabilityRevocationRegistry.md +53 -0
  131. package/docs/api/interfaces/CbioRuntime.md +886 -0
  132. package/docs/api/interfaces/ChildIdentity.md +77 -0
  133. package/docs/api/interfaces/Clock.md +15 -0
  134. package/docs/api/interfaces/CreateAgentClientOptions.md +41 -0
  135. package/docs/api/interfaces/CreateChildIdentityOptions.md +19 -0
  136. package/docs/api/interfaces/CreateDefaultVaultCoreDependenciesOptions.md +85 -0
  137. package/docs/api/interfaces/CreateIdentityOptions.md +15 -0
  138. package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +115 -0
  139. package/docs/api/interfaces/CreateVaultClientOptions.md +29 -0
  140. package/docs/api/interfaces/CreateVaultOptions.md +177 -0
  141. package/docs/api/interfaces/CreatedVault.md +39 -0
  142. package/docs/api/interfaces/CustomHttpFlowDefinition.md +71 -0
  143. package/docs/api/interfaces/CustomHttpFlowRegistry.md +41 -0
  144. package/docs/api/interfaces/DefaultPolicyEngineOptions.md +49 -0
  145. package/docs/api/interfaces/DeriveIdentityOptions.md +11 -0
  146. package/docs/api/interfaces/DispatchAuthorization.md +35 -0
  147. package/docs/api/interfaces/DispatchInstruction.md +47 -0
  148. package/docs/api/interfaces/DispatchRequest.md +77 -0
  149. package/docs/api/interfaces/DispatchResult.md +53 -0
  150. package/docs/api/interfaces/IStorageProvider.md +144 -0
  151. package/docs/api/interfaces/IdGenerator.md +39 -0
  152. package/docs/api/interfaces/IdentityPrivateVaultChildRecord.md +35 -0
  153. package/docs/api/interfaces/IdentityPrivateVaultChildrenState.md +17 -0
  154. package/docs/api/interfaces/IdentityPrivateVaultProfile.md +35 -0
  155. package/docs/api/interfaces/InitializeVaultCustodyOptions.md +29 -0
  156. package/docs/api/interfaces/InitializedVaultCustody.md +23 -0
  157. package/docs/api/interfaces/IssuerWriteSecretCommand.md +59 -0
  158. package/docs/api/interfaces/OwnerAuditRequest.md +47 -0
  159. package/docs/api/interfaces/OwnerDefineSecretTargetsCommand.md +53 -0
  160. package/docs/api/interfaces/OwnerDefineSecretTargetsInput.md +23 -0
  161. package/docs/api/interfaces/OwnerDeleteSecretCommand.md +47 -0
  162. package/docs/api/interfaces/OwnerExportSecretRequest.md +47 -0
  163. package/docs/api/interfaces/OwnerHttpFlowBoundary.md +51 -0
  164. package/docs/api/interfaces/OwnerIdentityRecord.md +23 -0
  165. package/docs/api/interfaces/OwnerIdentityRegistry.md +57 -0
  166. package/docs/api/interfaces/OwnerListAgentsRequest.md +41 -0
  167. package/docs/api/interfaces/OwnerListCapabilitiesRequest.md +47 -0
  168. package/docs/api/interfaces/OwnerProof.md +29 -0
  169. package/docs/api/interfaces/OwnerProofVerifier.md +181 -0
  170. package/docs/api/interfaces/OwnerRegisterAgentIdentityCommand.md +47 -0
  171. package/docs/api/interfaces/OwnerRegisterCapabilityCommand.md +47 -0
  172. package/docs/api/interfaces/OwnerRegisterCustomHttpFlowCommand.md +83 -0
  173. package/docs/api/interfaces/OwnerRevokeCapabilityCommand.md +53 -0
  174. package/docs/api/interfaces/OwnerSecretExport.md +35 -0
  175. package/docs/api/interfaces/OwnerSecretTargetBinding.md +35 -0
  176. package/docs/api/interfaces/OwnerStoreSecretInput.md +23 -0
  177. package/docs/api/interfaces/OwnerWriteSecretCommand.md +65 -0
  178. package/docs/api/interfaces/OwnerWriteSecretInput.md +29 -0
  179. package/docs/api/interfaces/PolicyEngine.md +81 -0
  180. package/docs/api/interfaces/RateLimitStore.md +33 -0
  181. package/docs/api/interfaces/RecoverVaultOptions.md +165 -0
  182. package/docs/api/interfaces/RecoveredVault.md +49 -0
  183. package/docs/api/interfaces/ReplayGuard.md +21 -0
  184. package/docs/api/interfaces/RestoreIdentityOptions.md +11 -0
  185. package/docs/api/interfaces/SecretAlias.md +11 -0
  186. package/docs/api/interfaces/SecretCustody.md +57 -0
  187. package/docs/api/interfaces/SecretId.md +11 -0
  188. package/docs/api/interfaces/SecretRecord.md +53 -0
  189. package/docs/api/interfaces/SecretRepository.md +69 -0
  190. package/docs/api/interfaces/SecretVersion.md +11 -0
  191. package/docs/api/interfaces/SignatureAgentProofVerifierOptions.md +21 -0
  192. package/docs/api/interfaces/Signer.md +31 -0
  193. package/docs/api/interfaces/TrustedExecutor.md +31 -0
  194. package/docs/api/interfaces/VaultAcquireSecretInput.md +53 -0
  195. package/docs/api/interfaces/VaultAcquireSecretResult.md +41 -0
  196. package/docs/api/interfaces/VaultAgentDispatchErrorResponse.md +25 -0
  197. package/docs/api/interfaces/VaultAgentDispatchRequest.md +75 -0
  198. package/docs/api/interfaces/VaultAgentDispatchResponse.md +17 -0
  199. package/docs/api/interfaces/VaultAuditQueryInput.md +29 -0
  200. package/docs/api/interfaces/VaultClient.md +234 -0
  201. package/docs/api/interfaces/VaultCore.md +311 -0
  202. package/docs/api/interfaces/VaultCoreDependencies.md +95 -0
  203. package/docs/api/interfaces/VaultCustomFlowResolver.md +25 -0
  204. package/docs/api/interfaces/VaultDeleteSecretInput.md +17 -0
  205. package/docs/api/interfaces/VaultExportSecretInput.md +17 -0
  206. package/docs/api/interfaces/VaultGrantCapabilityInput.md +17 -0
  207. package/docs/api/interfaces/VaultId.md +11 -0
  208. package/docs/api/interfaces/VaultIdentity.md +11 -0
  209. package/docs/api/interfaces/VaultListAgentsInput.md +11 -0
  210. package/docs/api/interfaces/VaultListCapabilitiesInput.md +17 -0
  211. package/docs/api/interfaces/VaultObject.md +33 -0
  212. package/docs/api/interfaces/VaultPrincipal.md +17 -0
  213. package/docs/api/interfaces/VaultProfile.md +23 -0
  214. package/docs/api/interfaces/VaultPublicMetadata.md +25 -0
  215. package/docs/api/interfaces/VaultRegisterAgentInput.md +23 -0
  216. package/docs/api/interfaces/VaultRegisterFlowInput.md +83 -0
  217. package/docs/api/interfaces/VaultRevokeCapabilityInput.md +23 -0
  218. package/docs/api/interfaces/VaultService.md +251 -0
  219. package/docs/api/interfaces/VaultSigner.md +21 -0
  220. package/docs/api/interfaces/VaultTargetBinding.md +35 -0
  221. package/docs/api/type-aliases/AgentCapabilityEnvelope.md +7 -0
  222. package/docs/api/type-aliases/CbioRuntimeModule.md +9 -0
  223. package/docs/api/type-aliases/IdentityPrivateVaultAccess.md +7 -0
  224. package/docs/api/type-aliases/RedactedResponseShape.md +7 -0
  225. package/docs/api/type-aliases/VaultAcquireSecretFlow.md +7 -0
  226. package/docs/api/type-aliases/VaultPrincipalKind.md +7 -0
  227. package/docs/api/type-aliases/VaultWriteSecretCommand.md +7 -0
  228. package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +7 -0
  229. package/docs/zh/PROCESS_ISOLATION.md +58 -0
  230. package/docs/zh/README.md +5 -0
  231. package/examples/process-isolation.ts +155 -0
  232. package/package.json +10 -2
@@ -0,0 +1,58 @@
1
+ # 进程隔离 (A/B 架构)
2
+
3
+ `@the-ai-company/cbio-node-runtime` 原生支持**进程隔离**架构(通常被称为 "A/B" 或 "中枢控制" 模型)。
4
+
5
+ 在此模型下,敏感操作被拆分到两个独立的操作系统进程中:
6
+
7
+ 1. **进程 B (Vault Server)**:持有 Vault 根密钥并管理加密存储。它作为一个“具备身份验证感知能力的代理服务器”运行。
8
+ 2. **进程 A (Agent/LLM)**:执行业务逻辑或大模型推理。它们可以**发起签名请求**,但**全程接触不到 Vault 的机密或根密钥**。
9
+
10
+ ## 核心组件
11
+
12
+ ### `AgentDispatchHttpTransport` (客户端)
13
+
14
+ 此组件运行在 **进程 A** 中。它实现了 `AgentDispatchTransport` 接口,但不是调用本地 Vault,而是将带签名的请求序列化为 JSON 载荷,并通过 HTTP 发送到远程端点。
15
+
16
+ ```typescript
17
+ import { createAgentClient, AgentDispatchHttpTransport } from '@the-ai-company/cbio-node-runtime';
18
+
19
+ // 进程 A 只需要知道远程 Vault 的 URL
20
+ const transport = new AgentDispatchHttpTransport('http://localhost:3000/dispatch');
21
+
22
+ const agent = createAgentClient({
23
+ agentIdentity, // 进程 A 仅持有自己的身份私钥
24
+ capability, // 进程 A 仅了解被授予的权限
25
+ transport,
26
+ });
27
+
28
+ // A 进程请求代发,机密明文全程不进入 A 的内存
29
+ await agent.dispatch({
30
+ secretAlias: 'api-token',
31
+ targetUrl: 'https://api.example.com/data',
32
+ method: 'POST',
33
+ });
34
+ ```
35
+
36
+ ### `handleVaultHttpDispatch` (服务端)
37
+
38
+ 此辅助函数运行在 **进程 B** 中。它提供了将传入的 HTTP 请求体传递给 `VaultService` 的标准方法。它处理的是完全 JSON 安全的 `VaultAgentDispatchRequest` 格式。
39
+
40
+ ```typescript
41
+ import { createVaultService, handleVaultHttpDispatch } from '@the-ai-company/cbio-node-runtime';
42
+
43
+ // 在任何 Node.js HTTP 服务器(如 Express/Fastify)中:
44
+ server.post('/dispatch', async (req, res) => {
45
+ const result = await handleVaultHttpDispatch(vaultService, req.body);
46
+ res.json(result);
47
+ });
48
+ ```
49
+
50
+ ## 安全优势
51
+
52
+ - **零机密暴露**:即使进程 A(如 LLM 进程)由于提示词注入(Prompt Injection)或内存检查被攻破,攻击者也无法提取 Vault 中的机密,因为它们物理上存储在进程 B 中。
53
+ - **受控出口面**:进程 B 强制执行 **权限表 (Capabilities)**。它只会在请求目的地匹配 Owner 预设的白名单 URL 时,才会注入机密并代发请求。
54
+ - **审计追踪**:进程 B 维护一份独立的、追加式审计日志,记录每个 Agent 发起的所有敏感请求。
55
+
56
+ ## 示例
57
+
58
+ 查看 [examples/process-isolation.ts](../examples/process-isolation.ts) 获取该架构的完整运行示例。
package/docs/zh/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  cbio 权限核心运行时。仅库,无 CLI 或 TUI。
4
4
 
5
+ ## 文档
6
+
7
+ - [进程隔离 (A/B 架构)](PROCESS_ISOLATION.md)
8
+ - [根目录文档](../../README.md)
9
+
5
10
  主入口现在围绕四个模块:
6
11
  - `vault-core`
7
12
  - `clients/owner`
@@ -0,0 +1,155 @@
1
+ import http from "node:http";
2
+ import {
3
+ createIdentity,
4
+ createVault,
5
+ createAgentClient,
6
+ createVaultService,
7
+ handleVaultHttpDispatch,
8
+ AgentDispatchHttpTransport,
9
+ MemoryStorageProvider,
10
+ } from "../src/runtime/index.js";
11
+ import { LocalSigner } from "../src/protocol/crypto.js";
12
+
13
+ /**
14
+ * This example demonstrates the A/B Process Architecture (Process Isolation).
15
+ *
16
+ * - Process B (The Vault): Hosts the actual secrets and performs the HTTP dispatch.
17
+ * - Process A (The Agent): Signs requests and sends them to Process B. A never sees the secret.
18
+ */
19
+
20
+ // --- Process B: The Vault Server Logic ---
21
+ async function startVaultServer(port: number) {
22
+ const ownerIdentity = createIdentity({ nickname: "vault-owner" });
23
+ const storage = new MemoryStorageProvider();
24
+
25
+ // Create a real vault in memory
26
+ const { core } = await createVault(storage, {
27
+ vaultId: "vault-isolated-server",
28
+ ownerIdentity,
29
+ });
30
+
31
+ // Wrap as a Service
32
+ const service = createVaultService((core as any)._deps);
33
+
34
+ const server = http.createServer(async (req, res) => {
35
+ if (req.method === "POST" && req.url === "/dispatch") {
36
+ let body = "";
37
+ for await (const chunk of req) body += chunk;
38
+
39
+ console.log("[Process B] Received dispatch request from Agent");
40
+
41
+ try {
42
+ const result = await handleVaultHttpDispatch(service, JSON.parse(body));
43
+ res.writeHead(200, { "Content-Type": "application/json" });
44
+ res.end(JSON.stringify(result));
45
+ } catch (err) {
46
+ const message = err instanceof Error ? err.message : String(err);
47
+ res.writeHead(500);
48
+ res.end(JSON.stringify({ ok: false, error: { code: "SERVER_ERROR", message } }));
49
+ }
50
+ } else {
51
+ res.writeHead(404).end();
52
+ }
53
+ });
54
+
55
+ return new Promise<{ server: http.Server; ownerIdentity: any; vault: any }>((resolve) => {
56
+ server.listen(port, () => {
57
+ console.log(`[Process B] Vault Server listening on port ${port}`);
58
+ resolve({ server, ownerIdentity, vault: core });
59
+ });
60
+ });
61
+ }
62
+
63
+ // --- Process A: The LLM Agent Logic ---
64
+ async function runAgentDemo(port: number, agentIdentity: any, capability: any) {
65
+ // Process A ONLY knows the remote URL and its own Agent Identity.
66
+ // It has NO access to the Vault's master key or storage.
67
+ const transport = new AgentDispatchHttpTransport(`http://localhost:${port}/dispatch`);
68
+
69
+ const agentClient = createAgentClient({
70
+ agentIdentity,
71
+ capability,
72
+ transport,
73
+ signer: new LocalSigner(agentIdentity),
74
+ });
75
+
76
+ console.log("[Process A] LLM Agent requesting secret-backed dispatch...");
77
+
78
+ try {
79
+ const result = await agentClient.dispatch({
80
+ secretAlias: "api-token",
81
+ targetUrl: "https://httpbin.org/post",
82
+ method: "POST",
83
+ body: JSON.stringify({ message: "Hello from isolated Process A" }),
84
+ });
85
+
86
+ console.log("[Process A] Dispatch Result Status:", result.status);
87
+ console.log("[Process A] (Secret was injected by Process B and never touched Process A's memory)");
88
+ } catch (err) {
89
+ const message = err instanceof Error ? err.message : String(err);
90
+ console.error("[Process A] Dispatch failed:", message);
91
+ }
92
+ }
93
+
94
+ // --- Orchestration ---
95
+ async function main() {
96
+ const PORT = 3456;
97
+
98
+ // 1. Start the "Vault Server" (Process B)
99
+ const { ownerIdentity, vault, server } = await startVaultServer(PORT);
100
+
101
+ // 2. Setup: Owner (in Process B's context) grants permission to an Agent
102
+ const agentIdentity = createIdentity({ nickname: "llm-agent-1" });
103
+
104
+ // Owner registers the agent and a capability (simulated local call for setup)
105
+ await vault.registerAgentIdentity({
106
+ vaultId: vault.vaultId,
107
+ owner: { kind: "owner", id: ownerIdentity.identityId },
108
+ agentIdentity: {
109
+ vaultId: vault.vaultId,
110
+ agentId: agentIdentity.identityId,
111
+ publicKey: agentIdentity.publicKey,
112
+ },
113
+ proof: { signature: "setup-proof", ownerId: ownerIdentity.identityId, requestedAt: new Date().toISOString() },
114
+ });
115
+
116
+ // Owner writes a secret (simulated local call for setup)
117
+ const secret = await vault.writeSecret({
118
+ kind: "owner.write_secret",
119
+ vaultId: vault.vaultId,
120
+ owner: { kind: "owner", id: ownerIdentity.identityId },
121
+ alias: "api-token",
122
+ plaintext: "SK-PROD-12345",
123
+ targetBindings: [{ kind: "site", targetId: "httpbin.org", targetUrl: "https://httpbin.org/post", methods: ["POST"] }],
124
+ requestedAt: new Date().toISOString(),
125
+ proof: { signature: "setup-proof", ownerId: ownerIdentity.identityId, requestedAt: new Date().toISOString() },
126
+ });
127
+
128
+ const capability = {
129
+ vaultId: vault.vaultId,
130
+ capabilityId: "cap-llm-1",
131
+ agentId: agentIdentity.identityId,
132
+ secretIds: [secret.secretId.value],
133
+ secretAliases: ["api-token"],
134
+ operation: "dispatch_http" as const,
135
+ allowedTargets: ["https://httpbin.org/post"],
136
+ allowedMethods: ["POST"],
137
+ issuedAt: new Date().toISOString(),
138
+ };
139
+
140
+ await vault.registerCapability({
141
+ vaultId: vault.vaultId,
142
+ owner: { kind: "owner", id: ownerIdentity.identityId },
143
+ capability,
144
+ proof: { signature: "setup-proof", ownerId: ownerIdentity.identityId, requestedAt: new Date().toISOString() },
145
+ });
146
+
147
+ // 3. Run the "LLM Agent" (Process A)
148
+ await runAgentDemo(PORT, agentIdentity, capability);
149
+
150
+ // 4. Cleanup
151
+ server.close();
152
+ console.log("Demo finished.");
153
+ }
154
+
155
+ main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@the-ai-company/cbio-node-runtime",
3
- "version": "1.42.0",
3
+ "version": "1.45.2",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "Node.js runtime for cbio identity and credential vault. Library only, no CLI or TUI.",
5
8
  "type": "module",
6
9
  "main": "./dist/runtime/index.js",
@@ -24,7 +27,9 @@
24
27
  },
25
28
  "scripts": {
26
29
  "build": "tsc",
27
- "prepare": "npm run build",
30
+ "build:docs": "npx typedoc --options typedoc.json",
31
+ "release": "npx standard-version && npm publish",
32
+ "prepare": "npm run build && npm run build:docs",
28
33
  "test": "npm run build && npm run test:acceptance",
29
34
  "test:acceptance": "node tests/smoke/runtime-surface.js && node tests/smoke/policy-and-persistence.js && node tests/smoke/replay-guard.js && node tests/smoke/security-guards.js"
30
35
  },
@@ -41,6 +46,9 @@
41
46
  "repository": "https://github.com/TheAICompany/cbio-node-runtime",
42
47
  "devDependencies": {
43
48
  "@types/node": "^20.0.0",
49
+ "standard-version": "^9.5.0",
50
+ "typedoc": "^0.28.18",
51
+ "typedoc-plugin-markdown": "^4.11.0",
44
52
  "typescript": "^5.0.0"
45
53
  },
46
54
  "engines": {