@kitsy/cnos 1.1.2 → 1.3.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 (66) hide show
  1. package/README.md +6 -3
  2. package/dist/browser/index.cjs +94 -0
  3. package/dist/browser/index.d.cts +16 -0
  4. package/dist/browser/index.d.ts +16 -0
  5. package/dist/browser/index.js +67 -0
  6. package/dist/build/index.cjs +2889 -0
  7. package/dist/build/index.d.cts +5 -0
  8. package/dist/build/index.d.ts +5 -0
  9. package/dist/build/index.js +26 -0
  10. package/dist/{chunk-53HXUSM6.js → chunk-CDXJISGB.js} +1 -1
  11. package/dist/{chunk-33ZDYDQJ.js → chunk-DRKDNY4I.js} +1470 -462
  12. package/dist/chunk-E7SE6N26.js +189 -0
  13. package/dist/chunk-EDCLLCNL.js +200 -0
  14. package/dist/{chunk-7FBRVJD6.js → chunk-FC3IV6A7.js} +1 -31
  15. package/dist/{chunk-JQGGSNCL.js → chunk-JDII6O72.js} +1 -1
  16. package/dist/chunk-K6QYI2T4.js +105 -0
  17. package/dist/{chunk-IHSV5AFX.js → chunk-OOKFRWTN.js} +1 -1
  18. package/dist/{chunk-HOS4E7XO.js → chunk-OWUZQ4OH.js} +1 -1
  19. package/dist/{chunk-IQOUWY6T.js → chunk-QTKXPY3N.js} +1 -1
  20. package/dist/configure/index.cjs +2928 -0
  21. package/dist/configure/index.d.cts +12 -0
  22. package/dist/configure/index.d.ts +12 -0
  23. package/dist/configure/index.js +24 -0
  24. package/dist/{envNaming-BrOk5ndZ.d.cts → envNaming-D6k66myh.d.cts} +1 -1
  25. package/dist/{envNaming-DCaNdnrF.d.ts → envNaming-Dy3WYiGK.d.ts} +1 -1
  26. package/dist/index.cjs +1396 -264
  27. package/dist/index.d.cts +2 -12
  28. package/dist/index.d.ts +2 -12
  29. package/dist/index.js +13 -143
  30. package/dist/internal.cjs +1913 -63
  31. package/dist/internal.d.cts +190 -8
  32. package/dist/internal.d.ts +190 -8
  33. package/dist/internal.js +669 -3
  34. package/dist/plugin/basic-schema.cjs +29 -2
  35. package/dist/plugin/basic-schema.d.cts +1 -1
  36. package/dist/plugin/basic-schema.d.ts +1 -1
  37. package/dist/plugin/basic-schema.js +2 -2
  38. package/dist/plugin/cli-args.cjs +29 -2
  39. package/dist/plugin/cli-args.d.cts +1 -1
  40. package/dist/plugin/cli-args.d.ts +1 -1
  41. package/dist/plugin/cli-args.js +2 -2
  42. package/dist/plugin/dotenv.cjs +38 -11
  43. package/dist/plugin/dotenv.d.cts +2 -2
  44. package/dist/plugin/dotenv.d.ts +2 -2
  45. package/dist/plugin/dotenv.js +2 -2
  46. package/dist/plugin/env-export.cjs +60 -48
  47. package/dist/plugin/env-export.d.cts +2 -2
  48. package/dist/plugin/env-export.d.ts +2 -2
  49. package/dist/plugin/env-export.js +2 -2
  50. package/dist/plugin/filesystem.cjs +46 -91
  51. package/dist/plugin/filesystem.d.cts +1 -1
  52. package/dist/plugin/filesystem.d.ts +1 -1
  53. package/dist/plugin/filesystem.js +2 -2
  54. package/dist/plugin/process-env.cjs +33 -6
  55. package/dist/plugin/process-env.d.cts +2 -2
  56. package/dist/plugin/process-env.d.ts +2 -2
  57. package/dist/plugin/process-env.js +2 -2
  58. package/dist/{plugin-BVNEHj19.d.cts → plugin-CyNkf7Dm.d.cts} +42 -2
  59. package/dist/{plugin-BVNEHj19.d.ts → plugin-CyNkf7Dm.d.ts} +42 -2
  60. package/dist/runtime/index.cjs +3116 -0
  61. package/dist/runtime/index.d.cts +23 -0
  62. package/dist/runtime/index.d.ts +23 -0
  63. package/dist/runtime/index.js +15 -0
  64. package/dist/{toPublicEnv-Dd152fFy.d.cts → toPublicEnv-Cz72m6y0.d.cts} +1 -1
  65. package/dist/{toPublicEnv-Gwz3xTK0.d.ts → toPublicEnv-D2PZkaN-.d.ts} +1 -1
  66. package/package.json +26 -1
