@invergent/agent-chat-react 2.0.0 → 2.0.2
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/index.cjs +130 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +131 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5982,7 +5982,13 @@ function ChatComposerInner({
|
|
|
5982
5982
|
disabled = false,
|
|
5983
5983
|
disabledReason,
|
|
5984
5984
|
tokenUsage,
|
|
5985
|
-
onComposerError
|
|
5985
|
+
onComposerError,
|
|
5986
|
+
showBrowser = false,
|
|
5987
|
+
onToggleBrowser,
|
|
5988
|
+
showWorkspace = false,
|
|
5989
|
+
onToggleWorkspace,
|
|
5990
|
+
canShowBrowser = false,
|
|
5991
|
+
canShowWorkspace = false
|
|
5986
5992
|
}) {
|
|
5987
5993
|
const { adapter } = useAgentChatAdapterContext();
|
|
5988
5994
|
const { textInput, attachments } = usePromptInputController();
|
|
@@ -6289,6 +6295,28 @@ function ChatComposerInner({
|
|
|
6289
6295
|
}
|
|
6290
6296
|
)
|
|
6291
6297
|
] }),
|
|
6298
|
+
canShowBrowser && onToggleBrowser && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6299
|
+
PromptInputButton,
|
|
6300
|
+
{
|
|
6301
|
+
"aria-label": showBrowser ? "Hide browser pane" : "Show browser pane",
|
|
6302
|
+
"aria-pressed": showBrowser,
|
|
6303
|
+
onClick: onToggleBrowser,
|
|
6304
|
+
tooltip: showBrowser ? "Hide browser pane" : "Show browser pane",
|
|
6305
|
+
className: showBrowser ? "bg-accent text-foreground" : void 0,
|
|
6306
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GlobeIcon, { className: "size-4" })
|
|
6307
|
+
}
|
|
6308
|
+
),
|
|
6309
|
+
canShowWorkspace && onToggleWorkspace && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6310
|
+
PromptInputButton,
|
|
6311
|
+
{
|
|
6312
|
+
"aria-label": showWorkspace ? "Hide workspace pane" : "Show workspace pane",
|
|
6313
|
+
"aria-pressed": showWorkspace,
|
|
6314
|
+
onClick: onToggleWorkspace,
|
|
6315
|
+
tooltip: showWorkspace ? "Hide workspace pane" : "Show workspace pane",
|
|
6316
|
+
className: showWorkspace ? "bg-accent text-foreground" : void 0,
|
|
6317
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FolderIcon, { className: "size-4" })
|
|
6318
|
+
}
|
|
6319
|
+
),
|
|
6292
6320
|
tokenUsage && tokenUsage.contextWindow > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6293
6321
|
Context,
|
|
6294
6322
|
{
|
|
@@ -7517,7 +7545,13 @@ function ChatThread({
|
|
|
7517
7545
|
tokenUsage,
|
|
7518
7546
|
retryIndicator,
|
|
7519
7547
|
onRetry,
|
|
7520
|
-
onComposerError
|
|
7548
|
+
onComposerError,
|
|
7549
|
+
showBrowser = false,
|
|
7550
|
+
onToggleBrowser,
|
|
7551
|
+
showWorkspace = false,
|
|
7552
|
+
onToggleWorkspace,
|
|
7553
|
+
canShowBrowser = false,
|
|
7554
|
+
canShowWorkspace = false
|
|
7521
7555
|
}) {
|
|
7522
7556
|
const groups = react.useMemo(() => groupMessages(messages), [messages]);
|
|
7523
7557
|
const artifactFallbacks = react.useMemo(() => {
|
|
@@ -7634,7 +7668,13 @@ function ChatThread({
|
|
|
7634
7668
|
disabled,
|
|
7635
7669
|
disabledReason,
|
|
7636
7670
|
tokenUsage,
|
|
7637
|
-
onComposerError
|
|
7671
|
+
onComposerError,
|
|
7672
|
+
showBrowser,
|
|
7673
|
+
onToggleBrowser,
|
|
7674
|
+
showWorkspace,
|
|
7675
|
+
onToggleWorkspace,
|
|
7676
|
+
canShowBrowser,
|
|
7677
|
+
canShowWorkspace
|
|
7638
7678
|
}
|
|
7639
7679
|
)
|
|
7640
7680
|
] })
|
|
@@ -9580,6 +9620,16 @@ function useAgentChatRuntime({
|
|
|
9580
9620
|
}));
|
|
9581
9621
|
}
|
|
9582
9622
|
}).catch(() => void 0);
|
|
9623
|
+
void adapter.getBrowserState(sessionId).then((browserState) => {
|
|
9624
|
+
if (sessionIdRef.current !== sessionId) return;
|
|
9625
|
+
setState((prev) => ({
|
|
9626
|
+
...prev,
|
|
9627
|
+
browser: browserState ? {
|
|
9628
|
+
status: browserState.status,
|
|
9629
|
+
controlOwner: browserState.controlOwner ?? null
|
|
9630
|
+
} : null
|
|
9631
|
+
}));
|
|
9632
|
+
}).catch(() => void 0);
|
|
9583
9633
|
return () => {
|
|
9584
9634
|
clearReconnectTimer();
|
|
9585
9635
|
closeStream();
|
|
@@ -9824,6 +9874,8 @@ function AgentChat({
|
|
|
9824
9874
|
}) {
|
|
9825
9875
|
const [workspacePath, setWorkspacePath] = react.useState(null);
|
|
9826
9876
|
const [mobileView, setMobileView] = react.useState("chat");
|
|
9877
|
+
const [showBrowser, setShowBrowser] = react.useState(true);
|
|
9878
|
+
const [showWorkspace, setShowWorkspace] = react.useState(true);
|
|
9827
9879
|
const runtime = useAgentChatRuntime({
|
|
9828
9880
|
adapter,
|
|
9829
9881
|
agentId,
|
|
@@ -9834,7 +9886,12 @@ function AgentChat({
|
|
|
9834
9886
|
const effectiveDisabled = disabled || isReadOnlySession;
|
|
9835
9887
|
const disabledReason = isReadOnlySession ? "Scheduled run is read-only" : void 0;
|
|
9836
9888
|
const browserState = runtime.state.browser;
|
|
9837
|
-
const
|
|
9889
|
+
const browserAvailable = browserState !== null && browserState.status !== "closed" && !!sessionId;
|
|
9890
|
+
const browserVisible = browserAvailable && showBrowser;
|
|
9891
|
+
const workspaceAvailable = !!sessionId;
|
|
9892
|
+
const workspaceVisible = workspaceAvailable && showWorkspace;
|
|
9893
|
+
const rightStackVisible = browserVisible || workspaceVisible;
|
|
9894
|
+
const bothPanesVisible = browserVisible && workspaceVisible;
|
|
9838
9895
|
react.useEffect(() => {
|
|
9839
9896
|
onMessagesChange?.(runtime.messages);
|
|
9840
9897
|
}, [onMessagesChange, runtime.messages]);
|
|
@@ -9842,11 +9899,18 @@ function AgentChat({
|
|
|
9842
9899
|
(path) => {
|
|
9843
9900
|
setWorkspacePath(path);
|
|
9844
9901
|
setMobileView("workspace");
|
|
9902
|
+
setShowWorkspace(true);
|
|
9845
9903
|
onFileSelect?.(path);
|
|
9846
9904
|
},
|
|
9847
9905
|
[onFileSelect]
|
|
9848
9906
|
);
|
|
9849
|
-
const
|
|
9907
|
+
const handleToggleBrowser = react.useCallback(() => {
|
|
9908
|
+
setShowBrowser((prev) => !prev);
|
|
9909
|
+
}, []);
|
|
9910
|
+
const handleToggleWorkspace = react.useCallback(() => {
|
|
9911
|
+
setShowWorkspace((prev) => !prev);
|
|
9912
|
+
}, []);
|
|
9913
|
+
const showMobileToggle = rightStackVisible;
|
|
9850
9914
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9851
9915
|
AgentChatAdapterProvider,
|
|
9852
9916
|
{
|
|
@@ -9864,8 +9928,11 @@ function AgentChat({
|
|
|
9864
9928
|
// Phone: flex column, tab toggle on top, then either chat or
|
|
9865
9929
|
// right stack visible based on `data-mobile-view`.
|
|
9866
9930
|
"flex min-h-0 flex-1 flex-col overflow-hidden bg-background text-sm text-foreground",
|
|
9867
|
-
// md+: restore desktop two-pane layout
|
|
9868
|
-
|
|
9931
|
+
// md+: restore desktop two-pane layout when the right stack
|
|
9932
|
+
// is visible. With both panes, absolute positioning lets the
|
|
9933
|
+
// browser/workspace split occupy a fixed width. Without the
|
|
9934
|
+
// right stack, the chat takes the full width.
|
|
9935
|
+
browserVisible ? "md:relative md:flex-row" : "md:flex-row"
|
|
9869
9936
|
),
|
|
9870
9937
|
style: { direction: "ltr", ...RIGHT_STACK_STYLE },
|
|
9871
9938
|
children: [
|
|
@@ -9906,8 +9973,13 @@ function AgentChat({
|
|
|
9906
9973
|
// Phone: full width column, hidden when workspace tab active.
|
|
9907
9974
|
"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",
|
|
9908
9975
|
showMobileToggle && "data-[mobile-view=workspace]:hidden md:flex!",
|
|
9909
|
-
// md+:
|
|
9910
|
-
|
|
9976
|
+
// md+: positioning depends on whether the browser/workspace
|
|
9977
|
+
// right stack is laid out. When the browser pane is shown
|
|
9978
|
+
// we pin a fixed-width column on the right and absolutely
|
|
9979
|
+
// position the chat panel beside it. Otherwise the chat
|
|
9980
|
+
// panel just flexes alongside the workspace (or fills the
|
|
9981
|
+
// space when nothing else is visible).
|
|
9982
|
+
browserVisible ? "md:absolute md:inset-y-0 md:left-0 md:right-(--right-stack-w,440px) md:flex" : "md:relative md:flex-1"
|
|
9911
9983
|
),
|
|
9912
9984
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9913
9985
|
ChatThread,
|
|
@@ -9924,12 +9996,18 @@ function AgentChat({
|
|
|
9924
9996
|
disabledReason,
|
|
9925
9997
|
tokenUsage: runtime.tokenUsage,
|
|
9926
9998
|
retryIndicator: runtime.retryIndicator,
|
|
9927
|
-
onComposerError
|
|
9999
|
+
onComposerError,
|
|
10000
|
+
showBrowser,
|
|
10001
|
+
onToggleBrowser: handleToggleBrowser,
|
|
10002
|
+
showWorkspace,
|
|
10003
|
+
onToggleWorkspace: handleToggleWorkspace,
|
|
10004
|
+
canShowBrowser: browserAvailable,
|
|
10005
|
+
canShowWorkspace: workspaceAvailable
|
|
9928
10006
|
}
|
|
9929
10007
|
)
|
|
9930
10008
|
}
|
|
9931
10009
|
),
|
|
9932
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10010
|
+
rightStackVisible && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9933
10011
|
"div",
|
|
9934
10012
|
{
|
|
9935
10013
|
"data-testid": "right-stack",
|
|
@@ -9938,17 +10016,23 @@ function AgentChat({
|
|
|
9938
10016
|
// Phone: full width column, hidden when chat tab active.
|
|
9939
10017
|
"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",
|
|
9940
10018
|
showMobileToggle && "data-[mobile-view=chat]:hidden md:flex!",
|
|
9941
|
-
// md+:
|
|
9942
|
-
//
|
|
9943
|
-
//
|
|
9944
|
-
|
|
10019
|
+
// md+: positioning differs depending on what is inside.
|
|
10020
|
+
// - browser visible (with or without workspace): absolute
|
|
10021
|
+
// right column at the configured width.
|
|
10022
|
+
// - workspace only: relative shrink-0 column letting
|
|
10023
|
+
// WorkspacePanel manage its own width via the resize
|
|
10024
|
+
// handle.
|
|
10025
|
+
browserVisible ? "md:absolute md:inset-y-0 md:right-0 md:w-(--right-stack-w,440px) md:flex-none" : "md:relative md:shrink-0 md:flex-none md:w-auto"
|
|
9945
10026
|
),
|
|
9946
10027
|
children: [
|
|
9947
|
-
|
|
10028
|
+
browserVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9948
10029
|
"div",
|
|
9949
10030
|
{
|
|
9950
10031
|
"data-testid": "browser-panel",
|
|
9951
|
-
className:
|
|
10032
|
+
className: cn(
|
|
10033
|
+
"min-h-0 w-full overflow-hidden",
|
|
10034
|
+
bothPanesVisible ? "h-1/2 border-b border-line" : "h-full"
|
|
10035
|
+
),
|
|
9952
10036
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9953
10037
|
BrowserPane,
|
|
9954
10038
|
{
|
|
@@ -9959,11 +10043,11 @@ function AgentChat({
|
|
|
9959
10043
|
)
|
|
9960
10044
|
}
|
|
9961
10045
|
),
|
|
9962
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10046
|
+
workspaceVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9963
10047
|
"div",
|
|
9964
10048
|
{
|
|
9965
10049
|
"data-testid": "workspace-panel-frame",
|
|
9966
|
-
className:
|
|
10050
|
+
className: bothPanesVisible ? "h-1/2 min-h-0 w-full overflow-hidden" : "min-h-0 h-full",
|
|
9967
10051
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9968
10052
|
WorkspacePanel,
|
|
9969
10053
|
{
|
|
@@ -9973,7 +10057,7 @@ function AgentChat({
|
|
|
9973
10057
|
onSelectedPathChange: setWorkspacePath,
|
|
9974
10058
|
refreshSignal: runtime.workspaceRefreshKey,
|
|
9975
10059
|
disabled: effectiveDisabled,
|
|
9976
|
-
fillParent:
|
|
10060
|
+
fillParent: bothPanesVisible
|
|
9977
10061
|
}
|
|
9978
10062
|
)
|
|
9979
10063
|
}
|
|
@@ -10780,6 +10864,16 @@ function truncate2(s, max) {
|
|
|
10780
10864
|
return `${s.slice(0, max - 1)}\u2026`;
|
|
10781
10865
|
}
|
|
10782
10866
|
var DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
10867
|
+
var MISSION_WORKER_KIND_BADGE_CLASS = {
|
|
10868
|
+
task: "border-primary/40 bg-primary/10 text-primary uppercase tracking-wide text-[10px]",
|
|
10869
|
+
worker: "border-foreground/30 bg-foreground/5 text-foreground/80 uppercase tracking-wide text-[10px]",
|
|
10870
|
+
delegation: "border-foreground/20 bg-foreground/[0.03] text-foreground/60 uppercase tracking-wide text-[10px]"
|
|
10871
|
+
};
|
|
10872
|
+
var MISSION_WORKER_KIND_TOOLTIP = {
|
|
10873
|
+
task: "Durable Task row created by spawn_task. Retried by the dispatcher; survives across coordinator wakes.",
|
|
10874
|
+
worker: "Async one-shot session spawned by spawn_worker. Durable session, no retry/DAG.",
|
|
10875
|
+
delegation: "Sync fork-join child spawned by delegate_task. Coordinator's wake blocked until it finished."
|
|
10876
|
+
};
|
|
10783
10877
|
var INITIAL_STATE = {
|
|
10784
10878
|
mission: null,
|
|
10785
10879
|
tasks: [],
|
|
@@ -10866,7 +10960,11 @@ function MissionDashboard({
|
|
|
10866
10960
|
[state.tasks]
|
|
10867
10961
|
);
|
|
10868
10962
|
const runningWorkerCount = react.useMemo(
|
|
10869
|
-
|
|
10963
|
+
// "running" means the child is still consuming compute right now.
|
|
10964
|
+
// For task-backed children that's ``taskStatus === "running"``; for
|
|
10965
|
+
// spawn_worker / delegate_task direct children the Task row doesn't
|
|
10966
|
+
// exist, so fall back to the session-level signal.
|
|
10967
|
+
() => state.workers.filter((w) => w.kind === "task" ? w.taskStatus === "running" : w.sessionStatus === "active").length,
|
|
10870
10968
|
[state.workers]
|
|
10871
10969
|
);
|
|
10872
10970
|
if (state.loading && !state.mission) {
|
|
@@ -10929,7 +11027,7 @@ function MissionDashboard({
|
|
|
10929
11027
|
}
|
|
10930
11028
|
};
|
|
10931
11029
|
const statusVariant = mission.status === "satisfied" ? "default" : mission.status === "failed" || mission.status === "cancelled" ? "destructive" : "secondary";
|
|
10932
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 p-4 sm:gap-6 sm:p-6
|
|
11030
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 p-4 sm:gap-6 sm:p-6", children: [
|
|
10933
11031
|
/* @__PURE__ */ jsxRuntime.jsxs(Card, { children: [
|
|
10934
11032
|
/* @__PURE__ */ jsxRuntime.jsx(CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-stretch gap-4 sm:flex-row sm:items-start sm:justify-between", children: [
|
|
10935
11033
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 min-w-0 flex-1", children: [
|
|
@@ -11077,7 +11175,16 @@ function MissionDashboard({
|
|
|
11077
11175
|
children: [
|
|
11078
11176
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
11079
11177
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
11080
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11178
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11179
|
+
Badge,
|
|
11180
|
+
{
|
|
11181
|
+
variant: "outline",
|
|
11182
|
+
className: MISSION_WORKER_KIND_BADGE_CLASS[w.kind],
|
|
11183
|
+
title: MISSION_WORKER_KIND_TOOLTIP[w.kind],
|
|
11184
|
+
children: w.kind
|
|
11185
|
+
}
|
|
11186
|
+
),
|
|
11187
|
+
/* @__PURE__ */ jsxRuntime.jsx(Badge, { className: "text-foreground/70", children: w.kind === "task" ? w.taskStatus ?? "\u2014" : w.sessionStatus }),
|
|
11081
11188
|
w.agentDefName ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-foreground/70", children: w.agentDefName }) : null
|
|
11082
11189
|
] }),
|
|
11083
11190
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm wrap-break-word", children: deriveMissionWorkerActivityLabel(w) }),
|