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

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 (234) 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 +119 -240
  9. package/dist/clients/owner/client.js.map +1 -1
  10. package/dist/clients/owner/contracts.d.ts +37 -70
  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.js.map +1 -1
  24. package/dist/runtime/identity.d.ts +2 -2
  25. package/dist/runtime/identity.js +3 -5
  26. package/dist/runtime/identity.js.map +1 -1
  27. package/dist/runtime/index.d.ts +10 -12
  28. package/dist/runtime/index.js +7 -8
  29. package/dist/runtime/index.js.map +1 -1
  30. package/dist/runtime/owner-session.d.ts +7 -6
  31. package/dist/runtime/owner-session.js +5 -6
  32. package/dist/runtime/owner-session.js.map +1 -1
  33. package/dist/storage/fs.d.ts +3 -2
  34. package/dist/storage/fs.js +8 -5
  35. package/dist/storage/fs.js.map +1 -1
  36. package/dist/storage/prefix.d.ts +1 -0
  37. package/dist/storage/prefix.js +7 -0
  38. package/dist/storage/prefix.js.map +1 -1
  39. package/dist/storage/provider.d.ts +2 -0
  40. package/dist/vault-core/contracts.d.ts +112 -193
  41. package/dist/vault-core/contracts.js +5 -8
  42. package/dist/vault-core/contracts.js.map +1 -1
  43. package/dist/vault-core/core.d.ts +127 -62
  44. package/dist/vault-core/core.js +500 -1182
  45. package/dist/vault-core/core.js.map +1 -1
  46. package/dist/vault-core/defaults.d.ts +26 -42
  47. package/dist/vault-core/defaults.js +73 -229
  48. package/dist/vault-core/defaults.js.map +1 -1
  49. package/dist/vault-core/errors.d.ts +3 -2
  50. package/dist/vault-core/errors.js.map +1 -1
  51. package/dist/vault-core/index.d.ts +5 -5
  52. package/dist/vault-core/index.js +2 -2
  53. package/dist/vault-core/index.js.map +1 -1
  54. package/dist/vault-core/persistence.d.ts +78 -118
  55. package/dist/vault-core/persistence.js +329 -421
  56. package/dist/vault-core/persistence.js.map +1 -1
  57. package/dist/vault-core/ports.d.ts +19 -24
  58. package/dist/vault-core/read-policy.d.ts +3 -2
  59. package/dist/vault-core/read-policy.js.map +1 -1
  60. package/dist/vault-core/tool-metadata.js +2 -2
  61. package/dist/vault-core/tool-metadata.js.map +1 -1
  62. package/dist/vault-ingress/defaults.d.ts +4 -2
  63. package/dist/vault-ingress/defaults.js +14 -8
  64. package/dist/vault-ingress/defaults.js.map +1 -1
  65. package/dist/vault-ingress/index.d.ts +43 -117
  66. package/dist/vault-ingress/index.js +98 -453
  67. package/dist/vault-ingress/index.js.map +1 -1
  68. package/dist/vault-ingress/remote-transport.d.ts +5 -3
  69. package/dist/vault-ingress/remote-transport.js +8 -28
  70. package/dist/vault-ingress/remote-transport.js.map +1 -1
  71. package/docs/ARCHITECTURE.md +39 -22
  72. package/docs/CUSTODY_MODEL.md +1 -1
  73. package/docs/IDENTITY_MODEL.md +5 -5
  74. package/docs/MIGRATION-1.51.md +19 -19
  75. package/docs/MIGRATION-1.65.md +61 -0
  76. package/docs/PROCESS_ISOLATION.md +2 -2
  77. package/docs/REFERENCE.md +42 -224
  78. package/docs/api/README.md +50 -29
  79. package/docs/api/classes/IdentityError.md +1 -1
  80. package/docs/api/classes/OwnerClientError.md +1 -1
  81. package/docs/api/classes/PersistentVaultAgentIdentityRegistry.md +89 -0
  82. package/docs/api/classes/PersistentVaultAgentSecretGrantRegistry.md +125 -0
  83. package/docs/api/classes/PersistentVaultAuditLog.md +65 -0
  84. package/docs/api/classes/PersistentVaultCustomHttpFlowRegistry.md +69 -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 +299 -214
  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 -9
  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 -150
  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 -117
  135. package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +3 -131
  136. package/docs/api/interfaces/CreateVaultOptions.md +1 -121
  137. package/docs/api/interfaces/CreatedVault.md +2 -2
  138. package/docs/api/interfaces/CustomHttpFlowDefinition.md +71 -0
  139. package/docs/api/interfaces/DefaultPolicyEngineOptions.md +1 -13
  140. package/docs/api/interfaces/DispatchAuthorization.md +43 -0
  141. package/docs/api/interfaces/DispatchInstruction.md +47 -0
  142. package/docs/api/interfaces/DispatchRequest.md +83 -0
  143. package/docs/api/interfaces/DispatchResult.md +53 -0
  144. package/docs/api/interfaces/IStorageProvider.md +13 -1
  145. package/docs/api/interfaces/InitializeVaultCustodyOptions.md +31 -11
  146. package/docs/api/interfaces/InitializedVaultCustody.md +1 -7
  147. package/docs/api/interfaces/OwnerAgentProvisionResult.md +2 -2
  148. package/docs/api/interfaces/OwnerClient.md +417 -0
  149. package/docs/api/interfaces/OwnerCreateSecretInput.md +1 -1
  150. package/docs/api/interfaces/OwnerRemoveSecretInput.md +1 -1
  151. package/docs/api/interfaces/OwnerRequestRecord.md +97 -0
  152. package/docs/api/interfaces/OwnerSensitiveActionConfirmation.md +1 -1
  153. package/docs/api/interfaces/OwnerSensitiveActionContext.md +1 -1
  154. package/docs/api/interfaces/OwnerSession.md +3 -3
  155. package/docs/api/interfaces/OwnerUpdateSecretInput.md +1 -1
  156. package/docs/api/interfaces/OwnerVisibleRequestRecord.md +73 -0
  157. package/docs/api/interfaces/RecoverVaultOptions.md +1 -121
  158. package/docs/api/interfaces/RecoveredVault.md +2 -2
  159. package/docs/api/interfaces/RequestRecord.md +107 -0
  160. package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
  161. package/docs/api/interfaces/SecretAlias.md +11 -0
  162. package/docs/api/interfaces/SecretDestinationGrant.md +41 -0
  163. package/docs/api/interfaces/SecretId.md +11 -0
  164. package/docs/api/interfaces/SecretRecord.md +89 -0
  165. package/docs/api/interfaces/Signer.md +1 -1
  166. package/docs/api/interfaces/VaultApproveDispatchInput.md +3 -9
  167. package/docs/api/interfaces/VaultAuditQueryInput.md +1 -1
  168. package/docs/api/interfaces/VaultCoreDependenciesOptions.md +1 -5
  169. package/docs/api/interfaces/VaultCreateAgentInput.md +1 -1
  170. package/docs/api/interfaces/VaultExportSecretInput.md +1 -1
  171. package/docs/api/interfaces/VaultGetRequestInput.md +17 -0
  172. package/docs/api/interfaces/VaultGrantAgentSecretInput.md +23 -0
  173. package/docs/api/interfaces/VaultGrantSecretDestinationInput.md +23 -0
  174. package/docs/api/interfaces/VaultId.md +11 -0
  175. package/docs/api/interfaces/VaultImportAgentInput.md +1 -1
  176. package/docs/api/interfaces/VaultIssueSessionTokenInput.md +5 -5
  177. package/docs/api/interfaces/VaultListAgentsInput.md +1 -1
  178. package/docs/api/interfaces/VaultListGrantsInput.md +23 -0
  179. package/docs/api/interfaces/VaultListRequestsInput.md +17 -0
  180. package/docs/api/interfaces/VaultListSecretsInput.md +1 -1
  181. package/docs/api/interfaces/VaultMetadata.md +1 -1
  182. package/docs/api/interfaces/VaultObject.md +2 -2
  183. package/docs/api/interfaces/VaultPrincipal.md +17 -0
  184. package/docs/api/interfaces/VaultProfile.md +1 -1
  185. package/docs/api/interfaces/VaultReadAgentPrivateKeyInput.md +7 -7
  186. package/docs/api/interfaces/VaultReadSecretPlaintextInput.md +1 -1
  187. package/docs/api/interfaces/VaultRegisterFlowInput.md +1 -1
  188. package/docs/api/interfaces/VaultRevokeAgentSecretInput.md +23 -0
  189. package/docs/api/interfaces/VaultRevokeSecretDestinationInput.md +23 -0
  190. package/docs/api/interfaces/VaultRevokeSessionTokenInput.md +1 -1
  191. package/docs/api/interfaces/VaultService.md +547 -0
  192. package/docs/api/interfaces/VaultUpdateAgentInput.md +7 -7
  193. package/docs/api/type-aliases/AgentId.md +7 -0
  194. package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
  195. package/docs/api/type-aliases/DispatchApprovalDecision.md +7 -0
  196. package/docs/api/type-aliases/GrantStatus.md +7 -0
  197. package/docs/api/type-aliases/SecretLifecycleStatus.md +7 -0
  198. package/docs/api/type-aliases/VaultPrincipalKind.md +7 -0
  199. package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +2 -2
  200. package/docs/es/README.md +3 -3
  201. package/docs/fr/README.md +3 -3
  202. package/docs/ja/README.md +5 -5
  203. package/docs/ko/README.md +5 -5
  204. package/docs/pt/README.md +3 -3
  205. package/docs/zh/PROCESS_ISOLATION.md +2 -2
  206. package/docs/zh/README.md +23 -24
  207. package/examples/process-isolation.ts +26 -35
  208. package/package.json +1 -1
  209. package/docs/api/functions/createOwnerHttpFlowBoundary.md +0 -17
  210. package/docs/api/functions/createStandardAcquireBoundary.md +0 -31
  211. package/docs/api/functions/createStandardDispatchBoundary.md +0 -23
  212. package/docs/api/functions/createVaultClient.md +0 -32
  213. package/docs/api/functions/deriveIdentityId.md +0 -17
  214. package/docs/api/functions/wrapVaultCoreAsVaultService.md +0 -31
  215. package/docs/api/interfaces/AgentSubmitCapabilityRequestInput.md +0 -41
  216. package/docs/api/interfaces/VaultApproveCapabilityRequestInput.md +0 -23
  217. package/docs/api/interfaces/VaultClient.md +0 -473
  218. package/docs/api/interfaces/VaultGrantCapabilityInput.md +0 -79
  219. package/docs/api/interfaces/VaultGrantCapabilityRequest.md +0 -23
  220. package/docs/api/interfaces/VaultIdentity.md +0 -11
  221. package/docs/api/interfaces/VaultListCapabilitiesInput.md +0 -17
  222. package/docs/api/interfaces/VaultRevokeCapabilityInput.md +0 -23
  223. package/docs/api/interfaces/VaultSigner.md +0 -21
  224. package/docs/api/interfaces/VaultSubmitCapabilityRequestInput.md +0 -73
  225. package/docs/api/type-aliases/AgentCapabilityEnvelope.md +0 -7
  226. package/docs/api/type-aliases/AgentVisibleSecretRecord.md +0 -7
  227. package/docs/api/type-aliases/CreateOwnerClientOptions.md +0 -7
  228. package/docs/api/type-aliases/OwnerAgentView.md +0 -7
  229. package/docs/api/type-aliases/OwnerClient.md +0 -13
  230. package/docs/api/type-aliases/OwnerGrantCapabilityInput.md +0 -7
  231. package/docs/api/type-aliases/OwnerPendingApprovalView.md +0 -7
  232. package/docs/api/type-aliases/OwnerRequestDetailView.md +0 -7
  233. package/docs/api/type-aliases/OwnerRequestSummaryView.md +0 -7
  234. 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 { createFlowIdValue, 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,42 +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,
255
+ requestedAt,
256
+ });
257
+ }
258
+ async ownerGrantSecretDestination(input) {
259
+ const requestedAt = input.requestedAt ?? this._clock.nowIso();
260
+ return this._vault.ownerGrantSecretDestination({
261
+ vaultId: this._vault.vaultId,
262
+ requestId: createRequestIdValue("grant_secret_destination"),
263
+ actor: { kind: "owner", id: this._rootAgentId },
264
+ secretAlias: input.secretAlias,
265
+ domain: input.domain,
266
+ requestedAt,
267
+ });
268
+ }
269
+ async ownerRevokeAgentSecret(input) {
270
+ const requestedAt = input.requestedAt ?? this._clock.nowIso();
271
+ return this._vault.ownerRevokeAgentSecret({
272
+ vaultId: this._vault.vaultId,
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
+ domain: input.domain,
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 },
309
297
  requestedAt,
310
298
  });
