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