@ai-matrx/content-ir-react 0.10.0 → 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 +67 -0
- package/dist/db-component.d.cts +8 -8
- package/dist/db-component.d.ts +8 -8
- package/dist/directive-host-DAb7Keg8.d.cts +63 -0
- package/dist/directive-host-DAb7Keg8.d.ts +63 -0
- package/dist/directives.cjs +382 -0
- package/dist/directives.cjs.map +1 -0
- package/dist/directives.d.cts +70 -0
- package/dist/directives.d.ts +70 -0
- package/dist/directives.js +369 -0
- package/dist/directives.js.map +1 -0
- package/dist/{host-types-CDcLW0TD.d.cts → host-types-C8jR31Wk.d.cts} +9 -0
- package/dist/{host-types-CpItjcYh.d.ts → host-types-IUEDmso7.d.ts} +9 -0
- package/dist/host.cjs +14 -4
- package/dist/host.cjs.map +1 -1
- package/dist/host.d.cts +5 -4
- package/dist/host.d.ts +5 -4
- package/dist/host.js +14 -4
- package/dist/host.js.map +1 -1
- package/dist/index.cjs +474 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -21
- package/dist/index.d.ts +85 -21
- package/dist/index.js +479 -36
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +401 -46
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +11 -10
- package/dist/react.d.ts +11 -10
- package/dist/react.js +404 -33
- package/dist/react.js.map +1 -1
- package/dist/{route-QL2Vqf2e.d.cts → route-B9U-9QCw.d.cts} +117 -3
- package/dist/{route-PUuEuEug.d.ts → route-gNpJ8zzW.d.ts} +117 -3
- package/dist/route.cjs +52 -2
- package/dist/route.cjs.map +1 -1
- package/dist/route.d.cts +1 -1
- package/dist/route.d.ts +1 -1
- package/dist/route.js +55 -2
- package/dist/route.js.map +1 -1
- package/package.json +15 -2
package/dist/index.cjs
CHANGED
|
@@ -30,11 +30,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
ApplyDirectiveButton: () => ApplyDirectiveButton,
|
|
33
34
|
ComponentResolver: () => ComponentResolver,
|
|
34
35
|
ContentIrRenderProvider: () => ContentIrRenderProvider,
|
|
35
36
|
DB_KIND_COMPONENT_KEY: () => DB_KIND_COMPONENT_KEY,
|
|
37
|
+
DIRECTIVE_BLOCK_TYPE: () => DIRECTIVE_BLOCK_TYPE,
|
|
36
38
|
DbKindComponentErrorBoundary: () => DbKindComponentErrorBoundary,
|
|
37
39
|
DelegatedOutput: () => DelegatedOutput,
|
|
40
|
+
DirectiveFallbackCard: () => DirectiveFallbackCard,
|
|
41
|
+
DirectiveHostProvider: () => DirectiveHostProvider,
|
|
42
|
+
DirectiveRender: () => DirectiveRender,
|
|
38
43
|
GENERIC_STRUCTURED_COMPONENT_KEY: () => GENERIC_STRUCTURED_COMPONENT_KEY,
|
|
39
44
|
GenericStructuredView: () => GenericStructuredView,
|
|
40
45
|
IR_PROVISIONAL_KEY: () => IR_PROVISIONAL_KEY,
|
|
@@ -44,11 +49,13 @@ __export(index_exports, {
|
|
|
44
49
|
ProvisionalKindBoundary: () => ProvisionalKindBoundary,
|
|
45
50
|
ProvisionalKindFrame: () => ProvisionalKindFrame,
|
|
46
51
|
RunResultView: () => RunResultView,
|
|
52
|
+
SideEffectDirectiveCard: () => SideEffectDirectiveCard,
|
|
47
53
|
applyIrKindRoute: () => applyIrKindRoute,
|
|
48
54
|
consoleErrorReporter: () => consoleErrorReporter,
|
|
49
55
|
createDbKindComponentCache: () => createDbKindComponentCache,
|
|
50
56
|
createKindRouteBinding: () => createKindRouteBinding,
|
|
51
57
|
envelopeFromPartialKind: () => envelopeFromPartialKind,
|
|
58
|
+
getDirectiveRenderer: () => getDirectiveRenderer,
|
|
52
59
|
isDbKindComponentBodyPending: () => isDbKindComponentBodyPending,
|
|
53
60
|
isPartialReadyKind: () => isPartialReadyKind,
|
|
54
61
|
isProvisionalBlock: () => isProvisionalBlock,
|
|
@@ -57,14 +64,18 @@ __export(index_exports, {
|
|
|
57
64
|
kindServerDataFromStoredValue: () => kindServerDataFromStoredValue,
|
|
58
65
|
markKindPartialUnsafe: () => markKindPartialUnsafe,
|
|
59
66
|
readIrRouteMarker: () => readIrRouteMarker,
|
|
67
|
+
registerDirectiveRenderer: () => registerDirectiveRenderer,
|
|
68
|
+
resetDirectiveRenderers: () => resetDirectiveRenderers,
|
|
60
69
|
resetPartialUnsafeKinds: () => resetPartialUnsafeKinds,
|
|
61
70
|
resetSourcelessDbRowReports: () => resetSourcelessDbRowReports,
|
|
62
71
|
resolveAnnouncedKindLoading: () => resolveAnnouncedKindLoading,
|
|
63
72
|
resolveProvisionalKindRender: () => resolveProvisionalKindRender,
|
|
73
|
+
resolveSupersededKindRender: () => resolveSupersededKindRender,
|
|
64
74
|
routeEnvOf: () => routeEnvOf,
|
|
65
75
|
useContentIrHost: () => useContentIrHost,
|
|
66
76
|
useContentIrHostOrNull: () => useContentIrHostOrNull,
|
|
67
77
|
useContentIrKindVersion: () => useContentIrKindVersion,
|
|
78
|
+
useDirectiveHost: () => useDirectiveHost,
|
|
68
79
|
useKindRouteEnv: () => useKindRouteEnv
|
|
69
80
|
});
|
|
70
81
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -85,17 +96,31 @@ function routeEnvOf(host) {
|
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
// host/ContentIrProvider.tsx
|
|
99
|
+
var import_react2 = require("react");
|
|
100
|
+
|
|
101
|
+
// directives/directive-host.tsx
|
|
88
102
|
var import_react = require("react");
|
|
89
103
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
90
|
-
var
|
|
104
|
+
var DirectiveHostContext = (0, import_react.createContext)(null);
|
|
105
|
+
function DirectiveHostProvider({ host, children }) {
|
|
106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DirectiveHostContext.Provider, { value: host, children });
|
|
107
|
+
}
|
|
108
|
+
var EMPTY_HOST = {};
|
|
109
|
+
function useDirectiveHost() {
|
|
110
|
+
return (0, import_react.useContext)(DirectiveHostContext) ?? EMPTY_HOST;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// host/ContentIrProvider.tsx
|
|
114
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
115
|
+
var ContentIrHostContext = (0, import_react2.createContext)(null);
|
|
91
116
|
function ContentIrRenderProvider({
|
|
92
117
|
host,
|
|
93
118
|
children
|
|
94
119
|
}) {
|
|
95
|
-
return /* @__PURE__ */ (0,
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ContentIrHostContext.Provider, { value: host, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DirectiveHostProvider, { host: host.directives ?? {}, children }) });
|
|
96
121
|
}
|
|
97
122
|
function useContentIrHostOrNull() {
|
|
98
|
-
return (0,
|
|
123
|
+
return (0, import_react2.useContext)(ContentIrHostContext);
|
|
99
124
|
}
|
|
100
125
|
function useContentIrHost() {
|
|
101
126
|
const host = useContentIrHostOrNull();
|
|
@@ -108,7 +133,7 @@ function useContentIrHost() {
|
|
|
108
133
|
}
|
|
109
134
|
function useKindRouteEnv() {
|
|
110
135
|
const host = useContentIrHost();
|
|
111
|
-
return (0,
|
|
136
|
+
return (0, import_react2.useMemo)(() => routeEnvOf(host), [host]);
|
|
112
137
|
}
|
|
113
138
|
|
|
114
139
|
// resolver/component-resolver.ts
|
|
@@ -445,6 +470,7 @@ var import_content_ir = require("@ai-matrx/content-ir");
|
|
|
445
470
|
var IR_ROUTE_KEY = "__ir_route";
|
|
446
471
|
var GENERIC_STRUCTURED_COMPONENT_KEY = "generic_structured";
|
|
447
472
|
var DB_KIND_COMPONENT_KEY = "db_kind_component";
|
|
473
|
+
var DIRECTIVE_BLOCK_TYPE = "matrx";
|
|
448
474
|
function isDbSourceResolution(resolution) {
|
|
449
475
|
return resolution !== null && resolution.resolvedBy === "db" && resolution.source === "db" && resolution.isActive;
|
|
450
476
|
}
|
|
@@ -522,6 +548,18 @@ function applyIrKindRoute(block, env, options) {
|
|
|
522
548
|
const kind = envelope.root.kind;
|
|
523
549
|
if (!kind) return block;
|
|
524
550
|
if (envelope.root.kindState === "pending_schema") return block;
|
|
551
|
+
if ((0, import_content_ir.isReservedDirectiveSlug)(kind)) {
|
|
552
|
+
if (block.type === DIRECTIVE_BLOCK_TYPE) return block;
|
|
553
|
+
return {
|
|
554
|
+
...block,
|
|
555
|
+
type: DIRECTIVE_BLOCK_TYPE,
|
|
556
|
+
serverData: void 0,
|
|
557
|
+
metadata: {
|
|
558
|
+
...block.metadata ?? {},
|
|
559
|
+
[IR_ROUTE_KEY]: { by: "directive", key: DIRECTIVE_BLOCK_TYPE }
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
}
|
|
525
563
|
const def = env.kinds.getDefinition(kind);
|
|
526
564
|
const resolution = env.components.resolve(kind, env.platform, "output");
|
|
527
565
|
const componentsSettled = env.components.hasSettled?.() ?? true;
|
|
@@ -616,6 +654,36 @@ function resolveAnnouncedKindLoading(block, options) {
|
|
|
616
654
|
if (verified && verified.root.status === "complete") return null;
|
|
617
655
|
return { kind, envelope: envelopeFromPartialKind(event) };
|
|
618
656
|
}
|
|
657
|
+
function parseCompletedJsonObject(content) {
|
|
658
|
+
let source = content.trim();
|
|
659
|
+
const fenced = source.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/i);
|
|
660
|
+
if (fenced?.[1]) source = fenced[1].trim();
|
|
661
|
+
try {
|
|
662
|
+
const value = JSON.parse(source);
|
|
663
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
664
|
+
} catch {
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function resolveSupersededKindRender(block, env, options) {
|
|
669
|
+
const event = (0, import_content_ir2.readPartialKindEvent)(block.metadata);
|
|
670
|
+
if (event?.state !== "superseded") return null;
|
|
671
|
+
if ((0, import_content_ir2.readEnvelope)(block.metadata)?.root.status === "complete") return null;
|
|
672
|
+
const value = parseCompletedJsonObject(block.content);
|
|
673
|
+
if (!value || (0, import_content_ir2.readObjectKind)(value) !== event.kind) return null;
|
|
674
|
+
const { [import_content_ir2.IR_PARTIAL_KEY]: _partial, ...rest } = block.metadata ?? {};
|
|
675
|
+
void _partial;
|
|
676
|
+
const envelope = (0, import_content_ir2.envelopeFromCompleteValue)(value, event.kind);
|
|
677
|
+
const terminalBlock = {
|
|
678
|
+
...block,
|
|
679
|
+
// A code/json block's serverData is an annotation, not kind data.
|
|
680
|
+
serverData: void 0,
|
|
681
|
+
metadata: { ...rest, [import_content_ir2.IR_ENVELOPE_KEY]: envelope }
|
|
682
|
+
};
|
|
683
|
+
const routed = applyIrKindRoute(terminalBlock, env, options);
|
|
684
|
+
if (routed === terminalBlock) return null;
|
|
685
|
+
return { block: routed, kind: event.kind, seq: event.seq, envelope };
|
|
686
|
+
}
|
|
619
687
|
function resolveProvisionalKindRender(block, env, options) {
|
|
620
688
|
if (options?.streamActive === false) return null;
|
|
621
689
|
const event = (0, import_content_ir2.readPartialKindEvent)(block.metadata);
|
|
@@ -656,12 +724,17 @@ function createKindRouteBinding(env, options) {
|
|
|
656
724
|
resolveProvisionalKindRender: (block, streamOptions) => resolveProvisionalKindRender(block, env, {
|
|
657
725
|
...streamOptions,
|
|
658
726
|
...ownedTypes ? { ownedTypes } : null
|
|
659
|
-
})
|
|
727
|
+
}),
|
|
728
|
+
resolveSupersededKindRender: (block) => resolveSupersededKindRender(
|
|
729
|
+
block,
|
|
730
|
+
env,
|
|
731
|
+
ownedTypes ? { ownedTypes } : void 0
|
|
732
|
+
)
|
|
660
733
|
};
|
|
661
734
|
}
|
|
662
735
|
|
|
663
736
|
// react/use-kind-version.ts
|
|
664
|
-
var
|
|
737
|
+
var import_react3 = require("react");
|
|
665
738
|
var noopSubscribe = () => () => {
|
|
666
739
|
};
|
|
667
740
|
var zero = () => 0;
|
|
@@ -673,7 +746,7 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
673
746
|
"[content-ir-react] useContentIrKindVersion needs either a ContentIrRenderProvider above it or explicit `sources`."
|
|
674
747
|
);
|
|
675
748
|
}
|
|
676
|
-
const subscribe = (0,
|
|
749
|
+
const subscribe = (0, import_react3.useCallback)(
|
|
677
750
|
(onStoreChange) => {
|
|
678
751
|
if (!kind || !resolved) return noopSubscribe();
|
|
679
752
|
const unsubKinds = resolved.kinds.subscribeKind(kind, onStoreChange);
|
|
@@ -688,7 +761,7 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
688
761
|
},
|
|
689
762
|
[resolved, kind]
|
|
690
763
|
);
|
|
691
|
-
const getSnapshot = (0,
|
|
764
|
+
const getSnapshot = (0, import_react3.useCallback)(
|
|
692
765
|
() => kind && resolved ? (
|
|
693
766
|
// Both counters are monotonic, so the sum is monotonic — a change in
|
|
694
767
|
// either registry produces a new snapshot value for this kind.
|
|
@@ -696,23 +769,377 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
696
769
|
) : 0,
|
|
697
770
|
[resolved, kind]
|
|
698
771
|
);
|
|
699
|
-
return (0,
|
|
772
|
+
return (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, zero);
|
|
700
773
|
}
|
|
701
774
|
|
|
702
775
|
// react/KindInstanceRender.tsx
|
|
703
|
-
var
|
|
776
|
+
var import_react6 = require("react");
|
|
777
|
+
var import_content_ir7 = require("@ai-matrx/content-ir");
|
|
778
|
+
|
|
779
|
+
// directives/DirectiveRender.tsx
|
|
780
|
+
var import_content_ir6 = require("@ai-matrx/content-ir");
|
|
781
|
+
|
|
782
|
+
// directives/DirectiveFallbackCard.tsx
|
|
704
783
|
var import_content_ir3 = require("@ai-matrx/content-ir");
|
|
705
|
-
|
|
784
|
+
|
|
785
|
+
// directives/ApplyDirectiveButton.tsx
|
|
786
|
+
var import_react4 = require("react");
|
|
787
|
+
|
|
788
|
+
// directives/icons.tsx
|
|
789
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
790
|
+
function Svg({ children, ...props }) {
|
|
791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
792
|
+
"svg",
|
|
793
|
+
{
|
|
794
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
795
|
+
viewBox: "0 0 24 24",
|
|
796
|
+
fill: "none",
|
|
797
|
+
stroke: "currentColor",
|
|
798
|
+
strokeWidth: 2,
|
|
799
|
+
strokeLinecap: "round",
|
|
800
|
+
strokeLinejoin: "round",
|
|
801
|
+
"aria-hidden": "true",
|
|
802
|
+
...props,
|
|
803
|
+
children
|
|
804
|
+
}
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
var FilePlusIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4" }),
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
|
|
810
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 15h6" }),
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M6 12v6" })
|
|
812
|
+
] });
|
|
813
|
+
var PencilIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
814
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 20h9" }),
|
|
815
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z" })
|
|
816
|
+
] });
|
|
817
|
+
var TrashIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
818
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 6h18" }),
|
|
819
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" }),
|
|
820
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" }),
|
|
821
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "10", x2: "10", y1: "11", y2: "17" }),
|
|
822
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "14", x2: "14", y1: "11", y2: "17" })
|
|
823
|
+
] });
|
|
824
|
+
var PlayIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polygon", { points: "6 3 20 12 6 21 6 3" }) });
|
|
825
|
+
var WebhookIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
826
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2" }),
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m6 17 3.13-5.78c.53-.97.1-2.01-.4-2.96A4 4 0 0 1 14 5.5c.63.42 1.13 1 1.44 1.66" }),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8" })
|
|
829
|
+
] });
|
|
830
|
+
var BoxesIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
831
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z" }),
|
|
832
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m7 16.5-4.74-2.85" }),
|
|
833
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m7 16.5 5-3" }),
|
|
834
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M7 16.5v5.17" }),
|
|
835
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z" }),
|
|
836
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m17 16.5-5-3" }),
|
|
837
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m17 16.5 4.74-2.85" }),
|
|
838
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M17 16.5v5.17" }),
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z" }),
|
|
840
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 8 7.26 5.15" }),
|
|
841
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m12 8 4.74-2.85" }),
|
|
842
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 13.5V8" })
|
|
843
|
+
] });
|
|
844
|
+
var ChevronDownIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m6 9 6 6 6-6" }) });
|
|
845
|
+
var ChevronRightIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m9 18 6-6-6-6" }) });
|
|
846
|
+
var MaximizeIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
847
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "15 3 21 3 21 9" }),
|
|
848
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "9 21 3 21 3 15" }),
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "21", x2: "14", y1: "3", y2: "10" }),
|
|
850
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "3", x2: "10", y1: "21", y2: "14" })
|
|
851
|
+
] });
|
|
852
|
+
var LoaderIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
|
|
853
|
+
var CheckCircleIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
854
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
855
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m9 12 2 2 4-4" })
|
|
856
|
+
] });
|
|
857
|
+
var AlertIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
|
|
858
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }),
|
|
859
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 9v4" }),
|
|
860
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 17h.01" })
|
|
861
|
+
] });
|
|
862
|
+
var AGENT_NOUNS = /* @__PURE__ */ new Set(["create_agent", "create_agent_definition", "agent"]);
|
|
863
|
+
function classIcon(directiveClass, noun) {
|
|
864
|
+
if (directiveClass === "action" && AGENT_NOUNS.has(noun)) return WebhookIcon;
|
|
865
|
+
switch (directiveClass) {
|
|
866
|
+
case "create":
|
|
867
|
+
return FilePlusIcon;
|
|
868
|
+
case "update":
|
|
869
|
+
return PencilIcon;
|
|
870
|
+
case "delete":
|
|
871
|
+
return TrashIcon;
|
|
872
|
+
default:
|
|
873
|
+
return PlayIcon;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// directives/ApplyDirectiveButton.tsx
|
|
878
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
879
|
+
function ApplyDirectiveButton({
|
|
880
|
+
directive,
|
|
881
|
+
label = "Apply",
|
|
882
|
+
itemCount,
|
|
883
|
+
onApplied
|
|
884
|
+
}) {
|
|
885
|
+
const host = useDirectiveHost();
|
|
886
|
+
const [state, setState] = (0, import_react4.useState)({ status: "idle" });
|
|
887
|
+
const [elapsed, setElapsed] = (0, import_react4.useState)(0);
|
|
888
|
+
const startedAt = (0, import_react4.useRef)(null);
|
|
889
|
+
(0, import_react4.useEffect)(() => {
|
|
890
|
+
if (state.status !== "applying") return;
|
|
891
|
+
startedAt.current = Date.now();
|
|
892
|
+
const id = setInterval(
|
|
893
|
+
() => setElapsed(Math.round((Date.now() - (startedAt.current ?? 0)) / 1e3)),
|
|
894
|
+
1e3
|
|
895
|
+
);
|
|
896
|
+
return () => clearInterval(id);
|
|
897
|
+
}, [state.status]);
|
|
898
|
+
if (!directive.parsed.executes) return null;
|
|
899
|
+
const confirm = host.confirm;
|
|
900
|
+
if (!confirm) return null;
|
|
901
|
+
const items = directive.items;
|
|
902
|
+
async function handleApply() {
|
|
903
|
+
if (!confirm) return;
|
|
904
|
+
setState({ status: "applying" });
|
|
905
|
+
try {
|
|
906
|
+
const result = await confirm({ __kind: directive.slug, items });
|
|
907
|
+
setState({ status: "applied", applied: result.applied, failed: result.failed });
|
|
908
|
+
onApplied?.();
|
|
909
|
+
} catch (error) {
|
|
910
|
+
setState({
|
|
911
|
+
status: "error",
|
|
912
|
+
message: error instanceof Error && error.message ? error.message : "That couldn't be applied just now. Please try again."
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
if (state.status === "applied") {
|
|
917
|
+
const bad = state.failed > 0;
|
|
918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
919
|
+
"span",
|
|
920
|
+
{
|
|
921
|
+
className: `inline-flex items-center gap-1 text-xs ${bad ? "text-destructive" : "text-primary"}`,
|
|
922
|
+
children: [
|
|
923
|
+
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" }),
|
|
924
|
+
"Applied ",
|
|
925
|
+
state.applied,
|
|
926
|
+
bad ? ` \xB7 ${state.failed} failed` : ""
|
|
927
|
+
]
|
|
928
|
+
}
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "inline-flex items-center gap-2", children: [
|
|
932
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
933
|
+
"button",
|
|
934
|
+
{
|
|
935
|
+
type: "button",
|
|
936
|
+
onClick: () => void handleApply(),
|
|
937
|
+
disabled: state.status === "applying" || items.length === 0,
|
|
938
|
+
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",
|
|
939
|
+
children: [
|
|
940
|
+
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" }),
|
|
941
|
+
state.status === "applying" ? `Applying${itemCount ? ` ${itemCount} ${itemCount === 1 ? "item" : "items"}` : ""}\u2026${elapsed ? ` ${elapsed}s` : ""}` : label
|
|
942
|
+
]
|
|
943
|
+
}
|
|
944
|
+
),
|
|
945
|
+
state.status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "inline-flex max-w-sm items-start gap-1 text-xs text-destructive", children: [
|
|
946
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
947
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: state.message })
|
|
948
|
+
] }) : null
|
|
949
|
+
] });
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// directives/DirectiveFallbackCard.tsx
|
|
953
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
954
|
+
function DirectiveFallbackCard({ directive, reason }) {
|
|
955
|
+
const host = useDirectiveHost();
|
|
956
|
+
const count = directive.items.length;
|
|
957
|
+
const display = (0, import_content_ir3.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
958
|
+
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: [
|
|
959
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BoxesIcon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
960
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-foreground", children: display.title }),
|
|
961
|
+
display.family ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
962
|
+
"\xB7 ",
|
|
963
|
+
display.family
|
|
964
|
+
] }) : null,
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
966
|
+
"\xB7 ",
|
|
967
|
+
count,
|
|
968
|
+
" ",
|
|
969
|
+
count === 1 ? "item" : "items"
|
|
970
|
+
] }),
|
|
971
|
+
reason ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
972
|
+
"\xB7 ",
|
|
973
|
+
reason
|
|
974
|
+
] }) : null,
|
|
975
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ApplyDirectiveButton, { directive })
|
|
976
|
+
] });
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// directives/registry.ts
|
|
980
|
+
var import_content_ir4 = require("@ai-matrx/content-ir");
|
|
981
|
+
var REGISTRY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir-react.directive-renderers");
|
|
982
|
+
var registry = globalThis[REGISTRY_SLOT] ??= {
|
|
983
|
+
bySlug: /* @__PURE__ */ new Map(),
|
|
984
|
+
byClass: /* @__PURE__ */ new Map()
|
|
985
|
+
};
|
|
986
|
+
function registerDirectiveRenderer(directiveClass, renderer, noun) {
|
|
987
|
+
if (noun) registry.bySlug.set((0, import_content_ir4.buildDirectiveSlug)(directiveClass, noun), renderer);
|
|
988
|
+
else registry.byClass.set(directiveClass, renderer);
|
|
989
|
+
}
|
|
990
|
+
function getDirectiveRenderer(directive) {
|
|
991
|
+
return registry.bySlug.get(directive.slug) ?? registry.byClass.get(directive.directiveClass) ?? null;
|
|
992
|
+
}
|
|
993
|
+
function resetDirectiveRenderers() {
|
|
994
|
+
registry.bySlug.clear();
|
|
995
|
+
registry.byClass.clear();
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// directives/SideEffectDirectiveCard.tsx
|
|
999
|
+
var import_react5 = require("react");
|
|
1000
|
+
var import_content_ir5 = require("@ai-matrx/content-ir");
|
|
1001
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1002
|
+
var ROWS_BEFORE_FOLD = 3;
|
|
1003
|
+
function ItemRow({
|
|
1004
|
+
directive,
|
|
1005
|
+
item,
|
|
1006
|
+
index,
|
|
1007
|
+
total
|
|
1008
|
+
}) {
|
|
1009
|
+
const host = useDirectiveHost();
|
|
1010
|
+
const titleColumn = (0, import_content_ir5.nounTitleColumn)(directive.noun, host.nouns);
|
|
1011
|
+
const title = (0, import_content_ir5.itemTitle)(item, titleColumn, index, total);
|
|
1012
|
+
const subtitle = (0, import_content_ir5.itemSubtitle)(item);
|
|
1013
|
+
const facts = (0, import_content_ir5.itemFacts)(item);
|
|
1014
|
+
const kind = host.itemKind?.(directive.slug) ?? null;
|
|
1015
|
+
const display = (0, import_content_ir5.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
1016
|
+
const openItem = host.openItem;
|
|
1017
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
|
|
1019
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.jsxs)("span", { className: "truncate text-[11px] text-muted-foreground", children: [
|
|
1020
|
+
fact.value,
|
|
1021
|
+
" ",
|
|
1022
|
+
fact.label
|
|
1023
|
+
] }, fact.key)) }),
|
|
1024
|
+
subtitle && facts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hidden truncate text-[11px] text-muted-foreground sm:inline", children: subtitle }) : null,
|
|
1025
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MaximizeIcon, { className: "ml-auto h-3 w-3 shrink-0 text-muted-foreground" }) : null
|
|
1026
|
+
] });
|
|
1027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2 py-1 text-xs", children: [
|
|
1028
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1029
|
+
"button",
|
|
1030
|
+
{
|
|
1031
|
+
type: "button",
|
|
1032
|
+
onClick: () => openItem({
|
|
1033
|
+
// Stamped so the panel's kind pipeline types it from its own first key.
|
|
1034
|
+
item: (0, import_content_ir5.asKindInstance)(item, kind) ?? item,
|
|
1035
|
+
itemKind: kind,
|
|
1036
|
+
title,
|
|
1037
|
+
subtitle: `${display.title} \xB7 item ${index + 1} of ${total}`,
|
|
1038
|
+
directive,
|
|
1039
|
+
index,
|
|
1040
|
+
total
|
|
1041
|
+
}),
|
|
1042
|
+
className: "flex min-w-0 flex-1 items-center gap-2 rounded px-1 py-0.5 text-left hover:bg-accent hover:text-accent-foreground",
|
|
1043
|
+
title: "Open to read it",
|
|
1044
|
+
children: body
|
|
1045
|
+
}
|
|
1046
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-2 px-1 py-0.5", children: body }),
|
|
1047
|
+
host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
|
|
1048
|
+
] });
|
|
1049
|
+
}
|
|
1050
|
+
function SideEffectDirectiveCard({ directive }) {
|
|
1051
|
+
const host = useDirectiveHost();
|
|
1052
|
+
const [expanded, setExpanded] = (0, import_react5.useState)(false);
|
|
1053
|
+
const items = directive.items;
|
|
1054
|
+
const total = items.length;
|
|
1055
|
+
const display = (0, import_content_ir5.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
1056
|
+
const Icon = classIcon(directive.directiveClass, directive.noun);
|
|
1057
|
+
const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
|
|
1058
|
+
const hidden = total - shown.length;
|
|
1059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "my-3 rounded-md border border-border bg-card px-2.5 py-1.5", "data-directive": directive.slug, children: [
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
1062
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-sm font-medium text-foreground", children: display.title }),
|
|
1063
|
+
display.family ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-xs text-muted-foreground", children: display.family }) : null,
|
|
1064
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "text-xs tabular-nums text-muted-foreground", children: [
|
|
1065
|
+
total,
|
|
1066
|
+
" ",
|
|
1067
|
+
total === 1 ? "item" : "items"
|
|
1068
|
+
] }),
|
|
1069
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ml-auto flex items-center gap-1", children: [
|
|
1070
|
+
host.renderCopy?.({ label: display.title, value: directive.shell, size: "icon" }),
|
|
1071
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ApplyDirectiveButton, { directive, itemCount: total })
|
|
1072
|
+
] })
|
|
1073
|
+
] }),
|
|
1074
|
+
total === 0 ? (
|
|
1075
|
+
// Stated, never silent: an empty batch is a real (and suspicious) state.
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mt-1 text-xs text-muted-foreground", children: "No items \u2014 nothing would be written." })
|
|
1077
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ItemRow, { directive, item, index: i, total }, i)) }),
|
|
1078
|
+
hidden > 0 || expanded ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1079
|
+
"button",
|
|
1080
|
+
{
|
|
1081
|
+
type: "button",
|
|
1082
|
+
onClick: () => setExpanded((v) => !v),
|
|
1083
|
+
className: "mt-0.5 inline-flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",
|
|
1084
|
+
children: [
|
|
1085
|
+
expanded ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronRightIcon, { className: "h-3 w-3" }),
|
|
1086
|
+
expanded ? "Show less" : `Show ${hidden} more`
|
|
1087
|
+
]
|
|
1088
|
+
}
|
|
1089
|
+
) : null
|
|
1090
|
+
] });
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// directives/DirectiveRender.tsx
|
|
1094
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1095
|
+
function DirectiveRender({ content, className }) {
|
|
1096
|
+
const host = useDirectiveHost();
|
|
1097
|
+
const directive = (0, import_content_ir6.tryDecodeDirectiveContent)(content, (message) => {
|
|
1098
|
+
const line = `[kind-directives] ${message}`;
|
|
1099
|
+
if (host.reportError) host.reportError(line);
|
|
1100
|
+
else console.error(line);
|
|
1101
|
+
});
|
|
1102
|
+
if (!directive) {
|
|
1103
|
+
const raw = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
1104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1105
|
+
"pre",
|
|
1106
|
+
{
|
|
1107
|
+
className: `my-3 overflow-x-auto rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground${className ? ` ${className}` : ""}`,
|
|
1108
|
+
children: raw
|
|
1109
|
+
}
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
const Renderer = getDirectiveRenderer(directive);
|
|
1113
|
+
if (Renderer) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Renderer, { directive });
|
|
1114
|
+
if (directive.parsed.executes) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SideEffectDirectiveCard, { directive });
|
|
1115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DirectiveFallbackCard, { directive });
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// react/KindInstanceRender.tsx
|
|
1119
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
706
1120
|
function isRecordValue(value) {
|
|
707
1121
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
708
1122
|
}
|
|
709
1123
|
function kindIsRoutable(kind, host) {
|
|
1124
|
+
if ((0, import_content_ir7.isReservedDirectiveSlug)(kind)) return true;
|
|
710
1125
|
if (host.kinds.getDefinition(kind)?.legacyBlockType) return true;
|
|
711
1126
|
const resolution = host.components.resolve(kind, host.platform, "output");
|
|
712
1127
|
if (!resolution?.isActive) return false;
|
|
713
1128
|
return resolution.componentKey !== GENERIC_STRUCTURED_COMPONENT_KEY;
|
|
714
1129
|
}
|
|
715
|
-
function KindInstanceRender({
|
|
1130
|
+
function KindInstanceRender(props) {
|
|
1131
|
+
if ((0, import_content_ir7.isReservedDirectiveSlug)(props.kind)) {
|
|
1132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1133
|
+
DirectiveRender,
|
|
1134
|
+
{
|
|
1135
|
+
content: props.value,
|
|
1136
|
+
...props.className === void 0 ? {} : { className: props.className }
|
|
1137
|
+
}
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(KindInstanceRenderInner, { ...props });
|
|
1141
|
+
}
|
|
1142
|
+
function KindInstanceRenderInner({
|
|
716
1143
|
kind,
|
|
717
1144
|
value,
|
|
718
1145
|
showRoutingNote = true,
|
|
@@ -721,10 +1148,10 @@ function KindInstanceRender({
|
|
|
721
1148
|
className
|
|
722
1149
|
}) {
|
|
723
1150
|
const host = useContentIrHost();
|
|
724
|
-
const [routingStatus, setRoutingStatus] = (0,
|
|
1151
|
+
const [routingStatus, setRoutingStatus] = (0, import_react6.useState)(
|
|
725
1152
|
() => kindIsRoutable(kind, host) ? "routable" : "checking"
|
|
726
1153
|
);
|
|
727
|
-
(0,
|
|
1154
|
+
(0, import_react6.useEffect)(() => {
|
|
728
1155
|
let cancelled = false;
|
|
729
1156
|
let warmed = false;
|
|
730
1157
|
const syncRoutingStatus = () => {
|
|
@@ -756,25 +1183,25 @@ function KindInstanceRender({
|
|
|
756
1183
|
content: JSON.stringify(value, null, 2),
|
|
757
1184
|
language: "json",
|
|
758
1185
|
metadata: {
|
|
759
|
-
[
|
|
1186
|
+
[import_content_ir7.IR_ENVELOPE_KEY]: (0, import_content_ir7.envelopeFromCompleteValue)(value, kind)
|
|
760
1187
|
}
|
|
761
1188
|
} : null;
|
|
762
1189
|
const frameClass = variant === "bare" ? void 0 : "rounded-md border border-border bg-card p-3";
|
|
763
1190
|
if (routingStatus === "unroutable" && unroutableFallback !== void 0) {
|
|
764
|
-
return /* @__PURE__ */ (0,
|
|
1191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: unroutableFallback });
|
|
765
1192
|
}
|
|
766
1193
|
const onTheFloor = block === null || routingStatus === "unroutable";
|
|
767
1194
|
const notice = "This shape has no custom component yet, so it renders through the universal viewer \u2014 exactly what production shows today.";
|
|
768
|
-
return /* @__PURE__ */ (0,
|
|
769
|
-
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0,
|
|
770
|
-
/* @__PURE__ */ (0,
|
|
1195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: className ? `space-y-3 ${className}` : "space-y-3", children: [
|
|
1196
|
+
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0, import_jsx_runtime8.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,
|
|
1197
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: frameClass, children: onTheFloor ? host.renderValue({ value, kind }) : host.renderBlock(block) })
|
|
771
1198
|
] });
|
|
772
1199
|
}
|
|
773
1200
|
|
|
774
1201
|
// react/ProvisionalKindBoundary.tsx
|
|
775
|
-
var
|
|
776
|
-
var
|
|
777
|
-
var ProvisionalKindBoundaryInner = class extends
|
|
1202
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
1203
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1204
|
+
var ProvisionalKindBoundaryInner = class extends import_react7.default.Component {
|
|
778
1205
|
state = { failed: false };
|
|
779
1206
|
static getDerivedStateFromError() {
|
|
780
1207
|
return { failed: true };
|
|
@@ -798,25 +1225,25 @@ var ProvisionalKindBoundaryInner = class extends import_react4.default.Component
|
|
|
798
1225
|
};
|
|
799
1226
|
function ProvisionalKindBoundary(props) {
|
|
800
1227
|
const host = useContentIrHost();
|
|
801
|
-
return /* @__PURE__ */ (0,
|
|
1228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProvisionalKindBoundaryInner, { ...props, reportError: host.reportError });
|
|
802
1229
|
}
|
|
803
1230
|
function ProvisionalKindFrame({ children }) {
|
|
804
1231
|
const host = useContentIrHost();
|
|
805
1232
|
const label = "Still arriving";
|
|
806
|
-
return /* @__PURE__ */ (0,
|
|
1233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "relative", "aria-busy": "true", children: [
|
|
807
1234
|
children,
|
|
808
|
-
/* @__PURE__ */ (0,
|
|
1235
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.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_runtime9.jsx)("span", { className: "text-[10px] text-muted-foreground", children: label }) })
|
|
809
1236
|
] });
|
|
810
1237
|
}
|
|
811
1238
|
|
|
812
1239
|
// react/GenericStructuredView.tsx
|
|
813
|
-
var
|
|
814
|
-
var
|
|
815
|
-
var
|
|
1240
|
+
var import_react8 = require("react");
|
|
1241
|
+
var import_content_ir8 = require("@ai-matrx/content-ir");
|
|
1242
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
816
1243
|
function readStructuredValue(content, metadata) {
|
|
817
|
-
const envelope = (0,
|
|
1244
|
+
const envelope = (0, import_content_ir8.readEnvelope)(metadata);
|
|
818
1245
|
if (envelope) {
|
|
819
|
-
return { value: (0,
|
|
1246
|
+
return { value: (0, import_content_ir8.reconstructRegionValue)(envelope), recovered: true };
|
|
820
1247
|
}
|
|
821
1248
|
try {
|
|
822
1249
|
return { value: JSON.parse(content), recovered: true };
|
|
@@ -831,25 +1258,25 @@ function GenericStructuredView({
|
|
|
831
1258
|
className
|
|
832
1259
|
}) {
|
|
833
1260
|
const host = useContentIrHost();
|
|
834
|
-
const envelope = (0,
|
|
1261
|
+
const envelope = (0, import_content_ir8.readEnvelope)(metadata);
|
|
835
1262
|
const status = envelope?.root.status ?? "complete";
|
|
836
1263
|
const { value, recovered } = readStructuredValue(content, metadata);
|
|
837
|
-
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0,
|
|
1264
|
+
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir8.readObjectKind)(value) : null) ?? "";
|
|
838
1265
|
const marker = readIrRouteMarker(metadata);
|
|
839
1266
|
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";
|
|
840
|
-
return /* @__PURE__ */ (0,
|
|
841
|
-
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0,
|
|
1267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
|
|
1268
|
+
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mb-2 text-xs text-muted-foreground", children: "Still arriving\u2026" }) : null,
|
|
842
1269
|
recovered ? host.renderValue({ value, ...kind ? { kind } : {}, note }) : (
|
|
843
1270
|
// Zero-data-loss backstop: the region never parsed, so show the source
|
|
844
1271
|
// verbatim rather than swallowing it.
|
|
845
|
-
/* @__PURE__ */ (0,
|
|
1272
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("pre", { className: "max-h-96 overflow-auto font-mono text-xs leading-relaxed text-muted-foreground", children: content })
|
|
846
1273
|
)
|
|
847
1274
|
] });
|
|
848
1275
|
}
|
|
849
1276
|
|
|
850
1277
|
// react/RuntimeWrapperViews.tsx
|
|
851
|
-
var
|
|
852
|
-
var
|
|
1278
|
+
var import_content_ir9 = require("@ai-matrx/content-ir");
|
|
1279
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
853
1280
|
function isRecord2(value) {
|
|
854
1281
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
855
1282
|
}
|
|
@@ -865,16 +1292,16 @@ function DelegatedOutput({
|
|
|
865
1292
|
}) {
|
|
866
1293
|
const host = useContentIrHost();
|
|
867
1294
|
if (output === null || output === void 0) {
|
|
868
|
-
return /* @__PURE__ */ (0,
|
|
1295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyLabel });
|
|
869
1296
|
}
|
|
870
1297
|
if (!isRecord2(output)) {
|
|
871
|
-
return /* @__PURE__ */ (0,
|
|
1298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: host.renderValue({ value: output }) });
|
|
872
1299
|
}
|
|
873
|
-
const kind = (0,
|
|
1300
|
+
const kind = (0, import_content_ir9.readObjectKind)(output) ?? declaredKind;
|
|
874
1301
|
if (!kind) {
|
|
875
|
-
return /* @__PURE__ */ (0,
|
|
1302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
|
|
876
1303
|
}
|
|
877
|
-
return /* @__PURE__ */ (0,
|
|
1304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
878
1305
|
KindInstanceRender,
|
|
879
1306
|
{
|
|
880
1307
|
kind,
|
|
@@ -888,10 +1315,10 @@ function DelegatedOutput({
|
|
|
888
1315
|
function NodeOutcomeView({ serverData, fallback }) {
|
|
889
1316
|
const wrapper = readWrapperFrom(
|
|
890
1317
|
serverData,
|
|
891
|
-
|
|
1318
|
+
import_content_ir9.readNodeOutcomeValue
|
|
892
1319
|
);
|
|
893
1320
|
if (!wrapper) return null;
|
|
894
|
-
return /* @__PURE__ */ (0,
|
|
1321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
895
1322
|
DelegatedOutput,
|
|
896
1323
|
{
|
|
897
1324
|
output: wrapper.output,
|
|
@@ -903,17 +1330,17 @@ function NodeOutcomeView({ serverData, fallback }) {
|
|
|
903
1330
|
function RunResultView({ serverData, fallback }) {
|
|
904
1331
|
const wrapper = readWrapperFrom(
|
|
905
1332
|
serverData,
|
|
906
|
-
|
|
1333
|
+
import_content_ir9.readRunResultValue
|
|
907
1334
|
);
|
|
908
1335
|
if (!wrapper) return null;
|
|
909
|
-
return /* @__PURE__ */ (0,
|
|
1336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "space-y-2", children: wrapper.outputs.length > 0 ? wrapper.outputs.map((outcome) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
910
1337
|
NodeOutcomeView,
|
|
911
1338
|
{
|
|
912
1339
|
serverData: { wrapper: outcome },
|
|
913
1340
|
...fallback === void 0 ? {} : { fallback }
|
|
914
1341
|
},
|
|
915
1342
|
`${outcome.node_id}:${outcome.attempt}`
|
|
916
|
-
)) : /* @__PURE__ */ (0,
|
|
1343
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
917
1344
|
DelegatedOutput,
|
|
918
1345
|
{
|
|
919
1346
|
output: wrapper.output,
|