@surfaces-ui/dev-server 0.0.0-stage → 0.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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Surfaces UI
2
+ Copyright 2026 Josh Schoen
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
package/README.md CHANGED
@@ -1,3 +1,34 @@
1
- # Temporary Holding Version
1
+ <!-- Generated by scripts/package-readmes.mjs from package.json. Edit the script, not this file. -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # @surfaces-ui/dev-server
4
+
5
+ Local Connect server for Surfaces UI data sources.
6
+
7
+ A Connect server for your data: DuckDB (files, Delta, Iceberg, object stores, Postgres), Teradata and DataFusion behind one set of read-only services, with search, pipelines and an agent. Configured by `surfaces.config.ts`.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @surfaces-ui/dev-server
13
+ ```
14
+
15
+ ## Use
16
+
17
+ ```bash
18
+ npx surfaces-dev # reads surfaces.config.ts; serves http://localhost:5220
19
+ npx surfaces-pipelines list # run pipelines headless, for CI or cron
20
+ ```
21
+
22
+ ## Part of Surfaces UI
23
+
24
+ Surfaces UI is a UI library for data and analytics: exploring schemas, querying, charting, tables at scale, chat, and pages an agent can build.
25
+
26
+ Every Surfaces UI package is released at the same version; install them all at that one version, since mixing releases is not supported.
27
+
28
+ - [The guides on surfaces-ui.com](https://surfaces-ui.com/#docs)
29
+ - [Getting started](https://github.com/teradata-labs/surfaces-ui/blob/main/docs/getting-started.md)
30
+ - [Building with an agent](https://github.com/teradata-labs/surfaces-ui/blob/main/docs/agent-integration.md)
31
+ - [Styling](https://github.com/teradata-labs/surfaces-ui/blob/main/docs/styling.md)
32
+ - [Source for this package](https://github.com/teradata-labs/surfaces-ui/tree/main/packages/dev-server)
33
+
34
+ Licensed under Apache-2.0. See LICENSE and NOTICE.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { CONFIG_FILES, loadConfig, openSources, serverOptions } from "./config.js";
5
+ import { ENV_FILE, loadEnvFile } from "./env.js";
6
+ import { createSurfacesServer } from "./server.js";
7
+ const args = process.argv.slice(2);
8
+ const flag = (name) => {
9
+ const at = args.indexOf(name);
10
+ return at === -1 ? undefined : args[at + 1];
11
+ };
12
+ const file = flag("--config") ?? CONFIG_FILES.find((f) => fs.existsSync(path.resolve(f)));
13
+ // Secrets (ANTHROPIC_API_KEY and the like) may sit in a git-ignored .env.local beside the config.
14
+ // Read it before the config loads, since the config reads the environment as it starts.
15
+ const secrets = loadEnvFile(path.dirname(path.resolve(file ?? CONFIG_FILES[0])));
16
+ if (secrets.names.length > 0)
17
+ console.log(`Read ${secrets.names.join(", ")} from ${ENV_FILE}.`);
18
+ try {
19
+ // With no config, serve the six sample industry models so there is something to explore.
20
+ const { config, dir } = file ? await loadConfig(file) : { config: { seeds: true }, dir: process.cwd() };
21
+ if (!file)
22
+ console.log(`No ${CONFIG_FILES[0]} found: serving the sample industry models. Create one, or pass --config <file>, to use your own data.`);
23
+ const sources = await openSources(config, dir);
24
+ const server = await createSurfacesServer(await serverOptions(config, sources, dir));
25
+ const { url } = await server.listen(Number(flag("--port") ?? config.port ?? 5220));
26
+ console.log(`Surfaces dev server: ${url}`);
27
+ for (const source of sources) {
28
+ const tables = await source.engine.listTables({ catalog: "", schema: "", search: "" });
29
+ const names = tables.map((t) => t.ref?.table);
30
+ console.log(` ${source.id}: ${names.length > 20 ? `${names.length}${names.length >= 1000 ? " or more" : ""} tables` : names.join(", ")}`);
31
+ }
32
+ console.log(` search: ${config.discovery?.embedder === "local" ? "semantic and keyword (local model)" : "keyword"}`);
33
+ // The index is built now, in the background, so the first search does not wait for it.
34
+ const began = Date.now();
35
+ void server.discovery?.warm().then(({ objects }) => console.log(` search index ready: ${objects} tables and columns, ${Math.round((Date.now() - began) / 1000)}s`), (error) => console.warn(` search index could not be built: ${error instanceof Error ? error.message : String(error)}`));
36
+ const stop = () => void server.close().then(() => process.exit(0));
37
+ process.on("SIGINT", stop);
38
+ process.on("SIGTERM", stop);
39
+ }
40
+ catch (error) {
41
+ console.error(error instanceof Error ? error.message : error);
42
+ process.exit(1);
43
+ }
44
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAuB,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE;IAC5B,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,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;IACF,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["#!/usr/bin/env node\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { CONFIG_FILES, type SurfacesConfig, loadConfig, openSources, serverOptions } from \"./config.js\";\nimport { ENV_FILE, loadEnvFile } from \"./env.js\";\nimport { createSurfacesServer } from \"./server.js\";\n\nconst args = process.argv.slice(2);\nconst flag = (name: string) => {\n const at = args.indexOf(name);\n return at === -1 ? undefined : args[at + 1];\n};\n\nconst file = flag(\"--config\") ?? CONFIG_FILES.find((f) => fs.existsSync(path.resolve(f)));\n\n// Secrets (ANTHROPIC_API_KEY and the like) may sit in a git-ignored .env.local beside the config.\n// Read it before the config loads, since the config reads the environment as it starts.\nconst secrets = loadEnvFile(path.dirname(path.resolve(file ?? CONFIG_FILES[0]!)));\nif (secrets.names.length > 0) console.log(`Read ${secrets.names.join(\", \")} from ${ENV_FILE}.`);\n\ntry {\n // With no config, serve the six sample industry models so there is something to explore.\n const { config, dir }: { config: SurfacesConfig; dir: string } = file ? await loadConfig(file) : { config: { seeds: true }, dir: process.cwd() };\n if (!file) console.log(`No ${CONFIG_FILES[0]} found: serving the sample industry models. Create one, or pass --config <file>, to use your own data.`);\n const sources = await openSources(config, dir);\n const server = await createSurfacesServer(await serverOptions(config, sources, dir));\n const { url } = await server.listen(Number(flag(\"--port\") ?? config.port ?? 5220));\n console.log(`Surfaces dev server: ${url}`);\n for (const source of sources) {\n const tables = await source.engine.listTables({ catalog: \"\", schema: \"\", search: \"\" });\n const names = tables.map((t) => t.ref?.table);\n console.log(` ${source.id}: ${names.length > 20 ? `${names.length}${names.length >= 1000 ? \" or more\" : \"\"} tables` : names.join(\", \")}`);\n }\n console.log(` search: ${config.discovery?.embedder === \"local\" ? \"semantic and keyword (local model)\" : \"keyword\"}`);\n // The index is built now, in the background, so the first search does not wait for it.\n const began = Date.now();\n void server.discovery?.warm().then(\n ({ objects }) => console.log(` search index ready: ${objects} tables and columns, ${Math.round((Date.now() - began) / 1000)}s`),\n (error: unknown) => console.warn(` search index could not be built: ${error instanceof Error ? error.message : String(error)}`),\n );\n const stop = () => void server.close().then(() => process.exit(0));\n process.on(\"SIGINT\", stop);\n process.on(\"SIGTERM\", stop);\n} catch (error) {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n}\n"]}
@@ -0,0 +1,217 @@
1
+ import type { AgentBackend } from "@surfaces-ui/agent";
2
+ import type { DataSource, ModelSettings } from "@surfaces-ui/data";
3
+ import { type DuckDbCatalog, type DuckDbConnection, type DuckDbSecretValues, type DuckDbTable } from "@surfaces-ui/engine-duckdb";
4
+ import { type DriverConnection } from "@surfaces-ui/engine-teradata";
5
+ import type { PipelineDefinition } from "@surfaces-ui/pipelines";
6
+ import { type JsonValue } from "@bufbuild/protobuf";
7
+ import type { StoredResultsOptions } from "@surfaces-ui/engine-service";
8
+ import type { AgentServices, ServerSource, SurfacesServerOptions } from "./server.js";
9
+ import { type FormConfig } from "./stores.js";
10
+ /** A DuckDB-backed source: files and lake tables exposed as named tables. */
11
+ export interface DuckDbSourceConfig {
12
+ id: string;
13
+ displayName?: string;
14
+ engine: "duckdb";
15
+ /** Local paths are relative to the config file; remote ones (`s3://`, `gs://`, `az://`, `https://`) need a connection that covers them. */
16
+ tables: DuckDbTable[];
17
+ /**
18
+ * Object stores and web locations the tables read from. Each names a
19
+ * secret; the values come from the server's environment (see `envSecrets`),
20
+ * never from this file.
21
+ */
22
+ connections?: DuckDbConnection[];
23
+ /** Catalogs to attach read-only: an Iceberg REST catalog, or a DuckDB database file. */
24
+ catalogs?: DuckDbCatalog[];
25
+ }
26
+ /** A DataFusion server reached over its HTTP SQL endpoint. Read-only: no kept results and no pipelines. */
27
+ export interface DataFusionSourceConfig {
28
+ id: string;
29
+ displayName?: string;
30
+ engine: "datafusion";
31
+ /** Address of the server, e.g. http://localhost:8080. */
32
+ baseUrl: string;
33
+ }
34
+ /**
35
+ * A Teradata system reached through Teradata Query Service (its REST API).
36
+ * Read-only: no kept results, no pipelines and no time travel. The password
37
+ * or JWT is never written here: `secret` names it, and the server reads
38
+ * `<NAME>_PASSWORD` or `<NAME>_TOKEN` from its environment (see `envSecrets`).
39
+ */
40
+ export interface TeradataSourceConfig {
41
+ id: string;
42
+ displayName?: string;
43
+ engine: "teradata";
44
+ /** Address of Query Service up to `/systems`, e.g. https://vantage.example.com:1443. */
45
+ baseUrl: string;
46
+ /** The system name configured in Query Service. */
47
+ system: string;
48
+ /** Database user. Needed with a password; not with a JWT. The user should hold SELECT rights only. */
49
+ user?: string;
50
+ /** Name of the secret holding the password or JWT. */
51
+ secret: string;
52
+ /** Default database: unqualified names resolve here. */
53
+ database?: string;
54
+ /** The databases listings, search and agent context cover when no database is named. Defaults to the default database. */
55
+ databases?: string[];
56
+ transport?: "query-service";
57
+ /** `explicit` (default) keeps one session set to UTC; `implicit` lets requests run side by side. See `QueryServiceOptions.session`. */
58
+ session?: "explicit" | "implicit";
59
+ }
60
+ /**
61
+ * A Teradata system reached through a driver connection the config opens
62
+ * itself, for example with the `teradatasql` package installed outside this
63
+ * repo. The server never imports a driver: `connect` is the config's own
64
+ * code, and it reads the password from the environment, never from here.
65
+ */
66
+ export interface TeradataDriverSourceConfig {
67
+ id: string;
68
+ displayName?: string;
69
+ engine: "teradata";
70
+ transport: "driver";
71
+ /** Opens the connection, on first use. Its errors are not passed on, since a driver's message can repeat its settings. */
72
+ connect(): DriverConnection | Promise<DriverConnection>;
73
+ /** Shown as where this source connects, such as the host name. Never a credential. */
74
+ address?: string;
75
+ /** Default database: unqualified names resolve here. */
76
+ database?: string;
77
+ /** The databases listings, search and agent context cover when no database is named. Defaults to the default database. */
78
+ databases?: string[];
79
+ }
80
+ export type SourceConfig = DuckDbSourceConfig | DataFusionSourceConfig | TeradataSourceConfig | TeradataDriverSourceConfig;
81
+ export interface DiscoveryConfig {
82
+ /**
83
+ * "local" runs a small embedding model on this machine for semantic search
84
+ * (needs `@surfaces-ui/embedder-local`; the model downloads once to a cache
85
+ * outside the repo). Omit for keyword search only.
86
+ */
87
+ embedder?: "local";
88
+ /** Source IDs whose data values may be profiled, shown and put in agent context. Default: none. */
89
+ allowSampleValues?: string[];
90
+ /** Folder for context packs and accepted descriptions, relative to the config file. Defaults to `.surfaces`. */
91
+ storeDir?: string;
92
+ }
93
+ export interface SurfacesConfig {
94
+ /** May be left out when `seeds` is on. */
95
+ sources?: SourceConfig[];
96
+ /**
97
+ * Serve the six synthetic industry models from `@surfaces-ui/seeds` as the
98
+ * sources `retail`, `healthcare`, `fraud`, `telco`, `transportation` and
99
+ * `manufacturing`, with their pipelines and forms. Their data is invented,
100
+ * so their values may be shown (they are added to `allowSampleValues`).
101
+ */
102
+ seeds?: boolean;
103
+ /**
104
+ * Semantic models: the dimensions, measures and metrics of a project's
105
+ * queries, which explorers and reports take their fields from. They are
106
+ * kept as one JSON file each in `dir` (default `<storeDir>/semantic`), so
107
+ * point it at a folder in your repo to review and commit them. `models`
108
+ * (in the contract's JSON form) are added when the folder has none of
109
+ * that name; with `seeds` on, each seed's starter models are too.
110
+ */
111
+ semantic?: {
112
+ dir?: string;
113
+ models?: JsonValue[];
114
+ };
115
+ /**
116
+ * Forms people can submit. Fields and checks are set here; a client sends
117
+ * only a form id and values. Submissions are appended to
118
+ * `<storeDir>/forms/<form id>.jsonl`.
119
+ */
120
+ forms?: FormConfig[];
121
+ discovery?: DiscoveryConfig;
122
+ /** Port for `surfaces-dev`. Defaults to 5220. */
123
+ port?: number;
124
+ maxResultRows?: number;
125
+ /**
126
+ * Pipelines the server can run: datasets built from one another by SQL,
127
+ * with data quality rules. The SQL lives here, never in the browser.
128
+ */
129
+ pipelines?: PipelineDefinition[];
130
+ /**
131
+ * Lets people save pipelines they approved (`SavePipeline`), typically ones
132
+ * an agent proposed. Each is checked by the server before it is kept, as
133
+ * one JSON file with its versions in `<storeDir>/pipelines/` (or `dir`).
134
+ * Pipelines in `pipelines` stay as written here. Off by default.
135
+ */
136
+ savedPipelines?: boolean | {
137
+ dir?: string;
138
+ };
139
+ /**
140
+ * dbt projects, served as pipelines read from their artifacts: models,
141
+ * seeds, snapshots and sources as datasets, dbt's tests as checks, and its
142
+ * runs and source freshness. dbt stays what builds them.
143
+ */
144
+ dbt?: DbtProjectConfig[];
145
+ /** Keeping query results so views do not re-run the query. `false` turns it off. */
146
+ storedResults?: StoredResultsOptions | false;
147
+ /**
148
+ * An agent to serve as `AgentService`, such as
149
+ * `anthropicAgent({ client: new Anthropic(), system: catalogPrompt(analyticsCatalog) })`.
150
+ * Its model key is read from this server's environment, never from config.
151
+ * A function gets the server's data source, for tools that list tables or
152
+ * run queries.
153
+ */
154
+ agent?: AgentBackend | ((dataSource: DataSource, services: AgentServices) => AgentBackend);
155
+ /**
156
+ * Which model each agent backend uses, shown and changed from a page
157
+ * (`ModelService`). Build it with `modelSettings` from `@surfaces-ui/data`.
158
+ * Keys stay in the environment; nothing here carries one.
159
+ */
160
+ models?: ModelSettings;
161
+ }
162
+ /**
163
+ * Reads a named secret from environment variables, so credentials stay out
164
+ * of config files and the repository. For the name `LAKE` it reads
165
+ * `LAKE_KEY_ID`, `LAKE_SECRET`, `LAKE_SESSION_TOKEN`, `LAKE_CONNECTION_STRING`
166
+ * `LAKE_TOKEN` and `LAKE_PASSWORD`, whichever are set.
167
+ */
168
+ export declare function envSecrets(env?: Record<string, string | undefined>): (name: string) => DuckDbSecretValues | undefined;
169
+ /** Identity helper that gives `surfaces.config.ts` type checking. */
170
+ export declare function defineConfig(config: SurfacesConfig): SurfacesConfig;
171
+ export declare const CONFIG_FILES: string[];
172
+ /** Loads a config file and resolves its relative paths. */
173
+ export declare function loadConfig(file: string): Promise<{
174
+ config: SurfacesConfig;
175
+ dir: string;
176
+ }>;
177
+ /** Opens the engines a config describes. */
178
+ export declare function openSources(config: SurfacesConfig, dir: string, resolveSecret?: (name: string) => DuckDbSecretValues | undefined | Promise<DuckDbSecretValues | undefined>): Promise<ServerSource[]>;
179
+ /** The seeds package and the sources, pipelines and forms it adds. */
180
+ export declare function loadSeeds(): Promise<{
181
+ sources: DuckDbSourceConfig[];
182
+ pipelines: PipelineDefinition[];
183
+ forms: import("@surfaces-ui/data").FormSpec[];
184
+ semanticModels: JsonValue[];
185
+ ids: string[];
186
+ }>;
187
+ /** A dbt project the server reads. Paths are relative to the config file. */
188
+ export interface DbtProjectConfig {
189
+ /** The pipeline's id. Defaults to the project's name. */
190
+ id?: string;
191
+ name?: string;
192
+ /** The source whose engine reads the warehouse dbt builds into. */
193
+ sourceId: string;
194
+ /** Where dbt writes its artifacts: the project's `target` directory. */
195
+ targetDir: string;
196
+ /**
197
+ * Lets a person, or an agent they approve, start `dbt build` (or
198
+ * `dbt compile` to check) from here. Needs `projectDir`. Credentials stay
199
+ * in dbt's profile and this server's environment. Off by default: runs
200
+ * made by dbt itself are reported either way.
201
+ */
202
+ build?: {
203
+ projectDir: string;
204
+ profilesDir?: string;
205
+ target?: string;
206
+ command?: string;
207
+ };
208
+ /** Starter semantic models from dbt's semantic layer (semantic_manifest.json). On by default. */
209
+ semanticModels?: boolean;
210
+ /**
211
+ * Put before each table's `schema.alias` when the source reads dbt's
212
+ * database under a name of its own: the name a DuckDB source attaches the
213
+ * database file as, for one.
214
+ */
215
+ relationPrefix?: string;
216
+ }
217
+ export declare function serverOptions(config: SurfacesConfig, sources: ServerSource[], dir?: string): Promise<SurfacesServerOptions>;