@ai-matrx/content-ir-react 0.14.0 → 0.15.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 +30 -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 +59 -15
- 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 +59 -15
- 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 +58 -14
- 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 +58 -14
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +56 -14
- 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 +56 -14
- 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 +3 -3
package/dist/react.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-
|
|
1
|
+
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-DVIaaGR_.cjs';
|
|
2
2
|
import { d as ComponentResolutionSource } from './component-resolution.types-C1MzCf2s.cjs';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import react__default, { ReactNode } from 'react';
|
|
5
5
|
import '@ai-matrx/content-ir';
|
|
6
|
-
import './directive-host-
|
|
6
|
+
import './directive-host-DJfF35FD.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The two registries this hook watches. Passed explicitly by a host whose
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-
|
|
1
|
+
import { c as KindDefinitionSource, C as ContentIrHost } from './host-types-9NfBeqrG.js';
|
|
2
2
|
import { d as ComponentResolutionSource } from './component-resolution.types-C1MzCf2s.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import react__default, { ReactNode } from 'react';
|
|
5
5
|
import '@ai-matrx/content-ir';
|
|
6
|
-
import './directive-host-
|
|
6
|
+
import './directive-host-DJfF35FD.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The two registries this hook watches. Passed explicitly by a host whose
|
package/dist/react.js
CHANGED
|
@@ -10,6 +10,16 @@ import { createContext as createContext2, useContext as useContext2, useMemo } f
|
|
|
10
10
|
import { createContext, useContext } from "react";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
12
|
var DirectiveHostContext = createContext(null);
|
|
13
|
+
var DirectiveScopeContext = createContext({});
|
|
14
|
+
function DirectiveScopeProvider({
|
|
15
|
+
conversationId,
|
|
16
|
+
children
|
|
17
|
+
}) {
|
|
18
|
+
return /* @__PURE__ */ jsx(DirectiveScopeContext.Provider, { value: { conversationId: conversationId ?? null }, children });
|
|
19
|
+
}
|
|
20
|
+
function useDirectiveScope() {
|
|
21
|
+
return useContext(DirectiveScopeContext);
|
|
22
|
+
}
|
|
13
23
|
var EMPTY_HOST = {};
|
|
14
24
|
function useDirectiveHost() {
|
|
15
25
|
return useContext(DirectiveHostContext) ?? EMPTY_HOST;
|
|
@@ -208,6 +218,10 @@ var MaximizeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
|
208
218
|
/* @__PURE__ */ jsx3("line", { x1: "3", x2: "10", y1: "21", y2: "14" })
|
|
209
219
|
] });
|
|
210
220
|
var LoaderIcon = (p) => /* @__PURE__ */ jsx3(Svg, { ...p, children: /* @__PURE__ */ jsx3("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
|
|
221
|
+
var RotateCcwIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
222
|
+
/* @__PURE__ */ jsx3("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
|
|
223
|
+
/* @__PURE__ */ jsx3("path", { d: "M3 3v5h5" })
|
|
224
|
+
] });
|
|
211
225
|
var CheckCircleIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
212
226
|
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "12", r: "10" }),
|
|
213
227
|
/* @__PURE__ */ jsx3("path", { d: "m9 12 2 2 4-4" })
|
|
@@ -243,6 +257,8 @@ function ApplyDirectiveButton({
|
|
|
243
257
|
onApplied
|
|
244
258
|
}) {
|
|
245
259
|
const host = useDirectiveHost();
|
|
260
|
+
const scope = useDirectiveScope();
|
|
261
|
+
const conversationId = scope.conversationId || void 0;
|
|
246
262
|
const items = directive.items;
|
|
247
263
|
const readsLedger = !!host.applyState && !!host.confirm && directive.parsed.executes && items.length > 0;
|
|
248
264
|
const [state, setState] = useState(
|
|
@@ -251,17 +267,19 @@ function ApplyDirectiveButton({
|
|
|
251
267
|
const [elapsed, setElapsed] = useState(0);
|
|
252
268
|
const startedAt = useRef(null);
|
|
253
269
|
const nounText = nounLabel(directive.noun, host.nouns);
|
|
254
|
-
const shellKey = readsLedger ? JSON.stringify([directive.slug, items]) : "";
|
|
270
|
+
const shellKey = readsLedger ? JSON.stringify([directive.slug, items, conversationId ?? null]) : "";
|
|
255
271
|
const read = host.applyState;
|
|
256
272
|
const report = host.reportError;
|
|
257
273
|
useEffect(() => {
|
|
258
274
|
if (!shellKey || !read) return;
|
|
259
|
-
const [slug, shellItems] = JSON.parse(shellKey);
|
|
275
|
+
const [slug, shellItems, inConversation] = JSON.parse(shellKey);
|
|
276
|
+
const shell = { __kind: slug, items: shellItems };
|
|
277
|
+
if (inConversation) shell.conversationId = inConversation;
|
|
260
278
|
let live = true;
|
|
261
279
|
let polls = 0;
|
|
262
280
|
let timer = null;
|
|
263
281
|
const ask = () => {
|
|
264
|
-
read(
|
|
282
|
+
read(shell).then((answer) => {
|
|
265
283
|
if (!live) return;
|
|
266
284
|
if (answer.state === "applied") {
|
|
267
285
|
setState(
|
|
@@ -307,8 +325,9 @@ function ApplyDirectiveButton({
|
|
|
307
325
|
if (!directive.parsed.executes) return null;
|
|
308
326
|
const confirm = host.confirm;
|
|
309
327
|
if (!confirm) return null;
|
|
310
|
-
async function handleApply() {
|
|
328
|
+
async function handleApply(again = false) {
|
|
311
329
|
if (!confirm) return;
|
|
330
|
+
const before = state;
|
|
312
331
|
if (host.ask) {
|
|
313
332
|
setState({ status: "asking" });
|
|
314
333
|
let ok = false;
|
|
@@ -316,7 +335,8 @@ function ApplyDirectiveButton({
|
|
|
316
335
|
ok = await host.ask({
|
|
317
336
|
directive,
|
|
318
337
|
items,
|
|
319
|
-
nounLabel: nounText
|
|
338
|
+
nounLabel: nounText,
|
|
339
|
+
...again ? { again: true } : {}
|
|
320
340
|
});
|
|
321
341
|
} catch (error) {
|
|
322
342
|
setState({
|
|
@@ -326,14 +346,17 @@ function ApplyDirectiveButton({
|
|
|
326
346
|
return;
|
|
327
347
|
}
|
|
328
348
|
if (!ok) {
|
|
329
|
-
setState({ status: "idle" });
|
|
349
|
+
setState(again ? before : { status: "idle" });
|
|
330
350
|
return;
|
|
331
351
|
}
|
|
332
352
|
}
|
|
333
353
|
setElapsed(0);
|
|
334
354
|
setState({ status: "applying" });
|
|
335
355
|
try {
|
|
336
|
-
const
|
|
356
|
+
const shell = { __kind: directive.slug, items };
|
|
357
|
+
if (conversationId) shell.conversationId = conversationId;
|
|
358
|
+
if (again) shell.force = true;
|
|
359
|
+
const result = await confirm(shell);
|
|
337
360
|
setState({
|
|
338
361
|
status: "applied",
|
|
339
362
|
applied: result.applied,
|
|
@@ -357,20 +380,35 @@ function ApplyDirectiveButton({
|
|
|
357
380
|
return /* @__PURE__ */ jsxs2(
|
|
358
381
|
"span",
|
|
359
382
|
{
|
|
360
|
-
className: `
|
|
383
|
+
className: `flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs ${bad ? "text-destructive" : "text-primary"}`,
|
|
361
384
|
"data-apply-state": "applied",
|
|
362
385
|
children: [
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
386
|
+
/* @__PURE__ */ jsxs2("span", { className: "inline-flex min-w-0 items-start gap-1", children: [
|
|
387
|
+
bad ? /* @__PURE__ */ jsx4(AlertIcon, { className: "mt-px h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ jsx4(CheckCircleIcon, { className: "mt-px h-3.5 w-3.5 shrink-0" }),
|
|
388
|
+
/* @__PURE__ */ jsxs2("span", { className: "min-w-0", children: [
|
|
389
|
+
state.message ?? `Applied ${state.applied}`,
|
|
390
|
+
bad && !state.message ? ` \xB7 ${state.failed} failed` : ""
|
|
391
|
+
] })
|
|
367
392
|
] }),
|
|
368
393
|
records.map((record) => /* @__PURE__ */ jsx4("span", { className: "inline-flex min-w-0 items-center", children: host.renderRecord?.({
|
|
369
394
|
...record,
|
|
370
395
|
fallback: recordFallbackName(label2, record.id),
|
|
371
396
|
context: "applied",
|
|
372
397
|
trashed
|
|
373
|
-
}) }, `${record.noun}:${record.id}`))
|
|
398
|
+
}) }, `${record.noun}:${record.id}`)),
|
|
399
|
+
/* @__PURE__ */ jsxs2(
|
|
400
|
+
"button",
|
|
401
|
+
{
|
|
402
|
+
type: "button",
|
|
403
|
+
onClick: () => void handleApply(!bad),
|
|
404
|
+
className: "inline-flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",
|
|
405
|
+
"data-apply-action": bad ? "retry" : "run-again",
|
|
406
|
+
children: [
|
|
407
|
+
/* @__PURE__ */ jsx4(RotateCcwIcon, { className: "h-3 w-3" }),
|
|
408
|
+
bad ? "Retry" : "Run again"
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
)
|
|
374
412
|
]
|
|
375
413
|
}
|
|
376
414
|
);
|
|
@@ -654,7 +692,11 @@ function isWholeJson(content) {
|
|
|
654
692
|
return false;
|
|
655
693
|
}
|
|
656
694
|
}
|
|
657
|
-
function DirectiveRender({
|
|
695
|
+
function DirectiveRender({ conversationId, ...props }) {
|
|
696
|
+
if (conversationId === void 0) return /* @__PURE__ */ jsx8(DirectiveRenderInner, { ...props });
|
|
697
|
+
return /* @__PURE__ */ jsx8(DirectiveScopeProvider, { conversationId, children: /* @__PURE__ */ jsx8(DirectiveRenderInner, { ...props }) });
|
|
698
|
+
}
|
|
699
|
+
function DirectiveRenderInner({ content, className, streaming }) {
|
|
658
700
|
const host = useDirectiveHost();
|
|
659
701
|
const directive = tryDecodeDirectiveContent(content, (message) => {
|
|
660
702
|
const line = `[kind-directives] ${message}`;
|