@kortexya/reasoninglayer 1.13.0 → 1.14.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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/config.ts
8
- var SDK_VERSION = "1.13.0";
8
+ var SDK_VERSION = "1.14.0";
9
9
  function resolveConfig(config) {
10
10
  if (!config.baseUrl) {
11
11
  throw new Error("ClientConfig.baseUrl is required");
@@ -541,29 +541,61 @@ var HttpClient = class {
541
541
  };
542
542
  };
543
543
 
544
- // src/serialization.ts
544
+ // src/user-data-fields.ts
545
545
  var USER_DATA_FIELDS = /* @__PURE__ */ new Set([
546
- // features — term/query feature maps (Record<string, ValueDto>)
547
- "features",
548
- // bindings — variable binding maps
546
+ "annotations",
547
+ "answers",
548
+ "antecedentFeatures",
549
+ "antecedent_features",
549
550
  "bindings",
550
- // evidence — causal evidence maps
551
+ "coefficients",
552
+ "conceptValues",
553
+ "concept_values",
554
+ "contextDependentRelations",
555
+ "context_dependent_relations",
556
+ "correctPattern",
557
+ "correct_pattern",
558
+ "currentValues",
559
+ "current_values",
560
+ "dataVersions",
561
+ "data_versions",
551
562
  "evidence",
552
- // exogenous values — causal intervention values
553
- "exogenous_values",
554
- "exogenousValues",
555
- // modified/suggested params — action review params
556
- "modified_params",
563
+ "extra",
564
+ "extracted",
565
+ "features",
566
+ "fieldTypes",
567
+ "field_types",
568
+ "filter",
569
+ "initialBindings",
570
+ "initial_bindings",
571
+ "inputs",
572
+ "interventions",
557
573
  "modifiedParams",
558
- "suggested_params",
559
- "suggestedParams",
560
- // match key — row matching keys
561
- "match_key",
562
- "matchKey",
563
- // concept values — RAG concept values
564
- "concept_values",
565
- "conceptValues"
574
+ "modified_params",
575
+ "observations",
576
+ "optionalInputs",
577
+ "optional_inputs",
578
+ "original",
579
+ "originalValues",
580
+ "original_values",
581
+ "outputs",
582
+ "perStrategyTaxonomies",
583
+ "per_strategy_taxonomies",
584
+ "propsOverride",
585
+ "props_override",
586
+ "roleMinimums",
587
+ "role_minimums",
588
+ "scope",
589
+ "scoresByName",
590
+ "scores_by_name",
591
+ "sortNames",
592
+ "sort_names",
593
+ "topK",
594
+ "top_k",
595
+ "values"
566
596
  ]);
597
+
598
+ // src/serialization.ts
567
599
  function camelToSnake(str) {
568
600
  return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
569
601
  }
@@ -630,11 +662,11 @@ function buildAuthHeaders(config) {
630
662
  return headers;
631
663
  }
632
664
  function transformRequestInit(init) {
633
- if (!init?.body || typeof init.body !== "string") return init;
634
- const headers = init.headers;
635
- if (hasRawBodyHeader(headers)) {
636
- return { ...init, headers: withoutRawBodyHeader(headers) };
665
+ if (!init) return init;
666
+ if (hasRawBodyHeader(init.headers)) {
667
+ return { ...init, headers: withoutRawBodyHeader(init.headers) };
637
668
  }
669
+ if (!init.body || typeof init.body !== "string") return init;
638
670
  try {
639
671
  const parsed = JSON.parse(init.body);
640
672
  const snaked = toSnakeCase(parsed);
@@ -643,15 +675,14 @@ function transformRequestInit(init) {
643
675
  return init;
644
676
  }
645
677
  }
678
+ var RAW_BODY_HEADER_LOWER = RAW_BODY_HEADER.toLowerCase();
646
679
  function hasRawBodyHeader(headers) {
647
680
  if (!headers) return false;
648
681
  if (headers instanceof Headers) return headers.get(RAW_BODY_HEADER) !== null;
649
682
  if (Array.isArray(headers)) {
650
- return headers.some(([name]) => name.toLowerCase() === RAW_BODY_HEADER.toLowerCase());
683
+ return headers.some(([name]) => name.toLowerCase() === RAW_BODY_HEADER_LOWER);
651
684
  }
652
- return Object.keys(headers).some(
653
- (name) => name.toLowerCase() === RAW_BODY_HEADER.toLowerCase()
654
- );
685
+ return Object.keys(headers).some((name) => name.toLowerCase() === RAW_BODY_HEADER_LOWER);
655
686
  }
656
687
  function withoutRawBodyHeader(headers) {
657
688
  if (headers instanceof Headers) {
@@ -660,12 +691,12 @@ function withoutRawBodyHeader(headers) {
660
691
  return copy;
661
692
  }
662
693
  if (Array.isArray(headers)) {
663
- return headers.filter(([name]) => name.toLowerCase() !== RAW_BODY_HEADER.toLowerCase());
694
+ return headers.filter(([name]) => name.toLowerCase() !== RAW_BODY_HEADER_LOWER);
664
695
  }
665
696
  if (headers) {
666
697
  const rest = {};
667
698
  for (const [name, value] of Object.entries(headers)) {
668
- if (name.toLowerCase() !== RAW_BODY_HEADER.toLowerCase()) {
699
+ if (name.toLowerCase() !== RAW_BODY_HEADER_LOWER) {
669
700
  rest[name] = value;
670
701
  }
671
702
  }
@@ -12089,7 +12120,8 @@ function ProofDtoFromApiToFront(dto) {
12089
12120
  ruleLabel: dto.rule_label,
12090
12121
  substitution: HomoiconicSubstitutionDtoFromApiToFront(dto.substitution),
12091
12122
  subproofs: dto.subproofs?.map(ProofDtoFromApiToFront),
12092
- certainty: dto.certainty
12123
+ certainty: dto.certainty,
12124
+ residuated: dto.residuated
12093
12125
  };
12094
12126
  }
12095
12127
  function ProvenanceTagDtoFromApiToFront(dto) {
@@ -12105,6 +12137,7 @@ function SolutionDtoFromApiToFront(dto) {
12105
12137
  certainty: dto.certainty,
12106
12138
  evidenceMatched: dto.evidence_matched ?? void 0,
12107
12139
  evidenceRatio: dto.evidence_ratio ?? void 0,
12140
+ evidenceSupport: dto.evidence_support ?? void 0,
12108
12141
  residuatedSorts: dto.residuated_sorts
12109
12142
  };
12110
12143
  }
@@ -12483,11 +12516,19 @@ function TaggedForwardChainResponseFromApiToFront(dto) {
12483
12516
  totalFacts: dto.total_facts
12484
12517
  };
12485
12518
  }
12519
+ function RuleAggregatorDtoFromFrontToApi(model) {
12520
+ return {
12521
+ group_by: model.groupBy,
12522
+ op: model.op,
12523
+ target: model.target
12524
+ };
12525
+ }
12486
12526
  function AddRuleRequestFromFrontToApi(model) {
12487
12527
  return {
12488
12528
  term: TermInputDtoFromFrontToApi(model.term),
12489
12529
  antecedents: model.antecedents?.map(TermInputDtoFromFrontToApi),
12490
- certainty: model.certainty
12530
+ certainty: model.certainty,
12531
+ aggregator: model.aggregator ? RuleAggregatorDtoFromFrontToApi(model.aggregator) : model.aggregator
12491
12532
  };
12492
12533
  }
12493
12534
  function AddFactRequestFromFrontToApi(model) {
@@ -12524,7 +12565,8 @@ function ForwardChainRequestFromFrontToApi(model) {
12524
12565
  persist_derived: model.persistDerived,
12525
12566
  enable_provenance_tags: model.enableProvenanceTags,
12526
12567
  max_iterations: model.maxIterations,
12527
- max_facts: model.maxFacts
12568
+ max_facts: model.maxFacts,
12569
+ emit_provenance: model.emitProvenance
12528
12570
  };
12529
12571
  }
12530
12572
  function FuzzyProveRequestFromFrontToApi(model) {
@@ -12535,7 +12577,8 @@ function FuzzyProveRequestFromFrontToApi(model) {
12535
12577
  max_solutions: model.maxSolutions,
12536
12578
  open_world: model.openWorld,
12537
12579
  save_goal: model.saveGoal,
12538
- tnorm: model.tnorm
12580
+ tnorm: model.tnorm,
12581
+ scope: model.scope
12539
12582
  };
12540
12583
  }
12541
12584
  function BulkFuzzyProveRequestFromFrontToApi(model) {
@@ -12641,14 +12684,29 @@ var InferenceClient = class {
12641
12684
  /**
12642
12685
  * Add an inference rule.
12643
12686
  *
12644
- * @param request - Rule definition using TermInputDto.
12687
+ * @param request - Rule definition using TermInputDto. Set `aggregator` to declare an
12688
+ * engine-side head aggregator (see {@link RuleAggregatorDto}).
12645
12689
  * @returns The created rule wrapped in an AddRuleResponse.
12690
+ * @throws {ApiError} If the rule is rejected or the request fails.
12691
+ *
12692
+ * @remarks
12693
+ * **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
12694
+ *
12695
+ * @example
12696
+ * ```typescript
12697
+ * await client.inference.addRule({
12698
+ * term: psi('total_spend', { customer_id: Var('C'), amount: Var('A') }),
12699
+ * antecedents: [psi('order', { customer_id: Var('C'), amount: Var('A') })],
12700
+ * aggregator: { groupBy: ['customer_id'], op: 'sum', target: 'amount' },
12701
+ * });
12702
+ * ```
12646
12703
  */
12647
12704
  async addRule(request) {
12648
12705
  const wireRequest = {
12649
12706
  term: convertTermArg(request.term),
12650
12707
  antecedents: request.antecedents?.map(convertTermArg),
12651
- certainty: request.certainty
12708
+ certainty: request.certainty,
12709
+ aggregator: request.aggregator
12652
12710
  };
12653
12711
  const response = await this.api.addRule(AddRuleRequestFromFrontToApi(wireRequest));
12654
12712
  return AddRuleResponseFromApiToFront(response.data);
@@ -17265,6 +17323,22 @@ function CausalAnalyzeRequestFromFrontToApi(model) {
17265
17323
  question: CausalAnalyzeQuestionDtoFromFrontToApi(model.question)
17266
17324
  };
17267
17325
  }
17326
+ function DiDValidationRequestFromFrontToApi(model) {
17327
+ return {
17328
+ covariates: model.covariates,
17329
+ outcome_post: model.outcomePost,
17330
+ outcome_pre: model.outcomePre,
17331
+ treatment: model.treatment
17332
+ };
17333
+ }
17334
+ function DiDValidationResponseFromApiToFront(dto) {
17335
+ return {
17336
+ badControls: dto.bad_controls,
17337
+ explanation: dto.explanation,
17338
+ framework: dto.framework,
17339
+ isValid: dto.is_valid
17340
+ };
17341
+ }
17268
17342
 
17269
17343
  // src/resources/causal.ts
17270
17344
  var CausalClient = class {
@@ -18055,6 +18129,53 @@ var CausalClient = class {
18055
18129
  );
18056
18130
  return RefuteEstimateResponseFromApiToFront(response.data);
18057
18131
  }
18132
+ // ===========================================================================
18133
+ // Design validation
18134
+ // ===========================================================================
18135
+ /**
18136
+ * Validate a Difference-in-Differences (DiD) design.
18137
+ *
18138
+ * @param request - The treatment variable, the pre- and post-treatment outcome
18139
+ * variables, and an optional conditioning set.
18140
+ * @returns Whether the design is theoretically sound, an explanation, the bad
18141
+ * controls found in the conditioning set, and the framework used.
18142
+ * @throws {BadRequestError} If the request is malformed.
18143
+ * @throws {ApiError} If the request otherwise fails.
18144
+ *
18145
+ * @remarks
18146
+ * Checks the design against the causal structure the backend builds from the
18147
+ * tenant's homoiconic rules, using the Transformed SWIG (Delta-SWIG) framework
18148
+ * of Knaus & Pfleiderer (2026). This is a design check over the *graph*: no
18149
+ * sample data is submitted and nothing is estimated — validate the design here,
18150
+ * then estimate the effect with {@link CausalClient.ateEstimate}.
18151
+ *
18152
+ * A design can be invalid even with an empty conditioning set (parallel trends
18153
+ * unsupported by the structure); `badControls` names the covariates that induce
18154
+ * bias if conditioned on, so an invalid design is often repaired by dropping
18155
+ * them and re-validating.
18156
+ *
18157
+ * Plain scalar JSON — no value serialization (`ValueDto` / `FeatureValueDto`)
18158
+ * is involved.
18159
+ *
18160
+ * @example
18161
+ * ```typescript
18162
+ * const did = await client.causal.validateDid({
18163
+ * treatment: 'minimum_wage_hike',
18164
+ * outcomePre: 'employment_2025',
18165
+ * outcomePost: 'employment_2026',
18166
+ * covariates: ['county_gdp'],
18167
+ * });
18168
+ * console.log(did.isValid); // false
18169
+ * console.log(did.badControls); // ['county_gdp']
18170
+ * console.log(did.framework); // 'Delta-SWIG (Knaus & Pfleiderer, 2026)'
18171
+ * ```
18172
+ */
18173
+ async validateDid(request) {
18174
+ const response = await this.api.validateDid(
18175
+ DiDValidationRequestFromFrontToApi(request)
18176
+ );
18177
+ return DiDValidationResponseFromApiToFront(response.data);
18178
+ }
18058
18179
  };
18059
18180
 
18060
18181
  // src/normalizers/ingestion.ts
@@ -20963,7 +21084,8 @@ function RegisterSourceRequestFromFrontToApi(model) {
20963
21084
  source_id: model.sourceId,
20964
21085
  source_name: model.sourceName,
20965
21086
  source_type: model.sourceType,
20966
- config: model.config
21087
+ config: model.config,
21088
+ mode: model.mode
20967
21089
  };
20968
21090
  }
20969
21091
  function RegisterSourceResponseFromApiToFront(dto) {
@@ -20971,12 +21093,14 @@ function RegisterSourceResponseFromApiToFront(dto) {
20971
21093
  success: dto.success,
20972
21094
  sourceId: dto.source_id,
20973
21095
  sourceType: dto.source_type,
21096
+ mode: dto.mode,
20974
21097
  message: dto.message
20975
21098
  };
20976
21099
  }
20977
21100
  function SourceSummaryDtoFromApiToFront(dto) {
20978
21101
  return {
20979
21102
  available: dto.available,
21103
+ mode: dto.mode,
20980
21104
  sourceId: dto.source_id,
20981
21105
  sourceType: dto.source_type
20982
21106
  };
@@ -20991,7 +21115,8 @@ function SourceDetailResponseFromApiToFront(dto) {
20991
21115
  return {
20992
21116
  sourceId: dto.source_id,
20993
21117
  sourceType: dto.source_type,
20994
- available: dto.available
21118
+ available: dto.available,
21119
+ mode: dto.mode
20995
21120
  };
20996
21121
  }
20997
21122
  function DiscoverSchemaRequestFromFrontToApi(model) {
@@ -21071,6 +21196,7 @@ function IngestFromSourceRequestFromFrontToApi(model) {
21071
21196
  function StructuredIngestionStatsDtoFromApiToFront(dto) {
21072
21197
  return {
21073
21198
  columnsDiscovered: dto.columns_discovered,
21199
+ columnsDropped: dto.columns_dropped,
21074
21200
  documentsRendered: dto.documents_rendered,
21075
21201
  elapsedMs: dto.elapsed_ms,
21076
21202
  entitiesCreated: dto.entities_created,
@@ -21080,7 +21206,8 @@ function StructuredIngestionStatsDtoFromApiToFront(dto) {
21080
21206
  relationsDiscovered: dto.relations_discovered,
21081
21207
  sortsCreated: dto.sorts_created,
21082
21208
  tablesDiscovered: dto.tables_discovered,
21083
- termsCreated: dto.terms_created
21209
+ termsCreated: dto.terms_created,
21210
+ termsProjected: dto.terms_projected
21084
21211
  };
21085
21212
  }
21086
21213
  function IngestFromSourceResponseFromApiToFront(dto) {
@@ -21104,8 +21231,31 @@ var SourcesClient = class {
21104
21231
  /**
21105
21232
  * Register a new data source.
21106
21233
  *
21107
- * @param request - Source registration request.
21108
- * @returns Registration result.
21234
+ * @param request - Source registration request. Set `mode` to declare the write-path
21235
+ * intent (`'transpile'` for live SQL views, `'ingest'` to materialize rows as
21236
+ * Ψ-term facts); omit it to take the capability-grounded default (`transpile` for
21237
+ * postgres, `ingest` otherwise).
21238
+ * @returns Registration result. `mode` always carries the **resolved** write-path
21239
+ * mode, including when the default applied.
21240
+ * @throws {ApiError} If registration fails, or with **422** if `mode` is not one of
21241
+ * `transpile` / `ingest`.
21242
+ *
21243
+ * @remarks
21244
+ * Registering with `mode: 'transpile'` makes {@link SourcesClient.ingest} refuse this
21245
+ * source with a **409** — materializing a transpiled source would create a second,
21246
+ * divergent namespace over the same rows.
21247
+ *
21248
+ * @example
21249
+ * ```typescript
21250
+ * const result = await client.sources.register({
21251
+ * sourceId: 'crm_postgres',
21252
+ * sourceName: 'CRM PostgreSQL',
21253
+ * sourceType: 'postgres',
21254
+ * config: { connection_string: 'postgres://user:pass@host/db' },
21255
+ * mode: 'ingest',
21256
+ * });
21257
+ * console.log(result.mode); // 'ingest'
21258
+ * ```
21109
21259
  */
21110
21260
  async register(request) {
21111
21261
  const response = await this.api.registerSource(RegisterSourceRequestFromFrontToApi(request));
@@ -22281,13 +22431,35 @@ function mapEntity(e) {
22281
22431
  sourceText: e.source_text ?? null
22282
22432
  };
22283
22433
  }
22434
+ function toRuleSeverity(severity) {
22435
+ switch (severity) {
22436
+ case "critical":
22437
+ case "major":
22438
+ case "minor":
22439
+ case "informational":
22440
+ return severity;
22441
+ default:
22442
+ return "informational";
22443
+ }
22444
+ }
22445
+ function toRuleStatus(status) {
22446
+ switch (status) {
22447
+ case "pass":
22448
+ case "fail":
22449
+ case "inconclusive":
22450
+ case "not_applicable":
22451
+ return status;
22452
+ default:
22453
+ return "inconclusive";
22454
+ }
22455
+ }
22284
22456
  function mapRuleResult(r) {
22285
22457
  return {
22286
22458
  ruleId: r.rule_id ?? "",
22287
22459
  ruleDescription: r.rule_description ?? "",
22288
22460
  ruleSort: r.rule_sort ?? "",
22289
- severity: r.severity ?? "informational",
22290
- status: r.status ?? "inconclusive",
22461
+ severity: toRuleSeverity(r.severity),
22462
+ status: toRuleStatus(r.status),
22291
22463
  confidence: r.confidence ?? 0,
22292
22464
  evidence: r.evidence ?? [],
22293
22465
  proofTrace: r.proof_trace ? r.proof_trace.map(mapProofStep) : null,
@@ -26537,11 +26709,112 @@ var FlowNetworksClient = class {
26537
26709
  };
26538
26710
 
26539
26711
  // src/normalizers/osfql.ts
26712
+ function isRecord(value) {
26713
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26714
+ }
26715
+ function OsfqlValueFromApiToFront(value) {
26716
+ if (!isRecord(value)) {
26717
+ return void 0;
26718
+ }
26719
+ const payload = value["value"];
26720
+ switch (value["type"]) {
26721
+ case "null":
26722
+ return { type: "null" };
26723
+ case "integer":
26724
+ return typeof payload === "number" ? { type: "integer", value: payload } : void 0;
26725
+ case "float":
26726
+ return typeof payload === "number" ? { type: "float", value: payload } : void 0;
26727
+ case "string":
26728
+ return typeof payload === "string" ? { type: "string", value: payload } : void 0;
26729
+ case "boolean":
26730
+ return typeof payload === "boolean" ? { type: "boolean", value: payload } : void 0;
26731
+ case "term_ref":
26732
+ return typeof payload === "string" ? { type: "term_ref", value: payload } : void 0;
26733
+ case "list": {
26734
+ if (!Array.isArray(payload)) {
26735
+ return void 0;
26736
+ }
26737
+ const items = payload;
26738
+ const parsed = [];
26739
+ for (const item of items) {
26740
+ const element = OsfqlValueFromApiToFront(item);
26741
+ if (element === void 0) {
26742
+ return void 0;
26743
+ }
26744
+ parsed.push(element);
26745
+ }
26746
+ return { type: "list", value: parsed };
26747
+ }
26748
+ case "term": {
26749
+ const term = OsfqlTermValueFromApiToFront(payload);
26750
+ return term === void 0 ? void 0 : { type: "term", value: term };
26751
+ }
26752
+ default:
26753
+ return void 0;
26754
+ }
26755
+ }
26756
+ function OsfqlTermValueFromApiToFront(value) {
26757
+ if (!isRecord(value)) {
26758
+ return void 0;
26759
+ }
26760
+ const sort = value["sort"];
26761
+ if (typeof sort !== "string") {
26762
+ return void 0;
26763
+ }
26764
+ const features = OsfqlBindingFromApiToFront(value["features"]);
26765
+ return features === void 0 ? void 0 : { sort, features };
26766
+ }
26767
+ function OsfqlBindingFromApiToFront(value) {
26768
+ if (!isRecord(value)) {
26769
+ return void 0;
26770
+ }
26771
+ const out = {};
26772
+ for (const [name, raw] of Object.entries(value)) {
26773
+ const parsed = OsfqlValueFromApiToFront(raw);
26774
+ if (parsed === void 0) {
26775
+ return void 0;
26776
+ }
26777
+ out[name] = parsed;
26778
+ }
26779
+ return out;
26780
+ }
26781
+ function OsfqlBindingsFromApiToFront(value) {
26782
+ if (!Array.isArray(value)) {
26783
+ return void 0;
26784
+ }
26785
+ const rows = value;
26786
+ const out = [];
26787
+ for (const row of rows) {
26788
+ const parsed = OsfqlBindingFromApiToFront(row);
26789
+ if (parsed === void 0) {
26790
+ return void 0;
26791
+ }
26792
+ out.push(parsed);
26793
+ }
26794
+ return out;
26795
+ }
26796
+ function OsfqlRequestFromFrontToApi(model) {
26797
+ return {
26798
+ query: model.query,
26799
+ reactive: model.reactive
26800
+ };
26801
+ }
26540
26802
  function OsfqlResponseFromApiToFront(dto) {
26803
+ const bindings = OsfqlBindingsFromApiToFront(dto.bindings);
26804
+ if (bindings === void 0) {
26805
+ return void 0;
26806
+ }
26807
+ let fetched;
26808
+ if (dto.fetched !== void 0 && dto.fetched !== null) {
26809
+ fetched = OsfqlBindingsFromApiToFront(dto.fetched);
26810
+ if (fetched === void 0) {
26811
+ return void 0;
26812
+ }
26813
+ }
26541
26814
  return {
26542
26815
  success: dto.success,
26543
- bindings: dto.bindings,
26544
- fetched: dto.fetched,
26816
+ bindings,
26817
+ fetched,
26545
26818
  producedTermIds: dto.produced_term_ids,
26546
26819
  definedSortIds: dto.defined_sort_ids,
26547
26820
  diagnostics: dto.diagnostics,
@@ -26587,15 +26860,28 @@ var OsfqlClient = class {
26587
26860
  * Execute an OSFQL program.
26588
26861
  *
26589
26862
  * @param query - The OSFQL program text (one or more statements separated by `;`).
26863
+ * @param options - Optional execution options. Set `reactive` to fire suspended
26864
+ * `AWAIT` demons whose triggers the program has just satisfied.
26590
26865
  * @returns The execution result including variable bindings, produced term IDs,
26591
26866
  * defined sort IDs, diagnostics, and statement count.
26592
26867
  * @throws {ApiError} If the request fails.
26868
+ * @throws {ReasoningLayerError} If the server returns bindings that do not satisfy the
26869
+ * published {@link OsfqlValue} contract.
26593
26870
  *
26594
26871
  * @remarks
26595
26872
  * The query is parsed, compiled, and executed against the caller's tenant-isolated
26596
26873
  * knowledge base. Results include variable bindings from MATCH queries and IDs of
26597
26874
  * any terms or sorts created by INSERT, DERIVE, or DEFINE statements.
26598
26875
  *
26876
+ * Bindings use the **tagged** {@link OsfqlValue} format with lowercase `type`
26877
+ * discriminators — not the PascalCase `ValueDto` term-CRUD format.
26878
+ *
26879
+ * `reactive` opts into **reactive (streaming) mode**: once the program has run,
26880
+ * any suspended `AWAIT` demon whose trigger is now satisfied fires
26881
+ * automatically, with no explicit `RELEASE RESIDUATIONS` statement. It defaults
26882
+ * to `false` — demons stay suspended until an explicit RELEASE — so omitting it
26883
+ * leaves the request byte-identical to before.
26884
+ *
26599
26885
  * @example
26600
26886
  * ```typescript
26601
26887
  * // Insert a record and query it back
@@ -26606,11 +26892,27 @@ var OsfqlClient = class {
26606
26892
  * console.log(result.bindings); // [{ N: { type: "string", value: "Alice" } }]
26607
26893
  * console.log(result.producedTermIds); // ["<uuid>"]
26608
26894
  * console.log(result.statementCount); // 2
26895
+ *
26896
+ * // Let an AWAIT demon fire as soon as its trigger is satisfied
26897
+ * await client.osfql.execute('AWAIT person(name: "Bob");');
26898
+ * const reactive = await client.osfql.execute(
26899
+ * 'INSERT person(name: "Bob", age: 41);',
26900
+ * { reactive: true },
26901
+ * );
26902
+ * console.log(reactive.producedTermIds); // includes the demon's own output
26609
26903
  * ```
26610
26904
  */
26611
- async execute(query) {
26612
- const response = await this.api.executeOsfql({ query });
26613
- return OsfqlResponseFromApiToFront(response.data);
26905
+ async execute(query, options) {
26906
+ const response = await this.api.executeOsfql(
26907
+ OsfqlRequestFromFrontToApi({ query, reactive: options?.reactive })
26908
+ );
26909
+ const parsed = OsfqlResponseFromApiToFront(response.data);
26910
+ if (parsed === void 0) {
26911
+ throw new ReasoningLayerError(
26912
+ "osfql/execute returned bindings that do not match the published OsfqlValue contract (expected tagged values with a lowercase `type` discriminator)"
26913
+ );
26914
+ }
26915
+ return parsed;
26614
26916
  }
26615
26917
  /**
26616
26918
  * Diagnose an OSFQL program for contradictions and inconsistencies.
@@ -26697,7 +26999,9 @@ function ConversationMessageRequestFromFrontToApi(model) {
26697
26999
  conversation_id: model.conversationId,
26698
27000
  session_id: model.sessionId,
26699
27001
  current_sort_context: model.currentSortContext,
26700
- generate_certificate: model.generateCertificate
27002
+ generate_certificate: model.generateCertificate,
27003
+ constrained_decode: model.constrainedDecode,
27004
+ model: model.model
26701
27005
  };
26702
27006
  }
26703
27007
  function DerivationSummaryDtoFromApiToFront(dto) {
@@ -26805,7 +27109,12 @@ function ConversationMessageResponseFromApiToFront(dto) {
26805
27109
  cognitiveStrategy: dto.cognitive_strategy ? CognitiveStrategyDtoFromApiToFront(dto.cognitive_strategy) : void 0,
26806
27110
  reasoningTrace: dto.reasoning_trace ? ReasoningTraceDtoFromApiToFront(dto.reasoning_trace) : void 0,
26807
27111
  validityCertificateHash: dto.validity_certificate_hash ?? void 0,
26808
- validityCertificateId: dto.validity_certificate_id ?? void 0
27112
+ validityCertificateId: dto.validity_certificate_id ?? void 0,
27113
+ validityCertificateRuleProgramHash: dto.validity_certificate_rule_program_hash ?? void 0,
27114
+ validityCertificateRuleRevision: dto.validity_certificate_rule_revision ?? void 0,
27115
+ modelId: dto.model_id ?? void 0,
27116
+ prefillMs: dto.prefill_ms ?? void 0,
27117
+ tokensPerSec: dto.tokens_per_sec ?? void 0
26809
27118
  };
26810
27119
  }
26811
27120
  function TurnDtoFromApiToFront(dto) {
@@ -30651,12 +30960,16 @@ function PropertyGraphQueryRequestFromFrontToApi(model) {
30651
30960
  };
30652
30961
  }
30653
30962
  function PropertyGraphExecuteResponseFromApiToFront(dto) {
30963
+ const bindings = OsfqlBindingsFromApiToFront(dto.bindings);
30964
+ if (bindings === void 0) {
30965
+ return void 0;
30966
+ }
30654
30967
  return {
30655
30968
  success: dto.success,
30656
30969
  language: dto.language,
30657
30970
  operation: dto.operation,
30658
30971
  osfql: dto.osfql,
30659
- bindings: dto.bindings,
30972
+ bindings,
30660
30973
  producedTermIds: dto.produced_term_ids,
30661
30974
  definedSortIds: dto.defined_sort_ids,
30662
30975
  diagnostics: dto.diagnostics,
@@ -30674,13 +30987,27 @@ function PropertyGraphTranslateResponseFromApiToFront(dto) {
30674
30987
  }
30675
30988
 
30676
30989
  // src/resources/property-graph.ts
30677
- var PropertyGraphClient = class {
30990
+ var PropertyGraphClient = class _PropertyGraphClient {
30678
30991
  /** @internal */
30679
30992
  api;
30680
30993
  /** @internal */
30681
30994
  constructor(api) {
30682
30995
  this.api = api;
30683
30996
  }
30997
+ /**
30998
+ * Parse an execution response, failing loudly on a contract violation.
30999
+ *
31000
+ * @internal
31001
+ */
31002
+ static parseExecuteResponse(dto) {
31003
+ const parsed = PropertyGraphExecuteResponseFromApiToFront(dto);
31004
+ if (parsed === void 0) {
31005
+ throw new ReasoningLayerError(
31006
+ "the property-graph endpoint returned bindings that do not match the published PropertyGraphValue contract (expected tagged values with a lowercase `type` discriminator)"
31007
+ );
31008
+ }
31009
+ return parsed;
31010
+ }
30684
31011
  /**
30685
31012
  * Execute a Cypher query.
30686
31013
  *
@@ -30688,6 +31015,8 @@ var PropertyGraphClient = class {
30688
31015
  * @returns Execution result: bindings, the OSFQL program that ran, produced term IDs,
30689
31016
  * defined sort IDs, diagnostics, compatibility notes, and the statement count.
30690
31017
  * @throws {ApiError} If the query cannot be parsed, cannot be lowered to OSFQL, or fails to execute.
31018
+ * @throws {ReasoningLayerError} If the server returns bindings that do not satisfy the
31019
+ * published {@link PropertyGraphValue} contract.
30691
31020
  *
30692
31021
  * @remarks
30693
31022
  * The query is parsed as Cypher, lowered to OSFQL, and executed against the
@@ -30707,7 +31036,7 @@ var PropertyGraphClient = class {
30707
31036
  const response = await this.api.executeCypherPost(
30708
31037
  PropertyGraphQueryRequestFromFrontToApi({ query })
30709
31038
  );
30710
- return PropertyGraphExecuteResponseFromApiToFront(response.data);
31039
+ return _PropertyGraphClient.parseExecuteResponse(response.data);
30711
31040
  }
30712
31041
  /**
30713
31042
  * Execute a GQL (ISO/IEC 39075) query.
@@ -30716,6 +31045,8 @@ var PropertyGraphClient = class {
30716
31045
  * @returns Execution result: bindings, the OSFQL program that ran, produced term IDs,
30717
31046
  * defined sort IDs, diagnostics, compatibility notes, and the statement count.
30718
31047
  * @throws {ApiError} If the query cannot be parsed, cannot be lowered to OSFQL, or fails to execute.
31048
+ * @throws {ReasoningLayerError} If the server returns bindings that do not satisfy the
31049
+ * published {@link PropertyGraphValue} contract.
30719
31050
  *
30720
31051
  * @remarks
30721
31052
  * The query is parsed as GQL, lowered to OSFQL, and executed against the
@@ -30735,7 +31066,7 @@ var PropertyGraphClient = class {
30735
31066
  const response = await this.api.executeGqlPost(
30736
31067
  PropertyGraphQueryRequestFromFrontToApi({ query })
30737
31068
  );
30738
- return PropertyGraphExecuteResponseFromApiToFront(response.data);
31069
+ return _PropertyGraphClient.parseExecuteResponse(response.data);
30739
31070
  }
30740
31071
  /**
30741
31072
  * Execute a Gremlin traversal.
@@ -30744,6 +31075,8 @@ var PropertyGraphClient = class {
30744
31075
  * @returns Execution result: bindings, the OSFQL program that ran, produced term IDs,
30745
31076
  * defined sort IDs, diagnostics, compatibility notes, and the statement count.
30746
31077
  * @throws {ApiError} If the traversal cannot be parsed, cannot be lowered to OSFQL, or fails to execute.
31078
+ * @throws {ReasoningLayerError} If the server returns bindings that do not satisfy the
31079
+ * published {@link PropertyGraphValue} contract.
30747
31080
  *
30748
31081
  * @remarks
30749
31082
  * The traversal is parsed as Gremlin, lowered to OSFQL, and executed against the
@@ -30762,7 +31095,7 @@ var PropertyGraphClient = class {
30762
31095
  const response = await this.api.executeGremlinPost(
30763
31096
  PropertyGraphQueryRequestFromFrontToApi({ query })
30764
31097
  );
30765
- return PropertyGraphExecuteResponseFromApiToFront(response.data);
31098
+ return _PropertyGraphClient.parseExecuteResponse(response.data);
30766
31099
  }
30767
31100
  /**
30768
31101
  * Translate a Cypher query to OSFQL without executing it.
@@ -30848,14 +31181,14 @@ var PropertyGraphClient = class {
30848
31181
  };
30849
31182
 
30850
31183
  // src/normalizers/sparql.ts
30851
- function isRecord(value) {
31184
+ function isRecord2(value) {
30852
31185
  return typeof value === "object" && value !== null && !Array.isArray(value);
30853
31186
  }
30854
31187
  function isString(value) {
30855
31188
  return typeof value === "string";
30856
31189
  }
30857
31190
  function headVars(head) {
30858
- if (!isRecord(head)) {
31191
+ if (!isRecord2(head)) {
30859
31192
  throw new Error('Malformed SPARQL results: "head" is not an object');
30860
31193
  }
30861
31194
  const vars = head["vars"];
@@ -30868,7 +31201,7 @@ function headVars(head) {
30868
31201
  return vars;
30869
31202
  }
30870
31203
  function SparqlRdfTermFromApiToFront(raw) {
30871
- if (!isRecord(raw)) {
31204
+ if (!isRecord2(raw)) {
30872
31205
  throw new Error("Malformed SPARQL results: a solution binding is not an object");
30873
31206
  }
30874
31207
  const termType = raw["type"];
@@ -30893,7 +31226,7 @@ function SparqlRdfTermFromApiToFront(raw) {
30893
31226
  };
30894
31227
  }
30895
31228
  if (termType === "triple") {
30896
- if (!isRecord(value)) {
31229
+ if (!isRecord2(value)) {
30897
31230
  throw new Error('Malformed SPARQL results: "triple" binding has a non-object value');
30898
31231
  }
30899
31232
  return {
@@ -30910,7 +31243,7 @@ function SparqlRdfTermFromApiToFront(raw) {
30910
31243
  );
30911
31244
  }
30912
31245
  function SparqlBindingSetFromApiToFront(raw) {
30913
- if (!isRecord(raw)) {
31246
+ if (!isRecord2(raw)) {
30914
31247
  throw new Error("Malformed SPARQL results: a solution is not an object");
30915
31248
  }
30916
31249
  const bindings = {};
@@ -30920,7 +31253,7 @@ function SparqlBindingSetFromApiToFront(raw) {
30920
31253
  return bindings;
30921
31254
  }
30922
31255
  function bindingsFromResultSet(results) {
30923
- if (!isRecord(results)) {
31256
+ if (!isRecord2(results)) {
30924
31257
  throw new Error('Malformed SPARQL results: "results" is not an object');
30925
31258
  }
30926
31259
  const bindings = results["bindings"];
@@ -30952,7 +31285,7 @@ function SparqlEntailmentRegimeFromApiToFront(entailment) {
30952
31285
  }
30953
31286
  }
30954
31287
  function SparqlQueryResultsFromApiToFront(raw) {
30955
- if (!isRecord(raw)) {
31288
+ if (!isRecord2(raw)) {
30956
31289
  throw new Error(
30957
31290
  "Malformed SPARQL results: the response body is not a SPARQL 1.1 Query Results JSON document (a CONSTRUCT or DESCRIBE query answers with an RDF graph document instead)"
30958
31291
  );
@@ -30979,7 +31312,7 @@ function GraphSparqlQueryRequestFromFrontToApi(model) {
30979
31312
  };
30980
31313
  }
30981
31314
  function GraphSparqlResultsFromApiToFront(raw) {
30982
- if (!isRecord(raw)) {
31315
+ if (!isRecord2(raw)) {
30983
31316
  throw new Error(
30984
31317
  "Malformed SPARQL results: the co-located store response is not a SPARQL 1.1 Query Results JSON document"
30985
31318
  );
@@ -31267,6 +31600,38 @@ var SparqlClient = class {
31267
31600
  };
31268
31601
 
31269
31602
  // src/normalizers/osf-diff.ts
31603
+ function TermSetSelectorFromFrontToApi(selector) {
31604
+ switch (selector.type) {
31605
+ case "document":
31606
+ return { type: "document", document_id: selector.documentId };
31607
+ case "document_version":
31608
+ return { type: "document_version", document_id: selector.documentId };
31609
+ case "collection":
31610
+ return { type: "collection", path: selector.path };
31611
+ case "term_ids":
31612
+ return { type: "term_ids", ids: selector.ids };
31613
+ case "sort":
31614
+ return {
31615
+ type: "sort",
31616
+ sort_name: selector.sortName,
31617
+ include_descendants: selector.includeDescendants
31618
+ };
31619
+ case "query":
31620
+ return { type: "query", osfql: selector.osfql };
31621
+ case "snapshot":
31622
+ return {
31623
+ type: "snapshot",
31624
+ snapshot_id: selector.snapshotId,
31625
+ filter: selector.filter === void 0 ? void 0 : TermSetSelectorFromFrontToApi(selector.filter)
31626
+ };
31627
+ case "as_of":
31628
+ return {
31629
+ type: "as_of",
31630
+ at: selector.at,
31631
+ filter: selector.filter === void 0 ? void 0 : TermSetSelectorFromFrontToApi(selector.filter)
31632
+ };
31633
+ }
31634
+ }
31270
31635
  function TemporalPointFromFrontToApi(model) {
31271
31636
  return {
31272
31637
  at: model.at,
@@ -31275,8 +31640,8 @@ function TemporalPointFromFrontToApi(model) {
31275
31640
  }
31276
31641
  function OsfDiffRequestFromFrontToApi(model) {
31277
31642
  return {
31278
- a: model.a,
31279
- b: model.b,
31643
+ a: TermSetSelectorFromFrontToApi(model.a),
31644
+ b: TermSetSelectorFromFrontToApi(model.b),
31280
31645
  include_clause_diff: model.includeClauseDiff,
31281
31646
  include_entity_diff: model.includeEntityDiff,
31282
31647
  threshold: model.threshold
@@ -31290,7 +31655,7 @@ function OsfDiffResponseFromApiToFront(dto) {
31290
31655
  function OsfDiffSequenceRequestFromFrontToApi(model) {
31291
31656
  return {
31292
31657
  document_family_id: model.documentFamilyId,
31293
- selectors: model.selectors,
31658
+ selectors: model.selectors?.map(TermSetSelectorFromFrontToApi),
31294
31659
  threshold: model.threshold
31295
31660
  };
31296
31661
  }
@@ -31301,7 +31666,7 @@ function OsfDiffSequenceResponseFromApiToFront(dto) {
31301
31666
  }
31302
31667
  function OsfDiffTemporalRequestFromFrontToApi(model) {
31303
31668
  return {
31304
- filter: model.filter,
31669
+ filter: model.filter === void 0 ? void 0 : TermSetSelectorFromFrontToApi(model.filter),
31305
31670
  from: TemporalPointFromFrontToApi(model.from),
31306
31671
  to: TemporalPointFromFrontToApi(model.to),
31307
31672
  threshold: model.threshold
@@ -31336,13 +31701,14 @@ var OsfDiffClient = class {
31336
31701
  * Entities are matched by OSF unification; `threshold` (default 0.7) is the
31337
31702
  * minimum match degree at which two entities are considered the same. Set
31338
31703
  * `includeClauseDiff` / `includeEntityDiff` to control which deltas the report
31339
- * carries. Selectors and the report are opaque wire-format JSON objects.
31704
+ * carries. Each side is a typed {@link OsfDiffSelector}; the report is an opaque
31705
+ * wire-format JSON object.
31340
31706
  *
31341
31707
  * @example
31342
31708
  * ```typescript
31343
31709
  * const result = await client.osfDiff.diff({
31344
- * a: { type: 'document', document_id: 'a1b2c3d4-...' },
31345
- * b: { type: 'document', document_id: 'e5f6a7b8-...' },
31710
+ * a: { type: 'document', documentId: 'a1b2c3d4-...' },
31711
+ * b: { type: 'document', documentId: 'e5f6a7b8-...' },
31346
31712
  * includeClauseDiff: true,
31347
31713
  * threshold: 0.8,
31348
31714
  * });
@@ -31402,7 +31768,7 @@ var OsfDiffClient = class {
31402
31768
  * const result = await client.osfDiff.diffTemporal({
31403
31769
  * from: { at: '2026-01-01T00:00:00Z' },
31404
31770
  * to: {}, // live
31405
- * filter: { type: 'document', document_id: 'a1b2c3d4-...' },
31771
+ * filter: { type: 'document', documentId: 'a1b2c3d4-...' },
31406
31772
  * });
31407
31773
  * console.log(result.report);
31408
31774
  * ```
@@ -31775,13 +32141,22 @@ function SatSolverStatsDtoFromApiToFront(dto) {
31775
32141
  }
31776
32142
  function modelFromApiToFront(raw) {
31777
32143
  if (!Array.isArray(raw)) {
31778
- return [];
32144
+ throw new ValidationError(
32145
+ "SAT solver returned a 'satisfiable' verdict without a model; the endpoint contract requires one. Refusing to report an assignment the solver did not give.",
32146
+ "model"
32147
+ );
31779
32148
  }
32149
+ const entries = raw;
31780
32150
  const model = [];
31781
- for (const entry of raw) {
31782
- if (typeof entry === "boolean") {
31783
- model.push(entry);
32151
+ for (let index = 0; index < entries.length; index += 1) {
32152
+ const entry = entries[index];
32153
+ if (typeof entry !== "boolean") {
32154
+ throw new ValidationError(
32155
+ `SAT model entry at index ${index} is ${typeof entry}, not a Boolean. The assignment vector is positional, so this entry cannot be dropped without corrupting every later variable.`,
32156
+ "model"
32157
+ );
31784
32158
  }
32159
+ model.push(entry);
31785
32160
  }
31786
32161
  return model;
31787
32162
  }
@@ -31832,12 +32207,19 @@ var SatClient = class {
31832
32207
  * Solver statistics are attached to every branch.
31833
32208
  * @throws {ApiError} If the request fails (e.g. a literal references a variable
31834
32209
  * index `>= numVars`, or a clause is empty).
32210
+ * @throws {ValidationError} If a `satisfiable` verdict arrives without a
32211
+ * well-formed Boolean model, which violates the endpoint contract.
31835
32212
  *
31836
32213
  * @remarks
31837
32214
  * Narrow on `result` to reach the model — it exists only on the `satisfiable`
31838
32215
  * branch. `maxConflicts: 0` (the default) means an unlimited budget, in which
31839
32216
  * case `unknown` cannot be returned.
31840
32217
  *
32218
+ * The model is index-aligned with the variables (`model[i]` is the value of
32219
+ * variable `i`). A `satisfiable` response whose model is missing or holds a
32220
+ * non-Boolean is reported as a {@link ValidationError} rather than silently
32221
+ * shortened — dropping an entry would shift every later variable's assignment.
32222
+ *
31841
32223
  * Plain JSON serialization: literals are `{ var, negated }` objects and the
31842
32224
  * model is a `boolean[]` indexed by variable number. No tagged `ValueDto` or
31843
32225
  * untagged `FeatureValueDto` encoding is used.
@@ -31889,12 +32271,12 @@ function EqLiteralDtoFromFrontToApi(model) {
31889
32271
  negated: model.negated
31890
32272
  };
31891
32273
  }
31892
- function isRecord2(value) {
32274
+ function isRecord3(value) {
31893
32275
  return typeof value === "object" && value !== null;
31894
32276
  }
31895
32277
  function assignmentsFromApiToFront(raw) {
31896
32278
  const assignments = {};
31897
- if (!isRecord2(raw)) {
32279
+ if (!isRecord3(raw)) {
31898
32280
  return assignments;
31899
32281
  }
31900
32282
  for (const [key, value] of Object.entries(raw)) {
@@ -32096,7 +32478,9 @@ var ChaseClient = class {
32096
32478
  * ```
32097
32479
  */
32098
32480
  async run(request) {
32099
- const response = await this.api.runChase(ChaseRunRequestFromFrontToApi(request));
32481
+ const response = await this.api.runChase(ChaseRunRequestFromFrontToApi(request), {
32482
+ headers: { [RAW_BODY_HEADER]: "1" }
32483
+ });
32100
32484
  return ChaseRunResponseFromApiToFront(response.data);
32101
32485
  }
32102
32486
  };
@@ -32226,7 +32610,7 @@ var ConformanceClient = class {
32226
32610
  };
32227
32611
 
32228
32612
  // src/normalizers/temporal.ts
32229
- function isRecord3(value) {
32613
+ function isRecord4(value) {
32230
32614
  return typeof value === "object" && value !== null && !Array.isArray(value);
32231
32615
  }
32232
32616
  function asNumber(value) {
@@ -32286,38 +32670,6 @@ function TemporalModelCheckResponseFromApiToFront(dto) {
32286
32670
  counterexample
32287
32671
  };
32288
32672
  }
32289
- function TermSetSelectorFromFrontToApi(selector) {
32290
- switch (selector.type) {
32291
- case "document":
32292
- return { type: "document", document_id: selector.documentId };
32293
- case "document_version":
32294
- return { type: "document_version", document_id: selector.documentId };
32295
- case "collection":
32296
- return { type: "collection", path: selector.path };
32297
- case "term_ids":
32298
- return { type: "term_ids", ids: selector.ids };
32299
- case "sort":
32300
- return {
32301
- type: "sort",
32302
- sort_name: selector.sortName,
32303
- include_descendants: selector.includeDescendants
32304
- };
32305
- case "query":
32306
- return { type: "query", osfql: selector.osfql };
32307
- case "snapshot":
32308
- return {
32309
- type: "snapshot",
32310
- snapshot_id: selector.snapshotId,
32311
- filter: selector.filter === void 0 ? void 0 : TermSetSelectorFromFrontToApi(selector.filter)
32312
- };
32313
- case "as_of":
32314
- return {
32315
- type: "as_of",
32316
- at: selector.at,
32317
- filter: selector.filter === void 0 ? void 0 : TermSetSelectorFromFrontToApi(selector.filter)
32318
- };
32319
- }
32320
- }
32321
32673
  function TemporalSeriesSpecFromFrontToApi(spec) {
32322
32674
  const time = spec.time.kind === "date_time_feature" ? { kind: "date_time_feature", name: spec.time.name } : { kind: "epoch_feature", name: spec.time.name, unit: spec.time.unit };
32323
32675
  const value = spec.value.kind === "feature" ? { kind: "feature", name: spec.value.name } : { kind: "count" };
@@ -32354,7 +32706,7 @@ function TemporalSeriesRequestFromFrontToApi(model) {
32354
32706
  };
32355
32707
  }
32356
32708
  function TemporalSeriesPointFromApiToFront(value) {
32357
- if (!isRecord3(value)) {
32709
+ if (!isRecord4(value)) {
32358
32710
  return void 0;
32359
32711
  }
32360
32712
  const bucketStart = asNumber(value["bucket_start"]);
@@ -32372,7 +32724,7 @@ function TemporalSeriesPointFromApiToFront(value) {
32372
32724
  };
32373
32725
  }
32374
32726
  function TemporalTrendSummaryFromApiToFront(value) {
32375
- if (!isRecord3(value)) {
32727
+ if (!isRecord4(value)) {
32376
32728
  return void 0;
32377
32729
  }
32378
32730
  const slopePerMs = asNumber(value["slope_per_ms"]);
@@ -32387,7 +32739,7 @@ function TemporalTrendSummaryFromApiToFront(value) {
32387
32739
  return { slopePerMs, intercept, first, last, delta, n };
32388
32740
  }
32389
32741
  function TemporalSeriesFromApiToFront(value) {
32390
- if (!isRecord3(value)) {
32742
+ if (!isRecord4(value)) {
32391
32743
  return void 0;
32392
32744
  }
32393
32745
  const rawPoints = value["points"];
@@ -32534,7 +32886,7 @@ var TemporalClient = class {
32534
32886
  };
32535
32887
 
32536
32888
  // src/normalizers/forecast.ts
32537
- function isRecord4(value) {
32889
+ function isRecord5(value) {
32538
32890
  return typeof value === "object" && value !== null && !Array.isArray(value);
32539
32891
  }
32540
32892
  function asNumber2(value) {
@@ -32587,7 +32939,7 @@ function ForecastRequestFromFrontToApi(model) {
32587
32939
  };
32588
32940
  }
32589
32941
  function CompetitorForecastFromApiToFront(value) {
32590
- if (!isRecord4(value)) {
32942
+ if (!isRecord5(value)) {
32591
32943
  return void 0;
32592
32944
  }
32593
32945
  const id = asString(value["id"]);
@@ -32599,7 +32951,7 @@ function CompetitorForecastFromApiToFront(value) {
32599
32951
  return { id, pWin, pTopK };
32600
32952
  }
32601
32953
  function OrderedComboFromApiToFront(value) {
32602
- if (!isRecord4(value)) {
32954
+ if (!isRecord5(value)) {
32603
32955
  return void 0;
32604
32956
  }
32605
32957
  const members = asStringArray(value["members"]);
@@ -32610,7 +32962,7 @@ function OrderedComboFromApiToFront(value) {
32610
32962
  return { members, probability };
32611
32963
  }
32612
32964
  function ForecastCoveringSetFromApiToFront(value) {
32613
- if (!isRecord4(value)) {
32965
+ if (!isRecord5(value)) {
32614
32966
  return void 0;
32615
32967
  }
32616
32968
  const members = asStringArray(value["members"]);
@@ -32623,7 +32975,7 @@ function ForecastCoveringSetFromApiToFront(value) {
32623
32975
  return { members, alpha, slice, sliceFallback };
32624
32976
  }
32625
32977
  function RankedInstrumentFromApiToFront(value) {
32626
- if (!isRecord4(value)) {
32978
+ if (!isRecord5(value)) {
32627
32979
  return void 0;
32628
32980
  }
32629
32981
  const id = asString(value["id"]);
@@ -32643,7 +32995,7 @@ function RankedInstrumentFromApiToFront(value) {
32643
32995
  return { id, score, rank, interval };
32644
32996
  }
32645
32997
  function ForecastBodyFromApiToFront(value) {
32646
- if (!isRecord4(value)) {
32998
+ if (!isRecord5(value)) {
32647
32999
  return void 0;
32648
33000
  }
32649
33001
  const shape = value["shape"];
@@ -32697,7 +33049,7 @@ function ForecastBodyFromApiToFront(value) {
32697
33049
  return void 0;
32698
33050
  }
32699
33051
  function ForecastCertificateFromApiToFront(value) {
32700
- if (!isRecord4(value)) {
33052
+ if (!isRecord5(value)) {
32701
33053
  return void 0;
32702
33054
  }
32703
33055
  const modelFingerprint = asString(value["model_fingerprint"]);
@@ -32716,7 +33068,7 @@ function ForecastCertificateFromApiToFront(value) {
32716
33068
  };
32717
33069
  }
32718
33070
  function CertifiedForecastFromApiToFront(value) {
32719
- if (!isRecord4(value)) {
33071
+ if (!isRecord5(value)) {
32720
33072
  return void 0;
32721
33073
  }
32722
33074
  const outcome = value["outcome"];
@@ -32993,7 +33345,9 @@ var DlClient = class {
32993
33345
  * ```
32994
33346
  */
32995
33347
  async satisfiable(request) {
32996
- const response = await this.api.satisfiable(DlSatisfiableRequestFromFrontToApi(request));
33348
+ const response = await this.api.satisfiable(DlSatisfiableRequestFromFrontToApi(request), {
33349
+ headers: { [RAW_BODY_HEADER]: "1" }
33350
+ });
32997
33351
  return DlSatisfiableResponseFromApiToFront(response.data);
32998
33352
  }
32999
33353
  /**
@@ -33029,7 +33383,9 @@ var DlClient = class {
33029
33383
  * ```
33030
33384
  */
33031
33385
  async subsumes(request) {
33032
- const response = await this.api.subsumes(DlSubsumesRequestFromFrontToApi(request));
33386
+ const response = await this.api.subsumes(DlSubsumesRequestFromFrontToApi(request), {
33387
+ headers: { [RAW_BODY_HEADER]: "1" }
33388
+ });
33033
33389
  return DlSubsumesResponseFromApiToFront(response.data);
33034
33390
  }
33035
33391
  };
@@ -33786,21 +34142,50 @@ var OntologyExportClient = class {
33786
34142
  constructor(api) {
33787
34143
  this.api = api;
33788
34144
  }
34145
+ /**
34146
+ * Issue a content-negotiated export request and project the response.
34147
+ *
34148
+ * @internal
34149
+ * @remarks
34150
+ * Goes through the transport directly rather than through the generated route
34151
+ * methods: `root` is repeatable server-side (`?root=a&root=b`), but utoipa
34152
+ * cannot express a repeated query parameter, so the generated routes type it as
34153
+ * a lone `root?: string` — narrower than the endpoint each route's own
34154
+ * "(repeatable)" doc comment describes. The transport's query serializer
34155
+ * already branches on `Array.isArray` and emits the repeats correctly.
34156
+ */
34157
+ async requestExport(path, options) {
34158
+ const response = await this.api.http.request({
34159
+ path,
34160
+ method: "GET",
34161
+ query: OntologyExportQueryFromFrontToApi(options),
34162
+ secure: true,
34163
+ headers: { Accept: OntologyExportAcceptFromFrontToApi(options?.format) }
34164
+ });
34165
+ const document = await response.text();
34166
+ return OntologyExportDocumentFromApiToFront(
34167
+ response.headers.get("content-type"),
34168
+ document
34169
+ );
34170
+ }
33789
34171
  /**
33790
34172
  * Export the tenant's sort lattice (or a sub-lattice) as an OWL ontology.
33791
34173
  *
33792
34174
  * @param options - Export options: the base IRI for synthesized IRIs, the root
33793
- * sort to restrict the export to, and the serialization to negotiate on.
34175
+ * sort (or sorts) to restrict the export to, and the serialization to
34176
+ * negotiate on.
33794
34177
  * @returns The exported document, verbatim, with the media type the server
33795
34178
  * answered with.
33796
34179
  * @throws {BadRequestError} If the base IRI is invalid or the query is malformed.
33797
- * @throws {NotFoundError} If the requested root sort does not exist.
34180
+ * @throws {NotFoundError} If a requested root sort does not exist.
33798
34181
  * @throws {ApiError} If the request otherwise fails.
33799
34182
  *
33800
34183
  * @remarks
33801
34184
  * Omit `root` to export the whole tenant schema. Omit `base` to let the backend
33802
34185
  * synthesize IRIs under `urn:osfkb:tenant:{tenant_id}`.
33803
34186
  *
34187
+ * `root` is repeatable: pass an array to export several sub-lattices at once.
34188
+ *
33804
34189
  * `format` selects the `Accept` header: an RDF serialization yields an RDF
33805
34190
  * document, and the default (`'json'`) yields the backend's JSON rendering as
33806
34191
  * JSON text — parse it with `JSON.parse` when you need the object.
@@ -33813,36 +34198,35 @@ var OntologyExportClient = class {
33813
34198
  * format: 'turtle',
33814
34199
  * });
33815
34200
  *
33816
- * console.log(owl.contentType); // 'text/turtle'
34201
+ * console.log(owl.contentType); // 'text/turtle; charset=utf-8'
33817
34202
  * console.log(owl.document); // '@prefix : <https://example.org/ontology#> ...'
34203
+ *
34204
+ * // Several sub-lattices in one export -> ?root=clinical_entity&root=administrative_entity
34205
+ * const both = await client.ontologyExport.exportOwl({
34206
+ * root: ['clinical_entity', 'administrative_entity'],
34207
+ * });
33818
34208
  * ```
33819
34209
  */
33820
34210
  async exportOwl(options) {
33821
- const response = await this.api.exportOntologyOwl(
33822
- OntologyExportQueryFromFrontToApi(options),
33823
- { headers: { Accept: OntologyExportAcceptFromFrontToApi(options?.format) } }
33824
- );
33825
- const document = await response.text();
33826
- return OntologyExportDocumentFromApiToFront(
33827
- response.headers.get("content-type"),
33828
- document
33829
- );
34211
+ return this.requestExport("/api/v1/ontology/export/owl", options);
33830
34212
  }
33831
34213
  /**
33832
34214
  * Export the tenant's schema constraints (or those of a sub-lattice) as SHACL
33833
34215
  * shapes.
33834
34216
  *
33835
34217
  * @param options - Export options: the base IRI for synthesized IRIs, the root
33836
- * sort to restrict the export to, and the serialization to negotiate on.
34218
+ * sort (or sorts) to restrict the export to, and the serialization to
34219
+ * negotiate on.
33837
34220
  * @returns The exported document, verbatim, with the media type the server
33838
34221
  * answered with.
33839
34222
  * @throws {BadRequestError} If the base IRI is invalid or the query is malformed.
33840
- * @throws {NotFoundError} If the requested root sort does not exist.
34223
+ * @throws {NotFoundError} If a requested root sort does not exist.
33841
34224
  * @throws {ApiError} If the request otherwise fails.
33842
34225
  *
33843
34226
  * @remarks
33844
34227
  * Each exported shape targets one sort and constrains its features. Omit `root`
33845
- * to export the whole tenant schema.
34228
+ * to export the whole tenant schema; pass an array to export the shapes of
34229
+ * several sub-lattices at once.
33846
34230
  *
33847
34231
  * `format` selects the `Accept` header: an RDF serialization yields an RDF
33848
34232
  * document, and the default (`'json'`) yields the backend's JSON rendering of
@@ -33852,20 +34236,12 @@ var OntologyExportClient = class {
33852
34236
  * ```typescript
33853
34237
  * const shacl = await client.ontologyExport.exportShacl({ format: 'turtle' });
33854
34238
  *
33855
- * console.log(shacl.contentType); // 'text/turtle'
34239
+ * console.log(shacl.contentType); // 'text/turtle; charset=utf-8'
33856
34240
  * console.log(shacl.document); // '... sh:NodeShape ...'
33857
34241
  * ```
33858
34242
  */
33859
34243
  async exportShacl(options) {
33860
- const response = await this.api.exportOntologyShacl(
33861
- OntologyExportQueryFromFrontToApi(options),
33862
- { headers: { Accept: OntologyExportAcceptFromFrontToApi(options?.format) } }
33863
- );
33864
- const document = await response.text();
33865
- return OntologyExportDocumentFromApiToFront(
33866
- response.headers.get("content-type"),
33867
- document
33868
- );
34244
+ return this.requestExport("/api/v1/ontology/export/shacl", options);
33869
34245
  }
33870
34246
  };
33871
34247