@thyn-ai/sqai 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -140,12 +140,29 @@ interface RuntimeStatus {
140
140
  platform: string;
141
141
  managed: boolean;
142
142
  }
143
+ /** A runtime bundle resolved for a specific module filter (build-on-provision). */
144
+ interface FilteredBundle {
145
+ url: string;
146
+ sha256: string;
147
+ version: string;
148
+ cacheKey: string;
149
+ }
143
150
  interface ProvisionerOptions {
144
151
  contract: CapabilityContract;
145
152
  autoInstall: boolean;
153
+ /**
154
+ * Build-on-provision: the developer's module filter. All 4,762 functions are
155
+ * available in the contract; only the selected modules are compiled + installed.
156
+ * Empty/undefined → the default pinned bundle (contract.runtime_bundle).
157
+ */
158
+ runtimeModules?: string[];
159
+ /** Build service that compiles a bundle for an exact filter (POST /v1/runtime/build). */
160
+ buildServiceUrl?: string;
146
161
  /** Injection points for tests. */
147
162
  runtimeFactory?: (config?: MojoRuntimeConfig) => MojoRuntime;
148
163
  downloadBundle?: (url: string, destination: string) => Promise<void>;
164
+ /** Resolve a filtered bundle (default: POST to buildServiceUrl). Test injection. */
165
+ resolveFilteredBundle?: (modules: string[], platformKey: string) => Promise<FilteredBundle>;
149
166
  /** Bundle cache directory (default: OS user cache — runtimeCacheDir()). */
150
167
  cacheDir?: string;
151
168
  /** Trust-root overrides (default: the embedded trust root). */
@@ -171,6 +188,27 @@ declare class RuntimeProvisioner {
171
188
  stop(): Promise<void>;
172
189
  private newRuntime;
173
190
  private cacheDir;
191
+ /** Normalized module filter (sorted, unique, non-empty) or null for the default bundle. */
192
+ private filterModules;
193
+ /** Ask the build service to compile + sign a bundle for exactly these modules. */
194
+ private resolveFilteredBundle;
195
+ /**
196
+ * The filter's cache key, computed IDENTICALLY to the build service
197
+ * (sha256("mods|platform|version")[:20], mods = sorted+unique, comma-joined).
198
+ * Lets the reuse fast-path find an already-running filtered daemon without a
199
+ * build-service round-trip. The build service's returned key is authoritative
200
+ * for install; this only has to match for the reuse optimization to hit.
201
+ */
202
+ private localCacheKey;
203
+ /**
204
+ * Deterministic per-filter daemon endpoint so a filtered runtime never collides
205
+ * with the default (or another filter's) daemon on the shared default socket.
206
+ */
207
+ private filterEndpoint;
208
+ private static readonly DAEMON_ENDPOINT_ENV;
209
+ /** Point the about-to-be-spawned daemon at a filter-specific socket/port/dir. */
210
+ private applyDaemonEndpointEnv;
211
+ private restoreEnv;
174
212
  private doEnsure;
175
213
  private provisionError;
176
214
  private wrapVerificationError;
@@ -179,7 +217,7 @@ declare class RuntimeProvisioner {
179
217
  private verifiedInstallOrNull;
180
218
  private acquireLock;
181
219
  private lockIsStale;
182
- /** Serialize installers on `<cacheDir>/<version>.lock`; returns the verified install. */
220
+ /** Serialize installers on `<cacheDir>/<installKey>.lock`; returns the verified install. */
183
221
  private ensureInstalled;
184
222
  /** Holder-of-the-lock path: download → verify → extract → atomic rename. */
185
223
  private downloadVerifyExtract;
@@ -197,12 +235,14 @@ declare class RuntimeProvisioner {
197
235
 
198
236
  /** Contract-derived wire value: everything the computation plane can
199
237
  * transport. The wire schema transports; the capability contract authorizes. */
200
- type AlgentaWireValue = null | boolean | number | string | AlgentaWireValue[] | {
201
- [key: string]: AlgentaWireValue;
238
+ type SqaiValue = null | boolean | number | string | SqaiValue[] | {
239
+ [key: string]: SqaiValue;
202
240
  } | {
203
241
  type: "decimal" | "bigint";
204
242
  value: string;
205
243
  };
244
+ /** @deprecated Renamed to {@link SqaiValue}. Kept as a non-breaking alias. */
245
+ type AlgentaWireValue = SqaiValue;
206
246
  interface SqaiSource {
207
247
  name: string;
208
248
  source_id: string | null;
@@ -253,8 +293,8 @@ type ComputationBinding = {
253
293
  interface ComputationSpec {
254
294
  module: string;
255
295
  function: string;
256
- args?: AlgentaWireValue[];
257
- kwargs?: Record<string, AlgentaWireValue>;
296
+ args?: SqaiValue[];
297
+ kwargs?: Record<string, SqaiValue>;
258
298
  bindings?: ComputationBinding[];
259
299
  seed?: number | string;
260
300
  }
@@ -287,7 +327,7 @@ interface BindingProvenance {
287
327
  }
288
328
  interface ComputeResult {
289
329
  status: "ok";
290
- value: AlgentaWireValue;
330
+ value: SqaiValue;
291
331
  value_type: string;
292
332
  module: string;
293
333
  function: string;
@@ -384,6 +424,15 @@ interface SqaiConfig {
384
424
  timeout?: number;
385
425
  maxRetries?: number;
386
426
  resultStore?: ResultStoreConfig;
427
+ /**
428
+ * Build-on-provision module filter. All 4,762 functions are available in the
429
+ * contract; set this to install only the modules you use. The build service
430
+ * compiles + signs a bundle for exactly this set (cached by filter-hash).
431
+ * Omit for the default pinned bundle. Env: SQAI_RUNTIME_MODULES (comma-separated).
432
+ */
433
+ runtimeModules?: string[];
434
+ /** Build service endpoint for filtered bundles. Env: SQAI_BUILD_SERVICE_URL. */
435
+ buildServiceUrl?: string;
387
436
  /** BYO substrate (tests). */
388
437
  runtime?: Runtime;
389
438
  /** BYO computation dispatch target (tests / custom self-hosted engines). */
@@ -438,11 +487,11 @@ declare function createSQAI(config?: SqaiConfig): SQAI;
438
487
 
439
488
  /** SQAI failure contract.
440
489
  *
441
- * Algenta error codes pass through verbatim (`source: "algenta"`); SQAI adds
490
+ * Algenta error codes pass through verbatim (`source: "engine"`); SQAI adds
442
491
  * its own codes in the same snake_case vocabulary (`source: "sqai"`). A code
443
492
  * is never renamed and the same condition never gets two codes.
444
493
  */
445
- type SqaiErrorSource = "algenta" | "sqai";
494
+ type SqaiErrorSource = "engine" | "sqai";
446
495
  interface SqaiErrorOptions {
447
496
  retryable?: boolean;
448
497
  requestId?: string | null;
@@ -485,8 +534,8 @@ declare const SQAI_ERROR_CODES: readonly ["unsupported_operation", "seed_require
485
534
  interface InvocationIdentity {
486
535
  module: string;
487
536
  function: string;
488
- args: AlgentaWireValue[];
489
- kwargs: Record<string, AlgentaWireValue>;
537
+ args: SqaiValue[];
538
+ kwargs: Record<string, SqaiValue>;
490
539
  resolved_bindings: Array<{
491
540
  parameter: string | number;
492
541
  source_name: string;
@@ -539,17 +588,17 @@ declare class ResultStore {
539
588
 
540
589
  interface ResolvedBindingValue {
541
590
  parameter: string | number;
542
- values: AlgentaWireValue;
591
+ values: SqaiValue;
543
592
  provenance: BindingProvenance;
544
593
  }
545
594
  interface ValidatedComputation {
546
595
  entry: CapabilityEntry;
547
596
  /** Final positional argument vector, ordered by the signature params. */
548
- argsVector: AlgentaWireValue[];
597
+ argsVector: SqaiValue[];
549
598
  seed: number | string | null;
550
599
  bindings: ResolvedBindingValue[];
551
600
  }
552
601
  declare function lookupCapability(index: ContractIndex, module: string, functionName: string): CapabilityEntry;
553
602
  declare function validateComputation(spec: ComputationSpec, index: ContractIndex, policy: SqaiPolicy | undefined, resolvedBindings: ResolvedBindingValue[]): ValidatedComputation;
554
603
 
555
- 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, 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 ValidatedComputation, computationHash, createSQAI, currentPlatformKey, invocationHash, isReadOnlyEligible, lookupCapability, runtimeCacheDir, validateComputation };
604
+ 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, 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, lookupCapability, runtimeCacheDir, validateComputation };
package/dist/index.d.ts CHANGED
@@ -140,12 +140,29 @@ interface RuntimeStatus {
140
140
  platform: string;
141
141
  managed: boolean;
142
142
  }
143
+ /** A runtime bundle resolved for a specific module filter (build-on-provision). */
144
+ interface FilteredBundle {
145
+ url: string;
146
+ sha256: string;
147
+ version: string;
148
+ cacheKey: string;
149
+ }
143
150
  interface ProvisionerOptions {
144
151
  contract: CapabilityContract;
145
152
  autoInstall: boolean;
153
+ /**
154
+ * Build-on-provision: the developer's module filter. All 4,762 functions are
155
+ * available in the contract; only the selected modules are compiled + installed.
156
+ * Empty/undefined → the default pinned bundle (contract.runtime_bundle).
157
+ */
158
+ runtimeModules?: string[];
159
+ /** Build service that compiles a bundle for an exact filter (POST /v1/runtime/build). */
160
+ buildServiceUrl?: string;
146
161
  /** Injection points for tests. */
147
162
  runtimeFactory?: (config?: MojoRuntimeConfig) => MojoRuntime;
148
163
  downloadBundle?: (url: string, destination: string) => Promise<void>;
164
+ /** Resolve a filtered bundle (default: POST to buildServiceUrl). Test injection. */
165
+ resolveFilteredBundle?: (modules: string[], platformKey: string) => Promise<FilteredBundle>;
149
166
  /** Bundle cache directory (default: OS user cache — runtimeCacheDir()). */
150
167
  cacheDir?: string;
151
168
  /** Trust-root overrides (default: the embedded trust root). */
@@ -171,6 +188,27 @@ declare class RuntimeProvisioner {
171
188
  stop(): Promise<void>;
172
189
  private newRuntime;
173
190
  private cacheDir;
191
+ /** Normalized module filter (sorted, unique, non-empty) or null for the default bundle. */
192
+ private filterModules;
193
+ /** Ask the build service to compile + sign a bundle for exactly these modules. */
194
+ private resolveFilteredBundle;
195
+ /**
196
+ * The filter's cache key, computed IDENTICALLY to the build service
197
+ * (sha256("mods|platform|version")[:20], mods = sorted+unique, comma-joined).
198
+ * Lets the reuse fast-path find an already-running filtered daemon without a
199
+ * build-service round-trip. The build service's returned key is authoritative
200
+ * for install; this only has to match for the reuse optimization to hit.
201
+ */
202
+ private localCacheKey;
203
+ /**
204
+ * Deterministic per-filter daemon endpoint so a filtered runtime never collides
205
+ * with the default (or another filter's) daemon on the shared default socket.
206
+ */
207
+ private filterEndpoint;
208
+ private static readonly DAEMON_ENDPOINT_ENV;
209
+ /** Point the about-to-be-spawned daemon at a filter-specific socket/port/dir. */
210
+ private applyDaemonEndpointEnv;
211
+ private restoreEnv;
174
212
  private doEnsure;
175
213
  private provisionError;
176
214
  private wrapVerificationError;
@@ -179,7 +217,7 @@ declare class RuntimeProvisioner {
179
217
  private verifiedInstallOrNull;
180
218
  private acquireLock;
181
219
  private lockIsStale;
182
- /** Serialize installers on `<cacheDir>/<version>.lock`; returns the verified install. */
220
+ /** Serialize installers on `<cacheDir>/<installKey>.lock`; returns the verified install. */
183
221
  private ensureInstalled;
184
222
  /** Holder-of-the-lock path: download → verify → extract → atomic rename. */
185
223
  private downloadVerifyExtract;
@@ -197,12 +235,14 @@ declare class RuntimeProvisioner {
197
235
 
198
236
  /** Contract-derived wire value: everything the computation plane can
199
237
  * transport. The wire schema transports; the capability contract authorizes. */
200
- type AlgentaWireValue = null | boolean | number | string | AlgentaWireValue[] | {
201
- [key: string]: AlgentaWireValue;
238
+ type SqaiValue = null | boolean | number | string | SqaiValue[] | {
239
+ [key: string]: SqaiValue;
202
240
  } | {
203
241
  type: "decimal" | "bigint";
204
242
  value: string;
205
243
  };
244
+ /** @deprecated Renamed to {@link SqaiValue}. Kept as a non-breaking alias. */
245
+ type AlgentaWireValue = SqaiValue;
206
246
  interface SqaiSource {
207
247
  name: string;
208
248
  source_id: string | null;
@@ -253,8 +293,8 @@ type ComputationBinding = {
253
293
  interface ComputationSpec {
254
294
  module: string;
255
295
  function: string;
256
- args?: AlgentaWireValue[];
257
- kwargs?: Record<string, AlgentaWireValue>;
296
+ args?: SqaiValue[];
297
+ kwargs?: Record<string, SqaiValue>;
258
298
  bindings?: ComputationBinding[];
259
299
  seed?: number | string;
260
300
  }
@@ -287,7 +327,7 @@ interface BindingProvenance {
287
327
  }
288
328
  interface ComputeResult {
289
329
  status: "ok";
290
- value: AlgentaWireValue;
330
+ value: SqaiValue;
291
331
  value_type: string;
292
332
  module: string;
293
333
  function: string;
@@ -384,6 +424,15 @@ interface SqaiConfig {
384
424
  timeout?: number;
385
425
  maxRetries?: number;
386
426
  resultStore?: ResultStoreConfig;
427
+ /**
428
+ * Build-on-provision module filter. All 4,762 functions are available in the
429
+ * contract; set this to install only the modules you use. The build service
430
+ * compiles + signs a bundle for exactly this set (cached by filter-hash).
431
+ * Omit for the default pinned bundle. Env: SQAI_RUNTIME_MODULES (comma-separated).
432
+ */
433
+ runtimeModules?: string[];
434
+ /** Build service endpoint for filtered bundles. Env: SQAI_BUILD_SERVICE_URL. */
435
+ buildServiceUrl?: string;
387
436
  /** BYO substrate (tests). */
388
437
  runtime?: Runtime;
389
438
  /** BYO computation dispatch target (tests / custom self-hosted engines). */
@@ -438,11 +487,11 @@ declare function createSQAI(config?: SqaiConfig): SQAI;
438
487
 
439
488
  /** SQAI failure contract.
440
489
  *
441
- * Algenta error codes pass through verbatim (`source: "algenta"`); SQAI adds
490
+ * Algenta error codes pass through verbatim (`source: "engine"`); SQAI adds
442
491
  * its own codes in the same snake_case vocabulary (`source: "sqai"`). A code
443
492
  * is never renamed and the same condition never gets two codes.
444
493
  */
445
- type SqaiErrorSource = "algenta" | "sqai";
494
+ type SqaiErrorSource = "engine" | "sqai";
446
495
  interface SqaiErrorOptions {
447
496
  retryable?: boolean;
448
497
  requestId?: string | null;
@@ -485,8 +534,8 @@ declare const SQAI_ERROR_CODES: readonly ["unsupported_operation", "seed_require
485
534
  interface InvocationIdentity {
486
535
  module: string;
487
536
  function: string;
488
- args: AlgentaWireValue[];
489
- kwargs: Record<string, AlgentaWireValue>;
537
+ args: SqaiValue[];
538
+ kwargs: Record<string, SqaiValue>;
490
539
  resolved_bindings: Array<{
491
540
  parameter: string | number;
492
541
  source_name: string;
@@ -539,17 +588,17 @@ declare class ResultStore {
539
588
 
540
589
  interface ResolvedBindingValue {
541
590
  parameter: string | number;
542
- values: AlgentaWireValue;
591
+ values: SqaiValue;
543
592
  provenance: BindingProvenance;
544
593
  }
545
594
  interface ValidatedComputation {
546
595
  entry: CapabilityEntry;
547
596
  /** Final positional argument vector, ordered by the signature params. */
548
- argsVector: AlgentaWireValue[];
597
+ argsVector: SqaiValue[];
549
598
  seed: number | string | null;
550
599
  bindings: ResolvedBindingValue[];
551
600
  }
552
601
  declare function lookupCapability(index: ContractIndex, module: string, functionName: string): CapabilityEntry;
553
602
  declare function validateComputation(spec: ComputationSpec, index: ContractIndex, policy: SqaiPolicy | undefined, resolvedBindings: ResolvedBindingValue[]): ValidatedComputation;
554
603
 
555
- 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, 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 ValidatedComputation, computationHash, createSQAI, currentPlatformKey, invocationHash, isReadOnlyEligible, lookupCapability, runtimeCacheDir, validateComputation };
604
+ 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, 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, lookupCapability, runtimeCacheDir, validateComputation };