@@ -0,0 +1,189 @@
1
+ import {
2
+ graphRequiresSecretHydration,
3
+ readRuntimeGraphFromEnv
4
+ } from "./chunk-K6QYI2T4.js";
5
+ import {
6
+ createCnos,
7
+ getBootstrappedSecretHydrationRequired,
8
+ getSingletonReady,
9
+ getSingletonRuntime,
10
+ setBootstrappedSecretHydrationRequired,
11
+ setSingletonReady,
12
+ setSingletonRuntime
13
+ } from "./chunk-EDCLLCNL.js";
14
+ import {
15
+ inspectValue,
16
+ readOrValue,
17
+ readValue,
18
+ requireValue,
19
+ toEnv,
20
+ toLogicalKey,
21
+ toNamespaceObject,
22
+ toPublicEnv
23
+ } from "./chunk-DRKDNY4I.js";
24
+
25
+ // src/runtime/index.ts
26
+ var NOT_READY_MESSAGE = "CNOS not initialized. Call await cnos.ready() or use cnos run.";
27
+ function getRuntimeOrThrow() {
28
+ const runtime = getSingletonRuntime();
29
+ if (!runtime) {
30
+ throw new Error(NOT_READY_MESSAGE);
31
+ }
32
+ return runtime;
33
+ }
34
+ function attachBootstrappedGraph(graph) {
35
+ if (getSingletonRuntime()) {
36
+ return;
37
+ }
38
+ const bootstrappedManifest = {
39
+ version: 1,
40
+ project: {
41
+ name: "bootstrapped"
42
+ },
43
+ workspaces: {
44
+ global: {
45
+ enabled: Boolean(graph.workspace.globalRoot),
46
+ ...graph.workspace.globalRoot ? {
47
+ root: graph.workspace.globalRoot
48
+ } : {},
49
+ allowWrite: false
50
+ },
51
+ items: {},
52
+ ...graph.workspace.workspaceSource === "implicit" ? {} : {
53
+ default: graph.workspace.workspaceId
54
+ }
55
+ },
56
+ profiles: {
57
+ default: graph.profile,
58
+ resolveFrom: ["default"]
59
+ },
60
+ plugins: {
61
+ loaders: [],
62
+ resolver: "profile-aware",
63
+ validators: [],
64
+ exporters: [],
65
+ inspectors: []
66
+ },
67
+ sources: {},
68
+ resolution: {
69
+ precedence: [],
70
+ arrayPolicy: "replace"
71
+ },
72
+ envMapping: {
73
+ explicit: {}
74
+ },
75
+ public: {
76
+ promote: [],
77
+ frameworks: {}
78
+ },
79
+ namespaces: {},
80
+ vaults: {},
81
+ writePolicy: {
82
+ define: {
83
+ defaultProfile: graph.profile,
84
+ targets: {
85
+ value: "./values/app.yml",
86
+ secret: "./secrets/app.yml"
87
+ }
88
+ }
89
+ },
90
+ schema: {}
91
+ };
92
+ const runtime = {
93
+ manifest: bootstrappedManifest,
94
+ plugins: [],
95
+ graph,
96
+ read(key) {
97
+ return readValue(graph, key);
98
+ },
99
+ require(key) {
100
+ return requireValue(graph, key);
101
+ },
102
+ readOr(key, fallback) {
103
+ return readOrValue(graph, key, fallback);
104
+ },
105
+ value(path) {
106
+ return readValue(graph, toLogicalKey("value", path));
107
+ },
108
+ secret(path) {
109
+ return readValue(graph, toLogicalKey("secret", path));
110
+ },
111
+ meta(path) {
112
+ return readValue(graph, toLogicalKey("meta", path));
113
+ },
114
+ inspect(key) {
115
+ return inspectValue(graph, key);
116
+ },
117
+ toObject() {
118
+ return toNamespaceObject(graph);
119
+ },
120
+ toNamespace(namespace) {
121
+ return toNamespaceObject(graph, namespace);
122
+ },
123
+ toEnv(options) {
124
+ return toEnv(graph, bootstrappedManifest, options);
125
+ },
126
+ toPublicEnv(options) {
127
+ return toPublicEnv(graph, bootstrappedManifest, options);
128
+ }
129
+ };
130
+ setSingletonRuntime(runtime);
131
+ setBootstrappedSecretHydrationRequired(graphRequiresSecretHydration(graph));
132
+ }
133
+ function bootstrapFromProcessEnv() {
134
+ if (typeof process === "undefined") {
135
+ return;
136
+ }
137
+ try {
138
+ const graph = readRuntimeGraphFromEnv(process.env);
139
+ if (graph) {
140
+ attachBootstrappedGraph(graph);
141
+ }
142
+ } catch {
143
+ }
144
+ }
145
+ bootstrapFromProcessEnv();
146
+ var cnos = Object.assign(
147
+ ((key) => readValue(getRuntimeOrThrow().graph, key)),
148
+ {
149
+ read(key) {
150
+ return readValue(getRuntimeOrThrow().graph, key);
151
+ },
152
+ require(key) {
153
+ return requireValue(getRuntimeOrThrow().graph, key);
154
+ },
155
+ readOr(key, fallback) {
156
+ return readOrValue(getRuntimeOrThrow().graph, key, fallback);
157
+ },
158
+ value(path) {
159
+ return readValue(getRuntimeOrThrow().graph, toLogicalKey("value", path));
160
+ },
161
+ secret(path) {
162
+ return readValue(getRuntimeOrThrow().graph, toLogicalKey("secret", path));
163
+ },
164
+ meta(path) {
165
+ return readValue(getRuntimeOrThrow().graph, toLogicalKey("meta", path));
166
+ },
167
+ async ready() {
168
+ if (getSingletonRuntime() && !getBootstrappedSecretHydrationRequired()) {
169
+ return;
170
+ }
171
+ const existing = getSingletonReady();
172
+ if (existing && !getBootstrappedSecretHydrationRequired()) {
173
+ await existing;
174
+ return;
175
+ }
176
+ const readyPromise = createCnos().then((runtime) => {
177
+ setSingletonRuntime(runtime);
178
+ return runtime;
179
+ });
180
+ setSingletonReady(readyPromise);
181
+ await readyPromise;
182
+ }
183
+ }
184
+ );
185
+ var runtime_default = cnos;
186
+
187
+ export {
188
+ runtime_default
189
+ };
@@ -0,0 +1,200 @@
1
+ import {
2
+ createEnvExportPlugin,
3
+ createPublicEnvExportPlugin
4
+ } from "./chunk-OOKFRWTN.js";
5
+ import {
6
+ createFilesystemSecretsPlugin,
7
+ createFilesystemValuesPlugin
8
+ } from "./chunk-FC3IV6A7.js";
9
+ import {
10
+ createProcessEnvPlugin
11
+ } from "./chunk-CDXJISGB.js";
12
+ import {
13
+ createBasicSchemaPlugin
14
+ } from "./chunk-JDII6O72.js";
15
+ import {
16
+ createCliArgsPlugin
17
+ } from "./chunk-OWUZQ4OH.js";
18
+ import {
19
+ createDotenvPlugin
20
+ } from "./chunk-QTKXPY3N.js";
21
+ import {
22
+ createCnos,
23
+ createProvenanceInspector
24
+ } from "./chunk-DRKDNY4I.js";
25
+
26
+ // src/defaultPlugins.ts
27
+ function defaultPlugins() {
28
+ return [
29
+ createFilesystemValuesPlugin(),
30
+ createFilesystemSecretsPlugin(),
31
+ createDotenvPlugin(),
32
+ createProcessEnvPlugin(),
33
+ createCliArgsPlugin(),
34
+ createBasicSchemaPlugin(),
35
+ createEnvExportPlugin(),
36
+ createPublicEnvExportPlugin(),
37
+ createProvenanceInspector()
38
+ ];
39
+ }
40
+
41
+ // src/runtime/state.ts
42
+ var singletonRuntime;
43
+ var singletonReady;
44
+ var bootstrappedSecretHydrationRequired = false;
45
+ function getSingletonRuntime() {
46
+ return singletonRuntime;
47
+ }
48
+ function setSingletonRuntime(runtime) {
49
+ singletonRuntime = runtime;
50
+ singletonReady = Promise.resolve(runtime);
51
+ bootstrappedSecretHydrationRequired = false;
52
+ return runtime;
53
+ }
54
+ function getSingletonReady() {
55
+ return singletonReady;
56
+ }
57
+ function setSingletonReady(promise) {
58
+ singletonReady = promise;
59
+ return promise;
60
+ }
61
+ function getBootstrappedSecretHydrationRequired() {
62
+ return bootstrappedSecretHydrationRequired;
63
+ }
64
+ function setBootstrappedSecretHydrationRequired(value) {
65
+ bootstrappedSecretHydrationRequired = value;
66
+ }
67
+
68
+ // package.json
69
+ var package_default = {
70
+ name: "@kitsy/cnos",
71
+ version: "1.3.0",
72
+ description: "Batteries-included CNOS runtime package wired with the official plugins.",
73
+ type: "module",
74
+ main: "./dist/index.cjs",
75
+ module: "./dist/index.js",
76
+ types: "./dist/index.d.ts",
77
+ exports: {
78
+ ".": {
79
+ types: "./dist/index.d.ts",
80
+ import: "./dist/index.js",
81
+ require: "./dist/index.cjs"
82
+ },
83
+ "./configure": {
84
+ types: "./dist/configure/index.d.ts",
85
+ import: "./dist/configure/index.js",
86
+ require: "./dist/configure/index.cjs"
87
+ },
88
+ "./create": {
89
+ types: "./dist/configure/index.d.ts",
90
+ import: "./dist/configure/index.js",
91
+ require: "./dist/configure/index.cjs"
92
+ },
93
+ "./internal": {
94
+ types: "./dist/internal.d.ts",
95
+ import: "./dist/internal.js",
96
+ require: "./dist/internal.cjs"
97
+ },
98
+ "./runtime": {
99
+ types: "./dist/runtime/index.d.ts",
100
+ import: "./dist/runtime/index.js",
101
+ require: "./dist/runtime/index.cjs"
102
+ },
103
+ "./browser": {
104
+ types: "./dist/browser/index.d.ts",
105
+ import: "./dist/browser/index.js",
106
+ require: "./dist/browser/index.cjs"
107
+ },
108
+ "./build": {
109
+ types: "./dist/build/index.d.ts",
110
+ import: "./dist/build/index.js",
111
+ require: "./dist/build/index.cjs"
112
+ },
113
+ "./plugins/filesystem": {
114
+ types: "./dist/plugin/filesystem.d.ts",
115
+ import: "./dist/plugin/filesystem.js",
116
+ require: "./dist/plugin/filesystem.cjs"
117
+ },
118
+ "./plugins/dotenv": {
119
+ types: "./dist/plugin/dotenv.d.ts",
120
+ import: "./dist/plugin/dotenv.js",
121
+ require: "./dist/plugin/dotenv.cjs"
122
+ },
123
+ "./plugins/process-env": {
124
+ types: "./dist/plugin/process-env.d.ts",
125
+ import: "./dist/plugin/process-env.js",
126
+ require: "./dist/plugin/process-env.cjs"
127
+ },
128
+ "./plugins/cli-args": {
129
+ types: "./dist/plugin/cli-args.d.ts",
130
+ import: "./dist/plugin/cli-args.js",
131
+ require: "./dist/plugin/cli-args.cjs"
132
+ },
133
+ "./plugins/basic-schema": {
134
+ types: "./dist/plugin/basic-schema.d.ts",
135
+ import: "./dist/plugin/basic-schema.js",
136
+ require: "./dist/plugin/basic-schema.cjs"
137
+ },
138
+ "./plugins/env-export": {
139
+ types: "./dist/plugin/env-export.d.ts",
140
+ import: "./dist/plugin/env-export.js",
141
+ require: "./dist/plugin/env-export.cjs"
142
+ }
143
+ },
144
+ files: [
145
+ "dist"
146
+ ],
147
+ license: "MIT",
148
+ repository: {
149
+ type: "git",
150
+ url: "https://github.com/kitsyai/cnos.git",
151
+ directory: "packages/cnos"
152
+ },
153
+ homepage: "https://github.com/kitsyai/cnos/tree/main/packages/cnos",
154
+ bugs: {
155
+ url: "https://github.com/kitsyai/cnos/issues"
156
+ },
157
+ keywords: [
158
+ "cnos",
159
+ "config",
160
+ "runtime"
161
+ ],
162
+ publishConfig: {
163
+ access: "public"
164
+ },
165
+ dependencies: {
166
+ yaml: "^2.8.3"
167
+ },
168
+ scripts: {
169
+ build: "rimraf dist && tsup --config tsup.config.ts",
170
+ clean: "rimraf dist",
171
+ dev: "tsup --config tsup.config.ts --watch",
172
+ lint: "eslint src test",
173
+ prepack: "pnpm build",
174
+ test: "vitest run",
175
+ typecheck: "tsc -p tsconfig.json --noEmit"
176
+ }
177
+ };
178
+
179
+ // src/createCnos.ts
180
+ async function createCnos2(options = {}) {
181
+ const runtime = await createCnos({
182
+ ...options,
183
+ processEnv: options.processEnv ?? process.env,
184
+ cnosVersion: package_default.version,
185
+ plugins: [...defaultPlugins(), ...options.plugins ?? []]
186
+ });
187
+ setSingletonRuntime(runtime);
188
+ return runtime;
189
+ }
190
+
191
+ export {
192
+ defaultPlugins,
193
+ getSingletonRuntime,
194
+ setSingletonRuntime,
195
+ getSingletonReady,
196
+ setSingletonReady,
197
+ getBootstrappedSecretHydrationRequired,
198
+ setBootstrappedSecretHydrationRequired,
199
+ createCnos2 as createCnos
200
+ };
@@ -2,11 +2,8 @@ import {
2
2
  CnosManifestError,
3
3
  isSecretReference,
4
4
  parseYaml,
5
- readLocalSecret,
6
- resolveSecretPassphrase,
7
- resolveSecretStoreRoot,
8
5
  toPortablePath
9
- } from "./chunk-33ZDYDQJ.js";
6
+ } from "./chunk-DRKDNY4I.js";
10
7
 
