@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/dist/index.js
CHANGED
|
@@ -398,16 +398,19 @@ var IrTree = class {
|
|
|
398
398
|
|
|
399
399
|
// core/json-tokenizer.ts
|
|
400
400
|
var JsonStreamTokenizer = class {
|
|
401
|
-
constructor(onToken) {
|
|
402
|
-
this.onToken = onToken;
|
|
403
|
-
}
|
|
404
|
-
onToken;
|
|
405
401
|
mode = "normal";
|
|
406
402
|
pos = 0;
|
|
407
403
|
stringBuffer = "";
|
|
408
404
|
primitiveBuffer = "";
|
|
409
405
|
unicodeBuffer = "";
|
|
410
406
|
tokenStart = 0;
|
|
407
|
+
onToken;
|
|
408
|
+
// Explicit field rather than a parameter property: consumers compile this
|
|
409
|
+
// source directly, and a strict host (the dashboard) sets
|
|
410
|
+
// `erasableSyntaxOnly`, under which parameter properties are a hard error.
|
|
411
|
+
constructor(onToken) {
|
|
412
|
+
this.onToken = onToken;
|
|
413
|
+
}
|
|
411
414
|
get position() {
|
|
412
415
|
return this.pos;
|
|
413
416
|
}
|
|
@@ -630,16 +633,6 @@ function safeCopy(value) {
|
|
|
630
633
|
}
|
|
631
634
|
}
|
|
632
635
|
var KindStreamParser = class {
|
|
633
|
-
constructor(options) {
|
|
634
|
-
this.options = options;
|
|
635
|
-
this.resolver = isSchemaResolver(options.schemas) ? options.schemas : {
|
|
636
|
-
get: (kind) => options.schemas[kind]
|
|
637
|
-
};
|
|
638
|
-
this.tokenizer = new JsonStreamTokenizer(
|
|
639
|
-
(token) => this.handleToken(token)
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
options;
|
|
643
636
|
resolver;
|
|
644
637
|
stack = [];
|
|
645
638
|
objectKinds = /* @__PURE__ */ new Map();
|
|
@@ -674,6 +667,18 @@ var KindStreamParser = class {
|
|
|
674
667
|
rootKind = "";
|
|
675
668
|
rootDone = false;
|
|
676
669
|
failed = false;
|
|
670
|
+
options;
|
|
671
|
+
// Explicit field, not a parameter property — see the note in
|
|
672
|
+
// `json-tokenizer.ts`: `erasableSyntaxOnly` hosts compile this source.
|
|
673
|
+
constructor(options) {
|
|
674
|
+
this.options = options;
|
|
675
|
+
this.resolver = isSchemaResolver(options.schemas) ? options.schemas : {
|
|
676
|
+
get: (kind) => options.schemas[kind]
|
|
677
|
+
};
|
|
678
|
+
this.tokenizer = new JsonStreamTokenizer(
|
|
679
|
+
(token) => this.handleToken(token)
|
|
680
|
+
);
|
|
681
|
+
}
|
|
677
682
|
push(chunk) {
|
|
678
683
|
if (this.failed || this.rootDone) return;
|
|
679
684
|
try {
|
|
@@ -2767,6 +2772,12 @@ function storageToKindSchema(kind, shape) {
|
|
|
2767
2772
|
}
|
|
2768
2773
|
return { kind, fields };
|
|
2769
2774
|
}
|
|
2775
|
+
var GENERIC_FALLBACK_COMPONENT_KEY = "generic_structured";
|
|
2776
|
+
function satisfies(resolved) {
|
|
2777
|
+
return Boolean(
|
|
2778
|
+
resolved?.isActive && resolved.componentKey !== GENERIC_FALLBACK_COMPONENT_KEY
|
|
2779
|
+
);
|
|
2780
|
+
}
|
|
2770
2781
|
var ajv = new Ajv({ allErrors: true, strict: false });
|
|
2771
2782
|
function stripKind(value) {
|
|
2772
2783
|
if (Array.isArray(value)) return value.map(stripKind);
|
|
@@ -2780,6 +2791,14 @@ function stripKind(value) {
|
|
|
2780
2791
|
}
|
|
2781
2792
|
return value;
|
|
2782
2793
|
}
|
|
2794
|
+
function describeAjvErrors(errors) {
|
|
2795
|
+
return (errors ?? []).map((e) => `${e.instancePath || "(root)"} ${e.message ?? ""}`.trim()).slice(0, 8);
|
|
2796
|
+
}
|
|
2797
|
+
function schemaDeclaresKind(emittedJsonSchema) {
|
|
2798
|
+
if (!emittedJsonSchema || typeof emittedJsonSchema !== "object") return false;
|
|
2799
|
+
const properties = emittedJsonSchema.properties;
|
|
2800
|
+
return !!properties && typeof properties === "object" && KIND_KEY in properties;
|
|
2801
|
+
}
|
|
2783
2802
|
function validateStructuralLeg(sample, emittedJsonSchema) {
|
|
2784
2803
|
let validate;
|
|
2785
2804
|
try {
|
|
@@ -2790,9 +2809,11 @@ function validateStructuralLeg(sample, emittedJsonSchema) {
|
|
|
2790
2809
|
detail: `emitted_json_schema failed to compile: ${err instanceof Error ? err.message : String(err)}`
|
|
2791
2810
|
};
|
|
2792
2811
|
}
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2812
|
+
if (validate(sample)) return { ok: true };
|
|
2813
|
+
const markedErrors = describeAjvErrors(validate.errors);
|
|
2814
|
+
if (validate(stripKind(sample))) return { ok: true };
|
|
2815
|
+
const strippedErrors = describeAjvErrors(validate.errors);
|
|
2816
|
+
const errors = schemaDeclaresKind(emittedJsonSchema) ? markedErrors : strippedErrors;
|
|
2796
2817
|
return { ok: false, detail: `sample failed schema: ${errors.join("; ")}` };
|
|
2797
2818
|
}
|
|
2798
2819
|
var SERVER_DATA_ANNOTATION_KEYS = /* @__PURE__ */ new Set(["language"]);
|
|
@@ -2842,16 +2863,18 @@ function validateRender(kind, sample, definition, resolvedComponent, dataOnly) {
|
|
|
2842
2863
|
detail: "data-only contract kind \u2014 render leg is structurally inapplicable (n/a)"
|
|
2843
2864
|
};
|
|
2844
2865
|
}
|
|
2845
|
-
|
|
2866
|
+
const onlyFallback = resolvedComponent?.isActive && resolvedComponent.componentKey === GENERIC_FALLBACK_COMPONENT_KEY;
|
|
2867
|
+
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;
|
|
2868
|
+
if (!definition && !satisfies(resolvedComponent)) {
|
|
2846
2869
|
return {
|
|
2847
2870
|
ok: false,
|
|
2848
|
-
detail: `kind "${kind}" has no component (not in the compiled registry, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2871
|
+
detail: noComponentDetail ?? `kind "${kind}" has no component (not in the compiled registry, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2849
2872
|
};
|
|
2850
2873
|
}
|
|
2851
|
-
if (definition && !definition.legacyBlockType && !definition.component && !definition.toLegacyServerData && !resolvedComponent
|
|
2874
|
+
if (definition && !definition.legacyBlockType && !definition.component && !definition.toLegacyServerData && !satisfies(resolvedComponent)) {
|
|
2852
2875
|
return {
|
|
2853
2876
|
ok: false,
|
|
2854
|
-
detail: `kind "${kind}" has no component (no compiled legacyBlockType/component facet, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2877
|
+
detail: noComponentDetail ?? `kind "${kind}" has no component (no compiled legacyBlockType/component facet, and no active role='output' kind_component row) \u2014 nothing to render`
|
|
2855
2878
|
};
|
|
2856
2879
|
}
|
|
2857
2880
|
if (definition?.toLegacyServerData) {
|
|
@@ -2875,7 +2898,7 @@ function validateRender(kind, sample, definition, resolvedComponent, dataOnly) {
|
|
|
2875
2898
|
}
|
|
2876
2899
|
return { ok: true };
|
|
2877
2900
|
}
|
|
2878
|
-
const satisfier = definition?.legacyBlockType ? `compiled component "${definition.legacyBlockType}"` : definition?.component ? "compiled component facet" : resolvedComponent ? `resolved ${resolvedComponent.source} component "${resolvedComponent.componentKey}"` : "component";
|
|
2901
|
+
const satisfier = definition?.legacyBlockType ? `compiled component "${definition.legacyBlockType}"` : definition?.component ? "compiled component facet" : satisfies(resolvedComponent) && resolvedComponent ? `resolved ${resolvedComponent.source} component "${resolvedComponent.componentKey}"` : "component";
|
|
2879
2902
|
return {
|
|
2880
2903
|
ok: true,
|
|
2881
2904
|
detail: `bridgeless kind \u2014 ${satisfier} parses content itself; full DOM render check deferred to an RTL harness`
|
|
@@ -4111,6 +4134,288 @@ function kindSchemaToJsonSchema(kind, resolve, options = {}) {
|
|
|
4111
4134
|
return { name: kind, schema: { ...rootNode, $defs: defs }, strict, unresolved };
|
|
4112
4135
|
}
|
|
4113
4136
|
|
|
4114
|
-
|
|
4137
|
+
// wire/partial-kind.ts
|
|
4138
|
+
var IR_PARTIAL_KEY = "__ir_partial";
|
|
4139
|
+
var PARTIAL_STATES = [
|
|
4140
|
+
"partial",
|
|
4141
|
+
"superseded",
|
|
4142
|
+
"retracted"
|
|
4143
|
+
];
|
|
4144
|
+
function isRecord5(value) {
|
|
4145
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4146
|
+
}
|
|
4147
|
+
function readPath(value) {
|
|
4148
|
+
if (!Array.isArray(value)) return null;
|
|
4149
|
+
return value.every(
|
|
4150
|
+
(segment) => typeof segment === "string" || typeof segment === "number"
|
|
4151
|
+
) ? value : null;
|
|
4152
|
+
}
|
|
4153
|
+
function readDiscriminator(value) {
|
|
4154
|
+
if (!isRecord5(value)) return null;
|
|
4155
|
+
if (value.format === "json" && value.key === "__kind") {
|
|
4156
|
+
return { format: "json", key: "__kind" };
|
|
4157
|
+
}
|
|
4158
|
+
if (value.format === "xml" && typeof value.tag === "string") {
|
|
4159
|
+
return { format: "xml", tag: value.tag };
|
|
4160
|
+
}
|
|
4161
|
+
if (value.format === "fence" && typeof value.language === "string") {
|
|
4162
|
+
return { format: "fence", language: value.language };
|
|
4163
|
+
}
|
|
4164
|
+
return null;
|
|
4165
|
+
}
|
|
4166
|
+
function readResidue(value) {
|
|
4167
|
+
if (value === null) return null;
|
|
4168
|
+
if (!isRecord5(value)) return void 0;
|
|
4169
|
+
const extra = value.extra;
|
|
4170
|
+
const optionalMissing = value.optionalMissing;
|
|
4171
|
+
const notices = value.notices;
|
|
4172
|
+
if (extra !== null && !isRecord5(extra)) return void 0;
|
|
4173
|
+
if (optionalMissing !== null && (!Array.isArray(optionalMissing) || !optionalMissing.every((item) => typeof item === "string"))) {
|
|
4174
|
+
return void 0;
|
|
4175
|
+
}
|
|
4176
|
+
if (notices !== null && (!Array.isArray(notices) || !notices.every(
|
|
4177
|
+
(notice) => isRecord5(notice) && typeof notice.code === "string" && typeof notice.message === "string" && (notice.at === void 0 || typeof notice.at === "number")
|
|
4178
|
+
))) {
|
|
4179
|
+
return void 0;
|
|
4180
|
+
}
|
|
4181
|
+
return { extra, optionalMissing, notices };
|
|
4182
|
+
}
|
|
4183
|
+
function readPartialKindEvent(metadata) {
|
|
4184
|
+
if (!isRecord5(metadata)) return null;
|
|
4185
|
+
const candidate = metadata[IR_PARTIAL_KEY];
|
|
4186
|
+
if (!isRecord5(candidate)) return null;
|
|
4187
|
+
if (candidate.v !== IR_VERSION) return null;
|
|
4188
|
+
if (typeof candidate.engine !== "string") return null;
|
|
4189
|
+
if (typeof candidate.seq !== "number" || !Number.isFinite(candidate.seq)) {
|
|
4190
|
+
return null;
|
|
4191
|
+
}
|
|
4192
|
+
const state = candidate.state;
|
|
4193
|
+
if (typeof state !== "string") return null;
|
|
4194
|
+
if (!PARTIAL_STATES.includes(state)) return null;
|
|
4195
|
+
if (state === "partial") {
|
|
4196
|
+
const root = candidate.root;
|
|
4197
|
+
if (!isRecord5(root)) return null;
|
|
4198
|
+
if (root.role !== "structured") return null;
|
|
4199
|
+
if (root.status !== "streaming") return null;
|
|
4200
|
+
if (root.kindState !== "speculative") return null;
|
|
4201
|
+
if (typeof root.kind !== "string" || !root.kind) return null;
|
|
4202
|
+
if (!isRecord5(root.value)) return null;
|
|
4203
|
+
const discriminator = readDiscriminator(root.discriminator);
|
|
4204
|
+
const path = readPath(root.path);
|
|
4205
|
+
const residue = readResidue(root.residue);
|
|
4206
|
+
if (discriminator === null || path === null || residue === void 0) {
|
|
4207
|
+
return null;
|
|
4208
|
+
}
|
|
4209
|
+
return {
|
|
4210
|
+
v: IR_VERSION,
|
|
4211
|
+
engine: candidate.engine,
|
|
4212
|
+
state: "partial",
|
|
4213
|
+
seq: candidate.seq,
|
|
4214
|
+
fingerprint: typeof candidate.fingerprint === "string" ? candidate.fingerprint : "",
|
|
4215
|
+
root: {
|
|
4216
|
+
role: "structured",
|
|
4217
|
+
kind: root.kind,
|
|
4218
|
+
kindState: "speculative",
|
|
4219
|
+
discriminator,
|
|
4220
|
+
path,
|
|
4221
|
+
status: "streaming",
|
|
4222
|
+
value: root.value,
|
|
4223
|
+
residue
|
|
4224
|
+
}
|
|
4225
|
+
};
|
|
4226
|
+
}
|
|
4227
|
+
if (typeof candidate.kind !== "string" || !candidate.kind) return null;
|
|
4228
|
+
if (state === "superseded") {
|
|
4229
|
+
return {
|
|
4230
|
+
v: IR_VERSION,
|
|
4231
|
+
engine: candidate.engine,
|
|
4232
|
+
state: "superseded",
|
|
4233
|
+
seq: candidate.seq,
|
|
4234
|
+
kind: candidate.kind
|
|
4235
|
+
};
|
|
4236
|
+
}
|
|
4237
|
+
if (typeof candidate.reason !== "string" || !candidate.reason) return null;
|
|
4238
|
+
if (candidate.becameKind !== null && typeof candidate.becameKind !== "string") {
|
|
4239
|
+
return null;
|
|
4240
|
+
}
|
|
4241
|
+
if (candidate.becameBlockType !== null && typeof candidate.becameBlockType !== "string") {
|
|
4242
|
+
return null;
|
|
4243
|
+
}
|
|
4244
|
+
return {
|
|
4245
|
+
v: IR_VERSION,
|
|
4246
|
+
engine: candidate.engine,
|
|
4247
|
+
state: "retracted",
|
|
4248
|
+
seq: candidate.seq,
|
|
4249
|
+
kind: candidate.kind,
|
|
4250
|
+
reason: candidate.reason,
|
|
4251
|
+
becameKind: candidate.becameKind,
|
|
4252
|
+
becameBlockType: candidate.becameBlockType
|
|
4253
|
+
};
|
|
4254
|
+
}
|
|
4255
|
+
function sanitizeInboundPartialKindMetadata(metadata, context, hooks = {}) {
|
|
4256
|
+
if (!isRecord5(metadata) || !(IR_PARTIAL_KEY in metadata)) {
|
|
4257
|
+
return metadata ?? void 0;
|
|
4258
|
+
}
|
|
4259
|
+
if (readPartialKindEvent(metadata) !== null) return metadata;
|
|
4260
|
+
const { [IR_PARTIAL_KEY]: raw, ...rest } = metadata;
|
|
4261
|
+
hooks.reportMalformed?.({ blockId: context.blockId, raw });
|
|
4262
|
+
return rest;
|
|
4263
|
+
}
|
|
4264
|
+
function isProvisionalKind(event) {
|
|
4265
|
+
return event !== null && event.state === "partial";
|
|
4266
|
+
}
|
|
4267
|
+
function isTerminalKindEvent(event) {
|
|
4268
|
+
return event !== null && (event.state === "superseded" || event.state === "retracted");
|
|
4269
|
+
}
|
|
4270
|
+
function advancePartialKind(seen, blockId, event) {
|
|
4271
|
+
if (event === null) return null;
|
|
4272
|
+
const last = seen[blockId];
|
|
4273
|
+
if (last !== void 0 && event.seq <= last) return null;
|
|
4274
|
+
return event;
|
|
4275
|
+
}
|
|
4276
|
+
function makePartialKindStalenessGate() {
|
|
4277
|
+
const seen = {};
|
|
4278
|
+
const lastAccepted = {};
|
|
4279
|
+
const terminated = {};
|
|
4280
|
+
return (blockId, metadata) => {
|
|
4281
|
+
if (!isRecord5(metadata)) return metadata;
|
|
4282
|
+
if (!(IR_PARTIAL_KEY in metadata)) {
|
|
4283
|
+
const open = lastAccepted[blockId];
|
|
4284
|
+
if (terminated[blockId] || open === void 0) return metadata;
|
|
4285
|
+
return { ...metadata, [IR_PARTIAL_KEY]: open };
|
|
4286
|
+
}
|
|
4287
|
+
const parsed = readPartialKindEvent(metadata);
|
|
4288
|
+
if (parsed === null) return metadata;
|
|
4289
|
+
if (advancePartialKind(seen, blockId, parsed) !== null) {
|
|
4290
|
+
seen[blockId] = parsed.seq;
|
|
4291
|
+
lastAccepted[blockId] = metadata[IR_PARTIAL_KEY];
|
|
4292
|
+
if (isTerminalKindEvent(parsed)) terminated[blockId] = true;
|
|
4293
|
+
return metadata;
|
|
4294
|
+
}
|
|
4295
|
+
const carried = lastAccepted[blockId];
|
|
4296
|
+
if (carried === void 0 || carried === metadata[IR_PARTIAL_KEY]) {
|
|
4297
|
+
return metadata;
|
|
4298
|
+
}
|
|
4299
|
+
return { ...metadata, [IR_PARTIAL_KEY]: carried };
|
|
4300
|
+
};
|
|
4301
|
+
}
|
|
4302
|
+
|
|
4303
|
+
// wire/runtime-wrapper.ts
|
|
4304
|
+
var NODE_OUTCOME_KIND = "node_outcome";
|
|
4305
|
+
var RUN_RESULT_KIND = "run_result";
|
|
4306
|
+
function isRecord6(value) {
|
|
4307
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4308
|
+
}
|
|
4309
|
+
function str(source, key) {
|
|
4310
|
+
const value = source[key];
|
|
4311
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
4312
|
+
}
|
|
4313
|
+
function num(source, key) {
|
|
4314
|
+
const value = source[key];
|
|
4315
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
4316
|
+
}
|
|
4317
|
+
function bool(source, key) {
|
|
4318
|
+
const value = source[key];
|
|
4319
|
+
return typeof value === "boolean" ? value : null;
|
|
4320
|
+
}
|
|
4321
|
+
function strings(source, key) {
|
|
4322
|
+
const value = source[key];
|
|
4323
|
+
if (!Array.isArray(value)) return null;
|
|
4324
|
+
const out = value.filter((item) => typeof item === "string");
|
|
4325
|
+
return out.length > 0 ? out : null;
|
|
4326
|
+
}
|
|
4327
|
+
function readOutputRef(frame, ref) {
|
|
4328
|
+
let cursor = frame;
|
|
4329
|
+
for (const segment of ref.split(".")) {
|
|
4330
|
+
if (!isRecord6(cursor)) return void 0;
|
|
4331
|
+
if (!(segment in cursor)) return void 0;
|
|
4332
|
+
cursor = cursor[segment];
|
|
4333
|
+
}
|
|
4334
|
+
return cursor;
|
|
4335
|
+
}
|
|
4336
|
+
function rehydrateNodeOutcome(raw, frame) {
|
|
4337
|
+
if (!isRecord6(raw)) return null;
|
|
4338
|
+
if (raw[KIND_KEY] !== NODE_OUTCOME_KIND) return null;
|
|
4339
|
+
const ref = str(raw, "output_ref");
|
|
4340
|
+
const resolved = ref === null ? void 0 : readOutputRef(frame, ref);
|
|
4341
|
+
return readNodeOutcomeValue(
|
|
4342
|
+
resolved === void 0 ? raw : { ...raw, output: resolved }
|
|
4343
|
+
);
|
|
4344
|
+
}
|
|
4345
|
+
function readNodeOutcomeValue(raw) {
|
|
4346
|
+
if (!isRecord6(raw)) return null;
|
|
4347
|
+
const runId = str(raw, "run_id");
|
|
4348
|
+
const nodeId = str(raw, "node_id");
|
|
4349
|
+
if (!runId || !nodeId) return null;
|
|
4350
|
+
const output = raw.output ?? null;
|
|
4351
|
+
return {
|
|
4352
|
+
__kind: NODE_OUTCOME_KIND,
|
|
4353
|
+
run_id: runId,
|
|
4354
|
+
node_id: nodeId,
|
|
4355
|
+
workflow_id: str(raw, "workflow_id"),
|
|
4356
|
+
step: num(raw, "step"),
|
|
4357
|
+
attempt: num(raw, "attempt") ?? 1,
|
|
4358
|
+
status: str(raw, "status") ?? "completed",
|
|
4359
|
+
started_at: str(raw, "started_at"),
|
|
4360
|
+
ended_at: str(raw, "ended_at"),
|
|
4361
|
+
duration_ms: num(raw, "duration_ms"),
|
|
4362
|
+
output_kind: str(raw, "output_kind"),
|
|
4363
|
+
output_kind_ok: bool(raw, "output_kind_ok"),
|
|
4364
|
+
output_kind_errors: strings(raw, "output_kind_errors"),
|
|
4365
|
+
output
|
|
4366
|
+
};
|
|
4367
|
+
}
|
|
4368
|
+
function rehydrateRunResult(raw, frame) {
|
|
4369
|
+
if (!isRecord6(raw)) return null;
|
|
4370
|
+
if (raw[KIND_KEY] !== RUN_RESULT_KIND) return null;
|
|
4371
|
+
const ref = str(raw, "output_ref");
|
|
4372
|
+
const resolved = ref === null ? void 0 : readOutputRef(frame, ref);
|
|
4373
|
+
const outputs = Array.isArray(raw.outputs) ? raw.outputs.map((child) => rehydrateNodeOutcome(child, frame) ?? child) : [];
|
|
4374
|
+
return readRunResultValue({
|
|
4375
|
+
...raw,
|
|
4376
|
+
...resolved === void 0 ? {} : { output: resolved },
|
|
4377
|
+
outputs
|
|
4378
|
+
});
|
|
4379
|
+
}
|
|
4380
|
+
function readRunResultValue(raw) {
|
|
4381
|
+
if (!isRecord6(raw)) return null;
|
|
4382
|
+
const runId = str(raw, "run_id");
|
|
4383
|
+
if (!runId) return null;
|
|
4384
|
+
const output = raw.output ?? null;
|
|
4385
|
+
const outputs = Array.isArray(raw.outputs) ? raw.outputs.map((child) => readNodeOutcomeValue(child)).filter((child) => child !== null) : [];
|
|
4386
|
+
return {
|
|
4387
|
+
__kind: RUN_RESULT_KIND,
|
|
4388
|
+
run_id: runId,
|
|
4389
|
+
workflow_id: str(raw, "workflow_id"),
|
|
4390
|
+
status: str(raw, "status") ?? "completed",
|
|
4391
|
+
started_at: str(raw, "started_at"),
|
|
4392
|
+
ended_at: str(raw, "ended_at"),
|
|
4393
|
+
duration_ms: num(raw, "duration_ms"),
|
|
4394
|
+
output_kind: str(raw, "output_kind"),
|
|
4395
|
+
output,
|
|
4396
|
+
outputs
|
|
4397
|
+
};
|
|
4398
|
+
}
|
|
4399
|
+
function kindVerdictOf(wrapper) {
|
|
4400
|
+
if (wrapper.output_kind_ok === true) return "passed";
|
|
4401
|
+
if (wrapper.output_kind_ok === false) return "failed";
|
|
4402
|
+
return "unchecked";
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4405
|
+
// wire/emit-payload.ts
|
|
4406
|
+
function withRootKind(kind, value) {
|
|
4407
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
4408
|
+
return { [KIND_KEY]: kind, ...value };
|
|
4409
|
+
}
|
|
4410
|
+
return value;
|
|
4411
|
+
}
|
|
4412
|
+
function emitPayloadJson(kind, value) {
|
|
4413
|
+
return JSON.stringify(withRootKind(kind, value), null, 2);
|
|
4414
|
+
}
|
|
4415
|
+
function emitPayloadFence(kind, value) {
|
|
4416
|
+
return "```json\n" + emitPayloadJson(kind, value) + "\n```";
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
export { IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, IrTree, JSON_DISCRIMINATOR, JsonStreamTokenizer, KIND_KEY, KindStorageError, KindStreamParser, NODE_OUTCOME_KIND, ParseSession, ROOT_STORAGE_NAME, RUN_RESULT_KIND, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
4115
4420
|
//# sourceMappingURL=index.js.map
|
|
4116
4421
|
//# sourceMappingURL=index.js.map
|