@kortexya/reasoninglayer 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/config.ts
2
- var SDK_VERSION = "0.2.8";
2
+ var SDK_VERSION = "0.3.0";
3
3
  function resolveConfig(config) {
4
4
  if (!config.baseUrl) {
5
5
  throw new Error("ClientConfig.baseUrl is required");
@@ -52,6 +52,18 @@ var BadRequestError = class extends ApiError {
52
52
  super(message, 400, body, headers, errorCode);
53
53
  }
54
54
  };
55
+ var AuthenticationError = class extends ApiError {
56
+ name = "AuthenticationError";
57
+ constructor(message, body, headers, errorCode) {
58
+ super(message, 401, body, headers, errorCode);
59
+ }
60
+ };
61
+ var ForbiddenError = class extends ApiError {
62
+ name = "ForbiddenError";
63
+ constructor(message, body, headers, errorCode) {
64
+ super(message, 403, body, headers, errorCode);
65
+ }
66
+ };
55
67
  var NotFoundError = class extends ApiError {
56
68
  name = "NotFoundError";
57
69
  constructor(message, body, headers, errorCode) {
@@ -137,6 +149,10 @@ function createApiError(status, body, headers) {
137
149
  switch (status) {
138
150
  case 400:
139
151
  return new BadRequestError(message, body, headers, errorCode);
152
+ case 401:
153
+ return new AuthenticationError(message, body, headers, errorCode);
154
+ case 403:
155
+ return new ForbiddenError(message, body, headers, errorCode);
140
156
  case 404:
141
157
  return new NotFoundError(message, body, headers, errorCode);
142
158
  case 409: {
@@ -354,7 +370,8 @@ var WebSocketClient = class {
354
370
  const queryParams = new URLSearchParams({ tenant_id: this.config.tenantId });
355
371
  if (params) {
356
372
  for (const [key, value] of Object.entries(params)) {
357
- queryParams.set(key, value);
373
+ const wireKey = key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
374
+ queryParams.set(wireKey, value);
358
375
  }
359
376
  }
360
377
  return `${baseUrl}${path}?${queryParams.toString()}`;
@@ -506,6 +523,45 @@ var HttpClient = class {
506
523
  };
507
524
  };
508
525
 
526
+ // src/serialization.ts
527
+ function camelToSnake(str) {
528
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
529
+ }
530
+ function snakeToCamel(str) {
531
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
532
+ }
533
+ function isPlainObject(value) {
534
+ if (value === null || typeof value !== "object") return false;
535
+ const proto = Object.getPrototypeOf(value);
536
+ return proto === Object.prototype || proto === null;
537
+ }
538
+ function toSnakeCase(input) {
539
+ if (Array.isArray(input)) {
540
+ return input.map((item) => toSnakeCase(item));
541
+ }
542
+ if (!isPlainObject(input)) {
543
+ return input;
544
+ }
545
+ const result = {};
546
+ for (const key of Object.keys(input)) {
547
+ result[camelToSnake(key)] = toSnakeCase(input[key]);
548
+ }
549
+ return result;
550
+ }
551
+ function toCamelCase(input) {
552
+ if (Array.isArray(input)) {
553
+ return input.map((item) => toCamelCase(item));
554
+ }
555
+ if (!isPlainObject(input)) {
556
+ return input;
557
+ }
558
+ const result = {};
559
+ for (const key of Object.keys(input)) {
560
+ result[snakeToCamel(key)] = toCamelCase(input[key]);
561
+ }
562
+ return result;
563
+ }
564
+
509
565
  // src/generated-bridge.ts
510
566
  function createGeneratedHttpClient(config) {
511
567
  return new HttpClient({
@@ -527,8 +583,40 @@ function buildAuthHeaders(config) {
527
583
  if (config.authenticatedUser) headers["X-Authenticated-User"] = config.authenticatedUser;
528
584
  return headers;
529
585
  }
586
+ function transformRequestInit(init) {
587
+ if (!init?.body || typeof init.body !== "string") return init;
588
+ try {
589
+ const parsed = JSON.parse(init.body);
590
+ const snaked = toSnakeCase(parsed);
591
+ return { ...init, body: JSON.stringify(snaked) };
592
+ } catch {
593
+ return init;
594
+ }
595
+ }
596
+ async function wrapResponseWithCamelCase(response) {
597
+ if (response.status === 204 || response.status === 304) {
598
+ return new Response(null, {
599
+ status: response.status,
600
+ statusText: response.statusText,
601
+ headers: response.headers
602
+ });
603
+ }
604
+ const text = await response.text();
605
+ let transformedBody = text;
606
+ try {
607
+ const parsed = JSON.parse(text);
608
+ transformedBody = JSON.stringify(toCamelCase(parsed));
609
+ } catch {
610
+ }
611
+ return new Response(transformedBody, {
612
+ status: response.status,
613
+ statusText: response.statusText,
614
+ headers: response.headers
615
+ });
616
+ }
530
617
  function createCustomFetch(config) {
531
618
  return async (input, init) => {
619
+ const transformedInit = transformRequestInit(init);
532
620
  const maxRetries = config.maxRetries;
533
621
  const timeoutMs = config.timeoutMs;
534
622
  let lastError;
@@ -537,8 +625,8 @@ function createCustomFetch(config) {
537
625
  await sleep(calculateRetryDelay(attempt, lastError));
538
626
  }
539
627
  try {
540
- const response = await executeFetch(input, init, timeoutMs, config);
541
- if (response.ok) return response;
628
+ const response = await executeFetch(input, transformedInit, timeoutMs, config);
629
+ if (response.ok) return await wrapResponseWithCamelCase(response);
542
630
  let body;
543
631
  try {
544
632
  body = await response.clone().json();
@@ -7162,6 +7250,20 @@ var Admin = class {
7162
7250
  format: "json",
7163
7251
  ...params
7164
7252
  });
7253
+ /**
7254
+ * @description Destructive operation that wipes all PostgreSQL rows, in-memory inference state, and cache entries for the specified tenant. Other tenants are unaffected. Use for tenant offboarding or testing.
7255
+ *
7256
+ * @tags admin
7257
+ * @name ClearTenantData
7258
+ * @summary Clear all data for a specific tenant
7259
+ * @request POST:/api/v1/admin/clear-tenant/{tenant_id}
7260
+ */
7261
+ clearTenantData = (tenantId, params = {}) => this.http.request({
7262
+ path: `/api/v1/admin/clear-tenant/${tenantId}`,
7263
+ method: "POST",
7264
+ format: "json",
7265
+ ...params
7266
+ });
7165
7267
  /**
7166
7268
  * @description Returns all tenant IDs that have terms or ingestion sessions, with counts. No X-Tenant-Id header required. Works in both PostgreSQL and in-memory modes.
7167
7269
  *
@@ -7356,7 +7458,7 @@ var SortsClient = class {
7356
7458
  */
7357
7459
  async isSubtype(childId, parentId) {
7358
7460
  const response = await this.sorts.isSubtype(childId, parentId);
7359
- return response.data.is_subtype;
7461
+ return response.data.isSubtype;
7360
7462
  }
7361
7463
  /**
7362
7464
  * Compute the Greatest Lower Bound (GLB) of two sorts — the most specific type
@@ -7403,7 +7505,7 @@ var SortsClient = class {
7403
7505
  * @see computeGlb
7404
7506
  */
7405
7507
  async findCommonSubtype(sortId1, sortId2) {
7406
- return this.computeGlb({ sort1_id: sortId1, sort2_id: sortId2 });
7508
+ return this.computeGlb({ sort1Id: sortId1, sort2Id: sortId2 });
7407
7509
  }
7408
7510
  /**
7409
7511
  * Find the most general type that covers both types.
@@ -7415,7 +7517,7 @@ var SortsClient = class {
7415
7517
  * @see computeLub
7416
7518
  */
7417
7519
  async findCommonSupertype(sortId1, sortId2) {
7418
- return this.computeLub({ sort1_id: sortId1, sort2_id: sortId2 });
7520
+ return this.computeLub({ sort1Id: sortId1, sort2Id: sortId2 });
7419
7521
  }
7420
7522
  /**
7421
7523
  * Get a human-readable explanation of how two types relate.
@@ -7427,7 +7529,7 @@ var SortsClient = class {
7427
7529
  * @see decodeGlb
7428
7530
  */
7429
7531
  async explainCommonSubtype(sortId1, sortId2) {
7430
- return this.decodeGlb({ sort1_id: sortId1, sort2_id: sortId2 });
7532
+ return this.decodeGlb({ sort1Id: sortId1, sort2Id: sortId2 });
7431
7533
  }
7432
7534
  /**
7433
7535
  * Get direct children of a sort.
@@ -7487,7 +7589,7 @@ var SortsClient = class {
7487
7589
  * @returns Comparison result.
7488
7590
  */
7489
7591
  async compareSorts(request) {
7490
- const response = await this.types.compareSorts({ ...request, tenant_id: this.tenantId });
7592
+ const response = await this.types.compareSorts({ ...request, tenantId: this.tenantId });
7491
7593
  return response.data;
7492
7594
  }
7493
7595
  /**
@@ -7520,8 +7622,8 @@ var SortsClient = class {
7520
7622
  * @example
7521
7623
  * ```typescript
7522
7624
  * const result = await client.sorts.getSortSimilarity({
7523
- * sort1_id: 'uuid-1',
7524
- * sort2_id: 'uuid-2',
7625
+ * sort1Id: 'uuid-1',
7626
+ * sort2Id: 'uuid-2',
7525
7627
  * });
7526
7628
  * console.log(result.degree); // 0.85
7527
7629
  * ```
@@ -7545,8 +7647,8 @@ var SortsClient = class {
7545
7647
  * @example
7546
7648
  * ```typescript
7547
7649
  * const result = await client.sorts.setSortSimilarity({
7548
- * sort1_id: 'uuid-1',
7549
- * sort2_id: 'uuid-2',
7650
+ * sort1Id: 'uuid-1',
7651
+ * sort2Id: 'uuid-2',
7550
7652
  * degree: 0.85,
7551
7653
  * });
7552
7654
  * console.log(result.success); // true
@@ -7572,11 +7674,11 @@ var SortsClient = class {
7572
7674
  * ```typescript
7573
7675
  * const result = await client.sorts.bulkSetSimilarities({
7574
7676
  * similarities: [
7575
- * { sort1_id: 'uuid-1', sort2_id: 'uuid-2', degree: 0.85 },
7576
- * { sort1_id: 'uuid-3', sort2_id: 'uuid-4', degree: 0.70 },
7677
+ * { sort1Id: 'uuid-1', sort2Id: 'uuid-2', degree: 0.85 },
7678
+ * { sort1Id: 'uuid-3', sort2Id: 'uuid-4', degree: 0.70 },
7577
7679
  * ],
7578
7680
  * });
7579
- * console.log(result.set_count); // 2
7681
+ * console.log(result.setCount); // 2
7580
7682
  * ```
7581
7683
  */
7582
7684
  async bulkSetSimilarities(request) {
@@ -7604,8 +7706,8 @@ var SortsClient = class {
7604
7706
  * @example
7605
7707
  * ```typescript
7606
7708
  * const result = await client.sorts.getPreorderDegree({
7607
- * sort1_id: 'uuid-1',
7608
- * sort2_id: 'uuid-2',
7709
+ * sort1Id: 'uuid-1',
7710
+ * sort2Id: 'uuid-2',
7609
7711
  * });
7610
7712
  * console.log(result.degree); // 0.72
7611
7713
  * ```
@@ -7629,8 +7731,8 @@ var SortsClient = class {
7629
7731
  * @example
7630
7732
  * ```typescript
7631
7733
  * const result = await client.sorts.getEquivalenceClasses();
7632
- * for (const ec of result.equivalence_classes) {
7633
- * console.log(`Class of ${ec.size} sorts:`, ec.sort_ids);
7734
+ * for (const ec of result.equivalenceClasses) {
7735
+ * console.log(`Class of ${ec.size} sorts:`, ec.sortIds);
7634
7736
  * }
7635
7737
  * ```
7636
7738
  */
@@ -7678,8 +7780,147 @@ var SortsClient = class {
7678
7780
  const response = await this.sorts.rejectLearnedSimilarity(request);
7679
7781
  return response.data;
7680
7782
  }
7783
+ // ─── Friendly Aliases ─────────────────────────────────────────────
7784
+ /**
7785
+ * Create multiple types in a single request.
7786
+ * Alias for {@link bulkCreateSorts}.
7787
+ *
7788
+ * @param request - Bulk sort definitions.
7789
+ * @returns Bulk creation result.
7790
+ *
7791
+ * @see bulkCreateSorts
7792
+ */
7793
+ async createMany(request) {
7794
+ return this.bulkCreateSorts(request);
7795
+ }
7681
7796
  };
7682
7797
 
7798
+ // src/utils/convert.ts
7799
+ var TAGGED_VALUE_TYPES = /* @__PURE__ */ new Set([
7800
+ "String",
7801
+ "Integer",
7802
+ "Real",
7803
+ "Boolean",
7804
+ "Uninstantiated",
7805
+ "Reference",
7806
+ "List",
7807
+ "FuzzyScalar",
7808
+ "FuzzyNumber",
7809
+ "Set"
7810
+ ]);
7811
+ function isPsiTermInput(value) {
7812
+ return typeof value === "object" && value !== null && "__psiTerm" in value && value.__psiTerm === true;
7813
+ }
7814
+ function isConstrainedPlainVar(value) {
7815
+ return typeof value === "object" && value !== null && "__constrainedVar" in value && value.__constrainedVar === true;
7816
+ }
7817
+ function isTaggedValueDto(value) {
7818
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
7819
+ const obj = value;
7820
+ return typeof obj.type === "string" && TAGGED_VALUE_TYPES.has(obj.type);
7821
+ }
7822
+ function toTaggedValue(value) {
7823
+ if (value === null) {
7824
+ return { type: "Uninstantiated" };
7825
+ }
7826
+ if (typeof value === "string") {
7827
+ return { type: "String", value };
7828
+ }
7829
+ if (typeof value === "number") {
7830
+ return Number.isInteger(value) ? { type: "Integer", value } : { type: "Real", value };
7831
+ }
7832
+ if (typeof value === "boolean") {
7833
+ return { type: "Boolean", value };
7834
+ }
7835
+ if (Array.isArray(value)) {
7836
+ return { type: "List", value: value.map(toTaggedValue) };
7837
+ }
7838
+ if (isPsiTermInput(value)) {
7839
+ throw new ValidationError(
7840
+ "PsiTermInput cannot be used in tagged value format (term CRUD). Use Value.reference(termId) to reference another term."
7841
+ );
7842
+ }
7843
+ if (isConstrainedPlainVar(value)) {
7844
+ throw new ValidationError(
7845
+ "ConstrainedPlainVar cannot be used in tagged value format (term CRUD). Constrained variables are only valid in inference contexts."
7846
+ );
7847
+ }
7848
+ if (isTaggedValueDto(value)) {
7849
+ return value;
7850
+ }
7851
+ throw new ValidationError(
7852
+ `Cannot convert value to tagged ValueDto format: ${JSON.stringify(value)}. Use plain JS values (string, number, boolean, null) or Value.* builders.`
7853
+ );
7854
+ }
7855
+ function toTaggedFeatures(features) {
7856
+ const result = {};
7857
+ for (const [key, value] of Object.entries(features)) {
7858
+ result[key] = toTaggedValue(value);
7859
+ }
7860
+ return result;
7861
+ }
7862
+ var VARIABLE_PATTERN = /^\?[A-Z]/;
7863
+ var REFERENCE_PATTERN = /^!/;
7864
+ function toUntaggedValue(value) {
7865
+ if (value === null) {
7866
+ return null;
7867
+ }
7868
+ if (typeof value === "string") {
7869
+ if (VARIABLE_PATTERN.test(value)) {
7870
+ return { name: value };
7871
+ }
7872
+ if (REFERENCE_PATTERN.test(value)) {
7873
+ return { termId: value.slice(1) };
7874
+ }
7875
+ return value;
7876
+ }
7877
+ if (typeof value === "number") {
7878
+ return value;
7879
+ }
7880
+ if (typeof value === "boolean") {
7881
+ return value;
7882
+ }
7883
+ if (Array.isArray(value)) {
7884
+ return value.map(toUntaggedValue);
7885
+ }
7886
+ if (isConstrainedPlainVar(value)) {
7887
+ const constraint = isPsiTermInput(value.constraint) ? toTermInputDto(value.constraint) : value.constraint;
7888
+ return { name: value.name, constraint };
7889
+ }
7890
+ if (isPsiTermInput(value)) {
7891
+ if (!value.features) {
7892
+ return { sortName: value.sortName };
7893
+ }
7894
+ return {
7895
+ sortName: value.sortName,
7896
+ features: toUntaggedFeatures(value.features)
7897
+ };
7898
+ }
7899
+ if (isTaggedValueDto(value)) {
7900
+ return value;
7901
+ }
7902
+ return value;
7903
+ }
7904
+ function toUntaggedFeatures(features) {
7905
+ const result = {};
7906
+ for (const [key, value] of Object.entries(features)) {
7907
+ result[key] = toUntaggedValue(value);
7908
+ }
7909
+ return result;
7910
+ }
7911
+ function toTermInputDto(input) {
7912
+ if (!isPsiTermInput(input)) {
7913
+ return input;
7914
+ }
7915
+ if (!input.features) {
7916
+ return { sortName: input.sortName };
7917
+ }
7918
+ return {
7919
+ sortName: input.sortName,
7920
+ features: toUntaggedFeatures(input.features)
7921
+ };
7922
+ }
7923
+
7683
7924
  // src/resources/terms.ts
7684
7925
  var TermsClient = class {
7685
7926
  /** @internal */
@@ -7691,11 +7932,44 @@ var TermsClient = class {
7691
7932
  /**
7692
7933
  * Create a new record.
7693
7934
  *
7694
- * @param request - Term creation parameters.
7935
+ * @param request - Term creation parameters. Features can be plain JS values
7936
+ * (auto-converted to tagged `ValueDto`) or explicit `Value.*` builder output.
7695
7937
  * @returns The created term with validation state.
7938
+ *
7939
+ * @remarks
7940
+ * **Serialization format: Tagged (`ValueDto`).**
7941
+ *
7942
+ * Plain value conversion:
7943
+ * - `string` → `{ type: "String", value: "..." }`
7944
+ * - `number` → `{ type: "Integer" | "Real", value: n }`
7945
+ * - `boolean` → `{ type: "Boolean", value: b }`
7946
+ * - `null` → `{ type: "Uninstantiated" }`
7947
+ * - `[...]` → `{ type: "List", value: [...] }`
7948
+ * - Existing `Value.*` output passes through unchanged.
7949
+ *
7950
+ * @example
7951
+ * ```typescript
7952
+ * // Plain values (recommended):
7953
+ * await client.terms.createTerm({
7954
+ * sortId: "sort-uuid",
7955
+ * ownerId: "owner-uuid",
7956
+ * features: { name: "Alice", age: 30, active: true },
7957
+ * });
7958
+ *
7959
+ * // Explicit Value builders (still works):
7960
+ * await client.terms.createTerm({
7961
+ * sortId: "sort-uuid",
7962
+ * ownerId: "owner-uuid",
7963
+ * features: { name: Value.string("Alice") },
7964
+ * });
7965
+ * ```
7696
7966
  */
7697
7967
  async createTerm(request) {
7698
- const response = await this.api.addTerm(request);
7968
+ const wireRequest = {
7969
+ ...request,
7970
+ features: convertFeatures(request.features)
7971
+ };
7972
+ const response = await this.api.addTerm(wireRequest);
7699
7973
  return response.data;
7700
7974
  }
7701
7975
  /**
@@ -7716,7 +7990,11 @@ var TermsClient = class {
7716
7990
  * @returns The updated term with validation state.
7717
7991
  */
7718
7992
  async updateTerm(termId, request) {
7719
- const response = await this.api.updateTerm(termId, request);
7993
+ const wireRequest = {
7994
+ ...request,
7995
+ features: convertFeatures(request.features)
7996
+ };
7997
+ const response = await this.api.updateTerm(termId, wireRequest);
7720
7998
  return response.data;
7721
7999
  }
7722
8000
  /**
@@ -7752,7 +8030,13 @@ var TermsClient = class {
7752
8030
  * @returns Bulk creation result with term UUIDs.
7753
8031
  */
7754
8032
  async bulkCreateTerms(request) {
7755
- const response = await this.api.bulkAddTerms(request);
8033
+ const wireRequest = {
8034
+ terms: request.terms.map((t) => ({
8035
+ ...t,
8036
+ features: convertFeatures(t.features)
8037
+ }))
8038
+ };
8039
+ const response = await this.api.bulkAddTerms(wireRequest);
7756
8040
  return response.data;
7757
8041
  }
7758
8042
  /**
@@ -7771,7 +8055,7 @@ var TermsClient = class {
7771
8055
  * const result = await client.terms.listTerms();
7772
8056
  * console.log(`Found ${result.count} terms`);
7773
8057
  * for (const term of result.terms) {
7774
- * console.log(term.id, term.sort_name);
8058
+ * console.log(term.id, term.sortName);
7775
8059
  * }
7776
8060
  * ```
7777
8061
  */
@@ -7793,14 +8077,34 @@ var TermsClient = class {
7793
8077
  * @example
7794
8078
  * ```typescript
7795
8079
  * const result = await client.terms.clearTerms();
7796
- * console.log(`${result.terms_cleared} terms cleared`);
8080
+ * console.log(`${result.termsCleared} terms cleared`);
7797
8081
  * ```
7798
8082
  */
7799
8083
  async clearTerms() {
7800
8084
  const response = await this.api.clearTerms();
7801
8085
  return response.data;
7802
8086
  }
8087
+ // ─── Friendly Aliases ─────────────────────────────────────────────
8088
+ /**
8089
+ * Create multiple records in a single request.
8090
+ * Alias for {@link bulkCreateTerms}.
8091
+ *
8092
+ * @param request - Bulk creation request.
8093
+ * @returns Bulk creation result with term UUIDs.
8094
+ *
8095
+ * @see bulkCreateTerms
8096
+ */
8097
+ async createMany(request) {
8098
+ return this.bulkCreateTerms(request);
8099
+ }
7803
8100
  };
8101
+ function convertFeatures(features) {
8102
+ const values = Object.values(features);
8103
+ if (values.length > 0 && values.every(isTaggedValueDto)) {
8104
+ return features;
8105
+ }
8106
+ return toTaggedFeatures(features);
8107
+ }
7804
8108
 
7805
8109
  // src/resources/inference.ts
7806
8110
  var InferenceClient = class {
@@ -7820,7 +8124,12 @@ var InferenceClient = class {
7820
8124
  * @returns The created rule wrapped in an AddRuleResponse.
7821
8125
  */
7822
8126
  async addRule(request) {
7823
- const response = await this.api.addRule(request);
8127
+ const wireRequest = {
8128
+ term: convertTermArg(request.term),
8129
+ antecedents: request.antecedents?.map(convertTermArg),
8130
+ certainty: request.certainty
8131
+ };
8132
+ const response = await this.api.addRule(wireRequest);
7824
8133
  return response.data;
7825
8134
  }
7826
8135
  /**
@@ -7830,7 +8139,10 @@ var InferenceClient = class {
7830
8139
  * @returns The created fact wrapped in an AddFactResponse.
7831
8140
  */
7832
8141
  async addFact(request) {
7833
- const response = await this.api.addFact(request);
8142
+ const wireRequest = {
8143
+ term: convertTermArg(request.term)
8144
+ };
8145
+ const response = await this.api.addFact(wireRequest);
7834
8146
  return response.data;
7835
8147
  }
7836
8148
  /**
@@ -7840,7 +8152,14 @@ var InferenceClient = class {
7840
8152
  * @returns Bulk creation result with rule_term_ids and rules_added count.
7841
8153
  */
7842
8154
  async bulkAddRules(request) {
7843
- const response = await this.api.bulkAddRules(request);
8155
+ const wireRequest = {
8156
+ rules: request.rules.map((r) => ({
8157
+ term: convertTermArg(r.term),
8158
+ antecedents: r.antecedents?.map(convertTermArg),
8159
+ certainty: r.certainty
8160
+ }))
8161
+ };
8162
+ const response = await this.api.bulkAddRules(wireRequest);
7844
8163
  return response.data;
7845
8164
  }
7846
8165
  /**
@@ -7850,7 +8169,10 @@ var InferenceClient = class {
7850
8169
  * @returns Bulk creation result with term_ids and facts_added count.
7851
8170
  */
7852
8171
  async bulkAddFacts(request) {
7853
- const response = await this.api.bulkAddFacts(request);
8172
+ const wireRequest = {
8173
+ facts: request.facts.map(convertTermArg)
8174
+ };
8175
+ const response = await this.api.bulkAddFacts(wireRequest);
7854
8176
  return response.data;
7855
8177
  }
7856
8178
  /**
@@ -7885,7 +8207,11 @@ var InferenceClient = class {
7885
8207
  * When it fires, the backend returns whatever solutions have been found so far.
7886
8208
  */
7887
8209
  async backwardChain(request) {
7888
- const response = await this.api.backwardChain(request);
8210
+ const wireRequest = {
8211
+ ...request,
8212
+ goal: request.goal ? convertTermArg(request.goal) : request.goal
8213
+ };
8214
+ const response = await this.api.backwardChain(wireRequest);
7889
8215
  return response.data;
7890
8216
  }
7891
8217
  /**
@@ -7901,7 +8227,11 @@ var InferenceClient = class {
7901
8227
  * If `persist_derived` is true, derived facts are permanently saved to the database.
7902
8228
  */
7903
8229
  async forwardChain(request) {
7904
- const response = await this.api.forwardChain(request);
8230
+ const wireRequest = {
8231
+ ...request,
8232
+ initialFacts: request.initialFacts?.map(convertTermArg)
8233
+ };
8234
+ const response = await this.api.forwardChain(wireRequest);
7905
8235
  return response.data;
7906
8236
  }
7907
8237
  /**
@@ -7925,7 +8255,11 @@ var InferenceClient = class {
7925
8255
  * @returns Fuzzy solutions with truth degrees.
7926
8256
  */
7927
8257
  async fuzzyProve(request) {
7928
- const response = await this.api.fuzzyProve(request);
8258
+ const wireRequest = {
8259
+ ...request,
8260
+ goal: request.goal ? convertTermArg(request.goal) : request.goal
8261
+ };
8262
+ const response = await this.api.fuzzyProve(wireRequest);
7929
8263
  return response.data;
7930
8264
  }
7931
8265
  /**
@@ -7938,7 +8272,11 @@ var InferenceClient = class {
7938
8272
  * Reduces latency via single HTTP round-trip, shared hierarchy, and rules across all goals.
7939
8273
  */
7940
8274
  async bulkFuzzyProve(request) {
7941
- const response = await this.api.bulkFuzzyProve(request);
8275
+ const wireRequest = {
8276
+ ...request,
8277
+ goals: request.goals?.map(convertTermArg)
8278
+ };
8279
+ const response = await this.api.bulkFuzzyProve(wireRequest);
7942
8280
  return response.data;
7943
8281
  }
7944
8282
  /**
@@ -7948,7 +8286,11 @@ var InferenceClient = class {
7948
8286
  * @returns Predictions with posterior probabilities.
7949
8287
  */
7950
8288
  async bayesianPredict(request) {
7951
- const response = await this.api.bayesianPredict(request);
8289
+ const wireRequest = {
8290
+ ...request,
8291
+ goal: request.goal ? convertTermArg(request.goal) : request.goal
8292
+ };
8293
+ const response = await this.api.bayesianPredict(wireRequest);
7952
8294
  return response.data;
7953
8295
  }
7954
8296
  /**
@@ -7983,7 +8325,11 @@ var InferenceClient = class {
7983
8325
  * @returns The created goal with ID, PsiTerm, and clause/constraint counts.
7984
8326
  */
7985
8327
  async createGoal(request) {
7986
- const response = await this.api.createGoal(request);
8328
+ const wireRequest = {
8329
+ ...request,
8330
+ clauses: request.clauses.map(convertTermArg)
8331
+ };
8332
+ const response = await this.api.createGoal(wireRequest);
7987
8333
  return response.data;
7988
8334
  }
7989
8335
  /**
@@ -8024,7 +8370,47 @@ var InferenceClient = class {
8024
8370
  const response = await this.api.getMetaSorts();
8025
8371
  return response.data;
8026
8372
  }
8373
+ // ─── Friendly Aliases ─────────────────────────────────────────────
8374
+ /**
8375
+ * Search for solutions by querying rules and facts backwards from a goal.
8376
+ * Alias for {@link backwardChain}.
8377
+ *
8378
+ * @param request - Backward chaining request.
8379
+ * @returns Solutions matching the goal.
8380
+ *
8381
+ * @see backwardChain
8382
+ */
8383
+ async query(request) {
8384
+ return this.backwardChain(request);
8385
+ }
8386
+ /**
8387
+ * Derive new facts by applying rules to existing facts.
8388
+ * Alias for {@link forwardChain}.
8389
+ *
8390
+ * @param request - Forward chaining request.
8391
+ * @returns Derived facts and statistics.
8392
+ *
8393
+ * @see forwardChain
8394
+ */
8395
+ async derive(request) {
8396
+ return this.forwardChain(request);
8397
+ }
8398
+ /**
8399
+ * Assert a fact into the knowledge base.
8400
+ * Alias for {@link addFact}.
8401
+ *
8402
+ * @param request - Fact definition.
8403
+ * @returns The created fact.
8404
+ *
8405
+ * @see addFact
8406
+ */
8407
+ async assertFact(request) {
8408
+ return this.addFact(request);
8409
+ }
8027
8410
  };
8411
+ function convertTermArg(input) {
8412
+ return isPsiTermInput(input) ? toTermInputDto(input) : input;
8413
+ }
8028
8414
 
8029
8415
  // src/resources/query.ts
8030
8416
  var QueryClient = class {
@@ -8037,13 +8423,18 @@ var QueryClient = class {
8037
8423
  /**
8038
8424
  * Find terms that unify with a given pattern.
8039
8425
  *
8040
- * @param request - Unifiable query with term input.
8426
+ * @param request - Unifiable query with term input. Features can be plain JS values
8427
+ * (auto-converted to tagged `ValueDto`) or explicit `Value.*` builder output.
8041
8428
  * @returns Array of matching terms (tagged ValueDto format).
8042
8429
  *
8043
8430
  * @see findMatching — friendlier alias for this method.
8044
8431
  */
8045
8432
  async findUnifiable(request) {
8046
- const response = await this.api.findUnifiable(request);
8433
+ const wireRequest = {
8434
+ ...request,
8435
+ pattern: convertPattern(request.pattern)
8436
+ };
8437
+ const response = await this.api.findUnifiable(wireRequest);
8047
8438
  return response.data.results;
8048
8439
  }
8049
8440
  /**
@@ -8060,7 +8451,7 @@ var QueryClient = class {
8060
8451
  /**
8061
8452
  * Execute an Order-Sorted Feature search.
8062
8453
  *
8063
- * @param request - OSF search request with pattern.
8454
+ * @param request - OSF search request with pattern. Features can be plain JS values.
8064
8455
  * @returns Structured search results including entities, relations, and suspended query information.
8065
8456
  *
8066
8457
  * @remarks
@@ -8070,26 +8461,36 @@ var QueryClient = class {
8070
8461
  * @see search — friendlier alias for this method.
8071
8462
  */
8072
8463
  async osfSearch(request) {
8073
- const response = await this.api.osfSearch(request);
8464
+ const wireRequest = {
8465
+ ...request,
8466
+ pattern: convertPattern(request.pattern)
8467
+ };
8468
+ const response = await this.api.osfSearch(wireRequest);
8074
8469
  return response.data;
8075
8470
  }
8076
8471
  /**
8077
8472
  * Validate a term against its sort's type witnesses.
8078
8473
  *
8079
- * @param request - Term validation request with sort_id and tagged features.
8474
+ * @param request - Term validation request with sort_id and features.
8475
+ * Features can be plain JS values (auto-converted to tagged `ValueDto`).
8080
8476
  * @returns Validation result with witness satisfaction status.
8081
8477
  *
8082
8478
  * @remarks
8083
8479
  * Uses tagged `ValueDto` format for features (same as term CRUD).
8084
8480
  */
8085
8481
  async validateTerm(request) {
8086
- const response = await this.api.validateTerm(request);
8482
+ const wireRequest = {
8483
+ ...request,
8484
+ term: convertPattern(request.term)
8485
+ };
8486
+ const response = await this.api.validateTerm(wireRequest);
8087
8487
  return response.data;
8088
8488
  }
8089
8489
  /**
8090
8490
  * Perform validated unification of two terms.
8091
8491
  *
8092
8492
  * @param request - Validated unification request with two terms to unify.
8493
+ * Features can be plain JS values (auto-converted to tagged `ValueDto`).
8093
8494
  * @returns Unification result with GLB sort and witness validation.
8094
8495
  *
8095
8496
  * @remarks
@@ -8098,10 +8499,15 @@ var QueryClient = class {
8098
8499
  * and validates the result against the GLB sort's type witnesses.
8099
8500
  */
8100
8501
  async validatedUnify(request) {
8502
+ const wireRequest = {
8503
+ ...request,
8504
+ ...request.term1 ? { term1: convertPattern(request.term1) } : {},
8505
+ ...request.term2 ? { term2: convertPattern(request.term2) } : {}
8506
+ };
8101
8507
  const response = await this.api.http.request({
8102
8508
  path: "/api/v1/query/validated-unify",
8103
8509
  method: "POST",
8104
- body: request,
8510
+ body: wireRequest,
8105
8511
  type: "application/json" /* Json */,
8106
8512
  format: "json"
8107
8513
  });
@@ -8142,6 +8548,16 @@ var QueryClient = class {
8142
8548
  return this.findUnifiable(request);
8143
8549
  }
8144
8550
  };
8551
+ function convertPattern(pattern) {
8552
+ const values = Object.values(pattern.features);
8553
+ if (values.length > 0 && values.every(isTaggedValueDto)) {
8554
+ return pattern;
8555
+ }
8556
+ return {
8557
+ sortId: pattern.sortId,
8558
+ features: toTaggedFeatures(pattern.features)
8559
+ };
8560
+ }
8145
8561
 
8146
8562
  // src/resources/cognitive.ts
8147
8563
  var CognitiveClient = class {
@@ -8177,7 +8593,7 @@ var CognitiveClient = class {
8177
8593
  * @returns The created agent response.
8178
8594
  */
8179
8595
  async createAgent(request) {
8180
- const response = await this.api.createAgent({ ...request, tenant_id: this.tenantId });
8596
+ const response = await this.api.createAgent({ ...request, tenantId: this.tenantId });
8181
8597
  return response.data;
8182
8598
  }
8183
8599
  /**
@@ -8223,7 +8639,7 @@ var CognitiveClient = class {
8223
8639
  * Uses POST with agent_id/tenant_id in the body (same pattern as other cognitive endpoints).
8224
8640
  */
8225
8641
  async getState(request) {
8226
- const response = await this.api.getAgentState({ ...request, tenant_id: this.tenantId });
8642
+ const response = await this.api.getAgentState({ ...request, tenantId: this.tenantId });
8227
8643
  return response.data.agent;
8228
8644
  }
8229
8645
  /**
@@ -8237,7 +8653,7 @@ var CognitiveClient = class {
8237
8653
  * Returns drives, deficits, curiosity targets, and the dominant drive.
8238
8654
  */
8239
8655
  async getAgentDrives(request) {
8240
- const response = await this.api.getAgentDrives(request.agent_id, {
8656
+ const response = await this.api.getAgentDrives(request.agentId, {
8241
8657
  tenant_id: this.tenantId
8242
8658
  });
8243
8659
  return response.data;
@@ -8253,7 +8669,7 @@ var CognitiveClient = class {
8253
8669
  * Uses GET with agent_id as path parameter and tenant_id as query parameter.
8254
8670
  */
8255
8671
  async getExtendedAgentState(request) {
8256
- const response = await this.api.getExtendedAgentState(request.agent_id, {
8672
+ const response = await this.api.getExtendedAgentState(request.agentId, {
8257
8673
  tenant_id: this.tenantId
8258
8674
  });
8259
8675
  return response.data.agent;
@@ -8266,7 +8682,7 @@ var CognitiveClient = class {
8266
8682
  * @returns The cycle outcome.
8267
8683
  */
8268
8684
  async runCycle(request) {
8269
- const response = await this.api.runCycle({ ...request, tenant_id: this.tenantId });
8685
+ const response = await this.api.runCycle({ ...request, tenantId: this.tenantId });
8270
8686
  return response.data;
8271
8687
  }
8272
8688
  // --- Beliefs ---
@@ -8277,7 +8693,7 @@ var CognitiveClient = class {
8277
8693
  * @returns The created belief response.
8278
8694
  */
8279
8695
  async addBelief(request) {
8280
- const response = await this.api.addBelief({ ...request, tenant_id: this.tenantId });
8696
+ const response = await this.api.addBelief({ ...request, tenantId: this.tenantId });
8281
8697
  return response.data;
8282
8698
  }
8283
8699
  // --- Goals ---
@@ -8288,7 +8704,7 @@ var CognitiveClient = class {
8288
8704
  * @returns The created goal response.
8289
8705
  */
8290
8706
  async addGoal(request) {
8291
- const response = await this.api.addGoal({ ...request, tenant_id: this.tenantId });
8707
+ const response = await this.api.addGoal({ ...request, tenantId: this.tenantId });
8292
8708
  return response.data;
8293
8709
  }
8294
8710
  // --- Cognitive Registry ---
@@ -8299,7 +8715,7 @@ var CognitiveClient = class {
8299
8715
  * @returns The created rule response.
8300
8716
  */
8301
8717
  async addRule(request) {
8302
- const response = await this.api.addCognitiveRule({ ...request, tenant_id: this.tenantId });
8718
+ const response = await this.api.addCognitiveRule({ ...request, tenantId: this.tenantId });
8303
8719
  return response.data;
8304
8720
  }
8305
8721
  /**
@@ -8309,7 +8725,7 @@ var CognitiveClient = class {
8309
8725
  * @returns The created sort response.
8310
8726
  */
8311
8727
  async addSort(request) {
8312
- const response = await this.api.createCognitiveSort({ ...request, tenant_id: this.tenantId });
8728
+ const response = await this.api.createCognitiveSort({ ...request, tenantId: this.tenantId });
8313
8729
  return response.data;
8314
8730
  }
8315
8731
  // --- Adaptive Modification ---
@@ -8324,7 +8740,7 @@ var CognitiveClient = class {
8324
8740
  * inference, not just at API boundaries. Uses POST to `/api/v1/cognitive/agents/adapt`.
8325
8741
  */
8326
8742
  async adaptiveModify(request) {
8327
- const response = await this.api.adaptiveModify({ ...request, tenant_id: this.tenantId });
8743
+ const response = await this.api.adaptiveModify({ ...request, tenantId: this.tenantId });
8328
8744
  return response.data;
8329
8745
  }
8330
8746
  // --- Episodic Memory ---
@@ -8335,7 +8751,7 @@ var CognitiveClient = class {
8335
8751
  * @returns Recalled episodes sorted by similarity/recency.
8336
8752
  */
8337
8753
  async recallEpisodes(request) {
8338
- const response = await this.episodicMemory.recallEpisodes({ ...request, tenant_id: this.tenantId });
8754
+ const response = await this.episodicMemory.recallEpisodes({ ...request, tenantId: this.tenantId });
8339
8755
  return response.data;
8340
8756
  }
8341
8757
  /**
@@ -8349,7 +8765,7 @@ var CognitiveClient = class {
8349
8765
  * unlike the original SDK which used GET with a path parameter.
8350
8766
  */
8351
8767
  async getEpisodeStats(request) {
8352
- const response = await this.episodicMemory.getEpisodeStats({ ...request, tenant_id: this.tenantId });
8768
+ const response = await this.episodicMemory.getEpisodeStats({ ...request, tenantId: this.tenantId });
8353
8769
  return response.data;
8354
8770
  }
8355
8771
  // --- HTN Planning ---
@@ -8360,7 +8776,7 @@ var CognitiveClient = class {
8360
8776
  * @returns The created method response.
8361
8777
  */
8362
8778
  async addHtnMethod(request) {
8363
- const response = await this.htn.addHtnMethod({ ...request, tenant_id: this.tenantId });
8779
+ const response = await this.htn.addHtnMethod({ ...request, tenantId: this.tenantId });
8364
8780
  return response.data;
8365
8781
  }
8366
8782
  // --- Messaging ---
@@ -8371,7 +8787,7 @@ var CognitiveClient = class {
8371
8787
  * @returns The send result.
8372
8788
  */
8373
8789
  async sendMessage(request) {
8374
- const response = await this.messaging.sendMessage({ ...request, tenant_id: this.tenantId });
8790
+ const response = await this.messaging.sendMessage({ ...request, tenantId: this.tenantId });
8375
8791
  return response.data;
8376
8792
  }
8377
8793
  /**
@@ -8381,7 +8797,7 @@ var CognitiveClient = class {
8381
8797
  * @returns The broadcast result.
8382
8798
  */
8383
8799
  async broadcastMessage(request) {
8384
- const response = await this.messaging.broadcastMessage({ ...request, tenant_id: this.tenantId });
8800
+ const response = await this.messaging.broadcastMessage({ ...request, tenantId: this.tenantId });
8385
8801
  return response.data;
8386
8802
  }
8387
8803
  /**
@@ -8391,7 +8807,7 @@ var CognitiveClient = class {
8391
8807
  * @returns The result.
8392
8808
  */
8393
8809
  async markMessagesRead(request) {
8394
- const response = await this.messaging.markMessagesRead({ ...request, tenant_id: this.tenantId });
8810
+ const response = await this.messaging.markMessagesRead({ ...request, tenantId: this.tenantId });
8395
8811
  return response.data;
8396
8812
  }
8397
8813
  // --- Feedback ---
@@ -8402,7 +8818,7 @@ var CognitiveClient = class {
8402
8818
  * @returns The feedback result.
8403
8819
  */
8404
8820
  async provideFeedback(request) {
8405
- const response = await this.api.provideFeedback({ ...request, tenant_id: this.tenantId });
8821
+ const response = await this.api.provideFeedback({ ...request, tenantId: this.tenantId });
8406
8822
  return response.data;
8407
8823
  }
8408
8824
  /**
@@ -8417,7 +8833,7 @@ var CognitiveClient = class {
8417
8833
  * Uses POST to `/api/v1/cognitive/learn_correction`.
8418
8834
  */
8419
8835
  async learnFromCorrection(request) {
8420
- const response = await this.api.learnFromCorrection({ ...request, tenant_id: this.tenantId });
8836
+ const response = await this.api.learnFromCorrection({ ...request, tenantId: this.tenantId });
8421
8837
  return response.data;
8422
8838
  }
8423
8839
  /**
@@ -8432,7 +8848,7 @@ var CognitiveClient = class {
8432
8848
  * Uses POST to `/api/v1/cognitive/agents/reflect`.
8433
8849
  */
8434
8850
  async reflectionQuery(request) {
8435
- const response = await this.api.reflectionQuery({ ...request, tenant_id: this.tenantId });
8851
+ const response = await this.api.reflectionQuery({ ...request, tenantId: this.tenantId });
8436
8852
  return response.data;
8437
8853
  }
8438
8854
  // --- Integrated Cycle ---
@@ -8443,7 +8859,7 @@ var CognitiveClient = class {
8443
8859
  * @returns The integrated cycle outcome with duration.
8444
8860
  */
8445
8861
  async integratedCycle(request) {
8446
- const response = await this.api.runIntegratedCycle({ ...request, tenant_id: this.tenantId });
8862
+ const response = await this.api.runIntegratedCycle({ ...request, tenantId: this.tenantId });
8447
8863
  return response.data;
8448
8864
  }
8449
8865
  // --- KB Subscription ---
@@ -8454,7 +8870,7 @@ var CognitiveClient = class {
8454
8870
  * @returns Subscription ID.
8455
8871
  */
8456
8872
  async subscribeToKb(request) {
8457
- const response = await this.api.subscribeToKb({ ...request, tenant_id: this.tenantId });
8873
+ const response = await this.api.subscribeToKb({ ...request, tenantId: this.tenantId });
8458
8874
  return response.data;
8459
8875
  }
8460
8876
  // --- Episode Recording ---
@@ -8465,7 +8881,7 @@ var CognitiveClient = class {
8465
8881
  * @returns The created episode ID.
8466
8882
  */
8467
8883
  async recordEpisode(request) {
8468
- const response = await this.episodicMemory.recordEpisode({ ...request, tenant_id: this.tenantId });
8884
+ const response = await this.episodicMemory.recordEpisode({ ...request, tenantId: this.tenantId });
8469
8885
  return response.data;
8470
8886
  }
8471
8887
  // --- Plan Library ---
@@ -8479,7 +8895,7 @@ var CognitiveClient = class {
8479
8895
  * Stores a successful action sequence as a reusable plan template.
8480
8896
  */
8481
8897
  async storePlan(request) {
8482
- const response = await this.planLibrary.storePlan({ ...request, tenant_id: this.tenantId });
8898
+ const response = await this.planLibrary.storePlan({ ...request, tenantId: this.tenantId });
8483
8899
  return response.data;
8484
8900
  }
8485
8901
  /**
@@ -8492,7 +8908,7 @@ var CognitiveClient = class {
8492
8908
  * Searches the plan library for plans that match the given goal.
8493
8909
  */
8494
8910
  async findPlans(request) {
8495
- const response = await this.planLibrary.findPlans({ ...request, tenant_id: this.tenantId });
8911
+ const response = await this.planLibrary.findPlans({ ...request, tenantId: this.tenantId });
8496
8912
  return response.data;
8497
8913
  }
8498
8914
  /**
@@ -8502,7 +8918,7 @@ var CognitiveClient = class {
8502
8918
  * @returns Whether the plan was deleted.
8503
8919
  */
8504
8920
  async deletePlan(request) {
8505
- const response = await this.planLibrary.deletePlan(request.plan_id, {
8921
+ const response = await this.planLibrary.deletePlan(request.planId, {
8506
8922
  tenant_id: this.tenantId
8507
8923
  });
8508
8924
  return response.data;
@@ -8514,7 +8930,7 @@ var CognitiveClient = class {
8514
8930
  * @returns Updated success rate and use count.
8515
8931
  */
8516
8932
  async updatePlanStats(request) {
8517
- const response = await this.planLibrary.updatePlanStats({ ...request, tenant_id: this.tenantId });
8933
+ const response = await this.planLibrary.updatePlanStats({ ...request, tenantId: this.tenantId });
8518
8934
  return response.data;
8519
8935
  }
8520
8936
  // --- WebSocket Subscriptions ---
@@ -8589,8 +9005,8 @@ var FuzzyClient = class {
8589
9005
  */
8590
9006
  async compareSimilarity(term1Id, term2Id, options) {
8591
9007
  return this.fuzzyUnify({
8592
- term1_id: term1Id,
8593
- term2_id: term2Id,
9008
+ term1Id,
9009
+ term2Id,
8594
9010
  ...options
8595
9011
  });
8596
9012
  }
@@ -8775,7 +9191,7 @@ var ConstraintsClient = class {
8775
9191
  * ```ts
8776
9192
  * const sessions = await client.constraints.listSessions();
8777
9193
  * for (const session of sessions) {
8778
- * console.log(`${session.session_id}: ${session.status}`);
9194
+ * console.log(`${session.sessionId}: ${session.status}`);
8779
9195
  * }
8780
9196
  * ```
8781
9197
  */
@@ -11150,7 +11566,7 @@ var NeuroSymbolicClient = class {
11150
11566
  * @example
11151
11567
  * ```ts
11152
11568
  * const result = await client.neuroSymbolic.trainFromTraces();
11153
- * console.log(`Triggered: ${result.triggered}, Loss: ${result.loss}, Traces: ${result.traces_consumed}`);
11569
+ * console.log(`Triggered: ${result.triggered}, Loss: ${result.loss}, Traces: ${result.tracesConsumed}`);
11154
11570
  * ```
11155
11571
  * @remarks Uses untagged serialization. POST /api/v1/admin/neuro-symbolic/train/from-traces
11156
11572
  */
@@ -11356,7 +11772,7 @@ var FunctionsClient = class {
11356
11772
  * },
11357
11773
  * ],
11358
11774
  * });
11359
- * console.log(result.function_id); // UUID of the registered function
11775
+ * console.log(result.functionId); // UUID of the registered function
11360
11776
  * ```
11361
11777
  */
11362
11778
  async registerFunction(request) {
@@ -11386,7 +11802,7 @@ var FunctionsClient = class {
11386
11802
  * arguments: [{ type: 'Integer', value: 5 }],
11387
11803
  * tenant_id: 'my-tenant-uuid',
11388
11804
  * });
11389
- * if (result.result_type === 'Value') {
11805
+ * if (result.resultType === 'Value') {
11390
11806
  * console.log(result.value); // { type: 'Integer', value: 120 }
11391
11807
  * } else {
11392
11808
  * console.log('Suspended:', result.reason);
@@ -11431,7 +11847,7 @@ var WebhookActionsClient = class {
11431
11847
  * outputs: ['message_id', 'sent_at'],
11432
11848
  * tenant_id: 'my-tenant-uuid',
11433
11849
  * });
11434
- * console.log(result.action_id, result.sort_id);
11850
+ * console.log(result.actionId, result.sortId);
11435
11851
  * ```
11436
11852
  */
11437
11853
  async register(request) {
@@ -11458,7 +11874,7 @@ var WebhookActionsClient = class {
11458
11874
  * inputs: { to: 'user@example.com', subject: 'Hello', body: 'World' },
11459
11875
  * tenant_id: 'my-tenant-uuid',
11460
11876
  * });
11461
- * console.log(result.invocation_id, result.callback_url);
11877
+ * console.log(result.invocationId, result.callbackUrl);
11462
11878
  * ```
11463
11879
  */
11464
11880
  async invoke(name, request) {
@@ -11484,7 +11900,7 @@ var WebhookActionsClient = class {
11484
11900
  * status: 'success',
11485
11901
  * outputs: { message_id: 'msg-456', sent_at: '2024-01-15T10:30:00Z' },
11486
11902
  * });
11487
- * console.log(result.demons_fired, result.term_updated);
11903
+ * console.log(result.demonsFired, result.termUpdated);
11488
11904
  * ```
11489
11905
  */
11490
11906
  async completeInvocation(invocationId, request) {
@@ -11505,7 +11921,7 @@ var WebhookActionsClient = class {
11505
11921
  * const result = await client.webhookActions.listActions();
11506
11922
  * console.log(`Found ${result.total} actions`);
11507
11923
  * for (const action of result.actions) {
11508
- * console.log(action.name, action.webhook_url);
11924
+ * console.log(action.name, action.webhookUrl);
11509
11925
  * }
11510
11926
  * ```
11511
11927
  */
@@ -11526,9 +11942,9 @@ var WebhookActionsClient = class {
11526
11942
  * @example
11527
11943
  * ```typescript
11528
11944
  * const result = await client.webhookActions.listPendingInvocations();
11529
- * console.log(`${result.total_pending} pending invocations`);
11945
+ * console.log(`${result.totalPending} pending invocations`);
11530
11946
  * for (const inv of result.invocations) {
11531
- * console.log(inv.invocation_id, inv.action_name, inv.status);
11947
+ * console.log(inv.invocationId, inv.actionName, inv.status);
11532
11948
  * }
11533
11949
  * ```
11534
11950
  */
@@ -11566,8 +11982,8 @@ var SyntheticClient = class {
11566
11982
  * term_id: 'term-uuid',
11567
11983
  * schema_sort_ids: ['sort-uuid-1', 'sort-uuid-2'],
11568
11984
  * });
11569
- * console.log(result.full_prompt);
11570
- * console.log(result.stable_prefix); // cacheable across calls
11985
+ * console.log(result.fullPrompt);
11986
+ * console.log(result.stablePrefix); // cacheable across calls
11571
11987
  * ```
11572
11988
  */
11573
11989
  async buildGenerationPrompt(request) {
@@ -11594,9 +12010,9 @@ var SyntheticClient = class {
11594
12010
  * ],
11595
12011
  * sort_names: { 'sort-uuid': 'Employee' },
11596
12012
  * });
11597
- * console.log(`Global ECE: ${report.global_ece}`);
11598
- * for (const target of report.augmentation_targets) {
11599
- * console.log(`${target.sort_name} needs ${target.recommended_examples} more examples`);
12013
+ * console.log(`Global ECE: ${report.globalEce}`);
12014
+ * for (const target of report.augmentationTargets) {
12015
+ * console.log(`${target.sortName} needs ${target.recommendedExamples} more examples`);
11600
12016
  * }
11601
12017
  * ```
11602
12018
  */
@@ -11624,7 +12040,7 @@ var SyntheticClient = class {
11624
12040
  * existing_term_ids: ['term-uuid-1', 'term-uuid-2'],
11625
12041
  * min_diversity_score: 0.3,
11626
12042
  * });
11627
- * console.log(`Novel: ${result.is_diverse}, score: ${result.novelty_score}`);
12043
+ * console.log(`Novel: ${result.isDiverse}, score: ${result.noveltyScore}`);
11628
12044
  * ```
11629
12045
  */
11630
12046
  async checkDiversity(request) {
@@ -11650,7 +12066,7 @@ var SyntheticClient = class {
11650
12066
  * target_sorts: ['sort-uuid'],
11651
12067
  * max_terms_per_sort: 50,
11652
12068
  * });
11653
- * console.log(`Exported ${result.example_count} examples`);
12069
+ * console.log(`Exported ${result.exampleCount} examples`);
11654
12070
  * // Write JSONL to file for fine-tuning
11655
12071
  * ```
11656
12072
  */
@@ -11712,8 +12128,8 @@ var SyntheticClient = class {
11712
12128
  * enable_verbalization: true,
11713
12129
  * seed: 42,
11714
12130
  * });
11715
- * console.log(`Generated ${result.training_pairs_count} training pairs`);
11716
- * console.log(`Report: ${result.report.terms_generated} terms generated`);
12131
+ * console.log(`Generated ${result.trainingPairsCount} training pairs`);
12132
+ * console.log(`Report: ${result.report.termsGenerated} terms generated`);
11717
12133
  * ```
11718
12134
  */
11719
12135
  async generateSynthetic(request) {
@@ -11795,7 +12211,7 @@ var SyntheticClient = class {
11795
12211
  * extracted: [{ sort_id: 'sort-uuid', features: { name: 'Alice' } }],
11796
12212
  * min_faithfulness_score: 0.5,
11797
12213
  * });
11798
- * console.log(`Passed: ${result.passed}, Score: ${result.faithfulness_score}`);
12214
+ * console.log(`Passed: ${result.passed}, Score: ${result.faithfulnessScore}`);
11799
12215
  * ```
11800
12216
  */
11801
12217
  async verifyRoundTrip(request) {
@@ -11829,7 +12245,7 @@ var ProofEngineClient = class {
11829
12245
  * const session = await client.proofEngine.createRuleStoreSession({
11830
12246
  * tenant_id: 'tenant-uuid',
11831
12247
  * });
11832
- * console.log(session.store_id);
12248
+ * console.log(session.storeId);
11833
12249
  * ```
11834
12250
  */
11835
12251
  async createRuleStoreSession(request) {
@@ -11849,7 +12265,7 @@ var ProofEngineClient = class {
11849
12265
  * @example
11850
12266
  * ```typescript
11851
12267
  * const session = await client.proofEngine.getRuleStoreSession('store-uuid');
11852
- * console.log(`${session.rule_count} rules in store`);
12268
+ * console.log(`${session.ruleCount} rules in store`);
11853
12269
  * ```
11854
12270
  */
11855
12271
  async getRuleStoreSession(storeId) {
@@ -11875,7 +12291,7 @@ var ProofEngineClient = class {
11875
12291
  * head: { constraints: [{ type: 'sort', var_name: 'X', sort_id: 'person-uuid' }] },
11876
12292
  * body: [],
11877
12293
  * });
11878
- * console.log(`Rule ${result.rule_id} asserted, ${result.rule_count} total`);
12294
+ * console.log(`Rule ${result.ruleId} asserted, ${result.ruleCount} total`);
11879
12295
  * ```
11880
12296
  */
11881
12297
  async assertRule(storeId, request) {
@@ -11900,7 +12316,7 @@ var ProofEngineClient = class {
11900
12316
  * const result = await client.proofEngine.retractRule('store-uuid', {
11901
12317
  * rule_id: 'rule-uuid',
11902
12318
  * });
11903
- * console.log(`${result.retracted_count} rules retracted`);
12319
+ * console.log(`${result.retractedCount} rules retracted`);
11904
12320
  * ```
11905
12321
  */
11906
12322
  async retractRule(storeId, request) {
@@ -11923,7 +12339,7 @@ var ProofEngineClient = class {
11923
12339
  * const result = await client.proofEngine.findRules('store-uuid', {
11924
12340
  * pattern: { constraints: [{ type: 'sort', var_name: 'X', sort_id: 'person-uuid' }] },
11925
12341
  * });
11926
- * console.log(`Found ${result.matching_rules.length} matching rules`);
12342
+ * console.log(`Found ${result.matchingRules.length} matching rules`);
11927
12343
  * ```
11928
12344
  */
11929
12345
  async findRules(storeId, request) {
@@ -11945,7 +12361,7 @@ var ProofEngineClient = class {
11945
12361
  * @example
11946
12362
  * ```typescript
11947
12363
  * const marker = await client.proofEngine.markRuleStore('store-uuid', {});
11948
- * console.log(`Checkpoint at index ${marker.marker_index}`);
12364
+ * console.log(`Checkpoint at index ${marker.markerIndex}`);
11949
12365
  * ```
11950
12366
  */
11951
12367
  async markRuleStore(storeId, request) {
@@ -11968,7 +12384,7 @@ var ProofEngineClient = class {
11968
12384
  * const result = await client.proofEngine.undoRuleStore('store-uuid', {
11969
12385
  * marker_index: 0,
11970
12386
  * });
11971
- * console.log(`Undo ${result.success ? 'succeeded' : 'failed'}, ${result.rule_count} rules`);
12387
+ * console.log(`Undo ${result.success ? 'succeeded' : 'failed'}, ${result.ruleCount} rules`);
11972
12388
  * ```
11973
12389
  */
11974
12390
  async undoRuleStore(storeId, request) {
@@ -11992,7 +12408,7 @@ var ProofEngineClient = class {
11992
12408
  * const session = await client.proofEngine.createTermStoreSession({
11993
12409
  * tenant_id: 'tenant-uuid',
11994
12410
  * });
11995
- * console.log(session.session_id);
12411
+ * console.log(session.sessionId);
11996
12412
  * ```
11997
12413
  */
11998
12414
  async createTermStoreSession(request) {
@@ -12012,7 +12428,7 @@ var ProofEngineClient = class {
12012
12428
  * @example
12013
12429
  * ```typescript
12014
12430
  * const session = await client.proofEngine.getTermStoreSession('session-uuid');
12015
- * console.log(`${session.term_count} terms, ${session.variable_count} variables`);
12431
+ * console.log(`${session.termCount} terms, ${session.variableCount} variables`);
12016
12432
  * ```
12017
12433
  */
12018
12434
  async getTermStoreSession(sessionId) {
@@ -12036,7 +12452,7 @@ var ProofEngineClient = class {
12036
12452
  * sort_id: 'person-uuid',
12037
12453
  * features: { name: "Alice" },
12038
12454
  * });
12039
- * console.log(`Created term ${term.term_id}`);
12455
+ * console.log(`Created term ${term.termId}`);
12040
12456
  * ```
12041
12457
  */
12042
12458
  async createStoreTerm(sessionId, request) {
@@ -12059,7 +12475,7 @@ var ProofEngineClient = class {
12059
12475
  * const variable = await client.proofEngine.createStoreVariable('session-uuid', {
12060
12476
  * sort_id: 'person-uuid',
12061
12477
  * });
12062
- * console.log(`Created variable ${variable.term_id}, is_variable: ${variable.is_variable}`);
12478
+ * console.log(`Created variable ${variable.termId}, is_variable: ${variable.isVariable}`);
12063
12479
  * ```
12064
12480
  */
12065
12481
  async createStoreVariable(sessionId, request) {
@@ -12084,7 +12500,7 @@ var ProofEngineClient = class {
12084
12500
  * variable_id: 'var-uuid',
12085
12501
  * target_id: 'term-uuid',
12086
12502
  * });
12087
- * console.log(`Bound ${result.variable_id} to ${result.bound_to}`);
12503
+ * console.log(`Bound ${result.variableId} to ${result.boundTo}`);
12088
12504
  * ```
12089
12505
  */
12090
12506
  async bindStoreVariable(sessionId, request) {
@@ -12108,7 +12524,7 @@ var ProofEngineClient = class {
12108
12524
  * const result = await client.proofEngine.dereferenceStoreTerm('session-uuid', {
12109
12525
  * term_id: 'var-uuid',
12110
12526
  * });
12111
- * console.log(`${result.original_id} -> ${result.dereferenced_id} (bound: ${result.is_bound})`);
12527
+ * console.log(`${result.originalId} -> ${result.dereferencedId} (bound: ${result.isBound})`);
12112
12528
  * ```
12113
12529
  */
12114
12530
  async dereferenceStoreTerm(sessionId, request) {
@@ -12132,7 +12548,7 @@ var ProofEngineClient = class {
12132
12548
  * const term = await client.proofEngine.getStoreTerm('session-uuid', {
12133
12549
  * term_id: 'term-uuid',
12134
12550
  * });
12135
- * console.log(`Sort: ${term.sort_id}, features:`, term.features);
12551
+ * console.log(`Sort: ${term.sortId}, features:`, term.features);
12136
12552
  * ```
12137
12553
  */
12138
12554
  async getStoreTerm(sessionId, request) {
@@ -12183,9 +12599,9 @@ var ProofEngineClient = class {
12183
12599
  * term2_id: 'term2-uuid',
12184
12600
  * });
12185
12601
  * if (result.success) {
12186
- * console.log(`Unified as ${result.unified_term_id}`);
12602
+ * console.log(`Unified as ${result.unifiedTermId}`);
12187
12603
  * } else {
12188
- * console.log(`Failed: ${result.failure_reason}`);
12604
+ * console.log(`Failed: ${result.failureReason}`);
12189
12605
  * }
12190
12606
  * ```
12191
12607
  */
@@ -12208,7 +12624,7 @@ var ProofEngineClient = class {
12208
12624
  * @example
12209
12625
  * ```typescript
12210
12626
  * const marker = await client.proofEngine.markTermStore('session-uuid', {});
12211
- * console.log(`Marker at index ${marker.marker_index}, trail length ${marker.trail_length}`);
12627
+ * console.log(`Marker at index ${marker.markerIndex}, trail length ${marker.trailLength}`);
12212
12628
  * ```
12213
12629
  */
12214
12630
  async markTermStore(sessionId, request) {
@@ -12232,7 +12648,7 @@ var ProofEngineClient = class {
12232
12648
  * const result = await client.proofEngine.backtrackTermStore('session-uuid', {
12233
12649
  * marker_index: 0,
12234
12650
  * });
12235
- * console.log(`Backtrack ${result.success ? 'succeeded' : 'failed'}, undid ${result.undone_entries} entries`);
12651
+ * console.log(`Backtrack ${result.success ? 'succeeded' : 'failed'}, undid ${result.undoneEntries} entries`);
12236
12652
  * ```
12237
12653
  */
12238
12654
  async backtrackTermStore(sessionId, request) {
@@ -12313,7 +12729,7 @@ var HealthClient = class {
12313
12729
  * ```typescript
12314
12730
  * const health = await client.health.check();
12315
12731
  * console.log(health.status); // "healthy"
12316
- * console.log(health.build_info.version); // "1.2.3"
12732
+ * console.log(health.buildInfo.version); // "1.2.3"
12317
12733
  * for (const component of health.components) {
12318
12734
  * console.log(`${component.name}: ${component.status}`);
12319
12735
  * }
@@ -12348,14 +12764,38 @@ var AdminClient = class {
12348
12764
  * ```typescript
12349
12765
  * const result = await client.admin.clearAllData();
12350
12766
  * console.log(result.message);
12351
- * console.log(`Tables cleared: ${result.postgres_tables_cleared}`);
12352
- * console.log(`Qdrant collections deleted: ${result.qdrant_collections_deleted}`);
12767
+ * console.log(`Tables cleared: ${result.postgresTablesCleared}`);
12768
+ * console.log(`Qdrant collections deleted: ${result.qdrantCollectionsDeleted}`);
12353
12769
  * ```
12354
12770
  */
12355
12771
  async clearAllData() {
12356
12772
  const response = await this.api.clearAllData();
12357
12773
  return response.data;
12358
12774
  }
12775
+ /**
12776
+ * Clear all data for a specific tenant.
12777
+ *
12778
+ * @param tenantId - The UUID of the tenant whose data should be cleared.
12779
+ * @returns Confirmation of what was wiped, including record counts and cache status.
12780
+ * @throws {ApiError} If the request fails.
12781
+ *
12782
+ * @remarks
12783
+ * Destructive operation that wipes all PostgreSQL rows, in-memory inference state,
12784
+ * and cache entries for the specified tenant. Other tenants are unaffected.
12785
+ * Use for tenant offboarding or testing.
12786
+ *
12787
+ * @example
12788
+ * ```typescript
12789
+ * const result = await client.admin.clearTenantData('550e8400-e29b-41d4-a716-446655440000');
12790
+ * console.log(result.message);
12791
+ * console.log(`Terms deleted: ${result.termsDeleted}`);
12792
+ * console.log(`Sessions deleted: ${result.sessionsDeleted}`);
12793
+ * ```
12794
+ */
12795
+ async clearTenantData(tenantId) {
12796
+ const response = await this.api.clearTenantData(tenantId);
12797
+ return response.data;
12798
+ }
12359
12799
  /**
12360
12800
  * List all tenants that have data in the system.
12361
12801
  *
@@ -12370,7 +12810,7 @@ var AdminClient = class {
12370
12810
  * ```typescript
12371
12811
  * const result = await client.admin.listTenants();
12372
12812
  * for (const tenant of result.tenants) {
12373
- * console.log(`${tenant.tenant_id}: ${tenant.term_count} terms, ${tenant.session_count} sessions`);
12813
+ * console.log(`${tenant.tenantId}: ${tenant.termCount} terms, ${tenant.sessionCount} sessions`);
12374
12814
  * }
12375
12815
  * ```
12376
12816
  */
@@ -12450,7 +12890,7 @@ var OntologyClient = class {
12450
12890
  * // Answer the questions and call again
12451
12891
  * const completed = await client.ontology.generate({
12452
12892
  * prompt: 'Build a customer support ticket system',
12453
- * session_id: result.session_id,
12893
+ * session_id: result.sessionId,
12454
12894
  * answers: { priority_levels: '3' },
12455
12895
  * });
12456
12896
  * }
@@ -12540,11 +12980,11 @@ var RagClient = class {
12540
12980
  * include_related: true,
12541
12981
  * });
12542
12982
  *
12543
- * for (const concept of result.primary_concepts) {
12544
- * console.log(`${concept.canonical_name} (${concept.match_degree})`);
12983
+ * for (const concept of result.primaryConcepts) {
12984
+ * console.log(`${concept.canonicalName} (${concept.matchDegree})`);
12545
12985
  * }
12546
12986
  *
12547
- * console.log(`Found ${result.stats.emergent_discovered} emergent relations`);
12987
+ * console.log(`Found ${result.stats.emergentDiscovered} emergent relations`);
12548
12988
  * ```
12549
12989
  */
12550
12990
  async ontologyRag(request) {
@@ -12556,7 +12996,7 @@ var RagClient = class {
12556
12996
  // src/builders/lp.ts
12557
12997
  function numericTerm(n) {
12558
12998
  return {
12559
- sort_name: Number.isInteger(n) ? "integer_type" : "real_type",
12999
+ sortName: Number.isInteger(n) ? "integer_type" : "real_type",
12560
13000
  features: { value: n }
12561
13001
  };
12562
13002
  }
@@ -12676,7 +13116,7 @@ function compileLP(problem, solutionSortName) {
12676
13116
  const ref = varRefs[varName];
12677
13117
  if (bounds.min !== void 0 && bounds.max !== void 0) {
12678
13118
  allAntecedents.push({
12679
- sort_name: "real_between_constraint",
13119
+ sortName: "real_between_constraint",
12680
13120
  features: {
12681
13121
  var: ref,
12682
13122
  lower: numericTerm(bounds.min),
@@ -12686,7 +13126,7 @@ function compileLP(problem, solutionSortName) {
12686
13126
  } else {
12687
13127
  if (bounds.min !== void 0) {
12688
13128
  allAntecedents.push({
12689
- sort_name: "real_ge_constraint",
13129
+ sortName: "real_ge_constraint",
12690
13130
  features: {
12691
13131
  left: ref,
12692
13132
  right: numericTerm(bounds.min)
@@ -12695,7 +13135,7 @@ function compileLP(problem, solutionSortName) {
12695
13135
  }
12696
13136
  if (bounds.max !== void 0) {
12697
13137
  allAntecedents.push({
12698
- sort_name: "real_le_constraint",
13138
+ sortName: "real_le_constraint",
12699
13139
  features: {
12700
13140
  left: ref,
12701
13141
  right: numericTerm(bounds.max)
@@ -12710,7 +13150,7 @@ function compileLP(problem, solutionSortName) {
12710
13150
  allAntecedents.push(...compiled.antecedents);
12711
13151
  const sortName = constraintOpToSort(constraint.op);
12712
13152
  allAntecedents.push({
12713
- sort_name: sortName,
13153
+ sortName,
12714
13154
  features: {
12715
13155
  left: compiled.resultRef,
12716
13156
  right: numericTerm(constraint.rhs)
@@ -12727,7 +13167,7 @@ function compileLP(problem, solutionSortName) {
12727
13167
  if (typeof objectiveRef === "number") {
12728
13168
  const objVar = { name: "?_lp_objective" };
12729
13169
  allAntecedents.push({
12730
- sort_name: "real_eq_constraint",
13170
+ sortName: "real_eq_constraint",
12731
13171
  features: {
12732
13172
  left: objVar,
12733
13173
  right: numericTerm(objectiveRef)
@@ -12737,7 +13177,7 @@ function compileLP(problem, solutionSortName) {
12737
13177
  }
12738
13178
  const objectiveSortName = problem.objective.direction === "maximize" ? "maximize_objective" : "minimize_objective";
12739
13179
  allAntecedents.push({
12740
- sort_name: objectiveSortName,
13180
+ sortName: objectiveSortName,
12741
13181
  features: {
12742
13182
  expression: objectiveRef,
12743
13183
  name: "objective"
@@ -12747,7 +13187,7 @@ function compileLP(problem, solutionSortName) {
12747
13187
  (name) => varRefs[name]
12748
13188
  );
12749
13189
  allAntecedents.push({
12750
- sort_name: "real_labeling_constraint",
13190
+ sortName: "real_labeling_constraint",
12751
13191
  features: {
12752
13192
  variables: variableRefList
12753
13193
  }
@@ -12758,7 +13198,7 @@ function compileLP(problem, solutionSortName) {
12758
13198
  }
12759
13199
  solutionFeatures["_objective"] = objectiveRef;
12760
13200
  const solutionTerm = {
12761
- sort_name: solutionSortName,
13201
+ sortName: solutionSortName,
12762
13202
  features: solutionFeatures
12763
13203
  };
12764
13204
  return { solutionTerm, antecedents: allAntecedents };
@@ -12792,7 +13232,7 @@ function compileLinearExpression(expression, varRefs, nextVar) {
12792
13232
  } else {
12793
13233
  const resultVar = { name: nextVar() };
12794
13234
  antecedents.push({
12795
- sort_name: "real_times_constraint",
13235
+ sortName: "real_times_constraint",
12796
13236
  features: {
12797
13237
  coefficient: numericTerm(coefficient),
12798
13238
  variable: varRef,
@@ -12812,7 +13252,7 @@ function compileLinearExpression(expression, varRefs, nextVar) {
12812
13252
  for (let i = 1; i < termResults.length; i++) {
12813
13253
  const sumVar = { name: nextVar() };
12814
13254
  antecedents.push({
12815
- sort_name: "real_plus_constraint",
13255
+ sortName: "real_plus_constraint",
12816
13256
  features: {
12817
13257
  left: current,
12818
13258
  right: termResults[i],
@@ -12901,29 +13341,30 @@ var OptimizeClient = class {
12901
13341
  const sortResponse = await this.sortsApi.bulkCreateSorts({
12902
13342
  sorts: [{ name: solutionSortName, parents: ["thing"] }]
12903
13343
  });
12904
- sortId = sortResponse.data.sort_ids[solutionSortName];
13344
+ const sortIdsMap = sortResponse.data.sortIds;
13345
+ sortId = Object.values(sortIdsMap)[0];
12905
13346
  const ruleResponse = await this.inferenceApi.addRule({
12906
13347
  term: compiled.solutionTerm,
12907
13348
  antecedents: compiled.antecedents,
12908
13349
  certainty: 1
12909
13350
  });
12910
- ruleTermId = ruleResponse.data.term.term_id;
13351
+ ruleTermId = ruleResponse.data.term.termId;
12911
13352
  const bcResponse = await this.inferenceApi.backwardChain({
12912
- goal: { sort_name: solutionSortName },
12913
- max_solutions: 1,
12914
- max_depth: maxDepth,
12915
- timeout_ms: timeoutMs
13353
+ goal: { sortName: solutionSortName },
13354
+ maxSolutions: 1,
13355
+ maxDepth,
13356
+ timeoutMs
12916
13357
  });
12917
- const queryTimeMs = bcResponse.data.query_time_ms;
13358
+ const queryTimeMs = bcResponse.data.queryTimeMs;
12918
13359
  if (bcResponse.data.solutions.length === 0) {
12919
13360
  return { status: "infeasible", solveTimeMs: queryTimeMs };
12920
13361
  }
12921
13362
  const solution = bcResponse.data.solutions[0];
12922
13363
  const variables = {};
12923
13364
  for (const binding of solution.substitution.bindings) {
12924
- const varName = binding.variable_name;
13365
+ const varName = binding.variableName;
12925
13366
  if (!varName) continue;
12926
- const value = parseFloat(binding.bound_to_display);
13367
+ const value = parseFloat(binding.boundToDisplay);
12927
13368
  if (isNaN(value)) continue;
12928
13369
  if (varName.startsWith("?") && !varName.startsWith("?_lp_")) {
12929
13370
  variables[varName.slice(1)] = value;
@@ -12986,7 +13427,7 @@ var OptimizeClient = class {
12986
13427
  async fromKnowledgeBase(config, options) {
12987
13428
  const sortId = await this.resolveSortName(config.variables.sort);
12988
13429
  const queryResponse = await this.queryApi.findBySort({
12989
- sort_id: sortId
13430
+ sortId
12990
13431
  });
12991
13432
  const terms = queryResponse.data.terms;
12992
13433
  if (terms.length === 0) {
@@ -13195,6 +13636,121 @@ var ReasoningLayerClient = class {
13195
13636
  rag;
13196
13637
  /** Linear program optimization (CLP(Q) simplex solver via backward chaining). */
13197
13638
  optimize;
13639
+ // ─── Group Caches ─────────────────────────────────────────────────
13640
+ _core;
13641
+ _ai;
13642
+ _reasoning;
13643
+ _analysis;
13644
+ _data;
13645
+ _workflow;
13646
+ _system;
13647
+ // ─── Friendly Aliases ─────────────────────────────────────────────
13648
+ /**
13649
+ * Type hierarchy operations.
13650
+ * Alias for {@link sorts} — "sort" is domain jargon for "type" in order-sorted algebras.
13651
+ */
13652
+ get types() {
13653
+ return this.sorts;
13654
+ }
13655
+ /**
13656
+ * Record CRUD operations.
13657
+ * Alias for {@link terms} — "term" is logic programming jargon for a data record.
13658
+ */
13659
+ get records() {
13660
+ return this.terms;
13661
+ }
13662
+ /**
13663
+ * Rule and fact operations (backward/forward chaining, fuzzy, Bayesian, NAF).
13664
+ * Alias for {@link inference}.
13665
+ */
13666
+ get rules() {
13667
+ return this.inference;
13668
+ }
13669
+ /**
13670
+ * Cognitive agent operations (BDI cycle, beliefs, goals, messaging).
13671
+ * Alias for {@link cognitive}.
13672
+ */
13673
+ get agents() {
13674
+ return this.cognitive;
13675
+ }
13676
+ // ─── Domain Groups ───────────────────────────────────────────────
13677
+ /** Core knowledge base operations — types, records, rules, functions, constraints, and queries. */
13678
+ get core() {
13679
+ return this._core ??= {
13680
+ types: this.sorts,
13681
+ records: this.terms,
13682
+ rules: this.inference,
13683
+ functions: this.functions,
13684
+ constraints: this.constraints,
13685
+ query: this.query
13686
+ };
13687
+ }
13688
+ /** AI and machine learning operations — agents, oversight, neuro-symbolic, RAG, generation. */
13689
+ get ai() {
13690
+ return this._ai ??= {
13691
+ agents: this.cognitive,
13692
+ oversight: this.oversight,
13693
+ neuroSymbolic: this.neuroSymbolic,
13694
+ rag: this.rag,
13695
+ generation: this.generation,
13696
+ synthetic: this.synthetic,
13697
+ proofEngine: this.proofEngine
13698
+ };
13699
+ }
13700
+ /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery. */
13701
+ get reasoningOps() {
13702
+ return this._reasoning ??= {
13703
+ optimize: this.optimize,
13704
+ ilp: this.ilp,
13705
+ cdl: this.cdl,
13706
+ execution: this.execution,
13707
+ reasoning: this.reasoning,
13708
+ preferences: this.preferences,
13709
+ discovery: this.discovery
13710
+ };
13711
+ }
13712
+ /** Analysis operations — causal, statistical, fuzzy, scenarios, communities, visualization. */
13713
+ get analysisOps() {
13714
+ return this._analysis ??= {
13715
+ causal: this.causal,
13716
+ statistical: this.statistical,
13717
+ fuzzy: this.fuzzy,
13718
+ scenarios: this.scenarios,
13719
+ communities: this.communities,
13720
+ visualization: this.visualization
13721
+ };
13722
+ }
13723
+ /** Data ingestion and extraction operations — documents, sources, collections, images. */
13724
+ get data() {
13725
+ return this._data ??= {
13726
+ ingestion: this.ingestion,
13727
+ extraction: this.extract,
13728
+ sources: this.sources,
13729
+ collections: this.collections,
13730
+ imageExtraction: this.imageExtraction,
13731
+ row: this.row
13732
+ };
13733
+ }
13734
+ /** Workflow operations — control flow, reviews, action reviews, webhooks. */
13735
+ get workflow() {
13736
+ return this._workflow ??= {
13737
+ control: this.control,
13738
+ reviews: this.reviews,
13739
+ actionReviews: this.actionReviews,
13740
+ webhookActions: this.webhookActions
13741
+ };
13742
+ }
13743
+ /** System administration — health, admin, spaces, namespaces, utilities, ontology. */
13744
+ get system() {
13745
+ return this._system ??= {
13746
+ health: this.health,
13747
+ admin: this.admin,
13748
+ spaces: this.spaces,
13749
+ namespaces: this.namespaces,
13750
+ utilities: this.utilities,
13751
+ ontology: this.ontology
13752
+ };
13753
+ }
13198
13754
  /**
13199
13755
  * Create a new ReasoningLayerClient.
13200
13756
  *
@@ -13301,100 +13857,146 @@ var ReasoningLayerClient = class {
13301
13857
  }
13302
13858
  };
13303
13859
 
13860
+ // src/types/sorts.ts
13861
+ var sorts_exports = {};
13862
+
13863
+ // src/types/terms.ts
13864
+ var terms_exports = {};
13865
+
13866
+ // src/types/inference.ts
13867
+ var inference_exports = {};
13868
+
13869
+ // src/types/cognitive.ts
13870
+ var cognitive_exports = {};
13871
+
13872
+ // src/types/causal.ts
13873
+ var causal_exports = {};
13874
+
13875
+ // src/types/fuzzy.ts
13876
+ var fuzzy_exports = {};
13877
+
13878
+ // src/types/constraints.ts
13879
+ var constraints_exports = {};
13880
+
13881
+ // src/types/query.ts
13882
+ var query_exports = {};
13883
+
13884
+ // src/types/values.ts
13885
+ var values_exports = {};
13886
+
13887
+ // src/types/homoiconic.ts
13888
+ var homoiconic_exports = {};
13889
+
13890
+ // src/types/execution.ts
13891
+ var execution_exports = {};
13892
+
13893
+ // src/types/control.ts
13894
+ var control_exports = {};
13895
+
13896
+ // src/types/spaces.ts
13897
+ var spaces_exports = {};
13898
+
13899
+ // src/types/row.ts
13900
+ var row_exports = {};
13901
+
13902
+ // src/types/namespaces.ts
13903
+ var namespaces_exports = {};
13904
+
13905
+ // src/types/collections.ts
13906
+ var collections_exports = {};
13907
+
13908
+ // src/types/visualization.ts
13909
+ var visualization_exports = {};
13910
+
13911
+ // src/types/statistical.ts
13912
+ var statistical_exports = {};
13913
+
13914
+ // src/types/reasoning.ts
13915
+ var reasoning_exports = {};
13916
+
13917
+ // src/types/ingestion.ts
13918
+ var ingestion_exports = {};
13919
+
13920
+ // src/types/reviews.ts
13921
+ var reviews_exports = {};
13922
+
13923
+ // src/types/sources.ts
13924
+ var sources_exports = {};
13925
+
13926
+ // src/types/communities.ts
13927
+ var communities_exports = {};
13928
+
13929
+ // src/types/utilities.ts
13930
+ var utilities_exports = {};
13931
+
13932
+ // src/types/scenarios.ts
13933
+ var scenarios_exports = {};
13934
+
13935
+ // src/types/action-reviews.ts
13936
+ var action_reviews_exports = {};
13937
+
13938
+ // src/types/discovery.ts
13939
+ var discovery_exports = {};
13940
+
13941
+ // src/types/extract.ts
13942
+ var extract_exports = {};
13943
+
13944
+ // src/types/oversight.ts
13945
+ var oversight_exports = {};
13946
+
13947
+ // src/types/cdl.ts
13948
+ var cdl_exports = {};
13949
+
13950
+ // src/types/neuro-symbolic.ts
13951
+ var neuro_symbolic_exports = {};
13952
+
13953
+ // src/types/analysis.ts
13954
+ var analysis_exports = {};
13955
+
13956
+ // src/types/preferences.ts
13957
+ var preferences_exports = {};
13958
+
13959
+ // src/types/functions.ts
13960
+ var functions_exports = {};
13961
+
13962
+ // src/types/webhook-actions.ts
13963
+ var webhook_actions_exports = {};
13964
+
13965
+ // src/types/proof-engine.ts
13966
+ var proof_engine_exports = {};
13967
+
13968
+ // src/types/synthetic.ts
13969
+ var synthetic_exports = {};
13970
+
13971
+ // src/types/health.ts
13972
+ var health_exports = {};
13973
+
13974
+ // src/types/admin.ts
13975
+ var admin_exports = {};
13976
+
13977
+ // src/types/image-extraction.ts
13978
+ var image_extraction_exports = {};
13979
+
13980
+ // src/types/ontology.ts
13981
+ var ontology_exports = {};
13982
+
13983
+ // src/types/generation.ts
13984
+ var generation_exports = {};
13985
+
13986
+ // src/types/rag.ts
13987
+ var rag_exports = {};
13988
+
13989
+ // src/types/optimize.ts
13990
+ var optimize_exports = {};
13991
+
13992
+ // src/types/ilp.ts
13993
+ var ilp_exports = {};
13994
+
13995
+ // src/types/plain-values.ts
13996
+ var plain_values_exports = {};
13997
+
13304
13998
  // src/builders/value.ts
13305
13999
  var Value = {
13306
- /**
13307
- * Create a string value.
13308
- *
13309
- * @param s - The string value.
13310
- * @returns A tagged `StringValue`: `{"type": "String", "value": "hello"}`.
13311
- *
13312
- * @remarks
13313
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13314
- * Do NOT use with homoiconic inference endpoints.
13315
- *
13316
- * @example
13317
- * ```typescript
13318
- * Value.string("Alice") // {"type": "String", "value": "Alice"}
13319
- * ```
13320
- */
13321
- string(s) {
13322
- return { type: "String", value: s };
13323
- },
13324
- /**
13325
- * Create an integer value.
13326
- *
13327
- * @param n - The integer value (i64 on backend).
13328
- * @returns A tagged `IntegerValue`: `{"type": "Integer", "value": 42}`.
13329
- *
13330
- * @remarks
13331
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13332
- * Do NOT use with homoiconic inference endpoints.
13333
- *
13334
- * @example
13335
- * ```typescript
13336
- * Value.integer(42) // {"type": "Integer", "value": 42}
13337
- * ```
13338
- */
13339
- integer(n) {
13340
- return { type: "Integer", value: n };
13341
- },
13342
- /**
13343
- * Create a real (floating-point) value.
13344
- *
13345
- * @param n - The real value (f64 on backend).
13346
- * @returns A tagged `RealValue`: `{"type": "Real", "value": 3.14}`.
13347
- *
13348
- * @remarks
13349
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13350
- * Do NOT use with homoiconic inference endpoints.
13351
- *
13352
- * @example
13353
- * ```typescript
13354
- * Value.real(3.14) // {"type": "Real", "value": 3.14}
13355
- * ```
13356
- */
13357
- real(n) {
13358
- return { type: "Real", value: n };
13359
- },
13360
- /**
13361
- * Create a boolean value.
13362
- *
13363
- * @param b - The boolean value.
13364
- * @returns A tagged `BooleanValue`: `{"type": "Boolean", "value": true}`.
13365
- *
13366
- * @remarks
13367
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13368
- * Do NOT use with homoiconic inference endpoints.
13369
- *
13370
- * @example
13371
- * ```typescript
13372
- * Value.boolean(true) // {"type": "Boolean", "value": true}
13373
- * ```
13374
- */
13375
- boolean(b) {
13376
- return { type: "Boolean", value: b };
13377
- },
13378
- /**
13379
- * Create an uninstantiated (unknown) value.
13380
- *
13381
- * @returns A tagged `UninstantiatedValue`: `{"type": "Uninstantiated"}`.
13382
- *
13383
- * @remarks
13384
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13385
- * Do NOT use with homoiconic inference endpoints.
13386
- *
13387
- * Represents a feature whose value has not yet been determined.
13388
- * In the untagged format, this corresponds to `null`.
13389
- *
13390
- * @example
13391
- * ```typescript
13392
- * Value.uninstantiated() // {"type": "Uninstantiated"}
13393
- * ```
13394
- */
13395
- uninstantiated() {
13396
- return { type: "Uninstantiated" };
13397
- },
13398
14000
  /**
13399
14001
  * Create a reference to another term by UUID.
13400
14002
  *
@@ -13403,7 +14005,6 @@ var Value = {
13403
14005
  *
13404
14006
  * @remarks
13405
14007
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13406
- * Do NOT use with homoiconic inference endpoints.
13407
14008
  *
13408
14009
  * @example
13409
14010
  * ```typescript
@@ -13413,24 +14014,6 @@ var Value = {
13413
14014
  reference(id) {
13414
14015
  return { type: "Reference", value: id };
13415
14016
  },
13416
- /**
13417
- * Create a list of values.
13418
- *
13419
- * @param items - The list items as `ValueDto` values.
13420
- * @returns A tagged `ListValue`: `{"type": "List", "value": [...]}`.
13421
- *
13422
- * @remarks
13423
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13424
- * Do NOT use with homoiconic inference endpoints.
13425
- *
13426
- * @example
13427
- * ```typescript
13428
- * Value.list([Value.integer(1), Value.integer(2), Value.integer(3)])
13429
- * ```
13430
- */
13431
- list(items) {
13432
- return { type: "List", value: items };
13433
- },
13434
14017
  /**
13435
14018
  * Create a fuzzy scalar with a value and membership degree.
13436
14019
  *
@@ -13440,7 +14023,6 @@ var Value = {
13440
14023
  *
13441
14024
  * @remarks
13442
14025
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13443
- * Do NOT use with homoiconic inference endpoints.
13444
14026
  *
13445
14027
  * @example
13446
14028
  * ```typescript
@@ -13458,7 +14040,6 @@ var Value = {
13458
14040
  *
13459
14041
  * @remarks
13460
14042
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13461
- * Do NOT use with homoiconic inference endpoints.
13462
14043
  *
13463
14044
  * Note: The `FuzzyShapeDto` uses `"kind"` as its discriminator, NOT `"type"`.
13464
14045
  *
@@ -13481,7 +14062,6 @@ var Value = {
13481
14062
  *
13482
14063
  * @remarks
13483
14064
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13484
- * Do NOT use with homoiconic inference endpoints.
13485
14065
  *
13486
14066
  * Represents partial information about set membership using Smyth powerdomain semantics.
13487
14067
  *
@@ -13496,7 +14076,7 @@ var Value = {
13496
14076
  value: {
13497
14077
  lower,
13498
14078
  upper,
13499
- sort_constraint: sortConstraint ?? null
14079
+ sortConstraint: sortConstraint ?? null
13500
14080
  }
13501
14081
  };
13502
14082
  }
@@ -13512,12 +14092,10 @@ var FuzzyShape = {
13512
14092
  *
13513
14093
  * @remarks
13514
14094
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13515
- * The discriminator field is `"kind"`, NOT `"type"`.
13516
14095
  *
13517
14096
  * @example
13518
14097
  * ```typescript
13519
14098
  * FuzzyShape.triangular(20, 22, 24)
13520
- * // {"kind": "Triangular", "a": 20, "b": 22, "c": 24}
13521
14099
  * ```
13522
14100
  */
13523
14101
  triangular(a, b, c) {
@@ -13530,16 +14108,14 @@ var FuzzyShape = {
13530
14108
  * @param b - Left shoulder (membership reaches 1).
13531
14109
  * @param c - Right shoulder (membership starts falling from 1).
13532
14110
  * @param d - Right foot (membership returns to 0).
13533
- * @returns A `TrapezoidalShape`: `{"kind": "Trapezoidal", "a": 18, "b": 20, "c": 24, "d": 26}`.
14111
+ * @returns A `TrapezoidalShape`.
13534
14112
  *
13535
14113
  * @remarks
13536
14114
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13537
- * The discriminator field is `"kind"`, NOT `"type"`.
13538
14115
  *
13539
14116
  * @example
13540
14117
  * ```typescript
13541
14118
  * FuzzyShape.trapezoidal(18, 20, 24, 26)
13542
- * // {"kind": "Trapezoidal", "a": 18, "b": 20, "c": 24, "d": 26}
13543
14119
  * ```
13544
14120
  */
13545
14121
  trapezoidal(a, b, c, d) {
@@ -13550,20 +14126,18 @@ var FuzzyShape = {
13550
14126
  *
13551
14127
  * @param mean - Center of the Gaussian curve (membership = 1).
13552
14128
  * @param stdDev - Standard deviation controlling width.
13553
- * @returns A `GaussianShape`: `{"kind": "Gaussian", "mean": 100, "std_dev": 15}`.
14129
+ * @returns A `GaussianShape`.
13554
14130
  *
13555
14131
  * @remarks
13556
14132
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13557
- * The discriminator field is `"kind"`, NOT `"type"`.
13558
14133
  *
13559
14134
  * @example
13560
14135
  * ```typescript
13561
14136
  * FuzzyShape.gaussian(100, 15)
13562
- * // {"kind": "Gaussian", "mean": 100, "std_dev": 15}
13563
14137
  * ```
13564
14138
  */
13565
14139
  gaussian(mean, stdDev) {
13566
- return { kind: "Gaussian", mean, std_dev: stdDev };
14140
+ return { kind: "Gaussian", mean, stdDev };
13567
14141
  },
13568
14142
  /**
13569
14143
  * Create a cyclic Gaussian fuzzy membership function with periodic wrapping.
@@ -13571,323 +14145,25 @@ var FuzzyShape = {
13571
14145
  * @param mean - Center of the Gaussian curve.
13572
14146
  * @param stdDev - Standard deviation controlling width.
13573
14147
  * @param period - Period of the cyclic wrapping (e.g., 360 for degrees).
13574
- * @returns A `CyclicGaussianShape`: `{"kind": "CyclicGaussian", "mean": 180, "std_dev": 30, "period": 360}`.
14148
+ * @returns A `CyclicGaussianShape`.
13575
14149
  *
13576
14150
  * @remarks
13577
14151
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13578
- * The discriminator field is `"kind"`, NOT `"type"`.
13579
14152
  *
13580
14153
  * @example
13581
14154
  * ```typescript
13582
14155
  * FuzzyShape.cyclicGaussian(180, 30, 360)
13583
- * // {"kind": "CyclicGaussian", "mean": 180, "std_dev": 30, "period": 360}
13584
14156
  * ```
13585
14157
  */
13586
14158
  cyclicGaussian(mean, stdDev, period) {
13587
- return { kind: "CyclicGaussian", mean, std_dev: stdDev, period };
13588
- }
13589
- };
13590
-
13591
- // src/builders/feature-input.ts
13592
- var FeatureInput = {
13593
- /**
13594
- * Create an untagged string value.
13595
- *
13596
- * @param s - The string value.
13597
- * @returns The raw string: `"hello"`.
13598
- *
13599
- * @remarks
13600
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13601
- * Do NOT use with term CRUD endpoints.
13602
- *
13603
- * @example
13604
- * ```typescript
13605
- * FeatureInput.string("Alice") // "Alice"
13606
- * ```
13607
- */
13608
- string(s) {
13609
- return s;
13610
- },
13611
- /**
13612
- * Create an untagged integer value.
13613
- *
13614
- * @param n - The integer value.
13615
- * @returns The raw number: `42`.
13616
- *
13617
- * @remarks
13618
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13619
- * Do NOT use with term CRUD endpoints.
13620
- *
13621
- * The backend distinguishes integers from reals. Use `FeatureInput.real()` for floating-point.
13622
- *
13623
- * @example
13624
- * ```typescript
13625
- * FeatureInput.integer(42) // 42
13626
- * ```
13627
- */
13628
- integer(n) {
13629
- return n;
13630
- },
13631
- /**
13632
- * Create an untagged real (floating-point) value.
13633
- *
13634
- * @param n - The real value.
13635
- * @returns The raw number: `3.14`.
13636
- *
13637
- * @remarks
13638
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13639
- * Do NOT use with term CRUD endpoints.
13640
- *
13641
- * The backend distinguishes integers from reals. Use `FeatureInput.integer()` for whole numbers.
13642
- *
13643
- * @example
13644
- * ```typescript
13645
- * FeatureInput.real(3.14) // 3.14
13646
- * ```
13647
- */
13648
- real(n) {
13649
- return n;
13650
- },
13651
- /**
13652
- * Create an untagged boolean value.
13653
- *
13654
- * @param b - The boolean value.
13655
- * @returns The raw boolean: `true` or `false`.
13656
- *
13657
- * @remarks
13658
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13659
- * Do NOT use with term CRUD endpoints.
13660
- *
13661
- * @example
13662
- * ```typescript
13663
- * FeatureInput.boolean(true) // true
13664
- * ```
13665
- */
13666
- boolean(b) {
13667
- return b;
13668
- },
13669
- /**
13670
- * Create an untagged null value representing an uninstantiated feature.
13671
- *
13672
- * @returns `null`.
13673
- *
13674
- * @remarks
13675
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13676
- * Do NOT use with term CRUD endpoints.
13677
- *
13678
- * Equivalent to `Value.uninstantiated()` in the tagged format.
13679
- *
13680
- * @example
13681
- * ```typescript
13682
- * FeatureInput.uninstantiated() // null
13683
- * ```
13684
- */
13685
- uninstantiated() {
13686
- return null;
13687
- },
13688
- /**
13689
- * Create a reference to an existing term by UUID.
13690
- *
13691
- * @param termId - The UUID of the referenced term.
13692
- * @returns An object: `{term_id: "uuid"}`.
13693
- *
13694
- * @remarks
13695
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13696
- * Do NOT use with term CRUD endpoints.
13697
- *
13698
- * @example
13699
- * ```typescript
13700
- * FeatureInput.ref("550e8400-e29b-41d4-a716-446655440000")
13701
- * // {term_id: "550e8400-e29b-41d4-a716-446655440000"}
13702
- * ```
13703
- */
13704
- ref(termId) {
13705
- return { term_id: termId };
13706
- },
13707
- /**
13708
- * Create an unconstrained variable.
13709
- *
13710
- * @param name - Variable name (conventionally prefixed with `?`, e.g., `"?X"`).
13711
- * @returns An object: `{name: "?X"}`.
13712
- *
13713
- * @remarks
13714
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13715
- * Do NOT use with term CRUD endpoints.
13716
- *
13717
- * For constrained variables, use {@link FeatureInput.constrainedVar} instead.
13718
- *
13719
- * @example
13720
- * ```typescript
13721
- * FeatureInput.variable("?X") // {name: "?X"}
13722
- * ```
13723
- */
13724
- variable(name) {
13725
- return { name };
13726
- },
13727
- /**
13728
- * Create a constrained variable with a constraint as a `TermInputDto`.
13729
- *
13730
- * @param name - Variable name (conventionally prefixed with `?`, e.g., `"?Salary"`).
13731
- * @param constraint - The constraint as a `TermInputDto` (typically a guard sort).
13732
- * @returns An object: `{name: "?Salary", constraint: {...}}`.
13733
- *
13734
- * @remarks
13735
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13736
- * Do NOT use with term CRUD endpoints.
13737
- *
13738
- * The most common constraint is a guard, which can be created with the `guard()` builder:
13739
- * ```typescript
13740
- * FeatureInput.constrainedVar("?Salary", guard("gt", 100))
13741
- * ```
13742
- *
13743
- * **Critical ordering note**: `ConstrainedVariable` (with `name` + `constraint`) must serialize
13744
- * before `Variable` (with only `name`) in the Rust `serde(untagged)` deserialization order.
13745
- * The builder ensures the `constraint` field is always present.
13746
- *
13747
- * @example
13748
- * ```typescript
13749
- * FeatureInput.constrainedVar("?Salary", guard("gt", 100))
13750
- * // {name: "?Salary", constraint: {sort_name: "guard", features: {op: "gt", right: 100}}}
13751
- * ```
13752
- */
13753
- constrainedVar(name, constraint) {
13754
- return { name, constraint };
13755
- },
13756
- /**
13757
- * Create an inline term by sort UUID in a feature value position.
13758
- *
13759
- * @param sortId - The sort UUID.
13760
- * @param features - Optional features for the inline term.
13761
- * @returns An object: `{sort_id: "uuid", features: {...}}`.
13762
- *
13763
- * @remarks
13764
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13765
- * Do NOT use with term CRUD endpoints.
13766
- *
13767
- * @example
13768
- * ```typescript
13769
- * FeatureInput.inlineTerm("sort-uuid", { name: FeatureInput.string("Alice") })
13770
- * ```
13771
- */
13772
- inlineTerm(sortId, features) {
13773
- return features !== void 0 ? { sort_id: sortId, features } : { sort_id: sortId };
13774
- },
13775
- /**
13776
- * Create an inline term by sort name in a feature value position.
13777
- *
13778
- * @param sortName - The sort name (resolved server-side).
13779
- * @param features - Optional features for the inline term.
13780
- * @returns An object: `{sort_name: "person", features: {...}}`.
13781
- *
13782
- * @remarks
13783
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13784
- * Do NOT use with term CRUD endpoints.
13785
- *
13786
- * @example
13787
- * ```typescript
13788
- * FeatureInput.inlineTermByName("person", { name: FeatureInput.string("Alice") })
13789
- * ```
13790
- */
13791
- inlineTermByName(sortName, features) {
13792
- return features !== void 0 ? { sort_name: sortName, features } : { sort_name: sortName };
13793
- },
13794
- /**
13795
- * Create a list of feature input values.
13796
- *
13797
- * @param items - The list items as `FeatureInputValueDto` values.
13798
- * @returns A raw JSON array: `[...]`.
13799
- *
13800
- * @remarks
13801
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13802
- * Do NOT use with term CRUD endpoints.
13803
- *
13804
- * @example
13805
- * ```typescript
13806
- * FeatureInput.list([FeatureInput.string("a"), FeatureInput.string("b")])
13807
- * // ["a", "b"]
13808
- * ```
13809
- */
13810
- list(items) {
13811
- return items;
13812
- }
13813
- };
13814
-
13815
- // src/builders/term-input.ts
13816
- var TermInput = {
13817
- /**
13818
- * Reference an existing term by UUID.
13819
- *
13820
- * @param termId - The UUID of the existing term.
13821
- * @returns A reference input: `{term_id: "uuid"}`.
13822
- *
13823
- * @remarks
13824
- * Serialization format: Untagged (TermInputDto). Use as top-level goal or rule head/body
13825
- * in inference requests.
13826
- *
13827
- * @example
13828
- * ```typescript
13829
- * TermInput.ref("550e8400-e29b-41d4-a716-446655440000")
13830
- * // {term_id: "550e8400-e29b-41d4-a716-446655440000"}
13831
- * ```
13832
- */
13833
- ref(termId) {
13834
- return { term_id: termId };
13835
- },
13836
- /**
13837
- * Define a term inline using a sort UUID and features.
13838
- *
13839
- * @param sortId - The sort UUID.
13840
- * @param features - Feature map with `FeatureInputValueDto` values.
13841
- * @returns An inline input: `{sort_id: "uuid", features: {...}}`.
13842
- *
13843
- * @remarks
13844
- * Serialization format: Untagged (TermInputDto). Use as top-level goal or rule head/body
13845
- * in inference requests.
13846
- *
13847
- * The `features` field is required for the sort_id variant per the backend schema.
13848
- *
13849
- * @example
13850
- * ```typescript
13851
- * TermInput.byId("sort-uuid", {
13852
- * name: FeatureInput.string("Alice"),
13853
- * })
13854
- * ```
13855
- */
13856
- byId(sortId, features) {
13857
- return { sort_id: sortId, features };
13858
- },
13859
- /**
13860
- * Define a term inline using a sort name and optional features.
13861
- *
13862
- * @param sortName - The sort name (resolved server-side to a sort UUID).
13863
- * @param features - Optional feature map with `FeatureInputValueDto` values.
13864
- * @returns An inline input: `{sort_name: "person", features: {...}}`.
13865
- *
13866
- * @remarks
13867
- * Serialization format: Untagged (TermInputDto). Use as top-level goal or rule head/body
13868
- * in inference requests.
13869
- *
13870
- * Sort name resolution happens server-side. The name must match an existing sort
13871
- * in the tenant's sort hierarchy.
13872
- *
13873
- * @example
13874
- * ```typescript
13875
- * TermInput.byName("person", {
13876
- * name: FeatureInput.string("Alice"),
13877
- * age: FeatureInput.integer(30),
13878
- * })
13879
- * // {sort_name: "person", features: {name: "Alice", age: 30}}
13880
- * ```
13881
- */
13882
- byName(sortName, features) {
13883
- return features !== void 0 ? { sort_name: sortName, features } : { sort_name: sortName };
14159
+ return { kind: "CyclicGaussian", mean, stdDev, period };
13884
14160
  }
13885
14161
  };
13886
14162
 
13887
14163
  // src/builders/guard.ts
13888
14164
  function guard(op, right) {
13889
14165
  return {
13890
- sort_name: "guard",
14166
+ sortName: "guard_constraint",
13891
14167
  features: { op, right }
13892
14168
  };
13893
14169
  }
@@ -14000,7 +14276,7 @@ var SortBuilder = class _SortBuilder {
14000
14276
  * builder.boundConstraint({
14001
14277
  * constraint_type: "upper",
14002
14278
  * target: "end_date",
14003
- * source_path: "company.dissolution_date",
14279
+ * source_path: "company.dissolutionDate",
14004
14280
  * })
14005
14281
  * ```
14006
14282
  */
@@ -14052,7 +14328,7 @@ var SortBuilder = class _SortBuilder {
14052
14328
  request.features = this._features;
14053
14329
  }
14054
14330
  if (this._boundConstraints.length > 0) {
14055
- request.bound_constraints = this._boundConstraints;
14331
+ request.boundConstraints = this._boundConstraints;
14056
14332
  }
14057
14333
  if (this._description !== null) {
14058
14334
  request.description = this._description;
@@ -14062,80 +14338,26 @@ var SortBuilder = class _SortBuilder {
14062
14338
  };
14063
14339
 
14064
14340
  // src/builders/psi.ts
14065
- function isPlainObject(v) {
14066
- return typeof v === "object" && v !== null && !Array.isArray(v);
14067
- }
14068
- function coerceObjectFeatures(obj) {
14069
- const rawFeatures = obj.features;
14070
- if (!isPlainObject(rawFeatures)) {
14071
- return void 0;
14072
- }
14073
- const coerced = {};
14074
- for (const [k, v] of Object.entries(rawFeatures)) {
14075
- coerced[k] = coerceFeatureValue(v);
14076
- }
14077
- return coerced;
14078
- }
14079
- function coerceFeatureValue(value) {
14080
- if (value === null) {
14081
- throw new ValidationError("null is not a valid feature value in psi() shorthand. Use FeatureInput.uninstantiated() for null values.");
14082
- }
14083
- if (typeof value === "string") {
14084
- return value;
14085
- }
14086
- if (typeof value === "number") {
14087
- return value;
14088
- }
14089
- if (typeof value === "boolean") {
14090
- return value;
14091
- }
14092
- if (Array.isArray(value)) {
14093
- return value.map(coerceFeatureValue);
14094
- }
14095
- if (isPlainObject(value)) {
14096
- if ("term_id" in value && typeof value.term_id === "string") {
14097
- return { term_id: value.term_id };
14098
- }
14099
- if ("name" in value && typeof value.name === "string" && "constraint" in value) {
14100
- return { name: value.name, constraint: value.constraint };
14101
- }
14102
- if ("name" in value && typeof value.name === "string") {
14103
- return { name: value.name };
14104
- }
14105
- if ("sort_name" in value && typeof value.sort_name === "string") {
14106
- const features = coerceObjectFeatures(value);
14107
- if (features) {
14108
- return { sort_name: value.sort_name, features };
14109
- }
14110
- return { sort_name: value.sort_name };
14111
- }
14112
- if ("sort_id" in value && typeof value.sort_id === "string") {
14113
- const features = coerceObjectFeatures(value);
14114
- if (features) {
14115
- return { sort_id: value.sort_id, features };
14116
- }
14117
- return { sort_id: value.sort_id };
14118
- }
14119
- }
14120
- throw new ValidationError(`Cannot coerce value of type ${typeof value} to FeatureInputValueDto`);
14121
- }
14122
14341
  function psi(sortName, features) {
14123
14342
  if (!features) {
14124
- return { sort_name: sortName };
14125
- }
14126
- const coerced = {};
14127
- for (const [key, value] of Object.entries(features)) {
14128
- coerced[key] = coerceFeatureValue(value);
14343
+ return { __psiTerm: true, sortName };
14129
14344
  }
14130
- return { sort_name: sortName, features: coerced };
14345
+ return {
14346
+ __psiTerm: true,
14347
+ sortName,
14348
+ features
14349
+ };
14350
+ }
14351
+ function constrained(name, constraint) {
14352
+ return { __constrainedVar: true, name, constraint };
14131
14353
  }
14132
14354
 
14133
14355
  // src/builders/allen.ts
14134
14356
  function allen(relation, intervalA, intervalBTermId) {
14135
14357
  return {
14136
14358
  type: "Allen",
14137
- interval_a: intervalA,
14138
- interval_b_term_id: intervalBTermId,
14359
+ intervalA,
14360
+ intervalBTermId,
14139
14361
  relation
14140
14362
  };
14141
14363
  }
@@ -14166,6 +14388,6 @@ function discriminateFeatureValue(value) {
14166
14388
  );
14167
14389
  }
14168
14390
 
14169
- export { ApiError, BadRequestError, ConstraintViolationError, FeatureInput, FuzzyShape, InternalServerError, LP, NetworkError, NotFoundError, RateLimitError, ReasoningLayerClient, ReasoningLayerError, SDK_VERSION, SortBuilder, TermInput, TimeoutError, ValidationError, Value, WebSocketClient, WebSocketConnection, allen, discriminateFeatureValue, guard, isUuid, psi };
14391
+ export { action_reviews_exports as ActionReviews, admin_exports as Admin, analysis_exports as Analysis, ApiError, AuthenticationError, BadRequestError, cdl_exports as CDL, causal_exports as Causal, cognitive_exports as Cognitive, collections_exports as Collections, communities_exports as Communities, ConstraintViolationError, constraints_exports as Constraints, control_exports as Control, discovery_exports as Discovery, execution_exports as Execution, extract_exports as Extract, ForbiddenError, functions_exports as Functions, fuzzy_exports as Fuzzy, FuzzyShape, generation_exports as Generation, health_exports as Health, homoiconic_exports as Homoiconic, ilp_exports as ILP, image_extraction_exports as ImageExtraction, inference_exports as Inference, ingestion_exports as Ingestion, InternalServerError, LP, namespaces_exports as Namespaces, NetworkError, neuro_symbolic_exports as NeuroSymbolic, NotFoundError, ontology_exports as Ontology, optimize_exports as Optimize, oversight_exports as Oversight, plain_values_exports as PlainValues, preferences_exports as Preferences, proof_engine_exports as ProofEngine, query_exports as Query, rag_exports as RAG, RateLimitError, reasoning_exports as Reasoning, ReasoningLayerClient, ReasoningLayerError, reviews_exports as Reviews, row_exports as Row, SDK_VERSION, scenarios_exports as Scenarios, SortBuilder, sorts_exports as Sorts, sources_exports as Sources, spaces_exports as Spaces, statistical_exports as Statistical, synthetic_exports as Synthetic, terms_exports as Terms, TimeoutError, utilities_exports as Utilities, ValidationError, Value, values_exports as Values, visualization_exports as Visualization, WebSocketClient, WebSocketConnection, webhook_actions_exports as WebhookActions, allen, constrained, discriminateFeatureValue, guard, isConstrainedPlainVar, isPsiTermInput, isTaggedValueDto, isUuid, psi, toTaggedFeatures, toTaggedValue, toTermInputDto, toUntaggedFeatures, toUntaggedValue };
14170
14392
  //# sourceMappingURL=index.js.map
14171
14393
  //# sourceMappingURL=index.js.map