@the-ai-company/cbio-node-runtime 1.63.7 → 1.64.0

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 (191) hide show
  1. package/README.md +11 -5
  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 +209 -195
  7. package/dist/clients/owner/client.js.map +1 -1
  8. package/dist/clients/owner/contracts.d.ts +47 -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 -42
  40. package/dist/vault-core/core.js +251 -274
  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/errors.d.ts +1 -1
  46. package/dist/vault-core/errors.js.map +1 -1
  47. package/dist/vault-core/index.d.ts +2 -2
  48. package/dist/vault-core/index.js +2 -2
  49. package/dist/vault-core/index.js.map +1 -1
  50. package/dist/vault-core/persistence.d.ts +19 -19
  51. package/dist/vault-core/persistence.js +78 -67
  52. package/dist/vault-core/persistence.js.map +1 -1
  53. package/dist/vault-core/ports.d.ts +23 -23
  54. package/dist/vault-core/tool-metadata.js +6 -6
  55. package/dist/vault-core/tool-metadata.js.map +1 -1
  56. package/dist/vault-ingress/defaults.d.ts +2 -2
  57. package/dist/vault-ingress/defaults.js +10 -10
  58. package/dist/vault-ingress/defaults.js.map +1 -1
  59. package/dist/vault-ingress/index.d.ts +46 -47
  60. package/dist/vault-ingress/index.js +34 -37
  61. package/dist/vault-ingress/index.js.map +1 -1
  62. package/dist/vault-ingress/remote-transport.d.ts +2 -2
  63. package/dist/vault-ingress/remote-transport.js +27 -27
  64. package/dist/vault-ingress/remote-transport.js.map +1 -1
  65. package/docs/ARCHITECTURE.md +1 -1
  66. package/docs/CUSTODY_MODEL.md +3 -3
  67. package/docs/IDENTITY_MODEL.md +4 -4
  68. package/docs/REFERENCE.md +27 -2
  69. package/docs/api/README.md +3 -4
  70. package/docs/api/classes/IdentityError.md +1 -1
  71. package/docs/api/classes/OwnerClientError.md +1 -1
  72. package/docs/api/classes/PersistentVaultAgentIdentityRegistry.md +6 -6
  73. package/docs/api/classes/PersistentVaultAgentSecretGrantRegistry.md +12 -12
  74. package/docs/api/classes/PersistentVaultAuditLog.md +1 -1
  75. package/docs/api/classes/PersistentVaultSecretCustody.md +7 -7
  76. package/docs/api/classes/PersistentVaultSecretDestinationGrantRegistry.md +12 -12
  77. package/docs/api/classes/PersistentVaultSecretRepository.md +7 -7
  78. package/docs/api/classes/VaultCore.md +53 -69
  79. package/docs/api/classes/VaultCoreError.md +1 -1
  80. package/docs/api/enumerations/AuditOperation.md +137 -0
  81. package/docs/api/enumerations/DispatchStatus.md +1 -1
  82. package/docs/api/enumerations/IdentityErrorCode.md +1 -1
  83. package/docs/api/enumerations/OwnerClientErrorCode.md +1 -1
  84. package/docs/api/functions/createAgentClient.md +1 -1
  85. package/docs/api/functions/createIdentity.md +2 -2
  86. package/docs/api/functions/createOwnerClient.md +1 -1
  87. package/docs/api/functions/createOwnerSession.md +1 -1
  88. package/docs/api/functions/createPersistentVaultCoreDependencies.md +3 -3
  89. package/docs/api/functions/createVault.md +1 -1
  90. package/docs/api/functions/createVaultCore.md +1 -1
  91. package/docs/api/functions/createVaultCoreDependencies.md +1 -1
  92. package/docs/api/functions/createVaultService.md +1 -1
  93. package/docs/api/functions/createWorkspaceStorage.md +1 -1
  94. package/docs/api/functions/deriveRootAgentId.md +3 -3
  95. package/docs/api/functions/deriveVaultWorkingKeyFromPassword.md +4 -4
  96. package/docs/api/functions/getDefaultWorkspaceDir.md +1 -1
  97. package/docs/api/functions/handleVaultAgentControlHttp.md +1 -1
  98. package/docs/api/functions/handleVaultHttpDispatch.md +1 -1
  99. package/docs/api/functions/initializeVaultCustody.md +1 -1
  100. package/docs/api/functions/listVaults.md +1 -1
  101. package/docs/api/functions/readVaultProfile.md +3 -3
  102. package/docs/api/functions/recoverVault.md +4 -4
  103. package/docs/api/functions/recoverVaultWorkingKey.md +1 -1
  104. package/docs/api/functions/restoreIdentity.md +3 -3
  105. package/docs/api/functions/updateVaultMetadata.md +1 -1
  106. package/docs/api/functions/writeVaultProfile.md +3 -3
  107. package/docs/api/interfaces/AgentClient.md +3 -3
  108. package/docs/api/interfaces/AgentDispatchIntent.md +7 -7
  109. package/docs/api/interfaces/AgentDispatchTransport.md +1 -1
  110. package/docs/api/interfaces/AgentIdentity.md +3 -3
  111. package/docs/api/interfaces/AgentIdentityRecord.md +11 -11
  112. package/docs/api/interfaces/AgentRequestResult.md +9 -9
  113. package/docs/api/interfaces/AgentRuntimeManifest.md +13 -13
  114. package/docs/api/interfaces/AgentSecretGrant.md +11 -11
  115. package/docs/api/interfaces/AgentSigner.md +1 -1
  116. package/docs/api/interfaces/AgentVisibleRequestRecord.md +13 -13
  117. package/docs/api/interfaces/AgentVisibleSecretRecord.md +13 -13
  118. package/docs/api/interfaces/AuditEntry.md +45 -25
  119. package/docs/api/interfaces/CbioRuntime.md +10 -10
  120. package/docs/api/interfaces/CreateAgentClientOptions.md +1 -1
  121. package/docs/api/interfaces/CreateIdentityOptions.md +1 -1
  122. package/docs/api/interfaces/CreateOwnerClientOptions.md +3 -13
  123. package/docs/api/interfaces/CreateOwnerSessionOptions.md +4 -10
  124. package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +3 -3
  125. package/docs/api/interfaces/CreateVaultOptions.md +2 -2
  126. package/docs/api/interfaces/CreatedVault.md +1 -1
  127. package/docs/api/interfaces/DefaultPolicyEngineOptions.md +9 -9
  128. package/docs/api/interfaces/DispatchAuthorization.md +11 -11
  129. package/docs/api/interfaces/DispatchInstruction.md +9 -9
  130. package/docs/api/interfaces/DispatchRequest.md +11 -11
  131. package/docs/api/interfaces/DispatchResult.md +11 -11
  132. package/docs/api/interfaces/IStorageProvider.md +1 -1
  133. package/docs/api/interfaces/InitializeVaultCustodyOptions.md +1 -1
  134. package/docs/api/interfaces/InitializedVaultCustody.md +1 -1
  135. package/docs/api/interfaces/OwnerAgentProvisionResult.md +3 -3
  136. package/docs/api/interfaces/OwnerClient.md +43 -11
  137. package/docs/api/interfaces/OwnerCreateSecretInput.md +3 -3
  138. package/docs/api/interfaces/OwnerRemoveSecretInput.md +3 -3
  139. package/docs/api/interfaces/OwnerRequestRecord.md +19 -19
  140. package/docs/api/interfaces/OwnerSensitiveActionConfirmation.md +1 -1
  141. package/docs/api/interfaces/OwnerSensitiveActionContext.md +1 -1
  142. package/docs/api/interfaces/OwnerSession.md +3 -3
  143. package/docs/api/interfaces/OwnerUpdateSecretInput.md +3 -3
  144. package/docs/api/interfaces/OwnerVisibleRequestRecord.md +21 -21
  145. package/docs/api/interfaces/RecoverVaultOptions.md +4 -4
  146. package/docs/api/interfaces/RecoveredVault.md +1 -1
  147. package/docs/api/interfaces/RequestRecord.md +19 -19
  148. package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
  149. package/docs/api/interfaces/SecretAlias.md +1 -1
  150. package/docs/api/interfaces/SecretDestinationGrant.md +11 -11
  151. package/docs/api/interfaces/SecretId.md +1 -1
  152. package/docs/api/interfaces/SecretRecord.md +13 -13
  153. package/docs/api/interfaces/Signer.md +1 -1
  154. package/docs/api/interfaces/VaultApproveDispatchInput.md +5 -5
  155. package/docs/api/interfaces/VaultAuditQueryInput.md +7 -7
  156. package/docs/api/interfaces/VaultCoreDependenciesOptions.md +5 -5
  157. package/docs/api/interfaces/VaultCreateAgentInput.md +3 -3
  158. package/docs/api/interfaces/VaultExportSecretInput.md +3 -3
  159. package/docs/api/interfaces/VaultGetRequestInput.md +5 -5
  160. package/docs/api/interfaces/VaultGrantAgentSecretInput.md +7 -7
  161. package/docs/api/interfaces/VaultGrantSecretDestinationInput.md +7 -7
  162. package/docs/api/interfaces/VaultId.md +1 -1
  163. package/docs/api/interfaces/VaultImportAgentInput.md +5 -5
  164. package/docs/api/interfaces/VaultIssueSessionTokenInput.md +5 -5
  165. package/docs/api/interfaces/VaultListAgentsInput.md +3 -3
  166. package/docs/api/interfaces/VaultListGrantsInput.md +7 -7
  167. package/docs/api/interfaces/VaultListRequestsInput.md +5 -5
  168. package/docs/api/interfaces/VaultListSecretsInput.md +3 -3
  169. package/docs/api/interfaces/VaultMetadata.md +1 -1
  170. package/docs/api/interfaces/VaultObject.md +1 -1
  171. package/docs/api/interfaces/VaultPrincipal.md +1 -1
  172. package/docs/api/interfaces/VaultProfile.md +1 -1
  173. package/docs/api/interfaces/VaultReadAgentPrivateKeyInput.md +5 -5
  174. package/docs/api/interfaces/VaultReadSecretPlaintextInput.md +3 -3
  175. package/docs/api/interfaces/VaultRevokeAgentSecretInput.md +7 -7
  176. package/docs/api/interfaces/VaultRevokeSecretDestinationInput.md +7 -7
  177. package/docs/api/interfaces/VaultRevokeSessionTokenInput.md +1 -1
  178. package/docs/api/interfaces/VaultService.md +8 -24
  179. package/docs/api/interfaces/VaultUpdateAgentInput.md +5 -5
  180. package/docs/api/type-aliases/AgentId.md +1 -1
  181. package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
  182. package/docs/api/type-aliases/DispatchApprovalDecision.md +1 -1
  183. package/docs/api/type-aliases/GrantStatus.md +1 -1
  184. package/docs/api/type-aliases/SecretLifecycleStatus.md +1 -1
  185. package/docs/api/type-aliases/VaultPrincipalKind.md +1 -1
  186. package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +1 -1
  187. package/docs/zh/README.md +9 -3
  188. package/examples/process-isolation.ts +21 -21
  189. package/package.json +2 -2
  190. package/docs/api/enumerations/AuditAction.md +0 -143
  191. package/docs/api/enumerations/AuditOutcome.md +0 -35
