@invergent/agent-chat-react 2.17.2 → 2.17.4
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 +75 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +76 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1335,6 +1335,11 @@ function TooltipContent({
|
|
|
1335
1335
|
|
|
1336
1336
|
// src/components/ai-elements/message.tsx
|
|
1337
1337
|
init_utils();
|
|
1338
|
+
var streamdownRehypePlugins = Object.entries(streamdown.defaultRehypePlugins).map(([name, plugin]) => {
|
|
1339
|
+
if (name !== "harden" || !Array.isArray(plugin)) return plugin;
|
|
1340
|
+
const [harden, options] = plugin;
|
|
1341
|
+
return [harden, { ...options, linkBlockPolicy: "text-only" }];
|
|
1342
|
+
});
|
|
1338
1343
|
|
|
1339
1344
|
// src/lib/oauth-popup.ts
|
|
1340
1345
|
function openOAuthPopup(url) {
|
|
@@ -1454,6 +1459,7 @@ var MessageResponse = react.memo(
|
|
|
1454
1459
|
className
|
|
1455
1460
|
),
|
|
1456
1461
|
plugins: streamdownPlugins,
|
|
1462
|
+
rehypePlugins: streamdownRehypePlugins,
|
|
1457
1463
|
components: streamdownComponents,
|
|
1458
1464
|
...props
|
|
1459
1465
|
}
|
|
@@ -1661,6 +1667,7 @@ var ReasoningContent = react.memo(
|
|
|
1661
1667
|
{
|
|
1662
1668
|
className: "[&_ol]:list-outside [&_ol]:pl-5 [&_ul]:list-outside [&_ul]:pl-5",
|
|
1663
1669
|
plugins: streamdownPlugins2,
|
|
1670
|
+
rehypePlugins: streamdownRehypePlugins,
|
|
1664
1671
|
children
|
|
1665
1672
|
}
|
|
1666
1673
|
)
|
|
@@ -12278,6 +12285,36 @@ function useCardStarts(adapter) {
|
|
|
12278
12285
|
);
|
|
12279
12286
|
return cardStarts.get(adapter) ?? /* @__PURE__ */ new Map();
|
|
12280
12287
|
}
|
|
12288
|
+
function useLocalDevice(adapter, wanted) {
|
|
12289
|
+
const [found, setFound] = react.useState(null);
|
|
12290
|
+
react.useEffect(() => {
|
|
12291
|
+
if (!wanted || !adapter.getLocalDeviceId) return;
|
|
12292
|
+
let live = true;
|
|
12293
|
+
void adapter.getLocalDeviceId().catch(() => null).then((id) => {
|
|
12294
|
+
if (live) setFound({ adapter, id });
|
|
12295
|
+
});
|
|
12296
|
+
return () => {
|
|
12297
|
+
live = false;
|
|
12298
|
+
};
|
|
12299
|
+
}, [adapter, wanted]);
|
|
12300
|
+
if (!adapter.getLocalDeviceId) return null;
|
|
12301
|
+
return found?.adapter === adapter ? found.id : void 0;
|
|
12302
|
+
}
|
|
12303
|
+
function useFolderLost(adapter, projectId, wanted) {
|
|
12304
|
+
const [found, setFound] = react.useState(null);
|
|
12305
|
+
react.useEffect(() => {
|
|
12306
|
+
if (!wanted || !projectId || !adapter.isProjectFolderLost) return;
|
|
12307
|
+
let live = true;
|
|
12308
|
+
void adapter.isProjectFolderLost({ projectId }).catch(() => false).then((lost) => {
|
|
12309
|
+
if (live) setFound({ adapter, projectId, lost });
|
|
12310
|
+
});
|
|
12311
|
+
return () => {
|
|
12312
|
+
live = false;
|
|
12313
|
+
};
|
|
12314
|
+
}, [adapter, projectId, wanted]);
|
|
12315
|
+
if (!adapter.isProjectFolderLost) return false;
|
|
12316
|
+
return found?.adapter === adapter && found.projectId === projectId ? found.lost : void 0;
|
|
12317
|
+
}
|
|
12281
12318
|
function ThreadCards({ message }) {
|
|
12282
12319
|
if (message.worker) return /* @__PURE__ */ jsxRuntime.jsx(WorkerCard, { worker: message.worker });
|
|
12283
12320
|
if (message.proposal) return /* @__PURE__ */ jsxRuntime.jsx(ProposalCard, { proposal: message.proposal });
|
|
@@ -12364,7 +12401,7 @@ function WorkerCard({ worker }) {
|
|
|
12364
12401
|
] });
|
|
12365
12402
|
}
|
|
12366
12403
|
function ProposalCard({ proposal }) {
|
|
12367
|
-
const { adapter, projectId, onOpenSession } = useAgentChatAdapterContext();
|
|
12404
|
+
const { adapter, projectId, projectComputer, onOpenSession } = useAgentChatAdapterContext();
|
|
12368
12405
|
const starts = useCardStarts(adapter);
|
|
12369
12406
|
const startOf = (key) => starts.get(`${proposal.proposalId}:${key}`);
|
|
12370
12407
|
const told = (key, start2) => setCardStart(adapter, `${proposal.proposalId}:${key}`, start2);
|
|
@@ -12381,6 +12418,9 @@ function ProposalCard({ proposal }) {
|
|
|
12381
12418
|
const starting = (key) => startingAt(key) !== void 0;
|
|
12382
12419
|
const canStart = !!projectId && !!adapter.startProposedThread;
|
|
12383
12420
|
const canStartHere = !!projectId && !!adapter.startLocalThread;
|
|
12421
|
+
const here = useLocalDevice(adapter, !!projectComputer && canStartHere);
|
|
12422
|
+
const onItsComputer = !!projectComputer && canStartHere && here === projectComputer.deviceId;
|
|
12423
|
+
const lost = useFolderLost(adapter, projectId, !!projectComputer && !onItsComputer && !(canStartHere && here === void 0));
|
|
12384
12424
|
const viewButtons = react.useRef({});
|
|
12385
12425
|
react.useEffect(() => {
|
|
12386
12426
|
drawnCards.set(proposal.proposalId, (drawnCards.get(proposal.proposalId) ?? 0) + 1);
|
|
@@ -12409,16 +12449,16 @@ function ProposalCard({ proposal }) {
|
|
|
12409
12449
|
}
|
|
12410
12450
|
};
|
|
12411
12451
|
const startable = proposal.threads.filter(
|
|
12412
|
-
(thread) => thread.where === "cloud" && !started[thread.key] && !starting(thread.key)
|
|
12452
|
+
(thread) => (projectComputer ? onItsComputer : thread.where === "cloud") && !started[thread.key] && !starting(thread.key)
|
|
12413
12453
|
);
|
|
12414
|
-
const startAll = async (
|
|
12415
|
-
for (const key of
|
|
12416
|
-
for (const key of
|
|
12454
|
+
const startAll = async (threads) => {
|
|
12455
|
+
for (const { key } of threads) told(key, { state: "starting", where: projectComputer ? "device" : "cloud" });
|
|
12456
|
+
for (const { key, title } of threads) await start(key, projectComputer ? title : void 0);
|
|
12417
12457
|
};
|
|
12418
12458
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "thread-proposal-card", className: "my-2 rounded-lg border border-border px-3 py-2 text-sm", children: [
|
|
12419
12459
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
12420
12460
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 font-medium text-foreground", children: "Proposed threads" }),
|
|
12421
|
-
canStart && startable.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(Button, { size: "xs", onClick: () => void startAll(startable
|
|
12461
|
+
(projectComputer ? onItsComputer : canStart) && startable.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(Button, { size: "xs", onClick: () => void startAll(startable), children: "Start all" })
|
|
12422
12462
|
] }),
|
|
12423
12463
|
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-1 space-y-2", children: proposal.threads.map((thread) => {
|
|
12424
12464
|
const threadId = started[thread.key];
|
|
@@ -12440,7 +12480,29 @@ function ProposalCard({ proposal }) {
|
|
|
12440
12480
|
onClick: () => onOpenSession(threadId),
|
|
12441
12481
|
children: "View thread"
|
|
12442
12482
|
}
|
|
12443
|
-
) :
|
|
12483
|
+
) : projectComputer ? onItsComputer ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12484
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Works in its own copy of the project's folder" }),
|
|
12485
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12486
|
+
Button,
|
|
12487
|
+
{
|
|
12488
|
+
size: "xs",
|
|
12489
|
+
variant: "outline",
|
|
12490
|
+
disabled: starting(thread.key),
|
|
12491
|
+
"aria-label": `${starting(thread.key) ? "Starting" : "Start"} ${thread.title}`,
|
|
12492
|
+
onClick: () => void start(thread.key, thread.title),
|
|
12493
|
+
children: starting(thread.key) ? "Starting\u2026" : "Start"
|
|
12494
|
+
}
|
|
12495
|
+
)
|
|
12496
|
+
] }) : canStartHere && here === void 0 || lost === void 0 ? null : lost ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
12497
|
+
"This project's folder can no longer be reached on ",
|
|
12498
|
+
/* @__PURE__ */ jsxRuntime.jsx("bdi", { children: projectComputer.name }),
|
|
12499
|
+
".",
|
|
12500
|
+
" ",
|
|
12501
|
+
canStartHere ? "Choose Use this computer for this project in its Overview to start its threads here." : "Open the project in Surogate Desktop and choose Use this computer for this project."
|
|
12502
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
12503
|
+
"Start this thread in Surogate Desktop on ",
|
|
12504
|
+
/* @__PURE__ */ jsxRuntime.jsx("bdi", { children: projectComputer.name })
|
|
12505
|
+
] }) : thread.where === "device" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12444
12506
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: canStartHere ? "Allow Surogate to work in a folder on your device" : "This works in a folder on your device, which needs Surogate Desktop" }),
|
|
12445
12507
|
canStartHere && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12446
12508
|
Button,
|
|
@@ -20477,6 +20539,11 @@ function AgentChat({
|
|
|
20477
20539
|
});
|
|
20478
20540
|
const sessionConfig = runtime.session?.config;
|
|
20479
20541
|
const projectId = sessionConfig?.workstream_role === "coordinator" && typeof sessionConfig.workstream_id === "string" ? sessionConfig.workstream_id : null;
|
|
20542
|
+
const projectComputer = react.useMemo(() => {
|
|
20543
|
+
const execution = projectId ? sessionConfig?.execution : void 0;
|
|
20544
|
+
const name = sessionComputer(sessionConfig);
|
|
20545
|
+
return execution?.kind === "device" && typeof execution.device_id === "string" && name !== null ? { deviceId: execution.device_id, name } : null;
|
|
20546
|
+
}, [projectId, sessionConfig]);
|
|
20480
20547
|
const threadRows = useProjectThreads(adapter, projectId);
|
|
20481
20548
|
react.useEffect(() => {
|
|
20482
20549
|
setOpenPane(null);
|
|
@@ -20605,6 +20672,7 @@ function AgentChat({
|
|
|
20605
20672
|
onOpenBilling,
|
|
20606
20673
|
onOpenSession: onSessionChange,
|
|
20607
20674
|
projectId,
|
|
20675
|
+
projectComputer,
|
|
20608
20676
|
threadRows,
|
|
20609
20677
|
readOnly: disabled === true
|
|
20610
20678
|
},
|