@kortexya/reasoninglayer 0.2.9 → 0.4.1

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.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/config.ts
4
- var SDK_VERSION = "0.2.9";
4
+ var SDK_VERSION = "0.4.1";
5
5
  function resolveConfig(config) {
6
6
  if (!config.baseUrl) {
7
7
  throw new Error("ClientConfig.baseUrl is required");
@@ -15,6 +15,7 @@ function resolveConfig(config) {
15
15
  userId: config.userId,
16
16
  namespaceId: config.namespaceId,
17
17
  authenticatedUser: config.authenticatedUser,
18
+ bearerToken: config.bearerToken,
18
19
  timeoutMs: config.timeoutMs ?? 3e4,
19
20
  maxRetries: config.maxRetries ?? 3,
20
21
  retryOn503: config.retryOn503 ?? false,
@@ -54,6 +55,18 @@ var BadRequestError = class extends ApiError {
54
55
  super(message, 400, body, headers, errorCode);
55
56
  }
56
57
  };
58
+ var AuthenticationError = class extends ApiError {
59
+ name = "AuthenticationError";
60
+ constructor(message, body, headers, errorCode) {
61
+ super(message, 401, body, headers, errorCode);
62
+ }
63
+ };
64
+ var ForbiddenError = class extends ApiError {
65
+ name = "ForbiddenError";
66
+ constructor(message, body, headers, errorCode) {
67
+ super(message, 403, body, headers, errorCode);
68
+ }
69
+ };
57
70
  var NotFoundError = class extends ApiError {
58
71
  name = "NotFoundError";
59
72
  constructor(message, body, headers, errorCode) {
@@ -139,6 +152,10 @@ function createApiError(status, body, headers) {
139
152
  switch (status) {
140
153
  case 400:
141
154
  return new BadRequestError(message, body, headers, errorCode);
155
+ case 401:
156
+ return new AuthenticationError(message, body, headers, errorCode);
157
+ case 403:
158
+ return new ForbiddenError(message, body, headers, errorCode);
142
159
  case 404:
143
160
  return new NotFoundError(message, body, headers, errorCode);
144
161
  case 409: {
@@ -354,9 +371,13 @@ var WebSocketClient = class {
354
371
  buildUrl(path, params) {
355
372
  const baseUrl = this.config.baseUrl.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
356
373
  const queryParams = new URLSearchParams({ tenant_id: this.config.tenantId });
374
+ if (this.config.bearerToken) {
375
+ queryParams.set("token", this.config.bearerToken);
376
+ }
357
377
  if (params) {
358
378
  for (const [key, value] of Object.entries(params)) {
359
- queryParams.set(key, value);
379
+ const wireKey = key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
380
+ queryParams.set(wireKey, value);
360
381
  }
361
382
  }
362
383
  return `${baseUrl}${path}?${queryParams.toString()}`;
@@ -508,6 +529,45 @@ var HttpClient = class {
508
529
  };
509
530
  };
510
531
 
532
+ // src/serialization.ts
533
+ function camelToSnake(str) {
534
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
535
+ }
536
+ function snakeToCamel(str) {
537
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
538
+ }
539
+ function isPlainObject(value) {
540
+ if (value === null || typeof value !== "object") return false;
541
+ const proto = Object.getPrototypeOf(value);
542
+ return proto === Object.prototype || proto === null;
543
+ }
544
+ function toSnakeCase(input) {
545
+ if (Array.isArray(input)) {
546
+ return input.map((item) => toSnakeCase(item));
547
+ }
548
+ if (!isPlainObject(input)) {
549
+ return input;
550
+ }
551
+ const result = {};
552
+ for (const key of Object.keys(input)) {
553
+ result[camelToSnake(key)] = toSnakeCase(input[key]);
554
+ }
555
+ return result;
556
+ }
557
+ function toCamelCase(input) {
558
+ if (Array.isArray(input)) {
559
+ return input.map((item) => toCamelCase(item));
560
+ }
561
+ if (!isPlainObject(input)) {
562
+ return input;
563
+ }
564
+ const result = {};
565
+ for (const key of Object.keys(input)) {
566
+ result[snakeToCamel(key)] = toCamelCase(input[key]);
567
+ }
568
+ return result;
569
+ }
570
+
511
571
  // src/generated-bridge.ts
512
572
  function createGeneratedHttpClient(config) {
513
573
  return new HttpClient({
@@ -527,10 +587,43 @@ function buildAuthHeaders(config) {
527
587
  if (config.userId) headers["X-User-Id"] = config.userId;
528
588
  if (config.namespaceId) headers["X-Namespace-Id"] = config.namespaceId;
529
589
  if (config.authenticatedUser) headers["X-Authenticated-User"] = config.authenticatedUser;
590
+ if (config.bearerToken) headers["Authorization"] = `Bearer ${config.bearerToken}`;
530
591
  return headers;
531
592
  }
593
+ function transformRequestInit(init) {
594
+ if (!init?.body || typeof init.body !== "string") return init;
595
+ try {
596
+ const parsed = JSON.parse(init.body);
597
+ const snaked = toSnakeCase(parsed);
598
+ return { ...init, body: JSON.stringify(snaked) };
599
+ } catch {
600
+ return init;
601
+ }
602
+ }
603
+ async function wrapResponseWithCamelCase(response) {
604
+ if (response.status === 204 || response.status === 304) {
605
+ return new Response(null, {
606
+ status: response.status,
607
+ statusText: response.statusText,
608
+ headers: response.headers
609
+ });
610
+ }
611
+ const text = await response.text();
612
+ let transformedBody = text;
613
+ try {
614
+ const parsed = JSON.parse(text);
615
+ transformedBody = JSON.stringify(toCamelCase(parsed));
616
+ } catch {
617
+ }
618
+ return new Response(transformedBody, {
619
+ status: response.status,
620
+ statusText: response.statusText,
621
+ headers: response.headers
622
+ });
623
+ }
532
624
  function createCustomFetch(config) {
533
625
  return async (input, init) => {
626
+ const transformedInit = transformRequestInit(init);
534
627
  const maxRetries = config.maxRetries;
535
628
  const timeoutMs = config.timeoutMs;
536
629
  let lastError;
@@ -539,8 +632,8 @@ function createCustomFetch(config) {
539
632
  await sleep(calculateRetryDelay(attempt, lastError));
540
633
  }
541
634
  try {
542
- const response = await executeFetch(input, init, timeoutMs, config);
543
- if (response.ok) return response;
635
+ const response = await executeFetch(input, transformedInit, timeoutMs, config);
636
+ if (response.ok) return await wrapResponseWithCamelCase(response);
544
637
  let body;
545
638
  try {
546
639
  body = await response.clone().json();
@@ -7164,6 +7257,20 @@ var Admin = class {
7164
7257
  format: "json",
7165
7258
  ...params
7166
7259
  });
7260
+ /**
7261
+ * @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.
7262
+ *
7263
+ * @tags admin
7264
+ * @name ClearTenantData
7265
+ * @summary Clear all data for a specific tenant
7266
+ * @request POST:/api/v1/admin/clear-tenant/{tenant_id}
7267
+ */
7268
+ clearTenantData = (tenantId, params = {}) => this.http.request({
7269
+ path: `/api/v1/admin/clear-tenant/${tenantId}`,
7270
+ method: "POST",
7271
+ format: "json",
7272
+ ...params
7273
+ });
7167
7274
  /**
7168
7275
  * @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.
7169
7276
  *
@@ -7358,7 +7465,7 @@ var SortsClient = class {
7358
7465
  */
7359
7466
  async isSubtype(childId, parentId) {
7360
7467
  const response = await this.sorts.isSubtype(childId, parentId);
7361
- return response.data.is_subtype;
7468
+ return response.data.isSubtype;
7362
7469
  }
7363
7470
  /**
7364
7471
  * Compute the Greatest Lower Bound (GLB) of two sorts — the most specific type
@@ -7405,7 +7512,7 @@ var SortsClient = class {
7405
7512
  * @see computeGlb
7406
7513
  */
7407
7514
  async findCommonSubtype(sortId1, sortId2) {
7408
- return this.computeGlb({ sort1_id: sortId1, sort2_id: sortId2 });
7515
+ return this.computeGlb({ sort1Id: sortId1, sort2Id: sortId2 });
7409
7516
  }
7410
7517
  /**
7411
7518
  * Find the most general type that covers both types.
@@ -7417,7 +7524,7 @@ var SortsClient = class {
7417
7524
  * @see computeLub
7418
7525
  */
7419
7526
  async findCommonSupertype(sortId1, sortId2) {
7420
- return this.computeLub({ sort1_id: sortId1, sort2_id: sortId2 });
7527
+ return this.computeLub({ sort1Id: sortId1, sort2Id: sortId2 });
7421
7528
  }
7422
7529
  /**
7423
7530
  * Get a human-readable explanation of how two types relate.
@@ -7429,7 +7536,7 @@ var SortsClient = class {
7429
7536
  * @see decodeGlb
7430
7537
  */
7431
7538
  async explainCommonSubtype(sortId1, sortId2) {
7432
- return this.decodeGlb({ sort1_id: sortId1, sort2_id: sortId2 });
7539
+ return this.decodeGlb({ sort1Id: sortId1, sort2Id: sortId2 });
7433
7540
  }
7434
7541
  /**
7435
7542
  * Get direct children of a sort.
@@ -7489,7 +7596,7 @@ var SortsClient = class {
7489
7596
  * @returns Comparison result.
7490
7597
  */
7491
7598
  async compareSorts(request) {
7492
- const response = await this.types.compareSorts({ ...request, tenant_id: this.tenantId });
7599
+ const response = await this.types.compareSorts({ ...request, tenantId: this.tenantId });
7493
7600
  return response.data;
7494
7601
  }
7495
7602
  /**
@@ -7522,8 +7629,8 @@ var SortsClient = class {
7522
7629
  * @example
7523
7630
  * ```typescript
7524
7631
  * const result = await client.sorts.getSortSimilarity({
7525
- * sort1_id: 'uuid-1',
7526
- * sort2_id: 'uuid-2',
7632
+ * sort1Id: 'uuid-1',
7633
+ * sort2Id: 'uuid-2',
7527
7634
  * });
7528
7635
  * console.log(result.degree); // 0.85
7529
7636
  * ```
@@ -7547,8 +7654,8 @@ var SortsClient = class {
7547
7654
  * @example
7548
7655
  * ```typescript
7549
7656
  * const result = await client.sorts.setSortSimilarity({
7550
- * sort1_id: 'uuid-1',
7551
- * sort2_id: 'uuid-2',
7657
+ * sort1Id: 'uuid-1',
7658
+ * sort2Id: 'uuid-2',
7552
7659
  * degree: 0.85,
7553
7660
  * });
7554
7661
  * console.log(result.success); // true
@@ -7574,11 +7681,11 @@ var SortsClient = class {
7574
7681
  * ```typescript
7575
7682
  * const result = await client.sorts.bulkSetSimilarities({
7576
7683
  * similarities: [
7577
- * { sort1_id: 'uuid-1', sort2_id: 'uuid-2', degree: 0.85 },
7578
- * { sort1_id: 'uuid-3', sort2_id: 'uuid-4', degree: 0.70 },
7684
+ * { sort1Id: 'uuid-1', sort2Id: 'uuid-2', degree: 0.85 },
7685
+ * { sort1Id: 'uuid-3', sort2Id: 'uuid-4', degree: 0.70 },
7579
7686
  * ],
7580
7687
  * });
7581
- * console.log(result.set_count); // 2
7688
+ * console.log(result.setCount); // 2
7582
7689
  * ```
7583
7690
  */
7584
7691
  async bulkSetSimilarities(request) {
@@ -7606,8 +7713,8 @@ var SortsClient = class {
7606
7713
  * @example
7607
7714
  * ```typescript
7608
7715
  * const result = await client.sorts.getPreorderDegree({
7609
- * sort1_id: 'uuid-1',
7610
- * sort2_id: 'uuid-2',
7716
+ * sort1Id: 'uuid-1',
7717
+ * sort2Id: 'uuid-2',
7611
7718
  * });
7612
7719
  * console.log(result.degree); // 0.72
7613
7720
  * ```
@@ -7631,8 +7738,8 @@ var SortsClient = class {
7631
7738
  * @example
7632
7739
  * ```typescript
7633
7740
  * const result = await client.sorts.getEquivalenceClasses();
7634
- * for (const ec of result.equivalence_classes) {
7635
- * console.log(`Class of ${ec.size} sorts:`, ec.sort_ids);
7741
+ * for (const ec of result.equivalenceClasses) {
7742
+ * console.log(`Class of ${ec.size} sorts:`, ec.sortIds);
7636
7743
  * }
7637
7744
  * ```
7638
7745
  */
@@ -7680,8 +7787,147 @@ var SortsClient = class {
7680
7787
  const response = await this.sorts.rejectLearnedSimilarity(request);
7681
7788
  return response.data;
7682
7789
  }
7790
+ // ─── Friendly Aliases ─────────────────────────────────────────────
7791
+ /**
7792
+ * Create multiple types in a single request.
7793
+ * Alias for {@link bulkCreateSorts}.
7794
+ *
7795
+ * @param request - Bulk sort definitions.
7796
+ * @returns Bulk creation result.
7797
+ *
7798
+ * @see bulkCreateSorts
7799
+ */
7800
+ async createMany(request) {
7801
+ return this.bulkCreateSorts(request);
7802
+ }
7683
7803
  };
7684
7804
 
7805
+ // src/utils/convert.ts
7806
+ var TAGGED_VALUE_TYPES = /* @__PURE__ */ new Set([
7807
+ "String",
7808
+ "Integer",
7809
+ "Real",
7810
+ "Boolean",
7811
+ "Uninstantiated",
7812
+ "Reference",
7813
+ "List",
7814
+ "FuzzyScalar",
7815
+ "FuzzyNumber",
7816
+ "Set"
7817
+ ]);
7818
+ function isPsiTermInput(value) {
7819
+ return typeof value === "object" && value !== null && "__psiTerm" in value && value.__psiTerm === true;
7820
+ }
7821
+ function isConstrainedPlainVar(value) {
7822
+ return typeof value === "object" && value !== null && "__constrainedVar" in value && value.__constrainedVar === true;
7823
+ }
7824
+ function isTaggedValueDto(value) {
7825
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
7826
+ const obj = value;
7827
+ return typeof obj.type === "string" && TAGGED_VALUE_TYPES.has(obj.type);
7828
+ }
7829
+ function toTaggedValue(value) {
7830
+ if (value === null) {
7831
+ return { type: "Uninstantiated" };
7832
+ }
7833
+ if (typeof value === "string") {
7834
+ return { type: "String", value };
7835
+ }
7836
+ if (typeof value === "number") {
7837
+ return Number.isInteger(value) ? { type: "Integer", value } : { type: "Real", value };
7838
+ }
7839
+ if (typeof value === "boolean") {
7840
+ return { type: "Boolean", value };
7841
+ }
7842
+ if (Array.isArray(value)) {
7843
+ return { type: "List", value: value.map(toTaggedValue) };
7844
+ }
7845
+ if (isPsiTermInput(value)) {
7846
+ throw new ValidationError(
7847
+ "PsiTermInput cannot be used in tagged value format (term CRUD). Use Value.reference(termId) to reference another term."
7848
+ );
7849
+ }
7850
+ if (isConstrainedPlainVar(value)) {
7851
+ throw new ValidationError(
7852
+ "ConstrainedPlainVar cannot be used in tagged value format (term CRUD). Constrained variables are only valid in inference contexts."
7853
+ );
7854
+ }
7855
+ if (isTaggedValueDto(value)) {
7856
+ return value;
7857
+ }
7858
+ throw new ValidationError(
7859
+ `Cannot convert value to tagged ValueDto format: ${JSON.stringify(value)}. Use plain JS values (string, number, boolean, null) or Value.* builders.`
7860
+ );
7861
+ }
7862
+ function toTaggedFeatures(features) {
7863
+ const result = {};
7864
+ for (const [key, value] of Object.entries(features)) {
7865
+ result[key] = toTaggedValue(value);
7866
+ }
7867
+ return result;
7868
+ }
7869
+ var VARIABLE_PATTERN = /^\?[A-Z]/;
7870
+ var REFERENCE_PATTERN = /^!/;
7871
+ function toUntaggedValue(value) {
7872
+ if (value === null) {
7873
+ return null;
7874
+ }
7875
+ if (typeof value === "string") {
7876
+ if (VARIABLE_PATTERN.test(value)) {
7877
+ return { name: value };
7878
+ }
7879
+ if (REFERENCE_PATTERN.test(value)) {
7880
+ return { termId: value.slice(1) };
7881
+ }
7882
+ return value;
7883
+ }
7884
+ if (typeof value === "number") {
7885
+ return value;
7886
+ }
7887
+ if (typeof value === "boolean") {
7888
+ return value;
7889
+ }
7890
+ if (Array.isArray(value)) {
7891
+ return value.map(toUntaggedValue);
7892
+ }
7893
+ if (isConstrainedPlainVar(value)) {
7894
+ const constraint = isPsiTermInput(value.constraint) ? toTermInputDto(value.constraint) : value.constraint;
7895
+ return { name: value.name, constraint };
7896
+ }
7897
+ if (isPsiTermInput(value)) {
7898
+ if (!value.features) {
7899
+ return { sortName: value.sortName };
7900
+ }
7901
+ return {
7902
+ sortName: value.sortName,
7903
+ features: toUntaggedFeatures(value.features)
7904
+ };
7905
+ }
7906
+ if (isTaggedValueDto(value)) {
7907
+ return value;
7908
+ }
7909
+ return value;
7910
+ }
7911
+ function toUntaggedFeatures(features) {
7912
+ const result = {};
7913
+ for (const [key, value] of Object.entries(features)) {
7914
+ result[key] = toUntaggedValue(value);
7915
+ }
7916
+ return result;
7917
+ }
7918
+ function toTermInputDto(input) {
7919
+ if (!isPsiTermInput(input)) {
7920
+ return input;
7921
+ }
7922
+ if (!input.features) {
7923
+ return { sortName: input.sortName };
7924
+ }
7925
+ return {
7926
+ sortName: input.sortName,
7927
+ features: toUntaggedFeatures(input.features)
7928
+ };
7929
+ }
7930
+
7685
7931
  // src/resources/terms.ts
7686
7932
  var TermsClient = class {
7687
7933
  /** @internal */
@@ -7693,11 +7939,44 @@ var TermsClient = class {
7693
7939
  /**
7694
7940
  * Create a new record.
7695
7941
  *
7696
- * @param request - Term creation parameters.
7942
+ * @param request - Term creation parameters. Features can be plain JS values
7943
+ * (auto-converted to tagged `ValueDto`) or explicit `Value.*` builder output.
7697
7944
  * @returns The created term with validation state.
7945
+ *
7946
+ * @remarks
7947
+ * **Serialization format: Tagged (`ValueDto`).**
7948
+ *
7949
+ * Plain value conversion:
7950
+ * - `string` → `{ type: "String", value: "..." }`
7951
+ * - `number` → `{ type: "Integer" | "Real", value: n }`
7952
+ * - `boolean` → `{ type: "Boolean", value: b }`
7953
+ * - `null` → `{ type: "Uninstantiated" }`
7954
+ * - `[...]` → `{ type: "List", value: [...] }`
7955
+ * - Existing `Value.*` output passes through unchanged.
7956
+ *
7957
+ * @example
7958
+ * ```typescript
7959
+ * // Plain values (recommended):
7960
+ * await client.terms.createTerm({
7961
+ * sortId: "sort-uuid",
7962
+ * ownerId: "owner-uuid",
7963
+ * features: { name: "Alice", age: 30, active: true },
7964
+ * });
7965
+ *
7966
+ * // Explicit Value builders (still works):
7967
+ * await client.terms.createTerm({
7968
+ * sortId: "sort-uuid",
7969
+ * ownerId: "owner-uuid",
7970
+ * features: { name: Value.string("Alice") },
7971
+ * });
7972
+ * ```
7698
7973
  */
7699
7974
  async createTerm(request) {
7700
- const response = await this.api.addTerm(request);
7975
+ const wireRequest = {
7976
+ ...request,
7977
+ features: convertFeatures(request.features)
7978
+ };
7979
+ const response = await this.api.addTerm(wireRequest);
7701
7980
  return response.data;
7702
7981
  }
7703
7982
  /**
@@ -7718,7 +7997,11 @@ var TermsClient = class {
7718
7997
  * @returns The updated term with validation state.
7719
7998
  */
7720
7999
  async updateTerm(termId, request) {
7721
- const response = await this.api.updateTerm(termId, request);
8000
+ const wireRequest = {
8001
+ ...request,
8002
+ features: convertFeatures(request.features)
8003
+ };
8004
+ const response = await this.api.updateTerm(termId, wireRequest);
7722
8005
  return response.data;
7723
8006
  }
7724
8007
  /**
@@ -7754,7 +8037,13 @@ var TermsClient = class {
7754
8037
  * @returns Bulk creation result with term UUIDs.
7755
8038
  */
7756
8039
  async bulkCreateTerms(request) {
7757
- const response = await this.api.bulkAddTerms(request);
8040
+ const wireRequest = {
8041
+ terms: request.terms.map((t) => ({
8042
+ ...t,
8043
+ features: convertFeatures(t.features)
8044
+ }))
8045
+ };
8046
+ const response = await this.api.bulkAddTerms(wireRequest);
7758
8047
  return response.data;
7759
8048
  }
7760
8049
  /**
@@ -7773,7 +8062,7 @@ var TermsClient = class {
7773
8062
  * const result = await client.terms.listTerms();
7774
8063
  * console.log(`Found ${result.count} terms`);
7775
8064
  * for (const term of result.terms) {
7776
- * console.log(term.id, term.sort_name);
8065
+ * console.log(term.id, term.sortName);
7777
8066
  * }
7778
8067
  * ```
7779
8068
  */
@@ -7795,14 +8084,34 @@ var TermsClient = class {
7795
8084
  * @example
7796
8085
  * ```typescript
7797
8086
  * const result = await client.terms.clearTerms();
7798
- * console.log(`${result.terms_cleared} terms cleared`);
8087
+ * console.log(`${result.termsCleared} terms cleared`);
7799
8088
  * ```
7800
8089
  */
7801
8090
  async clearTerms() {
7802
8091
  const response = await this.api.clearTerms();
7803
8092
  return response.data;
7804
8093
  }
8094
+ // ─── Friendly Aliases ─────────────────────────────────────────────
8095
+ /**
8096
+ * Create multiple records in a single request.
8097
+ * Alias for {@link bulkCreateTerms}.
8098
+ *
8099
+ * @param request - Bulk creation request.
8100
+ * @returns Bulk creation result with term UUIDs.
8101
+ *
8102
+ * @see bulkCreateTerms
8103
+ */
8104
+ async createMany(request) {
8105
+ return this.bulkCreateTerms(request);
8106
+ }
7805
8107
  };
8108
+ function convertFeatures(features) {
8109
+ const values = Object.values(features);
8110
+ if (values.length > 0 && values.every(isTaggedValueDto)) {
8111
+ return features;
8112
+ }
8113
+ return toTaggedFeatures(features);
8114
+ }
7806
8115
 
7807
8116
  // src/resources/inference.ts
7808
8117
  var InferenceClient = class {
@@ -7822,7 +8131,12 @@ var InferenceClient = class {
7822
8131
  * @returns The created rule wrapped in an AddRuleResponse.
7823
8132
  */
7824
8133
  async addRule(request) {
7825
- const response = await this.api.addRule(request);
8134
+ const wireRequest = {
8135
+ term: convertTermArg(request.term),
8136
+ antecedents: request.antecedents?.map(convertTermArg),
8137
+ certainty: request.certainty
8138
+ };
8139
+ const response = await this.api.addRule(wireRequest);
7826
8140
  return response.data;
7827
8141
  }
7828
8142
  /**
@@ -7832,7 +8146,10 @@ var InferenceClient = class {
7832
8146
  * @returns The created fact wrapped in an AddFactResponse.
7833
8147
  */
7834
8148
  async addFact(request) {
7835
- const response = await this.api.addFact(request);
8149
+ const wireRequest = {
8150
+ term: convertTermArg(request.term)
8151
+ };
8152
+ const response = await this.api.addFact(wireRequest);
7836
8153
  return response.data;
7837
8154
  }
7838
8155
  /**
@@ -7842,7 +8159,14 @@ var InferenceClient = class {
7842
8159
  * @returns Bulk creation result with rule_term_ids and rules_added count.
7843
8160
  */
7844
8161
  async bulkAddRules(request) {
7845
- const response = await this.api.bulkAddRules(request);
8162
+ const wireRequest = {
8163
+ rules: request.rules.map((r) => ({
8164
+ term: convertTermArg(r.term),
8165
+ antecedents: r.antecedents?.map(convertTermArg),
8166
+ certainty: r.certainty
8167
+ }))
8168
+ };
8169
+ const response = await this.api.bulkAddRules(wireRequest);
7846
8170
  return response.data;
7847
8171
  }
7848
8172
  /**
@@ -7852,7 +8176,10 @@ var InferenceClient = class {
7852
8176
  * @returns Bulk creation result with term_ids and facts_added count.
7853
8177
  */
7854
8178
  async bulkAddFacts(request) {
7855
- const response = await this.api.bulkAddFacts(request);
8179
+ const wireRequest = {
8180
+ facts: request.facts.map(convertTermArg)
8181
+ };
8182
+ const response = await this.api.bulkAddFacts(wireRequest);
7856
8183
  return response.data;
7857
8184
  }
7858
8185
  /**
@@ -7887,7 +8214,11 @@ var InferenceClient = class {
7887
8214
  * When it fires, the backend returns whatever solutions have been found so far.
7888
8215
  */
7889
8216
  async backwardChain(request) {
7890
- const response = await this.api.backwardChain(request);
8217
+ const wireRequest = {
8218
+ ...request,
8219
+ goal: request.goal ? convertTermArg(request.goal) : request.goal
8220
+ };
8221
+ const response = await this.api.backwardChain(wireRequest);
7891
8222
  return response.data;
7892
8223
  }
7893
8224
  /**
@@ -7903,7 +8234,11 @@ var InferenceClient = class {
7903
8234
  * If `persist_derived` is true, derived facts are permanently saved to the database.
7904
8235
  */
7905
8236
  async forwardChain(request) {
7906
- const response = await this.api.forwardChain(request);
8237
+ const wireRequest = {
8238
+ ...request,
8239
+ initialFacts: request.initialFacts?.map(convertTermArg)
8240
+ };
8241
+ const response = await this.api.forwardChain(wireRequest);
7907
8242
  return response.data;
7908
8243
  }
7909
8244
  /**
@@ -7927,7 +8262,11 @@ var InferenceClient = class {
7927
8262
  * @returns Fuzzy solutions with truth degrees.
7928
8263
  */
7929
8264
  async fuzzyProve(request) {
7930
- const response = await this.api.fuzzyProve(request);
8265
+ const wireRequest = {
8266
+ ...request,
8267
+ goal: request.goal ? convertTermArg(request.goal) : request.goal
8268
+ };
8269
+ const response = await this.api.fuzzyProve(wireRequest);
7931
8270
  return response.data;
7932
8271
  }
7933
8272
  /**
@@ -7940,7 +8279,11 @@ var InferenceClient = class {
7940
8279
  * Reduces latency via single HTTP round-trip, shared hierarchy, and rules across all goals.
7941
8280
  */
7942
8281
  async bulkFuzzyProve(request) {
7943
- const response = await this.api.bulkFuzzyProve(request);
8282
+ const wireRequest = {
8283
+ ...request,
8284
+ goals: request.goals?.map(convertTermArg)
8285
+ };
8286
+ const response = await this.api.bulkFuzzyProve(wireRequest);
7944
8287
  return response.data;
7945
8288
  }
7946
8289
  /**
@@ -7950,7 +8293,11 @@ var InferenceClient = class {
7950
8293
  * @returns Predictions with posterior probabilities.
7951
8294
  */
7952
8295
  async bayesianPredict(request) {
7953
- const response = await this.api.bayesianPredict(request);
8296
+ const wireRequest = {
8297
+ ...request,
8298
+ goal: request.goal ? convertTermArg(request.goal) : request.goal
8299
+ };
8300
+ const response = await this.api.bayesianPredict(wireRequest);
7954
8301
  return response.data;
7955
8302
  }
7956
8303
  /**
@@ -7985,7 +8332,11 @@ var InferenceClient = class {
7985
8332
  * @returns The created goal with ID, PsiTerm, and clause/constraint counts.
7986
8333
  */
7987
8334
  async createGoal(request) {
7988
- const response = await this.api.createGoal(request);
8335
+ const wireRequest = {
8336
+ ...request,
8337
+ clauses: request.clauses.map(convertTermArg)
8338
+ };
8339
+ const response = await this.api.createGoal(wireRequest);
7989
8340
  return response.data;
7990
8341
  }
7991
8342
  /**
@@ -8026,7 +8377,47 @@ var InferenceClient = class {
8026
8377
  const response = await this.api.getMetaSorts();
8027
8378
  return response.data;
8028
8379
  }
8380
+ // ─── Friendly Aliases ─────────────────────────────────────────────
8381
+ /**
8382
+ * Search for solutions by querying rules and facts backwards from a goal.
8383
+ * Alias for {@link backwardChain}.
8384
+ *
8385
+ * @param request - Backward chaining request.
8386
+ * @returns Solutions matching the goal.
8387
+ *
8388
+ * @see backwardChain
8389
+ */
8390
+ async query(request) {
8391
+ return this.backwardChain(request);
8392
+ }
8393
+ /**
8394
+ * Derive new facts by applying rules to existing facts.
8395
+ * Alias for {@link forwardChain}.
8396
+ *
8397
+ * @param request - Forward chaining request.
8398
+ * @returns Derived facts and statistics.
8399
+ *
8400
+ * @see forwardChain
8401
+ */
8402
+ async derive(request) {
8403
+ return this.forwardChain(request);
8404
+ }
8405
+ /**
8406
+ * Assert a fact into the knowledge base.
8407
+ * Alias for {@link addFact}.
8408
+ *
8409
+ * @param request - Fact definition.
8410
+ * @returns The created fact.
8411
+ *
8412
+ * @see addFact
8413
+ */
8414
+ async assertFact(request) {
8415
+ return this.addFact(request);
8416
+ }
8029
8417
  };
8418
+ function convertTermArg(input) {
8419
+ return isPsiTermInput(input) ? toTermInputDto(input) : input;
8420
+ }
8030
8421
 
8031
8422
  // src/resources/query.ts
8032
8423
  var QueryClient = class {
@@ -8039,13 +8430,18 @@ var QueryClient = class {
8039
8430
  /**
8040
8431
  * Find terms that unify with a given pattern.
8041
8432
  *
8042
- * @param request - Unifiable query with term input.
8433
+ * @param request - Unifiable query with term input. Features can be plain JS values
8434
+ * (auto-converted to tagged `ValueDto`) or explicit `Value.*` builder output.
8043
8435
  * @returns Array of matching terms (tagged ValueDto format).
8044
8436
  *
8045
8437
  * @see findMatching — friendlier alias for this method.
8046
8438
  */
8047
8439
  async findUnifiable(request) {
8048
- const response = await this.api.findUnifiable(request);
8440
+ const wireRequest = {
8441
+ ...request,
8442
+ pattern: convertPattern(request.pattern)
8443
+ };
8444
+ const response = await this.api.findUnifiable(wireRequest);
8049
8445
  return response.data.results;
8050
8446
  }
8051
8447
  /**
@@ -8062,7 +8458,7 @@ var QueryClient = class {
8062
8458
  /**
8063
8459
  * Execute an Order-Sorted Feature search.
8064
8460
  *
8065
- * @param request - OSF search request with pattern.
8461
+ * @param request - OSF search request with pattern. Features can be plain JS values.
8066
8462
  * @returns Structured search results including entities, relations, and suspended query information.
8067
8463
  *
8068
8464
  * @remarks
@@ -8072,26 +8468,36 @@ var QueryClient = class {
8072
8468
  * @see search — friendlier alias for this method.
8073
8469
  */
8074
8470
  async osfSearch(request) {
8075
- const response = await this.api.osfSearch(request);
8471
+ const wireRequest = {
8472
+ ...request,
8473
+ pattern: convertPattern(request.pattern)
8474
+ };
8475
+ const response = await this.api.osfSearch(wireRequest);
8076
8476
  return response.data;
8077
8477
  }
8078
8478
  /**
8079
8479
  * Validate a term against its sort's type witnesses.
8080
8480
  *
8081
- * @param request - Term validation request with sort_id and tagged features.
8481
+ * @param request - Term validation request with sort_id and features.
8482
+ * Features can be plain JS values (auto-converted to tagged `ValueDto`).
8082
8483
  * @returns Validation result with witness satisfaction status.
8083
8484
  *
8084
8485
  * @remarks
8085
8486
  * Uses tagged `ValueDto` format for features (same as term CRUD).
8086
8487
  */
8087
8488
  async validateTerm(request) {
8088
- const response = await this.api.validateTerm(request);
8489
+ const wireRequest = {
8490
+ ...request,
8491
+ term: convertPattern(request.term)
8492
+ };
8493
+ const response = await this.api.validateTerm(wireRequest);
8089
8494
  return response.data;
8090
8495
  }
8091
8496
  /**
8092
8497
  * Perform validated unification of two terms.
8093
8498
  *
8094
8499
  * @param request - Validated unification request with two terms to unify.
8500
+ * Features can be plain JS values (auto-converted to tagged `ValueDto`).
8095
8501
  * @returns Unification result with GLB sort and witness validation.
8096
8502
  *
8097
8503
  * @remarks
@@ -8100,10 +8506,15 @@ var QueryClient = class {
8100
8506
  * and validates the result against the GLB sort's type witnesses.
8101
8507
  */
8102
8508
  async validatedUnify(request) {
8509
+ const wireRequest = {
8510
+ ...request,
8511
+ ...request.term1 ? { term1: convertPattern(request.term1) } : {},
8512
+ ...request.term2 ? { term2: convertPattern(request.term2) } : {}
8513
+ };
8103
8514
  const response = await this.api.http.request({
8104
8515
  path: "/api/v1/query/validated-unify",
8105
8516
  method: "POST",
8106
- body: request,
8517
+ body: wireRequest,
8107
8518
  type: "application/json" /* Json */,
8108
8519
  format: "json"
8109
8520
  });
@@ -8144,6 +8555,16 @@ var QueryClient = class {
8144
8555
  return this.findUnifiable(request);
8145
8556
  }
8146
8557
  };
8558
+ function convertPattern(pattern) {
8559
+ const values = Object.values(pattern.features);
8560
+ if (values.length > 0 && values.every(isTaggedValueDto)) {
8561
+ return pattern;
8562
+ }
8563
+ return {
8564
+ sortId: pattern.sortId,
8565
+ features: toTaggedFeatures(pattern.features)
8566
+ };
8567
+ }
8147
8568
 
8148
8569
  // src/resources/cognitive.ts
8149
8570
  var CognitiveClient = class {
@@ -8179,7 +8600,7 @@ var CognitiveClient = class {
8179
8600
  * @returns The created agent response.
8180
8601
  */
8181
8602
  async createAgent(request) {
8182
- const response = await this.api.createAgent({ ...request, tenant_id: this.tenantId });
8603
+ const response = await this.api.createAgent({ ...request, tenantId: this.tenantId });
8183
8604
  return response.data;
8184
8605
  }
8185
8606
  /**
@@ -8189,8 +8610,8 @@ var CognitiveClient = class {
8189
8610
  * @returns The agent's basic state.
8190
8611
  *
8191
8612
  * @remarks
8192
- * Uses a direct HTTP request fallback because this endpoint
8193
- * is not present in the generated route class.
8613
+ * Uses GET `/api/v1/cognitive/agents/{agent_id}`.
8614
+ * Tenant is identified by the `X-Tenant-Id` header (set automatically).
8194
8615
  */
8195
8616
  async getAgent(agentId) {
8196
8617
  const response = await this.api.http.request({
@@ -8198,7 +8619,7 @@ var CognitiveClient = class {
8198
8619
  method: "GET",
8199
8620
  format: "json"
8200
8621
  });
8201
- return response.data;
8622
+ return response.data.agent;
8202
8623
  }
8203
8624
  /**
8204
8625
  * Delete a cognitive agent.
@@ -8206,8 +8627,8 @@ var CognitiveClient = class {
8206
8627
  * @param agentId - Agent UUID.
8207
8628
  *
8208
8629
  * @remarks
8209
- * Uses a direct HTTP request fallback because this endpoint
8210
- * is not present in the generated route class.
8630
+ * Uses DELETE `/api/v1/cognitive/agents/{agent_id}`.
8631
+ * Tenant is identified by the `X-Tenant-Id` header (set automatically).
8211
8632
  */
8212
8633
  async deleteAgent(agentId) {
8213
8634
  await this.api.http.request({
@@ -8225,38 +8646,43 @@ var CognitiveClient = class {
8225
8646
  * Uses POST with agent_id/tenant_id in the body (same pattern as other cognitive endpoints).
8226
8647
  */
8227
8648
  async getState(request) {
8228
- const response = await this.api.getAgentState({ ...request, tenant_id: this.tenantId });
8649
+ const response = await this.api.getAgentState({ ...request, tenantId: this.tenantId });
8229
8650
  return response.data.agent;
8230
8651
  }
8231
8652
  /**
8232
8653
  * Get agent drives and motivation state.
8233
8654
  *
8234
- * @param request - Agent ID and tenant ID.
8655
+ * @param request - Agent ID.
8235
8656
  * @returns The agent's motivation state including drives, deficits, and curiosity targets.
8236
8657
  *
8237
8658
  * @remarks
8238
- * Uses GET with agent_id as path parameter and tenant_id as query parameter.
8239
- * Returns drives, deficits, curiosity targets, and the dominant drive.
8659
+ * Uses GET `/api/v1/cognitive/agents/{agent_id}/drives`.
8660
+ * Tenant is identified by the `X-Tenant-Id` header (set automatically).
8240
8661
  */
8241
8662
  async getAgentDrives(request) {
8242
- const response = await this.api.getAgentDrives(request.agent_id, {
8243
- tenant_id: this.tenantId
8663
+ const response = await this.api.http.request({
8664
+ path: `/api/v1/cognitive/agents/${request.agentId}/drives`,
8665
+ method: "GET",
8666
+ format: "json"
8244
8667
  });
8245
8668
  return response.data;
8246
8669
  }
8247
8670
  /**
8248
8671
  * Get extended agent state including full cognitive state.
8249
8672
  *
8250
- * @param request - Agent ID and tenant ID.
8673
+ * @param request - Agent ID.
8251
8674
  * @returns The agent's extended state including beliefs, goals, intentions,
8252
8675
  * pending perceptions, activations, recent episodes, and rule utilities.
8253
8676
  *
8254
8677
  * @remarks
8255
- * Uses GET with agent_id as path parameter and tenant_id as query parameter.
8678
+ * Uses GET `/api/v1/cognitive/agents/{agent_id}/extended-state`.
8679
+ * Tenant is identified by the `X-Tenant-Id` header (set automatically).
8256
8680
  */
8257
8681
  async getExtendedAgentState(request) {
8258
- const response = await this.api.getExtendedAgentState(request.agent_id, {
8259
- tenant_id: this.tenantId
8682
+ const response = await this.api.http.request({
8683
+ path: `/api/v1/cognitive/agents/${request.agentId}/extended-state`,
8684
+ method: "GET",
8685
+ format: "json"
8260
8686
  });
8261
8687
  return response.data.agent;
8262
8688
  }
@@ -8268,7 +8694,7 @@ var CognitiveClient = class {
8268
8694
  * @returns The cycle outcome.
8269
8695
  */
8270
8696
  async runCycle(request) {
8271
- const response = await this.api.runCycle({ ...request, tenant_id: this.tenantId });
8697
+ const response = await this.api.runCycle({ ...request, tenantId: this.tenantId });
8272
8698
  return response.data;
8273
8699
  }
8274
8700
  // --- Beliefs ---
@@ -8279,7 +8705,7 @@ var CognitiveClient = class {
8279
8705
  * @returns The created belief response.
8280
8706
  */
8281
8707
  async addBelief(request) {
8282
- const response = await this.api.addBelief({ ...request, tenant_id: this.tenantId });
8708
+ const response = await this.api.addBelief({ ...request, tenantId: this.tenantId });
8283
8709
  return response.data;
8284
8710
  }
8285
8711
  // --- Goals ---
@@ -8290,7 +8716,7 @@ var CognitiveClient = class {
8290
8716
  * @returns The created goal response.
8291
8717
  */
8292
8718
  async addGoal(request) {
8293
- const response = await this.api.addGoal({ ...request, tenant_id: this.tenantId });
8719
+ const response = await this.api.addGoal({ ...request, tenantId: this.tenantId });
8294
8720
  return response.data;
8295
8721
  }
8296
8722
  // --- Cognitive Registry ---
@@ -8301,7 +8727,7 @@ var CognitiveClient = class {
8301
8727
  * @returns The created rule response.
8302
8728
  */
8303
8729
  async addRule(request) {
8304
- const response = await this.api.addCognitiveRule({ ...request, tenant_id: this.tenantId });
8730
+ const response = await this.api.addCognitiveRule({ ...request, tenantId: this.tenantId });
8305
8731
  return response.data;
8306
8732
  }
8307
8733
  /**
@@ -8311,7 +8737,7 @@ var CognitiveClient = class {
8311
8737
  * @returns The created sort response.
8312
8738
  */
8313
8739
  async addSort(request) {
8314
- const response = await this.api.createCognitiveSort({ ...request, tenant_id: this.tenantId });
8740
+ const response = await this.api.createCognitiveSort({ ...request, tenantId: this.tenantId });
8315
8741
  return response.data;
8316
8742
  }
8317
8743
  // --- Adaptive Modification ---
@@ -8326,7 +8752,7 @@ var CognitiveClient = class {
8326
8752
  * inference, not just at API boundaries. Uses POST to `/api/v1/cognitive/agents/adapt`.
8327
8753
  */
8328
8754
  async adaptiveModify(request) {
8329
- const response = await this.api.adaptiveModify({ ...request, tenant_id: this.tenantId });
8755
+ const response = await this.api.adaptiveModify({ ...request, tenantId: this.tenantId });
8330
8756
  return response.data;
8331
8757
  }
8332
8758
  // --- Episodic Memory ---
@@ -8337,7 +8763,7 @@ var CognitiveClient = class {
8337
8763
  * @returns Recalled episodes sorted by similarity/recency.
8338
8764
  */
8339
8765
  async recallEpisodes(request) {
8340
- const response = await this.episodicMemory.recallEpisodes({ ...request, tenant_id: this.tenantId });
8766
+ const response = await this.episodicMemory.recallEpisodes({ ...request, tenantId: this.tenantId });
8341
8767
  return response.data;
8342
8768
  }
8343
8769
  /**
@@ -8351,7 +8777,7 @@ var CognitiveClient = class {
8351
8777
  * unlike the original SDK which used GET with a path parameter.
8352
8778
  */
8353
8779
  async getEpisodeStats(request) {
8354
- const response = await this.episodicMemory.getEpisodeStats({ ...request, tenant_id: this.tenantId });
8780
+ const response = await this.episodicMemory.getEpisodeStats({ ...request, tenantId: this.tenantId });
8355
8781
  return response.data;
8356
8782
  }
8357
8783
  // --- HTN Planning ---
@@ -8362,7 +8788,7 @@ var CognitiveClient = class {
8362
8788
  * @returns The created method response.
8363
8789
  */
8364
8790
  async addHtnMethod(request) {
8365
- const response = await this.htn.addHtnMethod({ ...request, tenant_id: this.tenantId });
8791
+ const response = await this.htn.addHtnMethod({ ...request, tenantId: this.tenantId });
8366
8792
  return response.data;
8367
8793
  }
8368
8794
  // --- Messaging ---
@@ -8373,7 +8799,7 @@ var CognitiveClient = class {
8373
8799
  * @returns The send result.
8374
8800
  */
8375
8801
  async sendMessage(request) {
8376
- const response = await this.messaging.sendMessage({ ...request, tenant_id: this.tenantId });
8802
+ const response = await this.messaging.sendMessage({ ...request, tenantId: this.tenantId });
8377
8803
  return response.data;
8378
8804
  }
8379
8805
  /**
@@ -8383,7 +8809,7 @@ var CognitiveClient = class {
8383
8809
  * @returns The broadcast result.
8384
8810
  */
8385
8811
  async broadcastMessage(request) {
8386
- const response = await this.messaging.broadcastMessage({ ...request, tenant_id: this.tenantId });
8812
+ const response = await this.messaging.broadcastMessage({ ...request, tenantId: this.tenantId });
8387
8813
  return response.data;
8388
8814
  }
8389
8815
  /**
@@ -8393,7 +8819,7 @@ var CognitiveClient = class {
8393
8819
  * @returns The result.
8394
8820
  */
8395
8821
  async markMessagesRead(request) {
8396
- const response = await this.messaging.markMessagesRead({ ...request, tenant_id: this.tenantId });
8822
+ const response = await this.messaging.markMessagesRead({ ...request, tenantId: this.tenantId });
8397
8823
  return response.data;
8398
8824
  }
8399
8825
  // --- Feedback ---
@@ -8404,7 +8830,7 @@ var CognitiveClient = class {
8404
8830
  * @returns The feedback result.
8405
8831
  */
8406
8832
  async provideFeedback(request) {
8407
- const response = await this.api.provideFeedback({ ...request, tenant_id: this.tenantId });
8833
+ const response = await this.api.provideFeedback({ ...request, tenantId: this.tenantId });
8408
8834
  return response.data;
8409
8835
  }
8410
8836
  /**
@@ -8419,7 +8845,7 @@ var CognitiveClient = class {
8419
8845
  * Uses POST to `/api/v1/cognitive/learn_correction`.
8420
8846
  */
8421
8847
  async learnFromCorrection(request) {
8422
- const response = await this.api.learnFromCorrection({ ...request, tenant_id: this.tenantId });
8848
+ const response = await this.api.learnFromCorrection({ ...request, tenantId: this.tenantId });
8423
8849
  return response.data;
8424
8850
  }
8425
8851
  /**
@@ -8434,7 +8860,7 @@ var CognitiveClient = class {
8434
8860
  * Uses POST to `/api/v1/cognitive/agents/reflect`.
8435
8861
  */
8436
8862
  async reflectionQuery(request) {
8437
- const response = await this.api.reflectionQuery({ ...request, tenant_id: this.tenantId });
8863
+ const response = await this.api.reflectionQuery({ ...request, tenantId: this.tenantId });
8438
8864
  return response.data;
8439
8865
  }
8440
8866
  // --- Integrated Cycle ---
@@ -8445,7 +8871,7 @@ var CognitiveClient = class {
8445
8871
  * @returns The integrated cycle outcome with duration.
8446
8872
  */
8447
8873
  async integratedCycle(request) {
8448
- const response = await this.api.runIntegratedCycle({ ...request, tenant_id: this.tenantId });
8874
+ const response = await this.api.runIntegratedCycle({ ...request, tenantId: this.tenantId });
8449
8875
  return response.data;
8450
8876
  }
8451
8877
  // --- KB Subscription ---
@@ -8456,7 +8882,7 @@ var CognitiveClient = class {
8456
8882
  * @returns Subscription ID.
8457
8883
  */
8458
8884
  async subscribeToKb(request) {
8459
- const response = await this.api.subscribeToKb({ ...request, tenant_id: this.tenantId });
8885
+ const response = await this.api.subscribeToKb({ ...request, tenantId: this.tenantId });
8460
8886
  return response.data;
8461
8887
  }
8462
8888
  // --- Episode Recording ---
@@ -8467,7 +8893,7 @@ var CognitiveClient = class {
8467
8893
  * @returns The created episode ID.
8468
8894
  */
8469
8895
  async recordEpisode(request) {
8470
- const response = await this.episodicMemory.recordEpisode({ ...request, tenant_id: this.tenantId });
8896
+ const response = await this.episodicMemory.recordEpisode({ ...request, tenantId: this.tenantId });
8471
8897
  return response.data;
8472
8898
  }
8473
8899
  // --- Plan Library ---
@@ -8481,7 +8907,7 @@ var CognitiveClient = class {
8481
8907
  * Stores a successful action sequence as a reusable plan template.
8482
8908
  */
8483
8909
  async storePlan(request) {
8484
- const response = await this.planLibrary.storePlan({ ...request, tenant_id: this.tenantId });
8910
+ const response = await this.planLibrary.storePlan({ ...request, tenantId: this.tenantId });
8485
8911
  return response.data;
8486
8912
  }
8487
8913
  /**
@@ -8494,7 +8920,7 @@ var CognitiveClient = class {
8494
8920
  * Searches the plan library for plans that match the given goal.
8495
8921
  */
8496
8922
  async findPlans(request) {
8497
- const response = await this.planLibrary.findPlans({ ...request, tenant_id: this.tenantId });
8923
+ const response = await this.planLibrary.findPlans({ ...request, tenantId: this.tenantId });
8498
8924
  return response.data;
8499
8925
  }
8500
8926
  /**
@@ -8504,8 +8930,10 @@ var CognitiveClient = class {
8504
8930
  * @returns Whether the plan was deleted.
8505
8931
  */
8506
8932
  async deletePlan(request) {
8507
- const response = await this.planLibrary.deletePlan(request.plan_id, {
8508
- tenant_id: this.tenantId
8933
+ const response = await this.api.http.request({
8934
+ path: `/api/v1/cognitive/agents/plans/${request.planId}`,
8935
+ method: "DELETE",
8936
+ format: "json"
8509
8937
  });
8510
8938
  return response.data;
8511
8939
  }
@@ -8516,7 +8944,7 @@ var CognitiveClient = class {
8516
8944
  * @returns Updated success rate and use count.
8517
8945
  */
8518
8946
  async updatePlanStats(request) {
8519
- const response = await this.planLibrary.updatePlanStats({ ...request, tenant_id: this.tenantId });
8947
+ const response = await this.planLibrary.updatePlanStats({ ...request, tenantId: this.tenantId });
8520
8948
  return response.data;
8521
8949
  }
8522
8950
  // --- WebSocket Subscriptions ---
@@ -8591,8 +9019,8 @@ var FuzzyClient = class {
8591
9019
  */
8592
9020
  async compareSimilarity(term1Id, term2Id, options) {
8593
9021
  return this.fuzzyUnify({
8594
- term1_id: term1Id,
8595
- term2_id: term2Id,
9022
+ term1Id,
9023
+ term2Id,
8596
9024
  ...options
8597
9025
  });
8598
9026
  }
@@ -8777,7 +9205,7 @@ var ConstraintsClient = class {
8777
9205
  * ```ts
8778
9206
  * const sessions = await client.constraints.listSessions();
8779
9207
  * for (const session of sessions) {
8780
- * console.log(`${session.session_id}: ${session.status}`);
9208
+ * console.log(`${session.sessionId}: ${session.status}`);
8781
9209
  * }
8782
9210
  * ```
8783
9211
  */
@@ -11152,7 +11580,7 @@ var NeuroSymbolicClient = class {
11152
11580
  * @example
11153
11581
  * ```ts
11154
11582
  * const result = await client.neuroSymbolic.trainFromTraces();
11155
- * console.log(`Triggered: ${result.triggered}, Loss: ${result.loss}, Traces: ${result.traces_consumed}`);
11583
+ * console.log(`Triggered: ${result.triggered}, Loss: ${result.loss}, Traces: ${result.tracesConsumed}`);
11156
11584
  * ```
11157
11585
  * @remarks Uses untagged serialization. POST /api/v1/admin/neuro-symbolic/train/from-traces
11158
11586
  */
@@ -11358,7 +11786,7 @@ var FunctionsClient = class {
11358
11786
  * },
11359
11787
  * ],
11360
11788
  * });
11361
- * console.log(result.function_id); // UUID of the registered function
11789
+ * console.log(result.functionId); // UUID of the registered function
11362
11790
  * ```
11363
11791
  */
11364
11792
  async registerFunction(request) {
@@ -11388,7 +11816,7 @@ var FunctionsClient = class {
11388
11816
  * arguments: [{ type: 'Integer', value: 5 }],
11389
11817
  * tenant_id: 'my-tenant-uuid',
11390
11818
  * });
11391
- * if (result.result_type === 'Value') {
11819
+ * if (result.resultType === 'Value') {
11392
11820
  * console.log(result.value); // { type: 'Integer', value: 120 }
11393
11821
  * } else {
11394
11822
  * console.log('Suspended:', result.reason);
@@ -11433,7 +11861,7 @@ var WebhookActionsClient = class {
11433
11861
  * outputs: ['message_id', 'sent_at'],
11434
11862
  * tenant_id: 'my-tenant-uuid',
11435
11863
  * });
11436
- * console.log(result.action_id, result.sort_id);
11864
+ * console.log(result.actionId, result.sortId);
11437
11865
  * ```
11438
11866
  */
11439
11867
  async register(request) {
@@ -11460,7 +11888,7 @@ var WebhookActionsClient = class {
11460
11888
  * inputs: { to: 'user@example.com', subject: 'Hello', body: 'World' },
11461
11889
  * tenant_id: 'my-tenant-uuid',
11462
11890
  * });
11463
- * console.log(result.invocation_id, result.callback_url);
11891
+ * console.log(result.invocationId, result.callbackUrl);
11464
11892
  * ```
11465
11893
  */
11466
11894
  async invoke(name, request) {
@@ -11486,7 +11914,7 @@ var WebhookActionsClient = class {
11486
11914
  * status: 'success',
11487
11915
  * outputs: { message_id: 'msg-456', sent_at: '2024-01-15T10:30:00Z' },
11488
11916
  * });
11489
- * console.log(result.demons_fired, result.term_updated);
11917
+ * console.log(result.demonsFired, result.termUpdated);
11490
11918
  * ```
11491
11919
  */
11492
11920
  async completeInvocation(invocationId, request) {
@@ -11507,7 +11935,7 @@ var WebhookActionsClient = class {
11507
11935
  * const result = await client.webhookActions.listActions();
11508
11936
  * console.log(`Found ${result.total} actions`);
11509
11937
  * for (const action of result.actions) {
11510
- * console.log(action.name, action.webhook_url);
11938
+ * console.log(action.name, action.webhookUrl);
11511
11939
  * }
11512
11940
  * ```
11513
11941
  */
@@ -11528,9 +11956,9 @@ var WebhookActionsClient = class {
11528
11956
  * @example
11529
11957
  * ```typescript
11530
11958
  * const result = await client.webhookActions.listPendingInvocations();
11531
- * console.log(`${result.total_pending} pending invocations`);
11959
+ * console.log(`${result.totalPending} pending invocations`);
11532
11960
  * for (const inv of result.invocations) {
11533
- * console.log(inv.invocation_id, inv.action_name, inv.status);
11961
+ * console.log(inv.invocationId, inv.actionName, inv.status);
11534
11962
  * }
11535
11963
  * ```
11536
11964
  */
@@ -11568,8 +11996,8 @@ var SyntheticClient = class {
11568
11996
  * term_id: 'term-uuid',
11569
11997
  * schema_sort_ids: ['sort-uuid-1', 'sort-uuid-2'],
11570
11998
  * });
11571
- * console.log(result.full_prompt);
11572
- * console.log(result.stable_prefix); // cacheable across calls
11999
+ * console.log(result.fullPrompt);
12000
+ * console.log(result.stablePrefix); // cacheable across calls
11573
12001
  * ```
11574
12002
  */
11575
12003
  async buildGenerationPrompt(request) {
@@ -11596,9 +12024,9 @@ var SyntheticClient = class {
11596
12024
  * ],
11597
12025
  * sort_names: { 'sort-uuid': 'Employee' },
11598
12026
  * });
11599
- * console.log(`Global ECE: ${report.global_ece}`);
11600
- * for (const target of report.augmentation_targets) {
11601
- * console.log(`${target.sort_name} needs ${target.recommended_examples} more examples`);
12027
+ * console.log(`Global ECE: ${report.globalEce}`);
12028
+ * for (const target of report.augmentationTargets) {
12029
+ * console.log(`${target.sortName} needs ${target.recommendedExamples} more examples`);
11602
12030
  * }
11603
12031
  * ```
11604
12032
  */
@@ -11626,7 +12054,7 @@ var SyntheticClient = class {
11626
12054
  * existing_term_ids: ['term-uuid-1', 'term-uuid-2'],
11627
12055
  * min_diversity_score: 0.3,
11628
12056
  * });
11629
- * console.log(`Novel: ${result.is_diverse}, score: ${result.novelty_score}`);
12057
+ * console.log(`Novel: ${result.isDiverse}, score: ${result.noveltyScore}`);
11630
12058
  * ```
11631
12059
  */
11632
12060
  async checkDiversity(request) {
@@ -11652,7 +12080,7 @@ var SyntheticClient = class {
11652
12080
  * target_sorts: ['sort-uuid'],
11653
12081
  * max_terms_per_sort: 50,
11654
12082
  * });
11655
- * console.log(`Exported ${result.example_count} examples`);
12083
+ * console.log(`Exported ${result.exampleCount} examples`);
11656
12084
  * // Write JSONL to file for fine-tuning
11657
12085
  * ```
11658
12086
  */
@@ -11714,8 +12142,8 @@ var SyntheticClient = class {
11714
12142
  * enable_verbalization: true,
11715
12143
  * seed: 42,
11716
12144
  * });
11717
- * console.log(`Generated ${result.training_pairs_count} training pairs`);
11718
- * console.log(`Report: ${result.report.terms_generated} terms generated`);
12145
+ * console.log(`Generated ${result.trainingPairsCount} training pairs`);
12146
+ * console.log(`Report: ${result.report.termsGenerated} terms generated`);
11719
12147
  * ```
11720
12148
  */
11721
12149
  async generateSynthetic(request) {
@@ -11797,7 +12225,7 @@ var SyntheticClient = class {
11797
12225
  * extracted: [{ sort_id: 'sort-uuid', features: { name: 'Alice' } }],
11798
12226
  * min_faithfulness_score: 0.5,
11799
12227
  * });
11800
- * console.log(`Passed: ${result.passed}, Score: ${result.faithfulness_score}`);
12228
+ * console.log(`Passed: ${result.passed}, Score: ${result.faithfulnessScore}`);
11801
12229
  * ```
11802
12230
  */
11803
12231
  async verifyRoundTrip(request) {
@@ -11831,7 +12259,7 @@ var ProofEngineClient = class {
11831
12259
  * const session = await client.proofEngine.createRuleStoreSession({
11832
12260
  * tenant_id: 'tenant-uuid',
11833
12261
  * });
11834
- * console.log(session.store_id);
12262
+ * console.log(session.storeId);
11835
12263
  * ```
11836
12264
  */
11837
12265
  async createRuleStoreSession(request) {
@@ -11851,7 +12279,7 @@ var ProofEngineClient = class {
11851
12279
  * @example
11852
12280
  * ```typescript
11853
12281
  * const session = await client.proofEngine.getRuleStoreSession('store-uuid');
11854
- * console.log(`${session.rule_count} rules in store`);
12282
+ * console.log(`${session.ruleCount} rules in store`);
11855
12283
  * ```
11856
12284
  */
11857
12285
  async getRuleStoreSession(storeId) {
@@ -11877,7 +12305,7 @@ var ProofEngineClient = class {
11877
12305
  * head: { constraints: [{ type: 'sort', var_name: 'X', sort_id: 'person-uuid' }] },
11878
12306
  * body: [],
11879
12307
  * });
11880
- * console.log(`Rule ${result.rule_id} asserted, ${result.rule_count} total`);
12308
+ * console.log(`Rule ${result.ruleId} asserted, ${result.ruleCount} total`);
11881
12309
  * ```
11882
12310
  */
11883
12311
  async assertRule(storeId, request) {
@@ -11902,7 +12330,7 @@ var ProofEngineClient = class {
11902
12330
  * const result = await client.proofEngine.retractRule('store-uuid', {
11903
12331
  * rule_id: 'rule-uuid',
11904
12332
  * });
11905
- * console.log(`${result.retracted_count} rules retracted`);
12333
+ * console.log(`${result.retractedCount} rules retracted`);
11906
12334
  * ```
11907
12335
  */
11908
12336
  async retractRule(storeId, request) {
@@ -11925,7 +12353,7 @@ var ProofEngineClient = class {
11925
12353
  * const result = await client.proofEngine.findRules('store-uuid', {
11926
12354
  * pattern: { constraints: [{ type: 'sort', var_name: 'X', sort_id: 'person-uuid' }] },
11927
12355
  * });
11928
- * console.log(`Found ${result.matching_rules.length} matching rules`);
12356
+ * console.log(`Found ${result.matchingRules.length} matching rules`);
11929
12357
  * ```
11930
12358
  */
11931
12359
  async findRules(storeId, request) {
@@ -11947,7 +12375,7 @@ var ProofEngineClient = class {
11947
12375
  * @example
11948
12376
  * ```typescript
11949
12377
  * const marker = await client.proofEngine.markRuleStore('store-uuid', {});
11950
- * console.log(`Checkpoint at index ${marker.marker_index}`);
12378
+ * console.log(`Checkpoint at index ${marker.markerIndex}`);
11951
12379
  * ```
11952
12380
  */
11953
12381
  async markRuleStore(storeId, request) {
@@ -11970,7 +12398,7 @@ var ProofEngineClient = class {
11970
12398
  * const result = await client.proofEngine.undoRuleStore('store-uuid', {
11971
12399
  * marker_index: 0,
11972
12400
  * });
11973
- * console.log(`Undo ${result.success ? 'succeeded' : 'failed'}, ${result.rule_count} rules`);
12401
+ * console.log(`Undo ${result.success ? 'succeeded' : 'failed'}, ${result.ruleCount} rules`);
11974
12402
  * ```
11975
12403
  */
11976
12404
  async undoRuleStore(storeId, request) {
@@ -11994,7 +12422,7 @@ var ProofEngineClient = class {
11994
12422
  * const session = await client.proofEngine.createTermStoreSession({
11995
12423
  * tenant_id: 'tenant-uuid',
11996
12424
  * });
11997
- * console.log(session.session_id);
12425
+ * console.log(session.sessionId);
11998
12426
  * ```
11999
12427
  */
12000
12428
  async createTermStoreSession(request) {
@@ -12014,7 +12442,7 @@ var ProofEngineClient = class {
12014
12442
  * @example
12015
12443
  * ```typescript
12016
12444
  * const session = await client.proofEngine.getTermStoreSession('session-uuid');
12017
- * console.log(`${session.term_count} terms, ${session.variable_count} variables`);
12445
+ * console.log(`${session.termCount} terms, ${session.variableCount} variables`);
12018
12446
  * ```
12019
12447
  */
12020
12448
  async getTermStoreSession(sessionId) {
@@ -12038,7 +12466,7 @@ var ProofEngineClient = class {
12038
12466
  * sort_id: 'person-uuid',
12039
12467
  * features: { name: "Alice" },
12040
12468
  * });
12041
- * console.log(`Created term ${term.term_id}`);
12469
+ * console.log(`Created term ${term.termId}`);
12042
12470
  * ```
12043
12471
  */
12044
12472
  async createStoreTerm(sessionId, request) {
@@ -12061,7 +12489,7 @@ var ProofEngineClient = class {
12061
12489
  * const variable = await client.proofEngine.createStoreVariable('session-uuid', {
12062
12490
  * sort_id: 'person-uuid',
12063
12491
  * });
12064
- * console.log(`Created variable ${variable.term_id}, is_variable: ${variable.is_variable}`);
12492
+ * console.log(`Created variable ${variable.termId}, is_variable: ${variable.isVariable}`);
12065
12493
  * ```
12066
12494
  */
12067
12495
  async createStoreVariable(sessionId, request) {
@@ -12086,7 +12514,7 @@ var ProofEngineClient = class {
12086
12514
  * variable_id: 'var-uuid',
12087
12515
  * target_id: 'term-uuid',
12088
12516
  * });
12089
- * console.log(`Bound ${result.variable_id} to ${result.bound_to}`);
12517
+ * console.log(`Bound ${result.variableId} to ${result.boundTo}`);
12090
12518
  * ```
12091
12519
  */
12092
12520
  async bindStoreVariable(sessionId, request) {
@@ -12110,7 +12538,7 @@ var ProofEngineClient = class {
12110
12538
  * const result = await client.proofEngine.dereferenceStoreTerm('session-uuid', {
12111
12539
  * term_id: 'var-uuid',
12112
12540
  * });
12113
- * console.log(`${result.original_id} -> ${result.dereferenced_id} (bound: ${result.is_bound})`);
12541
+ * console.log(`${result.originalId} -> ${result.dereferencedId} (bound: ${result.isBound})`);
12114
12542
  * ```
12115
12543
  */
12116
12544
  async dereferenceStoreTerm(sessionId, request) {
@@ -12134,7 +12562,7 @@ var ProofEngineClient = class {
12134
12562
  * const term = await client.proofEngine.getStoreTerm('session-uuid', {
12135
12563
  * term_id: 'term-uuid',
12136
12564
  * });
12137
- * console.log(`Sort: ${term.sort_id}, features:`, term.features);
12565
+ * console.log(`Sort: ${term.sortId}, features:`, term.features);
12138
12566
  * ```
12139
12567
  */
12140
12568
  async getStoreTerm(sessionId, request) {
@@ -12185,9 +12613,9 @@ var ProofEngineClient = class {
12185
12613
  * term2_id: 'term2-uuid',
12186
12614
  * });
12187
12615
  * if (result.success) {
12188
- * console.log(`Unified as ${result.unified_term_id}`);
12616
+ * console.log(`Unified as ${result.unifiedTermId}`);
12189
12617
  * } else {
12190
- * console.log(`Failed: ${result.failure_reason}`);
12618
+ * console.log(`Failed: ${result.failureReason}`);
12191
12619
  * }
12192
12620
  * ```
12193
12621
  */
@@ -12210,7 +12638,7 @@ var ProofEngineClient = class {
12210
12638
  * @example
12211
12639
  * ```typescript
12212
12640
  * const marker = await client.proofEngine.markTermStore('session-uuid', {});
12213
- * console.log(`Marker at index ${marker.marker_index}, trail length ${marker.trail_length}`);
12641
+ * console.log(`Marker at index ${marker.markerIndex}, trail length ${marker.trailLength}`);
12214
12642
  * ```
12215
12643
  */
12216
12644
  async markTermStore(sessionId, request) {
@@ -12234,7 +12662,7 @@ var ProofEngineClient = class {
12234
12662
  * const result = await client.proofEngine.backtrackTermStore('session-uuid', {
12235
12663
  * marker_index: 0,
12236
12664
  * });
12237
- * console.log(`Backtrack ${result.success ? 'succeeded' : 'failed'}, undid ${result.undone_entries} entries`);
12665
+ * console.log(`Backtrack ${result.success ? 'succeeded' : 'failed'}, undid ${result.undoneEntries} entries`);
12238
12666
  * ```
12239
12667
  */
12240
12668
  async backtrackTermStore(sessionId, request) {
@@ -12315,7 +12743,7 @@ var HealthClient = class {
12315
12743
  * ```typescript
12316
12744
  * const health = await client.health.check();
12317
12745
  * console.log(health.status); // "healthy"
12318
- * console.log(health.build_info.version); // "1.2.3"
12746
+ * console.log(health.buildInfo.version); // "1.2.3"
12319
12747
  * for (const component of health.components) {
12320
12748
  * console.log(`${component.name}: ${component.status}`);
12321
12749
  * }
@@ -12350,14 +12778,38 @@ var AdminClient = class {
12350
12778
  * ```typescript
12351
12779
  * const result = await client.admin.clearAllData();
12352
12780
  * console.log(result.message);
12353
- * console.log(`Tables cleared: ${result.postgres_tables_cleared}`);
12354
- * console.log(`Qdrant collections deleted: ${result.qdrant_collections_deleted}`);
12781
+ * console.log(`Tables cleared: ${result.postgresTablesCleared}`);
12782
+ * console.log(`Qdrant collections deleted: ${result.qdrantCollectionsDeleted}`);
12355
12783
  * ```
12356
12784
  */
12357
12785
  async clearAllData() {
12358
12786
  const response = await this.api.clearAllData();
12359
12787
  return response.data;
12360
12788
  }
12789
+ /**
12790
+ * Clear all data for a specific tenant.
12791
+ *
12792
+ * @param tenantId - The UUID of the tenant whose data should be cleared.
12793
+ * @returns Confirmation of what was wiped, including record counts and cache status.
12794
+ * @throws {ApiError} If the request fails.
12795
+ *
12796
+ * @remarks
12797
+ * Destructive operation that wipes all PostgreSQL rows, in-memory inference state,
12798
+ * and cache entries for the specified tenant. Other tenants are unaffected.
12799
+ * Use for tenant offboarding or testing.
12800
+ *
12801
+ * @example
12802
+ * ```typescript
12803
+ * const result = await client.admin.clearTenantData('550e8400-e29b-41d4-a716-446655440000');
12804
+ * console.log(result.message);
12805
+ * console.log(`Terms deleted: ${result.termsDeleted}`);
12806
+ * console.log(`Sessions deleted: ${result.sessionsDeleted}`);
12807
+ * ```
12808
+ */
12809
+ async clearTenantData(tenantId) {
12810
+ const response = await this.api.clearTenantData(tenantId);
12811
+ return response.data;
12812
+ }
12361
12813
  /**
12362
12814
  * List all tenants that have data in the system.
12363
12815
  *
@@ -12372,7 +12824,7 @@ var AdminClient = class {
12372
12824
  * ```typescript
12373
12825
  * const result = await client.admin.listTenants();
12374
12826
  * for (const tenant of result.tenants) {
12375
- * console.log(`${tenant.tenant_id}: ${tenant.term_count} terms, ${tenant.session_count} sessions`);
12827
+ * console.log(`${tenant.tenantId}: ${tenant.termCount} terms, ${tenant.sessionCount} sessions`);
12376
12828
  * }
12377
12829
  * ```
12378
12830
  */
@@ -12452,7 +12904,7 @@ var OntologyClient = class {
12452
12904
  * // Answer the questions and call again
12453
12905
  * const completed = await client.ontology.generate({
12454
12906
  * prompt: 'Build a customer support ticket system',
12455
- * session_id: result.session_id,
12907
+ * session_id: result.sessionId,
12456
12908
  * answers: { priority_levels: '3' },
12457
12909
  * });
12458
12910
  * }
@@ -12542,11 +12994,11 @@ var RagClient = class {
12542
12994
  * include_related: true,
12543
12995
  * });
12544
12996
  *
12545
- * for (const concept of result.primary_concepts) {
12546
- * console.log(`${concept.canonical_name} (${concept.match_degree})`);
12997
+ * for (const concept of result.primaryConcepts) {
12998
+ * console.log(`${concept.canonicalName} (${concept.matchDegree})`);
12547
12999
  * }
12548
13000
  *
12549
- * console.log(`Found ${result.stats.emergent_discovered} emergent relations`);
13001
+ * console.log(`Found ${result.stats.emergentDiscovered} emergent relations`);
12550
13002
  * ```
12551
13003
  */
12552
13004
  async ontologyRag(request) {
@@ -12558,7 +13010,7 @@ var RagClient = class {
12558
13010
  // src/builders/lp.ts
12559
13011
  function numericTerm(n) {
12560
13012
  return {
12561
- sort_name: Number.isInteger(n) ? "integer_type" : "real_type",
13013
+ sortName: Number.isInteger(n) ? "integer_type" : "real_type",
12562
13014
  features: { value: n }
12563
13015
  };
12564
13016
  }
@@ -12678,7 +13130,7 @@ function compileLP(problem, solutionSortName) {
12678
13130
  const ref = varRefs[varName];
12679
13131
  if (bounds.min !== void 0 && bounds.max !== void 0) {
12680
13132
  allAntecedents.push({
12681
- sort_name: "real_between_constraint",
13133
+ sortName: "real_between_constraint",
12682
13134
  features: {
12683
13135
  var: ref,
12684
13136
  lower: numericTerm(bounds.min),
@@ -12688,7 +13140,7 @@ function compileLP(problem, solutionSortName) {
12688
13140
  } else {
12689
13141
  if (bounds.min !== void 0) {
12690
13142
  allAntecedents.push({
12691
- sort_name: "real_ge_constraint",
13143
+ sortName: "real_ge_constraint",
12692
13144
  features: {
12693
13145
  left: ref,
12694
13146
  right: numericTerm(bounds.min)
@@ -12697,7 +13149,7 @@ function compileLP(problem, solutionSortName) {
12697
13149
  }
12698
13150
  if (bounds.max !== void 0) {
12699
13151
  allAntecedents.push({
12700
- sort_name: "real_le_constraint",
13152
+ sortName: "real_le_constraint",
12701
13153
  features: {
12702
13154
  left: ref,
12703
13155
  right: numericTerm(bounds.max)
@@ -12712,7 +13164,7 @@ function compileLP(problem, solutionSortName) {
12712
13164
  allAntecedents.push(...compiled.antecedents);
12713
13165
  const sortName = constraintOpToSort(constraint.op);
12714
13166
  allAntecedents.push({
12715
- sort_name: sortName,
13167
+ sortName,
12716
13168
  features: {
12717
13169
  left: compiled.resultRef,
12718
13170
  right: numericTerm(constraint.rhs)
@@ -12729,7 +13181,7 @@ function compileLP(problem, solutionSortName) {
12729
13181
  if (typeof objectiveRef === "number") {
12730
13182
  const objVar = { name: "?_lp_objective" };
12731
13183
  allAntecedents.push({
12732
- sort_name: "real_eq_constraint",
13184
+ sortName: "real_eq_constraint",
12733
13185
  features: {
12734
13186
  left: objVar,
12735
13187
  right: numericTerm(objectiveRef)
@@ -12739,7 +13191,7 @@ function compileLP(problem, solutionSortName) {
12739
13191
  }
12740
13192
  const objectiveSortName = problem.objective.direction === "maximize" ? "maximize_objective" : "minimize_objective";
12741
13193
  allAntecedents.push({
12742
- sort_name: objectiveSortName,
13194
+ sortName: objectiveSortName,
12743
13195
  features: {
12744
13196
  expression: objectiveRef,
12745
13197
  name: "objective"
@@ -12749,7 +13201,7 @@ function compileLP(problem, solutionSortName) {
12749
13201
  (name) => varRefs[name]
12750
13202
  );
12751
13203
  allAntecedents.push({
12752
- sort_name: "real_labeling_constraint",
13204
+ sortName: "real_labeling_constraint",
12753
13205
  features: {
12754
13206
  variables: variableRefList
12755
13207
  }
@@ -12760,7 +13212,7 @@ function compileLP(problem, solutionSortName) {
12760
13212
  }
12761
13213
  solutionFeatures["_objective"] = objectiveRef;
12762
13214
  const solutionTerm = {
12763
- sort_name: solutionSortName,
13215
+ sortName: solutionSortName,
12764
13216
  features: solutionFeatures
12765
13217
  };
12766
13218
  return { solutionTerm, antecedents: allAntecedents };
@@ -12794,7 +13246,7 @@ function compileLinearExpression(expression, varRefs, nextVar) {
12794
13246
  } else {
12795
13247
  const resultVar = { name: nextVar() };
12796
13248
  antecedents.push({
12797
- sort_name: "real_times_constraint",
13249
+ sortName: "real_times_constraint",
12798
13250
  features: {
12799
13251
  coefficient: numericTerm(coefficient),
12800
13252
  variable: varRef,
@@ -12814,7 +13266,7 @@ function compileLinearExpression(expression, varRefs, nextVar) {
12814
13266
  for (let i = 1; i < termResults.length; i++) {
12815
13267
  const sumVar = { name: nextVar() };
12816
13268
  antecedents.push({
12817
- sort_name: "real_plus_constraint",
13269
+ sortName: "real_plus_constraint",
12818
13270
  features: {
12819
13271
  left: current,
12820
13272
  right: termResults[i],
@@ -12903,29 +13355,30 @@ var OptimizeClient = class {
12903
13355
  const sortResponse = await this.sortsApi.bulkCreateSorts({
12904
13356
  sorts: [{ name: solutionSortName, parents: ["thing"] }]
12905
13357
  });
12906
- sortId = sortResponse.data.sort_ids[solutionSortName];
13358
+ const sortIdsMap = sortResponse.data.sortIds;
13359
+ sortId = Object.values(sortIdsMap)[0];
12907
13360
  const ruleResponse = await this.inferenceApi.addRule({
12908
13361
  term: compiled.solutionTerm,
12909
13362
  antecedents: compiled.antecedents,
12910
13363
  certainty: 1
12911
13364
  });
12912
- ruleTermId = ruleResponse.data.term.term_id;
13365
+ ruleTermId = ruleResponse.data.term.termId;
12913
13366
  const bcResponse = await this.inferenceApi.backwardChain({
12914
- goal: { sort_name: solutionSortName },
12915
- max_solutions: 1,
12916
- max_depth: maxDepth,
12917
- timeout_ms: timeoutMs
13367
+ goal: { sortName: solutionSortName },
13368
+ maxSolutions: 1,
13369
+ maxDepth,
13370
+ timeoutMs
12918
13371
  });
12919
- const queryTimeMs = bcResponse.data.query_time_ms;
13372
+ const queryTimeMs = bcResponse.data.queryTimeMs;
12920
13373
  if (bcResponse.data.solutions.length === 0) {
12921
13374
  return { status: "infeasible", solveTimeMs: queryTimeMs };
12922
13375
  }
12923
13376
  const solution = bcResponse.data.solutions[0];
12924
13377
  const variables = {};
12925
13378
  for (const binding of solution.substitution.bindings) {
12926
- const varName = binding.variable_name;
13379
+ const varName = binding.variableName;
12927
13380
  if (!varName) continue;
12928
- const value = parseFloat(binding.bound_to_display);
13381
+ const value = parseFloat(binding.boundToDisplay);
12929
13382
  if (isNaN(value)) continue;
12930
13383
  if (varName.startsWith("?") && !varName.startsWith("?_lp_")) {
12931
13384
  variables[varName.slice(1)] = value;
@@ -12988,7 +13441,7 @@ var OptimizeClient = class {
12988
13441
  async fromKnowledgeBase(config, options) {
12989
13442
  const sortId = await this.resolveSortName(config.variables.sort);
12990
13443
  const queryResponse = await this.queryApi.findBySort({
12991
- sort_id: sortId
13444
+ sortId
12992
13445
  });
12993
13446
  const terms = queryResponse.data.terms;
12994
13447
  if (terms.length === 0) {
@@ -13197,6 +13650,121 @@ var ReasoningLayerClient = class {
13197
13650
  rag;
13198
13651
  /** Linear program optimization (CLP(Q) simplex solver via backward chaining). */
13199
13652
  optimize;
13653
+ // ─── Group Caches ─────────────────────────────────────────────────
13654
+ _core;
13655
+ _ai;
13656
+ _reasoning;
13657
+ _analysis;
13658
+ _data;
13659
+ _workflow;
13660
+ _system;
13661
+ // ─── Friendly Aliases ─────────────────────────────────────────────
13662
+ /**
13663
+ * Type hierarchy operations.
13664
+ * Alias for {@link sorts} — "sort" is domain jargon for "type" in order-sorted algebras.
13665
+ */
13666
+ get types() {
13667
+ return this.sorts;
13668
+ }
13669
+ /**
13670
+ * Record CRUD operations.
13671
+ * Alias for {@link terms} — "term" is logic programming jargon for a data record.
13672
+ */
13673
+ get records() {
13674
+ return this.terms;
13675
+ }
13676
+ /**
13677
+ * Rule and fact operations (backward/forward chaining, fuzzy, Bayesian, NAF).
13678
+ * Alias for {@link inference}.
13679
+ */
13680
+ get rules() {
13681
+ return this.inference;
13682
+ }
13683
+ /**
13684
+ * Cognitive agent operations (BDI cycle, beliefs, goals, messaging).
13685
+ * Alias for {@link cognitive}.
13686
+ */
13687
+ get agents() {
13688
+ return this.cognitive;
13689
+ }
13690
+ // ─── Domain Groups ───────────────────────────────────────────────
13691
+ /** Core knowledge base operations — types, records, rules, functions, constraints, and queries. */
13692
+ get core() {
13693
+ return this._core ??= {
13694
+ types: this.sorts,
13695
+ records: this.terms,
13696
+ rules: this.inference,
13697
+ functions: this.functions,
13698
+ constraints: this.constraints,
13699
+ query: this.query
13700
+ };
13701
+ }
13702
+ /** AI and machine learning operations — agents, oversight, neuro-symbolic, RAG, generation. */
13703
+ get ai() {
13704
+ return this._ai ??= {
13705
+ agents: this.cognitive,
13706
+ oversight: this.oversight,
13707
+ neuroSymbolic: this.neuroSymbolic,
13708
+ rag: this.rag,
13709
+ generation: this.generation,
13710
+ synthetic: this.synthetic,
13711
+ proofEngine: this.proofEngine
13712
+ };
13713
+ }
13714
+ /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery. */
13715
+ get reasoningOps() {
13716
+ return this._reasoning ??= {
13717
+ optimize: this.optimize,
13718
+ ilp: this.ilp,
13719
+ cdl: this.cdl,
13720
+ execution: this.execution,
13721
+ reasoning: this.reasoning,
13722
+ preferences: this.preferences,
13723
+ discovery: this.discovery
13724
+ };
13725
+ }
13726
+ /** Analysis operations — causal, statistical, fuzzy, scenarios, communities, visualization. */
13727
+ get analysisOps() {
13728
+ return this._analysis ??= {
13729
+ causal: this.causal,
13730
+ statistical: this.statistical,
13731
+ fuzzy: this.fuzzy,
13732
+ scenarios: this.scenarios,
13733
+ communities: this.communities,
13734
+ visualization: this.visualization
13735
+ };
13736
+ }
13737
+ /** Data ingestion and extraction operations — documents, sources, collections, images. */
13738
+ get data() {
13739
+ return this._data ??= {
13740
+ ingestion: this.ingestion,
13741
+ extraction: this.extract,
13742
+ sources: this.sources,
13743
+ collections: this.collections,
13744
+ imageExtraction: this.imageExtraction,
13745
+ row: this.row
13746
+ };
13747
+ }
13748
+ /** Workflow operations — control flow, reviews, action reviews, webhooks. */
13749
+ get workflow() {
13750
+ return this._workflow ??= {
13751
+ control: this.control,
13752
+ reviews: this.reviews,
13753
+ actionReviews: this.actionReviews,
13754
+ webhookActions: this.webhookActions
13755
+ };
13756
+ }
13757
+ /** System administration — health, admin, spaces, namespaces, utilities, ontology. */
13758
+ get system() {
13759
+ return this._system ??= {
13760
+ health: this.health,
13761
+ admin: this.admin,
13762
+ spaces: this.spaces,
13763
+ namespaces: this.namespaces,
13764
+ utilities: this.utilities,
13765
+ ontology: this.ontology
13766
+ };
13767
+ }
13200
13768
  /**
13201
13769
  * Create a new ReasoningLayerClient.
13202
13770
  *
@@ -13303,100 +13871,146 @@ var ReasoningLayerClient = class {
13303
13871
  }
13304
13872
  };
13305
13873
 
13306
- // src/builders/value.ts
13307
- var Value = {
13308
- /**
13309
- * Create a string value.
13310
- *
13311
- * @param s - The string value.
13312
- * @returns A tagged `StringValue`: `{"type": "String", "value": "hello"}`.
13313
- *
13314
- * @remarks
13315
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13316
- * Do NOT use with homoiconic inference endpoints.
13317
- *
13318
- * @example
13319
- * ```typescript
13320
- * Value.string("Alice") // {"type": "String", "value": "Alice"}
13321
- * ```
13322
- */
13323
- string(s) {
13324
- return { type: "String", value: s };
13325
- },
13326
- /**
13327
- * Create an integer value.
13328
- *
13329
- * @param n - The integer value (i64 on backend).
13330
- * @returns A tagged `IntegerValue`: `{"type": "Integer", "value": 42}`.
13331
- *
13332
- * @remarks
13333
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13334
- * Do NOT use with homoiconic inference endpoints.
13335
- *
13336
- * @example
13337
- * ```typescript
13338
- * Value.integer(42) // {"type": "Integer", "value": 42}
13339
- * ```
13340
- */
13341
- integer(n) {
13342
- return { type: "Integer", value: n };
13343
- },
13344
- /**
13345
- * Create a real (floating-point) value.
13346
- *
13347
- * @param n - The real value (f64 on backend).
13348
- * @returns A tagged `RealValue`: `{"type": "Real", "value": 3.14}`.
13349
- *
13350
- * @remarks
13351
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13352
- * Do NOT use with homoiconic inference endpoints.
13353
- *
13354
- * @example
13355
- * ```typescript
13356
- * Value.real(3.14) // {"type": "Real", "value": 3.14}
13357
- * ```
13358
- */
13359
- real(n) {
13360
- return { type: "Real", value: n };
13361
- },
13362
- /**
13363
- * Create a boolean value.
13364
- *
13365
- * @param b - The boolean value.
13366
- * @returns A tagged `BooleanValue`: `{"type": "Boolean", "value": true}`.
13367
- *
13368
- * @remarks
13369
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13370
- * Do NOT use with homoiconic inference endpoints.
13371
- *
13372
- * @example
13373
- * ```typescript
13374
- * Value.boolean(true) // {"type": "Boolean", "value": true}
13375
- * ```
13376
- */
13377
- boolean(b) {
13378
- return { type: "Boolean", value: b };
13379
- },
13380
- /**
13381
- * Create an uninstantiated (unknown) value.
13382
- *
13383
- * @returns A tagged `UninstantiatedValue`: `{"type": "Uninstantiated"}`.
13384
- *
13385
- * @remarks
13386
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13387
- * Do NOT use with homoiconic inference endpoints.
13388
- *
13389
- * Represents a feature whose value has not yet been determined.
13390
- * In the untagged format, this corresponds to `null`.
13391
- *
13392
- * @example
13393
- * ```typescript
13394
- * Value.uninstantiated() // {"type": "Uninstantiated"}
13395
- * ```
13396
- */
13397
- uninstantiated() {
13398
- return { type: "Uninstantiated" };
13399
- },
13874
+ // src/types/sorts.ts
13875
+ var sorts_exports = {};
13876
+
13877
+ // src/types/terms.ts
13878
+ var terms_exports = {};
13879
+
13880
+ // src/types/inference.ts
13881
+ var inference_exports = {};
13882
+
13883
+ // src/types/cognitive.ts
13884
+ var cognitive_exports = {};
13885
+
13886
+ // src/types/causal.ts
13887
+ var causal_exports = {};
13888
+
13889
+ // src/types/fuzzy.ts
13890
+ var fuzzy_exports = {};
13891
+
13892
+ // src/types/constraints.ts
13893
+ var constraints_exports = {};
13894
+
13895
+ // src/types/query.ts
13896
+ var query_exports = {};
13897
+
13898
+ // src/types/values.ts
13899
+ var values_exports = {};
13900
+
13901
+ // src/types/homoiconic.ts
13902
+ var homoiconic_exports = {};
13903
+
13904
+ // src/types/execution.ts
13905
+ var execution_exports = {};
13906
+
13907
+ // src/types/control.ts
13908
+ var control_exports = {};
13909
+
13910
+ // src/types/spaces.ts
13911
+ var spaces_exports = {};
13912
+
13913
+ // src/types/row.ts
13914
+ var row_exports = {};
13915
+
13916
+ // src/types/namespaces.ts
13917
+ var namespaces_exports = {};
13918
+
13919
+ // src/types/collections.ts
13920
+ var collections_exports = {};
13921
+
13922
+ // src/types/visualization.ts
13923
+ var visualization_exports = {};
13924
+
13925
+ // src/types/statistical.ts
13926
+ var statistical_exports = {};
13927
+
13928
+ // src/types/reasoning.ts
13929
+ var reasoning_exports = {};
13930
+
13931
+ // src/types/ingestion.ts
13932
+ var ingestion_exports = {};
13933
+
13934
+ // src/types/reviews.ts
13935
+ var reviews_exports = {};
13936
+
13937
+ // src/types/sources.ts
13938
+ var sources_exports = {};
13939
+
13940
+ // src/types/communities.ts
13941
+ var communities_exports = {};
13942
+
13943
+ // src/types/utilities.ts
13944
+ var utilities_exports = {};
13945
+
13946
+ // src/types/scenarios.ts
13947
+ var scenarios_exports = {};
13948
+
13949
+ // src/types/action-reviews.ts
13950
+ var action_reviews_exports = {};
13951
+
13952
+ // src/types/discovery.ts
13953
+ var discovery_exports = {};
13954
+
13955
+ // src/types/extract.ts
13956
+ var extract_exports = {};
13957
+
13958
+ // src/types/oversight.ts
13959
+ var oversight_exports = {};
13960
+
13961
+ // src/types/cdl.ts
13962
+ var cdl_exports = {};
13963
+
13964
+ // src/types/neuro-symbolic.ts
13965
+ var neuro_symbolic_exports = {};
13966
+
13967
+ // src/types/analysis.ts
13968
+ var analysis_exports = {};
13969
+
13970
+ // src/types/preferences.ts
13971
+ var preferences_exports = {};
13972
+
13973
+ // src/types/functions.ts
13974
+ var functions_exports = {};
13975
+
13976
+ // src/types/webhook-actions.ts
13977
+ var webhook_actions_exports = {};
13978
+
13979
+ // src/types/proof-engine.ts
13980
+ var proof_engine_exports = {};
13981
+
13982
+ // src/types/synthetic.ts
13983
+ var synthetic_exports = {};
13984
+
13985
+ // src/types/health.ts
13986
+ var health_exports = {};
13987
+
13988
+ // src/types/admin.ts
13989
+ var admin_exports = {};
13990
+
13991
+ // src/types/image-extraction.ts
13992
+ var image_extraction_exports = {};
13993
+
13994
+ // src/types/ontology.ts
13995
+ var ontology_exports = {};
13996
+
13997
+ // src/types/generation.ts
13998
+ var generation_exports = {};
13999
+
14000
+ // src/types/rag.ts
14001
+ var rag_exports = {};
14002
+
14003
+ // src/types/optimize.ts
14004
+ var optimize_exports = {};
14005
+
14006
+ // src/types/ilp.ts
14007
+ var ilp_exports = {};
14008
+
14009
+ // src/types/plain-values.ts
14010
+ var plain_values_exports = {};
14011
+
14012
+ // src/builders/value.ts
14013
+ var Value = {
13400
14014
  /**
13401
14015
  * Create a reference to another term by UUID.
13402
14016
  *
@@ -13405,7 +14019,6 @@ var Value = {
13405
14019
  *
13406
14020
  * @remarks
13407
14021
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13408
- * Do NOT use with homoiconic inference endpoints.
13409
14022
  *
13410
14023
  * @example
13411
14024
  * ```typescript
@@ -13415,24 +14028,6 @@ var Value = {
13415
14028
  reference(id) {
13416
14029
  return { type: "Reference", value: id };
13417
14030
  },
13418
- /**
13419
- * Create a list of values.
13420
- *
13421
- * @param items - The list items as `ValueDto` values.
13422
- * @returns A tagged `ListValue`: `{"type": "List", "value": [...]}`.
13423
- *
13424
- * @remarks
13425
- * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13426
- * Do NOT use with homoiconic inference endpoints.
13427
- *
13428
- * @example
13429
- * ```typescript
13430
- * Value.list([Value.integer(1), Value.integer(2), Value.integer(3)])
13431
- * ```
13432
- */
13433
- list(items) {
13434
- return { type: "List", value: items };
13435
- },
13436
14031
  /**
13437
14032
  * Create a fuzzy scalar with a value and membership degree.
13438
14033
  *
@@ -13442,7 +14037,6 @@ var Value = {
13442
14037
  *
13443
14038
  * @remarks
13444
14039
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13445
- * Do NOT use with homoiconic inference endpoints.
13446
14040
  *
13447
14041
  * @example
13448
14042
  * ```typescript
@@ -13460,7 +14054,6 @@ var Value = {
13460
14054
  *
13461
14055
  * @remarks
13462
14056
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13463
- * Do NOT use with homoiconic inference endpoints.
13464
14057
  *
13465
14058
  * Note: The `FuzzyShapeDto` uses `"kind"` as its discriminator, NOT `"type"`.
13466
14059
  *
@@ -13483,7 +14076,6 @@ var Value = {
13483
14076
  *
13484
14077
  * @remarks
13485
14078
  * Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
13486
- * Do NOT use with homoiconic inference endpoints.
13487
14079
  *
13488
14080
  * Represents partial information about set membership using Smyth powerdomain semantics.
13489
14081
  *
@@ -13498,7 +14090,7 @@ var Value = {
13498
14090
  value: {
13499
14091
  lower,
13500
14092
  upper,
13501
- sort_constraint: sortConstraint ?? null
14093
+ sortConstraint: sortConstraint ?? null
13502
14094
  }
13503
14095
  };
13504
14096
  }
@@ -13514,12 +14106,10 @@ var FuzzyShape = {
13514
14106
  *
13515
14107
  * @remarks
13516
14108
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13517
- * The discriminator field is `"kind"`, NOT `"type"`.
13518
14109
  *
13519
14110
  * @example
13520
14111
  * ```typescript
13521
14112
  * FuzzyShape.triangular(20, 22, 24)
13522
- * // {"kind": "Triangular", "a": 20, "b": 22, "c": 24}
13523
14113
  * ```
13524
14114
  */
13525
14115
  triangular(a, b, c) {
@@ -13532,16 +14122,14 @@ var FuzzyShape = {
13532
14122
  * @param b - Left shoulder (membership reaches 1).
13533
14123
  * @param c - Right shoulder (membership starts falling from 1).
13534
14124
  * @param d - Right foot (membership returns to 0).
13535
- * @returns A `TrapezoidalShape`: `{"kind": "Trapezoidal", "a": 18, "b": 20, "c": 24, "d": 26}`.
14125
+ * @returns A `TrapezoidalShape`.
13536
14126
  *
13537
14127
  * @remarks
13538
14128
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13539
- * The discriminator field is `"kind"`, NOT `"type"`.
13540
14129
  *
13541
14130
  * @example
13542
14131
  * ```typescript
13543
14132
  * FuzzyShape.trapezoidal(18, 20, 24, 26)
13544
- * // {"kind": "Trapezoidal", "a": 18, "b": 20, "c": 24, "d": 26}
13545
14133
  * ```
13546
14134
  */
13547
14135
  trapezoidal(a, b, c, d) {
@@ -13552,20 +14140,18 @@ var FuzzyShape = {
13552
14140
  *
13553
14141
  * @param mean - Center of the Gaussian curve (membership = 1).
13554
14142
  * @param stdDev - Standard deviation controlling width.
13555
- * @returns A `GaussianShape`: `{"kind": "Gaussian", "mean": 100, "std_dev": 15}`.
14143
+ * @returns A `GaussianShape`.
13556
14144
  *
13557
14145
  * @remarks
13558
14146
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13559
- * The discriminator field is `"kind"`, NOT `"type"`.
13560
14147
  *
13561
14148
  * @example
13562
14149
  * ```typescript
13563
14150
  * FuzzyShape.gaussian(100, 15)
13564
- * // {"kind": "Gaussian", "mean": 100, "std_dev": 15}
13565
14151
  * ```
13566
14152
  */
13567
14153
  gaussian(mean, stdDev) {
13568
- return { kind: "Gaussian", mean, std_dev: stdDev };
14154
+ return { kind: "Gaussian", mean, stdDev };
13569
14155
  },
13570
14156
  /**
13571
14157
  * Create a cyclic Gaussian fuzzy membership function with periodic wrapping.
@@ -13573,323 +14159,25 @@ var FuzzyShape = {
13573
14159
  * @param mean - Center of the Gaussian curve.
13574
14160
  * @param stdDev - Standard deviation controlling width.
13575
14161
  * @param period - Period of the cyclic wrapping (e.g., 360 for degrees).
13576
- * @returns A `CyclicGaussianShape`: `{"kind": "CyclicGaussian", "mean": 180, "std_dev": 30, "period": 360}`.
14162
+ * @returns A `CyclicGaussianShape`.
13577
14163
  *
13578
14164
  * @remarks
13579
14165
  * Serialization format: Tagged by `"kind"` (FuzzyShapeDto).
13580
- * The discriminator field is `"kind"`, NOT `"type"`.
13581
14166
  *
13582
14167
  * @example
13583
14168
  * ```typescript
13584
14169
  * FuzzyShape.cyclicGaussian(180, 30, 360)
13585
- * // {"kind": "CyclicGaussian", "mean": 180, "std_dev": 30, "period": 360}
13586
14170
  * ```
13587
14171
  */
13588
14172
  cyclicGaussian(mean, stdDev, period) {
13589
- return { kind: "CyclicGaussian", mean, std_dev: stdDev, period };
13590
- }
13591
- };
13592
-
13593
- // src/builders/feature-input.ts
13594
- var FeatureInput = {
13595
- /**
13596
- * Create an untagged string value.
13597
- *
13598
- * @param s - The string value.
13599
- * @returns The raw string: `"hello"`.
13600
- *
13601
- * @remarks
13602
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13603
- * Do NOT use with term CRUD endpoints.
13604
- *
13605
- * @example
13606
- * ```typescript
13607
- * FeatureInput.string("Alice") // "Alice"
13608
- * ```
13609
- */
13610
- string(s) {
13611
- return s;
13612
- },
13613
- /**
13614
- * Create an untagged integer value.
13615
- *
13616
- * @param n - The integer value.
13617
- * @returns The raw number: `42`.
13618
- *
13619
- * @remarks
13620
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13621
- * Do NOT use with term CRUD endpoints.
13622
- *
13623
- * The backend distinguishes integers from reals. Use `FeatureInput.real()` for floating-point.
13624
- *
13625
- * @example
13626
- * ```typescript
13627
- * FeatureInput.integer(42) // 42
13628
- * ```
13629
- */
13630
- integer(n) {
13631
- return n;
13632
- },
13633
- /**
13634
- * Create an untagged real (floating-point) value.
13635
- *
13636
- * @param n - The real value.
13637
- * @returns The raw number: `3.14`.
13638
- *
13639
- * @remarks
13640
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13641
- * Do NOT use with term CRUD endpoints.
13642
- *
13643
- * The backend distinguishes integers from reals. Use `FeatureInput.integer()` for whole numbers.
13644
- *
13645
- * @example
13646
- * ```typescript
13647
- * FeatureInput.real(3.14) // 3.14
13648
- * ```
13649
- */
13650
- real(n) {
13651
- return n;
13652
- },
13653
- /**
13654
- * Create an untagged boolean value.
13655
- *
13656
- * @param b - The boolean value.
13657
- * @returns The raw boolean: `true` or `false`.
13658
- *
13659
- * @remarks
13660
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13661
- * Do NOT use with term CRUD endpoints.
13662
- *
13663
- * @example
13664
- * ```typescript
13665
- * FeatureInput.boolean(true) // true
13666
- * ```
13667
- */
13668
- boolean(b) {
13669
- return b;
13670
- },
13671
- /**
13672
- * Create an untagged null value representing an uninstantiated feature.
13673
- *
13674
- * @returns `null`.
13675
- *
13676
- * @remarks
13677
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13678
- * Do NOT use with term CRUD endpoints.
13679
- *
13680
- * Equivalent to `Value.uninstantiated()` in the tagged format.
13681
- *
13682
- * @example
13683
- * ```typescript
13684
- * FeatureInput.uninstantiated() // null
13685
- * ```
13686
- */
13687
- uninstantiated() {
13688
- return null;
13689
- },
13690
- /**
13691
- * Create a reference to an existing term by UUID.
13692
- *
13693
- * @param termId - The UUID of the referenced term.
13694
- * @returns An object: `{term_id: "uuid"}`.
13695
- *
13696
- * @remarks
13697
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13698
- * Do NOT use with term CRUD endpoints.
13699
- *
13700
- * @example
13701
- * ```typescript
13702
- * FeatureInput.ref("550e8400-e29b-41d4-a716-446655440000")
13703
- * // {term_id: "550e8400-e29b-41d4-a716-446655440000"}
13704
- * ```
13705
- */
13706
- ref(termId) {
13707
- return { term_id: termId };
13708
- },
13709
- /**
13710
- * Create an unconstrained variable.
13711
- *
13712
- * @param name - Variable name (conventionally prefixed with `?`, e.g., `"?X"`).
13713
- * @returns An object: `{name: "?X"}`.
13714
- *
13715
- * @remarks
13716
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13717
- * Do NOT use with term CRUD endpoints.
13718
- *
13719
- * For constrained variables, use {@link FeatureInput.constrainedVar} instead.
13720
- *
13721
- * @example
13722
- * ```typescript
13723
- * FeatureInput.variable("?X") // {name: "?X"}
13724
- * ```
13725
- */
13726
- variable(name) {
13727
- return { name };
13728
- },
13729
- /**
13730
- * Create a constrained variable with a constraint as a `TermInputDto`.
13731
- *
13732
- * @param name - Variable name (conventionally prefixed with `?`, e.g., `"?Salary"`).
13733
- * @param constraint - The constraint as a `TermInputDto` (typically a guard sort).
13734
- * @returns An object: `{name: "?Salary", constraint: {...}}`.
13735
- *
13736
- * @remarks
13737
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13738
- * Do NOT use with term CRUD endpoints.
13739
- *
13740
- * The most common constraint is a guard, which can be created with the `guard()` builder:
13741
- * ```typescript
13742
- * FeatureInput.constrainedVar("?Salary", guard("gt", 100))
13743
- * ```
13744
- *
13745
- * **Critical ordering note**: `ConstrainedVariable` (with `name` + `constraint`) must serialize
13746
- * before `Variable` (with only `name`) in the Rust `serde(untagged)` deserialization order.
13747
- * The builder ensures the `constraint` field is always present.
13748
- *
13749
- * @example
13750
- * ```typescript
13751
- * FeatureInput.constrainedVar("?Salary", guard("gt", 100))
13752
- * // {name: "?Salary", constraint: {sort_name: "guard_constraint", features: {op: "gt", right: 100}}}
13753
- * ```
13754
- */
13755
- constrainedVar(name, constraint) {
13756
- return { name, constraint };
13757
- },
13758
- /**
13759
- * Create an inline term by sort UUID in a feature value position.
13760
- *
13761
- * @param sortId - The sort UUID.
13762
- * @param features - Optional features for the inline term.
13763
- * @returns An object: `{sort_id: "uuid", features: {...}}`.
13764
- *
13765
- * @remarks
13766
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13767
- * Do NOT use with term CRUD endpoints.
13768
- *
13769
- * @example
13770
- * ```typescript
13771
- * FeatureInput.inlineTerm("sort-uuid", { name: FeatureInput.string("Alice") })
13772
- * ```
13773
- */
13774
- inlineTerm(sortId, features) {
13775
- return features !== void 0 ? { sort_id: sortId, features } : { sort_id: sortId };
13776
- },
13777
- /**
13778
- * Create an inline term by sort name in a feature value position.
13779
- *
13780
- * @param sortName - The sort name (resolved server-side).
13781
- * @param features - Optional features for the inline term.
13782
- * @returns An object: `{sort_name: "person", features: {...}}`.
13783
- *
13784
- * @remarks
13785
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13786
- * Do NOT use with term CRUD endpoints.
13787
- *
13788
- * @example
13789
- * ```typescript
13790
- * FeatureInput.inlineTermByName("person", { name: FeatureInput.string("Alice") })
13791
- * ```
13792
- */
13793
- inlineTermByName(sortName, features) {
13794
- return features !== void 0 ? { sort_name: sortName, features } : { sort_name: sortName };
13795
- },
13796
- /**
13797
- * Create a list of feature input values.
13798
- *
13799
- * @param items - The list items as `FeatureInputValueDto` values.
13800
- * @returns A raw JSON array: `[...]`.
13801
- *
13802
- * @remarks
13803
- * Serialization format: Untagged (FeatureInputValueDto). Use with homoiconic inference endpoints.
13804
- * Do NOT use with term CRUD endpoints.
13805
- *
13806
- * @example
13807
- * ```typescript
13808
- * FeatureInput.list([FeatureInput.string("a"), FeatureInput.string("b")])
13809
- * // ["a", "b"]
13810
- * ```
13811
- */
13812
- list(items) {
13813
- return items;
13814
- }
13815
- };
13816
-
13817
- // src/builders/term-input.ts
13818
- var TermInput = {
13819
- /**
13820
- * Reference an existing term by UUID.
13821
- *
13822
- * @param termId - The UUID of the existing term.
13823
- * @returns A reference input: `{term_id: "uuid"}`.
13824
- *
13825
- * @remarks
13826
- * Serialization format: Untagged (TermInputDto). Use as top-level goal or rule head/body
13827
- * in inference requests.
13828
- *
13829
- * @example
13830
- * ```typescript
13831
- * TermInput.ref("550e8400-e29b-41d4-a716-446655440000")
13832
- * // {term_id: "550e8400-e29b-41d4-a716-446655440000"}
13833
- * ```
13834
- */
13835
- ref(termId) {
13836
- return { term_id: termId };
13837
- },
13838
- /**
13839
- * Define a term inline using a sort UUID and features.
13840
- *
13841
- * @param sortId - The sort UUID.
13842
- * @param features - Feature map with `FeatureInputValueDto` values.
13843
- * @returns An inline input: `{sort_id: "uuid", features: {...}}`.
13844
- *
13845
- * @remarks
13846
- * Serialization format: Untagged (TermInputDto). Use as top-level goal or rule head/body
13847
- * in inference requests.
13848
- *
13849
- * The `features` field is required for the sort_id variant per the backend schema.
13850
- *
13851
- * @example
13852
- * ```typescript
13853
- * TermInput.byId("sort-uuid", {
13854
- * name: FeatureInput.string("Alice"),
13855
- * })
13856
- * ```
13857
- */
13858
- byId(sortId, features) {
13859
- return { sort_id: sortId, features };
13860
- },
13861
- /**
13862
- * Define a term inline using a sort name and optional features.
13863
- *
13864
- * @param sortName - The sort name (resolved server-side to a sort UUID).
13865
- * @param features - Optional feature map with `FeatureInputValueDto` values.
13866
- * @returns An inline input: `{sort_name: "person", features: {...}}`.
13867
- *
13868
- * @remarks
13869
- * Serialization format: Untagged (TermInputDto). Use as top-level goal or rule head/body
13870
- * in inference requests.
13871
- *
13872
- * Sort name resolution happens server-side. The name must match an existing sort
13873
- * in the tenant's sort hierarchy.
13874
- *
13875
- * @example
13876
- * ```typescript
13877
- * TermInput.byName("person", {
13878
- * name: FeatureInput.string("Alice"),
13879
- * age: FeatureInput.integer(30),
13880
- * })
13881
- * // {sort_name: "person", features: {name: "Alice", age: 30}}
13882
- * ```
13883
- */
13884
- byName(sortName, features) {
13885
- return features !== void 0 ? { sort_name: sortName, features } : { sort_name: sortName };
14173
+ return { kind: "CyclicGaussian", mean, stdDev, period };
13886
14174
  }
13887
14175
  };
13888
14176
 
13889
14177
  // src/builders/guard.ts
13890
14178
  function guard(op, right) {
13891
14179
  return {
13892
- sort_name: "guard_constraint",
14180
+ sortName: "guard_constraint",
13893
14181
  features: { op, right }
13894
14182
  };
13895
14183
  }
@@ -14002,7 +14290,7 @@ var SortBuilder = class _SortBuilder {
14002
14290
  * builder.boundConstraint({
14003
14291
  * constraint_type: "upper",
14004
14292
  * target: "end_date",
14005
- * source_path: "company.dissolution_date",
14293
+ * source_path: "company.dissolutionDate",
14006
14294
  * })
14007
14295
  * ```
14008
14296
  */
@@ -14054,7 +14342,7 @@ var SortBuilder = class _SortBuilder {
14054
14342
  request.features = this._features;
14055
14343
  }
14056
14344
  if (this._boundConstraints.length > 0) {
14057
- request.bound_constraints = this._boundConstraints;
14345
+ request.boundConstraints = this._boundConstraints;
14058
14346
  }
14059
14347
  if (this._description !== null) {
14060
14348
  request.description = this._description;
@@ -14064,80 +14352,26 @@ var SortBuilder = class _SortBuilder {
14064
14352
  };
14065
14353
 
14066
14354
  // src/builders/psi.ts
14067
- function isPlainObject(v) {
14068
- return typeof v === "object" && v !== null && !Array.isArray(v);
14069
- }
14070
- function coerceObjectFeatures(obj) {
14071
- const rawFeatures = obj.features;
14072
- if (!isPlainObject(rawFeatures)) {
14073
- return void 0;
14074
- }
14075
- const coerced = {};
14076
- for (const [k, v] of Object.entries(rawFeatures)) {
14077
- coerced[k] = coerceFeatureValue(v);
14078
- }
14079
- return coerced;
14080
- }
14081
- function coerceFeatureValue(value) {
14082
- if (value === null) {
14083
- throw new ValidationError("null is not a valid feature value in psi() shorthand. Use FeatureInput.uninstantiated() for null values.");
14084
- }
14085
- if (typeof value === "string") {
14086
- return value;
14087
- }
14088
- if (typeof value === "number") {
14089
- return value;
14090
- }
14091
- if (typeof value === "boolean") {
14092
- return value;
14093
- }
14094
- if (Array.isArray(value)) {
14095
- return value.map(coerceFeatureValue);
14096
- }
14097
- if (isPlainObject(value)) {
14098
- if ("term_id" in value && typeof value.term_id === "string") {
14099
- return { term_id: value.term_id };
14100
- }
14101
- if ("name" in value && typeof value.name === "string" && "constraint" in value) {
14102
- return { name: value.name, constraint: value.constraint };
14103
- }
14104
- if ("name" in value && typeof value.name === "string") {
14105
- return { name: value.name };
14106
- }
14107
- if ("sort_name" in value && typeof value.sort_name === "string") {
14108
- const features = coerceObjectFeatures(value);
14109
- if (features) {
14110
- return { sort_name: value.sort_name, features };
14111
- }
14112
- return { sort_name: value.sort_name };
14113
- }
14114
- if ("sort_id" in value && typeof value.sort_id === "string") {
14115
- const features = coerceObjectFeatures(value);
14116
- if (features) {
14117
- return { sort_id: value.sort_id, features };
14118
- }
14119
- return { sort_id: value.sort_id };
14120
- }
14121
- }
14122
- throw new ValidationError(`Cannot coerce value of type ${typeof value} to FeatureInputValueDto`);
14123
- }
14124
14355
  function psi(sortName, features) {
14125
14356
  if (!features) {
14126
- return { sort_name: sortName };
14127
- }
14128
- const coerced = {};
14129
- for (const [key, value] of Object.entries(features)) {
14130
- coerced[key] = coerceFeatureValue(value);
14357
+ return { __psiTerm: true, sortName };
14131
14358
  }
14132
- return { sort_name: sortName, features: coerced };
14359
+ return {
14360
+ __psiTerm: true,
14361
+ sortName,
14362
+ features
14363
+ };
14364
+ }
14365
+ function constrained(name, constraint) {
14366
+ return { __constrainedVar: true, name, constraint };
14133
14367
  }
14134
14368
 
14135
14369
  // src/builders/allen.ts
14136
14370
  function allen(relation, intervalA, intervalBTermId) {
14137
14371
  return {
14138
14372
  type: "Allen",
14139
- interval_a: intervalA,
14140
- interval_b_term_id: intervalBTermId,
14373
+ intervalA,
14374
+ intervalBTermId,
14141
14375
  relation
14142
14376
  };
14143
14377
  }
@@ -14168,30 +14402,85 @@ function discriminateFeatureValue(value) {
14168
14402
  );
14169
14403
  }
14170
14404
 
14405
+ exports.ActionReviews = action_reviews_exports;
14406
+ exports.Admin = admin_exports;
14407
+ exports.Analysis = analysis_exports;
14171
14408
  exports.ApiError = ApiError;
14409
+ exports.AuthenticationError = AuthenticationError;
14172
14410
  exports.BadRequestError = BadRequestError;
14411
+ exports.CDL = cdl_exports;
14412
+ exports.Causal = causal_exports;
14413
+ exports.Cognitive = cognitive_exports;
14414
+ exports.Collections = collections_exports;
14415
+ exports.Communities = communities_exports;
14173
14416
  exports.ConstraintViolationError = ConstraintViolationError;
14174
- exports.FeatureInput = FeatureInput;
14417
+ exports.Constraints = constraints_exports;
14418
+ exports.Control = control_exports;
14419
+ exports.Discovery = discovery_exports;
14420
+ exports.Execution = execution_exports;
14421
+ exports.Extract = extract_exports;
14422
+ exports.ForbiddenError = ForbiddenError;
14423
+ exports.Functions = functions_exports;
14424
+ exports.Fuzzy = fuzzy_exports;
14175
14425
  exports.FuzzyShape = FuzzyShape;
14426
+ exports.Generation = generation_exports;
14427
+ exports.Health = health_exports;
14428
+ exports.Homoiconic = homoiconic_exports;
14429
+ exports.ILP = ilp_exports;
14430
+ exports.ImageExtraction = image_extraction_exports;
14431
+ exports.Inference = inference_exports;
14432
+ exports.Ingestion = ingestion_exports;
14176
14433
  exports.InternalServerError = InternalServerError;
14177
14434
  exports.LP = LP;
14435
+ exports.Namespaces = namespaces_exports;
14178
14436
  exports.NetworkError = NetworkError;
14437
+ exports.NeuroSymbolic = neuro_symbolic_exports;
14179
14438
  exports.NotFoundError = NotFoundError;
14439
+ exports.Ontology = ontology_exports;
14440
+ exports.Optimize = optimize_exports;
14441
+ exports.Oversight = oversight_exports;
14442
+ exports.PlainValues = plain_values_exports;
14443
+ exports.Preferences = preferences_exports;
14444
+ exports.ProofEngine = proof_engine_exports;
14445
+ exports.Query = query_exports;
14446
+ exports.RAG = rag_exports;
14180
14447
  exports.RateLimitError = RateLimitError;
14448
+ exports.Reasoning = reasoning_exports;
14181
14449
  exports.ReasoningLayerClient = ReasoningLayerClient;
14182
14450
  exports.ReasoningLayerError = ReasoningLayerError;
14451
+ exports.Reviews = reviews_exports;
14452
+ exports.Row = row_exports;
14183
14453
  exports.SDK_VERSION = SDK_VERSION;
14454
+ exports.Scenarios = scenarios_exports;
14184
14455
  exports.SortBuilder = SortBuilder;
14185
- exports.TermInput = TermInput;
14456
+ exports.Sorts = sorts_exports;
14457
+ exports.Sources = sources_exports;
14458
+ exports.Spaces = spaces_exports;
14459
+ exports.Statistical = statistical_exports;
14460
+ exports.Synthetic = synthetic_exports;
14461
+ exports.Terms = terms_exports;
14186
14462
  exports.TimeoutError = TimeoutError;
14463
+ exports.Utilities = utilities_exports;
14187
14464
  exports.ValidationError = ValidationError;
14188
14465
  exports.Value = Value;
14466
+ exports.Values = values_exports;
14467
+ exports.Visualization = visualization_exports;
14189
14468
  exports.WebSocketClient = WebSocketClient;
14190
14469
  exports.WebSocketConnection = WebSocketConnection;
14470
+ exports.WebhookActions = webhook_actions_exports;
14191
14471
  exports.allen = allen;
14472
+ exports.constrained = constrained;
14192
14473
  exports.discriminateFeatureValue = discriminateFeatureValue;
14193
14474
  exports.guard = guard;
14475
+ exports.isConstrainedPlainVar = isConstrainedPlainVar;
14476
+ exports.isPsiTermInput = isPsiTermInput;
14477
+ exports.isTaggedValueDto = isTaggedValueDto;
14194
14478
  exports.isUuid = isUuid;
14195
14479
  exports.psi = psi;
14480
+ exports.toTaggedFeatures = toTaggedFeatures;
14481
+ exports.toTaggedValue = toTaggedValue;
14482
+ exports.toTermInputDto = toTermInputDto;
14483
+ exports.toUntaggedFeatures = toUntaggedFeatures;
14484
+ exports.toUntaggedValue = toUntaggedValue;
14196
14485
  //# sourceMappingURL=index.cjs.map
14197
14486
  //# sourceMappingURL=index.cjs.map