@@ -1,26 +1,22 @@
1
1
  import { OwnerClientError, OwnerClientErrorCode } from "../../errors.js";
2
2
  import { createRequestIdValue, } from "../../internal/id-factory.js";
3
3
  import { createIdentity, restoreIdentity } from "../../runtime/identity.js";
4
- import { SystemClock } from "../../vault-core/index.js";
4
+ import { SystemClock, VaultCoreError } from "../../vault-core/index.js";
5
5
  const VAULT_MASTER_ID = "vault-master";
6
6
  class DefaultOwnerClient {
7
7
  _vault;
8
- _rootAgentIdInput;
9
- _signer;
10
8
  _clock;
11
9
  _skipWarmup;
12
- _passwordVerifier;
10
+ _password_verifier;
13
11
  _sensitiveActionVerifier;
14
- _rootAgentId;
15
- constructor(_vault, _rootAgentIdInput, _signer, _clock = new SystemClock(), _skipWarmup = false, _passwordVerifier, _sensitiveActionVerifier) {
12
+ _root_agent_id;
13
+ constructor(_vault, _clock = new SystemClock(), _skipWarmup = false, _password_verifier, _sensitiveActionVerifier) {
16
14
  this._vault = _vault;
17
- this._rootAgentIdInput = _rootAgentIdInput;
18
- this._signer = _signer;
19
15
  this._clock = _clock;
20
16
  this._skipWarmup = _skipWarmup;
21
- this._passwordVerifier = _passwordVerifier;
17
+ this._password_verifier = _password_verifier;
22
18
  this._sensitiveActionVerifier = _sensitiveActionVerifier;
23
- this._rootAgentId = _rootAgentIdInput ?? VAULT_MASTER_ID;
19
+ this._root_agent_id = VAULT_MASTER_ID;
24
20
  }
25
21
  async _confirmSensitiveAction(confirmation, context) {
26
22
  const normalizedPassword = confirmation.password.trim();
@@ -37,60 +33,81 @@ class DefaultOwnerClient {
37
33
  }
38
34
  return;
39
35
  }
40
- if (!this._passwordVerifier) {
41
- throw new OwnerClientError(OwnerClientErrorCode.SENSITIVE_ACTION_VERIFIER_REQUIRED, "OwnerClient: sensitiveActionVerifier or passwordVerifier is required for sensitive reads");
36
+ if (!this._password_verifier) {
37
+ throw new OwnerClientError(OwnerClientErrorCode.SENSITIVE_ACTION_VERIFIER_REQUIRED, "OwnerClient: sensitiveActionVerifier or password_verifier is required for sensitive reads");
42
38
  }
43
- const valid = await this._passwordVerifier(normalizedPassword);
39
+ const valid = await this._password_verifier(normalizedPassword);
44
40
  if (!valid) {
45
41
  throw new OwnerClientError(OwnerClientErrorCode.SENSITIVE_ACTION_INVALID_PASSWORD, "invalid vault password");
46
42
  }
47
43
  }
48
44
  async ownerCreateSecret(input) {
49
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
50
- const requestId = createRequestIdValue("create_secret");
51
- return this._vault.ownerCreateSecret({
52
- kind: "owner.create_secret",
53
- vaultId: this._vault.vaultId,
54
- requestId,
55
- owner: {
56
- kind: "owner",
57
- id: this._rootAgentId,
58
- },
59
- alias: input.alias,
60
- plaintext: input.plaintext,
61
- source: { kind: "manual" },
62
- requestedAt,
63
- });
45
+ const isBatch = Array.isArray(input);
46
+ const items = isBatch ? input : [input];
47
+ const requested_at = this._clock.nowIso();
48
+ // Phase 1: 并行校验(所有别名不得已存在)
49
+ // 通过 ownerListSecrets 获取当前所有别名,批量对比,避免逐个网络往返
50
+ const existing = await this._vault.ownerListSecrets({ vault_id: this._vault.vault_id, owner: { kind: "owner", id: this._root_agent_id } });
51
+ const existingAliases = new Set(existing.map(s => s.alias.value));
52
+ const duplicates = items.filter(item => existingAliases.has(item.alias));
53
+ if (duplicates.length > 0) {
54
+ const names = duplicates.map(d => `"${d.alias}"`).join(", ");
55
+ throw new VaultCoreError(`secret alias already exists: ${names}`, "VAULT_ALIAS_ALREADY_EXISTS");
56
+ }
57
+ // Phase 2: 并行写入(校验全过才到这里)
58
+ const results = await Promise.all(items.map(item => {
59
+ return this._vault.ownerCreateSecret({
60
+ kind: "owner.create_secret",
61
+ vault_id: this._vault.vault_id,
62
+ request_id: createRequestIdValue("create_secret"),
63
+ owner: { kind: "owner", id: this._root_agent_id },
64
+ alias: item.alias,
65
+ plaintext: item.plaintext,
66
+ source: { kind: "manual" },
67
+ requested_at: item.requested_at ?? requested_at,
68
+ });
69
+ }));
70
+ return isBatch ? results : results[0];
64
71
  }
65
72
  async ownerUpdateSecret(input) {
66
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
67
- const requestId = createRequestIdValue("update_secret");
68
- return this._vault.ownerUpdateSecret({
69
- kind: "owner.update_secret",
70
- vaultId: this._vault.vaultId,
71
- requestId,
72
- owner: {
73
- kind: "owner",
74
- id: this._rootAgentId,
75
- },
76
- alias: input.alias,
77
- plaintext: input.plaintext,
78
- source: { kind: "manual" },
79
- requestedAt,
80
- });
73
+ const isBatch = Array.isArray(input);
74
+ const items = isBatch ? input : [input];
75
+ const requested_at = this._clock.nowIso();
76
+ // Phase 1: 并行校验(所有别名必须已存在)
77
+ const existing = await this._vault.ownerListSecrets({ vault_id: this._vault.vault_id, owner: { kind: "owner", id: this._root_agent_id } });
78
+ const existingAliases = new Set(existing.map(s => s.alias.value));
79
+ const missing = items.filter(item => !existingAliases.has(item.alias));
80
+ if (missing.length > 0) {
81
+ const names = missing.map(d => `"${d.alias}"`).join(", ");
82
+ throw new VaultCoreError(`secret not found: ${names}`, "VAULT_SECRET_NOT_FOUND");
83
+ }
84
+ // Phase 2: 并行写入
85
+ const results = await Promise.all(items.map(item => {
86
+ return this._vault.ownerUpdateSecret({
87
+ kind: "owner.update_secret",
88
+ vault_id: this._vault.vault_id,
89
+ request_id: createRequestIdValue("update_secret"),
90
+ owner: { kind: "owner", id: this._root_agent_id },
91
+ alias: item.alias,
92
+ plaintext: item.plaintext,
93
+ source: { kind: "manual" },
94
+ requested_at: item.requested_at ?? requested_at,
95
+ });
96
+ }));
97
+ return isBatch ? results : results[0];
81
98
  }
82
99
  async ownerReadAudit(query = {}) {
83
- const requestedAt = this._clock.nowIso();
84
- const requestId = createRequestIdValue("read_audit");
100
+ const requested_at = this._clock.nowIso();
101
+ const request_id = createRequestIdValue("read_audit");
85
102
  return this._vault.ownerReadAudit({
86
- vaultId: this._vault.vaultId,
103
+ vault_id: this._vault.vault_id,
87
104
  actor: {
88
105
  kind: "owner",
89
- id: this._rootAgentId,
106
+ id: this._root_agent_id,
90
107
  },
91
- query: { ...query, vaultId: this._vault.vaultId },
92
- requestId,
93
- requestedAt,
108
+ query: { ...query, vault_id: this._vault.vault_id.value },
109
+ request_id,
110
+ requested_at,
94
111
  });
95
112
  }
96
113
  async ownerExportSecret(input) {
@@ -101,17 +118,17 @@ class DefaultOwnerClient {
101
118
  action: "export_secret",
102
119
  subject: input.alias,
103
120
  });
104
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
105
- const requestId = createRequestIdValue("export_secret");
121
+ const requested_at = input.requested_at ?? this._clock.nowIso();
122
+ const request_id = createRequestIdValue("export_secret");
106
123
  return this._vault.ownerExportSecret({
107
- vaultId: this._vault.vaultId,
124
+ vault_id: this._vault.vault_id,
108
125
  actor: {
109
126
  kind: "owner",
110
- id: this._rootAgentId,
127
+ id: this._root_agent_id,
111
128
  },
112
129
  alias: input.alias,
113
- requestId,
114
- requestedAt,
130
+ request_id,
131
+ requested_at,
115
132
  });
116
133
  }
117
134
  async ownerReadSecretPlaintext(input) {
@@ -123,14 +140,14 @@ class DefaultOwnerClient {
123
140
  subject: input.alias,
124
141
  });
125
142
  const exported = await this._vault.ownerExportSecret({
126
- vaultId: this._vault.vaultId,
143
+ vault_id: this._vault.vault_id,
127
144
  actor: {
128
145
  kind: "owner",
129
- id: this._rootAgentId,
146
+ id: this._root_agent_id,
130
147
  },
131
148
  alias: input.alias,
132
- requestId: createRequestIdValue("read_secret_plaintext"),
133
- requestedAt: input.requestedAt ?? this._clock.nowIso(),
149
+ request_id: createRequestIdValue("read_secret_plaintext"),
150
+ requested_at: input.requested_at ?? this._clock.nowIso(),
134
151
  });
135
152
  return exported.plaintext;
136
153
  }
