@ai-matrx/content-ir-react 0.9.3 → 0.11.0

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/db-component.d.cts +8 -8
  3. package/dist/db-component.d.ts +8 -8
  4. package/dist/directive-host-DAb7Keg8.d.cts +63 -0
  5. package/dist/directive-host-DAb7Keg8.d.ts +63 -0
  6. package/dist/directives.cjs +382 -0
  7. package/dist/directives.cjs.map +1 -0
  8. package/dist/directives.d.cts +70 -0
  9. package/dist/directives.d.ts +70 -0
  10. package/dist/directives.js +369 -0
  11. package/dist/directives.js.map +1 -0
  12. package/dist/{host-types-CDcLW0TD.d.cts → host-types-C8jR31Wk.d.cts} +9 -0
  13. package/dist/{host-types-CpItjcYh.d.ts → host-types-IUEDmso7.d.ts} +9 -0
  14. package/dist/host.cjs +14 -4
  15. package/dist/host.cjs.map +1 -1
  16. package/dist/host.d.cts +5 -4
  17. package/dist/host.d.ts +5 -4
  18. package/dist/host.js +14 -4
  19. package/dist/host.js.map +1 -1
  20. package/dist/index.cjs +456 -47
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +85 -21
  23. package/dist/index.d.ts +85 -21
  24. package/dist/index.js +454 -31
  25. package/dist/index.js.map +1 -1
  26. package/dist/react.cjs +401 -46
  27. package/dist/react.cjs.map +1 -1
  28. package/dist/react.d.cts +11 -10
  29. package/dist/react.d.ts +11 -10
  30. package/dist/react.js +398 -29
  31. package/dist/react.js.map +1 -1
  32. package/dist/resolver.cjs +19 -1
  33. package/dist/resolver.cjs.map +1 -1
  34. package/dist/resolver.d.cts +3 -0
  35. package/dist/resolver.d.ts +3 -0
  36. package/dist/resolver.js +19 -1
  37. package/dist/resolver.js.map +1 -1
  38. package/dist/{route-QL2Vqf2e.d.cts → route-Bu85A41G.d.cts} +83 -3
  39. package/dist/{route-PUuEuEug.d.ts → route-DoFoDKBn.d.ts} +83 -3
  40. package/dist/route.cjs +14 -0
  41. package/dist/route.cjs.map +1 -1
  42. package/dist/route.d.cts +1 -1
  43. package/dist/route.d.ts +1 -1
  44. package/dist/route.js +15 -0
  45. package/dist/route.js.map +1 -1
  46. 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,6 +64,8 @@ __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,
@@ -65,6 +74,7 @@ __export(index_exports, {
65
74
  useContentIrHost: () => useContentIrHost,
66
75
  useContentIrHostOrNull: () => useContentIrHostOrNull,
67
76
  useContentIrKindVersion: () => useContentIrKindVersion,
77
+ useDirectiveHost: () => useDirectiveHost,
68
78
  useKindRouteEnv: () => useKindRouteEnv
69
79
  });
70
80
  module.exports = __toCommonJS(index_exports);
@@ -85,17 +95,31 @@ function routeEnvOf(host) {
85
95
  }
86
96
 
87
97
  // host/ContentIrProvider.tsx
98
+ var import_react2 = require("react");
99
+
100
+ // directives/directive-host.tsx
88
101
  var import_react = require("react");
89
102
  var import_jsx_runtime = require("react/jsx-runtime");
90
- var ContentIrHostContext = (0, import_react.createContext)(null);
103
+ var DirectiveHostContext = (0, import_react.createContext)(null);
104
+ function DirectiveHostProvider({ host, children }) {
105
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DirectiveHostContext.Provider, { value: host, children });
106
+ }
107
+ var EMPTY_HOST = {};
108
+ function useDirectiveHost() {
109
+ return (0, import_react.useContext)(DirectiveHostContext) ?? EMPTY_HOST;
110
+ }
111
+
112
+ // host/ContentIrProvider.tsx
113
+ var import_jsx_runtime2 = require("react/jsx-runtime");
114
+ var ContentIrHostContext = (0, import_react2.createContext)(null);
91
115
  function ContentIrRenderProvider({
92
116
  host,
93
117
  children
94
118
  }) {
95
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentIrHostContext.Provider, { value: host, children });
119
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ContentIrHostContext.Provider, { value: host, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DirectiveHostProvider, { host: host.directives ?? {}, children }) });
96
120
  }
