@reintent/core/internal
For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.
Kernel
BoundaryProps
type BoundaryProps = object;Defined in: packages/core/src/kernel/jsx.ts
A boundary: its children are expanded, and what they throw is handed to onThrow, whose result
is expanded in their place (it may throw again, to the next boundary out). React's error
boundary, for the kernel; the layer above builds <Reconsider> on it.
Properties
Pick
type Pick = object;Defined in: packages/core/src/kernel/scope.ts
Properties
Result
type Result<T> = object;Defined in: packages/core/src/kernel/render.ts
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Properties
Run
type Run = object;Defined in: packages/core/src/kernel/scope.ts
Properties
| Property | Type | Description |
|---|---|---|
calls? | Set<string> | The useCompute keys taken in the component being called. |
compute? | (key, fn, props) => unknown | While a renderer skips calls: how a useCompute in the component being called is made. |
picks | Pick[] | - |
reads? | Set<IntentContext<any>> | "all" | The contexts the component being called read, while a renderer records them; all: the scope. |
scope | Scope | null | - |
Scope
type Scope = ReadonlyMap<IntentContext<any>, unknown>;Defined in: packages/core/src/kernel/scope.ts
Boundary
const Boundary: Component<BoundaryProps>;Defined in: packages/core/src/kernel/jsx.ts
Inputs
const Inputs: IntentContext<unknown>;Defined in: packages/core/src/kernel/scope.ts
The inputs a run was handed. Its shape is the layer above's (the choices' layers).
Provided
const Provided: IntentContext<ReadonlySet<IntentContext<any>>>;Defined in: packages/core/src/kernel/scope.ts
The contexts the evaluation was handed at its root (provide): those that name its reads. A
context only a Provider in the tree adds is part of the program, and names nothing unless it
names reads anywhere (0047 §3).
Trace
const Trace: IntentContext<{
report: void;
}>;Defined in: packages/core/src/kernel/scope.ts
This run's trace: useContext(Trace).report(item).
asElement()
function asElement(x): IntentElement | undefined;Defined in: packages/core/src/kernel/jsx.ts
An element of the kernel's, or another runtime's read as one; undefined for anything else. Its key
is the kernel's (keyFor): an entity's component takes its id as its key in React's JSX too.
Parameters
| Parameter | Type |
|---|---|
x | unknown |
Returns
IntentElement | undefined
contextOfProvider()
function contextOfProvider(t): IntentContext<unknown> | undefined;Defined in: packages/core/src/kernel/context.ts
For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.
Parameters
| Parameter | Type |
|---|---|
t | unknown |
Returns
IntentContext<unknown> | undefined
createRenderer()
function createRenderer<T>(
tree,
once?,
calls?
): object;Defined in: packages/core/src/kernel/render.ts
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
Returns
| Name | Type | Default value | Description |
|---|---|---|---|
stats | object | - | Renders run and renders handed back unchanged; component calls made and calls skipped. |
stats.calls | number | 0 | - |
stats.renders | number | 0 | - |
stats.reused | number | 0 | - |
stats.skipped | number | 0 | - |
tree | Child | - | - |
render() | (inputs, opts?) => Result<T> | - | - |
hostKindOf()
function hostKindOf(t): string | undefined;Defined in: packages/core/src/kernel/jsx.ts
For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.
Parameters
| Parameter | Type |
|---|---|
t | unknown |
Returns
string | undefined
inScope()
function inScope<T>(
r,
scope,
fn
): T;Defined in: packages/core/src/kernel/scope.ts
Run fn as a component of r, with scope in scope.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
Returns
T
isBoundary()
function isBoundary(t): boolean;Defined in: packages/core/src/kernel/jsx.ts
For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.
Parameters
| Parameter | Type |
|---|---|
t | unknown |
Returns
boolean
isElement()
function isElement(x): x is IntentElement;Defined in: packages/core/src/kernel/jsx.ts
For the realizer, the libraries and the tools (0024): a second realizer's contract (@reintent/react), and what they read underneath the public entry.
Parameters
| Parameter | Type |
|---|---|
x | unknown |
Returns
x is IntentElement
renderOnce()
function renderOnce<T>(
tree,
inputs,
provide?
): object;Defined in: packages/core/src/kernel/render.ts
One render, nothing skipped: the result and what it picked.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
Returns
object
useContexts()
function useContexts(): Scope;Defined in: packages/core/src/kernel/scope.ts
Every context value in scope: for a layer built on the kernel.
Returns
Choices
Belief
type Belief = object;Defined in: packages/core/src/choices/layers.ts
System One's answer under one stamp: its weights, and how decisive it was, when it says (0116 §4).
Properties
| Property | Modifier | Type |
|---|---|---|
answer | readonly | Weights |
confidence? | readonly | number |
stamp | readonly | string |
CascadeInput
type CascadeInput<T> = object;Defined in: packages/core/src/choices/cascade.ts
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Type | Description |
|---|---|---|
accepts? | (value) => boolean | An open generated space accepts a person's value beyond its current support. |
axis | (spec) => number | undefined | - |
defaultValue? | T | - |
generated? | boolean | The possibilities are System Two's candidates (generate): their source is 'generated'. |
informed | boolean | Whether the prior says anything (false: equal weights by default). |
instead? | boolean | A judgment asks what instead of defaultValue: where a person left it and it was measured to fit, none weighs. |
named? | NameRecord | - |
open? | boolean | Whether there is anything to choose here; closed, only a preview or a decision overrides the default. |
policy | Policy | - |
possibilities | Choices<T> | The possibilities and code's prior over them. |
preview? | object | A preview's hypothesis for this choice, if any. |
preview.value | Decided | - |
record? | ChoiceRecord | - |
stamp? | string | The input stamp a belief must have been given under; undefined: nobody judges this one. |
unloaded? | boolean | - |
where? | string | The context this read is in (whereOf its ctx): which of the host's measurements hold here. |
written? | T | The program's own word in this context (0118): the prior here, in place of code's and Code's taste. |
ChoiceRecord
type ChoiceRecord = object;Defined in: packages/core/src/choices/layers.ts
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
beliefs? | readonly | readonly Belief[] | What System One answered, by the input stamp it answered under; newest first. |
constraints? | readonly | readonly Constraint[] | - |
decision? | readonly | object & DecisionOrigin | A person's decision; wrapped, since undefined may be a value. |
drawn? | readonly | readonly Drawn[] | What a sampling <World sample> drew for this choice (0089 §3), oldest first: each draw's seed and the value it took, taken when the draw was committed. fresh: the draw began a new round (without replacement, every value had been drawn). A commit, in the history. |
measured? | readonly | Readonly<Record<string, Measured>> | What the host measured, by the context it measured in (whereOf the read's ctx): Code's, reduced to constraints and weights for that context only; a cache, not history. |
preferences? | readonly | readonly Preference[] | - |
Declarations
type Declarations = object;Defined in: packages/core/src/choices/declare.ts
Several entities' declarations, by entity name: what a reprogramming patches.
Index Signature
[entity: string]: FieldsDrawn
type Drawn = object;Defined in: packages/core/src/choices/layers.ts
One draw of a choice in a sampling World: its seed, and the value it took.
Properties
| Property | Modifier | Type |
|---|---|---|
fresh? | readonly | true |
seed | readonly | number |
value | readonly | Decided |
GeneratedRecord
type GeneratedRecord = object;Defined in: packages/core/src/choices/layers.ts
Properties
NameRecord
type NameRecord = object;Defined in: packages/core/src/choices/layers.ts
Properties
| Property | Modifier | Type |
|---|---|---|
constraints? | readonly | readonly Constraint[] |
preferences? | readonly | readonly Preference[] |
Outcome
type Outcome<T> = object;Defined in: packages/core/src/choices/cascade.ts
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Type | Description |
|---|---|---|
beyond? | number | β (0115 §4): the share of System One's answer outside K (BEYOND), of what it gave to that and to what a person left. With cause: 'judged', it was K's likeliest or near it (0115 §4.4): the value is K's all the same, and the choice is unmet, for System Two. |
cause? | "measured" | "judged" | Why none fits, when it is what the host measured (0065 §7); for an unmet no person said, System One judged none of K is what was asked for ('judged', 0115). |
confidence? | number | How decisive the belief it rests on was, when System One said (0116 §4). |
dist? | Weights | The effective distribution, when it said anything. |
draw? | Weights | In a sampling World: what a draw would draw from, every possibility it may take, weighed (0089). |
measured? | true | What the host measured in this context ruled a possibility out or weighed one. |
named? | true | The constraint that settled it was on the choice's name. |
none? | true | Every possibility is ruled out: none fits. |
source | Source | - |
stale? | true | The belief was given under another stamp. |
status | Status | - |
unfit? | true | What the host measured here rules out every possibility a person left: the measurement is set aside, the value is the one that measured best, and the choice is unresolved with none that fits (none, cause: 'measured'), for a <World onUnresolved> to handle (0065 §7). |
unmet? | unknown | What a person said that K does not hold: its tag is one of the possibilities, its data is not that possibility's. The person's intent is not met; the choice escalates ('unmet'). |
value | T | undefined | - |
waiting? | unknown[] | Values that do not apply because they are not one of the possibilities. |
wants | boolean | Whether System One's answer for the current stamp is still wanted. |
PatchOp
type PatchOp =
| {
op: "add" | "replace" | "test";
path: string;
value: Json;
}
| {
op: "remove";
path: string;
};Defined in: packages/core/src/choices/declare.ts
One operation of a JSON Patch (RFC 6902): those a reprogramming of K needs.
Policy
type Policy = object;Defined in: packages/core/src/choices/cascade.ts
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
minBeyond? | readonly | number | β below K's likeliest that still goes to System Two (0115 §4.4, §10): from this much, a β the likeliest does not lead by minMargin is unmet. Unset: MIN_BEYOND. |
minMargin | readonly | number | - |
otherwise | readonly | Otherwise | - |
sample? | readonly | object | A sampling <World id sample> in scope (0089): whose draws to read, and with replacement or not. |
sample.replace | readonly | boolean | - |
sample.world | readonly | string | - |
Possibility
type Possibility<T> = object;Defined in: packages/core/src/choices/choices.ts
Choices as data (principles, 「选择 C」; 0006 Level 0): a finite distribution over the
possibilities K, as a list of { value, weight }. A possibility is compared by its tag: a string
is its own tag, a tagged value { kind: 'grid', … } has kind as its tag, anything else its
JSON. Weights sum to one; state(x) is the degenerate one, δ_x.
New, after 0006; tags, margin and argmax from Huxpro/airtalk#857 (core/intent/value.ts).
Type Parameters
| Type Parameter |
|---|
T |
Properties
RefInfo
type RefInfo = object;Defined in: packages/core/src/choices/declare.ts
What a handle knows besides its identity: kept in the process, never serialized.
Properties
| Property | Modifier | Type |
|---|---|---|
entity | readonly | object |
entity.decl | readonly | Fields |
entity.name | readonly | string |
field | readonly | string |
TagOf
type TagOf<D> = D extends object ? Str<K> : D extends object ? Str<keyof R> : never;Defined in: packages/core/src/choices/declare.ts
A possibility's tag in a declaration.
Type Parameters
| Type Parameter |
|---|
D |
DEFAULT_POLICY
const DEFAULT_POLICY: Policy;Defined in: packages/core/src/choices/cascade.ts
Both codebases' TAU.
EMPTY
const EMPTY: Layers;Defined in: packages/core/src/choices/layers.ts
at()
function at<T>(v, axis): T | undefined;Defined in: packages/core/src/choices/layers.ts
A piecewise value read at a point; a constant is itself everywhere.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
v | Decided<T> | undefined |
axis | (name) => number | undefined |
Returns
T | undefined
best()
function best<T>(c): T | undefined;Defined in: packages/core/src/choices/choices.ts
The likeliest possibility; a tie goes to the one listed first.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
c | Choices<T> |
Returns
T | undefined
Example
import { choices } from '@reintent/core';
import { best } from '@reintent/core/internal';
console.log(
best(
choices([
{ value: 'grid', weight: 0.6 },
{ value: 'list', weight: 0.4 },
]),
),
); // → 'grid'
console.log(best(choices('formal', 'warm'))); // → 'formal'canonical()
function canonical(v): string;Defined in: packages/core/src/choices/layers.ts
A canonical JSON (keys sorted): what input stamps are made of.
Parameters
| Parameter | Type |
|---|---|
v | unknown |
Returns
string
cascade()
function cascade<T>(i): Outcome<T>;Defined in: packages/core/src/choices/cascade.ts
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
i | CascadeInput<T> |
Returns
Outcome<T>
checkEntity()
function checkEntity(name, fields): string[];Defined in: packages/core/src/choices/declare.ts
The errors in an entity's declaration (0015 §3.2), empty when it holds: its shape, K, the prior,
the default, what given and the conditions name, and cycles. What entity throws, as a list.
Parameters
| Parameter | Type |
|---|---|
name | string |
fields | unknown |
Returns
string[]
Example
import { checkEntity } from '@reintent/core/internal';
const [typo, cycle] = checkEntity('bear', {
style: { kinds: ['toy', 'pixel'], given: ['pocket'] },
pocket: {
kinds: ['none', 'seam'],
forbid: [{ when: { style: ['pixl'] }, kinds: ['seam'] }],
},
});
console.log(typo); // → "pocket: forbid[0] names style 'pixl', which is not one of its kinds"
console.log(cycle); // → 'a cycle: style → pocket → style'declarations()
function declarations(...entities): Declarations;Defined in: packages/core/src/choices/declare.ts
Entities' declarations by name: what patch reprograms.
Parameters
| Parameter | Type |
|---|---|
...entities | readonly object[] |
Returns
familyOf()
function familyOf(entity, field): ChoiceFamily;Defined in: packages/core/src/choices/declare.ts
A family of field: a handle for any of, the singleton's when none is given.
Parameters
Returns
flatMap()
function flatMap<A, B>(c, f): Choices<B>;Defined in: packages/core/src/choices/choices.ts
One choice depending on another's outcome: the monad's bind.
Type Parameters
| Type Parameter |
|---|
A |
B |
Parameters
Returns
Choices<B>
Example
import { choices } from '@reintent/core';
import { flatMap } from '@reintent/core/internal';
// How many columns depends on the layout: the joint distribution over the outcome.
const layout = choices([
{ value: 'grid', weight: 0.6 },
{ value: 'list', weight: 0.4 },
]);
const columns = flatMap(layout, (l) =>
l === 'grid'
? choices([
{ value: 3, weight: 0.5 },
{ value: 2, weight: 0.5 },
])
: choices([1]),
);
console.log(columns);
// → [ { value: 3, weight: 0.3 }, { value: 2, weight: 0.3 }, { value: 1, weight: 0.4 } ]givenOf()
function givenOf(d): string[];Defined in: packages/core/src/choices/declare.ts
What a declared choice depends on: given, then the fields its conditions name; each once.
Parameters
| Parameter | Type |
|---|---|
d | ChoiceDecl |
Returns
string[]
holds()
function holds(c, tags): boolean;Defined in: packages/core/src/choices/declare.ts
Whether a condition holds for these tags (a field not read has none).
Parameters
| Parameter | Type |
|---|---|
c | Condition |
tags | Readonly<Record<string, string | undefined>> |
Returns
boolean
isFixed()
function isFixed(f): f is FixedDecl;Defined in: packages/core/src/choices/declare.ts
Whether a field is a part that is not a choice.
Parameters
| Parameter | Type |
|---|---|
f | FieldDecl |
Returns
f is FixedDecl
isInformed()
function isInformed(c): boolean;Defined in: packages/core/src/choices/choices.ts
Whether the weights say anything: false for the equal-weights shorthand, which is no prior.
Parameters
| Parameter | Type |
|---|---|
c | Choices<unknown> |
Returns
boolean
isState()
function isState(c): boolean;Defined in: packages/core/src/choices/choices.ts
Whether these choices are a determined state.
Parameters
| Parameter | Type |
|---|---|
c | Choices<unknown> |
Returns
boolean
margin()
function margin(c): number;Defined in: packages/core/src/choices/choices.ts
Best minus second best (1 when there is only one).
Parameters
Returns
number
Example
import { choices } from '@reintent/core';
import { margin } from '@reintent/core/internal';
const c = choices([
{ value: 'grid', weight: 0.5 },
{ value: 'list', weight: 0.3 },
{ value: 'carousel', weight: 0.2 },
]);
console.log(margin(c)); // → 0.2
// The default policy takes the likeliest only at a margin of 0.2 or more (`<Resolve>`).normalize()
function normalize<T>(c): Choices<T> | undefined;Defined in: packages/core/src/choices/choices.ts
Normalised to sum to one; undefined when nothing is left.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
c | Choices<T> |
Returns
Choices<T> | undefined
patch()
function patch(decls, ops):
| {
decls: Declarations;
ok: true;
}
| {
errors: string[];
ok: false;
};Defined in: packages/core/src/choices/declare.ts
A reprogramming of declarations as a JSON Patch (0015 §3.3): the new declarations, or why not. The
result is checked as entity checks it, and a patch may not touch what is fixed. Nothing is
changed in place: the old declarations are the old version's.
Parameters
| Parameter | Type |
|---|---|
decls | Declarations |
ops | readonly PatchOp[] |
Returns
| {
decls: Declarations;
ok: true;
}
| {
errors: string[];
ok: false;
}
Example
import { entity } from '@reintent/core';
import { declarations, patch } from '@reintent/core/internal';
const Man = entity('man', {
hat: { kinds: { usual: { hatScale: 1 }, big: { hatScale: 1.45 } }, default: 'big' },
outline: { fixed: 'a man in a bowler hat' },
});
// "The hat, bigger still": one possibility more.
const bigger = patch(declarations(Man), [
{ op: 'add', path: '/man/hat/kinds/absurd', value: { hatScale: 1.95 } },
]);
console.log(bigger.ok && JSON.stringify(bigger.decls.man.hat));
// → '{"kinds":{"usual":{"hatScale":1},"big":{"hatScale":1.45},"absurd":{"hatScale":1.95}},"default":"big"}'
// What is fixed is not a reprogramming's.
const touched = patch(declarations(Man), [
{ op: 'replace', path: '/man/outline/fixed', value: 'a man in a top hat' },
]);
console.log(touched.ok || touched.errors); // → [ 'man/outline is fixed: a patch may not touch it' ]possibilitiesOf()
function possibilitiesOf(d, given): object;Defined in: packages/core/src/choices/declare.ts
K for a declared choice given what it depends on: its kinds less what forbid rules out, over
the prior renormalised (or equal weights, saying nothing); and its default in this K.
Parameters
| Parameter | Type |
|---|---|
d | ChoiceDecl |
given | Readonly<Record<string, string | undefined>> |
Returns
object
| Name | Type |
|---|---|
defaultValue | unknown |
K | Choices<unknown> |
refInfo()
function refInfo(x): RefInfo | undefined;Defined in: packages/core/src/choices/declare.ts
The handle's or the family's entity and field, if it is one.
Parameters
| Parameter | Type |
|---|---|
x | unknown |
Returns
RefInfo | undefined
refOf()
function refOf(
entity,
field,
of
): ChoiceRef;Defined in: packages/core/src/choices/declare.ts
A handle on of's choice field of an entity.
Parameters
| Parameter | Type |
|---|---|
entity | { decl: Fields; name: string; } |
entity.decl | Fields |
entity.name | string |
field | string |
of | string |
Returns
reweigh()
function reweigh<T>(c, w): Choices<T>;Defined in: packages/core/src/choices/choices.ts
The possibilities of c weighted by w (by tag); tags w does not name weigh nothing.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
Returns
Choices<T>
sameTag()
function sameTag(a, b): boolean;Defined in: packages/core/src/choices/choices.ts
Whether two possibilities are the same one (by tag).
Parameters
| Parameter | Type |
|---|---|
a | unknown |
b | unknown |
Returns
boolean
sameUses()
function sameUses(a, b): boolean;Defined in: packages/core/src/choices/layers.ts
Whether two input stamps ({ uses, facts }) were given the same inputs, whatever the facts.
Parameters
| Parameter | Type |
|---|---|
a | string |
b | string |
Returns
boolean
tagsOf()
function tagsOf(d): string[];Defined in: packages/core/src/choices/declare.ts
A declared choice's tags, its open tail's last.
Parameters
| Parameter | Type |
|---|---|
d | ChoiceDecl |
Returns
string[]
tailOf()
function tailOf(d): string | undefined;Defined in: packages/core/src/choices/declare.ts
The open tail's tag, if it has one.
Parameters
| Parameter | Type |
|---|---|
d | ChoiceDecl |
Returns
string | undefined
weightsOf()
function weightsOf(c): Weights;Defined in: packages/core/src/choices/choices.ts
Parameters
| Parameter | Type |
|---|---|
c | Choices<unknown> |
Returns
whereOf()
function whereOf(ctx): string;Defined in: packages/core/src/choices/layers.ts
The context a read was read in (its ctx), as the key its measurements are kept under.
Parameters
| Parameter | Type |
|---|---|
ctx | Readonly<Record<string, string>> |
Returns
string
Intent
Escalation
Defined in: packages/core/src/intent/hooks.ts
Thrown by useChoose when its choice cannot settle and a <World> (or <Reconsider>) around
it is to handle it; what nothing catches reaches the root's boundary, which reports it.
Extends
Error
Constructors
Constructor
new Escalation(
id,
reason,
dist?,
tried?,
wanted?,
can?,
beyond?
): Escalation;Defined in: packages/core/src/intent/hooks.ts
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
id | Id | undefined | - |
reason | Reason | undefined | - |
dist? | Record<string, number> | undefined | - |
tried? | readonly Action[] | [] | What the boundaries it passed through tried (0004 §4). |
wanted? | unknown | undefined | For 'unmet': what the person said, which K does not hold. |
can? | Can | ANY | Which steps apply to it: rejudging a judged choice, regenerating a generated one. |
beyond? | number | undefined | For an 'unmet' System One judged (cause: 'judged'): its share outside K (BEYOND, 0115). |
Returns
Overrides
Error.constructorProperties
| Property | Modifier | Type | Default value | Description |
|---|---|---|---|---|
beyond? | readonly | number | undefined | For an 'unmet' System One judged (cause: 'judged'): its share outside K (BEYOND, 0115). |
can | readonly | Can | ANY | Which steps apply to it: rejudging a judged choice, regenerating a generated one. |
dist? | readonly | Record<string, number> | undefined | - |
id | readonly | Id | undefined | - |
reason | readonly | Reason | undefined | - |
tried | readonly | readonly Action[] | [] | What the boundaries it passed through tried (0004 §4). |
wanted? | readonly | unknown | undefined | For 'unmet': what the person said, which K does not hold. |
Action
type Action = "rejudge" | "regenerate" | "ask" | "reprogram";Defined in: packages/core/src/intent/trace.ts
ChooseOptions
type ChooseOptions<T> = Id & object;Defined in: packages/core/src/intent/hooks.ts
Type Declaration
| Name | Type | Description |
|---|---|---|
about? | unknown | Anything the component says about the choice, passed through to the read. |
ask? | readonly Ask[] | Who answers the choice, in order (0033 §2). 'model' with a question: System One weighs the possibilities. 'human': while it cannot settle, it is listed in intent.questions(), after the model has answered when both are asked. Who prevails is the layers' business: a person's decision is on top whatever the order. |
askWhenTold? | boolean | With ask having 'model': the prior already answers the question while nobody has told the intent anything, so System One is asked only once a person has (intent.tell, 0114). Until then the prior's weights stand, read as Code's: a program System Two wrote from one sentence weighs its possibilities as it writes them, and needs no second call to start. A literal: it must not change from one evaluation to the next. |
defaultValue? | NoInfer<T> | This choice's own fallback: used while unresolved, by the policy in scope. |
describe? | Readonly<Record<string, string>> | What each possibility means, by its tag (0116 §3): what System One is shown beside the tag, part of the input stamp. A possibility it leaves out is shown by its tag alone. |
instead? | boolean | The question asks what to take instead of defaultValue where it cannot stay: in a context where a person left defaultValue and the host measured it to fit, System One is not asked, and what it answered does not weigh; what was measured there settles it (0065 §6). Where a person ruled it out, or nothing was measured, the judgment weighs as without it. |
open? | boolean | Whether there is anything to choose here (default true). Closed, the possibilities stay what they are, and only a preview or a decision overrides defaultValue (airtalk's open: false). |
otherwise? | Otherwise | A local override of the policy's otherwise. Inside a preview, nothing is asked or escalated. Deprecated Say who answers with ask, and what to do when it cannot settle with an enclosing <World onUnresolved> (0046 §6). |
priorAlong? | Piecewise<NoInfer<T>> | The program's own word along an axis (0118): on each stretch, the possibility it gives there (a screen shape's class prefix, tall:flex-col). Where the context reads a point in one, that is the prior here, in place of code's prior and Code's taste; a judgment replaces it, a measurement may rule it out, and a person's decision is above it. A literal of the program. |
question? | string | The question this choice answers: the prompt System One is given when ask has 'model', and what a person is shown when ask has 'human'. |
shape? | Shape | The shape of the possibilities (0116 §2): levels in order, or whether a proposition holds. System One is told it, and it is part of the input stamp. |
stays? | object | With instead: the question asked where the default can stay (a person left it and the host measured it to fit), in place of not asking. Its own question, so its own input stamp (uses adds { stays: true }): the answer to what to take instead never weighs there, and this one weighs only there. It replaces Code's taste in that context as any judgment does (0065 §6, §9). |
stays.minMargin? | number | How sure its answer must be to settle the choice there (the policy's minMargin, raised to this): it asks whether another is clearly better than what fits, so an answer short of it is weighed with Code's taste, not in its place (0065 §6). |
stays.question | string | - |
stays.uses? | Record<string, unknown> | - |
uses? | Record<string, unknown> | What System One reads besides the question, part of its input stamp (as judge's uses). |
Type Parameters
| Type Parameter |
|---|
T |
Effect
type Effect = "judge" | "generate";Defined in: packages/core/src/intent/trace.ts
Escalated
type Escalated = Unresolved;Defined in: packages/core/src/intent/trace.ts
Deprecated
Renamed Unresolved (0046 §5).
Generated
type Generated<V> = object;Defined in: packages/core/src/intent/hooks.ts
Type Parameters
| Type Parameter |
|---|
V |
Properties
Hypotheses
type Hypotheses = Readonly<Record<string, {
value: Decided;
}>>;Defined in: packages/core/src/intent/scope.ts
Judged
type Judged<T> = object;Defined in: packages/core/src/intent/hooks.ts
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Modifier | Type |
|---|---|---|
$judge | readonly | true |
choices | readonly | | Choices<T> | Generation<T> |
describe? | readonly | Readonly<Record<string, string>> |
question | readonly | string |
shape? | readonly | Shape |
uses? | readonly | Record<string, unknown> |
SwitchProps
type SwitchProps<T> = BranchProps<T>;Defined in: packages/core/src/intent/handlers.ts
Type Parameters
| Type Parameter |
|---|
T extends Tagged |
Deprecated
Renamed BranchProps (0046 §6).
TraceItem
type TraceItem =
| ChoiceRead
| ModelRequest
| Unresolved
| {
type: string;
};Defined in: packages/core/src/intent/trace.ts
escalationsOf
const escalationsOf: (trace) => Unresolved[] = unresolvedOf;Defined in: packages/core/src/intent/trace.ts
Parameters
| Parameter | Type |
|---|---|
trace | readonly unknown[] |
Returns
Deprecated
Renamed unresolvedOf (0046 §5).
InputContext
const InputContext: IntentContext<unknown>;Defined in: packages/core/src/intent/input.ts
The root input in scope; its key is the input itself, canonical.
PolicyContext
const PolicyContext: IntentContext<Policy>;Defined in: packages/core/src/intent/scope.ts
PreviewContext
const PreviewContext: IntentContext<Readonly<Record<string, {
value: unknown;
}>>>;Defined in: packages/core/src/intent/scope.ts
QuietContext
const QuietContext: IntentContext<boolean>;Defined in: packages/core/src/intent/scope.ts
Under a <Reconsider> handling an escalation: choices fall back instead of escalating again.
ctxOf()
function ctxOf(scope): Record<string, string>;Defined in: packages/core/src/intent/hooks.ts
The contexts in scope that name something, by name: those the evaluation was handed (provide),
with the value in scope here (a Provider in the tree may give it another), and those that name
reads anywhere (names: 'anywhere'). Another context only the program provides names nothing.
Parameters
| Parameter | Type |
|---|---|
scope | ReadonlyMap<IntentContext<any>, unknown> |
Returns
Record<string, string>
escalated()
function escalated(
e,
allow,
goal?,
boundary?,
step?
): Unresolved;Defined in: packages/core/src/intent/handlers.ts
Parameters
| Parameter | Type |
|---|---|
e | Escalation |
allow | readonly Action[] |
goal? | string |
boundary? | string |
step? | ReprogramOptions |
Returns
isJudged()
function isJudged(x): x is Judged<unknown>;Defined in: packages/core/src/intent/hooks.ts
Parameters
| Parameter | Type |
|---|---|
x | unknown |
Returns
x is Judged<unknown>
readsOf()
function readsOf(trace): ChoiceRead[];Defined in: packages/core/src/intent/trace.ts
Parameters
| Parameter | Type |
|---|---|
trace | readonly unknown[] |
Returns
requestsOf()
function requestsOf(trace): ModelRequest[];Defined in: packages/core/src/intent/trace.ts
Parameters
| Parameter | Type |
|---|---|
trace | readonly unknown[] |
Returns
RootBoundary()
function RootBoundary(p): IntentElement;Defined in: packages/core/src/intent/handlers.ts
The root's boundary: what no <Reconsider> caught is reported with nothing allowed.
Parameters
Returns
stampOf()
function stampOf(r): string;Defined in: packages/core/src/intent/hooks.ts
An input stamp: exactly what the handler is given, canonical. An answer holds while these are the same; when any of them changes (the question, the possibilities, what it reads, what was said of the whole), it is for another case, and is asked again. Nothing the handler is not given is in it, and everything it is given is.
judge { prompt: the question, kinds: the possibilities' tags, shape, describe, uses, facts, input } generate { prompt: the instruction, n (when greater than 1), uses, facts, input }
input is the root's input (0045 §3), when the intent has one: an answer asked under one input
is not taken for another.
The stamp is the full canonical content, never a hash of it: two stamps are the same only when
what they hold is. Neither handler is given the program, nor its name: a reprogramming that
leaves a choice's question, possibilities and inputs as they were leaves its answer standing, and
one that changes any of them asks that choice again, and no other (0047 §4). A judge that should
read part of the program is handed it in uses, and then that part is in the stamp.
Parameters
| Parameter | Type |
|---|---|
r | { describe?: Readonly<Record<string, string>>; facts: readonly string[]; input?: unknown; kinds?: readonly string[]; n?: number; prompt: string; shape?: Shape; uses?: Record<string, unknown>; } |
r.describe? | Readonly<Record<string, string>> |
r.facts | readonly string[] |
r.input? | unknown |
r.kinds? | readonly string[] |
r.n? | number |
r.prompt | string |
r.shape? | Shape |
r.uses? | Record<string, unknown> |
Returns
string
unresolvedOf()
function unresolvedOf(trace): Unresolved[];Defined in: packages/core/src/intent/trace.ts
Parameters
| Parameter | Type |
|---|---|
trace | readonly unknown[] |
Returns
Other
Commit
Re-exports Commit
Fragment
Re-exports Fragment
isHostNode
Re-exports isHostNode
Reason
Re-exports Reason
Unresolved
Re-exports Unresolved
Runtime
IntentAdapter
type IntentAdapter = IntentStore & object;Defined in: packages/core/src/runtime/root.ts
Integration-only access. Public hosts use realize/connect.
Type Declaration
| Name | Type | Description |
|---|---|---|
at() | () => number | How many times the intent has changed: a commit, an answer, an input, a boundary out of steps. It only grows, and it has grown before a subscriber is called (0056 §2: a handle's at). |
attach() | () => Presentation | - |
realize() | (provide?, shown?) => Realization | Legacy local evaluation that drains synchronous model answers. |
IntentState
type IntentState = object;Defined in: packages/core/src/runtime/root.ts
An intent's state as data, for a view to select from (adapterOf(intent).getState()).
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
history | readonly | object | - |
history.canRedo | readonly | boolean | - |
history.canUndo | readonly | boolean | - |
history.notes | readonly | readonly string[] | Each commit's note, oldest first. |
layers | readonly | Layers | The choices' layers: what a person decided and said, what the models answered. |
revision | readonly | number | - |
version | readonly | string | - |
IntentStore
type IntentStore = object;Defined in: packages/core/src/runtime/root.ts
An intent as an external store, for an integration (adapterOf(intent)): what useSyncExternalStore reads.
Methods
flush()
flush(r): boolean;Defined in: packages/core/src/runtime/root.ts
Sends what a shown r asked for, once. True when something was written.
Parameters
| Parameter | Type |
|---|---|
r | Realization |
Returns
boolean
getSnapshot()
getSnapshot(provide?): Realization;Defined in: packages/core/src/runtime/root.ts
λ in a context, as it is: nothing is sent and nothing written. The same value until a change.
Parameters
| Parameter | Type |
|---|---|
provide? | Provide |
Returns
getState()
getState(): IntentState;Defined in: packages/core/src/runtime/root.ts
The intent's state as data: the same object until it changes.
Returns
isCurrent()
isCurrent(r): boolean;Defined in: packages/core/src/runtime/root.ts
Whether r is still what the intent gives: nothing has changed since it was evaluated (0034's
epoch), and the intent is not disposed. Reads only: nothing is sent, and nothing is evaluated
again.
Parameters
| Parameter | Type |
|---|---|
r | Realization |
Returns
boolean
subscribe()
subscribe(fn): () => void;Defined in: packages/core/src/runtime/root.ts
Called when λ or the state may have changed: a commit, an answer, a boundary out of steps.
Parameters
| Parameter | Type |
|---|---|
fn | () => void |
Returns
() => void
JudgeBudget
type JudgeBudget = object;Defined in: packages/core/src/runtime/root.ts
Limits new judge requests across one explore/questions call. Zero uses cached beliefs and priors only.
Properties
LayerStore
type LayerStore = ReturnType<typeof createLayerStore>;Defined in: packages/core/src/runtime/store.ts
Presentation
type Presentation = object;Defined in: packages/core/src/runtime/root.ts
A displayed realization's lifetime, independent of other displays of the intent.
Methods
disconnect()
disconnect(): void;Defined in: packages/core/src/runtime/root.ts
Returns
void
present()
present(result): boolean;Defined in: packages/core/src/runtime/root.ts
Parameters
| Parameter | Type |
|---|---|
result | Realization |
Returns
boolean
Program
type Program = object;Defined in: packages/core/src/runtime/store.ts
A version of the program. version names it and is never given to another: undoing back to a
program restores its version, and a new program gets a new one, whatever its place in the
history. revision is the place: how many programs came before it, for a person to read.
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
element | readonly | Child | - |
note? | readonly | string | - |
parts? | readonly | Readonly<Record<string, Component<any>>> | The version of each reprogrammable component that has been reprogrammed, by its id (0056 §7). |
revision | readonly | number | - |
version | readonly | string | - |
RecordedProposal
type RecordedProposal = object;Defined in: packages/core/src/runtime/recordings.ts
What a recorded reprogramming answers: a program by name (the host's), and what it says it did.
Properties
RequestState
type RequestState = object;Defined in: packages/core/src/runtime/root.ts
Properties
| Property | Type | Description |
|---|---|---|
effect | ModelRequest["effect"] | - |
error? | string | - |
hypothetical? | true | Requested to inspect hypothetical worlds, rather than a shown realization. Cleared once a shown evaluation needs the same request. |
key | string | - |
stamp | string | - |
status | "running" | "completed" | "failed" | - |
CONTENT_KIND
const CONTENT_KIND: "reintent:content" = 'reintent:content';Defined in: packages/core/src/runtime/content.ts
The reserved kind of a slot's node. The reintent: namespace is the protocol's.
PREFER
const PREFER: 6 = 6;Defined in: packages/core/src/runtime/store.ts
A soft preference's default factor (Huxpro/airtalk#857's e11, after #818's PREF_WEIGHT).
adapterOf()
function adapterOf(intent): IntentAdapter;Defined in: packages/core/src/runtime/root.ts
Integration contract shared by all host adapters, independent of their JSX representation.
Parameters
| Parameter | Type |
|---|---|
intent | object |
Returns
checkContent()
function checkContent(tree, slots): CatalogError[];Defined in: packages/core/src/runtime/content.ts
Everything wrong with the slots in a tree, for a host that does or does not support host
content (slots: the slots the root's input declares; none: the host does not support it). A
slot is placed among the children, and is { slot } with no children of its own; one in a prop,
at any depth, is refused.
Parameters
Returns
createLayerStore()
function createLayerStore(init?): object;Defined in: packages/core/src/runtime/store.ts
Parameters
| Parameter | Type |
|---|---|
init | Partial<Layers> |
Returns
| Name | Type | Description |
|---|---|---|
history | object | - |
get history.canRedo | boolean | - |
get history.canUndo | boolean | - |
get history.entries | readonly Commit[] | - |
redo() | () => void | - |
reset() | () => void | Back to before the first commit, and forget them. |
undo() | () => void | - |
get layers | Layers | - |
get program | Program | undefined | - |
believe() | ( id, stamp, answer ) => void | - |
commit() | (note, fn) => void | A person's commit: one entry in the history, one notification. A no-op commits nothing. |
generated() | ( id, stamp, value ) => void | - |
hold() | (fn) => T | Hold notifications while fn runs, then notify once if anything changed. |
measure() | ( id, where, m ) => boolean | What the host measured of a choice's possibilities in one context (where), kept until it measures there again. The same measurement again writes nothing and notifies no one; one from an evaluation older than the one kept (epoch) is refused. |
setProgram() | (element, note?) => void | The program, outside the history (what a host starts with), and its name. |
subscribe() | (fn) => () => undefined | - |
unload() | (of, unloaded) => void | - |
isContent()
function isContent(v): v is HostNode;Defined in: packages/core/src/runtime/content.ts
Whether a value is a node of the reserved kind (well formed or not).
Parameters
| Parameter | Type |
|---|---|
v | unknown |
Returns
v is HostNode
layerStoreOf()
function layerStoreOf(intent): LayerStore;Defined in: packages/core/src/runtime/root.ts
Where an intent keeps its layers and their history: for tools and tests (internal).
Parameters
| Parameter | Type |
|---|---|
intent | object |
Returns
onPresented()
function onPresented(listener): () => void;Defined in: packages/core/src/runtime/root.ts
Be told of each intent the first time a lease presents a current evaluation of it: one a host really shows, not one made and dropped (StrictMode's second state, a render Suspense drops). For tools that show "the root on the page", like the docs' sandbox (internal). Returns the stop.
Parameters
| Parameter | Type |
|---|---|
listener | (intent) => void |
Returns
() => void
Last updated on
Edit on GitHub