@askdb/config 1.0.0-beta.16 → 1.0.0-beta.18

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 (69) hide show
  1. package/README.md +15 -4
  2. package/dist/ai-env.d.ts +31 -0
  3. package/dist/ai-env.d.ts.map +1 -0
  4. package/dist/ai-env.js +88 -0
  5. package/dist/ai-env.js.map +1 -0
  6. package/dist/bootstrap.d.ts +6 -4
  7. package/dist/bootstrap.d.ts.map +1 -1
  8. package/dist/bootstrap.js +6 -17
  9. package/dist/bootstrap.js.map +1 -1
  10. package/dist/defaults.d.ts +7 -20
  11. package/dist/defaults.d.ts.map +1 -1
  12. package/dist/defaults.js +7 -58
  13. package/dist/defaults.js.map +1 -1
  14. package/dist/env.d.ts +2 -1
  15. package/dist/env.d.ts.map +1 -1
  16. package/dist/env.js +2 -1
  17. package/dist/env.js.map +1 -1
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/load-merge.js +1 -1
  23. package/dist/load-merge.js.map +1 -1
  24. package/dist/projection.d.ts +12 -2
  25. package/dist/projection.d.ts.map +1 -1
  26. package/dist/projection.js +18 -6
  27. package/dist/projection.js.map +1 -1
  28. package/dist/resolve.d.ts +36 -0
  29. package/dist/resolve.d.ts.map +1 -0
  30. package/dist/{normalize.js → resolve.js} +375 -8
  31. package/dist/resolve.js.map +1 -0
  32. package/dist/runtime-config.d.ts +5 -173
  33. package/dist/runtime-config.d.ts.map +1 -1
  34. package/dist/runtime-config.js +18 -222
  35. package/dist/runtime-config.js.map +1 -1
  36. package/dist/runtime-store.d.ts +9 -6
  37. package/dist/runtime-store.d.ts.map +1 -1
  38. package/dist/runtime-store.js +9 -11
  39. package/dist/runtime-store.js.map +1 -1
  40. package/dist/runtime-types.d.ts +176 -0
  41. package/dist/runtime-types.d.ts.map +1 -0
  42. package/dist/runtime-types.js +2 -0
  43. package/dist/runtime-types.js.map +1 -0
  44. package/dist/scaffold/ai.d.ts +3 -0
  45. package/dist/scaffold/ai.d.ts.map +1 -1
  46. package/dist/scaffold/ai.js +3 -0
  47. package/dist/scaffold/ai.js.map +1 -1
  48. package/dist/scaffold/index.d.ts +12 -3
  49. package/dist/scaffold/index.d.ts.map +1 -1
  50. package/dist/scaffold/index.js +10 -3
  51. package/dist/scaffold/index.js.map +1 -1
  52. package/dist/scaffold/package-manager.d.ts +93 -0
  53. package/dist/scaffold/package-manager.d.ts.map +1 -0
  54. package/dist/scaffold/package-manager.js +200 -0
  55. package/dist/scaffold/package-manager.js.map +1 -0
  56. package/dist/scaffold/plan.d.ts +110 -0
  57. package/dist/scaffold/plan.d.ts.map +1 -0
  58. package/dist/scaffold/plan.js +301 -0
  59. package/dist/scaffold/plan.js.map +1 -0
  60. package/dist/types.d.ts +6 -13
  61. package/dist/types.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/dist/flatten.d.ts +0 -14
  64. package/dist/flatten.d.ts.map +0 -1
  65. package/dist/flatten.js +0 -255
  66. package/dist/flatten.js.map +0 -1
  67. package/dist/normalize.d.ts +0 -58
  68. package/dist/normalize.d.ts.map +0 -1
  69. package/dist/normalize.js.map +0 -1
