@ai-matrx/content-ir-react 0.11.10 → 0.11.11
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 +22 -0
- package/dist/directives.cjs +60 -7
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +22 -2
- package/dist/directives.d.ts +22 -2
- package/dist/directives.js +60 -7
- package/dist/directives.js.map +1 -1
- package/dist/index.cjs +128 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +107 -54
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +127 -76
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +105 -54
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
DelegatedOutput: () => DelegatedOutput,
|
|
40
40
|
DirectiveFallbackCard: () => DirectiveFallbackCard,
|
|
41
41
|
DirectiveHostProvider: () => DirectiveHostProvider,
|
|
42
|
+
DirectiveProvisionalCard: () => DirectiveProvisionalCard,
|
|
42
43
|
DirectiveRender: () => DirectiveRender,
|
|
43
44
|
GENERIC_STRUCTURED_COMPONENT_KEY: () => GENERIC_STRUCTURED_COMPONENT_KEY,
|
|
44
45
|
GenericStructuredView: () => GenericStructuredView,
|
|
@@ -63,6 +64,7 @@ __export(index_exports, {
|
|
|
63
64
|
kindIsRoutable: () => kindIsRoutable,
|
|
64
65
|
kindServerDataFromStoredValue: () => kindServerDataFromStoredValue,
|
|
65
66
|
markKindPartialUnsafe: () => markKindPartialUnsafe,
|
|
67
|
+
provisionalDirectiveSlug: () => provisionalDirectiveSlug,
|
|
66
68
|
readIrRouteMarker: () => readIrRouteMarker,
|
|
67
69
|
registerDirectiveRenderer: () => registerDirectiveRenderer,
|
|
68
70
|
resetDirectiveRenderers: () => resetDirectiveRenderers,
|
|
@@ -769,10 +771,10 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
769
771
|
|
|
770
772
|
// react/KindInstanceRender.tsx
|
|
771
773
|
var import_react6 = require("react");
|
|
772
|
-
var
|
|
774
|
+
var import_content_ir8 = require("@ai-matrx/content-ir");
|
|
773
775
|
|
|
774
776
|
// directives/DirectiveRender.tsx
|
|
775
|
-
var
|
|
777
|
+
var import_content_ir7 = require("@ai-matrx/content-ir");
|
|
776
778
|
|
|
777
779
|
// directives/DirectiveFallbackCard.tsx
|
|
778
780
|
var import_content_ir3 = require("@ai-matrx/content-ir");
|
|
@@ -971,15 +973,55 @@ function DirectiveFallbackCard({ directive, reason }) {
|
|
|
971
973
|
] });
|
|
972
974
|
}
|
|
973
975
|
|
|
974
|
-
// directives/
|
|
976
|
+
// directives/DirectiveProvisionalCard.tsx
|
|
975
977
|
var import_content_ir4 = require("@ai-matrx/content-ir");
|
|
978
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
979
|
+
var COMPLETE_SLUG_RE = /^\{\s*"__kind"\s*:\s*"([^"]+)"/;
|
|
980
|
+
function provisionalDirectiveSlug(content) {
|
|
981
|
+
const match = content.trimStart().match(COMPLETE_SLUG_RE);
|
|
982
|
+
return match?.[1] ?? null;
|
|
983
|
+
}
|
|
984
|
+
function DirectiveProvisionalCard({ content, streaming, className }) {
|
|
985
|
+
const host = useDirectiveHost();
|
|
986
|
+
const slug = provisionalDirectiveSlug(content);
|
|
987
|
+
const known = slug ? (0, import_content_ir4.parseDirectiveSlug)(slug) : null;
|
|
988
|
+
const display = known ? (0, import_content_ir4.directiveDisplay)(known.directiveClass, known.noun, host.nouns) : null;
|
|
989
|
+
const Icon = known ? classIcon(known.directiveClass, known.noun) : BoxesIcon;
|
|
990
|
+
const title = display?.title ?? "Structured action";
|
|
991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
992
|
+
"div",
|
|
993
|
+
{
|
|
994
|
+
className: `my-3 rounded-md border border-border bg-card px-2.5 py-1.5${className ? ` ${className}` : ""}`,
|
|
995
|
+
"data-directive": slug ?? void 0,
|
|
996
|
+
"data-directive-state": streaming ? "streaming" : "incomplete",
|
|
997
|
+
children: [
|
|
998
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
999
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
1000
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-sm font-medium text-foreground", children: title }),
|
|
1001
|
+
display?.family ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-xs text-muted-foreground", children: display.family }) : null,
|
|
1002
|
+
streaming ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", role: "status", children: [
|
|
1003
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-primary", "aria-hidden": true }),
|
|
1004
|
+
"Writing\u2026"
|
|
1005
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-xs text-destructive", role: "status", children: "Cut off before it finished \u2014 nothing can be applied." })
|
|
1006
|
+
] }),
|
|
1007
|
+
streaming ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("details", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
1008
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("summary", { className: "cursor-pointer select-none hover:text-foreground", children: "Show what arrived" }),
|
|
1009
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("pre", { className: "mt-1 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded bg-muted px-2 py-1 text-[11px]", children: content })
|
|
1010
|
+
] })
|
|
1011
|
+
]
|
|
1012
|
+
}
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// directives/registry.ts
|
|
1017
|
+
var import_content_ir5 = require("@ai-matrx/content-ir");
|
|
976
1018
|
var REGISTRY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir-react.directive-renderers");
|
|
977
1019
|
var registry = globalThis[REGISTRY_SLOT] ??= {
|
|
978
1020
|
bySlug: /* @__PURE__ */ new Map(),
|
|
979
1021
|
byClass: /* @__PURE__ */ new Map()
|
|
980
1022
|
};
|
|
981
1023
|
function registerDirectiveRenderer(directiveClass, renderer, noun) {
|
|
982
|
-
if (noun) registry.bySlug.set((0,
|
|
1024
|
+
if (noun) registry.bySlug.set((0, import_content_ir5.buildDirectiveSlug)(directiveClass, noun), renderer);
|
|
983
1025
|
else registry.byClass.set(directiveClass, renderer);
|
|
984
1026
|
}
|
|
985
1027
|
function getDirectiveRenderer(directive) {
|
|
@@ -992,8 +1034,8 @@ function resetDirectiveRenderers() {
|
|
|
992
1034
|
|
|
993
1035
|
// directives/SideEffectDirectiveCard.tsx
|
|
994
1036
|
var import_react5 = require("react");
|
|
995
|
-
var
|
|
996
|
-
var
|
|
1037
|
+
var import_content_ir6 = require("@ai-matrx/content-ir");
|
|
1038
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
997
1039
|
var ROWS_BEFORE_FOLD = 3;
|
|
998
1040
|
function ItemRow({
|
|
999
1041
|
directive,
|
|
@@ -1002,31 +1044,31 @@ function ItemRow({
|
|
|
1002
1044
|
total
|
|
1003
1045
|
}) {
|
|
1004
1046
|
const host = useDirectiveHost();
|
|
1005
|
-
const titleColumn = (0,
|
|
1006
|
-
const title = (0,
|
|
1007
|
-
const subtitle = (0,
|
|
1008
|
-
const facts = (0,
|
|
1047
|
+
const titleColumn = (0, import_content_ir6.nounTitleColumn)(directive.noun, host.nouns);
|
|
1048
|
+
const title = (0, import_content_ir6.itemTitle)(item, titleColumn, index, total);
|
|
1049
|
+
const subtitle = (0, import_content_ir6.itemSubtitle)(item);
|
|
1050
|
+
const facts = (0, import_content_ir6.itemFacts)(item);
|
|
1009
1051
|
const kind = host.itemKind?.(directive.slug) ?? null;
|
|
1010
|
-
const display = (0,
|
|
1052
|
+
const display = (0, import_content_ir6.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
1011
1053
|
const openItem = host.openItem;
|
|
1012
|
-
const body = /* @__PURE__ */ (0,
|
|
1013
|
-
/* @__PURE__ */ (0,
|
|
1014
|
-
/* @__PURE__ */ (0,
|
|
1054
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1055
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
|
|
1056
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hidden min-w-0 flex-1 items-baseline gap-2 overflow-hidden sm:flex", children: facts.map((fact) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "truncate text-[11px] text-muted-foreground", children: [
|
|
1015
1057
|
fact.value,
|
|
1016
1058
|
" ",
|
|
1017
1059
|
fact.label
|
|
1018
1060
|
] }, fact.key)) }),
|
|
1019
|
-
subtitle && facts.length === 0 ? /* @__PURE__ */ (0,
|
|
1020
|
-
openItem ? /* @__PURE__ */ (0,
|
|
1061
|
+
subtitle && facts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hidden truncate text-[11px] text-muted-foreground sm:inline", children: subtitle }) : null,
|
|
1062
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MaximizeIcon, { className: "ml-auto h-3 w-3 shrink-0 text-muted-foreground" }) : null
|
|
1021
1063
|
] });
|
|
1022
|
-
return /* @__PURE__ */ (0,
|
|
1023
|
-
openItem ? /* @__PURE__ */ (0,
|
|
1064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2 py-1 text-xs", children: [
|
|
1065
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1024
1066
|
"button",
|
|
1025
1067
|
{
|
|
1026
1068
|
type: "button",
|
|
1027
1069
|
onClick: () => openItem({
|
|
1028
1070
|
// Stamped so the panel's kind pipeline types it from its own first key.
|
|
1029
|
-
item: (0,
|
|
1071
|
+
item: (0, import_content_ir6.asKindInstance)(item, kind) ?? item,
|
|
1030
1072
|
itemKind: kind,
|
|
1031
1073
|
title,
|
|
1032
1074
|
subtitle: `${display.title} \xB7 item ${index + 1} of ${total}`,
|
|
@@ -1038,7 +1080,7 @@ function ItemRow({
|
|
|
1038
1080
|
title: "Open to read it",
|
|
1039
1081
|
children: body
|
|
1040
1082
|
}
|
|
1041
|
-
) : /* @__PURE__ */ (0,
|
|
1083
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-2 px-1 py-0.5", children: body }),
|
|
1042
1084
|
host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
|
|
1043
1085
|
] });
|
|
1044
1086
|
}
|
|
@@ -1047,37 +1089,37 @@ function SideEffectDirectiveCard({ directive }) {
|
|
|
1047
1089
|
const [expanded, setExpanded] = (0, import_react5.useState)(false);
|
|
1048
1090
|
const items = directive.items;
|
|
1049
1091
|
const total = items.length;
|
|
1050
|
-
const display = (0,
|
|
1092
|
+
const display = (0, import_content_ir6.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
1051
1093
|
const Icon = classIcon(directive.directiveClass, directive.noun);
|
|
1052
1094
|
const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
|
|
1053
1095
|
const hidden = total - shown.length;
|
|
1054
|
-
return /* @__PURE__ */ (0,
|
|
1055
|
-
/* @__PURE__ */ (0,
|
|
1056
|
-
/* @__PURE__ */ (0,
|
|
1057
|
-
/* @__PURE__ */ (0,
|
|
1058
|
-
display.family ? /* @__PURE__ */ (0,
|
|
1059
|
-
/* @__PURE__ */ (0,
|
|
1096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "my-3 rounded-md border border-border bg-card px-2.5 py-1.5", "data-directive": directive.slug, children: [
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
1098
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
1099
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-sm font-medium text-foreground", children: display.title }),
|
|
1100
|
+
display.family ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-xs text-muted-foreground", children: display.family }) : null,
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "text-xs tabular-nums text-muted-foreground", children: [
|
|
1060
1102
|
total,
|
|
1061
1103
|
" ",
|
|
1062
1104
|
total === 1 ? "item" : "items"
|
|
1063
1105
|
] }),
|
|
1064
|
-
/* @__PURE__ */ (0,
|
|
1106
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "ml-auto flex items-center gap-1", children: [
|
|
1065
1107
|
host.renderCopy?.({ label: display.title, value: directive.shell, size: "icon" }),
|
|
1066
|
-
/* @__PURE__ */ (0,
|
|
1108
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ApplyDirectiveButton, { directive, itemCount: total })
|
|
1067
1109
|
] })
|
|
1068
1110
|
] }),
|
|
1069
1111
|
total === 0 ? (
|
|
1070
1112
|
// Stated, never silent: an empty batch is a real (and suspicious) state.
|
|
1071
|
-
/* @__PURE__ */ (0,
|
|
1072
|
-
) : /* @__PURE__ */ (0,
|
|
1073
|
-
hidden > 0 || expanded ? /* @__PURE__ */ (0,
|
|
1113
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "mt-1 text-xs text-muted-foreground", children: "No items \u2014 nothing would be written." })
|
|
1114
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ItemRow, { directive, item, index: i, total }, i)) }),
|
|
1115
|
+
hidden > 0 || expanded ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1074
1116
|
"button",
|
|
1075
1117
|
{
|
|
1076
1118
|
type: "button",
|
|
1077
1119
|
onClick: () => setExpanded((v) => !v),
|
|
1078
1120
|
className: "mt-0.5 inline-flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",
|
|
1079
1121
|
children: [
|
|
1080
|
-
expanded ? /* @__PURE__ */ (0,
|
|
1122
|
+
expanded ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronRightIcon, { className: "h-3 w-3" }),
|
|
1081
1123
|
expanded ? "Show less" : `Show ${hidden} more`
|
|
1082
1124
|
]
|
|
1083
1125
|
}
|
|
@@ -1086,17 +1128,28 @@ function SideEffectDirectiveCard({ directive }) {
|
|
|
1086
1128
|
}
|
|
1087
1129
|
|
|
1088
1130
|
// directives/DirectiveRender.tsx
|
|
1089
|
-
var
|
|
1090
|
-
function
|
|
1131
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1132
|
+
function isWholeJson(content) {
|
|
1133
|
+
try {
|
|
1134
|
+
JSON.parse(content);
|
|
1135
|
+
return true;
|
|
1136
|
+
} catch {
|
|
1137
|
+
return false;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
function DirectiveRender({ content, className, streaming }) {
|
|
1091
1141
|
const host = useDirectiveHost();
|
|
1092
|
-
const directive = (0,
|
|
1142
|
+
const directive = (0, import_content_ir7.tryDecodeDirectiveContent)(content, (message) => {
|
|
1093
1143
|
const line = `[kind-directives] ${message}`;
|
|
1094
1144
|
if (host.reportError) host.reportError(line);
|
|
1095
1145
|
else console.error(line);
|
|
1096
1146
|
});
|
|
1097
1147
|
if (!directive) {
|
|
1148
|
+
if (typeof content === "string" && (0, import_content_ir7.looksLikeDirectiveHead)(content) && !isWholeJson(content)) {
|
|
1149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DirectiveProvisionalCard, { content, streaming: streaming !== false, className });
|
|
1150
|
+
}
|
|
1098
1151
|
const raw = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
1099
|
-
return /* @__PURE__ */ (0,
|
|
1152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1100
1153
|
"pre",
|
|
1101
1154
|
{
|
|
1102
1155
|
className: `my-3 overflow-x-auto rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground${className ? ` ${className}` : ""}`,
|
|
@@ -1105,26 +1158,26 @@ function DirectiveRender({ content, className }) {
|
|
|
1105
1158
|
);
|
|
1106
1159
|
}
|
|
1107
1160
|
const Renderer = getDirectiveRenderer(directive);
|
|
1108
|
-
if (Renderer) return /* @__PURE__ */ (0,
|
|
1109
|
-
if (directive.parsed.executes) return /* @__PURE__ */ (0,
|
|
1110
|
-
return /* @__PURE__ */ (0,
|
|
1161
|
+
if (Renderer) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Renderer, { directive });
|
|
1162
|
+
if (directive.parsed.executes) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SideEffectDirectiveCard, { directive });
|
|
1163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DirectiveFallbackCard, { directive });
|
|
1111
1164
|
}
|
|
1112
1165
|
|
|
1113
1166
|
// react/KindInstanceRender.tsx
|
|
1114
|
-
var
|
|
1167
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1115
1168
|
function isRecordValue(value) {
|
|
1116
1169
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1117
1170
|
}
|
|
1118
1171
|
function kindIsRoutable(kind, host) {
|
|
1119
|
-
if ((0,
|
|
1172
|
+
if ((0, import_content_ir8.isReservedDirectiveSlug)(kind)) return true;
|
|
1120
1173
|
if (host.kinds.getDefinition(kind)?.legacyBlockType) return true;
|
|
1121
1174
|
const resolution = host.components.resolve(kind, host.platform, "output");
|
|
1122
1175
|
if (!resolution?.isActive) return false;
|
|
1123
1176
|
return resolution.componentKey !== GENERIC_STRUCTURED_COMPONENT_KEY;
|
|
1124
1177
|
}
|
|
1125
1178
|
function KindInstanceRender(props) {
|
|
1126
|
-
if ((0,
|
|
1127
|
-
return /* @__PURE__ */ (0,
|
|
1179
|
+
if ((0, import_content_ir8.isReservedDirectiveSlug)(props.kind)) {
|
|
1180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1128
1181
|
DirectiveRender,
|
|
1129
1182
|
{
|
|
1130
1183
|
content: props.value,
|
|
@@ -1132,7 +1185,7 @@ function KindInstanceRender(props) {
|
|
|
1132
1185
|
}
|
|
1133
1186
|
);
|
|
1134
1187
|
}
|
|
1135
|
-
return /* @__PURE__ */ (0,
|
|
1188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(KindInstanceRenderInner, { ...props });
|
|
1136
1189
|
}
|
|
1137
1190
|
function KindInstanceRenderInner({
|
|
1138
1191
|
kind,
|
|
@@ -1178,24 +1231,24 @@ function KindInstanceRenderInner({
|
|
|
1178
1231
|
content: JSON.stringify(value, null, 2),
|
|
1179
1232
|
language: "json",
|
|
1180
1233
|
metadata: {
|
|
1181
|
-
[
|
|
1234
|
+
[import_content_ir8.IR_ENVELOPE_KEY]: (0, import_content_ir8.envelopeFromCompleteValue)(value, kind)
|
|
1182
1235
|
}
|
|
1183
1236
|
} : null;
|
|
1184
1237
|
const frameClass = variant === "bare" ? void 0 : "rounded-md border border-border bg-card p-3";
|
|
1185
1238
|
if (routingStatus === "unroutable" && unroutableFallback !== void 0) {
|
|
1186
|
-
return /* @__PURE__ */ (0,
|
|
1239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: unroutableFallback });
|
|
1187
1240
|
}
|
|
1188
1241
|
const onTheFloor = block === null || routingStatus === "unroutable";
|
|
1189
1242
|
const notice = "This shape has no custom component yet, so it renders through the universal viewer \u2014 exactly what production shows today.";
|
|
1190
|
-
return /* @__PURE__ */ (0,
|
|
1191
|
-
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0,
|
|
1192
|
-
/* @__PURE__ */ (0,
|
|
1243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: className ? `space-y-3 ${className}` : "space-y-3", children: [
|
|
1244
|
+
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-800 dark:text-amber-200", children: notice }) : null,
|
|
1245
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: frameClass, children: onTheFloor ? host.renderValue({ value, kind }) : host.renderBlock(block) })
|
|
1193
1246
|
] });
|
|
1194
1247
|
}
|
|
1195
1248
|
|
|
1196
1249
|
// react/ProvisionalKindBoundary.tsx
|
|
1197
1250
|
var import_react7 = __toESM(require("react"), 1);
|
|
1198
|
-
var
|
|
1251
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1199
1252
|
var ProvisionalKindBoundaryInner = class extends import_react7.default.Component {
|
|
1200
1253
|
state = { failed: false };
|
|
1201
1254
|
static getDerivedStateFromError() {
|
|
@@ -1220,25 +1273,25 @@ var ProvisionalKindBoundaryInner = class extends import_react7.default.Component
|
|
|
1220
1273
|
};
|
|
1221
1274
|
function ProvisionalKindBoundary(props) {
|
|
1222
1275
|
const host = useContentIrHost();
|
|
1223
|
-
return /* @__PURE__ */ (0,
|
|
1276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ProvisionalKindBoundaryInner, { ...props, reportError: host.reportError });
|
|
1224
1277
|
}
|
|
1225
1278
|
function ProvisionalKindFrame({ children }) {
|
|
1226
1279
|
const host = useContentIrHost();
|
|
1227
1280
|
const label = "Still arriving";
|
|
1228
|
-
return /* @__PURE__ */ (0,
|
|
1281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "relative", "aria-busy": "true", children: [
|
|
1229
1282
|
children,
|
|
1230
|
-
/* @__PURE__ */ (0,
|
|
1283
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "pointer-events-none absolute -top-2 right-4 z-10 select-none rounded-full bg-background px-1.5 leading-4", children: host.renderShimmer?.(label) ?? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-[10px] text-muted-foreground", children: label }) })
|
|
1231
1284
|
] });
|
|
1232
1285
|
}
|
|
1233
1286
|
|
|
1234
1287
|
// react/GenericStructuredView.tsx
|
|
1235
1288
|
var import_react8 = require("react");
|
|
1236
|
-
var
|
|
1237
|
-
var
|
|
1289
|
+
var import_content_ir9 = require("@ai-matrx/content-ir");
|
|
1290
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1238
1291
|
function readStructuredValue(content, metadata) {
|
|
1239
|
-
const envelope = (0,
|
|
1292
|
+
const envelope = (0, import_content_ir9.readEnvelope)(metadata);
|
|
1240
1293
|
if (envelope) {
|
|
1241
|
-
return { value: (0,
|
|
1294
|
+
return { value: (0, import_content_ir9.reconstructRegionValue)(envelope), recovered: true };
|
|
1242
1295
|
}
|
|
1243
1296
|
try {
|
|
1244
1297
|
return { value: JSON.parse(content), recovered: true };
|
|
@@ -1253,25 +1306,25 @@ function GenericStructuredView({
|
|
|
1253
1306
|
className
|
|
1254
1307
|
}) {
|
|
1255
1308
|
const host = useContentIrHost();
|
|
1256
|
-
const envelope = (0,
|
|
1309
|
+
const envelope = (0, import_content_ir9.readEnvelope)(metadata);
|
|
1257
1310
|
const status = envelope?.root.status ?? "complete";
|
|
1258
1311
|
const { value, recovered } = readStructuredValue(content, metadata);
|
|
1259
|
-
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0,
|
|
1312
|
+
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir9.readObjectKind)(value) : null) ?? "";
|
|
1260
1313
|
const marker = readIrRouteMarker(metadata);
|
|
1261
1314
|
const note = marker?.reason === "inactive" ? "a custom view is registered but held inactive" : marker?.reason === "broken-instance" ? "this instance did not match the shape's schema" : marker?.reason === "unregistered" ? "this shape isn't registered on this platform" : "no custom view yet";
|
|
1262
|
-
return /* @__PURE__ */ (0,
|
|
1263
|
-
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0,
|
|
1315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
|
|
1316
|
+
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "mb-2 text-xs text-muted-foreground", children: "Still arriving\u2026" }) : null,
|
|
1264
1317
|
recovered ? host.renderValue({ value, ...kind ? { kind } : {}, note }) : (
|
|
1265
1318
|
// Zero-data-loss backstop: the region never parsed, so show the source
|
|
1266
1319
|
// verbatim rather than swallowing it.
|
|
1267
|
-
/* @__PURE__ */ (0,
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("pre", { className: "max-h-96 overflow-auto font-mono text-xs leading-relaxed text-muted-foreground", children: content })
|
|
1268
1321
|
)
|
|
1269
1322
|
] });
|
|
1270
1323
|
}
|
|
1271
1324
|
|
|
1272
1325
|
// react/RuntimeWrapperViews.tsx
|
|
1273
|
-
var
|
|
1274
|
-
var
|
|
1326
|
+
var import_content_ir10 = require("@ai-matrx/content-ir");
|
|
1327
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1275
1328
|
function isRecord2(value) {
|
|
1276
1329
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1277
1330
|
}
|
|
@@ -1287,16 +1340,16 @@ function DelegatedOutput({
|
|
|
1287
1340
|
}) {
|
|
1288
1341
|
const host = useContentIrHost();
|
|
1289
1342
|
if (output === null || output === void 0) {
|
|
1290
|
-
return /* @__PURE__ */ (0,
|
|
1343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyLabel });
|
|
1291
1344
|
}
|
|
1292
1345
|
if (!isRecord2(output)) {
|
|
1293
|
-
return /* @__PURE__ */ (0,
|
|
1346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: host.renderValue({ value: output }) });
|
|
1294
1347
|
}
|
|
1295
|
-
const kind = (0,
|
|
1348
|
+
const kind = (0, import_content_ir10.readObjectKind)(output) ?? declaredKind;
|
|
1296
1349
|
if (!kind) {
|
|
1297
|
-
return /* @__PURE__ */ (0,
|
|
1350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
|
|
1298
1351
|
}
|
|
1299
|
-
return /* @__PURE__ */ (0,
|
|
1352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1300
1353
|
KindInstanceRender,
|
|
1301
1354
|
{
|
|
1302
1355
|
kind,
|
|
@@ -1310,10 +1363,10 @@ function DelegatedOutput({
|
|
|
1310
1363
|
function NodeOutcomeView({ serverData, fallback }) {
|
|
1311
1364
|
const wrapper = readWrapperFrom(
|
|
1312
1365
|
serverData,
|
|
1313
|
-
|
|
1366
|
+
import_content_ir10.readNodeOutcomeValue
|
|
1314
1367
|
);
|
|
1315
1368
|
if (!wrapper) return null;
|
|
1316
|
-
return /* @__PURE__ */ (0,
|
|
1369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1317
1370
|
DelegatedOutput,
|
|
1318
1371
|
{
|
|
1319
1372
|
output: wrapper.output,
|
|
@@ -1325,17 +1378,17 @@ function NodeOutcomeView({ serverData, fallback }) {
|
|
|
1325
1378
|
function RunResultView({ serverData, fallback }) {
|
|
1326
1379
|
const wrapper = readWrapperFrom(
|
|
1327
1380
|
serverData,
|
|
1328
|
-
|
|
1381
|
+
import_content_ir10.readRunResultValue
|
|
1329
1382
|
);
|
|
1330
1383
|
if (!wrapper) return null;
|
|
1331
|
-
return /* @__PURE__ */ (0,
|
|
1384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "space-y-2", children: wrapper.outputs.length > 0 ? wrapper.outputs.map((outcome) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1332
1385
|
NodeOutcomeView,
|
|
1333
1386
|
{
|
|
1334
1387
|
serverData: { wrapper: outcome },
|
|
1335
1388
|
...fallback === void 0 ? {} : { fallback }
|
|
1336
1389
|
},
|
|
1337
1390
|
`${outcome.node_id}:${outcome.attempt}`
|
|
1338
|
-
)) : /* @__PURE__ */ (0,
|
|
1391
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1339
1392
|
DelegatedOutput,
|
|
1340
1393
|
{
|
|
1341
1394
|
output: wrapper.output,
|