@@ -140,161 +157,161 @@ class DefaultOwnerClient {
140
157
  verificationCode: input.verificationCode,
141
158
  }, {
142
159
  action: "read_agent_private_key",
143
- subject: input.rootAgentId,
160
+ subject: input.root_agent_id,
144
161
  });
145
162
  const agents = await this._vault.ownerListAgents({
146
- vaultId: this._vault.vaultId,
147
- requestId: createRequestIdValue("read_agent_private_key"),
148
- requestedAt: input.requestedAt ?? this._clock.nowIso(),
163
+ vault_id: this._vault.vault_id,
164
+ request_id: createRequestIdValue("read_agent_private_key"),
165
+ requested_at: input.requested_at ?? this._clock.nowIso(),
149
166
  actor: {
150
167
  kind: "owner",
151
- id: this._rootAgentId,
168
+ id: this._root_agent_id,
152
169
  },
153
170
  });
154
- const agent = agents.find((record) => record.rootAgentId === input.rootAgentId);
155
- if (!agent?.privateKey) {
171
+ const agent = agents.find((record) => record.root_agent_id === input.root_agent_id);
172
+ if (!agent?.private_key) {
156
173
  throw new OwnerClientError(OwnerClientErrorCode.AGENT_PRIVATE_KEY_NOT_FOUND, "agent private key not found");
157
174
  }
158
- return agent.privateKey;
175
+ return agent.private_key;
159
176
  }
