@happyvertical/smrt-config 0.55.3 → 0.55.4

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/AGENTS.md CHANGED
@@ -29,7 +29,9 @@ Configuration management with cosmiconfig, secret sanitization, and SSG export.
29
29
 
30
30
  ## Key Files
31
31
 
32
- - `src/loader.ts` — cosmiconfig integration and file discovery
32
+ - `src/index.ts` — Node entry: `src/shared.ts` plus `loadConfig()`; `src/browser.ts` — `exports['.'].browser` entry, same surface with a `loadConfig()` that rejects (model roots bundle for browsers, #3625)
33
+ - `src/shared.ts` — the config API (get/set/resolve/clear); must stay free of `loader.ts` (cosmiconfig, jiti, node:fs). Loader state is in `src/loader-state.ts`
34
+ - `src/loader.ts` — cosmiconfig integration and file discovery (Node entry only)
33
35
  - `src/merge.ts` — deep merge logic, runtime config store
34
36
  - `src/export.ts` — sanitization and export formatting (JSON/JS)
35
37
  - `src/runtime-profile.ts` — application runtime presets, validation, capabilities, and diagnostics
@@ -37,6 +39,7 @@ Configuration management with cosmiconfig, secret sanitization, and SSG export.
37
39
 
38
40
  ## Gotchas
39
41
 
42
+ - **Keep `shared.ts` browser-safe**: new API goes in `shared.ts` (both entries export it); only Node I/O belongs in `index.ts`/`loader.ts`. `src/browser.test.ts` checks the two entries export the same names.
40
43
  - **AI credentials are bound to their source's provider**: a lower-priority key/baseUrl is dropped when another provider wins; redacted base URLs show only the origin. **AI keys come from the environment**: the `ai` block names a variable (`apiKeyEnv`); resolver errors/`toJSON()` never contain keys or URL credentials. Core and the chat dev routes use this resolver; agents share its provider key-name map (`getDefaultAIKeyEnvName`) and keep per-tenant secret lookup; do not add new provider-env parsing elsewhere.
41
44
  - **clearCache() is global**: affects all modules sharing the config instance
42
45
  - **SSG export defaults to no secrets**: must explicitly set `includeSecrets: true` to include them
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Browser entry of `@happyvertical/smrt-config` (`exports['.'].browser`).
3
+ *
4
+ * Everything the Node entry exposes except the filesystem loader: model
5
+ * packages read already-loaded config (`getPackageConfig`, `getModuleConfig`,
6
+ * ...) and must bundle for a browser without reaching cosmiconfig, jiti, or
7
+ * `node:fs` (#3625). `loadConfig()` is the one export that cannot work here;
8
+ * it rejects with an explicit error instead of silently returning `{}`. Seed
9
+ * browser config with `setConfig()`.
10
+ */
11
+ import type { LoadConfigOptions, SmrtConfig } from './types.js';
12
+ export * from './shared.js';
13
+ /**
14
+ * Filesystem config discovery is unavailable in a browser build.
15
+ *
16
+ * @throws Always: use `setConfig()` to provide configuration in the browser.
17
+ * @see {@link setConfig}
18
+ */
19
+ export declare function loadConfig(_options?: LoadConfigOptions): Promise<SmrtConfig>;
20
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEhE,cAAc,aAAa,CAAC;AAE5B;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,UAAU,CAAC,CAIrB"}
@@ -0,0 +1,9 @@
1
+ import { A as getDefaultAIKeyEnvName, C as getApplicationRuntimePreset, D as DEFAULT_AI_ENV_PREFIXES, E as AI_PROVIDER_KEY_ENV, F as tryResolveAIProviderConfig, I as withAIAliases, M as redactBaseUrl, N as resolveAIProviderConfig, O as canonicalizeAIConfig, P as toAIClientOptions, S as RuntimeProfileValidationError, T as AIProviderNotConfiguredError, _ as parseExportedConfig, a as getModuleConfig, b as getRuntimeConfig, c as mergeAIConfigLayers, d as resolveConfiguredApplicationRuntime, f as resolveEffectiveApplicationRuntime, g as mergeExportedConfig, h as exportConfig, i as getConfig, j as mergeAIConfigObjects, k as describeAIProviderConfig, l as resolveCliDatabaseConfig, m as tryResolveConfiguredAIProvider, n as defineConfig, o as getPackageConfig, p as setConfig, r as getAIConfigBlock, s as getSiteConfig, t as clearCache, u as resolveConfiguredAIProvider, v as sanitizeConfig, w as resolveApplicationRuntime, x as mergeConfigs, y as clearRuntimeConfig } from "./chunks/shared-B81TOCQq.js";
2
+ //#region src/browser.ts
3
+ async function loadConfig(_options) {
4
+ throw new Error("@happyvertical/smrt-config: loadConfig() reads smrt.config.* from the filesystem and is not available in a browser build. Provide configuration with setConfig() instead.");
5
+ }
6
+ //#endregion
7
+ export { AIProviderNotConfiguredError, AI_PROVIDER_KEY_ENV, DEFAULT_AI_ENV_PREFIXES, RuntimeProfileValidationError, canonicalizeAIConfig, clearCache, clearRuntimeConfig, defineConfig, describeAIProviderConfig, exportConfig, getAIConfigBlock, getApplicationRuntimePreset, getConfig, getDefaultAIKeyEnvName, getModuleConfig, getPackageConfig, getRuntimeConfig, getSiteConfig, loadConfig, mergeAIConfigLayers, mergeAIConfigObjects, mergeConfigs, mergeExportedConfig, parseExportedConfig, redactBaseUrl, resolveAIProviderConfig, resolveApplicationRuntime, resolveCliDatabaseConfig, resolveConfiguredAIProvider, resolveConfiguredApplicationRuntime, resolveEffectiveApplicationRuntime, sanitizeConfig, setConfig, toAIClientOptions, tryResolveAIProviderConfig, tryResolveConfiguredAIProvider, withAIAliases };
8
+
9
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * Browser entry of `@happyvertical/smrt-config` (`exports['.'].browser`).\n *\n * Everything the Node entry exposes except the filesystem loader: model\n * packages read already-loaded config (`getPackageConfig`, `getModuleConfig`,\n * ...) and must bundle for a browser without reaching cosmiconfig, jiti, or\n * `node:fs` (#3625). `loadConfig()` is the one export that cannot work here;\n * it rejects with an explicit error instead of silently returning `{}`. Seed\n * browser config with `setConfig()`.\n */\nimport type { LoadConfigOptions, SmrtConfig } from './types.js';\n\nexport * from './shared.js';\n\n/**\n * Filesystem config discovery is unavailable in a browser build.\n *\n * @throws Always: use `setConfig()` to provide configuration in the browser.\n * @see {@link setConfig}\n */\nexport async function loadConfig(\n _options?: LoadConfigOptions,\n): Promise<SmrtConfig> {\n throw new Error(\n '@happyvertical/smrt-config: loadConfig() reads smrt.config.* from the filesystem and is not available in a browser build. Provide configuration with setConfig() instead.',\n );\n}\n"],"mappings":";;AAoBA,eAAsB,WACpB,UACqB;CACrB,MAAM,IAAI,MACR,2KACF;AACF"}