@dudousxd/nestjs-agent-react 0.34.5 → 0.35.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/dist/{generative-ui-DdUZPCXX.d.ts → generative-ui-ClYT7OgL.d.cts} +32 -5
- package/dist/{generative-ui-CyHY8Lh1.d.cts → generative-ui-D1efzu_K.d.ts} +32 -5
- package/dist/genui-json-render.cjs +34 -6
- package/dist/genui-json-render.cjs.map +1 -1
- package/dist/genui-json-render.d.cts +2 -2
- package/dist/genui-json-render.d.ts +2 -2
- package/dist/genui-json-render.js +34 -6
- package/dist/genui-json-render.js.map +1 -1
- package/dist/genui-server-playwright.d.cts +2 -2
- package/dist/genui-server-playwright.d.ts +2 -2
- package/dist/genui-server.d.cts +3 -3
- package/dist/genui-server.d.ts +3 -3
- package/dist/genui.cjs +37 -5
- package/dist/genui.cjs.map +1 -1
- package/dist/genui.d.cts +4 -4
- package/dist/genui.d.ts +4 -4
- package/dist/genui.js +36 -5
- package/dist/genui.js.map +1 -1
- package/dist/index.cjs +47 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +47 -7
- package/dist/index.js.map +1 -1
- package/dist/{react-registry-z9GFbTm9.d.ts → react-registry-CC84Jm3U.d.ts} +1 -1
- package/dist/{react-registry-Di4IVrw-.d.cts → react-registry-R0eFtDCG.d.cts} +1 -1
- package/dist/{types-DZtFsWec.d.cts → types-COuArD3c.d.cts} +34 -1
- package/dist/{types-DZtFsWec.d.ts → types-COuArD3c.d.ts} +34 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -8,9 +8,9 @@ import * as React from 'react';
|
|
|
8
8
|
import React__default, { ReactNode, Context } from 'react';
|
|
9
9
|
import { UiCapabilities } from '@dudousxd/nestjs-agent-core/genui';
|
|
10
10
|
export { UiCapabilities } from '@dudousxd/nestjs-agent-core/genui';
|
|
11
|
-
import { g as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions,
|
|
12
|
-
export {
|
|
13
|
-
import './types-
|
|
11
|
+
import { g as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions, k as ApprovalTarget, l as TranscriptBlock, U as UsageSummary, m as TimestampInfo, C as ChatStatus, n as TranscriptFile, M as MessageUsageInfo, o as ToolCatalog, p as AnyToolUIPart } from './generative-ui-ClYT7OgL.cjs';
|
|
12
|
+
export { q as ApprovalBlockOptions, B as BuildBlocksOptions, r as CoercibleQuestion, D as DescribeToolCallOptions, E as ElicitationBlockOptions, s as GroupToolActivityOptions, R as RawAnswer, t as ResolvedReading, v as ResolvedResultView, w as RetrievedPassage, S as SettleAction, x as ToolActivityGroup, y as ToolCallDescription, z as ToolCallState, F as ToolCallStatus, H as TranscriptApproval, I as TranscriptApprovalStatus, J as TranscriptElicitationBlock, K as TranscriptElicitationOutcome, L as TranscriptFilesBlock, N as TranscriptQuestion, O as TranscriptQuestionOption, P as TranscriptReasoningBlock, Q as TranscriptSettleState, V as TranscriptSource, W as TranscriptSourcesBlock, X as TranscriptTextBlock, Y as TranscriptToolBlock, Z as TranscriptToolCall, _ as buildTranscriptBlocks, $ as coerceAnswer, a0 as correctedCallIds, a1 as describeTimestamp, a2 as describeToolCall, a3 as describeUsage, a4 as extractMessageText, a5 as fillTemplate, a6 as formatRelativeTime, a7 as groupToolActivity, a8 as inferResultView, a9 as isActionCall, aa as phraseFor, ab as proposalNeedsPolling, ac as readPath, ad as reconcileProposalMessages, ae as resolveResultView, af as toolCallState, ag as toolCatalogFrom } from './generative-ui-ClYT7OgL.cjs';
|
|
13
|
+
import './types-COuArD3c.cjs';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The `code`s this library's own loop closes a failed run's stream with (`event: error`). A client
|
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ import * as React from 'react';
|
|
|
8
8
|
import React__default, { ReactNode, Context } from 'react';
|
|
9
9
|
import { UiCapabilities } from '@dudousxd/nestjs-agent-core/genui';
|
|
10
10
|
export { UiCapabilities } from '@dudousxd/nestjs-agent-core/genui';
|
|
11
|
-
import { g as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions,
|
|
12
|
-
export {
|
|
13
|
-
import './types-
|
|
11
|
+
import { g as GenuiProviderValue, T as TranscriptUiBlock, A as ApproveOptions, k as ApprovalTarget, l as TranscriptBlock, U as UsageSummary, m as TimestampInfo, C as ChatStatus, n as TranscriptFile, M as MessageUsageInfo, o as ToolCatalog, p as AnyToolUIPart } from './generative-ui-D1efzu_K.js';
|
|
12
|
+
export { q as ApprovalBlockOptions, B as BuildBlocksOptions, r as CoercibleQuestion, D as DescribeToolCallOptions, E as ElicitationBlockOptions, s as GroupToolActivityOptions, R as RawAnswer, t as ResolvedReading, v as ResolvedResultView, w as RetrievedPassage, S as SettleAction, x as ToolActivityGroup, y as ToolCallDescription, z as ToolCallState, F as ToolCallStatus, H as TranscriptApproval, I as TranscriptApprovalStatus, J as TranscriptElicitationBlock, K as TranscriptElicitationOutcome, L as TranscriptFilesBlock, N as TranscriptQuestion, O as TranscriptQuestionOption, P as TranscriptReasoningBlock, Q as TranscriptSettleState, V as TranscriptSource, W as TranscriptSourcesBlock, X as TranscriptTextBlock, Y as TranscriptToolBlock, Z as TranscriptToolCall, _ as buildTranscriptBlocks, $ as coerceAnswer, a0 as correctedCallIds, a1 as describeTimestamp, a2 as describeToolCall, a3 as describeUsage, a4 as extractMessageText, a5 as fillTemplate, a6 as formatRelativeTime, a7 as groupToolActivity, a8 as inferResultView, a9 as isActionCall, aa as phraseFor, ab as proposalNeedsPolling, ac as readPath, ad as reconcileProposalMessages, ae as resolveResultView, af as toolCallState, ag as toolCatalogFrom } from './generative-ui-D1efzu_K.js';
|
|
13
|
+
import './types-COuArD3c.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The `code`s this library's own loop closes a failed run's stream with (`event: error`). A client
|
package/dist/index.js
CHANGED
|
@@ -932,7 +932,10 @@ var AgentChatTransport = class {
|
|
|
932
932
|
component: event.component,
|
|
933
933
|
props: event.props,
|
|
934
934
|
...event.version !== void 0 ? { version: event.version } : {},
|
|
935
|
-
...event.toolCallId !== void 0 ? { toolCallId: event.toolCallId } : {}
|
|
935
|
+
...event.toolCallId !== void 0 ? { toolCallId: event.toolCallId } : {},
|
|
936
|
+
// A preview of a layout the model is still writing: the final push (same id)
|
|
937
|
+
// replaces this part in place.
|
|
938
|
+
...event.partial === true ? { partial: true } : {}
|
|
936
939
|
}
|
|
937
940
|
});
|
|
938
941
|
break;
|
|
@@ -1292,7 +1295,8 @@ function toGenerativeUIItem(part) {
|
|
|
1292
1295
|
...typeof source.fallbackText === "string" ? { fallbackText: source.fallbackText } : {},
|
|
1293
1296
|
props: isRecord(source.props) ? source.props : {},
|
|
1294
1297
|
version: typeof source.version === "number" ? source.version : null,
|
|
1295
|
-
toolCallId: typeof source.toolCallId === "string" ? source.toolCallId : null
|
|
1298
|
+
toolCallId: typeof source.toolCallId === "string" ? source.toolCallId : null,
|
|
1299
|
+
...source.partial === true ? { partial: true } : {}
|
|
1296
1300
|
};
|
|
1297
1301
|
}
|
|
1298
1302
|
var resolverCaches = /* @__PURE__ */ new WeakMap();
|
|
@@ -1411,6 +1415,7 @@ function useGenerativeUIState(part, options, fallbackTree) {
|
|
|
1411
1415
|
item?.props ?? empty
|
|
1412
1416
|
);
|
|
1413
1417
|
if (item === null) return null;
|
|
1418
|
+
if (item.partial === true && Object.keys(item.props).length === 0) return null;
|
|
1414
1419
|
if (name === GENUI_TREE_COMPONENT && item.fallbackText !== void 0 && (!isRecord(item.props.root) || typeof item.props.root.type !== "string"))
|
|
1415
1420
|
return {
|
|
1416
1421
|
status: "problem",
|
|
@@ -1433,6 +1438,14 @@ function useGenerativeUIState(part, options, fallbackTree) {
|
|
|
1433
1438
|
// src/genui/generative-ui.tsx
|
|
1434
1439
|
import { jsx } from "react/jsx-runtime";
|
|
1435
1440
|
var TreeScopeContext = createContext2(null);
|
|
1441
|
+
var GenuiNodeContext = sharedContext(
|
|
1442
|
+
"@dudousxd/nestjs-agent-react:genui-node"
|
|
1443
|
+
);
|
|
1444
|
+
function renderPlaceholder(scope, node) {
|
|
1445
|
+
const { placeholder } = scope;
|
|
1446
|
+
if (typeof placeholder === "function") return placeholder(node);
|
|
1447
|
+
return placeholder !== void 0 ? placeholder : scope.loading;
|
|
1448
|
+
}
|
|
1436
1449
|
function renderFallback(fallback2, problem) {
|
|
1437
1450
|
if (typeof fallback2 === "function") return fallback2(problem);
|
|
1438
1451
|
if (fallback2 !== void 0) return fallback2;
|
|
@@ -1468,6 +1481,12 @@ function nodeItem(node, id) {
|
|
|
1468
1481
|
function TreeNode({ node, id }) {
|
|
1469
1482
|
const scope = useContext2(TreeScopeContext);
|
|
1470
1483
|
const item = useMemo2(() => nodeItem(node, id), [node, id]);
|
|
1484
|
+
const incomplete = node.incomplete === true;
|
|
1485
|
+
const held = node.held === true;
|
|
1486
|
+
const state = useMemo2(
|
|
1487
|
+
() => ({ id, type: node.type, incomplete, held }),
|
|
1488
|
+
[id, node.type, incomplete, held]
|
|
1489
|
+
);
|
|
1471
1490
|
const storedVersion = scope?.componentVersions?.[node.type];
|
|
1472
1491
|
const definition = scope?.options.catalog?.get?.(node.type);
|
|
1473
1492
|
const incompatible = storedVersion !== void 0 && definition !== void 0 && storedVersion !== (definition.version ?? 1);
|
|
@@ -1478,11 +1497,14 @@ function TreeNode({ node, id }) {
|
|
|
1478
1497
|
scope?.options.resolveComponent
|
|
1479
1498
|
);
|
|
1480
1499
|
const validation = useValidatedProps(
|
|
1481
|
-
incompatible ? void 0 : scope?.options.catalog,
|
|
1500
|
+
incompatible || incomplete ? void 0 : scope?.options.catalog,
|
|
1482
1501
|
node.type,
|
|
1483
1502
|
item.props
|
|
1484
1503
|
);
|
|
1485
1504
|
if (scope === null) return null;
|
|
1505
|
+
if (held) {
|
|
1506
|
+
return /* @__PURE__ */ jsx(GenuiNodeContext.Provider, { value: state, children: renderPlaceholder(scope, state) });
|
|
1507
|
+
}
|
|
1486
1508
|
if (resolution.status === "loading" || validation.status === "pending") return scope.loading;
|
|
1487
1509
|
if (resolution.status === "unknown") {
|
|
1488
1510
|
if (scope.fallback === void 0 && scope.fallbackText !== void 0)
|
|
@@ -1500,7 +1522,7 @@ function TreeNode({ node, id }) {
|
|
|
1500
1522
|
}
|
|
1501
1523
|
const Renderer = resolution.Component;
|
|
1502
1524
|
const children = Array.isArray(node.children) ? node.children : [];
|
|
1503
|
-
return /* @__PURE__ */ jsx(Renderer, { ...validation.props, children: children.length > 0 ? children.map((child, index) => {
|
|
1525
|
+
return /* @__PURE__ */ jsx(GenuiNodeContext.Provider, { value: state, children: /* @__PURE__ */ jsx(Renderer, { ...validation.props, children: children.length > 0 ? children.map((child, index) => {
|
|
1504
1526
|
const childId = `${id}.${index}`;
|
|
1505
1527
|
if (scope.fallback === void 0 && scope.fallbackText !== void 0)
|
|
1506
1528
|
return /* @__PURE__ */ jsx(TreeNode, { node: child, id: childId }, childId);
|
|
@@ -1514,7 +1536,7 @@ function TreeNode({ node, id }) {
|
|
|
1514
1536
|
},
|
|
1515
1537
|
childId
|
|
1516
1538
|
);
|
|
1517
|
-
}) : void 0 });
|
|
1539
|
+
}) : void 0 }) });
|
|
1518
1540
|
}
|
|
1519
1541
|
function GenuiTree({ root }) {
|
|
1520
1542
|
if (root === void 0 || root === null || typeof root.type !== "string") return null;
|
|
@@ -1528,6 +1550,7 @@ function GenerativeUIScope({
|
|
|
1528
1550
|
fallbackText,
|
|
1529
1551
|
componentVersions,
|
|
1530
1552
|
loading = null,
|
|
1553
|
+
placeholder,
|
|
1531
1554
|
onError,
|
|
1532
1555
|
children
|
|
1533
1556
|
}) {
|
|
@@ -1542,6 +1565,7 @@ function GenerativeUIScope({
|
|
|
1542
1565
|
...componentVersions !== void 0 ? { componentVersions } : {},
|
|
1543
1566
|
...fallbackText !== void 0 ? { fallbackText } : {},
|
|
1544
1567
|
loading,
|
|
1568
|
+
placeholder,
|
|
1545
1569
|
onError
|
|
1546
1570
|
}),
|
|
1547
1571
|
[
|
|
@@ -1552,6 +1576,7 @@ function GenerativeUIScope({
|
|
|
1552
1576
|
fallbackText,
|
|
1553
1577
|
componentVersions,
|
|
1554
1578
|
loading,
|
|
1579
|
+
placeholder,
|
|
1555
1580
|
onError
|
|
1556
1581
|
]
|
|
1557
1582
|
);
|
|
@@ -1567,6 +1592,7 @@ function GenuiProvider({
|
|
|
1567
1592
|
treeRenderer,
|
|
1568
1593
|
fallback: fallback2,
|
|
1569
1594
|
loading,
|
|
1595
|
+
placeholder,
|
|
1570
1596
|
onError,
|
|
1571
1597
|
children
|
|
1572
1598
|
}) {
|
|
@@ -1578,9 +1604,10 @@ function GenuiProvider({
|
|
|
1578
1604
|
...treeRenderer !== void 0 ? { treeRenderer } : {},
|
|
1579
1605
|
...fallback2 !== void 0 ? { fallback: fallback2 } : {},
|
|
1580
1606
|
...loading !== void 0 ? { loading } : {},
|
|
1607
|
+
...placeholder !== void 0 ? { placeholder } : {},
|
|
1581
1608
|
...onError !== void 0 ? { onError } : {}
|
|
1582
1609
|
}),
|
|
1583
|
-
[registry, catalog, resolveComponent, treeRenderer, fallback2, loading, onError]
|
|
1610
|
+
[registry, catalog, resolveComponent, treeRenderer, fallback2, loading, placeholder, onError]
|
|
1584
1611
|
);
|
|
1585
1612
|
const renderUi = useCallback((block) => /* @__PURE__ */ jsx(GenerativeUI, { part: block }), []);
|
|
1586
1613
|
return /* @__PURE__ */ jsx(GenuiContext.Provider, { value, children: /* @__PURE__ */ jsx(AmbientRenderUiContext.Provider, { value: renderUi, children }) });
|
|
@@ -1610,11 +1637,13 @@ function GenerativeUI({
|
|
|
1610
1637
|
treeRenderer,
|
|
1611
1638
|
fallback: ownFallback,
|
|
1612
1639
|
loading: ownLoading,
|
|
1640
|
+
placeholder: ownPlaceholder,
|
|
1613
1641
|
onError: ownOnError
|
|
1614
1642
|
}) {
|
|
1615
1643
|
const provided = useContext2(GenuiContext);
|
|
1616
1644
|
const fallback2 = ownFallback !== void 0 ? ownFallback : provided?.fallback;
|
|
1617
1645
|
const loading = ownLoading ?? provided?.loading ?? null;
|
|
1646
|
+
const placeholder = ownPlaceholder !== void 0 ? ownPlaceholder : provided?.placeholder;
|
|
1618
1647
|
const onError = ownOnError ?? provided?.onError;
|
|
1619
1648
|
const options = useMergedOptions({
|
|
1620
1649
|
...registry !== void 0 ? { registry } : {},
|
|
@@ -1642,6 +1671,7 @@ function GenerativeUI({
|
|
|
1642
1671
|
...state.item.fallbackText !== void 0 ? { fallbackText: state.item.fallbackText } : {},
|
|
1643
1672
|
fallback: fallback2,
|
|
1644
1673
|
loading,
|
|
1674
|
+
...placeholder !== void 0 ? { placeholder } : {},
|
|
1645
1675
|
...onError !== void 0 ? { onError } : {},
|
|
1646
1676
|
children: /* @__PURE__ */ jsx(ItemBoundary, { item: state.item, fallback: fallback2, onError, children: /* @__PURE__ */ jsx(Renderer, { ...state.props }) })
|
|
1647
1677
|
}
|
|
@@ -3332,6 +3362,12 @@ function buildTranscriptBlocks(message, options) {
|
|
|
3332
3362
|
flushSources();
|
|
3333
3363
|
flushFiles();
|
|
3334
3364
|
}
|
|
3365
|
+
const settledCalls = /* @__PURE__ */ new Set();
|
|
3366
|
+
for (const part of message.parts ?? []) {
|
|
3367
|
+
if (isToolUIPart(part) && (part.state === "output-available" || part.state === "output-error" || part.state === "output-denied")) {
|
|
3368
|
+
settledCalls.add(part.toolCallId);
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3335
3371
|
for (const part of message.parts ?? []) {
|
|
3336
3372
|
if (isToolUIPart(part)) {
|
|
3337
3373
|
const elicitation = options.elicitation;
|
|
@@ -3372,6 +3408,9 @@ function buildTranscriptBlocks(message, options) {
|
|
|
3372
3408
|
flushAll();
|
|
3373
3409
|
if (isDataUIPart(part)) {
|
|
3374
3410
|
const ui = part.type === UI_PART ? readUiComponent(part) : null;
|
|
3411
|
+
if (ui?.partial === true && (Object.keys(ui.props).length === 0 || ui.toolCallId !== null && settledCalls.has(ui.toolCallId))) {
|
|
3412
|
+
continue;
|
|
3413
|
+
}
|
|
3375
3414
|
if (ui !== null) {
|
|
3376
3415
|
blocks.push({ kind: "ui", key: `${message.id}-ui-${ui.id}`, ...ui });
|
|
3377
3416
|
}
|
|
@@ -3780,7 +3819,8 @@ function readUiComponent(part) {
|
|
|
3780
3819
|
(version) => typeof version === "number" && Number.isSafeInteger(version) && version > 0
|
|
3781
3820
|
) ? { componentVersions: { ...data.componentVersions } } : {},
|
|
3782
3821
|
...typeof data.fallbackText === "string" ? { fallbackText: data.fallbackText } : {},
|
|
3783
|
-
toolCallId: typeof data.toolCallId === "string" ? data.toolCallId : null
|
|
3822
|
+
toolCallId: typeof data.toolCallId === "string" ? data.toolCallId : null,
|
|
3823
|
+
...data.partial === true ? { partial: true } : {}
|
|
3784
3824
|
};
|
|
3785
3825
|
}
|
|
3786
3826
|
function isRecord4(value) {
|