160
177
  async _ownerRegisterManagedAgentIdentity(input) {
161
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
162
- const requestId = createRequestIdValue("register_agent.identity");
178
+ const requested_at = input.requested_at ?? this._clock.nowIso();
179
+ const request_id = createRequestIdValue("register_agent.identity");
163
180
  const agentRecord = {
164
- vaultId: this._vault.vaultId,
165
- rootAgentId: input.rootAgentId,
166
- publicKey: input.publicKey,
167
- privateKey: input.privateKey,
181
+ vault_id: this._vault.vault_id,
182
+ root_agent_id: input.root_agent_id,
183
+ public_key: input.public_key,
184
+ private_key: input.private_key,
168
185
  metadata: input.metadata,
169
186
  nickname: input.nickname,
170
187
  };
171
188
  await this._vault.ownerRegisterAgentIdentity({
172
- vaultId: this._vault.vaultId,
173
- requestId,
189
+ vault_id: this._vault.vault_id,
190
+ request_id,
174
191
  owner: {
175
192
  kind: "owner",
176
- id: this._rootAgentId,
193
+ id: this._root_agent_id,
177
194
  },
178
195
  agentRecord,
179
- requestedAt,
196
+ requested_at,
180
197
  });
181
198
  return agentRecord;
182
199
  }
