@ai-matrx/content-ir-react 0.14.0 → 0.15.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 +23 -0
- package/dist/{directive-host-DLp5QFI2.d.cts → directive-host-DJfF35FD.d.cts} +39 -9
- package/dist/{directive-host-DLp5QFI2.d.ts → directive-host-DJfF35FD.d.ts} +39 -9
- package/dist/directives.cjs +52 -10
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +9 -2
- package/dist/directives.d.ts +9 -2
- package/dist/directives.js +52 -10
- package/dist/directives.js.map +1 -1
- package/dist/{host-types-DHKFg06S.d.ts → host-types-9NfBeqrG.d.ts} +1 -1
- package/dist/{host-types-BpmKg07p.d.cts → host-types-DVIaaGR_.d.cts} +1 -1
- package/dist/host.cjs +1 -0
- 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 +1 -0
- package/dist/host.js.map +1 -1
- package/dist/index.cjs +51 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +51 -9
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +49 -9
- 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 +49 -9
- package/dist/react.js.map +1 -1
- package/dist/{route-Bf-kciHw.d.cts → route-BCtPhF7W.d.cts} +39 -9
- package/dist/{route-ymqupVjr.d.ts → route-DDbgc-ID.d.ts} +39 -9
- package/dist/route.d.cts +1 -1
- package/dist/route.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as ComponentResolutionSource, a as ComponentResolution, b as ContentIrErrorReporter } from './component-resolution.types-DLO2w-0n.cjs';
|
|
2
2
|
export { c as ComponentRole, d as ContentIrErrorReport, J as JsonObject, K as KindComponentRow, S as SystemComponentEntry, e as consoleErrorReporter } from './component-resolution.types-DLO2w-0n.cjs';
|
|
3
|
-
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-
|
|
4
|
-
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as DirectiveApplyState, f as DirectiveAskRequest, g as DirectiveCopyProps, h as DirectiveHost, i as DirectiveHostProvider, j as DirectiveHostProviderProps, k as DirectiveOpenItemOptions, l as DirectiveRecordProps, m as DirectiveRecordRef, G as GENERIC_STRUCTURED_COMPONENT_KEY,
|
|
3
|
+
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-BCtPhF7W.cjs';
|
|
4
|
+
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as DirectiveApplyState, f as DirectiveAskRequest, g as DirectiveCopyProps, h as DirectiveHost, i as DirectiveHostProvider, j as DirectiveHostProviderProps, k as DirectiveOpenItemOptions, l as DirectiveRecordProps, m as DirectiveRecordRef, n as DirectiveScope, o as DirectiveScopeProvider, p as DirectiveShell, G as GENERIC_STRUCTURED_COMPONENT_KEY, q as GenericFallbackReason, I as IR_PROVISIONAL_KEY, r as IR_ROUTE_KEY, s as IrRenderBlock, t as IrRoutableBlock, u as IrRouteMarker, v as KindRouteBinding, w as KindRouteOptions, P as PartialRenderOptions, x as ProvisionalKindRender, S as StructuredValueRenderProps, y as SupersededKindRender, z as applyIrKindRoute, A as createKindRouteBinding, B as envelopeFromPartialKind, E as isPartialReadyKind, F as isProvisionalBlock, H as kindServerDataFromStoredValue, J as markKindPartialUnsafe, L as readIrRouteMarker, M as resetPartialUnsafeKinds, N as resetSourcelessDbRowReports, O as resolveAnnouncedKindLoading, Q as resolveProvisionalKindRender, R as resolveSupersededKindRender, T as routeEnvOf, U as useDirectiveHost, V as useDirectiveScope } from './route-BCtPhF7W.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import react__default, { ReactNode, ComponentType } from 'react';
|
|
7
7
|
export { ComponentResolver, ComponentResolverOptions } from './resolver.cjs';
|
|
@@ -292,8 +292,15 @@ interface DirectiveRenderProps {
|
|
|
292
292
|
* OFF rather than "writing…" forever. Omitted = it may still be arriving.
|
|
293
293
|
*/
|
|
294
294
|
streaming?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* The conversation this directive renders in (a chat message). Applies and
|
|
297
|
+
* ledger reads key on it — the same namespace an agent proposal's Approve
|
|
298
|
+
* uses — so one action can never apply twice through two doors. Omit in a
|
|
299
|
+
* person's own content. Overrides any enclosing `DirectiveScopeProvider`.
|
|
300
|
+
*/
|
|
301
|
+
conversationId?: string | null;
|
|
295
302
|
}
|
|
296
|
-
declare function DirectiveRender({
|
|
303
|
+
declare function DirectiveRender({ conversationId, ...props }: DirectiveRenderProps): react.JSX.Element;
|
|
297
304
|
|
|
298
305
|
/**
|
|
299
306
|
* WHAT A DIRECTIVE ITEM WILL DO TO AN EXISTING RECORD — for the card, the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as ComponentResolutionSource, a as ComponentResolution, b as ContentIrErrorReporter } from './component-resolution.types-DLO2w-0n.js';
|
|
2
2
|
export { c as ComponentRole, d as ContentIrErrorReport, J as JsonObject, K as KindComponentRow, S as SystemComponentEntry, e as consoleErrorReporter } from './component-resolution.types-DLO2w-0n.js';
|
|
3
|
-
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-
|
|
4
|
-
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as DirectiveApplyState, f as DirectiveAskRequest, g as DirectiveCopyProps, h as DirectiveHost, i as DirectiveHostProvider, j as DirectiveHostProviderProps, k as DirectiveOpenItemOptions, l as DirectiveRecordProps, m as DirectiveRecordRef, G as GENERIC_STRUCTURED_COMPONENT_KEY,
|
|
3
|
+
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-DDbgc-ID.js';
|
|
4
|
+
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as DirectiveApplyState, f as DirectiveAskRequest, g as DirectiveCopyProps, h as DirectiveHost, i as DirectiveHostProvider, j as DirectiveHostProviderProps, k as DirectiveOpenItemOptions, l as DirectiveRecordProps, m as DirectiveRecordRef, n as DirectiveScope, o as DirectiveScopeProvider, p as DirectiveShell, G as GENERIC_STRUCTURED_COMPONENT_KEY, q as GenericFallbackReason, I as IR_PROVISIONAL_KEY, r as IR_ROUTE_KEY, s as IrRenderBlock, t as IrRoutableBlock, u as IrRouteMarker, v as KindRouteBinding, w as KindRouteOptions, P as PartialRenderOptions, x as ProvisionalKindRender, S as StructuredValueRenderProps, y as SupersededKindRender, z as applyIrKindRoute, A as createKindRouteBinding, B as envelopeFromPartialKind, E as isPartialReadyKind, F as isProvisionalBlock, H as kindServerDataFromStoredValue, J as markKindPartialUnsafe, L as readIrRouteMarker, M as resetPartialUnsafeKinds, N as resetSourcelessDbRowReports, O as resolveAnnouncedKindLoading, Q as resolveProvisionalKindRender, R as resolveSupersededKindRender, T as routeEnvOf, U as useDirectiveHost, V as useDirectiveScope } from './route-DDbgc-ID.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import react__default, { ReactNode, ComponentType } from 'react';
|
|
7
7
|
export { ComponentResolver, ComponentResolverOptions } from './resolver.js';
|
|
@@ -292,8 +292,15 @@ interface DirectiveRenderProps {
|
|
|
292
292
|
* OFF rather than "writing…" forever. Omitted = it may still be arriving.
|
|
293
293
|
*/
|
|
294
294
|
streaming?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* The conversation this directive renders in (a chat message). Applies and
|
|
297
|
+
* ledger reads key on it — the same namespace an agent proposal's Approve
|
|
298
|
+
* uses — so one action can never apply twice through two doors. Omit in a
|
|
299
|
+
* person's own content. Overrides any enclosing `DirectiveScopeProvider`.
|
|
300
|
+
*/
|
|
301
|
+
conversationId?: string | null;
|
|
295
302
|
}
|
|
296
|
-
declare function DirectiveRender({
|
|
303
|
+
declare function DirectiveRender({ conversationId, ...props }: DirectiveRenderProps): react.JSX.Element;
|
|
297
304
|
|
|
298
305
|
/**
|
|
299
306
|
* WHAT A DIRECTIVE ITEM WILL DO TO AN EXISTING RECORD — for the card, the
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,16 @@ import { createContext as createContext2, useContext as useContext2, useMemo } f
|
|
|
20
20
|
import { createContext, useContext } from "react";
|
|
21
21
|
import { jsx } from "react/jsx-runtime";
|
|
22
22
|
var DirectiveHostContext = createContext(null);
|
|
23
|
+
var DirectiveScopeContext = createContext({});
|
|
24
|
+
function DirectiveScopeProvider({
|
|
25
|
+
conversationId,
|
|
26
|
+
children
|
|
27
|
+
}) {
|
|
28
|
+
return /* @__PURE__ */ jsx(DirectiveScopeContext.Provider, { value: { conversationId: conversationId ?? null }, children });
|
|
29
|
+
}
|
|
30
|
+
function useDirectiveScope() {
|
|
31
|
+
return useContext(DirectiveScopeContext);
|
|
32
|
+
}
|
|
23
33
|
function DirectiveHostProvider({ host, children }) {
|
|
24
34
|
return /* @__PURE__ */ jsx(DirectiveHostContext.Provider, { value: host, children });
|
|
25
35
|
}
|
|
@@ -867,6 +877,10 @@ var MaximizeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
|
867
877
|
/* @__PURE__ */ jsx3("line", { x1: "3", x2: "10", y1: "21", y2: "14" })
|
|
868
878
|
] });
|
|
869
879
|
var LoaderIcon = (p) => /* @__PURE__ */ jsx3(Svg, { ...p, children: /* @__PURE__ */ jsx3("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
|
|
880
|
+
var RotateCcwIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
881
|
+
/* @__PURE__ */ jsx3("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
|
|
882
|
+
/* @__PURE__ */ jsx3("path", { d: "M3 3v5h5" })
|
|
883
|
+
] });
|
|
870
884
|
var CheckCircleIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
871
885
|
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "12", r: "10" }),
|
|
872
886
|
/* @__PURE__ */ jsx3("path", { d: "m9 12 2 2 4-4" })
|
|
@@ -902,6 +916,8 @@ function ApplyDirectiveButton({
|
|
|
902
916
|
onApplied
|
|
903
917
|
}) {
|
|
904
918
|
const host = useDirectiveHost();
|
|
919
|
+
const scope = useDirectiveScope();
|
|
920
|
+
const conversationId = scope.conversationId || void 0;
|
|
905
921
|
const items = directive.items;
|
|
906
922
|
const readsLedger = !!host.applyState && !!host.confirm && directive.parsed.executes && items.length > 0;
|
|
907
923
|
const [state, setState] = useState(
|
|
@@ -910,17 +926,19 @@ function ApplyDirectiveButton({
|
|
|
910
926
|
const [elapsed, setElapsed] = useState(0);
|
|
911
927
|
const startedAt = useRef(null);
|
|
912
928
|
const nounText = nounLabel(directive.noun, host.nouns);
|
|
913
|
-
const shellKey = readsLedger ? JSON.stringify([directive.slug, items]) : "";
|
|
929
|
+
const shellKey = readsLedger ? JSON.stringify([directive.slug, items, conversationId ?? null]) : "";
|
|
914
930
|
const read = host.applyState;
|
|
915
931
|
const report = host.reportError;
|
|
916
932
|
useEffect(() => {
|
|
917
933
|
if (!shellKey || !read) return;
|
|
918
|
-
const [slug, shellItems] = JSON.parse(shellKey);
|
|
934
|
+
const [slug, shellItems, inConversation] = JSON.parse(shellKey);
|
|
935
|
+
const shell = { __kind: slug, items: shellItems };
|
|
936
|
+
if (inConversation) shell.conversationId = inConversation;
|
|
919
937
|
let live = true;
|
|
920
938
|
let polls = 0;
|
|
921
939
|
let timer = null;
|
|
922
940
|
const ask = () => {
|
|
923
|
-
read(
|
|
941
|
+
read(shell).then((answer) => {
|
|
924
942
|
if (!live) return;
|
|
925
943
|
if (answer.state === "applied") {
|
|
926
944
|
setState(
|
|
@@ -966,8 +984,9 @@ function ApplyDirectiveButton({
|
|
|
966
984
|
if (!directive.parsed.executes) return null;
|
|
967
985
|
const confirm = host.confirm;
|
|
968
986
|
if (!confirm) return null;
|
|
969
|
-
async function handleApply() {
|
|
987
|
+
async function handleApply(again = false) {
|
|
970
988
|
if (!confirm) return;
|
|
989
|
+
const before = state;
|
|
971
990
|
if (host.ask) {
|
|
972
991
|
setState({ status: "asking" });
|
|
973
992
|
let ok = false;
|
|
@@ -975,7 +994,8 @@ function ApplyDirectiveButton({
|
|
|
975
994
|
ok = await host.ask({
|
|
976
995
|
directive,
|
|
977
996
|
items,
|
|
978
|
-
nounLabel: nounText
|
|
997
|
+
nounLabel: nounText,
|
|
998
|
+
...again ? { again: true } : {}
|
|
979
999
|
});
|
|
980
1000
|
} catch (error) {
|
|
981
1001
|
setState({
|
|
@@ -985,14 +1005,17 @@ function ApplyDirectiveButton({
|
|
|
985
1005
|
return;
|
|
986
1006
|
}
|
|
987
1007
|
if (!ok) {
|
|
988
|
-
setState({ status: "idle" });
|
|
1008
|
+
setState(again ? before : { status: "idle" });
|
|
989
1009
|
return;
|
|
990
1010
|
}
|
|
991
1011
|
}
|
|
992
1012
|
setElapsed(0);
|
|
993
1013
|
setState({ status: "applying" });
|
|
994
1014
|
try {
|
|
995
|
-
const
|
|
1015
|
+
const shell = { __kind: directive.slug, items };
|
|
1016
|
+
if (conversationId) shell.conversationId = conversationId;
|
|
1017
|
+
if (again) shell.force = true;
|
|
1018
|
+
const result = await confirm(shell);
|
|
996
1019
|
setState({
|
|
997
1020
|
status: "applied",
|
|
998
1021
|
applied: result.applied,
|
|
@@ -1029,7 +1052,20 @@ function ApplyDirectiveButton({
|
|
|
1029
1052
|
fallback: recordFallbackName(label2, record.id),
|
|
1030
1053
|
context: "applied",
|
|
1031
1054
|
trashed
|
|
1032
|
-
}) }, `${record.noun}:${record.id}`))
|
|
1055
|
+
}) }, `${record.noun}:${record.id}`)),
|
|
1056
|
+
/* @__PURE__ */ jsxs2(
|
|
1057
|
+
"button",
|
|
1058
|
+
{
|
|
1059
|
+
type: "button",
|
|
1060
|
+
onClick: () => void handleApply(!bad),
|
|
1061
|
+
className: "inline-flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",
|
|
1062
|
+
"data-apply-action": bad ? "retry" : "run-again",
|
|
1063
|
+
children: [
|
|
1064
|
+
/* @__PURE__ */ jsx4(RotateCcwIcon, { className: "h-3 w-3" }),
|
|
1065
|
+
bad ? "Retry" : "Run again"
|
|
1066
|
+
]
|
|
1067
|
+
}
|
|
1068
|
+
)
|
|
1033
1069
|
]
|
|
1034
1070
|
}
|
|
1035
1071
|
);
|
|
@@ -1321,7 +1357,11 @@ function isWholeJson(content) {
|
|
|
1321
1357
|
return false;
|
|
1322
1358
|
}
|
|
1323
1359
|
}
|
|
1324
|
-
function DirectiveRender({
|
|
1360
|
+
function DirectiveRender({ conversationId, ...props }) {
|
|
1361
|
+
if (conversationId === void 0) return /* @__PURE__ */ jsx8(DirectiveRenderInner, { ...props });
|
|
1362
|
+
return /* @__PURE__ */ jsx8(DirectiveScopeProvider, { conversationId, children: /* @__PURE__ */ jsx8(DirectiveRenderInner, { ...props }) });
|
|
1363
|
+
}
|
|
1364
|
+
function DirectiveRenderInner({ content, className, streaming }) {
|
|
1325
1365
|
const host = useDirectiveHost();
|
|
1326
1366
|
const directive = tryDecodeDirectiveContent(content, (message) => {
|
|
1327
1367
|
const line = `[kind-directives] ${message}`;
|
|
@@ -1785,6 +1825,7 @@ export {
|
|
|
1785
1825
|
DirectiveHostProvider,
|
|
1786
1826
|
DirectiveProvisionalCard,
|
|
1787
1827
|
DirectiveRender,
|
|
1828
|
+
DirectiveScopeProvider,
|
|
1788
1829
|
GENERIC_STRUCTURED_COMPONENT_KEY,
|
|
1789
1830
|
GenericStructuredView,
|
|
1790
1831
|
IR_PROVISIONAL_KEY,
|
|
@@ -1827,6 +1868,7 @@ export {
|
|
|
1827
1868
|
useContentIrHostOrNull,
|
|
1828
1869
|
useContentIrKindVersion,
|
|
1829
1870
|
useDirectiveHost,
|
|
1871
|
+
useDirectiveScope,
|
|
1830
1872
|
useKindRouteEnv
|
|
1831
1873
|
};
|
|
1832
1874
|
//# sourceMappingURL=index.js.map
|