@ai-matrx/content-ir 0.1.2 → 0.2.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/CHANGELOG.md +38 -0
- package/README.md +6 -0
- package/dist/index.cjs +345 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +340 -6
- package/dist/index.d.ts +340 -6
- package/dist/index.js +328 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 — 2026-08-24
|
|
4
|
+
|
|
5
|
+
- **FIX — `validateStructuralLeg` no longer rejects every current kind
|
|
6
|
+
instance.** The leg validated ONLY the `__kind`-stripped copy of the sample,
|
|
7
|
+
a leftover from the dead "marker is envelope framing" doctrine. Since the
|
|
8
|
+
2026-08-23 ruling every `emitted_json_schema` DECLARES `__kind` (const +
|
|
9
|
+
required), so stripping turned a valid instance into
|
|
10
|
+
`(root) must have required property '__kind'` — 503 of the 842 live kind
|
|
11
|
+
definitions, i.e. every marker-declaring kind, failed the Shape Studio Test
|
|
12
|
+
tab, the gate tab, the example manager, and instance save. The leg now
|
|
13
|
+
validates the caller's value VERBATIM and only retries the marker-free
|
|
14
|
+
reduction if that fails (backward compatibility for a row still pinned to a
|
|
15
|
+
pre-2026-08-23 marker-free schema), and reports the errors from whichever
|
|
16
|
+
attempt matches the schema in hand.
|
|
17
|
+
- `JsonTokenizer` and `KindStreamParser` declare explicit fields instead of
|
|
18
|
+
constructor parameter properties. Consumers compile this SOURCE directly, and
|
|
19
|
+
a strict host (`apps/dashboard`) sets `erasableSyntaxOnly`, under which
|
|
20
|
+
parameter properties are a hard error — the flag had to be turned off in
|
|
21
|
+
Workflow Studio for exactly this reason, and is now back on. Behaviour is
|
|
22
|
+
unchanged; the published 0.2.0 tarball does not carry this edit.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 0.2.0 — 2026-08-23
|
|
26
|
+
|
|
27
|
+
- Added the `wire/` layer — the server→UI contracts every UI reads the same way:
|
|
28
|
+
- `wire/partial-kind` — the streaming partial-kinds channel (`__ir_partial`): `readPartialKindEvent`,
|
|
29
|
+
`sanitizeInboundPartialKindMetadata`, `advancePartialKind`, `makePartialKindStalenessGate`,
|
|
30
|
+
`isProvisionalKind`, `isTerminalKindEvent`, `IR_PARTIAL_KEY` + the event types.
|
|
31
|
+
- `wire/runtime-wrapper` — the `node_outcome` / `run_result` runtime-wrapper reader and THE `output_ref`
|
|
32
|
+
elision gate: `readOutputRef`, `rehydrateNodeOutcome`, `rehydrateRunResult`, `readNodeOutcomeValue`,
|
|
33
|
+
`readRunResultValue`, `kindVerdictOf`, `NODE_OUTCOME_KIND`, `RUN_RESULT_KIND` + the wrapper types.
|
|
34
|
+
- `wire/emit-payload` — the emit/render payload composer: `withRootKind`, `emitPayloadJson`, `emitPayloadFence`.
|
|
35
|
+
- Brought the partial-kind suite pinned to the Python producer's generated fixture
|
|
36
|
+
(`__tests__/partial-kind-events.generated.json`, regenerated by aidream `scripts/generate_partial_kind_fixture.py`
|
|
37
|
+
and drift-gated by `packages/matrx-ai/tests/parity/test_partial_kind_fixture.py`) plus new pure suites for the
|
|
38
|
+
runtime-wrapper reader and the emit composer (196 tests).
|
|
39
|
+
- Existing 0.1.x API unchanged.
|
|
40
|
+
|
|
3
41
|
## 0.1.2 — 2026-08-22
|
|
4
42
|
|
|
5
43
|
- Added a CommonJS export condition for Jest and other require-based consumers.
|
package/README.md
CHANGED
|
@@ -11,6 +11,12 @@ import {
|
|
|
11
11
|
createKindStreamParser,
|
|
12
12
|
envelopeFromCompleteValue,
|
|
13
13
|
validateStructuralLeg,
|
|
14
|
+
// wire layer (0.2.0): streaming partial kinds + runtime wrappers + emit payload
|
|
15
|
+
readPartialKindEvent,
|
|
16
|
+
makePartialKindStalenessGate,
|
|
17
|
+
rehydrateNodeOutcome,
|
|
18
|
+
rehydrateRunResult,
|
|
19
|
+
withRootKind,
|
|
14
20
|
} from "@ai-matrx/content-ir";
|
|
15
21
|
```
|
|
16
22
|
|
package/dist/index.cjs
CHANGED
|
@@ -404,16 +404,19 @@ var IrTree = class {
|
|
|
404
404
|
|
|
405
405
|
// core/json-tokenizer.ts
|
|
406
406
|
var JsonStreamTokenizer = class {
|
|
407
|
-
constructor(onToken) {
|
|
408
|
-
this.onToken = onToken;
|
|
409
|
-
}
|
|
410
|
-
onToken;
|
|
411
407
|
mode = "normal";
|
|
412
408
|
pos = 0;
|
|
413
409
|
stringBuffer = "";
|
|
414
410
|
primitiveBuffer = "";
|
|
415
411
|
unicodeBuffer = "";
|
|
416
412
|
tokenStart = 0;
|
|
413
|
+
onToken;
|
|
414
|
+
// Explicit field rather than a parameter property: consumers compile this
|
|
415
|
+
// source directly, and a strict host (the dashboard) sets
|
|
416
|
+
// `erasableSyntaxOnly`, under which parameter properties are a hard error.
|
|
417
|
+
constructor(onToken) {
|
|
418
|
+
this.onToken = onToken;
|
|
419
|
+
}
|
|
417
420
|
get position() {
|
|
418
421
|
return this.pos;
|
|
419
422
|
}
|
|
@@ -636,16 +639,6 @@ function safeCopy(value) {
|
|
|
636
639
|
}
|
|
637
640
|
}
|
|
638
641
|
var KindStreamParser = class {
|
|
639
|
-
constructor(options) {
|
|
640
|
-
this.options = options;
|
|
641
|
-
this.resolver = isSchemaResolver(options.schemas) ? options.schemas : {
|
|
642
|
-
get: (kind) => options.schemas[kind]
|
|
643
|
-
};
|
|
644
|
-
this.tokenizer = new JsonStreamTokenizer(
|
|
645
|
-
(token) => this.handleToken(token)
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
options;
|
|
649
642
|
resolver;
|
|
650
643
|
stack = [];
|
|
651
644
|
objectKinds = /* @__PURE__ */ new Map();
|
|
@@ -680,6 +673,18 @@ var KindStreamParser = class {
|
|
|
680
673
|
rootKind = "";
|
|
681
674
|
rootDone = false;
|
|
682
675
|
failed = false;
|
|
676
|
+
options;
|
|
677
|
+
// Explicit field, not a parameter property — see the note in
|
|
678
|
+
// `json-tokenizer.ts`: `erasableSyntaxOnly` hosts compile this source.
|
|
679
|
+
constructor(options) {
|
|
680
|
+
this.options = options;
|
|
681
|
+
this.resolver = isSchemaResolver(options.schemas) ? options.schemas : {
|
|
682
|
+
get: (kind) => options.schemas[kind]
|
|
683
|
+
};
|
|
684
|
+
this.tokenizer = new JsonStreamTokenizer(
|
|
685
|
+
(token) => this.handleToken(token)
|
|
686
|
+
);
|
|
687
|
+
}
|
|
683
688
|
push(chunk) {
|
|
684
689
|
if (this.failed || this.rootDone) return;
|
|
685
690
|
try {
|
|
@@ -2773,6 +2778,12 @@ function storageToKindSchema(kind, shape) {
|
|
|
2773
2778
|
}
|
|
2774
2779
|
return { kind, fields };
|
|
2775
2780
|
}
|
|
2781
|
+
var GENERIC_FALLBACK_COMPONENT_KEY = "generic_structured";
|
|
2782
|
+
function satisfies(resolved) {
|
|
2783
|
+
return Boolean(
|
|
2784
|
+
resolved?.isActive && resolved.componentKey !== GENERIC_FALLBACK_COMPONENT_KEY
|
|
2785
|
+
);
|
|
2786
|
+
}
|
|
2776
2787
|
var ajv = new Ajv__default.default({ allErrors: true, strict: false });
|
|
2777
2788
|
function stripKind(value) {
|
|
2778
2789
|
if (Array.isArray(value)) return value.map(stripKind);
|
|
@@ -2786,6 +2797,14 @@ function stripKind(value) {
|
|
|
2786
2797
|
}
|
|
2787
2798
|
return value;
|
|
2788
2799
|
}
|
|
2800
|
+
function describeAjvErrors(errors) {
|
|
2801
|
+
return (errors ?? []).map((e) => `${e.instancePath || "(root)"} ${e.message ?? ""}`.trim()).slice(0, 8);
|
|
2802
|
+
}
|
|
2803
|
+
function schemaDeclaresKind(emittedJsonSchema) {
|
|
2804
|
+
if (!emittedJsonSchema || typeof emittedJsonSchema !== "object") return false;
|
|
2805
|
+
const properties = emittedJsonSchema.properties;
|
|
2806
|
+
return !!properties && typeof properties === "object" && KIND_KEY in properties;
|
|
2807
|
+
}
|
|
2789
2808
|
function validateStructuralLeg(sample, emittedJsonSchema) {
|
|
2790
2809
|
let validate;
|
|
2791
2810
|
try {
|
|
@@ -2796,9 +2815,11 @@ function validateStructuralLeg(sample, emittedJsonSchema) {
|
|
|
2796
2815
|
detail: `emitted_json_schema failed to compile: ${err instanceof Error ? err.message : String(err)}`
|
|
2797
2816
|
};
|
|
2798
2817
|
}
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2818
|
+
if (validate(sample)) return { ok: true };
|
|
2819
|
+
const markedErrors = describeAjvErrors(validate.errors);
|
|
2820
|
+
if (validate(stripKind(sample))) return { ok: true };
|
|
2821
|
+
const strippedErrors = describeAjvErrors(validate.errors);
|
|
2822
|
+
const errors = schemaDeclaresKind(emittedJsonSchema) ? markedErrors : strippedErrors;
|
|
2802
2823
|
return { ok: false, detail: `sample failed schema: ${errors.join("; ")}` };
|
|
2803
2824
|
}
|
|
2804
2825
|
var SERVER_DATA_ANNOTATION_KEYS = /* @__PURE__ */ new Set(["language"]);
|
|
@@ -2848,16 +2869,18 @@ function validateRender(kind, sample, definition, resolvedComponent, dataOnly) {
|
|
|
2848
2869
|
detail: "data-only contract kind \u2014 render leg is structurally inapplicable (n/a)"
|
|
2849
2870
|
};
|
|
2850
2871
|
}
|
|
2851
|
-
|
|
2872
|
+
const onlyFallback = resolvedComponent?.isActive && resolvedComponent.componentKey === GENERIC_FALLBACK_COMPONENT_KEY;
|
|
2873
|
+
const noComponentDetail = onlyFallback ? `the only active role='output' component for kind "${kind}" is '${GENERIC_FALLBACK_COMPONENT_KEY}' \u2014 that IS the generic viewer, i.e. no component. A reader would get a key/value dump. Author a real source='db' component (or register a compiled one), then retire the generic row.` : null;
|
|
2874
|
+
if (!definition && !satisfies(resolvedComponent)) {
|
|
2852
2875
|
return {
|
|
2853
2876
|
ok: false,
|
|
2854
|
-
detail: `kind "${kind}" has no component (not in the compiled registry, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2877
|
+
detail: noComponentDetail ?? `kind "${kind}" has no component (not in the compiled registry, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2855
2878
|
};
|
|
2856
2879
|
}
|
|
2857
|
-
if (definition && !definition.legacyBlockType && !definition.component && !definition.toLegacyServerData && !resolvedComponent
|
|
2880
|
+
if (definition && !definition.legacyBlockType && !definition.component && !definition.toLegacyServerData && !satisfies(resolvedComponent)) {
|
|
2858
2881
|
return {
|
|
2859
2882
|
ok: false,
|
|
2860
|
-
detail: `kind "${kind}" has no component (no compiled legacyBlockType/component facet, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2883
|
+
detail: noComponentDetail ?? `kind "${kind}" has no component (no compiled legacyBlockType/component facet, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2861
2884
|
};
|
|
2862
2885
|
}
|
|
2863
2886
|
if (definition?.toLegacyServerData) {
|
|
@@ -2881,7 +2904,7 @@ function validateRender(kind, sample, definition, resolvedComponent, dataOnly) {
|
|
|
2881
2904
|
}
|
|
2882
2905
|
return { ok: true };
|
|
2883
2906
|
}
|
|
2884
|
-
const satisfier = definition?.legacyBlockType ? `compiled component "${definition.legacyBlockType}"` : definition?.component ? "compiled component facet" : resolvedComponent ? `resolved ${resolvedComponent.source} component "${resolvedComponent.componentKey}"` : "component";
|
|
2907
|
+
const satisfier = definition?.legacyBlockType ? `compiled component "${definition.legacyBlockType}"` : definition?.component ? "compiled component facet" : satisfies(resolvedComponent) && resolvedComponent ? `resolved ${resolvedComponent.source} component "${resolvedComponent.componentKey}"` : "component";
|
|
2885
2908
|
return {
|
|
2886
2909
|
ok: true,
|
|
2887
2910
|
detail: `bridgeless kind \u2014 ${satisfier} parses content itself; full DOM render check deferred to an RTL harness`
|
|
@@ -4117,8 +4140,291 @@ function kindSchemaToJsonSchema(kind, resolve, options = {}) {
|
|
|
4117
4140
|
return { name: kind, schema: { ...rootNode, $defs: defs }, strict, unresolved };
|
|
4118
4141
|
}
|
|
4119
4142
|
|
|
4143
|
+
// wire/partial-kind.ts
|
|
4144
|
+
var IR_PARTIAL_KEY = "__ir_partial";
|
|
4145
|
+
var PARTIAL_STATES = [
|
|
4146
|
+
"partial",
|
|
4147
|
+
"superseded",
|
|
4148
|
+
"retracted"
|
|
4149
|
+
];
|
|
4150
|
+
function isRecord5(value) {
|
|
4151
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4152
|
+
}
|
|
4153
|
+
function readPath(value) {
|
|
4154
|
+
if (!Array.isArray(value)) return null;
|
|
4155
|
+
return value.every(
|
|
4156
|
+
(segment) => typeof segment === "string" || typeof segment === "number"
|
|
4157
|
+
) ? value : null;
|
|
4158
|
+
}
|
|
4159
|
+
function readDiscriminator(value) {
|
|
4160
|
+
if (!isRecord5(value)) return null;
|
|
4161
|
+
if (value.format === "json" && value.key === "__kind") {
|
|
4162
|
+
return { format: "json", key: "__kind" };
|
|
4163
|
+
}
|
|
4164
|
+
if (value.format === "xml" && typeof value.tag === "string") {
|
|
4165
|
+
return { format: "xml", tag: value.tag };
|
|
4166
|
+
}
|
|
4167
|
+
if (value.format === "fence" && typeof value.language === "string") {
|
|
4168
|
+
return { format: "fence", language: value.language };
|
|
4169
|
+
}
|
|
4170
|
+
return null;
|
|
4171
|
+
}
|
|
4172
|
+
function readResidue(value) {
|
|
4173
|
+
if (value === null) return null;
|
|
4174
|
+
if (!isRecord5(value)) return void 0;
|
|
4175
|
+
const extra = value.extra;
|
|
4176
|
+
const optionalMissing = value.optionalMissing;
|
|
4177
|
+
const notices = value.notices;
|
|
4178
|
+
if (extra !== null && !isRecord5(extra)) return void 0;
|
|
4179
|
+
if (optionalMissing !== null && (!Array.isArray(optionalMissing) || !optionalMissing.every((item) => typeof item === "string"))) {
|
|
4180
|
+
return void 0;
|
|
4181
|
+
}
|
|
4182
|
+
if (notices !== null && (!Array.isArray(notices) || !notices.every(
|
|
4183
|
+
(notice) => isRecord5(notice) && typeof notice.code === "string" && typeof notice.message === "string" && (notice.at === void 0 || typeof notice.at === "number")
|
|
4184
|
+
))) {
|
|
4185
|
+
return void 0;
|
|
4186
|
+
}
|
|
4187
|
+
return { extra, optionalMissing, notices };
|
|
4188
|
+
}
|
|
4189
|
+
function readPartialKindEvent(metadata) {
|
|
4190
|
+
if (!isRecord5(metadata)) return null;
|
|
4191
|
+
const candidate = metadata[IR_PARTIAL_KEY];
|
|
4192
|
+
if (!isRecord5(candidate)) return null;
|
|
4193
|
+
if (candidate.v !== IR_VERSION) return null;
|
|
4194
|
+
if (typeof candidate.engine !== "string") return null;
|
|
4195
|
+
if (typeof candidate.seq !== "number" || !Number.isFinite(candidate.seq)) {
|
|
4196
|
+
return null;
|
|
4197
|
+
}
|
|
4198
|
+
const state = candidate.state;
|
|
4199
|
+
if (typeof state !== "string") return null;
|
|
4200
|
+
if (!PARTIAL_STATES.includes(state)) return null;
|
|
4201
|
+
if (state === "partial") {
|
|
4202
|
+
const root = candidate.root;
|
|
4203
|
+
if (!isRecord5(root)) return null;
|
|
4204
|
+
if (root.role !== "structured") return null;
|
|
4205
|
+
if (root.status !== "streaming") return null;
|
|
4206
|
+
if (root.kindState !== "speculative") return null;
|
|
4207
|
+
if (typeof root.kind !== "string" || !root.kind) return null;
|
|
4208
|
+
if (!isRecord5(root.value)) return null;
|
|
4209
|
+
const discriminator = readDiscriminator(root.discriminator);
|
|
4210
|
+
const path = readPath(root.path);
|
|
4211
|
+
const residue = readResidue(root.residue);
|
|
4212
|
+
if (discriminator === null || path === null || residue === void 0) {
|
|
4213
|
+
return null;
|
|
4214
|
+
}
|
|
4215
|
+
return {
|
|
4216
|
+
v: IR_VERSION,
|
|
4217
|
+
engine: candidate.engine,
|
|
4218
|
+
state: "partial",
|
|
4219
|
+
seq: candidate.seq,
|
|
4220
|
+
fingerprint: typeof candidate.fingerprint === "string" ? candidate.fingerprint : "",
|
|
4221
|
+
root: {
|
|
4222
|
+
role: "structured",
|
|
4223
|
+
kind: root.kind,
|
|
4224
|
+
kindState: "speculative",
|
|
4225
|
+
discriminator,
|
|
4226
|
+
path,
|
|
4227
|
+
status: "streaming",
|
|
4228
|
+
value: root.value,
|
|
4229
|
+
residue
|
|
4230
|
+
}
|
|
4231
|
+
};
|
|
4232
|
+
}
|
|
4233
|
+
if (typeof candidate.kind !== "string" || !candidate.kind) return null;
|
|
4234
|
+
if (state === "superseded") {
|
|
4235
|
+
return {
|
|
4236
|
+
v: IR_VERSION,
|
|
4237
|
+
engine: candidate.engine,
|
|
4238
|
+
state: "superseded",
|
|
4239
|
+
seq: candidate.seq,
|
|
4240
|
+
kind: candidate.kind
|
|
4241
|
+
};
|
|
4242
|
+
}
|
|
4243
|
+
if (typeof candidate.reason !== "string" || !candidate.reason) return null;
|
|
4244
|
+
if (candidate.becameKind !== null && typeof candidate.becameKind !== "string") {
|
|
4245
|
+
return null;
|
|
4246
|
+
}
|
|
4247
|
+
if (candidate.becameBlockType !== null && typeof candidate.becameBlockType !== "string") {
|
|
4248
|
+
return null;
|
|
4249
|
+
}
|
|
4250
|
+
return {
|
|
4251
|
+
v: IR_VERSION,
|
|
4252
|
+
engine: candidate.engine,
|
|
4253
|
+
state: "retracted",
|
|
4254
|
+
seq: candidate.seq,
|
|
4255
|
+
kind: candidate.kind,
|
|
4256
|
+
reason: candidate.reason,
|
|
4257
|
+
becameKind: candidate.becameKind,
|
|
4258
|
+
becameBlockType: candidate.becameBlockType
|
|
4259
|
+
};
|
|
4260
|
+
}
|
|
4261
|
+
function sanitizeInboundPartialKindMetadata(metadata, context, hooks = {}) {
|
|
4262
|
+
if (!isRecord5(metadata) || !(IR_PARTIAL_KEY in metadata)) {
|
|
4263
|
+
return metadata ?? void 0;
|
|
4264
|
+
}
|
|
4265
|
+
if (readPartialKindEvent(metadata) !== null) return metadata;
|
|
4266
|
+
const { [IR_PARTIAL_KEY]: raw, ...rest } = metadata;
|
|
4267
|
+
hooks.reportMalformed?.({ blockId: context.blockId, raw });
|
|
4268
|
+
return rest;
|
|
4269
|
+
}
|
|
4270
|
+
function isProvisionalKind(event) {
|
|
4271
|
+
return event !== null && event.state === "partial";
|
|
4272
|
+
}
|
|
4273
|
+
function isTerminalKindEvent(event) {
|
|
4274
|
+
return event !== null && (event.state === "superseded" || event.state === "retracted");
|
|
4275
|
+
}
|
|
4276
|
+
function advancePartialKind(seen, blockId, event) {
|
|
4277
|
+
if (event === null) return null;
|
|
4278
|
+
const last = seen[blockId];
|
|
4279
|
+
if (last !== void 0 && event.seq <= last) return null;
|
|
4280
|
+
return event;
|
|
4281
|
+
}
|
|
4282
|
+
function makePartialKindStalenessGate() {
|
|
4283
|
+
const seen = {};
|
|
4284
|
+
const lastAccepted = {};
|
|
4285
|
+
const terminated = {};
|
|
4286
|
+
return (blockId, metadata) => {
|
|
4287
|
+
if (!isRecord5(metadata)) return metadata;
|
|
4288
|
+
if (!(IR_PARTIAL_KEY in metadata)) {
|
|
4289
|
+
const open = lastAccepted[blockId];
|
|
4290
|
+
if (terminated[blockId] || open === void 0) return metadata;
|
|
4291
|
+
return { ...metadata, [IR_PARTIAL_KEY]: open };
|
|
4292
|
+
}
|
|
4293
|
+
const parsed = readPartialKindEvent(metadata);
|
|
4294
|
+
if (parsed === null) return metadata;
|
|
4295
|
+
if (advancePartialKind(seen, blockId, parsed) !== null) {
|
|
4296
|
+
seen[blockId] = parsed.seq;
|
|
4297
|
+
lastAccepted[blockId] = metadata[IR_PARTIAL_KEY];
|
|
4298
|
+
if (isTerminalKindEvent(parsed)) terminated[blockId] = true;
|
|
4299
|
+
return metadata;
|
|
4300
|
+
}
|
|
4301
|
+
const carried = lastAccepted[blockId];
|
|
4302
|
+
if (carried === void 0 || carried === metadata[IR_PARTIAL_KEY]) {
|
|
4303
|
+
return metadata;
|
|
4304
|
+
}
|
|
4305
|
+
return { ...metadata, [IR_PARTIAL_KEY]: carried };
|
|
4306
|
+
};
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
// wire/runtime-wrapper.ts
|
|
4310
|
+
var NODE_OUTCOME_KIND = "node_outcome";
|
|
4311
|
+
var RUN_RESULT_KIND = "run_result";
|
|
4312
|
+
function isRecord6(value) {
|
|
4313
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4314
|
+
}
|
|
4315
|
+
function str(source, key) {
|
|
4316
|
+
const value = source[key];
|
|
4317
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
4318
|
+
}
|
|
4319
|
+
function num(source, key) {
|
|
4320
|
+
const value = source[key];
|
|
4321
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
4322
|
+
}
|
|
4323
|
+
function bool(source, key) {
|
|
4324
|
+
const value = source[key];
|
|
4325
|
+
return typeof value === "boolean" ? value : null;
|
|
4326
|
+
}
|
|
4327
|
+
function strings(source, key) {
|
|
4328
|
+
const value = source[key];
|
|
4329
|
+
if (!Array.isArray(value)) return null;
|
|
4330
|
+
const out = value.filter((item) => typeof item === "string");
|
|
4331
|
+
return out.length > 0 ? out : null;
|
|
4332
|
+
}
|
|
4333
|
+
function readOutputRef(frame, ref) {
|
|
4334
|
+
let cursor = frame;
|
|
4335
|
+
for (const segment of ref.split(".")) {
|
|
4336
|
+
if (!isRecord6(cursor)) return void 0;
|
|
4337
|
+
if (!(segment in cursor)) return void 0;
|
|
4338
|
+
cursor = cursor[segment];
|
|
4339
|
+
}
|
|
4340
|
+
return cursor;
|
|
4341
|
+
}
|
|
4342
|
+
function rehydrateNodeOutcome(raw, frame) {
|
|
4343
|
+
if (!isRecord6(raw)) return null;
|
|
4344
|
+
if (raw[KIND_KEY] !== NODE_OUTCOME_KIND) return null;
|
|
4345
|
+
const ref = str(raw, "output_ref");
|
|
4346
|
+
const resolved = ref === null ? void 0 : readOutputRef(frame, ref);
|
|
4347
|
+
return readNodeOutcomeValue(
|
|
4348
|
+
resolved === void 0 ? raw : { ...raw, output: resolved }
|
|
4349
|
+
);
|
|
4350
|
+
}
|
|
4351
|
+
function readNodeOutcomeValue(raw) {
|
|
4352
|
+
if (!isRecord6(raw)) return null;
|
|
4353
|
+
const runId = str(raw, "run_id");
|
|
4354
|
+
const nodeId = str(raw, "node_id");
|
|
4355
|
+
if (!runId || !nodeId) return null;
|
|
4356
|
+
const output = raw.output ?? null;
|
|
4357
|
+
return {
|
|
4358
|
+
__kind: NODE_OUTCOME_KIND,
|
|
4359
|
+
run_id: runId,
|
|
4360
|
+
node_id: nodeId,
|
|
4361
|
+
workflow_id: str(raw, "workflow_id"),
|
|
4362
|
+
step: num(raw, "step"),
|
|
4363
|
+
attempt: num(raw, "attempt") ?? 1,
|
|
4364
|
+
status: str(raw, "status") ?? "completed",
|
|
4365
|
+
started_at: str(raw, "started_at"),
|
|
4366
|
+
ended_at: str(raw, "ended_at"),
|
|
4367
|
+
duration_ms: num(raw, "duration_ms"),
|
|
4368
|
+
output_kind: str(raw, "output_kind"),
|
|
4369
|
+
output_kind_ok: bool(raw, "output_kind_ok"),
|
|
4370
|
+
output_kind_errors: strings(raw, "output_kind_errors"),
|
|
4371
|
+
output
|
|
4372
|
+
};
|
|
4373
|
+
}
|
|
4374
|
+
function rehydrateRunResult(raw, frame) {
|
|
4375
|
+
if (!isRecord6(raw)) return null;
|
|
4376
|
+
if (raw[KIND_KEY] !== RUN_RESULT_KIND) return null;
|
|
4377
|
+
const ref = str(raw, "output_ref");
|
|
4378
|
+
const resolved = ref === null ? void 0 : readOutputRef(frame, ref);
|
|
4379
|
+
const outputs = Array.isArray(raw.outputs) ? raw.outputs.map((child) => rehydrateNodeOutcome(child, frame) ?? child) : [];
|
|
4380
|
+
return readRunResultValue({
|
|
4381
|
+
...raw,
|
|
4382
|
+
...resolved === void 0 ? {} : { output: resolved },
|
|
4383
|
+
outputs
|
|
4384
|
+
});
|
|
4385
|
+
}
|
|
4386
|
+
function readRunResultValue(raw) {
|
|
4387
|
+
if (!isRecord6(raw)) return null;
|
|
4388
|
+
const runId = str(raw, "run_id");
|
|
4389
|
+
if (!runId) return null;
|
|
4390
|
+
const output = raw.output ?? null;
|
|
4391
|
+
const outputs = Array.isArray(raw.outputs) ? raw.outputs.map((child) => readNodeOutcomeValue(child)).filter((child) => child !== null) : [];
|
|
4392
|
+
return {
|
|
4393
|
+
__kind: RUN_RESULT_KIND,
|
|
4394
|
+
run_id: runId,
|
|
4395
|
+
workflow_id: str(raw, "workflow_id"),
|
|
4396
|
+
status: str(raw, "status") ?? "completed",
|
|
4397
|
+
started_at: str(raw, "started_at"),
|
|
4398
|
+
ended_at: str(raw, "ended_at"),
|
|
4399
|
+
duration_ms: num(raw, "duration_ms"),
|
|
4400
|
+
output_kind: str(raw, "output_kind"),
|
|
4401
|
+
output,
|
|
4402
|
+
outputs
|
|
4403
|
+
};
|
|
4404
|
+
}
|
|
4405
|
+
function kindVerdictOf(wrapper) {
|
|
4406
|
+
if (wrapper.output_kind_ok === true) return "passed";
|
|
4407
|
+
if (wrapper.output_kind_ok === false) return "failed";
|
|
4408
|
+
return "unchecked";
|
|
4409
|
+
}
|
|
4410
|
+
|
|
4411
|
+
// wire/emit-payload.ts
|
|
4412
|
+
function withRootKind(kind, value) {
|
|
4413
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
4414
|
+
return { [KIND_KEY]: kind, ...value };
|
|
4415
|
+
}
|
|
4416
|
+
return value;
|
|
4417
|
+
}
|
|
4418
|
+
function emitPayloadJson(kind, value) {
|
|
4419
|
+
return JSON.stringify(withRootKind(kind, value), null, 2);
|
|
4420
|
+
}
|
|
4421
|
+
function emitPayloadFence(kind, value) {
|
|
4422
|
+
return "```json\n" + emitPayloadJson(kind, value) + "\n```";
|
|
4423
|
+
}
|
|
4424
|
+
|
|
4120
4425
|
exports.IR_ENVELOPE_CACHE_VERSION = IR_ENVELOPE_CACHE_VERSION;
|
|
4121
4426
|
exports.IR_ENVELOPE_KEY = IR_ENVELOPE_KEY;
|
|
4427
|
+
exports.IR_PARTIAL_KEY = IR_PARTIAL_KEY;
|
|
4122
4428
|
exports.IR_VERSION = IR_VERSION;
|
|
4123
4429
|
exports.IrTree = IrTree;
|
|
4124
4430
|
exports.JSON_DISCRIMINATOR = JSON_DISCRIMINATOR;
|
|
@@ -4126,8 +4432,11 @@ exports.JsonStreamTokenizer = JsonStreamTokenizer;
|
|
|
4126
4432
|
exports.KIND_KEY = KIND_KEY;
|
|
4127
4433
|
exports.KindStorageError = KindStorageError;
|
|
4128
4434
|
exports.KindStreamParser = KindStreamParser;
|
|
4435
|
+
exports.NODE_OUTCOME_KIND = NODE_OUTCOME_KIND;
|
|
4129
4436
|
exports.ParseSession = ParseSession;
|
|
4130
4437
|
exports.ROOT_STORAGE_NAME = ROOT_STORAGE_NAME;
|
|
4438
|
+
exports.RUN_RESULT_KIND = RUN_RESULT_KIND;
|
|
4439
|
+
exports.advancePartialKind = advancePartialKind;
|
|
4131
4440
|
exports.buildAgentSchemaWithRenderBlockSupport = buildAgentSchemaWithRenderBlockSupport;
|
|
4132
4441
|
exports.buildCompliantKindSnapshot = buildCompliantKindSnapshot;
|
|
4133
4442
|
exports.classifyInboundEnvelopeMetadata = classifyInboundEnvelopeMetadata;
|
|
@@ -4139,6 +4448,8 @@ exports.createFingerprinter = createFingerprinter;
|
|
|
4139
4448
|
exports.createKindStreamParser = createKindStreamParser;
|
|
4140
4449
|
exports.describeDualGateFailure = describeDualGateFailure;
|
|
4141
4450
|
exports.disposeParseSession = disposeParseSession;
|
|
4451
|
+
exports.emitPayloadFence = emitPayloadFence;
|
|
4452
|
+
exports.emitPayloadJson = emitPayloadJson;
|
|
4142
4453
|
exports.emptyValueForFieldSchema = emptyValueForFieldSchema;
|
|
4143
4454
|
exports.envelopeCacheFromEnvelopes = envelopeCacheFromEnvelopes;
|
|
4144
4455
|
exports.envelopeFromCompleteValue = envelopeFromCompleteValue;
|
|
@@ -4157,20 +4468,31 @@ exports.isDuplicateBlockSlug = isDuplicateBlockSlug;
|
|
|
4157
4468
|
exports.isEmptyResidue = isEmptyResidue;
|
|
4158
4469
|
exports.isIrEnvelopeCache = isIrEnvelopeCache;
|
|
4159
4470
|
exports.isJsonAnyField = isJsonAnyField;
|
|
4471
|
+
exports.isProvisionalKind = isProvisionalKind;
|
|
4160
4472
|
exports.isScalarArrayType = isScalarArrayType;
|
|
4473
|
+
exports.isTerminalKindEvent = isTerminalKindEvent;
|
|
4161
4474
|
exports.kindSchemaToJsonSchema = kindSchemaToJsonSchema;
|
|
4162
4475
|
exports.kindSchemaToStorage = kindSchemaToStorage;
|
|
4476
|
+
exports.kindVerdictOf = kindVerdictOf;
|
|
4477
|
+
exports.makePartialKindStalenessGate = makePartialKindStalenessGate;
|
|
4163
4478
|
exports.mergeResidueIntoValue = mergeResidueIntoValue;
|
|
4164
4479
|
exports.normalizeAiSchemaInput = normalizeAiSchemaInput;
|
|
4165
4480
|
exports.normalizeJsonRegion = normalizeJsonRegion;
|
|
4166
4481
|
exports.openParseSession = openParseSession;
|
|
4167
4482
|
exports.readEnvelope = readEnvelope;
|
|
4483
|
+
exports.readNodeOutcomeValue = readNodeOutcomeValue;
|
|
4168
4484
|
exports.readObjectKind = readObjectKind;
|
|
4485
|
+
exports.readOutputRef = readOutputRef;
|
|
4486
|
+
exports.readPartialKindEvent = readPartialKindEvent;
|
|
4487
|
+
exports.readRunResultValue = readRunResultValue;
|
|
4169
4488
|
exports.reconstructRegionValue = reconstructRegionValue;
|
|
4489
|
+
exports.rehydrateNodeOutcome = rehydrateNodeOutcome;
|
|
4490
|
+
exports.rehydrateRunResult = rehydrateRunResult;
|
|
4170
4491
|
exports.reuseEnvelopeIfCurrent = reuseEnvelopeIfCurrent;
|
|
4171
4492
|
exports.runKindDualGate = runKindDualGate;
|
|
4172
4493
|
exports.runSchemaConversion = runSchemaConversion;
|
|
4173
4494
|
exports.sanitizeInboundEnvelopeMetadata = sanitizeInboundEnvelopeMetadata;
|
|
4495
|
+
exports.sanitizeInboundPartialKindMetadata = sanitizeInboundPartialKindMetadata;
|
|
4174
4496
|
exports.scalarArrayItemType = scalarArrayItemType;
|
|
4175
4497
|
exports.schemaLayoutMode = schemaLayoutMode;
|
|
4176
4498
|
exports.schemaStructureDepth = schemaStructureDepth;
|
|
@@ -4179,6 +4501,7 @@ exports.storageToKindSchema = storageToKindSchema;
|
|
|
4179
4501
|
exports.stripKindDeep = stripKindDeep;
|
|
4180
4502
|
exports.validateBlockSchemaSavePlan = validateBlockSchemaSavePlan;
|
|
4181
4503
|
exports.validateStructuralLeg = validateStructuralLeg;
|
|
4504
|
+
exports.withRootKind = withRootKind;
|
|
4182
4505
|
exports.xmlDiscriminator = xmlDiscriminator;
|
|
4183
4506
|
//# sourceMappingURL=index.cjs.map
|
|
4184
4507
|
//# sourceMappingURL=index.cjs.map
|