311
- return capability;
312
299
  }
313
300
  async ownerRegisterFlow(input) {
314
301
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
@@ -327,7 +314,7 @@ class DefaultVaultClient {
327
314
  requestId,
328
315
  owner: {
329
316
  kind: "owner",
330
- id: this._identityId,
317
+ id: this._rootAgentId,
331
318
  },
332
319
  flow,
333
320
  requestedAt,
@@ -335,7 +322,7 @@ class DefaultVaultClient {
335
322
  return {
336
323
  vaultId: this._vault.vaultId,
337
324
  flowId,
338
- ownerId: this._identityId,
325
+ ownerId: this._rootAgentId,
339
326
  mode: input.mode,
340
327
  targetUrl: input.targetUrl,
341
328
  method: input.method,
@@ -360,7 +347,7 @@ class DefaultVaultClient {
360
347
  requestId,
361
348
  owner: {
362
349
  kind: "owner",
363
- id: this._identityId,
350
+ id: this._rootAgentId,
364
351
  },
365
352
  alias: input.alias,
366
353
  requestedAt,
@@ -375,7 +362,7 @@ class DefaultVaultClient {
375
362
  requestedAt,
376
363
  actor: {
377
364
  kind: "owner",
378
- id: this._identityId,
365
+ id: this._rootAgentId,
379
366
  },
380
367
  });
381
368
  return agents.map((agent) => ({
@@ -383,20 +370,6 @@ class DefaultVaultClient {
383
370
  privateKey: undefined,
384
371
  }));
385
372
  }
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
373
  async ownerListRequests(input = {}) {
401
374
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
402
375
  const requestId = createRequestIdValue("list_requests");
@@ -404,11 +377,8 @@ class DefaultVaultClient {
404
377
  vaultId: this._vault.vaultId,
405
378
  requestId,
406
379
  requestedAt,
407
- actor: {
408
- kind: "owner",
409
- id: this._identityId,
410
- },
411
- agentId: input.agentId,
380
+ actor: { kind: "owner", id: this._rootAgentId },
381
+ rootAgentId: input.rootAgentId,
412
382
  });
413
383
  }
414
384
  async ownerGetRequest(input) {
@@ -420,20 +390,11 @@ class DefaultVaultClient {
420
390
  requestedAt,
421
391
  actor: {
422
392
  kind: "owner",
423
- id: this._identityId,
393
+ id: this._rootAgentId,
424
394
  },
425
395
  targetRequestId: input.requestId,
426
396
  });
427
397
  }
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
398
  async ownerListSecrets(input = {}) {
438
399
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
439
400
  const requestId = createRequestIdValue("list_secrets");
@@ -441,37 +402,22 @@ class DefaultVaultClient {
441
402
  vaultId: this._vault.vaultId,
442
403
  owner: {
443
404
  kind: "owner",
444
- id: this._identityId,
405
+ id: this._rootAgentId,
445
406
  },
446
407
  requestId,
447
408
  });
448
409
  }
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
410
  async ownerIssueSessionToken(input) {
465
411
  const requestedAt = input.requestedAt ?? this._clock.nowIso();
466
412
  const requestId = createRequestIdValue("issue_session_token");
467
413
  return this._vault.ownerIssueSessionToken({
468
414
  vaultId: this._vault.vaultId,
415
+ requestId,
416
+ rootAgentId: input.rootAgentId,
469
417
  actor: {
470
418
  kind: "owner",
471
- id: this._identityId,
419
+ id: this._rootAgentId,
472
420
  },
473
- agentId: input.agentId,
474
- requestId,
475
421
  requestedAt,
476
422
  });
477
423
  }
@@ -480,120 +426,53 @@ class DefaultVaultClient {
480
426
  vaultId: this._vault.vaultId,
481
427
  actor: {
482
428
  kind: "owner",
483
- id: this._identityId,
429
+ id: this._rootAgentId,
484
430
  },
485
431
  token: input.token,
486
432
  });
