local-operator-ui 0.31.11 → 0.31.12
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/out/main/index.js +156 -7
- package/out/renderer/assets/{_basePickBy-DfG4wjig.js → _basePickBy-BmRJBnL9.js} +1 -1
- package/out/renderer/assets/{_baseUniq-BGWDx1XP.js → _baseUniq-7Lo40p8f.js} +1 -1
- package/out/renderer/assets/{agent-details-page-DhkOKq6G.js → agent-details-page-Dr0_4VXU.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-BRjvfsAy.js → agent-hub-page-CWhlINHl.js} +2 -2
- package/out/renderer/assets/agents-page-CfRvRbxk.js +2 -0
- package/out/renderer/assets/{arc-BbZdEs1w.js → arc-BzsVSHwA.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-4lLfeFcj.js → architectureDiagram-IEHRJDOE-Bw5-VATM.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-CzCeK4l6.js → blockDiagram-JOT3LUYC-BGagYddg.js} +1 -1
- package/out/renderer/assets/{book-open-CNgko0U5.js → book-open-6gMxcFCn.js} +1 -1
- package/out/renderer/assets/browser-page-B6fHPjNZ.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-Bynwfiuq.js → browser-webauthn-prompt-7nbHSC-s.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-DV6jCVYX.js → c4Diagram-VJAJSXHY-baq7nLZj.js} +1 -1
- package/out/renderer/assets/channel-DwqaTZnF.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-oN7e33U6.js → chunk-4BMEZGHF-g1gXYo4V.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-BY7xgPLa.js → chunk-A2AXSNBT--A5WU7y8.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-CdvId8Is.js → chunk-AEK57VVT-DzJ3UVbN.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-BnHX7WDi.js → chunk-D6G4REZN-C-t_FTD9.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D-FjPJs7.js → chunk-RZ5BOZE2-BYlLeO8W.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-DE_XcGmS.js → chunk-XZIHB7SX-lFzFuHTM.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-D8nKB_Ad.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-D8nKB_Ad.js +1 -0
- package/out/renderer/assets/clone-C2OvbMzz.js +1 -0
- package/out/renderer/assets/{console-mirror-DjoNpI7u.js → console-mirror-Dw_ms9Pv.js} +13 -13
- package/out/renderer/assets/{consoleCapture-BTYJP9Fs.js → consoleCapture-BSLdNXhT.js} +1 -1
- package/out/renderer/assets/{dagre-OKDRZEBW-DSno4uDg.js → dagre-OKDRZEBW-BVSzUiqR.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-Cta_mlzh.js → diagram-SSKATNLV-B2vAnmRK.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DXZvuw9Y.js → diagram-VNBRO52H-DWMJqgBu.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-DX_NZcvT.js → erDiagram-Q7BY3M3F-CUzlaIt5.js} +1 -1
- package/out/renderer/assets/{error-boundary-Be38BRVp.js → error-boundary-CAHYSCjh.js} +2 -2
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CkKn14vu.js → flowDiagram-4HSFHLVR-DD5CmZz9.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-pfUZL8XQ.js → ganttDiagram-APWFNJXF-C1VcnkEW.js} +4 -4
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DyxkVnKD.js → gitGraphDiagram-7IBYFJ6S-hEwYc4s_.js} +1 -1
- package/out/renderer/assets/{graph-CS6U_APD.js → graph-iFEIY46g.js} +1 -1
- package/out/renderer/assets/{index-BoBj0LUC.js → index-BZY6SC3C.js} +385 -389
- package/out/renderer/assets/index-DLdCxgd4.css +1 -0
- package/out/renderer/assets/{index-W19BqfEn.js → index-Dws1_64y.js} +1 -1
- package/out/renderer/assets/{index-0hsmy_dv.js → index-xYgenPjE.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-DstV9F9y.js → infoDiagram-PH2N3AL5-Fb3LRSKa.js} +1 -1
- package/out/renderer/assets/{installer-DOOu7eM6.js → installer-CzcDRHum.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DMxIQQHc.js → journeyDiagram-U35MCT3I-CQoYP1F8.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-DwCNWIKf.js → kanban-definition-NDS4AKOZ-CteRmk-W.js} +1 -1
- package/out/renderer/assets/{layout-rRE-L5H5.js → layout-DYvIW0gu.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-D3XdLDk2.js → legacy-agents-page-1fM02PQU.js} +3 -3
- package/out/renderer/assets/{mermaid.core-CHO9EN5d.js → mermaid.core-CF1Z-P7X.js} +5 -5
- package/out/renderer/assets/mesh-page-DI8M-fjS.js +2 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-C0TbE2NA.js → mindmap-definition-ALO5MXBD-DndDQMdO.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CyrcQL7E.js → org-surface-gate-BfrGIWSX.js} +1 -1
- package/out/renderer/assets/{page-header-BXIWLsA1.js → page-header-DuARVVAM.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-psQNoVHK.js → pieDiagram-IB7DONF6-CBrJnfZ7.js} +1 -1
- package/out/renderer/assets/{projects-page-DLrWcA92.js → projects-page-MsZOyOOD.js} +3 -3
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DAX1qBwZ.js → quadrantDiagram-7GDLP6J5-BVP2IC46.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-BRutmqUf.js → radar-MK3ICKWK-DjZTeeh9.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-fe1Bn89n.js → radient-auth-buttons-D7orNp3U.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-PTinIVCd.js → requirementDiagram-KVF5MWMF-lJJAXVZZ.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DuPXhi_4.js → sankeyDiagram-QLVOVGJD-LQXNh0UX.js} +1 -1
- package/out/renderer/assets/{schedules-page-Bxn30SeI.js → schedules-page-CtMM9uV6.js} +10 -10
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-CSbiipy3.js → sequenceDiagram-X6HHIX6F-1jw8SEPO.js} +1 -1
- package/out/renderer/assets/{settings-page-DeQ29q0v.js → settings-page-DRypESjz.js} +10 -10
- package/out/renderer/assets/{settings-section-BeU3N8-t.js → settings-section-j4eB5zEy.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-B0olW3ZC.js → stateDiagram-DGXRK772-B0lcRZrZ.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BfR0vu7W.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-DrFO8Scg.js → timeline-definition-BDJGKUSR-TbB_U2GW.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-DB-9HDGk.js → use-download-agent-mutation-BdgO7Jmf.js} +2 -2
- package/out/renderer/assets/{use-memberships-query-DJonF1zy.js → use-memberships-query-f3E2Ca39.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-ResXi4IE.js → xychartDiagram-VJFVF3MP-CGIvaGsN.js} +1 -1
- package/out/renderer/console-capture.html +4 -4
- package/out/renderer/index.html +5 -5
- package/out/renderer/installer.html +4 -4
- package/package.json +4 -2
- package/out/renderer/assets/agents-page-DgY_6v2S.js +0 -2
- package/out/renderer/assets/browser-page-BVkXt8Il.js +0 -1
- package/out/renderer/assets/channel-DZvj1zQv.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-CxG-TQSG.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-CxG-TQSG.js +0 -1
- package/out/renderer/assets/clone-CzEyof2a.js +0 -1
- package/out/renderer/assets/index-BjeBA__i.css +0 -1
- package/out/renderer/assets/mesh-page-Bo6Mw1uW.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DesKgCmL.js +0 -1
- /package/out/renderer/assets/{index-C-P4UaBn.js → index-Ci5ykqkd.js} +0 -0
package/out/main/index.js
CHANGED
|
@@ -67,6 +67,7 @@ const mcpOperationId = zod.z.string().regex(/^[a-f0-9]{32}$/);
|
|
|
67
67
|
const mcpCatalogCwd = zod.z.string().min(1).max(4096).regex(/^(\/|[A-Za-z]:[\\/])/);
|
|
68
68
|
const SUBSCRIPTION_ID_PATTERN = /^[a-f0-9]{32}$/;
|
|
69
69
|
const requestId = zod.z.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/);
|
|
70
|
+
const meshId = zod.z.string().regex(/^[A-Za-z0-9_-]{1,128}$/);
|
|
70
71
|
const sessionImage = zod.z.object({
|
|
71
72
|
data_b64: zod.z.string().min(1).max(1e6),
|
|
72
73
|
mime_type: zod.z.enum(["image/png", "image/jpeg", "image/gif", "image/webp"])
|
|
@@ -296,6 +297,24 @@ const desktopRequestUnion = zod.z.discriminatedUnion("op", [
|
|
|
296
297
|
* archived state, and an unarchive control on a row found by search.
|
|
297
298
|
*/
|
|
298
299
|
include_archived: zod.z.boolean().optional(),
|
|
300
|
+
/*
|
|
301
|
+
* Whether conversations OTHER devices hold belong in the answer.
|
|
302
|
+
*
|
|
303
|
+
* ABSENT MEANS `false`, the same compatibility promise `include_archived`
|
|
304
|
+
* makes and for the same reason: the app's own sidebar fetch has always
|
|
305
|
+
* meant "this device's catalogue", and a client that predates the mesh must
|
|
306
|
+
* keep reading exactly that. The Mesh tab is the ONE surface that asks for
|
|
307
|
+
* the federated list, because "which conversation is on which device" is its
|
|
308
|
+
* question and it cannot answer it from `session_count` alone.
|
|
309
|
+
*
|
|
310
|
+
* THE COST IS NOT ZERO, which is why only that surface asks: the backend's
|
|
311
|
+
* peer projection dials each peer's relay under a 12 s fan-out budget and is
|
|
312
|
+
* TTL-cached at 20 s (`network/relay.py`, `session/peer_rows.py`), while a
|
|
313
|
+
* machine in no network short-circuits to no call at all — so the flag costs
|
|
314
|
+
* a paired device one cached fan-out per cadence, and an unpaired one
|
|
315
|
+
* nothing. The sidebar's two-second poll must never carry it.
|
|
316
|
+
*/
|
|
317
|
+
include_peers: zod.z.boolean().optional(),
|
|
299
318
|
/*
|
|
300
319
|
* The four parameters that make the catalogue PAGEABLE, and the switch that
|
|
301
320
|
* makes the daemon count it.
|
|
@@ -1384,14 +1403,81 @@ const desktopRequestUnion = zod.z.discriminatedUnion("op", [
|
|
|
1384
1403
|
* UI that could would have to re-implement the relay's authorisation model in
|
|
1385
1404
|
* JavaScript.
|
|
1386
1405
|
*
|
|
1387
|
-
* THE MUTATING MESH OPS
|
|
1388
|
-
*
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1391
|
-
*
|
|
1406
|
+
* THE MUTATING MESH OPS LANDED WITH THE SURFACES THAT USE THEM (slice 2: the drag
|
|
1407
|
+
* layer, the invite action, the member list), which is the rule this block stated
|
|
1408
|
+
* while they were still absent: a request schema entry with no caller is a
|
|
1409
|
+
* capability this app advertises but cannot exercise.
|
|
1410
|
+
*
|
|
1411
|
+
* `features.session_transfer` gates the TRANSFER and only it (`capabilities.py`):
|
|
1412
|
+
* a backend can host a network, mint invites and remove members without being able
|
|
1413
|
+
* to move a conversation, and the surfaces that gate on the wrong key draw a
|
|
1414
|
+
* control that 404s. The three ops below therefore sit behind different keys —
|
|
1415
|
+
* `networks.invite`/`networks.member.remove` behind `features.peers` (they are
|
|
1416
|
+
* routes the mesh itself introduced), `sessions.transfer` behind
|
|
1417
|
+
* `features.session_transfer`.
|
|
1418
|
+
*
|
|
1419
|
+
* WHAT TRAVELS, AND WHAT DOES NOT. `to` is the destination device id or the
|
|
1420
|
+
* literal `"local"` (a RECALL), because that is the route's own shape: one route,
|
|
1421
|
+
* two protocols, and the direction is decided by which of the two ends is asking
|
|
1422
|
+
* — see `guide://network`. `request_id` is minted by the CALLER and is what makes
|
|
1423
|
+
* a retry replay a recorded outcome instead of starting a second move for a
|
|
1424
|
+
* request that may still be running, so it is sent on every drop rather than kept
|
|
1425
|
+
* for a retry path this surface does not have.
|
|
1392
1426
|
*/
|
|
1393
1427
|
zod.z.object({ op: zod.z.literal("peers.list") }).strict(),
|
|
1394
1428
|
zod.z.object({ op: zod.z.literal("networks.list") }).strict(),
|
|
1429
|
+
/*
|
|
1430
|
+
* Mint an invite. `role` is the joined device's own role in the network and
|
|
1431
|
+
* `device` BINDS the token to one device id, so a token intercepted on its way to
|
|
1432
|
+
* another machine cannot be redeemed by a third one. The token itself NEVER
|
|
1433
|
+
* crosses this API (the receipt carries a path, and it is written where the
|
|
1434
|
+
* renderer cannot read it) — which is why the answer is a receipt and not a
|
|
1435
|
+
* secret.
|
|
1436
|
+
*/
|
|
1437
|
+
zod.z.object({
|
|
1438
|
+
op: zod.z.literal("networks.invite"),
|
|
1439
|
+
networkId: meshId,
|
|
1440
|
+
role: zod.z.enum(["read", "drive", "admin"]),
|
|
1441
|
+
deviceId: meshId.optional()
|
|
1442
|
+
}).strict(),
|
|
1443
|
+
/*
|
|
1444
|
+
* Revoke a membership. `confirm` is the NETWORK'S NAME, typed by the user, and
|
|
1445
|
+
* the route compares it exactly: this is the one mesh act that changes other
|
|
1446
|
+
* devices' state (every peer is rekeyed and the removed device is locked out on
|
|
1447
|
+
* its next handshake), so the request must carry what the user was shown rather
|
|
1448
|
+
* than a bool a stray retry could also send.
|
|
1449
|
+
*/
|
|
1450
|
+
zod.z.object({
|
|
1451
|
+
op: zod.z.literal("networks.member.remove"),
|
|
1452
|
+
networkId: meshId,
|
|
1453
|
+
deviceId: meshId,
|
|
1454
|
+
confirm: zod.z.string().min(1).max(256)
|
|
1455
|
+
}).strict(),
|
|
1456
|
+
/*
|
|
1457
|
+
* Ask a device to take a conversation, or ask THIS device to take one back.
|
|
1458
|
+
*
|
|
1459
|
+
* THE DIRECTION IS THE PROTOCOL'S, not a UI preference: there is no push verb, so
|
|
1460
|
+
* a drop on a peer is this device asking that peer to PULL (`to: <device_id>`),
|
|
1461
|
+
* and a drop on this device is a recall (`to: "local"`). `keep` is the reversible
|
|
1462
|
+
* half — it mints a new id at the destination and leaves the source running —
|
|
1463
|
+
* while a move deletes the source's copy once the handoff commits, which is why
|
|
1464
|
+
* `source_retired = (mode == "move")` on the receipt.
|
|
1465
|
+
*
|
|
1466
|
+
* `wait_s` is a CEILING ON WAITING INSIDE THE REQUEST, not a promise: the route
|
|
1467
|
+
* returns as soon as it has a definite outcome, and a `busy` source refuses
|
|
1468
|
+
* rather than being interrupted. The desktop's own deadline for this op is
|
|
1469
|
+
* derived from the route's published bound rather than from the 20 s control
|
|
1470
|
+
* budget (see `moveClientBoundMs`) — the defect this avoids is a client that gives
|
|
1471
|
+
* up first and reports its own timeout for a move the backend was about to answer.
|
|
1472
|
+
*/
|
|
1473
|
+
zod.z.object({
|
|
1474
|
+
op: zod.z.literal("sessions.transfer"),
|
|
1475
|
+
sessionId,
|
|
1476
|
+
to: zod.z.union([zod.z.literal("local"), meshId]),
|
|
1477
|
+
keep: zod.z.boolean().optional(),
|
|
1478
|
+
waitS: zod.z.number().min(0).max(300).optional(),
|
|
1479
|
+
requestId: requestId.optional()
|
|
1480
|
+
}).strict(),
|
|
1395
1481
|
/*
|
|
1396
1482
|
* The Projects surface (`/v1/desktop/projects*`), APPENDED to the union
|
|
1397
1483
|
* rather than inserted beside the other catalogue ops: the backend serves
|
|
@@ -1592,7 +1678,23 @@ const LONG_READ_OPS = /* @__PURE__ */ new Set([
|
|
|
1592
1678
|
...PROVIDER_READ_OPS,
|
|
1593
1679
|
...MESH_READ_OPS
|
|
1594
1680
|
]);
|
|
1595
|
-
|
|
1681
|
+
const MOVE_OP_DEADLINE_S = 90;
|
|
1682
|
+
const MOVE_OFFLOAD_CONFIRM_S = 30;
|
|
1683
|
+
const MOVE_COPY_WAIT_S = 300;
|
|
1684
|
+
const MOVE_CONTROL_SLACK_S = 10;
|
|
1685
|
+
const MOVE_CLIENT_MARGIN_S = 15;
|
|
1686
|
+
const MOVE_APP_MARGIN_MS = 1e4;
|
|
1687
|
+
function moveClientBoundMs(shape) {
|
|
1688
|
+
const recall = shape.to === "local";
|
|
1689
|
+
const hold = recall || shape.keep ? MOVE_COPY_WAIT_S : MOVE_OFFLOAD_CONFIRM_S;
|
|
1690
|
+
const waitS = Math.max(0, shape.waitS ?? 0);
|
|
1691
|
+
return (MOVE_OP_DEADLINE_S + hold + MOVE_CONTROL_SLACK_S + MOVE_CLIENT_MARGIN_S) * 1e3 + waitS * 1e3;
|
|
1692
|
+
}
|
|
1693
|
+
function desktopRequestDeadlineMs(request) {
|
|
1694
|
+
if (typeof request !== "string" && request.op === "sessions.transfer") {
|
|
1695
|
+
return moveClientBoundMs(request) + MOVE_APP_MARGIN_MS;
|
|
1696
|
+
}
|
|
1697
|
+
const op = typeof request === "string" ? request : request.op;
|
|
1596
1698
|
return LONG_READ_OPS.has(op) ? DESKTOP_LONG_READ_DEADLINE_MS : DESKTOP_CONTROL_DEADLINE_MS;
|
|
1597
1699
|
}
|
|
1598
1700
|
const DESKTOP_DEADLINE_EXCEEDED_CODE = "deadline_exceeded";
|
|
@@ -1654,6 +1756,12 @@ const PANEL_READ_OPS = /* @__PURE__ */ new Set([
|
|
|
1654
1756
|
function desktopRequestDeadlineDetail(op, deadlineMs) {
|
|
1655
1757
|
const seconds = Math.round(deadlineMs / 1e3);
|
|
1656
1758
|
const code = DESKTOP_DEADLINE_EXCEEDED_CODE;
|
|
1759
|
+
if (op === "sessions.transfer") {
|
|
1760
|
+
return {
|
|
1761
|
+
code,
|
|
1762
|
+
message: `The app waits up to ${seconds} seconds for a move, and it was still running when the app stopped waiting. The move was asked for, so its outcome is unknown from here: read the session again before moving it anywhere else.`
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1657
1765
|
if (READ_ONLY_OPS.has(op)) {
|
|
1658
1766
|
return {
|
|
1659
1767
|
code,
|
|
@@ -1713,6 +1821,46 @@ function desktopEndpoint(request) {
|
|
|
1713
1821
|
return { path: "/v1/desktop/peers", method: "GET" };
|
|
1714
1822
|
case "networks.list":
|
|
1715
1823
|
return { path: "/v1/desktop/networks", method: "GET" };
|
|
1824
|
+
/*
|
|
1825
|
+
* THE THREE MESH WRITES. Each path segment is `encodeURIComponent`ed even
|
|
1826
|
+
* though `meshId` already refuses `/`, `.` and `%`: the schema is this
|
|
1827
|
+
* client's check, and a redirect or a hand-built request must not be able to
|
|
1828
|
+
* turn a device id into a path fragment. `device: null` on an invite is the
|
|
1829
|
+
* route's own "unbound token" — an invite any device may redeem once.
|
|
1830
|
+
*/
|
|
1831
|
+
case "networks.invite":
|
|
1832
|
+
return {
|
|
1833
|
+
path: `/v1/desktop/networks/${encodeURIComponent(request.networkId)}/invite`,
|
|
1834
|
+
method: "POST",
|
|
1835
|
+
body: { role: request.role, device: request.deviceId ?? null }
|
|
1836
|
+
};
|
|
1837
|
+
case "networks.member.remove":
|
|
1838
|
+
return {
|
|
1839
|
+
path: `/v1/desktop/networks/${encodeURIComponent(request.networkId)}/members/${encodeURIComponent(request.deviceId)}`,
|
|
1840
|
+
method: "DELETE",
|
|
1841
|
+
// The NETWORK'S NAME, as typed: see the op's own comment for why the
|
|
1842
|
+
// route takes a name rather than a bool.
|
|
1843
|
+
body: { confirm: request.confirm }
|
|
1844
|
+
};
|
|
1845
|
+
case "sessions.transfer":
|
|
1846
|
+
return {
|
|
1847
|
+
path: `/v1/desktop/sessions/${encodeURIComponent(request.sessionId)}/transfer`,
|
|
1848
|
+
method: "POST",
|
|
1849
|
+
body: {
|
|
1850
|
+
to: request.to,
|
|
1851
|
+
// Sent explicitly rather than omitted-when-false: `keep` decides whether
|
|
1852
|
+
// the SOURCE'S COPY IS DELETED, so the request says which move it is
|
|
1853
|
+
// rather than leaving the route's default to answer for a drop a user
|
|
1854
|
+
// made from a menu that offered the copy.
|
|
1855
|
+
keep: request.keep ?? false,
|
|
1856
|
+
wait_s: request.waitS ?? 0,
|
|
1857
|
+
// Omitted while absent, and this one is load-bearing: the route
|
|
1858
|
+
// journals an UNCONFIRMED move under this key so a retry replays the
|
|
1859
|
+
// recorded outcome instead of moving twice, and a request with no key
|
|
1860
|
+
// is a different (unjournalled) request on purpose.
|
|
1861
|
+
...request.requestId ? { request_id: request.requestId } : {}
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1716
1864
|
case "profiles.list":
|
|
1717
1865
|
return { path: "/v1/desktop/profiles", method: "GET" };
|
|
1718
1866
|
case "profiles.get":
|
|
@@ -1769,6 +1917,7 @@ function desktopEndpoint(request) {
|
|
|
1769
1917
|
if (request.scope_name) params.set("scope_name", request.scope_name);
|
|
1770
1918
|
if (request.cursor) params.set("cursor", request.cursor);
|
|
1771
1919
|
if (request.with_counts) params.set("with_counts", "true");
|
|
1920
|
+
if (request.include_peers) params.set("include_peers", "true");
|
|
1772
1921
|
return {
|
|
1773
1922
|
path: `/v1/desktop/sessions?${params}`,
|
|
1774
1923
|
method: "GET"
|
|
@@ -6166,7 +6315,7 @@ async function requestDesktopOutcome(input, backendUrl, token) {
|
|
|
6166
6315
|
}
|
|
6167
6316
|
const target2 = desktopEndpoint(request);
|
|
6168
6317
|
let answered = false;
|
|
6169
|
-
const deadlineMs = desktopRequestDeadlineMs(request
|
|
6318
|
+
const deadlineMs = desktopRequestDeadlineMs(request);
|
|
6170
6319
|
try {
|
|
6171
6320
|
const body = target2.body === void 0 ? void 0 : JSON.stringify(target2.body);
|
|
6172
6321
|
if (body && Buffer.byteLength(body) > desktopRequestByteBudget(request.op)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o,c as b,g as v,k as O,h as P,j as p,l as w,m as A,n as x,t as c,o as N}from"./_baseUniq-
|
|
1
|
+
import{e as o,c as b,g as v,k as O,h as P,j as p,l as w,m as A,n as x,t as c,o as N}from"./_baseUniq-7Lo40p8f.js";import{as as g,aa as y,at as E,au as F,av as M,aw as I,ax as _,ay as $,az as B,aA as T}from"./mermaid.core-CF1Z-P7X.js";var S=/\s/;function z(n){for(var r=n.length;r--&&S.test(n.charAt(r)););return r}var G=/^\s+/;function H(n){return n&&n.slice(0,z(n)+1).replace(G,"")}var m=NaN,L=/^[-+]0x[0-9a-f]+$/i,R=/^0b[01]+$/i,q=/^0o[0-7]+$/i,C=parseInt;function K(n){if(typeof n=="number")return n;if(o(n))return m;if(g(n)){var r=typeof n.valueOf=="function"?n.valueOf():n;n=g(r)?r+"":r}if(typeof n!="string")return n===0?n:+n;n=H(n);var t=R.test(n);return t||q.test(n)?C(n.slice(2),t?2:8):L.test(n)?m:+n}var W=1/0,X=17976931348623157e292;function Y(n){if(!n)return n===0?n:0;if(n=K(n),n===W||n===-1/0){var r=n<0?-1:1;return r*X}return n===n?n:0}function D(n){var r=Y(n),t=r%1;return r===r?t?r-t:r:0}function fn(n){var r=n==null?0:n.length;return r?b(n):[]}var l=Object.prototype,J=l.hasOwnProperty,dn=y(function(n,r){n=Object(n);var t=-1,e=r.length,a=e>2?r[2]:void 0;for(a&&E(r[0],r[1],a)&&(e=1);++t<e;)for(var f=r[t],i=F(f),s=-1,d=i.length;++s<d;){var u=i[s],h=n[u];(h===void 0||M(h,l[u])&&!J.call(n,u))&&(n[u]=f[u])}return n});function un(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}function Q(n){return function(r,t,e){var a=Object(r);if(!I(r)){var f=v(t);r=O(r),t=function(s){return f(a[s],s,a)}}var i=n(r,t,e);return i>-1?a[f?r[i]:i]:void 0}}var U=Math.max;function Z(n,r,t){var e=n==null?0:n.length;if(!e)return-1;var a=t==null?0:D(t);return a<0&&(a=U(e+a,0)),P(n,v(r),a)}var hn=Q(Z);function V(n,r){var t=-1,e=I(n)?Array(n.length):[];return p(n,function(a,f,i){e[++t]=r(a,f,i)}),e}function gn(n,r){var t=_(n)?w:V;return t(n,v(r))}var j=Object.prototype,k=j.hasOwnProperty;function nn(n,r){return n!=null&&k.call(n,r)}function vn(n,r){return n!=null&&A(n,r,nn)}function rn(n,r){return n<r}function tn(n,r,t){for(var e=-1,a=n.length;++e<a;){var f=n[e],i=r(f);if(i!=null&&(s===void 0?i===i&&!o(i):t(i,s)))var s=i,d=f}return d}function mn(n){return n&&n.length?tn(n,$,rn):void 0}function an(n,r,t,e){if(!g(n))return n;r=x(r,n);for(var a=-1,f=r.length,i=f-1,s=n;s!=null&&++a<f;){var d=c(r[a]),u=t;if(d==="__proto__"||d==="constructor"||d==="prototype")return n;if(a!=i){var h=s[d];u=void 0,u===void 0&&(u=g(h)?h:B(r[a+1])?[]:{})}T(s,d,u),s=s[d]}return n}function on(n,r,t){for(var e=-1,a=r.length,f={};++e<a;){var i=r[e],s=N(n,i);t(s,i)&&an(f,x(i,n),s)}return f}export{rn as a,tn as b,V as c,on as d,mn as e,fn as f,hn as g,vn as h,dn as i,D as j,un as l,gn as m,Y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aH as S,aI as Rn,ax as T,aJ as w,aK as xn,aL as Mn,aw as sn,aM as mn,aN as un,aO as x,au as U,aP as Cn,aQ as on,aR as Fn,aS as E,aF as gn,aT as R,as as ln,aU as Dn,aV as D,aW as Gn,aX as Un,aY as _,aA as Nn,aZ as Bn,av as Kn,a_ as X,a$ as Hn,b0 as jn,az as Yn,ay as cn,aD as Zn,b1 as m}from"./mermaid.core-CHO9EN5d.js";var qn="[object Symbol]";function N(n){return typeof n=="symbol"||S(n)&&Rn(n)==qn}function dn(n,r){for(var e=-1,t=n==null?0:n.length,a=Array(t);++e<t;)a[e]=r(n[e],e,n);return a}var J=w?w.prototype:void 0,Q=J?J.toString:void 0;function pn(n){if(typeof n=="string")return n;if(T(n))return dn(n,pn)+"";if(N(n))return Q?Q.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Xn(){}function An(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Jn(n,r,e,t){for(var a=n.length,i=e+-1;++i<a;)if(r(n[i],i,n))return i;return-1}function Qn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,a=n.length;++t<a;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Jn(n,Qn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):Mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||N(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,ar=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,a,i){r.push(a?i.replace(ir,"$1"):t||e)}),r});function fr(n){return n==null?"":pn(n)}function yn(n,r){return T(n)?n:B(n,r)?[n]:ar(fr(n))}function M(n){if(typeof n=="string"||N(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function bn(n,r){r=yn(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[M(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:bn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,a=n.length;++e<t;)n[a+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,a){var i=-1,f=n.length;for(e||(e=ur),a||(a=[]);++i<f;){var s=n[i];e(s)?K(a,s):t||(a[a.length]=s)}return a}function or(n,r,e,t){var a=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++a]);++a<i;)e=r(e,n[a],a,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,U(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,a=0,i=[];++e<t;){var f=n[e];r(f,e,n)&&(i[a++]=f)}return i}function hn(){return[]}var cr=Object.prototype,dr=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,H=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return dr.call(n,r)}))}:hn;function pr(n,r){return x(n,H(n),r)}var Ar=Object.getOwnPropertySymbols,wn=Ar?function(n){for(var r=[];n;)K(r,H(n)),n=Cn(n);return r}:hn;function yr(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,H)}function br(n){return On(n,U,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Ir="[object Date]",Pr="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",Mr="[object Symbol]",mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Ur="[object Int16Array]",Nr="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",Hr="[object Uint16Array]",jr="[object Uint32Array]";function Yr(n,r,e){var t=n.constructor;switch(r){case mr:return on(n);case Er:case Ir:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Ur:case Nr:case Br:case Kr:case Hr:case jr:return Fn(n,e);case Pr:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case Mr:return Sr(n)}}var Zr="[object Map]";function qr(n){return S(n)&&E(n)==Zr}var nn=R&&R.isMap,Xr=nn?gn(nn):qr,Jr="[object Set]";function Qr(n){return S(n)&&E(n)==Jr}var rn=R&&R.isSet,Wr=rn?gn(rn):Qr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",ae="[object Map]",fe="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",de="[object DataView]",pe="[object Float32Array]",Ae="[object Float64Array]",ye="[object Int8Array]",be="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[de]=g[re]=g[ee]=g[pe]=g[Ae]=g[ye]=g[be]=g[Te]=g[ae]=g[fe]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,a,i){var f,s=r&zr,u=r&Vr,d=r&kr;if(f!==void 0)return f;if(!ln(n))return n;var l=T(n);if(l){if(f=wr(n),!s)return Dn(n,f)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!a){if(f=u||c?{}:Un(n),!s)return u?yr(n,lr(f,n)):pr(n,gr(f,n))}else{if(!g[o])return a?n:{};f=Yr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,f),Wr(n)?n.forEach(function(p){f.add(C(p,r,e,p,n,i))}):Xr(n)&&n.forEach(function(p,A){f.set(A,C(p,r,e,A,n,i))});var y=d?u?br:G:u?U:$,b=l?void 0:y(n);return An(b||n,function(p,A){b&&(A=p,p=n[A]),Nn(f,A,C(p,r,e,A,n,i))}),f}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function I(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}I.prototype.add=I.prototype.push=Se;I.prototype.has=Ee;function Ie(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Pe=1,ve=2;function In(n,r,e,t,a,i){var f=e&Pe,s=n.length,u=r.length;if(s!=u&&!(f&&u>s))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var o=-1,c=!0,h=e&ve?new I:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var y=n[o],b=r[o];if(t)var p=f?t(b,y,o,r,n,i):t(y,b,o,n,r,i);if(p!==void 0){if(p)continue;c=!1;break}if(h){if(!Ie(r,function(A,O){if(!En(h,O)&&(y===A||a(y,A,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(y===b||a(y,b,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,a){e[++r]=[a,t]}),e}function j(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,Me="[object Boolean]",me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ue="[object Set]",Ne="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",He="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function je(n,r,e,t,a,i,f){switch(e){case He:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new X(n),new X(r)));case Me:case me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ne:return n==r+"";case Fe:var s=Le;case Ue:var u=tℜif(s||(s=j),n.size!=r.size&&!u)return!1;var d=f.get(n);if(d)return d==r;t|=xe,f.set(n,r);var l=In(s(n),s(r),t,a,i,f);return f.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var Ye=1,Ze=Object.prototype,qe=Ze.hasOwnProperty;function Xe(n,r,e,t,a,i){var f=e&Ye,s=G(n),u=s.length,d=G(r),l=d.length;if(u!=l&&!f)return!1;for(var o=u;o--;){var c=s[o];if(!(f?c in r:qe.call(r,c)))return!1}var h=i.get(n),y=i.get(r);if(h&&y)return h==r&&y==n;var b=!0;i.set(n,r),i.set(r,n);for(var p=f;++o<u;){c=s[o];var A=n[c],O=r[c];if(t)var q=f?t(O,A,c,r,n,i):t(A,O,c,n,r,i);if(!(q===void 0?A===O||a(A,O,e,t,i):q)){b=!1;break}p||(p=c=="constructor")}if(b&&!p){var P=n.constructor,v=r.constructor;P!=v&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof v=="function"&&v instanceof v)&&(b=!1)}return i.delete(n),i.delete(r),b}var Je=1,tn="[object Arguments]",an="[object Array]",L="[object Object]",Qe=Object.prototype,fn=Qe.hasOwnProperty;function We(n,r,e,t,a,i){var f=T(n),s=T(r),u=f?an:E(n),d=s?an:E(r);u=u==tn?L:u,d=d==tn?L:d;var l=u==L,o=d==L,c=u==d;if(c&&D(n)){if(!D(r))return!1;f=!0,l=!1}if(c&&!l)return i||(i=new _),f||Hn(n)?In(n,r,e,t,a,i):je(n,r,u,e,t,a,i);if(!(e&Je)){var h=l&&fn.call(n,"__wrapped__"),y=o&&fn.call(r,"__wrapped__");if(h||y){var b=h?n.value():n,p=y?r.value():r;return i||(i=new _),a(b,p,e,t,i)}}return c?(i||(i=new _),Xe(n,r,e,t,a,i)):!1}function Y(n,r,e,t,a){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,Y,a)}var ze=1,Ve=2;function ke(n,r,e,t){var a=e.length,i=a;if(n==null)return!i;for(n=Object(n);a--;){var f=e[a];if(f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++a<i;){f=e[a];var s=f[0],u=n[s],d=f[1];if(f[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?Y(d,u,ze|Ve,t,l):o))return!1}}return!0}function Pn(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],a=n[t];r[e]=[t,a,Pn(a)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=yn(r,n);for(var t=-1,a=r.length,i=!1;++t<a;){var f=M(r[t]);if(!(i=n!=null&&e(n,f)))break;n=n[f]}return i||++t!=a?i:(a=n==null?0:n.length,!!a&&jn(a)&&Yn(f,a)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var at=1,ft=2;function st(n,r){return B(n)&&Pn(r)?vn(M(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):Y(r,t,at|ft)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return bn(r,n)}}function gt(n){return B(n)?ut(M(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Zn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var a=e.length,i=-1,f=Object(e);++i<a&&t(f[i],i,f)!==!1;);return e}}var Z=ct(lt);function dt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?An:Z;return e(n,dt(r))}function pt(n,r){var e=[];return Z(n,function(t,a,i){r(t,a,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:pt;return e(n,Ln(r))}function At(n,r){return dn(r,function(e){return n[e]})}function St(n){return n==null?[]:At(n,$(n))}function Et(n){return n===void 0}function yt(n,r,e,t,a){return a(n,function(i,f,s){e=t?(t=!1,i):r(e,i,f,s)}),e}function It(n,r,e){var t=T(n)?or:yt,a=arguments.length<3;return t(n,Ln(r),e,a,Z)}var bt=1/0,Tt=m&&1/j(new m([,-0]))[1]==bt?function(n){return new m(n)}:Xn,ht=200;function Pt(n,r,e){var t=-1,a=Vn,i=n.length,f=!0,s=[],u=s;if(i>=ht){var d=r?null:Tt(n);if(d)return j(d);f=!1,a=En,u=new I}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,f&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else a(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,pt as B,Ie as C,Xn as D,I as S,Pt as a,C as b,Ot as c,$t as d,N as e,_t as f,Ln as g,Jn as h,Et as i,Z as j,$ as k,dn as l,tt as m,yn as n,bn as o,dt as p,lt as q,It as r,it as s,M as t,fr as u,St as v,Vn as w,En as x,zn as y,br as z};
|
|
1
|
+
import{aH as S,aI as Rn,ax as T,aJ as w,aK as xn,aL as Mn,aw as sn,aM as mn,aN as un,aO as x,au as U,aP as Cn,aQ as on,aR as Fn,aS as E,aF as gn,aT as R,as as ln,aU as Dn,aV as D,aW as Gn,aX as Un,aY as _,aA as Nn,aZ as Bn,av as Kn,a_ as X,a$ as Hn,b0 as jn,az as Yn,ay as cn,aD as Zn,b1 as m}from"./mermaid.core-CF1Z-P7X.js";var qn="[object Symbol]";function N(n){return typeof n=="symbol"||S(n)&&Rn(n)==qn}function dn(n,r){for(var e=-1,t=n==null?0:n.length,a=Array(t);++e<t;)a[e]=r(n[e],e,n);return a}var J=w?w.prototype:void 0,Q=J?J.toString:void 0;function pn(n){if(typeof n=="string")return n;if(T(n))return dn(n,pn)+"";if(N(n))return Q?Q.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Xn(){}function An(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Jn(n,r,e,t){for(var a=n.length,i=e+-1;++i<a;)if(r(n[i],i,n))return i;return-1}function Qn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,a=n.length;++t<a;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Jn(n,Qn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):Mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||N(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,ar=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,a,i){r.push(a?i.replace(ir,"$1"):t||e)}),r});function fr(n){return n==null?"":pn(n)}function yn(n,r){return T(n)?n:B(n,r)?[n]:ar(fr(n))}function M(n){if(typeof n=="string"||N(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function bn(n,r){r=yn(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[M(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:bn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,a=n.length;++e<t;)n[a+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,a){var i=-1,f=n.length;for(e||(e=ur),a||(a=[]);++i<f;){var s=n[i];e(s)?K(a,s):t||(a[a.length]=s)}return a}function or(n,r,e,t){var a=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++a]);++a<i;)e=r(e,n[a],a,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,U(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,a=0,i=[];++e<t;){var f=n[e];r(f,e,n)&&(i[a++]=f)}return i}function hn(){return[]}var cr=Object.prototype,dr=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,H=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return dr.call(n,r)}))}:hn;function pr(n,r){return x(n,H(n),r)}var Ar=Object.getOwnPropertySymbols,wn=Ar?function(n){for(var r=[];n;)K(r,H(n)),n=Cn(n);return r}:hn;function yr(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,H)}function br(n){return On(n,U,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Ir="[object Date]",Pr="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",Mr="[object Symbol]",mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Ur="[object Int16Array]",Nr="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",Hr="[object Uint16Array]",jr="[object Uint32Array]";function Yr(n,r,e){var t=n.constructor;switch(r){case mr:return on(n);case Er:case Ir:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Ur:case Nr:case Br:case Kr:case Hr:case jr:return Fn(n,e);case Pr:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case Mr:return Sr(n)}}var Zr="[object Map]";function qr(n){return S(n)&&E(n)==Zr}var nn=R&&R.isMap,Xr=nn?gn(nn):qr,Jr="[object Set]";function Qr(n){return S(n)&&E(n)==Jr}var rn=R&&R.isSet,Wr=rn?gn(rn):Qr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",ae="[object Map]",fe="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",de="[object DataView]",pe="[object Float32Array]",Ae="[object Float64Array]",ye="[object Int8Array]",be="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[de]=g[re]=g[ee]=g[pe]=g[Ae]=g[ye]=g[be]=g[Te]=g[ae]=g[fe]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,a,i){var f,s=r&zr,u=r&Vr,d=r&kr;if(f!==void 0)return f;if(!ln(n))return n;var l=T(n);if(l){if(f=wr(n),!s)return Dn(n,f)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!a){if(f=u||c?{}:Un(n),!s)return u?yr(n,lr(f,n)):pr(n,gr(f,n))}else{if(!g[o])return a?n:{};f=Yr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,f),Wr(n)?n.forEach(function(p){f.add(C(p,r,e,p,n,i))}):Xr(n)&&n.forEach(function(p,A){f.set(A,C(p,r,e,A,n,i))});var y=d?u?br:G:u?U:$,b=l?void 0:y(n);return An(b||n,function(p,A){b&&(A=p,p=n[A]),Nn(f,A,C(p,r,e,A,n,i))}),f}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function I(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}I.prototype.add=I.prototype.push=Se;I.prototype.has=Ee;function Ie(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Pe=1,ve=2;function In(n,r,e,t,a,i){var f=e&Pe,s=n.length,u=r.length;if(s!=u&&!(f&&u>s))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var o=-1,c=!0,h=e&ve?new I:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var y=n[o],b=r[o];if(t)var p=f?t(b,y,o,r,n,i):t(y,b,o,n,r,i);if(p!==void 0){if(p)continue;c=!1;break}if(h){if(!Ie(r,function(A,O){if(!En(h,O)&&(y===A||a(y,A,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(y===b||a(y,b,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,a){e[++r]=[a,t]}),e}function j(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,Me="[object Boolean]",me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ue="[object Set]",Ne="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",He="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function je(n,r,e,t,a,i,f){switch(e){case He:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new X(n),new X(r)));case Me:case me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ne:return n==r+"";case Fe:var s=Le;case Ue:var u=tℜif(s||(s=j),n.size!=r.size&&!u)return!1;var d=f.get(n);if(d)return d==r;t|=xe,f.set(n,r);var l=In(s(n),s(r),t,a,i,f);return f.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var Ye=1,Ze=Object.prototype,qe=Ze.hasOwnProperty;function Xe(n,r,e,t,a,i){var f=e&Ye,s=G(n),u=s.length,d=G(r),l=d.length;if(u!=l&&!f)return!1;for(var o=u;o--;){var c=s[o];if(!(f?c in r:qe.call(r,c)))return!1}var h=i.get(n),y=i.get(r);if(h&&y)return h==r&&y==n;var b=!0;i.set(n,r),i.set(r,n);for(var p=f;++o<u;){c=s[o];var A=n[c],O=r[c];if(t)var q=f?t(O,A,c,r,n,i):t(A,O,c,n,r,i);if(!(q===void 0?A===O||a(A,O,e,t,i):q)){b=!1;break}p||(p=c=="constructor")}if(b&&!p){var P=n.constructor,v=r.constructor;P!=v&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof v=="function"&&v instanceof v)&&(b=!1)}return i.delete(n),i.delete(r),b}var Je=1,tn="[object Arguments]",an="[object Array]",L="[object Object]",Qe=Object.prototype,fn=Qe.hasOwnProperty;function We(n,r,e,t,a,i){var f=T(n),s=T(r),u=f?an:E(n),d=s?an:E(r);u=u==tn?L:u,d=d==tn?L:d;var l=u==L,o=d==L,c=u==d;if(c&&D(n)){if(!D(r))return!1;f=!0,l=!1}if(c&&!l)return i||(i=new _),f||Hn(n)?In(n,r,e,t,a,i):je(n,r,u,e,t,a,i);if(!(e&Je)){var h=l&&fn.call(n,"__wrapped__"),y=o&&fn.call(r,"__wrapped__");if(h||y){var b=h?n.value():n,p=y?r.value():r;return i||(i=new _),a(b,p,e,t,i)}}return c?(i||(i=new _),Xe(n,r,e,t,a,i)):!1}function Y(n,r,e,t,a){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,Y,a)}var ze=1,Ve=2;function ke(n,r,e,t){var a=e.length,i=a;if(n==null)return!i;for(n=Object(n);a--;){var f=e[a];if(f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++a<i;){f=e[a];var s=f[0],u=n[s],d=f[1];if(f[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?Y(d,u,ze|Ve,t,l):o))return!1}}return!0}function Pn(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],a=n[t];r[e]=[t,a,Pn(a)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=yn(r,n);for(var t=-1,a=r.length,i=!1;++t<a;){var f=M(r[t]);if(!(i=n!=null&&e(n,f)))break;n=n[f]}return i||++t!=a?i:(a=n==null?0:n.length,!!a&&jn(a)&&Yn(f,a)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var at=1,ft=2;function st(n,r){return B(n)&&Pn(r)?vn(M(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):Y(r,t,at|ft)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return bn(r,n)}}function gt(n){return B(n)?ut(M(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Zn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var a=e.length,i=-1,f=Object(e);++i<a&&t(f[i],i,f)!==!1;);return e}}var Z=ct(lt);function dt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?An:Z;return e(n,dt(r))}function pt(n,r){var e=[];return Z(n,function(t,a,i){r(t,a,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:pt;return e(n,Ln(r))}function At(n,r){return dn(r,function(e){return n[e]})}function St(n){return n==null?[]:At(n,$(n))}function Et(n){return n===void 0}function yt(n,r,e,t,a){return a(n,function(i,f,s){e=t?(t=!1,i):r(e,i,f,s)}),e}function It(n,r,e){var t=T(n)?or:yt,a=arguments.length<3;return t(n,Ln(r),e,a,Z)}var bt=1/0,Tt=m&&1/j(new m([,-0]))[1]==bt?function(n){return new m(n)}:Xn,ht=200;function Pt(n,r,e){var t=-1,a=Vn,i=n.length,f=!0,s=[],u=s;if(i>=ht){var d=r?null:Tt(n);if(d)return j(d);f=!1,a=En,u=new I}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,f&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else a(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,pt as B,Ie as C,Xn as D,I as S,Pt as a,C as b,Ot as c,$t as d,N as e,_t as f,Ln as g,Jn as h,Et as i,Z as j,$ as k,dn as l,tt as m,yn as n,bn as o,dt as p,lt as q,It as r,it as s,M as t,fr as u,St as v,Vn as w,En as x,zn as y,br as z};
|
package/out/renderer/assets/{agent-details-page-DhkOKq6G.js → agent-details-page-Dr0_4VXU.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as
|
|
1
|
+
import{r as T,j as e,c as G}from"./index-Ci5ykqkd.js";import{l as ue,c as he,u as xe,d as ge,g as je,i as fe,a as pe,b as ye,e as ve}from"./use-memberships-query-f3E2Ca39.js";import{h as ne,g as I,ar as b,as as K,ad as Y,at as B,au as we,av as be,aw as ie,i as re,a as Ce,ae as Ne,ax as Ae,B as ke,ay as Se,az as De,aA as J,ac as Ee,aB as Te,aC as Fe}from"./index-BZY6SC3C.js";import{c as _e,L as Pe,T as ee,B as l,S as M,a as oe,b as z,d as L,e as v,X as qe,f as w,A as te,g as se,h as ae}from"./error-boundary-CAHYSCjh.js";import{f as W,u as ze,i as Le,a as Me,b as Ie,c as Ke,O as Be,H as Oe,A as Qe}from"./use-download-agent-mutation-BdgO7Jmf.js";import"./console-mirror-Dw_ms9Pv.js";import"./en-US-BkS8Ixxl.js";import"./book-open-6gMxcFCn.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Be=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],Re=Pe("message-circle",Be),F={all:["agent-comments"],list:t=>[...F.all,"list",t]},$e=({agentId:t,enabled:r=!0})=>ne({queryKey:F.list(t||"invalid"),queryFn:async()=>{if(!t)throw new Error("Agent ID is required to fetch comments.");return(await ue(t)).result},enabled:!!t&&r,staleTime:2*60*1e3,gcTime:5*60*1e3,refetchOnWindowFocus:!0}),We=()=>{const t=I(),{isAuthenticated:r}=b();return K({mutationFn:async a=>{const{agentId:i,data:s}=a;if(!r)throw new Error("Authentication required.");return he(i,s)},onSuccess:(a,i)=>{t.invalidateQueries({queryKey:F.list(i.agentId)}),O("Comment posted")},onError:a=>{Y(`Failed to post comment: ${a.message}`)}})},Ye=()=>{const t=I(),{isAuthenticated:r}=b();return K({mutationFn:async a=>{const{agentId:i,commentId:s,data:c}=a;if(!r)throw new Error("Authentication required.");return xe(i,s,c)},onSuccess:(a,i)=>{t.invalidateQueries({queryKey:F.list(i.agentId)}),O("Comment updated")},onError:a=>{Y(`Failed to update comment: ${a.message}`)}})},He=()=>{const t=I(),{isAuthenticated:r}=b();return K({mutationFn:async a=>{const{agentId:i,commentId:s}=a;if(!r)throw new Error("Authentication required.");return ge(i,s)},onSuccess:(a,i)=>{t.invalidateQueries({queryKey:F.list(i.agentId)}),O("Comment deleted")},onError:a=>{Y(`Failed to delete comment: ${a.message}`)}})},Je=({agentId:t})=>{const{isAuthenticated:r,user:a}=b(),[i,s]=E.useState(""),[c,f]=E.useState(null),[h,C]=E.useState(""),{data:d,isLoading:P,error:N}=$e({agentId:t}),p=d?.records??[],A=We(),k=Ye(),S=He(),Q=async n=>{if(n.preventDefault(),!(!i.trim()||!r||!t))try{await A.mutateAsync({agentId:t,data:{text:i}}),s("")}catch(o){console.error("Submit comment error caught in component:",o)}},m=(n,o)=>{f(n),C(o)},x=()=>{f(null),C("")},y=async()=>{if(!(!c||!h.trim()||!r||!t))try{await k.mutateAsync({agentId:t,commentId:c,data:{text:h}}),x()}catch(n){console.error("Update comment error caught in component:",n)}},U=async n=>{if(!(!r||!t)&&window.confirm("Are you sure you want to delete this comment?"))try{await S.mutateAsync({agentId:t,commentId:n})}catch(o){console.error("Delete comment error caught in component:",o)}},B=n=>r&&a?.radientUser?.account?.id===n.account_id;return e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"mb-4 font-semibold text-heading text-ink",children:"Comments"}),r?e.jsxs("div",{className:"mb-4 flex flex-col gap-1.5",children:[e.jsxs(_e,{htmlFor:"new-comment",children:[e.jsx(Re,{size:14,"aria-hidden":"true"}),"Leave a comment"]}),e.jsxs("form",{onSubmit:Q,className:"flex flex-col gap-3",children:[e.jsx(ee,{id:"new-comment",placeholder:"Share your thoughts...",rows:3,value:i,onChange:n=>s(n.target.value),required:!0}),e.jsx(l,{type:"submit",variant:"primary",disabled:A.isPending||!i.trim(),className:"self-end",children:A.isPending?e.jsx(z,{size:"sm",label:"Posting comment"}):"Post comment"})]})]}):e.jsx("p",{className:"mt-6 mb-4 text-body-sm text-ink-muted",children:"Sign in to leave comments."}),e.jsx(oe,{className:"my-6"}),P&&e.jsx("ul",{className:"flex flex-col",children:[...Array(3)].map((n,o)=>e.jsxs("li",{className:"flex gap-3 pb-6",children:[e.jsx(L,{children:e.jsx(M,{children:e.jsx(v,{className:"size-full"})})}),e.jsxs("div",{className:"flex w-full flex-col gap-1.5",children:[e.jsx(v,{className:"h-3.5 w-24"}),e.jsx(v,{className:"h-3 w-15"}),e.jsx(v,{className:"mt-2 h-3.5 w-full"}),e.jsx(v,{className:"h-3.5 w-4/5"})]})]},`skeleton-${o}`))}),N&&e.jsxs("p",{role:"alert",className:"my-6 text-body-sm text-danger",children:["Failed to load comments: ",N.message]}),!P&&!N&&e.jsx("ul",{className:"flex flex-col gap-6",children:p.length===0?e.jsx("li",{className:"text-body-sm text-ink-muted",children:"No comments yet. Yours would be the first."}):p.map(n=>c===n.id?e.jsxs("li",{className:"flex gap-3",children:[e.jsx(L,{children:e.jsx(M,{children:n.account_metadata?.name?.charAt(0).toUpperCase()||"?"})}),e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[e.jsx(ee,{rows:3,value:h,onChange:o=>C(o.target.value),autoFocus:!0,"aria-label":"Edit comment"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(l,{variant:"secondary",size:"sm",onClick:x,children:[e.jsx(qe,{}),"Cancel"]}),e.jsxs(l,{variant:"primary",size:"sm",onClick:y,disabled:k.isPending||!h.trim(),children:[k.isPending?e.jsx(z,{size:"xs",label:"Saving comment"}):e.jsx(we,{}),"Save"]})]})]})]},n.id):e.jsxs("li",{className:"flex gap-3",children:[e.jsx(L,{children:e.jsx(M,{children:n.account_metadata?.name?.charAt(0).toUpperCase()||"?"})}),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-body text-ink",children:n.account_metadata?.name||"Anonymous"}),e.jsxs("p",{className:"text-ink-muted text-meta",children:[W(new Date(n.created_at))," ","ago"]})]}),B(n)&&e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx(w,{content:"Edit comment",children:e.jsx(l,{variant:"ghost",size:"icon-sm",onClick:()=>m(n.id,n.text),disabled:!!c,"aria-label":"Edit comment",children:e.jsx(be,{})})}),e.jsx(w,{content:"Delete comment",children:e.jsx(l,{variant:"ghost",size:"icon-sm",onClick:()=>U(n.id),disabled:!!c,"aria-label":"Delete comment",children:e.jsx(ie,{})})})]})]}),e.jsx("p",{className:"mt-2 text-body-sm text-ink whitespace-pre-wrap",children:n.text})]})]},n.id))})]})},H={all:["agent-details"],detail:t=>[...H.all,t]},Ve=({agentId:t,enabled:r=!0})=>ne({queryKey:H.detail(t||"invalid"),queryFn:async()=>{if(!t)throw new Error("Agent ID is required to fetch details.");return await je(t)},select:i=>i.result,enabled:!!t&&r,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1}),Xe=()=>{const t=I(),r=re(),{isAuthenticated:a}=b();return K({mutationFn:async({agentId:s})=>{if(!a)throw new Error("Authentication required to delist an agent.");if(!s)throw new Error("Agent ID is required to delist.");return pe(s)},onSuccess:(s,c)=>{O("Agent delisted"),t.invalidateQueries({queryKey:H.detail(c.agentId)}),fe(t),r("/agent-hub")},onError:s=>{console.error("Delist agent error:",s)}})},Ze={like:"The like did not go through",favourite:"The favourite did not go through",download:"The download did not start",delist:"The agent was not delisted"},$=({children:t})=>e.jsx("span",{className:"inline-flex h-4 min-w-5 items-center text-meta text-ink-muted",children:t}),ot=()=>{const{agentId:t}=Ce(),r=re(),{isAuthenticated:a,user:i}=b(),{data:s,isLoading:c,isFetching:f,error:h,refetch:C}=Ve({agentId:t??"",enabled:!!t}),d=s?.visibility==="org",{memberships:P}=ye({enabled:d}),N=d?P.find(me=>me.tenant_id===s?.tenant_id)?.tenant_name??null:null,{statuses:p,isKnown:A,isError:k,isFetching:S,refetch:Q}=Le({agentIds:t&&!d?[t]:[]}),m=Me(A,p,t),x=m&&p[t??""]?.liked===!0,y=m&&p[t??""]?.favourited===!0,U=s?.like_count??0,B=s?.favourite_count??0,n=s?.download_count??0,o=ze(),_=Ie(),D=Ke(),g=Xe(),[le,q]=E.useState(!1),[j,u]=E.useState(null),R=!!i&&!!s&&i.radientUser?.account?.id===s.account_id,J=()=>{!t||!a||o.isPending||(u(null),o.mutate({agentId:t,isCurrentlyLiked:x},{onError:()=>u("like")}))},V=()=>{!t||!a||_.isPending||(u(null),_.mutate({agentId:t,isCurrentlyFavourited:y},{onError:()=>u("favourite")}))},X=()=>{!t||!s||D.isPending||(u(null),D.mutate({agentId:s.id,agentName:s.name},{onError:()=>u("download")}))},ce=()=>{!t||!R||g.isPending||(u(null),g.mutate({agentId:t},{onError:()=>u("delist")}),q(!1))},T=j?j==="like"?{action:"like",error:o.error,retry:J}:j==="favourite"?{action:"favourite",error:_.error,retry:V}:j==="download"?{action:"download",error:D.error,retry:X}:{action:"delist",error:g.error,retry:void 0}:null,de=()=>{r("/agent-hub")};return c?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(z,{label:"Loading agent details"})}):h?e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs(te,{variant:"danger",className:"max-w-2xl",children:[e.jsx(se,{children:"This agent could not be loaded"}),e.jsx(ae,{children:Ne("The Radient agent catalogue did not answer.",h)}),e.jsx("div",{className:"mt-2",children:e.jsx(l,{variant:"outline",size:"sm",onClick:()=>void C(),disabled:f,"aria-busy":f,children:f?"Trying…":"Try again"})})]})}):s?e.jsxs("div",{className:"m-6 flex flex-1 flex-col rounded-lg border border-hairline bg-surface p-8",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[e.jsx(l,{variant:"ghost",size:"icon",onClick:de,"aria-label":"Back to Agent hub",children:e.jsx(Ae,{})}),e.jsx(L,{className:"size-11 shrink-0",children:e.jsx(M,{children:e.jsx(ke,{size:22,"aria-hidden":"true"})})}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("h1",{className:"truncate text-display text-ink",children:s.name}),d&&e.jsx(Oe,{orgName:N})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!d&&e.jsxs(e.Fragment,{children:[e.jsx(w,{content:"Sign in to Radient to use this feature",disabled:a,children:e.jsx("span",{children:e.jsxs(l,{variant:"ghost",size:"sm",onClick:J,disabled:!a||o.isPending||!m,"aria-label":m?x?"Unlike agent":"Like agent":"Like state unavailable",className:Z(x&&"text-danger"),children:[e.jsx(Qe,{fill:x?"currentColor":"none"}),e.jsx($,{children:U})]})})}),e.jsx(w,{content:"Sign in to Radient to use this feature",disabled:a,children:e.jsx("span",{children:e.jsxs(l,{variant:"ghost",size:"sm",onClick:V,disabled:!a||_.isPending||!m,"aria-label":m?y?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",className:Z(y&&"text-warning"),children:[e.jsx(Se,{fill:y?"currentColor":"none"}),e.jsx($,{children:B})]})})})]}),e.jsx(w,{content:"Download agent to your computer",children:e.jsx("span",{children:e.jsxs(l,{variant:"ghost",size:"icon",onClick:X,disabled:D.isPending,"aria-label":"Download agent",className:"ml-1",children:[e.jsx(De,{}),e.jsx($,{children:D.isPending?e.jsx(v,{className:"h-3.5 w-5"}):n})]})})}),R&&!d&&e.jsx(w,{content:"Permanently delist this agent from Agent hub",children:e.jsx("span",{children:e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>q(!0),disabled:g.isPending,"aria-label":"Delist agent",className:"ml-1 text-danger hover:bg-danger-wash hover:text-danger",children:e.jsx(ie,{})})})})]})]}),a&&k&&!j&&!d&&e.jsxs("output",{className:"mb-6 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-details-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so this agent's viewer state is not shown."}),e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>void Q(),disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})]}),T&&j&&e.jsxs(te,{variant:"danger",className:"mb-6","data-testid":"agent-details-error",children:[e.jsx(se,{children:Ze[j]}),e.jsx(ae,{children:ve(T.action,T.error,s.name)}),T.retry&&e.jsx("div",{className:"mt-2",children:e.jsx(l,{variant:"outline",size:"sm",onClick:T.retry,children:"Try again"})})]}),e.jsx(Ue,{tags:s.tags,categories:s.categories}),e.jsxs("div",{className:"mt-4 mb-6 flex flex-col gap-2 text-body-sm text-ink-muted",children:[e.jsxs("p",{children:["Created by: ",s.account_metadata?.name??"Unknown"," (",s.account_metadata?.email??"No email",")"]}),e.jsxs("p",{children:["Created: ",W(new Date(s.created_at))," ago (",G(s.created_at),")"]}),e.jsxs("p",{children:["Last modified: ",W(new Date(s.updated_at))," ","ago (",G(s.updated_at),")"]})]}),e.jsx("div",{className:"mt-2 mb-8 leading-relaxed text-body text-ink",children:s.description||"No description provided."}),e.jsx(oe,{className:"my-6"}),!d&&e.jsx(Je,{agentId:s.id}),e.jsx(Te,{open:le,onClose:()=>q(!1),title:"Delist this agent?",maxWidth:"xs",actions:e.jsxs(e.Fragment,{children:[e.jsx(Ee,{onClick:()=>q(!1),children:"Cancel"}),e.jsx(Fe,{onClick:()=>{!t||!R||g.isPending||ce()},disabled:g.isPending,children:g.isPending?e.jsx(z,{size:"sm",label:"Delisting agent"}):"Delist"})]}),dialogProps:{"aria-describedby":"delist-dialog-description"},children:e.jsxs("div",{id:"delist-dialog-description",className:"text-body text-ink-muted",children:['This takes "',s.name,'" off the hub straight away, and nobody will be able to download it. You can upload it again later.']})})]}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("p",{className:"text-body text-ink",children:"Agent not found."})})};export{ot as AgentDetailsPage};
|
|
6
|
+
*/const Ue=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],Re=_e("message-circle",Ue),F={all:["agent-comments"],list:t=>[...F.all,"list",t]},$e=({agentId:t,enabled:r=!0})=>ne({queryKey:F.list(t||"invalid"),queryFn:async()=>{if(!t)throw new Error("Agent ID is required to fetch comments.");return(await ue(t)).result},enabled:!!t&&r,staleTime:2*60*1e3,gcTime:5*60*1e3,refetchOnWindowFocus:!0}),We=()=>{const t=I(),{isAuthenticated:r}=b();return K({mutationFn:async a=>{const{agentId:i,data:s}=a;if(!r)throw new Error("Authentication required.");return he(i,s)},onSuccess:(a,i)=>{t.invalidateQueries({queryKey:F.list(i.agentId)}),B("Comment posted")},onError:a=>{Y(`Failed to post comment: ${a.message}`)}})},Ye=()=>{const t=I(),{isAuthenticated:r}=b();return K({mutationFn:async a=>{const{agentId:i,commentId:s,data:c}=a;if(!r)throw new Error("Authentication required.");return xe(i,s,c)},onSuccess:(a,i)=>{t.invalidateQueries({queryKey:F.list(i.agentId)}),B("Comment updated")},onError:a=>{Y(`Failed to update comment: ${a.message}`)}})},He=()=>{const t=I(),{isAuthenticated:r}=b();return K({mutationFn:async a=>{const{agentId:i,commentId:s}=a;if(!r)throw new Error("Authentication required.");return ge(i,s)},onSuccess:(a,i)=>{t.invalidateQueries({queryKey:F.list(i.agentId)}),B("Comment deleted")},onError:a=>{Y(`Failed to delete comment: ${a.message}`)}})},Ve=({agentId:t})=>{const{isAuthenticated:r,user:a}=b(),[i,s]=T.useState(""),[c,f]=T.useState(null),[h,C]=T.useState(""),{data:d,isLoading:_,error:N}=$e({agentId:t}),p=d?.records??[],A=We(),k=Ye(),S=He(),O=async n=>{if(n.preventDefault(),!(!i.trim()||!r||!t))try{await A.mutateAsync({agentId:t,data:{text:i}}),s("")}catch(o){console.error("Submit comment error caught in component:",o)}},m=(n,o)=>{f(n),C(o)},x=()=>{f(null),C("")},y=async()=>{if(!(!c||!h.trim()||!r||!t))try{await k.mutateAsync({agentId:t,commentId:c,data:{text:h}}),x()}catch(n){console.error("Update comment error caught in component:",n)}},Q=async n=>{if(!(!r||!t)&&window.confirm("Are you sure you want to delete this comment?"))try{await S.mutateAsync({agentId:t,commentId:n})}catch(o){console.error("Delete comment error caught in component:",o)}},U=n=>r&&a?.radientUser?.account?.id===n.account_id;return e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"mb-4 font-semibold text-heading text-ink",children:"Comments"}),r?e.jsxs("div",{className:"mb-4 flex flex-col gap-1.5",children:[e.jsxs(Pe,{htmlFor:"new-comment",children:[e.jsx(Re,{size:14,"aria-hidden":"true"}),"Leave a comment"]}),e.jsxs("form",{onSubmit:O,className:"flex flex-col gap-3",children:[e.jsx(ee,{id:"new-comment",placeholder:"Share your thoughts...",rows:3,value:i,onChange:n=>s(n.target.value),required:!0}),e.jsx(l,{type:"submit",variant:"primary",disabled:A.isPending||!i.trim(),className:"self-end",children:A.isPending?e.jsx(M,{size:"sm",label:"Posting comment"}):"Post comment"})]})]}):e.jsx("p",{className:"mt-6 mb-4 text-body-sm text-ink-muted",children:"Sign in to leave comments."}),e.jsx(oe,{className:"my-6"}),_&&e.jsx("ul",{className:"flex flex-col",children:[...Array(3)].map((n,o)=>e.jsxs("li",{className:"flex gap-3 pb-6",children:[e.jsx(z,{children:e.jsx(L,{children:e.jsx(v,{className:"size-full"})})}),e.jsxs("div",{className:"flex w-full flex-col gap-1.5",children:[e.jsx(v,{className:"h-3.5 w-24"}),e.jsx(v,{className:"h-3 w-15"}),e.jsx(v,{className:"mt-2 h-3.5 w-full"}),e.jsx(v,{className:"h-3.5 w-4/5"})]})]},`skeleton-${o}`))}),N&&e.jsxs("p",{role:"alert",className:"my-6 text-body-sm text-danger",children:["Failed to load comments: ",N.message]}),!_&&!N&&e.jsx("ul",{className:"flex flex-col gap-6",children:p.length===0?e.jsx("li",{className:"text-body-sm text-ink-muted",children:"No comments yet. Yours would be the first."}):p.map(n=>c===n.id?e.jsxs("li",{className:"flex gap-3",children:[e.jsx(z,{children:e.jsx(L,{children:n.account_metadata?.name?.charAt(0).toUpperCase()||"?"})}),e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[e.jsx(ee,{rows:3,value:h,onChange:o=>C(o.target.value),autoFocus:!0,"aria-label":"Edit comment"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(l,{variant:"secondary",size:"sm",onClick:x,children:[e.jsx(qe,{}),"Cancel"]}),e.jsxs(l,{variant:"primary",size:"sm",onClick:y,disabled:k.isPending||!h.trim(),children:[k.isPending?e.jsx(M,{size:"xs",label:"Saving comment"}):e.jsx(we,{}),"Save"]})]})]})]},n.id):e.jsxs("li",{className:"flex gap-3",children:[e.jsx(z,{children:e.jsx(L,{children:n.account_metadata?.name?.charAt(0).toUpperCase()||"?"})}),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-body text-ink",children:n.account_metadata?.name||"Anonymous"}),e.jsxs("p",{className:"text-ink-muted text-meta",children:[W(new Date(n.created_at))," ","ago"]})]}),U(n)&&e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx(w,{content:"Edit comment",children:e.jsx(l,{variant:"ghost",size:"icon-sm",onClick:()=>m(n.id,n.text),disabled:!!c,"aria-label":"Edit comment",children:e.jsx(be,{})})}),e.jsx(w,{content:"Delete comment",children:e.jsx(l,{variant:"ghost",size:"icon-sm",onClick:()=>Q(n.id),disabled:!!c,"aria-label":"Delete comment",children:e.jsx(ie,{})})})]})]}),e.jsx("p",{className:"mt-2 text-body-sm text-ink whitespace-pre-wrap",children:n.text})]})]},n.id))})]})},H={all:["agent-details"],detail:t=>[...H.all,t]},Xe=({agentId:t,enabled:r=!0})=>ne({queryKey:H.detail(t||"invalid"),queryFn:async()=>{if(!t)throw new Error("Agent ID is required to fetch details.");return await je(t)},select:i=>i.result,enabled:!!t&&r,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1}),Ze=()=>{const t=I(),r=re(),{isAuthenticated:a}=b();return K({mutationFn:async({agentId:s})=>{if(!a)throw new Error("Authentication required to delist an agent.");if(!s)throw new Error("Agent ID is required to delist.");return pe(s)},onSuccess:(s,c)=>{B("Agent delisted"),t.invalidateQueries({queryKey:H.detail(c.agentId)}),fe(t),r("/agent-hub")},onError:s=>{console.error("Delist agent error:",s)}})},Ge={like:"The like did not go through",favourite:"The favourite did not go through",download:"The download did not start",delist:"The agent was not delisted"},$=({children:t})=>e.jsx("span",{className:"inline-flex h-4 min-w-5 items-center text-meta text-ink-muted",children:t}),ot=()=>{const{agentId:t}=Ce(),r=re(),{isAuthenticated:a,user:i}=b(),{data:s,isLoading:c,isFetching:f,error:h,refetch:C}=Xe({agentId:t??"",enabled:!!t}),d=s?.visibility==="org",{memberships:_}=ye({enabled:d}),N=d?_.find(me=>me.tenant_id===s?.tenant_id)?.tenant_name??null:null,{statuses:p,isKnown:A,isError:k,isFetching:S,refetch:O}=ze({agentIds:t&&!d?[t]:[]}),m=Le(A,p,t),x=m&&p[t??""]?.liked===!0,y=m&&p[t??""]?.favourited===!0,Q=s?.like_count??0,U=s?.favourite_count??0,n=s?.download_count??0,o=Me(),P=Ie(),D=Ke(),g=Ze(),[le,q]=T.useState(!1),[j,u]=T.useState(null),R=!!i&&!!s&&i.radientUser?.account?.id===s.account_id,V=()=>{!t||!a||o.isPending||(u(null),o.mutate({agentId:t,isCurrentlyLiked:x},{onError:()=>u("like")}))},X=()=>{!t||!a||P.isPending||(u(null),P.mutate({agentId:t,isCurrentlyFavourited:y},{onError:()=>u("favourite")}))},Z=()=>{!t||!s||D.isPending||(u(null),D.mutate({agentId:s.id,agentName:s.name},{onError:()=>u("download")}))},ce=()=>{!t||!R||g.isPending||(u(null),g.mutate({agentId:t},{onError:()=>u("delist")}),q(!1))},E=j?j==="like"?{action:"like",error:o.error,retry:V}:j==="favourite"?{action:"favourite",error:P.error,retry:X}:j==="download"?{action:"download",error:D.error,retry:Z}:{action:"delist",error:g.error,retry:void 0}:null,de=()=>{r("/agent-hub")};return c?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(M,{label:"Loading agent details"})}):h?e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs(te,{variant:"danger",className:"max-w-2xl",children:[e.jsx(se,{children:"This agent could not be loaded"}),e.jsx(ae,{children:Ne("The Radient agent catalogue did not answer.",h)}),e.jsx("div",{className:"mt-2",children:e.jsx(l,{variant:"outline",size:"sm",onClick:()=>void C(),disabled:f,"aria-busy":f,children:f?"Trying…":"Try again"})})]})}):s?e.jsxs("div",{className:"m-6 flex flex-1 flex-col rounded-lg border border-hairline bg-surface p-8",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[e.jsx(l,{variant:"ghost",size:"icon",onClick:de,"aria-label":"Back to Agent hub",children:e.jsx(Ae,{})}),e.jsx(z,{className:"size-11 shrink-0",children:e.jsx(L,{children:e.jsx(ke,{size:22,"aria-hidden":"true"})})}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("h1",{className:"truncate text-display text-ink",children:s.name}),d&&e.jsx(Be,{orgName:N})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!d&&e.jsxs(e.Fragment,{children:[e.jsx(w,{content:"Sign in to Radient to use this feature",disabled:a,children:e.jsx("span",{children:e.jsxs(l,{variant:"ghost",size:"sm",onClick:V,disabled:!a||o.isPending||!m,"aria-label":m?x?"Unlike agent":"Like agent":"Like state unavailable",className:G(x&&"text-danger"),children:[e.jsx(Oe,{fill:x?"currentColor":"none"}),e.jsx($,{children:Q})]})})}),e.jsx(w,{content:"Sign in to Radient to use this feature",disabled:a,children:e.jsx("span",{children:e.jsxs(l,{variant:"ghost",size:"sm",onClick:X,disabled:!a||P.isPending||!m,"aria-label":m?y?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",className:G(y&&"text-warning"),children:[e.jsx(Se,{fill:y?"currentColor":"none"}),e.jsx($,{children:U})]})})})]}),e.jsx(w,{content:"Download agent to your computer",children:e.jsx("span",{children:e.jsxs(l,{variant:"ghost",size:"icon",onClick:Z,disabled:D.isPending,"aria-label":"Download agent",className:"ml-1",children:[e.jsx(De,{}),e.jsx($,{children:D.isPending?e.jsx(v,{className:"h-3.5 w-5"}):n})]})})}),R&&!d&&e.jsx(w,{content:"Permanently delist this agent from Agent hub",children:e.jsx("span",{children:e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>q(!0),disabled:g.isPending,"aria-label":"Delist agent",className:"ml-1 text-danger hover:bg-danger-wash hover:text-danger",children:e.jsx(ie,{})})})})]})]}),a&&k&&!j&&!d&&e.jsxs("output",{className:"mb-6 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-details-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so this agent's viewer state is not shown."}),e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>void O(),disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})]}),E&&j&&e.jsxs(te,{variant:"danger",className:"mb-6","data-testid":"agent-details-error",children:[e.jsx(se,{children:Ge[j]}),e.jsx(ae,{children:ve(E.action,E.error,s.name)}),E.retry&&e.jsx("div",{className:"mt-2",children:e.jsx(l,{variant:"outline",size:"sm",onClick:E.retry,children:"Try again"})})]}),e.jsx(Qe,{tags:s.tags,categories:s.categories}),e.jsxs("div",{className:"mt-4 mb-6 flex flex-col gap-2 text-body-sm text-ink-muted",children:[e.jsxs("p",{children:["Created by: ",s.account_metadata?.name??"Unknown"," (",s.account_metadata?.email??"No email",")"]}),e.jsxs("p",{children:["Created: ",W(new Date(s.created_at))," ago (",J(s.created_at),")"]}),e.jsxs("p",{children:["Last modified: ",W(new Date(s.updated_at))," ","ago (",J(s.updated_at),")"]})]}),e.jsx("div",{className:"mt-2 mb-8 leading-relaxed text-body text-ink",children:s.description||"No description provided."}),e.jsx(oe,{className:"my-6"}),!d&&e.jsx(Ve,{agentId:s.id}),e.jsx(Ee,{open:le,onClose:()=>q(!1),title:"Delist this agent?",maxWidth:"xs",actions:e.jsxs(e.Fragment,{children:[e.jsx(Te,{onClick:()=>q(!1),children:"Cancel"}),e.jsx(Fe,{onClick:()=>{!t||!R||g.isPending||ce()},disabled:g.isPending,children:g.isPending?e.jsx(M,{size:"sm",label:"Delisting agent"}):"Delist"})]}),dialogProps:{"aria-describedby":"delist-dialog-description"},children:e.jsxs("div",{id:"delist-dialog-description",className:"text-body text-ink-muted",children:['This takes "',s.name,'" off the hub straight away, and nobody will be able to download it. You can upload it again later.']})})]}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("p",{className:"text-body text-ink",children:"Agent not found."})})};export{ot as AgentDetailsPage};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as i,j as e,c as
|
|
1
|
+
import{r as i,j as e,c as L}from"./index-Ci5ykqkd.js";import{i as pe,ar as ie,ay as Ee,az as he,bc as Ie,r as Le,h as Fe,am as Me,g as $e,as as De,bd as Ue,at as qe,be as ge,bf as Ye,af as Ve,ae as be,c as Be,b1 as He,bg as Qe}from"./index-BZY6SC3C.js";import{o as je,u as We,a as Ge,C as Ze,b as Je}from"./org-surface-gate-BfrGIWSX.js";import{P as Ke}from"./page-header-DuARVVAM.js";import{c as Xe,f as V,B as N,e as m,A as Q,g as W,h as G,p as se,q as te,r as ne,s as re,t as B,I as ea}from"./error-boundary-CAHYSCjh.js";import{R as aa,u as sa}from"./radient-auth-buttons-D7orNp3U.js";import{e as ta,f as na,p as ra,P as ia,b as la,h as oa}from"./use-memberships-query-f3E2Ca39.js";import{O as ca,A as da,f as ua,H as ma,a as ha,b as ga,c as xa,d as ve,C as fa,u as pa,i as ba}from"./use-download-agent-mutation-BdgO7Jmf.js";import"./console-mirror-Dw_ms9Pv.js";import"./en-US-BkS8Ixxl.js";import"./book-open-6gMxcFCn.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ja=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],va=Xe("circle-ellipsis",ja),Na=({agent:a,isLiked:t,isFavourited:n,onLikeToggle:r,onFavouriteToggle:o,onDownload:c,isLikeActionLoading:h=!1,isFavouriteActionLoading:y=!1,isDownloading:x=!1,actionError:d=null,onRetryAction:p,showActions:b=!0,viewerStateKnown:f=!0,orgName:j=null})=>{const k=pe(),{isAuthenticated:u}=ie(),_=a.description??"",[P,R]=i.useState(!1),l=i.useRef(null),v=i.useCallback(g=>{if(l.current?.disconnect(),l.current=null,!g)return;const C=()=>R(g.scrollHeight-g.clientHeight>1);C();const D=new ResizeObserver(C);D.observe(g),l.current=D},[]),M=u?f?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",$=u?f?n?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",z=f?t?"Unlike agent":"Like agent":"Like state unavailable",O=f?n?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",E=a.visibility==="org";return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface transition-colors duration-fast ease-out-quart hover:border-control",children:[e.jsxs("button",{type:"button",onClick:()=>k(`/agent-hub/${a.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${a.name}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:a.name}),E&&e.jsx(ca,{orgName:j}),e.jsx(q,{content:P?_:"",children:e.jsx("span",{ref:v,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:_})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(da,{tags:a.tags,categories:a.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[a.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",ua(new Date(a.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":E?"org":u?f?"known":"unknown":"signed-out",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsx(q,{content:M,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u&&f?()=>r(a.id):void 0,disabled:h||!u||!f,"aria-label":z,className:I(t&&"text-danger"),children:[e.jsx(ma,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.like_count??0})]})})}),e.jsx(q,{content:$,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u?()=>o(a.id):void 0,disabled:y||!u||!f,"aria-label":O,className:I(n&&"text-warning"),children:[e.jsx(Ee,{fill:n?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.favourite_count??0})]})})})]}),e.jsx(q,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(he,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:x?e.jsx(m,{className:"h-3 w-6"}):(a.download_count??0).toLocaleString()})]})})]}),b&&c&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>c(a),disabled:x,"aria-label":`Download ${a.name}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(he,{"data-testid":"agent-download"}),"Get"]})})]}),d&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:d}),p&&e.jsx(N,{variant:"ghost",size:"sm",onClick:p,children:"Try again"})]})]})},ya=({agent:a,status:t,viewerStateKnown:n=!0,orgName:r=null})=>{const{isAuthenticated:o}=ie(),[c,h]=i.useState(null),y=t?.liked??!1,x=t?.favourited??!1,d=ha(),p=ga(),b=xa(),f=()=>{!o||d.isPending||(h(null),d.mutate({agentId:a.id,isCurrentlyLiked:y},{onError:()=>h("like")}))},j=()=>{!o||p.isPending||(h(null),p.mutate({agentId:a.id,isCurrentlyFavourited:x},{onError:()=>h("favourite")}))},k=()=>{b.isPending||(h(null),b.mutate({agentId:a.id,agentName:a.name},{onError:()=>h("download")}))},u=c?c==="like"?{action:"like",error:d.error,retry:f}:c==="favourite"?{action:"favourite",error:p.error,retry:j}:{action:"download",error:b.error,retry:k}:null;return e.jsx(Na,{agent:a,isLiked:o&&y,isFavourited:o&&x,onLikeToggle:f,onFavouriteToggle:j,onDownload:k,isLikeActionLoading:d.isPending,isFavouriteActionLoading:p.isPending,isDownloading:b.isPending,viewerStateKnown:n,orgName:r,actionError:u?ta(u.action,u.error,a.name):null,onRetryAction:u?.retry})},xe=({selected:a,onClick:t,children:n,...r})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":a,className:I("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",a?Ie:"text-ink hover:bg-row-hover"),...r,children:n}),fe=Object.keys(fa),wa=a=>[...a].sort((t,n)=>{const r=fe.indexOf(t),o=fe.indexOf(n);return r!==-1&&o!==-1?r-o:r!==-1?-1:o!==-1?1:t.localeCompare(n)}),ka=({selectedCategory:a,onSelectCategory:t,categories:n})=>{const r=wa(a&&!n.includes(a)?[...n,a]:n);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:"Categories"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(xe,{selected:a===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Le,{size:16,"aria-hidden":"true"})}),"All categories"]}),r.map(o=>{const c=ve(o),h=o==="other"?e.jsx(va,{size:16}):c.icon;return e.jsxs(xe,{selected:a===o,onClick:()=>t(o),"data-testid":`category-${o}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:h}),c.label]},o)})]})]})},Ne={all:["org-teams"],list:a=>[...Ne.all,"list",a]},Ca=({tenantId:a,enabled:t=!0})=>{const n=Fe({queryKey:Ne.list(a??""),queryFn:async()=>(await na(a)).result??{teams:[]},enabled:t&&!!a,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retry:Me});return{...n,teams:n.data?.teams??[]}},Sa=(a,t)=>{const n=a?.name?.trim()||t?.trim()||"Team",r=a?.renamed_from?.trim()||null;return a?.invalid_name===!0&&r?{level:"warning",message:`Pulled "${n}". The published name "${r}" is not usable locally, so the team was stored as "${n}".`}:r?{level:"success",message:`Pulled "${n}" (you already have a team called "${r}").`}:{level:"success",message:`Pulled team "${n}".`}},Ta=()=>{const a=$e();return De({mutationFn:async({teamId:t,tenantId:n})=>{if(!ge.baseUrl)throw new Error("Local Operator API URL is not configured.");return Ve.pullOrgTeamFromRadient(ge.baseUrl,t,n)},onSuccess:(t,n)=>{const r=Sa(t.result,n.name);r.level==="warning"?Ue(r.message):Ye(r.message),a.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Aa=["refresh-hub","retry","sign-in"],_a=({tenantId:a,orgName:t})=>{const{teams:n,isLoading:r,isFetching:o,isError:c,error:h,refetch:y}=Ca({tenantId:a}),x=je(h),d=Ta(),[p,b]=i.useState(null),[f,j]=i.useState(null),[k,u]=i.useState(!1),_=i.useMemo(()=>{if(!qe(d.error))return null;const l=n.find(v=>v.id===p);return ra({code:d.error.code,message:d.error.message,details:d.error.details},{name:l?.name??"this team",hubAgentId:null,surface:"pull"})},[d.error,p,n]),P=(l,v)=>{switch(l){case"refresh-hub":y();break;case"retry":R(v);break;case"sign-in":u(!0);break}},R=l=>{d.isPending||(b(null),j(l.id),d.mutate({teamId:l.id,tenantId:a,name:l.name},{onSettled:()=>j(null),onError:()=>b(l.id)}))};return e.jsxs("section",{className:"mb-6 rounded-lg border border-hairline bg-surface","aria-labelledby":"org-teams-heading","data-testid":"org-teams",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2 px-4 pt-3 pb-2",children:[e.jsx("h2",{id:"org-teams-heading",className:"font-medium text-heading text-ink",children:"Teams"}),!r&&!c&&e.jsxs("p",{className:"text-meta text-ink-dim","data-testid":"org-teams-count",children:[n.length," ",n.length===1?"team":"teams"," shared with"," ",t??"this organization"]})]}),r&&e.jsxs("div",{className:"flex flex-col gap-2 px-4 pb-4","data-testid":"org-teams-loading",children:[e.jsx("span",{className:"sr-only",children:"Loading teams…"}),e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col gap-2",children:[e.jsx(m,{className:"h-4.5 w-40"}),e.jsx(m,{className:"h-3.5 w-64"})]})]}),!r&&c&&e.jsxs(H,{variant:x?"warning":"danger",className:"mx-4 mb-4","data-testid":"org-teams-error",children:[e.jsx(W,{children:x==="plan"?"That organization needs an active Team plan":x==="no_access"?"You do not have access to that organization":"Teams could not be loaded"}),e.jsx(G,{children:x==="plan"?`Reading an organization's teams is part of the Team plan. An owner of ${t??"this organization"} can activate it in the Radient console, and then its teams will be listed here.`:x==="no_access"?`You are not a member of ${t??"that organization"}, so its teams are not listed here. An owner can invite you again.`:be("The teams shared with this organization could not be read.",h)}),x!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void y(),disabled:o,"aria-busy":o,children:o?"Trying…":"Try again"})})]}),!r&&!c&&n.length===0&&e.jsx("p",{className:"px-4 pb-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:"No teams have been shared with this organization yet."}),!r&&!c&&n.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline border-t border-hairline",children:n.map(l=>e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:l.name}),e.jsxs("span",{className:"truncate text-meta text-ink-muted",children:[l.project||"No project",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),Pa(l),l.version?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"v",l.version]}):null]}),p===l.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:_?.body??d.error?.message??`"${l.name}" could not be pulled.`}),_?.actions.filter(v=>Aa.includes(v)).map(v=>e.jsx(N,{variant:"primary",size:"sm",onClick:()=>P(v,l),children:ia[v]},v)),k&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(aa,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{u(!1),b(null),y()}})})]})]}),e.jsx(N,{variant:"secondary",size:"sm",onClick:()=>R(l),disabled:d.isPending,"aria-label":`Pull team ${l.name}`,children:f===l.id?"Pulling…":"Pull"})]},l.id))})]})},Pa=a=>a.members.length===0?"No members":a.members.map(t=>t.count>1?`${t.role} ×${t.count}`:t.role).join(", "),Ra=(a,t)=>{const[n,r]=i.useState(a);return i.useEffect(()=>{const o=setTimeout(()=>r(a),t);return()=>clearTimeout(o)},[a,t]),n},B=[{value:"download_count:desc",label:"Most downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"Most liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"Most favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"Newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"Recently updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"Name (A to Z)",sort:"name",order:"asc"}],za=[{value:"name",label:"Name"},{value:"description",label:"Description"}],Oa=300,F="public",Ea=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(m,{className:"h-5.5 w-2/3"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(m,{className:"h-5.5 w-24"}),e.jsx(m,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(m,{className:"h-5.5 w-24"})})]}),e.jsx(m,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"ml-auto h-7 w-16"})]})]}),Ba=()=>{const a=pe(),{isAuthenticated:t}=ie(),[n,r]=i.useState(1),[o]=i.useState(12),[c,h]=i.useState(null),[y,x]=i.useState(""),[d,p]=i.useState("name"),[b,f]=i.useState(B[0].value),[j,k]=i.useState(F),[u,_]=i.useState([]),P=Ra(y,Oa),R=B.find(s=>s.value===b)??B[0],l=Qe(),v=sa(),M=Be(l.data,"radient_org"),$=t?Ge(M,v):null,{memberships:z}=la({enabled:Je(M)}),O=i.useMemo(()=>We(z),[z]),E=j===F||O.some(s=>s.tenant_id===j);i.useEffect(()=>{E||k(F)},[E]);const g=j===F?null:O.find(s=>s.tenant_id===j)??null,C=g?.tenant_id,D=g?.role==="owner"||g?.role==="admin",ye=i.useMemo(()=>new Map(z.map(s=>[s.tenant_id,s.tenant_name])),[z]),{data:U,agents:we,isLoading:ke,isFetching:S,error:T,refetch:le,pagination:A}=oa({page:n,perPage:o,categories:c?[c]:void 0,name:d==="name"&&P||void 0,description:d==="description"&&P||void 0,sort:R.sort,order:R.order,tenantId:C}),L=g?je(T):null,Y=we??[],oe=S&&U!==void 0,{statuses:ce,isKnown:Ce,isError:Se,isFetching:Z,refetch:Te}=pa({agentIds:C?[]:Y.map(s=>s.id)}),J=i.useRef(null),K=i.useRef(null),[de,Ae]=i.useState(0);i.useEffect(()=>{de!==0&&(J.current??K.current)?.focus()},[de]);const ue=i.useRef(null),X=i.useRef(!1),ee=i.useMemo(()=>[...new Set((U?.records??[]).flatMap(s=>s.categories??[]))],[U]);i.useEffect(()=>{_(s=>ee.every(ae=>s.includes(ae))?s:[...new Set([...s,...ee])])},[ee]);const V=c!==null||P!=="",_e=()=>{h(null),x(""),r(1),Ae(s=>s+1)},w=(ke||S)&&U===void 0,me=!w&&!V&&(T!==null||Y.length===0);i.useEffect(()=>{!X.current||w||(X.current=!1,T?ue.current?.focus():(J.current??K.current)?.focus())},[w,T]);const Pe=s=>{r(s)},Re=s=>{h(s),r(1)},ze=s=>{x(s),r(1)},Oe=s=>{p(s),r(1)};return e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(Ke,{title:"Agent hub",subtitle:"Discover and download community agents on Radient",icon:He}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-tour-tag":"agent-hub-sidebar-container",children:!me&&e.jsx(ka,{selectedCategory:c,onSelectCategory:Re,categories:u})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[$&&e.jsxs(H,{variant:"warning",className:"mb-3 max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(W,{children:"Organizations are unavailable"}),e.jsx(G,{children:$})]}),O.length>0&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:"agent-hub-scope-label",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs(se,{value:j,onValueChange:s=>{k(s),r(1)},children:[e.jsx(te,{className:"w-56","aria-labelledby":"agent-hub-scope-label","data-testid":"agent-hub-scope",children:e.jsx(ne,{})}),e.jsxs(re,{children:[e.jsx(Q,{value:F,children:"Public hub"}),O.map(s=>e.jsx(Q,{value:s.tenant_id,children:s.tenant_name||"Organization"},s.tenant_id))]})]})]}),!me&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:I("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(ea,{ref:J,type:"search",value:y,onChange:s=>ze(s.target.value),placeholder:"Search agents","aria-label":"Search agents",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(se,{value:d,onValueChange:Oe,children:[e.jsx(te,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":"Search in","data-testid":"agent-hub-search-scope",children:e.jsx(ne,{})}),e.jsx(re,{children:za.map(s=>e.jsx(Q,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs(se,{value:b,onValueChange:f,children:[e.jsx(te,{className:"w-48","aria-label":"Sort agents","data-testid":"agent-hub-sort",children:e.jsx(ne,{})}),e.jsx(re,{children:B.map(s=>e.jsx(Q,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("p",{"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[w?"Loading agents…":A?`${A.totalRecords} ${A.totalRecords===1?"agent":"agents"}`:"",oe?e.jsx(e.Fragment,{children:" Updating…"}):null]}),t&&Se&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so no card shows a viewer state."}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>void Te(),disabled:Z,"aria-busy":Z,children:Z?"Trying…":"Try again"})]}),w&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(s,ae)=>e.jsx(Ea,{},ae))}),w&&A===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(m,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:I(!w&&T&&!L?"block":"sr-only"),children:!w&&T&&!L&&e.jsxs(H,{variant:"danger",className:"max-w-2xl","aria-busy":S,"data-testid":"agent-hub-error",children:[e.jsx(W,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(G,{children:t?be("The agent list could not be loaded.",T):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(N,{ref:ue,variant:"outline",size:"sm",onClick:()=>{X.current=!0,le()},disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})})]})}),!w&&L&&g&&e.jsxs(H,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(W,{children:L==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(G,{children:L==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${g.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${g.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),L==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void le(),disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})})]}),!w&&!T&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":oe,children:Y.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:I("col-span-full w-full flex flex-col items-center gap-2 rounded-lg border border-hairline bg-surface px-6 py-10 text-center",!C&&"max-w-2xl justify-self-center"),children:[e.jsx("p",{className:"text-heading text-ink",children:C?"This organization has no shared agents yet.":c?`No agents in ${ve(c).label}.`:V?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:C?`Agents published into ${g?.tenant_name||"this organization"} appear here for its members.`:c?"Nothing in this category yet. Clear the filter to see the whole hub.":V?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:V?e.jsx(N,{variant:"secondary",onClick:_e,children:c?"Clear filter":"Clear search"}):C&&!D?null:e.jsx(N,{ref:K,variant:"secondary",onClick:()=>a("/agents"),children:"Publish an agent"})})]}):Y.map(s=>e.jsx(ya,{agent:s,status:t?ce[s.id]:void 0,viewerStateKnown:t&&ba(Ce,ce,s.id),orgName:s.visibility==="org"?ye.get(s.tenant_id)??null:null},s.id))}),!w&&A&&A.totalPages>1&&e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx(Ze,{count:A.totalPages,page:A.page,onChange:Pe})}),g&&e.jsx(_a,{tenantId:g.tenant_id,orgName:g.tenant_name||null})]})]})]})};export{Ba as AgentHubPage};
|
|
6
|
+
*/const ja=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],va=Xe("circle-ellipsis",ja),Na=({agent:a,isLiked:t,isFavourited:n,onLikeToggle:r,onFavouriteToggle:o,onDownload:c,isLikeActionLoading:h=!1,isFavouriteActionLoading:y=!1,isDownloading:x=!1,actionError:d=null,onRetryAction:p,showActions:b=!0,viewerStateKnown:f=!0,orgName:j=null})=>{const k=pe(),{isAuthenticated:u}=ie(),_=a.description??"",[P,R]=i.useState(!1),l=i.useRef(null),v=i.useCallback(g=>{if(l.current?.disconnect(),l.current=null,!g)return;const C=()=>R(g.scrollHeight-g.clientHeight>1);C();const D=new ResizeObserver(C);D.observe(g),l.current=D},[]),M=u?f?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",$=u?f?n?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",z=f?t?"Unlike agent":"Like agent":"Like state unavailable",O=f?n?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",E=a.visibility==="org";return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface transition-colors duration-fast ease-out-quart hover:border-control",children:[e.jsxs("button",{type:"button",onClick:()=>k(`/agent-hub/${a.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${a.name}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:a.name}),E&&e.jsx(ca,{orgName:j}),e.jsx(V,{content:P?_:"",children:e.jsx("span",{ref:v,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:_})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(da,{tags:a.tags,categories:a.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[a.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",ua(new Date(a.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":E?"org":u?f?"known":"unknown":"signed-out",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsx(V,{content:M,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u&&f?()=>r(a.id):void 0,disabled:h||!u||!f,"aria-label":z,className:L(t&&"text-danger"),children:[e.jsx(ma,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.like_count??0})]})})}),e.jsx(V,{content:$,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u?()=>o(a.id):void 0,disabled:y||!u||!f,"aria-label":O,className:L(n&&"text-warning"),children:[e.jsx(Ee,{fill:n?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.favourite_count??0})]})})})]}),e.jsx(V,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(he,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:x?e.jsx(m,{className:"h-3 w-6"}):(a.download_count??0).toLocaleString()})]})})]}),b&&c&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>c(a),disabled:x,"aria-label":`Download ${a.name}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(he,{"data-testid":"agent-download"}),"Get"]})})]}),d&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:d}),p&&e.jsx(N,{variant:"ghost",size:"sm",onClick:p,children:"Try again"})]})]})},ya=({agent:a,status:t,viewerStateKnown:n=!0,orgName:r=null})=>{const{isAuthenticated:o}=ie(),[c,h]=i.useState(null),y=t?.liked??!1,x=t?.favourited??!1,d=ha(),p=ga(),b=xa(),f=()=>{!o||d.isPending||(h(null),d.mutate({agentId:a.id,isCurrentlyLiked:y},{onError:()=>h("like")}))},j=()=>{!o||p.isPending||(h(null),p.mutate({agentId:a.id,isCurrentlyFavourited:x},{onError:()=>h("favourite")}))},k=()=>{b.isPending||(h(null),b.mutate({agentId:a.id,agentName:a.name},{onError:()=>h("download")}))},u=c?c==="like"?{action:"like",error:d.error,retry:f}:c==="favourite"?{action:"favourite",error:p.error,retry:j}:{action:"download",error:b.error,retry:k}:null;return e.jsx(Na,{agent:a,isLiked:o&&y,isFavourited:o&&x,onLikeToggle:f,onFavouriteToggle:j,onDownload:k,isLikeActionLoading:d.isPending,isFavouriteActionLoading:p.isPending,isDownloading:b.isPending,viewerStateKnown:n,orgName:r,actionError:u?ta(u.action,u.error,a.name):null,onRetryAction:u?.retry})},xe=({selected:a,onClick:t,children:n,...r})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":a,className:L("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",a?Le:"text-ink hover:bg-row-hover"),...r,children:n}),fe=Object.keys(fa),wa=a=>[...a].sort((t,n)=>{const r=fe.indexOf(t),o=fe.indexOf(n);return r!==-1&&o!==-1?r-o:r!==-1?-1:o!==-1?1:t.localeCompare(n)}),ka=({selectedCategory:a,onSelectCategory:t,categories:n})=>{const r=wa(a&&!n.includes(a)?[...n,a]:n);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:"Categories"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(xe,{selected:a===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Ie,{size:16,"aria-hidden":"true"})}),"All categories"]}),r.map(o=>{const c=ve(o),h=o==="other"?e.jsx(va,{size:16}):c.icon;return e.jsxs(xe,{selected:a===o,onClick:()=>t(o),"data-testid":`category-${o}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:h}),c.label]},o)})]})]})},Ne={all:["org-teams"],list:a=>[...Ne.all,"list",a]},Ca=({tenantId:a,enabled:t=!0})=>{const n=Fe({queryKey:Ne.list(a??""),queryFn:async()=>(await na(a)).result??{teams:[]},enabled:t&&!!a,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retry:Me});return{...n,teams:n.data?.teams??[]}},Sa=(a,t)=>{const n=a?.name?.trim()||t?.trim()||"Team",r=a?.renamed_from?.trim()||null;return a?.invalid_name===!0&&r?{level:"warning",message:`Pulled "${n}". The published name "${r}" is not usable locally, so the team was stored as "${n}".`}:r?{level:"success",message:`Pulled "${n}" (you already have a team called "${r}").`}:{level:"success",message:`Pulled team "${n}".`}},Ta=()=>{const a=$e();return De({mutationFn:async({teamId:t,tenantId:n})=>{if(!ge.baseUrl)throw new Error("Local Operator API URL is not configured.");return Ye.pullOrgTeamFromRadient(ge.baseUrl,t,n)},onSuccess:(t,n)=>{const r=Sa(t.result,n.name);r.level==="warning"?Ue(r.message):qe(r.message),a.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Aa=["refresh-hub","retry","sign-in"],_a=({tenantId:a,orgName:t})=>{const{teams:n,isLoading:r,isFetching:o,isError:c,error:h,refetch:y}=Ca({tenantId:a}),x=je(h),d=Ta(),[p,b]=i.useState(null),[f,j]=i.useState(null),[k,u]=i.useState(!1),_=i.useMemo(()=>{if(!Ve(d.error))return null;const l=n.find(v=>v.id===p);return ra({code:d.error.code,message:d.error.message,details:d.error.details},{name:l?.name??"this team",hubAgentId:null,surface:"pull"})},[d.error,p,n]),P=(l,v)=>{switch(l){case"refresh-hub":y();break;case"retry":R(v);break;case"sign-in":u(!0);break}},R=l=>{d.isPending||(b(null),j(l.id),d.mutate({teamId:l.id,tenantId:a,name:l.name},{onSettled:()=>j(null),onError:()=>b(l.id)}))};return e.jsxs("section",{className:"mb-6 rounded-lg border border-hairline bg-surface","aria-labelledby":"org-teams-heading","data-testid":"org-teams",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2 px-4 pt-3 pb-2",children:[e.jsx("h2",{id:"org-teams-heading",className:"font-medium text-heading text-ink",children:"Teams"}),!r&&!c&&e.jsxs("p",{className:"text-meta text-ink-dim","data-testid":"org-teams-count",children:[n.length," ",n.length===1?"team":"teams"," shared with"," ",t??"this organization"]})]}),r&&e.jsxs("div",{className:"flex flex-col gap-2 px-4 pb-4","data-testid":"org-teams-loading",children:[e.jsx("span",{className:"sr-only",children:"Loading teams…"}),e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col gap-2",children:[e.jsx(m,{className:"h-4.5 w-40"}),e.jsx(m,{className:"h-3.5 w-64"})]})]}),!r&&c&&e.jsxs(Q,{variant:x?"warning":"danger",className:"mx-4 mb-4","data-testid":"org-teams-error",children:[e.jsx(W,{children:x==="plan"?"That organization needs an active Team plan":x==="no_access"?"You do not have access to that organization":"Teams could not be loaded"}),e.jsx(G,{children:x==="plan"?`Reading an organization's teams is part of the Team plan. An owner of ${t??"this organization"} can activate it in the Radient console, and then its teams will be listed here.`:x==="no_access"?`You are not a member of ${t??"that organization"}, so its teams are not listed here. An owner can invite you again.`:be("The teams shared with this organization could not be read.",h)}),x!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void y(),disabled:o,"aria-busy":o,children:o?"Trying…":"Try again"})})]}),!r&&!c&&n.length===0&&e.jsx("p",{className:"px-4 pb-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:"No teams have been shared with this organization yet."}),!r&&!c&&n.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline border-t border-hairline",children:n.map(l=>e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:l.name}),e.jsxs("span",{className:"truncate text-meta text-ink-muted",children:[l.project||"No project",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),Pa(l),l.version?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"v",l.version]}):null]}),p===l.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:_?.body??d.error?.message??`"${l.name}" could not be pulled.`}),_?.actions.filter(v=>Aa.includes(v)).map(v=>e.jsx(N,{variant:"primary",size:"sm",onClick:()=>P(v,l),children:ia[v]},v)),k&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(aa,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{u(!1),b(null),y()}})})]})]}),e.jsx(N,{variant:"secondary",size:"sm",onClick:()=>R(l),disabled:d.isPending,"aria-label":`Pull team ${l.name}`,children:f===l.id?"Pulling…":"Pull"})]},l.id))})]})},Pa=a=>a.members.length===0?"No members":a.members.map(t=>t.count>1?`${t.role} ×${t.count}`:t.role).join(", "),Ra=(a,t)=>{const[n,r]=i.useState(a);return i.useEffect(()=>{const o=setTimeout(()=>r(a),t);return()=>clearTimeout(o)},[a,t]),n},H=[{value:"download_count:desc",label:"Most downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"Most liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"Most favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"Newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"Recently updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"Name (A to Z)",sort:"name",order:"asc"}],za=[{value:"name",label:"Name"},{value:"description",label:"Description"}],Oa=300,F="public",Ea=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(m,{className:"h-5.5 w-2/3"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(m,{className:"h-5.5 w-24"}),e.jsx(m,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(m,{className:"h-5.5 w-24"})})]}),e.jsx(m,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"ml-auto h-7 w-16"})]})]}),Ha=()=>{const a=pe(),{isAuthenticated:t}=ie(),[n,r]=i.useState(1),[o]=i.useState(12),[c,h]=i.useState(null),[y,x]=i.useState(""),[d,p]=i.useState("name"),[b,f]=i.useState(H[0].value),[j,k]=i.useState(F),[u,_]=i.useState([]),P=Ra(y,Oa),R=H.find(s=>s.value===b)??H[0],l=Be(),v=sa(),M=He(l.data,"radient_org"),$=t?Ge(M,v):null,{memberships:z}=la({enabled:Je(M)}),O=i.useMemo(()=>We(z),[z]),E=j===F||O.some(s=>s.tenant_id===j);i.useEffect(()=>{E||k(F)},[E]);const g=j===F?null:O.find(s=>s.tenant_id===j)??null,C=g?.tenant_id,D=g?.role==="owner"||g?.role==="admin",ye=i.useMemo(()=>new Map(z.map(s=>[s.tenant_id,s.tenant_name])),[z]),{data:U,agents:we,isLoading:ke,isFetching:S,error:T,refetch:le,pagination:A}=oa({page:n,perPage:o,categories:c?[c]:void 0,name:d==="name"&&P||void 0,description:d==="description"&&P||void 0,sort:R.sort,order:R.order,tenantId:C}),I=g?je(T):null,q=we??[],oe=S&&U!==void 0,{statuses:ce,isKnown:Ce,isError:Se,isFetching:Z,refetch:Te}=pa({agentIds:C?[]:q.map(s=>s.id)}),J=i.useRef(null),K=i.useRef(null),[de,Ae]=i.useState(0);i.useEffect(()=>{de!==0&&(J.current??K.current)?.focus()},[de]);const ue=i.useRef(null),X=i.useRef(!1),ee=i.useMemo(()=>[...new Set((U?.records??[]).flatMap(s=>s.categories??[]))],[U]);i.useEffect(()=>{_(s=>ee.every(ae=>s.includes(ae))?s:[...new Set([...s,...ee])])},[ee]);const Y=c!==null||P!=="",_e=()=>{h(null),x(""),r(1),Ae(s=>s+1)},w=(ke||S)&&U===void 0,me=!w&&!Y&&(T!==null||q.length===0);i.useEffect(()=>{!X.current||w||(X.current=!1,T?ue.current?.focus():(J.current??K.current)?.focus())},[w,T]);const Pe=s=>{r(s)},Re=s=>{h(s),r(1)},ze=s=>{x(s),r(1)},Oe=s=>{p(s),r(1)};return e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(Ke,{title:"Agent hub",subtitle:"Discover and download community agents on Radient",icon:Qe}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-tour-tag":"agent-hub-sidebar-container",children:!me&&e.jsx(ka,{selectedCategory:c,onSelectCategory:Re,categories:u})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[$&&e.jsxs(Q,{variant:"warning",className:"mb-3 max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(W,{children:"Organizations are unavailable"}),e.jsx(G,{children:$})]}),O.length>0&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:"agent-hub-scope-label",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs(se,{value:j,onValueChange:s=>{k(s),r(1)},children:[e.jsx(te,{className:"w-56","aria-labelledby":"agent-hub-scope-label","data-testid":"agent-hub-scope",children:e.jsx(ne,{})}),e.jsxs(re,{children:[e.jsx(B,{value:F,children:"Public hub"}),O.map(s=>e.jsx(B,{value:s.tenant_id,children:s.tenant_name||"Organization"},s.tenant_id))]})]})]}),!me&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:L("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(ea,{ref:J,type:"search",value:y,onChange:s=>ze(s.target.value),placeholder:"Search agents","aria-label":"Search agents",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(se,{value:d,onValueChange:Oe,children:[e.jsx(te,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":"Search in","data-testid":"agent-hub-search-scope",children:e.jsx(ne,{})}),e.jsx(re,{children:za.map(s=>e.jsx(B,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs(se,{value:b,onValueChange:f,children:[e.jsx(te,{className:"w-48","aria-label":"Sort agents","data-testid":"agent-hub-sort",children:e.jsx(ne,{})}),e.jsx(re,{children:H.map(s=>e.jsx(B,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("p",{"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[w?"Loading agents…":A?`${A.totalRecords} ${A.totalRecords===1?"agent":"agents"}`:"",oe?e.jsx(e.Fragment,{children:" Updating…"}):null]}),t&&Se&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so no card shows a viewer state."}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>void Te(),disabled:Z,"aria-busy":Z,children:Z?"Trying…":"Try again"})]}),w&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(s,ae)=>e.jsx(Ea,{},ae))}),w&&A===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(m,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:L(!w&&T&&!I?"block":"sr-only"),children:!w&&T&&!I&&e.jsxs(Q,{variant:"danger",className:"max-w-2xl","aria-busy":S,"data-testid":"agent-hub-error",children:[e.jsx(W,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(G,{children:t?be("The agent list could not be loaded.",T):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(N,{ref:ue,variant:"outline",size:"sm",onClick:()=>{X.current=!0,le()},disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})})]})}),!w&&I&&g&&e.jsxs(Q,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(W,{children:I==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(G,{children:I==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${g.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${g.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),I==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void le(),disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})})]}),!w&&!T&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":oe,children:q.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:L("col-span-full w-full flex flex-col items-center gap-2 rounded-lg border border-hairline bg-surface px-6 py-10 text-center",!C&&"max-w-2xl justify-self-center"),children:[e.jsx("p",{className:"text-heading text-ink",children:C?"This organization has no shared agents yet.":c?`No agents in ${ve(c).label}.`:Y?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:C?`Agents published into ${g?.tenant_name||"this organization"} appear here for its members.`:c?"Nothing in this category yet. Clear the filter to see the whole hub.":Y?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:Y?e.jsx(N,{variant:"secondary",onClick:_e,children:c?"Clear filter":"Clear search"}):C&&!D?null:e.jsx(N,{ref:K,variant:"secondary",onClick:()=>a("/agents"),children:"Publish an agent"})})]}):q.map(s=>e.jsx(ya,{agent:s,status:t?ce[s.id]:void 0,viewerStateKnown:t&&ba(Ce,ce,s.id),orgName:s.visibility==="org"?ye.get(s.tenant_id)??null:null},s.id))}),!w&&A&&A.totalPages>1&&e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx(Ze,{count:A.totalPages,page:A.page,onChange:Pe})}),g&&e.jsx(_a,{tenantId:g.tenant_id,orgName:g.tenant_name||null})]})]})]})};export{Ha as AgentHubPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-1fM02PQU.js","./index-Ci5ykqkd.js","./index-DLdCxgd4.css","./index-BZY6SC3C.js","./error-boundary-CAHYSCjh.js","./console-mirror-Dw_ms9Pv.js","./console-mirror-DOrYoP_4.css","./index-CSPo12AE.css","./page-header-DuARVVAM.js","./settings-section-j4eB5zEy.js","./org-surface-gate-BfrGIWSX.js","./use-memberships-query-f3E2Ca39.js","./radient-auth-buttons-D7orNp3U.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as O,a as Q,b as J,c as V,d as W,e as G,f as H,g as X,h as Y,B as Z,U as ee,P as te,r as ae,_ as se,i as $,j as z,k as L}from"./index-BZY6SC3C.js";import{j as e,r as n,c as w}from"./index-Ci5ykqkd.js";import{B as h}from"./error-boundary-CAHYSCjh.js";import"./console-mirror-Dw_ms9Pv.js";const ne=n.lazy(()=>se(()=>import("./legacy-agents-page-1fM02PQU.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url).then(t=>({default:t.LegacyAgentsPage}))),m="w-full rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink";function T({profile:t,creating:E,onSaved:b}){const[j,r]=n.useState(!1),[v,c]=n.useState(E),[p,x]=n.useState(t?.name??""),[g,y]=n.useState(t?.kind??"role"),[P,d]=n.useState(t?.description??""),[N,u]=n.useState(t?.instructions??""),[_,D]=n.useState(t?.tools?.join(", ")??""),[I,k]=n.useState(t?.effort??"inherit"),[U,R]=n.useState(t?.delegate??!1),[f,a]=n.useState(!1),[o,l]=n.useState(null),i=n.useRef(null),C=$(),S=E||j,K=async s=>{if(s.preventDefault(),f)return;const M={kind:g,description:P,instructions:N,tools:_.split(",").map(q=>q.trim()).filter(Boolean),effort:I,delegate:U},A=JSON.stringify({name:p,fields:M,fresh:S});if(i.current&&i.current.body!==A){l("The previous save has not been confirmed. Retry it unchanged or reload the profile to reconcile before editing again.");return}i.current??={id:crypto.randomUUID(),body:A},a(!0),l(null);try{const q=await L({op:S?"profiles.create":"profiles.update",requestId:i.current.id,name:p,fields:M});i.current=null,c(!1),b(q.name)}catch(q){l(q instanceof Error?q.message:"Profile could not be saved.")}finally{a(!1)}},F=async()=>{if(!(!t||f)){a(!0),l(null);try{const s=await L({op:"profiles.install",name:t.name,requestId:crypto.randomUUID()});c(!1),r(!1),i.current=null,x(s.name),y(s.kind),d(s.description??""),u(s.instructions??""),D(s.tools?.join(", ")??""),k(s.effort??"inherit"),R(s.delegate??!1),b(s.name)}catch(s){l(s instanceof Error?s.message:"Profile could not be installed.")}finally{a(!1)}}};return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:S?j?"Extend agent":"Create agent":t?.name}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Reusable instructions shared by agent commands, subagents and teams. Chats remain separate."})]}),t&&!S&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-meta text-ink-muted",children:[t.source==="builtin"?"Built-in":t.source==="installed"?"Installed":"Custom",t.divergent_fields?.length?" · Modified":""," ·"," ",t.kind]}),t.source==="builtin"?e.jsx(h,{variant:"outline",onClick:F,disabled:f,children:"Install"}):e.jsx(h,{variant:"outline",onClick:()=>c(!0),children:"Edit"}),e.jsx(h,{variant:"outline",onClick:()=>{r(!0),c(!0),x(""),i.current=null},children:"Extend"}),e.jsx(h,{onClick:()=>{z.getState().stageDraft({kind:"agent",name:t.name}),C("/chat")},children:"New chat"})]}),o&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:o}),!v&&t?.source==="builtin"&&e.jsx("p",{id:"builtin-readonly",className:"text-body-sm text-ink-muted",children:"Built-in agents are read-only. Install this one to edit it, or Extend it to start a separate agent from its instructions."}),e.jsxs("form",{onSubmit:K,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:!v||f,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:m,value:p,disabled:!S,required:!0,"aria-describedby":t?.source==="builtin"?"builtin-readonly":void 0,onChange:s=>x(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Kind"}),e.jsxs("select",{className:m,value:g,disabled:!S,onChange:s=>y(s.target.value),children:[e.jsx("option",{value:"role",children:"Role"}),e.jsx("option",{value:"specialist",children:"Specialist"})]})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"When to use this agent"}),e.jsx("input",{className:m,value:P,maxLength:8e3,onChange:s=>d(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Instructions"}),e.jsx("textarea",{className:w(m,"min-h-52"),value:N,required:!0,maxLength:8e3,onChange:s=>u(s.target.value)})]}),g==="role"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Allowed tools"}),e.jsx("input",{className:m,value:_,onChange:s=>D(s.target.value),placeholder:"All tools when empty; otherwise comma-separated names"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Effort tier"}),e.jsx("input",{className:m,value:I,onChange:s=>k(s.target.value),"aria-describedby":"effort-help"}),e.jsx("span",{id:"effort-help",className:"text-meta text-ink-muted",children:"Use inherit, or a tier configured in backend settings. Unsupported tiers are rejected before saving."})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-body-sm",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>R(s.target.checked)}),"May delegate to subagents"]})]})]}),v&&e.jsx(h,{type:"submit",disabled:f,children:f?"Saving…":S?"Create agent":"Save changes"})]}),!v&&t?.packaged_instructions&&t.divergent_fields?.length?e.jsxs("details",{className:"text-body-sm",children:[e.jsx("summary",{children:"Compare packaged instructions"}),e.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-body-sm text-ink-muted",children:t.packaged_instructions})]}):null]})}function B({team:t,onSaved:E}){const[b,j]=n.useState(t?.name??""),[r,v]=n.useState(t?.description??""),[c,p]=n.useState(t?.manager??"manager"),[x,g]=n.useState((t?.members??[]).map(a=>({...a,key:crypto.randomUUID()}))),[y,P]=n.useState(t?.instructions??""),[d,N]=n.useState(t?.project??""),[u,_]=n.useState(!1),[D,I]=n.useState(null),k=n.useRef(null),U=$(),R=async a=>{if(a.preventDefault(),u)return;const o={name:b,description:r,manager:c,members:x.map(({key:i,...C})=>C),instructions:y,project:d},l=JSON.stringify(o);if(k.current&&k.current.body!==l){I("The previous save has not been confirmed. Reload the team before changing that request.");return}k.current??={id:crypto.randomUUID(),body:l},_(!0),I(null);try{const i=t?await L({op:"teams.update",name:t.name,requestId:k.current.id,fields:o}):await L({op:"teams.create",requestId:k.current.id,fields:o});k.current=null,E(i.name)}catch(i){I(i instanceof Error?i.message:"Team could not be saved.")}finally{_(!1)}},f=(a,o)=>g(l=>l.map((i,C)=>C===a?{...i,...o}:i));return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:t?t.name:"Create team"}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"The manager leads the chat. Members retain their own instructions and start only when delegated work."})]}),t&&e.jsx(h,{onClick:()=>{z.getState().stageDraft({kind:"team",name:t.name}),U("/chat")},children:"New team chat"}),D&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:D}),e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:u,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:m,required:!0,maxLength:64,value:b,onChange:a=>j(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Description"}),e.jsx("input",{className:m,value:r,onChange:a=>v(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Manager agent"}),e.jsx("input",{className:m,required:!0,value:c,onChange:a=>p(a.target.value)})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-heading",children:"Members"}),x.map((a,o)=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{className:w(m,"w-48 flex-1"),"aria-label":`Member ${o+1} name`,required:!0,value:a.role,onChange:l=>f(o,{role:l.target.value})}),e.jsxs("select",{className:w(m,"w-32"),"aria-label":`Member ${o+1} kind`,value:a.kind,onChange:l=>f(o,{kind:l.target.value}),children:[e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"team",children:"Nested team"})]}),e.jsx("input",{className:w(m,"w-20"),"aria-label":`Member ${o+1} count`,type:"number",min:1,max:16,value:a.count,onChange:l=>f(o,{count:Number(l.target.value)})}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>g(l=>l.filter((i,C)=>C!==o)),children:"Remove"})]},a.key)),e.jsx(h,{type:"button",variant:"outline",onClick:()=>g(a=>[...a,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]),children:"Add member"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Collaboration instructions"}),e.jsx("textarea",{className:w(m,"min-h-36"),maxLength:8e3,value:y,onChange:a=>P(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Project brief"}),e.jsx("textarea",{className:w(m,"min-h-36"),maxLength:8e3,value:d,onChange:a=>N(a.target.value)})]})]}),e.jsx(h,{type:"submit",disabled:u,children:u?"Saving…":t?"Save team":"Create team"})]})]})}function oe(){const t=O(),{agentId:E}=Q(),[b,j]=J(),r=b.get("kind")==="team"||b.get("create")==="team",v=b.has("create"),c=b.get("name"),p=V(),x=W(p.data,r?"team_catalogue":"profile_catalogue"),g=G(x&&!r),y=H(x&&r),P=X(),d=Y({queryKey:["desktop",r?"team":"profile",c],enabled:x&&!!c&&!v,queryFn:()=>L({op:r?"teams.get":"profiles.get",name:c??""}),retry:!1}),N=async u=>{await P.invalidateQueries({queryKey:["desktop"]}),j({kind:r?"team":"agent",name:u})};return E?e.jsx(n.Suspense,{fallback:e.jsx("p",{className:"p-6 text-body",children:"Loading saved agent…"}),children:e.jsx(ne,{})}):e.jsxs("div",{className:"flex h-full min-h-0 bg-canvas text-ink",children:[e.jsxs("aside",{ref:t,className:"flex w-64 shrink-0 flex-col gap-4 border-r border-hairline bg-surface p-4",children:[e.jsx("h1",{className:"text-heading",children:"Agents and teams"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{variant:r?"ghost":"outline",onClick:()=>j({kind:"agent"}),children:[e.jsx(Z,{className:"size-4"}),"Agents"]}),e.jsxs(h,{variant:r?"outline":"ghost",onClick:()=>j({kind:"team"}),children:[e.jsx(ee,{className:"size-4"}),"Teams"]})]}),e.jsxs(h,{variant:"outline",disabled:!x,onClick:()=>j({create:r?"team":"agent"}),children:[e.jsx(te,{className:"size-4"}),r?"Create team":"Create agent"]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(r?y.data:g.data)?.map(u=>e.jsx("button",{type:"button",className:w("flex h-8 w-full items-center rounded-md px-2 text-left text-body-sm hover:bg-row-hover",u.name===c&&ae),onClick:()=>j({kind:r?"team":"agent",name:u.name}),children:e.jsx("span",{className:"truncate",children:u.name})},u.name))})]}),e.jsx("main",{className:"min-w-0 flex-1 overflow-auto p-6",children:x?g.error||y.error||d.error?e.jsxs("div",{role:"alert",children:[e.jsx("p",{className:"text-danger",children:g.error?.message||y.error?.message||d.error?.message}),e.jsx(h,{variant:"outline",onClick:()=>{g.refetch(),y.refetch(),d.refetch()},children:"Retry"})]}):v?r?e.jsx(B,{onSaved:N},"create-team"):e.jsx(T,{creating:!0,onSaved:N},"create-agent"):c&&d.isLoading?e.jsx("p",{"aria-live":"polite",children:"Loading details…"}):c&&d.data?r?e.jsx(B,{team:d.data,onSaved:N},c):e.jsx(T,{profile:d.data,creating:!1,onSaved:N},`${c}:${d.data.source}`):e.jsxs("div",{children:[e.jsx("h2",{className:"text-title",children:r?"Reusable teams":"Reusable agents"}),e.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Select a definition to view or edit it. A new chat does not change its definition."})]}):e.jsxs("div",{"aria-live":"polite",className:"space-y-3 text-body-sm",children:[e.jsx("p",{children:p.isLoading?"Connecting to the backend…":p.error?p.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."}),e.jsx(h,{variant:"outline",onClick:()=>void p.refetch(),children:"Retry connection"})]})})]})}export{oe as AgentsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{w as ln,p as un,m as H,s as q,n as j,o as an,q as y,t as tn,v as L,x as _,y as rn,z as o,A as sn,C as on,D as fn}from"./index-
|
|
1
|
+
import{w as ln,p as un,m as H,s as q,n as j,o as an,q as y,t as tn,v as L,x as _,y as rn,z as o,A as sn,C as on,D as fn}from"./index-BZY6SC3C.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function mn(l){return l.endAngle}function pn(l){return l&&l.padAngle}function dn(l,h,C,D,v,A,B,u){var E=C-l,s=D-h,n=B-v,m=u-A,a=m*E-n*s;if(!(a*a<y))return a=(n*(h-A)-m*(l-v))/a,[l+a*E,h+a*s]}function W(l,h,C,D,v,A,B){var u=l-C,E=h-D,s=(B?A:-A)/L(u*u+E*E),n=s*E,m=-s*u,a=l+n,i=h+m,f=C+n,c=D+m,F=(a+f)/2,t=(i+c)/2,p=f-a,g=c-i,R=p*p+g*g,T=v-A,P=a*c-f*i,I=(g<0?-1:1)*L(on(0,T*T*R-P*P)),O=(P*g-p*I)/R,S=(-P*p-g*I)/R,w=(P*g+p*I)/R,d=(-P*p+g*I)/R,x=O-F,e=S-t,r=w-F,G=d-t;return x*x+e*e>r*r+G*G&&(O=w,S=d),{cx:O,cy:S,x01:-n,y01:-m,x11:O*(v/T-1),y11:S*(v/T-1)}}function hn(){var l=cn,h=yn,C=j(0),D=null,v=gn,A=mn,B=pn,u=null,E=ln(s);function s(){var n,m,a=+l.apply(this,arguments),i=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,F=rn(c-f),t=c>f;if(u||(u=n=E()),i<a&&(m=i,i=a,a=m),!(i>y))u.moveTo(0,0);else if(F>tn-y)u.moveTo(i*H(f),i*q(f)),u.arc(0,0,i,f,c,!t),a>y&&(u.moveTo(a*H(c),a*q(c)),u.arc(0,0,a,c,f,t));else{var p=f,g=c,R=f,T=c,P=F,I=F,O=B.apply(this,arguments)/2,S=O>y&&(D?+D.apply(this,arguments):L(a*a+i*i)),w=_(rn(i-a)/2,+C.apply(this,arguments)),d=w,x=w,e,r;if(S>y){var G=sn(S/a*q(O)),M=sn(S/i*q(O));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(I-=M*2)>y?(M*=t?1:-1,p+=M,g-=M):(I=0,p=g=(f+c)/2)}var J=i*H(p),K=i*q(p),N=a*H(T),Q=a*q(T);if(w>y){var U=i*H(g),V=i*q(g),X=a*H(R),Y=a*q(R),z;if(F<un)if(z=dn(J,K,X,Y,U,V,N,Q)){var Z=J-z[0],$=K-z[1],k=U-z[0],b=V-z[1],nn=1/q(fn((Z*k+$*b)/(L(Z*Z+$*$)*L(k*k+b*b)))/2),en=L(z[0]*z[0]+z[1]*z[1]);d=_(w,(a-en)/(nn-1)),x=_(w,(i-en)/(nn+1))}else d=x=0}I>y?x>y?(e=W(X,Y,J,K,i,x,t),r=W(U,V,N,Q,i,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,i,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(J,K),u.arc(0,0,i,p,g,!t)):u.moveTo(J,K),!(a>y)||!(P>y)?u.lineTo(N,Q):d>y?(e=W(N,Q,U,V,a,-d,t),r=W(J,K,X,Y,a,-d,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),d<w?u.arc(e.cx,e.cy,d,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,d,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,d,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,R,t)}if(u.closePath(),n)return u=null,n+""||null}return s.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,m=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-un/2;return[H(m)*n,q(m)*n]},s.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),s):l},s.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),s):h},s.cornerRadius=function(n){return arguments.length?(C=typeof n=="function"?n:j(+n),s):C},s.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),s):D},s.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),s):v},s.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),s):A},s.padAngle=function(n){return arguments.length?(B=typeof n=="function"?n:j(+n),s):B},s.context=function(n){return arguments.length?(u=n??null,s):u},s}export{hn as d};
|