@agent-native/dispatch 0.14.2 → 0.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -122
- package/dist/actions/approve-dispatch-change.d.ts +10 -10
- package/dist/actions/list_apps.d.ts +1 -0
- package/dist/actions/list_apps.js +16 -8
- package/dist/actions/list_apps.js.map +1 -1
- package/dist/actions/provider-api-register.js +64 -2
- package/dist/actions/provider-api-register.js.map +1 -1
- package/dist/actions/reject-dispatch-change.d.ts +10 -10
- package/dist/actions/set-mcp-app-access.js +1 -4
- package/dist/actions/set-mcp-app-access.js.map +1 -1
- package/dist/components/action-query-error.d.ts +8 -0
- package/dist/components/action-query-error.d.ts.map +1 -0
- package/dist/components/action-query-error.js +10 -0
- package/dist/components/action-query-error.js.map +1 -0
- package/dist/components/app-keys-popover.d.ts +4 -0
- package/dist/components/app-keys-popover.d.ts.map +1 -1
- package/dist/components/app-keys-popover.js +26 -14
- package/dist/components/app-keys-popover.js.map +1 -1
- package/dist/components/dispatch-control-plane.d.ts.map +1 -1
- package/dist/components/dispatch-control-plane.js +31 -27
- package/dist/components/dispatch-control-plane.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/layout/Layout.d.ts +1 -0
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +19 -21
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/workspace-app-card.d.ts.map +1 -1
- package/dist/components/workspace-app-card.js +8 -5
- package/dist/components/workspace-app-card.js.map +1 -1
- package/dist/components/workspace-resource-effective-stack.d.ts.map +1 -1
- package/dist/components/workspace-resource-effective-stack.js +6 -1
- package/dist/components/workspace-resource-effective-stack.js.map +1 -1
- package/dist/components/workspace-resource-impact-preview.d.ts.map +1 -1
- package/dist/components/workspace-resource-impact-preview.js +6 -1
- package/dist/components/workspace-resource-impact-preview.js.map +1 -1
- package/dist/routes/pages/$appId.d.ts.map +1 -1
- package/dist/routes/pages/$appId.js +6 -1
- package/dist/routes/pages/$appId.js.map +1 -1
- package/dist/routes/pages/agents.d.ts.map +1 -1
- package/dist/routes/pages/agents.js +5 -8
- package/dist/routes/pages/agents.js.map +1 -1
- package/dist/routes/pages/approval.d.ts.map +1 -1
- package/dist/routes/pages/approval.js +6 -1
- package/dist/routes/pages/approval.js.map +1 -1
- package/dist/routes/pages/approvals.d.ts.map +1 -1
- package/dist/routes/pages/approvals.js +8 -5
- package/dist/routes/pages/approvals.js.map +1 -1
- package/dist/routes/pages/apps.$appId.d.ts.map +1 -1
- package/dist/routes/pages/apps.$appId.js +4 -2
- package/dist/routes/pages/apps.$appId.js.map +1 -1
- package/dist/routes/pages/apps.d.ts.map +1 -1
- package/dist/routes/pages/apps.js +9 -3
- package/dist/routes/pages/apps.js.map +1 -1
- package/dist/routes/pages/audit.d.ts.map +1 -1
- package/dist/routes/pages/audit.js +4 -2
- package/dist/routes/pages/audit.js.map +1 -1
- package/dist/routes/pages/chat.d.ts.map +1 -1
- package/dist/routes/pages/chat.js +16 -2
- package/dist/routes/pages/chat.js.map +1 -1
- package/dist/routes/pages/destinations.d.ts.map +1 -1
- package/dist/routes/pages/destinations.js +5 -3
- package/dist/routes/pages/destinations.js.map +1 -1
- package/dist/routes/pages/identities.d.ts.map +1 -1
- package/dist/routes/pages/identities.js +5 -3
- package/dist/routes/pages/identities.js.map +1 -1
- package/dist/routes/pages/integrations.d.ts.map +1 -1
- package/dist/routes/pages/integrations.js +9 -3
- package/dist/routes/pages/integrations.js.map +1 -1
- package/dist/routes/pages/thread-debug.d.ts.map +1 -1
- package/dist/routes/pages/thread-debug.js +7 -6
- package/dist/routes/pages/thread-debug.js.map +1 -1
- package/dist/routes/pages/vault.d.ts.map +1 -1
- package/dist/routes/pages/vault.js +23 -7
- package/dist/routes/pages/vault.js.map +1 -1
- package/dist/routes/pages/workspace.d.ts.map +1 -1
- package/dist/routes/pages/workspace.js +9 -3
- package/dist/routes/pages/workspace.js.map +1 -1
- package/dist/server/lib/dispatch-store.d.ts +24 -21
- package/dist/server/lib/dispatch-store.d.ts.map +1 -1
- package/dist/server/lib/dispatch-store.js +59 -23
- package/dist/server/lib/dispatch-store.js.map +1 -1
- package/dist/server/lib/mcp-access-store.d.ts.map +1 -1
- package/dist/server/lib/mcp-access-store.js +30 -2
- package/dist/server/lib/mcp-access-store.js.map +1 -1
- package/dist/server/lib/vault-store.d.ts.map +1 -1
- package/dist/server/lib/vault-store.js +102 -37
- package/dist/server/lib/vault-store.js.map +1 -1
- package/dist/server/plugins/agent-chat.d.ts +1 -1
- package/package.json +2 -3
- package/src/actions/list_apps.spec.ts +52 -0
- package/src/actions/list_apps.ts +16 -8
- package/src/actions/provider-api-register.spec.ts +193 -0
- package/src/actions/provider-api-register.ts +66 -1
- package/src/actions/set-mcp-app-access.spec.ts +73 -0
- package/src/actions/set-mcp-app-access.ts +1 -5
- package/src/components/action-query-error.spec.tsx +56 -0
- package/src/components/action-query-error.tsx +32 -0
- package/src/components/app-keys-popover.spec.tsx +85 -0
- package/src/components/app-keys-popover.tsx +76 -50
- package/src/components/dispatch-control-plane.spec.tsx +106 -0
- package/src/components/dispatch-control-plane.tsx +71 -115
- package/src/components/index.ts +1 -0
- package/src/components/layout/Layout.spec.tsx +42 -2
- package/src/components/layout/Layout.tsx +22 -27
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/toast.tsx +1 -1
- package/src/components/workspace-app-card.spec.tsx +80 -0
- package/src/components/workspace-app-card.tsx +36 -25
- package/src/components/workspace-resource-effective-stack.tsx +13 -1
- package/src/components/workspace-resource-impact-preview.tsx +12 -1
- package/src/routes/pages/$appId.tsx +17 -1
- package/src/routes/pages/agents.tsx +24 -11
- package/src/routes/pages/approval.tsx +16 -4
- package/src/routes/pages/approvals.tsx +108 -89
- package/src/routes/pages/apps.$appId.tsx +9 -2
- package/src/routes/pages/apps.tsx +20 -7
- package/src/routes/pages/audit.tsx +29 -20
- package/src/routes/pages/chat.spec.tsx +94 -0
- package/src/routes/pages/chat.tsx +30 -10
- package/src/routes/pages/destinations.tsx +75 -62
- package/src/routes/pages/identities.tsx +74 -63
- package/src/routes/pages/integrations.tsx +17 -10
- package/src/routes/pages/thread-debug.tsx +18 -12
- package/src/routes/pages/vault.tsx +59 -26
- package/src/routes/pages/workspace.tsx +69 -55
- package/src/server/lib/approval-fencing.spec.ts +420 -0
- package/src/server/lib/dispatch-store.ts +94 -21
- package/src/server/lib/mcp-access-store.spec.ts +116 -4
- package/src/server/lib/mcp-access-store.ts +37 -2
- package/src/server/lib/mcp-gateway.spec.ts +79 -3
- package/src/server/lib/vault-store.ts +151 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-keys-popover.d.ts","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"app-keys-popover.d.ts","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAwB1D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC5C;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAa,EACb,IAAe,GAChB,EAAE,mBAAmB,mDAwCrB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,mDA8LA"}
|
|
@@ -3,22 +3,27 @@ import { useActionMutation, useActionQuery } from "@agent-native/core/client";
|
|
|
3
3
|
import { IconCheck, IconLoader2, IconRefresh, IconSettings, } from "@tabler/icons-react";
|
|
4
4
|
import { useMemo, useState } from "react";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
|
+
import { ActionQueryError } from "./action-query-error.js";
|
|
6
7
|
import { Button } from "./ui/button.js";
|
|
7
8
|
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover.js";
|
|
8
9
|
import { Skeleton } from "./ui/skeleton.js";
|
|
10
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip.js";
|
|
9
11
|
export function AppKeysPopover({ appId, appName, trigger, align = "end", side = "bottom", }) {
|
|
10
12
|
const [open, setOpen] = useState(false);
|
|
11
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: trigger ?? (_jsx(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(PopoverTrigger, { asChild: true, children: trigger ?? (_jsx(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": `Manage keys for ${appName}`, onClick: (event) => {
|
|
14
|
+
// Keep parent card click handlers from also firing. Do not
|
|
15
|
+
// preventDefault here: Radix uses the same click to open the
|
|
16
|
+
// popover trigger.
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
}, className: "size-7 rounded-md p-0 text-muted-foreground transition-[background-color,color] hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-foreground", children: _jsx(IconSettings, { size: 14 }) })) }) }), _jsx(TooltipContent, { children: "Manage keys" })] }), _jsx(PopoverContent, { align: align, side: side, sideOffset: 6, className: "w-80 p-3", onClick: (event) => event.stopPropagation(), children: open ? _jsx(AppKeysPanel, { appId: appId, appName: appName }) : null })] }));
|
|
17
19
|
}
|
|
18
|
-
function AppKeysPanel({ appId, appName }) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
export function AppKeysPanel({ appId, appName, }) {
|
|
21
|
+
const secretsQuery = useActionQuery("list-vault-secret-options", {});
|
|
22
|
+
const grantsQuery = useActionQuery("list-vault-grants", { appId });
|
|
23
|
+
const accessQuery = useActionQuery("get-vault-access-settings", {});
|
|
24
|
+
const { data: secrets = [], isLoading: secretsLoading } = secretsQuery;
|
|
25
|
+
const { data: grants = [], isLoading: grantsLoading, refetch: refetchGrants, } = grantsQuery;
|
|
26
|
+
const { data: accessSettings, isLoading: accessLoading } = accessQuery;
|
|
22
27
|
const accessMode = accessSettings?.mode === "manual" ? "manual" : "all-apps";
|
|
23
28
|
const grantBySecretId = useMemo(() => {
|
|
24
29
|
const map = new Map();
|
|
@@ -59,6 +64,7 @@ function AppKeysPanel({ appId, appName }) {
|
|
|
59
64
|
onError: (err) => toast.error(`Sync failed: ${String(err)}`),
|
|
60
65
|
});
|
|
61
66
|
const isLoading = secretsLoading || grantsLoading || accessLoading;
|
|
67
|
+
const error = secretsQuery.error ?? grantsQuery.error ?? accessQuery.error;
|
|
62
68
|
const grantedCount = grantBySecretId.size;
|
|
63
69
|
const typedSecrets = secrets;
|
|
64
70
|
const allApps = accessMode !== "manual";
|
|
@@ -77,11 +83,17 @@ function AppKeysPanel({ appId, appName }) {
|
|
|
77
83
|
grantMutation.mutate({ secretId: secret.id, appId }, { onSettled });
|
|
78
84
|
}
|
|
79
85
|
};
|
|
80
|
-
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 px-1", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("p", { className: "truncate text-sm font-semibold text-foreground", children: ["Keys for ", appName] }), _jsx("p", { className: "text-[11px] text-muted-foreground", children:
|
|
81
|
-
?
|
|
82
|
-
:
|
|
86
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 px-1", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("p", { className: "truncate text-sm font-semibold text-foreground", children: ["Keys for ", appName] }), _jsx("p", { className: "text-[11px] text-muted-foreground", children: error
|
|
87
|
+
? null
|
|
88
|
+
: allApps
|
|
89
|
+
? `${typedSecrets.length} available`
|
|
90
|
+
: `${grantedCount} of ${typedSecrets.length} granted` })] }), !error ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: syncMutation.isPending ||
|
|
83
91
|
typedSecrets.length === 0 ||
|
|
84
|
-
(!allApps && grantedCount === 0), onClick: () => syncMutation.mutate({ appId }), className: "h-7 px-2", children: [syncMutation.isPending ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : (_jsx(IconRefresh, { className: "h-3 w-3" })), _jsx("span", { className: "ml-1 text-xs", children: "Sync" })] })] }), _jsx("div", { className: "max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5", children:
|
|
92
|
+
(!allApps && grantedCount === 0), onClick: () => syncMutation.mutate({ appId }), className: "h-7 px-2", children: [syncMutation.isPending ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : (_jsx(IconRefresh, { className: "h-3 w-3" })), _jsx("span", { className: "ml-1 text-xs", children: "Sync" })] })) : null] }), _jsx("div", { className: "max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5", children: error ? (_jsx(ActionQueryError, { error: error, onRetry: () => {
|
|
93
|
+
void secretsQuery.refetch();
|
|
94
|
+
void grantsQuery.refetch();
|
|
95
|
+
void accessQuery.refetch();
|
|
96
|
+
} })) : isLoading ? (_jsx("div", { className: "space-y-1.5 p-1.5", children: Array.from({ length: 3 }).map((_, index) => (_jsxs("div", { className: "flex items-start gap-3 rounded-md px-2.5 py-2", children: [_jsx(Skeleton, { className: "mt-0.5 h-4 w-4 shrink-0 rounded" }), _jsxs("div", { className: "flex-1 space-y-1.5", children: [_jsx(Skeleton, { className: "h-3 w-1/2" }), _jsx(Skeleton, { className: "h-3 w-3/4" })] })] }, index))) })) : typedSecrets.length === 0 ? (_jsx("p", { className: "rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground", children: "No vault keys yet. Add one from the Vault page." })) : (typedSecrets.map((secret) => {
|
|
85
97
|
const granted = allApps || grantBySecretId.has(secret.id);
|
|
86
98
|
const pending = pendingSecretIds.has(secret.id);
|
|
87
99
|
return (_jsxs("button", { type: "button", "aria-pressed": granted, disabled: pending || allApps, onClick: () => toggleSecret(secret), className: `flex w-full items-start gap-3 rounded-md px-2.5 py-2 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60 ${pending || allApps ? "" : "cursor-pointer"} ${granted
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-keys-popover.js","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAyB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,CAAC,EACnC,SAAS,EAAE,0HACT,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAC5B,IACE,OAAO;4BACL,CAAC,CAAC,uCAAuC;4BACzC,CAAC,CAAC,+EACN,EAAE,aAEF,eACE,SAAS,EAAE,2EACT,OAAO;oCACL,CAAC,CAAC,8CAA8C;oCAChD,CAAC,CAAC,6CACN,EAAE,YAED,OAAO,CAAC,CAAC,CAAC,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,GAC9C,EACP,gBAAM,SAAS,EAAC,gBAAgB,aAC9B,eAAM,SAAS,EAAC,4BAA4B,YACzC,MAAM,CAAC,aAAa,GAChB,EACP,eAAM,SAAS,EAAC,iDAAiD,YAC9D,OAAO;4CACN,CAAC,CAAC,uBAAuB;4CACzB,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,IAAI,cAAc,GAC/C,IACF,KA/BF,MAAM,CAAC,EAAE,CAgCP,CACV,CAAC;gBACJ,CAAC,CAAC,CACH,GACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useActionMutation, useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconCheck,\n IconLoader2,\n IconRefresh,\n IconSettings,\n} from \"@tabler/icons-react\";\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { toast } from \"sonner\";\n\nimport { Button } from \"./ui/button\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./ui/popover\";\nimport { Skeleton } from \"./ui/skeleton\";\n\ninterface VaultSecret {\n id: string;\n name?: string | null;\n credentialKey: string;\n provider?: string | null;\n description?: string | null;\n}\n\ninterface VaultGrant {\n id: string;\n secretId: string;\n appId: string;\n status?: string | null;\n}\n\ninterface AppKeysPopoverProps {\n appId: string;\n appName: string;\n trigger?: ReactNode;\n align?: \"start\" | \"center\" | \"end\";\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n}\n\nexport function AppKeysPopover({\n appId,\n appName,\n trigger,\n align = \"end\",\n side = \"bottom\",\n}: AppKeysPopoverProps) {\n const [open, setOpen] = useState(false);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n {trigger ?? (\n <button\n type=\"button\"\n aria-label={`Manage keys for ${appName}`}\n onClick={(event) => {\n // Keep parent card click handlers from also firing. Do not\n // preventDefault here: Radix uses the same click to open the\n // popover trigger.\n event.stopPropagation();\n }}\n className=\"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-transparent text-muted-foreground/70 hover:border-border hover:bg-accent/40 hover:text-foreground\"\n >\n <IconSettings size={14} />\n </button>\n )}\n </PopoverTrigger>\n <PopoverContent\n align={align}\n side={side}\n sideOffset={6}\n className=\"w-80 p-3\"\n onClick={(event) => event.stopPropagation()}\n >\n {open ? <AppKeysPanel appId={appId} appName={appName} /> : null}\n </PopoverContent>\n </Popover>\n );\n}\n\nfunction AppKeysPanel({ appId, appName }: { appId: string; appName: string }) {\n const { data: secrets = [], isLoading: secretsLoading } = useActionQuery(\n \"list-vault-secret-options\",\n {},\n );\n const {\n data: grants = [],\n isLoading: grantsLoading,\n refetch: refetchGrants,\n } = useActionQuery(\"list-vault-grants\", { appId });\n const { data: accessSettings, isLoading: accessLoading } = useActionQuery(\n \"get-vault-access-settings\",\n {},\n );\n const accessMode =\n (accessSettings as any)?.mode === \"manual\" ? \"manual\" : \"all-apps\";\n\n const grantBySecretId = useMemo(() => {\n const map = new Map<string, VaultGrant>();\n for (const grant of grants as VaultGrant[]) {\n if (grant.status && grant.status !== \"active\") continue;\n map.set(grant.secretId, grant);\n }\n return map;\n }, [grants]);\n\n // Track per-secret pending state so a fast double-click on the same row\n // can't queue two `create-vault-grant` requests (which would silently\n // create duplicate active grants — a later revoke only clears one).\n const [pendingSecretIds, setPendingSecretIds] = useState<Set<string>>(\n () => new Set(),\n );\n const markPending = (secretId: string, pending: boolean) =>\n setPendingSecretIds((prev) => {\n const next = new Set(prev);\n if (pending) next.add(secretId);\n else next.delete(secretId);\n return next;\n });\n\n const grantMutation = useActionMutation(\"create-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not grant: ${String(err)}`),\n });\n\n const revokeMutation = useActionMutation(\"revoke-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not revoke: ${String(err)}`),\n });\n\n const syncMutation = useActionMutation(\"sync-vault-to-app\", {\n onSuccess: (result: any) => {\n const synced = result?.synced ?? 0;\n toast.success(\n synced > 0\n ? `Synced ${synced} key${synced === 1 ? \"\" : \"s\"} to ${appName}`\n : `${appName} is up to date`,\n );\n },\n onError: (err) => toast.error(`Sync failed: ${String(err)}`),\n });\n\n const isLoading = secretsLoading || grantsLoading || accessLoading;\n const grantedCount = grantBySecretId.size;\n const typedSecrets = secrets as VaultSecret[];\n const allApps = accessMode !== \"manual\";\n\n const toggleSecret = (secret: VaultSecret) => {\n if (allApps) return;\n if (pendingSecretIds.has(secret.id)) return;\n const existing = grantBySecretId.get(secret.id);\n markPending(secret.id, true);\n const onSettled = () => markPending(secret.id, false);\n if (existing) {\n revokeMutation.mutate({ grantId: existing.id }, { onSettled });\n } else {\n grantMutation.mutate({ secretId: secret.id, appId }, { onSettled });\n }\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-foreground\">\n Keys for {appName}\n </p>\n <p className=\"text-[11px] text-muted-foreground\">\n {allApps\n ? `${typedSecrets.length} available`\n : `${grantedCount} of ${typedSecrets.length} granted`}\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={\n syncMutation.isPending ||\n typedSecrets.length === 0 ||\n (!allApps && grantedCount === 0)\n }\n onClick={() => syncMutation.mutate({ appId })}\n className=\"h-7 px-2\"\n >\n {syncMutation.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n <IconRefresh className=\"h-3 w-3\" />\n )}\n <span className=\"ml-1 text-xs\">Sync</span>\n </Button>\n </div>\n\n <div className=\"max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5\">\n {isLoading ? (\n <div className=\"space-y-1.5 p-1.5\">\n {Array.from({ length: 3 }).map((_, index) => (\n <div\n key={index}\n className=\"flex items-start gap-3 rounded-md px-2.5 py-2\"\n >\n <Skeleton className=\"mt-0.5 h-4 w-4 shrink-0 rounded\" />\n <div className=\"flex-1 space-y-1.5\">\n <Skeleton className=\"h-3 w-1/2\" />\n <Skeleton className=\"h-3 w-3/4\" />\n </div>\n </div>\n ))}\n </div>\n ) : typedSecrets.length === 0 ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n No vault keys yet. Add one from the Vault page.\n </p>\n ) : (\n typedSecrets.map((secret) => {\n const granted = allApps || grantBySecretId.has(secret.id);\n const pending = pendingSecretIds.has(secret.id);\n return (\n <button\n key={secret.id}\n type=\"button\"\n aria-pressed={granted}\n disabled={pending || allApps}\n onClick={() => toggleSecret(secret)}\n className={`flex w-full items-start gap-3 rounded-md px-2.5 py-2 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60 ${\n pending || allApps ? \"\" : \"cursor-pointer\"\n } ${\n granted\n ? \"border border-primary/45 bg-primary/5\"\n : \"border border-transparent hover:border-muted-foreground/30 hover:bg-accent/35\"\n }`}\n >\n <span\n className={`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border ${\n granted\n ? \"border-primary/60 bg-primary/10 text-primary\"\n : \"border-muted-foreground/35 text-transparent\"\n }`}\n >\n {granted ? <IconCheck className=\"h-3 w-3\" /> : null}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium\">\n {secret.credentialKey}\n </span>\n <span className=\"block truncate text-xs text-muted-foreground/70\">\n {allApps\n ? \"Available to this app\"\n : secret.provider || secret.name || \"Vault secret\"}\n </span>\n </span>\n </button>\n );\n })\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"app-keys-popover.js","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAyBvE,MAAM,UAAU,cAAc,CAAC,EAC7B,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAK,GAAG,KAAK,EACb,IAAI,GAAG,QAAQ,GACK;IACpB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,aACxC,MAAC,OAAO,eACN,KAAC,cAAc,IAAC,OAAO,kBACrB,KAAC,cAAc,IAAC,OAAO,kBACpB,OAAO,IAAI,CACV,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,IAAI,gBACG,mBAAmB,OAAO,EAAE,EACxC,OAAO,EAAE,CAAC,KAAK,EAAE,EA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,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAChD,OAAO,CACL,kBAEE,IAAI,EAAC,QAAQ,kBACC,OAAO,EACrB,QAAQ,EAAE,OAAO,IAAI,OAAO,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EACnC,SAAS,EAAE,0HACT,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAC5B,IACE,OAAO;4BACL,CAAC,CAAC,uCAAuC;4BACzC,CAAC,CAAC,+EACN,EAAE,aAEF,eACE,SAAS,EAAE,2EACT,OAAO;oCACL,CAAC,CAAC,8CAA8C;oCAChD,CAAC,CAAC,6CACN,EAAE,YAED,OAAO,CAAC,CAAC,CAAC,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,GAC9C,EACP,gBAAM,SAAS,EAAC,gBAAgB,aAC9B,eAAM,SAAS,EAAC,4BAA4B,YACzC,MAAM,CAAC,aAAa,GAChB,EACP,eAAM,SAAS,EAAC,iDAAiD,YAC9D,OAAO;4CACN,CAAC,CAAC,uBAAuB;4CACzB,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,IAAI,cAAc,GAC/C,IACF,KA/BF,MAAM,CAAC,EAAE,CAgCP,CACV,CAAC;gBACJ,CAAC,CAAC,CACH,GACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useActionMutation, useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconCheck,\n IconLoader2,\n IconRefresh,\n IconSettings,\n} from \"@tabler/icons-react\";\nimport { useMemo, useState, type ReactNode } from \"react\";\nimport { toast } from \"sonner\";\n\nimport { ActionQueryError } from \"./action-query-error\";\nimport { Button } from \"./ui/button\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./ui/popover\";\nimport { Skeleton } from \"./ui/skeleton\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"./ui/tooltip\";\n\ninterface VaultSecret {\n id: string;\n name?: string | null;\n credentialKey: string;\n provider?: string | null;\n description?: string | null;\n}\n\ninterface VaultGrant {\n id: string;\n secretId: string;\n appId: string;\n status?: string | null;\n}\n\ninterface AppKeysPopoverProps {\n appId: string;\n appName: string;\n trigger?: ReactNode;\n align?: \"start\" | \"center\" | \"end\";\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n}\n\nexport function AppKeysPopover({\n appId,\n appName,\n trigger,\n align = \"end\",\n side = \"bottom\",\n}: AppKeysPopoverProps) {\n const [open, setOpen] = useState(false);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <Tooltip>\n <TooltipTrigger asChild>\n <PopoverTrigger asChild>\n {trigger ?? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label={`Manage keys for ${appName}`}\n onClick={(event) => {\n // Keep parent card click handlers from also firing. Do not\n // preventDefault here: Radix uses the same click to open the\n // popover trigger.\n event.stopPropagation();\n }}\n className=\"size-7 rounded-md p-0 text-muted-foreground transition-[background-color,color] hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-foreground\"\n >\n <IconSettings size={14} />\n </Button>\n )}\n </PopoverTrigger>\n </TooltipTrigger>\n <TooltipContent>Manage keys</TooltipContent>\n </Tooltip>\n <PopoverContent\n align={align}\n side={side}\n sideOffset={6}\n className=\"w-80 p-3\"\n onClick={(event) => event.stopPropagation()}\n >\n {open ? <AppKeysPanel appId={appId} appName={appName} /> : null}\n </PopoverContent>\n </Popover>\n );\n}\n\nexport function AppKeysPanel({\n appId,\n appName,\n}: {\n appId: string;\n appName: string;\n}) {\n const secretsQuery = useActionQuery(\"list-vault-secret-options\", {});\n const grantsQuery = useActionQuery(\"list-vault-grants\", { appId });\n const accessQuery = useActionQuery(\"get-vault-access-settings\", {});\n const { data: secrets = [], isLoading: secretsLoading } = secretsQuery;\n const {\n data: grants = [],\n isLoading: grantsLoading,\n refetch: refetchGrants,\n } = grantsQuery;\n const { data: accessSettings, isLoading: accessLoading } = accessQuery;\n const accessMode =\n (accessSettings as any)?.mode === \"manual\" ? \"manual\" : \"all-apps\";\n\n const grantBySecretId = useMemo(() => {\n const map = new Map<string, VaultGrant>();\n for (const grant of grants as VaultGrant[]) {\n if (grant.status && grant.status !== \"active\") continue;\n map.set(grant.secretId, grant);\n }\n return map;\n }, [grants]);\n\n // Track per-secret pending state so a fast double-click on the same row\n // can't queue two `create-vault-grant` requests (which would silently\n // create duplicate active grants — a later revoke only clears one).\n const [pendingSecretIds, setPendingSecretIds] = useState<Set<string>>(\n () => new Set(),\n );\n const markPending = (secretId: string, pending: boolean) =>\n setPendingSecretIds((prev) => {\n const next = new Set(prev);\n if (pending) next.add(secretId);\n else next.delete(secretId);\n return next;\n });\n\n const grantMutation = useActionMutation(\"create-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not grant: ${String(err)}`),\n });\n\n const revokeMutation = useActionMutation(\"revoke-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not revoke: ${String(err)}`),\n });\n\n const syncMutation = useActionMutation(\"sync-vault-to-app\", {\n onSuccess: (result: any) => {\n const synced = result?.synced ?? 0;\n toast.success(\n synced > 0\n ? `Synced ${synced} key${synced === 1 ? \"\" : \"s\"} to ${appName}`\n : `${appName} is up to date`,\n );\n },\n onError: (err) => toast.error(`Sync failed: ${String(err)}`),\n });\n\n const isLoading = secretsLoading || grantsLoading || accessLoading;\n const error = secretsQuery.error ?? grantsQuery.error ?? accessQuery.error;\n const grantedCount = grantBySecretId.size;\n const typedSecrets = secrets as VaultSecret[];\n const allApps = accessMode !== \"manual\";\n\n const toggleSecret = (secret: VaultSecret) => {\n if (allApps) return;\n if (pendingSecretIds.has(secret.id)) return;\n const existing = grantBySecretId.get(secret.id);\n markPending(secret.id, true);\n const onSettled = () => markPending(secret.id, false);\n if (existing) {\n revokeMutation.mutate({ grantId: existing.id }, { onSettled });\n } else {\n grantMutation.mutate({ secretId: secret.id, appId }, { onSettled });\n }\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-foreground\">\n Keys for {appName}\n </p>\n <p className=\"text-[11px] text-muted-foreground\">\n {error\n ? null\n : allApps\n ? `${typedSecrets.length} available`\n : `${grantedCount} of ${typedSecrets.length} granted`}\n </p>\n </div>\n {!error ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={\n syncMutation.isPending ||\n typedSecrets.length === 0 ||\n (!allApps && grantedCount === 0)\n }\n onClick={() => syncMutation.mutate({ appId })}\n className=\"h-7 px-2\"\n >\n {syncMutation.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n <IconRefresh className=\"h-3 w-3\" />\n )}\n <span className=\"ml-1 text-xs\">Sync</span>\n </Button>\n ) : null}\n </div>\n\n <div className=\"max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5\">\n {error ? (\n <ActionQueryError\n error={error}\n onRetry={() => {\n void secretsQuery.refetch();\n void grantsQuery.refetch();\n void accessQuery.refetch();\n }}\n />\n ) : isLoading ? (\n <div className=\"space-y-1.5 p-1.5\">\n {Array.from({ length: 3 }).map((_, index) => (\n <div\n key={index}\n className=\"flex items-start gap-3 rounded-md px-2.5 py-2\"\n >\n <Skeleton className=\"mt-0.5 h-4 w-4 shrink-0 rounded\" />\n <div className=\"flex-1 space-y-1.5\">\n <Skeleton className=\"h-3 w-1/2\" />\n <Skeleton className=\"h-3 w-3/4\" />\n </div>\n </div>\n ))}\n </div>\n ) : typedSecrets.length === 0 ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n No vault keys yet. Add one from the Vault page.\n </p>\n ) : (\n typedSecrets.map((secret) => {\n const granted = allApps || grantBySecretId.has(secret.id);\n const pending = pendingSecretIds.has(secret.id);\n return (\n <button\n key={secret.id}\n type=\"button\"\n aria-pressed={granted}\n disabled={pending || allApps}\n onClick={() => toggleSecret(secret)}\n className={`flex w-full items-start gap-3 rounded-md px-2.5 py-2 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60 ${\n pending || allApps ? \"\" : \"cursor-pointer\"\n } ${\n granted\n ? \"border border-primary/45 bg-primary/5\"\n : \"border border-transparent hover:border-muted-foreground/30 hover:bg-accent/35\"\n }`}\n >\n <span\n className={`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border ${\n granted\n ? \"border-primary/60 bg-primary/10 text-primary\"\n : \"border-muted-foreground/35 text-transparent\"\n }`}\n >\n {granted ? <IconCheck className=\"h-3 w-3\" /> : null}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium\">\n {secret.credentialKey}\n </span>\n <span className=\"block truncate text-xs text-muted-foreground/70\">\n {allApps\n ? \"Available to this app\"\n : secret.provider || secret.name || \"Vault secret\"}\n </span>\n </span>\n </button>\n );\n })\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-control-plane.d.ts","sourceRoot":"","sources":["../../src/components/dispatch-control-plane.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dispatch-control-plane.d.ts","sourceRoot":"","sources":["../../src/components/dispatch-control-plane.tsx"],"names":[],"mappings":"AAkKA,wBAAgB,oBAAoB,oDAqBnC"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { PromptComposer, isInBuilderFrame, useActionQuery, useChatModels, useT, } from "@agent-native/core/client";
|
|
3
|
-
import { IconArrowUpRight
|
|
2
|
+
import { PromptComposer, isInBuilderFrame, navigateWithAgentChatViewTransition, useActionQuery, useChatModels, useT, } from "@agent-native/core/client";
|
|
3
|
+
import { IconArrowUpRight } from "@tabler/icons-react";
|
|
4
4
|
import { Link, useNavigate } from "react-router";
|
|
5
5
|
import { submitOverviewPrompt } from "../lib/overview-chat.js";
|
|
6
|
+
import { ActionQueryError } from "./action-query-error.js";
|
|
6
7
|
import { CreateAppPopover } from "./create-app-popover.js";
|
|
7
|
-
import {
|
|
8
|
+
import { useSetPageTitle } from "./layout/HeaderActions.js";
|
|
8
9
|
import { Button } from "./ui/button.js";
|
|
9
10
|
import { Skeleton } from "./ui/skeleton.js";
|
|
10
11
|
import { WorkspaceAppCard } from "./workspace-app-card.js";
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"Create an app for onboarding requests",
|
|
14
|
-
"Check which agents can help with analytics",
|
|
15
|
-
];
|
|
16
|
-
const WORKSPACE_LINKS = [
|
|
17
|
-
{ to: "/automations", labelKey: "dispatch.nav.automations" },
|
|
18
|
-
{ to: "/approvals", labelKey: "dispatch.nav.approvals" },
|
|
19
|
-
{ to: "/destinations", labelKey: "dispatch.nav.delivery" },
|
|
20
|
-
{ to: "/agents", labelKey: "dispatch.nav.agents" },
|
|
21
|
-
{ to: "/vault", labelKey: "dispatch.nav.vault" },
|
|
22
|
-
{ to: "/audit", labelKey: "dispatch.nav.audit" },
|
|
23
|
-
];
|
|
24
|
-
function SectionHeader({ icon: Icon, title, detail, action, }) {
|
|
25
|
-
return (_jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Icon, { size: 16, className: "shrink-0 text-muted-foreground" }), _jsxs("div", { className: "min-w-0", children: [_jsx("h2", { className: "truncate text-sm font-semibold text-foreground", children: title }), detail ? (_jsx("p", { className: "mt-0.5 truncate text-xs text-muted-foreground", children: detail })) : null] })] }), action ? _jsx("div", { className: "shrink-0", children: action }) : null] }));
|
|
12
|
+
function SectionHeader({ title, action, }) {
|
|
13
|
+
return (_jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [_jsx("h2", { className: "truncate text-sm font-semibold text-foreground", children: title }), action ? _jsx("div", { className: "shrink-0", children: action }) : null] }));
|
|
26
14
|
}
|
|
27
15
|
function CommandPanel() {
|
|
16
|
+
const t = useT();
|
|
28
17
|
const { selectedModel } = useChatModels();
|
|
29
18
|
const navigate = useNavigate();
|
|
19
|
+
const promptSuggestions = [
|
|
20
|
+
t("dispatch.pages.suggestionWorkspaceHealth", {
|
|
21
|
+
defaultValue: "Summarize the current workspace health",
|
|
22
|
+
}),
|
|
23
|
+
t("dispatch.pages.suggestionOnboardingApp", {
|
|
24
|
+
defaultValue: "Create an app for onboarding requests",
|
|
25
|
+
}),
|
|
26
|
+
t("dispatch.pages.suggestionAnalyticsAgents", {
|
|
27
|
+
defaultValue: "Check which agents can help with analytics",
|
|
28
|
+
}),
|
|
29
|
+
];
|
|
30
30
|
function send(message) {
|
|
31
31
|
const trimmed = message.trim();
|
|
32
32
|
if (!trimmed)
|
|
@@ -35,7 +35,7 @@ function CommandPanel() {
|
|
|
35
35
|
submitOverviewPrompt(trimmed, selectedModel);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
navigate
|
|
38
|
+
navigateWithAgentChatViewTransition(navigate, "/chat", {
|
|
39
39
|
state: {
|
|
40
40
|
dispatchPrompt: {
|
|
41
41
|
id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
@@ -45,19 +45,23 @@ function CommandPanel() {
|
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
return (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
return (_jsx("section", { className: "flex flex-col", children: _jsxs("div", { className: "mx-auto flex w-full max-w-3xl flex-col pt-4 sm:pt-6", children: [_jsxs("div", { className: "mb-5 text-center", children: [_jsx("h2", { className: "text-2xl font-semibold tracking-tight text-foreground sm:text-3xl", children: t("dispatch.pages.chatAcrossApps", {
|
|
49
|
+
defaultValue: "Chat across your apps",
|
|
50
|
+
}) }), _jsx("p", { className: "mx-auto mt-2 max-w-xl text-sm leading-6 text-muted-foreground", children: t("dispatch.pages.chatAcrossAppsDescription", {
|
|
51
|
+
defaultValue: "Route work, inspect status, or create something new from one place.",
|
|
52
|
+
}) })] }), _jsx(PromptComposer, { placeholder: t("dispatch.pages.overviewPromptPlaceholder", {
|
|
53
|
+
defaultValue: "Ask Dispatch anything...",
|
|
54
|
+
}), onSubmit: (text) => send(text) }), _jsx("div", { className: "mt-3 flex flex-wrap justify-center gap-2", children: promptSuggestions.map((suggestion) => (_jsx("button", { type: "button", onClick: () => send(suggestion), className: "cursor-pointer rounded-md border border-transparent bg-muted/60 px-2.5 py-1.5 text-xs text-muted-foreground transition-[background-color,color] hover:bg-muted hover:text-foreground", children: suggestion }, suggestion))) })] }) }));
|
|
53
55
|
}
|
|
54
56
|
function AppsPanel({ apps, isLoading, }) {
|
|
55
57
|
const visibleApps = apps.filter((app) => !app.isDispatch && !app.archived);
|
|
56
58
|
const showSkeletons = isLoading && visibleApps.length === 0;
|
|
57
|
-
return (_jsxs("section", { className: "flex flex-col gap-3", children: [_jsx(SectionHeader, {
|
|
59
|
+
return (_jsxs("section", { className: "flex flex-col gap-3", children: [_jsx(SectionHeader, { title: "Apps", action: _jsx(Button, { variant: "outline", size: "sm", asChild: true, children: _jsxs(Link, { to: "/apps", children: ["View all", _jsx(IconArrowUpRight, { size: 14 })] }) }) }), showSkeletons ? (_jsx("div", { className: "grid gap-3 md:grid-cols-2", children: Array.from({ length: 4 }).map((_, index) => (_jsxs("div", { className: "rounded-xl border border-border/60 bg-card/40 p-4", children: [_jsx(Skeleton, { className: "h-4 w-32" }), _jsx(Skeleton, { className: "mt-3 h-3 w-24" }), _jsx(Skeleton, { className: "mt-3 h-3 w-full" })] }, index))) })) : visibleApps.length > 0 ? (_jsx("div", { className: "grid gap-3 md:grid-cols-2", children: visibleApps.map((app) => (_jsx(WorkspaceAppCard, { app: app, className: "min-h-32" }, app.id))) })) : (_jsx(CreateAppPopover, {}))] }));
|
|
58
60
|
}
|
|
59
61
|
export function DispatchControlPlane() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
useSetPageTitle(_jsx("span", { "aria-hidden": true }));
|
|
63
|
+
const appsQuery = useActionQuery("list-workspace-apps", { includeAgentCards: false, includeArchived: true });
|
|
64
|
+
const { data: workspaceApps = [], isLoading: appsLoading } = appsQuery;
|
|
65
|
+
return (_jsxs("div", { className: "flex flex-col gap-8", children: [_jsx(CommandPanel, {}), appsQuery.isError ? (_jsx(ActionQueryError, { error: appsQuery.error, onRetry: () => void appsQuery.refetch() })) : (_jsx(AppsPanel, { apps: workspaceApps ?? [], isLoading: appsLoading }))] }));
|
|
62
66
|
}
|
|
63
67
|
//# sourceMappingURL=dispatch-control-plane.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-control-plane.js","sourceRoot":"","sources":["../../src/components/dispatch-control-plane.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,IAAI,GACL,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,UAAU,GAEX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,kBAAkB,GAAG;IACzB,wCAAwC;IACxC,uCAAuC;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Y,KAAG,EAChB,KAAC,cAAc,KAAG,EAClB,KAAC,SAAS,IAAC,IAAI,EAAE,aAAa,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,GAAI,IAC5D,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import {\n PromptComposer,\n isInBuilderFrame,\n useActionQuery,\n useChatModels,\n useT,\n} from \"@agent-native/core/client\";\nimport {\n IconArrowUpRight,\n IconBroadcast,\n IconStack3,\n type IconProps,\n} from \"@tabler/icons-react\";\nimport type { ReactNode } from \"react\";\nimport { Link, useNavigate } from \"react-router\";\n\nimport { submitOverviewPrompt } from \"../lib/overview-chat\";\nimport type { WorkspaceAppSummary } from \"../lib/workspace-apps\";\nimport { CreateAppPopover } from \"./create-app-popover\";\nimport { DispatchShell } from \"./dispatch-shell\";\nimport { Button } from \"./ui/button\";\nimport { Skeleton } from \"./ui/skeleton\";\nimport { WorkspaceAppCard } from \"./workspace-app-card\";\n\nconst PROMPT_SUGGESTIONS = [\n \"Summarize the current workspace health\",\n \"Create an app for onboarding requests\",\n \"Check which agents can help with analytics\",\n];\n\nconst WORKSPACE_LINKS = [\n { to: \"/automations\", labelKey: \"dispatch.nav.automations\" },\n { to: \"/approvals\", labelKey: \"dispatch.nav.approvals\" },\n { to: \"/destinations\", labelKey: \"dispatch.nav.delivery\" },\n { to: \"/agents\", labelKey: \"dispatch.nav.agents\" },\n { to: \"/vault\", labelKey: \"dispatch.nav.vault\" },\n { to: \"/audit\", labelKey: \"dispatch.nav.audit\" },\n] as const;\n\nfunction SectionHeader({\n icon: Icon,\n title,\n detail,\n action,\n}: {\n icon: React.ComponentType<IconProps>;\n title: string;\n detail?: string;\n action?: ReactNode;\n}) {\n return (\n <div className=\"flex min-w-0 items-center justify-between gap-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <Icon size={16} className=\"shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0\">\n <h2 className=\"truncate text-sm font-semibold text-foreground\">\n {title}\n </h2>\n {detail ? (\n <p className=\"mt-0.5 truncate text-xs text-muted-foreground\">\n {detail}\n </p>\n ) : null}\n </div>\n </div>\n {action ? <div className=\"shrink-0\">{action}</div> : null}\n </div>\n );\n}\n\nfunction CommandPanel() {\n const { selectedModel } = useChatModels();\n const navigate = useNavigate();\n\n function send(message: string) {\n const trimmed = message.trim();\n if (!trimmed) return;\n\n if (isInBuilderFrame()) {\n submitOverviewPrompt(trimmed, selectedModel);\n return;\n }\n\n navigate(\"/chat\", {\n state: {\n dispatchPrompt: {\n id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n message: trimmed,\n selectedModel,\n },\n },\n });\n }\n\n return (\n <section className=\"rounded-lg border bg-card p-4\">\n <div className=\"mb-3 flex items-center justify-between gap-3\">\n <div className=\"flex items-center gap-2\">\n <IconBroadcast size={16} className=\"text-muted-foreground\" />\n <h2 className=\"text-sm font-semibold text-foreground\">\n Ask Dispatch\n </h2>\n </div>\n <Button variant=\"outline\" size=\"sm\" asChild>\n <Link to=\"/chat\">\n Open chat\n <IconArrowUpRight size={14} />\n </Link>\n </Button>\n </div>\n <PromptComposer\n placeholder=\"Route work, inspect status, or create an app...\"\n onSubmit={(text) => send(text)}\n />\n <div className=\"mt-3 flex flex-wrap gap-2\">\n {PROMPT_SUGGESTIONS.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n onClick={() => send(suggestion)}\n className=\"cursor-pointer rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-muted-foreground transition hover:border-foreground/30 hover:text-foreground\"\n >\n {suggestion}\n </button>\n ))}\n </div>\n </section>\n );\n}\n\nfunction WorkspaceLinks() {\n const t = useT();\n\n return (\n <nav\n aria-label={t(\"dispatch.pages.workspaceShortcutsAria\")}\n className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground\"\n >\n <span className=\"font-medium text-foreground/70\">\n {t(\"dispatch.pages.also\")}\n </span>\n {WORKSPACE_LINKS.map((item, index) => (\n <span key={item.to} className=\"inline-flex items-center gap-x-3\">\n {index > 0 ? (\n <span aria-hidden className=\"text-border\">\n ·\n </span>\n ) : null}\n <Link\n to={item.to}\n className=\"transition hover:text-foreground hover:underline underline-offset-4\"\n >\n {t(item.labelKey)}\n </Link>\n </span>\n ))}\n </nav>\n );\n}\n\nfunction AppsPanel({\n apps,\n isLoading,\n}: {\n apps: WorkspaceAppSummary[];\n isLoading: boolean;\n}) {\n const visibleApps = apps.filter((app) => !app.isDispatch && !app.archived);\n const showSkeletons = isLoading && visibleApps.length === 0;\n\n return (\n <section className=\"flex flex-col gap-3\">\n <SectionHeader\n icon={IconStack3}\n title=\"Apps\"\n detail={\n visibleApps.length === 1 ? \"1 active\" : `${visibleApps.length} active`\n }\n action={\n <Button variant=\"outline\" size=\"sm\" asChild>\n <Link to=\"/apps\">\n View all\n <IconArrowUpRight size={14} />\n </Link>\n </Button>\n }\n />\n {showSkeletons ? (\n <div className=\"grid gap-3 md:grid-cols-2\">\n {Array.from({ length: 4 }).map((_, index) => (\n <div key={index} className=\"rounded-lg border bg-card p-4\">\n <Skeleton className=\"h-4 w-32\" />\n <Skeleton className=\"mt-3 h-3 w-24\" />\n <Skeleton className=\"mt-3 h-3 w-full\" />\n </div>\n ))}\n </div>\n ) : visibleApps.length > 0 ? (\n <div className=\"grid gap-3 md:grid-cols-2\">\n {visibleApps.map((app) => (\n <WorkspaceAppCard key={app.id} app={app} className=\"min-h-32\" />\n ))}\n </div>\n ) : (\n <CreateAppPopover />\n )}\n </section>\n );\n}\n\nexport function DispatchControlPlane() {\n const { data: workspaceApps = [], isLoading: appsLoading } = useActionQuery<\n WorkspaceAppSummary[]\n >(\"list-workspace-apps\", { includeAgentCards: false, includeArchived: true });\n\n return (\n <DispatchShell\n title=\"Overview\"\n description=\"Ask Dispatch or jump into a workspace app.\"\n >\n <div className=\"flex flex-col gap-6\">\n <CommandPanel />\n <WorkspaceLinks />\n <AppsPanel apps={workspaceApps ?? []} isLoading={appsLoading} />\n </div>\n </DispatchShell>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dispatch-control-plane.js","sourceRoot":"","sources":["../../src/components/dispatch-control-plane.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,mCAAmC,EACnC,cAAc,EACd,aAAa,EACb,IAAI,GACL,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,SAAS,aAAa,CAAC,EACrB,KAAK,EACL,MAAM,GAIP;IACC,OAAO,CACL,eAAK,SAAS,EAAC,iDAAiD,aAC9D,aAAI,SAAS,EAAC,gDAAgD,YAC3D,KAAK,GACH,EACJ,MAAM,CAAC,CAAC,CAAC,cAAK,SAAS,EAAC,UAAU,YAAE,MAAM,GAAO,CAAC,CAAC,CAAC,IAAI,IACrD,CACP,CAAC;AACJ,CAAC;AAED,SAAS,YAAY;IACnB,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,iBAAiB,GAAG;QACxB,CAAC,CAAC,0CAA0C,EAAE;YAC5C,YAAY,EAAE,wCAAwC;SACvD,CAAC;QACF,CAAC,CAA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ACP,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC3B,cAAK,SAAS,EAAC,2BAA2B,YACvC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACxB,KAAC,gBAAgB,IAAc,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC,UAAU,IAAtC,GAAG,CAAC,EAAE,CAAmC,CACjE,CAAC,GACE,CACP,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,KAAG,CACrB,IACO,CACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,eAAe,CAAC,qCAAoB,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,cAAc,CAC9B,qBAAqB,EACrB,EAAE,iBAAiB,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,CACpD,CAAC;IACF,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;IAEvE,OAAO,CACL,eAAK,SAAS,EAAC,qBAAqB,aAClC,KAAC,YAAY,KAAG,EACf,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CACnB,KAAC,gBAAgB,IACf,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,SAAS,CAAC,OAAO,EAAE,GACvC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IAAC,IAAI,EAAE,aAAa,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,GAAI,CACjE,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n PromptComposer,\n isInBuilderFrame,\n navigateWithAgentChatViewTransition,\n useActionQuery,\n useChatModels,\n useT,\n} from \"@agent-native/core/client\";\nimport { IconArrowUpRight } from \"@tabler/icons-react\";\nimport type { ReactNode } from \"react\";\nimport { Link, useNavigate } from \"react-router\";\n\nimport { submitOverviewPrompt } from \"../lib/overview-chat\";\nimport type { WorkspaceAppSummary } from \"../lib/workspace-apps\";\nimport { ActionQueryError } from \"./action-query-error\";\nimport { CreateAppPopover } from \"./create-app-popover\";\nimport { useSetPageTitle } from \"./layout/HeaderActions\";\nimport { Button } from \"./ui/button\";\nimport { Skeleton } from \"./ui/skeleton\";\nimport { WorkspaceAppCard } from \"./workspace-app-card\";\n\nfunction SectionHeader({\n title,\n action,\n}: {\n title: string;\n action?: ReactNode;\n}) {\n return (\n <div className=\"flex min-w-0 items-center justify-between gap-3\">\n <h2 className=\"truncate text-sm font-semibold text-foreground\">\n {title}\n </h2>\n {action ? <div className=\"shrink-0\">{action}</div> : null}\n </div>\n );\n}\n\nfunction CommandPanel() {\n const t = useT();\n const { selectedModel } = useChatModels();\n const navigate = useNavigate();\n const promptSuggestions = [\n t(\"dispatch.pages.suggestionWorkspaceHealth\", {\n defaultValue: \"Summarize the current workspace health\",\n }),\n t(\"dispatch.pages.suggestionOnboardingApp\", {\n defaultValue: \"Create an app for onboarding requests\",\n }),\n t(\"dispatch.pages.suggestionAnalyticsAgents\", {\n defaultValue: \"Check which agents can help with analytics\",\n }),\n ];\n\n function send(message: string) {\n const trimmed = message.trim();\n if (!trimmed) return;\n\n if (isInBuilderFrame()) {\n submitOverviewPrompt(trimmed, selectedModel);\n return;\n }\n\n navigateWithAgentChatViewTransition(navigate, \"/chat\", {\n state: {\n dispatchPrompt: {\n id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n message: trimmed,\n selectedModel,\n },\n },\n });\n }\n\n return (\n <section className=\"flex flex-col\">\n <div className=\"mx-auto flex w-full max-w-3xl flex-col pt-4 sm:pt-6\">\n <div className=\"mb-5 text-center\">\n <h2 className=\"text-2xl font-semibold tracking-tight text-foreground sm:text-3xl\">\n {t(\"dispatch.pages.chatAcrossApps\", {\n defaultValue: \"Chat across your apps\",\n })}\n </h2>\n <p className=\"mx-auto mt-2 max-w-xl text-sm leading-6 text-muted-foreground\">\n {t(\"dispatch.pages.chatAcrossAppsDescription\", {\n defaultValue:\n \"Route work, inspect status, or create something new from one place.\",\n })}\n </p>\n </div>\n <PromptComposer\n placeholder={t(\"dispatch.pages.overviewPromptPlaceholder\", {\n defaultValue: \"Ask Dispatch anything...\",\n })}\n onSubmit={(text) => send(text)}\n />\n <div className=\"mt-3 flex flex-wrap justify-center gap-2\">\n {promptSuggestions.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n onClick={() => send(suggestion)}\n className=\"cursor-pointer rounded-md border border-transparent bg-muted/60 px-2.5 py-1.5 text-xs text-muted-foreground transition-[background-color,color] hover:bg-muted hover:text-foreground\"\n >\n {suggestion}\n </button>\n ))}\n </div>\n </div>\n </section>\n );\n}\n\nfunction AppsPanel({\n apps,\n isLoading,\n}: {\n apps: WorkspaceAppSummary[];\n isLoading: boolean;\n}) {\n const visibleApps = apps.filter((app) => !app.isDispatch && !app.archived);\n const showSkeletons = isLoading && visibleApps.length === 0;\n\n return (\n <section className=\"flex flex-col gap-3\">\n <SectionHeader\n title=\"Apps\"\n action={\n <Button variant=\"outline\" size=\"sm\" asChild>\n <Link to=\"/apps\">\n View all\n <IconArrowUpRight size={14} />\n </Link>\n </Button>\n }\n />\n {showSkeletons ? (\n <div className=\"grid gap-3 md:grid-cols-2\">\n {Array.from({ length: 4 }).map((_, index) => (\n <div\n key={index}\n className=\"rounded-xl border border-border/60 bg-card/40 p-4\"\n >\n <Skeleton className=\"h-4 w-32\" />\n <Skeleton className=\"mt-3 h-3 w-24\" />\n <Skeleton className=\"mt-3 h-3 w-full\" />\n </div>\n ))}\n </div>\n ) : visibleApps.length > 0 ? (\n <div className=\"grid gap-3 md:grid-cols-2\">\n {visibleApps.map((app) => (\n <WorkspaceAppCard key={app.id} app={app} className=\"min-h-32\" />\n ))}\n </div>\n ) : (\n <CreateAppPopover />\n )}\n </section>\n );\n}\n\nexport function DispatchControlPlane() {\n useSetPageTitle(<span aria-hidden />);\n const appsQuery = useActionQuery<WorkspaceAppSummary[]>(\n \"list-workspace-apps\",\n { includeAgentCards: false, includeArchived: true },\n );\n const { data: workspaceApps = [], isLoading: appsLoading } = appsQuery;\n\n return (\n <div className=\"flex flex-col gap-8\">\n <CommandPanel />\n {appsQuery.isError ? (\n <ActionQueryError\n error={appsQuery.error}\n onRetry={() => void appsQuery.refetch()}\n />\n ) : (\n <AppsPanel apps={workspaceApps ?? []} isLoading={appsLoading} />\n )}\n </div>\n );\n}\n"]}
|
|
@@ -10,4 +10,5 @@ export { Layout, NavContent } from "./layout/Layout.js";
|
|
|
10
10
|
export type { DispatchExtensionConfig, DispatchNavIcon, DispatchNavItem, DispatchNavSection, } from "./layout/Layout.js";
|
|
11
11
|
export { CreateAppPopover, CreateAppFlow } from "./create-app-popover.js";
|
|
12
12
|
export { AppKeysPopover } from "./app-keys-popover.js";
|
|
13
|
+
export { ActionQueryError } from "./action-query-error.js";
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EACV,uBAAuB,EACvB,eAAe,EACf,eAAe,EACf,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EACV,uBAAuB,EACvB,eAAe,EACf,eAAe,EACf,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export { DispatchShell } from "./dispatch-shell.js";
|
|
|
9
9
|
export { Layout, NavContent } from "./layout/Layout.js";
|
|
10
10
|
export { CreateAppPopover, CreateAppFlow } from "./create-app-popover.js";
|
|
11
11
|
export { AppKeysPopover } from "./app-keys-popover.js";
|
|
12
|
+
export { ActionQueryError } from "./action-query-error.js";
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["/**\n * Public dispatch UI components. Most consumers only use `dispatchRoutes`\n * and never import from here directly — components are exported as a\n * customization escape hatch for embedding (e.g. mount `<DispatchShell>`\n * inside a parent layout, or render `<AppKeysPopover>` next to a custom\n * card list).\n */\nexport { DispatchShell } from \"./dispatch-shell.js\";\nexport { Layout, NavContent } from \"./layout/Layout.js\";\nexport type {\n DispatchExtensionConfig,\n DispatchNavIcon,\n DispatchNavItem,\n DispatchNavSection,\n} from \"./layout/Layout.js\";\nexport { CreateAppPopover, CreateAppFlow } from \"./create-app-popover.js\";\nexport { AppKeysPopover } from \"./app-keys-popover.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * Public dispatch UI components. Most consumers only use `dispatchRoutes`\n * and never import from here directly — components are exported as a\n * customization escape hatch for embedding (e.g. mount `<DispatchShell>`\n * inside a parent layout, or render `<AppKeysPopover>` next to a custom\n * card list).\n */\nexport { DispatchShell } from \"./dispatch-shell.js\";\nexport { Layout, NavContent } from \"./layout/Layout.js\";\nexport type {\n DispatchExtensionConfig,\n DispatchNavIcon,\n DispatchNavItem,\n DispatchNavSection,\n} from \"./layout/Layout.js\";\nexport { CreateAppPopover, CreateAppFlow } from \"./create-app-popover.js\";\nexport { AppKeysPopover } from \"./app-keys-popover.js\";\nexport { ActionQueryError } from \"./action-query-error.js\";\n"]}
|
|
@@ -22,6 +22,7 @@ export interface DispatchExtensionConfig {
|
|
|
22
22
|
/** Extra React Query keys to invalidate when Dispatch receives DB sync events. */
|
|
23
23
|
queryKeys?: readonly string[];
|
|
24
24
|
}
|
|
25
|
+
export declare function formatThreadAge(updatedAt: number, now?: number): string;
|
|
25
26
|
export declare function NavContent({ onNavigate, extensions, collapsed, collapsible, onCollapsedChange, }: {
|
|
26
27
|
onNavigate?: () => void;
|
|
27
28
|
extensions?: DispatchExtensionConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":"AA0CA,OAAO,EAKL,KAAK,aAAa,EAElB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAiBf,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,YAAY,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,iFAAiF;IACjF,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,mFAAmF;IACnF,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,gEAAgE;IAChE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AAED,MAAM,WAAW,uBAAuB;IACtC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACtC,kFAAkF;IAClF,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AA6ND,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAa,UAWlE;AAsPD,wBAAgB,UAAU,CAAC,EACzB,UAAU,EACV,UAAU,EACV,SAAiB,EACjB,WAAmB,EACnB,iBAAiB,GAClB,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD,mDA6PA;AAED,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,UAAU,GACX,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC,mDA2IA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AgentSidebar, FeedbackButton, appBasePath, appPath, focusAgentChat, navigateWithAgentChatViewTransition, useActionQuery, useAgentChatHomeHandoff, useAgentChatHomeHandoffLinks, useChatThreads,
|
|
2
|
+
import { AgentSidebar, FeedbackButton, appBasePath, appPath, focusAgentChat, navigateWithAgentChatViewTransition, useActionQuery, useAgentChatHomeHandoff, useAgentChatHomeHandoffLinks, useChatThreads, useT, } from "@agent-native/core/client";
|
|
3
3
|
import { ExtensionsSidebarSection } from "@agent-native/core/client/extensions";
|
|
4
4
|
import { InvitationBanner, OrgSwitcher } from "@agent-native/core/client/org";
|
|
5
5
|
import { IconActivity, IconArrowUpRight, IconApps, IconBrain, IconChartBar, IconBrandTelegram, IconKey, IconChevronDown, IconDots, IconEdit, IconLayersSubtract, IconMessageQuestion, IconMessages, IconPlus, IconPlugConnected, IconBroadcast, IconFingerprint, IconHistory, IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand, IconPuzzle, IconSettings, IconSettingsAutomation, IconShieldCheck, } from "@tabler/icons-react";
|
|
@@ -14,13 +14,6 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip.js";
|
|
|
14
14
|
import { Header } from "./Header.js";
|
|
15
15
|
import { HeaderActionsProvider } from "./HeaderActions.js";
|
|
16
16
|
const PRIMARY_NAV_ITEMS = [
|
|
17
|
-
{
|
|
18
|
-
id: "chat",
|
|
19
|
-
to: "/chat",
|
|
20
|
-
label: "Chat",
|
|
21
|
-
icon: IconMessageQuestion,
|
|
22
|
-
section: "primary",
|
|
23
|
-
},
|
|
24
17
|
{
|
|
25
18
|
id: "overview",
|
|
26
19
|
to: "/overview",
|
|
@@ -28,6 +21,13 @@ const PRIMARY_NAV_ITEMS = [
|
|
|
28
21
|
icon: IconBroadcast,
|
|
29
22
|
section: "primary",
|
|
30
23
|
},
|
|
24
|
+
{
|
|
25
|
+
id: "chat",
|
|
26
|
+
to: "/chat",
|
|
27
|
+
label: "Chat",
|
|
28
|
+
icon: IconMessageQuestion,
|
|
29
|
+
section: "primary",
|
|
30
|
+
},
|
|
31
31
|
{
|
|
32
32
|
id: "apps",
|
|
33
33
|
to: "/apps",
|
|
@@ -218,8 +218,8 @@ function threadIdFromPath(pathname) {
|
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function formatThreadAge(updatedAt,
|
|
222
|
-
const diffMs = Math.max(0,
|
|
221
|
+
export function formatThreadAge(updatedAt, now = Date.now()) {
|
|
222
|
+
const diffMs = Math.max(0, now - updatedAt);
|
|
223
223
|
const minutes = Math.floor(diffMs / 60_000);
|
|
224
224
|
if (minutes < 1)
|
|
225
225
|
return "now";
|
|
@@ -229,12 +229,11 @@ function formatThreadAge(updatedAt, formatDate) {
|
|
|
229
229
|
if (hours < 24)
|
|
230
230
|
return `${hours}h`;
|
|
231
231
|
const days = Math.floor(hours / 24);
|
|
232
|
-
if (days <
|
|
232
|
+
if (days < 14)
|
|
233
233
|
return `${days}d`;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
});
|
|
234
|
+
if (days < 365)
|
|
235
|
+
return `${Math.floor(days / 7)}w`;
|
|
236
|
+
return `${Math.floor(days / 365)}y`;
|
|
238
237
|
}
|
|
239
238
|
function threadTitle(thread, fallback) {
|
|
240
239
|
return thread.title || thread.preview || fallback;
|
|
@@ -248,7 +247,6 @@ function threadUpdatedAt(thread) {
|
|
|
248
247
|
}
|
|
249
248
|
function DispatchChatsSection({ onNavigate }) {
|
|
250
249
|
const t = useT();
|
|
251
|
-
const { formatDate } = useFormatters();
|
|
252
250
|
const navigate = useNavigate();
|
|
253
251
|
const location = useLocation();
|
|
254
252
|
const { threads, activeThreadId, isLoading: chatsLoading, createThread, switchThread, renameThread, refreshThreads, } = useChatThreads(undefined, "dispatch", undefined, { autoCreate: false });
|
|
@@ -343,11 +341,11 @@ function DispatchChatsSection({ onNavigate }) {
|
|
|
343
341
|
event.preventDefault();
|
|
344
342
|
cancelRenameThread();
|
|
345
343
|
}
|
|
346
|
-
}, maxLength: 160, "aria-label": t("dispatch.sidebar.renameThread", { title }), className: "h-6 min-w-0 rounded-sm border-sidebar-border bg-background px-1.5 text-xs" }) })) : (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
344
|
+
}, maxLength: 160, "aria-label": t("dispatch.sidebar.renameThread", { title }), className: "h-6 min-w-0 rounded-sm border-sidebar-border bg-background px-1.5 text-xs" }) })) : (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { type: "button", onClick: () => openThread(thread.id), className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 py-1.5 pe-1 text-start text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx("span", { className: "block min-w-0 flex-1 truncate", children: title }), _jsx("time", { className: "w-8 shrink-0 whitespace-nowrap text-end text-[11px] tabular-nums text-muted-foreground/60 transition-opacity group-hover/item:opacity-0 group-focus-within/item:opacity-0", children: isActive
|
|
345
|
+
? ""
|
|
346
|
+
: formatThreadAge(threadUpdatedAt(thread)) })] }) }), _jsx(TooltipContent, { side: "right", children: title })] }), _jsx("div", { className: "pointer-events-none absolute end-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5", children: _jsxs(DropdownMenu, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": t("dispatch.sidebar.chatOptions", {
|
|
347
|
+
title,
|
|
348
|
+
}), className: "pointer-events-auto rounded p-0.5 text-muted-foreground/50 opacity-0 transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/item:opacity-100 group-focus-within/item:opacity-100 data-[state=open]:opacity-100 data-[state=open]:text-foreground", children: _jsx(IconDots, { className: "size-3" }) }) }) }), _jsx(TooltipContent, { side: "right", children: t("dispatch.sidebar.chatOptions", { title }) })] }), _jsx(DropdownMenuContent, { align: "start", side: "right", className: "w-44", children: _jsxs(DropdownMenuItem, { onSelect: () => startRenameThread(thread), children: [_jsx(IconEdit, { className: "size-3.5" }), t("dispatch.sidebar.renameChat")] }) })] }) })] })) }, thread.id));
|
|
351
349
|
}), _jsxs("button", { type: "button", onClick: () => void handleNewChat(), className: "flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-1.5 text-xs text-muted-foreground/60 transition-colors hover:bg-sidebar-accent/50 hover:text-foreground", children: [_jsx(IconPlus, { className: "size-3 shrink-0" }), _jsx("span", { className: "truncate", children: t("dispatch.sidebar.newChat") })] })] }));
|
|
352
350
|
}
|
|
353
351
|
export function NavContent({ onNavigate, extensions, collapsed = false, collapsible = false, onCollapsedChange, }) {
|