@the-ai-company/cbio-node-runtime 1.63.3 → 1.63.6

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 (233) hide show
  1. package/README.md +48 -209
  2. package/dist/clients/agent/client.d.ts +18 -40
  3. package/dist/clients/agent/client.js +22 -109
  4. package/dist/clients/agent/client.js.map +1 -1
  5. package/dist/clients/agent/contracts.d.ts +1 -8
  6. package/dist/clients/agent/index.d.ts +1 -1
  7. package/dist/clients/owner/client.d.ts +2 -102
  8. package/dist/clients/owner/client.js +111 -266
  9. package/dist/clients/owner/client.js.map +1 -1
  10. package/dist/clients/owner/contracts.d.ts +37 -75
  11. package/dist/clients/owner/index.d.ts +2 -4
  12. package/dist/clients/owner/index.js +1 -2
  13. package/dist/clients/owner/index.js.map +1 -1
  14. package/dist/internal/id-factory.d.ts +0 -2
  15. package/dist/internal/id-factory.js +0 -6
  16. package/dist/internal/id-factory.js.map +1 -1
  17. package/dist/protocol/identity.d.ts +1 -1
  18. package/dist/protocol/identity.js +3 -3
  19. package/dist/protocol/identity.js.map +1 -1
  20. package/dist/public-types.d.ts +5 -14
  21. package/dist/public-types.js +1 -8
  22. package/dist/public-types.js.map +1 -1
  23. package/dist/runtime/bootstrap.d.ts +1 -3
  24. package/dist/runtime/bootstrap.js.map +1 -1
  25. package/dist/runtime/identity.d.ts +2 -2
  26. package/dist/runtime/identity.js +3 -5
  27. package/dist/runtime/identity.js.map +1 -1
  28. package/dist/runtime/index.d.ts +10 -12
  29. package/dist/runtime/index.js +7 -8
  30. package/dist/runtime/index.js.map +1 -1
  31. package/dist/runtime/owner-session.d.ts +7 -6
  32. package/dist/runtime/owner-session.js +5 -6
  33. package/dist/runtime/owner-session.js.map +1 -1
  34. package/dist/storage/fs.d.ts +3 -2
  35. package/dist/storage/fs.js +8 -5
  36. package/dist/storage/fs.js.map +1 -1
  37. package/dist/storage/prefix.d.ts +1 -0
  38. package/dist/storage/prefix.js +7 -0
  39. package/dist/storage/prefix.js.map +1 -1
  40. package/dist/storage/provider.d.ts +2 -0
  41. package/dist/vault-core/contracts.d.ts +95 -210
  42. package/dist/vault-core/contracts.js +8 -11
  43. package/dist/vault-core/contracts.js.map +1 -1
  44. package/dist/vault-core/core.d.ts +119 -62
  45. package/dist/vault-core/core.js +518 -1180
  46. package/dist/vault-core/core.js.map +1 -1
  47. package/dist/vault-core/defaults.d.ts +22 -44
  48. package/dist/vault-core/defaults.js +65 -234
  49. package/dist/vault-core/defaults.js.map +1 -1
  50. package/dist/vault-core/errors.d.ts +3 -2
  51. package/dist/vault-core/errors.js.map +1 -1
  52. package/dist/vault-core/index.d.ts +5 -5
  53. package/dist/vault-core/index.js +2 -2
  54. package/dist/vault-core/index.js.map +1 -1
  55. package/dist/vault-core/persistence.d.ts +72 -119
  56. package/dist/vault-core/persistence.js +310 -427
  57. package/dist/vault-core/persistence.js.map +1 -1
  58. package/dist/vault-core/ports.d.ts +19 -30
  59. package/dist/vault-core/read-policy.d.ts +3 -2
  60. package/dist/vault-core/read-policy.js.map +1 -1
  61. package/dist/vault-core/tool-metadata.js +2 -2
  62. package/dist/vault-core/tool-metadata.js.map +1 -1
  63. package/dist/vault-ingress/defaults.d.ts +4 -2
  64. package/dist/vault-ingress/defaults.js +14 -8
  65. package/dist/vault-ingress/defaults.js.map +1 -1
  66. package/dist/vault-ingress/index.d.ts +39 -119
  67. package/dist/vault-ingress/index.js +98 -456
  68. package/dist/vault-ingress/index.js.map +1 -1
  69. package/dist/vault-ingress/remote-transport.d.ts +5 -3
  70. package/dist/vault-ingress/remote-transport.js +8 -28
  71. package/dist/vault-ingress/remote-transport.js.map +1 -1
  72. package/docs/ARCHITECTURE.md +39 -22
  73. package/docs/CUSTODY_MODEL.md +1 -1
  74. package/docs/IDENTITY_MODEL.md +5 -5
  75. package/docs/MIGRATION-1.51.md +19 -19
  76. package/docs/MIGRATION-1.65.md +87 -0
  77. package/docs/PROCESS_ISOLATION.md +2 -2
  78. package/docs/REFERENCE.md +42 -224
  79. package/docs/api/README.md +48 -30
  80. package/docs/api/classes/IdentityError.md +1 -1
  81. package/docs/api/classes/OwnerClientError.md +1 -1
  82. package/docs/api/classes/PersistentVaultAgentIdentityRegistry.md +89 -0
  83. package/docs/api/classes/PersistentVaultAgentSecretGrantRegistry.md +125 -0
  84. package/docs/api/classes/PersistentVaultAuditLog.md +65 -0
  85. package/docs/api/classes/PersistentVaultSecretCustody.md +93 -0
  86. package/docs/api/classes/PersistentVaultSecretDestinationGrantRegistry.md +125 -0
  87. package/docs/api/classes/PersistentVaultSecretRepository.md +127 -0
  88. package/docs/api/classes/VaultCore.md +264 -237
  89. package/docs/api/classes/VaultCoreError.md +3 -3
  90. package/docs/api/enumerations/AuditAction.md +143 -0
  91. package/docs/api/enumerations/AuditOutcome.md +35 -0
  92. package/docs/api/enumerations/DispatchStatus.md +35 -0
  93. package/docs/api/enumerations/IdentityErrorCode.md +1 -1
  94. package/docs/api/enumerations/OwnerClientErrorCode.md +1 -1
  95. package/docs/api/functions/createAgentClient.md +1 -15
  96. package/docs/api/functions/createIdentity.md +2 -2
  97. package/docs/api/functions/createOwnerClient.md +17 -0
  98. package/docs/api/functions/createOwnerSession.md +1 -1
  99. package/docs/api/functions/createPersistentVaultCoreDependencies.md +4 -4
  100. package/docs/api/functions/createVault.md +1 -1
  101. package/docs/api/functions/createVaultCore.md +1 -1
  102. package/docs/api/functions/createVaultCoreDependencies.md +1 -1
  103. package/docs/api/functions/createVaultService.md +5 -13
  104. package/docs/api/functions/createWorkspaceStorage.md +1 -1
  105. package/docs/api/functions/deriveRootAgentId.md +17 -0
  106. package/docs/api/functions/deriveVaultWorkingKeyFromPassword.md +1 -1
  107. package/docs/api/functions/getDefaultWorkspaceDir.md +1 -1
  108. package/docs/api/functions/handleVaultAgentControlHttp.md +2 -2
  109. package/docs/api/functions/handleVaultHttpDispatch.md +2 -2
  110. package/docs/api/functions/initializeVaultCustody.md +7 -3
  111. package/docs/api/functions/listVaults.md +1 -1
  112. package/docs/api/functions/readVaultProfile.md +1 -1
  113. package/docs/api/functions/recoverVault.md +1 -1
  114. package/docs/api/functions/recoverVaultWorkingKey.md +4 -8
  115. package/docs/api/functions/restoreIdentity.md +1 -1
  116. package/docs/api/functions/updateVaultMetadata.md +1 -1
  117. package/docs/api/functions/writeVaultProfile.md +1 -1
  118. package/docs/api/interfaces/AgentClient.md +20 -59
  119. package/docs/api/interfaces/AgentDispatchIntent.md +1 -1
  120. package/docs/api/interfaces/AgentDispatchTransport.md +12 -44
  121. package/docs/api/interfaces/AgentIdentity.md +3 -3
  122. package/docs/api/interfaces/AgentIdentityRecord.md +47 -0
  123. package/docs/api/interfaces/AgentRequestResult.md +35 -0
  124. package/docs/api/interfaces/AgentRuntimeManifest.md +55 -0
  125. package/docs/api/interfaces/AgentSecretGrant.md +41 -0
  126. package/docs/api/interfaces/AgentSigner.md +1 -1
  127. package/docs/api/interfaces/AgentVisibleRequestRecord.md +53 -0
  128. package/docs/api/interfaces/AgentVisibleSecretRecord.md +65 -0
  129. package/docs/api/interfaces/AuditEntry.md +83 -0
  130. package/docs/api/interfaces/CbioRuntime.md +13 -154
  131. package/docs/api/interfaces/CreateAgentClientOptions.md +4 -10
  132. package/docs/api/interfaces/CreateIdentityOptions.md +1 -1
  133. package/docs/api/interfaces/{CreateVaultClientOptions.md → CreateOwnerClientOptions.md} +9 -11
  134. package/docs/api/interfaces/CreateOwnerSessionOptions.md +3 -121
  135. package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +3 -131
  136. package/docs/api/interfaces/CreateVaultOptions.md +1 -125
  137. package/docs/api/interfaces/CreatedVault.md +2 -2
  138. package/docs/api/interfaces/DefaultPolicyEngineOptions.md +1 -13
  139. package/docs/api/interfaces/DispatchAuthorization.md +43 -0
  140. package/docs/api/interfaces/DispatchInstruction.md +47 -0
  141. package/docs/api/interfaces/DispatchRequest.md +83 -0
  142. package/docs/api/interfaces/DispatchResult.md +53 -0
  143. package/docs/api/interfaces/IStorageProvider.md +13 -1
  144. package/docs/api/interfaces/InitializeVaultCustodyOptions.md +31 -11
  145. package/docs/api/interfaces/InitializedVaultCustody.md +1 -7
  146. package/docs/api/interfaces/OwnerAgentProvisionResult.md +2 -2
  147. package/docs/api/interfaces/OwnerClient.md +401 -0
  148. package/docs/api/interfaces/OwnerCreateSecretInput.md +1 -1
  149. package/docs/api/interfaces/OwnerRemoveSecretInput.md +1 -1
  150. package/docs/api/interfaces/OwnerRequestRecord.md +97 -0
  151. package/docs/api/interfaces/OwnerSensitiveActionConfirmation.md +1 -1
  152. package/docs/api/interfaces/OwnerSensitiveActionContext.md +1 -1
  153. package/docs/api/interfaces/OwnerSession.md +3 -3
  154. package/docs/api/interfaces/OwnerUpdateSecretInput.md +1 -1
  155. package/docs/api/interfaces/OwnerVisibleRequestRecord.md +73 -0
  156. package/docs/api/interfaces/RecoverVaultOptions.md +1 -125
  157. package/docs/api/interfaces/RecoveredVault.md +2 -2
  158. package/docs/api/interfaces/RequestRecord.md +107 -0
  159. package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
  160. package/docs/api/interfaces/SecretAlias.md +11 -0
  161. package/docs/api/interfaces/SecretDestinationGrant.md +41 -0
  162. package/docs/api/interfaces/SecretId.md +11 -0
  163. package/docs/api/interfaces/SecretRecord.md +89 -0
  164. package/docs/api/interfaces/Signer.md +1 -1
  165. package/docs/api/interfaces/VaultApproveDispatchInput.md +3 -9
  166. package/docs/api/interfaces/VaultAuditQueryInput.md +1 -1
  167. package/docs/api/interfaces/VaultCoreDependenciesOptions.md +1 -5
  168. package/docs/api/interfaces/VaultCreateAgentInput.md +1 -1
  169. package/docs/api/interfaces/VaultExportSecretInput.md +1 -1
  170. package/docs/api/interfaces/VaultGetRequestInput.md +17 -0
  171. package/docs/api/interfaces/VaultGrantAgentSecretInput.md +23 -0
  172. package/docs/api/interfaces/VaultGrantSecretDestinationInput.md +23 -0
  173. package/docs/api/interfaces/VaultId.md +11 -0
  174. package/docs/api/interfaces/VaultImportAgentInput.md +1 -1
  175. package/docs/api/interfaces/VaultIssueSessionTokenInput.md +5 -5
  176. package/docs/api/interfaces/VaultListAgentsInput.md +1 -1
  177. package/docs/api/interfaces/VaultListGrantsInput.md +23 -0
  178. package/docs/api/interfaces/VaultListRequestsInput.md +17 -0
  179. package/docs/api/interfaces/VaultListSecretsInput.md +1 -1
  180. package/docs/api/interfaces/VaultMetadata.md +1 -1
  181. package/docs/api/interfaces/VaultObject.md +2 -2
  182. package/docs/api/interfaces/VaultPrincipal.md +17 -0
  183. package/docs/api/interfaces/VaultProfile.md +1 -1
  184. package/docs/api/interfaces/VaultReadAgentPrivateKeyInput.md +7 -7
  185. package/docs/api/interfaces/VaultReadSecretPlaintextInput.md +1 -1
  186. package/docs/api/interfaces/VaultRevokeAgentSecretInput.md +23 -0
  187. package/docs/api/interfaces/VaultRevokeSecretDestinationInput.md +23 -0
  188. package/docs/api/interfaces/VaultRevokeSessionTokenInput.md +1 -1
  189. package/docs/api/interfaces/VaultService.md +511 -0
  190. package/docs/api/interfaces/VaultUpdateAgentInput.md +7 -7
  191. package/docs/api/type-aliases/AgentId.md +7 -0
  192. package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
  193. package/docs/api/type-aliases/DispatchApprovalDecision.md +7 -0
  194. package/docs/api/type-aliases/GrantStatus.md +7 -0
  195. package/docs/api/type-aliases/SecretLifecycleStatus.md +7 -0
  196. package/docs/api/type-aliases/VaultPrincipalKind.md +7 -0
  197. package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +2 -2
  198. package/docs/es/README.md +3 -3
  199. package/docs/fr/README.md +3 -3
  200. package/docs/ja/README.md +5 -5
  201. package/docs/ko/README.md +5 -5
  202. package/docs/pt/README.md +3 -3
  203. package/docs/zh/PROCESS_ISOLATION.md +2 -2
  204. package/docs/zh/README.md +47 -63
  205. package/examples/process-isolation.ts +26 -35
  206. package/package.json +1 -1
  207. package/docs/api/functions/createOwnerHttpFlowBoundary.md +0 -17
  208. package/docs/api/functions/createStandardAcquireBoundary.md +0 -31
  209. package/docs/api/functions/createStandardDispatchBoundary.md +0 -23
  210. package/docs/api/functions/createVaultClient.md +0 -32
  211. package/docs/api/functions/deriveIdentityId.md +0 -17
  212. package/docs/api/functions/wrapVaultCoreAsVaultService.md +0 -31
  213. package/docs/api/interfaces/AgentSubmitCapabilityRequestInput.md +0 -41
  214. package/docs/api/interfaces/VaultApproveCapabilityRequestInput.md +0 -23
  215. package/docs/api/interfaces/VaultClient.md +0 -473
  216. package/docs/api/interfaces/VaultGrantCapabilityInput.md +0 -79
  217. package/docs/api/interfaces/VaultGrantCapabilityRequest.md +0 -23
  218. package/docs/api/interfaces/VaultIdentity.md +0 -11
  219. package/docs/api/interfaces/VaultListCapabilitiesInput.md +0 -17
  220. package/docs/api/interfaces/VaultRegisterFlowInput.md +0 -77
  221. package/docs/api/interfaces/VaultRevokeCapabilityInput.md +0 -23
  222. package/docs/api/interfaces/VaultSigner.md +0 -21
  223. package/docs/api/interfaces/VaultSubmitCapabilityRequestInput.md +0 -73
  224. package/docs/api/type-aliases/AgentCapabilityEnvelope.md +0 -7
  225. package/docs/api/type-aliases/AgentVisibleSecretRecord.md +0 -7
  226. package/docs/api/type-aliases/CreateOwnerClientOptions.md +0 -7
  227. package/docs/api/type-aliases/OwnerAgentView.md +0 -7
  228. package/docs/api/type-aliases/OwnerClient.md +0 -13
  229. package/docs/api/type-aliases/OwnerGrantCapabilityInput.md +0 -7
  230. package/docs/api/type-aliases/OwnerPendingApprovalView.md +0 -7
  231. package/docs/api/type-aliases/OwnerRequestDetailView.md +0 -7
  232. package/docs/api/type-aliases/OwnerRequestSummaryView.md +0 -7
  233. package/docs/api/type-aliases/OwnerSecretView.md +0 -7
