@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/dist/index.d.ts 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 };
package/dist/index.js CHANGED
@@ -112,13 +112,13 @@ var SQAI_ERROR_CODES = [
112
112
  "contract_mismatch",
113
113
  "invalid_intent"
114
114
  ];
115
- var RETRYABLE_ALGENTA_CODES = /* @__PURE__ */ new Set([
115
+ var RETRYABLE_ENGINE_CODES = /* @__PURE__ */ new Set([
116
116
  "network_error",
117
117
  "timeout",
118
118
  "rate_limited",
119
119
  "service_unavailable"
120
120
  ]);
121
- function fromAlgentaError(error) {
121
+ function fromEngineError(error) {
122
122
  if (error instanceof SqaiError) {
123
123
  return error;
124
124
  }
@@ -128,7 +128,7 @@ function fromAlgentaError(error) {
128
128
  const details = errorLike.details && typeof errorLike.details === "object" ? errorLike.details : {};
129
129
  return new SqaiError(code, message, {
130
130
  source: "engine",
131
- retryable: RETRYABLE_ALGENTA_CODES.has(code),
131
+ retryable: RETRYABLE_ENGINE_CODES.has(code),
132
132
  details
133
133
  });
134
134
  }
@@ -137,12 +137,14 @@ function fromAlgentaError(error) {
137
137
  var DEFAULT_BUILD_SERVICE_URL = "https://sqai-buildservice.fly.dev";
138
138
  function readEnv(env = process.env) {
139
139
  const apiKey = (env.SQAI_API_KEY ?? "").trim() || void 0;
140
- const engineUrl = (env.SQAI_ENGINE_URL ?? "").trim() || void 0;
140
+ const deploymentUrl = (env.SQAI_DEPLOYMENT_URL ?? "").trim() || void 0;
141
+ const legacyEngineUrl = (env.SQAI_ENGINE_URL ?? "").trim() || void 0;
142
+ const engineUrl = deploymentUrl ?? legacyEngineUrl;
141
143
  const autoInstall = (env.SQAI_RUNTIME_AUTO_INSTALL ?? "").trim() !== "0";
142
144
  const modulesRaw = (env.SQAI_RUNTIME_MODULES ?? "").split(",").map((m) => m.trim()).filter((m) => m.length > 0);
143
145
  const runtimeModules = modulesRaw.length > 0 ? modulesRaw : void 0;
144
146
  const buildServiceUrl = (env.SQAI_BUILD_SERVICE_URL ?? "").trim() || DEFAULT_BUILD_SERVICE_URL;
145
- return { apiKey, engineUrl, autoInstall, runtimeModules, buildServiceUrl };
147
+ return { apiKey, engineUrl, deploymentUrl, autoInstall, runtimeModules, buildServiceUrl };
146
148
  }
147
149
  function inferMode(explicit, resolved) {
148
150
  if (explicit) {
@@ -151,9 +153,6 @@ function inferMode(explicit, resolved) {
151
153
  if (resolved.engineUrl) {
152
154
  return "self_hosted";
153
155
  }
154
- if (resolved.apiKey) {
155
- return "api";
156
- }
157
156
  return "local";
158
157
  }
159
158
 
@@ -843,6 +842,9 @@ function digestsEqual(actualHex, expectedHex) {
843
842
  const expected = Buffer.from(expectedHex.toLowerCase(), "utf-8");
844
843
  return actual.length === expected.length && timingSafeEqual(actual, expected);
845
844
  }
845
+ function isGeneratedBytecodeCache(path) {
846
+ return path.split("/").includes("__pycache__") && path.endsWith(".pyc") && isSafeRelativePath(path);
847
+ }
846
848
  function parseVerifiedManifest(manifestBytes) {
847
849
  let manifest;
848
850
  try {
@@ -1051,6 +1053,9 @@ async function verifyInstalledBundleDir(installDir, expectations) {
1051
1053
  }
1052
1054
  const entry = byPath.get(relPath);
1053
1055
  if (entry === void 0) {
1056
+ if (isGeneratedBytecodeCache(relPath)) {
1057
+ continue;
1058
+ }
1054
1059
  throw new BundleVerificationError(
1055
1060
  "unlisted_member",
1056
1061
  `installed file not listed in signed manifest: '${relPath}'`
@@ -1219,6 +1224,21 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1219
1224
  }
1220
1225
  return new MojoRuntime(config ?? {});
1221
1226
  }
1227
+ async ensureLocalLoginKey() {
1228
+ if (this.options.runtimeFactory || process.env.ALGENTA_API_KEY || process.env.DE_API_KEY) {
1229
+ return;
1230
+ }
1231
+ const key = await readCachedApiKey();
1232
+ if (key) {
1233
+ process.env.ALGENTA_API_KEY = key;
1234
+ return;
1235
+ }
1236
+ throw new SqaiError(
1237
+ "login_required",
1238
+ "Local compute requires a free SQAI device login. Run `sqai login` once, or set SQAI_API_KEY in this process.",
1239
+ { details: { reason: "login_key_missing" } }
1240
+ );
1241
+ }
1222
1242
  cacheDir() {
1223
1243
  return this.options.cacheDir ?? runtimeCacheDir();
1224
1244
  }
@@ -1324,6 +1344,7 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1324
1344
  async doEnsure() {
1325
1345
  const platformKey = currentPlatformKey();
1326
1346
  const filter = this.filterModules();
1347
+ await this.ensureLocalLoginKey();
1327
1348
  const probeEndpoint = filter ? this.filterEndpoint(this.localCacheKey(filter, platformKey)) : void 0;
1328
1349
  const runtime = this.newRuntime(probeEndpoint ? { tcpAddress: probeEndpoint.tcp } : void 0);
1329
1350
  try {
@@ -1351,7 +1372,7 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1351
1372
  const supported = Object.keys(bundle.platforms);
1352
1373
  throw new SqaiError(
1353
1374
  "unsupported_platform",
1354
- 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}'.`,
1375
+ 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}'.`,
1355
1376
  { details: { platform: platformKey, supported } }
1356
1377
  );
1357
1378
  }
@@ -1459,12 +1480,22 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1459
1480
  }
1460
1481
  async lockIsStale(lockPath) {
1461
1482
  const freshMs = this.options.lockFreshMs ?? LOCK_FRESH_MS;
1483
+ const ageFromMtime = async () => {
1484
+ try {
1485
+ const stat = await fs2.stat(lockPath);
1486
+ return Date.now() - stat.mtimeMs;
1487
+ } catch (error) {
1488
+ const code = error.code;
1489
+ return code === "ENOENT" ? null : Number.POSITIVE_INFINITY;
1490
+ }
1491
+ };
1462
1492
  try {
1463
1493
  const raw = await fs2.readFile(lockPath, "utf-8");
1464
1494
  const parsed = JSON.parse(raw);
1465
1495
  const createdAt = typeof parsed.created_at === "string" ? Date.parse(parsed.created_at) : NaN;
1466
1496
  if (!Number.isFinite(createdAt)) {
1467
- return true;
1497
+ const age = await ageFromMtime();
1498
+ return age !== null && age >= freshMs;
1468
1499
  }
1469
1500
  return Date.now() - createdAt >= freshMs;
1470
1501
  } catch (error) {
@@ -1472,7 +1503,8 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1472
1503
  if (code === "ENOENT") {
1473
1504
  return false;
1474
1505
  }
1475
- return true;
1506
+ const age = await ageFromMtime();
1507
+ return age !== null && age >= freshMs;
1476
1508
  }
1477
1509
  }
1478
1510
  /** Serialize installers on `<cacheDir>/<installKey>.lock`; returns the verified install. */
@@ -1610,12 +1642,7 @@ var RuntimeProvisioner = class _RuntimeProvisioner {
1610
1642
  "start",
1611
1643
  "--foreground"
1612
1644
  ];
1613
- if (!process.env.ALGENTA_API_KEY && !process.env.DE_API_KEY) {
1614
- const key = await readCachedApiKey();
1615
- if (key) {
1616
- process.env.ALGENTA_API_KEY = key;
1617
- }
1618
- }
1645
+ await this.ensureLocalLoginKey();
1619
1646
  const managed = this.newRuntime(
1620
1647
  endpoint ? { autoStart: true, daemonCommand, tcpAddress: endpoint.tcp } : { autoStart: true, daemonCommand }
1621
1648
  );
@@ -1684,7 +1711,7 @@ async function dispatchComputation(target, entry, argsVector, seed, requestId, t
1684
1711
  request_id: response.request_id ?? requestId
1685
1712
  };
1686
1713
  } catch (error) {
1687
- throw fromAlgentaError(error);
1714
+ throw fromEngineError(error);
1688
1715
  }
1689
1716
  }
1690
1717
  return dispatchHttp(target, module, functionName, args, requestId);
@@ -1721,7 +1748,7 @@ async function dispatchHttp(target, module, functionName, args, requestId) {
1721
1748
  } catch (error) {
1722
1749
  throw new SqaiError(
1723
1750
  "compute_runtime_unavailable",
1724
- `The hosted compute endpoint is unreachable: ${error.message}. Check SQAI_ENGINE_URL / SQAI_API_KEY.`,
1751
+ `The SQAI deployment endpoint is unreachable: ${error.message}. Check SQAI_DEPLOYMENT_URL / SQAI_API_KEY.`,
1725
1752
  { retryable: true }
1726
1753
  );
1727
1754
  }
@@ -1904,7 +1931,7 @@ var SQAI = class {
1904
1931
  const env = readEnv();
1905
1932
  this.mode = inferMode(config.mode, env);
1906
1933
  this.apiKey = config.apiKey ?? env.apiKey;
1907
- this.engineUrl = config.engineUrl ?? env.engineUrl;
1934
+ this.engineUrl = config.deploymentUrl ?? config.engineUrl ?? env.engineUrl;
1908
1935
  this.tenantId = config.tenantId ?? null;
1909
1936
  this.policy = config.policy;
1910
1937
  this.configuredTarget = config.computeTarget;
@@ -1932,7 +1959,7 @@ var SQAI = class {
1932
1959
  this.algentaRuntime = this.rawRuntime;
1933
1960
  }
1934
1961
  // ── Query plane ────────────────────────────────────────────────────────────
1935
- async connect(source, options = {}) {
1962
+ async connect(source = null, options = {}) {
1936
1963
  try {
1937
1964
  const registration = await this.algentaRuntime.connect(source, options);
1938
1965
  const mapped = mapSource(registration);
@@ -1951,7 +1978,84 @@ var SQAI = class {
1951
1978
  this.sources.set(mapped.name, mapped);
1952
1979
  return mapped;
1953
1980
  } catch (error) {
1954
- throw error instanceof SqaiError ? error : fromAlgentaError(error);
1981
+ throw error instanceof SqaiError ? error : fromEngineError(error);
1982
+ }
1983
+ }
1984
+ async createConnector(request2) {
1985
+ const createConnector = this.algentaRuntime.createConnector;
1986
+ if (typeof createConnector !== "function") {
1987
+ throw unsupportedSubstrateOperation("createConnector");
1988
+ }
1989
+ try {
1990
+ return await createConnector.call(this.algentaRuntime, request2);
1991
+ } catch (error) {
1992
+ throw fromEngineError(error);
1993
+ }
1994
+ }
1995
+ async listConnectors(options = {}) {
1996
+ const listConnectors = this.algentaRuntime.listConnectors;
1997
+ if (typeof listConnectors !== "function") {
1998
+ throw unsupportedSubstrateOperation("listConnectors");
1999
+ }
2000
+ try {
2001
+ return await listConnectors.call(this.algentaRuntime, options);
2002
+ } catch (error) {
2003
+ throw fromEngineError(error);
2004
+ }
2005
+ }
2006
+ async getConnector(connectorId) {
2007
+ const getConnector = this.algentaRuntime.getConnector;
2008
+ if (typeof getConnector !== "function") {
2009
+ throw unsupportedSubstrateOperation("getConnector");
2010
+ }
2011
+ try {
2012
+ return await getConnector.call(this.algentaRuntime, connectorId);
2013
+ } catch (error) {
2014
+ throw fromEngineError(error);
2015
+ }
2016
+ }
2017
+ async updateConnector(connectorId, request2) {
2018
+ const updateConnector = this.algentaRuntime.updateConnector;
2019
+ if (typeof updateConnector !== "function") {
2020
+ throw unsupportedSubstrateOperation("updateConnector");
2021
+ }
2022
+ try {
2023
+ return await updateConnector.call(this.algentaRuntime, connectorId, request2);
2024
+ } catch (error) {
2025
+ throw fromEngineError(error);
2026
+ }
2027
+ }
2028
+ async testConnector(connectorIdOrConnector) {
2029
+ const testConnector = this.algentaRuntime.testConnector;
2030
+ if (typeof testConnector !== "function") {
2031
+ throw unsupportedSubstrateOperation("testConnector");
2032
+ }
2033
+ try {
2034
+ return await testConnector.call(this.algentaRuntime, connectorIdOrConnector);
2035
+ } catch (error) {
2036
+ throw fromEngineError(error);
2037
+ }
2038
+ }
2039
+ async browseConnector(connectorIdOrConnector) {
2040
+ const browseConnector = this.algentaRuntime.browseConnector;
2041
+ if (typeof browseConnector !== "function") {
2042
+ throw unsupportedSubstrateOperation("browseConnector");
2043
+ }
2044
+ try {
2045
+ return await browseConnector.call(this.algentaRuntime, connectorIdOrConnector);
2046
+ } catch (error) {
2047
+ throw fromEngineError(error);
2048
+ }
2049
+ }
2050
+ async deleteConnector(connectorId) {
2051
+ const deleteConnector = this.algentaRuntime.deleteConnector;
2052
+ if (typeof deleteConnector !== "function") {
2053
+ throw unsupportedSubstrateOperation("deleteConnector");
2054
+ }
2055
+ try {
2056
+ await deleteConnector.call(this.algentaRuntime, connectorId);
2057
+ } catch (error) {
2058
+ throw fromEngineError(error);
1955
2059
  }
1956
2060
  }
1957
2061
  listSources() {
@@ -1962,28 +2066,28 @@ var SQAI = class {
1962
2066
  try {
1963
2067
  return await this.algentaRuntime.resolve(spec);
1964
2068
  } catch (error) {
1965
- throw fromAlgentaError(error);
2069
+ throw fromEngineError(error);
1966
2070
  }
1967
2071
  }
1968
2072
  async query(plan) {
1969
2073
  try {
1970
2074
  return await this.algentaRuntime.query(plan);
1971
2075
  } catch (error) {
1972
- throw fromAlgentaError(error);
2076
+ throw fromEngineError(error);
1973
2077
  }
1974
2078
  }
1975
2079
  async queryWithMetadata(plan) {
1976
2080
  try {
1977
2081
  return await this.algentaRuntime.queryWithMetadata(plan);
1978
2082
  } catch (error) {
1979
- throw fromAlgentaError(error);
2083
+ throw fromEngineError(error);
1980
2084
  }
1981
2085
  }
1982
2086
  async verify(plan) {
1983
2087
  try {
1984
2088
  return await this.algentaRuntime.verify(plan);
1985
2089
  } catch (error) {
1986
- throw fromAlgentaError(error);
2090
+ throw fromEngineError(error);
1987
2091
  }
1988
2092
  }
1989
2093
  async ask(spec) {
@@ -2005,14 +2109,14 @@ var SQAI = class {
2005
2109
  if (typeof this.algentaRuntime.extractColumns !== "function") {
2006
2110
  throw new SqaiError(
2007
2111
  "unsupported_operation",
2008
- "The installed algenta-sdk build does not provide extractColumns; upgrade the substrate.",
2009
- { details: { required: "algenta-sdk extractColumns" } }
2112
+ "The installed SQAI package does not provide extractColumns; upgrade SQAI.",
2113
+ { details: { required: "sqai.extractColumns" } }
2010
2114
  );
2011
2115
  }
2012
2116
  try {
2013
2117
  return await this.algentaRuntime.extractColumns(sourceName, columns, options);
2014
2118
  } catch (error) {
2015
- throw fromAlgentaError(error);
2119
+ throw fromEngineError(error);
2016
2120
  }
2017
2121
  }
2018
2122
  // ── Computation plane ──────────────────────────────────────────────────────
@@ -2142,7 +2246,7 @@ var SQAI = class {
2142
2246
  "API mode requires SQAI_API_KEY for the computation plane."
2143
2247
  );
2144
2248
  }
2145
- return { kind: "http", baseUrl: "https://api.algenta.ai", apiKey: this.apiKey };
2249
+ return { kind: "http", baseUrl: "https://api.sqai.com", apiKey: this.apiKey };
2146
2250
  }
2147
2251
  const runtime = await this.provisioner.ensure();
2148
2252
  return { kind: "local", runtime };
@@ -2200,6 +2304,13 @@ var SQAI = class {
2200
2304
  function createSQAI(config = {}) {
2201
2305
  return new SQAI(config);
2202
2306
  }
2307
+ function unsupportedSubstrateOperation(operation) {
2308
+ return new SqaiError(
2309
+ "unsupported_operation",
2310
+ `The installed SQAI package does not provide ${operation}; upgrade SQAI.`,
2311
+ { details: { required: `sqai.${operation}` } }
2312
+ );
2313
+ }
2203
2314
  function mapSource(registration) {
2204
2315
  const record = registration;
2205
2316
  return {
@@ -2213,12 +2324,60 @@ function mapSource(registration) {
2213
2324
  status: String(registration.status ?? "ready")
2214
2325
  };
2215
2326
  }
2327
+
2328
+ // src/types.ts
2329
+ var SQAI_CONNECTOR_TYPES = [
2330
+ "s3",
2331
+ "gcs",
2332
+ "azure",
2333
+ "clickhouse",
2334
+ "bigquery",
2335
+ "snowflake",
2336
+ "redshift",
2337
+ "postgres",
2338
+ "postgresql",
2339
+ "sqlite",
2340
+ "mysql",
2341
+ "mssql",
2342
+ "oracle",
2343
+ "neo4j",
2344
+ "redis",
2345
+ "elastic",
2346
+ "elasticsearch",
2347
+ "rest",
2348
+ "rest_api",
2349
+ "file",
2350
+ "file_upload",
2351
+ "github_repo",
2352
+ "gitlab_repo",
2353
+ "bitbucket_repo",
2354
+ "local_repo",
2355
+ "repo_archive"
2356
+ ];
2357
+ var SQAI_CONNECTOR_TYPE_ALIASES = {
2358
+ postgresql: "postgres",
2359
+ click_house: "clickhouse",
2360
+ redis_cache: "redis",
2361
+ elastic: "elasticsearch",
2362
+ rest_api: "rest",
2363
+ file_upload: "file",
2364
+ github: "github_repo",
2365
+ github_repository: "github_repo",
2366
+ gitlab: "gitlab_repo",
2367
+ gitlab_repository: "gitlab_repo",
2368
+ bitbucket: "bitbucket_repo",
2369
+ bitbucket_repository: "bitbucket_repo",
2370
+ local_repository: "local_repo",
2371
+ archive_repository: "repo_archive"
2372
+ };
2216
2373
  export {
2217
2374
  ContractIndex,
2218
2375
  LoginError,
2219
2376
  ResultStore,
2220
2377
  RuntimeProvisioner,
2221
2378
  SQAI,
2379
+ SQAI_CONNECTOR_TYPES,
2380
+ SQAI_CONNECTOR_TYPE_ALIASES,
2222
2381
  SQAI_ERROR_CODES,
2223
2382
  SqaiError,
2224
2383
  computationHash,
@@ -2234,4 +2393,3 @@ export {
2234
2393
  sqaiHome,
2235
2394
  validateComputation
2236
2395
  };
2237
- //# sourceMappingURL=index.js.map
package/dist/unsafe.cjs CHANGED
@@ -38,4 +38,3 @@ var getUnsafeAlgentaRuntime = getUnsafeRuntime;
38
38
  getUnsafeAlgentaRuntime,
39
39
  getUnsafeRuntime
40
40
  });
41
- //# sourceMappingURL=unsafe.cjs.map
package/dist/unsafe.js CHANGED
@@ -12,4 +12,3 @@ export {
12
12
  getUnsafeAlgentaRuntime,
13
13
  getUnsafeRuntime
14
14
  };
15
- //# sourceMappingURL=unsafe.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thyn-ai/sqai",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "SQAI (Structured Query AI) — the deterministic, read-only structured-data SDK for AI agents, with full provenance.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -49,7 +49,6 @@
49
49
  "structured-data",
50
50
  "deterministic",
51
51
  "read-only",
52
- "algenta",
53
52
  "sqai"
54
53
  ],
55
54
  "scripts": {