@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
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// directives.ts
|
|
22
|
+
var directives_exports = {};
|
|
23
|
+
__export(directives_exports, {
|
|
24
|
+
ApplyDirectiveButton: () => ApplyDirectiveButton,
|
|
25
|
+
DirectiveFallbackCard: () => DirectiveFallbackCard,
|
|
26
|
+
DirectiveHostProvider: () => DirectiveHostProvider,
|
|
27
|
+
DirectiveRender: () => DirectiveRender,
|
|
28
|
+
SideEffectDirectiveCard: () => SideEffectDirectiveCard,
|
|
29
|
+
getDirectiveRenderer: () => getDirectiveRenderer,
|
|
30
|
+
registerDirectiveRenderer: () => registerDirectiveRenderer,
|
|
31
|
+
resetDirectiveRenderers: () => resetDirectiveRenderers,
|
|
32
|
+
useDirectiveHost: () => useDirectiveHost
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(directives_exports);
|
|
35
|
+
|
|
36
|
+
// directives/directive-host.tsx
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
+
var DirectiveHostContext = (0, import_react.createContext)(null);
|
|
40
|
+
function DirectiveHostProvider({ host, children }) {
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DirectiveHostContext.Provider, { value: host, children });
|
|
42
|
+
}
|
|
43
|
+
var EMPTY_HOST = {};
|
|
44
|
+
function useDirectiveHost() {
|
|
45
|
+
return (0, import_react.useContext)(DirectiveHostContext) ?? EMPTY_HOST;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// directives/registry.ts
|
|
49
|
+
var import_content_ir = require("@ai-matrx/content-ir");
|
|
50
|
+
var REGISTRY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir-react.directive-renderers");
|
|
51
|
+
var registry = globalThis[REGISTRY_SLOT] ??= {
|
|
52
|
+
bySlug: /* @__PURE__ */ new Map(),
|
|
53
|
+
byClass: /* @__PURE__ */ new Map()
|
|
54
|
+
};
|
|
55
|
+
function registerDirectiveRenderer(directiveClass, renderer, noun) {
|
|
56
|
+
if (noun) registry.bySlug.set((0, import_content_ir.buildDirectiveSlug)(directiveClass, noun), renderer);
|
|
57
|
+
else registry.byClass.set(directiveClass, renderer);
|
|
58
|
+
}
|
|
59
|
+
function getDirectiveRenderer(directive) {
|
|
60
|
+
return registry.bySlug.get(directive.slug) ?? registry.byClass.get(directive.directiveClass) ?? null;
|
|
61
|
+
}
|
|
62
|
+
function resetDirectiveRenderers() {
|
|
63
|
+
registry.bySlug.clear();
|
|
64
|
+
registry.byClass.clear();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// directives/ApplyDirectiveButton.tsx
|
|
68
|
+
var import_react2 = require("react");
|
|
69
|
+
|
|
70
|
+
// directives/icons.tsx
|
|
71
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
72
|
+
function Svg({ children, ...props }) {
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
74
|
+
"svg",
|
|
75
|
+
{
|
|
76
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
77
|
+
viewBox: "0 0 24 24",
|
|
78
|
+
fill: "none",
|
|
79
|
+
stroke: "currentColor",
|
|
80
|
+
strokeWidth: 2,
|
|
81
|
+
strokeLinecap: "round",
|
|
82
|
+
strokeLinejoin: "round",
|
|
83
|
+
"aria-hidden": "true",
|
|
84
|
+
...props,
|
|
85
|
+
children
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
var FilePlusIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4" }),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }),
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M3 15h6" }),
|
|
93
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M6 12v6" })
|
|
94
|
+
] });
|
|
95
|
+
var PencilIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 20h9" }),
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" })
|
|
98
|
+
] });
|
|
99
|
+
var TrashIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M3 6h18" }),
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" }),
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" }),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "10", x2: "10", y1: "11", y2: "17" }),
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "14", x2: "14", y1: "11", y2: "17" })
|
|
105
|
+
] });
|
|
106
|
+
var PlayIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polygon", { points: "6 3 20 12 6 21 6 3" }) });
|
|
107
|
+
var WebhookIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" }),
|
|
109
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" }),
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8" })
|
|
111
|
+
] });
|
|
112
|
+
var BoxesIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" }),
|
|
114
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m7 16.5-4.74-2.85" }),
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m7 16.5 5-3" }),
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M7 16.5v5.17" }),
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" }),
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m17 16.5-5-3" }),
|
|
119
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m17 16.5 4.74-2.85" }),
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M17 16.5v5.17" }),
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" }),
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 8 7.26 5.15" }),
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m12 8 4.74-2.85" }),
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 13.5V8" })
|
|
125
|
+
] });
|
|
126
|
+
var ChevronDownIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m6 9 6 6 6-6" }) });
|
|
127
|
+
var ChevronRightIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m9 18 6-6-6-6" }) });
|
|
128
|
+
var MaximizeIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "15 3 21 3 21 9" }),
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "9 21 3 21 3 15" }),
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "21", x2: "14", y1: "3", y2: "10" }),
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "3", x2: "10", y1: "21", y2: "14" })
|
|
133
|
+
] });
|
|
134
|
+
var LoaderIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Svg, { ...p, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
|
|
135
|
+
var CheckCircleIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m9 12 2 2 4-4" })
|
|
138
|
+
] });
|
|
139
|
+
var AlertIcon = (p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Svg, { ...p, children: [
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" }),
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 9v4" }),
|
|
142
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 17h.01" })
|
|
143
|
+
] });
|
|
144
|
+
var AGENT_NOUNS = /* @__PURE__ */ new Set(["create_agent", "create_agent_definition", "agent"]);
|
|
145
|
+
function classIcon(directiveClass, noun) {
|
|
146
|
+
if (directiveClass === "action" && AGENT_NOUNS.has(noun)) return WebhookIcon;
|
|
147
|
+
switch (directiveClass) {
|
|
148
|
+
case "create":
|
|
149
|
+
return FilePlusIcon;
|
|
150
|
+
case "update":
|
|
151
|
+
return PencilIcon;
|
|
152
|
+
case "delete":
|
|
153
|
+
return TrashIcon;
|
|
154
|
+
default:
|
|
155
|
+
return PlayIcon;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// directives/ApplyDirectiveButton.tsx
|
|
160
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
161
|
+
function ApplyDirectiveButton({
|
|
162
|
+
directive,
|
|
163
|
+
label = "Apply",
|
|
164
|
+
itemCount,
|
|
165
|
+
onApplied
|
|
166
|
+
}) {
|
|
167
|
+
const host = useDirectiveHost();
|
|
168
|
+
const [state, setState] = (0, import_react2.useState)({ status: "idle" });
|
|
169
|
+
const [elapsed, setElapsed] = (0, import_react2.useState)(0);
|
|
170
|
+
const startedAt = (0, import_react2.useRef)(null);
|
|
171
|
+
(0, import_react2.useEffect)(() => {
|
|
172
|
+
if (state.status !== "applying") return;
|
|
173
|
+
startedAt.current = Date.now();
|
|
174
|
+
const id = setInterval(
|
|
175
|
+
() => setElapsed(Math.round((Date.now() - (startedAt.current ?? 0)) / 1e3)),
|
|
176
|
+
1e3
|
|
177
|
+
);
|
|
178
|
+
return () => clearInterval(id);
|
|
179
|
+
}, [state.status]);
|
|
180
|
+
if (!directive.parsed.executes) return null;
|
|
181
|
+
const confirm = host.confirm;
|
|
182
|
+
if (!confirm) return null;
|
|
183
|
+
const items = directive.items;
|
|
184
|
+
async function handleApply() {
|
|
185
|
+
if (!confirm) return;
|
|
186
|
+
setState({ status: "applying" });
|
|
187
|
+
try {
|
|
188
|
+
const result = await confirm({ __kind: directive.slug, items });
|
|
189
|
+
setState({ status: "applied", applied: result.applied, failed: result.failed });
|
|
190
|
+
onApplied?.();
|
|
191
|
+
} catch (error) {
|
|
192
|
+
setState({
|
|
193
|
+
status: "error",
|
|
194
|
+
message: error instanceof Error && error.message ? error.message : "That couldn't be applied just now. Please try again."
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (state.status === "applied") {
|
|
199
|
+
const bad = state.failed > 0;
|
|
200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
201
|
+
"span",
|
|
202
|
+
{
|
|
203
|
+
className: `inline-flex items-center gap-1 text-xs ${bad ? "text-destructive" : "text-primary"}`,
|
|
204
|
+
children: [
|
|
205
|
+
bad ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AlertIcon, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckCircleIcon, { className: "h-3.5 w-3.5" }),
|
|
206
|
+
"Applied ",
|
|
207
|
+
state.applied,
|
|
208
|
+
bad ? ` \xB7 ${state.failed} failed` : ""
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "inline-flex items-center gap-2", children: [
|
|
214
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
215
|
+
"button",
|
|
216
|
+
{
|
|
217
|
+
type: "button",
|
|
218
|
+
onClick: () => void handleApply(),
|
|
219
|
+
disabled: state.status === "applying" || items.length === 0,
|
|
220
|
+
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",
|
|
221
|
+
children: [
|
|
222
|
+
state.status === "applying" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PlayIcon, { className: "h-3.5 w-3.5" }),
|
|
223
|
+
state.status === "applying" ? `Applying${itemCount ? ` ${itemCount} ${itemCount === 1 ? "item" : "items"}` : ""}\u2026${elapsed ? ` ${elapsed}s` : ""}` : label
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
state.status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "inline-flex max-w-sm items-start gap-1 text-xs text-destructive", children: [
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AlertIcon, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: state.message })
|
|
230
|
+
] }) : null
|
|
231
|
+
] });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// directives/SideEffectDirectiveCard.tsx
|
|
235
|
+
var import_react3 = require("react");
|
|
236
|
+
var import_content_ir2 = require("@ai-matrx/content-ir");
|
|
237
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
238
|
+
var ROWS_BEFORE_FOLD = 3;
|
|
239
|
+
function ItemRow({
|
|
240
|
+
directive,
|
|
241
|
+
item,
|
|
242
|
+
index,
|
|
243
|
+
total
|
|
244
|
+
}) {
|
|
245
|
+
const host = useDirectiveHost();
|
|
246
|
+
const titleColumn = (0, import_content_ir2.nounTitleColumn)(directive.noun, host.nouns);
|
|
247
|
+
const title = (0, import_content_ir2.itemTitle)(item, titleColumn, index, total);
|
|
248
|
+
const subtitle = (0, import_content_ir2.itemSubtitle)(item);
|
|
249
|
+
const facts = (0, import_content_ir2.itemFacts)(item);
|
|
250
|
+
const kind = host.itemKind?.(directive.slug) ?? null;
|
|
251
|
+
const display = (0, import_content_ir2.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
252
|
+
const openItem = host.openItem;
|
|
253
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
|
|
255
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.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_runtime4.jsxs)("span", { className: "truncate text-[11px] text-muted-foreground", children: [
|
|
256
|
+
fact.value,
|
|
257
|
+
" ",
|
|
258
|
+
fact.label
|
|
259
|
+
] }, fact.key)) }),
|
|
260
|
+
subtitle && facts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "hidden truncate text-[11px] text-muted-foreground sm:inline", children: subtitle }) : null,
|
|
261
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MaximizeIcon, { className: "ml-auto h-3 w-3 shrink-0 text-muted-foreground" }) : null
|
|
262
|
+
] });
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2 py-1 text-xs", children: [
|
|
264
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
265
|
+
"button",
|
|
266
|
+
{
|
|
267
|
+
type: "button",
|
|
268
|
+
onClick: () => openItem({
|
|
269
|
+
// Stamped so the panel's kind pipeline types it from its own first key.
|
|
270
|
+
item: (0, import_content_ir2.asKindInstance)(item, kind) ?? item,
|
|
271
|
+
itemKind: kind,
|
|
272
|
+
title,
|
|
273
|
+
subtitle: `${display.title} \xB7 item ${index + 1} of ${total}`,
|
|
274
|
+
directive,
|
|
275
|
+
index,
|
|
276
|
+
total
|
|
277
|
+
}),
|
|
278
|
+
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",
|
|
279
|
+
title: "Open to read it",
|
|
280
|
+
children: body
|
|
281
|
+
}
|
|
282
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-2 px-1 py-0.5", children: body }),
|
|
283
|
+
host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
|
|
284
|
+
] });
|
|
285
|
+
}
|
|
286
|
+
function SideEffectDirectiveCard({ directive }) {
|
|
287
|
+
const host = useDirectiveHost();
|
|
288
|
+
const [expanded, setExpanded] = (0, import_react3.useState)(false);
|
|
289
|
+
const items = directive.items;
|
|
290
|
+
const total = items.length;
|
|
291
|
+
const display = (0, import_content_ir2.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
292
|
+
const Icon = classIcon(directive.directiveClass, directive.noun);
|
|
293
|
+
const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
|
|
294
|
+
const hidden = total - shown.length;
|
|
295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "my-3 rounded-md border border-border bg-card px-2.5 py-1.5", "data-directive": directive.slug, children: [
|
|
296
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
298
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-medium text-foreground", children: display.title }),
|
|
299
|
+
display.family ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-xs text-muted-foreground", children: display.family }) : null,
|
|
300
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "text-xs tabular-nums text-muted-foreground", children: [
|
|
301
|
+
total,
|
|
302
|
+
" ",
|
|
303
|
+
total === 1 ? "item" : "items"
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ml-auto flex items-center gap-1", children: [
|
|
306
|
+
host.renderCopy?.({ label: display.title, value: directive.shell, size: "icon" }),
|
|
307
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ApplyDirectiveButton, { directive, itemCount: total })
|
|
308
|
+
] })
|
|
309
|
+
] }),
|
|
310
|
+
total === 0 ? (
|
|
311
|
+
// Stated, never silent: an empty batch is a real (and suspicious) state.
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mt-1 text-xs text-muted-foreground", children: "No items \u2014 nothing would be written." })
|
|
313
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ItemRow, { directive, item, index: i, total }, i)) }),
|
|
314
|
+
hidden > 0 || expanded ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
315
|
+
"button",
|
|
316
|
+
{
|
|
317
|
+
type: "button",
|
|
318
|
+
onClick: () => setExpanded((v) => !v),
|
|
319
|
+
className: "mt-0.5 inline-flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",
|
|
320
|
+
children: [
|
|
321
|
+
expanded ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChevronRightIcon, { className: "h-3 w-3" }),
|
|
322
|
+
expanded ? "Show less" : `Show ${hidden} more`
|
|
323
|
+
]
|
|
324
|
+
}
|
|
325
|
+
) : null
|
|
326
|
+
] });
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// directives/DirectiveFallbackCard.tsx
|
|
330
|
+
var import_content_ir3 = require("@ai-matrx/content-ir");
|
|
331
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
332
|
+
function DirectiveFallbackCard({ directive, reason }) {
|
|
333
|
+
const host = useDirectiveHost();
|
|
334
|
+
const count = directive.items.length;
|
|
335
|
+
const display = (0, import_content_ir3.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
336
|
+
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: [
|
|
337
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BoxesIcon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-foreground", children: display.title }),
|
|
339
|
+
display.family ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
340
|
+
"\xB7 ",
|
|
341
|
+
display.family
|
|
342
|
+
] }) : null,
|
|
343
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
344
|
+
"\xB7 ",
|
|
345
|
+
count,
|
|
346
|
+
" ",
|
|
347
|
+
count === 1 ? "item" : "items"
|
|
348
|
+
] }),
|
|
349
|
+
reason ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
350
|
+
"\xB7 ",
|
|
351
|
+
reason
|
|
352
|
+
] }) : null,
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ApplyDirectiveButton, { directive })
|
|
354
|
+
] });
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// directives/DirectiveRender.tsx
|
|
358
|
+
var import_content_ir4 = require("@ai-matrx/content-ir");
|
|
359
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
360
|
+
function DirectiveRender({ content, className }) {
|
|
361
|
+
const host = useDirectiveHost();
|
|
362
|
+
const directive = (0, import_content_ir4.tryDecodeDirectiveContent)(content, (message) => {
|
|
363
|
+
const line = `[kind-directives] ${message}`;
|
|
364
|
+
if (host.reportError) host.reportError(line);
|
|
365
|
+
else console.error(line);
|
|
366
|
+
});
|
|
367
|
+
if (!directive) {
|
|
368
|
+
const raw = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
370
|
+
"pre",
|
|
371
|
+
{
|
|
372
|
+
className: `my-3 overflow-x-auto rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground${className ? ` ${className}` : ""}`,
|
|
373
|
+
children: raw
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
const Renderer = getDirectiveRenderer(directive);
|
|
378
|
+
if (Renderer) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Renderer, { directive });
|
|
379
|
+
if (directive.parsed.executes) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SideEffectDirectiveCard, { directive });
|
|
380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DirectiveFallbackCard, { directive });
|
|
381
|
+
}
|
|
382
|
+
//# sourceMappingURL=directives.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../directives.ts","../directives/directive-host.tsx","../directives/registry.ts","../directives/ApplyDirectiveButton.tsx","../directives/icons.tsx","../directives/SideEffectDirectiveCard.tsx","../directives/DirectiveFallbackCard.tsx","../directives/DirectiveRender.tsx"],"sourcesContent":["/**\n * `@ai-matrx/content-ir-react/directives` — the Kind Directives render tier:\n * the host seams (`DirectiveHostProvider`), the renderer registry with THE\n * PREFIX TIER, the side-effect card, the fallback floor, the Apply control, and\n * `DirectiveRender` — THE renderer every UI draws a directive through. Client\n * entry (stamped \"use client\").\n */\nexport * from \"./directives/directive-host\";\nexport * from \"./directives/registry\";\nexport * from \"./directives/ApplyDirectiveButton\";\nexport * from \"./directives/SideEffectDirectiveCard\";\nexport * from \"./directives/DirectiveFallbackCard\";\nexport * from \"./directives/DirectiveRender\";\n","\"use client\";\n\n/**\n * THE DIRECTIVE HOST CONTRACT — what the directive tier refuses to decide.\n *\n * The package owns the DECISIONS (decode → renderer → card → floor, the\n * position law, never-null rendering) and the card itself. Four things stay\n * host property and enter through named seams:\n *\n * 1. APPLYING a side-effect directive — `POST /directives/confirm` as the\n * user, with the host's auth and base URL. Absent → the Apply control is\n * ABSENT (honest), never a dead button.\n * 2. OPENING an item to read it before approving — a window panel, a dialog,\n * a route. Absent → items are not clickable.\n * 3. COPY controls — host chrome (matrx-frontend's CopyButtons). Absent → none.\n * 4. The NOUN catalog + item-kind lookup — server-derived tables the host\n * mirrors (or reads from its kind catalog's `items` edges).\n *\n * A host that has adopted `ContentIrRenderProvider` passes `directives` on its\n * ContentIrHost; a host that has NOT (Workflow Studio, 2026-09-08) mounts\n * `DirectiveHostProvider` alone — the directive tier never requires the full\n * render host, because a chat bubble must be able to draw a directive card\n * identically everywhere, today.\n */\n\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport type {\n DecodedDirective,\n DirectiveItemKindLookup,\n DirectiveNounCatalog,\n} from \"@ai-matrx/content-ir\";\n\nexport interface DirectiveApplyResult {\n applied: number;\n failed: number;\n}\n\nexport interface DirectiveOpenItemOptions {\n /** The item, `__kind`-stamped when the shape has an item kind. */\n item: Record<string, unknown>;\n /** The content-IR kind this item IS, or null when the shape has none. */\n itemKind: string | null;\n /** What the item is called — the same title the card shows. */\n title: string;\n /** \"Run Create agent definition · item 1 of 1\". */\n subtitle: string | null;\n directive: DecodedDirective;\n index: number;\n total: number;\n}\n\nexport interface DirectiveCopyProps {\n label: string;\n /** The value to copy — the whole shell or one item. */\n value: unknown;\n /** The item's kind, when copying an item. */\n kind?: string | null;\n size: \"icon\" | \"xs\";\n}\n\nexport interface DirectiveHost {\n /**\n * Apply a side-effect directive as the user (the server re-validates every\n * item against the registered model and runs the ONE handler; idempotent).\n * Reject with an Error whose message is safe to show.\n */\n confirm?: (shell: { __kind: string; items: Record<string, unknown>[] }) => Promise<DirectiveApplyResult>;\n /** Open ONE item to read it properly before approving the write. */\n openItem?: (options: DirectiveOpenItemOptions) => void;\n /** Host copy controls. */\n renderCopy?: (props: DirectiveCopyProps) => ReactNode;\n /** The mirrored noun catalog (label / family / title column). */\n nouns?: DirectiveNounCatalog;\n /** slug → the kind ONE item is (THE DIRECTIVE⇄KIND SEAM), or null. */\n itemKind?: DirectiveItemKindLookup;\n /** Where a decode failure or an unhonourable shell is reported. Default: console.error. */\n reportError?: (message: string) => void;\n}\n\nconst DirectiveHostContext = createContext<DirectiveHost | null>(null);\n\nexport interface DirectiveHostProviderProps {\n host: DirectiveHost;\n children: ReactNode;\n}\n\nexport function DirectiveHostProvider({ host, children }: DirectiveHostProviderProps) {\n return <DirectiveHostContext.Provider value={host}>{children}</DirectiveHostContext.Provider>;\n}\n\nconst EMPTY_HOST: DirectiveHost = {};\n\n/**\n * The wired directive host. Unlike the render host this does NOT throw when\n * unwired: a directive still renders (named, itemised, copy-less, apply-less)\n * — degrading the chrome is honest, hiding the content is not.\n */\nexport function useDirectiveHost(): DirectiveHost {\n return useContext(DirectiveHostContext) ?? EMPTY_HOST;\n}\n","/**\n * Kind Directives — the renderer registry, and THE PREFIX TIER.\n *\n * A directive IS a kind instance, so the renderer for one is resolved from its\n * SLUG, in the same shape the kind component resolver uses:\n *\n * getDirectiveRenderer(directive)\n * → an exact-slug renderer (directive_v1_action_plan_tree)\n * → else the CLASS prefix rule (every directive_v1_reference_*)\n * → else null (DirectiveRender's own tier: the\n * side-effect card, then the floor)\n *\n * THE PREFIX RULE is Arman's routing-language ruling made real: registering\n * `reference` once gives EVERY enrolled noun a renderer for free; a custom\n * renderer for one slug overrides it; a brand-new server noun renders with\n * ZERO client edits. Hosts register their bespoke renderers (reference chips,\n * plan trees) here; the package supplies the side-effect card and the floor.\n */\n\nimport type { ComponentType } from \"react\";\nimport {\n type DecodedDirective,\n type DirectiveClass,\n buildDirectiveSlug,\n} from \"@ai-matrx/content-ir\";\n\nexport interface DirectiveRendererProps {\n /** The decoded two-key shell — slug, class, noun, items, position law. */\n directive: DecodedDirective;\n}\n\nexport type DirectiveRenderer = ComponentType<DirectiveRendererProps>;\n\n// REGISTRY ON A globalThis SLOT — never module-level Maps. With `splitting:\n// false` dual ESM/CJS output this module is duplicated into the root bundle and\n// the `./directives` bundle, and a host registering a renderer through one\n// graph must be visible to a card rendering through the other.\nconst REGISTRY_SLOT = Symbol.for(\"ai-matrx.content-ir-react.directive-renderers\");\ninterface Registry {\n bySlug: Map<string, DirectiveRenderer>;\n byClass: Map<DirectiveClass, DirectiveRenderer>;\n}\ntype RegistryHolder = typeof globalThis & { [REGISTRY_SLOT]?: Registry };\nconst registry: Registry = ((globalThis as RegistryHolder)[REGISTRY_SLOT] ??= {\n bySlug: new Map(),\n byClass: new Map(),\n});\n\n/**\n * Register a renderer for a whole CLASS (the prefix rule), or for one exact\n * `(class, noun)` pair, which wins. `noun` is passed as a noun, never a\n * hand-typed slug: the slug is BUILT by the grammar, so a registration whose\n * slug could not be parsed back is unconstructable rather than unreachable.\n */\nexport function registerDirectiveRenderer(\n directiveClass: DirectiveClass,\n renderer: DirectiveRenderer,\n noun?: string,\n): void {\n if (noun) registry.bySlug.set(buildDirectiveSlug(directiveClass, noun), renderer);\n else registry.byClass.set(directiveClass, renderer);\n}\n\n/** The renderer for a slug: exact → class prefix rule → null. */\nexport function getDirectiveRenderer(\n directive: Pick<DecodedDirective, \"slug\" | \"directiveClass\">,\n): DirectiveRenderer | null {\n return (\n registry.bySlug.get(directive.slug) ?? registry.byClass.get(directive.directiveClass) ?? null\n );\n}\n\n/** Tests only. */\nexport function resetDirectiveRenderers(): void {\n registry.bySlug.clear();\n registry.byClass.clear();\n}\n","\"use client\";\n\n/**\n * \"Apply\" for a side-effect Kind Directive that arrived as CONTENT.\n *\n * THE POSITION RULE, honoured exactly: a directive inside content NEVER\n * auto-executes — that is the guard against untrusted content mutating things.\n * But \"does not auto-execute\" was never \"is inert\": the user seeing it must be\n * able to say yes. This button IS that yes, through the host's `confirm` seam\n * (`POST /directives/confirm`, re-validated server-side, run as the user).\n *\n * No `confirm` seam → NO button. A control that cannot do its job is absent,\n * never dead. Only a side-effect class is applicable at all (`parsed.executes`).\n */\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { DecodedDirective } from \"@ai-matrx/content-ir\";\nimport { useDirectiveHost } from \"./directive-host\";\nimport { AlertIcon, CheckCircleIcon, LoaderIcon, PlayIcon } from \"./icons\";\n\ntype ApplyState =\n | { status: \"idle\" }\n | { status: \"applying\" }\n | { status: \"applied\"; applied: number; failed: number }\n | { status: \"error\"; message: string };\n\nexport interface ApplyDirectiveButtonProps {\n directive: DecodedDirective;\n label?: string;\n /** How many things this will write — shown during the wait so a long apply reads as work, not a frozen spinner. */\n itemCount?: number;\n onApplied?: () => void;\n}\n\nexport function ApplyDirectiveButton({\n directive,\n label = \"Apply\",\n itemCount,\n onApplied,\n}: ApplyDirectiveButtonProps) {\n const host = useDirectiveHost();\n const [state, setState] = useState<ApplyState>({ status: \"idle\" });\n const [elapsed, setElapsed] = useState(0);\n const startedAt = useRef<number | null>(null);\n\n // An honest clock beats a fake progress bar.\n useEffect(() => {\n if (state.status !== \"applying\") return;\n startedAt.current = Date.now();\n const id = setInterval(\n () => setElapsed(Math.round((Date.now() - (startedAt.current ?? 0)) / 1000)),\n 1000,\n );\n return () => clearInterval(id);\n }, [state.status]);\n\n if (!directive.parsed.executes) return null;\n const confirm = host.confirm;\n if (!confirm) return null;\n\n const items = directive.items;\n\n async function handleApply() {\n if (!confirm) return;\n setState({ status: \"applying\" });\n try {\n const result = await confirm({ __kind: directive.slug, items });\n setState({ status: \"applied\", applied: result.applied, failed: result.failed });\n onApplied?.();\n } catch (error) {\n setState({\n status: \"error\",\n message:\n error instanceof Error && error.message\n ? error.message\n : \"That couldn't be applied just now. Please try again.\",\n });\n }\n }\n\n if (state.status === \"applied\") {\n const bad = state.failed > 0;\n return (\n <span\n className={`inline-flex items-center gap-1 text-xs ${bad ? \"text-destructive\" : \"text-primary\"}`}\n >\n {bad ? <AlertIcon className=\"h-3.5 w-3.5\" /> : <CheckCircleIcon className=\"h-3.5 w-3.5\" />}\n Applied {state.applied}\n {bad ? ` · ${state.failed} failed` : \"\"}\n </span>\n );\n }\n\n return (\n <span className=\"inline-flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => void handleApply()}\n disabled={state.status === \"applying\" || items.length === 0}\n 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\"\n >\n {state.status === \"applying\" ? (\n <LoaderIcon className=\"h-3.5 w-3.5 animate-spin\" />\n ) : (\n <PlayIcon className=\"h-3.5 w-3.5\" />\n )}\n {state.status === \"applying\"\n ? `Applying${itemCount ? ` ${itemCount} ${itemCount === 1 ? \"item\" : \"items\"}` : \"\"}…${elapsed ? ` ${elapsed}s` : \"\"}`\n : label}\n </button>\n {state.status === \"error\" ? (\n <span className=\"inline-flex max-w-sm items-start gap-1 text-xs text-destructive\">\n <AlertIcon className=\"mt-0.5 h-3.5 w-3.5 shrink-0\" />\n <span>{state.message}</span>\n </span>\n ) : null}\n </span>\n );\n}\n\nexport default ApplyDirectiveButton;\n","/**\n * The handful of glyphs the directive cards need, as inline SVG. This package\n * depends on no icon library (see the FEATURE boundary); the paths are the\n * Lucide set's (ISC), so the cards look identical to a Lucide-using host.\n */\n\nimport type { ReactElement, SVGProps } from \"react\";\n\ntype IconProps = SVGProps<SVGSVGElement>;\n\nfunction Svg({ children, ...props }: IconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n {...props}\n >\n {children}\n </svg>\n );\n}\n\nexport const FilePlusIcon = (p: IconProps) => (\n <Svg {...p}>\n <path d=\"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4\" />\n <path d=\"M14 2v4a2 2 0 0 0 2 2h4\" />\n <path d=\"M3 15h6\" />\n <path d=\"M6 12v6\" />\n </Svg>\n);\nexport const PencilIcon = (p: IconProps) => (\n <Svg {...p}>\n <path d=\"M12 20h9\" />\n <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\" />\n </Svg>\n);\nexport const TrashIcon = (p: IconProps) => (\n <Svg {...p}>\n <path d=\"M3 6h18\" />\n <path d=\"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6\" />\n <path d=\"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2\" />\n <line x1=\"10\" x2=\"10\" y1=\"11\" y2=\"17\" />\n <line x1=\"14\" x2=\"14\" y1=\"11\" y2=\"17\" />\n </Svg>\n);\nexport const PlayIcon = (p: IconProps) => (\n <Svg {...p}>\n <polygon points=\"6 3 20 12 6 21 6 3\" />\n </Svg>\n);\nexport const WebhookIcon = (p: IconProps) => (\n <Svg {...p}>\n <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\" />\n <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\" />\n <path d=\"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8\" />\n </Svg>\n);\nexport const BoxesIcon = (p: IconProps) => (\n <Svg {...p}>\n <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\" />\n <path d=\"m7 16.5-4.74-2.85\" />\n <path d=\"m7 16.5 5-3\" />\n <path d=\"M7 16.5v5.17\" />\n <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\" />\n <path d=\"m17 16.5-5-3\" />\n <path d=\"m17 16.5 4.74-2.85\" />\n <path d=\"M17 16.5v5.17\" />\n <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\" />\n <path d=\"M12 8 7.26 5.15\" />\n <path d=\"m12 8 4.74-2.85\" />\n <path d=\"M12 13.5V8\" />\n </Svg>\n);\nexport const ChevronDownIcon = (p: IconProps) => (\n <Svg {...p}>\n <path d=\"m6 9 6 6 6-6\" />\n </Svg>\n);\nexport const ChevronRightIcon = (p: IconProps) => (\n <Svg {...p}>\n <path d=\"m9 18 6-6-6-6\" />\n </Svg>\n);\nexport const MaximizeIcon = (p: IconProps) => (\n <Svg {...p}>\n <polyline points=\"15 3 21 3 21 9\" />\n <polyline points=\"9 21 3 21 3 15\" />\n <line x1=\"21\" x2=\"14\" y1=\"3\" y2=\"10\" />\n <line x1=\"3\" x2=\"10\" y1=\"21\" y2=\"14\" />\n </Svg>\n);\nexport const LoaderIcon = (p: IconProps) => (\n <Svg {...p}>\n <path d=\"M21 12a9 9 0 1 1-6.219-8.56\" />\n </Svg>\n);\nexport const CheckCircleIcon = (p: IconProps) => (\n <Svg {...p}>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"m9 12 2 2 4-4\" />\n </Svg>\n);\nexport const AlertIcon = (p: IconProps) => (\n <Svg {...p}>\n <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\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n </Svg>\n);\n\n/**\n * The icon for a side-effect directive card. THE CLASS LEADS: on a card whose\n * job is \"authorize this write\", the first thing to see is whether this\n * CREATES, CHANGES, or DELETES. A noun override exists only where the platform\n * has a settled visual identity for the thing — agents are a Webhook.\n */\nconst AGENT_NOUNS = new Set([\"create_agent\", \"create_agent_definition\", \"agent\"]);\n\nexport function classIcon(directiveClass: string, noun: string): (p: IconProps) => ReactElement {\n if (directiveClass === \"action\" && AGENT_NOUNS.has(noun)) return WebhookIcon;\n switch (directiveClass) {\n case \"create\":\n return FilePlusIcon;\n case \"update\":\n return PencilIcon;\n case \"delete\":\n return TrashIcon;\n default:\n return PlayIcon;\n }\n}\n","\"use client\";\n\n/**\n * The card for a SIDE-EFFECT directive in content — create / update / delete /\n * action. One card for every shape the server can register, so a person is\n * never asked to approve a write they cannot identify.\n *\n * WHY IT EXISTS (Arman, 2026-08-26): the floor it replaced gave \"a name and\n * then an apply button, which essentially tells the user to click apply and\n * conduct a potentially destructive action without any clue as to what this\n * thing is.\"\n *\n * THE DESIGN:\n * - Say what it IS, from authority — the catalog's own words for the title,\n * the noun's title column for each item, never a guess.\n * - Facts, not prose — a few scalar chips; nesting goes to the panel.\n * - Read before you approve — `View` opens the item through the host's seam,\n * which wraps the item's OWN kind component (THE DIRECTIVE⇄KIND SEAM).\n * - Copy is table stakes, at the batch and at the item (host chrome).\n * - Apply stays exactly where it was — the host's confirm seam.\n *\n * NEVER RETURNS NULL — a shape with no items degrades to a stated line.\n */\n\nimport { useState } from \"react\";\nimport {\n asKindInstance,\n directiveDisplay,\n itemFacts,\n itemSubtitle,\n itemTitle,\n nounTitleColumn,\n type DecodedDirective,\n} from \"@ai-matrx/content-ir\";\nimport { ApplyDirectiveButton } from \"./ApplyDirectiveButton\";\nimport { useDirectiveHost } from \"./directive-host\";\nimport { ChevronDownIcon, ChevronRightIcon, MaximizeIcon, classIcon } from \"./icons\";\n\nexport interface SideEffectDirectiveCardProps {\n directive: DecodedDirective;\n}\n\n/** How many items render as rows before the rest collapse behind a toggle. */\nconst ROWS_BEFORE_FOLD = 3;\n\nfunction ItemRow({\n directive,\n item,\n index,\n total,\n}: {\n directive: DecodedDirective;\n item: Record<string, unknown>;\n index: number;\n total: number;\n}) {\n const host = useDirectiveHost();\n const titleColumn = nounTitleColumn(directive.noun, host.nouns);\n const title = itemTitle(item, titleColumn, index, total);\n const subtitle = itemSubtitle(item);\n const facts = itemFacts(item);\n const kind = host.itemKind?.(directive.slug) ?? null;\n const display = directiveDisplay(directive.directiveClass, directive.noun, host.nouns);\n const openItem = host.openItem;\n\n const body = (\n <>\n {/* THE IDENTITY WINS THE SPACE: the title keeps its intrinsic width and the facts give way. */}\n <span className=\"min-w-0 shrink-0 truncate font-medium text-foreground\">{title}</span>\n <span className=\"hidden min-w-0 flex-1 items-baseline gap-2 overflow-hidden sm:flex\">\n {facts.map((fact) => (\n <span key={fact.key} className=\"truncate text-[11px] text-muted-foreground\">\n {fact.value} {fact.label}\n </span>\n ))}\n </span>\n {subtitle && facts.length === 0 ? (\n <span className=\"hidden truncate text-[11px] text-muted-foreground sm:inline\">{subtitle}</span>\n ) : null}\n {openItem ? (\n <MaximizeIcon className=\"ml-auto h-3 w-3 shrink-0 text-muted-foreground\" />\n ) : null}\n </>\n );\n\n return (\n <div className=\"flex items-center gap-2 py-1 text-xs\">\n {openItem ? (\n <button\n type=\"button\"\n onClick={() =>\n openItem({\n // Stamped so the panel's kind pipeline types it from its own first key.\n item: asKindInstance(item, kind) ?? item,\n itemKind: kind,\n title,\n subtitle: `${display.title} · item ${index + 1} of ${total}`,\n directive,\n index,\n total,\n })\n }\n 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\"\n title=\"Open to read it\"\n >\n {body}\n </button>\n ) : (\n <span className=\"flex min-w-0 flex-1 items-center gap-2 px-1 py-0.5\">{body}</span>\n )}\n {host.renderCopy?.({ label: title, value: item, kind, size: \"xs\" })}\n </div>\n );\n}\n\nexport function SideEffectDirectiveCard({ directive }: SideEffectDirectiveCardProps) {\n const host = useDirectiveHost();\n const [expanded, setExpanded] = useState(false);\n const items = directive.items;\n const total = items.length;\n const display = directiveDisplay(directive.directiveClass, directive.noun, host.nouns);\n const Icon = classIcon(directive.directiveClass, directive.noun);\n\n const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);\n const hidden = total - shown.length;\n\n return (\n <div className=\"my-3 rounded-md border border-border bg-card px-2.5 py-1.5\" data-directive={directive.slug}>\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <Icon className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"text-sm font-medium text-foreground\">{display.title}</span>\n {display.family ? <span className=\"text-xs text-muted-foreground\">{display.family}</span> : null}\n <span className=\"text-xs tabular-nums text-muted-foreground\">\n {total} {total === 1 ? \"item\" : \"items\"}\n </span>\n <div className=\"ml-auto flex items-center gap-1\">\n {host.renderCopy?.({ label: display.title, value: directive.shell, size: \"icon\" })}\n <ApplyDirectiveButton directive={directive} itemCount={total} />\n </div>\n </div>\n\n {total === 0 ? (\n // Stated, never silent: an empty batch is a real (and suspicious) state.\n <p className=\"mt-1 text-xs text-muted-foreground\">No items — nothing would be written.</p>\n ) : (\n <div className=\"mt-0.5 divide-y divide-border/60\">\n {shown.map((item, i) => (\n <ItemRow key={i} directive={directive} item={item} index={i} total={total} />\n ))}\n </div>\n )}\n\n {hidden > 0 || expanded ? (\n <button\n type=\"button\"\n onClick={() => setExpanded((v) => !v)}\n className=\"mt-0.5 inline-flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:text-foreground\"\n >\n {expanded ? <ChevronDownIcon className=\"h-3 w-3\" /> : <ChevronRightIcon className=\"h-3 w-3\" />}\n {expanded ? \"Show less\" : `Show ${hidden} more`}\n </button>\n ) : null}\n </div>\n );\n}\n\nexport default SideEffectDirectiveCard;\n","\"use client\";\n\n/**\n * The neutral \"we could not render this, but we will NEVER hide it\" card —\n * THE PREFIX FLOOR of the Kind Directives route.\n *\n * THE RULE THIS ENFORCES: a registered directive renderer must never return\n * `null`. `DirectiveRender` renders a renderer's output verbatim, so a `null`\n * deletes the assistant's whole message block (2026-07-26: a 70KB content plan\n * vanished exactly that way). When a renderer cannot draw its rich view, it\n * renders THIS instead: named by class and noun, itemised by count, with Apply\n * when the class is a side effect and the host can apply.\n */\n\nimport { directiveDisplay, type DecodedDirective } from \"@ai-matrx/content-ir\";\nimport { ApplyDirectiveButton } from \"./ApplyDirectiveButton\";\nimport { useDirectiveHost } from \"./directive-host\";\nimport { BoxesIcon } from \"./icons\";\n\nexport interface DirectiveFallbackCardProps {\n directive: DecodedDirective;\n /** Short, human explanation of why the rich renderer degraded. */\n reason?: string;\n}\n\nexport function DirectiveFallbackCard({ directive, reason }: DirectiveFallbackCardProps) {\n const host = useDirectiveHost();\n const count = directive.items.length;\n const display = directiveDisplay(directive.directiveClass, directive.noun, host.nouns);\n return (\n <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\">\n <BoxesIcon className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"text-foreground\">{display.title}</span>\n {display.family ? <span className=\"text-muted-foreground\">· {display.family}</span> : null}\n <span className=\"text-muted-foreground\">\n · {count} {count === 1 ? \"item\" : \"items\"}\n </span>\n {reason ? <span className=\"text-muted-foreground\">· {reason}</span> : null}\n <ApplyDirectiveButton directive={directive} />\n </div>\n );\n}\n\nexport default DirectiveFallbackCard;\n","\"use client\";\n\n/**\n * DirectiveRender — THE renderer for anything whose `__kind` is a reserved\n * directive slug, on every AI Matrx UI.\n *\n * Pipeline (one pipeline, mirroring the backend):\n * 1. `tryDecodeDirectiveContent` → the two-key shell (a stored 4-key fence is\n * translated inside the decoder). Not a directive (bad JSON / no reserved\n * `__kind`) → raw <pre>, never throws. An unhonourable shell is REPORTED\n * through the host and falls to raw — a render seam must not take a whole\n * message block down over one fence, and must never go silent.\n * 2. `getDirectiveRenderer` → exact slug, else the CLASS prefix rule (the\n * host's registrations). Found → render it.\n * 3. THE SIDE-EFFECT TIER — every create / update / delete / action shape\n * renders the side-effect card, so a person is never asked to approve a\n * write they cannot identify.\n * 4. THE FLOOR — a class nothing registers still shows the fallback card.\n * Never null, never silent.\n *\n * Position decides capability: in content only `reference`/`secret` resolve;\n * a side-effect directive in prose is a card with an explicit Apply, never\n * executed on sight.\n */\n\nimport { tryDecodeDirectiveContent } from \"@ai-matrx/content-ir\";\nimport { useDirectiveHost } from \"./directive-host\";\nimport { DirectiveFallbackCard } from \"./DirectiveFallbackCard\";\nimport { getDirectiveRenderer } from \"./registry\";\nimport { SideEffectDirectiveCard } from \"./SideEffectDirectiveCard\";\n\nexport interface DirectiveRenderProps {\n /** The fence body (JSON string) or an already-parsed shell / value. */\n content: unknown;\n className?: string;\n}\n\nexport function DirectiveRender({ content, className }: DirectiveRenderProps) {\n const host = useDirectiveHost();\n const directive = tryDecodeDirectiveContent(content, (message) => {\n const line = `[kind-directives] ${message}`;\n if (host.reportError) host.reportError(line);\n else console.error(line);\n });\n\n if (!directive) {\n const raw = typeof content === \"string\" ? content : JSON.stringify(content, null, 2);\n return (\n <pre\n className={`my-3 overflow-x-auto rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground${className ? ` ${className}` : \"\"}`}\n >\n {raw}\n </pre>\n );\n }\n\n const Renderer = getDirectiveRenderer(directive);\n if (Renderer) return <Renderer directive={directive} />;\n if (directive.parsed.executes) return <SideEffectDirectiveCard directive={directive} />;\n return <DirectiveFallbackCard directive={directive} />;\n}\n\nexport default DirectiveRender;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBA,mBAA0D;AA8DjD;AART,IAAM,2BAAuB,4BAAoC,IAAI;AAO9D,SAAS,sBAAsB,EAAE,MAAM,SAAS,GAA+B;AACpF,SAAO,4CAAC,qBAAqB,UAArB,EAA8B,OAAO,MAAO,UAAS;AAC/D;AAEA,IAAM,aAA4B,CAAC;AAO5B,SAAS,mBAAkC;AAChD,aAAO,yBAAW,oBAAoB,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;AAAA,iDAAC,aAAU,WAAU,8CAA6C;AAAA,IAClE,6CAAC,UAAK,WAAU,mBAAmB,kBAAQ,OAAM;AAAA,IAChD,QAAQ,SAAS,8CAAC,UAAK,WAAU,yBAAwB;AAAA;AAAA,MAAG,QAAQ;AAAA,OAAO,IAAU;AAAA,IACtF,8CAAC,UAAK,WAAU,yBAAwB;AAAA;AAAA,MACnC;AAAA,MAAM;AAAA,MAAE,UAAU,IAAI,SAAS;AAAA,OACpC;AAAA,IACC,SAAS,8CAAC,UAAK,WAAU,yBAAwB;AAAA;AAAA,MAAG;AAAA,OAAO,IAAU;AAAA,IACtE,6CAAC,wBAAqB,WAAsB;AAAA,KAC9C;AAEJ;;;AChBA,IAAAC,qBAA0C;AAuBpC,IAAAC,sBAAA;AAXC,SAAS,gBAAgB,EAAE,SAAS,UAAU,GAAyB;AAC5E,QAAM,OAAO,iBAAiB;AAC9B,QAAM,gBAAY,8CAA0B,SAAS,CAAC,YAAY;AAChE,UAAM,OAAO,qBAAqB,OAAO;AACzC,QAAI,KAAK,YAAa,MAAK,YAAY,IAAI;AAAA,QACtC,SAAQ,MAAM,IAAI;AAAA,EACzB,CAAC;AAED,MAAI,CAAC,WAAW;AACd,UAAM,MAAM,OAAO,YAAY,WAAW,UAAU,KAAK,UAAU,SAAS,MAAM,CAAC;AACnF,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,wGAAwG,YAAY,IAAI,SAAS,KAAK,EAAE;AAAA,QAElJ;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,QAAM,WAAW,qBAAqB,SAAS;AAC/C,MAAI,SAAU,QAAO,6CAAC,YAAS,WAAsB;AACrD,MAAI,UAAU,OAAO,SAAU,QAAO,6CAAC,2BAAwB,WAAsB;AACrF,SAAO,6CAAC,yBAAsB,WAAsB;AACtD;","names":["import_react","import_jsx_runtime","import_jsx_runtime","import_react","import_content_ir","import_jsx_runtime","import_content_ir","import_jsx_runtime","import_content_ir","import_jsx_runtime"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export { D as DirectiveApplyResult, a as DirectiveCopyProps, b as DirectiveHost, c as DirectiveHostProvider, d as DirectiveHostProviderProps, e as DirectiveOpenItemOptions, u as useDirectiveHost } from './directive-host-DAb7Keg8.cjs';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ComponentType } from 'react';
|
|
4
|
+
import { DecodedDirective, DirectiveClass } from '@ai-matrx/content-ir';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Kind Directives — the renderer registry, and THE PREFIX TIER.
|
|
8
|
+
*
|
|
9
|
+
* A directive IS a kind instance, so the renderer for one is resolved from its
|
|
10
|
+
* SLUG, in the same shape the kind component resolver uses:
|
|
11
|
+
*
|
|
12
|
+
* getDirectiveRenderer(directive)
|
|
13
|
+
* → an exact-slug renderer (directive_v1_action_plan_tree)
|
|
14
|
+
* → else the CLASS prefix rule (every directive_v1_reference_*)
|
|
15
|
+
* → else null (DirectiveRender's own tier: the
|
|
16
|
+
* side-effect card, then the floor)
|
|
17
|
+
*
|
|
18
|
+
* THE PREFIX RULE is Arman's routing-language ruling made real: registering
|
|
19
|
+
* `reference` once gives EVERY enrolled noun a renderer for free; a custom
|
|
20
|
+
* renderer for one slug overrides it; a brand-new server noun renders with
|
|
21
|
+
* ZERO client edits. Hosts register their bespoke renderers (reference chips,
|
|
22
|
+
* plan trees) here; the package supplies the side-effect card and the floor.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
interface DirectiveRendererProps {
|
|
26
|
+
/** The decoded two-key shell — slug, class, noun, items, position law. */
|
|
27
|
+
directive: DecodedDirective;
|
|
28
|
+
}
|
|
29
|
+
type DirectiveRenderer = ComponentType<DirectiveRendererProps>;
|
|
30
|
+
/**
|
|
31
|
+
* Register a renderer for a whole CLASS (the prefix rule), or for one exact
|
|
32
|
+
* `(class, noun)` pair, which wins. `noun` is passed as a noun, never a
|
|
33
|
+
* hand-typed slug: the slug is BUILT by the grammar, so a registration whose
|
|
34
|
+
* slug could not be parsed back is unconstructable rather than unreachable.
|
|
35
|
+
*/
|
|
36
|
+
declare function registerDirectiveRenderer(directiveClass: DirectiveClass, renderer: DirectiveRenderer, noun?: string): void;
|
|
37
|
+
/** The renderer for a slug: exact → class prefix rule → null. */
|
|
38
|
+
declare function getDirectiveRenderer(directive: Pick<DecodedDirective, "slug" | "directiveClass">): DirectiveRenderer | null;
|
|
39
|
+
/** Tests only. */
|
|
40
|
+
declare function resetDirectiveRenderers(): void;
|
|
41
|
+
|
|
42
|
+
interface ApplyDirectiveButtonProps {
|
|
43
|
+
directive: DecodedDirective;
|
|
44
|
+
label?: string;
|
|
45
|
+
/** How many things this will write — shown during the wait so a long apply reads as work, not a frozen spinner. */
|
|
46
|
+
itemCount?: number;
|
|
47
|
+
onApplied?: () => void;
|
|
48
|
+
}
|
|
49
|
+
declare function ApplyDirectiveButton({ directive, label, itemCount, onApplied, }: ApplyDirectiveButtonProps): react.JSX.Element | null;
|
|
50
|
+
|
|
51
|
+
interface SideEffectDirectiveCardProps {
|
|
52
|
+
directive: DecodedDirective;
|
|
53
|
+
}
|
|
54
|
+
declare function SideEffectDirectiveCard({ directive }: SideEffectDirectiveCardProps): react.JSX.Element;
|
|
55
|
+
|
|
56
|
+
interface DirectiveFallbackCardProps {
|
|
57
|
+
directive: DecodedDirective;
|
|
58
|
+
/** Short, human explanation of why the rich renderer degraded. */
|
|
59
|
+
reason?: string;
|
|
60
|
+
}
|
|
61
|
+
declare function DirectiveFallbackCard({ directive, reason }: DirectiveFallbackCardProps): react.JSX.Element;
|
|
62
|
+
|
|
63
|
+
interface DirectiveRenderProps {
|
|
64
|
+
/** The fence body (JSON string) or an already-parsed shell / value. */
|
|
65
|
+
content: unknown;
|
|
66
|
+
className?: string;
|
|
67
|
+
}
|
|
68
|
+
declare function DirectiveRender({ content, className }: DirectiveRenderProps): react.JSX.Element;
|
|
69
|
+
|
|
70
|
+
export { ApplyDirectiveButton, type ApplyDirectiveButtonProps, DirectiveFallbackCard, type DirectiveFallbackCardProps, DirectiveRender, type DirectiveRenderProps, type DirectiveRenderer, type DirectiveRendererProps, SideEffectDirectiveCard, type SideEffectDirectiveCardProps, getDirectiveRenderer, registerDirectiveRenderer, resetDirectiveRenderers };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export { D as DirectiveApplyResult, a as DirectiveCopyProps, b as DirectiveHost, c as DirectiveHostProvider, d as DirectiveHostProviderProps, e as DirectiveOpenItemOptions, u as useDirectiveHost } from './directive-host-DAb7Keg8.js';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ComponentType } from 'react';
|
|
4
|
+
import { DecodedDirective, DirectiveClass } from '@ai-matrx/content-ir';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Kind Directives — the renderer registry, and THE PREFIX TIER.
|
|
8
|
+
*
|
|
9
|
+
* A directive IS a kind instance, so the renderer for one is resolved from its
|
|
10
|
+
* SLUG, in the same shape the kind component resolver uses:
|
|
11
|
+
*
|
|
12
|
+
* getDirectiveRenderer(directive)
|
|
13
|
+
* → an exact-slug renderer (directive_v1_action_plan_tree)
|
|
14
|
+
* → else the CLASS prefix rule (every directive_v1_reference_*)
|
|
15
|
+
* → else null (DirectiveRender's own tier: the
|
|
16
|
+
* side-effect card, then the floor)
|
|
17
|
+
*
|
|
18
|
+
* THE PREFIX RULE is Arman's routing-language ruling made real: registering
|
|
19
|
+
* `reference` once gives EVERY enrolled noun a renderer for free; a custom
|
|
20
|
+
* renderer for one slug overrides it; a brand-new server noun renders with
|
|
21
|
+
* ZERO client edits. Hosts register their bespoke renderers (reference chips,
|
|
22
|
+
* plan trees) here; the package supplies the side-effect card and the floor.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
interface DirectiveRendererProps {
|
|
26
|
+
/** The decoded two-key shell — slug, class, noun, items, position law. */
|
|
27
|
+
directive: DecodedDirective;
|
|
28
|
+
}
|
|
29
|
+
type DirectiveRenderer = ComponentType<DirectiveRendererProps>;
|
|
30
|
+
/**
|
|
31
|
+
* Register a renderer for a whole CLASS (the prefix rule), or for one exact
|
|
32
|
+
* `(class, noun)` pair, which wins. `noun` is passed as a noun, never a
|
|
33
|
+
* hand-typed slug: the slug is BUILT by the grammar, so a registration whose
|
|
34
|
+
* slug could not be parsed back is unconstructable rather than unreachable.
|
|
35
|
+
*/
|
|
36
|
+
declare function registerDirectiveRenderer(directiveClass: DirectiveClass, renderer: DirectiveRenderer, noun?: string): void;
|
|
37
|
+
/** The renderer for a slug: exact → class prefix rule → null. */
|
|
38
|
+
declare function getDirectiveRenderer(directive: Pick<DecodedDirective, "slug" | "directiveClass">): DirectiveRenderer | null;
|
|
39
|
+
/** Tests only. */
|
|
40
|
+
declare function resetDirectiveRenderers(): void;
|
|
41
|
+
|
|
42
|
+
interface ApplyDirectiveButtonProps {
|
|
43
|
+
directive: DecodedDirective;
|
|
44
|
+
label?: string;
|
|
45
|
+
/** How many things this will write — shown during the wait so a long apply reads as work, not a frozen spinner. */
|
|
46
|
+
itemCount?: number;
|
|
47
|
+
onApplied?: () => void;
|
|
48
|
+
}
|
|
49
|
+
declare function ApplyDirectiveButton({ directive, label, itemCount, onApplied, }: ApplyDirectiveButtonProps): react.JSX.Element | null;
|
|
50
|
+
|
|
51
|
+
interface SideEffectDirectiveCardProps {
|
|
52
|
+
directive: DecodedDirective;
|
|
53
|
+
}
|
|
54
|
+
declare function SideEffectDirectiveCard({ directive }: SideEffectDirectiveCardProps): react.JSX.Element;
|
|
55
|
+
|
|
56
|
+
interface DirectiveFallbackCardProps {
|
|
57
|
+
directive: DecodedDirective;
|
|
58
|
+
/** Short, human explanation of why the rich renderer degraded. */
|
|
59
|
+
reason?: string;
|
|
60
|
+
}
|
|
61
|
+
declare function DirectiveFallbackCard({ directive, reason }: DirectiveFallbackCardProps): react.JSX.Element;
|
|
62
|
+
|
|
63
|
+
interface DirectiveRenderProps {
|
|
64
|
+
/** The fence body (JSON string) or an already-parsed shell / value. */
|
|
65
|
+
content: unknown;
|
|
66
|
+
className?: string;
|
|
67
|
+
}
|
|
68
|
+
declare function DirectiveRender({ content, className }: DirectiveRenderProps): react.JSX.Element;
|
|
69
|
+
|
|
70
|
+
export { ApplyDirectiveButton, type ApplyDirectiveButtonProps, DirectiveFallbackCard, type DirectiveFallbackCardProps, DirectiveRender, type DirectiveRenderProps, type DirectiveRenderer, type DirectiveRendererProps, SideEffectDirectiveCard, type SideEffectDirectiveCardProps, getDirectiveRenderer, registerDirectiveRenderer, resetDirectiveRenderers };
|