183
200
  async ownerImportAgent(input) {
184
- const identity = restoreIdentity(input.privateKey, { nickname: input.nickname });
201
+ const identity = restoreIdentity(input.private_key, { nickname: input.nickname });
185
202
  const agent = await this._ownerRegisterManagedAgentIdentity({
186
- rootAgentId: identity.rootAgentId,
187
- publicKey: identity.publicKey,
188
- privateKey: identity.privateKey,
203
+ root_agent_id: identity.root_agent_id,
204
+ public_key: identity.public_key,
205
+ private_key: identity.private_key,
189
206
  metadata: input.metadata,
190
207
  nickname: input.nickname,
191
- requestedAt: input.requestedAt,
208
+ requested_at: input.requested_at,
192
209
  });
193
- const sessionToken = await this.ownerIssueSessionToken({
194
- rootAgentId: agent.rootAgentId,
195
- requestedAt: input.requestedAt,
210
+ const session_token = await this.ownerIssueSessionToken({
211
+ root_agent_id: agent.root_agent_id,
212
+ requested_at: input.requested_at,
196
213
  });
197
214
  return {
198
215
  agent: {
199
216
  ...agent,
200
- privateKey: undefined,
217
+ private_key: undefined,
201
218
  },
202
- sessionToken,
219
+ session_token,
203
220
  };
204
221
  }
205
222
  async ownerCreateAgent(input) {
206
223
  const identity = createIdentity();
207
224
  const agent = await this._ownerRegisterManagedAgentIdentity({
208
- rootAgentId: identity.rootAgentId,
209
- publicKey: identity.publicKey,
210
- privateKey: identity.privateKey,
225
+ root_agent_id: identity.root_agent_id,
226
+ public_key: identity.public_key,
227
+ private_key: identity.private_key,
211
228
  metadata: input.metadata,
212
229
  nickname: input.nickname,
213
- requestedAt: input.requestedAt,
230
+ requested_at: input.requested_at,
214
231
  });
215
- const sessionToken = await this.ownerIssueSessionToken({
216
- rootAgentId: agent.rootAgentId,
217
- requestedAt: input.requestedAt,
232
+ const session_token = await this.ownerIssueSessionToken({
233
+ root_agent_id: agent.root_agent_id,
234
+ requested_at: input.requested_at,
218
235
  });
219
236
  return {
220
237
  agent: {
221
238
  ...agent,
222
- privateKey: undefined,
239
+ private_key: undefined,
223
240
  },
224
- sessionToken,
241
+ session_token,
225
242
  };
226
243
  }
227
244
  async ownerUpdateAgent(input) {
228
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
229
- const requestId = createRequestIdValue("update_agent.identity");
245
+ const requested_at = input.requested_at ?? this._clock.nowIso();
246
+ const request_id = createRequestIdValue("update_agent.identity");
230
247
  const updated = await this._vault.ownerUpdateAgentIdentity({
231
- vaultId: this._vault.vaultId,
232
- requestId,
248
+ vault_id: this._vault.vault_id,
249
+ request_id,
233
250
  owner: {
234
251
  kind: "owner",
235
- id: this._rootAgentId,
252
+ id: this._root_agent_id,
236
253
  },
237
254
  metadata: input.metadata,
238
- rootAgentId: input.rootAgentId,
255
+ root_agent_id: input.root_agent_id,
239
256
  nickname: input.nickname,
240
- requestedAt,
257
+ requested_at,
241
258
  });
242
259
  return {
243
260
  ...updated,
244
- privateKey: undefined,
261
+ private_key: undefined,
245
262
  };
246
263
  }
247
264
  async ownerGrantAgentSecret(input) {
248
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
265
+ const requested_at = input.requested_at ?? this._clock.nowIso();
249
266
  return this._vault.ownerGrantAgentSecret({
250
- vaultId: this._vault.vaultId,
251
- requestId: createRequestIdValue("grant_agent_secret"),
252
- actor: { kind: "owner", id: this._rootAgentId },
253
- rootAgentId: input.rootAgentId,
254
- secretAlias: input.secretAlias,
255
- requestedAt,
267
+ vault_id: this._vault.vault_id,
268
+ request_id: createRequestIdValue("grant_agent_secret"),
269
+ actor: { kind: "owner", id: this._root_agent_id },
270
+ root_agent_id: input.root_agent_id,
271
+ secret_alias: input.secret_alias,
272
+ requested_at,
256
273
  });
257
274
  }
258
275
  async ownerGrantSecretDestination(input) {
259
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
276
+ const requested_at = input.requested_at ?? this._clock.nowIso();
260
277
  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
- siteId: input.siteId,
266
- requestedAt,
278
+ vault_id: this._vault.vault_id,
279
+ request_id: createRequestIdValue("grant_secret_destination"),
280
+ actor: { kind: "owner", id: this._root_agent_id },
281
+ secret_alias: input.secret_alias,
282
+ site_id: input.site_id,
283
+ requested_at,
267
284
  });
268
285
  }
269
286
  async ownerRevokeAgentSecret(input) {
270
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
287
+ const requested_at = input.requested_at ?? this._clock.nowIso();
271
288
  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,
289
+ vault_id: this._vault.vault_id,
290
+ request_id: createRequestIdValue("revoke_agent_secret"),
291
+ actor: { kind: "owner", id: this._root_agent_id },
292
+ root_agent_id: input.root_agent_id,
293
+ secret_alias: input.secret_alias,
294
+ requested_at,
278
295
  });
279
296
  }
