@thyn-ai/sqai 0.1.5 → 0.1.6

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/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ SQAI — Structured Query AI
2
+ Copyright 2026 Thyn (thyn.ai)
3
+
4
+ This product includes software developed by Thyn (https://thyn.ai).
5
+
6
+ SQAI is built on the Algenta deterministic execution engine
7
+ (https://algenta.ai) and consumes the published algenta-sdk (npm) and
8
+ algenta-core (PyPI) packages.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @thyn-ai/sqai
2
+
3
+ TypeScript SDK for SQAI, a deterministic, read-only structured-data tool for AI agents.
4
+
5
+ Install:
6
+
7
+ ```bash
8
+ npm install @thyn-ai/sqai
9
+ ```
10
+
11
+ Use `createSQAI()` to connect local files or in-memory rows and ask governed queries. Run `sqai login` once before dispatching deterministic computations through the managed SQAI runtime.
12
+
13
+ Docs: https://docs.sqai.com
package/dist/index.cjs CHANGED
@@ -35,6 +35,8 @@ __export(index_exports, {
35
35
  ResultStore: () => ResultStore,
36
36
  RuntimeProvisioner: () => RuntimeProvisioner,
37
37
  SQAI: () => SQAI,
38
+ SQAI_CONNECTOR_TYPES: () => SQAI_CONNECTOR_TYPES,
39
+ SQAI_CONNECTOR_TYPE_ALIASES: () => SQAI_CONNECTOR_TYPE_ALIASES,
38
40
  SQAI_ERROR_CODES: () => SQAI_ERROR_CODES,
39
41
  SqaiError: () => SqaiError,
40
42
  computationHash: () => computationHash,
@@ -166,13 +168,13 @@ var SQAI_ERROR_CODES = [
166
168
  "contract_mismatch",
167
169
  "invalid_intent"
168
170
  ];
169
- var RETRYABLE_ALGENTA_CODES = /* @__PURE__ */ new Set([
171
+ var RETRYABLE_ENGINE_CODES = /* @__PURE__ */ new Set([
170
172
  "network_error",
171
173
  "timeout",
172
174
  "rate_limited",
173
175
  "service_unavailable"
174
176
  ]);
175
- function fromAlgentaError(error) {
177
+ function fromEngineError(error) {
176
178
  if (error instanceof SqaiError) {
177
179
  return error;
178
180
  }
@@ -182,7 +184,7 @@ function fromAlgentaError(error) {
182
184
  const details = errorLike.details && typeof errorLike.details === "object" ? errorLike.details : {};
183
185
  return new SqaiError(code, message, {
184
186
  source: "engine",
185
- retryable: RETRYABLE_ALGENTA_CODES.has(code),
187
+ retryable: RETRYABLE_ENGINE_CODES.has(code),
186
188
  details
187
189
  });
188
190
  }
@@ -191,12 +193,14 @@ function fromAlgentaError(error) {
191
193
  var DEFAULT_BUILD_SERVICE_URL = "https://sqai-buildservice.fly.dev";
192
194
  function readEnv(env = process.env) {
193
195
  const apiKey = (env.SQAI_API_KEY ?? "").trim() || void 0;
194
- const engineUrl = (env.SQAI_ENGINE_URL ?? "").trim() || void 0;
196
+ const deploymentUrl = (env.SQAI_DEPLOYMENT_URL ?? "").trim() || void 0;
197
+ const legacyEngineUrl = (env.SQAI_ENGINE_URL ?? "").trim() || void 0;
198
+ const engineUrl = deploymentUrl ?? legacyEngineUrl;
195
199
  const autoInstall = (env.SQAI_RUNTIME_AUTO_INSTALL ?? "").trim() !== "0";
196
200
  const modulesRaw = (env.SQAI_RUNTIME_MODULES ?? "").split(",").map((m) => m.trim()).filter((m) => m.length > 0);
197
201
  const runtimeModules = modulesRaw.length > 0 ? modulesRaw : void 0;
198
202
  const buildServiceUrl = (env.SQAI_BUILD_SERVICE_URL ?? "").trim() || DEFAULT_BUILD_SERVICE_URL;
199
- return { apiKey, engineUrl, autoInstall, runtimeModules, buildServiceUrl };
203
+ return { apiKey, engineUrl, deploymentUrl, autoInstall, runtimeModules, buildServiceUrl };
200
204
  }
201
205
  function inferMode(explicit, resolved) {
202
206
  if (explicit) {
@@ -205,9 +209,6 @@ function inferMode(explicit, resolved) {
205
209
  if (resolved.engineUrl) {
206
210
  return "self_hosted";
207
211
  }
208
- if (resolved.apiKey) {
209
- return "api";
210
- }
211
212
  return "local";
212
213
  }
213
214
 
@@ -897,6 +898,9 @@ function digestsEqual(actualHex, expectedHex) {
897
898
  const expected = Buffer.from(expectedHex.toLowerCase(), "utf-8");
898
899
  return actual.length === expected.length && (0, import_node_crypto5.timingSafeEqual)(actual, expected);
899
900
  }
901
+ function isGeneratedBytecodeCache(path) {
902
+ return path.split("/").includes("__pycache__") && path.endsWith(".pyc") && isSafeRelativePath(path);
903
+ }
900
904
  function parseVerifiedManifest(manifestBytes) {
901
905
  let manifest;
902
906
  try {
@@ -1105,6 +1109,9 @@ async function verifyInstalledBundleDir(installDir, expectations) {
1105
1109
  }
1106
1110
  const entry = byPath.get(relPath);
1107
1111
  if (entry === void 0) {
1112
+ if (isGeneratedBytecodeCache(relPath)) {
1113
+ continue;
1114
+ }
1108
1115
  throw new BundleVerificationError(
1109
1116
  "unlisted_member",
1110
1117
  `installed file not listed in signed manifest: '${relPath}'`
@@ -1273,6 +1280,21 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1273
1280
  }
1274
1281
  return new import_algenta_sdk2.MojoRuntime(config ?? {});
1275
1282
  }
1283
+ async ensureLocalLoginKey() {
1284
+ if (this.options.runtimeFactory || process.env.ALGENTA_API_KEY || process.env.DE_API_KEY) {
1285
+ return;
1286
+ }
1287
+ const key = await readCachedApiKey();
1288
+ if (key) {
1289
+ process.env.ALGENTA_API_KEY = key;
1290
+ return;
1291
+ }
1292
+ throw new SqaiError(
1293
+ "login_required",
1294
+ "Local compute requires a free SQAI device login. Run `sqai login` once, or set SQAI_API_KEY in this process.",
1295
+ { details: { reason: "login_key_missing" } }
1296
+ );
1297
+ }
1276
1298
  cacheDir() {
1277
1299
  return this.options.cacheDir ?? runtimeCacheDir();
1278
1300
  }
@@ -1378,6 +1400,7 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1378
1400
  async doEnsure() {
1379
1401
  const platformKey = currentPlatformKey();
1380
1402
  const filter = this.filterModules();
1403
+ await this.ensureLocalLoginKey();
1381
1404
  const probeEndpoint = filter ? this.filterEndpoint(this.localCacheKey(filter, platformKey)) : void 0;
1382
1405
  const runtime = this.newRuntime(probeEndpoint ? { tcpAddress: probeEndpoint.tcp } : void 0);
1383
1406
  try {
@@ -1405,7 +1428,7 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1405
1428
  const supported = Object.keys(bundle.platforms);
1406
1429
  throw new SqaiError(
1407
1430
  "unsupported_platform",
1408
- supported.length === 0 ? "No managed runtime bundle is published yet for any platform. Start a local Algenta runtime daemon, or set SQAI_ENGINE_URL / SQAI_API_KEY to use a hosted engine." : `No managed runtime bundle is published for '${platformKey}'.`,
1431
+ supported.length === 0 ? "No managed runtime bundle is published yet for any platform. Run `sqai login`, or set SQAI_DEPLOYMENT_URL / SQAI_API_KEY for a managed SQAI deployment." : `No managed runtime bundle is published for '${platformKey}'.`,
1409
1432
  { details: { platform: platformKey, supported } }
1410
1433
  );
1411
1434
  }
@@ -1513,12 +1536,22 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1513
1536
  }
1514
1537
  async lockIsStale(lockPath) {
1515
1538
  const freshMs = this.options.lockFreshMs ?? LOCK_FRESH_MS;
1539
+ const ageFromMtime = async () => {
1540
+ try {
1541
+ const stat = await import_node_fs3.promises.stat(lockPath);
1542
+ return Date.now() - stat.mtimeMs;
1543
+ } catch (error) {
1544
+ const code = error.code;
1545
+ return code === "ENOENT" ? null : Number.POSITIVE_INFINITY;
1546
+ }
1547
+ };
1516
1548
  try {
1517
1549
  const raw = await import_node_fs3.promises.readFile(lockPath, "utf-8");
1518
1550
  const parsed = JSON.parse(raw);
1519
1551
  const createdAt = typeof parsed.created_at === "string" ? Date.parse(parsed.created_at) : NaN;
1520
1552
  if (!Number.isFinite(createdAt)) {
1521
- return true;
1553
+ const age = await ageFromMtime();
1554
+ return age !== null && age >= freshMs;
1522
1555
  }
1523
1556
  return Date.now() - createdAt >= freshMs;
1524
1557
  } catch (error) {
@@ -1526,7 +1559,8 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1526
1559
  if (code === "ENOENT") {
1527
1560
  return false;
1528
1561
  }
1529
- return true;
1562
+ const age = await ageFromMtime();
1563
+ return age !== null && age >= freshMs;
1530
1564
  }
1531
1565
  }
1532
1566
  /** Serialize installers on `<cacheDir>/<installKey>.lock`; returns the verified install. */
@@ -1664,12 +1698,7 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1664
1698
  "start",
1665
1699
  "--foreground"
1666
1700
  ];
1667
- if (!process.env.ALGENTA_API_KEY && !process.env.DE_API_KEY) {
1668
- const key = await readCachedApiKey();
1669
- if (key) {
1670
- process.env.ALGENTA_API_KEY = key;
1671
- }
1672
- }
1701
+ await this.ensureLocalLoginKey();
1673
1702
  const managed = this.newRuntime(
1674
1703
  endpoint ? { autoStart: true, daemonCommand, tcpAddress: endpoint.tcp } : { autoStart: true, daemonCommand }
1675
1704
  );
@@ -1738,7 +1767,7 @@ async function dispatchComputation(target, entry, argsVector, seed, requestId, t
1738
1767
  request_id: response.request_id ?? requestId
1739
1768
  };
1740
1769
  } catch (error) {
1741
- throw fromAlgentaError(error);
1770
+ throw fromEngineError(error);
1742
1771
  }
1743
1772
  }
1744
1773
  return dispatchHttp(target, module2, functionName, args, requestId);
@@ -1775,7 +1804,7 @@ async function dispatchHttp(target, module2, functionName, args, requestId) {
1775
1804
  } catch (error) {
1776
1805
  throw new SqaiError(
1777
1806
  "compute_runtime_unavailable",
1778
- `The hosted compute endpoint is unreachable: ${error.message}. Check SQAI_ENGINE_URL / SQAI_API_KEY.`,
1807
+ `The SQAI deployment endpoint is unreachable: ${error.message}. Check SQAI_DEPLOYMENT_URL / SQAI_API_KEY.`,
1779
1808
  { retryable: true }
1780
1809
  );
1781
1810
  }
@@ -1958,7 +1987,7 @@ var SQAI = class {
1958
1987
  const env = readEnv();
1959
1988
  this.mode = inferMode(config.mode, env);
1960
1989
  this.apiKey = config.apiKey ?? env.apiKey;
1961
- this.engineUrl = config.engineUrl ?? env.engineUrl;
1990
+ this.engineUrl = config.deploymentUrl ?? config.engineUrl ?? env.engineUrl;
1962
1991
  this.tenantId = config.tenantId ?? null;
1963
1992
  this.policy = config.policy;
1964
1993
  this.configuredTarget = config.computeTarget;
@@ -1986,7 +2015,7 @@ var SQAI = class {
1986
2015
  this.algentaRuntime = this.rawRuntime;
1987
2016
  }
1988
2017
  // ── Query plane ────────────────────────────────────────────────────────────
1989
- async connect(source, options = {}) {
2018
+ async connect(source = null, options = {}) {
1990
2019
  try {
1991
2020
  const registration = await this.algentaRuntime.connect(source, options);
1992
2021
  const mapped = mapSource(registration);
@@ -2005,7 +2034,84 @@ var SQAI = class {
2005
2034
  this.sources.set(mapped.name, mapped);
2006
2035
  return mapped;
2007
2036
  } catch (error) {
2008
- throw error instanceof SqaiError ? error : fromAlgentaError(error);
2037
+ throw error instanceof SqaiError ? error : fromEngineError(error);
2038
+ }
2039
+ }
2040
+ async createConnector(request2) {
2041
+ const createConnector = this.algentaRuntime.createConnector;
2042
+ if (typeof createConnector !== "function") {
2043
+ throw unsupportedSubstrateOperation("createConnector");
2044
+ }
2045
+ try {
2046
+ return await createConnector.call(this.algentaRuntime, request2);
2047
+ } catch (error) {
2048
+ throw fromEngineError(error);
2049
+ }
2050
+ }
2051
+ async listConnectors(options = {}) {
2052
+ const listConnectors = this.algentaRuntime.listConnectors;
2053
+ if (typeof listConnectors !== "function") {
2054
+ throw unsupportedSubstrateOperation("listConnectors");
2055
+ }
2056
+ try {
2057
+ return await listConnectors.call(this.algentaRuntime, options);
2058
+ } catch (error) {
2059
+ throw fromEngineError(error);
2060
+ }
2061
+ }
2062
+ async getConnector(connectorId) {
2063
+ const getConnector = this.algentaRuntime.getConnector;
2064
+ if (typeof getConnector !== "function") {
2065
+ throw unsupportedSubstrateOperation("getConnector");
2066
+ }
2067
+ try {
2068
+ return await getConnector.call(this.algentaRuntime, connectorId);
2069
+ } catch (error) {
2070
+ throw fromEngineError(error);
2071
+ }
2072
+ }
2073
+ async updateConnector(connectorId, request2) {
2074
+ const updateConnector = this.algentaRuntime.updateConnector;
2075
+ if (typeof updateConnector !== "function") {
2076
+ throw unsupportedSubstrateOperation("updateConnector");
2077
+ }
2078
+ try {
2079
+ return await updateConnector.call(this.algentaRuntime, connectorId, request2);
2080
+ } catch (error) {
2081
+ throw fromEngineError(error);
2082
+ }
2083
+ }
2084
+ async testConnector(connectorIdOrConnector) {
2085
+ const testConnector = this.algentaRuntime.testConnector;
2086
+ if (typeof testConnector !== "function") {
2087
+ throw unsupportedSubstrateOperation("testConnector");
2088
+ }
2089
+ try {
2090
+ return await testConnector.call(this.algentaRuntime, connectorIdOrConnector);
2091
+ } catch (error) {
2092
+ throw fromEngineError(error);
2093
+ }
2094
+ }
2095
+ async browseConnector(connectorIdOrConnector) {
2096
+ const browseConnector = this.algentaRuntime.browseConnector;
2097
+ if (typeof browseConnector !== "function") {
2098
+ throw unsupportedSubstrateOperation("browseConnector");
2099
+ }
2100
+ try {
2101
+ return await browseConnector.call(this.algentaRuntime, connectorIdOrConnector);
2102
+ } catch (error) {
2103
+ throw fromEngineError(error);
2104
+ }
2105
+ }
2106
+ async deleteConnector(connectorId) {
2107
+ const deleteConnector = this.algentaRuntime.deleteConnector;
2108
+ if (typeof deleteConnector !== "function") {
2109
+ throw unsupportedSubstrateOperation("deleteConnector");
2110
+ }
2111
+ try {
2112
+ await deleteConnector.call(this.algentaRuntime, connectorId);
2113
+ } catch (error) {
2114
+ throw fromEngineError(error);
2009
2115
  }
2010
2116
  }
2011
2117
  listSources() {
@@ -2016,28 +2122,28 @@ var SQAI = class {
2016
2122
  try {
2017
2123
  return await this.algentaRuntime.resolve(spec);
2018
2124
  } catch (error) {
2019
- throw fromAlgentaError(error);
2125
+ throw fromEngineError(error);
2020
2126
  }
2021
2127
  }
2022
2128
  async query(plan) {
2023
2129
  try {
2024
2130
  return await this.algentaRuntime.query(plan);
2025
2131
  } catch (error) {
2026
- throw fromAlgentaError(error);
2132
+ throw fromEngineError(error);
2027
2133
  }
2028
2134
  }
2029
2135
  async queryWithMetadata(plan) {
2030
2136
  try {
2031
2137
  return await this.algentaRuntime.queryWithMetadata(plan);
2032
2138
  } catch (error) {
2033
- throw fromAlgentaError(error);
2139
+ throw fromEngineError(error);
2034
2140
  }
2035
2141
  }
2036
2142
  async verify(plan) {
2037
2143
  try {
2038
2144
  return await this.algentaRuntime.verify(plan);
2039
2145
  } catch (error) {
2040
- throw fromAlgentaError(error);
2146
+ throw fromEngineError(error);
2041
2147
  }
2042
2148
  }
2043
2149
  async ask(spec) {
@@ -2059,14 +2165,14 @@ var SQAI = class {
2059
2165
  if (typeof this.algentaRuntime.extractColumns !== "function") {
2060
2166
  throw new SqaiError(
2061
2167
  "unsupported_operation",
2062
- "The installed algenta-sdk build does not provide extractColumns; upgrade the substrate.",
2063
- { details: { required: "algenta-sdk extractColumns" } }
2168
+ "The installed SQAI package does not provide extractColumns; upgrade SQAI.",
2169
+ { details: { required: "sqai.extractColumns" } }
2064
2170
  );
2065
2171
  }
2066
2172
  try {
2067
2173
  return await this.algentaRuntime.extractColumns(sourceName, columns, options);
2068
2174
  } catch (error) {
2069
- throw fromAlgentaError(error);
2175
+ throw fromEngineError(error);
2070
2176
  }
2071
2177
  }
2072
2178
  // ── Computation plane ──────────────────────────────────────────────────────
@@ -2196,7 +2302,7 @@ var SQAI = class {
2196
2302
  "API mode requires SQAI_API_KEY for the computation plane."
2197
2303
  );
2198
2304
  }
2199
- return { kind: "http", baseUrl: "https://api.algenta.ai", apiKey: this.apiKey };
2305
+ return { kind: "http", baseUrl: "https://api.sqai.com", apiKey: this.apiKey };
2200
2306
  }
2201
2307
  const runtime = await this.provisioner.ensure();
2202
2308
  return { kind: "local", runtime };
@@ -2254,6 +2360,13 @@ var SQAI = class {
2254
2360
  function createSQAI(config = {}) {
2255
2361
  return new SQAI(config);
2256
2362
  }
2363
+ function unsupportedSubstrateOperation(operation) {
2364
+ return new SqaiError(
2365
+ "unsupported_operation",
2366
+ `The installed SQAI package does not provide ${operation}; upgrade SQAI.`,
2367
+ { details: { required: `sqai.${operation}` } }
2368
+ );
2369
+ }
2257
2370
  function mapSource(registration) {
2258
2371
  const record = registration;
2259
2372
  return {
@@ -2267,6 +2380,52 @@ function mapSource(registration) {
2267
2380
  status: String(registration.status ?? "ready")
2268
2381
  };
2269
2382
  }
2383
+
2384
+ // src/types.ts
2385
+ var SQAI_CONNECTOR_TYPES = [
2386
+ "s3",
2387
+ "gcs",
2388
+ "azure",
2389
+ "clickhouse",
2390
+ "bigquery",
2391
+ "snowflake",
2392
+ "redshift",
2393
+ "postgres",
2394
+ "postgresql",
2395
+ "sqlite",
2396
+ "mysql",
2397
+ "mssql",
2398
+ "oracle",
2399
+ "neo4j",
2400
+ "redis",
2401
+ "elastic",
2402
+ "elasticsearch",
2403
+ "rest",
2404
+ "rest_api",
2405
+ "file",
2406
+ "file_upload",
2407
+ "github_repo",
2408
+ "gitlab_repo",
2409
+ "bitbucket_repo",
2410
+ "local_repo",
2411
+ "repo_archive"
2412
+ ];
2413
+ var SQAI_CONNECTOR_TYPE_ALIASES = {
2414
+ postgresql: "postgres",
2415
+ click_house: "clickhouse",
2416
+ redis_cache: "redis",
2417
+ elastic: "elasticsearch",
2418
+ rest_api: "rest",
2419
+ file_upload: "file",
2420
+ github: "github_repo",
2421
+ github_repository: "github_repo",
2422
+ gitlab: "gitlab_repo",
2423
+ gitlab_repository: "gitlab_repo",
2424
+ bitbucket: "bitbucket_repo",
2425
+ bitbucket_repository: "bitbucket_repo",
2426
+ local_repository: "local_repo",
2427
+ archive_repository: "repo_archive"
2428
+ };
2270
2429
  // Annotate the CommonJS export names for ESM import in node:
2271
2430
  0 && (module.exports = {
2272
2431
  ContractIndex,
@@ -2274,6 +2433,8 @@ function mapSource(registration) {
2274
2433
  ResultStore,
2275
2434
  RuntimeProvisioner,
2276
2435
  SQAI,
2436
+ SQAI_CONNECTOR_TYPES,
2437
+ SQAI_CONNECTOR_TYPE_ALIASES,
2277
2438
  SQAI_ERROR_CODES,
2278
2439
  SqaiError,
2279
2440
  computationHash,
@@ -2289,4 +2450,3 @@ function mapSource(registration) {
2289
2450
  sqaiHome,
2290
2451
  validateComputation
2291
2452
  });
2292
- //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ export { QueryResponse, ResolveResponse, ResolvedPlan } from 'algenta-sdk';
3
3
 
4
4
  /** Capability contract: the generated, hash-pinned inventory of everything
5
5
  * SQAI exposes. Loaded from the vendored contracts/algenta-capabilities.json
6
- * (synced hash-verified from the decision-engine generator). SQAI keeps no
6
+ * (synced hash-verified from the generator). SQAI keeps no
7
7
  * handwritten operation lists — this file is the only authority. */
8
8
  interface CapabilitySignatureParam {
9
9
  name: string;
@@ -66,8 +66,7 @@ declare class ContractIndex {
66
66
  /** SQAI_* environment mapping and zero-config mode inference.
67
67
  *
68
68
  * Inference order (explicit config always overrides):
69
- * SQAI_ENGINE_URL present -> "self_hosted"
70
- * SQAI_API_KEY present -> "api"
69
+ * SQAI_DEPLOYMENT_URL / SQAI_ENGINE_URL present -> "self_hosted"
71
70
  * otherwise -> "local"
72
71
  */
73
72
  type SqaiMode = "local" | "api" | "self_hosted";
@@ -187,6 +186,7 @@ declare class RuntimeProvisioner {
187
186
  status(): Promise<RuntimeStatus>;
188
187
  stop(): Promise<void>;
189
188
  private newRuntime;
189
+ private ensureLocalLoginKey;
190
190
  private cacheDir;
191
191
  /** Normalized module filter (sorted, unique, non-empty) or null for the default bundle. */
192
192
  private filterModules;
@@ -225,13 +225,7 @@ declare class RuntimeProvisioner {
225
225
  private spawnInstalled;
226
226
  }
227
227
 
228
- /** Public SQAI types.
229
- *
230
- * Vocabulary rule: Algenta envelope field names pass through verbatim
231
- * (plan_hash, schema_revision, intent_signature, deterministic_scope,
232
- * decision_path, validated, engine_used, ...). SQAI never invents parallel
233
- * names for the same concept.
234
- */
228
+ /** Public SQAI types. */
235
229
 
236
230
  /** Contract-derived wire value: everything the computation plane can
237
231
  * transport. The wire schema transports; the capability contract authorizes. */
@@ -241,8 +235,6 @@ type SqaiValue = null | boolean | number | string | SqaiValue[] | {
241
235
  type: "decimal" | "bigint";
242
236
  value: string;
243
237
  };
244
- /** @deprecated Renamed to {@link SqaiValue}. Kept as a non-breaking alias. */
245
- type AlgentaWireValue = SqaiValue;
246
238
  interface SqaiSource {
247
239
  name: string;
248
240
  source_id: string | null;
@@ -256,6 +248,74 @@ interface SqaiSource {
256
248
  schema_revision: string | null;
257
249
  status: string;
258
250
  }
251
+ type SqaiConnectorConfig = Record<string, unknown>;
252
+ declare const SQAI_CONNECTOR_TYPES: readonly ["s3", "gcs", "azure", "clickhouse", "bigquery", "snowflake", "redshift", "postgres", "postgresql", "sqlite", "mysql", "mssql", "oracle", "neo4j", "redis", "elastic", "elasticsearch", "rest", "rest_api", "file", "file_upload", "github_repo", "gitlab_repo", "bitbucket_repo", "local_repo", "repo_archive"];
253
+ type SqaiConnectorType = (typeof SQAI_CONNECTOR_TYPES)[number];
254
+ declare const SQAI_CONNECTOR_TYPE_ALIASES: Readonly<Record<string, SqaiConnectorType>>;
255
+ interface SqaiConnectorPreview {
256
+ type?: SqaiConnectorType | string;
257
+ connector_type?: SqaiConnectorType | string;
258
+ provider?: string;
259
+ [key: string]: unknown;
260
+ }
261
+ interface SqaiManagedConnectOptions {
262
+ name?: string;
263
+ description?: string;
264
+ connectorId?: string;
265
+ connector?: SqaiConnectorPreview;
266
+ selection?: Record<string, unknown>;
267
+ datasetName?: string;
268
+ persist?: boolean;
269
+ visibility?: string;
270
+ connectionName?: string;
271
+ }
272
+ interface SqaiConnectorCreateRequest {
273
+ name: string;
274
+ connectorType: SqaiConnectorType | string;
275
+ config?: SqaiConnectorConfig;
276
+ description?: string;
277
+ visibility?: string;
278
+ }
279
+ interface SqaiConnectorUpdateRequest {
280
+ name?: string;
281
+ description?: string;
282
+ visibility?: string;
283
+ config?: SqaiConnectorConfig;
284
+ }
285
+ interface SqaiConnectorInfo {
286
+ id: string;
287
+ name: string;
288
+ connector_type: string;
289
+ status: string;
290
+ visibility: string;
291
+ description?: string | null;
292
+ last_tested_at?: string | null;
293
+ error_message?: string | null;
294
+ created_at?: string;
295
+ }
296
+ interface SqaiConnectorListResult {
297
+ connectors: SqaiConnectorInfo[];
298
+ total: number;
299
+ page: number;
300
+ limit: number;
301
+ pages: number;
302
+ }
303
+ interface SqaiConnectorTestResult {
304
+ success: boolean;
305
+ message: string;
306
+ latency_ms?: number | null;
307
+ status?: string | null;
308
+ error_type?: string | null;
309
+ recoverable?: boolean | null;
310
+ }
311
+ interface SqaiConnectorBrowseResult {
312
+ connector_type: string;
313
+ items: Array<Record<string, unknown>>;
314
+ total: number;
315
+ message: string;
316
+ labels: Record<string, unknown>;
317
+ discovery: Record<string, unknown>;
318
+ }
259
319
  interface QueryFilterCondition {
260
320
  column?: string;
261
321
  dimension_hint?: string;
@@ -414,6 +474,9 @@ type DispatchTarget = {
414
474
  interface SqaiConfig {
415
475
  mode?: SqaiMode;
416
476
  apiKey?: string;
477
+ /** Public SQAI deployment URL. Prefer this over engineUrl in new code. */
478
+ deploymentUrl?: string;
479
+ /** @deprecated Use deploymentUrl. Kept for backward compatibility. */
417
480
  engineUrl?: string;
418
481
  tenantId?: string;
419
482
  policy?: SqaiPolicy;
@@ -435,7 +498,7 @@ interface SqaiConfig {
435
498
  buildServiceUrl?: string;
436
499
  /** BYO substrate (tests). */
437
500
  runtime?: Runtime;
438
- /** BYO computation dispatch target (tests / custom self-hosted engines). */
501
+ /** BYO computation dispatch target (tests / custom SQAI deployments). */
439
502
  computeTarget?: DispatchTarget;
440
503
  }
441
504
  declare class SQAI {
@@ -453,9 +516,17 @@ declare class SQAI {
453
516
  private readonly timeoutMs;
454
517
  private readonly sources;
455
518
  constructor(config?: SqaiConfig);
456
- connect(source: string | Array<Record<string, unknown>> | Record<string, unknown>, options?: {
457
- name?: string;
458
- }): Promise<SqaiSource>;
519
+ connect(source?: string | Array<Record<string, unknown>> | Record<string, unknown> | null, options?: SqaiManagedConnectOptions): Promise<SqaiSource>;
520
+ createConnector(request: SqaiConnectorCreateRequest): Promise<SqaiConnectorInfo>;
521
+ listConnectors(options?: {
522
+ page?: number;
523
+ limit?: number;
524
+ }): Promise<SqaiConnectorListResult>;
525
+ getConnector(connectorId: string): Promise<SqaiConnectorInfo>;
526
+ updateConnector(connectorId: string, request: SqaiConnectorUpdateRequest): Promise<SqaiConnectorInfo>;
527
+ testConnector(connectorIdOrConnector: string | SqaiConnectorPreview): Promise<SqaiConnectorTestResult>;
528
+ browseConnector(connectorIdOrConnector: string | SqaiConnectorPreview): Promise<SqaiConnectorBrowseResult>;
529
+ deleteConnector(connectorId: string): Promise<void>;
459
530
  listSources(): SqaiSource[];
460
531
  resolve(spec: QuerySpec): Promise<ResolveResponse>;
461
532
  query(plan: ResolvedPlan | ResolveResponse): Promise<QueryResponse>;
@@ -487,9 +558,9 @@ declare function createSQAI(config?: SqaiConfig): SQAI;
487
558
 
488
559
  /** SQAI failure contract.
489
560
  *
490
- * Algenta error codes pass through verbatim (`source: "engine"`); SQAI adds
491
- * its own codes in the same snake_case vocabulary (`source: "sqai"`). A code
492
- * is never renamed and the same condition never gets two codes.
561
+ * Engine error codes pass through verbatim (`source: "engine"`); SQAI adds its
562
+ * own codes in the same snake_case vocabulary (`source: "sqai"`). A code is
563
+ * never renamed and the same condition never gets two codes.
493
564
  */
494
565
  type SqaiErrorSource = "engine" | "sqai";
495
566
  interface SqaiErrorOptions {
@@ -513,7 +584,7 @@ declare class SqaiError extends Error {
513
584
  request_id: string | null;
514
585
  };
515
586
  }
516
- /** Codes SQAI adds on top of the Algenta vocabulary. */
587
+ /** SQAI error codes surfaced by the SDK. */
517
588
  declare const SQAI_ERROR_CODES: readonly ["unsupported_operation", "seed_required", "duplicate_argument_binding", "policy_denied_source", "policy_denied_field", "policy_denied_function", "source_already_registered", "runtime_provision_failed", "daemon_port_conflict", "unsupported_platform", "compute_runtime_unavailable", "result_not_found", "contract_mismatch", "invalid_intent"];
518
589
 
519
590
  /** Two-hash determinism contract.
@@ -631,4 +702,4 @@ interface ValidatedComputation {
631
702
  declare function lookupCapability(index: ContractIndex, module: string, functionName: string): CapabilityEntry;
632
703
  declare function validateComputation(spec: ComputationSpec, index: ContractIndex, policy: SqaiPolicy | undefined, resolvedBindings: ResolvedBindingValue[]): ValidatedComputation;
633
704
 
634
- export { type AlgentaWireValue, type AskOutcome, type BindingProvenance, type CapabilityContract, type CapabilityEntry, type CapabilityMatch, type ColumnExtract, type ComputationBinding, type ComputationSpec, type ComputeResult, ContractIndex, type DeterminismEnvelope, type InvocationIdentity, LoginError, type LoginResult, type QueryFilterCondition, type QueryFilterSpec, type QuerySpec, type ResolvedBindingValue, ResultStore, type ResultStoreConfig, RuntimeProvisioner, type RuntimeStatus, SQAI, SQAI_ERROR_CODES, type SqaiConfig, SqaiError, type SqaiErrorSource, type SqaiIntent, type SqaiOutcome, type SqaiPolicy, type SqaiResultRecord, type SqaiSource, type SqaiValue, type ValidatedComputation, computationHash, createSQAI, currentPlatformKey, invocationHash, isReadOnlyEligible, login, logout, lookupCapability, readCachedApiKey, runtimeCacheDir, sqaiHome, validateComputation };
705
+ export { type AskOutcome, type BindingProvenance, type CapabilityContract, type CapabilityEntry, type CapabilityMatch, type ColumnExtract, type ComputationBinding, type ComputationSpec, type ComputeResult, ContractIndex, type DeterminismEnvelope, type InvocationIdentity, LoginError, type LoginResult, type QueryFilterCondition, type QueryFilterSpec, type QuerySpec, type ResolvedBindingValue, ResultStore, type ResultStoreConfig, RuntimeProvisioner, type RuntimeStatus, SQAI, SQAI_CONNECTOR_TYPES, SQAI_CONNECTOR_TYPE_ALIASES, SQAI_ERROR_CODES, type SqaiConfig, type SqaiConnectorBrowseResult, type SqaiConnectorConfig, type SqaiConnectorCreateRequest, type SqaiConnectorInfo, type SqaiConnectorListResult, type SqaiConnectorPreview, type SqaiConnectorTestResult, type SqaiConnectorType, type SqaiConnectorUpdateRequest, SqaiError, type SqaiErrorSource, type SqaiIntent, type SqaiManagedConnectOptions, type SqaiOutcome, type SqaiPolicy, type SqaiResultRecord, type SqaiSource, type SqaiValue, type ValidatedComputation, computationHash, createSQAI, currentPlatformKey, invocationHash, isReadOnlyEligible, login, logout, lookupCapability, readCachedApiKey, runtimeCacheDir, sqaiHome, validateComputation };