487
433
  }
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
434
  async ownerIssueAllSessionTokens() {
513
435
  return this._vault.ownerIssueAllAgentSessionTokens({
514
- vaultId: this._vault.vaultId,
515
- actor: { kind: "owner", id: this._identityId },
436
+ kind: "owner",
437
+ id: this._rootAgentId,
516
438
  });
517
439
  }
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({
440
+ async ownerApproveDispatch(input) {
441
+ const requestedAt = this._clock.nowIso();
442
+ return this._vault.ownerApproveDispatch({
535
443
  vaultId: this._vault.vaultId,
536
444
  requestId: input.requestId,
537
- owner: { kind: "owner", id: this._identityId },
445
+ actor: { kind: "owner", id: this._rootAgentId },
446
+ decision: input.decision,
447
+ requestedAt,
538
448
  });
539
449
  }
540
- async ownerDeny(requestId) {
541
- return this._vault.ownerDeny({
450
+ async ownerDenyDispatch(requestId) {
451
+ const requestedAt = this._clock.nowIso();
452
+ await this._vault.ownerApproveDispatch({
542
453
  vaultId: this._vault.vaultId,
543
454
  requestId,
544
- owner: { kind: "owner", id: this._identityId },
455
+ actor: { kind: "owner", id: this._rootAgentId },
456
+ decision: "deny",
457
+ requestedAt,
545
458
  });
546
459
  }
547
- ownerOnCapabilityState(callback) {
548
- return this._vault.ownerOnCapabilityState(callback);
460
+ ownerOnPendingDispatch(callback) {
461
+ return this._vault.ownerOnPendingDispatch(callback);
549
462
  }
550
463
  }
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);
464
+ export async function createOwnerClient(options) {
465
+ const identity = options.ownerIdentity;
466
+ const rootAgentId = identity.rootAgentId;
467
+ const client = new DefaultOwnerClient(options.vault, rootAgentId, undefined, // signer no longer directly used in simple owner client
468
+ options.clock ?? new SystemClock(), options.skipWarmup ?? false, options.passwordVerifier, options.sensitiveActionVerifier);
593
469
  if (!options.skipWarmup) {
594
- client.ownerIssueAllSessionTokens().catch((err) => {
595
- console.error("VaultClient: failed to warmup session tokens:", err);
596
- });
470
+ try {
471
+ await client.ownerIssueAllSessionTokens();
472
+ }
473
+ catch (e) {
474
+ console.warn("OwnerClient warmup failed:", e);
475
+ }
597
476
  }
598
477
  return client;
599
478
  }