envpkt 0.1.0 → 0.4.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 +296 -107
- package/dist/cli.js +803 -198
- package/dist/index.d.ts +85 -7
- package/dist/index.js +369 -75
- package/package.json +22 -20
- package/schemas/envpkt.schema.json +46 -3
package/dist/index.d.ts
CHANGED
|
@@ -24,12 +24,14 @@ declare const SecretMetaSchema: _sinclair_typebox0.TObject<{
|
|
|
24
24
|
expires: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
25
25
|
rotation_url: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
26
26
|
purpose: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
27
|
+
comment: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
27
28
|
capabilities: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
|
|
28
29
|
created: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
29
30
|
rotates: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
30
31
|
rate_limit: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
31
32
|
model_hint: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
32
33
|
source: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
34
|
+
encrypted_value: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
33
35
|
required: _sinclair_typebox0.TOptional<_sinclair_typebox0.TBoolean>;
|
|
34
36
|
tags: _sinclair_typebox0.TOptional<_sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TString>>;
|
|
35
37
|
}>;
|
|
@@ -48,6 +50,13 @@ declare const CallbackConfigSchema: _sinclair_typebox0.TObject<{
|
|
|
48
50
|
type CallbackConfig = Static<typeof CallbackConfigSchema>;
|
|
49
51
|
declare const ToolsConfigSchema: _sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TUnknown>;
|
|
50
52
|
type ToolsConfig = Static<typeof ToolsConfigSchema>;
|
|
53
|
+
declare const EnvMetaSchema: _sinclair_typebox0.TObject<{
|
|
54
|
+
value: _sinclair_typebox0.TString;
|
|
55
|
+
purpose: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
56
|
+
comment: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
57
|
+
tags: _sinclair_typebox0.TOptional<_sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TString>>;
|
|
58
|
+
}>;
|
|
59
|
+
type EnvMeta = Static<typeof EnvMetaSchema>;
|
|
51
60
|
declare const EnvpktConfigSchema: _sinclair_typebox0.TObject<{
|
|
52
61
|
version: _sinclair_typebox0.TNumber;
|
|
53
62
|
catalog: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
@@ -62,20 +71,28 @@ declare const EnvpktConfigSchema: _sinclair_typebox0.TObject<{
|
|
|
62
71
|
recipient: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
63
72
|
secrets: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
|
|
64
73
|
}>>;
|
|
65
|
-
|
|
74
|
+
secret: _sinclair_typebox0.TOptional<_sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TObject<{
|
|
66
75
|
service: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
67
76
|
expires: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
68
77
|
rotation_url: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
69
78
|
purpose: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
79
|
+
comment: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
70
80
|
capabilities: _sinclair_typebox0.TOptional<_sinclair_typebox0.TArray<_sinclair_typebox0.TString>>;
|
|
71
81
|
created: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
72
82
|
rotates: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
73
83
|
rate_limit: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
74
84
|
model_hint: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
75
85
|
source: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
86
|
+
encrypted_value: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
76
87
|
required: _sinclair_typebox0.TOptional<_sinclair_typebox0.TBoolean>;
|
|
77
88
|
tags: _sinclair_typebox0.TOptional<_sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TString>>;
|
|
78
|
-
}
|
|
89
|
+
}>>>;
|
|
90
|
+
env: _sinclair_typebox0.TOptional<_sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TObject<{
|
|
91
|
+
value: _sinclair_typebox0.TString;
|
|
92
|
+
purpose: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
93
|
+
comment: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
94
|
+
tags: _sinclair_typebox0.TOptional<_sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TString>>;
|
|
95
|
+
}>>>;
|
|
79
96
|
lifecycle: _sinclair_typebox0.TOptional<_sinclair_typebox0.TObject<{
|
|
80
97
|
stale_warning_days: _sinclair_typebox0.TOptional<_sinclair_typebox0.TNumber>;
|
|
81
98
|
require_expiration: _sinclair_typebox0.TOptional<_sinclair_typebox0.TBoolean>;
|
|
@@ -117,6 +134,21 @@ type AuditResult = {
|
|
|
117
134
|
readonly orphaned: number;
|
|
118
135
|
readonly agent?: AgentIdentity;
|
|
119
136
|
};
|
|
137
|
+
type EnvDriftStatus = "default" | "overridden" | "missing";
|
|
138
|
+
type EnvDriftEntry = {
|
|
139
|
+
readonly key: string;
|
|
140
|
+
readonly defaultValue: string;
|
|
141
|
+
readonly currentValue: string | undefined;
|
|
142
|
+
readonly status: EnvDriftStatus;
|
|
143
|
+
readonly purpose: string | undefined;
|
|
144
|
+
};
|
|
145
|
+
type EnvAuditResult = {
|
|
146
|
+
readonly entries: ReadonlyArray<EnvDriftEntry>;
|
|
147
|
+
readonly total: number;
|
|
148
|
+
readonly defaults_applied: number;
|
|
149
|
+
readonly overridden: number;
|
|
150
|
+
readonly missing: number;
|
|
151
|
+
};
|
|
120
152
|
type FleetAgent = {
|
|
121
153
|
readonly path: string;
|
|
122
154
|
readonly agent?: AgentIdentity;
|
|
@@ -162,6 +194,11 @@ type FnoxError = {
|
|
|
162
194
|
readonly _tag: "FnoxParseError";
|
|
163
195
|
readonly message: string;
|
|
164
196
|
};
|
|
197
|
+
type ConfigSource = "flag" | "env" | "cwd" | "search";
|
|
198
|
+
type ResolvedPath = {
|
|
199
|
+
readonly path: string;
|
|
200
|
+
readonly source: ConfigSource;
|
|
201
|
+
};
|
|
165
202
|
type ResolveOptions = {
|
|
166
203
|
readonly configPath?: string;
|
|
167
204
|
readonly output?: string;
|
|
@@ -200,6 +237,10 @@ type BootResult = {
|
|
|
200
237
|
readonly skipped: ReadonlyArray<string>;
|
|
201
238
|
readonly secrets: Readonly<Record<string, string>>;
|
|
202
239
|
readonly warnings: ReadonlyArray<string>;
|
|
240
|
+
readonly envDefaults: Readonly<Record<string, string>>;
|
|
241
|
+
readonly overridden: ReadonlyArray<string>;
|
|
242
|
+
readonly configPath: string;
|
|
243
|
+
readonly configSource: ConfigSource;
|
|
203
244
|
};
|
|
204
245
|
type BootError = ConfigError | FnoxError | CatalogError | {
|
|
205
246
|
readonly _tag: "AuditFailed";
|
|
@@ -216,10 +257,31 @@ type IdentityError = {
|
|
|
216
257
|
readonly _tag: "IdentityNotFound";
|
|
217
258
|
readonly path: string;
|
|
218
259
|
};
|
|
260
|
+
type SealError = {
|
|
261
|
+
readonly _tag: "AgeNotFound";
|
|
262
|
+
readonly message: string;
|
|
263
|
+
} | {
|
|
264
|
+
readonly _tag: "EncryptFailed";
|
|
265
|
+
readonly key: string;
|
|
266
|
+
readonly message: string;
|
|
267
|
+
} | {
|
|
268
|
+
readonly _tag: "DecryptFailed";
|
|
269
|
+
readonly key: string;
|
|
270
|
+
readonly message: string;
|
|
271
|
+
} | {
|
|
272
|
+
readonly _tag: "NoRecipient";
|
|
273
|
+
readonly message: string;
|
|
274
|
+
};
|
|
219
275
|
//#endregion
|
|
220
276
|
//#region src/core/config.d.ts
|
|
221
277
|
/** Find envpkt.toml in the given directory */
|
|
222
278
|
declare const findConfigPath: (dir: string) => Option<string>;
|
|
279
|
+
type DiscoveredConfig = {
|
|
280
|
+
readonly path: string;
|
|
281
|
+
readonly source: "cwd" | "search";
|
|
282
|
+
};
|
|
283
|
+
/** Discover config by checking CWD, then ENVPKT_SEARCH_PATH, then built-in candidate paths */
|
|
284
|
+
declare const discoverConfig: (cwd?: string) => Option<DiscoveredConfig>;
|
|
223
285
|
/** Read a config file, returning Either<ConfigError, string> */
|
|
224
286
|
declare const readConfigFile: (path: string) => Either<ConfigError, string>;
|
|
225
287
|
/** Parse a TOML string, returning Either<ConfigError, unknown> */
|
|
@@ -228,18 +290,19 @@ declare const parseToml: (raw: string) => Either<ConfigError, unknown>;
|
|
|
228
290
|
declare const validateConfig: (data: unknown) => Either<ConfigError, EnvpktConfig>;
|
|
229
291
|
/** Load and validate an envpkt.toml from a file path */
|
|
230
292
|
declare const loadConfig: (path: string) => Either<ConfigError, EnvpktConfig>;
|
|
231
|
-
/** Load config from CWD, returning
|
|
293
|
+
/** Load config from CWD or discovery chain, returning path, source, and parsed config */
|
|
232
294
|
declare const loadConfigFromCwd: (cwd?: string) => Either<ConfigError, {
|
|
233
295
|
path: string;
|
|
296
|
+
source: "cwd" | "search";
|
|
234
297
|
config: EnvpktConfig;
|
|
235
298
|
}>;
|
|
236
299
|
/**
|
|
237
300
|
* Resolve config path via priority chain:
|
|
238
301
|
* 1. Explicit flag path
|
|
239
302
|
* 2. ENVPKT_CONFIG env var
|
|
240
|
-
* 3. CWD discovery
|
|
303
|
+
* 3. CWD + discovery chain (home dir, cloud storage, custom search paths)
|
|
241
304
|
*/
|
|
242
|
-
declare const resolveConfigPath: (flagPath?: string, envVar?: string, cwd?: string) => Either<ConfigError,
|
|
305
|
+
declare const resolveConfigPath: (flagPath?: string, envVar?: string, cwd?: string) => Either<ConfigError, ResolvedPath>;
|
|
243
306
|
//#endregion
|
|
244
307
|
//#region src/core/catalog.d.ts
|
|
245
308
|
/** Load and validate a catalog file, mapping ConfigError → CatalogError */
|
|
@@ -260,6 +323,7 @@ declare const formatPacket: (result: ResolveResult, options?: FormatPacketOption
|
|
|
260
323
|
//#endregion
|
|
261
324
|
//#region src/core/audit.d.ts
|
|
262
325
|
declare const computeAudit: (config: EnvpktConfig, fnoxKeys?: ReadonlySet<string>, today?: Date) => AuditResult;
|
|
326
|
+
declare const computeEnvAudit: (config: EnvpktConfig, env?: Readonly<Record<string, string | undefined>>) => EnvAuditResult;
|
|
263
327
|
//#endregion
|
|
264
328
|
//#region src/core/patterns.d.ts
|
|
265
329
|
type ConfidenceLevel = "high" | "medium" | "low";
|
|
@@ -318,7 +382,7 @@ type ScanOptions = {
|
|
|
318
382
|
declare const envScan: (env: Readonly<Record<string, string | undefined>>, options?: ScanOptions) => ScanResult;
|
|
319
383
|
/** Bidirectional drift detection between config and live environment */
|
|
320
384
|
declare const envCheck: (config: EnvpktConfig, env: Readonly<Record<string, string | undefined>>) => CheckResult;
|
|
321
|
-
/** Generate TOML [
|
|
385
|
+
/** Generate TOML [secret.*] blocks from scan results, mirroring init.ts pattern */
|
|
322
386
|
declare const generateTomlFromScan: (matches: ReadonlyArray<MatchResult>) => string;
|
|
323
387
|
//#endregion
|
|
324
388
|
//#region src/core/boot.d.ts
|
|
@@ -332,6 +396,20 @@ declare class EnvpktBootError extends Error {
|
|
|
332
396
|
constructor(error: BootError);
|
|
333
397
|
}
|
|
334
398
|
//#endregion
|
|
399
|
+
//#region src/core/seal.d.ts
|
|
400
|
+
/** Encrypt a plaintext string using age with the given recipient public key (armored output) */
|
|
401
|
+
declare const ageEncrypt: (plaintext: string, recipient: string) => Either<SealError, string>;
|
|
402
|
+
/** Decrypt an age-armored ciphertext using the given identity file */
|
|
403
|
+
declare const ageDecrypt: (ciphertext: string, identityPath: string) => Either<SealError, string>;
|
|
404
|
+
/** Seal multiple secrets: encrypt each value with the recipient key and set encrypted_value on meta */
|
|
405
|
+
declare const sealSecrets: (meta: Readonly<Record<string, SecretMeta>>, values: Readonly<Record<string, string>>, recipient: string) => Either<SealError, Record<string, SecretMeta>>;
|
|
406
|
+
/** Unseal secrets: decrypt encrypted_value for each meta entry that has one */
|
|
407
|
+
declare const unsealSecrets: (meta: Readonly<Record<string, SecretMeta>>, identityPath: string) => Either<SealError, Record<string, string>>;
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/core/resolve-values.d.ts
|
|
410
|
+
/** Resolve plaintext values for the given keys via cascade: fnox → env → interactive prompt */
|
|
411
|
+
declare const resolveValues: (keys: ReadonlyArray<string>, profile?: string, agentKey?: string) => Promise<Record<string, string>>;
|
|
412
|
+
//#endregion
|
|
335
413
|
//#region src/core/fleet.d.ts
|
|
336
414
|
declare const scanFleet: (rootDir: string, options?: {
|
|
337
415
|
maxDepth?: number;
|
|
@@ -389,4 +467,4 @@ type ToolDef = {
|
|
|
389
467
|
declare const toolDefinitions: readonly ToolDef[];
|
|
390
468
|
declare const callTool: (name: string, args: Record<string, unknown>) => CallToolResult;
|
|
391
469
|
//#endregion
|
|
392
|
-
export { type AgentIdentity, AgentIdentitySchema, type AuditResult, type BootError, type BootOptions, type BootResult, type CallbackConfig, CallbackConfigSchema, type CatalogError, type CheckResult, type ConfidenceLevel, type ConfigError, type ConsumerType, type CredentialPattern, type DriftEntry, type DriftStatus, EnvpktBootError, type EnvpktConfig, EnvpktConfigSchema, type FleetAgent, type FleetHealth, type FnoxConfig, type FnoxError, type FnoxSecret, type FormatPacketOptions, type HealthStatus, type IdentityError, type LifecycleConfig, LifecycleConfigSchema, type MatchResult, type ResolveOptions, type ResolveResult, type ScanOptions, type ScanResult, type SecretDisplay, type SecretHealth, type SecretMeta, SecretMetaSchema, type SecretStatus, type ToolsConfig, ToolsConfigSchema, ageAvailable, boot, bootSafe, callTool, compareFnoxAndEnvpkt, computeAudit, createServer, deriveServiceFromName, detectFnox, envCheck, envScan, extractFnoxKeys, findConfigPath, fnoxAvailable, fnoxExport, fnoxGet, formatPacket, generateTomlFromScan, loadCatalog, loadConfig, loadConfigFromCwd, maskValue, matchEnvVar, matchValueShape, parseToml, readConfigFile, readFnoxConfig, readResource, resolveConfig, resolveConfigPath, resolveSecrets, resourceDefinitions, scanEnv, scanFleet, startServer, toolDefinitions, unwrapAgentKey, validateConfig };
|
|
470
|
+
export { type AgentIdentity, AgentIdentitySchema, type AuditResult, type BootError, type BootOptions, type BootResult, type CallbackConfig, CallbackConfigSchema, type CatalogError, type CheckResult, type ConfidenceLevel, type ConfigError, type ConfigSource, type ConsumerType, type CredentialPattern, type DriftEntry, type DriftStatus, type EnvAuditResult, type EnvDriftEntry, type EnvDriftStatus, type EnvMeta, EnvMetaSchema, EnvpktBootError, type EnvpktConfig, EnvpktConfigSchema, type FleetAgent, type FleetHealth, type FnoxConfig, type FnoxError, type FnoxSecret, type FormatPacketOptions, type HealthStatus, type IdentityError, type LifecycleConfig, LifecycleConfigSchema, type MatchResult, type ResolveOptions, type ResolveResult, type ResolvedPath, type ScanOptions, type ScanResult, type SealError, type SecretDisplay, type SecretHealth, type SecretMeta, SecretMetaSchema, type SecretStatus, type ToolsConfig, ToolsConfigSchema, ageAvailable, ageDecrypt, ageEncrypt, boot, bootSafe, callTool, compareFnoxAndEnvpkt, computeAudit, computeEnvAudit, createServer, deriveServiceFromName, detectFnox, discoverConfig, envCheck, envScan, extractFnoxKeys, findConfigPath, fnoxAvailable, fnoxExport, fnoxGet, formatPacket, generateTomlFromScan, loadCatalog, loadConfig, loadConfigFromCwd, maskValue, matchEnvVar, matchValueShape, parseToml, readConfigFile, readFnoxConfig, readResource, resolveConfig, resolveConfigPath, resolveSecrets, resolveValues, resourceDefinitions, scanEnv, scanFleet, sealSecrets, startServer, toolDefinitions, unsealSecrets, unwrapAgentKey, validateConfig };
|