11
8
  // ../../plugins/filesystem/src/helpers.ts
12
9
  import { readdir } from "fs/promises";
@@ -98,31 +95,6 @@ function yamlObjectToEntries(document, filePath, namespace, sourceId, workspaceI
98
95
  }
99
96
  }));
100
97
  }
101
- async function resolveSecretValue(value, processEnv) {
102
- if (!isSecretReference(value)) {
103
- return value;
104
- }
105
- if (value.provider === "local") {
106
- const passphrase = resolveSecretPassphrase(value.vault, processEnv);
107
- if (!passphrase) {
108
- return value;
109
- }
110
- return readLocalSecret(
111
- resolveSecretStoreRoot(processEnv),
112
- value.ref,
113
- passphrase,
114
- value.vault
115
- );
116
- }
117
- if (value.provider === "env") {
118
- const resolved = processEnv?.[value.ref];
119
- if (resolved === void 0) {
120
- return value;
121
- }
122
- return resolved;
123
- }
124
- return value;
125
- }
126
98
  function toSecretReferenceMetadata(value) {
127
99
  if (!isSecretReference(value)) {
128
100
  return void 0;
@@ -155,10 +127,8 @@ function createFilesystemSecretsPlugin() {
155
127
  const fileEntries = filesystemSecretsReader(file.relativePath, document, file.workspaceId);
156
128
  for (const entry of fileEntries) {
157
129
  const metadata = toSecretReferenceMetadata(entry.value);
158
- const resolvedValue = await resolveSecretValue(entry.value, context.processEnv);
159
130
  entries.push({
160
131
  ...entry,
161
- value: resolvedValue,
162
132
  ...metadata ? { metadata } : {}
163
133
  });
164
134
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  applySchemaRules
3
- } from "./chunk-33ZDYDQJ.js";
3
+ } from "./chunk-DRKDNY4I.js";
4
4
 
5
5
  // ../../plugins/basic-schema/src/index.ts
6
6
  function createBasicSchemaPlugin() {
@@ -0,0 +1,105 @@
1
+ import {
2
+ isSecretReference
3
+ } from "./chunk-DRKDNY4I.js";
4
+
5
+ // src/runtime/bootstrap.ts
6
+ import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
7
+ var CNOS_GRAPH_ENV_VAR = "__CNOS_GRAPH__";
8
+ var CNOS_SECRET_PAYLOAD_ENV_VAR = "__CNOS_SECRET_PAYLOAD__";
9
+ var CNOS_SESSION_KEY_ENV_VAR = "__CNOS_SESSION_KEY__";
10
+ function serializeRuntimeGraph(graph) {
11
+ const payload = {
12
+ entries: Array.from(graph.entries.values()),
13
+ profile: graph.profile,
14
+ resolvedAt: graph.resolvedAt,
15
+ profileSource: graph.profileSource,
16
+ workspace: graph.workspace
17
+ };
18
+ return JSON.stringify(payload);
19
+ }
20
+ function deserializeRuntimeGraph(source) {
21
+ const payload = JSON.parse(source);
22
+ if (!payload || !Array.isArray(payload.entries) || typeof payload.profile !== "string" || typeof payload.resolvedAt !== "string" || !payload.profileSource || !payload.workspace || typeof payload.workspace.workspaceId !== "string" || !Array.isArray(payload.workspace.workspaceChain) || !Array.isArray(payload.workspace.workspaceRoots)) {
23
+ throw new Error("Invalid CNOS runtime bootstrap payload");
24
+ }
25
+ return {
26
+ entries: new Map(
27
+ payload.entries.map((entry) => [
28
+ entry.key,
29
+ {
30
+ key: entry.key,
31
+ value: entry.value,
32
+ namespace: entry.namespace,
33
+ winner: entry.winner,
34
+ overridden: entry.overridden ?? []
35
+ }
36
+ ])
37
+ ),
38
+ profile: payload.profile,
39
+ resolvedAt: payload.resolvedAt,
40
+ profileSource: payload.profileSource,
41
+ workspace: payload.workspace
42
+ };
43
+ }
44
+ function decryptSecretPayload(serialized, sessionKey) {
45
+ const payload = JSON.parse(serialized);
46
+ if (!payload || typeof payload.iv !== "string" || typeof payload.tag !== "string" || typeof payload.ciphertext !== "string") {
47
+ throw new Error("Invalid CNOS secret payload");
48
+ }
49
+ const key = Buffer.from(sessionKey, "hex");
50
+ const iv = Buffer.from(payload.iv, "base64");
51
+ const tag = Buffer.from(payload.tag, "base64");
52
+ const ciphertext = Buffer.from(payload.ciphertext, "base64");
53
+ const decipher = createDecipheriv("aes-256-gcm", key, iv);
54
+ decipher.setAuthTag(tag);
55
+ const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
56
+ return JSON.parse(plaintext);
57
+ }
58
+ function serializeSecretPayload(values) {
59
+ const key = randomBytes(32);
60
+ const iv = randomBytes(12);
61
+ const cipher = createCipheriv("aes-256-gcm", key, iv);
62
+ const ciphertext = Buffer.concat([cipher.update(JSON.stringify(values), "utf8"), cipher.final()]);
63
+ const tag = cipher.getAuthTag();
64
+ return {
65
+ payload: JSON.stringify({
66
+ iv: iv.toString("base64"),
67
+ tag: tag.toString("base64"),
68
+ ciphertext: ciphertext.toString("base64")
69
+ }),
70
+ sessionKey: key.toString("hex")
71
+ };
72
+ }
73
+ function readRuntimeGraphFromEnv(processEnv = process.env) {
74
+ const serialized = processEnv[CNOS_GRAPH_ENV_VAR];
75
+ if (!serialized) {
76
+ return void 0;
77
+ }
78
+ const graph = deserializeRuntimeGraph(serialized);
79
+ const secretPayload = processEnv[CNOS_SECRET_PAYLOAD_ENV_VAR];
80
+ const sessionKey = processEnv[CNOS_SESSION_KEY_ENV_VAR];
81
+ if (secretPayload && sessionKey) {
82
+ const decrypted = decryptSecretPayload(secretPayload, sessionKey);
83
+ for (const [key, value] of Object.entries(decrypted)) {
84
+ const entry = graph.entries.get(key);
85
+ if (entry) {
86
+ entry.value = value;
87
+ }
88
+ }
89
+ }
90
+ return graph;
91
+ }
92
+ function graphRequiresSecretHydration(graph) {
93
+ return Array.from(graph.entries.values()).some((entry) => entry.namespace === "secret" && isSecretReference(entry.value));
94
+ }
95
+
96
+ export {
97
+ CNOS_GRAPH_ENV_VAR,
98
+ CNOS_SECRET_PAYLOAD_ENV_VAR,
99
+ CNOS_SESSION_KEY_ENV_VAR,
100
+ serializeRuntimeGraph,
101
+ deserializeRuntimeGraph,
102
+ serializeSecretPayload,
103
+ readRuntimeGraphFromEnv,
104
+ graphRequiresSecretHydration
105
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  toEnv,
3
3
  toPublicEnv
4
- } from "./chunk-33ZDYDQJ.js";
4
+ } from "./chunk-DRKDNY4I.js";
5
5
 
6
6
  // ../../plugins/env-export/src/index.ts
7
7
  function createEnvExportPlugin() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  joinConfigPath
3
- } from "./chunk-33ZDYDQJ.js";
3
+ } from "./chunk-DRKDNY4I.js";
4
4
 
5
5
  // ../../plugins/cli-args/src/index.ts
6
6
  var CLI_ARGS_PLUGIN_ID = "@kitsy/cnos/plugins/cli-args";
@@ -2,7 +2,7 @@ import {
2
2
  envVarToLogicalKey,
3
3
  resolveWorkspaceScopedPath,
4
4
  toPortablePath
5
- } from "./chunk-33ZDYDQJ.js";
5
+ } from "./chunk-DRKDNY4I.js";
6
6
 
7
7
  // ../../plugins/dotenv/src/index.ts
8
8
  import { readFile } from "fs/promises";