@the-ai-company/cbio-node-runtime 1.48.5 → 1.49.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.
- package/README.md +40 -25
- package/dist/clients/agent/client.d.ts +8 -6
- package/dist/clients/agent/client.js +67 -49
- package/dist/clients/agent/client.js.map +1 -1
- package/dist/clients/agent/contracts.d.ts +13 -1
- package/dist/clients/agent/index.d.ts +1 -1
- package/dist/clients/owner/client.d.ts +20 -14
- package/dist/clients/owner/client.js +140 -50
- package/dist/clients/owner/client.js.map +1 -1
- package/dist/clients/owner/contracts.d.ts +58 -26
- package/dist/clients/owner/index.d.ts +1 -1
- package/dist/runtime/index.d.ts +4 -3
- package/dist/runtime/index.js +5 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/vault-core/contracts.d.ts +90 -3
- package/dist/vault-core/contracts.js +3 -0
- package/dist/vault-core/contracts.js.map +1 -1
- package/dist/vault-core/core.d.ts +44 -25
- package/dist/vault-core/core.js +290 -73
- package/dist/vault-core/core.js.map +1 -1
- package/dist/vault-core/defaults.d.ts +9 -1
- package/dist/vault-core/defaults.js +39 -6
- package/dist/vault-core/defaults.js.map +1 -1
- package/dist/vault-core/index.d.ts +3 -3
- package/dist/vault-core/index.js +1 -1
- package/dist/vault-core/index.js.map +1 -1
- package/dist/vault-core/persistence.d.ts +1 -0
- package/dist/vault-core/persistence.js +7 -1
- package/dist/vault-core/persistence.js.map +1 -1
- package/dist/vault-core/ports.d.ts +8 -0
- package/dist/vault-ingress/defaults.d.ts +4 -1
- package/dist/vault-ingress/defaults.js +12 -3
- package/dist/vault-ingress/defaults.js.map +1 -1
- package/dist/vault-ingress/index.d.ts +137 -21
- package/dist/vault-ingress/index.js +156 -46
- package/dist/vault-ingress/index.js.map +1 -1
- package/dist/vault-ingress/remote-transport.d.ts +7 -2
- package/dist/vault-ingress/remote-transport.js +61 -3
- package/dist/vault-ingress/remote-transport.js.map +1 -1
- package/dist/vault-ingress/server-utils.d.ts +2 -1
- package/dist/vault-ingress/server-utils.js +42 -1
- package/dist/vault-ingress/server-utils.js.map +1 -1
- package/docs/REFERENCE.md +46 -17
- package/docs/api/README.md +10 -3
- package/docs/api/classes/IdentityError.md +1 -1
- package/docs/api/classes/VaultCore.md +258 -102
- package/docs/api/classes/VaultCoreError.md +1 -1
- package/docs/api/enumerations/IdentityErrorCode.md +1 -1
- package/docs/api/functions/createAgentClient.md +1 -1
- package/docs/api/functions/createIdentity.md +1 -1
- package/docs/api/functions/createOwnerHttpFlowBoundary.md +1 -1
- package/docs/api/functions/createPersistentVaultCoreDependencies.md +1 -1
- package/docs/api/functions/createStandardAcquireBoundary.md +1 -1
- package/docs/api/functions/createStandardDispatchBoundary.md +1 -1
- package/docs/api/functions/createVault.md +1 -1
- package/docs/api/functions/createVaultClient.md +1 -1
- package/docs/api/functions/createVaultCore.md +1 -1
- package/docs/api/functions/createVaultCoreDependencies.md +1 -1
- package/docs/api/functions/createVaultService.md +1 -1
- package/docs/api/functions/createWorkspaceStorage.md +1 -1
- package/docs/api/functions/deriveIdentityId.md +1 -1
- package/docs/api/functions/deriveVaultWorkingKeyFromPassword.md +1 -1
- package/docs/api/functions/getDefaultWorkspaceDir.md +1 -1
- package/docs/api/functions/handleVaultAgentControlHttp.md +21 -0
- package/docs/api/functions/handleVaultHttpDispatch.md +1 -1
- package/docs/api/functions/initializeVaultCustody.md +1 -1
- package/docs/api/functions/listVaults.md +1 -1
- package/docs/api/functions/readVaultProfile.md +1 -1
- package/docs/api/functions/recoverVault.md +1 -1
- package/docs/api/functions/recoverVaultWorkingKey.md +1 -1
- package/docs/api/functions/restoreIdentity.md +1 -1
- package/docs/api/functions/updateVaultMetadata.md +1 -1
- package/docs/api/functions/wrapVaultCoreAsVaultService.md +1 -1
- package/docs/api/functions/writeVaultProfile.md +1 -1
- package/docs/api/interfaces/AgentClient.md +41 -5
- package/docs/api/interfaces/AgentDispatchIntent.md +1 -1
- package/docs/api/interfaces/AgentDispatchTransport.md +51 -3
- package/docs/api/interfaces/AgentIdentity.md +1 -1
- package/docs/api/interfaces/AgentSigner.md +1 -1
- package/docs/api/interfaces/AgentSubmitCapabilityRequestInput.md +41 -0
- package/docs/api/interfaces/CbioRuntime.md +21 -1
- package/docs/api/interfaces/CreateAgentClientOptions.md +3 -9
- package/docs/api/interfaces/CreateIdentityOptions.md +1 -1
- package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +1 -1
- package/docs/api/interfaces/CreateVaultClientOptions.md +1 -1
- package/docs/api/interfaces/CreateVaultOptions.md +1 -1
- package/docs/api/interfaces/CreatedVault.md +1 -1
- package/docs/api/interfaces/DefaultPolicyEngineOptions.md +1 -1
- package/docs/api/interfaces/IStorageProvider.md +1 -1
- package/docs/api/interfaces/InitializeVaultCustodyOptions.md +1 -1
- package/docs/api/interfaces/InitializedVaultCustody.md +1 -1
- package/docs/api/interfaces/OwnerAgentProvisionResult.md +17 -0
- package/docs/api/interfaces/OwnerDefineSecretTargetsInput.md +1 -1
- package/docs/api/interfaces/OwnerSecretTargetBinding.md +1 -1
- package/docs/api/interfaces/OwnerStoreSecretInput.md +1 -1
- package/docs/api/interfaces/OwnerWriteSecretInput.md +1 -1
- package/docs/api/interfaces/RecoverVaultOptions.md +1 -1
- package/docs/api/interfaces/RecoveredVault.md +1 -1
- package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
- package/docs/api/interfaces/Signer.md +1 -1
- package/docs/api/interfaces/VaultApproveCapabilityRequestInput.md +23 -0
- package/docs/api/interfaces/VaultAuditQueryInput.md +1 -1
- package/docs/api/interfaces/VaultClient.md +123 -33
- package/docs/api/interfaces/VaultCoreDependenciesOptions.md +1 -1
- package/docs/api/interfaces/VaultCreateAgentInput.md +1 -1
- package/docs/api/interfaces/VaultDeleteSecretInput.md +1 -1
- package/docs/api/interfaces/VaultExportSecretInput.md +1 -1
- package/docs/api/interfaces/VaultGrantCapabilityInput.md +13 -19
- package/docs/api/interfaces/VaultIdentity.md +1 -1
- package/docs/api/interfaces/{VaultRegisterAgentInput.md → VaultImportAgentInput.md} +4 -10
- package/docs/api/interfaces/VaultListAgentsInput.md +1 -1
- package/docs/api/interfaces/VaultListCapabilitiesInput.md +1 -1
- package/docs/api/interfaces/VaultListSecretsInput.md +11 -0
- package/docs/api/interfaces/VaultMetadata.md +1 -1
- package/docs/api/interfaces/VaultObject.md +1 -1
- package/docs/api/interfaces/VaultProfile.md +1 -1
- package/docs/api/interfaces/VaultRegisterFlowInput.md +1 -1
- package/docs/api/interfaces/VaultRevokeCapabilityInput.md +1 -1
- package/docs/api/interfaces/VaultSigner.md +1 -1
- package/docs/api/interfaces/VaultSubmitCapabilityRequestInput.md +79 -0
- package/docs/api/type-aliases/AgentCapabilityEnvelope.md +1 -1
- package/docs/api/type-aliases/AgentVisibleSecretRecord.md +7 -0
- package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
- package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +1 -1
- package/examples/process-isolation.ts +24 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,27 +68,23 @@ import { createVaultClient } from '@the-ai-company/cbio-node-runtime';
|
|
|
68
68
|
const client = createVaultClient({ vault: vault.vault });
|
|
69
69
|
|
|
70
70
|
// Generate and register a new agent in one step
|
|
71
|
-
const
|
|
71
|
+
const createdAgent = await client.ownerCreateAgent({
|
|
72
72
|
agentId: 'worker-1',
|
|
73
73
|
nickname: 'Background Worker'
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
console.log(`Agent public key: ${
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// 4. Issue a Session Token (Optional but Recommended)
|
|
80
|
-
// Avoid passing the raw private key to agent processes (v1.48+).
|
|
81
|
-
const session = await client.issueSessionToken({ agentId: 'worker-1' });
|
|
76
|
+
console.log(`Agent public key: ${createdAgent.agent.publicKey}`);
|
|
77
|
+
const session = createdAgent.sessionToken;
|
|
82
78
|
|
|
83
79
|
// RECOMENDED (v1.48.4+): Batch issue tokens for all agents at once
|
|
84
|
-
const tokens = await client.
|
|
80
|
+
const tokens = await client.ownerIssueAllSessionTokens();
|
|
85
81
|
```
|
|
86
82
|
|
|
87
83
|
### 5. Secret Management (Owner)
|
|
88
84
|
|
|
89
85
|
```ts
|
|
90
86
|
// Write a secret and bind it to a target site
|
|
91
|
-
const record = await client.
|
|
87
|
+
const record = await client.ownerWriteSecret({
|
|
92
88
|
alias: 'api-token',
|
|
93
89
|
plaintext: 'super-secret-value',
|
|
94
90
|
targetBindings: [{
|
|
@@ -100,10 +96,11 @@ const record = await client.writeSecret({
|
|
|
100
96
|
});
|
|
101
97
|
|
|
102
98
|
// 4. Grant agent capabilities
|
|
103
|
-
await client.
|
|
99
|
+
await client.ownerGrantCapability({
|
|
104
100
|
agentId: 'worker-1',
|
|
105
101
|
secretAliases: ['api-token'],
|
|
106
|
-
|
|
102
|
+
scope: 'https://api.example.com/*',
|
|
103
|
+
methods: ['POST']
|
|
107
104
|
});
|
|
108
105
|
|
|
109
106
|
// 5. Setup client with automatic warmup (v1.48.4+)
|
|
@@ -117,7 +114,7 @@ const client = createVaultClient({
|
|
|
117
114
|
|
|
118
115
|
### 6. Consuming Secrets (Agent)
|
|
119
116
|
|
|
120
|
-
Agents run in isolated processes and communicate with the vault via a transport.
|
|
117
|
+
Agents run in isolated processes and communicate with the vault via a transport. Agent execution now requires a **Session Token** issued by the owner.
|
|
121
118
|
|
|
122
119
|
#### Using a Session Token (Stateless/Token-based)
|
|
123
120
|
```ts
|
|
@@ -126,25 +123,43 @@ import { createAgentClient } from '@the-ai-company/cbio-node-runtime';
|
|
|
126
123
|
const agent = createAgentClient({
|
|
127
124
|
agentIdentity: { agentId: 'worker-1' },
|
|
128
125
|
capability: myCapability,
|
|
129
|
-
token: session.token,
|
|
126
|
+
token: session.token,
|
|
130
127
|
vault: vault.vault
|
|
131
128
|
});
|
|
132
129
|
|
|
133
|
-
const result = await agent.
|
|
130
|
+
const result = await agent.agentDispatch({ ... });
|
|
134
131
|
```
|
|
135
132
|
|
|
136
|
-
|
|
133
|
+
The agent process does not execute directly with its raw private key. If it has an identity key, it still needs to exchange that trust for a session token before dispatching.
|
|
134
|
+
|
|
135
|
+
### 7. Proactive Capability Requests
|
|
136
|
+
|
|
137
|
+
If an LLM or orchestration layer already knows it needs a broader scope, it can ask for that scope up front instead of triggering one pending dispatch per concrete URL.
|
|
138
|
+
|
|
137
139
|
```ts
|
|
138
|
-
|
|
140
|
+
const request = await client.ownerSubmitCapabilityRequest({
|
|
141
|
+
requester: { kind: 'trusted_executor', id: 'llm-planner' },
|
|
142
|
+
agentId: 'worker-1',
|
|
143
|
+
secretAliases: ['api-token'],
|
|
144
|
+
scope: 'https://api.example.com/users/*',
|
|
145
|
+
methods: ['GET'],
|
|
146
|
+
justification: 'Need collection-level user read access'
|
|
147
|
+
});
|
|
139
148
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
const pendingRequests = await client.ownerListPendingCapabilityRequests();
|
|
150
|
+
|
|
151
|
+
const capability = await client.ownerApproveCapabilityRequest({
|
|
152
|
+
requestId: pendingRequests[0].requestId,
|
|
153
|
+
capabilityId: 'cap-users-read'
|
|
145
154
|
});
|
|
146
155
|
```
|
|
147
156
|
|
|
157
|
+
This flow is separate from dispatch discovery:
|
|
158
|
+
- `ownerSubmitCapabilityRequest(...)` creates a pending capability request for owner review.
|
|
159
|
+
- `ownerOnPendingCapabilityRequest(...)` pushes new requests to the owner UI or controller.
|
|
160
|
+
- `ownerApproveCapabilityRequest(...)` turns the request into a real stored capability.
|
|
161
|
+
- `ownerRejectCapabilityRequest(...)` drops the request without granting access.
|
|
162
|
+
|
|
148
163
|
---
|
|
149
164
|
|
|
150
165
|
## Documentation
|
|
@@ -165,21 +180,21 @@ The system uses a **Discovery-first** model. If an agent attempts an action not
|
|
|
165
180
|
|
|
166
181
|
```ts
|
|
167
182
|
// In Agent process
|
|
168
|
-
const result = await agent.
|
|
183
|
+
const result = await agent.agentDispatch({ ... });
|
|
169
184
|
if (result.status === 'PENDING') {
|
|
170
185
|
console.log("Discovery needed: Waiting for owner approval...");
|
|
171
186
|
}
|
|
172
187
|
|
|
173
188
|
// OR: Use the Observer for real-time push (v1.48.4+)
|
|
174
|
-
ownerClient.
|
|
189
|
+
ownerClient.ownerOnPendingDispatch((req) => {
|
|
175
190
|
console.log("New discovery request:", req.requestId);
|
|
176
191
|
});
|
|
177
192
|
|
|
178
193
|
// In Owner process (GUI or Script)
|
|
179
|
-
const pending = await client.
|
|
194
|
+
const pending = await client.ownerListPendingDispatches();
|
|
180
195
|
if (pending.length > 0) {
|
|
181
196
|
// Inspect and approve the request, optionally making it permanent
|
|
182
|
-
await client.
|
|
197
|
+
await client.ownerApproveDispatch({
|
|
183
198
|
requestId: pending[0].requestId,
|
|
184
199
|
permanent: true
|
|
185
200
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CreatedIdentity } from "../../runtime/identity.js";
|
|
2
2
|
import { type Clock } from "../../vault-core/index.js";
|
|
3
3
|
import type { VaultService } from "../../vault-ingress/index.js";
|
|
4
|
-
import type { AgentCapabilityEnvelope, AgentDispatchIntent, AgentDispatchTransport,
|
|
4
|
+
import type { AgentCapabilityEnvelope, AgentDispatchIntent, AgentDispatchTransport, AgentSubmitCapabilityRequestInput, AgentVisibleSecretRecord } from "./contracts.js";
|
|
5
5
|
export interface AgentIdentity {
|
|
6
6
|
agentId: string;
|
|
7
7
|
}
|
|
@@ -11,14 +11,14 @@ export interface AgentIdentity {
|
|
|
11
11
|
*/
|
|
12
12
|
export interface AgentClient {
|
|
13
13
|
/**
|
|
14
|
-
* Dispatches a
|
|
14
|
+
* Dispatches a session-token-authenticated request to a target using a vault secret.
|
|
15
15
|
*
|
|
16
16
|
* @param intent - The destination, method, and secret alias to use.
|
|
17
17
|
* @returns The result of the remote operation.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
|
-
* const result = await agent.
|
|
21
|
+
* const result = await agent.agentDispatch({
|
|
22
22
|
* targetUrl: 'https://api.example.com/data',
|
|
23
23
|
* method: 'POST',
|
|
24
24
|
* secretAlias: 'api-token',
|
|
@@ -26,15 +26,17 @@ export interface AgentClient {
|
|
|
26
26
|
* });
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
agentDispatch(intent: AgentDispatchIntent): Promise<import("../../vault-core/index.js").DispatchResult>;
|
|
30
|
+
agentListCapabilities(): Promise<readonly import("../../vault-core/index.js").AgentCapability[]>;
|
|
31
|
+
agentListSecrets(): Promise<readonly AgentVisibleSecretRecord[]>;
|
|
32
|
+
agentSubmitCapabilityRequest(input: AgentSubmitCapabilityRequestInput): Promise<import("../../vault-core/index.js").PendingCapabilityRequestRecord>;
|
|
30
33
|
}
|
|
31
34
|
export interface CreateAgentClientOptions {
|
|
32
35
|
agentIdentity: CreatedIdentity | AgentIdentity;
|
|
33
36
|
capability: AgentCapabilityEnvelope;
|
|
34
37
|
vault?: VaultService;
|
|
35
38
|
transport?: AgentDispatchTransport;
|
|
36
|
-
|
|
37
|
-
token?: string;
|
|
39
|
+
token: string;
|
|
38
40
|
clock?: Clock;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
@@ -1,48 +1,22 @@
|
|
|
1
|
-
import { LocalSigner } from "../../protocol/crypto.js";
|
|
2
1
|
import { SystemClock } from "../../vault-core/index.js";
|
|
3
2
|
import { LocalVaultTransport } from "../../vault-ingress/defaults.js";
|
|
4
|
-
function createDispatchBinding(requestId, requestedAt, agentId, capabilityId, secretAlias, targetUrl, method, body) {
|
|
5
|
-
return JSON.stringify({
|
|
6
|
-
requestId,
|
|
7
|
-
requestedAt,
|
|
8
|
-
agentId,
|
|
9
|
-
capabilityId,
|
|
10
|
-
secretAlias: secretAlias ?? null,
|
|
11
|
-
targetUrl,
|
|
12
|
-
method,
|
|
13
|
-
body: body ?? null,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
3
|
class DefaultAgentClient {
|
|
17
4
|
_identity;
|
|
18
5
|
_capability;
|
|
19
|
-
_signer;
|
|
20
6
|
_transport;
|
|
21
7
|
_clock;
|
|
22
8
|
_token;
|
|
23
|
-
constructor(_identity, _capability,
|
|
9
|
+
constructor(_identity, _capability, _transport, _clock, _token) {
|
|
24
10
|
this._identity = _identity;
|
|
25
11
|
this._capability = _capability;
|
|
26
|
-
this._signer = _signer;
|
|
27
12
|
this._transport = _transport;
|
|
28
13
|
this._clock = _clock;
|
|
29
14
|
this._token = _token;
|
|
30
15
|
}
|
|
31
|
-
async
|
|
16
|
+
async agentDispatch(intent) {
|
|
32
17
|
const requestedAt = intent.requestedAt ?? this._clock.nowIso();
|
|
33
18
|
const requestId = `${this._identity.agentId}:${requestedAt}:${intent.secretAlias ?? "no-secret"}:${intent.method}`;
|
|
34
|
-
|
|
35
|
-
if (this._token) {
|
|
36
|
-
// Use token-based authentication
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
// Use signature-based authentication
|
|
40
|
-
if (!this._signer) {
|
|
41
|
-
throw new Error("AgentClient: signer required for signature-based authentication when no token is provided");
|
|
42
|
-
}
|
|
43
|
-
signature = await this._signer.sign(createDispatchBinding(requestId, requestedAt, this._identity.agentId, this._capability.capabilityId, intent.secretAlias, intent.targetUrl, intent.method, intent.body));
|
|
44
|
-
}
|
|
45
|
-
return this._transport.dispatch({
|
|
19
|
+
return this._transport.agentDispatch({
|
|
46
20
|
vaultId: this._capability.vaultId,
|
|
47
21
|
requestId,
|
|
48
22
|
requestedAt,
|
|
@@ -57,9 +31,8 @@ class DefaultAgentClient {
|
|
|
57
31
|
secretIds: this._capability.secretIds,
|
|
58
32
|
secretAliases: this._capability.secretAliases,
|
|
59
33
|
operation: this._capability.operation,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
allowedPaths: this._capability.allowedPaths,
|
|
34
|
+
scope: this._capability.scope,
|
|
35
|
+
methods: this._capability.methods,
|
|
63
36
|
issuedAt: this._capability.issuedAt,
|
|
64
37
|
expiresAt: this._capability.expiresAt,
|
|
65
38
|
revocationVersion: this._capability.revocationVersion,
|
|
@@ -68,7 +41,6 @@ class DefaultAgentClient {
|
|
|
68
41
|
},
|
|
69
42
|
proof: {
|
|
70
43
|
agentId: this._identity.agentId,
|
|
71
|
-
signature,
|
|
72
44
|
token: this._token,
|
|
73
45
|
requestId,
|
|
74
46
|
requestedAt,
|
|
@@ -80,30 +52,76 @@ class DefaultAgentClient {
|
|
|
80
52
|
body: intent.body,
|
|
81
53
|
});
|
|
82
54
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
function resolveAgentSigner(options) {
|
|
91
|
-
if (options.signer) {
|
|
92
|
-
return options.signer;
|
|
55
|
+
async _createProof(requestId, requestedAt, _action, _payload = {}) {
|
|
56
|
+
return {
|
|
57
|
+
agentId: this._identity.agentId,
|
|
58
|
+
token: this._token,
|
|
59
|
+
requestId,
|
|
60
|
+
requestedAt,
|
|
61
|
+
};
|
|
93
62
|
}
|
|
94
|
-
|
|
95
|
-
|
|
63
|
+
async agentListCapabilities() {
|
|
64
|
+
const requestedAt = this._clock.nowIso();
|
|
65
|
+
const requestId = `${this._identity.agentId}:${requestedAt}:list_capabilities`;
|
|
66
|
+
return this._transport.agentListCapabilities({
|
|
67
|
+
vaultId: this._capability.vaultId,
|
|
68
|
+
requestId,
|
|
69
|
+
requestedAt,
|
|
70
|
+
agent: { kind: "agent", id: this._identity.agentId },
|
|
71
|
+
proof: await this._createProof(requestId, requestedAt, "list_capabilities"),
|
|
72
|
+
});
|
|
96
73
|
}
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
async agentListSecrets() {
|
|
75
|
+
const requestedAt = this._clock.nowIso();
|
|
76
|
+
const requestId = `${this._identity.agentId}:${requestedAt}:list_secrets`;
|
|
77
|
+
return this._transport.agentListSecrets({
|
|
78
|
+
vaultId: this._capability.vaultId,
|
|
79
|
+
requestId,
|
|
80
|
+
requestedAt,
|
|
81
|
+
agent: { kind: "agent", id: this._identity.agentId },
|
|
82
|
+
proof: await this._createProof(requestId, requestedAt, "list_secrets"),
|
|
83
|
+
});
|
|
99
84
|
}
|
|
100
|
-
|
|
85
|
+
async agentSubmitCapabilityRequest(input) {
|
|
86
|
+
const requestedAt = input.requestedAt ?? this._clock.nowIso();
|
|
87
|
+
const requestId = `${this._identity.agentId}:${requestedAt}:submit_capability_request`;
|
|
88
|
+
const payload = {
|
|
89
|
+
scope: input.scope,
|
|
90
|
+
methods: input.methods,
|
|
91
|
+
operation: input.operation ?? "dispatch_http",
|
|
92
|
+
secretAliases: input.secretAliases ?? [],
|
|
93
|
+
justification: input.justification ?? null,
|
|
94
|
+
};
|
|
95
|
+
return this._transport.agentSubmitCapabilityRequest({
|
|
96
|
+
vaultId: this._capability.vaultId,
|
|
97
|
+
requestId,
|
|
98
|
+
requestedAt,
|
|
99
|
+
agent: { kind: "agent", id: this._identity.agentId },
|
|
100
|
+
proof: await this._createProof(requestId, requestedAt, "submit_capability_request", payload),
|
|
101
|
+
scope: {
|
|
102
|
+
operation: input.operation ?? "dispatch_http",
|
|
103
|
+
secretAliases: input.secretAliases ?? [],
|
|
104
|
+
scope: input.scope,
|
|
105
|
+
methods: [...input.methods],
|
|
106
|
+
},
|
|
107
|
+
justification: input.justification,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function isCreateAgentClientOptions(value) {
|
|
112
|
+
return typeof value === "object" && value !== null && "agentIdentity" in value && "capability" in value;
|
|
101
113
|
}
|
|
102
114
|
function resolveAgentIdentity(options) {
|
|
103
115
|
return "agentId" in options.agentIdentity
|
|
104
116
|
? options.agentIdentity
|
|
105
117
|
: { agentId: options.agentIdentity.identityId };
|
|
106
118
|
}
|
|
119
|
+
function resolveAgentToken(options) {
|
|
120
|
+
if (!options.token) {
|
|
121
|
+
throw new Error("createAgentClient() requires a session token; raw private-key execution is not supported");
|
|
122
|
+
}
|
|
123
|
+
return options.token;
|
|
124
|
+
}
|
|
107
125
|
function resolveAgentTransport(options) {
|
|
108
126
|
if (options.transport) {
|
|
109
127
|
return options.transport;
|
|
@@ -132,6 +150,6 @@ export function createAgentClient(options) {
|
|
|
132
150
|
if (!isCreateAgentClientOptions(options)) {
|
|
133
151
|
throw new Error("createAgentClient() requires a single options object");
|
|
134
152
|
}
|
|
135
|
-
return new DefaultAgentClient(resolveAgentIdentity(options), options.capability,
|
|
153
|
+
return new DefaultAgentClient(resolveAgentIdentity(options), options.capability, resolveAgentTransport(options), options.clock ?? new SystemClock(), resolveAgentToken(options));
|
|
136
154
|
}
|
|
137
155
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/clients/agent/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/clients/agent/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAc,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAkDtE,MAAM,kBAAkB;IAEH;IACA;IACA;IACA;IACA;IALnB,YACmB,SAAwB,EACxB,WAAoC,EACpC,UAAkC,EAClC,MAAa,EACb,MAAc;QAJd,cAAS,GAAT,SAAS,CAAe;QACxB,gBAAW,GAAX,WAAW,CAAyB;QACpC,eAAU,GAAV,UAAU,CAAwB;QAClC,WAAM,GAAN,MAAM,CAAO;QACb,WAAM,GAAN,MAAM,CAAQ;IAC9B,CAAC;IAEJ,KAAK,CAAC,aAAa,CAAC,MAA2B;QAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC/D,MAAM,SAAS,GAAG,GAAG,IAAI,CAAC,SAAS,C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10 +6,22 @@ export interface AgentDispatchIntent {
|
|
|
6
6
|
body?: string;
|
|
7
7
|
requestedAt?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface AgentSubmitCapabilityRequestInput {
|
|
10
|
+
operation?: "dispatch_http" | "custom_http";
|
|
11
|
+
secretAliases?: readonly string[];
|
|
12
|
+
scope: string;
|
|
13
|
+
methods: readonly string[];
|
|
14
|
+
justification?: string;
|
|
15
|
+
requestedAt?: string;
|
|
16
|
+
}
|
|
9
17
|
export type AgentCapabilityEnvelope = import("../../vault-core/index.js").AgentCapability;
|
|
18
|
+
export type AgentVisibleSecretRecord = import("../../vault-core/index.js").AgentVisibleSecretRecord;
|
|
10
19
|
export interface AgentSigner {
|
|
11
20
|
sign(input: string): Promise<string>;
|
|
12
21
|
}
|
|
13
22
|
export interface AgentDispatchTransport {
|
|
14
|
-
|
|
23
|
+
agentDispatch(request: import("../../vault-core/index.js").DispatchRequest): Promise<import("../../vault-core/index.js").DispatchResult>;
|
|
24
|
+
agentListCapabilities(request: import("../../vault-core/index.js").AgentListCapabilitiesRequest): Promise<readonly import("../../vault-core/index.js").AgentCapability[]>;
|
|
25
|
+
agentListSecrets(request: import("../../vault-core/index.js").AgentListSecretsRequest): Promise<readonly AgentVisibleSecretRecord[]>;
|
|
26
|
+
agentSubmitCapabilityRequest(request: import("../../vault-core/index.js").AgentSubmitCapabilityRequestCommand): Promise<import("../../vault-core/index.js").PendingCapabilityRequestRecord>;
|
|
15
27
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createAgentClient } from "./client.js";
|
|
2
2
|
export type { AgentClient, CreateAgentClientOptions, AgentIdentity, } from "./client.js";
|
|
3
|
-
export type { AgentCapabilityEnvelope, AgentDispatchIntent, AgentDispatchTransport, AgentSigner, } from "./contracts.js";
|
|
3
|
+
export type { AgentCapabilityEnvelope, AgentDispatchIntent, AgentDispatchTransport, AgentSigner, AgentSubmitCapabilityRequestInput, AgentVisibleSecretRecord, } from "./contracts.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CreatedIdentity } from "../../runtime/identity.js";
|
|
2
2
|
import { type Clock } from "../../vault-core/index.js";
|
|
3
3
|
import type { VaultService } from "../../vault-ingress/index.js";
|
|
4
|
-
import type { VaultAuditQueryInput, OwnerDefineSecretTargetsInput, VaultExportSecretInput, VaultGrantCapabilityInput, VaultRegisterFlowInput,
|
|
4
|
+
import type { VaultAuditQueryInput, OwnerDefineSecretTargetsInput, VaultExportSecretInput, VaultGrantCapabilityInput, VaultRegisterFlowInput, VaultImportAgentInput, VaultCreateAgentInput, OwnerAgentProvisionResult, OwnerStoreSecretInput, OwnerWriteSecretInput, VaultDeleteSecretInput, VaultListAgentsInput, VaultListCapabilitiesInput, VaultListSecretsInput, VaultRevokeCapabilityInput, VaultSubmitCapabilityRequestInput, VaultApproveCapabilityRequestInput } from "./contracts.js";
|
|
5
5
|
export interface VaultIdentity {
|
|
6
6
|
identityId: string;
|
|
7
7
|
}
|
|
@@ -16,53 +16,59 @@ export interface VaultClient {
|
|
|
16
16
|
/**
|
|
17
17
|
* Securely stores a new secret in the vault.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
ownerStoreSecret(input: OwnerStoreSecretInput): Promise<import("../../vault-core/index.js").SecretRecord>;
|
|
20
20
|
/**
|
|
21
21
|
* Refines the allowed targets for an existing secret.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
ownerDefineSecretTargets(input: OwnerDefineSecretTargetsInput): Promise<import("../../vault-core/index.js").SecretRecord>;
|
|
24
24
|
/**
|
|
25
25
|
* Atomic operation to store a secret and define its targets in one step.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
ownerWriteSecret(input: OwnerWriteSecretInput): Promise<import("../../vault-core/index.js").SecretRecord>;
|
|
28
28
|
/**
|
|
29
29
|
* Exports a secret's plaintext.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
ownerExportSecret(input: VaultExportSecretInput): Promise<import("../../vault-core/index.js").OwnerSecretExport>;
|
|
32
32
|
/**
|
|
33
33
|
* Grants a specific capability to an agent.
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
ownerGrantCapability(input: VaultGrantCapabilityInput): Promise<void>;
|
|
36
36
|
/**
|
|
37
37
|
* Reads the tamper-evident audit log for the vault.
|
|
38
38
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
ownerReadAudit(query?: VaultAuditQueryInput): Promise<readonly import("../../vault-core/index.js").AuditEntry[]>;
|
|
40
|
+
ownerImportAgent(input: VaultImportAgentInput): Promise<OwnerAgentProvisionResult>;
|
|
41
41
|
/**
|
|
42
42
|
* Generates a new identity and registers it as an agent in one step.
|
|
43
43
|
* The private key is stored in the vault for managed custody.
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
ownerCreateAgent(input: VaultCreateAgentInput): Promise<OwnerAgentProvisionResult>;
|
|
46
46
|
/**
|
|
47
47
|
* Registers a custom HTTP flow for complex secret usage.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
ownerRegisterFlow(input: VaultRegisterFlowInput): Promise<void>;
|
|
50
50
|
/**
|
|
51
51
|
* Permanently deletes a secret from the vault.
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
ownerDeleteSecret(input: VaultDeleteSecretInput): Promise<void>;
|
|
54
54
|
/**
|
|
55
55
|
* Lists all agents registered in the vault.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
ownerListAgents(input?: VaultListAgentsInput): Promise<readonly import("../../vault-core/index.js").AgentIdentityRecord[]>;
|
|
58
58
|
/**
|
|
59
59
|
* Lists all active capabilities granted to agents.
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
ownerListCapabilities(input?: VaultListCapabilitiesInput): Promise<readonly import("../../vault-core/index.js").AgentCapability[]>;
|
|
62
|
+
ownerListSecrets(input?: VaultListSecretsInput): Promise<readonly import("../../vault-core/index.js").AgentVisibleSecretRecord[]>;
|
|
62
63
|
/**
|
|
63
64
|
* Revokes a previously granted capability.
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
|
+
ownerRevokeCapability(input: VaultRevokeCapabilityInput): Promise<void>;
|
|
67
|
+
ownerSubmitCapabilityRequest(input: VaultSubmitCapabilityRequestInput): Promise<import("../../vault-core/index.js").PendingCapabilityRequestRecord>;
|
|
68
|
+
ownerListPendingCapabilityRequests(): Promise<readonly import("../../vault-core/index.js").PendingCapabilityRequestRecord[]>;
|
|
69
|
+
ownerApproveCapabilityRequest(input: VaultApproveCapabilityRequestInput): Promise<import("../../vault-core/index.js").AgentCapability>;
|
|
70
|
+
ownerRejectCapabilityRequest(requestId: string): Promise<void>;
|
|
71
|
+
ownerOnPendingCapabilityRequest(callback: (record: import("../../vault-core/index.js").PendingCapabilityRequestRecord) => void): () => void;
|
|
66
72
|
}
|
|
67
73
|
export interface CreateVaultClientOptions {
|
|
68
74
|
vault: VaultService;
|