@ai-matrx/content-ir-react 0.11.10 → 0.11.11
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 +22 -0
- package/dist/directives.cjs +60 -7
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +22 -2
- package/dist/directives.d.ts +22 -2
- package/dist/directives.js +60 -7
- package/dist/directives.js.map +1 -1
- package/dist/index.cjs +128 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +107 -54
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +127 -76
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +105 -54
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -115,10 +115,10 @@ function useContentIrKindVersion(kind, sources) {
|
|
|
115
115
|
|
|
116
116
|
// react/KindInstanceRender.tsx
|
|
117
117
|
var import_react6 = require("react");
|
|
118
|
-
var
|
|
118
|
+
var import_content_ir7 = require("@ai-matrx/content-ir");
|
|
119
119
|
|
|
120
120
|
// directives/DirectiveRender.tsx
|
|
121
|
-
var
|
|
121
|
+
var import_content_ir5 = require("@ai-matrx/content-ir");
|
|
122
122
|
|
|
123
123
|
// directives/DirectiveFallbackCard.tsx
|
|
124
124
|
var import_content_ir = require("@ai-matrx/content-ir");
|
|
@@ -317,8 +317,48 @@ function DirectiveFallbackCard({ directive, reason }) {
|
|
|
317
317
|
] });
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
// directives/
|
|
320
|
+
// directives/DirectiveProvisionalCard.tsx
|
|
321
321
|
var import_content_ir2 = require("@ai-matrx/content-ir");
|
|
322
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
323
|
+
var COMPLETE_SLUG_RE = /^\{\s*"__kind"\s*:\s*"([^"]+)"/;
|
|
324
|
+
function provisionalDirectiveSlug(content) {
|
|
325
|
+
const match = content.trimStart().match(COMPLETE_SLUG_RE);
|
|
326
|
+
return match?.[1] ?? null;
|
|
327
|
+
}
|
|
328
|
+
function DirectiveProvisionalCard({ content, streaming, className }) {
|
|
329
|
+
const host = useDirectiveHost();
|
|
330
|
+
const slug = provisionalDirectiveSlug(content);
|
|
331
|
+
const known = slug ? (0, import_content_ir2.parseDirectiveSlug)(slug) : null;
|
|
332
|
+
const display = known ? (0, import_content_ir2.directiveDisplay)(known.directiveClass, known.noun, host.nouns) : null;
|
|
333
|
+
const Icon = known ? classIcon(known.directiveClass, known.noun) : BoxesIcon;
|
|
334
|
+
const title = display?.title ?? "Structured action";
|
|
335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
336
|
+
"div",
|
|
337
|
+
{
|
|
338
|
+
className: `my-3 rounded-md border border-border bg-card px-2.5 py-1.5${className ? ` ${className}` : ""}`,
|
|
339
|
+
"data-directive": slug ?? void 0,
|
|
340
|
+
"data-directive-state": streaming ? "streaming" : "incomplete",
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
343
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
344
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-sm font-medium text-foreground", children: title }),
|
|
345
|
+
display?.family ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-xs text-muted-foreground", children: display.family }) : null,
|
|
346
|
+
streaming ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", role: "status", children: [
|
|
347
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-primary", "aria-hidden": true }),
|
|
348
|
+
"Writing\u2026"
|
|
349
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-xs text-destructive", role: "status", children: "Cut off before it finished \u2014 nothing can be applied." })
|
|
350
|
+
] }),
|
|
351
|
+
streaming ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("details", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
352
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("summary", { className: "cursor-pointer select-none hover:text-foreground", children: "Show what arrived" }),
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("pre", { className: "mt-1 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded bg-muted px-2 py-1 text-[11px]", children: content })
|
|
354
|
+
] })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// directives/registry.ts
|
|
361
|
+
var import_content_ir3 = require("@ai-matrx/content-ir");
|
|
322
362
|
var REGISTRY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.content-ir-react.directive-renderers");
|
|
323
363
|
var registry = globalThis[REGISTRY_SLOT] ??= {
|
|
324
364
|
bySlug: /* @__PURE__ */ new Map(),
|
|
@@ -330,8 +370,8 @@ function getDirectiveRenderer(directive) {
|
|
|
330
370
|
|
|
331
371
|
// directives/SideEffectDirectiveCard.tsx
|
|
332
372
|
var import_react5 = require("react");
|
|
333
|
-
var
|
|
334
|
-
var
|
|
373
|
+
var import_content_ir4 = require("@ai-matrx/content-ir");
|
|
374
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
335
375
|
var ROWS_BEFORE_FOLD = 3;
|
|
336
376
|
function ItemRow({
|
|
337
377
|
directive,
|
|
@@ -340,31 +380,31 @@ function ItemRow({
|
|
|
340
380
|
total
|
|
341
381
|
}) {
|
|
342
382
|
const host = useDirectiveHost();
|
|
343
|
-
const titleColumn = (0,
|
|
344
|
-
const title = (0,
|
|
345
|
-
const subtitle = (0,
|
|
346
|
-
const facts = (0,
|
|
383
|
+
const titleColumn = (0, import_content_ir4.nounTitleColumn)(directive.noun, host.nouns);
|
|
384
|
+
const title = (0, import_content_ir4.itemTitle)(item, titleColumn, index, total);
|
|
385
|
+
const subtitle = (0, import_content_ir4.itemSubtitle)(item);
|
|
386
|
+
const facts = (0, import_content_ir4.itemFacts)(item);
|
|
347
387
|
const kind = host.itemKind?.(directive.slug) ?? null;
|
|
348
|
-
const display = (0,
|
|
388
|
+
const display = (0, import_content_ir4.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
349
389
|
const openItem = host.openItem;
|
|
350
|
-
const body = /* @__PURE__ */ (0,
|
|
351
|
-
/* @__PURE__ */ (0,
|
|
352
|
-
/* @__PURE__ */ (0,
|
|
390
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "min-w-0 shrink-0 truncate font-medium text-foreground", children: title }),
|
|
392
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.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_runtime7.jsxs)("span", { className: "truncate text-[11px] text-muted-foreground", children: [
|
|
353
393
|
fact.value,
|
|
354
394
|
" ",
|
|
355
395
|
fact.label
|
|
356
396
|
] }, fact.key)) }),
|
|
357
|
-
subtitle && facts.length === 0 ? /* @__PURE__ */ (0,
|
|
358
|
-
openItem ? /* @__PURE__ */ (0,
|
|
397
|
+
subtitle && facts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hidden truncate text-[11px] text-muted-foreground sm:inline", children: subtitle }) : null,
|
|
398
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MaximizeIcon, { className: "ml-auto h-3 w-3 shrink-0 text-muted-foreground" }) : null
|
|
359
399
|
] });
|
|
360
|
-
return /* @__PURE__ */ (0,
|
|
361
|
-
openItem ? /* @__PURE__ */ (0,
|
|
400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2 py-1 text-xs", children: [
|
|
401
|
+
openItem ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
362
402
|
"button",
|
|
363
403
|
{
|
|
364
404
|
type: "button",
|
|
365
405
|
onClick: () => openItem({
|
|
366
406
|
// Stamped so the panel's kind pipeline types it from its own first key.
|
|
367
|
-
item: (0,
|
|
407
|
+
item: (0, import_content_ir4.asKindInstance)(item, kind) ?? item,
|
|
368
408
|
itemKind: kind,
|
|
369
409
|
title,
|
|
370
410
|
subtitle: `${display.title} \xB7 item ${index + 1} of ${total}`,
|
|
@@ -376,7 +416,7 @@ function ItemRow({
|
|
|
376
416
|
title: "Open to read it",
|
|
377
417
|
children: body
|
|
378
418
|
}
|
|
379
|
-
) : /* @__PURE__ */ (0,
|
|
419
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "flex min-w-0 flex-1 items-center gap-2 px-1 py-0.5", children: body }),
|
|
380
420
|
host.renderCopy?.({ label: title, value: item, kind, size: "xs" })
|
|
381
421
|
] });
|
|
382
422
|
}
|
|
@@ -385,37 +425,37 @@ function SideEffectDirectiveCard({ directive }) {
|
|
|
385
425
|
const [expanded, setExpanded] = (0, import_react5.useState)(false);
|
|
386
426
|
const items = directive.items;
|
|
387
427
|
const total = items.length;
|
|
388
|
-
const display = (0,
|
|
428
|
+
const display = (0, import_content_ir4.directiveDisplay)(directive.directiveClass, directive.noun, host.nouns);
|
|
389
429
|
const Icon = classIcon(directive.directiveClass, directive.noun);
|
|
390
430
|
const shown = expanded ? items : items.slice(0, ROWS_BEFORE_FOLD);
|
|
391
431
|
const hidden = total - shown.length;
|
|
392
|
-
return /* @__PURE__ */ (0,
|
|
393
|
-
/* @__PURE__ */ (0,
|
|
394
|
-
/* @__PURE__ */ (0,
|
|
395
|
-
/* @__PURE__ */ (0,
|
|
396
|
-
display.family ? /* @__PURE__ */ (0,
|
|
397
|
-
/* @__PURE__ */ (0,
|
|
432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "my-3 rounded-md border border-border bg-card px-2.5 py-1.5", "data-directive": directive.slug, children: [
|
|
433
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
434
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
435
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-sm font-medium text-foreground", children: display.title }),
|
|
436
|
+
display.family ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-xs text-muted-foreground", children: display.family }) : null,
|
|
437
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "text-xs tabular-nums text-muted-foreground", children: [
|
|
398
438
|
total,
|
|
399
439
|
" ",
|
|
400
440
|
total === 1 ? "item" : "items"
|
|
401
441
|
] }),
|
|
402
|
-
/* @__PURE__ */ (0,
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "ml-auto flex items-center gap-1", children: [
|
|
403
443
|
host.renderCopy?.({ label: display.title, value: directive.shell, size: "icon" }),
|
|
404
|
-
/* @__PURE__ */ (0,
|
|
444
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ApplyDirectiveButton, { directive, itemCount: total })
|
|
405
445
|
] })
|
|
406
446
|
] }),
|
|
407
447
|
total === 0 ? (
|
|
408
448
|
// Stated, never silent: an empty batch is a real (and suspicious) state.
|
|
409
|
-
/* @__PURE__ */ (0,
|
|
410
|
-
) : /* @__PURE__ */ (0,
|
|
411
|
-
hidden > 0 || expanded ? /* @__PURE__ */ (0,
|
|
449
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "mt-1 text-xs text-muted-foreground", children: "No items \u2014 nothing would be written." })
|
|
450
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mt-0.5 divide-y divide-border/60", children: shown.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ItemRow, { directive, item, index: i, total }, i)) }),
|
|
451
|
+
hidden > 0 || expanded ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
412
452
|
"button",
|
|
413
453
|
{
|
|
414
454
|
type: "button",
|
|
415
455
|
onClick: () => setExpanded((v) => !v),
|
|
416
456
|
className: "mt-0.5 inline-flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",
|
|
417
457
|
children: [
|
|
418
|
-
expanded ? /* @__PURE__ */ (0,
|
|
458
|
+
expanded ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronRightIcon, { className: "h-3 w-3" }),
|
|
419
459
|
expanded ? "Show less" : `Show ${hidden} more`
|
|
420
460
|
]
|
|
421
461
|
}
|
|
@@ -424,17 +464,28 @@ function SideEffectDirectiveCard({ directive }) {
|
|
|
424
464
|
}
|
|
425
465
|
|
|
426
466
|
// directives/DirectiveRender.tsx
|
|
427
|
-
var
|
|
428
|
-
function
|
|
467
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
468
|
+
function isWholeJson(content) {
|
|
469
|
+
try {
|
|
470
|
+
JSON.parse(content);
|
|
471
|
+
return true;
|
|
472
|
+
} catch {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function DirectiveRender({ content, className, streaming }) {
|
|
429
477
|
const host = useDirectiveHost();
|
|
430
|
-
const directive = (0,
|
|
478
|
+
const directive = (0, import_content_ir5.tryDecodeDirectiveContent)(content, (message) => {
|
|
431
479
|
const line = `[kind-directives] ${message}`;
|
|
432
480
|
if (host.reportError) host.reportError(line);
|
|
433
481
|
else console.error(line);
|
|
434
482
|
});
|
|
435
483
|
if (!directive) {
|
|
484
|
+
if (typeof content === "string" && (0, import_content_ir5.looksLikeDirectiveHead)(content) && !isWholeJson(content)) {
|
|
485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DirectiveProvisionalCard, { content, streaming: streaming !== false, className });
|
|
486
|
+
}
|
|
436
487
|
const raw = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
437
|
-
return /* @__PURE__ */ (0,
|
|
488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
438
489
|
"pre",
|
|
439
490
|
{
|
|
440
491
|
className: `my-3 overflow-x-auto rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground${className ? ` ${className}` : ""}`,
|
|
@@ -443,13 +494,13 @@ function DirectiveRender({ content, className }) {
|
|
|
443
494
|
);
|
|
444
495
|
}
|
|
445
496
|
const Renderer = getDirectiveRenderer(directive);
|
|
446
|
-
if (Renderer) return /* @__PURE__ */ (0,
|
|
447
|
-
if (directive.parsed.executes) return /* @__PURE__ */ (0,
|
|
448
|
-
return /* @__PURE__ */ (0,
|
|
497
|
+
if (Renderer) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Renderer, { directive });
|
|
498
|
+
if (directive.parsed.executes) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SideEffectDirectiveCard, { directive });
|
|
499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DirectiveFallbackCard, { directive });
|
|
449
500
|
}
|
|
450
501
|
|
|
451
502
|
// route/kind-route.ts
|
|
452
|
-
var
|
|
503
|
+
var import_content_ir6 = require("@ai-matrx/content-ir");
|
|
453
504
|
var IR_ROUTE_KEY = "__ir_route";
|
|
454
505
|
var GENERIC_STRUCTURED_COMPONENT_KEY = "generic_structured";
|
|
455
506
|
var SOURCELESS_DB_ROW_SLOT = /* @__PURE__ */ Symbol.for(
|
|
@@ -468,20 +519,20 @@ function readIrRouteMarker(metadata) {
|
|
|
468
519
|
}
|
|
469
520
|
|
|
470
521
|
// react/KindInstanceRender.tsx
|
|
471
|
-
var
|
|
522
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
472
523
|
function isRecordValue(value) {
|
|
473
524
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
474
525
|
}
|
|
475
526
|
function kindIsRoutable(kind, host) {
|
|
476
|
-
if ((0,
|
|
527
|
+
if ((0, import_content_ir7.isReservedDirectiveSlug)(kind)) return true;
|
|
477
528
|
if (host.kinds.getDefinition(kind)?.legacyBlockType) return true;
|
|
478
529
|
const resolution = host.components.resolve(kind, host.platform, "output");
|
|
479
530
|
if (!resolution?.isActive) return false;
|
|
480
531
|
return resolution.componentKey !== GENERIC_STRUCTURED_COMPONENT_KEY;
|
|
481
532
|
}
|
|
482
533
|
function KindInstanceRender(props) {
|
|
483
|
-
if ((0,
|
|
484
|
-
return /* @__PURE__ */ (0,
|
|
534
|
+
if ((0, import_content_ir7.isReservedDirectiveSlug)(props.kind)) {
|
|
535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
485
536
|
DirectiveRender,
|
|
486
537
|
{
|
|
487
538
|
content: props.value,
|
|
@@ -489,7 +540,7 @@ function KindInstanceRender(props) {
|
|
|
489
540
|
}
|
|
490
541
|
);
|
|
491
542
|
}
|
|
492
|
-
return /* @__PURE__ */ (0,
|
|
543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(KindInstanceRenderInner, { ...props });
|
|
493
544
|
}
|
|
494
545
|
function KindInstanceRenderInner({
|
|
495
546
|
kind,
|
|
@@ -535,18 +586,18 @@ function KindInstanceRenderInner({
|
|
|
535
586
|
content: JSON.stringify(value, null, 2),
|
|
536
587
|
language: "json",
|
|
537
588
|
metadata: {
|
|
538
|
-
[
|
|
589
|
+
[import_content_ir7.IR_ENVELOPE_KEY]: (0, import_content_ir7.envelopeFromCompleteValue)(value, kind)
|
|
539
590
|
}
|
|
540
591
|
} : null;
|
|
541
592
|
const frameClass = variant === "bare" ? void 0 : "rounded-md border border-border bg-card p-3";
|
|
542
593
|
if (routingStatus === "unroutable" && unroutableFallback !== void 0) {
|
|
543
|
-
return /* @__PURE__ */ (0,
|
|
594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: unroutableFallback });
|
|
544
595
|
}
|
|
545
596
|
const onTheFloor = block === null || routingStatus === "unroutable";
|
|
546
597
|
const notice = "This shape has no custom component yet, so it renders through the universal viewer \u2014 exactly what production shows today.";
|
|
547
|
-
return /* @__PURE__ */ (0,
|
|
548
|
-
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0,
|
|
549
|
-
/* @__PURE__ */ (0,
|
|
598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: className ? `space-y-3 ${className}` : "space-y-3", children: [
|
|
599
|
+
showRoutingNote && routingStatus === "unroutable" ? host.renderNotice?.(notice) ?? /* @__PURE__ */ (0, import_jsx_runtime9.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,
|
|
600
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: frameClass, children: onTheFloor ? host.renderValue({ value, kind }) : host.renderBlock(block) })
|
|
550
601
|
] });
|
|
551
602
|
}
|
|
552
603
|
|
|
@@ -554,7 +605,7 @@ function KindInstanceRenderInner({
|
|
|
554
605
|
var import_react7 = __toESM(require("react"), 1);
|
|
555
606
|
|
|
556
607
|
// route/partial-kind-route.ts
|
|
557
|
-
var
|
|
608
|
+
var import_content_ir8 = require("@ai-matrx/content-ir");
|
|
558
609
|
var PARTIAL_UNSAFE_SLOT = /* @__PURE__ */ Symbol.for(
|
|
559
610
|
"ai-matrx.content-ir-react.partial-unsafe-kinds"
|
|
560
611
|
);
|
|
@@ -564,7 +615,7 @@ function markKindPartialUnsafe(kind) {
|
|
|
564
615
|
}
|
|
565
616
|
|
|
566
617
|
// react/ProvisionalKindBoundary.tsx
|
|
567
|
-
var
|
|
618
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
568
619
|
var ProvisionalKindBoundaryInner = class extends import_react7.default.Component {
|
|
569
620
|
state = { failed: false };
|
|
570
621
|
static getDerivedStateFromError() {
|
|
@@ -589,25 +640,25 @@ var ProvisionalKindBoundaryInner = class extends import_react7.default.Component
|
|
|
589
640
|
};
|
|
590
641
|
function ProvisionalKindBoundary(props) {
|
|
591
642
|
const host = useContentIrHost();
|
|
592
|
-
return /* @__PURE__ */ (0,
|
|
643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ProvisionalKindBoundaryInner, { ...props, reportError: host.reportError });
|
|
593
644
|
}
|
|
594
645
|
function ProvisionalKindFrame({ children }) {
|
|
595
646
|
const host = useContentIrHost();
|
|
596
647
|
const label = "Still arriving";
|
|
597
|
-
return /* @__PURE__ */ (0,
|
|
648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "relative", "aria-busy": "true", children: [
|
|
598
649
|
children,
|
|
599
|
-
/* @__PURE__ */ (0,
|
|
650
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.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_runtime10.jsx)("span", { className: "text-[10px] text-muted-foreground", children: label }) })
|
|
600
651
|
] });
|
|
601
652
|
}
|
|
602
653
|
|
|
603
654
|
// react/GenericStructuredView.tsx
|
|
604
655
|
var import_react8 = require("react");
|
|
605
|
-
var
|
|
606
|
-
var
|
|
656
|
+
var import_content_ir9 = require("@ai-matrx/content-ir");
|
|
657
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
607
658
|
function readStructuredValue(content, metadata) {
|
|
608
|
-
const envelope = (0,
|
|
659
|
+
const envelope = (0, import_content_ir9.readEnvelope)(metadata);
|
|
609
660
|
if (envelope) {
|
|
610
|
-
return { value: (0,
|
|
661
|
+
return { value: (0, import_content_ir9.reconstructRegionValue)(envelope), recovered: true };
|
|
611
662
|
}
|
|
612
663
|
try {
|
|
613
664
|
return { value: JSON.parse(content), recovered: true };
|
|
@@ -622,25 +673,25 @@ function GenericStructuredView({
|
|
|
622
673
|
className
|
|
623
674
|
}) {
|
|
624
675
|
const host = useContentIrHost();
|
|
625
|
-
const envelope = (0,
|
|
676
|
+
const envelope = (0, import_content_ir9.readEnvelope)(metadata);
|
|
626
677
|
const status = envelope?.root.status ?? "complete";
|
|
627
678
|
const { value, recovered } = readStructuredValue(content, metadata);
|
|
628
|
-
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0,
|
|
679
|
+
const kind = envelope?.root.kind ?? (typeof value === "object" && value !== null && !Array.isArray(value) ? (0, import_content_ir9.readObjectKind)(value) : null) ?? "";
|
|
629
680
|
const marker = readIrRouteMarker(metadata);
|
|
630
681
|
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";
|
|
631
|
-
return /* @__PURE__ */ (0,
|
|
632
|
-
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0,
|
|
682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: className ? `my-2 min-w-0 ${className}` : "my-2 min-w-0", children: [
|
|
683
|
+
status === "streaming" ? streamingIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "mb-2 text-xs text-muted-foreground", children: "Still arriving\u2026" }) : null,
|
|
633
684
|
recovered ? host.renderValue({ value, ...kind ? { kind } : {}, note }) : (
|
|
634
685
|
// Zero-data-loss backstop: the region never parsed, so show the source
|
|
635
686
|
// verbatim rather than swallowing it.
|
|
636
|
-
/* @__PURE__ */ (0,
|
|
687
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("pre", { className: "max-h-96 overflow-auto font-mono text-xs leading-relaxed text-muted-foreground", children: content })
|
|
637
688
|
)
|
|
638
689
|
] });
|
|
639
690
|
}
|
|
640
691
|
|
|
641
692
|
// react/RuntimeWrapperViews.tsx
|
|
642
|
-
var
|
|
643
|
-
var
|
|
693
|
+
var import_content_ir10 = require("@ai-matrx/content-ir");
|
|
694
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
644
695
|
function isRecord2(value) {
|
|
645
696
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
646
697
|
}
|
|
@@ -656,16 +707,16 @@ function DelegatedOutput({
|
|
|
656
707
|
}) {
|
|
657
708
|
const host = useContentIrHost();
|
|
658
709
|
if (output === null || output === void 0) {
|
|
659
|
-
return /* @__PURE__ */ (0,
|
|
710
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyLabel });
|
|
660
711
|
}
|
|
661
712
|
if (!isRecord2(output)) {
|
|
662
|
-
return /* @__PURE__ */ (0,
|
|
713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: host.renderValue({ value: output }) });
|
|
663
714
|
}
|
|
664
|
-
const kind = (0,
|
|
715
|
+
const kind = (0, import_content_ir10.readObjectKind)(output) ?? declaredKind;
|
|
665
716
|
if (!kind) {
|
|
666
|
-
return /* @__PURE__ */ (0,
|
|
717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: fallback?.(output) ?? host.renderValue({ value: output }) });
|
|
667
718
|
}
|
|
668
|
-
return /* @__PURE__ */ (0,
|
|
719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
669
720
|
KindInstanceRender,
|
|
670
721
|
{
|
|
671
722
|
kind,
|
|
@@ -679,10 +730,10 @@ function DelegatedOutput({
|
|
|
679
730
|
function NodeOutcomeView({ serverData, fallback }) {
|
|
680
731
|
const wrapper = readWrapperFrom(
|
|
681
732
|
serverData,
|
|
682
|
-
|
|
733
|
+
import_content_ir10.readNodeOutcomeValue
|
|
683
734
|
);
|
|
684
735
|
if (!wrapper) return null;
|
|
685
|
-
return /* @__PURE__ */ (0,
|
|
736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
686
737
|
DelegatedOutput,
|
|
687
738
|
{
|
|
688
739
|
output: wrapper.output,
|
|
@@ -694,17 +745,17 @@ function NodeOutcomeView({ serverData, fallback }) {
|
|
|
694
745
|
function RunResultView({ serverData, fallback }) {
|
|
695
746
|
const wrapper = readWrapperFrom(
|
|
696
747
|
serverData,
|
|
697
|
-
|
|
748
|
+
import_content_ir10.readRunResultValue
|
|
698
749
|
);
|
|
699
750
|
if (!wrapper) return null;
|
|
700
|
-
return /* @__PURE__ */ (0,
|
|
751
|
+
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)(
|
|
701
752
|
NodeOutcomeView,
|
|
702
753
|
{
|
|
703
754
|
serverData: { wrapper: outcome },
|
|
704
755
|
...fallback === void 0 ? {} : { fallback }
|
|
705
756
|
},
|
|
706
757
|
`${outcome.node_id}:${outcome.attempt}`
|
|
707
|
-
)) : /* @__PURE__ */ (0,
|
|
758
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
708
759
|
DelegatedOutput,
|
|
709
760
|
{
|
|
710
761
|
output: wrapper.output,
|