@kitsy/cnos 1.3.0 → 1.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.
Files changed (58) hide show
  1. package/dist/build/index.cjs +102 -9
  2. package/dist/build/index.d.cts +1 -1
  3. package/dist/build/index.d.ts +1 -1
  4. package/dist/build/index.js +8 -8
  5. package/dist/{chunk-DRKDNY4I.js → chunk-APIU4GTB.js} +14 -4
  6. package/dist/{chunk-K6QYI2T4.js → chunk-EQSKV3DP.js} +1 -1
  7. package/dist/{chunk-JDII6O72.js → chunk-FWJC4Y2D.js} +1 -1
  8. package/dist/{chunk-QTKXPY3N.js → chunk-HMM76UYZ.js} +1 -1
  9. package/dist/{chunk-OOKFRWTN.js → chunk-J4K4JUJL.js} +1 -1
  10. package/dist/{chunk-EDCLLCNL.js → chunk-JSBVYK2T.js} +8 -8
  11. package/dist/{chunk-E7SE6N26.js → chunk-LJD4SM32.js} +3 -3
  12. package/dist/{chunk-FC3IV6A7.js → chunk-T6Y57KTT.js} +20 -1
  13. package/dist/chunk-WCHX2QFY.js +115 -0
  14. package/dist/{chunk-OWUZQ4OH.js → chunk-ZTPSFXWP.js} +1 -1
  15. package/dist/configure/index.cjs +102 -9
  16. package/dist/configure/index.d.cts +3 -3
  17. package/dist/configure/index.d.ts +3 -3
  18. package/dist/configure/index.js +8 -8
  19. package/dist/{envNaming-Dy3WYiGK.d.ts → envNaming-Dvm_LP2D.d.ts} +1 -1
  20. package/dist/{envNaming-D6k66myh.d.cts → envNaming-S4B-dHUx.d.cts} +1 -1
  21. package/dist/index.cjs +102 -9
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +10 -10
  25. package/dist/internal.cjs +14 -2
  26. package/dist/internal.d.cts +5 -4
  27. package/dist/internal.d.ts +5 -4
  28. package/dist/internal.js +10 -3
  29. package/dist/plugin/basic-schema.d.cts +1 -1
  30. package/dist/plugin/basic-schema.d.ts +1 -1
  31. package/dist/plugin/basic-schema.js +2 -2
  32. package/dist/plugin/cli-args.d.cts +1 -1
  33. package/dist/plugin/cli-args.d.ts +1 -1
  34. package/dist/plugin/cli-args.js +2 -2
  35. package/dist/plugin/dotenv.d.cts +2 -2
  36. package/dist/plugin/dotenv.d.ts +2 -2
  37. package/dist/plugin/dotenv.js +2 -2
  38. package/dist/plugin/env-export.d.cts +2 -2
  39. package/dist/plugin/env-export.d.ts +2 -2
  40. package/dist/plugin/env-export.js +2 -2
  41. package/dist/plugin/filesystem.cjs +19 -0
  42. package/dist/plugin/filesystem.d.cts +1 -1
  43. package/dist/plugin/filesystem.d.ts +1 -1
  44. package/dist/plugin/filesystem.js +2 -2
  45. package/dist/plugin/process-env.cjs +74 -7
  46. package/dist/plugin/process-env.d.cts +4 -3
  47. package/dist/plugin/process-env.d.ts +4 -3
  48. package/dist/plugin/process-env.js +6 -4
  49. package/dist/{plugin-CyNkf7Dm.d.cts → plugin-B4xwySxw.d.cts} +2 -1
  50. package/dist/{plugin-CyNkf7Dm.d.ts → plugin-B4xwySxw.d.ts} +2 -1
  51. package/dist/runtime/index.cjs +102 -9
  52. package/dist/runtime/index.d.cts +1 -1
  53. package/dist/runtime/index.d.ts +1 -1
  54. package/dist/runtime/index.js +10 -10
  55. package/dist/{toPublicEnv-D2PZkaN-.d.ts → toPublicEnv-CvhGAfsB.d.ts} +1 -1
  56. package/dist/{toPublicEnv-Cz72m6y0.d.cts → toPublicEnv-ggmphZFs.d.cts} +1 -1
  57. package/package.json +1 -1
  58. package/dist/chunk-CDXJISGB.js +0 -49