@@ -1,27 +1,26 @@
1
- import { LocalSigner } from "../../protocol/crypto.js";
2
1
  import { OwnerClientError, OwnerClientErrorCode } from "../../errors.js";
3
- import { createAgentIdValue, createCapabilityIdValue, createFlowIdValue, createRequestIdValue, } from "../../internal/id-factory.js";
2
+ import { createRequestIdValue, } from "../../internal/id-factory.js";
4
3
  import { createIdentity, restoreIdentity } from "../../runtime/identity.js";
5
4
  import { SystemClock } from "../../vault-core/index.js";
6
5
  const VAULT_MASTER_ID = "vault-master";
7
- class DefaultVaultClient {
6
+ class DefaultOwnerClient {
8
7
  _vault;
9
- _identity;
8
+ _rootAgentIdInput;
10
9
  _signer;
11
10
  _clock;
12
11
  _skipWarmup;
13
12
  _passwordVerifier;
14
13
  _sensitiveActionVerifier;
15
- _identityId;
16
- constructor(_vault, _identity, _signer, _clock = new SystemClock(), _skipWarmup = false, _passwordVerifier, _sensitiveActionVerifier) {
14
+ _rootAgentId;
15
+ constructor(_vault, _rootAgentIdInput, _signer, _clock = new SystemClock(), _skipWarmup = false, _passwordVerifier, _sensitiveActionVerifier) {
17
16
  this._vault = _vault;
18
- this._identity = _identity;
17
+ this._rootAgentIdInput = _rootAgentIdInput;
19
18
  this._signer = _signer;
20
19
  this._clock = _clock;
21
20
  this._skipWarmup = _skipWarmup;
22
21
  this._passwordVerifier = _passwordVerifier;
23
22
  this._sensitiveActionVerifier = _sensitiveActionVerifier;
24
- this._identityId = _identity?.identityId ?? VAULT_MASTER_ID;
23
+ this._rootAgentId = _rootAgentIdInput ?? VAULT_MASTER_ID;
25
24
  }
26
25
  async _confirmSensitiveAction(confirmation, context) {
27
26
  const normalizedPassword = confirmation.password.trim();
@@ -39,38 +38,13 @@ class DefaultVaultClient {
39
38
  return;
40
39
  }
41
40
  if (!this._passwordVerifier) {
42
- throw new OwnerClientError(OwnerClientErrorCode.SENSITIVE_ACTION_VERIFIER_REQUIRED, "VaultClient: sensitiveActionVerifier or passwordVerifier is required for sensitive reads");
41
+ throw new OwnerClientError(OwnerClientErrorCode.SENSITIVE_ACTION_VERIFIER_REQUIRED, "OwnerClient: sensitiveActionVerifier or passwordVerifier is required for sensitive reads");
43
42
  }
44
43
  const valid = await this._passwordVerifier(normalizedPassword);
45
44
  if (!valid) {
46
45
  throw new OwnerClientError(OwnerClientErrorCode.SENSITIVE_ACTION_INVALID_PASSWORD, "invalid vault password");
47
46
  }
48
47
  }
49
- _resolveGrantedCapability(input) {
50
- if ("capability" in input) {
51
- return {
52
- requestedAt: input.requestedAt ?? input.capability.issuedAt,
53
- capability: {
54
- vaultId: input.capability.vaultId,
55
- capabilityId: input.capability.capabilityId,
56
- agentId: input.capability.agentId,
57
- operation: input.capability.operation,
58
- customFlowId: input.capability.customFlowId,
59
- write: input.capability.write,
60
- read: input.capability.read,
61
- issuedAt: input.capability.issuedAt,
62
- expiresAt: input.capability.expiresAt,
63
- rateLimit: input.capability.rateLimit,
64
- skipAudit: input.capability.skipAudit,
65
- auditRequired: input.capability.auditRequired,
66
- },
67
- };
68
- }
69
- return {
70
- requestedAt: input.requestedAt,
71
- capability: input,
72
- };
73
- }
74
48
  async ownerCreateSecret(input) {
75
49
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
76
50
  const requestId = createRequestIdValue("create_secret");
@@ -80,7 +54,7 @@ class DefaultVaultClient {
80
54
  requestId,
81
55
  owner: {
82
56
  kind: "owner",
83
- id: this._identityId,
57
+ id: this._rootAgentId,
84
58
  },
85
59
  alias: input.alias,
86
60
  plaintext: input.plaintext,
@@ -97,7 +71,7 @@ class DefaultVaultClient {
97
71
  requestId,
98
72
  owner: {
99
73
  kind: "owner",
100
- id: this._identityId,
74
+ id: this._rootAgentId,
101
75
  },
102
76
  alias: input.alias,
103
77
  plaintext: input.plaintext,
@@ -112,9 +86,9 @@ class DefaultVaultClient {
112
86
  vaultId: this._vault.vaultId,
113
87
  actor: {
114
88
  kind: "owner",
115
- id: this._identityId,
89
+ id: this._rootAgentId,
116
90
  },
117
- query,
91
+ query: { ...query, vaultId: this._vault.vaultId },
118
92
  requestId,
119
93
  requestedAt,
120
94
  });
@@ -133,7 +107,7 @@ class DefaultVaultClient {
133
107
  vaultId: this._vault.vaultId,
134
108
  actor: {
135
109
  kind: "owner",
136
- id: this._identityId,
110
+ id: this._rootAgentId,
137
111
  },
138
112
  alias: input.alias,
139
113
  requestId,
@@ -152,7 +126,7 @@ class DefaultVaultClient {
152
126
  vaultId: this._vault.vaultId,
153
127
  actor: {
154
128
  kind: "owner",
155
- id: this._identityId,
129
+ id: this._rootAgentId,
156
130
  },
157
131
  alias: input.alias,
158
132
  requestId: createRequestIdValue("read_secret_plaintext"),
@@ -166,7 +140,7 @@ class DefaultVaultClient {
166
140
  verificationCode: input.verificationCode,
167
141
  }, {
168
142
  action: "read_agent_private_key",
169
- subject: input.agentId,
143
+ subject: input.rootAgentId,
170
144
  });
171
145
  const agents = await this._vault.ownerListAgents({
172
146
  vaultId: this._vault.vaultId,
@@ -174,10 +148,10 @@ class DefaultVaultClient {
174
148
  requestedAt: input.requestedAt ?? this._clock.nowIso(),
175
149
  actor: {
176
150
  kind: "owner",
177
- id: this._identityId,
151
+ id: this._rootAgentId,
178
152
  },
179
153
  });
180
- const agent = agents.find((record) => record.agentId === input.agentId);
154
+ const agent = agents.find((record) => record.rootAgentId === input.rootAgentId);
181
155
  if (!agent?.privateKey) {
182
156
  throw new OwnerClientError(OwnerClientErrorCode.AGENT_PRIVATE_KEY_NOT_FOUND, "agent private key not found");
183
157
  }
@@ -185,11 +159,10 @@ class DefaultVaultClient {
185
159
  }
186
160
  async _ownerRegisterManagedAgentIdentity(input) {
187
161
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
188
- const requestId = createRequestIdValue("register_agent_identity");
189
- const agentIdentity = {
162
+ const requestId = createRequestIdValue("register_agent.identity");
163
+ const agentRecord = {
190
164
  vaultId: this._vault.vaultId,
191
- agentId: input.agentId,
192
- identityId: input.identityId,
165
+ rootAgentId: input.rootAgentId,
193
166
  publicKey: input.publicKey,
194
167
  privateKey: input.privateKey,
195
168
  metadata: input.metadata,
@@ -200,18 +173,17 @@ class DefaultVaultClient {
200
173
  requestId,
201
174
  owner: {
202
175
  kind: "owner",
203
- id: this._identityId,
176
+ id: this._rootAgentId,
204
177
  },
205
- agentIdentity,
178
+ agentRecord,
206
179
  requestedAt,
207
180
  });
208
- return agentIdentity;
181
+ return agentRecord;
209
182
  }
210
183
  async ownerImportAgent(input) {
211
184
  const identity = restoreIdentity(input.privateKey, { nickname: input.nickname });
212
185
  const agent = await this._ownerRegisterManagedAgentIdentity({
213
- agentId: createAgentIdValue(),
214
- identityId: identity.identityId,
186
+ rootAgentId: identity.rootAgentId,
215
187
  publicKey: identity.publicKey,
216
188
  privateKey: identity.privateKey,
217
189
  metadata: input.metadata,
@@ -219,7 +191,7 @@ class DefaultVaultClient {
219
191
  requestedAt: input.requestedAt,
220
192
  });
221
193
  const sessionToken = await this.ownerIssueSessionToken({
222
- agentId: agent.agentId,
194
+ rootAgentId: agent.rootAgentId,
223
195
  requestedAt: input.requestedAt,
224
196
  });
225
197
  return {
@@ -233,8 +205,7 @@ class DefaultVaultClient {
233
205
  async ownerCreateAgent(input) {
234
206
  const identity = createIdentity();
235
207
  const agent = await this._ownerRegisterManagedAgentIdentity({
236
- agentId: createAgentIdValue(),
237
- identityId: identity.identityId,
208
+ rootAgentId: identity.rootAgentId,
238
209
  publicKey: identity.publicKey,
239
210
  privateKey: identity.privateKey,
240
211
  metadata: input.metadata,
@@ -242,7 +213,7 @@ class DefaultVaultClient {
242
213
  requestedAt: input.requestedAt,
243
214
  });
244
215
  const sessionToken = await this.ownerIssueSessionToken({
245
- agentId: agent.agentId,
216
+ rootAgentId: agent.rootAgentId,
246
217
  requestedAt: input.requestedAt,
247
218
  });
248
219
  return {
@@ -255,17 +226,17 @@ class DefaultVaultClient {
255
226
  }
256
227
  async ownerUpdateAgent(input) {
257
228
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
258
- const requestId = createRequestIdValue("update_agent_identity");
229
+ const requestId = createRequestIdValue("update_agent.identity");
259
230
  const updated = await this._vault.ownerUpdateAgentIdentity({
260
231
  vaultId: this._vault.vaultId,
261
232
  requestId,
262
233
  owner: {
263
234
  kind: "owner",
264
- id: this._identityId,
235
+ id: this._rootAgentId,
265
236
  },
266
- agentId: input.agentId,
267
- nickname: input.nickname,
268
237
  metadata: input.metadata,
238
+ rootAgentId: input.rootAgentId,
239
+ nickname: input.nickname,
269
240
  requestedAt,
270
241
  });
271
242
  return {
@@ -273,76 +244,58 @@ class DefaultVaultClient {
273
244
  privateKey: undefined,
274
245
  };
275
246
  }
276
- async ownerGrantCapability(input) {
277
- const normalized = this._resolveGrantedCapability(input);
278
- const requestedAt = normalized.requestedAt ?? this._clock.nowIso();
279
- const capabilityId = normalized.capability.capabilityId ?? createCapabilityIdValue();
280
- const requestId = createRequestIdValue("register_capability");
281
- const skipAudit = normalized.capability.skipAudit ?? (normalized.capability.auditRequired === undefined
282
- ? undefined
283
- : !normalized.capability.auditRequired);
284
- const capability = {
285
- vaultId: normalized.capability.vaultId ?? this._vault.vaultId,
286
- agentId: normalized.capability.agentId,
287
- capabilityId,
288
- operation: normalized.capability.operation ?? "dispatch_http",
289
- customFlowId: normalized.capability.customFlowId,
290
- write: {
291
- secretIds: normalized.capability.write.secretIds ? [...normalized.capability.write.secretIds] : undefined,
292
- scope: normalized.capability.write.scope,
293
- methods: [...normalized.capability.write.methods],
294
- },
295
- read: { paths: [...normalized.capability.read.paths] },
296
- expiresAt: normalized.capability.expiresAt,
297
- rateLimit: normalized.capability.rateLimit,
298
- skipAudit,
299
- issuedAt: normalized.capability.issuedAt ?? requestedAt,
300
- };
301
- await this._vault.ownerRegisterCapability({
247
+ async ownerGrantAgentSecret(input) {
248
+ const requestedAt = input.requestedAt ?? this._clock.nowIso();
249
+ return this._vault.ownerGrantAgentSecret({
302
250
  vaultId: this._vault.vaultId,
303
- requestId,
304
- owner: {
305
- kind: "owner",
306
- id: this._identityId,
307
- },
308
- capability,
251
+ requestId: createRequestIdValue("grant_agent_secret"),
252
+ actor: { kind: "owner", id: this._rootAgentId },
253
+ rootAgentId: input.rootAgentId,
254
+ secretAlias: input.secretAlias,
309
255
  requestedAt,
310
256
  });
311
- return capability;
312
257
  }
313
- async ownerRegisterFlow(input) {
258
+ async ownerGrantSecretDestination(input) {
314
259
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
315
- const flowId = createFlowIdValue();
316
- const requestId = createRequestIdValue("register_custom_flow");
317
- const flow = {
318
- flowId,
319
- mode: input.mode,
320
- targetUrl: input.targetUrl,
321
- method: input.method,
322
- responseVisibility: input.responseVisibility,
323
- responseSecret: input.responseSecret,
324
- };
325
- await this._vault.ownerRegisterCustomFlow({
260
+ return this._vault.ownerGrantSecretDestination({
326
261
  vaultId: this._vault.vaultId,
327
- requestId,
328
- owner: {
329
- kind: "owner",
330
- id: this._identityId,
331
- },
332
- flow,
262
+ requestId: createRequestIdValue("grant_secret_destination"),
263
+ actor: { kind: "owner", id: this._rootAgentId },
264
+ secretAlias: input.secretAlias,
265
+ siteId: input.siteId,
333
266
  requestedAt,
334
267
  });
335
- return {
268
+ }
269
+ async ownerRevokeAgentSecret(input) {
270
+ const requestedAt = input.requestedAt ?? this._clock.nowIso();
271
+ return this._vault.ownerRevokeAgentSecret({
336
272
  vaultId: this._vault.vaultId,
337
- flowId,
338
- ownerId: this._identityId,
339
- mode: input.mode,
340
- targetUrl: input.targetUrl,
341
- method: input.method,
342
- responseVisibility: input.responseVisibility,
343
- responseSecret: input.responseSecret,
344
- createdAt: requestedAt,
345
- };
273
+ requestId: createRequestIdValue("revoke_agent_secret"),
274
+ actor: { kind: "owner", id: this._rootAgentId },
275
+ rootAgentId: input.rootAgentId,
276
+ secretAlias: input.secretAlias,
277
+ requestedAt,
278
+ });
279
+ }
280
+ async ownerRevokeSecretDestination(input) {
281
+ const requestedAt = input.requestedAt ?? this._clock.nowIso();
282
+ return this._vault.ownerRevokeSecretDestination({
283
+ vaultId: this._vault.vaultId,
284
+ requestId: createRequestIdValue("revoke_secret_destination"),
285
+ actor: { kind: "owner", id: this._rootAgentId },
286
+ secretAlias: input.secretAlias,
287
+ siteId: input.siteId,
288
+ requestedAt,
289
+ });
290
+ }
291
+ async ownerListGrants(input = {}) {
292
+ const requestedAt = this._clock.nowIso();
293
+ return this._vault.ownerListGrants({
294
+ vaultId: this._vault.vaultId,
295
+ requestId: createRequestIdValue("list_grants"),
296
+ actor: { kind: "owner", id: this._rootAgentId },
297
+ requestedAt,
298
+ });
346
299
  }
347
300
  async ownerRemoveSecret(input) {
348
301
  await this._confirmSensitiveAction({
@@ -360,7 +313,7 @@ class DefaultVaultClient {
360
313
  requestId,
361
314
  owner: {
362
315
  kind: "owner",
363
- id: this._identityId,
316
+ id: this._rootAgentId,
364
317
  },
365
318
  alias: input.alias,
366
319
  requestedAt,
@@ -375,7 +328,7 @@ class DefaultVaultClient {
375
328
  requestedAt,
376
329
  actor: {
377
330
  kind: "owner",
378
- id: this._identityId,
331
+ id: this._rootAgentId,
379
332
  },
380
333
  });
381
334
  return agents.map((agent) => ({
@@ -383,20 +336,6 @@ class DefaultVaultClient {
383
336
  privateKey: undefined,
384
337
  }));
385
338
  }
386
- async ownerListCapabilities(input = {}) {
387
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
388
- const requestId = createRequestIdValue("list_capabilities");
389
- return this._vault.ownerListCapabilities({
390
- vaultId: this._vault.vaultId,
391
- requestId,
392
- requestedAt,
393
- actor: {
394
- kind: "owner",
395
- id: this._identityId,
396
- },
397
- agentId: input.agentId,
398
- });
399
- }
400
339
  async ownerListRequests(input = {}) {
401
340
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
402
341
  const requestId = createRequestIdValue("list_requests");
@@ -404,11 +343,8 @@ class DefaultVaultClient {
404
343
  vaultId: this._vault.vaultId,
405
344
  requestId,
406
345
  requestedAt,
407
- actor: {
408
- kind: "owner",
409
- id: this._identityId,
410
- },
411
- agentId: input.agentId,
346
+ actor: { kind: "owner", id: this._rootAgentId },
347
+ rootAgentId: input.rootAgentId,
412
348
  });
413
349
  }
414
350
  async ownerGetRequest(input) {
@@ -420,20 +356,11 @@ class DefaultVaultClient {
420
356
  requestedAt,
421
357
  actor: {
422
358
  kind: "owner",
423
- id: this._identityId,
359
+ id: this._rootAgentId,
424
360
  },
425
361
  targetRequestId: input.requestId,
426
362
  });
427
363
  }
428
- async ownerListCapabilityStates(input = {}) {
429
- return this._vault.ownerListCapabilityStates({
430
- vaultId: this._vault.vaultId,
431
- owner: { kind: "owner", id: this._identityId },
432
- agentId: input.agentId,
433
- writeGranted: input.writeGranted,
434
- readGranted: input.readGranted,
435
- });
436
- }
437
364
  async ownerListSecrets(input = {}) {
438
365
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
439
366
  const requestId = createRequestIdValue("list_secrets");
@@ -441,37 +368,22 @@ class DefaultVaultClient {
441
368
  vaultId: this._vault.vaultId,
442
369
  owner: {
443
370
  kind: "owner",
444
- id: this._identityId,
371
+ id: this._rootAgentId,
445
372
  },
446
373
  requestId,
447
374
  });
448
375
  }
449
- async ownerRevokeCapability(input) {
450
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
451
- const requestId = createRequestIdValue("revoke_capability");
452
- return this._vault.ownerRevokeCapability({
453
- vaultId: this._vault.vaultId,
454
- requestId,
455
- requestedAt,
456
- owner: {
457
- kind: "owner",
458
- id: this._identityId,
459
- },
460
- agentId: input.agentId,
461
- capabilityId: input.capabilityId,
462
- });
463
- }
464
376
  async ownerIssueSessionToken(input) {
465
377
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
466
378
  const requestId = createRequestIdValue("issue_session_token");
467
379
  return this._vault.ownerIssueSessionToken({
468
380
  vaultId: this._vault.vaultId,
381
+ requestId,
382
+ rootAgentId: input.rootAgentId,
469
383
  actor: {
470
384
  kind: "owner",
471
- id: this._identityId,
385
+ id: this._rootAgentId,
472
386
  },
473
- agentId: input.agentId,
474
- requestId,
475
387
  requestedAt,
476
388
  });
477
389
  }
@@ -480,120 +392,53 @@ class DefaultVaultClient {
480
392
  vaultId: this._vault.vaultId,
481
393
  actor: {
482
394
  kind: "owner",
483
- id: this._identityId,
395
+ id: this._rootAgentId,
484
396
  },
485
397
  token: input.token,
486
398
  });
487
399
  }
488
- async ownerSubmitCapabilityRequest(input) {
489
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
490
- const requestId = createRequestIdValue("submit_capability_request");
491
- return this._vault.ownerSubmitCapabilityRequest({
492
- vaultId: this._vault.vaultId,
493
- requestId,
494
- requester: input.requester,
495
- agentId: input.agentId,
496
- capability: {
497
- operation: input.operation ?? "dispatch_http",
498
- write: {
499
- secretIds: input.write.secretIds ? [...input.write.secretIds] : undefined,
500
- scope: input.write.scope,
501
- methods: [...input.write.methods],
502
- },
503
- read: { paths: [...input.read.paths] },
504
- rateLimit: input.rateLimit,
505
- skipAudit: input.skipAudit,
506
- expiresAt: input.expiresAt,
507
- },
508
- reason: input.reason,
509
- requestedAt,
510
- });
511
- }
512
400
  async ownerIssueAllSessionTokens() {
513
401
  return this._vault.ownerIssueAllAgentSessionTokens({
514
- vaultId: this._vault.vaultId,
515
- actor: { kind: "owner", id: this._identityId },
402
+ kind: "owner",
403
+ id: this._rootAgentId,
516
404
  });
517
405
  }
518
- async ownerApproveCapabilityRead(input) {
519
- return this._vault.ownerApproveCapabilityRead({
520
- vaultId: this._vault.vaultId,
521
- requestId: input.requestId,
522
- owner: { kind: "owner", id: this._identityId },
523
- read: input.read ? { paths: [...input.read.paths] } : undefined,
524
- });
525
- }
526
- async ownerAllowOnce(input) {
527
- return this._vault.ownerAllowOnce({
528
- vaultId: this._vault.vaultId,
529
- requestId: input.requestId,
530
- owner: { kind: "owner", id: this._identityId },
531
- });
532
- }
533
- async ownerAllowAlways(input) {
534
- return this._vault.ownerAllowAlways({
406
+ async ownerApproveDispatch(input) {
407
+ const requestedAt = this._clock.nowIso();
408
+ return this._vault.ownerApproveDispatch({
535
409
  vaultId: this._vault.vaultId,
536
410
  requestId: input.requestId,
537
- owner: { kind: "owner", id: this._identityId },
411
+ actor: { kind: "owner", id: this._rootAgentId },
412
+ decision: input.decision,
413
+ requestedAt,
538
414
  });
539
415
  }
540
- async ownerDeny(requestId) {
541
- return this._vault.ownerDeny({
416
+ async ownerDenyDispatch(requestId) {
417
+ const requestedAt = this._clock.nowIso();
418
+ await this._vault.ownerApproveDispatch({
542
419
  vaultId: this._vault.vaultId,
543
420
  requestId,
544
- owner: { kind: "owner", id: this._identityId },
421
+ actor: { kind: "owner", id: this._rootAgentId },
422
+ decision: "deny",
423
+ requestedAt,
545
424
  });
546
425
  }
547
- ownerOnCapabilityState(callback) {
548
- return this._vault.ownerOnCapabilityState(callback);
426
+ ownerOnPendingDispatch(callback) {
427
+ return this._vault.ownerOnPendingDispatch(callback);
549
428
  }
550
429
  }
551
- function isCreateVaultClientOptions(value) {
552
- return typeof value === "object" && value !== null && "vault" in value;
553
- }
554
- function isCreatedIdentity(value) {
555
- return "privateKey" in value && "publicKey" in value;
556
- }
557
- function resolveVaultSigner(identity, signer) {
558
- if (signer) {
559
- return signer;
560
- }
561
- if (identity && isCreatedIdentity(identity)) {
562
- return new LocalSigner(identity);
563
- }
564
- return undefined;
565
- }
566
- function resolveVaultIdentity(options) {
567
- if (!options.ownerIdentity) {
568
- return undefined;
569
- }
570
- return {
571
- identityId: options.ownerIdentity.identityId,
572
- };
573
- }
574
- /**
575
- * Creates a {@link VaultClient} instance for a specific vault owner.
576
- *
577
- * @param options - Configuration including optional owner identity and the vault service.
578
- * @returns An initialized {@link VaultClient}.
579
- *
580
- * @example
581
- * ```ts
582
- * const client = createVaultClient({
583
- * ownerIdentity,
584
- * vault
585
- * });
586
- * ```
587
- */
588
- export function createVaultClient(options) {
589
- if (!isCreateVaultClientOptions(options)) {
590
- throw new OwnerClientError(OwnerClientErrorCode.INVALID_CREATE_VAULT_CLIENT_OPTIONS, "createVaultClient() requires a single options object with 'vault'");
591
- }
592
- const client = new DefaultVaultClient(options.vault, resolveVaultIdentity(options), resolveVaultSigner(options.ownerIdentity, options.signer), options.clock ?? new SystemClock(), options.skipWarmup, options.passwordVerifier, options.sensitiveActionVerifier);
430
+ export async function createOwnerClient(options) {
431
+ const identity = options.ownerIdentity;
432
+ const rootAgentId = identity.rootAgentId;
433
+ const client = new DefaultOwnerClient(options.vault, rootAgentId, undefined, // signer no longer directly used in simple owner client
434
+ options.clock ?? new SystemClock(), options.skipWarmup ?? false, options.passwordVerifier, options.sensitiveActionVerifier);
593
435
  if (!options.skipWarmup) {
594
- client.ownerIssueAllSessionTokens().catch((err) => {
595
- console.error("VaultClient: failed to warmup session tokens:", err);
596
- });
436
+ try {
437
+ await client.ownerIssueAllSessionTokens();
438
+ }
439
+ catch (e) {
440
+ console.warn("OwnerClient warmup failed:", e);
441
+ }
597
442
  }
598
443
  return client;
599
444
  }