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

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 (189) hide show
  1. package/README.md +2 -2
  2. package/dist/clients/agent/client.d.ts +2 -2
  3. package/dist/clients/agent/client.js +46 -49
  4. package/dist/clients/agent/client.js.map +1 -1
  5. package/dist/clients/agent/contracts.d.ts +5 -5
  6. package/dist/clients/owner/client.js +169 -176
  7. package/dist/clients/owner/client.js.map +1 -1
  8. package/dist/clients/owner/contracts.d.ts +45 -48
  9. package/dist/protocol/childSecretNaming.d.ts +1 -1
  10. package/dist/protocol/childSecretNaming.js +2 -2
  11. package/dist/protocol/childSecretNaming.js.map +1 -1
  12. package/dist/protocol/crypto.d.ts +4 -4
  13. package/dist/protocol/crypto.js +14 -14
  14. package/dist/protocol/crypto.js.map +1 -1
  15. package/dist/protocol/identity.d.ts +2 -2
  16. package/dist/protocol/identity.js +4 -4
  17. package/dist/protocol/identity.js.map +1 -1
  18. package/dist/public-types.d.ts +1 -1
  19. package/dist/public-types.js +1 -1
  20. package/dist/public-types.js.map +1 -1
  21. package/dist/runtime/bootstrap.d.ts +6 -6
  22. package/dist/runtime/bootstrap.js +26 -26
  23. package/dist/runtime/bootstrap.js.map +1 -1
  24. package/dist/runtime/identity.d.ts +6 -6
  25. package/dist/runtime/identity.js +14 -12
  26. package/dist/runtime/identity.js.map +1 -1
  27. package/dist/runtime/index.d.ts +1 -1
  28. package/dist/runtime/index.js +1 -1
  29. package/dist/runtime/index.js.map +1 -1
  30. package/dist/runtime/owner-session.d.ts +1 -5
  31. package/dist/runtime/owner-session.js +4 -5
  32. package/dist/runtime/owner-session.js.map +1 -1
  33. package/dist/runtime/vault-metadata.d.ts +2 -2
  34. package/dist/runtime/vault-metadata.js +2 -2
  35. package/dist/runtime/vault-metadata.js.map +1 -1
  36. package/dist/vault-core/contracts.d.ts +235 -238
  37. package/dist/vault-core/contracts.js +25 -34
  38. package/dist/vault-core/contracts.js.map +1 -1
  39. package/dist/vault-core/core.d.ts +41 -41
  40. package/dist/vault-core/core.js +257 -255
  41. package/dist/vault-core/core.js.map +1 -1
  42. package/dist/vault-core/defaults.d.ts +25 -25
  43. package/dist/vault-core/defaults.js +95 -95
  44. package/dist/vault-core/defaults.js.map +1 -1
  45. package/dist/vault-core/index.d.ts +2 -2
  46. package/dist/vault-core/index.js +2 -2
  47. package/dist/vault-core/index.js.map +1 -1
  48. package/dist/vault-core/persistence.d.ts +19 -19
  49. package/dist/vault-core/persistence.js +78 -66
  50. package/dist/vault-core/persistence.js.map +1 -1
  51. package/dist/vault-core/ports.d.ts +23 -23
  52. package/dist/vault-core/tool-metadata.js +6 -6
  53. package/dist/vault-core/tool-metadata.js.map +1 -1
  54. package/dist/vault-ingress/defaults.d.ts +2 -2
  55. package/dist/vault-ingress/defaults.js +10 -10
  56. package/dist/vault-ingress/defaults.js.map +1 -1
  57. package/dist/vault-ingress/index.d.ts +46 -46
  58. package/dist/vault-ingress/index.js +34 -34
  59. package/dist/vault-ingress/index.js.map +1 -1
  60. package/dist/vault-ingress/remote-transport.d.ts +2 -2
  61. package/dist/vault-ingress/remote-transport.js +27 -27
  62. package/dist/vault-ingress/remote-transport.js.map +1 -1
  63. package/docs/ARCHITECTURE.md +1 -1
  64. package/docs/CUSTODY_MODEL.md +3 -3
  65. package/docs/IDENTITY_MODEL.md +4 -4
  66. package/docs/REFERENCE.md +1 -1
  67. package/docs/api/README.md +3 -4
  68. package/docs/api/classes/IdentityError.md +1 -1
  69. package/docs/api/classes/OwnerClientError.md +1 -1
  70. package/docs/api/classes/PersistentVaultAgentIdentityRegistry.md +6 -6
  71. package/docs/api/classes/PersistentVaultAgentSecretGrantRegistry.md +12 -12
  72. package/docs/api/classes/PersistentVaultAuditLog.md +1 -1
  73. package/docs/api/classes/PersistentVaultSecretCustody.md +7 -7
  74. package/docs/api/classes/PersistentVaultSecretDestinationGrantRegistry.md +12 -12
  75. package/docs/api/classes/PersistentVaultSecretRepository.md +7 -7
  76. package/docs/api/classes/VaultCore.md +53 -53
  77. package/docs/api/classes/VaultCoreError.md +1 -1
  78. package/docs/api/enumerations/AuditOperation.md +137 -0
  79. package/docs/api/enumerations/DispatchStatus.md +1 -1
  80. package/docs/api/enumerations/IdentityErrorCode.md +1 -1
  81. package/docs/api/enumerations/OwnerClientErrorCode.md +1 -1
  82. package/docs/api/functions/createAgentClient.md +1 -1
  83. package/docs/api/functions/createIdentity.md +2 -2
  84. package/docs/api/functions/createOwnerClient.md +1 -1
  85. package/docs/api/functions/createOwnerSession.md +1 -1
  86. package/docs/api/functions/createPersistentVaultCoreDependencies.md +3 -3
  87. package/docs/api/functions/createVault.md +1 -1
  88. package/docs/api/functions/createVaultCore.md +1 -1
  89. package/docs/api/functions/createVaultCoreDependencies.md +1 -1
  90. package/docs/api/functions/createVaultService.md +1 -1
  91. package/docs/api/functions/createWorkspaceStorage.md +1 -1
  92. package/docs/api/functions/deriveRootAgentId.md +3 -3
  93. package/docs/api/functions/deriveVaultWorkingKeyFromPassword.md +4 -4
  94. package/docs/api/functions/getDefaultWorkspaceDir.md +1 -1
  95. package/docs/api/functions/handleVaultAgentControlHttp.md +1 -1
  96. package/docs/api/functions/handleVaultHttpDispatch.md +1 -1
  97. package/docs/api/functions/initializeVaultCustody.md +1 -1
  98. package/docs/api/functions/listVaults.md +1 -1
  99. package/docs/api/functions/readVaultProfile.md +3 -3
  100. package/docs/api/functions/recoverVault.md +4 -4
  101. package/docs/api/functions/recoverVaultWorkingKey.md +1 -1
  102. package/docs/api/functions/restoreIdentity.md +3 -3
  103. package/docs/api/functions/updateVaultMetadata.md +1 -1
  104. package/docs/api/functions/writeVaultProfile.md +3 -3
  105. package/docs/api/interfaces/AgentClient.md +3 -3
  106. package/docs/api/interfaces/AgentDispatchIntent.md +7 -7
  107. package/docs/api/interfaces/AgentDispatchTransport.md +1 -1
  108. package/docs/api/interfaces/AgentIdentity.md +3 -3
  109. package/docs/api/interfaces/AgentIdentityRecord.md +11 -11
  110. package/docs/api/interfaces/AgentRequestResult.md +9 -9
  111. package/docs/api/interfaces/AgentRuntimeManifest.md +13 -13
  112. package/docs/api/interfaces/AgentSecretGrant.md +11 -11
  113. package/docs/api/interfaces/AgentSigner.md +1 -1
  114. package/docs/api/interfaces/AgentVisibleRequestRecord.md +13 -13
  115. package/docs/api/interfaces/AgentVisibleSecretRecord.md +13 -13
  116. package/docs/api/interfaces/AuditEntry.md +45 -25
  117. package/docs/api/interfaces/CbioRuntime.md +10 -10
  118. package/docs/api/interfaces/CreateAgentClientOptions.md +1 -1
  119. package/docs/api/interfaces/CreateIdentityOptions.md +1 -1
  120. package/docs/api/interfaces/CreateOwnerClientOptions.md +3 -13
  121. package/docs/api/interfaces/CreateOwnerSessionOptions.md +4 -10
  122. package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +3 -3
  123. package/docs/api/interfaces/CreateVaultOptions.md +2 -2
  124. package/docs/api/interfaces/CreatedVault.md +1 -1
  125. package/docs/api/interfaces/DefaultPolicyEngineOptions.md +9 -9
  126. package/docs/api/interfaces/DispatchAuthorization.md +11 -11
  127. package/docs/api/interfaces/DispatchInstruction.md +9 -9
  128. package/docs/api/interfaces/DispatchRequest.md +11 -11
  129. package/docs/api/interfaces/DispatchResult.md +11 -11
  130. package/docs/api/interfaces/IStorageProvider.md +1 -1
  131. package/docs/api/interfaces/InitializeVaultCustodyOptions.md +1 -1
  132. package/docs/api/interfaces/InitializedVaultCustody.md +1 -1
  133. package/docs/api/interfaces/OwnerAgentProvisionResult.md +3 -3
  134. package/docs/api/interfaces/OwnerClient.md +5 -5
  135. package/docs/api/interfaces/OwnerCreateSecretInput.md +3 -3
  136. package/docs/api/interfaces/OwnerRemoveSecretInput.md +3 -3
  137. package/docs/api/interfaces/OwnerRequestRecord.md +19 -19
  138. package/docs/api/interfaces/OwnerSensitiveActionConfirmation.md +1 -1
  139. package/docs/api/interfaces/OwnerSensitiveActionContext.md +1 -1
  140. package/docs/api/interfaces/OwnerSession.md +3 -3
  141. package/docs/api/interfaces/OwnerUpdateSecretInput.md +3 -3
  142. package/docs/api/interfaces/OwnerVisibleRequestRecord.md +21 -21
  143. package/docs/api/interfaces/RecoverVaultOptions.md +4 -4
  144. package/docs/api/interfaces/RecoveredVault.md +1 -1
  145. package/docs/api/interfaces/RequestRecord.md +19 -19
  146. package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
  147. package/docs/api/interfaces/SecretAlias.md +1 -1
  148. package/docs/api/interfaces/SecretDestinationGrant.md +11 -11
  149. package/docs/api/interfaces/SecretId.md +1 -1
  150. package/docs/api/interfaces/SecretRecord.md +13 -13
  151. package/docs/api/interfaces/Signer.md +1 -1
  152. package/docs/api/interfaces/VaultApproveDispatchInput.md +5 -5
  153. package/docs/api/interfaces/VaultAuditQueryInput.md +7 -7
  154. package/docs/api/interfaces/VaultCoreDependenciesOptions.md +5 -5
  155. package/docs/api/interfaces/VaultCreateAgentInput.md +3 -3
  156. package/docs/api/interfaces/VaultExportSecretInput.md +3 -3
  157. package/docs/api/interfaces/VaultGetRequestInput.md +5 -5
  158. package/docs/api/interfaces/VaultGrantAgentSecretInput.md +7 -7
  159. package/docs/api/interfaces/VaultGrantSecretDestinationInput.md +7 -7
  160. package/docs/api/interfaces/VaultId.md +1 -1
  161. package/docs/api/interfaces/VaultImportAgentInput.md +5 -5
  162. package/docs/api/interfaces/VaultIssueSessionTokenInput.md +5 -5
  163. package/docs/api/interfaces/VaultListAgentsInput.md +3 -3
  164. package/docs/api/interfaces/VaultListGrantsInput.md +7 -7
  165. package/docs/api/interfaces/VaultListRequestsInput.md +5 -5
  166. package/docs/api/interfaces/VaultListSecretsInput.md +3 -3
  167. package/docs/api/interfaces/VaultMetadata.md +1 -1
  168. package/docs/api/interfaces/VaultObject.md +1 -1
  169. package/docs/api/interfaces/VaultPrincipal.md +1 -1
  170. package/docs/api/interfaces/VaultProfile.md +1 -1
  171. package/docs/api/interfaces/VaultReadAgentPrivateKeyInput.md +5 -5
  172. package/docs/api/interfaces/VaultReadSecretPlaintextInput.md +3 -3
  173. package/docs/api/interfaces/VaultRevokeAgentSecretInput.md +7 -7
  174. package/docs/api/interfaces/VaultRevokeSecretDestinationInput.md +7 -7
  175. package/docs/api/interfaces/VaultRevokeSessionTokenInput.md +1 -1
  176. package/docs/api/interfaces/VaultService.md +8 -8
  177. package/docs/api/interfaces/VaultUpdateAgentInput.md +5 -5
  178. package/docs/api/type-aliases/AgentId.md +1 -1
  179. package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
  180. package/docs/api/type-aliases/DispatchApprovalDecision.md +1 -1
  181. package/docs/api/type-aliases/GrantStatus.md +1 -1
  182. package/docs/api/type-aliases/SecretLifecycleStatus.md +1 -1
  183. package/docs/api/type-aliases/VaultPrincipalKind.md +1 -1
  184. package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +1 -1
  185. package/docs/zh/README.md +1 -1
  186. package/examples/process-isolation.ts +21 -21
  187. package/package.json +2 -2
  188. package/docs/api/enumerations/AuditAction.md +0 -143
  189. package/docs/api/enumerations/AuditOutcome.md +0 -35
