@ai-matrx/content-ir-react 0.11.11 → 0.12.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 +33 -0
- package/dist/directive-host-Bl-ZgJWp.d.cts +116 -0
- package/dist/directive-host-Bl-ZgJWp.d.ts +116 -0
- package/dist/directives.cjs +164 -23
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +43 -2
- package/dist/directives.d.ts +43 -2
- package/dist/directives.js +149 -7
- package/dist/directives.js.map +1 -1
- package/dist/{host-types-C8jR31Wk.d.cts → host-types-BgROpyjE.d.cts} +1 -1
- package/dist/{host-types-IUEDmso7.d.ts → host-types-Cz-1pGHz.d.ts} +1 -1
- package/dist/host.cjs.map +1 -1
- package/dist/host.d.cts +3 -3
- package/dist/host.d.ts +3 -3
- package/dist/host.js.map +1 -1
- package/dist/index.cjs +179 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -3
- package/dist/index.d.ts +44 -3
- package/dist/index.js +149 -7
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +174 -39
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +143 -7
- package/dist/react.js.map +1 -1
- package/dist/{route-B9U-9QCw.d.cts → route-DxK1SoPh.d.cts} +54 -1
- package/dist/{route-gNpJ8zzW.d.ts → route-JGZfl2nL.d.ts} +54 -1
- package/dist/route.d.cts +1 -1
- package/dist/route.d.ts +1 -1
- package/package.json +3 -2
- package/dist/directive-host-DAb7Keg8.d.cts +0 -63
- package/dist/directive-host-DAb7Keg8.d.ts +0 -63
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ApplyDirectiveButton: () => ApplyDirectiveButton,
|
|
34
|
+
CHANGE_VALUE_MAX: () => CHANGE_VALUE_MAX,
|
|
34
35
|
ComponentResolver: () => ComponentResolver,
|
|
35
36
|
ContentIrRenderProvider: () => ContentIrRenderProvider,
|
|
36
37
|
DB_KIND_COMPONENT_KEY: () => DB_KIND_COMPONENT_KEY,
|
|
@@ -51,21 +52,26 @@ __export(index_exports, {
|
|
|
51
52
|
ProvisionalKindFrame: () => ProvisionalKindFrame,
|
|
52
53
|
RunResultView: () => RunResultView,
|
|
53
54
|
SideEffectDirectiveCard: () => SideEffectDirectiveCard,
|
|
55
|
+
TARGETING_CLASSES: () => TARGETING_CLASSES,
|
|
54
56
|
applyIrKindRoute: () => applyIrKindRoute,
|
|
55
57
|
consoleErrorReporter: () => consoleErrorReporter,
|
|
56
58
|
createDbKindComponentCache: () => createDbKindComponentCache,
|
|
57
59
|
createKindRouteBinding: () => createKindRouteBinding,
|
|
58
60
|
envelopeFromPartialKind: () => envelopeFromPartialKind,
|
|
61
|
+
fieldLabel: () => fieldLabel,
|
|
59
62
|
getDirectiveRenderer: () => getDirectiveRenderer,
|
|
60
63
|
isDbKindComponentBodyPending: () => isDbKindComponentBodyPending,
|
|
61
64
|
isPartialReadyKind: () => isPartialReadyKind,
|
|
62
65
|
isProvisionalBlock: () => isProvisionalBlock,
|
|
63
66
|
isRecordValue: () => isRecordValue,
|
|
67
|
+
itemChanges: () => itemChanges,
|
|
68
|
+
itemRecordId: () => itemRecordId,
|
|
64
69
|
kindIsRoutable: () => kindIsRoutable,
|
|
65
70
|
kindServerDataFromStoredValue: () => kindServerDataFromStoredValue,
|
|
66
71
|
markKindPartialUnsafe: () => markKindPartialUnsafe,
|
|
67
72
|
provisionalDirectiveSlug: () => provisionalDirectiveSlug,
|
|
68
73
|
readIrRouteMarker: () => readIrRouteMarker,
|
|
74
|
+
recordFallbackName: () => recordFallbackName,
|
|
69
75
|
registerDirectiveRenderer: () => registerDirectiveRenderer,
|
|
70
76
|
resetDirectiveRenderers: () => resetDirectiveRenderers,
|
|
71
77
|
resetPartialUnsafeKinds: () => resetPartialUnsafeKinds,
|
|
@@ -771,16 +777,73 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
771
777
|
|
|
772
778
|
// react/KindInstanceRender.tsx
|
|
773
779
|
var import_react6 = require("react");
|
|
774
|
-
var
|
|
780
|
+
var import_content_ir9 = require("@ai-matrx/content-ir");
|
|
775
781
|
|
|
776
782
|
// directives/DirectiveRender.tsx
|
|
777
|
-
var
|
|
783
|
+
var import_content_ir8 = require("@ai-matrx/content-ir");
|
|
778
784
|
|
|
779
785
|
// directives/DirectiveFallbackCard.tsx
|
|
780
|
-
var
|
|
786
|
+
var import_content_ir4 = require("@ai-matrx/content-ir");
|
|
781
787
|
|
|
782
788
|
// directives/ApplyDirectiveButton.tsx
|
|
783
789
|
var import_react4 = require("react");
|
|
790
|
+
var import_content_ir3 = require("@ai-matrx/content-ir");
|
|
791
|
+
|
|
792
|
+
// directives/item-changes.ts
|
|
793
|
+
var import_uuid = require("@ai-matrx/kit/uuid");
|
|
794
|
+
var TARGETING_CLASSES = /* @__PURE__ */ new Set(["update", "delete"]);
|
|
795
|
+
var NOT_A_CHANGE = /* @__PURE__ */ new Set(["__kind", "id"]);
|
|
796
|
+
var CHANGE_VALUE_MAX = 60;
|
|
797
|
+
function itemRecordId(item) {
|
|
798
|
+
const id = item.id;
|
|
799
|
+
if (typeof id === "string" && id.trim()) return id.trim();
|
|
800
|
+
if (typeof id === "number") return String(id);
|
|
801
|
+
return null;
|
|
802
|
+
}
|
|
803
|
+
function fieldLabel(key) {
|
|
804
|
+
const spaced = key.replace(/_/g, " ").trim();
|
|
805
|
+
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
|
806
|
+
}
|
|
807
|
+
function recordFallbackName(nounLabel3, id) {
|
|
808
|
+
const short = (0, import_uuid.isUuidShape)(id) ? id.slice(0, 8) : id.length > 12 ? `${id.slice(0, 12)}\u2026` : id;
|
|
809
|
+
return `${nounLabel3} ${short}`;
|
|
810
|
+
}
|
|
811
|
+
function describeValue(value) {
|
|
812
|
+
if (value === null || value === void 0) return { value: "cleared", full: "cleared", clears: true };
|
|
813
|
+
if (typeof value === "string") {
|
|
814
|
+
const trimmed = value.trim();
|
|
815
|
+
if (!trimmed) return { value: "cleared", full: "cleared", clears: true };
|
|
816
|
+
const oneLine = trimmed.replace(/\s+/g, " ");
|
|
817
|
+
const shown = oneLine.length > CHANGE_VALUE_MAX ? `${oneLine.slice(0, CHANGE_VALUE_MAX - 1)}\u2026` : oneLine;
|
|
818
|
+
return { value: shown, full: trimmed, clears: false };
|
|
819
|
+
}
|
|
820
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
821
|
+
return { value: String(value), full: String(value), clears: false };
|
|
822
|
+
}
|
|
823
|
+
if (Array.isArray(value)) {
|
|
824
|
+
const n2 = value.length;
|
|
825
|
+
const text2 = n2 === 0 ? "cleared" : `${n2} ${n2 === 1 ? "entry" : "entries"}`;
|
|
826
|
+
return { value: text2, full: safeJson(value), clears: n2 === 0 };
|
|
827
|
+
}
|
|
828
|
+
const n = Object.keys(value).length;
|
|
829
|
+
const text = n === 0 ? "cleared" : `${n} ${n === 1 ? "field" : "fields"}`;
|
|
830
|
+
return { value: text, full: safeJson(value), clears: n === 0 };
|
|
831
|
+
}
|
|
832
|
+
function safeJson(value) {
|
|
833
|
+
try {
|
|
834
|
+
return JSON.stringify(value, null, 2);
|
|
835
|
+
} catch {
|
|
836
|
+
return String(value);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
function itemChanges(item) {
|
|
840
|
+
const out = [];
|
|
841
|
+
for (const [key, raw] of Object.entries(item)) {
|
|
842
|
+
if (NOT_A_CHANGE.has(key)) continue;
|
|
843
|
+
out.push({ key, label: fieldLabel(key), ...describeValue(raw) });
|
|
844
|
+
}
|
|
845
|
+
return out;
|
|
846
|
+
}
|
|
784
847
|
|
|
785
848
|
// directives/icons.tsx
|
|
786
849
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -898,10 +961,38 @@ function ApplyDirectiveButton({
|
|
|
898
961
|
const items = directive.items;
|
|
899
962
|
async function handleApply() {
|
|
900
963
|
if (!confirm) return;
|
|
964
|
+
if (host.ask) {
|
|
965
|
+
setState({ status: "asking" });
|
|
966
|
+
let ok = false;
|
|
967
|
+
try {
|
|
968
|
+
ok = await host.ask({
|
|
969
|
+
directive,
|
|
970
|
+
items,
|
|
971
|
+
nounLabel: (0, import_content_ir3.nounLabel)(directive.noun, host.nouns)
|
|
972
|
+
});
|
|
973
|
+
} catch (error) {
|
|
974
|
+
setState({
|
|
975
|
+
status: "error",
|
|
976
|
+
message: error instanceof Error && error.message ? error.message : "We could not ask you to confirm this, so nothing was done."
|
|
977
|
+
});
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (!ok) {
|
|
981
|
+
setState({ status: "idle" });
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
setElapsed(0);
|
|
901
986
|
setState({ status: "applying" });
|
|
902
987
|
try {
|
|
903
988
|
const result = await confirm({ __kind: directive.slug, items });
|
|
904
|
-
setState({
|
|
989
|
+
setState({
|
|
990
|
+
status: "applied",
|
|
991
|
+
applied: result.applied,
|
|
992
|
+
failed: result.failed,
|
|
993
|
+
message: result.message?.trim() ? result.message.trim() : null,
|
|
994
|
+
records: result.records ?? []
|
|
995
|
+
});
|
|
905
996
|
onApplied?.();
|
|
906
997
|
} catch (error) {
|
|
907
998
|
setState({
|
|
@@ -912,15 +1003,26 @@ function ApplyDirectiveButton({
|
|
|
912
1003
|
}
|
|
913
1004
|
if (state.status === "applied") {
|
|
914
1005
|
const bad = state.failed > 0;
|
|
1006
|
+
const trashed = directive.directiveClass === "delete";
|
|
1007
|
+
const label2 = (0, import_content_ir3.nounLabel)(directive.noun, host.nouns);
|
|
1008
|
+
const records = host.renderRecord ? state.records : [];
|
|
915
1009
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
916
1010
|
"span",
|
|
917
1011
|
{
|
|
918
|
-
className: `inline-flex items-center gap-1 text-xs ${bad ? "text-destructive" : "text-primary"}`,
|
|
1012
|
+
className: `inline-flex min-w-0 flex-wrap items-center gap-1 text-xs ${bad ? "text-destructive" : "text-primary"}`,
|
|
1013
|
+
"data-apply-state": "applied",
|
|
919
1014
|
children: [
|
|
920
|
-
bad ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AlertIcon, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckCircleIcon, { className: "h-3.5 w-3.5" }),
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1015
|
+
bad ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AlertIcon, { className: "h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckCircleIcon, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
1016
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
1017
|
+
state.message ?? `Applied ${state.applied}`,
|
|
1018
|
+
bad && !state.message ? ` \xB7 ${state.failed} failed` : ""
|
|
1019
|
+
] }),
|
|
1020
|
+
records.map((record) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "inline-flex min-w-0 items-center", children: host.renderRecord?.({
|
|
1021
|
+
...record,
|
|
1022
|
+
fallback: recordFallbackName(label2, record.id),
|
|
1023
|
+
context: "applied",
|
|
1024
|
+
trashed
|
|
1025
|
+
}) }, `${record.noun}:${record.id}`))
|
|
924
1026
|
]
|
|
925
1027
|
}
|
|
926
1028
|
);
|
|
@@ -931,7 +1033,7 @@ function ApplyDirectiveButton({
|
|
|
931
1033
|
{
|
|
932
1034
|
type: "button",
|
|
933
1035
|
onClick: () => void handleApply(),
|
|
934
|
-
disabled: state.status === "applying" || items.length === 0,
|
|
1036
|
+
disabled: state.status === "applying" || state.status === "asking" || items.length === 0,
|
|
935
1037
|
className: "inline-flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-xs font-medium hover:bg-accent disabled:opacity-50",
|
|
936
1038
|
children: [
|
|
937
1039
|
state.status === "applying" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PlayIcon, { className: "h-3.5 w-3.5" }),
|
|
@@ -951,7 +1053,7 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
|
951
1053
|
function DirectiveFallbackCard({ directive, reason }) {
|
|
952
1054
|
const host = useDirectiveHost();
|
|
953
1055
|
const count = directive.items.length;
|
|
954
|
-
const display = (0,
|
|
1056
|
+
const display = (0, import_content_ir4.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
955
1057
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "my-3 inline-flex flex-wrap items-center gap-2 rounded-md border border-border bg-muted px-2.5 py-1 text-sm", children: [
|
|
956
1058
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BoxesIcon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
957
1059
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-foreground", children: display.title }),
|
|
@@ -974,7 +1076,7 @@ function DirectiveFallbackCard({ directive, reason }) {
|
|
|
974
1076
|
}
|
|
975
1077
|
|
|
976
1078
|
// directives/DirectiveProvisionalCard.tsx
|
|
977
|
-
var
|
|
1079
|
+
var import_content_ir5 = require("@ai-matrx/content-ir");
|
|
978
1080
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
979
1081
|
var COMPLETE_SLUG_RE = /^\{\s*"__kind"\s*:\s*"([^"]+)"/;
|
|
980
1082
|
function provisionalDirectiveSlug(content) {
|
|
@@ -984,8 +1086,8 @@ function provisionalDirectiveSlug(content) {
|
|
|
984
1086
|
function DirectiveProvisionalCard({ content, streaming, className }) {
|
|
985
1087
|
const host = useDirectiveHost();
|
|
986
1088
|
const slug = provisionalDirectiveSlug(content);
|
|
987
|
-
const known = slug ? (0,
|
|
988
|
-
const display = known ? (0,
|
|
1089
|
+
const known = slug ? (0, import_content_ir5.parseDirectiveSlug)(slug) : null;
|
|
1090
|
+
const display = known ? (0, import_content_ir5.directiveDisplay)(known.directiveClass, known.noun, host.nouns) : null;
|
|
989
1091
|
const Icon = known ? classIcon(known.directiveClass, known.noun) : BoxesIcon;
|
|
990
1092
|
const title = display?.title ?? "Structured action";
|
|
991
1093
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
@@ -1014,14 +1116,14 @@ function DirectiveProvisionalCard({ content, streaming, className }) {
|
|
|
1014
1116
|
}
|
|
1015
1117
|
|
|
1016
1118
|
// directives/registry.ts
|
|
1017
|
-
var
|
|
1119
|
+
var import_content_ir6 = require("@ai-matrx/content-ir");
|
|
1018
1120
|
var REGISTRY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir-react.directive-renderers");
|
|
1019
1121
|
var registry = globalThis[REGISTRY_SLOT] ??= {
|
|
1020
1122
|
bySlug: /* @__PURE__ */ new Map(),
|
|
1021
1123
|
byClass: /* @__PURE__ */ new Map()
|
|
1022
1124
|
};
|
|
1023
1125
|
function registerDirectiveRenderer(directiveClass, renderer, noun) {
|
|
1024
|
-
if (noun) registry.bySlug.set((0,
|
|
1126
|
+
if (noun) registry.bySlug.set((0, import_content_ir6.buildDirectiveSlug)(directiveClass, noun), renderer);
|
|
1025
1127
|
else registry.byClass.set(directiveClass, renderer);
|
|
1026
1128
|
}
|
|
1027
1129
|
function getDirectiveRenderer(directive) {
|
|
@@ -1034,7 +1136,7 @@ function resetDirectiveRenderers() {
|
|
|
1034
1136
|
|
|
1035
1137
|
// directives/SideEffectDirectiveCard.tsx
|
|
1036
1138
|
var import_react5 = require("react");
|
|
1037
|
-
var
|
|
1139
|
+
var import_content_ir7 = require("@ai-matrx/content-ir");
|
|
1038
1140
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1039
1141
|
var ROWS_BEFORE_FOLD = 3;
|
|
1040
1142
|
function ItemRow({
|
|
@@ -1044,12 +1146,16 @@ function ItemRow({
|
|
|
1044
1146
|
total
|
|
1045
1147
|
}) {
|
|
1046
1148
|
const host = useDirectiveHost();
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1149
|
+
const recordId = TARGETING_CLASSES.has(directive.directiveClass) ? itemRecordId(item) : null;
|
|
1150
|
+
if (recordId) {
|
|
1151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TargetRow, { directive, item, recordId });
|
|
1152
|
+
}
|
|
1153
|
+
const titleColumn = (0, import_content_ir7.nounTitleColumn)(directive.noun, host.nouns);
|
|
1154
|
+
const title = (0, import_content_ir7.itemTitle)(item, titleColumn, index, total);
|
|
1155
|
+
const subtitle = (0, import_content_ir7.itemSubtitle)(item);
|
|
1156
|
+
const facts = (0, import_content_ir7.itemFacts)(item);
|
|
1051
1157
|
const kind = host.itemKind?.(directive.slug) ?? null;
|
|
1052
|
-
const display = (0,
|
|
1158
|
+
const display = (0, import_content_ir7.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
1053
1159
|
const openItem = host.openItem;
|
|
1054
1160
|
const body = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1055
1161
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
|
|
@@ -1068,7 +1174,7 @@ function ItemRow({
|
|
|
1068
1174
|
type: "button",
|
|
1069
1175
|
onClick: () => openItem({
|
|
1070
1176
|
// Stamped so the panel's kind pipeline types it from its own first key.
|
|
1071
|
-
item: (0,
|
|
1177
|
+
item: (0, import_content_ir7.asKindInstance)(item, kind) ?? item,
|
|
1072
1178
|
itemKind: kind,
|
|
1073
1179
|
title,
|
|
1074
1180
|
subtitle: `${display.title} \xB7 item ${index + 1} of ${total}`,
|
|
@@ -1084,12 +1190,47 @@ function ItemRow({
|
|
|
1084
1190
|
host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
|
|
1085
1191
|
] });
|
|
1086
1192
|
}
|
|
1193
|
+
function TargetRow({
|
|
1194
|
+
directive,
|
|
1195
|
+
item,
|
|
1196
|
+
recordId
|
|
1197
|
+
}) {
|
|
1198
|
+
const host = useDirectiveHost();
|
|
1199
|
+
const fallback = recordFallbackName((0, import_content_ir7.nounLabel)(directive.noun, host.nouns), recordId);
|
|
1200
|
+
const changes = directive.directiveClass === "update" ? itemChanges(item) : [];
|
|
1201
|
+
const name = host.renderRecord ? host.renderRecord({ noun: directive.noun, id: recordId, fallback, context: "row" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate font-medium text-foreground", children: fallback });
|
|
1202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "py-1 text-xs", "data-directive-target": recordId, children: [
|
|
1203
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-1 px-1", children: name }),
|
|
1205
|
+
host.renderCopy?.({ label: fallback, value: item, size: "xs" })
|
|
1206
|
+
] }),
|
|
1207
|
+
directive.directiveClass === "update" ? changes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "px-1 text-[11px] text-muted-foreground", children: "Sets no fields \u2014 nothing would change." }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "mt-0.5 space-y-0.5 px-1", children: changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1208
|
+
"li",
|
|
1209
|
+
{
|
|
1210
|
+
className: "flex min-w-0 items-baseline gap-1.5 text-[11px]",
|
|
1211
|
+
title: `${change.label} \u2192 ${change.full}`,
|
|
1212
|
+
children: [
|
|
1213
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "shrink-0 text-muted-foreground", children: change.label }),
|
|
1214
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": true, className: "shrink-0 text-muted-foreground", children: "\u2192" }),
|
|
1215
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1216
|
+
"span",
|
|
1217
|
+
{
|
|
1218
|
+
className: `min-w-0 truncate ${change.clears ? "italic text-muted-foreground" : "text-foreground"}`,
|
|
1219
|
+
children: change.value
|
|
1220
|
+
}
|
|
1221
|
+
)
|
|
1222
|
+
]
|
|
1223
|
+
},
|
|
1224
|
+
change.key
|
|
1225
|
+
)) }) : null
|
|
1226
|
+
] });
|
|
1227
|
+
}
|
|
1087
1228
|
function SideEffectDirectiveCard({ directive }) {
|
|
1088
1229
|
const host = useDirectiveHost();
|
|
1089
1230
|
const [expanded, setExpanded] = (0, import_react5.useState)(false);
|
|
1090
1231
|
const items = directive.items;
|
|
1091
1232
|
const total = items.length;
|
|
1092
|
-
const display = (0,
|
|
1233
|
+
const display = (0, import_content_ir7.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
1093
1234
|
const Icon = classIcon(directive.directiveClass, directive.noun);
|
|
1094
1235
|
const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
|
|
1095
1236
|
const hidden = total - shown.length;
|
|
@@ -1139,13 +1280,13 @@ function isWholeJson(content) {
|
|
|
1139
1280
|
}
|
|
1140
1281
|
function DirectiveRender({ content, className, streaming }) {
|
|
1141
1282
|
const host = useDirectiveHost();
|
|
1142
|
-
const directive = (0,
|
|
1283
|
+
const directive = (0, import_content_ir8.tryDecodeDirectiveContent)(content, (message) => {
|
|
1143
1284
|
const line = `[kind-directives] ${message}`;
|
|
1144
1285
|
if (host.reportError) host.reportError(line);
|
|
1145
1286
|
else console.error(line);
|
|
1146
1287
|
});
|
|
1147
1288
|
if (!directive) {
|
|
1148
|
-
if (typeof content === "string" && (0,
|
|
1289
|
+
if (typeof content === "string" && (0, import_content_ir8.looksLikeDirectiveHead)(content) && !isWholeJson(content)) {
|
|
1149
1290
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DirectiveProvisionalCard, { content, streaming: streaming !== false, className });
|
|
1150
1291
|
}
|
|
1151
1292
|
const raw = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
@@ -1169,14 +1310,14 @@ function isRecordValue(value) {
|
|
|
1169
1310
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1170
1311
|
}
|
|
1171
1312
|
function kindIsRoutable(kind, host) {
|
|
1172
|
-
if ((0,
|
|
1313
|
+
if ((0, import_content_ir9.isReservedDirectiveSlug)(kind)) return true;
|
|
1173
1314
|
if (host.kinds.getDefinition(kind)?.legacyBlockType) return true;
|
|
1174
1315
|
const resolution = host.components.resolve(kind, host.platform, "output");
|
|
1175
1316
|
if (!resolution?.isActive) return false;
|
|
1176
1317
|
return resolution.componentKey !== GENERIC_STRUCTURED_COMPONENT_KEY;
|
|
1177
1318
|
}
|
|
1178
1319
|
function KindInstanceRender(props) {
|
|
1179
|
-
if ((0,
|
|
1320
|
+
if ((0, import_content_ir9.isReservedDirectiveSlug)(props.kind)) {
|
|
1180
1321
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1181
1322
|
DirectiveRender,
|
|
1182
1323
|
{
|
|
@@ -1231,7 +1372,7 @@ function KindInstanceRenderInner({
|
|
|
1231
1372
|
content: JSON.stringify(value, null, 2),
|
|
1232
1373
|
language: "json",
|
|
1233
1374
|
metadata: {
|
|
1234
|
-
[
|
|
1375
|
+
[import_content_ir9.IR_ENVELOPE_KEY]: (0, import_content_ir9.envelopeFromCompleteValue)(value, kind)
|
|
1235
1376
|
}
|
|
1236
1377
|
} : null;
|
|
1237
1378
|
const frameClass = variant === "bare" ? void 0 : "rounded-md border border-border bg-card p-3";
|
|
@@ -1286,12 +1427,12 @@ function ProvisionalKindFrame({ children }) {
|
|
|
1286
1427
|
|
|
1287
1428
|
// react/GenericStructuredView.tsx
|
|
1288
1429
|
var import_react8 = require("react");
|
|
1289
|
-
var
|
|
1430
|
+
var import_content_ir10 = require("@ai-matrx/content-ir");
|
|
1290
1431
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1291
1432
|
function readStructuredValue(content, metadata) {
|
|
1292
|
-
const envelope = (0,
|
|
1433
|
+
const envelope = (0, import_content_ir10.readEnvelope)(metadata);
|
|
1293
1434
|
if (envelope) {
|
|
1294
|
-
return { value: (0,
|
|
1435
|
+
return { value: (0, import_content_ir10.reconstructRegionValue)(envelope), recovered: true };
|
|
1295
1436
|
}
|
|
1296
1437
|
try {
|
|
1297
1438
|
return { value: JSON.parse(content), recovered: true };
|
|
@@ -1306,10 +1447,10 @@ function GenericStructuredView({
|
|
|
1306
1447
|
className
|
|
1307
1448
|
}) {
|
|
1308
1449
|
const host = useContentIrHost();
|
|
1309
|
-
const envelope = (0,
|
|
1450
|
+
const envelope = (0, import_content_ir10.readEnvelope)(metadata);
|
|
1310
1451
|
const status = envelope?.root.status ?? "complete";
|
|
1311
1452
|
const { value, recovered } = readStructuredValue(content, metadata);
|
|
1312
|
-
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0,
|
|
1453
|
+
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir10.readObjectKind)(value) : null) ?? "";
|
|
1313
1454
|
const marker = readIrRouteMarker(metadata);
|
|
1314
1455
|
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";
|
|
1315
1456
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
|
|
@@ -1323,7 +1464,7 @@ function GenericStructuredView({
|
|
|
1323
1464
|
}
|
|
1324
1465
|
|
|
1325
1466
|
// react/RuntimeWrapperViews.tsx
|
|
1326
|
-
var
|
|
1467
|
+
var import_content_ir11 = require("@ai-matrx/content-ir");
|
|
1327
1468
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1328
1469
|
function isRecord2(value) {
|
|
1329
1470
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -1345,7 +1486,7 @@ function DelegatedOutput({
|
|
|
1345
1486
|
if (!isRecord2(output)) {
|
|
1346
1487
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: host.renderValue({ value: output }) });
|
|
1347
1488
|
}
|
|
1348
|
-
const kind = (0,
|
|
1489
|
+
const kind = (0, import_content_ir11.readObjectKind)(output) ?? declaredKind;
|
|
1349
1490
|
if (!kind) {
|
|
1350
1491
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
|
|
1351
1492
|
}
|
|
@@ -1363,7 +1504,7 @@ function DelegatedOutput({
|
|
|
1363
1504
|
function NodeOutcomeView({ serverData, fallback }) {
|
|
1364
1505
|
const wrapper = readWrapperFrom(
|
|
1365
1506
|
serverData,
|
|
1366
|
-
|
|
1507
|
+
import_content_ir11.readNodeOutcomeValue
|
|
1367
1508
|
);
|
|
1368
1509
|
if (!wrapper) return null;
|
|
1369
1510
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -1378,7 +1519,7 @@ function NodeOutcomeView({ serverData, fallback }) {
|
|
|
1378
1519
|
function RunResultView({ serverData, fallback }) {
|
|
1379
1520
|
const wrapper = readWrapperFrom(
|
|
1380
1521
|
serverData,
|
|
1381
|
-
|
|
1522
|
+
import_content_ir11.readRunResultValue
|
|
1382
1523
|
);
|
|
1383
1524
|
if (!wrapper) return null;
|
|
1384
1525
|
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)(
|