280
297
  async ownerRevokeSecretDestination(input) {
281
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
298
+ const requested_at = input.requested_at ?? this._clock.nowIso();
282
299
  return this._vault.ownerRevokeSecretDestination({
283
- vaultId: this._vault.vaultId,
284
- requestId: createRequestIdValue("revoke_secret_destination"),
285
- actor: { kind: "owner", id: this._rootAgentId },
286
- secretAlias: input.secretAlias,
287
- siteId: input.siteId,
288
- requestedAt,
300
+ vault_id: this._vault.vault_id,
301
+ request_id: createRequestIdValue("revoke_secret_destination"),
302
+ actor: { kind: "owner", id: this._root_agent_id },
303
+ secret_alias: input.secret_alias,
304
+ site_id: input.site_id,
305
+ requested_at,
289
306
  });
290
307
  }
291
308
  async ownerListGrants(input = {}) {
292
- const requestedAt = this._clock.nowIso();
309
+ const requested_at = this._clock.nowIso();
293
310
  return this._vault.ownerListGrants({
294
- vaultId: this._vault.vaultId,
295
- requestId: createRequestIdValue("list_grants"),
296
- actor: { kind: "owner", id: this._rootAgentId },
297
- requestedAt,
311
+ vault_id: this._vault.vault_id,
312
+ request_id: createRequestIdValue("list_grants"),
313
+ actor: { kind: "owner", id: this._root_agent_id },
314
+ requested_at,
298
315
  });
299
316
  }