@@ -1,4 +1,4 @@
1
- import { AuditAction, AuditOutcome, DispatchStatus, } from "./contracts.js";
1
+ import { AuditOperation, DispatchStatus, } from "./contracts.js";
2
2
  import { VaultCoreError } from "./errors.js";
3
3
  import { applyResponseReadPolicy } from "./read-policy.js";
4
4
  import { getAgentToolbox } from "./tool-metadata.js";
@@ -18,14 +18,15 @@ function extractDomain(url) {
18
18
  return url;
19
19
  }
20
20
  }
21
- function toAuditEntry(deps, actor, action, outcome, detail, extra = {}) {
21
+ function toAuditEntry(deps, actor, operation, decision, execution_status, detail, extra = {}) {
22
22
  return {
23
- entryId: deps.ids.newAuditEntryId(),
24
- occurredAt: deps.clock.nowIso(),
25
- vaultId: deps.vaultId,
23
+ event_id: deps.ids.newAuditEntryId(),
24
+ ts: deps.clock.nowIso(),
25
+ vault_id: deps.vault_id.value,
26
26
  actor,
27
- action,
28
- outcome,
27
+ operation,
28
+ decision,
29
+ execution_status,
29
30
  detail,
30
31
  ...extra,
31
32
  };
@@ -35,8 +36,8 @@ export class VaultCore {
35
36
  constructor(deps) {
36
37
  this._deps = deps;
37
38
  }
38
- get vaultId() {
39
- return this._deps.vaultId;
39
+ get vault_id() {
40
+ return this._deps.vault_id;
40
41
  }
41
42
  _assertOwnerPrincipal(actor, errorCode = "VAULT_ACCESS_DENIED") {
42
43
  if (actor.kind !== "owner") {
@@ -53,108 +54,109 @@ export class VaultCore {
53
54
  }
54
55
  catch (error) {
55
56
  const detail = error instanceof Error ? error.message : String(error);
56
- await this._appendAudit(toAuditEntry(this._deps, command.agent, AuditAction.EVALUATE_DISPATCH_POLICY, AuditOutcome.DENIED, `proof verification failed: ${detail}`, {
57
- requestId: command.requestId,
57
+ await this._appendAudit(toAuditEntry(this._deps, command.agent, AuditOperation.POLICY_EVALUATE, "denied", "not_executed", `proof verification failed: ${detail}`, {
58
+ request_id: command.request_id,
59
+ secret_alias: command.secret_alias,
58
60
  ...extraAudit,
59
61
  }));
60
62
  throw error;
61
63
  }
62
64
  }
63
65
  // ─── Grant Management ─────────────────────────────────────────────────────────
64
- async ownerGrantAgentSecret(actor, rootAgentId, secretAlias, request) {
66
+ async ownerGrantAgentSecret(actor, root_agent_id, secret_alias, request) {
65
67
  this._assertOwnerPrincipal(actor);
66
68
  const now = this._deps.clock.nowIso();
67
69
  const grant = {
68
- vaultId: this._deps.vaultId,
69
- rootAgentId,
70
- secretAlias,
70
+ vault_id: this._deps.vault_id,
71
+ root_agent_id,
72
+ secret_alias,
71
73
  status: "approved",
72
- requestedAt: now,
73
- grantedAt: now,
74
+ requested_at: now,
75
+ granted_at: now,
74
76
  };
75
- await this._deps.agentSecretGrants.upsert(grant);
76
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.GRANT_AGENT_SECRET, AuditOutcome.SUCCEEDED, `granted secret "${secretAlias}" to agent "${rootAgentId}"`, {
77
- requestId: request?.requestId,
78
- rootAgentId,
79
- secretAlias,
77
+ await this._deps.agent_secretGrants.upsert(grant);
78
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.GRANT_SECRET, "allowed", "succeeded", `granted secret "${secret_alias}" to agent "${root_agent_id}"`, {
79
+ request_id: request?.request_id,
80
+ root_agent_id,
81
+ secret_alias: secret_alias,
80
82
  }));
81
83
  return grant;
82
84
  }
83
- async ownerGrantSecretDestination(actor, secretAlias, siteId, request) {
85
+ async ownerGrantSecretDestination(actor, secret_alias, site_id, request) {
84
86
  this._assertOwnerPrincipal(actor);
85
87
  const now = this._deps.clock.nowIso();
86
88
  const grant = {
87
- vaultId: this._deps.vaultId,
88
- secretAlias,
89
- siteId,
89
+ vault_id: this._deps.vault_id,
90
+ secret_alias,
91
+ site_id,
90
92
  status: "approved",
91
- requestedAt: now,
92
- grantedAt: now,
93
+ requested_at: now,
94
+ granted_at: now,
93
95
  };
94
- await this._deps.secretDestinationGrants.upsert(grant);
95
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.GRANT_SECRET_DESTINATION, AuditOutcome.SUCCEEDED, `granted destination "${siteId}" for secret "${secretAlias}"`, {
96
- requestId: request?.requestId,
97
- secretAlias,
98
- siteId,
96
+ await this._deps.secret_destinationGrants.upsert(grant);
97
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.GRANT_DESTINATION, "allowed", "succeeded", `granted destination "${site_id}" for secret "${secret_alias}"`, {
98
+ request_id: request?.request_id,
99
+ secret_alias: secret_alias,
100
+ site_id,
99
101
  }));
100
102
  return grant;
101
103
  }
102
- async ownerRevokeAgentSecret(actor, rootAgentId, secretAlias, request) {
104
+ async ownerRevokeAgentSecret(actor, root_agent_id, secret_alias, request) {
103
105
  this._assertOwnerPrincipal(actor);
104
- await this._deps.agentSecretGrants.delete(this._deps.vaultId, rootAgentId, secretAlias);
105
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.REVOKE_AGENT_SECRET, AuditOutcome.SUCCEEDED, `revoked secret "${secretAlias}" from agent "${rootAgentId}"`, {
106
- requestId: request?.requestId,
107
- rootAgentId,
108
- secretAlias,
106
+ await this._deps.agent_secretGrants.delete(this._deps.vault_id, root_agent_id, secret_alias);
107
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.REVOKE_SECRET, "allowed", "succeeded", `revoked secret "${secret_alias}" from agent "${root_agent_id}"`, {
108
+ request_id: request?.request_id,
109
+ root_agent_id,
110
+ secret_alias: secret_alias,
109
111
  }));
110
112
  }
111
- async ownerRevokeSecretDestination(actor, secretAlias, siteId, request) {
113
+ async ownerRevokeSecretDestination(actor, secret_alias, site_id, request) {
112
114
  this._assertOwnerPrincipal(actor);
113
- await this._deps.secretDestinationGrants.delete(this._deps.vaultId, secretAlias, siteId);
114
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.REVOKE_SECRET_DESTINATION, AuditOutcome.SUCCEEDED, `revoked destination "${siteId}" from secret "${secretAlias}"`, {
115
- requestId: request?.requestId,
116
- secretAlias,
117
- siteId,
115
+ await this._deps.secret_destinationGrants.delete(this._deps.vault_id, secret_alias, site_id);
116
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.REVOKE_DESTINATION, "allowed", "succeeded", `revoked destination "${site_id}" from secret "${secret_alias}"`, {
117
+ request_id: request?.request_id,
118
+ secret_alias: secret_alias,
119
+ site_id,
118
120
  }));
119
121
  }
120
- async ownerListGrants(actor, rootAgentId, secretAlias) {
122
+ async ownerListGrants(actor, root_agent_id, secret_alias) {
121
123
  this._assertOwnerPrincipal(actor);
122
- const [agentSecrets, secretDestinations] = await Promise.all([
123
- this._deps.agentSecretGrants.list(this._deps.vaultId, rootAgentId),
124
- this._deps.secretDestinationGrants.list(this._deps.vaultId, secretAlias),
124
+ const [agent_secrets, secret_destinations] = await Promise.all([
125
+ this._deps.agent_secretGrants.list(this._deps.vault_id, root_agent_id),
126
+ this._deps.secret_destinationGrants.list(this._deps.vault_id, secret_alias),
125
127
  ]);
126
- return { agentSecrets, secretDestinations };
128
+ return { agent_secrets, secret_destinations };
127
129
  }
128
130
  // ─── Dispatch Authorization ───────────────────────────────────────────────────
129
131
  async agentAuthorizeDispatch(request) {
130
- const { agent, secretAlias, targetUrl } = request;
131
- if (!secretAlias) {
132
- return { vaultId: this._deps.vaultId, decision: "deny", reason: "secretAlias required", secretId: null };
132
+ const { agent, secret_alias, target_url } = request;
133
+ if (!secret_alias) {
134
+ return { vault_id: this._deps.vault_id, decision: "deny", reason: "secret_alias required", secret_id: null };
133
135
  }
134
- const secret = await this._deps.secrets.getByAlias({ value: secretAlias });
136
+ const secret = await this._deps.secrets.getByAlias({ value: secret_alias });
135
137
  if (!secret) {
136
- return { vaultId: this._deps.vaultId, decision: "deny", reason: `secret not found: ${secretAlias}`, secretId: null };
138
+ return { vault_id: this._deps.vault_id, decision: "deny", reason: `secret not found: ${secret_alias}`, secret_id: null };
137
139
  }
138
140
  // 1. Check Agent-Secret Grant
139
- const agentSecretGrant = await this._deps.agentSecretGrants.get(this._deps.vaultId, agent.id, secretAlias);
140
- const agentSecretApproved = agentSecretGrant?.status === "approved";
141
+ const agent_secretGrant = await this._deps.agent_secretGrants.get(this._deps.vault_id, agent.id, secret_alias);
142
+ const agent_secretApproved = agent_secretGrant?.status === "approved";
141
143
  // 2. Check Secret-Destination Grant
142
- const siteId = extractDomain(targetUrl);
143
- const destGrant = await this._deps.secretDestinationGrants.get(this._deps.vaultId, secretAlias, siteId);
144
+ const site_id = extractDomain(target_url);
145
+ const destGrant = await this._deps.secret_destinationGrants.get(this._deps.vault_id, secret_alias, site_id);
144
146
  const destApproved = destGrant?.status === "approved";
145
- if (agentSecretApproved && destApproved) {
146
- return { vaultId: this._deps.vaultId, decision: "allow", reason: "granted", secretId: secret.secretId };
147
+ if (agent_secretApproved && destApproved) {
148
+ return { vault_id: this._deps.vault_id, decision: "allow", reason: "granted", secret_id: secret.secret_id };
147
149
  }
148
- const missingGrants = {
149
- agentSecret: !agentSecretApproved,
150
- secretDestination: !destApproved,
150
+ const missing_grants = {
151
+ agent_secret: !agent_secretApproved,
152
+ secret_destination: !destApproved,
151
153
  };
152
154
  return {
153
- vaultId: this._deps.vaultId,
155
+ vault_id: this._deps.vault_id,
154
156
  decision: "pending",
155
157
  reason: "pending approval",
156
- secretId: secret.secretId,
157
- missingGrants,
158
+ secret_id: secret.secret_id,
159
+ missing_grants,
158
160
  };
159
161
  }
160
162
  async agentDispatchSecret(request) {
@@ -162,73 +164,73 @@ export class VaultCore {
162
164
  const authorization = await this.agentAuthorizeDispatch(request);
163
165
  if (authorization.decision === "deny") {
164
166
  const result = {
165
- vaultId: this._deps.vaultId,
166
- requestId: request.requestId,
167
+ vault_id: this._deps.vault_id,
168
+ request_id: request.request_id,
167
169
  status: DispatchStatus.DENIED,
168
- targetUrl: request.targetUrl,
170
+ target_url: request.target_url,
169
171
  method: request.method,
170
172
  error: authorization.reason ?? "denied",
171
173
  };
172
- await this._appendAudit(toAuditEntry(this._deps, request.agent, AuditAction.EVALUATE_DISPATCH_POLICY, AuditOutcome.DENIED, authorization.reason ?? "denied", {
173
- requestId: request.requestId,
174
- targetUrl: request.targetUrl,
175
- secretAlias: request.secretAlias,
174
+ await this._appendAudit(toAuditEntry(this._deps, request.agent, AuditOperation.POLICY_EVALUATE, "denied", "not_executed", authorization.reason ?? "denied", {
175
+ request_id: request.request_id,
176
+ target: { kind: "http", url: request.target_url },
177
+ secret_alias: request.secret_alias,
176
178
  }));
177
179
  await this._recordRequestInternal(request, result);
178
180
  return result;
179
181
  }
180
182
  if (authorization.decision === "pending") {
181
183
  const result = {
182
- vaultId: this._deps.vaultId,
183
- requestId: request.requestId,
184
+ vault_id: this._deps.vault_id,
185
+ request_id: request.request_id,
184
186
  status: DispatchStatus.PENDING,
185
- targetUrl: request.targetUrl,
187
+ target_url: request.target_url,
186
188
  method: request.method,
187
189
  };
188
- await this._appendAudit(toAuditEntry(this._deps, request.agent, AuditAction.PENDING_DISPATCH_APPROVAL, AuditOutcome.ALLOWED, "request held for human approval", {
189
- requestId: request.requestId,
190
- targetUrl: request.targetUrl,
191
- secretAlias: request.secretAlias,
190
+ await this._appendAudit(toAuditEntry(this._deps, request.agent, AuditOperation.DISPATCH_HOLD, "allowed", "not_executed", "request held for human approval", {
191
+ request_id: request.request_id,
192
+ target: { kind: "http", url: request.target_url },
193
+ secret_alias: request.secret_alias,
192
194
  }));
193
- await this._recordRequestInternal(request, result, authorization.missingGrants);
195
+ await this._recordRequestInternal(request, result, authorization.missing_grants);
194
196
  return result;
195
197
  }
196
198
  // Proceed with dispatch
197
- const secretId = authorization.secretId;
198
- const secretRecord = await this._deps.secrets.getById(secretId);
199
+ const secret_id = authorization.secret_id;
200
+ const secretRecord = await this._deps.secrets.getById(secret_id);
199
201
  if (!secretRecord) {
200
202
  throw new VaultCoreError("secret record not found after authorization", "VAULT_INTERNAL_ERROR");
201
203
  }
202
- const plaintext = await this._deps.custody.load(secretId);
204
+ const plaintext = await this._deps.custody.load(secret_id);
203
205
  if (plaintext === null) {
204
206
  throw new VaultCoreError("secret material not found", "VAULT_SECRET_NOT_FOUND");
205
207
  }
206
208
  const result = await this._deps.executor.dispatch({
207
- vaultId: this._deps.vaultId,
208
- requestId: request.requestId,
209
- secretId: secretId,
210
- targetUrl: request.targetUrl,
209
+ vault_id: this._deps.vault_id,
210
+ request_id: request.request_id,
211
+ secret_id: secret_id,
212
+ target_url: request.target_url,
211
213
  method: request.method,
212
214
  headers: request.headers,
213
215
  body: request.body,
214
216
  }, { record: secretRecord, plaintext });
215
- await this._appendAudit(toAuditEntry(this._deps, request.agent, AuditAction.DISPATCH_SECRET, result.status === DispatchStatus.SUCCEEDED ? AuditOutcome.SUCCEEDED : AuditOutcome.FAILED, result.status === DispatchStatus.SUCCEEDED ? "dispatch completed" : (result.error ?? "dispatch failed"), {
216
- requestId: request.requestId,
217
- targetUrl: request.targetUrl,
218
- secretAlias: request.secretAlias,
219
- secretId: secretId.value,
217
+ await this._appendAudit(toAuditEntry(this._deps, request.agent, AuditOperation.SECRET_DISPATCH, "allowed", result.status === DispatchStatus.SUCCEEDED ? "succeeded" : "failed", result.status === DispatchStatus.SUCCEEDED ? "dispatch completed" : (result.error ?? "dispatch failed"), {
218
+ request_id: request.request_id,
219
+ target: { kind: "http", url: request.target_url },
220
+ secret_alias: request.secret_alias,
221
+ secret_id: secret_id.value,
220
222
  }));
221
223
  await this._recordRequestInternal(request, result);
222
224
  return {
223
225
  ...result,
224
- vaultId: this._deps.vaultId,
225
- responseBody: undefined, // Hide body in direct return
226
+ vault_id: this._deps.vault_id,
227
+ response_body: undefined, // Hide body in direct return
226
228
  };
227
229
  }
228
230
  // ─── Pending Approval ─────────────────────────────────────────────────────────
229
- async ownerApproveDispatch(actor, requestId, decision) {
231
+ async ownerApproveDispatch(actor, request_id, decision) {
230
232
  this._assertOwnerPrincipal(actor);
231
- const record = await this._deps.requests.get(this._deps.vaultId, requestId);
233
+ const record = await this._deps.requests.get(this._deps.vault_id, request_id);
232
234
  if (!record) {
233
235
  throw new VaultCoreError("request record not found", "VAULT_REQUEST_NOT_FOUND");
234
236
  }
@@ -241,61 +243,61 @@ export class VaultCore {
241
243
  execution: { status: DispatchStatus.DENIED },
242
244
  };
243
245
  await this._deps.requests.save(updated);
244
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.REJECT_DISPATCH, AuditOutcome.SUCCEEDED, "dispatch rejected by owner", {
245
- requestId,
246
- rootAgentId: record.rootAgentId,
246
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.DISPATCH_REJECT, "allowed", "succeeded", "dispatch rejected by owner", {
247
+ request_id,
248
+ root_agent_id: record.root_agent_id,
247
249
  }));
248
250
  return null;
249
251
  }
250
- const secretAlias = record.request.secretAlias;
251
- if (!secretAlias) {
252
- throw new VaultCoreError("record missing secretAlias", "VAULT_INTERNAL_ERROR");
252
+ const secret_alias = record.request.secret_alias;
253
+ if (!secret_alias) {
254
+ throw new VaultCoreError("record missing secret_alias", "VAULT_INTERNAL_ERROR");
253
255
  }
254
- const secret = await this._deps.secrets.getByAlias({ value: secretAlias });
256
+ const secret = await this._deps.secrets.getByAlias({ value: secret_alias });
255
257
  if (!secret) {
256
258
  throw new VaultCoreError("secret not found during approval", "VAULT_SECRET_NOT_FOUND");
257
259
  }
258
260
  // Auto-grant if requested
259
261
  if (decision === "allow_and_grant") {
260
262
  const now = this._deps.clock.nowIso();
261
- const siteId = extractDomain(record.request.targetUrl);
263
+ const site_id = extractDomain(record.request.target_url);
262
264
  await Promise.all([
263
- this._deps.agentSecretGrants.upsert({
264
- vaultId: this._deps.vaultId,
265
- rootAgentId: record.rootAgentId,
266
- secretAlias,
265
+ this._deps.agent_secretGrants.upsert({
266
+ vault_id: this._deps.vault_id,
267
+ root_agent_id: record.root_agent_id,
268
+ secret_alias,
267
269
  status: "approved",
268
- requestedAt: now,
269
- grantedAt: now,
270
+ requested_at: now,
271
+ granted_at: now,
270
272
  }),
271
- this._deps.secretDestinationGrants.upsert({
272
- vaultId: this._deps.vaultId,
273
- secretAlias,
274
- siteId,
273
+ this._deps.secret_destinationGrants.upsert({
274
+ vault_id: this._deps.vault_id,
275
+ secret_alias,
276
+ site_id,
275
277
  status: "approved",
276
- requestedAt: now,
277
- grantedAt: now,
278
+ requested_at: now,
279
+ granted_at: now,
278
280
  }),
279
281
  ]);
280
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.GRANT_AGENT_SECRET, AuditOutcome.SUCCEEDED, "granted during dispatch approval", {
281
- rootAgentId: record.rootAgentId,
282
- secretAlias,
282
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.GRANT_SECRET, "allowed", "succeeded", "granted during dispatch approval", {
283
+ root_agent_id: record.root_agent_id,
284
+ secret_alias: secret_alias,
283
285
  }));
284
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.GRANT_SECRET_DESTINATION, AuditOutcome.SUCCEEDED, "granted during dispatch approval", {
285
- secretAlias,
286
- siteId,
286
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.GRANT_DESTINATION, "allowed", "succeeded", "granted during dispatch approval", {
287
+ secret_alias: secret_alias,
288
+ site_id,
287
289
  }));
288
290
  }
289
291
  // Execute
290
- const plaintext = await this._deps.custody.load(secret.secretId);
292
+ const plaintext = await this._deps.custody.load(secret.secret_id);
291
293
  if (plaintext === null) {
292
294
  throw new VaultCoreError("secret material not found", "VAULT_SECRET_NOT_FOUND");
293
295
  }
294
296
  const result = await this._deps.executor.dispatch({
295
- vaultId: this._deps.vaultId,
296
- requestId,
297
- secretId: secret.secretId,
298
- targetUrl: record.request.targetUrl,
297
+ vault_id: this._deps.vault_id,
298
+ request_id,
299
+ secret_id: secret.secret_id,
300
+ target_url: record.request.target_url,
299
301
  method: record.request.method,
300
302
  headers: record.request.headers,
301
303
  body: record.request.body,
@@ -303,77 +305,77 @@ export class VaultCore {
303
305
  const finalRecord = {
304
306
  ...record,
305
307
  response: {
306
- status: result.responseStatus,
307
- body: result.responseBody,
308
+ status: result.response_status,
309
+ body: result.response_body,
308
310
  error: result.error,
309
311
  },
310
312
  execution: { status: result.status },
311
313
  };
312
314
  await this._deps.requests.save(finalRecord);
313
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.APPROVE_DISPATCH, AuditOutcome.SUCCEEDED, `dispatch approved (${decision})`, {
314
- requestId,
315
- rootAgentId: record.rootAgentId,
315
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.DISPATCH_APPROVE, "allowed", "succeeded", `dispatch approved (${decision})`, {
316
+ request_id,
317
+ root_agent_id: record.root_agent_id,
316
318
  }));
317
319
  return result;
318
320
  }
319
321
  // ─── Agent Control APIs ───────────────────────────────────────────────────────
320
322
  async agentGetRuntimeManifest(command) {
321
323
  await this._verifyAgentControlProof(command, "get_manifest");
322
- const agentRecord = await this._deps.agentRecords.get(this._deps.vaultId, command.agent.id);
324
+ const agentRecord = await this._deps.agentRecords.get(this._deps.vault_id, command.agent.id);
323
325
  if (!agentRecord) {
324
326
  throw new VaultCoreError("agent.identity not registered", "VAULT_DISPATCH_DENIED");
325
327
  }
326
- const [agentSecrets, secretDestinations] = await Promise.all([
327
- this._deps.agentSecretGrants.list(this._deps.vaultId, command.agent.id),
328
- this._deps.secretDestinationGrants.list(this._deps.vaultId), // All destination grants for these secrets? Or just a subset?
328
+ const [agent_secrets, secret_destinations] = await Promise.all([
329
+ this._deps.agent_secretGrants.list(this._deps.vault_id, command.agent.id),
330
+ this._deps.secret_destinationGrants.list(this._deps.vault_id), // All destination grants for these secrets? Or just a subset?
329
331
  // For simplicity, return all destinations that mention a secret the agent has a grant for.
330
332
  ]);
331
- const secretAliases = new Set(agentSecrets.map(g => g.secretAlias));
332
- const relevantDestinations = secretDestinations.filter(d => secretAliases.has(d.secretAlias));
333
+ const secret_aliases = new Set(agent_secrets.map(g => g.secret_alias));
334
+ const relevantDestinations = secret_destinations.filter(d => secret_aliases.has(d.secret_alias));
333
335
  return {
334
- rootAgentId: command.agent.id,
335
- vaultId: this._deps.vaultId.value,
336
- issuedAt: this._deps.clock.nowIso(),
336
+ root_agent_id: command.agent.id,
337
+ vault_id: this._deps.vault_id.value,
338
+ issued_at: this._deps.clock.nowIso(),
337
339
  agent: {
338
- rootAgentId: agentRecord.rootAgentId,
339
- publicKey: agentRecord.publicKey,
340
+ root_agent_id: agentRecord.root_agent_id,
341
+ public_key: agentRecord.public_key,
340
342
  nickname: agentRecord.nickname,
341
343
  metadata: agentRecord.metadata,
342
344
  },
343
345
  grants: {
344
- agentSecrets: agentSecrets.filter(g => g.status === "approved"),
345
- secretDestinations: relevantDestinations.filter(d => d.status === "approved"),
346
+ agent_secrets: agent_secrets.filter(g => g.status === "approved"),
347
+ secret_destinations: relevantDestinations.filter(d => d.status === "approved"),
346
348
  },
347
349
  tools: getAgentToolbox(),
348
350
  };
349
351
  }
350
352
  async agentListSecrets(command) {
351
353
  await this._verifyAgentControlProof(command, "list_secrets");
352
- const records = await this._deps.secrets.list(this._deps.vaultId);
353
- const grants = await this._deps.agentSecretGrants.list(this._deps.vaultId, command.agent.id);
354
- const approvedAliases = new Set(grants.filter(g => g.status === "approved").map(g => g.secretAlias));
354
+ const records = await this._deps.secrets.list(this._deps.vault_id);
355
+ const grants = await this._deps.agent_secretGrants.list(this._deps.vault_id, command.agent.id);
356
+ const approvedAliases = new Set(grants.filter(g => g.status === "approved").map(g => g.secret_alias));
355
357
  return records.map(record => ({
356
- vaultId: record.vaultId,
357
- secretId: record.secretId,
358
+ vault_id: record.vault_id,
359
+ secret_id: record.secret_id,
358
360
  alias: record.alias,
359
361
  version: record.version,
360
- lifecycleStatus: record.lifecycleStatus ?? "ACTIVE",
361
- issuerId: record.issuerId,
362
+ lifecycle_status: record.lifecycle_status ?? "ACTIVE",
363
+ issuer_id: record.issuer_id,
362
364
  source: record.source,
363
- createdAt: record.createdAt,
364
- updatedAt: record.updatedAt,
365
+ created_at: record.created_at,
366
+ updated_at: record.updated_at,
365
367
  granted: approvedAliases.has(record.alias.value),
366
368
  }));
367
369
  }
368
370
  async agentListRequests(command) {
369
371
  await this._verifyAgentControlProof(command, "list_requests");
370
- const records = await this._deps.requests.list(this._deps.vaultId, command.agent.id);
372
+ const records = await this._deps.requests.list(this._deps.vault_id, command.agent.id);
371
373
  return records.map(r => this.toAgentVisibleRequestRecord(r));
372
374
  }
373
375
  async agentGetRequest(command) {
374
376
  await this._verifyAgentControlProof(command, "read_request");
375
- const record = await this._deps.requests.get(this._deps.vaultId, command.targetRequestId);
376
- if (!record || record.rootAgentId !== command.agent.id) {
377
+ const record = await this._deps.requests.get(this._deps.vault_id, command.target_request_id);
378
+ if (!record || record.root_agent_id !== command.agent.id) {
377
379
  throw new VaultCoreError("request record not found", "VAULT_READ_DENIED");
378
380
  }
379
381
  // By default, no read-policy is granted anymore in this simplified model.
@@ -382,10 +384,10 @@ export class VaultCore {
382
384
  // unless they have a specific grant (omitted for now to focus on dispatch).
383
385
  const parsedResponseBody = applyResponseReadPolicy(record.response?.body, { paths: [] });
384
386
  return {
385
- requestId: record.requestId,
386
- executionStatus: record.execution.status,
387
- responseStatus: record.response?.status,
388
- responseBody: parsedResponseBody,
387
+ request_id: record.request_id,
388
+ execution_status: record.execution.status,
389
+ response_status: record.response?.status,
390
+ response_body: parsedResponseBody,
389
391
  error: record.response?.error,
390
392
  };
391
393
  }
@@ -393,37 +395,37 @@ export class VaultCore {
393
395
  async ownerRegisterAgentIdentity(command) {
394
396
  this._assertOwnerPrincipal(command.owner);
395
397
  await this._deps.agentRecords.register(command.agentRecord);
396
- await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditAction.REGISTER_AGENT_IDENTITY, AuditOutcome.SUCCEEDED, `agent identity registered: "${command.agentRecord.rootAgentId}"`, { rootAgentId: command.agentRecord.rootAgentId }));
398
+ await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditOperation.IDENTITY_REGISTER, "allowed", "succeeded", `agent identity registered: "${command.agentRecord.root_agent_id}"`, { root_agent_id: command.agentRecord.root_agent_id }));
397
399
  }
398
400
  async ownerUpdateAgentIdentity(command) {
399
401
  this._assertOwnerPrincipal(command.owner);
400
- const existing = await this._deps.agentRecords.get(command.vaultId, command.rootAgentId);
402
+ const existing = await this._deps.agentRecords.get(command.vault_id, command.root_agent_id);
401
403
  if (!existing)
402
404
  throw new VaultCoreError("agent identity not found", "VAULT_IDENTITY_NOT_FOUND");
403
405
  const updated = { ...existing, nickname: command.nickname ?? existing.nickname, metadata: command.metadata ?? existing.metadata };
404
406
  await this._deps.agentRecords.register(updated);
405
- await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditAction.UPDATE_AGENT_IDENTITY, AuditOutcome.SUCCEEDED, `agent identity updated: "${command.rootAgentId}"`, { rootAgentId: command.rootAgentId }));
407
+ await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditOperation.IDENTITY_UPDATE, "allowed", "succeeded", `agent identity updated: "${command.root_agent_id}"`, { root_agent_id: command.root_agent_id }));
406
408
  return updated;
407
409
  }
408
410
  async ownerCreateSecret(command) {
409
411
  this._assertOwnerPrincipal(command.owner);
410
412
  await this._deps.policy.authorizeWrite(command);
411
- const secretId = this._deps.ids.newSecretId();
413
+ const secret_id = this._deps.ids.newSecretId();
412
414
  const now = this._deps.clock.nowIso();
413
415
  const record = {
414
- vaultId: command.vaultId,
415
- secretId,
416
+ vault_id: command.vault_id,
417
+ secret_id,
416
418
  alias: { value: command.alias },
417
419
  version: this._deps.ids.newVersion(),
418
- lifecycleStatus: "ACTIVE",
419
- issuerId: null,
420
- source: command.source ? (command.source.kind === "request" ? { kind: "request", requestId: command.source.requestId } : { kind: "manual" }) : { kind: "manual" },
421
- createdAt: now,
422
- updatedAt: now,
420
+ lifecycle_status: "ACTIVE",
421
+ issuer_id: null,
422
+ source: command.source ? (command.source.kind === "request" ? { kind: "request", request_id: command.source.request_id } : { kind: "manual" }) : { kind: "manual" },
423
+ created_at: now,
424
+ updated_at: now,
423
425
  };
424
426
  await this._deps.secrets.save(record);
425
- await this._deps.custody.store(secretId, command.plaintext);
426
- await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditAction.WRITE_SECRET, AuditOutcome.SUCCEEDED, `secret created: "${command.alias}"`, { secretAlias: command.alias, secretId: secretId.value }));
427
+ await this._deps.custody.store(secret_id, command.plaintext);
428
+ await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditOperation.SECRET_WRITE, "allowed", "succeeded", `secret created: "${command.alias}"`, { secret_alias: command.alias, secret_id: secret_id.value }));
427
429
  return record;
428
430
  }
429
431
  async ownerUpdateSecret(command) {
@@ -432,16 +434,16 @@ export class VaultCore {
432
434
  const existing = await this._deps.secrets.getByAlias({ value: command.alias });
433
435
  if (!existing)
434
436
  throw new VaultCoreError("secret not found", "VAULT_SECRET_NOT_FOUND");
435
- const secretId = existing.secretId;
437
+ const secret_id = existing.secret_id;
436
438
  const now = this._deps.clock.nowIso();
437
439
  const record = {
438
440
  ...existing,
439
441
  version: this._deps.ids.newVersion(),
440
- updatedAt: now,
442
+ updated_at: now,
441
443
  };
442
444
  await this._deps.secrets.save(record);
443
- await this._deps.custody.store(secretId, command.plaintext);
444
- await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditAction.WRITE_SECRET, AuditOutcome.SUCCEEDED, `secret updated: "${command.alias}"`, { secretAlias: command.alias, secretId: secretId.value }));
445
+ await this._deps.custody.store(secret_id, command.plaintext);
446
+ await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditOperation.SECRET_WRITE, "allowed", "succeeded", `secret updated: "${command.alias}"`, { secret_alias: command.alias, secret_id: secret_id.value }));
445
447
  return record;
446
448
  }
447
449
  async ownerRemoveSecret(command) {
@@ -449,43 +451,43 @@ export class VaultCore {
449
451
  const record = await this._deps.secrets.getByAlias({ value: command.alias });
450
452
  if (!record)
451
453
  throw new VaultCoreError("secret not found", "VAULT_SECRET_NOT_FOUND");
452
- await this._deps.secrets.delete(record.secretId);
453
- await this._deps.custody.delete(record.secretId);
454
- await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditAction.DELETE_SECRET, AuditOutcome.SUCCEEDED, `secret deleted: "${command.alias}"`, { secretAlias: command.alias, secretId: record.secretId.value }));
454
+ await this._deps.secrets.delete(record.secret_id);
455
+ await this._deps.custody.delete(record.secret_id);
456
+ await this._appendAudit(toAuditEntry(this._deps, command.owner, AuditOperation.SECRET_DELETE, "allowed", "succeeded", `secret deleted: "${command.alias}"`, { secret_alias: command.alias, secret_id: record.secret_id.value }));
455
457
  }
456
458
  async ownerWriteSecret(command) {
457
459
  this._assertOwnerPrincipal(command.owner ?? command.issuer);
458
460
  await this._deps.policy.authorizeWrite(command);
459
461
  const existing = await this._deps.secrets.getByAlias({ value: command.alias });
460
- const secretId = existing ? existing.secretId : this._deps.ids.newSecretId();
462
+ const secret_id = existing ? existing.secret_id : this._deps.ids.newSecretId();
461
463
  const now = this._deps.clock.nowIso();
462
464
  const record = {
463
- vaultId: command.vaultId,
464
- secretId,
465
+ vault_id: command.vault_id,
466
+ secret_id,
465
467
  alias: { value: command.alias },
466
468
  version: this._deps.ids.newVersion(),
467
- lifecycleStatus: "ACTIVE",
468
- issuerId: command.issuer?.id ?? null,
469
+ lifecycle_status: "ACTIVE",
470
+ issuer_id: command.issuer?.id ?? null,
469
471
  source: command.source,
470
- createdAt: existing ? existing.createdAt : now,
471
- updatedAt: now,
472
+ created_at: existing ? existing.created_at : now,
473
+ updated_at: now,
472
474
  };
473
475
  await this._deps.secrets.save(record);
474
- await this._deps.custody.store(secretId, command.plaintext);
476
+ await this._deps.custody.store(secret_id, command.plaintext);
475
477
  // Generic write doesn't have a specific audit message here, assuming it's called by Create/Update which do their own audit.
476
478
  // However, if called directly:
477
479
  if (!existing) {
478
- await this._appendAudit(toAuditEntry(this._deps, command.owner ?? command.issuer, AuditAction.WRITE_SECRET, AuditOutcome.SUCCEEDED, `secret created via generic write: "${command.alias}"`, { secretAlias: command.alias, secretId: secretId.value }));
480
+ await this._appendAudit(toAuditEntry(this._deps, command.owner ?? command.issuer, AuditOperation.SECRET_WRITE, "allowed", "succeeded", `secret created via generic write: "${command.alias}"`, { secret_alias: command.alias, secret_id: secret_id.value }));
479
481
  }
480
482
  else {
481
- await this._appendAudit(toAuditEntry(this._deps, command.owner ?? command.issuer, AuditAction.WRITE_SECRET, AuditOutcome.SUCCEEDED, `secret updated via generic write: "${command.alias}"`, { secretAlias: command.alias, secretId: secretId.value }));
483
+ await this._appendAudit(toAuditEntry(this._deps, command.owner ?? command.issuer, AuditOperation.SECRET_WRITE, "allowed", "succeeded", `secret updated via generic write: "${command.alias}"`, { secret_alias: command.alias, secret_id: secret_id.value }));
482
484
  }
483
485
  return record;
484
486
  }
485
487
  async ownerReadAudit(actor, query) {
486
488
  this._assertOwnerPrincipal(actor);
487
489
  const entries = await this._deps.audit.query(query);
488
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.READ_AUDIT, AuditOutcome.SUCCEEDED, "audit log accessed", { detail: JSON.stringify(query) }));
490
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.MANAGEMENT_READ_AUDIT, "allowed", "succeeded", "audit log accessed", { detail: JSON.stringify(query) }));
489
491
  return entries;
490
492
  }
491
493
  async ownerExportSecret(actor, alias) {
@@ -493,73 +495,73 @@ export class VaultCore {
493
495
  const record = await this._deps.secrets.getByAlias({ value: alias });
494
496
  if (!record)
495
497
  throw new VaultCoreError("secret not found", "VAULT_SECRET_NOT_FOUND");
496
- const plaintext = await this._deps.custody.load(record.secretId);
498
+ const plaintext = await this._deps.custody.load(record.secret_id);
497
499
  if (plaintext === null)
498
500
  throw new VaultCoreError("secret material not found", "VAULT_SECRET_NOT_FOUND");
499
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.EXPORT_SECRET, AuditOutcome.SUCCEEDED, `secret exported as plaintext: "${alias}"`, { secretAlias: alias, secretId: record.secretId.value }));
500
- return { vaultId: this._deps.vaultId, secretId: record.secretId, alias: record.alias, plaintext, exportedAt: this._deps.clock.nowIso() };
501
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.SECRET_EXPORT, "allowed", "succeeded", `secret exported as plaintext: "${alias}"`, { secret_alias: alias, secret_id: record.secret_id.value }));
502
+ return { vault_id: this._deps.vault_id, secret_id: record.secret_id, alias: record.alias, plaintext, exported_at: this._deps.clock.nowIso() };
501
503
  }
502
504
  async ownerListAgents(actor) {
503
505
  this._assertOwnerPrincipal(actor);
504
- const identities = await this._deps.agentRecords.list(this._deps.vaultId);
505
- const sessionTokens = await this._deps.sessionTokens.list();
506
+ const identities = await this._deps.agentRecords.list(this._deps.vault_id);
507
+ const session_tokens = await this._deps.session_tokens.list();
506
508
  const tokensByAgentId = new Map();
507
- for (const st of sessionTokens) {
508
- const list = tokensByAgentId.get(st.rootAgentId) ?? [];
509
+ for (const st of session_tokens) {
510
+ const list = tokensByAgentId.get(st.root_agent_id) ?? [];
509
511
  list.push(st);
510
- tokensByAgentId.set(st.rootAgentId, list);
512
+ tokensByAgentId.set(st.root_agent_id, list);
511
513
  }
512
- const result = identities.map(id => ({ ...id, sessionTokens: tokensByAgentId.get(id.rootAgentId) ?? [] }));
513
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.LIST_AGENTS, AuditOutcome.SUCCEEDED, "agent identity list accessed"));
514
+ const result = identities.map(id => ({ ...id, session_tokens: tokensByAgentId.get(id.root_agent_id) ?? [] }));
515
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.MANAGEMENT_LIST_AGENTS, "allowed", "succeeded", "agent identity list accessed"));
514
516
  return result;
515
517
  }
516
- async ownerListRequests(actor, rootAgentId) {
518
+ async ownerListRequests(actor, root_agent_id) {
517
519
  this._assertOwnerPrincipal(actor);
518
- const records = await this._deps.requests.list(this._deps.vaultId, rootAgentId);
519
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.LIST_REQUESTS, AuditOutcome.SUCCEEDED, "request list accessed"));
520
+ const records = await this._deps.requests.list(this._deps.vault_id, root_agent_id);
521
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.MANAGEMENT_LIST_REQUESTS, "allowed", "succeeded", "request list accessed"));
520
522
  return records.map(r => this.toOwnerVisibleRequestRecord(r));
521
523
  }
522
- async ownerGetRequest(actor, requestId) {
524
+ async ownerGetRequest(actor, request_id) {
523
525
  this._assertOwnerPrincipal(actor);
524
- const record = await this._deps.requests.get(this._deps.vaultId, requestId);
526
+ const record = await this._deps.requests.get(this._deps.vault_id, request_id);
525
527
  if (!record)
526
528
  throw new VaultCoreError("request record not found", "VAULT_REQUEST_NOT_FOUND");
527
529
  const result = this.toOwnerRequestRecord(record);
528
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.READ_REQUEST, AuditOutcome.SUCCEEDED, `dispatch request detailed: "${requestId}"`, { requestId }));
530
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.MANAGEMENT_READ_REQUEST, "allowed", "succeeded", `dispatch request detailed: "${request_id}"`, { request_id }));
529
531
  return result;
530
532
  }
531
533
  async ownerListSecrets(actor) {
532
534
  this._assertOwnerPrincipal(actor);
533
- const records = await this._deps.secrets.list(this._deps.vaultId);
534
- await this._appendAudit(toAuditEntry(this._deps, actor, AuditAction.LIST_SECRETS, AuditOutcome.SUCCEEDED, "secret list accessed"));
535
+ const records = await this._deps.secrets.list(this._deps.vault_id);
536
+ await this._appendAudit(toAuditEntry(this._deps, actor, AuditOperation.MANAGEMENT_LIST_SECRETS, "allowed", "succeeded", "secret list accessed"));
535
537
  return records.map(r => ({
536
- vaultId: r.vaultId,
537
- secretId: r.secretId,
538
+ vault_id: r.vault_id,
539
+ secret_id: r.secret_id,
538
540
  alias: r.alias,
539
541
  version: r.version,
540
- lifecycleStatus: r.lifecycleStatus ?? "ACTIVE",
541
- issuerId: r.issuerId,
542
+ lifecycle_status: r.lifecycle_status ?? "ACTIVE",
543
+ issuer_id: r.issuer_id,
542
544
  source: r.source,
543
- createdAt: r.createdAt,
544
- updatedAt: r.updatedAt,
545
+ created_at: r.created_at,
546
+ updated_at: r.updated_at,
545
547
  granted: true,
546
548
  }));
547
549
  }
548
550
  async ownerIssueSessionToken(request) {
549
551
  this._assertOwnerPrincipal(request.actor);
550
- const token = await this._deps.sessionTokens.issue(request.rootAgentId);
551
- await this._appendAudit(toAuditEntry(this._deps, request.actor, AuditAction.ISSUE_SESSION_TOKEN, AuditOutcome.SUCCEEDED, `session token issued for agent: "${request.rootAgentId}"`, { rootAgentId: request.rootAgentId }));
552
- return { token, rootAgentId: request.rootAgentId, issuedAt: this._deps.clock.nowIso() };
552
+ const token = await this._deps.session_tokens.issue(request.root_agent_id);
553
+ await this._appendAudit(toAuditEntry(this._deps, request.actor, AuditOperation.IDENTITY_ISSUE_TOKEN, "allowed", "succeeded", `session token issued for agent: "${request.root_agent_id}"`, { root_agent_id: request.root_agent_id }));
554
+ return { token, root_agent_id: request.root_agent_id, issued_at: this._deps.clock.nowIso() };
553
555
  }
554
556
  async ownerIssueAllAgentSessionTokens(actor) {
555
557
  this._assertOwnerPrincipal(actor);
556
558
  const agents = await this.ownerListAgents(actor);
557
- return Promise.all(agents.map(a => this.ownerIssueSessionToken({ vaultId: this._deps.vaultId, actor, rootAgentId: a.rootAgentId })));
559
+ return Promise.all(agents.map(a => this.ownerIssueSessionToken({ vault_id: this._deps.vault_id, actor, root_agent_id: a.root_agent_id })));
558
560
  }
559
561
  async ownerRevokeSessionToken(request) {
560
562
  this._assertOwnerPrincipal(request.actor);
561
- await this._deps.sessionTokens.revoke(request.token);
562
- await this._appendAudit(toAuditEntry(this._deps, request.actor, AuditAction.REVOKE_SESSION_TOKEN, AuditOutcome.SUCCEEDED, "session token revoked"));
563
+ await this._deps.session_tokens.revoke(request.token);
564
+ await this._appendAudit(toAuditEntry(this._deps, request.actor, AuditOperation.IDENTITY_REVOKE_TOKEN, "allowed", "succeeded", "session token revoked"));
563
565
  }
564
566
  // ─── Event Observers ──────────────────────────────────────────────────────────
565
567
  _requestObservers = [];
@@ -575,27 +577,27 @@ export class VaultCore {
575
577
  return this.ownerOnPendingDispatch(callback);
576
578
  }
577
579
  // ─── Internal Helpers ──────────────────────────────────────────────────────────
578
- async _recordRequestInternal(request, result, missingGrants) {
580
+ async _recordRequestInternal(request, result, missing_grants) {
579
581
  const record = {
580
- vaultId: this._deps.vaultId,
581
- requestId: request.requestId,
582
- rootAgentId: request.agent.id,
582
+ vault_id: this._deps.vault_id,
583
+ request_id: request.request_id,
584
+ root_agent_id: request.agent.id,
583
585
  reason: request.reason,
584
- createdAt: this._deps.clock.nowIso(),
586
+ created_at: this._deps.clock.nowIso(),
585
587
  request: {
586
- targetUrl: request.targetUrl,
588
+ target_url: request.target_url,
587
589
  method: request.method,
588
590
  headers: request.headers,
589
591
  body: request.body,
590
- secretAlias: request.secretAlias,
592
+ secret_alias: request.secret_alias,
591
593
  },
592
594
  response: {
593
- status: result.responseStatus,
594
- body: result.responseBody,
595
+ status: result.response_status,
596
+ body: result.response_body,
595
597
  error: result.error,
596
598
  },
597
599
  execution: { status: result.status },
598
- missingGrants,
600
+ missing_grants,
599
601
  };
600
602
  await this._deps.requests.save(record);
601
603
  if (result.status === DispatchStatus.PENDING) {
@@ -604,46 +606,46 @@ export class VaultCore {
604
606
  }
605
607
  toAgentVisibleRequestRecord(record) {
606
608
  return {
607
- requestId: record.requestId,
608
- createdAt: record.createdAt,
609
+ request_id: record.request_id,
610
+ created_at: record.created_at,
609
611
  reason: record.reason,
610
- targetUrl: record.request.targetUrl,
611
- executionStatus: record.execution.status,
612
- responseStatus: record.response?.status,
612
+ target_url: record.request.target_url,
613
+ execution_status: record.execution.status,
614
+ response_status: record.response?.status,
613
615
  error: record.response?.error,
614
- hasResponseBody: !!record.response?.body,
616
+ has_response_body: !!record.response?.body,
615
617
  };
616
618
  }
617
619
  toOwnerVisibleRequestRecord(record) {
618
620
  return {
619
- requestId: record.requestId,
620
- createdAt: record.createdAt,
621
- rootAgentId: record.rootAgentId,
621
+ request_id: record.request_id,
622
+ created_at: record.created_at,
623
+ root_agent_id: record.root_agent_id,
622
624
  reason: record.reason,
623
- targetUrl: record.request.targetUrl,
624
- executionStatus: record.execution.status,
625
- responseStatus: record.response?.status,
625
+ target_url: record.request.target_url,
626
+ execution_status: record.execution.status,
627
+ response_status: record.response?.status,
626
628
  error: record.response?.error,
627
- hasResponseBody: !!record.response?.body,
628
- missingGrants: record.missingGrants,
629
+ has_response_body: !!record.response?.body,
630
+ missing_grants: record.missing_grants,
629
631
  };
630
632
  }
631
633
  toOwnerRequestRecord(record) {
632
634
  return {
633
- requestId: record.requestId,
634
- createdAt: record.createdAt,
635
- rootAgentId: record.rootAgentId,
635
+ request_id: record.request_id,
636
+ created_at: record.created_at,
637
+ root_agent_id: record.root_agent_id,
636
638
  reason: record.reason,
637
639
  request: {
638
- targetUrl: record.request.targetUrl,
640
+ target_url: record.request.target_url,
639
641
  method: record.request.method,
640
642
  headers: record.request.headers,
641
643
  body: record.request.body,
642
- secretAlias: record.request.secretAlias,
644
+ secret_alias: record.request.secret_alias,
643
645
  },
644
646
  response: record.response,
645
- executionStatus: record.execution.status,
646
- missingGrants: record.missingGrants,
647
+ execution_status: record.execution.status,
648
+ missing_grants: record.missing_grants,
647
649
  };
648
650
  }
649
651
  }