@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolstore manifest type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Describes an approved secure command bundle that CES can publish into
|
|
5
|
+
* its private immutable toolstore. Each manifest records:
|
|
6
|
+
*
|
|
7
|
+
* - **sourceUrl** — The canonical URL the bundle was fetched from.
|
|
8
|
+
* - **expectedDigest** — SHA-256 hex digest that the downloaded bytes
|
|
9
|
+
* must match before publication.
|
|
10
|
+
* - **bundleId** — Unique identifier for the command bundle
|
|
11
|
+
* (e.g. "gh-cli", "aws-cli").
|
|
12
|
+
* - **version** — Semantic version of the bundle.
|
|
13
|
+
* - **commandProfiles** — Profile names from the secure command manifest
|
|
14
|
+
* that this bundle declares.
|
|
15
|
+
*
|
|
16
|
+
* ## Publishing rules
|
|
17
|
+
*
|
|
18
|
+
* 1. **Only CES can write** — bundles are published into the CES-private
|
|
19
|
+
* data root, which the assistant process cannot reach.
|
|
20
|
+
* 2. **Immutable once published** — a bundle directory keyed by its digest
|
|
21
|
+
* is never overwritten. Re-publishing the same digest is a no-op.
|
|
22
|
+
* 3. **Workspace-origin binaries are never publishable** — bundles must
|
|
23
|
+
* come from a known source URL; arbitrary assistant-provided bytes are
|
|
24
|
+
* rejected.
|
|
25
|
+
* 4. **Publication does not grant credentials** — writing a bundle into
|
|
26
|
+
* the toolstore is purely a content operation. Credential-use grants
|
|
27
|
+
* are managed by a separate subsystem.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import type { SecureCommandManifest } from "../commands/profiles.js";
|
|
31
|
+
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Bundle origin
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Describes the provenance of a bundle.
|
|
38
|
+
*
|
|
39
|
+
* `sourceUrl` must be an HTTPS URL. Workspace paths, file:// URLs, and
|
|
40
|
+
* data: URLs are structurally rejected.
|
|
41
|
+
*/
|
|
42
|
+
export interface BundleOrigin {
|
|
43
|
+
/** HTTPS URL from which the bundle was fetched. */
|
|
44
|
+
sourceUrl: string;
|
|
45
|
+
/** ISO-8601 timestamp of when the bundle was fetched. */
|
|
46
|
+
fetchedAt: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Toolstore manifest
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A toolstore manifest describes a single approved secure command bundle.
|
|
55
|
+
*
|
|
56
|
+
* This is the metadata stored alongside the bundle contents in the
|
|
57
|
+
* content-addressed toolstore directory.
|
|
58
|
+
*/
|
|
59
|
+
export interface ToolstoreManifest {
|
|
60
|
+
/** SHA-256 hex digest of the bundle contents. Content-address key. */
|
|
61
|
+
digest: string;
|
|
62
|
+
|
|
63
|
+
/** Unique identifier for the command bundle. */
|
|
64
|
+
bundleId: string;
|
|
65
|
+
|
|
66
|
+
/** Semantic version of the bundle. */
|
|
67
|
+
version: string;
|
|
68
|
+
|
|
69
|
+
/** Provenance information — where the bundle came from. */
|
|
70
|
+
origin: BundleOrigin;
|
|
71
|
+
|
|
72
|
+
/** Profile names declared in the secure command manifest. */
|
|
73
|
+
declaredProfiles: string[];
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The full secure command manifest embedded in the toolstore manifest.
|
|
77
|
+
* Used for runtime validation without needing to re-parse the bundle.
|
|
78
|
+
*/
|
|
79
|
+
secureCommandManifest: SecureCommandManifest;
|
|
80
|
+
|
|
81
|
+
/** ISO-8601 timestamp of when the bundle was published to the toolstore. */
|
|
82
|
+
publishedAt: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Validation helpers
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
/** Regex for a valid SHA-256 hex digest. */
|
|
90
|
+
const SHA256_HEX_PATTERN = /^[a-f0-9]{64}$/;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns true if the given string is a valid SHA-256 hex digest.
|
|
94
|
+
*/
|
|
95
|
+
export function isValidSha256Hex(digest: string): boolean {
|
|
96
|
+
return SHA256_HEX_PATTERN.test(digest);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Schemes that are structurally rejected as bundle source URLs.
|
|
101
|
+
* Only HTTPS sources are accepted.
|
|
102
|
+
*/
|
|
103
|
+
const REJECTED_URL_SCHEMES = ["file:", "data:", "blob:", "javascript:"];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Validate a source URL for bundle origin.
|
|
107
|
+
*
|
|
108
|
+
* Accepted: HTTPS URLs only.
|
|
109
|
+
* Rejected: file://, data://, workspace paths, non-URL strings.
|
|
110
|
+
*
|
|
111
|
+
* Returns an error message if invalid, or null if valid.
|
|
112
|
+
*/
|
|
113
|
+
export function validateSourceUrl(sourceUrl: string): string | null {
|
|
114
|
+
if (!sourceUrl || sourceUrl.trim().length === 0) {
|
|
115
|
+
return "sourceUrl is required and must be non-empty.";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Must be a valid URL
|
|
119
|
+
let parsed: URL;
|
|
120
|
+
try {
|
|
121
|
+
parsed = new URL(sourceUrl);
|
|
122
|
+
} catch {
|
|
123
|
+
return `sourceUrl "${sourceUrl}" is not a valid URL. Only HTTPS URLs are accepted.`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Must be HTTPS
|
|
127
|
+
if (parsed.protocol !== "https:") {
|
|
128
|
+
if (REJECTED_URL_SCHEMES.includes(parsed.protocol)) {
|
|
129
|
+
return `sourceUrl scheme "${parsed.protocol}" is not allowed. Only HTTPS URLs are accepted as bundle sources.`;
|
|
130
|
+
}
|
|
131
|
+
return `sourceUrl scheme "${parsed.protocol}" is not allowed. Only HTTPS URLs are accepted.`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Workspace-origin path patterns that are never publishable as bundle
|
|
139
|
+
* sources. These catch attempts to publish assistant-provided bytes
|
|
140
|
+
* directly from the workspace directory.
|
|
141
|
+
*/
|
|
142
|
+
const WORKSPACE_PATH_PATTERNS = [
|
|
143
|
+
/^~?\/?\.vellum\//,
|
|
144
|
+
/\/\.vellum\//,
|
|
145
|
+
/\/workspace\//i,
|
|
146
|
+
] as const;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns true if the given path looks like a workspace-origin path
|
|
150
|
+
* that should never be accepted as a bundle source.
|
|
151
|
+
*/
|
|
152
|
+
export function isWorkspaceOriginPath(path: string): boolean {
|
|
153
|
+
return WORKSPACE_PATH_PATTERNS.some((pattern) => pattern.test(path));
|
|
154
|
+
}
|