@ai-matrx/content-ir 0.10.4 → 0.11.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 +52 -0
- package/dist/directives.cjs +386 -0
- package/dist/directives.cjs.map +1 -0
- package/dist/directives.d.cts +294 -0
- package/dist/directives.d.ts +294 -0
- package/dist/directives.js +348 -0
- package/dist/directives.js.map +1 -0
- package/dist/index.cjs +378 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +343 -1
- package/dist/index.js.map +1 -1
- package/package.json +15 -2
package/dist/index.d.cts
CHANGED
|
@@ -6,4 +6,5 @@ export { ParseSession, ParseSessionOptions, disposeParseSession, getParseSession
|
|
|
6
6
|
export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateResult, KindBlockProps, KindDefinition, KindEdgeSpec, KindStorageError, KindStorageShape, KindTier, LegResult, ROOT_STORAGE_NAME, StoredFieldElement, describeDualGateFailure, kindSchemaToStorage, runKindDualGate, storageToKindSchema, validateStructuralLeg } from './registry.cjs';
|
|
7
7
|
export { ArrayItemKindBinding, BlockSchemaDraft, ConversionProblem, DroppedMetadata, FieldComparison, ItemKindRefCheck, JsonSchemaNode, KindJsonSchemaExport, KindJsonSchemaOptions, KindSchemaFromJsonResult, SavePlanEntry, SavePlanValidation, SchemaConversionResult, buildAgentSchemaWithRenderBlockSupport, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, fieldsToDbPayload, injectKindIntoObjectSchema, isDuplicateBlockSlug, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, normalizeAiSchemaInput, runSchemaConversion, validateBlockSchemaSavePlan } from './convert.cjs';
|
|
8
8
|
export { AnyPartialKindEvent, IR_PARTIAL_KEY, KindVerdict, NODE_OUTCOME_KIND, NodeOutcomeWrapper, PartialKindEvent, PartialKindNode, PartialKindState, RUN_RESULT_KIND, RetractedKindEvent, RunResultWrapper, SupersededKindEvent, advancePartialKind, emitPayloadFence, emitPayloadJson, isProvisionalKind, isTerminalKindEvent, kindVerdictOf, makePartialKindStalenessGate, readNodeOutcomeValue, readOutputRef, readPartialKindEvent, readRunResultValue, rehydrateNodeOutcome, rehydrateRunResult, sanitizeInboundPartialKindMetadata, withRootKind } from './wire.cjs';
|
|
9
|
+
export { ACTION_BY_CLASS, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DecodedDirective, DirectiveCapability, DirectiveClass, DirectiveDecodeError, DirectiveDisplay, DirectiveItemKindLookup, DirectiveItemsEdge, DirectiveNounCatalog, DirectiveNounEntry, DirectiveSlug, IN_CONTENT_CLASSES, ItemFact, KindDirectiveShell, RESERVED_PREFIX, SIDE_EFFECT_CLASSES, SLUG_PREFIX, asKindInstance, buildDirectiveSlug, buildKindDirective, capabilityOf, decodeDirective, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, executesAtOutputRoot, isDirectiveClass, isKindDirective, isLegacyShell, isReservedDirectiveSlug, itemFacts, itemSubtitle, itemTitle, legacyShellUses, looksLikeDirectiveHead, nounFamily, nounLabel, nounTitleColumn, parseDirectiveSlug, resetLegacyShellUses, resolvesInContent, titleCaseToken, tryDecodeDirective, tryDecodeDirectiveContent } from './directives.cjs';
|
|
9
10
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { ParseSession, ParseSessionOptions, disposeParseSession, getParseSession
|
|
|
6
6
|
export { DualGateDefinition, DualGateInput, DualGateResolvedComponent, DualGateResult, KindBlockProps, KindDefinition, KindEdgeSpec, KindStorageError, KindStorageShape, KindTier, LegResult, ROOT_STORAGE_NAME, StoredFieldElement, describeDualGateFailure, kindSchemaToStorage, runKindDualGate, storageToKindSchema, validateStructuralLeg } from './registry.js';
|
|
7
7
|
export { ArrayItemKindBinding, BlockSchemaDraft, ConversionProblem, DroppedMetadata, FieldComparison, ItemKindRefCheck, JsonSchemaNode, KindJsonSchemaExport, KindJsonSchemaOptions, KindSchemaFromJsonResult, SavePlanEntry, SavePlanValidation, SchemaConversionResult, buildAgentSchemaWithRenderBlockSupport, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, fieldsToDbPayload, injectKindIntoObjectSchema, isDuplicateBlockSlug, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, normalizeAiSchemaInput, runSchemaConversion, validateBlockSchemaSavePlan } from './convert.js';
|
|
8
8
|
export { AnyPartialKindEvent, IR_PARTIAL_KEY, KindVerdict, NODE_OUTCOME_KIND, NodeOutcomeWrapper, PartialKindEvent, PartialKindNode, PartialKindState, RUN_RESULT_KIND, RetractedKindEvent, RunResultWrapper, SupersededKindEvent, advancePartialKind, emitPayloadFence, emitPayloadJson, isProvisionalKind, isTerminalKindEvent, kindVerdictOf, makePartialKindStalenessGate, readNodeOutcomeValue, readOutputRef, readPartialKindEvent, readRunResultValue, rehydrateNodeOutcome, rehydrateRunResult, sanitizeInboundPartialKindMetadata, withRootKind } from './wire.js';
|
|
9
|
+
export { ACTION_BY_CLASS, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DecodedDirective, DirectiveCapability, DirectiveClass, DirectiveDecodeError, DirectiveDisplay, DirectiveItemKindLookup, DirectiveItemsEdge, DirectiveNounCatalog, DirectiveNounEntry, DirectiveSlug, IN_CONTENT_CLASSES, ItemFact, KindDirectiveShell, RESERVED_PREFIX, SIDE_EFFECT_CLASSES, SLUG_PREFIX, asKindInstance, buildDirectiveSlug, buildKindDirective, capabilityOf, decodeDirective, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, executesAtOutputRoot, isDirectiveClass, isKindDirective, isLegacyShell, isReservedDirectiveSlug, itemFacts, itemSubtitle, itemTitle, legacyShellUses, looksLikeDirectiveHead, nounFamily, nounLabel, nounTitleColumn, parseDirectiveSlug, resetLegacyShellUses, resolvesInContent, titleCaseToken, tryDecodeDirective, tryDecodeDirectiveContent } from './directives.js';
|
|
9
10
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -4625,6 +4625,348 @@ function emitPayloadFence(kind, value) {
|
|
|
4625
4625
|
return "```json\n" + emitPayloadJson(kind, value) + "\n```";
|
|
4626
4626
|
}
|
|
4627
4627
|
|
|
4628
|
-
|
|
4628
|
+
// directives/grammar.ts
|
|
4629
|
+
var RESERVED_PREFIX = "directive_v";
|
|
4630
|
+
var DIRECTIVE_VERSION = 1;
|
|
4631
|
+
var SLUG_PREFIX = `${RESERVED_PREFIX}${DIRECTIVE_VERSION}_`;
|
|
4632
|
+
var CLASSES = [
|
|
4633
|
+
"reference",
|
|
4634
|
+
"view",
|
|
4635
|
+
"create",
|
|
4636
|
+
"update",
|
|
4637
|
+
"delete",
|
|
4638
|
+
"action",
|
|
4639
|
+
"validation",
|
|
4640
|
+
"secret"
|
|
4641
|
+
];
|
|
4642
|
+
var CAPABILITY_BY_CLASS = {
|
|
4643
|
+
reference: "pure",
|
|
4644
|
+
view: "pure",
|
|
4645
|
+
validation: "pure",
|
|
4646
|
+
secret: "sensitive",
|
|
4647
|
+
create: "side_effect",
|
|
4648
|
+
update: "side_effect",
|
|
4649
|
+
delete: "side_effect",
|
|
4650
|
+
action: "side_effect"
|
|
4651
|
+
};
|
|
4652
|
+
var SIDE_EFFECT_CLASSES = new Set(
|
|
4653
|
+
CLASSES.filter((c) => CAPABILITY_BY_CLASS[c] === "side_effect")
|
|
4654
|
+
);
|
|
4655
|
+
var IN_CONTENT_CLASSES = /* @__PURE__ */ new Set([
|
|
4656
|
+
"reference",
|
|
4657
|
+
"secret"
|
|
4658
|
+
]);
|
|
4659
|
+
function isDirectiveClass(value) {
|
|
4660
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(CAPABILITY_BY_CLASS, value);
|
|
4661
|
+
}
|
|
4662
|
+
function isReservedDirectiveSlug(slug) {
|
|
4663
|
+
return typeof slug === "string" && slug.startsWith(RESERVED_PREFIX);
|
|
4664
|
+
}
|
|
4665
|
+
function isToken(value) {
|
|
4666
|
+
return /^[a-z][a-z0-9_]*$/.test(value);
|
|
4667
|
+
}
|
|
4668
|
+
function buildDirectiveSlug(directiveClass, noun, version = DIRECTIVE_VERSION) {
|
|
4669
|
+
if (!isDirectiveClass(directiveClass)) {
|
|
4670
|
+
throw new Error(
|
|
4671
|
+
`unknown directive class ${JSON.stringify(directiveClass)}; the vocabulary is CLOSED: ${CLASSES.join(", ")}.`
|
|
4672
|
+
);
|
|
4673
|
+
}
|
|
4674
|
+
if (typeof noun !== "string" || !isToken(noun)) {
|
|
4675
|
+
throw new Error(
|
|
4676
|
+
`invalid directive noun ${JSON.stringify(noun)} for class ${JSON.stringify(directiveClass)}: a noun is lowercase [a-z0-9_], starts with a letter, and is non-empty.`
|
|
4677
|
+
);
|
|
4678
|
+
}
|
|
4679
|
+
return `${RESERVED_PREFIX}${version}_${directiveClass}_${noun}`;
|
|
4680
|
+
}
|
|
4681
|
+
function parseDirectiveSlug(slug) {
|
|
4682
|
+
if (!isReservedDirectiveSlug(slug)) return null;
|
|
4683
|
+
const rest = slug.slice(RESERVED_PREFIX.length);
|
|
4684
|
+
const firstSep = rest.indexOf("_");
|
|
4685
|
+
if (firstSep <= 0) return null;
|
|
4686
|
+
const versionDigits = rest.slice(0, firstSep);
|
|
4687
|
+
if (!/^[0-9]+$/.test(versionDigits)) return null;
|
|
4688
|
+
const remainder = rest.slice(firstSep + 1);
|
|
4689
|
+
const classSep = remainder.indexOf("_");
|
|
4690
|
+
if (classSep <= 0) return null;
|
|
4691
|
+
const directiveClass = remainder.slice(0, classSep);
|
|
4692
|
+
const noun = remainder.slice(classSep + 1);
|
|
4693
|
+
if (!isDirectiveClass(directiveClass) || !isToken(noun)) return null;
|
|
4694
|
+
return {
|
|
4695
|
+
slug,
|
|
4696
|
+
version: Number.parseInt(versionDigits, 10),
|
|
4697
|
+
directiveClass,
|
|
4698
|
+
noun,
|
|
4699
|
+
capability: CAPABILITY_BY_CLASS[directiveClass],
|
|
4700
|
+
executes: executesAtOutputRoot(directiveClass),
|
|
4701
|
+
inContent: resolvesInContent(directiveClass)
|
|
4702
|
+
};
|
|
4703
|
+
}
|
|
4704
|
+
function capabilityOf(directiveClass) {
|
|
4705
|
+
return CAPABILITY_BY_CLASS[directiveClass];
|
|
4706
|
+
}
|
|
4707
|
+
function executesAtOutputRoot(directiveClass) {
|
|
4708
|
+
return isDirectiveClass(directiveClass) && SIDE_EFFECT_CLASSES.has(directiveClass);
|
|
4709
|
+
}
|
|
4710
|
+
function resolvesInContent(directiveClass) {
|
|
4711
|
+
return isDirectiveClass(directiveClass) && IN_CONTENT_CLASSES.has(directiveClass);
|
|
4712
|
+
}
|
|
4713
|
+
function directiveSlugOf(obj) {
|
|
4714
|
+
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return null;
|
|
4715
|
+
const slug = obj[KIND_KEY];
|
|
4716
|
+
return isReservedDirectiveSlug(slug) ? slug : null;
|
|
4717
|
+
}
|
|
4718
|
+
function isKindDirective(obj) {
|
|
4719
|
+
return directiveSlugOf(obj) !== null;
|
|
4720
|
+
}
|
|
4721
|
+
function buildKindDirective(slug, items) {
|
|
4722
|
+
return { [KIND_KEY]: slug, items };
|
|
4723
|
+
}
|
|
4724
|
+
function looksLikeDirectiveHead(content) {
|
|
4725
|
+
const match = content.trimStart().match(/^\{\s*"__kind"\s*:\s*"([^"]*)/);
|
|
4726
|
+
return !!match && isReservedDirectiveSlug(match[1]);
|
|
4727
|
+
}
|
|
4728
|
+
|
|
4729
|
+
// directives/legacy-shell.ts
|
|
4730
|
+
var LEGACY_SENTINEL = "matrx_version";
|
|
4731
|
+
var CLASS_BY_LEGACY_KIND = {
|
|
4732
|
+
reference: "reference",
|
|
4733
|
+
secret: "secret",
|
|
4734
|
+
validation: "validation"
|
|
4735
|
+
};
|
|
4736
|
+
var LEGACY_SIDE_EFFECT_KINDS = /* @__PURE__ */ new Set(["output_directive", "function"]);
|
|
4737
|
+
var VERB_NOUN_RE = /^(create|update|delete):([a-z][a-z0-9_]*)$/;
|
|
4738
|
+
var USES_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir.legacy-shell-uses");
|
|
4739
|
+
var uses = globalThis[USES_SLOT] ??= { count: 0 };
|
|
4740
|
+
function legacyShellUses() {
|
|
4741
|
+
return uses.count;
|
|
4742
|
+
}
|
|
4743
|
+
function resetLegacyShellUses() {
|
|
4744
|
+
uses.count = 0;
|
|
4745
|
+
}
|
|
4746
|
+
function isLegacyShell(obj) {
|
|
4747
|
+
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return false;
|
|
4748
|
+
const record = obj;
|
|
4749
|
+
if (!(LEGACY_SENTINEL in record)) return false;
|
|
4750
|
+
const kind = record.kind;
|
|
4751
|
+
return typeof kind === "string" && (kind in CLASS_BY_LEGACY_KIND || LEGACY_SIDE_EFFECT_KINDS.has(kind));
|
|
4752
|
+
}
|
|
4753
|
+
function slugForLegacy(kind, type) {
|
|
4754
|
+
let directiveClass;
|
|
4755
|
+
let noun;
|
|
4756
|
+
if (LEGACY_SIDE_EFFECT_KINDS.has(kind)) {
|
|
4757
|
+
const match = VERB_NOUN_RE.exec(type);
|
|
4758
|
+
if (match) {
|
|
4759
|
+
directiveClass = match[1];
|
|
4760
|
+
noun = match[2];
|
|
4761
|
+
} else {
|
|
4762
|
+
directiveClass = "action";
|
|
4763
|
+
noun = type;
|
|
4764
|
+
}
|
|
4765
|
+
} else {
|
|
4766
|
+
const mapped = CLASS_BY_LEGACY_KIND[kind];
|
|
4767
|
+
if (!mapped) return null;
|
|
4768
|
+
directiveClass = mapped;
|
|
4769
|
+
noun = type;
|
|
4770
|
+
}
|
|
4771
|
+
try {
|
|
4772
|
+
return buildDirectiveSlug(directiveClass, noun);
|
|
4773
|
+
} catch {
|
|
4774
|
+
return null;
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
function translateLegacyShell(obj) {
|
|
4778
|
+
const kind = obj.kind;
|
|
4779
|
+
const type = obj.type;
|
|
4780
|
+
if (typeof kind !== "string" || typeof type !== "string") return null;
|
|
4781
|
+
const slug = slugForLegacy(kind, type);
|
|
4782
|
+
if (slug === null) return null;
|
|
4783
|
+
const items = obj.items;
|
|
4784
|
+
uses.count += 1;
|
|
4785
|
+
return { [KIND_KEY]: slug, items: Array.isArray(items) ? [...items] : [] };
|
|
4786
|
+
}
|
|
4787
|
+
|
|
4788
|
+
// directives/decode.ts
|
|
4789
|
+
var DirectiveDecodeError = class extends Error {
|
|
4790
|
+
constructor(message) {
|
|
4791
|
+
super(message);
|
|
4792
|
+
this.name = "DirectiveDecodeError";
|
|
4793
|
+
}
|
|
4794
|
+
};
|
|
4795
|
+
function asObject(value) {
|
|
4796
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
4797
|
+
return value;
|
|
4798
|
+
}
|
|
4799
|
+
function decodeDirective(value) {
|
|
4800
|
+
let obj = asObject(value);
|
|
4801
|
+
if (obj === null) return null;
|
|
4802
|
+
let legacy = false;
|
|
4803
|
+
if (isLegacyShell(obj)) {
|
|
4804
|
+
const translated = translateLegacyShell(obj);
|
|
4805
|
+
if (translated === null) {
|
|
4806
|
+
throw new DirectiveDecodeError(
|
|
4807
|
+
`a retired 4-key shell with kind=${JSON.stringify(obj.kind)} type=${JSON.stringify(obj.type)} does not map onto the Kind Directives grammar. Emit the current shell: {"${KIND_KEY}": "directive_v1_<class>_<noun>", "items": [...]}.`
|
|
4808
|
+
);
|
|
4809
|
+
}
|
|
4810
|
+
obj = translated;
|
|
4811
|
+
legacy = true;
|
|
4812
|
+
}
|
|
4813
|
+
const rawSlug = obj[KIND_KEY];
|
|
4814
|
+
if (!isReservedDirectiveSlug(rawSlug)) return null;
|
|
4815
|
+
const parsed = parseDirectiveSlug(rawSlug);
|
|
4816
|
+
if (parsed === null) {
|
|
4817
|
+
throw new DirectiveDecodeError(
|
|
4818
|
+
`malformed directive slug ${JSON.stringify(rawSlug)} \u2014 it claims the reserved "directive_v" namespace but does not parse as directive_v<version>_<class>_<noun>.`
|
|
4819
|
+
);
|
|
4820
|
+
}
|
|
4821
|
+
const rawItems = obj.items;
|
|
4822
|
+
const items = Array.isArray(rawItems) ? rawItems.filter((i) => asObject(i) !== null) : [];
|
|
4823
|
+
return {
|
|
4824
|
+
parsed,
|
|
4825
|
+
slug: parsed.slug,
|
|
4826
|
+
directiveClass: parsed.directiveClass,
|
|
4827
|
+
noun: parsed.noun,
|
|
4828
|
+
items,
|
|
4829
|
+
shell: { [KIND_KEY]: parsed.slug, items },
|
|
4830
|
+
legacyShell: legacy
|
|
4831
|
+
};
|
|
4832
|
+
}
|
|
4833
|
+
function tryDecodeDirective(value, onError) {
|
|
4834
|
+
try {
|
|
4835
|
+
return decodeDirective(value);
|
|
4836
|
+
} catch (error) {
|
|
4837
|
+
onError?.(error instanceof Error ? error.message : "directive decode failed");
|
|
4838
|
+
return null;
|
|
4839
|
+
}
|
|
4840
|
+
}
|
|
4841
|
+
function tryDecodeDirectiveContent(content, onError) {
|
|
4842
|
+
if (typeof content !== "string") return tryDecodeDirective(content, onError);
|
|
4843
|
+
let parsed;
|
|
4844
|
+
try {
|
|
4845
|
+
parsed = JSON.parse(content);
|
|
4846
|
+
} catch {
|
|
4847
|
+
return null;
|
|
4848
|
+
}
|
|
4849
|
+
return tryDecodeDirective(parsed, onError);
|
|
4850
|
+
}
|
|
4851
|
+
|
|
4852
|
+
// directives/display.ts
|
|
4853
|
+
function titleCaseToken(token) {
|
|
4854
|
+
const words = token.replace(/_/g, " ").trim();
|
|
4855
|
+
return words ? words.charAt(0).toUpperCase() + words.slice(1) : token;
|
|
4856
|
+
}
|
|
4857
|
+
var ACTION_BY_CLASS = {
|
|
4858
|
+
reference: "Reference",
|
|
4859
|
+
view: "View",
|
|
4860
|
+
create: "Create",
|
|
4861
|
+
update: "Update",
|
|
4862
|
+
delete: "Delete",
|
|
4863
|
+
action: "Run",
|
|
4864
|
+
validation: "Validate",
|
|
4865
|
+
secret: "Secret"
|
|
4866
|
+
};
|
|
4867
|
+
function nounLabel(noun, catalog) {
|
|
4868
|
+
const label = catalog?.(noun)?.label;
|
|
4869
|
+
return label && label.length > 0 ? label : titleCaseToken(noun);
|
|
4870
|
+
}
|
|
4871
|
+
function nounFamily(noun, catalog) {
|
|
4872
|
+
return catalog?.(noun)?.family ?? "";
|
|
4873
|
+
}
|
|
4874
|
+
function nounTitleColumn(noun, catalog) {
|
|
4875
|
+
return catalog?.(noun)?.titleColumn ?? null;
|
|
4876
|
+
}
|
|
4877
|
+
function directiveDisplay(directiveClass, noun, catalog) {
|
|
4878
|
+
const label = nounLabel(noun, catalog);
|
|
4879
|
+
const action = ACTION_BY_CLASS[directiveClass];
|
|
4880
|
+
return {
|
|
4881
|
+
noun: label,
|
|
4882
|
+
family: nounFamily(noun, catalog),
|
|
4883
|
+
action,
|
|
4884
|
+
title: `${action} ${label}`
|
|
4885
|
+
};
|
|
4886
|
+
}
|
|
4887
|
+
|
|
4888
|
+
// directives/item-summary.ts
|
|
4889
|
+
var NAME_KEYS = ["name", "title", "label", "heading", "slug", "key", "question", "summary"];
|
|
4890
|
+
var FACT_EXCLUDE = /* @__PURE__ */ new Set([
|
|
4891
|
+
"__kind",
|
|
4892
|
+
...NAME_KEYS,
|
|
4893
|
+
"id",
|
|
4894
|
+
"description",
|
|
4895
|
+
"about",
|
|
4896
|
+
"notes",
|
|
4897
|
+
"content",
|
|
4898
|
+
"text",
|
|
4899
|
+
"body",
|
|
4900
|
+
"organization_id",
|
|
4901
|
+
"user_id",
|
|
4902
|
+
"created_by",
|
|
4903
|
+
"resource_type"
|
|
4904
|
+
]);
|
|
4905
|
+
function firstString(item, keys) {
|
|
4906
|
+
for (const key of keys) {
|
|
4907
|
+
const value = item[key];
|
|
4908
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
4909
|
+
}
|
|
4910
|
+
return null;
|
|
4911
|
+
}
|
|
4912
|
+
function itemTitle(item, titleColumn, index, total) {
|
|
4913
|
+
const fromCatalog = titleColumn ? firstString(item, [titleColumn]) : null;
|
|
4914
|
+
const name = fromCatalog ?? firstString(item, NAME_KEYS);
|
|
4915
|
+
if (name) return name;
|
|
4916
|
+
return total > 1 ? `Item ${index + 1} of ${total}` : "Item";
|
|
4917
|
+
}
|
|
4918
|
+
function itemSubtitle(item) {
|
|
4919
|
+
return firstString(item, ["description", "about", "summary", "doc"]);
|
|
4920
|
+
}
|
|
4921
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4922
|
+
var FACT_LABEL_OVERRIDES = {
|
|
4923
|
+
variable_definitions: "variables",
|
|
4924
|
+
context_policies: "context",
|
|
4925
|
+
custom_tools: "custom tools"
|
|
4926
|
+
};
|
|
4927
|
+
function factLabel(key) {
|
|
4928
|
+
return FACT_LABEL_OVERRIDES[key] ?? key.replace(/_/g, " ");
|
|
4929
|
+
}
|
|
4930
|
+
function itemFacts(item, limit = 4) {
|
|
4931
|
+
const facts = [];
|
|
4932
|
+
for (const [key, value] of Object.entries(item)) {
|
|
4933
|
+
if (facts.length >= limit) break;
|
|
4934
|
+
if (FACT_EXCLUDE.has(key)) continue;
|
|
4935
|
+
if (Array.isArray(value)) {
|
|
4936
|
+
if (value.length === 0) continue;
|
|
4937
|
+
facts.push({ key, label: factLabel(key), value: String(value.length) });
|
|
4938
|
+
continue;
|
|
4939
|
+
}
|
|
4940
|
+
if (typeof value === "string") {
|
|
4941
|
+
const trimmed = value.trim();
|
|
4942
|
+
if (!trimmed || trimmed.length > 40) continue;
|
|
4943
|
+
if (UUID_RE.test(trimmed)) continue;
|
|
4944
|
+
facts.push({ key, label: factLabel(key), value: trimmed });
|
|
4945
|
+
continue;
|
|
4946
|
+
}
|
|
4947
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
4948
|
+
facts.push({ key, label: factLabel(key), value: String(value) });
|
|
4949
|
+
}
|
|
4950
|
+
}
|
|
4951
|
+
return facts;
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4954
|
+
// directives/item-kind.ts
|
|
4955
|
+
function directiveItemKindFromEdges(edges) {
|
|
4956
|
+
for (const edge of edges ?? []) {
|
|
4957
|
+
const field = edge.field_name ?? edge.fieldPath;
|
|
4958
|
+
const child = edge.child_kind ?? edge.childKind;
|
|
4959
|
+
if (field === "items" && typeof child === "string" && child) return child;
|
|
4960
|
+
}
|
|
4961
|
+
return null;
|
|
4962
|
+
}
|
|
4963
|
+
function asKindInstance(item, kind) {
|
|
4964
|
+
const existing = item[KIND_KEY];
|
|
4965
|
+
const resolved = typeof existing === "string" && existing ? existing : kind;
|
|
4966
|
+
if (!resolved) return null;
|
|
4967
|
+
return { [KIND_KEY]: resolved, ...item };
|
|
4968
|
+
}
|
|
4969
|
+
|
|
4970
|
+
export { ACTION_BY_CLASS, CAPABILITY_BY_CLASS, CLASSES, DIRECTIVE_VERSION, DirectiveDecodeError, IN_CONTENT_CLASSES, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, IrTree, JSON_DISCRIMINATOR, JsonStreamTokenizer, KIND_KEY, KindStorageError, KindStreamParser, NODE_OUTCOME_KIND, ParseSession, RESERVED_PREFIX, ROOT_STORAGE_NAME, RUN_RESULT_KIND, SIDE_EFFECT_CLASSES, SLUG_PREFIX, advancePartialKind, asKindInstance, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, buildDirectiveSlug, buildKindDirective, capabilityOf, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, decodeDirective, describeDualGateFailure, directiveDisplay, directiveItemKindFromEdges, directiveSlugOf, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, executesAtOutputRoot, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDirectiveClass, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isKindDirective, isLegacyShell, isProvisionalKind, isReservedDirectiveSlug, isScalarArrayType, isTerminalKindEvent, itemFacts, itemSubtitle, itemTitle, kindSchemaFromJsonSchema, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, legacyShellUses, looksLikeDirectiveHead, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, nounFamily, nounLabel, nounTitleColumn, openParseSession, parseDirectiveSlug, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, resetLegacyShellUses, resolvesInContent, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, titleCaseToken, tryDecodeDirective, tryDecodeDirectiveContent, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
|
|
4629
4971
|
//# sourceMappingURL=index.js.map
|
|
4630
4972
|
//# sourceMappingURL=index.js.map
|