@vellumai/credential-executor 0.10.7-dev.202607102035.64f07ea → 0.10.7-staging.1
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/Dockerfile +1 -1
- package/node_modules/@vellumai/service-contracts/package.json +2 -1
- package/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +2 -0
- package/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +686 -0
- package/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +5 -3
- package/node_modules/@vellumai/service-contracts/src/grants.ts +184 -0
- package/node_modules/@vellumai/service-contracts/src/index.ts +4 -2
- package/node_modules/@vellumai/service-contracts/src/rendering.ts +135 -0
- package/node_modules/@vellumai/service-contracts/src/rpc.ts +447 -4
- package/package.json +3 -2
- package/src/__tests__/bulk-set-credentials.test.ts +1 -1
- package/src/__tests__/command-executor.test.ts +1879 -0
- package/src/__tests__/command-validator.test.ts +1405 -0
- package/src/__tests__/command-workspace.test.ts +1050 -0
- package/src/__tests__/grant-store.test.ts +689 -0
- package/src/__tests__/http-executor.test.ts +1336 -0
- package/src/__tests__/http-policy.test.ts +1069 -0
- package/src/__tests__/local-materializers.test.ts +860 -0
- package/src/__tests__/local-standalone.test.ts +36 -5
- package/src/__tests__/local-token-refresh.test.ts +361 -0
- package/src/__tests__/manage-secure-command-tool.test.ts +134 -0
- package/src/__tests__/managed-integration.test.ts +91 -112
- package/src/__tests__/managed-lazy-getters.test.ts +359 -0
- package/src/__tests__/managed-materializers.test.ts +1028 -0
- package/src/__tests__/managed-reconnect.test.ts +2 -2
- package/src/__tests__/managed-rejection.test.ts +43 -0
- package/src/__tests__/toolstore.test.ts +773 -0
- package/src/__tests__/transport.test.ts +27 -23
- package/src/audit/store.ts +188 -0
- package/src/cli.ts +1 -1
- package/src/commands/auth-adapters.ts +169 -0
- package/src/commands/egress-hooks.ts +203 -0
- package/src/commands/executor.ts +1155 -0
- package/src/commands/output-scan.ts +157 -0
- package/src/commands/profiles.ts +286 -0
- package/src/commands/validator.ts +702 -0
- package/src/commands/workspace.ts +550 -0
- package/src/grants/index.ts +17 -0
- package/src/grants/persistent-store.ts +309 -0
- package/src/grants/rpc-handlers.ts +293 -0
- package/src/grants/temporary-store.ts +289 -0
- package/src/http/audit.ts +84 -0
- package/src/http/executor.ts +684 -0
- package/src/http/path-template.ts +245 -0
- package/src/http/policy.ts +238 -0
- package/src/http/response-filter.ts +233 -0
- package/src/index.ts +88 -8
- package/src/main.ts +340 -228
- package/src/managed-errors.ts +9 -0
- package/src/managed-lazy-getters.ts +106 -0
- package/src/managed-main.ts +822 -0
- package/src/materializers/local-oauth-lookup.ts +98 -0
- package/src/materializers/local-token-refresh.ts +287 -0
- package/src/materializers/local.ts +316 -0
- package/src/materializers/managed-platform.ts +295 -0
- package/src/paths.ts +20 -4
- package/src/server.ts +469 -52
- package/src/subjects/local.ts +177 -0
- package/src/subjects/managed.ts +311 -0
- package/src/subjects/policy.ts +79 -0
- package/src/toolstore/integrity.ts +94 -0
- package/src/toolstore/manifest.ts +154 -0
- package/src/toolstore/publish.ts +571 -0
- package/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +0 -104
- package/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +0 -118
|
@@ -7,6 +7,22 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Methods:
|
|
9
9
|
*
|
|
10
|
+
* **Tool execution**
|
|
11
|
+
* - `make_authenticated_request` — Execute an authenticated HTTP request
|
|
12
|
+
* - `run_authenticated_command` — Execute a command with credential env vars
|
|
13
|
+
* - `manage_secure_command_tool` — Register/unregister a secure command tool
|
|
14
|
+
*
|
|
15
|
+
* **Approval flow**
|
|
16
|
+
* - `approval_required` — CES notifies the assistant that approval is needed
|
|
17
|
+
* - `record_grant` — Record a grant decision after guardian approval
|
|
18
|
+
*
|
|
19
|
+
* **Grant management**
|
|
20
|
+
* - `list_grants` — List grants for a CES connection
|
|
21
|
+
* - `revoke_grant` — Revoke a specific grant
|
|
22
|
+
*
|
|
23
|
+
* **Audit**
|
|
24
|
+
* - `list_audit_records` — List audit records for inspection
|
|
25
|
+
*
|
|
10
26
|
* **Lifecycle**
|
|
11
27
|
* - `update_managed_credential` — Push an updated API key to CES after hatch
|
|
12
28
|
*
|
|
@@ -15,10 +31,15 @@
|
|
|
15
31
|
* - `set_credential` — Store or update a credential
|
|
16
32
|
* - `delete_credential` — Delete a credential by account name
|
|
17
33
|
* - `list_credentials` — List all credential account names
|
|
18
|
-
* - `bulk_set_credentials` — Store multiple credentials at once
|
|
19
34
|
*/
|
|
20
35
|
|
|
21
36
|
import { z } from "zod";
|
|
37
|
+
import {
|
|
38
|
+
AuditRecordSummarySchema,
|
|
39
|
+
GrantProposalSchema,
|
|
40
|
+
PersistentGrantRecordSchema,
|
|
41
|
+
TemporaryGrantDecisionSchema,
|
|
42
|
+
} from "./grants.js";
|
|
22
43
|
import { RpcErrorSchema } from "./error.js";
|
|
23
44
|
|
|
24
45
|
// ---------------------------------------------------------------------------
|
|
@@ -26,6 +47,14 @@ import { RpcErrorSchema } from "./error.js";
|
|
|
26
47
|
// ---------------------------------------------------------------------------
|
|
27
48
|
|
|
28
49
|
export const CesRpcMethod = {
|
|
50
|
+
MakeAuthenticatedRequest: "make_authenticated_request",
|
|
51
|
+
RunAuthenticatedCommand: "run_authenticated_command",
|
|
52
|
+
ManageSecureCommandTool: "manage_secure_command_tool",
|
|
53
|
+
ApprovalRequired: "approval_required",
|
|
54
|
+
RecordGrant: "record_grant",
|
|
55
|
+
ListGrants: "list_grants",
|
|
56
|
+
RevokeGrant: "revoke_grant",
|
|
57
|
+
ListAuditRecords: "list_audit_records",
|
|
29
58
|
/** Push an updated assistant credential to CES after post-hatch provisioning. */
|
|
30
59
|
UpdateManagedCredential: "update_managed_credential",
|
|
31
60
|
/** Retrieve a single credential by account name. */
|
|
@@ -40,7 +69,353 @@ export const CesRpcMethod = {
|
|
|
40
69
|
BulkSetCredentials: "bulk_set_credentials",
|
|
41
70
|
} as const;
|
|
42
71
|
|
|
43
|
-
export type CesRpcMethod =
|
|
72
|
+
export type CesRpcMethod =
|
|
73
|
+
(typeof CesRpcMethod)[keyof typeof CesRpcMethod];
|
|
74
|
+
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// make_authenticated_request
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
export const MakeAuthenticatedRequestSchema = z.object({
|
|
80
|
+
/** CES credential handle to use for authentication. */
|
|
81
|
+
credentialHandle: z.string(),
|
|
82
|
+
/** HTTP method. */
|
|
83
|
+
method: z.string(),
|
|
84
|
+
/** Target URL. */
|
|
85
|
+
url: z.string(),
|
|
86
|
+
/** Optional request headers (credential headers are injected by CES). */
|
|
87
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
88
|
+
/** Optional request body (string or JSON-serialisable). */
|
|
89
|
+
body: z.unknown().optional(),
|
|
90
|
+
/** Human-readable purpose for audit logging. */
|
|
91
|
+
purpose: z.string(),
|
|
92
|
+
/** Existing grant ID to consume, if the caller holds one. */
|
|
93
|
+
grantId: z.string().optional(),
|
|
94
|
+
/** Conversation ID for conversation-scoped temporary grants. */
|
|
95
|
+
conversationId: z.string().optional(),
|
|
96
|
+
});
|
|
97
|
+
export type MakeAuthenticatedRequest = z.infer<
|
|
98
|
+
typeof MakeAuthenticatedRequestSchema
|
|
99
|
+
>;
|
|
100
|
+
|
|
101
|
+
export const MakeAuthenticatedRequestResponseSchema = z.object({
|
|
102
|
+
/** Whether the request was executed (not whether the HTTP call succeeded). */
|
|
103
|
+
success: z.boolean(),
|
|
104
|
+
/** HTTP status code returned by the target. */
|
|
105
|
+
statusCode: z.number().optional(),
|
|
106
|
+
/** Response headers. */
|
|
107
|
+
responseHeaders: z.record(z.string(), z.string()).optional(),
|
|
108
|
+
/** Response body (string). */
|
|
109
|
+
responseBody: z.string().optional(),
|
|
110
|
+
/** Structured error if execution failed. */
|
|
111
|
+
error: RpcErrorSchema.optional(),
|
|
112
|
+
/** Audit record ID for this execution. */
|
|
113
|
+
auditId: z.string().optional(),
|
|
114
|
+
});
|
|
115
|
+
export type MakeAuthenticatedRequestResponse = z.infer<
|
|
116
|
+
typeof MakeAuthenticatedRequestResponseSchema
|
|
117
|
+
>;
|
|
118
|
+
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// run_authenticated_command
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A file to stage from the assistant workspace into the CES scratch directory.
|
|
125
|
+
*/
|
|
126
|
+
const WorkspaceInputSchema = z.object({
|
|
127
|
+
/** Relative path within the assistant workspace directory. */
|
|
128
|
+
workspacePath: z.string(),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A file the command produces in the scratch directory that should be
|
|
133
|
+
* copied back to the assistant workspace after execution.
|
|
134
|
+
*/
|
|
135
|
+
const WorkspaceOutputSchema = z.object({
|
|
136
|
+
/** Relative path within the scratch directory where the command writes output. */
|
|
137
|
+
scratchPath: z.string(),
|
|
138
|
+
/** Relative path within the assistant workspace where the output is copied. */
|
|
139
|
+
workspacePath: z.string(),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export const RunAuthenticatedCommandSchema = z.object({
|
|
143
|
+
/** CES credential handle to use for environment injection. */
|
|
144
|
+
credentialHandle: z.string(),
|
|
145
|
+
/** Secure command reference in format '<bundleDigest>/<profileName> [argv...]'. Only manifest-driven secure commands are supported. */
|
|
146
|
+
command: z.string(),
|
|
147
|
+
/** Optional path used for resolving workspace input/output staging, not as the actual execution working directory (CES always runs commands in the scratch directory). */
|
|
148
|
+
cwd: z.string().optional(),
|
|
149
|
+
/** Workspace files to stage as read-only inputs in the CES scratch directory. */
|
|
150
|
+
inputs: z.array(WorkspaceInputSchema).optional(),
|
|
151
|
+
/** Workspace files to copy back from the CES scratch directory after execution. */
|
|
152
|
+
outputs: z.array(WorkspaceOutputSchema).optional(),
|
|
153
|
+
/** Human-readable purpose for audit logging. */
|
|
154
|
+
purpose: z.string(),
|
|
155
|
+
/** Existing grant ID to consume, if the caller holds one. */
|
|
156
|
+
grantId: z.string().optional(),
|
|
157
|
+
/** Conversation ID for conversation-scoped temporary grants. */
|
|
158
|
+
conversationId: z.string().optional(),
|
|
159
|
+
});
|
|
160
|
+
export type RunAuthenticatedCommand = z.infer<
|
|
161
|
+
typeof RunAuthenticatedCommandSchema
|
|
162
|
+
>;
|
|
163
|
+
|
|
164
|
+
export const RunAuthenticatedCommandResponseSchema = z.object({
|
|
165
|
+
/** Whether the command was executed. */
|
|
166
|
+
success: z.boolean(),
|
|
167
|
+
/** Process exit code. */
|
|
168
|
+
exitCode: z.number().optional(),
|
|
169
|
+
/** Combined stdout output. */
|
|
170
|
+
stdout: z.string().optional(),
|
|
171
|
+
/** Combined stderr output. */
|
|
172
|
+
stderr: z.string().optional(),
|
|
173
|
+
/** Structured error if execution failed. */
|
|
174
|
+
error: RpcErrorSchema.optional(),
|
|
175
|
+
/** Audit record ID for this execution. */
|
|
176
|
+
auditId: z.string().optional(),
|
|
177
|
+
});
|
|
178
|
+
export type RunAuthenticatedCommandResponse = z.infer<
|
|
179
|
+
typeof RunAuthenticatedCommandResponseSchema
|
|
180
|
+
>;
|
|
181
|
+
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
// manage_secure_command_tool
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
export const ManageSecureCommandToolAction = {
|
|
187
|
+
Register: "register",
|
|
188
|
+
Unregister: "unregister",
|
|
189
|
+
} as const;
|
|
190
|
+
|
|
191
|
+
export type ManageSecureCommandToolAction =
|
|
192
|
+
(typeof ManageSecureCommandToolAction)[keyof typeof ManageSecureCommandToolAction];
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Zod schema for allowed argv patterns within a command profile.
|
|
196
|
+
*/
|
|
197
|
+
const AllowedArgvPatternSchema = z.object({
|
|
198
|
+
name: z.string(),
|
|
199
|
+
tokens: z.array(z.string()),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Zod schema for allowed network targets within a command profile.
|
|
204
|
+
*/
|
|
205
|
+
const AllowedNetworkTargetSchema = z.object({
|
|
206
|
+
hostPattern: z.string(),
|
|
207
|
+
ports: z.array(z.number()).optional(),
|
|
208
|
+
protocols: z.array(z.enum(["http", "https"])).optional(),
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Zod schema for a single command profile within a secure command manifest.
|
|
213
|
+
*/
|
|
214
|
+
const CommandProfileSchema = z.object({
|
|
215
|
+
description: z.string(),
|
|
216
|
+
allowedArgvPatterns: z.array(AllowedArgvPatternSchema),
|
|
217
|
+
deniedSubcommands: z.array(z.string()),
|
|
218
|
+
deniedFlags: z.array(z.string()).optional(),
|
|
219
|
+
allowedNetworkTargets: z.array(AllowedNetworkTargetSchema).optional(),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Zod schema for auth adapter configuration (discriminated union on `type`).
|
|
224
|
+
*/
|
|
225
|
+
const AuthAdapterConfigSchema = z.discriminatedUnion("type", [
|
|
226
|
+
z.object({
|
|
227
|
+
type: z.literal("env_var"),
|
|
228
|
+
envVarName: z.string(),
|
|
229
|
+
valuePrefix: z.string().optional(),
|
|
230
|
+
}),
|
|
231
|
+
z.object({
|
|
232
|
+
type: z.literal("temp_file"),
|
|
233
|
+
envVarName: z.string(),
|
|
234
|
+
fileExtension: z.string().optional(),
|
|
235
|
+
fileMode: z.number().optional(),
|
|
236
|
+
}),
|
|
237
|
+
z.object({
|
|
238
|
+
type: z.literal("credential_process"),
|
|
239
|
+
envVarName: z.string(),
|
|
240
|
+
helperCommand: z.string(),
|
|
241
|
+
timeoutMs: z.number().optional(),
|
|
242
|
+
}),
|
|
243
|
+
]);
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Zod schema for the full secure command manifest passed during register.
|
|
247
|
+
* This mirrors the {@link SecureCommandManifest} interface in
|
|
248
|
+
* `credential-executor/src/commands/profiles.ts`.
|
|
249
|
+
*/
|
|
250
|
+
export const SecureCommandManifestSchema = z.object({
|
|
251
|
+
schemaVersion: z.string(),
|
|
252
|
+
bundleDigest: z.string(),
|
|
253
|
+
bundleId: z.string(),
|
|
254
|
+
version: z.string(),
|
|
255
|
+
entrypoint: z.string(),
|
|
256
|
+
commandProfiles: z.record(z.string(), CommandProfileSchema),
|
|
257
|
+
authAdapter: AuthAdapterConfigSchema,
|
|
258
|
+
egressMode: z.enum(["proxy_required", "no_network"]),
|
|
259
|
+
cleanConfigDirs: z.record(z.string(), z.string()).optional(),
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
export const ManageSecureCommandToolSchema = z.object({
|
|
263
|
+
/** Whether to register or unregister the tool. */
|
|
264
|
+
action: z.enum(["register", "unregister"]),
|
|
265
|
+
/** Tool name to register/unregister. */
|
|
266
|
+
toolName: z.string(),
|
|
267
|
+
/** CES credential handle the tool should use (required for register). */
|
|
268
|
+
credentialHandle: z.string().optional(),
|
|
269
|
+
/** Human-readable description of the tool (required for register). */
|
|
270
|
+
description: z.string().optional(),
|
|
271
|
+
/** Bundle identifier for the secure command package (required for register). */
|
|
272
|
+
bundleId: z.string().optional(),
|
|
273
|
+
/** Semantic version of the bundle to install (required for register). */
|
|
274
|
+
version: z.string().optional(),
|
|
275
|
+
/** HTTPS URL from which CES will download the bundle (required for register). */
|
|
276
|
+
sourceUrl: z.string().optional(),
|
|
277
|
+
/** SHA-256 hex digest of the bundle for integrity verification (required for register). */
|
|
278
|
+
sha256: z.string().optional(),
|
|
279
|
+
/**
|
|
280
|
+
* Full secure command manifest for the bundle (required for register).
|
|
281
|
+
* Contains entrypoint, command profiles, auth adapter, egress mode, etc.
|
|
282
|
+
* CES validates this manifest before publishing the bundle.
|
|
283
|
+
*/
|
|
284
|
+
secureCommandManifest: SecureCommandManifestSchema.optional(),
|
|
285
|
+
});
|
|
286
|
+
export type ManageSecureCommandTool = z.infer<
|
|
287
|
+
typeof ManageSecureCommandToolSchema
|
|
288
|
+
>;
|
|
289
|
+
|
|
290
|
+
export const ManageSecureCommandToolResponseSchema = z.object({
|
|
291
|
+
/** Whether the operation succeeded. */
|
|
292
|
+
success: z.boolean(),
|
|
293
|
+
/** Structured error if the operation failed. */
|
|
294
|
+
error: RpcErrorSchema.optional(),
|
|
295
|
+
});
|
|
296
|
+
export type ManageSecureCommandToolResponse = z.infer<
|
|
297
|
+
typeof ManageSecureCommandToolResponseSchema
|
|
298
|
+
>;
|
|
299
|
+
|
|
300
|
+
// ---------------------------------------------------------------------------
|
|
301
|
+
// approval_required (CES → assistant notification)
|
|
302
|
+
// ---------------------------------------------------------------------------
|
|
303
|
+
|
|
304
|
+
export const ApprovalRequiredSchema = z.object({
|
|
305
|
+
/** The proposal that requires approval. */
|
|
306
|
+
proposal: GrantProposalSchema,
|
|
307
|
+
/** Deterministic hash of the proposal. */
|
|
308
|
+
proposalHash: z.string(),
|
|
309
|
+
/** Human-readable rendering of the proposal. */
|
|
310
|
+
renderedProposal: z.string(),
|
|
311
|
+
/** The CES connection requesting approval. */
|
|
312
|
+
sessionId: z.string(),
|
|
313
|
+
/** The conversation ID for conversation-scoped grants. */
|
|
314
|
+
conversationId: z.string().optional(),
|
|
315
|
+
});
|
|
316
|
+
export type ApprovalRequired = z.infer<typeof ApprovalRequiredSchema>;
|
|
317
|
+
|
|
318
|
+
export const ApprovalRequiredResponseSchema = z.object({
|
|
319
|
+
/** Whether the assistant acknowledged the approval request. */
|
|
320
|
+
acknowledged: z.boolean(),
|
|
321
|
+
});
|
|
322
|
+
export type ApprovalRequiredResponse = z.infer<
|
|
323
|
+
typeof ApprovalRequiredResponseSchema
|
|
324
|
+
>;
|
|
325
|
+
|
|
326
|
+
// ---------------------------------------------------------------------------
|
|
327
|
+
// record_grant
|
|
328
|
+
// ---------------------------------------------------------------------------
|
|
329
|
+
|
|
330
|
+
export const RecordGrantSchema = z.object({
|
|
331
|
+
/** The grant decision from the guardian. */
|
|
332
|
+
decision: TemporaryGrantDecisionSchema,
|
|
333
|
+
/** The CES connection this grant applies to. */
|
|
334
|
+
sessionId: z.string(),
|
|
335
|
+
/** The conversation ID for conversation-scoped grants. */
|
|
336
|
+
conversationId: z.string().optional(),
|
|
337
|
+
});
|
|
338
|
+
export type RecordGrant = z.infer<typeof RecordGrantSchema>;
|
|
339
|
+
|
|
340
|
+
export const RecordGrantResponseSchema = z.object({
|
|
341
|
+
/** Whether the grant was successfully recorded. */
|
|
342
|
+
success: z.boolean(),
|
|
343
|
+
/** The persisted grant record (when approved and recorded). */
|
|
344
|
+
grant: PersistentGrantRecordSchema.optional(),
|
|
345
|
+
/** Structured error if recording failed. */
|
|
346
|
+
error: RpcErrorSchema.optional(),
|
|
347
|
+
});
|
|
348
|
+
export type RecordGrantResponse = z.infer<typeof RecordGrantResponseSchema>;
|
|
349
|
+
|
|
350
|
+
// ---------------------------------------------------------------------------
|
|
351
|
+
// list_grants
|
|
352
|
+
// ---------------------------------------------------------------------------
|
|
353
|
+
|
|
354
|
+
export const ListGrantsSchema = z.object({
|
|
355
|
+
/** Filter by CES connection ID. */
|
|
356
|
+
sessionId: z.string().optional(),
|
|
357
|
+
/** Filter by credential handle. */
|
|
358
|
+
credentialHandle: z.string().optional(),
|
|
359
|
+
/** Filter by grant status. */
|
|
360
|
+
status: z
|
|
361
|
+
.enum(["active", "expired", "revoked", "consumed"])
|
|
362
|
+
.optional(),
|
|
363
|
+
});
|
|
364
|
+
export type ListGrants = z.infer<typeof ListGrantsSchema>;
|
|
365
|
+
|
|
366
|
+
export const ListGrantsResponseSchema = z.object({
|
|
367
|
+
/** List of matching grant records. */
|
|
368
|
+
grants: z.array(PersistentGrantRecordSchema),
|
|
369
|
+
});
|
|
370
|
+
export type ListGrantsResponse = z.infer<typeof ListGrantsResponseSchema>;
|
|
371
|
+
|
|
372
|
+
// ---------------------------------------------------------------------------
|
|
373
|
+
// revoke_grant
|
|
374
|
+
// ---------------------------------------------------------------------------
|
|
375
|
+
|
|
376
|
+
export const RevokeGrantSchema = z.object({
|
|
377
|
+
/** The grant to revoke. */
|
|
378
|
+
grantId: z.string(),
|
|
379
|
+
/** Human-readable reason for revocation. */
|
|
380
|
+
reason: z.string().optional(),
|
|
381
|
+
});
|
|
382
|
+
export type RevokeGrant = z.infer<typeof RevokeGrantSchema>;
|
|
383
|
+
|
|
384
|
+
export const RevokeGrantResponseSchema = z.object({
|
|
385
|
+
/** Whether the grant was successfully revoked. */
|
|
386
|
+
success: z.boolean(),
|
|
387
|
+
/** Structured error if revocation failed. */
|
|
388
|
+
error: RpcErrorSchema.optional(),
|
|
389
|
+
});
|
|
390
|
+
export type RevokeGrantResponse = z.infer<typeof RevokeGrantResponseSchema>;
|
|
391
|
+
|
|
392
|
+
// ---------------------------------------------------------------------------
|
|
393
|
+
// list_audit_records
|
|
394
|
+
// ---------------------------------------------------------------------------
|
|
395
|
+
|
|
396
|
+
export const ListAuditRecordsSchema = z.object({
|
|
397
|
+
/** Filter by CES connection ID. */
|
|
398
|
+
sessionId: z.string().optional(),
|
|
399
|
+
/** Filter by credential handle. */
|
|
400
|
+
credentialHandle: z.string().optional(),
|
|
401
|
+
/** Filter by grant ID. */
|
|
402
|
+
grantId: z.string().optional(),
|
|
403
|
+
/** Maximum number of records to return. */
|
|
404
|
+
limit: z.number().optional(),
|
|
405
|
+
/** Cursor for pagination (opaque string from a previous response). */
|
|
406
|
+
cursor: z.string().optional(),
|
|
407
|
+
});
|
|
408
|
+
export type ListAuditRecords = z.infer<typeof ListAuditRecordsSchema>;
|
|
409
|
+
|
|
410
|
+
export const ListAuditRecordsResponseSchema = z.object({
|
|
411
|
+
/** List of matching audit record summaries. */
|
|
412
|
+
records: z.array(AuditRecordSummarySchema),
|
|
413
|
+
/** Cursor for the next page (null if no more results). */
|
|
414
|
+
nextCursor: z.string().nullable(),
|
|
415
|
+
});
|
|
416
|
+
export type ListAuditRecordsResponse = z.infer<
|
|
417
|
+
typeof ListAuditRecordsResponseSchema
|
|
418
|
+
>;
|
|
44
419
|
|
|
45
420
|
// ---------------------------------------------------------------------------
|
|
46
421
|
// update_managed_credential
|
|
@@ -83,7 +458,9 @@ export const GetCredentialResponseSchema = z.object({
|
|
|
83
458
|
/** The credential value (present only when found). */
|
|
84
459
|
value: z.string().optional(),
|
|
85
460
|
});
|
|
86
|
-
export type GetCredentialResponse = z.infer<
|
|
461
|
+
export type GetCredentialResponse = z.infer<
|
|
462
|
+
typeof GetCredentialResponseSchema
|
|
463
|
+
>;
|
|
87
464
|
|
|
88
465
|
// ---------------------------------------------------------------------------
|
|
89
466
|
// set_credential
|
|
@@ -101,7 +478,9 @@ export const SetCredentialResponseSchema = z.object({
|
|
|
101
478
|
/** Whether the credential was successfully stored. */
|
|
102
479
|
ok: z.boolean(),
|
|
103
480
|
});
|
|
104
|
-
export type SetCredentialResponse = z.infer<
|
|
481
|
+
export type SetCredentialResponse = z.infer<
|
|
482
|
+
typeof SetCredentialResponseSchema
|
|
483
|
+
>;
|
|
105
484
|
|
|
106
485
|
// ---------------------------------------------------------------------------
|
|
107
486
|
// delete_credential
|
|
@@ -177,6 +556,38 @@ export type BulkSetCredentialsResponse = z.infer<
|
|
|
177
556
|
* schemas. Useful for building type-safe RPC dispatch layers.
|
|
178
557
|
*/
|
|
179
558
|
export interface CesRpcContract {
|
|
559
|
+
[CesRpcMethod.MakeAuthenticatedRequest]: {
|
|
560
|
+
request: MakeAuthenticatedRequest;
|
|
561
|
+
response: MakeAuthenticatedRequestResponse;
|
|
562
|
+
};
|
|
563
|
+
[CesRpcMethod.RunAuthenticatedCommand]: {
|
|
564
|
+
request: RunAuthenticatedCommand;
|
|
565
|
+
response: RunAuthenticatedCommandResponse;
|
|
566
|
+
};
|
|
567
|
+
[CesRpcMethod.ManageSecureCommandTool]: {
|
|
568
|
+
request: ManageSecureCommandTool;
|
|
569
|
+
response: ManageSecureCommandToolResponse;
|
|
570
|
+
};
|
|
571
|
+
[CesRpcMethod.ApprovalRequired]: {
|
|
572
|
+
request: ApprovalRequired;
|
|
573
|
+
response: ApprovalRequiredResponse;
|
|
574
|
+
};
|
|
575
|
+
[CesRpcMethod.RecordGrant]: {
|
|
576
|
+
request: RecordGrant;
|
|
577
|
+
response: RecordGrantResponse;
|
|
578
|
+
};
|
|
579
|
+
[CesRpcMethod.ListGrants]: {
|
|
580
|
+
request: ListGrants;
|
|
581
|
+
response: ListGrantsResponse;
|
|
582
|
+
};
|
|
583
|
+
[CesRpcMethod.RevokeGrant]: {
|
|
584
|
+
request: RevokeGrant;
|
|
585
|
+
response: RevokeGrantResponse;
|
|
586
|
+
};
|
|
587
|
+
[CesRpcMethod.ListAuditRecords]: {
|
|
588
|
+
request: ListAuditRecords;
|
|
589
|
+
response: ListAuditRecordsResponse;
|
|
590
|
+
};
|
|
180
591
|
[CesRpcMethod.UpdateManagedCredential]: {
|
|
181
592
|
request: UpdateManagedCredential;
|
|
182
593
|
response: UpdateManagedCredentialResponse;
|
|
@@ -207,6 +618,38 @@ export interface CesRpcContract {
|
|
|
207
618
|
* Schema lookup map for runtime validation of RPC payloads.
|
|
208
619
|
*/
|
|
209
620
|
export const CesRpcSchemas = {
|
|
621
|
+
[CesRpcMethod.MakeAuthenticatedRequest]: {
|
|
622
|
+
request: MakeAuthenticatedRequestSchema,
|
|
623
|
+
response: MakeAuthenticatedRequestResponseSchema,
|
|
624
|
+
},
|
|
625
|
+
[CesRpcMethod.RunAuthenticatedCommand]: {
|
|
626
|
+
request: RunAuthenticatedCommandSchema,
|
|
627
|
+
response: RunAuthenticatedCommandResponseSchema,
|
|
628
|
+
},
|
|
629
|
+
[CesRpcMethod.ManageSecureCommandTool]: {
|
|
630
|
+
request: ManageSecureCommandToolSchema,
|
|
631
|
+
response: ManageSecureCommandToolResponseSchema,
|
|
632
|
+
},
|
|
633
|
+
[CesRpcMethod.ApprovalRequired]: {
|
|
634
|
+
request: ApprovalRequiredSchema,
|
|
635
|
+
response: ApprovalRequiredResponseSchema,
|
|
636
|
+
},
|
|
637
|
+
[CesRpcMethod.RecordGrant]: {
|
|
638
|
+
request: RecordGrantSchema,
|
|
639
|
+
response: RecordGrantResponseSchema,
|
|
640
|
+
},
|
|
641
|
+
[CesRpcMethod.ListGrants]: {
|
|
642
|
+
request: ListGrantsSchema,
|
|
643
|
+
response: ListGrantsResponseSchema,
|
|
644
|
+
},
|
|
645
|
+
[CesRpcMethod.RevokeGrant]: {
|
|
646
|
+
request: RevokeGrantSchema,
|
|
647
|
+
response: RevokeGrantResponseSchema,
|
|
648
|
+
},
|
|
649
|
+
[CesRpcMethod.ListAuditRecords]: {
|
|
650
|
+
request: ListAuditRecordsSchema,
|
|
651
|
+
response: ListAuditRecordsResponseSchema,
|
|
652
|
+
},
|
|
210
653
|
[CesRpcMethod.UpdateManagedCredential]: {
|
|
211
654
|
request: UpdateManagedCredentialSchema,
|
|
212
655
|
response: UpdateManagedCredentialResponseSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vellumai/credential-executor",
|
|
3
|
-
"version": "0.10.7-
|
|
3
|
+
"version": "0.10.7-staging.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
10
|
"credential-executor": "./src/main.ts",
|
|
11
|
+
"credential-executor-managed": "./src/managed-main.ts",
|
|
11
12
|
"ces": "./src/cli.ts"
|
|
12
13
|
},
|
|
13
14
|
"scripts": {
|
|
14
15
|
"dev": "bun run src/main.ts",
|
|
15
|
-
"dev:managed": "CES_MODE=managed bun run src/main.ts",
|
|
16
|
+
"dev:managed": "CES_MODE=managed bun run src/managed-main.ts",
|
|
16
17
|
"lint": "eslint",
|
|
17
18
|
"lint:unused": "knip --include files,dependencies,unlisted",
|
|
18
19
|
"typecheck": "bunx tsc --noEmit",
|
|
@@ -16,7 +16,7 @@ import type { SecureKeyBackend } from "@vellumai/credential-storage";
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Build a minimal BulkSetCredentials handler using the same logic as
|
|
19
|
-
* main.ts, backed by the given SecureKeyBackend.
|
|
19
|
+
* main.ts / managed-main.ts, backed by the given SecureKeyBackend.
|
|
20
20
|
*/
|
|
21
21
|
function buildBulkSetHandler(secureKeyBackend: SecureKeyBackend) {
|
|
22
22
|
return async (req: { credentials: Array<{ account: string; value: string }> }) => {
|