@agent-native/dispatch 0.2.3 → 0.2.5
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 +4 -4
- package/dist/actions/start-workspace-app-creation.js +1 -1
- package/dist/actions/start-workspace-app-creation.js.map +1 -1
- package/dist/components/agents-panel.d.ts.map +1 -1
- package/dist/components/agents-panel.js +68 -4
- package/dist/components/agents-panel.js.map +1 -1
- package/dist/components/create-app-popover.d.ts.map +1 -1
- package/dist/components/create-app-popover.js +2 -0
- package/dist/components/create-app-popover.js.map +1 -1
- package/dist/lib/overview-chat.d.ts +2 -0
- package/dist/lib/overview-chat.d.ts.map +1 -0
- package/dist/lib/overview-chat.js +20 -0
- package/dist/lib/overview-chat.js.map +1 -0
- package/dist/routes/pages/overview.d.ts.map +1 -1
- package/dist/routes/pages/overview.js +4 -8
- package/dist/routes/pages/overview.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +5 -2
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/plugins/integrations.d.ts.map +1 -1
- package/dist/server/plugins/integrations.js +2 -1
- package/dist/server/plugins/integrations.js.map +1 -1
- package/package.json +2 -2
- package/src/actions/start-workspace-app-creation.ts +1 -1
- package/src/components/agents-panel.tsx +117 -22
- package/src/components/create-app-popover.tsx +2 -0
- package/src/lib/overview-chat.spec.ts +48 -0
- package/src/lib/overview-chat.ts +24 -0
- package/src/routes/pages/overview.tsx +3 -8
- package/src/server/lib/app-creation-store.ts +5 -1
- package/src/server/plugins/integrations.ts +2 -1
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@ The agent and the UI are equal citizens of the same system. Every action works b
|
|
|
18
18
|
- **Any database, any host** — Any SQL database Drizzle supports. Any hosting target Nitro supports. No lock-in.
|
|
19
19
|
- **Any AI agent** — Claude Code, Codex, Gemini CLI, OpenCode, or Builder.io. Use whichever agent you prefer.
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Templates
|
|
22
22
|
|
|
23
|
-
Start from a complete, production-grade SaaS app. Each one replaces tools you're paying for
|
|
23
|
+
Start from a complete, production-grade SaaS app — cloneable, not scaffolded. Each one replaces tools you're paying for, except you own everything and can customize it however you want. Not demos; products.
|
|
24
24
|
|
|
25
25
|
<table>
|
|
26
26
|
<tr>
|
|
@@ -145,7 +145,7 @@ Generate forms from a prompt, branch logic with the agent, and own every respons
|
|
|
145
145
|
</tr>
|
|
146
146
|
</table>
|
|
147
147
|
|
|
148
|
-
Every template is cloneable SaaS — fork it, customize it with the agent, own it. Try them with example data before connecting your own sources.
|
|
148
|
+
Every template is a complete cloneable SaaS — fork it, customize it with the agent, own it. Try them with example data before connecting your own sources.
|
|
149
149
|
|
|
150
150
|
## Quick Start
|
|
151
151
|
|
|
@@ -184,7 +184,7 @@ my-platform/
|
|
|
184
184
|
Add another app later:
|
|
185
185
|
|
|
186
186
|
```bash
|
|
187
|
-
agent-native add-app notes --template content
|
|
187
|
+
npx @agent-native/core add-app notes --template content
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
Deploy every app behind one origin:
|
|
@@ -3,7 +3,7 @@ import { getWorkspaceAppIdValidationError } from "@agent-native/core/shared";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { startWorkspaceAppCreation } from "../server/lib/app-creation-store.js";
|
|
5
5
|
export default defineAction({
|
|
6
|
-
description: "Start creating a new workspace app from Dispatch. In local dev this returns a code-agent prompt; in production it creates a Builder branch when a Builder project is configured.",
|
|
6
|
+
description: "Start creating a new workspace app from Dispatch when the request truly needs its own app. In local dev this returns a code-agent prompt; in production it creates a Builder branch when a Builder project is configured. The result must be a separate workspace app under apps/<app-id>, not a new route or file in apps/starter.",
|
|
7
7
|
schema: z.object({
|
|
8
8
|
prompt: z.string().min(1).describe("The user's app creation request"),
|
|
9
9
|
appId: z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-workspace-app-creation.js","sourceRoot":"","sources":["../../src/actions/start-workspace-app-creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"start-workspace-app-creation.js","sourceRoot":"","sources":["../../src/actions/start-workspace-app-creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,qUAAqU;IACvU,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QACrE,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,GAAG,CAAC,EAAE,CAAC;aACP,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,gCAAgC,CAAC,KAAK,CAAC,EAAE;YAC3D,OAAO,EACL,yEAAyE;SAC5E,CAAC;aACD,QAAQ,EAAE;aACV,QAAQ,EAAE;aACV,QAAQ,CAAC,+BAA+B,CAAC;QAC5C,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,EAAE;aACV,QAAQ,CAAC,wBAAwB,CAAC;QACrC,SAAS,EAAE,CAAC;aACT,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;aACjB,GAAG,CAAC,GAAG,CAAC;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,+CAA+C,CAAC;KAC7D,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC;CACrD,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { getWorkspaceAppIdValidationError } from \"@agent-native/core/shared\";\nimport { z } from \"zod\";\nimport { startWorkspaceAppCreation } from \"../server/lib/app-creation-store.js\";\n\nexport default defineAction({\n description:\n \"Start creating a new workspace app from Dispatch when the request truly needs its own app. In local dev this returns a code-agent prompt; in production it creates a Builder branch when a Builder project is configured. The result must be a separate workspace app under apps/<app-id>, not a new route or file in apps/starter.\",\n schema: z.object({\n prompt: z.string().min(1).describe(\"The user's app creation request\"),\n appId: z\n .string()\n .max(64)\n .refine((appId) => !getWorkspaceAppIdValidationError(appId), {\n message:\n \"Use a non-reserved app id with lowercase letters, numbers, and hyphens.\",\n })\n .optional()\n .nullable()\n .describe(\"Desired workspace app id/path\"),\n template: z\n .string()\n .optional()\n .nullable()\n .describe(\"Template to start from\"),\n secretIds: z\n .array(z.string())\n .max(100)\n .optional()\n .describe(\"Dispatch vault secret IDs to grant to the app\"),\n }),\n run: async (args) => startWorkspaceAppCreation(args),\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents-panel.d.ts","sourceRoot":"","sources":["../../src/components/agents-panel.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC/B;
|
|
1
|
+
{"version":3,"file":"agents-panel.d.ts","sourceRoot":"","sources":["../../src/components/agents-panel.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC/B;AA4CD,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,2CAuRA"}
|
|
@@ -5,21 +5,66 @@ import { Input } from "../components/ui/input.js";
|
|
|
5
5
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "../components/ui/alert-dialog.js";
|
|
6
6
|
import { IconExternalLink, IconTrash } from "@tabler/icons-react";
|
|
7
7
|
import { agentNativePath } from "@agent-native/core/client";
|
|
8
|
+
function slugifyAgentName(value) {
|
|
9
|
+
return value
|
|
10
|
+
.trim()
|
|
11
|
+
.toLowerCase()
|
|
12
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
13
|
+
.replace(/^-+|-+$/g, "");
|
|
14
|
+
}
|
|
15
|
+
function validateAgentForm(name, url) {
|
|
16
|
+
const errors = {};
|
|
17
|
+
const trimmedName = name.trim();
|
|
18
|
+
const trimmedUrl = url.trim();
|
|
19
|
+
if (!trimmedName) {
|
|
20
|
+
errors.name = "Agent name is required.";
|
|
21
|
+
}
|
|
22
|
+
else if (!slugifyAgentName(trimmedName)) {
|
|
23
|
+
errors.name = "Agent name must include at least one letter or number.";
|
|
24
|
+
}
|
|
25
|
+
if (!trimmedUrl) {
|
|
26
|
+
errors.url = "Agent endpoint URL is required.";
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = new URL(trimmedUrl);
|
|
31
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
32
|
+
errors.url = "Use an http:// or https:// endpoint URL.";
|
|
33
|
+
}
|
|
34
|
+
else if (!parsed.hostname) {
|
|
35
|
+
errors.url = "Enter a complete endpoint URL with a host.";
|
|
36
|
+
}
|
|
37
|
+
else if (parsed.username || parsed.password) {
|
|
38
|
+
errors.url = "Do not include credentials in the endpoint URL.";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
errors.url =
|
|
43
|
+
"Enter a valid endpoint URL, such as https://app.example.com.";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return errors;
|
|
47
|
+
}
|
|
8
48
|
export function AgentsPanel({ agents, onRefresh, }) {
|
|
9
49
|
const [name, setName] = useState("");
|
|
10
50
|
const [url, setUrl] = useState("");
|
|
11
51
|
const [description, setDescription] = useState("");
|
|
12
52
|
const [saving, setSaving] = useState(false);
|
|
53
|
+
const [errors, setErrors] = useState({});
|
|
13
54
|
const nameRef = useRef(null);
|
|
14
55
|
const customAgents = agents.filter((agent) => agent.source === "custom");
|
|
15
56
|
const workspaceAgents = agents.filter((agent) => agent.source === "workspace");
|
|
16
57
|
const builtinAgents = agents.filter((agent) => agent.source === "builtin");
|
|
17
|
-
const handleAdd = async () => {
|
|
58
|
+
const handleAdd = async (event) => {
|
|
59
|
+
event?.preventDefault();
|
|
18
60
|
const trimmedName = name.trim();
|
|
19
61
|
const trimmedUrl = url.trim();
|
|
20
|
-
|
|
62
|
+
const nextErrors = validateAgentForm(trimmedName, trimmedUrl);
|
|
63
|
+
if (Object.keys(nextErrors).length > 0) {
|
|
64
|
+
setErrors(nextErrors);
|
|
21
65
|
return;
|
|
22
|
-
|
|
66
|
+
}
|
|
67
|
+
const id = slugifyAgentName(trimmedName);
|
|
23
68
|
const agentJson = JSON.stringify({
|
|
24
69
|
id,
|
|
25
70
|
name: trimmedName,
|
|
@@ -42,9 +87,22 @@ export function AgentsPanel({ agents, onRefresh, }) {
|
|
|
42
87
|
setName("");
|
|
43
88
|
setUrl("");
|
|
44
89
|
setDescription("");
|
|
90
|
+
setErrors({});
|
|
45
91
|
onRefresh();
|
|
46
92
|
nameRef.current?.focus();
|
|
47
93
|
}
|
|
94
|
+
else {
|
|
95
|
+
setErrors({
|
|
96
|
+
form: `Could not add agent. Request failed with ${res.status}.`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
setErrors({
|
|
102
|
+
form: error instanceof Error
|
|
103
|
+
? error.message
|
|
104
|
+
: "Could not add agent. Please try again.",
|
|
105
|
+
});
|
|
48
106
|
}
|
|
49
107
|
finally {
|
|
50
108
|
setSaving(false);
|
|
@@ -59,6 +117,12 @@ export function AgentsPanel({ agents, onRefresh, }) {
|
|
|
59
117
|
if (res.ok)
|
|
60
118
|
onRefresh();
|
|
61
119
|
};
|
|
62
|
-
return (_jsx("section", { className: "rounded-2xl border bg-card p-5", children: _jsxs("div", { className: "grid gap-4 xl:grid-cols-[minmax(0,1fr)_320px]", children: [_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: "Available by default" }), _jsxs("div", { className: "mt-2 flex flex-wrap gap-2", children: [builtinAgents.map((agent) => (_jsxs("div", { className: "inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs text-muted-foreground", children: [_jsx("span", { className: "h-2 w-2 rounded-full", style: { backgroundColor: agent.color } }), _jsx("span", { children: agent.name })] }, agent.id))), builtinAgents.length === 0 && (_jsx("div", { className: "rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground", children: "No default agents detected." }))] })] }), _jsxs("div", { children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: "Added in this workspace" }), _jsxs("div", { className: "mt-2 space-y-2", children: [workspaceAgents.map((agent) => (_jsx("div", { className: "flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3", children: _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: agent.name }), agent.description ? (_jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: agent.description })) : null, _jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: _jsxs("a", { href: agent.url, target: "_blank", rel: "noreferrer", className: "inline-flex items-center gap-1 hover:text-foreground", children: [agent.url, _jsx(IconExternalLink, { className: "h-3 w-3" })] }) })] }) }, agent.id))), customAgents.map((agent) => (_jsxs("div", { className: "flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: agent.name }), agent.description ? (_jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: agent.description })) : null, _jsxs("div", { className: "mt-1 flex items-center gap-2 text-xs text-muted-foreground", children: [_jsxs("a", { href: agent.url, target: "_blank", rel: "noreferrer", className: "inline-flex items-center gap-1 hover:text-foreground", children: [agent.url, _jsx(IconExternalLink, { className: "h-3 w-3" })] }), _jsx("span", { children: "\u00B7" }), _jsx("span", { children: agent.scope || "shared" })] })] }), _jsxs(AlertDialog, { children: [_jsx(AlertDialogTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", children: _jsx(IconTrash, { className: "h-4 w-4" }) }) }), _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Remove this agent?" }), _jsxs(AlertDialogDescription, { children: ["\u201C", agent.name, "\u201D will be removed from the workspace. Any jobs or chats that delegate to it will stop working."] })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Cancel" }), _jsx(AlertDialogAction, { onClick: () => handleDelete(agent.resourceId), children: "Remove" })] })] })] })] }, agent.id))), workspaceAgents.length === 0 && customAgents.length === 0 && (_jsx("div", { className: "rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground", children: "No extra agents added yet." }))] })] })] }), _jsxs("div", { className: "rounded-xl border bg-muted/20 p-4", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: "Add external agent" }), _jsx("p", { className: "mt-1 text-xs leading-relaxed text-muted-foreground", children: "Add another A2A-compatible app by saving its agent endpoint here." }), _jsxs("
|
|
120
|
+
return (_jsx("section", { className: "rounded-2xl border bg-card p-5", children: _jsxs("div", { className: "grid gap-4 xl:grid-cols-[minmax(0,1fr)_320px]", children: [_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: "Available by default" }), _jsxs("div", { className: "mt-2 flex flex-wrap gap-2", children: [builtinAgents.map((agent) => (_jsxs("div", { className: "inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs text-muted-foreground", children: [_jsx("span", { className: "h-2 w-2 rounded-full", style: { backgroundColor: agent.color } }), _jsx("span", { children: agent.name })] }, agent.id))), builtinAgents.length === 0 && (_jsx("div", { className: "rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground", children: "No default agents detected." }))] })] }), _jsxs("div", { children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: "Added in this workspace" }), _jsxs("div", { className: "mt-2 space-y-2", children: [workspaceAgents.map((agent) => (_jsx("div", { className: "flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3", children: _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: agent.name }), agent.description ? (_jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: agent.description })) : null, _jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: _jsxs("a", { href: agent.url, target: "_blank", rel: "noreferrer", className: "inline-flex items-center gap-1 hover:text-foreground", children: [agent.url, _jsx(IconExternalLink, { className: "h-3 w-3" })] }) })] }) }, agent.id))), customAgents.map((agent) => (_jsxs("div", { className: "flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: agent.name }), agent.description ? (_jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: agent.description })) : null, _jsxs("div", { className: "mt-1 flex items-center gap-2 text-xs text-muted-foreground", children: [_jsxs("a", { href: agent.url, target: "_blank", rel: "noreferrer", className: "inline-flex items-center gap-1 hover:text-foreground", children: [agent.url, _jsx(IconExternalLink, { className: "h-3 w-3" })] }), _jsx("span", { children: "\u00B7" }), _jsx("span", { children: agent.scope || "shared" })] })] }), _jsxs(AlertDialog, { children: [_jsx(AlertDialogTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", children: _jsx(IconTrash, { className: "h-4 w-4" }) }) }), _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Remove this agent?" }), _jsxs(AlertDialogDescription, { children: ["\u201C", agent.name, "\u201D will be removed from the workspace. Any jobs or chats that delegate to it will stop working."] })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Cancel" }), _jsx(AlertDialogAction, { onClick: () => handleDelete(agent.resourceId), children: "Remove" })] })] })] })] }, agent.id))), workspaceAgents.length === 0 && customAgents.length === 0 && (_jsx("div", { className: "rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground", children: "No extra agents added yet." }))] })] })] }), _jsxs("div", { className: "rounded-xl border bg-muted/20 p-4", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: "Add external agent" }), _jsx("p", { className: "mt-1 text-xs leading-relaxed text-muted-foreground", children: "Add another A2A-compatible app by saving its agent endpoint here." }), _jsxs("form", { className: "mt-4 space-y-3", onSubmit: handleAdd, noValidate: true, children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Input, { ref: nameRef, value: name, onChange: (event) => {
|
|
121
|
+
setName(event.target.value);
|
|
122
|
+
setErrors((current) => ({ ...current, name: undefined }));
|
|
123
|
+
}, placeholder: "Name", "aria-invalid": Boolean(errors.name), "aria-describedby": errors.name ? "external-agent-name-error" : undefined }), errors.name ? (_jsx("p", { id: "external-agent-name-error", className: "text-xs font-medium text-destructive", children: errors.name })) : null] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Input, { value: url, onChange: (event) => {
|
|
124
|
+
setUrl(event.target.value);
|
|
125
|
+
setErrors((current) => ({ ...current, url: undefined }));
|
|
126
|
+
}, placeholder: "https://app.example.com", "aria-invalid": Boolean(errors.url), "aria-describedby": errors.url ? "external-agent-url-error" : undefined }), errors.url ? (_jsx("p", { id: "external-agent-url-error", className: "text-xs font-medium text-destructive", children: errors.url })) : null] }), _jsx(Input, { value: description, onChange: (event) => setDescription(event.target.value), placeholder: "Description (optional)" }), errors.form ? (_jsx("p", { className: "text-xs font-medium text-destructive", children: errors.form })) : null, _jsx(Button, { type: "submit", className: "w-full", disabled: saving, children: saving ? "Saving..." : "Add agent" })] })] })] }) }));
|
|
63
127
|
}
|
|
64
128
|
//# sourceMappingURL=agents-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents-panel.js","sourceRoot":"","sources":["../../src/components/agents-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,i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AAC,IAAI,CAC5D,cAAK,SAAS,EAAC,yEAAyE,2CAElF,CACP,IACG,IACF,IACF,EAEN,eAAK,SAAS,EAAC,mCAAmC,aAChD,cAAK,SAAS,EAAC,qCAAqC,mCAE9C,EACN,YAAG,SAAS,EAAC,oDAAoD,kFAE7D,EACJ,eAAK,SAAS,EAAC,gBAAgB,aAC7B,KAAC,KAAK,IACJ,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAChD,WAAW,EAAC,MAAM,GAClB,EACF,KAAC,KAAK,IACJ,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC/C,WAAW,EAAC,yBAAyB,GACrC,EACF,KAAC,KAAK,IACJ,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACvD,WAAW,EAAC,wBAAwB,GACpC,EACF,KAAC,MAAM,IACL,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,MAAM,YAE9C,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,GAC5B,IACL,IACF,IACF,GACE,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { useRef, useState } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n AlertDialogTrigger,\n} from \"@/components/ui/alert-dialog\";\nimport { IconExternalLink, IconTrash } from \"@tabler/icons-react\";\nimport { agentNativePath } from \"@agent-native/core/client\";\n\nexport interface ConnectedAgent {\n id: string;\n name: string;\n description: string;\n url: string;\n color: string;\n source: \"builtin\" | \"custom\" | \"workspace\";\n resourceId?: string;\n path?: string;\n scope?: \"shared\" | \"personal\";\n}\n\nexport function AgentsPanel({\n agents,\n onRefresh,\n}: {\n agents: ConnectedAgent[];\n onRefresh: () => void;\n}) {\n const [name, setName] = useState(\"\");\n const [url, setUrl] = useState(\"\");\n const [description, setDescription] = useState(\"\");\n const [saving, setSaving] = useState(false);\n const nameRef = useRef<HTMLInputElement>(null);\n\n const customAgents = agents.filter((agent) => agent.source === \"custom\");\n const workspaceAgents = agents.filter(\n (agent) => agent.source === \"workspace\",\n );\n const builtinAgents = agents.filter((agent) => agent.source === \"builtin\");\n\n const handleAdd = async () => {\n const trimmedName = name.trim();\n const trimmedUrl = url.trim();\n if (!trimmedName || !trimmedUrl) return;\n\n const id = trimmedName.toLowerCase().replace(/[^a-z0-9-]/g, \"-\");\n const agentJson = JSON.stringify(\n {\n id,\n name: trimmedName,\n description: description.trim() || undefined,\n url: trimmedUrl,\n color: \"#6B7280\",\n },\n null,\n 2,\n );\n\n setSaving(true);\n try {\n const res = await fetch(agentNativePath(\"/_agent-native/resources\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n path: `remote-agents/${id}.json`,\n content: agentJson,\n shared: true,\n }),\n });\n if (res.ok) {\n setName(\"\");\n setUrl(\"\");\n setDescription(\"\");\n onRefresh();\n nameRef.current?.focus();\n }\n } finally {\n setSaving(false);\n }\n };\n\n const handleDelete = async (resourceId?: string) => {\n if (!resourceId) return;\n const res = await fetch(\n agentNativePath(`/_agent-native/resources/${resourceId}`),\n {\n method: \"DELETE\",\n },\n );\n if (res.ok) onRefresh();\n };\n\n return (\n <section className=\"rounded-2xl border bg-card p-5\">\n <div className=\"grid gap-4 xl:grid-cols-[minmax(0,1fr)_320px]\">\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-sm font-medium text-foreground\">\n Available by default\n </div>\n <div className=\"mt-2 flex flex-wrap gap-2\">\n {builtinAgents.map((agent) => (\n <div\n key={agent.id}\n className=\"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs text-muted-foreground\"\n >\n <span\n className=\"h-2 w-2 rounded-full\"\n style={{ backgroundColor: agent.color }}\n />\n <span>{agent.name}</span>\n </div>\n ))}\n {builtinAgents.length === 0 && (\n <div className=\"rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground\">\n No default agents detected.\n </div>\n )}\n </div>\n </div>\n\n <div>\n <div className=\"text-sm font-medium text-foreground\">\n Added in this workspace\n </div>\n <div className=\"mt-2 space-y-2\">\n {workspaceAgents.map((agent) => (\n <div\n key={agent.id}\n className=\"flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3\"\n >\n <div className=\"min-w-0\">\n <div className=\"text-sm font-medium text-foreground\">\n {agent.name}\n </div>\n {agent.description ? (\n <div className=\"mt-1 text-xs text-muted-foreground\">\n {agent.description}\n </div>\n ) : null}\n <div className=\"mt-1 text-xs text-muted-foreground\">\n <a\n href={agent.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"inline-flex items-center gap-1 hover:text-foreground\"\n >\n {agent.url}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n </div>\n </div>\n </div>\n ))}\n {customAgents.map((agent) => (\n <div\n key={agent.id}\n className=\"flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3\"\n >\n <div className=\"min-w-0\">\n <div className=\"text-sm font-medium text-foreground\">\n {agent.name}\n </div>\n {agent.description ? (\n <div className=\"mt-1 text-xs text-muted-foreground\">\n {agent.description}\n </div>\n ) : null}\n <div className=\"mt-1 flex items-center gap-2 text-xs text-muted-foreground\">\n <a\n href={agent.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"inline-flex items-center gap-1 hover:text-foreground\"\n >\n {agent.url}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n <span>·</span>\n <span>{agent.scope || \"shared\"}</span>\n </div>\n </div>\n <AlertDialog>\n <AlertDialogTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\">\n <IconTrash className=\"h-4 w-4\" />\n </Button>\n </AlertDialogTrigger>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove this agent?</AlertDialogTitle>\n <AlertDialogDescription>\n “{agent.name}” will be removed from the workspace. Any\n jobs or chats that delegate to it will stop working.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => handleDelete(agent.resourceId)}\n >\n Remove\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n ))}\n {workspaceAgents.length === 0 && customAgents.length === 0 && (\n <div className=\"rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground\">\n No extra agents added yet.\n </div>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"rounded-xl border bg-muted/20 p-4\">\n <div className=\"text-sm font-medium text-foreground\">\n Add external agent\n </div>\n <p className=\"mt-1 text-xs leading-relaxed text-muted-foreground\">\n Add another A2A-compatible app by saving its agent endpoint here.\n </p>\n <div className=\"mt-4 space-y-3\">\n <Input\n ref={nameRef}\n value={name}\n onChange={(event) => setName(event.target.value)}\n placeholder=\"Name\"\n />\n <Input\n value={url}\n onChange={(event) => setUrl(event.target.value)}\n placeholder=\"https://app.example.com\"\n />\n <Input\n value={description}\n onChange={(event) => setDescription(event.target.value)}\n placeholder=\"Description (optional)\"\n />\n <Button\n className=\"w-full\"\n onClick={handleAdd}\n disabled={!name.trim() || !url.trim() || saving}\n >\n {saving ? \"Saving...\" : \"Add agent\"}\n </Button>\n </div>\n </div>\n </div>\n </section>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file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AC,IAAI,IACJ,EACN,KAAC,KAAK,IACJ,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACvD,WAAW,EAAC,wBAAwB,GACpC,EACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACb,YAAG,SAAS,EAAC,sCAAsC,YAChD,MAAM,CAAC,IAAI,GACV,CACL,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,QAAQ,EAAC,QAAQ,EAAE,MAAM,YACtD,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,GAC5B,IACJ,IACH,IACF,GACE,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { useRef, useState, type FormEvent } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n AlertDialogTrigger,\n} from \"@/components/ui/alert-dialog\";\nimport { IconExternalLink, IconTrash } from \"@tabler/icons-react\";\nimport { agentNativePath } from \"@agent-native/core/client\";\n\nexport interface ConnectedAgent {\n id: string;\n name: string;\n description: string;\n url: string;\n color: string;\n source: \"builtin\" | \"custom\" | \"workspace\";\n resourceId?: string;\n path?: string;\n scope?: \"shared\" | \"personal\";\n}\n\ntype AgentFormErrors = Partial<Record<\"name\" | \"url\" | \"form\", string>>;\n\nfunction slugifyAgentName(value: string): string {\n return value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nfunction validateAgentForm(name: string, url: string): AgentFormErrors {\n const errors: AgentFormErrors = {};\n const trimmedName = name.trim();\n const trimmedUrl = url.trim();\n\n if (!trimmedName) {\n errors.name = \"Agent name is required.\";\n } else if (!slugifyAgentName(trimmedName)) {\n errors.name = \"Agent name must include at least one letter or number.\";\n }\n\n if (!trimmedUrl) {\n errors.url = \"Agent endpoint URL is required.\";\n } else {\n try {\n const parsed = new URL(trimmedUrl);\n if (parsed.protocol !== \"https:\" && parsed.protocol !== \"http:\") {\n errors.url = \"Use an http:// or https:// endpoint URL.\";\n } else if (!parsed.hostname) {\n errors.url = \"Enter a complete endpoint URL with a host.\";\n } else if (parsed.username || parsed.password) {\n errors.url = \"Do not include credentials in the endpoint URL.\";\n }\n } catch {\n errors.url =\n \"Enter a valid endpoint URL, such as https://app.example.com.\";\n }\n }\n\n return errors;\n}\n\nexport function AgentsPanel({\n agents,\n onRefresh,\n}: {\n agents: ConnectedAgent[];\n onRefresh: () => void;\n}) {\n const [name, setName] = useState(\"\");\n const [url, setUrl] = useState(\"\");\n const [description, setDescription] = useState(\"\");\n const [saving, setSaving] = useState(false);\n const [errors, setErrors] = useState<AgentFormErrors>({});\n const nameRef = useRef<HTMLInputElement>(null);\n\n const customAgents = agents.filter((agent) => agent.source === \"custom\");\n const workspaceAgents = agents.filter(\n (agent) => agent.source === \"workspace\",\n );\n const builtinAgents = agents.filter((agent) => agent.source === \"builtin\");\n\n const handleAdd = async (event?: FormEvent<HTMLFormElement>) => {\n event?.preventDefault();\n const trimmedName = name.trim();\n const trimmedUrl = url.trim();\n const nextErrors = validateAgentForm(trimmedName, trimmedUrl);\n if (Object.keys(nextErrors).length > 0) {\n setErrors(nextErrors);\n return;\n }\n\n const id = slugifyAgentName(trimmedName);\n const agentJson = JSON.stringify(\n {\n id,\n name: trimmedName,\n description: description.trim() || undefined,\n url: trimmedUrl,\n color: \"#6B7280\",\n },\n null,\n 2,\n );\n\n setSaving(true);\n try {\n const res = await fetch(agentNativePath(\"/_agent-native/resources\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n path: `remote-agents/${id}.json`,\n content: agentJson,\n shared: true,\n }),\n });\n if (res.ok) {\n setName(\"\");\n setUrl(\"\");\n setDescription(\"\");\n setErrors({});\n onRefresh();\n nameRef.current?.focus();\n } else {\n setErrors({\n form: `Could not add agent. Request failed with ${res.status}.`,\n });\n }\n } catch (error) {\n setErrors({\n form:\n error instanceof Error\n ? error.message\n : \"Could not add agent. Please try again.\",\n });\n } finally {\n setSaving(false);\n }\n };\n\n const handleDelete = async (resourceId?: string) => {\n if (!resourceId) return;\n const res = await fetch(\n agentNativePath(`/_agent-native/resources/${resourceId}`),\n {\n method: \"DELETE\",\n },\n );\n if (res.ok) onRefresh();\n };\n\n return (\n <section className=\"rounded-2xl border bg-card p-5\">\n <div className=\"grid gap-4 xl:grid-cols-[minmax(0,1fr)_320px]\">\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-sm font-medium text-foreground\">\n Available by default\n </div>\n <div className=\"mt-2 flex flex-wrap gap-2\">\n {builtinAgents.map((agent) => (\n <div\n key={agent.id}\n className=\"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs text-muted-foreground\"\n >\n <span\n className=\"h-2 w-2 rounded-full\"\n style={{ backgroundColor: agent.color }}\n />\n <span>{agent.name}</span>\n </div>\n ))}\n {builtinAgents.length === 0 && (\n <div className=\"rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground\">\n No default agents detected.\n </div>\n )}\n </div>\n </div>\n\n <div>\n <div className=\"text-sm font-medium text-foreground\">\n Added in this workspace\n </div>\n <div className=\"mt-2 space-y-2\">\n {workspaceAgents.map((agent) => (\n <div\n key={agent.id}\n className=\"flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3\"\n >\n <div className=\"min-w-0\">\n <div className=\"text-sm font-medium text-foreground\">\n {agent.name}\n </div>\n {agent.description ? (\n <div className=\"mt-1 text-xs text-muted-foreground\">\n {agent.description}\n </div>\n ) : null}\n <div className=\"mt-1 text-xs text-muted-foreground\">\n <a\n href={agent.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"inline-flex items-center gap-1 hover:text-foreground\"\n >\n {agent.url}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n </div>\n </div>\n </div>\n ))}\n {customAgents.map((agent) => (\n <div\n key={agent.id}\n className=\"flex items-start justify-between gap-3 rounded-xl border bg-muted/30 px-4 py-3\"\n >\n <div className=\"min-w-0\">\n <div className=\"text-sm font-medium text-foreground\">\n {agent.name}\n </div>\n {agent.description ? (\n <div className=\"mt-1 text-xs text-muted-foreground\">\n {agent.description}\n </div>\n ) : null}\n <div className=\"mt-1 flex items-center gap-2 text-xs text-muted-foreground\">\n <a\n href={agent.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"inline-flex items-center gap-1 hover:text-foreground\"\n >\n {agent.url}\n <IconExternalLink className=\"h-3 w-3\" />\n </a>\n <span>·</span>\n <span>{agent.scope || \"shared\"}</span>\n </div>\n </div>\n <AlertDialog>\n <AlertDialogTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\">\n <IconTrash className=\"h-4 w-4\" />\n </Button>\n </AlertDialogTrigger>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove this agent?</AlertDialogTitle>\n <AlertDialogDescription>\n “{agent.name}” will be removed from the workspace. Any\n jobs or chats that delegate to it will stop working.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => handleDelete(agent.resourceId)}\n >\n Remove\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n ))}\n {workspaceAgents.length === 0 && customAgents.length === 0 && (\n <div className=\"rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground\">\n No extra agents added yet.\n </div>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"rounded-xl border bg-muted/20 p-4\">\n <div className=\"text-sm font-medium text-foreground\">\n Add external agent\n </div>\n <p className=\"mt-1 text-xs leading-relaxed text-muted-foreground\">\n Add another A2A-compatible app by saving its agent endpoint here.\n </p>\n <form className=\"mt-4 space-y-3\" onSubmit={handleAdd} noValidate>\n <div className=\"space-y-1.5\">\n <Input\n ref={nameRef}\n value={name}\n onChange={(event) => {\n setName(event.target.value);\n setErrors((current) => ({ ...current, name: undefined }));\n }}\n placeholder=\"Name\"\n aria-invalid={Boolean(errors.name)}\n aria-describedby={\n errors.name ? \"external-agent-name-error\" : undefined\n }\n />\n {errors.name ? (\n <p\n id=\"external-agent-name-error\"\n className=\"text-xs font-medium text-destructive\"\n >\n {errors.name}\n </p>\n ) : null}\n </div>\n <div className=\"space-y-1.5\">\n <Input\n value={url}\n onChange={(event) => {\n setUrl(event.target.value);\n setErrors((current) => ({ ...current, url: undefined }));\n }}\n placeholder=\"https://app.example.com\"\n aria-invalid={Boolean(errors.url)}\n aria-describedby={\n errors.url ? \"external-agent-url-error\" : undefined\n }\n />\n {errors.url ? (\n <p\n id=\"external-agent-url-error\"\n className=\"text-xs font-medium text-destructive\"\n >\n {errors.url}\n </p>\n ) : null}\n </div>\n <Input\n value={description}\n onChange={(event) => setDescription(event.target.value)}\n placeholder=\"Description (optional)\"\n />\n {errors.form ? (\n <p className=\"text-xs font-medium text-destructive\">\n {errors.form}\n </p>\n ) : null}\n <Button type=\"submit\" className=\"w-full\" disabled={saving}>\n {saving ? \"Saving...\" : \"Add agent\"}\n </Button>\n </form>\n </div>\n </div>\n </section>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app-popover.d.ts","sourceRoot":"","sources":["../../src/components/create-app-popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAkCrE,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CACpC;
|
|
1
|
+
{"version":3,"file":"create-app-popover.d.ts","sourceRoot":"","sources":["../../src/components/create-app-popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAkCrE,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CACpC;AA4ED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,SAAc,GACf,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAsQA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,KAAgB,GACjB,EAAE,qBAAqB,2CA0BvB"}
|
|
@@ -27,6 +27,7 @@ function buildAppCreationPrompt(input) {
|
|
|
27
27
|
: `Requested Dispatch vault key grants for this app: none`;
|
|
28
28
|
return [
|
|
29
29
|
`Create a new agent-native app in this workspace.`,
|
|
30
|
+
`This is a new workspace app request, not a feature request for the current app.`,
|
|
30
31
|
``,
|
|
31
32
|
`Suggested app name: ${input.appId} (you may adjust the slug if it conflicts)`,
|
|
32
33
|
`User prompt: ${input.prompt.trim()}`,
|
|
@@ -34,6 +35,7 @@ function buildAppCreationPrompt(input) {
|
|
|
34
35
|
``,
|
|
35
36
|
`Pick a starter template that fits the user's prompt — analytics, calendar, content, design, dispatch, forms, mail, slides, videos, clips, or starter when none of the others fit.`,
|
|
36
37
|
`Use the workspace app layout: create it under apps/${input.appId}, mount it at /${input.appId}, keep it on the shared workspace database/hosting model, and avoid table-name collisions by namespacing any new domain tables to the app.`,
|
|
38
|
+
`Do not satisfy this by adding a route, page, component, or file inside apps/starter or another existing app unless the user explicitly asks to modify that existing app.`,
|
|
37
39
|
keyList
|
|
38
40
|
? `After the app exists, grant the selected Dispatch vault keys to appId "${input.appId}" and sync them once the app server is available. Treat these as requested grants, not active grants before creation succeeds.`
|
|
39
41
|
: `Do not grant any Dispatch vault keys unless the user asks later.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app-popover.js","sourceRoot":"","sources":["../../src/components/create-app-popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACrE,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,UAAU,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,OAAO,EACP,WAAW,EACX,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAsBhD,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,KAAK;SACT,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,MAAM,OAAO,GAAG,MAAM;SACnB,OAAO,CAAC,sDAAsD,EAAE,GAAG,CAAC;SACpE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;IACV,OAAO,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,IAAI,SAAS,CAAC;AACpD,CAAC;AAED,SAAS,sBAAsB,CAAC,KAI/B;IACC,MAAM,OAAO,GAAG,KA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DAA4D,YAEtE,KAAC,aAAa,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,GACjC,IACT,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useMemo, useState, type ReactNode } from \"react\";\nimport {\n PromptComposer,\n agentNativePath,\n appBasePath,\n isInBuilderFrame,\n sendToAgentChat,\n useDevMode,\n} from \"@agent-native/core/client\";\nimport { getWorkspaceAppIdValidationError } from \"@agent-native/core/shared\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconCheck,\n IconChevronDown,\n IconKey,\n IconLoader2,\n IconPlus,\n} from \"@tabler/icons-react\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/components/ui/popover\";\nimport { Button } from \"@/components/ui/button\";\n\ninterface VaultSecretOption {\n id: string;\n name: string;\n credentialKey: string;\n provider?: string | null;\n description?: string | null;\n}\n\ninterface CreateAppPopoverProps {\n /**\n * Custom trigger element. Defaults to a dashed-border tile that matches the\n * apps grid empty state.\n */\n trigger?: ReactNode;\n /**\n * Override the popover alignment. Defaults to \"center\" with a 10px offset.\n */\n align?: \"start\" | \"center\" | \"end\";\n}\n\nfunction slugify(value: string): string {\n return value\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .replace(/^[^a-z]+/, \"\")\n .slice(0, 48);\n}\n\nfunction titleFromPrompt(prompt: string): string {\n const cleaned = prompt\n .replace(/\\b(build|create|make|an?|the|app|tool|dashboard)\\b/gi, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n return slugify(cleaned || \"new-app\") || \"new-app\";\n}\n\nfunction buildAppCreationPrompt(input: {\n appId: string;\n prompt: string;\n selectedKeys: string[];\n}): string {\n const keyList = input.selectedKeys.join(\", \");\n const grantRequest = keyList\n ? `Requested Dispatch vault key grants for this app: ${keyList}`\n : `Requested Dispatch vault key grants for this app: none`;\n\n return [\n `Create a new agent-native app in this workspace.`,\n ``,\n `Suggested app name: ${input.appId} (you may adjust the slug if it conflicts)`,\n `User prompt: ${input.prompt.trim()}`,\n grantRequest,\n ``,\n `Pick a starter template that fits the user's prompt — analytics, calendar, content, design, dispatch, forms, mail, slides, videos, clips, or starter when none of the others fit.`,\n `Use the workspace app layout: create it under apps/${input.appId}, mount it at /${input.appId}, keep it on the shared workspace database/hosting model, and avoid table-name collisions by namespacing any new domain tables to the app.`,\n keyList\n ? `After the app exists, grant the selected Dispatch vault keys to appId \"${input.appId}\" and sync them once the app server is available. Treat these as requested grants, not active grants before creation succeeds.`\n : `Do not grant any Dispatch vault keys unless the user asks later.`,\n ``,\n `App readiness requirements before handing off:`,\n `- Update the workspace app registry metadata for \"${input.appId}\" so Dispatch lists the app at /${input.appId} after merge/deploy.`,\n `- Update the app manifest/package/deploy metadata needed by the existing workspace deployment model.`,\n `- Verify the app's agent card/A2A metadata is ready so Dispatch can discover and delegate to the app after deployment.`,\n `When it is ready, start or update the workspace dev server and navigate the user to /${input.appId}.`,\n ].join(\"\\n\");\n}\n\nasync function fetchJson(url: string, init?: RequestInit): Promise<any> {\n const res = await fetch(url, init);\n const data = await res.json().catch(() => null);\n if (!res.ok) {\n throw new Error(\n data?.error || data?.message || `Request failed ${res.status}`,\n );\n }\n return data;\n}\n\nfunction defaultDispatchBasePath(): string | null {\n const base = appBasePath();\n if (base === \"/dispatch\") return null;\n return null;\n}\n\nfunction actionUrl(basePath: string | null, action: string): string {\n const path = `/_agent-native/actions/${action}`;\n if (basePath === null) return agentNativePath(path);\n const normalized = basePath.replace(/\\/+$/, \"\");\n return `${normalized}${path}`;\n}\n\n/**\n * Inline two-step app-creation flow: prompt → optional key picker → submit.\n * Used both in the popover form and in the dedicated `/new-app` page so the\n * same UX shows up everywhere a teammate kicks off a new workspace app.\n */\nexport function CreateAppFlow({\n onClose,\n className = \"\",\n}: {\n onClose?: () => void;\n className?: string;\n}) {\n const [step, setStep] = useState<\"prompt\" | \"keys\">(\"prompt\");\n const [prompt, setPrompt] = useState(\"\");\n const [selectedSecretIds, setSelectedSecretIds] = useState<string[]>([]);\n const [secrets, setSecrets] = useState<VaultSecretOption[]>([]);\n const [secretsError, setSecretsError] = useState<string | null>(null);\n const [statusMessage, setStatusMessage] = useState<string | null>(null);\n const [branchUrl, setBranchUrl] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n const { isDevMode } = useDevMode();\n\n const basePath = useMemo(() => defaultDispatchBasePath(), []);\n\n // Fetch the vault keys eagerly so step 2 has them ready the moment the user\n // taps \"Choose keys\" — no spinner, no pause between steps.\n useEffect(() => {\n let cancelled = false;\n fetchJson(actionUrl(basePath, \"list-vault-secret-options\"))\n .then((data) => {\n if (cancelled) return;\n setSecrets(Array.isArray(data) ? data : []);\n setSecretsError(null);\n })\n .catch((err) => {\n if (cancelled) return;\n setSecrets([]);\n setSecretsError(err?.message || \"Could not load Dispatch keys\");\n });\n return () => {\n cancelled = true;\n };\n }, [basePath]);\n\n const selectedSecrets = useMemo(\n () => secrets.filter((s) => selectedSecretIds.includes(s.id)),\n [secrets, selectedSecretIds],\n );\n const selectedSecretLabel =\n selectedSecretIds.length === 0\n ? \"no keys\"\n : `${selectedSecretIds.length} key${selectedSecretIds.length === 1 ? \"\" : \"s\"}`;\n\n function toggleSecret(id: string) {\n setSelectedSecretIds((cur) =>\n cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id],\n );\n }\n\n async function submit(rawPrompt: string, selectedKeys: string[]) {\n const trimmed = rawPrompt.trim();\n if (!trimmed || isSubmitting) return;\n const appId = titleFromPrompt(trimmed);\n const validationError = getWorkspaceAppIdValidationError(appId);\n if (validationError) {\n setStatusMessage(validationError);\n return;\n }\n\n const message = buildAppCreationPrompt({\n appId,\n prompt: trimmed,\n selectedKeys,\n });\n setIsSubmitting(true);\n setStatusMessage(null);\n setBranchUrl(null);\n\n try {\n if (isInBuilderFrame()) {\n sendToAgentChat({ message, submit: true, type: \"code\" });\n setStatusMessage(\"Sent to Builder chat.\");\n onClose?.();\n } else if (isDevMode) {\n sendToAgentChat({ message, submit: true, type: \"code\", newTab: true });\n setStatusMessage(\"Sent to the local agent.\");\n onClose?.();\n } else {\n const result = await fetchJson(\n actionUrl(basePath, \"start-workspace-app-creation\"),\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n prompt: trimmed,\n appId,\n secretIds: selectedKeys.length > 0 ? selectedSecretIds : [],\n }),\n },\n );\n if (result?.mode === \"builder\") {\n setBranchUrl(result?.url || null);\n setStatusMessage(\"Builder branch created.\");\n } else {\n setStatusMessage(\n result?.message ||\n \"Builder app creation is coming soon. Open this workspace in Builder to create an app from this prompt.\",\n );\n }\n }\n } catch (err: any) {\n setStatusMessage(err?.message || \"Could not start the new app flow.\");\n } finally {\n setIsSubmitting(false);\n }\n }\n\n const submitWithSelectedKeys = () =>\n submit(\n prompt,\n selectedSecrets.map((s) => s.credentialKey),\n );\n\n return (\n <div className={`flex flex-col gap-3 ${className}`}>\n {step === \"prompt\" ? (\n <>\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <p className=\"text-sm font-semibold text-foreground\">Create app</p>\n <button\n type=\"button\"\n onClick={() => setStep(\"keys\")}\n className=\"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background/40 px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent/50\"\n >\n <IconKey size={11} />\n {selectedSecretLabel}\n </button>\n </div>\n <PromptComposer\n autoFocus\n disabled={isSubmitting}\n placeholder=\"Describe the app your teammate should be able to use...\"\n draftScope=\"dispatch:create-app\"\n onSubmit={(text) => {\n setPrompt(text);\n submit(\n text,\n selectedSecrets.map((s) => s.credentialKey),\n );\n }}\n />\n </>\n ) : (\n <>\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <button\n type=\"button\"\n onClick={() => setStep(\"prompt\")}\n className=\"inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground hover:text-foreground\"\n >\n <IconArrowLeft size={12} />\n Back\n </button>\n <span className=\"text-[11px] text-muted-foreground/70\">\n {selectedSecretLabel} selected\n </span>\n </div>\n <div className=\"max-h-[340px] space-y-2 overflow-y-auto rounded-md border border-border bg-card p-2\">\n {secretsError ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n {secretsError}\n </p>\n ) : secrets.length === 0 ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n No Dispatch vault keys found yet.\n </p>\n ) : (\n secrets.map((secret) => {\n const selected = selectedSecretIds.includes(secret.id);\n return (\n <div\n key={secret.id}\n className={`group rounded-md border text-sm ${\n selected\n ? \"border-primary/45 bg-primary/5\"\n : \"border-border hover:border-muted-foreground/40 hover:bg-accent/35\"\n }`}\n >\n <button\n type=\"button\"\n aria-pressed={selected}\n onClick={() => toggleSecret(secret.id)}\n className=\"flex w-full cursor-pointer items-start gap-3 rounded-md px-3 py-2 text-left\"\n >\n <span\n className={`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border ${\n selected\n ? \"border-primary/60 bg-primary/10 text-primary\"\n : \"border-muted-foreground/35 text-transparent\"\n }`}\n >\n {selected ? <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 {selected\n ? \"Will be requested for this app\"\n : \"Click to request\"}\n </span>\n </span>\n </button>\n {(secret.provider || secret.name) && (\n <details className=\"group/details border-t border-border/60 px-3 py-1.5 text-xs text-muted-foreground/75\">\n <summary className=\"flex cursor-pointer list-none items-center gap-1.5 text-[11px] hover:text-muted-foreground [&::-webkit-details-marker]:hidden\">\n <IconChevronDown className=\"h-3 w-3 transition-transform group-open/details:rotate-180\" />\n Details\n </summary>\n <div className=\"mt-1.5 space-y-1 pb-0.5 pl-4\">\n <div className=\"truncate\">\n Provider: {secret.provider || \"Not specified\"}\n </div>\n <div className=\"truncate\">Name: {secret.name}</div>\n </div>\n </details>\n )}\n </div>\n );\n })\n )}\n </div>\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={submitWithSelectedKeys}\n disabled={!prompt.trim() || isSubmitting}\n >\n {isSubmitting ? (\n <IconLoader2 className=\"h-3.5 w-3.5 animate-spin\" />\n ) : (\n <IconPlus className=\"h-3.5 w-3.5\" />\n )}\n Create app\n </Button>\n </div>\n {!prompt.trim() ? (\n <p className=\"px-1 text-[11px] text-muted-foreground/70\">\n Add a prompt on the previous step before creating the app.\n </p>\n ) : null}\n </>\n )}\n\n {statusMessage ? (\n <div className=\"rounded-md border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground\">\n {statusMessage}\n {branchUrl ? (\n <a\n href={branchUrl}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"ml-2 inline-flex items-center gap-1 font-medium text-foreground underline\"\n >\n Open branch <IconArrowUpRight className=\"h-3 w-3\" />\n </a>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport function CreateAppPopover({\n trigger,\n align = \"center\",\n}: CreateAppPopoverProps) {\n const [open, setOpen] = useState(false);\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n {trigger ?? (\n <button\n type=\"button\"\n className=\"flex min-h-32 cursor-pointer items-center justify-center rounded-lg border border-dashed bg-card p-4 text-sm font-medium text-muted-foreground transition hover:border-foreground/30 hover:text-foreground\"\n >\n <span className=\"inline-flex items-center gap-2\">\n <IconPlus size={16} />\n Create app\n </span>\n </button>\n )}\n </PopoverTrigger>\n <PopoverContent\n align={align}\n sideOffset={10}\n className=\"w-[calc(100vw-2rem)] rounded-xl p-3 shadow-xl sm:w-[460px]\"\n >\n <CreateAppFlow onClose={() => setOpen(false)} />\n </PopoverContent>\n </Popover>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-app-popover.js","sourceRoot":"","sources":["../../src/components/create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ect, useMemo, useState, type ReactNode } from \"react\";\nimport {\n PromptComposer,\n agentNativePath,\n appBasePath,\n isInBuilderFrame,\n sendToAgentChat,\n useDevMode,\n} from \"@agent-native/core/client\";\nimport { getWorkspaceAppIdValidationError } from \"@agent-native/core/shared\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconCheck,\n IconChevronDown,\n IconKey,\n IconLoader2,\n IconPlus,\n} from \"@tabler/icons-react\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/components/ui/popover\";\nimport { Button } from \"@/components/ui/button\";\n\ninterface VaultSecretOption {\n id: string;\n name: string;\n credentialKey: string;\n provider?: string | null;\n description?: string | null;\n}\n\ninterface CreateAppPopoverProps {\n /**\n * Custom trigger element. Defaults to a dashed-border tile that matches the\n * apps grid empty state.\n */\n trigger?: ReactNode;\n /**\n * Override the popover alignment. Defaults to \"center\" with a 10px offset.\n */\n align?: \"start\" | \"center\" | \"end\";\n}\n\nfunction slugify(value: string): string {\n return value\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .replace(/^[^a-z]+/, \"\")\n .slice(0, 48);\n}\n\nfunction titleFromPrompt(prompt: string): string {\n const cleaned = prompt\n .replace(/\\b(build|create|make|an?|the|app|tool|dashboard)\\b/gi, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n return slugify(cleaned || \"new-app\") || \"new-app\";\n}\n\nfunction buildAppCreationPrompt(input: {\n appId: string;\n prompt: string;\n selectedKeys: string[];\n}): string {\n const keyList = input.selectedKeys.join(\", \");\n const grantRequest = keyList\n ? `Requested Dispatch vault key grants for this app: ${keyList}`\n : `Requested Dispatch vault key grants for this app: none`;\n\n return [\n `Create a new agent-native app in this workspace.`,\n `This is a new workspace app request, not a feature request for the current app.`,\n ``,\n `Suggested app name: ${input.appId} (you may adjust the slug if it conflicts)`,\n `User prompt: ${input.prompt.trim()}`,\n grantRequest,\n ``,\n `Pick a starter template that fits the user's prompt — analytics, calendar, content, design, dispatch, forms, mail, slides, videos, clips, or starter when none of the others fit.`,\n `Use the workspace app layout: create it under apps/${input.appId}, mount it at /${input.appId}, keep it on the shared workspace database/hosting model, and avoid table-name collisions by namespacing any new domain tables to the app.`,\n `Do not satisfy this by adding a route, page, component, or file inside apps/starter or another existing app unless the user explicitly asks to modify that existing app.`,\n keyList\n ? `After the app exists, grant the selected Dispatch vault keys to appId \"${input.appId}\" and sync them once the app server is available. Treat these as requested grants, not active grants before creation succeeds.`\n : `Do not grant any Dispatch vault keys unless the user asks later.`,\n ``,\n `App readiness requirements before handing off:`,\n `- Update the workspace app registry metadata for \"${input.appId}\" so Dispatch lists the app at /${input.appId} after merge/deploy.`,\n `- Update the app manifest/package/deploy metadata needed by the existing workspace deployment model.`,\n `- Verify the app's agent card/A2A metadata is ready so Dispatch can discover and delegate to the app after deployment.`,\n `When it is ready, start or update the workspace dev server and navigate the user to /${input.appId}.`,\n ].join(\"\\n\");\n}\n\nasync function fetchJson(url: string, init?: RequestInit): Promise<any> {\n const res = await fetch(url, init);\n const data = await res.json().catch(() => null);\n if (!res.ok) {\n throw new Error(\n data?.error || data?.message || `Request failed ${res.status}`,\n );\n }\n return data;\n}\n\nfunction defaultDispatchBasePath(): string | null {\n const base = appBasePath();\n if (base === \"/dispatch\") return null;\n return null;\n}\n\nfunction actionUrl(basePath: string | null, action: string): string {\n const path = `/_agent-native/actions/${action}`;\n if (basePath === null) return agentNativePath(path);\n const normalized = basePath.replace(/\\/+$/, \"\");\n return `${normalized}${path}`;\n}\n\n/**\n * Inline two-step app-creation flow: prompt → optional key picker → submit.\n * Used both in the popover form and in the dedicated `/new-app` page so the\n * same UX shows up everywhere a teammate kicks off a new workspace app.\n */\nexport function CreateAppFlow({\n onClose,\n className = \"\",\n}: {\n onClose?: () => void;\n className?: string;\n}) {\n const [step, setStep] = useState<\"prompt\" | \"keys\">(\"prompt\");\n const [prompt, setPrompt] = useState(\"\");\n const [selectedSecretIds, setSelectedSecretIds] = useState<string[]>([]);\n const [secrets, setSecrets] = useState<VaultSecretOption[]>([]);\n const [secretsError, setSecretsError] = useState<string | null>(null);\n const [statusMessage, setStatusMessage] = useState<string | null>(null);\n const [branchUrl, setBranchUrl] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n const { isDevMode } = useDevMode();\n\n const basePath = useMemo(() => defaultDispatchBasePath(), []);\n\n // Fetch the vault keys eagerly so step 2 has them ready the moment the user\n // taps \"Choose keys\" — no spinner, no pause between steps.\n useEffect(() => {\n let cancelled = false;\n fetchJson(actionUrl(basePath, \"list-vault-secret-options\"))\n .then((data) => {\n if (cancelled) return;\n setSecrets(Array.isArray(data) ? data : []);\n setSecretsError(null);\n })\n .catch((err) => {\n if (cancelled) return;\n setSecrets([]);\n setSecretsError(err?.message || \"Could not load Dispatch keys\");\n });\n return () => {\n cancelled = true;\n };\n }, [basePath]);\n\n const selectedSecrets = useMemo(\n () => secrets.filter((s) => selectedSecretIds.includes(s.id)),\n [secrets, selectedSecretIds],\n );\n const selectedSecretLabel =\n selectedSecretIds.length === 0\n ? \"no keys\"\n : `${selectedSecretIds.length} key${selectedSecretIds.length === 1 ? \"\" : \"s\"}`;\n\n function toggleSecret(id: string) {\n setSelectedSecretIds((cur) =>\n cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id],\n );\n }\n\n async function submit(rawPrompt: string, selectedKeys: string[]) {\n const trimmed = rawPrompt.trim();\n if (!trimmed || isSubmitting) return;\n const appId = titleFromPrompt(trimmed);\n const validationError = getWorkspaceAppIdValidationError(appId);\n if (validationError) {\n setStatusMessage(validationError);\n return;\n }\n\n const message = buildAppCreationPrompt({\n appId,\n prompt: trimmed,\n selectedKeys,\n });\n setIsSubmitting(true);\n setStatusMessage(null);\n setBranchUrl(null);\n\n try {\n if (isInBuilderFrame()) {\n sendToAgentChat({ message, submit: true, type: \"code\" });\n setStatusMessage(\"Sent to Builder chat.\");\n onClose?.();\n } else if (isDevMode) {\n sendToAgentChat({ message, submit: true, type: \"code\", newTab: true });\n setStatusMessage(\"Sent to the local agent.\");\n onClose?.();\n } else {\n const result = await fetchJson(\n actionUrl(basePath, \"start-workspace-app-creation\"),\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n prompt: trimmed,\n appId,\n secretIds: selectedKeys.length > 0 ? selectedSecretIds : [],\n }),\n },\n );\n if (result?.mode === \"builder\") {\n setBranchUrl(result?.url || null);\n setStatusMessage(\"Builder branch created.\");\n } else {\n setStatusMessage(\n result?.message ||\n \"Builder app creation is coming soon. Open this workspace in Builder to create an app from this prompt.\",\n );\n }\n }\n } catch (err: any) {\n setStatusMessage(err?.message || \"Could not start the new app flow.\");\n } finally {\n setIsSubmitting(false);\n }\n }\n\n const submitWithSelectedKeys = () =>\n submit(\n prompt,\n selectedSecrets.map((s) => s.credentialKey),\n );\n\n return (\n <div className={`flex flex-col gap-3 ${className}`}>\n {step === \"prompt\" ? (\n <>\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <p className=\"text-sm font-semibold text-foreground\">Create app</p>\n <button\n type=\"button\"\n onClick={() => setStep(\"keys\")}\n className=\"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background/40 px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent/50\"\n >\n <IconKey size={11} />\n {selectedSecretLabel}\n </button>\n </div>\n <PromptComposer\n autoFocus\n disabled={isSubmitting}\n placeholder=\"Describe the app your teammate should be able to use...\"\n draftScope=\"dispatch:create-app\"\n onSubmit={(text) => {\n setPrompt(text);\n submit(\n text,\n selectedSecrets.map((s) => s.credentialKey),\n );\n }}\n />\n </>\n ) : (\n <>\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <button\n type=\"button\"\n onClick={() => setStep(\"prompt\")}\n className=\"inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground hover:text-foreground\"\n >\n <IconArrowLeft size={12} />\n Back\n </button>\n <span className=\"text-[11px] text-muted-foreground/70\">\n {selectedSecretLabel} selected\n </span>\n </div>\n <div className=\"max-h-[340px] space-y-2 overflow-y-auto rounded-md border border-border bg-card p-2\">\n {secretsError ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n {secretsError}\n </p>\n ) : secrets.length === 0 ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n No Dispatch vault keys found yet.\n </p>\n ) : (\n secrets.map((secret) => {\n const selected = selectedSecretIds.includes(secret.id);\n return (\n <div\n key={secret.id}\n className={`group rounded-md border text-sm ${\n selected\n ? \"border-primary/45 bg-primary/5\"\n : \"border-border hover:border-muted-foreground/40 hover:bg-accent/35\"\n }`}\n >\n <button\n type=\"button\"\n aria-pressed={selected}\n onClick={() => toggleSecret(secret.id)}\n className=\"flex w-full cursor-pointer items-start gap-3 rounded-md px-3 py-2 text-left\"\n >\n <span\n className={`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border ${\n selected\n ? \"border-primary/60 bg-primary/10 text-primary\"\n : \"border-muted-foreground/35 text-transparent\"\n }`}\n >\n {selected ? <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 {selected\n ? \"Will be requested for this app\"\n : \"Click to request\"}\n </span>\n </span>\n </button>\n {(secret.provider || secret.name) && (\n <details className=\"group/details border-t border-border/60 px-3 py-1.5 text-xs text-muted-foreground/75\">\n <summary className=\"flex cursor-pointer list-none items-center gap-1.5 text-[11px] hover:text-muted-foreground [&::-webkit-details-marker]:hidden\">\n <IconChevronDown className=\"h-3 w-3 transition-transform group-open/details:rotate-180\" />\n Details\n </summary>\n <div className=\"mt-1.5 space-y-1 pb-0.5 pl-4\">\n <div className=\"truncate\">\n Provider: {secret.provider || \"Not specified\"}\n </div>\n <div className=\"truncate\">Name: {secret.name}</div>\n </div>\n </details>\n )}\n </div>\n );\n })\n )}\n </div>\n <div className=\"flex items-center justify-end gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={submitWithSelectedKeys}\n disabled={!prompt.trim() || isSubmitting}\n >\n {isSubmitting ? (\n <IconLoader2 className=\"h-3.5 w-3.5 animate-spin\" />\n ) : (\n <IconPlus className=\"h-3.5 w-3.5\" />\n )}\n Create app\n </Button>\n </div>\n {!prompt.trim() ? (\n <p className=\"px-1 text-[11px] text-muted-foreground/70\">\n Add a prompt on the previous step before creating the app.\n </p>\n ) : null}\n </>\n )}\n\n {statusMessage ? (\n <div className=\"rounded-md border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground\">\n {statusMessage}\n {branchUrl ? (\n <a\n href={branchUrl}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"ml-2 inline-flex items-center gap-1 font-medium text-foreground underline\"\n >\n Open branch <IconArrowUpRight className=\"h-3 w-3\" />\n </a>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport function CreateAppPopover({\n trigger,\n align = \"center\",\n}: CreateAppPopoverProps) {\n const [open, setOpen] = useState(false);\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n {trigger ?? (\n <button\n type=\"button\"\n className=\"flex min-h-32 cursor-pointer items-center justify-center rounded-lg border border-dashed bg-card p-4 text-sm font-medium text-muted-foreground transition hover:border-foreground/30 hover:text-foreground\"\n >\n <span className=\"inline-flex items-center gap-2\">\n <IconPlus size={16} />\n Create app\n </span>\n </button>\n )}\n </PopoverTrigger>\n <PopoverContent\n align={align}\n sideOffset={10}\n className=\"w-[calc(100vw-2rem)] rounded-xl p-3 shadow-xl sm:w-[460px]\"\n >\n <CreateAppFlow onClose={() => setOpen(false)} />\n </PopoverContent>\n </Popover>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overview-chat.d.ts","sourceRoot":"","sources":["../../src/lib/overview-chat.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAC5B,MAAM,GAAG,IAAI,CAkBf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isInBuilderFrame, sendToAgentChat } from "@agent-native/core/client";
|
|
2
|
+
export function submitOverviewPrompt(message, selectedModel) {
|
|
3
|
+
const trimmed = message.trim();
|
|
4
|
+
if (!trimmed)
|
|
5
|
+
return null;
|
|
6
|
+
if (isInBuilderFrame()) {
|
|
7
|
+
return sendToAgentChat({
|
|
8
|
+
message: trimmed,
|
|
9
|
+
submit: true,
|
|
10
|
+
type: "code",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return sendToAgentChat({
|
|
14
|
+
message: trimmed,
|
|
15
|
+
submit: true,
|
|
16
|
+
newTab: true,
|
|
17
|
+
model: selectedModel || undefined,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=overview-chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overview-chat.js","sourceRoot":"","sources":["../../src/lib/overview-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE9E,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,aAA6B;IAE7B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,IAAI,gBAAgB,EAAE,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC;YACrB,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC;QACrB,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,aAAa,IAAI,SAAS;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isInBuilderFrame, sendToAgentChat } from \"@agent-native/core/client\";\n\nexport function submitOverviewPrompt(\n message: string,\n selectedModel?: string | null,\n): string | null {\n const trimmed = message.trim();\n if (!trimmed) return null;\n\n if (isInBuilderFrame()) {\n return sendToAgentChat({\n message: trimmed,\n submit: true,\n type: \"code\",\n });\n }\n\n return sendToAgentChat({\n message: trimmed,\n submit: true,\n newTab: true,\n model: selectedModel || undefined,\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/overview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/overview.tsx"],"names":[],"mappings":"AA0dA,wBAAgB,IAAI;;IAEnB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,4CA0SpC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { Link } from "react-router";
|
|
4
|
-
import { PromptComposer,
|
|
4
|
+
import { PromptComposer, useActionQuery, useChatModels, agentNativePath, } from "@agent-native/core/client";
|
|
5
5
|
import { IconActivity, IconAlertTriangle, IconApps, IconArrowUpRight, IconCheck, IconClockHour4, IconInfoCircle, IconKey, IconListCheck, IconRocket, IconPlugConnected, IconShieldCheck, } from "@tabler/icons-react";
|
|
6
6
|
import { AppKeysPopover } from "../../components/app-keys-popover.js";
|
|
7
7
|
import { CreateAppPopover } from "../../components/create-app-popover.js";
|
|
@@ -11,6 +11,7 @@ import { Badge } from "../../components/ui/badge.js";
|
|
|
11
11
|
import { Button } from "../../components/ui/button.js";
|
|
12
12
|
import { Skeleton } from "../../components/ui/skeleton.js";
|
|
13
13
|
import { Tooltip, TooltipContent, TooltipTrigger, } from "../../components/ui/tooltip.js";
|
|
14
|
+
import { submitOverviewPrompt } from "../../lib/overview-chat.js";
|
|
14
15
|
const ZERO_TASK_QUEUE_STATS = {
|
|
15
16
|
pending: 0,
|
|
16
17
|
processing: 0,
|
|
@@ -35,14 +36,9 @@ const HOME_CHAT_SUGGESTIONS = [
|
|
|
35
36
|
function HomeChatPanel() {
|
|
36
37
|
const { selectedModel } = useChatModels();
|
|
37
38
|
const send = (message) => {
|
|
38
|
-
|
|
39
|
-
message,
|
|
40
|
-
submit: true,
|
|
41
|
-
newTab: true,
|
|
42
|
-
model: selectedModel || undefined,
|
|
43
|
-
});
|
|
39
|
+
submitOverviewPrompt(message, selectedModel);
|
|
44
40
|
};
|
|
45
|
-
return (_jsx("section", { className: "px-2 py-6 sm:py-10", children: _jsxs("div", { className: "mx-auto w-full max-w-2xl space-y-
|
|
41
|
+
return (_jsx("section", { className: "px-2 py-6 sm:py-10", children: _jsxs("div", { className: "mx-auto w-full max-w-2xl space-y-8", children: [_jsx("h1", { className: "text-center text-2xl font-semibold tracking-tight text-foreground sm:text-3xl", children: "What should we do next?" }), _jsx(PromptComposer, { placeholder: "Message agent\u2026", onSubmit: (text) => {
|
|
46
42
|
const trimmed = text.trim();
|
|
47
43
|
if (!trimmed)
|
|
48
44
|
return;
|