300
317
  async ownerRemoveSecret(input) {
@@ -305,94 +322,94 @@ class DefaultOwnerClient {
305
322
  action: "delete_secret",
306
323
  subject: input.alias,
307
324
  });
308
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
309
- const requestId = createRequestIdValue("remove_secret");
325
+ const requested_at = input.requested_at ?? this._clock.nowIso();
326
+ const request_id = createRequestIdValue("remove_secret");
310
327
  await this._vault.ownerRemoveSecret({
311
328
  kind: "owner.remove_secret",
312
- vaultId: this._vault.vaultId,
313
- requestId,
329
+ vault_id: this._vault.vault_id,
330
+ request_id,
314
331
  owner: {
315
332
  kind: "owner",
316
- id: this._rootAgentId,
333
+ id: this._root_agent_id,
317
334
  },
318
335
  alias: input.alias,
319
- requestedAt,
336
+ requested_at,
320
337
  });
321
338
  }
322
339
  async ownerListAgents(input = {}) {
323
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
324
- const requestId = createRequestIdValue("list_agents");
340
+ const requested_at = input.requested_at ?? this._clock.nowIso();
341
+ const request_id = createRequestIdValue("list_agents");
325
342
  const agents = await this._vault.ownerListAgents({
326
- vaultId: this._vault.vaultId,
327
- requestId,
328
- requestedAt,
343
+ vault_id: this._vault.vault_id,
344
+ request_id,
345
+ requested_at,
329
346
  actor: {
330
347
  kind: "owner",
331
- id: this._rootAgentId,
348
+ id: this._root_agent_id,
332
349
  },
333
350
  });
334
351
  return agents.map((agent) => ({
335
352
  ...agent,
336
- privateKey: undefined,
353
+ private_key: undefined,
337
354
  }));
338
355
  }
339
356
  async ownerListRequests(input = {}) {
340
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
341
- const requestId = createRequestIdValue("list_requests");
357
+ const requested_at = input.requested_at ?? this._clock.nowIso();
358
+ const request_id = createRequestIdValue("list_requests");
342
359
  return this._vault.ownerListRequests({
343
- vaultId: this._vault.vaultId,
344
- requestId,
345
- requestedAt,
346
- actor: { kind: "owner", id: this._rootAgentId },
347
- rootAgentId: input.rootAgentId,
360
+ vault_id: this._vault.vault_id,
361
+ request_id,
362
+ requested_at,
363
+ actor: { kind: "owner", id: this._root_agent_id },
364
+ root_agent_id: input.root_agent_id,
348
365
  });
349
366
  }
350
367
  async ownerGetRequest(input) {
351
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
352
- const requestId = createRequestIdValue("get_request");
368
+ const requested_at = input.requested_at ?? this._clock.nowIso();
369
+ const request_id = createRequestIdValue("get_request");
353
370
  return this._vault.ownerGetRequest({
354
- vaultId: this._vault.vaultId,
355
- requestId,
356
- requestedAt,
371
+ vault_id: this._vault.vault_id,
372
+ request_id,
373
+ requested_at,
357
374
  actor: {
358
375
  kind: "owner",
359
- id: this._rootAgentId,
376
+ id: this._root_agent_id,
360
377
  },
361
- targetRequestId: input.requestId,
378
+ target_request_id: input.request_id,
362
379
  });
363
380
  }