97
121
  function useContentIrHostOrNull() {
98
- return (0, import_react.useContext)(ContentIrHostContext);
122
+ return (0, import_react2.useContext)(ContentIrHostContext);
99
123
  }
100
124
  function useContentIrHost() {
101
125
  const host = useContentIrHostOrNull();
@@ -108,7 +132,7 @@ function useContentIrHost() {
108
132
  }
109
133
  function useKindRouteEnv() {
110
134
  const host = useContentIrHost();
111
- return (0, import_react.useMemo)(() => routeEnvOf(host), [host]);
135
+ return (0, import_react2.useMemo)(() => routeEnvOf(host), [host]);
112
136
  }
113
137
 
114
138
  // resolver/component-resolver.ts
@@ -126,11 +150,15 @@ function errorFields(error) {
126
150
  ...error.stack === void 0 ? {} : { stack: error.stack }
127
151
  };
128
152
  }
153
+ var WARM_RETRY_DELAYS_MS = [1e3, 5e3, 15e3];
129
154
  var ComponentResolver = class {
130
155
  compiled = null;
131
156
  db = /* @__PURE__ */ new Map();
132
157
  warmPromise = null;
133
158
  warmFailureLogged = false;
159
+ /** Consecutive warm-load failures — indexes WARM_RETRY_DELAYS_MS. */
160
+ warmFailures = 0;
161
+ warmRetryTimer = null;
134
162
  /**
135
163
  * True once a list load has RUN TO COMPLETION (success or failure), or once
136
164
  * any rows have been ingested by any tier. Until then `resolve()` answering
@@ -397,6 +425,11 @@ var ComponentResolver = class {
397
425
  this.warmPromise = loadAll().then((rows) => {
398
426
  this.ingestDbRows(rows);
399
427
  this.settled = true;
428
+ this.warmFailures = 0;
429
+ if (this.warmRetryTimer) {
430
+ clearTimeout(this.warmRetryTimer);
431
+ this.warmRetryTimer = null;
432
+ }
400
433
  }).catch((error) => {
401
434
  const message = `component-resolver warm load failed (compiled bootstrap still serving): ${describe(error)}`;
402
435
  if (!this.warmFailureLogged) {
@@ -409,8 +442,17 @@ var ComponentResolver = class {
409
442
  ...errorFields(error),
410
443
  raw: error
411
444
  });
412
- this.settled = true;
413
445
  this.warmPromise = null;
446
+ this.warmFailures += 1;
447
+ const delay = WARM_RETRY_DELAYS_MS[this.warmFailures - 1] ?? null;
448
+ if (delay === null) {
449
+ this.settled = true;
450
+ } else if (!this.warmRetryTimer) {
451
+ this.warmRetryTimer = setTimeout(() => {
452
+ this.warmRetryTimer = null;
453
+ void this.ensureWarm();
454
+ }, delay);
455
+ }
414
456
  });
415
457
  }
416
458
  return this.warmPromise;
@@ -427,6 +469,7 @@ var import_content_ir = require("@ai-matrx/content-ir");
427
469
  var IR_ROUTE_KEY = "__ir_route";
428
470
  var GENERIC_STRUCTURED_COMPONENT_KEY = "generic_structured";
429
471
  var DB_KIND_COMPONENT_KEY = "db_kind_component";
472
+ var DIRECTIVE_BLOCK_TYPE = "matrx";
430
473
  function isDbSourceResolution(resolution) {
431
474
  return resolution !== null && resolution.resolvedBy === "db" && resolution.source === "db" && resolution.isActive;
432
475
  }
@@ -504,6 +547,18 @@ function applyIrKindRoute(block, env, options) {
504
547
  const kind = envelope.root.kind;
505
548
  if (!kind) return block;
506
549
  if (envelope.root.kindState === "pending_schema") return block;
550
+ if ((0, import_content_ir.isReservedDirectiveSlug)(kind)) {
551
+ if (block.type === DIRECTIVE_BLOCK_TYPE) return block;
552
+ return {
553
+ ...block,
554
+ type: DIRECTIVE_BLOCK_TYPE,
555
+ serverData: void 0,
556
+ metadata: {
557
+ ...block.metadata ?? {},
558
+ [IR_ROUTE_KEY]: { by: "directive", key: DIRECTIVE_BLOCK_TYPE }
559
+ }
560
+ };
561
+ }
507
562
  const def = env.kinds.getDefinition(kind);
508
563
  const resolution = env.components.resolve(kind, env.platform, "output");
509
564
  const componentsSettled = env.components.hasSettled?.() ?? true;
@@ -643,7 +698,7 @@ function createKindRouteBinding(env, options) {
643
698
  }
644
699
 
645
700
  // react/use-kind-version.ts
646
- var import_react2 = require("react");
701
+ var import_react3 = require("react");
647
702
  var noopSubscribe = () => () => {
648
703
  };
649
704
  var zero = () => 0;
@@ -655,7 +710,7 @@ function useContentIrKindVersion(kind, sources) {
655
710
  "[content-ir-react] useContentIrKindVersion needs either a ContentIrRenderProvider above it or explicit `sources`."
656
711
  );
657
712
  }
658
- const subscribe = (0, import_react2.useCallback)(
713
+ const subscribe = (0, import_react3.useCallback)(
659
714
  (onStoreChange) => {
660
715
  if (!kind || !resolved) return noopSubscribe();
661
716
  const unsubKinds = resolved.kinds.subscribeKind(kind, onStoreChange);
@@ -670,7 +725,7 @@ function useContentIrKindVersion(kind, sources) {
670
725
  },
671
726
  [resolved, kind]
672
727
  );
673
- const getSnapshot = (0, import_react2.useCallback)(
728
+ const getSnapshot = (0, import_react3.useCallback)(
674
729
  () => kind && resolved ? (
675
730
  // Both counters are monotonic, so the sum is monotonic — a change in
676
731
  // either registry produces a new snapshot value for this kind.
@@ -678,23 +733,377 @@ function useContentIrKindVersion(kind, sources) {
678
733
  ) : 0,
679
734
  [resolved, kind]
680
735
  );
681
- return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, zero);
736
+ return (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, zero);
682
737
  }
683
738
 
684
739
  // react/KindInstanceRender.tsx
685
- var import_react3 = require("react");
740
+ var import_react6 = require("react");
741
+ var import_content_ir7 = require("@ai-matrx/content-ir");
742
+
743
+ // directives/DirectiveRender.tsx
744
+ var import_content_ir6 = require("@ai-matrx/content-ir");
745
+
746
+ // directives/DirectiveFallbackCard.tsx
686
747
  var import_content_ir3 = require("@ai-matrx/content-ir");
687
- var import_jsx_runtime2 = require("react/jsx-runtime");
748
+
749
+ // directives/ApplyDirectiveButton.tsx
750
+ var import_react4 = require("react");
751
+
752
+ // directives/icons.tsx
753
+ var import_jsx_runtime3 = require("react/jsx-runtime");
754
+ function Svg({ children, ...props }) {
755
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
756
+ "svg",
757
+ {
758
+ xmlns: "http://www.w3.org/2000/svg",
759
+ viewBox: "0 0 24 24",
760
+ fill: "none",
761
+ stroke: "currentColor",
762
+ strokeWidth: 2,
763
+ strokeLinecap: "round",
764
+ strokeLinejoin: "round",
765
+ "aria-hidden": "true",
766
+ ...props,
767
+ children
768
+ }
769
+ );
770
+ }
771
+ var FilePlusIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
772
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4" }),
773
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
774
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 15h6" }),
775
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M6 12v6" })
776
+ ] });
777
+ var PencilIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
778
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 20h9" }),
779
+ /* @__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" })
780
+ ] });
781
+ var TrashIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
782
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 6h18" }),
783
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" }),
784
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" }),
785
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "10", x2: "10", y1: "11", y2: "17" }),
786
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "14", x2: "14", y1: "11", y2: "17" })
787
+ ] });
788
+ 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" }) });
789
+ var WebhookIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
790
+ /* @__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" }),
791
+ /* @__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" }),
792
+ /* @__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" })
793
+ ] });
794
+ var BoxesIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
795
+ /* @__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" }),
796
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m7 16.5-4.74-2.85" }),
797
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m7 16.5 5-3" }),
798
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M7 16.5v5.17" }),
799
+ /* @__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" }),
800
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m17 16.5-5-3" }),
801
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m17 16.5 4.74-2.85" }),
802
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M17 16.5v5.17" }),
803
+ /* @__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" }),
804
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 8 7.26 5.15" }),
805
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m12 8 4.74-2.85" }),
806
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 13.5V8" })
807
+ ] });
808
+ 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" }) });
809
+ 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" }) });
810
+ var MaximizeIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
811
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "15 3 21 3 21 9" }),
812
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("polyline", { points: "9 21 3 21 3 15" }),
813
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "21", x2: "14", y1: "3", y2: "10" }),
814
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "3", x2: "10", y1: "21", y2: "14" })
815
+ ] });
816
+ 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" }) });
817
+ var CheckCircleIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
818
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m9 12 2 2 4-4" })
820
+ ] });
821
+ var AlertIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Svg, { ...p, children: [
822
+ /* @__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" }),
823
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 9v4" }),
824
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 17h.01" })
825
+ ] });
826
+ var AGENT_NOUNS = /* @__PURE__ */ new Set(["create_agent", "create_agent_definition", "agent"]);
827
+ function classIcon(directiveClass, noun) {
828
+ if (directiveClass === "action" && AGENT_NOUNS.has(noun)) return WebhookIcon;
829
+ switch (directiveClass) {
830
+ case "create":
831
+ return FilePlusIcon;
832
+ case "update":
833
+ return PencilIcon;
834
+ case "delete":
835
+ return TrashIcon;
836
+ default:
837
+ return PlayIcon;
838
+ }
839
+ }
840
+
841
+ // directives/ApplyDirectiveButton.tsx
842
+ var import_jsx_runtime4 = require("react/jsx-runtime");
843
+ function ApplyDirectiveButton({
844
+ directive,
845
+ label = "Apply",
846
+ itemCount,
847
+ onApplied
848
+ }) {
849
+ const host = useDirectiveHost();
850
+ const [state, setState] = (0, import_react4.useState)({ status: "idle" });
851
+ const [elapsed, setElapsed] = (0, import_react4.useState)(0);
852
+ const startedAt = (0, import_react4.useRef)(null);
853
+ (0, import_react4.useEffect)(() => {
854
+ if (state.status !== "applying") return;
855
+ startedAt.current = Date.now();
856
+ const id = setInterval(
857
+ () => setElapsed(Math.round((Date.now() - (startedAt.current ?? 0)) / 1e3)),
858
+ 1e3
859
+ );
860
+ return () => clearInterval(id);
861
+ }, [state.status]);
862
+ if (!directive.parsed.executes) return null;
863
+ const confirm = host.confirm;
864
+ if (!confirm) return null;
865
+ const items = directive.items;
866
+ async function handleApply() {
867
+ if (!confirm) return;
868
+ setState({ status: "applying" });
869
+ try {
870
+ const result = await confirm({ __kind: directive.slug, items });
871
+ setState({ status: "applied", applied: result.applied, failed: result.failed });
872
+ onApplied?.();
873
+ } catch (error) {
874
+ setState({
875
+ status: "error",
876
+ message: error instanceof Error && error.message ? error.message : "That couldn't be applied just now. Please try again."
877
+ });
878
+ }
879
+ }
880
+ if (state.status === "applied") {
881
+ const bad = state.failed > 0;
882
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
883
+ "span",
884
+ {
885
+ className: `inline-flex items-center gap-1 text-xs ${bad ? "text-destructive" : "text-primary"}`,
886
+ children: [
887
+ 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" }),
888
+ "Applied ",
889
+ state.applied,
890
+ bad ? ` \xB7 ${state.failed} failed` : ""
891
+ ]
892
+ }
893
+ );
894
+ }
895
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "inline-flex items-center gap-2", children: [
896
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
897
+ "button",
898
+ {
899
+ type: "button",
900
+ onClick: () => void handleApply(),
901
+ disabled: state.status === "applying" || items.length === 0,
902
+ 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",
903
+ children: [
904
+ 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" }),
905
+ state.status === "applying" ? `Applying${itemCount ? ` ${itemCount} ${itemCount === 1 ? "item" : "items"}` : ""}\u2026${elapsed ? ` ${elapsed}s` : ""}` : label
906
+ ]
907
+ }
908
+ ),
909
+ 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: [
910
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
911
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: state.message })
912
+ ] }) : null
913
+ ] });
914
+ }
915
+
916
+ // directives/DirectiveFallbackCard.tsx
917
+ var import_jsx_runtime5 = require("react/jsx-runtime");
918
+ function DirectiveFallbackCard({ directive, reason }) {
919
+ const host = useDirectiveHost();
920
+ const count = directive.items.length;
921
+ const display = (0, import_content_ir3.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
922
+ 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: [
923
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BoxesIcon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
924
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-foreground", children: display.title }),
925
+ display.family ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
926
+ "\xB7 ",
927
+ display.family
928
+ ] }) : null,
929
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
930
+ "\xB7 ",
931
+ count,
932
+ " ",
933
+ count === 1 ? "item" : "items"
934
+ ] }),
935
+ reason ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
936
+ "\xB7 ",
937
+ reason
938
+ ] }) : null,
939
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ApplyDirectiveButton, { directive })
940
+ ] });
941
+ }
942
+
943
+ // directives/registry.ts
944
+ var import_content_ir4 = require("@ai-matrx/content-ir");
945
+ var REGISTRY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir-react.directive-renderers");
946
+ var registry = globalThis[REGISTRY_SLOT] ??= {
947
+ bySlug: /* @__PURE__ */ new Map(),
948
+ byClass: /* @__PURE__ */ new Map()
949
+ };
950
+ function registerDirectiveRenderer(directiveClass, renderer, noun) {
951
+ if (noun) registry.bySlug.set((0, import_content_ir4.buildDirectiveSlug)(directiveClass, noun), renderer);
952
+ else registry.byClass.set(directiveClass, renderer);
953
+ }
954
+ function getDirectiveRenderer(directive) {
955
+ return registry.bySlug.get(directive.slug) ?? registry.byClass.get(directive.directiveClass) ?? null;
956
+ }
957
+ function resetDirectiveRenderers() {
958
+ registry.bySlug.clear();
959
+ registry.byClass.clear();
960
+ }
961
+
962
+ // directives/SideEffectDirectiveCard.tsx
963
+ var import_react5 = require("react");
964
+ var import_content_ir5 = require("@ai-matrx/content-ir");
965
+ var import_jsx_runtime6 = require("react/jsx-runtime");
966
+ var ROWS_BEFORE_FOLD = 3;
967
+ function ItemRow({
968
+ directive,
969
+ item,
970
+ index,
971
+ total
972
+ }) {
973
+ const host = useDirectiveHost();
974
+ const titleColumn = (0, import_content_ir5.nounTitleColumn)(directive.noun, host.nouns);
975
+ const title = (0, import_content_ir5.itemTitle)(item, titleColumn, index, total);
976
+ const subtitle = (0, import_content_ir5.itemSubtitle)(item);
977
+ const facts = (0, import_content_ir5.itemFacts)(item);
978
+ const kind = host.itemKind?.(directive.slug) ?? null;
979
+ const display = (0, import_content_ir5.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
980
+ const openItem = host.openItem;
981
+ const body = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
982
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
983
+ /* @__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: [
984
+ fact.value,
985
+ " ",
986
+ fact.label
987
+ ] }, fact.key)) }),
988
+ subtitle && facts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hidden truncate text-[11px] text-muted-foreground sm:inline", children: subtitle }) : null,
989
+ openItem ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MaximizeIcon, { className: "ml-auto h-3 w-3 shrink-0 text-muted-foreground" }) : null
990
+ ] });
991
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2 py-1 text-xs", children: [
992
+ openItem ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
993
+ "button",
994
+ {
995
+ type: "button",
996
+ onClick: () => openItem({
997
+ // Stamped so the panel's kind pipeline types it from its own first key.
998
+ item: (0, import_content_ir5.asKindInstance)(item, kind) ?? item,
999
+ itemKind: kind,
1000
+ title,
1001
+ subtitle: `${display.title} \xB7 item ${index + 1} of ${total}`,
1002
+ directive,
1003
+ index,
1004
+ total
1005
+ }),
1006
+ 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",
1007
+ title: "Open to read it",
1008
+ children: body
1009
+ }
1010
+ ) : /* @__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 }),
1011
+ host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
1012
+ ] });
1013
+ }
1014
+ function SideEffectDirectiveCard({ directive }) {
1015
+ const host = useDirectiveHost();
1016
+ const [expanded, setExpanded] = (0, import_react5.useState)(false);
1017
+ const items = directive.items;
1018
+ const total = items.length;
1019
+ const display = (0, import_content_ir5.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
1020
+ const Icon = classIcon(directive.directiveClass, directive.noun);
1021
+ const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
1022
+ const hidden = total - shown.length;
1023
+ 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: [
1024
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
1025
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
1026
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-sm font-medium text-foreground", children: display.title }),
1027
+ display.family ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-xs text-muted-foreground", children: display.family }) : null,
1028
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "text-xs tabular-nums text-muted-foreground", children: [
1029
+ total,
1030
+ " ",
1031
+ total === 1 ? "item" : "items"
1032
+ ] }),
1033
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ml-auto flex items-center gap-1", children: [
1034
+ host.renderCopy?.({ label: display.title, value: directive.shell, size: "icon" }),
1035
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ApplyDirectiveButton, { directive, itemCount: total })
1036
+ ] })
1037
+ ] }),
1038
+ total === 0 ? (
1039
+ // Stated, never silent: an empty batch is a real (and suspicious) state.
1040
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mt-1 text-xs text-muted-foreground", children: "No items \u2014 nothing would be written." })
1041
+ ) : /* @__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)) }),
1042
+ hidden > 0 || expanded ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1043
+ "button",
1044
+ {
1045
+ type: "button",
1046
+ onClick: () => setExpanded((v) => !v),
1047
+ className: "mt-0.5 inline-flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",
1048
+ children: [
1049
+ 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" }),
1050
+ expanded ? "Show less" : `Show ${hidden} more`
1051
+ ]
1052
+ }
1053
+ ) : null
1054
+ ] });
1055
+ }
1056
+
1057
+ // directives/DirectiveRender.tsx
1058
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1059
+ function DirectiveRender({ content, className }) {
1060
+ const host = useDirectiveHost();
1061
+ const directive = (0, import_content_ir6.tryDecodeDirectiveContent)(content, (message) => {
1062
+ const line = `[kind-directives] ${message}`;
1063
+ if (host.reportError) host.reportError(line);
1064
+ else console.error(line);
1065
+ });
1066
+ if (!directive) {
1067
+ const raw = typeof content === "string" ? content : JSON.stringify(content, null, 2);
1068
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1069
+ "pre",
1070
+ {
1071
+ className: `my-3 overflow-x-auto rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground${className ? ` ${className}` : ""}`,
1072
+ children: raw
1073
+ }
1074
+ );
1075
+ }
1076
+ const Renderer = getDirectiveRenderer(directive);
1077
+ if (Renderer) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Renderer, { directive });
1078
+ if (directive.parsed.executes) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SideEffectDirectiveCard, { directive });
1079
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DirectiveFallbackCard, { directive });
1080
+ }
1081
+
1082
+ // react/KindInstanceRender.tsx
1083
+ var import_jsx_runtime8 = require("react/jsx-runtime");
688
1084
  function isRecordValue(value) {
689
1085
  return typeof value === "object" && value !== null && !Array.isArray(value);
690
1086
  }
691
1087
  function kindIsRoutable(kind, host) {
1088
+ if ((0, import_content_ir7.isReservedDirectiveSlug)(kind)) return true;
692
1089
  if (host.kinds.getDefinition(kind)?.legacyBlockType) return true;
693
1090
  const resolution = host.components.resolve(kind, host.platform, "output");
694
1091
  if (!resolution?.isActive) return false;
695
1092
  return resolution.componentKey !== GENERIC_STRUCTURED_COMPONENT_KEY;
696
1093
  }
697
- function KindInstanceRender({
1094
+ function KindInstanceRender(props) {
1095
+ if ((0, import_content_ir7.isReservedDirectiveSlug)(props.kind)) {
1096
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1097
+ DirectiveRender,
1098
+ {
1099
+ content: props.value,
1100
+ ...props.className === void 0 ? {} : { className: props.className }
1101
+ }
1102
+ );
1103
+ }
1104
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(KindInstanceRenderInner, { ...props });
1105
+ }
1106
+ function KindInstanceRenderInner({
698
1107
  kind,
699
1108
  value,
700
1109
  showRoutingNote = true,
@@ -703,10 +1112,10 @@ function KindInstanceRender({
703
1112
  className
704
1113
  }) {
705
1114
  const host = useContentIrHost();
706
- const [routingStatus, setRoutingStatus] = (0, import_react3.useState)(
1115
+ const [routingStatus, setRoutingStatus] = (0, import_react6.useState)(
707
1116
  () => kindIsRoutable(kind, host) ? "routable" : "checking"
708
1117
  );
709
- (0, import_react3.useEffect)(() => {
1118
+ (0, import_react6.useEffect)(() => {
710
1119
  let cancelled = false;
711
1120
  let warmed = false;
712
1121
  const syncRoutingStatus = () => {
@@ -738,25 +1147,25 @@ function KindInstanceRender({
738
1147
  content: JSON.stringify(value, null, 2),
739
1148
  language: "json",
740
1149
  metadata: {
741
- [import_content_ir3.IR_ENVELOPE_KEY]: (0, import_content_ir3.envelopeFromCompleteValue)(value, kind)
1150
+ [import_content_ir7.IR_ENVELOPE_KEY]: (0, import_content_ir7.envelopeFromCompleteValue)(value, kind)
742
1151
  }
743
1152
  } : null;
744
1153
  const frameClass = variant === "bare" ? void 0 : "rounded-md border border-border bg-card p-3";
745
1154
  if (routingStatus === "unroutable" && unroutableFallback !== void 0) {
746
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: unroutableFallback });
1155
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: unroutableFallback });
747
1156
  }
748
1157
  const onTheFloor = block === null || routingStatus === "unroutable";
749
1158
  const notice = "This shape has no custom component yet, so it renders through the universal viewer \u2014 exactly what production shows today.";
750
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: className ? `space-y-3 ${className}` : "space-y-3", children: [
751
- showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0, import_jsx_runtime2.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,
752
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: frameClass, children: onTheFloor ? host.renderValue({ value, kind }) : host.renderBlock(block) })
1159
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: className ? `space-y-3 ${className}` : "space-y-3", children: [
1160
+ 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,
1161
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: frameClass, children: onTheFloor ? host.renderValue({ value, kind }) : host.renderBlock(block) })
753
1162
  ] });
754
1163
  }
755
1164
 
756
1165
  // react/ProvisionalKindBoundary.tsx
757
- var import_react4 = __toESM(require("react"), 1);
758
- var import_jsx_runtime3 = require("react/jsx-runtime");
759
- var ProvisionalKindBoundaryInner = class extends import_react4.default.Component {
1166
+ var import_react7 = __toESM(require("react"), 1);
1167
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1168
+ var ProvisionalKindBoundaryInner = class extends import_react7.default.Component {
760
1169
  state = { failed: false };
761
1170
  static getDerivedStateFromError() {
762
1171
  return { failed: true };
@@ -780,25 +1189,25 @@ var ProvisionalKindBoundaryInner = class extends import_react4.default.Component
780
1189
  };
781
1190
  function ProvisionalKindBoundary(props) {
782
1191
  const host = useContentIrHost();
783
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProvisionalKindBoundaryInner, { ...props, reportError: host.reportError });
1192
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProvisionalKindBoundaryInner, { ...props, reportError: host.reportError });
784
1193
  }
785
1194
  function ProvisionalKindFrame({ children }) {
786
1195
  const host = useContentIrHost();
787
1196
  const label = "Still arriving";
788
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", "aria-busy": "true", children: [
1197
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "relative", "aria-busy": "true", children: [
789
1198
  children,
790
- /* @__PURE__ */ (0, import_jsx_runtime3.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_runtime3.jsx)("span", { className: "text-[10px] text-muted-foreground", children: label }) })
1199
+ /* @__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 }) })
791
1200
  ] });
792
1201
  }
793
1202
 
794
1203
  // react/GenericStructuredView.tsx
795
- var import_react5 = require("react");
796
- var import_content_ir4 = require("@ai-matrx/content-ir");
797
- var import_jsx_runtime4 = require("react/jsx-runtime");
1204
+ var import_react8 = require("react");
1205
+ var import_content_ir8 = require("@ai-matrx/content-ir");
1206
+ var import_jsx_runtime10 = require("react/jsx-runtime");
798
1207
  function readStructuredValue(content, metadata) {
799
- const envelope = (0, import_content_ir4.readEnvelope)(metadata);
1208
+ const envelope = (0, import_content_ir8.readEnvelope)(metadata);
800
1209
  if (envelope) {
801
- return { value: (0, import_content_ir4.reconstructRegionValue)(envelope), recovered: true };
1210
+ return { value: (0, import_content_ir8.reconstructRegionValue)(envelope), recovered: true };
802
1211
  }
803
1212
  try {
804
1213
  return { value: JSON.parse(content), recovered: true };
@@ -813,25 +1222,25 @@ function GenericStructuredView({
813
1222
  className
814
1223
  }) {
815
1224
  const host = useContentIrHost();
816
- const envelope = (0, import_content_ir4.readEnvelope)(metadata);
1225
+ const envelope = (0, import_content_ir8.readEnvelope)(metadata);
817
1226
  const status = envelope?.root.status ?? "complete";
818
1227
  const { value, recovered } = readStructuredValue(content, metadata);
819
- const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir4.readObjectKind)(value) : null) ?? "";
1228
+ const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir8.readObjectKind)(value) : null) ?? "";
820
1229
  const marker = readIrRouteMarker(metadata);
821
1230
  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";
822
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
823
- status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mb-2 text-xs text-muted-foreground", children: "Still arriving\u2026" }) : null,
1231
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
1232
+ status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mb-2 text-xs text-muted-foreground", children: "Still arriving\u2026" }) : null,
824
1233
  recovered ? host.renderValue({ value, ...kind ? { kind } : {}, note }) : (
825
1234
  // Zero-data-loss backstop: the region never parsed, so show the source
826
1235
  // verbatim rather than swallowing it.
827
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { className: "max-h-96 overflow-auto font-mono text-xs leading-relaxed text-muted-foreground", children: content })
1236
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("pre", { className: "max-h-96 overflow-auto font-mono text-xs leading-relaxed text-muted-foreground", children: content })
828
1237
  )
829
1238
  ] });
830
1239
  }
831
1240
 
832
1241
  // react/RuntimeWrapperViews.tsx
833
- var import_content_ir5 = require("@ai-matrx/content-ir");
834
- var import_jsx_runtime5 = require("react/jsx-runtime");
1242
+ var import_content_ir9 = require("@ai-matrx/content-ir");
1243
+ var import_jsx_runtime11 = require("react/jsx-runtime");
835
1244
  function isRecord2(value) {
836
1245
  return typeof value === "object" && value !== null && !Array.isArray(value);
837
1246
  }
@@ -847,16 +1256,16 @@ function DelegatedOutput({
847
1256
  }) {
848
1257
  const host = useContentIrHost();
849
1258
  if (output === null || output === void 0) {
850
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyLabel });
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyLabel });
851
1260
  }
852
1261
  if (!isRecord2(output)) {
853
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: host.renderValue({ value: output }) });
1262
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: host.renderValue({ value: output }) });
854
1263
  }
855
- const kind = (0, import_content_ir5.readObjectKind)(output) ?? declaredKind;
1264
+ const kind = (0, import_content_ir9.readObjectKind)(output) ?? declaredKind;
856
1265
  if (!kind) {
857
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
1266
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
858
1267
  }
859
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1268
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
860
1269
  KindInstanceRender,
861
1270
  {
862
1271
  kind,
@@ -870,10 +1279,10 @@ function DelegatedOutput({
870
1279
  function NodeOutcomeView({ serverData, fallback }) {
871
1280
  const wrapper = readWrapperFrom(
872
1281
  serverData,
873
- import_content_ir5.readNodeOutcomeValue
1282
+ import_content_ir9.readNodeOutcomeValue
874
1283
  );
875
1284
  if (!wrapper) return null;
876
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1285
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
877
1286
  DelegatedOutput,
878
1287
  {
879
1288
  output: wrapper.output,
@@ -885,17 +1294,17 @@ function NodeOutcomeView({ serverData, fallback }) {
885
1294
  function RunResultView({ serverData, fallback }) {
886
1295
  const wrapper = readWrapperFrom(
887
1296
  serverData,
888
- import_content_ir5.readRunResultValue
1297
+ import_content_ir9.readRunResultValue
889
1298
  );
890
1299
  if (!wrapper) return null;
891
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "space-y-2", children: wrapper.outputs.length > 0 ? wrapper.outputs.map((outcome) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1300
+ 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)(
892
1301
  NodeOutcomeView,
893
1302
  {
894
1303
  serverData: { wrapper: outcome },
895
1304
  ...fallback === void 0 ? {} : { fallback }
896
1305
  },
897
1306
  `${outcome.node_id}:${outcome.attempt}`
898
- )) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1307
+ )) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
899
1308
  DelegatedOutput,
900
1309
  {
901
1310
  output: wrapper.output,