@ai-matrx/content-ir-react 0.11.11 → 0.12.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.
- package/CHANGELOG.md +26 -0
- package/dist/directive-host-Bl-ZgJWp.d.cts +116 -0
- package/dist/directive-host-Bl-ZgJWp.d.ts +116 -0
- package/dist/directives.cjs +164 -23
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +43 -2
- package/dist/directives.d.ts +43 -2
- package/dist/directives.js +149 -7
- package/dist/directives.js.map +1 -1
- package/dist/{host-types-C8jR31Wk.d.cts → host-types-BgROpyjE.d.cts} +1 -1
- package/dist/{host-types-IUEDmso7.d.ts → host-types-Cz-1pGHz.d.ts} +1 -1
- package/dist/host.cjs.map +1 -1
- package/dist/host.d.cts +3 -3
- package/dist/host.d.ts +3 -3
- package/dist/host.js.map +1 -1
- package/dist/index.cjs +179 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -3
- package/dist/index.d.ts +44 -3
- package/dist/index.js +149 -7
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +174 -39
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +143 -7
- package/dist/react.js.map +1 -1
- package/dist/{route-B9U-9QCw.d.cts → route-DxK1SoPh.d.cts} +54 -1
- package/dist/{route-gNpJ8zzW.d.ts → route-JGZfl2nL.d.ts} +54 -1
- package/dist/route.d.cts +1 -1
- package/dist/route.d.ts +1 -1
- package/package.json +1 -1
- package/dist/directive-host-DAb7Keg8.d.cts +0 -63
- package/dist/directive-host-DAb7Keg8.d.ts +0 -63
package/dist/react.cjs
CHANGED
|
@@ -115,16 +115,73 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
115
115
|
|
|
116
116
|
// react/KindInstanceRender.tsx
|
|
117
117
|
var import_react6 = require("react");
|
|
118
|
-
var
|
|
118
|
+
var import_content_ir8 = require("@ai-matrx/content-ir");
|
|
119
119
|
|
|
120
120
|
// directives/DirectiveRender.tsx
|
|
121
|
-
var
|
|
121
|
+
var import_content_ir6 = require("@ai-matrx/content-ir");
|
|
122
122
|
|
|
123
123
|
// directives/DirectiveFallbackCard.tsx
|
|
124
|
-
var
|
|
124
|
+
var import_content_ir2 = require("@ai-matrx/content-ir");
|
|
125
125
|
|
|
126
126
|
// directives/ApplyDirectiveButton.tsx
|
|
127
127
|
var import_react4 = require("react");
|
|
128
|
+
var import_content_ir = require("@ai-matrx/content-ir");
|
|
129
|
+
|
|
130
|
+
// directives/item-changes.ts
|
|
131
|
+
var TARGETING_CLASSES = /* @__PURE__ */ new Set(["update", "delete"]);
|
|
132
|
+
var NOT_A_CHANGE = /* @__PURE__ */ new Set(["__kind", "id"]);
|
|
133
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
134
|
+
var CHANGE_VALUE_MAX = 60;
|
|
135
|
+
function itemRecordId(item) {
|
|
136
|
+
const id = item.id;
|
|
137
|
+
if (typeof id === "string" && id.trim()) return id.trim();
|
|
138
|
+
if (typeof id === "number") return String(id);
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function fieldLabel(key) {
|
|
142
|
+
const spaced = key.replace(/_/g, " ").trim();
|
|
143
|
+
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
|
144
|
+
}
|
|
145
|
+
function recordFallbackName(nounLabel3, id) {
|
|
146
|
+
const short = UUID_RE.test(id) ? id.slice(0, 8) : id.length > 12 ? `${id.slice(0, 12)}\u2026` : id;
|
|
147
|
+
return `${nounLabel3} ${short}`;
|
|
148
|
+
}
|
|
149
|
+
function describeValue(value) {
|
|
150
|
+
if (value === null || value === void 0) return { value: "cleared", full: "cleared", clears: true };
|
|
151
|
+
if (typeof value === "string") {
|
|
152
|
+
const trimmed = value.trim();
|
|
153
|
+
if (!trimmed) return { value: "cleared", full: "cleared", clears: true };
|
|
154
|
+
const oneLine = trimmed.replace(/\s+/g, " ");
|
|
155
|
+
const shown = oneLine.length > CHANGE_VALUE_MAX ? `${oneLine.slice(0, CHANGE_VALUE_MAX - 1)}\u2026` : oneLine;
|
|
156
|
+
return { value: shown, full: trimmed, clears: false };
|
|
157
|
+
}
|
|
158
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
159
|
+
return { value: String(value), full: String(value), clears: false };
|
|
160
|
+
}
|
|
161
|
+
if (Array.isArray(value)) {
|
|
162
|
+
const n2 = value.length;
|
|
163
|
+
const text2 = n2 === 0 ? "cleared" : `${n2} ${n2 === 1 ? "entry" : "entries"}`;
|
|
164
|
+
return { value: text2, full: safeJson(value), clears: n2 === 0 };
|
|
165
|
+
}
|
|
166
|
+
const n = Object.keys(value).length;
|
|
167
|
+
const text = n === 0 ? "cleared" : `${n} ${n === 1 ? "field" : "fields"}`;
|
|
168
|
+
return { value: text, full: safeJson(value), clears: n === 0 };
|
|
169
|
+
}
|
|
170
|
+
function safeJson(value) {
|
|
171
|
+
try {
|
|
172
|
+
return JSON.stringify(value, null, 2);
|
|
173
|
+
} catch {
|
|
174
|
+
return String(value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function itemChanges(item) {
|
|
178
|
+
const out = [];
|
|
179
|
+
for (const [key, raw] of Object.entries(item)) {
|
|
180
|
+
if (NOT_A_CHANGE.has(key)) continue;
|
|
181
|
+
out.push({ key, label: fieldLabel(key), ...describeValue(raw) });
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
128
185
|
|
|
129
186
|
// directives/icons.tsx
|
|
130
187
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -242,10 +299,38 @@ function ApplyDirectiveButton({
|
|
|
242
299
|
const items = directive.items;
|
|
243
300
|
async function handleApply() {
|
|
244
301
|
if (!confirm) return;
|
|
302
|
+
if (host.ask) {
|
|
303
|
+
setState({ status: "asking" });
|
|
304
|
+
let ok = false;
|
|
305
|
+
try {
|
|
306
|
+
ok = await host.ask({
|
|
307
|
+
directive,
|
|
308
|
+
items,
|
|
309
|
+
nounLabel: (0, import_content_ir.nounLabel)(directive.noun, host.nouns)
|
|
310
|
+
});
|
|
311
|
+
} catch (error) {
|
|
312
|
+
setState({
|
|
313
|
+
status: "error",
|
|
314
|
+
message: error instanceof Error && error.message ? error.message : "We could not ask you to confirm this, so nothing was done."
|
|
315
|
+
});
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (!ok) {
|
|
319
|
+
setState({ status: "idle" });
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
setElapsed(0);
|
|
245
324
|
setState({ status: "applying" });
|
|
246
325
|
try {
|
|
247
326
|
const result = await confirm({ __kind: directive.slug, items });
|
|
248
|
-
setState({
|
|
327
|
+
setState({
|
|
328
|
+
status: "applied",
|
|
329
|
+
applied: result.applied,
|
|
330
|
+
failed: result.failed,
|
|
331
|
+
message: result.message?.trim() ? result.message.trim() : null,
|
|
332
|
+
records: result.records ?? []
|
|
333
|
+
});
|
|
249
334
|
onApplied?.();
|
|
250
335
|
} catch (error) {
|
|
251
336
|
setState({
|
|
@@ -256,15 +341,26 @@ function ApplyDirectiveButton({
|
|
|
256
341
|
}
|
|
257
342
|
if (state.status === "applied") {
|
|
258
343
|
const bad = state.failed > 0;
|
|
344
|
+
const trashed = directive.directiveClass === "delete";
|
|
345
|
+
const label2 = (0, import_content_ir.nounLabel)(directive.noun, host.nouns);
|
|
346
|
+
const records = host.renderRecord ? state.records : [];
|
|
259
347
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
260
348
|
"span",
|
|
261
349
|
{
|
|
262
|
-
className: `inline-flex items-center gap-1 text-xs ${bad ? "text-destructive" : "text-primary"}`,
|
|
350
|
+
className: `inline-flex min-w-0 flex-wrap items-center gap-1 text-xs ${bad ? "text-destructive" : "text-primary"}`,
|
|
351
|
+
"data-apply-state": "applied",
|
|
263
352
|
children: [
|
|
264
|
-
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" }),
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
353
|
+
bad ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AlertIcon, { className: "h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckCircleIcon, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
354
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
355
|
+
state.message ?? `Applied ${state.applied}`,
|
|
356
|
+
bad && !state.message ? ` \xB7 ${state.failed} failed` : ""
|
|
357
|
+
] }),
|
|
358
|
+
records.map((record) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "inline-flex min-w-0 items-center", children: host.renderRecord?.({
|
|
359
|
+
...record,
|
|
360
|
+
fallback: recordFallbackName(label2, record.id),
|
|
361
|
+
context: "applied",
|
|
362
|
+
trashed
|
|
363
|
+
}) }, `${record.noun}:${record.id}`))
|
|
268
364
|
]
|
|
269
365
|
}
|
|
270
366
|
);
|
|
@@ -275,7 +371,7 @@ function ApplyDirectiveButton({
|
|
|
275
371
|
{
|
|
276
372
|
type: "button",
|
|
277
373
|
onClick: () => void handleApply(),
|
|
278
|
-
disabled: state.status === "applying" || items.length === 0,
|
|
374
|
+
disabled: state.status === "applying" || state.status === "asking" || items.length === 0,
|
|
279
375
|
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",
|
|
280
376
|
children: [
|
|
281
377
|
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" }),
|
|
@@ -295,7 +391,7 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
|
295
391
|
function DirectiveFallbackCard({ directive, reason }) {
|
|
296
392
|
const host = useDirectiveHost();
|
|
297
393
|
const count = directive.items.length;
|
|
298
|
-
const display = (0,
|
|
394
|
+
const display = (0, import_content_ir2.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
299
395
|
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: [
|
|
300
396
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BoxesIcon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
301
397
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-foreground", children: display.title }),
|
|
@@ -318,7 +414,7 @@ function DirectiveFallbackCard({ directive, reason }) {
|
|
|
318
414
|
}
|
|
319
415
|
|
|
320
416
|
// directives/DirectiveProvisionalCard.tsx
|
|
321
|
-
var
|
|
417
|
+
var import_content_ir3 = require("@ai-matrx/content-ir");
|
|
322
418
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
323
419
|
var COMPLETE_SLUG_RE = /^\{\s*"__kind"\s*:\s*"([^"]+)"/;
|
|
324
420
|
function provisionalDirectiveSlug(content) {
|
|
@@ -328,8 +424,8 @@ function provisionalDirectiveSlug(content) {
|
|
|
328
424
|
function DirectiveProvisionalCard({ content, streaming, className }) {
|
|
329
425
|
const host = useDirectiveHost();
|
|
330
426
|
const slug = provisionalDirectiveSlug(content);
|
|
331
|
-
const known = slug ? (0,
|
|
332
|
-
const display = known ? (0,
|
|
427
|
+
const known = slug ? (0, import_content_ir3.parseDirectiveSlug)(slug) : null;
|
|
428
|
+
const display = known ? (0, import_content_ir3.directiveDisplay)(known.directiveClass, known.noun, host.nouns) : null;
|
|
333
429
|
const Icon = known ? classIcon(known.directiveClass, known.noun) : BoxesIcon;
|
|
334
430
|
const title = display?.title ?? "Structured action";
|
|
335
431
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
@@ -358,7 +454,7 @@ function DirectiveProvisionalCard({ content, streaming, className }) {
|
|
|
358
454
|
}
|
|
359
455
|
|
|
360
456
|
// directives/registry.ts
|
|
361
|
-
var
|
|
457
|
+
var import_content_ir4 = require("@ai-matrx/content-ir");
|
|
362
458
|
var REGISTRY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir-react.directive-renderers");
|
|
363
459
|
var registry = globalThis[REGISTRY_SLOT] ??= {
|
|
364
460
|
bySlug: /* @__PURE__ */ new Map(),
|
|
@@ -370,7 +466,7 @@ function getDirectiveRenderer(directive) {
|
|
|
370
466
|
|
|
371
467
|
// directives/SideEffectDirectiveCard.tsx
|
|
372
468
|
var import_react5 = require("react");
|
|
373
|
-
var
|
|
469
|
+
var import_content_ir5 = require("@ai-matrx/content-ir");
|
|
374
470
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
375
471
|
var ROWS_BEFORE_FOLD = 3;
|
|
376
472
|
function ItemRow({
|
|
@@ -380,12 +476,16 @@ function ItemRow({
|
|
|
380
476
|
total
|
|
381
477
|
}) {
|
|
382
478
|
const host = useDirectiveHost();
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
479
|
+
const recordId = TARGETING_CLASSES.has(directive.directiveClass) ? itemRecordId(item) : null;
|
|
480
|
+
if (recordId) {
|
|
481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TargetRow, { directive, item, recordId });
|
|
482
|
+
}
|
|
483
|
+
const titleColumn = (0, import_content_ir5.nounTitleColumn)(directive.noun, host.nouns);
|
|
484
|
+
const title = (0, import_content_ir5.itemTitle)(item, titleColumn, index, total);
|
|
485
|
+
const subtitle = (0, import_content_ir5.itemSubtitle)(item);
|
|
486
|
+
const facts = (0, import_content_ir5.itemFacts)(item);
|
|
387
487
|
const kind = host.itemKind?.(directive.slug) ?? null;
|
|
388
|
-
const display = (0,
|
|
488
|
+
const display = (0, import_content_ir5.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
389
489
|
const openItem = host.openItem;
|
|
390
490
|
const body = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
391
491
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
|
|
@@ -404,7 +504,7 @@ function ItemRow({
|
|
|
404
504
|
type: "button",
|
|
405
505
|
onClick: () => openItem({
|
|
406
506
|
// Stamped so the panel's kind pipeline types it from its own first key.
|
|
407
|
-
item: (0,
|
|
507
|
+
item: (0, import_content_ir5.asKindInstance)(item, kind) ?? item,
|
|
408
508
|
itemKind: kind,
|
|
409
509
|
title,
|
|
410
510
|
subtitle: `${display.title} \xB7 item ${index + 1} of ${total}`,
|
|
@@ -420,12 +520,47 @@ function ItemRow({
|
|
|
420
520
|
host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
|
|
421
521
|
] });
|
|
422
522
|
}
|
|
523
|
+
function TargetRow({
|
|
524
|
+
directive,
|
|
525
|
+
item,
|
|
526
|
+
recordId
|
|
527
|
+
}) {
|
|
528
|
+
const host = useDirectiveHost();
|
|
529
|
+
const fallback = recordFallbackName((0, import_content_ir5.nounLabel)(directive.noun, host.nouns), recordId);
|
|
530
|
+
const changes = directive.directiveClass === "update" ? itemChanges(item) : [];
|
|
531
|
+
const name = host.renderRecord ? host.renderRecord({ noun: directive.noun, id: recordId, fallback, context: "row" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "truncate font-medium text-foreground", children: fallback });
|
|
532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "py-1 text-xs", "data-directive-target": recordId, children: [
|
|
533
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
534
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-1 px-1", children: name }),
|
|
535
|
+
host.renderCopy?.({ label: fallback, value: item, size: "xs" })
|
|
536
|
+
] }),
|
|
537
|
+
directive.directiveClass === "update" ? changes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "px-1 text-[11px] text-muted-foreground", children: "Sets no fields \u2014 nothing would change." }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "mt-0.5 space-y-0.5 px-1", children: changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
538
|
+
"li",
|
|
539
|
+
{
|
|
540
|
+
className: "flex min-w-0 items-baseline gap-1.5 text-[11px]",
|
|
541
|
+
title: `${change.label} \u2192 ${change.full}`,
|
|
542
|
+
children: [
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "shrink-0 text-muted-foreground", children: change.label }),
|
|
544
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": true, className: "shrink-0 text-muted-foreground", children: "\u2192" }),
|
|
545
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
546
|
+
"span",
|
|
547
|
+
{
|
|
548
|
+
className: `min-w-0 truncate ${change.clears ? "italic text-muted-foreground" : "text-foreground"}`,
|
|
549
|
+
children: change.value
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
]
|
|
553
|
+
},
|
|
554
|
+
change.key
|
|
555
|
+
)) }) : null
|
|
556
|
+
] });
|
|
557
|
+
}
|
|
423
558
|
function SideEffectDirectiveCard({ directive }) {
|
|
424
559
|
const host = useDirectiveHost();
|
|
425
560
|
const [expanded, setExpanded] = (0, import_react5.useState)(false);
|
|
426
561
|
const items = directive.items;
|
|
427
562
|
const total = items.length;
|
|
428
|
-
const display = (0,
|
|
563
|
+
const display = (0, import_content_ir5.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
429
564
|
const Icon = classIcon(directive.directiveClass, directive.noun);
|
|
430
565
|
const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
|
|
431
566
|
const hidden = total - shown.length;
|
|
@@ -475,13 +610,13 @@ function isWholeJson(content) {
|
|
|
475
610
|
}
|
|
476
611
|
function DirectiveRender({ content, className, streaming }) {
|
|
477
612
|
const host = useDirectiveHost();
|
|
478
|
-
const directive = (0,
|
|
613
|
+
const directive = (0, import_content_ir6.tryDecodeDirectiveContent)(content, (message) => {
|
|
479
614
|
const line = `[kind-directives] ${message}`;
|
|
480
615
|
if (host.reportError) host.reportError(line);
|
|
481
616
|
else console.error(line);
|
|
482
617
|
});
|
|
483
618
|
if (!directive) {
|
|
484
|
-
if (typeof content === "string" && (0,
|
|
619
|
+
if (typeof content === "string" && (0, import_content_ir6.looksLikeDirectiveHead)(content) && !isWholeJson(content)) {
|
|
485
620
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DirectiveProvisionalCard, { content, streaming: streaming !== false, className });
|
|
486
621
|
}
|
|
487
622
|
const raw = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
@@ -500,7 +635,7 @@ function DirectiveRender({ content, className, streaming }) {
|
|
|
500
635
|
}
|
|
501
636
|
|
|
502
637
|
// route/kind-route.ts
|
|
503
|
-
var
|
|
638
|
+
var import_content_ir7 = require("@ai-matrx/content-ir");
|
|
504
639
|
var IR_ROUTE_KEY = "__ir_route";
|
|
505
640
|
var GENERIC_STRUCTURED_COMPONENT_KEY = "generic_structured";
|
|
506
641
|
var SOURCELESS_DB_ROW_SLOT = /* @__PURE__ */ Symbol.for(
|
|
@@ -524,14 +659,14 @@ function isRecordValue(value) {
|
|
|
524
659
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
525
660
|
}
|
|
526
661
|
function kindIsRoutable(kind, host) {
|
|
527
|
-
if ((0,
|
|
662
|
+
if ((0, import_content_ir8.isReservedDirectiveSlug)(kind)) return true;
|
|
528
663
|
if (host.kinds.getDefinition(kind)?.legacyBlockType) return true;
|
|
529
664
|
const resolution = host.components.resolve(kind, host.platform, "output");
|
|
530
665
|
if (!resolution?.isActive) return false;
|
|
531
666
|
return resolution.componentKey !== GENERIC_STRUCTURED_COMPONENT_KEY;
|
|
532
667
|
}
|
|
533
668
|
function KindInstanceRender(props) {
|
|
534
|
-
if ((0,
|
|
669
|
+
if ((0, import_content_ir8.isReservedDirectiveSlug)(props.kind)) {
|
|
535
670
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
536
671
|
DirectiveRender,
|
|
537
672
|
{
|
|
@@ -586,7 +721,7 @@ function KindInstanceRenderInner({
|
|
|
586
721
|
content: JSON.stringify(value, null, 2),
|
|
587
722
|
language: "json",
|
|
588
723
|
metadata: {
|
|
589
|
-
[
|
|
724
|
+
[import_content_ir8.IR_ENVELOPE_KEY]: (0, import_content_ir8.envelopeFromCompleteValue)(value, kind)
|
|
590
725
|
}
|
|
591
726
|
} : null;
|
|
592
727
|
const frameClass = variant === "bare" ? void 0 : "rounded-md border border-border bg-card p-3";
|
|
@@ -605,7 +740,7 @@ function KindInstanceRenderInner({
|
|
|
605
740
|
var import_react7 = __toESM(require("react"), 1);
|
|
606
741
|
|
|
607
742
|
// route/partial-kind-route.ts
|
|
608
|
-
var
|
|
743
|
+
var import_content_ir9 = require("@ai-matrx/content-ir");
|
|
609
744
|
var PARTIAL_UNSAFE_SLOT = /* @__PURE__ */ Symbol.for(
|
|
610
745
|
"ai-matrx.content-ir-react.partial-unsafe-kinds"
|
|
611
746
|
);
|
|
@@ -653,12 +788,12 @@ function ProvisionalKindFrame({ children }) {
|
|
|
653
788
|
|
|
654
789
|
// react/GenericStructuredView.tsx
|
|
655
790
|
var import_react8 = require("react");
|
|
656
|
-
var
|
|
791
|
+
var import_content_ir10 = require("@ai-matrx/content-ir");
|
|
657
792
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
658
793
|
function readStructuredValue(content, metadata) {
|
|
659
|
-
const envelope = (0,
|
|
794
|
+
const envelope = (0, import_content_ir10.readEnvelope)(metadata);
|
|
660
795
|
if (envelope) {
|
|
661
|
-
return { value: (0,
|
|
796
|
+
return { value: (0, import_content_ir10.reconstructRegionValue)(envelope), recovered: true };
|
|
662
797
|
}
|
|
663
798
|
try {
|
|
664
799
|
return { value: JSON.parse(content), recovered: true };
|
|
@@ -673,10 +808,10 @@ function GenericStructuredView({
|
|
|
673
808
|
className
|
|
674
809
|
}) {
|
|
675
810
|
const host = useContentIrHost();
|
|
676
|
-
const envelope = (0,
|
|
811
|
+
const envelope = (0, import_content_ir10.readEnvelope)(metadata);
|
|
677
812
|
const status = envelope?.root.status ?? "complete";
|
|
678
813
|
const { value, recovered } = readStructuredValue(content, metadata);
|
|
679
|
-
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0,
|
|
814
|
+
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir10.readObjectKind)(value) : null) ?? "";
|
|
680
815
|
const marker = readIrRouteMarker(metadata);
|
|
681
816
|
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";
|
|
682
817
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
|
|
@@ -690,7 +825,7 @@ function GenericStructuredView({
|
|
|
690
825
|
}
|
|
691
826
|
|
|
692
827
|
// react/RuntimeWrapperViews.tsx
|
|
693
|
-
var
|
|
828
|
+
var import_content_ir11 = require("@ai-matrx/content-ir");
|
|
694
829
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
695
830
|
function isRecord2(value) {
|
|
696
831
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -712,7 +847,7 @@ function DelegatedOutput({
|
|
|
712
847
|
if (!isRecord2(output)) {
|
|
713
848
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: host.renderValue({ value: output }) });
|
|
714
849
|
}
|
|
715
|
-
const kind = (0,
|
|
850
|
+
const kind = (0, import_content_ir11.readObjectKind)(output) ?? declaredKind;
|
|
716
851
|
if (!kind) {
|
|
717
852
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
|
|
718
853
|
}
|
|
@@ -730,7 +865,7 @@ function DelegatedOutput({
|
|
|
730
865
|
function NodeOutcomeView({ serverData, fallback }) {
|
|
731
866
|
const wrapper = readWrapperFrom(
|
|
732
867
|
serverData,
|
|
733
|
-
|
|
868
|
+
import_content_ir11.readNodeOutcomeValue
|
|
734
869
|
);
|
|
735
870
|
if (!wrapper) return null;
|
|
736
871
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -745,7 +880,7 @@ function NodeOutcomeView({ serverData, fallback }) {
|
|
|
745
880
|
function RunResultView({ serverData, fallback }) {
|
|
746
881
|
const wrapper = readWrapperFrom(
|
|
747
882
|
serverData,
|
|
748
|
-
|
|
883
|
+
import_content_ir11.readRunResultValue
|
|
749
884
|
);
|
|
750
885
|
if (!wrapper) return null;
|
|
751
886
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "space-y-2", children: wrapper.outputs.length > 0 ? wrapper.outputs.map((outcome) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|