@fuaran-ui/ops 0.9.0 → 0.21.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 +1095 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -12
- package/dist/index.d.ts +123 -12
- package/dist/index.js +1093 -76
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result, NodeId, NodeKind, JsonValue, Binding, SemanticStyle, StateBehaviour, Node, Cell, ColExpr, DataSource, Transform, EvalError, Table, TextSource, CellFormat, ColumnWidth, Orientation, ToneVariant, StyleWeight, Emphasis, HeadingVariant, BadgeVariant, IconSource, IconSize } from '@fuaran-ui/schema';
|
|
1
|
+
import { Result, NodeId, NodeKind, JsonValue, Binding, SemanticStyle, StateBehaviour, Node, Cell, ColExpr, DataSource, Transform, EvalError, Table, TextSource, CellFormat, ColumnWidth, Orientation, ToneVariant, StyleWeight, Emphasis, TrendPolarity, HeadingVariant, BadgeVariant, IconSource, IconSize, DecodePolicy } from '@fuaran-ui/schema';
|
|
2
2
|
|
|
3
3
|
/** Local JSON AST. Shape-for-shape port of the F# decoder's private `Json` DU. */
|
|
4
4
|
type JsonAst = {
|
|
@@ -23,6 +23,15 @@ type JsonAst = {
|
|
|
23
23
|
interface ParseError {
|
|
24
24
|
readonly message: string;
|
|
25
25
|
readonly offset: number;
|
|
26
|
+
/**
|
|
27
|
+
* True when this failure is a WIRE_FORMAT.md §21 resource-limit breach rather
|
|
28
|
+
* than a syntax error. It exists because the two must not be reported the
|
|
29
|
+
* same way: §21.2 rule 2 forbids reporting a limit breach as `INVALID_JSON`,
|
|
30
|
+
* since the input is well-formed and merely too large to walk, and calling it
|
|
31
|
+
* malformed sends the author to repair the wrong thing. `decodeNode` reads
|
|
32
|
+
* this flag to choose between `INVALID_JSON` and `LIMIT_EXCEEDED`.
|
|
33
|
+
*/
|
|
34
|
+
readonly limit?: boolean;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* Parse a JSON document into the local AST. Mirrors the F# `tryParse`: empty /
|
|
@@ -131,9 +140,37 @@ declare const evalErrorString: (e: EvalError) => string;
|
|
|
131
140
|
declare const stepParams: (t: Transform) => readonly string[];
|
|
132
141
|
/** Every distinct param name a pipeline references — the TS mirror of Core `Transform.paramsOf`. */
|
|
133
142
|
declare const pipelineParams: (pipeline: readonly Transform[]) => readonly string[];
|
|
143
|
+
/**
|
|
144
|
+
* Substitute every `inParam` bound in `listEnv` with the literal `in` form, through the
|
|
145
|
+
* whole pipeline — the TS mirror of Core `Transform.substituteListParams`. Unbound list
|
|
146
|
+
* params are left intact for the caller's prune to catch. Only `filter` / `derive` carry
|
|
147
|
+
* a `ColExpr`; every other step is returned unchanged.
|
|
148
|
+
*/
|
|
149
|
+
declare const substituteListParams: (listEnv: Readonly<Record<string, readonly Cell[]>>, pipeline: readonly Transform[]) => readonly Transform[];
|
|
134
150
|
|
|
135
151
|
/** Stable AI-friendly discriminator for decode-time failures (WIRE_FORMAT.md §6). */
|
|
136
|
-
type DecodeErrorCode = 'INVALID_JSON' | 'MISSING_FIELD' | 'WRONG_TYPE' | 'UNKNOWN_DU_CASE' | 'WRONG_NODE_KIND' | 'EMPTY_NODE_ID'
|
|
152
|
+
type DecodeErrorCode = 'INVALID_JSON' | 'MISSING_FIELD' | 'WRONG_TYPE' | 'UNKNOWN_DU_CASE' | 'WRONG_NODE_KIND' | 'EMPTY_NODE_ID'
|
|
153
|
+
/**
|
|
154
|
+
* A WIRE_FORMAT.md §21 resource limit was exceeded — the document is
|
|
155
|
+
* well-formed and merely too large to walk. Deliberately distinct from
|
|
156
|
+
* `INVALID_JSON`, which §21.2 rule 2 forbids using for this: calling a
|
|
157
|
+
* well-formed document malformed sends the author to repair the wrong thing.
|
|
158
|
+
*/
|
|
159
|
+
| 'LIMIT_EXCEEDED'
|
|
160
|
+
/**
|
|
161
|
+
* The document names a kind the HOST'S DECLARED decode policy does not admit
|
|
162
|
+
* (WIRE_FORMAT.md §23).
|
|
163
|
+
*
|
|
164
|
+
* Deliberately distinct from `WRONG_NODE_KIND`, which says the vocabulary has
|
|
165
|
+
* no such kind. This one says the kind exists and THIS DEPLOYMENT does not
|
|
166
|
+
* take it — a different fact with a different remedy, and conflating them
|
|
167
|
+
* would send a repairing author to invent a spelling that is already correct.
|
|
168
|
+
*
|
|
169
|
+
* Raised ONLY when a caller supplied a narrowing policy. With no policy the
|
|
170
|
+
* code is unreachable, which is what keeps §22's "a decoder owes nothing"
|
|
171
|
+
* true of the default decoder.
|
|
172
|
+
*/
|
|
173
|
+
| 'KIND_NOT_ADMITTED';
|
|
137
174
|
/** AI-recoverable decode-time failure. Mirrors the F# `DecodeError` record. */
|
|
138
175
|
interface DecodeError {
|
|
139
176
|
readonly code: DecodeErrorCode;
|
|
@@ -175,6 +212,8 @@ declare const coerce: {
|
|
|
175
212
|
tone: (v: JsonValue) => Result<ToneVariant, string>;
|
|
176
213
|
weight: (v: JsonValue) => Result<StyleWeight, string>;
|
|
177
214
|
emphasis: (v: JsonValue) => Result<Emphasis, string>;
|
|
215
|
+
/** `Metric.TrendPolarity` (Phase 867) - the UpdateProp twin of `decodeTrendPolarity`. */
|
|
216
|
+
trendPolarity: (v: JsonValue) => Result<TrendPolarity, string>;
|
|
178
217
|
/**
|
|
179
218
|
* The behavioural `emphasis` BOOL on Fact / LabelValueRow — the UpdateProp
|
|
180
219
|
* twin of `decodeEmphasisFlag`, so a TreeOp edit gets the same
|
|
@@ -189,10 +228,34 @@ declare const coerce: {
|
|
|
189
228
|
iconSize: (v: JsonValue) => Result<IconSize, string>;
|
|
190
229
|
stringOption: (v: JsonValue) => Result<string | undefined, string>;
|
|
191
230
|
};
|
|
192
|
-
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Decode a canonical-JSON `Node` payload into the storage-shape `Node<unknown>`.
|
|
233
|
+
*
|
|
234
|
+
* `policy` is the OPTIONAL WIRE_FORMAT §23 host-declared admission policy: a
|
|
235
|
+
* tree naming a kind outside it is refused with `KIND_NOT_ADMITTED` at the
|
|
236
|
+
* offending `kind.$type`, naming the kind and the policy. **Omitted, the decoder
|
|
237
|
+
* has exactly the obligations it had before** — every valid document decodes and
|
|
238
|
+
* the code is unreachable, which is what keeps §22 unqualified. Build a policy
|
|
239
|
+
* with `@fuaran-ui/schema`'s `CLOSED_PROFILE`, `excluding` or `admitting`.
|
|
240
|
+
*
|
|
241
|
+
* The reference host spells this as a sibling entry point rather than an
|
|
242
|
+
* optional argument, because F# optional parameters exist only on type members
|
|
243
|
+
* and defaulting in place would reshape its whole decoder surface. What the two
|
|
244
|
+
* hosts owe each other is the same behaviour on the same bytes, not the same
|
|
245
|
+
* arity — the `decode-policy/` corpus family is where that is asserted.
|
|
246
|
+
*/
|
|
247
|
+
declare const decodeNode: (json: string, policy?: DecodePolicy) => R<Node<unknown>>;
|
|
248
|
+
/**
|
|
249
|
+
* Decode a canonical-JSON `TreeOp` payload into the storage-shape
|
|
250
|
+
* `TreeOp<unknown>`.
|
|
251
|
+
*
|
|
252
|
+
* `policy` is the optional §23 admission policy. A node kind reaches an op two
|
|
253
|
+
* ways — inside a node-bearing operation, and as `EditNode`'s replacement kind —
|
|
254
|
+
* and both are gated, because an op stream that could introduce a refused kind
|
|
255
|
+
* into an admitted tree would make the policy a property of the first decode
|
|
256
|
+
* only rather than a closure.
|
|
257
|
+
*/
|
|
258
|
+
declare const decodeOp: (json: string, policy?: DecodePolicy) => R<TreeOp<unknown>>;
|
|
196
259
|
|
|
197
260
|
type ApplyErrorCode = 'NodeNotFound' | 'ParentNotFound' | 'ChildlessKind' | 'PositionOutOfRange' | 'DuplicateNodeId' | 'FieldNotFound' | 'SlotNotFound' | 'KindMismatch' | 'PathInvalid' | 'PathNotSupportedYet' | 'OrderingMismatch' | 'BatchAborted';
|
|
198
261
|
interface ApplyError {
|
|
@@ -379,6 +442,22 @@ declare const pasteOpWith: <TMsg>(freshIds: FreshIds, targetRoot: Node<TMsg>, in
|
|
|
379
442
|
/** `pasteOpWith` under the default derived-suffix id strategy. */
|
|
380
443
|
declare const pasteOp: <TMsg>(targetRoot: Node<TMsg>, incoming: Node<TMsg>, target: PlaceTarget) => Result<TreeOp<TMsg>, PlaceError>;
|
|
381
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Who authored a DAG op. Structurally identical to `Actor` in
|
|
447
|
+
* `@fuaran-ui/op-stream`, and DELIBERATELY declared here rather than imported:
|
|
448
|
+
* op-stream depends on this package, so importing it would invert the package
|
|
449
|
+
* dependency. TypeScript is structurally typed, so an op-stream `Actor` is
|
|
450
|
+
* assignable here and vice versa with no import and no new dependency edge.
|
|
451
|
+
*/
|
|
452
|
+
type DagActor = {
|
|
453
|
+
readonly kind: 'human';
|
|
454
|
+
readonly id: string;
|
|
455
|
+
} | {
|
|
456
|
+
readonly kind: 'agent';
|
|
457
|
+
readonly model: string;
|
|
458
|
+
readonly version: string;
|
|
459
|
+
readonly id: string;
|
|
460
|
+
};
|
|
382
461
|
/** The result envelope captured on a DAG record (closed shape). */
|
|
383
462
|
type DagResultEnvelope = {
|
|
384
463
|
readonly $type: 'Success';
|
|
@@ -401,7 +480,7 @@ interface DagOpRecord<TMsg = unknown> {
|
|
|
401
480
|
readonly op: TreeOp<TMsg>;
|
|
402
481
|
readonly outcomeHash?: string;
|
|
403
482
|
readonly promptId?: string;
|
|
404
|
-
readonly
|
|
483
|
+
readonly actor: DagActor;
|
|
405
484
|
/** Unix seconds. */
|
|
406
485
|
readonly timestamp: number;
|
|
407
486
|
readonly resultEnvelope: DagResultEnvelope;
|
|
@@ -409,10 +488,10 @@ interface DagOpRecord<TMsg = unknown> {
|
|
|
409
488
|
}
|
|
410
489
|
/**
|
|
411
490
|
* Encode a `DagOpRecord` to its canonical JSON wire form. Keys in Ordinal order
|
|
412
|
-
* (hash < op < outcomeHash < parents < promptId < resultEnvelope <
|
|
413
|
-
*
|
|
414
|
-
* absent; `op` nests `encodeOp`
|
|
415
|
-
* `DagWire.encodeRecord`.
|
|
491
|
+
* (actor < hash < op < outcomeHash < parents < promptId < resultEnvelope <
|
|
492
|
+
* streamId < timestamp < tombstoned); `outcomeHash` / `promptId` omitted when
|
|
493
|
+
* absent; `op` nests `encodeOp` and `actor` nests the canonical actor form
|
|
494
|
+
* verbatim. Byte-identical to the F# `DagWire.encodeRecord`.
|
|
416
495
|
*/
|
|
417
496
|
declare const encodeDagRecord: <TMsg>(record: DagOpRecord<TMsg>) => string;
|
|
418
497
|
type DecodeResult<T> = {
|
|
@@ -729,4 +808,36 @@ declare const decodeElicitationOutcome: (json: string) => Result<ElicitationOutc
|
|
|
729
808
|
*/
|
|
730
809
|
declare const validateAnswerDocument: (json: string) => Result<undefined, ElicitationError>;
|
|
731
810
|
|
|
732
|
-
|
|
811
|
+
/**
|
|
812
|
+
* Keys under this prefix are HOST-OWNED: a tree-originated write naming one is
|
|
813
|
+
* refused, so a tree-originated SEED naming one must be too.
|
|
814
|
+
*
|
|
815
|
+
* Declared here rather than imported because the TypeScript tier carries no
|
|
816
|
+
* shared state-key policy module (the F# tier's `Fuaran.UI.StateKeyPolicy`).
|
|
817
|
+
* It must stay in step with that definition — there is one prefix, and a host
|
|
818
|
+
* that names a slot `host.<whatever>` is entitled to have every tier honour it.
|
|
819
|
+
*/
|
|
820
|
+
declare const HOST_RESERVED_PREFIX = "host.";
|
|
821
|
+
/**
|
|
822
|
+
* Collect the seed map for a tree: the value each `$state.<key>` slot carries
|
|
823
|
+
* before anything else has said anything.
|
|
824
|
+
*
|
|
825
|
+
* Order-independent by construction (charter §5) — the whole tree is walked
|
|
826
|
+
* before any binding resolves, so a badge declared before the grid that carries
|
|
827
|
+
* its rows is not a special case.
|
|
828
|
+
*/
|
|
829
|
+
declare const collectStateSeeds: <TMsg>(tree: Node<TMsg>) => Readonly<Record<string, unknown>>;
|
|
830
|
+
/**
|
|
831
|
+
* Lay a tree's seeds UNDER a host's own binding sources. The host's map wins on
|
|
832
|
+
* every key it names — a seed is the value before anything else has said
|
|
833
|
+
* anything, never an override, which is the only reading consistent with the
|
|
834
|
+
* wire's standing posture that the host owns named data.
|
|
835
|
+
*
|
|
836
|
+
* Returns the caller's own object unchanged when the tree declares nothing, so
|
|
837
|
+
* an unseeded tree costs one walk and no allocation.
|
|
838
|
+
*/
|
|
839
|
+
declare const withStateSeeds: <TMsg, S extends {
|
|
840
|
+
readonly state?: Readonly<Record<string, unknown>>;
|
|
841
|
+
}>(tree: Node<TMsg>, sources: S) => S;
|
|
842
|
+
|
|
843
|
+
export { type Answer, type AnswerContract, type AnswerField, type AnswerSpace, type AnswerValue, type ApplyError, type ApplyErrorCode, type ApplyResult, type Compatibility, type DagActor, type DagOpRecord, type DagResultEnvelope, type DecodeError, type DecodeErrorCode, type Decoded, ELICITATION_KEY, ELICITATION_VERSION, type ElicitationEnvelope, type ElicitationError, type ElicitationErrorCode, type ElicitationOutcome, type ElicitationOutcomeEnvelope, type Envelope, type EnvelopeError, type EnvelopeErrorCode, type EvalEnv, type FreshIds, HOST_RESERVED_PREFIX, type JsonAst, type MergeConflict, type MergeResult, type OpApplyTelemetryRecord, PAYLOAD_KEY, PROFILE_KEY, type ParseError, type PlaceError, type PlaceTarget, type Placement, type Profile, REQUIRED_PROFILE_KEY, type SourceResolver, type TreeOp, type UnknownKind, apply, canPlace, cellString, coerce, collectStateSeeds, coreV1, decodeDagRecord, decodeElicitation, decodeElicitationOutcome, decodeEnvelope, decodeEnvelopeAst, decodeNode, decodeNodeTolerant, decodeOp, decodeTolerant, derivedFreshIds, duplicateOp, duplicateOpWith, encodeCell, encodeColExpr, encodeDagRecord, encodeDataSource, encodeElicitation, encodeElicitationOutcome, encodeEnvelope, encodeNode, encodeOp, encodePipeline, evalErrorString, evalPipeline, evalPipelineInEnv, evalPipelineWith, evalPipelineWithInEnv, evalSource, field as jsonField, liveValueToTable, merge3Way, moveOp, negotiate, negotiateEnvelope, noResolve, nudgeOp, parse, pasteOp, pasteOpWith, pipelineParams, placeOp, reencodeNode, renderAstCanonical, renderProfile, sequentialFreshIds, stepParams, substituteListParams, tryParseProfile, validateAnswer, validateAnswerAt, validateAnswerDocument, withStateSeeds };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result, NodeId, NodeKind, JsonValue, Binding, SemanticStyle, StateBehaviour, Node, Cell, ColExpr, DataSource, Transform, EvalError, Table, TextSource, CellFormat, ColumnWidth, Orientation, ToneVariant, StyleWeight, Emphasis, HeadingVariant, BadgeVariant, IconSource, IconSize } from '@fuaran-ui/schema';
|
|
1
|
+
import { Result, NodeId, NodeKind, JsonValue, Binding, SemanticStyle, StateBehaviour, Node, Cell, ColExpr, DataSource, Transform, EvalError, Table, TextSource, CellFormat, ColumnWidth, Orientation, ToneVariant, StyleWeight, Emphasis, TrendPolarity, HeadingVariant, BadgeVariant, IconSource, IconSize, DecodePolicy } from '@fuaran-ui/schema';
|
|
2
2
|
|
|
3
3
|
/** Local JSON AST. Shape-for-shape port of the F# decoder's private `Json` DU. */
|
|
4
4
|
type JsonAst = {
|
|
@@ -23,6 +23,15 @@ type JsonAst = {
|
|
|
23
23
|
interface ParseError {
|
|
24
24
|
readonly message: string;
|
|
25
25
|
readonly offset: number;
|
|
26
|
+
/**
|
|
27
|
+
* True when this failure is a WIRE_FORMAT.md §21 resource-limit breach rather
|
|
28
|
+
* than a syntax error. It exists because the two must not be reported the
|
|
29
|
+
* same way: §21.2 rule 2 forbids reporting a limit breach as `INVALID_JSON`,
|
|
30
|
+
* since the input is well-formed and merely too large to walk, and calling it
|
|
31
|
+
* malformed sends the author to repair the wrong thing. `decodeNode` reads
|
|
32
|
+
* this flag to choose between `INVALID_JSON` and `LIMIT_EXCEEDED`.
|
|
33
|
+
*/
|
|
34
|
+
readonly limit?: boolean;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* Parse a JSON document into the local AST. Mirrors the F# `tryParse`: empty /
|
|
@@ -131,9 +140,37 @@ declare const evalErrorString: (e: EvalError) => string;
|
|
|
131
140
|
declare const stepParams: (t: Transform) => readonly string[];
|
|
132
141
|
/** Every distinct param name a pipeline references — the TS mirror of Core `Transform.paramsOf`. */
|
|
133
142
|
declare const pipelineParams: (pipeline: readonly Transform[]) => readonly string[];
|
|
143
|
+
/**
|
|
144
|
+
* Substitute every `inParam` bound in `listEnv` with the literal `in` form, through the
|
|
145
|
+
* whole pipeline — the TS mirror of Core `Transform.substituteListParams`. Unbound list
|
|
146
|
+
* params are left intact for the caller's prune to catch. Only `filter` / `derive` carry
|
|
147
|
+
* a `ColExpr`; every other step is returned unchanged.
|
|
148
|
+
*/
|
|
149
|
+
declare const substituteListParams: (listEnv: Readonly<Record<string, readonly Cell[]>>, pipeline: readonly Transform[]) => readonly Transform[];
|
|
134
150
|
|
|
135
151
|
/** Stable AI-friendly discriminator for decode-time failures (WIRE_FORMAT.md §6). */
|
|
136
|
-
type DecodeErrorCode = 'INVALID_JSON' | 'MISSING_FIELD' | 'WRONG_TYPE' | 'UNKNOWN_DU_CASE' | 'WRONG_NODE_KIND' | 'EMPTY_NODE_ID'
|
|
152
|
+
type DecodeErrorCode = 'INVALID_JSON' | 'MISSING_FIELD' | 'WRONG_TYPE' | 'UNKNOWN_DU_CASE' | 'WRONG_NODE_KIND' | 'EMPTY_NODE_ID'
|
|
153
|
+
/**
|
|
154
|
+
* A WIRE_FORMAT.md §21 resource limit was exceeded — the document is
|
|
155
|
+
* well-formed and merely too large to walk. Deliberately distinct from
|
|
156
|
+
* `INVALID_JSON`, which §21.2 rule 2 forbids using for this: calling a
|
|
157
|
+
* well-formed document malformed sends the author to repair the wrong thing.
|
|
158
|
+
*/
|
|
159
|
+
| 'LIMIT_EXCEEDED'
|
|
160
|
+
/**
|
|
161
|
+
* The document names a kind the HOST'S DECLARED decode policy does not admit
|
|
162
|
+
* (WIRE_FORMAT.md §23).
|
|
163
|
+
*
|
|
164
|
+
* Deliberately distinct from `WRONG_NODE_KIND`, which says the vocabulary has
|
|
165
|
+
* no such kind. This one says the kind exists and THIS DEPLOYMENT does not
|
|
166
|
+
* take it — a different fact with a different remedy, and conflating them
|
|
167
|
+
* would send a repairing author to invent a spelling that is already correct.
|
|
168
|
+
*
|
|
169
|
+
* Raised ONLY when a caller supplied a narrowing policy. With no policy the
|
|
170
|
+
* code is unreachable, which is what keeps §22's "a decoder owes nothing"
|
|
171
|
+
* true of the default decoder.
|
|
172
|
+
*/
|
|
173
|
+
| 'KIND_NOT_ADMITTED';
|
|
137
174
|
/** AI-recoverable decode-time failure. Mirrors the F# `DecodeError` record. */
|
|
138
175
|
interface DecodeError {
|
|
139
176
|
readonly code: DecodeErrorCode;
|
|
@@ -175,6 +212,8 @@ declare const coerce: {
|
|
|
175
212
|
tone: (v: JsonValue) => Result<ToneVariant, string>;
|
|
176
213
|
weight: (v: JsonValue) => Result<StyleWeight, string>;
|
|
177
214
|
emphasis: (v: JsonValue) => Result<Emphasis, string>;
|
|
215
|
+
/** `Metric.TrendPolarity` (Phase 867) - the UpdateProp twin of `decodeTrendPolarity`. */
|
|
216
|
+
trendPolarity: (v: JsonValue) => Result<TrendPolarity, string>;
|
|
178
217
|
/**
|
|
179
218
|
* The behavioural `emphasis` BOOL on Fact / LabelValueRow — the UpdateProp
|
|
180
219
|
* twin of `decodeEmphasisFlag`, so a TreeOp edit gets the same
|
|
@@ -189,10 +228,34 @@ declare const coerce: {
|
|
|
189
228
|
iconSize: (v: JsonValue) => Result<IconSize, string>;
|
|
190
229
|
stringOption: (v: JsonValue) => Result<string | undefined, string>;
|
|
191
230
|
};
|
|
192
|
-
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Decode a canonical-JSON `Node` payload into the storage-shape `Node<unknown>`.
|
|
233
|
+
*
|
|
234
|
+
* `policy` is the OPTIONAL WIRE_FORMAT §23 host-declared admission policy: a
|
|
235
|
+
* tree naming a kind outside it is refused with `KIND_NOT_ADMITTED` at the
|
|
236
|
+
* offending `kind.$type`, naming the kind and the policy. **Omitted, the decoder
|
|
237
|
+
* has exactly the obligations it had before** — every valid document decodes and
|
|
238
|
+
* the code is unreachable, which is what keeps §22 unqualified. Build a policy
|
|
239
|
+
* with `@fuaran-ui/schema`'s `CLOSED_PROFILE`, `excluding` or `admitting`.
|
|
240
|
+
*
|
|
241
|
+
* The reference host spells this as a sibling entry point rather than an
|
|
242
|
+
* optional argument, because F# optional parameters exist only on type members
|
|
243
|
+
* and defaulting in place would reshape its whole decoder surface. What the two
|
|
244
|
+
* hosts owe each other is the same behaviour on the same bytes, not the same
|
|
245
|
+
* arity — the `decode-policy/` corpus family is where that is asserted.
|
|
246
|
+
*/
|
|
247
|
+
declare const decodeNode: (json: string, policy?: DecodePolicy) => R<Node<unknown>>;
|
|
248
|
+
/**
|
|
249
|
+
* Decode a canonical-JSON `TreeOp` payload into the storage-shape
|
|
250
|
+
* `TreeOp<unknown>`.
|
|
251
|
+
*
|
|
252
|
+
* `policy` is the optional §23 admission policy. A node kind reaches an op two
|
|
253
|
+
* ways — inside a node-bearing operation, and as `EditNode`'s replacement kind —
|
|
254
|
+
* and both are gated, because an op stream that could introduce a refused kind
|
|
255
|
+
* into an admitted tree would make the policy a property of the first decode
|
|
256
|
+
* only rather than a closure.
|
|
257
|
+
*/
|
|
258
|
+
declare const decodeOp: (json: string, policy?: DecodePolicy) => R<TreeOp<unknown>>;
|
|
196
259
|
|
|
197
260
|
type ApplyErrorCode = 'NodeNotFound' | 'ParentNotFound' | 'ChildlessKind' | 'PositionOutOfRange' | 'DuplicateNodeId' | 'FieldNotFound' | 'SlotNotFound' | 'KindMismatch' | 'PathInvalid' | 'PathNotSupportedYet' | 'OrderingMismatch' | 'BatchAborted';
|
|
198
261
|
interface ApplyError {
|
|
@@ -379,6 +442,22 @@ declare const pasteOpWith: <TMsg>(freshIds: FreshIds, targetRoot: Node<TMsg>, in
|
|
|
379
442
|
/** `pasteOpWith` under the default derived-suffix id strategy. */
|
|
380
443
|
declare const pasteOp: <TMsg>(targetRoot: Node<TMsg>, incoming: Node<TMsg>, target: PlaceTarget) => Result<TreeOp<TMsg>, PlaceError>;
|
|
381
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Who authored a DAG op. Structurally identical to `Actor` in
|
|
447
|
+
* `@fuaran-ui/op-stream`, and DELIBERATELY declared here rather than imported:
|
|
448
|
+
* op-stream depends on this package, so importing it would invert the package
|
|
449
|
+
* dependency. TypeScript is structurally typed, so an op-stream `Actor` is
|
|
450
|
+
* assignable here and vice versa with no import and no new dependency edge.
|
|
451
|
+
*/
|
|
452
|
+
type DagActor = {
|
|
453
|
+
readonly kind: 'human';
|
|
454
|
+
readonly id: string;
|
|
455
|
+
} | {
|
|
456
|
+
readonly kind: 'agent';
|
|
457
|
+
readonly model: string;
|
|
458
|
+
readonly version: string;
|
|
459
|
+
readonly id: string;
|
|
460
|
+
};
|
|
382
461
|
/** The result envelope captured on a DAG record (closed shape). */
|
|
383
462
|
type DagResultEnvelope = {
|
|
384
463
|
readonly $type: 'Success';
|
|
@@ -401,7 +480,7 @@ interface DagOpRecord<TMsg = unknown> {
|
|
|
401
480
|
readonly op: TreeOp<TMsg>;
|
|
402
481
|
readonly outcomeHash?: string;
|
|
403
482
|
readonly promptId?: string;
|
|
404
|
-
readonly
|
|
483
|
+
readonly actor: DagActor;
|
|
405
484
|
/** Unix seconds. */
|
|
406
485
|
readonly timestamp: number;
|
|
407
486
|
readonly resultEnvelope: DagResultEnvelope;
|
|
@@ -409,10 +488,10 @@ interface DagOpRecord<TMsg = unknown> {
|
|
|
409
488
|
}
|
|
410
489
|
/**
|
|
411
490
|
* Encode a `DagOpRecord` to its canonical JSON wire form. Keys in Ordinal order
|
|
412
|
-
* (hash < op < outcomeHash < parents < promptId < resultEnvelope <
|
|
413
|
-
*
|
|
414
|
-
* absent; `op` nests `encodeOp`
|
|
415
|
-
* `DagWire.encodeRecord`.
|
|
491
|
+
* (actor < hash < op < outcomeHash < parents < promptId < resultEnvelope <
|
|
492
|
+
* streamId < timestamp < tombstoned); `outcomeHash` / `promptId` omitted when
|
|
493
|
+
* absent; `op` nests `encodeOp` and `actor` nests the canonical actor form
|
|
494
|
+
* verbatim. Byte-identical to the F# `DagWire.encodeRecord`.
|
|
416
495
|
*/
|
|
417
496
|
declare const encodeDagRecord: <TMsg>(record: DagOpRecord<TMsg>) => string;
|
|
418
497
|
type DecodeResult<T> = {
|
|
@@ -729,4 +808,36 @@ declare const decodeElicitationOutcome: (json: string) => Result<ElicitationOutc
|
|
|
729
808
|
*/
|
|
730
809
|
declare const validateAnswerDocument: (json: string) => Result<undefined, ElicitationError>;
|
|
731
810
|
|
|
732
|
-
|
|
811
|
+
/**
|
|
812
|
+
* Keys under this prefix are HOST-OWNED: a tree-originated write naming one is
|
|
813
|
+
* refused, so a tree-originated SEED naming one must be too.
|
|
814
|
+
*
|
|
815
|
+
* Declared here rather than imported because the TypeScript tier carries no
|
|
816
|
+
* shared state-key policy module (the F# tier's `Fuaran.UI.StateKeyPolicy`).
|
|
817
|
+
* It must stay in step with that definition — there is one prefix, and a host
|
|
818
|
+
* that names a slot `host.<whatever>` is entitled to have every tier honour it.
|
|
819
|
+
*/
|
|
820
|
+
declare const HOST_RESERVED_PREFIX = "host.";
|
|
821
|
+
/**
|
|
822
|
+
* Collect the seed map for a tree: the value each `$state.<key>` slot carries
|
|
823
|
+
* before anything else has said anything.
|
|
824
|
+
*
|
|
825
|
+
* Order-independent by construction (charter §5) — the whole tree is walked
|
|
826
|
+
* before any binding resolves, so a badge declared before the grid that carries
|
|
827
|
+
* its rows is not a special case.
|
|
828
|
+
*/
|
|
829
|
+
declare const collectStateSeeds: <TMsg>(tree: Node<TMsg>) => Readonly<Record<string, unknown>>;
|
|
830
|
+
/**
|
|
831
|
+
* Lay a tree's seeds UNDER a host's own binding sources. The host's map wins on
|
|
832
|
+
* every key it names — a seed is the value before anything else has said
|
|
833
|
+
* anything, never an override, which is the only reading consistent with the
|
|
834
|
+
* wire's standing posture that the host owns named data.
|
|
835
|
+
*
|
|
836
|
+
* Returns the caller's own object unchanged when the tree declares nothing, so
|
|
837
|
+
* an unseeded tree costs one walk and no allocation.
|
|
838
|
+
*/
|
|
839
|
+
declare const withStateSeeds: <TMsg, S extends {
|
|
840
|
+
readonly state?: Readonly<Record<string, unknown>>;
|
|
841
|
+
}>(tree: Node<TMsg>, sources: S) => S;
|
|
842
|
+
|
|
843
|
+
export { type Answer, type AnswerContract, type AnswerField, type AnswerSpace, type AnswerValue, type ApplyError, type ApplyErrorCode, type ApplyResult, type Compatibility, type DagActor, type DagOpRecord, type DagResultEnvelope, type DecodeError, type DecodeErrorCode, type Decoded, ELICITATION_KEY, ELICITATION_VERSION, type ElicitationEnvelope, type ElicitationError, type ElicitationErrorCode, type ElicitationOutcome, type ElicitationOutcomeEnvelope, type Envelope, type EnvelopeError, type EnvelopeErrorCode, type EvalEnv, type FreshIds, HOST_RESERVED_PREFIX, type JsonAst, type MergeConflict, type MergeResult, type OpApplyTelemetryRecord, PAYLOAD_KEY, PROFILE_KEY, type ParseError, type PlaceError, type PlaceTarget, type Placement, type Profile, REQUIRED_PROFILE_KEY, type SourceResolver, type TreeOp, type UnknownKind, apply, canPlace, cellString, coerce, collectStateSeeds, coreV1, decodeDagRecord, decodeElicitation, decodeElicitationOutcome, decodeEnvelope, decodeEnvelopeAst, decodeNode, decodeNodeTolerant, decodeOp, decodeTolerant, derivedFreshIds, duplicateOp, duplicateOpWith, encodeCell, encodeColExpr, encodeDagRecord, encodeDataSource, encodeElicitation, encodeElicitationOutcome, encodeEnvelope, encodeNode, encodeOp, encodePipeline, evalErrorString, evalPipeline, evalPipelineInEnv, evalPipelineWith, evalPipelineWithInEnv, evalSource, field as jsonField, liveValueToTable, merge3Way, moveOp, negotiate, negotiateEnvelope, noResolve, nudgeOp, parse, pasteOp, pasteOpWith, pipelineParams, placeOp, reencodeNode, renderAstCanonical, renderProfile, sequentialFreshIds, stepParams, substituteListParams, tryParseProfile, validateAnswer, validateAnswerAt, validateAnswerDocument, withStateSeeds };
|