@@ -294,6 +294,11 @@ var DEFAULT_NAMESPACES = {
294
294
  shareable: false,
295
295
  readonly: true
296
296
  },
297
+ process: {
298
+ kind: "system",
299
+ shareable: false,
300
+ readonly: true
301
+ },
297
302
  public: {
298
303
  kind: "projection",
299
304
  source: "promote",
@@ -953,12 +958,15 @@ async function exists2(targetPath) {
953
958
  return false;
954
959
  }
955
960
  }
956
- async function resolveLocalWorkspaceRoot(manifestRoot, workspaceId) {
961
+ async function resolveLocalWorkspaceRoot(manifestRoot, workspaceId, manifest) {
957
962
  const workspaceRoot = import_node_path5.default.join(manifestRoot, "workspaces", workspaceId);
958
963
  if (await exists2(workspaceRoot)) {
959
964
  return workspaceRoot;
960
965
  }
961
- const legacyMarkers = ["values", "secrets", "env", "profiles"].map(
966
+ const customDataNamespaceRoots = Object.entries(manifest.namespaces).filter(
967
+ ([namespace, definition]) => namespace !== "value" && namespace !== "secret" && definition.kind === "data" && !definition.sensitive
968
+ ).map(([namespace]) => namespace);
969
+ const legacyMarkers = ["values", "secrets", "env", "profiles", ...customDataNamespaceRoots].map(
962
970
  (segment) => import_node_path5.default.join(manifestRoot, segment)
963
971
  );
964
972
  if ((await Promise.all(legacyMarkers.map((marker) => exists2(marker)))).some(Boolean)) {
@@ -1045,7 +1053,7 @@ async function resolveWorkspaceContext(manifest, options) {
1045
1053
  workspaceRoots.push({
1046
1054
  scope: "local",
1047
1055
  workspaceId: chainWorkspaceId,
1048
- path: await resolveLocalWorkspaceRoot(options.manifestRoot, chainWorkspaceId)
1056
+ path: await resolveLocalWorkspaceRoot(options.manifestRoot, chainWorkspaceId, manifest)
1049
1057
  });
1050
1058
  }
1051
1059
  return {
@@ -1210,6 +1218,7 @@ async function runPipeline(options) {
1210
1218
  const collectedEntries = await Promise.all(
1211
1219
  options.plugins.map(
1212
1220
  (plugin) => plugin.load({
1221
+ manifest: options.manifest,
1213
1222
  manifestConfig: {
1214
1223
  ...options.manifest.sources[plugin.id] ?? {},
1215
1224
  envMapping: options.manifest.envMapping
@@ -2308,7 +2317,7 @@ function envVarToLogicalKey(envVar, config = {}) {
2308
2317
  // package.json
2309
2318
  var package_default = {
2310
2319
  name: "@kitsy/cnos",
2311
- version: "1.3.0",
2320
+ version: "1.4.0",
2312
2321
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
2313
2322
  type: "module",
2314
2323
  main: "./dist/index.cjs",
@@ -2782,11 +2791,30 @@ function createFilesystemValuesPlugin() {
2782
2791
  sourceRoot,
2783
2792
  context.profileActivation.values
2784
2793
  );
2794
+ const customNamespaces = Object.entries(context.manifest.namespaces).filter(
2795
+ ([namespace, definition]) => namespace !== "value" && namespace !== "secret" && definition.kind === "data" && !definition.sensitive
2796
+ ).map(([namespace]) => namespace);
2785
2797
  const entries = [];
2786
2798
  for (const file of files) {
2787
2799
  const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
2788
2800
  entries.push(...filesystemValuesReader(file.relativePath, document, file.workspaceId));
2789
2801
  }
2802
+ for (const namespace of customNamespaces) {
2803
+ const layers = [
2804
+ namespace,
2805
+ ...context.profileChain.filter((profile) => profile !== "base").map((profile) => `profiles/${profile}/${namespace}`)
2806
+ ];
2807
+ const namespaceFiles = await collectFilesystemLayerFiles(
2808
+ context.manifestRoot,
2809
+ context.workspace.workspaceRoots,
2810
+ sourceRoot,
2811
+ layers
2812
+ );
2813
+ for (const file of namespaceFiles) {
2814
+ const document = await (0, import_promises13.readFile)(file.absolutePath, "utf8");
2815
+ entries.push(...yamlObjectToEntries(document, file.relativePath, namespace, "filesystem-values", file.workspaceId));
2816
+ }
2817
+ }
2790
2818
  return entries;
2791
2819
  }
2792
2820
  };
@@ -2794,6 +2822,11 @@ function createFilesystemValuesPlugin() {
2794
2822
 
2795
2823
  // ../../plugins/process-env/src/index.ts
2796
2824
  var PROCESS_ENV_PLUGIN_ID = "@kitsy/cnos/plugins/process-env";
2825
+ var PROCESS_GRAPH_OMIT = /* @__PURE__ */ new Set([
2826
+ "__CNOS_GRAPH__",
2827
+ "__CNOS_SECRET_PAYLOAD__",
2828
+ "__CNOS_SESSION_KEY__"
2829
+ ]);
2797
2830
  function processEnvEntriesFromObject(env, mapping = {}, workspaceId = "default") {
2798
2831
  return Object.entries(env).flatMap(([envVar, value]) => {
2799
2832
  if (typeof value !== "string") {
@@ -2818,17 +2851,77 @@ function processEnvEntriesFromObject(env, mapping = {}, workspaceId = "default")
2818
2851
  ];
2819
2852
  });
2820
2853
  }
2854
+ function processNamespaceEntriesFromContext(env, workspaceId = "default") {
2855
+ const envEntries = Object.entries(env).filter((entry) => typeof entry[1] === "string").filter(([envVar]) => !PROCESS_GRAPH_OMIT.has(envVar)).map(([envVar, value]) => ({
2856
+ key: `process.env.${envVar}`,
2857
+ value,
2858
+ namespace: "process",
2859
+ sourceId: "process-runtime",
2860
+ pluginId: PROCESS_ENV_PLUGIN_ID,
2861
+ workspaceId,
2862
+ origin: {
2863
+ envVar
2864
+ }
2865
+ }));
2866
+ const runtimeEntries = [
2867
+ {
2868
+ key: "process.cwd",
2869
+ value: process.cwd(),
2870
+ namespace: "process",
2871
+ sourceId: "process-runtime",
2872
+ pluginId: PROCESS_ENV_PLUGIN_ID,
2873
+ workspaceId
2874
+ },
2875
+ {
2876
+ key: "process.platform",
2877
+ value: process.platform,
2878
+ namespace: "process",
2879
+ sourceId: "process-runtime",
2880
+ pluginId: PROCESS_ENV_PLUGIN_ID,
2881
+ workspaceId
2882
+ },
2883
+ {
2884
+ key: "process.arch",
2885
+ value: process.arch,
2886
+ namespace: "process",
2887
+ sourceId: "process-runtime",
2888
+ pluginId: PROCESS_ENV_PLUGIN_ID,
2889
+ workspaceId
2890
+ },
2891
+ {
2892
+ key: "process.node.version",
2893
+ value: process.version,
2894
+ namespace: "process",
2895
+ sourceId: "process-runtime",
2896
+ pluginId: PROCESS_ENV_PLUGIN_ID,
2897
+ workspaceId
2898
+ },
2899
+ {
2900
+ key: "process.args.raw",
2901
+ value: process.argv.slice(2),
2902
+ namespace: "process",
2903
+ sourceId: "process-runtime",
2904
+ pluginId: PROCESS_ENV_PLUGIN_ID,
2905
+ workspaceId
2906
+ }
2907
+ ];
2908
+ return [...runtimeEntries, ...envEntries];
2909
+ }
2821
2910
  function createProcessEnvPlugin() {
2822
2911
  return {
2823
2912
  id: "process-env",
2824
2913
  kind: "loader",
2825
2914
  async load(context) {
2826
2915
  const config = context.manifestConfig;
2827
- return processEnvEntriesFromObject(
2828
- context.processEnv ?? process.env,
2829
- config.envMapping,
2830
- context.workspace.workspaceId
2831
- );
2916
+ const env = context.processEnv ?? process.env;
2917
+ return [
2918
+ ...processEnvEntriesFromObject(
2919
+ env,
2920
+ config.envMapping,
2921
+ context.workspace.workspaceId
2922
+ ),
2923
+ ...processNamespaceEntriesFromContext(env, context.workspace.workspaceId)
2924
+ ];
2832
2925
  }
2833
2926
  };
2834
2927
  }
@@ -1,4 +1,4 @@
1
- import { C as CnosCreateOptions } from '../plugin-CyNkf7Dm.cjs';
1
+ import { C as CnosCreateOptions } from '../plugin-B4xwySxw.cjs';
2
2
 
3
3
  declare function resolveBrowserData(options?: CnosCreateOptions): Promise<Record<string, unknown>>;
4
4
 
@@ -1,4 +1,4 @@
1
- import { C as CnosCreateOptions } from '../plugin-CyNkf7Dm.js';
1
+ import { C as CnosCreateOptions } from '../plugin-B4xwySxw.js';
2
2
 
3
3
  declare function resolveBrowserData(options?: CnosCreateOptions): Promise<Record<string, unknown>>;
4
4
 
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createCnos
3
- } from "../chunk-EDCLLCNL.js";
4
- import "../chunk-OOKFRWTN.js";
5
- import "../chunk-FC3IV6A7.js";
6
- import "../chunk-CDXJISGB.js";
7
- import "../chunk-JDII6O72.js";
8
- import "../chunk-OWUZQ4OH.js";
9
- import "../chunk-QTKXPY3N.js";
10
- import "../chunk-DRKDNY4I.js";
3
+ } from "../chunk-JSBVYK2T.js";
4
+ import "../chunk-J4K4JUJL.js";
5
+ import "../chunk-T6Y57KTT.js";
6
+ import "../chunk-WCHX2QFY.js";
7
+ import "../chunk-FWJC4Y2D.js";
8
+ import "../chunk-ZTPSFXWP.js";
9
+ import "../chunk-HMM76UYZ.js";
10
+ import "../chunk-APIU4GTB.js";
11
11
 
12
12
  // src/build/index.ts
13
13
  async function resolveBrowserData(options = {}) {
@@ -234,7 +234,7 @@ function resolveWorkspaceScopedPath(workspaceRoot, template, tokens) {
234
234
  return path.resolve(workspaceRoot, interpolated);
235
235
  }
236
236
  function resolveNamespaceDirectory(workspaceRoot, namespace, profile) {
237
- const rootFolder = namespace === "value" ? "values" : "secrets";
237
+ const rootFolder = namespace === "value" ? "values" : namespace === "secret" ? "secrets" : namespace;
238
238
  if (profile && profile !== "base") {
239
239
  return path.resolve(workspaceRoot, "profiles", profile, rootFolder);
240
240
  }
@@ -303,6 +303,11 @@ var DEFAULT_NAMESPACES = {
303
303
  shareable: false,
304
304
  readonly: true
305
305
  },
306
+ process: {
307
+ kind: "system",
308
+ shareable: false,
309
+ readonly: true
310
+ },
306
311
  public: {
307
312
  kind: "projection",
308
313
  source: "promote",
@@ -1997,12 +2002,15 @@ async function exists3(targetPath) {
1997
2002
  return false;
1998
2003
  }
1999
2004
  }
2000
- async function resolveLocalWorkspaceRoot(manifestRoot, workspaceId) {
2005
+ async function resolveLocalWorkspaceRoot(manifestRoot, workspaceId, manifest) {
2001
2006
  const workspaceRoot = path9.join(manifestRoot, "workspaces", workspaceId);
2002
2007
  if (await exists3(workspaceRoot)) {
2003
2008
  return workspaceRoot;
2004
2009
  }
2005
- const legacyMarkers = ["values", "secrets", "env", "profiles"].map(
2010
+ const customDataNamespaceRoots = Object.entries(manifest.namespaces).filter(
2011
+ ([namespace, definition]) => namespace !== "value" && namespace !== "secret" && definition.kind === "data" && !definition.sensitive
2012
+ ).map(([namespace]) => namespace);
2013
+ const legacyMarkers = ["values", "secrets", "env", "profiles", ...customDataNamespaceRoots].map(
2006
2014
  (segment) => path9.join(manifestRoot, segment)
2007
2015
  );
2008
2016
  if ((await Promise.all(legacyMarkers.map((marker) => exists3(marker)))).some(Boolean)) {
@@ -2089,7 +2097,7 @@ async function resolveWorkspaceContext(manifest, options) {
2089
2097
  workspaceRoots.push({
2090
2098
  scope: "local",
2091
2099
  workspaceId: chainWorkspaceId,
2092
- path: await resolveLocalWorkspaceRoot(options.manifestRoot, chainWorkspaceId)
2100
+ path: await resolveLocalWorkspaceRoot(options.manifestRoot, chainWorkspaceId, manifest)
2093
2101
  });
2094
2102
  }
2095
2103
  return {
@@ -2254,6 +2262,7 @@ async function runPipeline(options) {
2254
2262
  const collectedEntries = await Promise.all(
2255
2263
  options.plugins.map(
2256
2264
  (plugin) => plugin.load({
2265
+ manifest: options.manifest,
2257
2266
  manifestConfig: {
2258
2267
  ...options.manifest.sources[plugin.id] ?? {},
2259
2268
  envMapping: options.manifest.envMapping
@@ -2571,6 +2580,7 @@ export {
2571
2580
  parseYaml,
2572
2581
  stringifyYaml,
2573
2582
  loadManifest,
2583
+ getNamespaceDefinition,
2574
2584
  ensureProjectionAllowed,
2575
2585
  applySchemaRules,
2576
2586
  writeVaultSessionKey,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSecretReference
3
- } from "./chunk-DRKDNY4I.js";
3
+ } from "./chunk-APIU4GTB.js";
4
4
 
5
5
  // src/runtime/bootstrap.ts
6
6
  import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  applySchemaRules
3
- } from "./chunk-DRKDNY4I.js";
3
+ } from "./chunk-APIU4GTB.js";
4
4
 
5
5
  // ../../plugins/basic-schema/src/index.ts
6
6
  function createBasicSchemaPlugin() {
@@ -2,7 +2,7 @@ import {
2
2
  envVarToLogicalKey,
3
3
  resolveWorkspaceScopedPath,
4
4
  toPortablePath
5
- } from "./chunk-DRKDNY4I.js";
5
+ } from "./chunk-APIU4GTB.js";
6
6
 
7
7
  // ../../plugins/dotenv/src/index.ts
8
8
  import { readFile } from "fs/promises";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  toEnv,
3
3
  toPublicEnv
4
- } from "./chunk-DRKDNY4I.js";
4
+ } from "./chunk-APIU4GTB.js";
5
5
 
6
6
  // ../../plugins/env-export/src/index.ts
7
7
  function createEnvExportPlugin() {
@@ -1,27 +1,27 @@
1
1
  import {
2
2
  createEnvExportPlugin,
3
3
  createPublicEnvExportPlugin
4
- } from "./chunk-OOKFRWTN.js";
4
+ } from "./chunk-J4K4JUJL.js";
5
5
  import {
6
6
  createFilesystemSecretsPlugin,
7
7
  createFilesystemValuesPlugin
8
- } from "./chunk-FC3IV6A7.js";
8
+ } from "./chunk-T6Y57KTT.js";
9
9
  import {
10
10
  createProcessEnvPlugin
11
- } from "./chunk-CDXJISGB.js";
11
+ } from "./chunk-WCHX2QFY.js";
12
12
  import {
13
13
  createBasicSchemaPlugin
14
- } from "./chunk-JDII6O72.js";
14
+ } from "./chunk-FWJC4Y2D.js";
15
15
  import {
16
16
  createCliArgsPlugin
17
- } from "./chunk-OWUZQ4OH.js";
17
+ } from "./chunk-ZTPSFXWP.js";
18
18
  import {
19
19
  createDotenvPlugin
20
- } from "./chunk-QTKXPY3N.js";
20
+ } from "./chunk-HMM76UYZ.js";
21
21
  import {
22
22
  createCnos,
23
23
  createProvenanceInspector
24
- } from "./chunk-DRKDNY4I.js";
24
+ } from "./chunk-APIU4GTB.js";
25
25
 
26
26
  // src/defaultPlugins.ts
27
27
  function defaultPlugins() {
@@ -68,7 +68,7 @@ function setBootstrappedSecretHydrationRequired(value) {
68
68
  // package.json
69
69
  var package_default = {
70
70
  name: "@kitsy/cnos",
71
- version: "1.3.0",
71
+ version: "1.4.0",
72
72
  description: "Batteries-included CNOS runtime package wired with the official plugins.",
73
73
  type: "module",
74
74
  main: "./dist/index.cjs",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  graphRequiresSecretHydration,
3
3
  readRuntimeGraphFromEnv
4
- } from "./chunk-K6QYI2T4.js";
4
+ } from "./chunk-EQSKV3DP.js";
5
5
  import {
6
6
  createCnos,
7
7
  getBootstrappedSecretHydrationRequired,
@@ -10,7 +10,7 @@ import {
10
10
  setBootstrappedSecretHydrationRequired,
11
11
  setSingletonReady,
12
12
  setSingletonRuntime
13
- } from "./chunk-EDCLLCNL.js";
13
+ } from "./chunk-JSBVYK2T.js";
14
14
  import {
15
15
  inspectValue,
16
16
  readOrValue,
@@ -20,7 +20,7 @@ import {
20
20
  toLogicalKey,
21
21
  toNamespaceObject,
22
22
  toPublicEnv
23
- } from "./chunk-DRKDNY4I.js";
23
+ } from "./chunk-APIU4GTB.js";
24
24
 
25
25
  // src/runtime/index.ts
26
26
  var NOT_READY_MESSAGE = "CNOS not initialized. Call await cnos.ready() or use cnos run.";
@@ -3,7 +3,7 @@ import {
3
3
  isSecretReference,
4
4
  parseYaml,
5
5
  toPortablePath
6
- } from "./chunk-DRKDNY4I.js";
6
+ } from "./chunk-APIU4GTB.js";
7
7
 
8
8
  // ../../plugins/filesystem/src/helpers.ts
9
9
  import { readdir } from "fs/promises";
@@ -155,11 +155,30 @@ function createFilesystemValuesPlugin() {
155
155
  sourceRoot,
156
156
  context.profileActivation.values
157
157
  );
158
+ const customNamespaces = Object.entries(context.manifest.namespaces).filter(
159
+ ([namespace, definition]) => namespace !== "value" && namespace !== "secret" && definition.kind === "data" && !definition.sensitive
160
+ ).map(([namespace]) => namespace);
158
161
  const entries = [];
159
162
  for (const file of files) {
160
163
  const document = await readFile2(file.absolutePath, "utf8");
161
164
  entries.push(...filesystemValuesReader(file.relativePath, document, file.workspaceId));
162
165
  }
166
+ for (const namespace of customNamespaces) {
167
+ const layers = [
168
+ namespace,
169
+ ...context.profileChain.filter((profile) => profile !== "base").map((profile) => `profiles/${profile}/${namespace}`)
170
+ ];
171
+ const namespaceFiles = await collectFilesystemLayerFiles(
172
+ context.manifestRoot,
173
+ context.workspace.workspaceRoots,
174
+ sourceRoot,
175
+ layers
176
+ );
177
+ for (const file of namespaceFiles) {
178
+ const document = await readFile2(file.absolutePath, "utf8");
179
+ entries.push(...yamlObjectToEntries(document, file.relativePath, namespace, "filesystem-values", file.workspaceId));
180
+ }
181
+ }
163
182
  return entries;
164
183
  }
165
184
  };
@@ -0,0 +1,115 @@
1
+ import {
2
+ envVarToLogicalKey
3
+ } from "./chunk-APIU4GTB.js";
4
+
5
+ // ../../plugins/process-env/src/index.ts
6
+ var PROCESS_ENV_PLUGIN_ID = "@kitsy/cnos/plugins/process-env";
7
+ var PROCESS_GRAPH_OMIT = /* @__PURE__ */ new Set([
8
+ "__CNOS_GRAPH__",
9
+ "__CNOS_SECRET_PAYLOAD__",
10
+ "__CNOS_SESSION_KEY__"
11
+ ]);
12
+ function processEnvEntriesFromObject(env, mapping = {}, workspaceId = "default") {
13
+ return Object.entries(env).flatMap(([envVar, value]) => {
14
+ if (typeof value !== "string") {
15
+ return [];
16
+ }
17
+ const logicalKey = envVarToLogicalKey(envVar, mapping);
18
+ if (!logicalKey) {
19
+ return [];
20
+ }
21
+ return [
22
+ {
23
+ key: logicalKey,
24
+ value,
25
+ namespace: logicalKey.startsWith("secret.") ? "secret" : "value",
26
+ sourceId: "process-env",
27
+ pluginId: PROCESS_ENV_PLUGIN_ID,
28
+ workspaceId,
29
+ origin: {
30
+ envVar
31
+ }
32
+ }
33
+ ];
34
+ });
35
+ }
36
+ function processNamespaceEntriesFromContext(env, workspaceId = "default") {
37
+ const envEntries = Object.entries(env).filter((entry) => typeof entry[1] === "string").filter(([envVar]) => !PROCESS_GRAPH_OMIT.has(envVar)).map(([envVar, value]) => ({
38
+ key: `process.env.${envVar}`,
39
+ value,
40
+ namespace: "process",
41
+ sourceId: "process-runtime",
42
+ pluginId: PROCESS_ENV_PLUGIN_ID,
43
+ workspaceId,
44
+ origin: {
45
+ envVar
46
+ }
47
+ }));
48
+ const runtimeEntries = [
49
+ {
50
+ key: "process.cwd",
51
+ value: process.cwd(),
52
+ namespace: "process",
53
+ sourceId: "process-runtime",
54
+ pluginId: PROCESS_ENV_PLUGIN_ID,
55
+ workspaceId
56
+ },
57
+ {
58
+ key: "process.platform",
59
+ value: process.platform,
60
+ namespace: "process",
61
+ sourceId: "process-runtime",
62
+ pluginId: PROCESS_ENV_PLUGIN_ID,
63
+ workspaceId
64
+ },
65
+ {
66
+ key: "process.arch",
67
+ value: process.arch,
68
+ namespace: "process",
69
+ sourceId: "process-runtime",
70
+ pluginId: PROCESS_ENV_PLUGIN_ID,
71
+ workspaceId
72
+ },
73
+ {
74
+ key: "process.node.version",
75
+ value: process.version,
76
+ namespace: "process",
77
+ sourceId: "process-runtime",
78
+ pluginId: PROCESS_ENV_PLUGIN_ID,
79
+ workspaceId
80
+ },
81
+ {
82
+ key: "process.args.raw",
83
+ value: process.argv.slice(2),
84
+ namespace: "process",
85
+ sourceId: "process-runtime",
86
+ pluginId: PROCESS_ENV_PLUGIN_ID,
87
+ workspaceId
88
+ }
89
+ ];
90
+ return [...runtimeEntries, ...envEntries];
91
+ }
92
+ function createProcessEnvPlugin() {
93
+ return {
94
+ id: "process-env",
95
+ kind: "loader",
96
+ async load(context) {
97
+ const config = context.manifestConfig;
98
+ const env = context.processEnv ?? process.env;
99
+ return [
100
+ ...processEnvEntriesFromObject(
101
+ env,
102
+ config.envMapping,
103
+ context.workspace.workspaceId
104
+ ),
105
+ ...processNamespaceEntriesFromContext(env, context.workspace.workspaceId)
106
+ ];
107
+ }
108
+ };
109
+ }
110
+
111
+ export {
112
+ processEnvEntriesFromObject,
113
+ processNamespaceEntriesFromContext,
114
+ createProcessEnvPlugin
115
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  joinConfigPath
3
- } from "./chunk-DRKDNY4I.js";
3
+ } from "./chunk-APIU4GTB.js";
4
4
 
5
5
  // ../../plugins/cli-args/src/index.ts
6
6
  var CLI_ARGS_PLUGIN_ID = "@kitsy/cnos/plugins/cli-args";