@kortexya/reasoninglayer 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -13
- package/dist/index.d.ts +70 -13
- package/dist/index.js +22 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -109,7 +109,7 @@ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | object;
|
|
|
109
109
|
* This is the single source of truth for the version constant.
|
|
110
110
|
* The `scripts/release.sh` script updates this value alongside `package.json`.
|
|
111
111
|
*/
|
|
112
|
-
declare const SDK_VERSION = "0.
|
|
112
|
+
declare const SDK_VERSION = "0.13.0";
|
|
113
113
|
/**
|
|
114
114
|
* Configuration for the Reasoning Layer client.
|
|
115
115
|
*
|
|
@@ -18582,14 +18582,50 @@ declare namespace homoiconic {
|
|
|
18582
18582
|
* await client.inference.addFact({ term: psi("person", { name: "Alice" }) });
|
|
18583
18583
|
* ```
|
|
18584
18584
|
*/
|
|
18585
|
-
|
|
18585
|
+
/**
|
|
18586
|
+
* A psi-term identified by sort name.
|
|
18587
|
+
*/
|
|
18588
|
+
interface PsiTermInputByName {
|
|
18586
18589
|
/** @internal Brand field to distinguish from plain objects. Stripped before serialization. */
|
|
18587
18590
|
readonly __psiTerm: true;
|
|
18588
|
-
/** Sort name for this term. */
|
|
18591
|
+
/** Sort name for this term (resolved server-side). */
|
|
18589
18592
|
readonly sortName: string;
|
|
18590
18593
|
/** Features using plain JavaScript values. */
|
|
18591
18594
|
readonly features?: PlainFeatureMap;
|
|
18592
18595
|
}
|
|
18596
|
+
/**
|
|
18597
|
+
* A psi-term identified by sort ID (UUID).
|
|
18598
|
+
*/
|
|
18599
|
+
interface PsiTermInputById {
|
|
18600
|
+
/** @internal Brand field to distinguish from plain objects. Stripped before serialization. */
|
|
18601
|
+
readonly __psiTerm: true;
|
|
18602
|
+
/** Sort ID (UUID) for this term. */
|
|
18603
|
+
readonly sortId: string;
|
|
18604
|
+
/** Features using plain JavaScript values. */
|
|
18605
|
+
readonly features?: PlainFeatureMap;
|
|
18606
|
+
}
|
|
18607
|
+
/**
|
|
18608
|
+
* A format-agnostic psi-term produced by the `psi()` builder.
|
|
18609
|
+
*
|
|
18610
|
+
* @remarks
|
|
18611
|
+
* Exactly one of `sortName` or `sortId` is present — enforced by the union type.
|
|
18612
|
+
* Can be passed to both term CRUD methods (converted to tagged `ValueDto` format)
|
|
18613
|
+
* and inference methods (converted to untagged `TermInputDto` format).
|
|
18614
|
+
* The SDK handles the conversion automatically based on which method receives it.
|
|
18615
|
+
*
|
|
18616
|
+
* Distinguished from plain objects by the `__psiTerm` brand field, which is
|
|
18617
|
+
* stripped before serialization.
|
|
18618
|
+
*
|
|
18619
|
+
* @example
|
|
18620
|
+
* ```typescript
|
|
18621
|
+
* // Works with term CRUD:
|
|
18622
|
+
* await client.terms.createTerm({ sortId, ownerId, features: { name: "Alice" } });
|
|
18623
|
+
*
|
|
18624
|
+
* // Works with inference:
|
|
18625
|
+
* await client.inference.addFact({ term: psi("person", { name: "Alice" }) });
|
|
18626
|
+
* ```
|
|
18627
|
+
*/
|
|
18628
|
+
type PsiTermInput = PsiTermInputByName | PsiTermInputById;
|
|
18593
18629
|
/**
|
|
18594
18630
|
* A constrained variable for use in inference contexts.
|
|
18595
18631
|
*
|
|
@@ -18662,9 +18698,11 @@ type plainValues_ConstrainedPlainVar = ConstrainedPlainVar;
|
|
|
18662
18698
|
type plainValues_PlainFeatureMap = PlainFeatureMap;
|
|
18663
18699
|
type plainValues_PlainFeatureValue = PlainFeatureValue;
|
|
18664
18700
|
type plainValues_PsiTermInput = PsiTermInput;
|
|
18701
|
+
type plainValues_PsiTermInputById = PsiTermInputById;
|
|
18702
|
+
type plainValues_PsiTermInputByName = PsiTermInputByName;
|
|
18665
18703
|
type plainValues_TermInputArg = TermInputArg;
|
|
18666
18704
|
declare namespace plainValues {
|
|
18667
|
-
export type { plainValues_ConstrainedPlainVar as ConstrainedPlainVar, plainValues_PlainFeatureMap as PlainFeatureMap, plainValues_PlainFeatureValue as PlainFeatureValue, plainValues_PsiTermInput as PsiTermInput, plainValues_TermInputArg as TermInputArg };
|
|
18705
|
+
export type { plainValues_ConstrainedPlainVar as ConstrainedPlainVar, plainValues_PlainFeatureMap as PlainFeatureMap, plainValues_PlainFeatureValue as PlainFeatureValue, plainValues_PsiTermInput as PsiTermInput, plainValues_PsiTermInputById as PsiTermInputById, plainValues_PsiTermInputByName as PsiTermInputByName, plainValues_TermInputArg as TermInputArg };
|
|
18668
18706
|
}
|
|
18669
18707
|
|
|
18670
18708
|
/**
|
|
@@ -40745,7 +40783,7 @@ declare class SortBuilder {
|
|
|
40745
40783
|
}
|
|
40746
40784
|
|
|
40747
40785
|
/**
|
|
40748
|
-
* Create a format-agnostic psi-term
|
|
40786
|
+
* Create a format-agnostic psi-term identified by sort name.
|
|
40749
40787
|
*
|
|
40750
40788
|
* @param sortName - The sort name (resolved server-side).
|
|
40751
40789
|
* @param features - Optional features map using plain JavaScript values.
|
|
@@ -40773,12 +40811,6 @@ declare class SortBuilder {
|
|
|
40773
40811
|
* // With variable (auto-detected "?" prefix):
|
|
40774
40812
|
* const query = psi("person", { name: "?Name", age: "?Age" });
|
|
40775
40813
|
*
|
|
40776
|
-
* // With constrained variable:
|
|
40777
|
-
* const eligible = psi("eligible", {
|
|
40778
|
-
* applicant: "?A",
|
|
40779
|
-
* score: constrained("?S", guard("gt", 700)),
|
|
40780
|
-
* });
|
|
40781
|
-
*
|
|
40782
40814
|
* // Nested psi-terms:
|
|
40783
40815
|
* const company = psi("company", {
|
|
40784
40816
|
* name: "Acme",
|
|
@@ -40791,10 +40823,35 @@ declare class SortBuilder {
|
|
|
40791
40823
|
* // Term reference (auto-detected "!" prefix):
|
|
40792
40824
|
* const withRef = psi("department", { manager: "!550e8400-..." });
|
|
40793
40825
|
* ```
|
|
40826
|
+
*/
|
|
40827
|
+
declare function psi(sortName: string, features?: Record<string, unknown>): PsiTermInputByName;
|
|
40828
|
+
/**
|
|
40829
|
+
* Create a format-agnostic psi-term identified by sort ID.
|
|
40794
40830
|
*
|
|
40795
|
-
* @
|
|
40831
|
+
* @param sort - Object with `sortId` (UUID).
|
|
40832
|
+
* @param features - Optional features map using plain JavaScript values.
|
|
40833
|
+
* @returns A `PsiTermInput` that can be used with both term CRUD and inference methods.
|
|
40834
|
+
*
|
|
40835
|
+
* @remarks
|
|
40836
|
+
* Use this overload when you have a sort ID from a runtime lookup (e.g., `listSorts()`
|
|
40837
|
+
* after LLM-based ingestion) and don't have the sort name.
|
|
40838
|
+
*
|
|
40839
|
+
* @example
|
|
40840
|
+
* ```typescript
|
|
40841
|
+
* import { psi } from '@kortexya/reasoninglayer';
|
|
40842
|
+
*
|
|
40843
|
+
* // By sort ID:
|
|
40844
|
+
* const term = psi({ sortId: "550e8400-e29b-41d4-a716-446655440000" }, { name: "Alice" });
|
|
40845
|
+
*
|
|
40846
|
+
* // From a runtime lookup:
|
|
40847
|
+
* const sorts = await client.sorts.listSorts();
|
|
40848
|
+
* const personSort = sorts.items.find(s => s.name === "person");
|
|
40849
|
+
* const query = psi({ sortId: personSort.sortId }, { name: "?Name" });
|
|
40850
|
+
* ```
|
|
40796
40851
|
*/
|
|
40797
|
-
declare function psi(
|
|
40852
|
+
declare function psi(sort: {
|
|
40853
|
+
sortId: string;
|
|
40854
|
+
}, features?: Record<string, unknown>): PsiTermInputById;
|
|
40798
40855
|
/**
|
|
40799
40856
|
* Create a constrained variable for use in `psi()` features.
|
|
40800
40857
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | object;
|
|
|
109
109
|
* This is the single source of truth for the version constant.
|
|
110
110
|
* The `scripts/release.sh` script updates this value alongside `package.json`.
|
|
111
111
|
*/
|
|
112
|
-
declare const SDK_VERSION = "0.
|
|
112
|
+
declare const SDK_VERSION = "0.13.0";
|
|
113
113
|
/**
|
|
114
114
|
* Configuration for the Reasoning Layer client.
|
|
115
115
|
*
|
|
@@ -18582,14 +18582,50 @@ declare namespace homoiconic {
|
|
|
18582
18582
|
* await client.inference.addFact({ term: psi("person", { name: "Alice" }) });
|
|
18583
18583
|
* ```
|
|
18584
18584
|
*/
|
|
18585
|
-
|
|
18585
|
+
/**
|
|
18586
|
+
* A psi-term identified by sort name.
|
|
18587
|
+
*/
|
|
18588
|
+
interface PsiTermInputByName {
|
|
18586
18589
|
/** @internal Brand field to distinguish from plain objects. Stripped before serialization. */
|
|
18587
18590
|
readonly __psiTerm: true;
|
|
18588
|
-
/** Sort name for this term. */
|
|
18591
|
+
/** Sort name for this term (resolved server-side). */
|
|
18589
18592
|
readonly sortName: string;
|
|
18590
18593
|
/** Features using plain JavaScript values. */
|
|
18591
18594
|
readonly features?: PlainFeatureMap;
|
|
18592
18595
|
}
|
|
18596
|
+
/**
|
|
18597
|
+
* A psi-term identified by sort ID (UUID).
|
|
18598
|
+
*/
|
|
18599
|
+
interface PsiTermInputById {
|
|
18600
|
+
/** @internal Brand field to distinguish from plain objects. Stripped before serialization. */
|
|
18601
|
+
readonly __psiTerm: true;
|
|
18602
|
+
/** Sort ID (UUID) for this term. */
|
|
18603
|
+
readonly sortId: string;
|
|
18604
|
+
/** Features using plain JavaScript values. */
|
|
18605
|
+
readonly features?: PlainFeatureMap;
|
|
18606
|
+
}
|
|
18607
|
+
/**
|
|
18608
|
+
* A format-agnostic psi-term produced by the `psi()` builder.
|
|
18609
|
+
*
|
|
18610
|
+
* @remarks
|
|
18611
|
+
* Exactly one of `sortName` or `sortId` is present — enforced by the union type.
|
|
18612
|
+
* Can be passed to both term CRUD methods (converted to tagged `ValueDto` format)
|
|
18613
|
+
* and inference methods (converted to untagged `TermInputDto` format).
|
|
18614
|
+
* The SDK handles the conversion automatically based on which method receives it.
|
|
18615
|
+
*
|
|
18616
|
+
* Distinguished from plain objects by the `__psiTerm` brand field, which is
|
|
18617
|
+
* stripped before serialization.
|
|
18618
|
+
*
|
|
18619
|
+
* @example
|
|
18620
|
+
* ```typescript
|
|
18621
|
+
* // Works with term CRUD:
|
|
18622
|
+
* await client.terms.createTerm({ sortId, ownerId, features: { name: "Alice" } });
|
|
18623
|
+
*
|
|
18624
|
+
* // Works with inference:
|
|
18625
|
+
* await client.inference.addFact({ term: psi("person", { name: "Alice" }) });
|
|
18626
|
+
* ```
|
|
18627
|
+
*/
|
|
18628
|
+
type PsiTermInput = PsiTermInputByName | PsiTermInputById;
|
|
18593
18629
|
/**
|
|
18594
18630
|
* A constrained variable for use in inference contexts.
|
|
18595
18631
|
*
|
|
@@ -18662,9 +18698,11 @@ type plainValues_ConstrainedPlainVar = ConstrainedPlainVar;
|
|
|
18662
18698
|
type plainValues_PlainFeatureMap = PlainFeatureMap;
|
|
18663
18699
|
type plainValues_PlainFeatureValue = PlainFeatureValue;
|
|
18664
18700
|
type plainValues_PsiTermInput = PsiTermInput;
|
|
18701
|
+
type plainValues_PsiTermInputById = PsiTermInputById;
|
|
18702
|
+
type plainValues_PsiTermInputByName = PsiTermInputByName;
|
|
18665
18703
|
type plainValues_TermInputArg = TermInputArg;
|
|
18666
18704
|
declare namespace plainValues {
|
|
18667
|
-
export type { plainValues_ConstrainedPlainVar as ConstrainedPlainVar, plainValues_PlainFeatureMap as PlainFeatureMap, plainValues_PlainFeatureValue as PlainFeatureValue, plainValues_PsiTermInput as PsiTermInput, plainValues_TermInputArg as TermInputArg };
|
|
18705
|
+
export type { plainValues_ConstrainedPlainVar as ConstrainedPlainVar, plainValues_PlainFeatureMap as PlainFeatureMap, plainValues_PlainFeatureValue as PlainFeatureValue, plainValues_PsiTermInput as PsiTermInput, plainValues_PsiTermInputById as PsiTermInputById, plainValues_PsiTermInputByName as PsiTermInputByName, plainValues_TermInputArg as TermInputArg };
|
|
18668
18706
|
}
|
|
18669
18707
|
|
|
18670
18708
|
/**
|
|
@@ -40745,7 +40783,7 @@ declare class SortBuilder {
|
|
|
40745
40783
|
}
|
|
40746
40784
|
|
|
40747
40785
|
/**
|
|
40748
|
-
* Create a format-agnostic psi-term
|
|
40786
|
+
* Create a format-agnostic psi-term identified by sort name.
|
|
40749
40787
|
*
|
|
40750
40788
|
* @param sortName - The sort name (resolved server-side).
|
|
40751
40789
|
* @param features - Optional features map using plain JavaScript values.
|
|
@@ -40773,12 +40811,6 @@ declare class SortBuilder {
|
|
|
40773
40811
|
* // With variable (auto-detected "?" prefix):
|
|
40774
40812
|
* const query = psi("person", { name: "?Name", age: "?Age" });
|
|
40775
40813
|
*
|
|
40776
|
-
* // With constrained variable:
|
|
40777
|
-
* const eligible = psi("eligible", {
|
|
40778
|
-
* applicant: "?A",
|
|
40779
|
-
* score: constrained("?S", guard("gt", 700)),
|
|
40780
|
-
* });
|
|
40781
|
-
*
|
|
40782
40814
|
* // Nested psi-terms:
|
|
40783
40815
|
* const company = psi("company", {
|
|
40784
40816
|
* name: "Acme",
|
|
@@ -40791,10 +40823,35 @@ declare class SortBuilder {
|
|
|
40791
40823
|
* // Term reference (auto-detected "!" prefix):
|
|
40792
40824
|
* const withRef = psi("department", { manager: "!550e8400-..." });
|
|
40793
40825
|
* ```
|
|
40826
|
+
*/
|
|
40827
|
+
declare function psi(sortName: string, features?: Record<string, unknown>): PsiTermInputByName;
|
|
40828
|
+
/**
|
|
40829
|
+
* Create a format-agnostic psi-term identified by sort ID.
|
|
40794
40830
|
*
|
|
40795
|
-
* @
|
|
40831
|
+
* @param sort - Object with `sortId` (UUID).
|
|
40832
|
+
* @param features - Optional features map using plain JavaScript values.
|
|
40833
|
+
* @returns A `PsiTermInput` that can be used with both term CRUD and inference methods.
|
|
40834
|
+
*
|
|
40835
|
+
* @remarks
|
|
40836
|
+
* Use this overload when you have a sort ID from a runtime lookup (e.g., `listSorts()`
|
|
40837
|
+
* after LLM-based ingestion) and don't have the sort name.
|
|
40838
|
+
*
|
|
40839
|
+
* @example
|
|
40840
|
+
* ```typescript
|
|
40841
|
+
* import { psi } from '@kortexya/reasoninglayer';
|
|
40842
|
+
*
|
|
40843
|
+
* // By sort ID:
|
|
40844
|
+
* const term = psi({ sortId: "550e8400-e29b-41d4-a716-446655440000" }, { name: "Alice" });
|
|
40845
|
+
*
|
|
40846
|
+
* // From a runtime lookup:
|
|
40847
|
+
* const sorts = await client.sorts.listSorts();
|
|
40848
|
+
* const personSort = sorts.items.find(s => s.name === "person");
|
|
40849
|
+
* const query = psi({ sortId: personSort.sortId }, { name: "?Name" });
|
|
40850
|
+
* ```
|
|
40796
40851
|
*/
|
|
40797
|
-
declare function psi(
|
|
40852
|
+
declare function psi(sort: {
|
|
40853
|
+
sortId: string;
|
|
40854
|
+
}, features?: Record<string, unknown>): PsiTermInputById;
|
|
40798
40855
|
/**
|
|
40799
40856
|
* Create a constrained variable for use in `psi()` features.
|
|
40800
40857
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/config.ts
|
|
2
|
-
var SDK_VERSION = "0.
|
|
2
|
+
var SDK_VERSION = "0.13.0";
|
|
3
3
|
function resolveConfig(config) {
|
|
4
4
|
if (!config.baseUrl) {
|
|
5
5
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -8521,11 +8521,12 @@ function toUntaggedValue(value) {
|
|
|
8521
8521
|
return { name: value.name, constraint };
|
|
8522
8522
|
}
|
|
8523
8523
|
if (isPsiTermInput(value)) {
|
|
8524
|
+
const sortKey = "sortId" in value && value.sortId ? { sortId: value.sortId } : { sortName: value.sortName };
|
|
8524
8525
|
if (!value.features) {
|
|
8525
|
-
return
|
|
8526
|
+
return sortKey;
|
|
8526
8527
|
}
|
|
8527
8528
|
return {
|
|
8528
|
-
|
|
8529
|
+
...sortKey,
|
|
8529
8530
|
features: toUntaggedFeatures(value.features)
|
|
8530
8531
|
};
|
|
8531
8532
|
}
|
|
@@ -8545,13 +8546,12 @@ function toTermInputDto(input) {
|
|
|
8545
8546
|
if (!isPsiTermInput(input)) {
|
|
8546
8547
|
return input;
|
|
8547
8548
|
}
|
|
8548
|
-
|
|
8549
|
-
|
|
8549
|
+
const features = input.features ? toUntaggedFeatures(input.features) : void 0;
|
|
8550
|
+
if ("sortId" in input && input.sortId) {
|
|
8551
|
+
return { sortId: input.sortId, features: features ?? {} };
|
|
8550
8552
|
}
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
features: toUntaggedFeatures(input.features)
|
|
8554
|
-
};
|
|
8553
|
+
const { sortName } = input;
|
|
8554
|
+
return features ? { sortName, features } : { sortName };
|
|
8555
8555
|
}
|
|
8556
8556
|
|
|
8557
8557
|
// src/normalizers/values.ts
|
|
@@ -22466,13 +22466,23 @@ var SortBuilder = class _SortBuilder {
|
|
|
22466
22466
|
};
|
|
22467
22467
|
|
|
22468
22468
|
// src/builders/psi.ts
|
|
22469
|
-
function psi(
|
|
22469
|
+
function psi(sortOrName, features) {
|
|
22470
|
+
if (typeof sortOrName === "string") {
|
|
22471
|
+
if (!features) {
|
|
22472
|
+
return { __psiTerm: true, sortName: sortOrName };
|
|
22473
|
+
}
|
|
22474
|
+
return {
|
|
22475
|
+
__psiTerm: true,
|
|
22476
|
+
sortName: sortOrName,
|
|
22477
|
+
features
|
|
22478
|
+
};
|
|
22479
|
+
}
|
|
22470
22480
|
if (!features) {
|
|
22471
|
-
return { __psiTerm: true,
|
|
22481
|
+
return { __psiTerm: true, sortId: sortOrName.sortId };
|
|
22472
22482
|
}
|
|
22473
22483
|
return {
|
|
22474
22484
|
__psiTerm: true,
|
|
22475
|
-
|
|
22485
|
+
sortId: sortOrName.sortId,
|
|
22476
22486
|
features
|
|
22477
22487
|
};
|
|
22478
22488
|
}
|