Skip to content

Function: psi()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / psi

Function: psi()

Call Signature

psi(sortName, features?): PsiTermInputByName

Defined in: src/builders/psi.ts:53

Create a format-agnostic psi-term identified by sort name.

Parameters

sortName

string

The sort name (resolved server-side).

features?

Record<string, unknown>

Optional features map using plain JavaScript values.

Returns

PsiTermInputByName

A PsiTermInput that can be used with both term CRUD and inference methods.

Remarks

The psi() builder stores plain values as-is. Conversion to the correct wire format (tagged ValueDto or untagged TermInputDto) happens automatically when you pass the result to a resource client method.

Special string prefixes (only meaningful in inference context):

  • "?X" (? + uppercase letter) — auto-detected as a variable
  • "!uuid" (! prefix) — auto-detected as a term reference (strips !)

null means uninstantiated — maps to {"type":"Uninstantiated"} in tagged format or JSON null in untagged format, depending on which endpoint receives it.

Example

import { psi, constrained, guard } from '@kortexya/reasoninglayer';
// Simple term:
const alice = psi("person", { name: "Alice", age: 30 });
// With variable (auto-detected "?" prefix):
const query = psi("person", { name: "?Name", age: "?Age" });
// Nested psi-terms:
const company = psi("company", {
name: "Acme",
ceo: psi("person", { name: "Bob" }),
});
// Uninstantiated values:
const partial = psi("employee", { name: "Alice", salary: null });
// Term reference (auto-detected "!" prefix):
const withRef = psi("department", { manager: "!550e8400-..." });

Call Signature

psi(sort, features?): PsiTermInputById

Defined in: src/builders/psi.ts:82

Create a format-agnostic psi-term identified by sort ID.

Parameters

sort

Object with sortId (UUID).

sortId

string

features?

Record<string, unknown>

Optional features map using plain JavaScript values.

Returns

PsiTermInputById

A PsiTermInput that can be used with both term CRUD and inference methods.

Remarks

Use this overload when you have a sort ID from a runtime lookup (e.g., listSorts() after LLM-based ingestion) and don’t have the sort name.

Example

import { psi } from '@kortexya/reasoninglayer';
// By sort ID:
const term = psi({ sortId: "550e8400-e29b-41d4-a716-446655440000" }, { name: "Alice" });
// From a runtime lookup:
const sorts = await client.sorts.listSorts();
const personSort = sorts.items.find(s => s.name === "person");
const query = psi({ sortId: personSort.sortId }, { name: "?Name" });