364
381
  async ownerListSecrets(input = {}) {
365
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
366
- const requestId = createRequestIdValue("list_secrets");
382
+ const requested_at = input.requested_at ?? this._clock.nowIso();
383
+ const request_id = createRequestIdValue("list_secrets");
367
384
  return this._vault.ownerListSecrets({
368
- vaultId: this._vault.vaultId,
385
+ vault_id: this._vault.vault_id,
369
386
  owner: {
370
387
  kind: "owner",
371
- id: this._rootAgentId,
388
+ id: this._root_agent_id,
372
389
  },
373
- requestId,
390
+ request_id,
374
391
  });
375
392
  }
376
393
  async ownerIssueSessionToken(input) {
377
- const requestedAt = input.requestedAt ?? this._clock.nowIso();
378
- const requestId = createRequestIdValue("issue_session_token");
394
+ const requested_at = input.requested_at ?? this._clock.nowIso();
395
+ const request_id = createRequestIdValue("issue_session_token");
379
396
  return this._vault.ownerIssueSessionToken({
380
- vaultId: this._vault.vaultId,
381
- requestId,
382
- rootAgentId: input.rootAgentId,
397
+ vault_id: this._vault.vault_id,
398
+ request_id,
399
+ root_agent_id: input.root_agent_id,
383
400
  actor: {
384
401
  kind: "owner",
385
- id: this._rootAgentId,
402
+ id: this._root_agent_id,
386
403
  },
387
- requestedAt,
404
+ requested_at,
388
405
  });
389
406
  }
390
407
  async ownerRevokeSessionToken(input) {
391
408
  return this._vault.ownerRevokeSessionToken({
392
- vaultId: this._vault.vaultId,
409
+ vault_id: this._vault.vault_id,
393
410
  actor: {
394
411
  kind: "owner",
395
- id: this._rootAgentId,
412
+ id: this._root_agent_id,
396
413
  },
397
414
  token: input.token,
398
415
  });
@@ -400,27 +417,27 @@ class DefaultOwnerClient {
400
417
  async ownerIssueAllSessionTokens() {
401
418
  return this._vault.ownerIssueAllAgentSessionTokens({
402
419
  kind: "owner",
403
- id: this._rootAgentId,
420
+ id: this._root_agent_id,
404
421
  });
405
422
  }
406
423
  async ownerApproveDispatch(input) {
407
- const requestedAt = this._clock.nowIso();
424
+ const requested_at = this._clock.nowIso();
408
425
  return this._vault.ownerApproveDispatch({
409
- vaultId: this._vault.vaultId,
410
- requestId: input.requestId,
411
- actor: { kind: "owner", id: this._rootAgentId },
426
+ vault_id: this._vault.vault_id,
427
+ request_id: input.request_id,
428
+ actor: { kind: "owner", id: this._root_agent_id },
412
429
  decision: input.decision,
413
- requestedAt,
430
+ requested_at,
414
431
  });
415
432
  }
416
- async ownerDenyDispatch(requestId) {
417
- const requestedAt = this._clock.nowIso();
433
+ async ownerDenyDispatch(request_id) {
434
+ const requested_at = this._clock.nowIso();
418
435
  await this._vault.ownerApproveDispatch({
419
- vaultId: this._vault.vaultId,
420
- requestId,
421
- actor: { kind: "owner", id: this._rootAgentId },
436
+ vault_id: this._vault.vault_id,
437
+ request_id,
438
+ actor: { kind: "owner", id: this._root_agent_id },
422
439
  decision: "deny",
423
- requestedAt,
440
+ requested_at,
424
441
  });
425
442
  }
426
443
  ownerOnPendingDispatch(callback) {
@@ -428,10 +445,7 @@ class DefaultOwnerClient {
428
445
  }
429
446
  }
430
447
  export async function createOwnerClient(options) {
431
- const identity = options.ownerIdentity;
432
- const rootAgentId = identity.rootAgentId;
433
- const client = new DefaultOwnerClient(options.vault, rootAgentId, undefined, // signer no longer directly used in simple owner client
434
- options.clock ?? new SystemClock(), options.skipWarmup ?? false, options.passwordVerifier, options.sensitiveActionVerifier);
448
+ const client = new DefaultOwnerClient(options.vault, options.clock ?? new SystemClock(), options.skipWarmup ?? false, options.password_verifier, options.sensitiveActionVerifier);
435
449
  if (!options.skipWarmup) {
436
450
  try {
437
451
  await client.ownerIssueAllSessionTokens();