@@ -1,178 +1,10 @@
1
- import type { AskDbDialectId, AskDbIntrospectionProvider, AskDbRagStore, AskDbStudioExecuteProvider } from "./constants.js";
2
- import type { AskDbConfig } from "./types.js";
3
- /** One resolved `ai` section: its provider, the connection it uses, its model, and an env view built from that connection only. */
4
- export type AskDbRuntimeAiSection = {
5
- provider: string;
6
- /** Connection name within `ai.providerConfig.<provider>`. */
7
- connection: string;
8
- model: string | undefined;
9
- /** `AiEnv` for `@askdb/ai` registry calls, built from this section's connection only. */
10
- env: Record<string, string | undefined>;
11
- };
12
- /**
13
- * Typed AI runtime settings for `@askdb/core` (not `process.env`).
14
- */
15
- export type AskDbRuntimeAiConfig = {
16
- /**
17
- * Flat env-shaped map built from the runtime snapshot: the language view plus every other
18
- * canonical key. Pass to `@askdb/ai` registry methods such as `resolveAiConfig` and
19
- * `createLanguageModelFromEnv`.
20
- */
21
- aiEnv: Record<string, string | undefined>;
22
- /** `ai.language`: the language model. `model` is undefined only for a custom provider with no model set. */
23
- language: AskDbRuntimeAiSection & {
24
- modelFamily: string | undefined;
25
- };
26
- /**
27
- * `ai.embedding`: the embedding model. Undefined unless `rag.embedder` is `"ai"`. Pass `env`
28
- * to `resolveEmbeddingConfig` / `createEmbeddingModelFromEnv`, and `{ dimensions }` as the
29
- * latter's options: `env` holds the connection and model, not the width.
30
- */
31
- embedding: (AskDbRuntimeAiSection & {
32
- model: string;
33
- /**
34
- * `ai.embedding.dimensions`: the vector size to request from the provider. Undefined
35
- * leaves the width to the model; `detectEmbeddingDimensions` in `@askdb/rag` learns it.
36
- */
37
- dimensions: number | undefined;
38
- }) | undefined;
39
- };
40
- /**
41
- * OpenAI embedder settings for the `askdb-rag` CLI. Filled from `ai.embedding` when its provider
42
- * is `openai`; otherwise only from the OpenAI language connection.
43
- */
44
- export type AskDbRuntimeRagEmbedderConfig = {
45
- apiKey: string | undefined;
46
- baseURL: string | undefined;
47
- model: string | undefined;
48
- };
49
- export type AskDbRuntimeRagConfig = {
50
- embedder: AskDbRuntimeRagEmbedderConfig;
51
- /** `rag.store`, or `"memory"` when the config has no `rag` block. Read this rather than `structured.rag`, which is `undefined` when the block is omitted. */
52
- store: AskDbRagStore;
53
- /** `rag.storeConfig` as written, with no defaults filled in; `{}` when the config has no `rag` block or the block has no `storeConfig`. */
54
- storeConfig: NonNullable<AskDbConfig["rag"]>["storeConfig"];
55
- };
56
- export type AskDbRuntimeLoggingConfig = {
57
- level: string | undefined;
58
- correlationId: string | undefined;
59
- logFile: string | undefined;
60
- logStdout: boolean;
61
- };
62
- export type AskDbRuntimeHttpApiConfig = {
63
- listen: {
64
- port: number;
65
- host: string;
66
- };
67
- /** Whether `POST /ask` accepts a per-request `schemaJson` override. Default `false`. */
68
- allowSchemaOverride: boolean;
69
- /** Model-call timeout per `POST /ask` request, in milliseconds (1 to 2147483647). Default `60000`. */
70
- requestTimeoutMs: number;
71
- };
72
- export type AskDbRuntimeIntrospectionConfig = {
73
- provider: AskDbIntrospectionProvider;
74
- /**
75
- * Resolved Postgres connection URL when `provider === "postgres"`:
76
- * `providerConfig.postgres.databaseUrl`, or its flat key `ASKDB_INTROSPECT_POSTGRES_URL`. Never read from `process.env`.
77
- * `undefined` for non-Postgres providers.
78
- */
79
- postgresDatabaseUrl: string | undefined;
80
- /** Resolved from `introspection.providerConfig.prisma.schemaPath`; `undefined` triggers auto-discovery in `@askdb/prisma`. */
81
- prismaSchemaPath: string | undefined;
82
- /**
83
- * Resolved MySQL connection URL when `provider === "mysql"`:
84
- * `providerConfig.mysql.databaseUrl`, or its flat key `ASKDB_INTROSPECT_MYSQL_URL`. Never read from `process.env`.
85
- * `undefined` for non-MySQL providers.
86
- */
87
- mysqlDatabaseUrl: string | undefined;
88
- /**
89
- * Schemas (MySQL/MariaDB: databases) to introspect, for every provider:
90
- * `introspection.schemas` → `ASKDB_INTROSPECT_SCHEMAS` (comma-separated).
91
- * `undefined` means the engine's default. `askdb introspect --schemas` overrides it.
92
- */
93
- schemas: string[] | undefined;
94
- /**
95
- * Resolved SQLite file path when `provider === "sqlite"`:
96
- * `providerConfig.sqlite.file`, or its flat key `ASKDB_INTROSPECT_SQLITE_FILE`. Never read from `process.env`.
97
- * `undefined` for non-SQLite providers.
98
- */
99
- sqliteFile: string | undefined;
100
- /**
101
- * Resolved SQL Server connection URL when `provider === "sqlserver"`:
102
- * `providerConfig.sqlserver.databaseUrl`, or its flat key `ASKDB_INTROSPECT_SQLSERVER_URL`. Never read from `process.env`.
103
- * `undefined` for non-SQL Server providers.
104
- */
105
- sqlserverDatabaseUrl: string | undefined;
106
- /** Resolved from `introspection.outputDir`; falls back to the package default (`./askdb/`). */
107
- outputDir: string;
108
- };
109
- export type AskDbRuntimeDevConfig = {
110
- mockSql: string | undefined;
111
- };
112
- export type AskDbRuntimeModesConfig = {
113
- askdbMode: string | undefined;
114
- omitSensitiveFromPrompt: boolean;
115
- };
116
- export type AskDbRuntimeNlToSqlConfig = {
117
- /**
118
- * Optional NL→SQL dialect override from `askdb.config.ts`. When set, hosts
119
- * (CLI / HTTP API / Studio) pass this to `ask({ dialect })` instead of
120
- * inferring from the introspection provider.
121
- */
122
- dialect: AskDbDialectId | undefined;
123
- };
124
- export type AskDbRuntimeStudioConfig = {
125
- execute: {
126
- /**
127
- * Resolved execute provider. Falls back to the active introspection provider when it
128
- * is a live engine (`postgres`, `mysql`, `sqlite`, `sqlserver`), then defaults to
129
- * `"postgres"` for backward compatibility.
130
- */
131
- provider: AskDbStudioExecuteProvider;
132
- /** Connection URL used by the Studio playground query runner for network databases. */
133
- databaseUrl: string | undefined;
134
- /** SQLite file path used when `provider === "sqlite"`. */
135
- file: string | undefined;
136
- /** Whether `POST /api/execute` is allowed. Default `false` (opt-in). */
137
- enabled: boolean;
138
- /**
139
- * Whether `databaseUrl` / `file` may fall back to the active introspection
140
- * connection. Default `false`.
141
- */
142
- useIntrospectionConnection: boolean;
143
- /**
144
- * True when the introspection config has a connection for this provider that
145
- * Studio did not use because `useIntrospectionConnection` is off. Lets hosts
146
- * explain why execute reports "not configured".
147
- */
148
- introspectionConnectionAvailable: boolean;
149
- /** Per-query timeout in milliseconds. Default `30000`. */
150
- timeoutMs: number;
151
- /** Maximum rows returned per query. Default `500`. */
152
- maxRows: number;
153
- };
154
- };
155
- /**
156
- * Typed runtime view over the bootstrapped AskDB config snapshot.
157
- */
158
- export type AskDbRuntimeConfig = {
159
- readonly structured: Readonly<AskDbConfig>;
160
- /** Canonical flattened map (subprocess env via {@link mergeAskDbFlatIntoEnvMap}). */
161
- readonly flat: Readonly<Record<string, string>>;
162
- ai: AskDbRuntimeAiConfig;
163
- introspection: AskDbRuntimeIntrospectionConfig;
164
- rag: AskDbRuntimeRagConfig;
165
- logging: AskDbRuntimeLoggingConfig;
166
- httpApi: AskDbRuntimeHttpApiConfig;
167
- dev: AskDbRuntimeDevConfig;
168
- modes: AskDbRuntimeModesConfig;
169
- nlToSql: AskDbRuntimeNlToSqlConfig;
170
- studio: AskDbRuntimeStudioConfig;
171
- /** One message per deprecated config key in use (it names the old and new key, never a value). */
172
- deprecations: readonly string[];
173
- };
1
+ import type { AskDbRuntimeConfig } from "./runtime-types.js";
174
2
  /**
175
3
  * Returns typed runtime configuration from the snapshot installed by {@link bootstrapAskDbEnv}.
4
+ *
5
+ * Every value is resolved from the snapshot's structured config. The snapshot's own flat map is
6
+ * never read back: another copy of `@askdb/config` may have installed it (ADR 0005), so `flat`
7
+ * and `ai.aiEnv` are this copy's projection of the same structured config.
176
8
  */
177
9
  export declare function getAskDbRuntimeConfig(): AskDbRuntimeConfig;
178
10
  //# sourceMappingURL=runtime-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-config.d.ts","sourceRoot":"","sources":["../src/runtime-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,0BAA0B,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAE5H,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAc9C,mIAAmI;AACnI,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC1C,4GAA4G;IAC5G,QAAQ,EAAE,qBAAqB,GAAG;QAAE,WAAW,E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,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,EAAE,EAAE,oBAAoB,CAAC;IACzB,aAAa,EAAE,+BAA+B,CAAC;IAC/C,GAAG,EAAE,qBAAqB,CAAC;IAC3B,OAAO,EAAE,yBAAyB,CAAC;IACnC,OAAO,EAAE,yBAAyB,CAAC;IACnC,GAAG,EAAE,qBAAqB,CAAC;IAC3B,KAAK,EAAE,uBAAuB,CAAC;IAC/B,OAAO,EAAE,yBAAyB,CAAC;IACnC,MAAM,EAAE,wBAAwB,CAAC;IACjC,kGAAkG;IAClG,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC;AAgCF;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAiI1D"}
1
+ {"version":3,"file":"runtime-config.d.ts","sourceRoot":"","sources":["../src/runtime-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAe7D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAU1D"}
@@ -1,235 +1,31 @@
1
- import { ASKDB_STUDIO_EXECUTE_PROVIDERS } from "./constants.js";
2
- import { DEFAULT_HTTP_API_REQUEST_TIMEOUT_MS, DEFAULT_INTROSPECT_OUTPUT_DIR, DEFAULT_STUDIO_EXECUTE_MAX_ROWS, DEFAULT_STUDIO_EXECUTE_TIMEOUT_MS, parseHttpApiListenPort, parseHttpApiRequestTimeoutMs, parsePositiveInteger, } from "./defaults.js";
3
- import { aiEmbeddingEnv, aiLanguageEnv } from "./flatten.js";
4
- import { normalizeAskDbConfig } from "./normalize.js";
5
- import { flatToAiEnv, getAskDbRuntimeStore } from "./runtime-store.js";
6
- function isTruthyFlag(raw) {
7
- return raw !== undefined && ["1", "true", "yes"].includes(raw.toLowerCase());
8
- }
9
- /** Normalization is pure, so it runs once per installed config object. */
10
- const normalizedByConfig = new WeakMap();
11
- function normalizedFor(structured) {
12
- let normalized = normalizedByConfig.get(structured);
13
- if (!normalized) {
14
- normalized = normalizeAskDbConfig(structured);
15
- normalizedByConfig.set(structured, normalized);
1
+ import { resolveAskDbConfig } from "./resolve.js";
2
+ import { getAskDbRuntimeStore } from "./runtime-store.js";
3
+ /** Resolution is pure, so it runs once per installed config object. */
4
+ const resolutionByConfig = new WeakMap();
5
+ function resolutionFor(structured) {
6
+ let resolution = resolutionByConfig.get(structured);
7
+ if (!resolution) {
8
+ resolution = resolveAskDbConfig(structured);
9
+ resolutionByConfig.set(structured, resolution);
16
10
  }
17
- return normalized;
18
- }
19
- /** The runtime view of a resolved `ai` section, with `env` built from its connection only. */
20
- function runtimeSection(section, env) {
21
- return { provider: section.provider, connection: section.connection.name, model: section.model, env };
22
- }
23
- function pickFlat(flat, key) {
24
- const v = flat[key];
25
- if (v === undefined || v.trim() === "")
26
- return undefined;
27
- return v.trim();
11
+ return resolution;
28
12
  }
29
13
  /**
30
14
  * Returns typed runtime configuration from the snapshot installed by {@link bootstrapAskDbEnv}.
15
+ *
16
+ * Every value is resolved from the snapshot's structured config. The snapshot's own flat map is
17
+ * never read back: another copy of `@askdb/config` may have installed it (ADR 0005), so `flat`
18
+ * and `ai.aiEnv` are this copy's projection of the same structured config.
31
19
  */
32
20
  export function getAskDbRuntimeConfig() {
33
- const { structured, flat } = getAskDbRuntimeStore();
34
- const aiEnv = flatToAiEnv(flat);
35
- const { config: normalized, deprecations } = normalizedFor(structured);
36
- const language = normalized.ai.language;
37
- const embeddingSection = normalized.ai.embedding;
38
- const embedding = embeddingSection
39
- ? {
40
- ...runtimeSection(embeddingSection, aiEmbeddingEnv(embeddingSection)),
41
- dimensions: embeddingSection.dimensions,
42
- }
43
- : undefined;
44
- // The RAG CLI's OpenAI embedder never reads another provider's key or base URL.
45
- const openaiEmbedding = embedding?.provider === "openai" ? embedding : undefined;
46
- const logStdoutRaw = pickFlat(flat, "ASKDB_LOG_STDOUT");
47
- const logStdout = isTruthyFlag(logStdoutRaw);
48
- const port = parseHttpApiListenPort(structured.httpApi?.listen?.port, "httpApi.listen.port") ??
49
- parseHttpApiListenPort(pickFlat(flat, "PORT"), "PORT") ??
50
- 3000;
51
- const host = structured.httpApi?.listen?.host ?? pickFlat(flat, "HOST") ?? "127.0.0.1";
52
- const omitRaw = pickFlat(flat, "ASKDB_OMIT_SENSITIVE_FROM_PROMPT");
53
- const omitFromFlat = isTruthyFlag(omitRaw);
54
- const prismaSchemaPathRaw = structured.introspection.provider === "prisma"
55
- ? structured.introspection.providerConfig?.prisma?.schemaPath?.trim()
56
- : undefined;
57
- // Per-engine connection lookup. We deliberately only resolve the field for
58
- // the active provider so the runtime view stays minimal and other branches
59
- // surface `undefined` (cheap exhaustiveness check at the consumer).
60
- const postgresDatabaseUrl = structured.introspection.provider === "postgres"
61
- ? structured.introspection.providerConfig?.postgres?.databaseUrl?.trim() ||
62
- pickFlat(flat, "ASKDB_INTROSPECT_POSTGRES_URL")
63
- : undefined;
64
- const mysqlDatabaseUrl = structured.introspection.provider === "mysql"
65
- ? structured.introspection.providerConfig?.mysql?.databaseUrl?.trim() ||
66
- pickFlat(flat, "ASKDB_INTROSPECT_MYSQL_URL")
67
- : undefined;
68
- const schemas = (structured.introspection.schemas ?? pickFlat(flat, "ASKDB_INTROSPECT_SCHEMAS")?.split(","))
69
- ?.map((s) => s.trim())
70
- .filter(Boolean);
71
- const sqliteFile = structured.introspection.provider === "sqlite"
72
- ? structured.introspection.providerConfig?.sqlite?.file?.trim() ||
73
- pickFlat(flat, "ASKDB_INTROSPECT_SQLITE_FILE")
74
- : undefined;
75
- const sqlserverDatabaseUrl = structured.introspection.provider === "sqlserver"
76
- ? structured.introspection.providerConfig?.sqlserver?.databaseUrl?.trim() ||
77
- pickFlat(flat, "ASKDB_INTROSPECT_SQLSERVER_URL")
78
- : undefined;
21
+ const { structured } = getAskDbRuntimeStore();
22
+ const { resolved, flat, deprecations } = resolutionFor(structured);
79
23
  return {
80
24
  structured,
81
25
  flat,
82
- ai: {
83
- aiEnv,
84
- language: { ...runtimeSection(language, aiLanguageEnv(language)), modelFamily: language.modelFamily },
85
- embedding,
86
- },
87
- introspection: {
88
- provider: structured.introspection.provider,
89
- postgresDatabaseUrl,
90
- prismaSchemaPath: prismaSchemaPathRaw || undefined,
91
- mysqlDatabaseUrl,
92
- schemas: schemas?.length ? schemas : undefined,
93
- sqliteFile,
94
- sqlserverDatabaseUrl,
95
- outputDir: pickFlat(flat, "ASKDB_INTROSPECT_OUT") ??
96
- structured.introspection.outputDir?.trim() ??
97
- DEFAULT_INTROSPECT_OUTPUT_DIR,
98
- },
99
- rag: {
100
- embedder: openaiEmbedding
101
- ? {
102
- apiKey: openaiEmbedding.env.OPENAI_API_KEY,
103
- baseURL: openaiEmbedding.env.OPENAI_BASE_URL,
104
- model: openaiEmbedding.model,
105
- }
106
- : {
107
- apiKey: pickFlat(flat, "OPENAI_API_KEY"),
108
- baseURL: pickFlat(flat, "OPENAI_BASE_URL"),
109
- model: undefined,
110
- },
111
- store: normalized.rag.store,
112
- storeConfig: normalized.rag.storeConfig,
113
- },
114
- logging: {
115
- level: structured.logging?.level ?? pickFlat(flat, "ASKDB_LOG_LEVEL"),
116
- correlationId: structured.logging?.correlationId ?? pickFlat(flat, "ASKDB_CORRELATION_ID"),
117
- logFile: structured.logging?.logFile ?? pickFlat(flat, "ASKDB_LOG_FILE"),
118
- logStdout,
119
- },
120
- httpApi: {
121
- listen: { port, host },
122
- // Only a real boolean counts: flattening rejects anything else, so a store installed
123
- // without it falls back to the flat key, which is set only for `true`.
124
- allowSchemaOverride: typeof structured.httpApi?.allowSchemaOverride === "boolean"
125
- ? structured.httpApi.allowSchemaOverride
126
- : isTruthyFlag(pickFlat(flat, "ASKDB_HTTP_ALLOW_SCHEMA_OVERRIDE")),
127
- requestTimeoutMs: parseHttpApiRequestTimeoutMs(structured.httpApi?.requestTimeoutMs, "httpApi.requestTimeoutMs") ??
128
- parseHttpApiRequestTimeoutMs(pickFlat(flat, "ASKDB_HTTP_REQUEST_TIMEOUT_MS"), "ASKDB_HTTP_REQUEST_TIMEOUT_MS") ??
129
- DEFAULT_HTTP_API_REQUEST_TIMEOUT_MS,
130
- },
131
- dev: {
132
- mockSql: structured.dev?.mockSql ?? pickFlat(flat, "ASKDB_MOCK_SQL"),
133
- },
134
- modes: {
135
- askdbMode: structured.modes?.askdbMode ?? pickFlat(flat, "ASKDB_MODE"),
136
- omitSensitiveFromPrompt: Boolean(structured.modes?.omitSensitiveFromPrompt) || omitFromFlat,
137
- },
138
- nlToSql: {
139
- dialect: structured.dialect,
140
- },
141
- studio: {
142
- execute: resolveStudioExecuteConfig(structured, flat),
143
- },
26
+ ...resolved,
27
+ ai: { aiEnv: { ...flat }, ...resolved.ai },
144
28
  deprecations,
145
29
  };
146
30
  }
147
- function resolveStudioExecuteConfig(structured, flat) {
148
- // 1. Explicit provider from structured config or env.
149
- const providerRaw = structured.studio?.execute?.provider ??
150
- pickFlat(flat, "ASKDB_STUDIO_EXECUTE_PROVIDER");
151
- let provider;
152
- if (providerRaw !== undefined && ASKDB_STUDIO_EXECUTE_PROVIDERS.includes(providerRaw)) {
153
- provider = providerRaw;
154
- }
155
- else {
156
- // 2. Fall back to introspection provider when it is a live execute provider.
157
- const introspectionProvider = structured.introspection?.provider;
158
- if (introspectionProvider !== undefined && ASKDB_STUDIO_EXECUTE_PROVIDERS.includes(introspectionProvider)) {
159
- provider = introspectionProvider;
160
- }
161
- else {
162
- // 3. Default to postgres for backward compatibility.
163
- provider = "postgres";
164
- }
165
- }
166
- const execute = structured.studio?.execute;
167
- const enabled = (typeof execute?.enabled === "boolean" ? execute.enabled : undefined) ??
168
- parseFlatBoolean(pickFlat(flat, "ASKDB_STUDIO_EXECUTE_ENABLED")) ??
169
- false;
170
- const useIntrospectionConnection = (typeof execute?.useIntrospectionConnection === "boolean" ? execute.useIntrospectionConnection : undefined) ??
171
- parseFlatBoolean(pickFlat(flat, "ASKDB_STUDIO_EXECUTE_USE_INTROSPECTION_CONNECTION")) ??
172
- false;
173
- const timeoutMs = parsePositiveInteger(execute?.timeoutMs) ??
174
- parsePositiveInteger(pickFlat(flat, "ASKDB_STUDIO_EXECUTE_TIMEOUT_MS")) ??
175
- DEFAULT_STUDIO_EXECUTE_TIMEOUT_MS;
176
- const maxRows = parsePositiveInteger(execute?.maxRows) ??
177
- parsePositiveInteger(pickFlat(flat, "ASKDB_STUDIO_EXECUTE_MAX_ROWS")) ??
178
- DEFAULT_STUDIO_EXECUTE_MAX_ROWS;
179
- // Connection resolution — each provider draws from its own structured field
180
- // first, then the relevant flat env key. The introspection connection is only
181
- // reused when `useIntrospectionConnection` is explicitly on, so turning execute
182
- // on never silently runs ad-hoc SQL with introspection credentials.
183
- const introspectionConnection = introspectionConnectionFor(provider, structured, flat);
184
- let databaseUrl;
185
- let file;
186
- if (provider === "sqlite") {
187
- file = execute?.file?.trim() || pickFlat(flat, "ASKDB_STUDIO_SQLITE_FILE");
188
- }
189
- else {
190
- databaseUrl = execute?.databaseUrl?.trim() || pickFlat(flat, "ASKDB_STUDIO_DATABASE_URL");
191
- }
192
- const explicit = provider === "sqlite" ? file : databaseUrl;
193
- if (!explicit && useIntrospectionConnection && introspectionConnection) {
194
- if (provider === "sqlite")
195
- file = introspectionConnection;
196
- else
197
- databaseUrl = introspectionConnection;
198
- }
199
- return {
200
- provider,
201
- databaseUrl,
202
- file,
203
- enabled,
204
- useIntrospectionConnection,
205
- introspectionConnectionAvailable: !explicit && !useIntrospectionConnection && introspectionConnection !== undefined,
206
- timeoutMs,
207
- maxRows,
208
- };
209
- }
210
- function introspectionConnectionFor(provider, structured, flat) {
211
- const intro = structured.introspection;
212
- if (intro?.provider !== provider)
213
- return undefined;
214
- switch (provider) {
215
- case "postgres":
216
- return intro.providerConfig?.postgres?.databaseUrl?.trim() || pickFlat(flat, "ASKDB_INTROSPECT_POSTGRES_URL");
217
- case "mysql":
218
- return intro.providerConfig?.mysql?.databaseUrl?.trim() || pickFlat(flat, "ASKDB_INTROSPECT_MYSQL_URL");
219
- case "sqlserver":
220
- return intro.providerConfig?.sqlserver?.databaseUrl?.trim() || pickFlat(flat, "ASKDB_INTROSPECT_SQLSERVER_URL");
221
- case "sqlite":
222
- return intro.providerConfig?.sqlite?.file?.trim() || pickFlat(flat, "ASKDB_INTROSPECT_SQLITE_FILE");
223
- }
224
- }
225
- function parseFlatBoolean(raw) {
226
- if (raw === undefined)
227
- return undefined;
228
- const v = raw.toLowerCase();
229
- if (["1", "true", "yes", "on"].includes(v))
230
- return true;
231
- if (["0", "false", "no", "off"].includes(v))
232
- return false;
233
- return undefined;
234
- }
235
31
  //# sourceMappingURL=runtime-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-config.js","sourceRoot":"","sources":["../src/runtime-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EACL,mCAAmC,EACnC,6BAA6B,EAC7B,+BAA+B,EAC/B,iCAAiC,EACjC,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAA+B,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAyLvE,SAAS,YAAY,CAAC,GAAuB;IAC3C,OAAO,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,0EAA0E;AAC1E,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAmD,CAAC;AAE1F,SAAS,aAAa,CAAC,UAAiC;IACtD,IAAI,UAAU,GAAG,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACpD,IA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,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,EAAE,UAAU,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAC9C,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IACnE,OAAO;QACL,UAAU;QACV,IAAI;QACJ,GAAG,QAAQ;QACX,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,QAAQ,CAAC,EAAE,EAAE;QAC1C,YAAY;KACb,CAAC;AACJ,CAAC"}
@@ -1,26 +1,29 @@
1
1
  import type { AskDbConfig } from "./types.js";
2
2
  export type AskDbRuntimeStore = {
3
3
  readonly structured: AskDbConfig;
4
- /** Canonical string map from {@link flattenAskDbConfig} (same keys as former merged `process.env`). */
4
+ /**
5
+ * Canonical string map from {@link flattenAskDbConfig}. Written for copies of `@askdb/config`
6
+ * that still read it; this copy resolves every value from `structured` and never reads it back.
7
+ */
5
8
  readonly flat: Readonly<Record<string, string>>;
6
9
  };
7
10
  export declare function setAskDbRuntime(data: AskDbRuntimeStore): void;
8
- export declare function clearAskDbRuntime(): void;
9
11
  /**
10
12
  * `true` once `bootstrapAskDbEnv()` (or another installer) has set the runtime snapshot.
11
13
  * A host-facing factory can use it to bootstrap only when its host hasn't already done so.
12
14
  */
13
15
  export declare function isAskDbRuntimeInitialized(): boolean;
14
16
  export declare function getAskDbRuntimeStore(): AskDbRuntimeStore;
15
- /** Build an env-shaped map for `@askdb/core` from the flattened runtime snapshot (not `process.env`). */
16
- export declare function flatToAiEnv(flat: Readonly<Record<string, string>>): Record<string, string | undefined>;
17
17
  /**
18
18
  * Merge AskDB flat keys into a base env map (e.g. for spawning child processes).
19
19
  * Does not read `process.env` itself.
20
20
  */
21
21
  export declare function mergeAskDbFlatIntoEnvMap(base: NodeJS.ProcessEnv, flat: Readonly<Record<string, string>>): NodeJS.ProcessEnv;
22
- /** @internal Tests only — replaces the runtime store without loading from disk. */
23
- export declare function setAskDbRuntimeForTests(data: AskDbRuntimeStore): void;
22
+ /**
23
+ * @internal Tests only — installs `config` as `bootstrapAskDbEnv()` installs a loaded file,
24
+ * without reading the disk. Throws the same `askdb.config: …` errors as `defineConfig`.
25
+ */
26
+ export declare function setAskDbRuntimeForTests(config: AskDbConfig): void;
24
27
  /** @internal Tests only. */
25
28
  export declare function resetAskDbRuntimeForTests(): void;
26
29
  //# sourceMappingURL=runtime-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-store.d.ts","sourceRoot":"","sources":["../src/runtime-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,uGAAuG;IACvG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAYF,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAE7D;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,CAEnD;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CASxD;AAED,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAEtG;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,CAAC,UAAU,EACvB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACrC,MAAM,CAAC,UAAU,CAQnB;AAED,mFAAmF;AACnF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAErE;AAED,4BAA4B;AAC5B,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD"}
1
+ {"version":3,"file":"runtime-store.d.ts","sourceRoot":"","sources":["../src/runtime-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAYF,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,CAEnD;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CASxD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,CAAC,UAAU,EACvB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACrC,MAAM,CAAC,UAAU,CAQnB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAGjE;AAED,4BAA4B;AAC5B,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD"}
@@ -1,3 +1,4 @@
1
+ import { defineConfig } from "./projection.js";
1
2
  /**
2
3
  * The snapshot lives on `globalThis` under a registered symbol, not in a module variable, so every
3
4
  * copy of `@askdb/config` in a process shares it: a host that bootstraps with its own version is
@@ -9,9 +10,6 @@ const runtimeHolder = globalThis;
9
10
  export function setAskDbRuntime(data) {
10
11
  runtimeHolder[RUNTIME_STORE_KEY] = data;
11
12
  }
12
- export function clearAskDbRuntime() {
13
- delete runtimeHolder[RUNTIME_STORE_KEY];
14
- }
15
13
  /**
16
14
  * `true` once `bootstrapAskDbEnv()` (or another installer) has set the runtime snapshot.
17
15
  * A host-facing factory can use it to bootstrap only when its host hasn't already done so.
@@ -27,10 +25,6 @@ export function getAskDbRuntimeStore() {
27
25
  }
28
26
  return stored;
29
27
  }
30
- /** Build an env-shaped map for `@askdb/core` from the flattened runtime snapshot (not `process.env`). */
31
- export function flatToAiEnv(flat) {
32
- return { ...flat };
33
- }
34
28
  /**
35
29
  * Merge AskDB flat keys into a base env map (e.g. for spawning child processes).
36
30
  * Does not read `process.env` itself.
@@ -44,12 +38,16 @@ export function mergeAskDbFlatIntoEnvMap(base, flat) {
44
38
  }
45
39
  return out;
46
40
  }
47
- /** @internal Tests only — replaces the runtime store without loading from disk. */
48
- export function setAskDbRuntimeForTests(data) {
49
- setAskDbRuntime(data);
41
+ /**
42
+ * @internal Tests only — installs `config` as `bootstrapAskDbEnv()` installs a loaded file,
43
+ * without reading the disk. Throws the same `askdb.config: …` errors as `defineConfig`.
44
+ */
45
+ export function setAskDbRuntimeForTests(config) {
46
+ const { config: structured, entries } = defineConfig(config);
47
+ setAskDbRuntime({ structured, flat: { ...entries } });
50
48
  }
51
49
  /** @internal Tests only. */
52
50
  export function resetAskDbRuntimeForTests() {
53
- clearAskDbRuntime();
51
+ delete runtimeHolder[RUNTIME_STORE_KEY];
54
52
  }
55
53
  //# sourceMappingURL=runtime-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-store.js","sourceRoot":"","sources":["../src/runtime-store.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAE1E,MAAM,aAAa,GAAG,UAA6E,CAAC;AAEpG,MAAM,UAAU,eAAe,CAAC,IAAuB;IACrD,aAAa,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;AAC1C,CAAC;AAED,M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