@tangle-network/agent-app 0.60.92 → 0.60.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant/index.js +13 -11
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-react/index.js +3 -2
- package/dist/chat-routes/index.js +3 -3
- package/dist/chat-store/index.js +2 -2
- package/dist/{chunk-ORFRFCXQ.js → chunk-5CEUXI5V.js} +42 -606
- package/dist/chunk-5CEUXI5V.js.map +1 -0
- package/dist/chunk-6OQYTH7T.js +2202 -0
- package/dist/chunk-6OQYTH7T.js.map +1 -0
- package/dist/chunk-EBNIZHRX.js +579 -0
- package/dist/chunk-EBNIZHRX.js.map +1 -0
- package/dist/{chunk-JWZ32ZGD.js → chunk-FZSIYAKQ.js} +2 -2
- package/dist/{chunk-736V4L2S.js → chunk-K7JI5WY4.js} +968 -3161
- package/dist/chunk-K7JI5WY4.js.map +1 -0
- package/dist/{chunk-IMTU5LCF.js → chunk-NRG2YHGY.js} +1 -1
- package/dist/{chunk-2YLSWZ5W.js → chunk-WKD4E52F.js} +4 -4
- package/dist/{chunk-2FLSODOX.js → chunk-Y4WLCFDZ.js} +6 -6
- package/dist/design-canvas-react/index.js +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/public-consultation/index.js +3 -3
- package/dist/studio-react/index.js +2 -2
- package/dist/web-react/agent-profile-editor.js +17 -0
- package/dist/web-react/agent-profile-editor.js.map +1 -0
- package/dist/web-react/index.js +41 -37
- package/dist/workspace-react/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-736V4L2S.js.map +0 -1
- package/dist/chunk-ORFRFCXQ.js.map +0 -1
- /package/dist/{chunk-JWZ32ZGD.js.map → chunk-FZSIYAKQ.js.map} +0 -0
- /package/dist/{chunk-IMTU5LCF.js.map → chunk-NRG2YHGY.js.map} +0 -0
- /package/dist/{chunk-2YLSWZ5W.js.map → chunk-WKD4E52F.js.map} +0 -0
- /package/dist/{chunk-2FLSODOX.js.map → chunk-Y4WLCFDZ.js.map} +0 -0
|
@@ -0,0 +1,2202 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HarnessPicker,
|
|
3
|
+
filterAcceptedFiles
|
|
4
|
+
} from "./chunk-EBNIZHRX.js";
|
|
5
|
+
import {
|
|
6
|
+
EffortPicker,
|
|
7
|
+
ModelPicker,
|
|
8
|
+
OVERLAY_SHADOW,
|
|
9
|
+
POPOVER_OPTION_FOCUS,
|
|
10
|
+
PopoverSurface,
|
|
11
|
+
effortLevelsFromIds
|
|
12
|
+
} from "./chunk-HG4OONJA.js";
|
|
13
|
+
import {
|
|
14
|
+
isModelCompatibleWithHarness,
|
|
15
|
+
snapModelToHarness
|
|
16
|
+
} from "./chunk-MCYJON3F.js";
|
|
17
|
+
import {
|
|
18
|
+
isCommitSha,
|
|
19
|
+
parseGitHubLocation,
|
|
20
|
+
publicHttpsUrlProblem,
|
|
21
|
+
readSkillFrontmatter
|
|
22
|
+
} from "./chunk-B7CL7ENS.js";
|
|
23
|
+
|
|
24
|
+
// src/web-react/agent-profile-editor.tsx
|
|
25
|
+
import { useEffect as useEffect4, useId as useId5, useMemo as useMemo3, useState as useState7 } from "react";
|
|
26
|
+
import { REASONING_EFFORTS } from "@tangle-network/agent-interface/profile";
|
|
27
|
+
import { reasoningEffortsFor } from "@tangle-network/agent-interface/harness-capabilities";
|
|
28
|
+
import { agentProfileSchema } from "@tangle-network/agent-interface/profile-schema";
|
|
29
|
+
import { Button as Button5, Input as Input5, Textarea, Switch as Switch2, Select as Select2, SelectContent as SelectContent2, SelectItem as SelectItem2, SelectTrigger as SelectTrigger2, SelectValue as SelectValue2 } from "@tangle-network/sandbox-ui/primitives";
|
|
30
|
+
import { TooltipProvider } from "@tangle-network/ui/primitives";
|
|
31
|
+
|
|
32
|
+
// src/web-react/agent-profile-registry-search.tsx
|
|
33
|
+
import { useRef, useState } from "react";
|
|
34
|
+
import { Button, Input } from "@tangle-network/sandbox-ui/primitives";
|
|
35
|
+
|
|
36
|
+
// src/web-react/agent-profile-registry.ts
|
|
37
|
+
var AgentProfileRegistryError = class extends Error {
|
|
38
|
+
constructor(kind, message) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.kind = kind;
|
|
41
|
+
this.name = "AgentProfileRegistryError";
|
|
42
|
+
}
|
|
43
|
+
kind;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/web-react/agent-profile-registry-search.tsx
|
|
47
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
48
|
+
var idle = { status: "idle", results: [], unavailable: [], failure: null };
|
|
49
|
+
function failureOf(cause) {
|
|
50
|
+
if (cause instanceof AgentProfileRegistryError) return { kind: cause.kind, message: cause.message };
|
|
51
|
+
return { kind: "failed", message: cause instanceof Error ? cause.message : "Registry search failed." };
|
|
52
|
+
}
|
|
53
|
+
function failureText(failure) {
|
|
54
|
+
if (failure.kind === "authorization-required") {
|
|
55
|
+
return "Registry search needs authorization. Sign in again or ask a workspace owner.";
|
|
56
|
+
}
|
|
57
|
+
if (failure.kind === "unavailable") return failure.message || "Registry search is unavailable right now.";
|
|
58
|
+
return failure.message || "Registry search failed.";
|
|
59
|
+
}
|
|
60
|
+
function useRegistrySearch(search) {
|
|
61
|
+
const [state, setState] = useState(idle);
|
|
62
|
+
const request = useRef(0);
|
|
63
|
+
async function run(query) {
|
|
64
|
+
const text = query.trim();
|
|
65
|
+
if (!text) return;
|
|
66
|
+
const epoch = ++request.current;
|
|
67
|
+
const controller = new AbortController();
|
|
68
|
+
setState((current) => ({ ...current, status: "searching", failure: null }));
|
|
69
|
+
try {
|
|
70
|
+
const result = await search(text, controller.signal);
|
|
71
|
+
if (request.current !== epoch) return;
|
|
72
|
+
setState({ status: "done", results: result.items, unavailable: result.unavailable ?? [], failure: null });
|
|
73
|
+
} catch (cause) {
|
|
74
|
+
if (request.current !== epoch) return;
|
|
75
|
+
setState({ status: "done", results: [], unavailable: [], failure: failureOf(cause) });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { state, run };
|
|
79
|
+
}
|
|
80
|
+
function SearchBox({ label, placeholder, disabled, onSearch }) {
|
|
81
|
+
const [query, setQuery] = useState("");
|
|
82
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
Input,
|
|
85
|
+
{
|
|
86
|
+
"aria-label": label,
|
|
87
|
+
disabled,
|
|
88
|
+
value: query,
|
|
89
|
+
placeholder,
|
|
90
|
+
onChange: (event) => setQuery(event.target.value),
|
|
91
|
+
onKeyDown: (event) => {
|
|
92
|
+
if (event.key === "Enter") {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
onSearch(query);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", disabled: disabled || !query.trim(), onClick: () => onSearch(query), children: "Search" })
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
102
|
+
function SearchStatus({ state, empty }) {
|
|
103
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
|
+
state.status === "searching" && /* @__PURE__ */ jsx("p", { role: "status", className: "text-xs text-muted-foreground", children: "Searching\u2026" }),
|
|
105
|
+
state.failure && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-xs text-destructive", children: failureText(state.failure) }),
|
|
106
|
+
!state.failure && state.unavailable.length > 0 && /* @__PURE__ */ jsxs("p", { role: "status", className: "text-xs text-muted-foreground", children: [
|
|
107
|
+
"Some catalogs could not answer: ",
|
|
108
|
+
state.unavailable.join(", "),
|
|
109
|
+
"."
|
|
110
|
+
] }),
|
|
111
|
+
state.status === "done" && !state.failure && state.results.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: empty })
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
function AgentProfileRegistrySkillSearch({ registry, disabled, existing, validate, onAdd }) {
|
|
115
|
+
const { state, run } = useRegistrySearch(async (query, signal) => {
|
|
116
|
+
const result = await registry.searchSkills(query, signal);
|
|
117
|
+
return { items: result.skills, unavailable: result.unavailable };
|
|
118
|
+
});
|
|
119
|
+
const [added, setAdded] = useState([]);
|
|
120
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-lg border border-border p-3", children: [
|
|
121
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: "Find skills in maintained catalogs" }),
|
|
122
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Search shows each skill's source and declared permissions. Adding a skill saves a reference; nothing is installed until the profile runs." }),
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
SearchBox,
|
|
125
|
+
{
|
|
126
|
+
label: "Search skill catalogs",
|
|
127
|
+
placeholder: "Search skills",
|
|
128
|
+
disabled: disabled || state.status === "searching",
|
|
129
|
+
onSearch: (query) => void run(query)
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ jsx(SearchStatus, { state, empty: "No skills matched that search." }),
|
|
133
|
+
state.results.length > 0 && /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: state.results.map((skill, index) => {
|
|
134
|
+
const configured = existing.some((ref) => ref.name === skill.name) || added.includes(skill.name);
|
|
135
|
+
const issue = configured ? null : validate(skill.ref);
|
|
136
|
+
return /* @__PURE__ */ jsxs(
|
|
137
|
+
"li",
|
|
138
|
+
{
|
|
139
|
+
className: "space-y-1 rounded-lg border border-border p-3 text-sm",
|
|
140
|
+
"aria-label": `Catalog skill ${skill.name}`,
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
|
|
143
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
144
|
+
/* @__PURE__ */ jsx("span", { className: "block break-words font-medium text-foreground", children: skill.name }),
|
|
145
|
+
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: skill.catalog })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
Button,
|
|
149
|
+
{
|
|
150
|
+
type: "button",
|
|
151
|
+
variant: "outline",
|
|
152
|
+
size: "sm",
|
|
153
|
+
disabled: disabled || configured || Boolean(issue),
|
|
154
|
+
"aria-label": `Add skill ${skill.name}`,
|
|
155
|
+
onClick: () => {
|
|
156
|
+
if (onAdd(skill.ref)) setAdded((current) => [...current, skill.name]);
|
|
157
|
+
},
|
|
158
|
+
children: configured ? "Added" : "Add skill"
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
] }),
|
|
162
|
+
skill.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: skill.description }),
|
|
163
|
+
skill.ref.kind === "github" && /* @__PURE__ */ jsxs("p", { className: "break-words text-xs text-muted-foreground", children: [
|
|
164
|
+
"Source: ",
|
|
165
|
+
skill.ref.repository,
|
|
166
|
+
" / ",
|
|
167
|
+
skill.ref.path,
|
|
168
|
+
skill.ref.ref ? ` @ ${skill.ref.ref}` : ""
|
|
169
|
+
] }),
|
|
170
|
+
skill.permissions && skill.permissions.length > 0 && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
171
|
+
"Requests: ",
|
|
172
|
+
skill.permissions.join(", ")
|
|
173
|
+
] }),
|
|
174
|
+
issue && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: issue })
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
`${skill.catalog}:${skill.name}:${index}`
|
|
178
|
+
);
|
|
179
|
+
}) })
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
function AgentProfileRegistryMcpSearch({ registry, disabled, existingNames, validate, onAdd }) {
|
|
183
|
+
const { state, run } = useRegistrySearch(async (query, signal) => {
|
|
184
|
+
const result = await registry.searchMcpServers(query, signal);
|
|
185
|
+
return { items: result.mcpServers, unavailable: result.unavailable };
|
|
186
|
+
});
|
|
187
|
+
const [added, setAdded] = useState([]);
|
|
188
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-lg border border-border p-3", children: [
|
|
189
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: "Find MCP servers in registries" }),
|
|
190
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Results come from the official MCP Registry and configured custom registries. Listing does not imply trust or authorize installation." }),
|
|
191
|
+
/* @__PURE__ */ jsx(
|
|
192
|
+
SearchBox,
|
|
193
|
+
{
|
|
194
|
+
label: "Search MCP registries",
|
|
195
|
+
placeholder: "Search MCP servers",
|
|
196
|
+
disabled: disabled || state.status === "searching",
|
|
197
|
+
onSearch: (query) => void run(query)
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsx(SearchStatus, { state, empty: "No MCP servers matched that search." }),
|
|
201
|
+
state.results.length > 0 && /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: state.results.map((item, index) => {
|
|
202
|
+
const configured = existingNames.includes(item.name) || added.includes(item.name);
|
|
203
|
+
const issue = configured ? null : validate(item.name, item.server);
|
|
204
|
+
return /* @__PURE__ */ jsxs(
|
|
205
|
+
"li",
|
|
206
|
+
{
|
|
207
|
+
className: "space-y-1 rounded-lg border border-border p-3 text-sm",
|
|
208
|
+
"aria-label": `Registry server ${item.name}`,
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
|
|
211
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
212
|
+
/* @__PURE__ */ jsx("span", { className: "block break-words font-medium text-foreground", children: item.name }),
|
|
213
|
+
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: item.catalog })
|
|
214
|
+
] }),
|
|
215
|
+
/* @__PURE__ */ jsx(
|
|
216
|
+
Button,
|
|
217
|
+
{
|
|
218
|
+
type: "button",
|
|
219
|
+
variant: "outline",
|
|
220
|
+
size: "sm",
|
|
221
|
+
disabled: disabled || configured || Boolean(issue),
|
|
222
|
+
"aria-label": `Add server ${item.name}`,
|
|
223
|
+
onClick: () => {
|
|
224
|
+
if (onAdd(item.name, item.server)) setAdded((current) => [...current, item.name]);
|
|
225
|
+
},
|
|
226
|
+
children: configured ? "Added" : "Add server"
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
] }),
|
|
230
|
+
item.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: item.description }),
|
|
231
|
+
/* @__PURE__ */ jsx("p", { className: "break-words text-xs text-muted-foreground", children: "command" in item.server ? `Command: ${item.server.command}` : `URL: ${item.server.url}` }),
|
|
232
|
+
issue && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: issue })
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
`${item.catalog}:${item.name}:${index}`
|
|
236
|
+
);
|
|
237
|
+
}) })
|
|
238
|
+
] });
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/web-react/agent-profile-form-kit.tsx
|
|
242
|
+
import { useId, useState as useState2 } from "react";
|
|
243
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@tangle-network/ui/primitives";
|
|
244
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
245
|
+
var formText = {
|
|
246
|
+
body: "text-sm leading-6 text-foreground",
|
|
247
|
+
muted: "text-sm leading-6 text-muted-foreground",
|
|
248
|
+
error: "text-sm leading-6 text-destructive",
|
|
249
|
+
label: "text-sm font-medium leading-6 text-foreground",
|
|
250
|
+
/** Section titles are the one step up: 16px semibold. */
|
|
251
|
+
title: "text-base font-semibold leading-6 text-foreground"
|
|
252
|
+
};
|
|
253
|
+
var formRow = "grid gap-4 @xl/profile-editor:grid-cols-2";
|
|
254
|
+
var listRow = "flex flex-col gap-1 @lg/profile-editor:flex-row @lg/profile-editor:items-start @lg/profile-editor:justify-between @lg/profile-editor:gap-3";
|
|
255
|
+
var rowActions = "flex shrink-0 flex-wrap gap-1 -ml-3 @lg/profile-editor:ml-0";
|
|
256
|
+
function InfoGlyph({ className }) {
|
|
257
|
+
return /* @__PURE__ */ jsxs2("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", className, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
258
|
+
/* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "9" }),
|
|
259
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 16v-4M12 8h.01" })
|
|
260
|
+
] });
|
|
261
|
+
}
|
|
262
|
+
function InfoHint({ label, children }) {
|
|
263
|
+
const [open, setOpen] = useState2(false);
|
|
264
|
+
return /* @__PURE__ */ jsxs2(Tooltip, { open, onOpenChange: setOpen, delayDuration: 150, children: [
|
|
265
|
+
/* @__PURE__ */ jsx2(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx2(
|
|
266
|
+
"button",
|
|
267
|
+
{
|
|
268
|
+
type: "button",
|
|
269
|
+
"aria-label": `About ${label}`,
|
|
270
|
+
onClick: () => setOpen((current) => !current),
|
|
271
|
+
className: "inline-flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
272
|
+
children: /* @__PURE__ */ jsx2(InfoGlyph, { className: "size-4" })
|
|
273
|
+
}
|
|
274
|
+
) }),
|
|
275
|
+
/* @__PURE__ */ jsx2(TooltipContent, { side: "top", className: "max-w-72 text-sm leading-5", children })
|
|
276
|
+
] });
|
|
277
|
+
}
|
|
278
|
+
function fieldMessageId(htmlFor) {
|
|
279
|
+
return `${htmlFor}-message`;
|
|
280
|
+
}
|
|
281
|
+
function Field({ label, htmlFor, info, hint, error, status, aside, children }) {
|
|
282
|
+
const message = error ?? status ?? hint;
|
|
283
|
+
return /* @__PURE__ */ jsxs2("div", { className: "min-w-0 space-y-2", children: [
|
|
284
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex min-h-6 items-center justify-between gap-2", children: [
|
|
285
|
+
/* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
286
|
+
/* @__PURE__ */ jsx2("label", { htmlFor, className: formText.label, children: label }),
|
|
287
|
+
info && /* @__PURE__ */ jsx2(InfoHint, { label, children: info })
|
|
288
|
+
] }),
|
|
289
|
+
aside
|
|
290
|
+
] }),
|
|
291
|
+
children,
|
|
292
|
+
message && /* @__PURE__ */ jsx2(
|
|
293
|
+
"div",
|
|
294
|
+
{
|
|
295
|
+
id: fieldMessageId(htmlFor),
|
|
296
|
+
role: error ? "alert" : void 0,
|
|
297
|
+
className: error ? formText.error : formText.muted,
|
|
298
|
+
children: message
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
] });
|
|
302
|
+
}
|
|
303
|
+
function Chevron({ className }) {
|
|
304
|
+
return /* @__PURE__ */ jsx2("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", className, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx2("path", { d: "m6 9 6 6 6-6" }) });
|
|
305
|
+
}
|
|
306
|
+
function Section({ title, description, summary, defaultOpen = false, collapsible = false, children }) {
|
|
307
|
+
const headingId = useId();
|
|
308
|
+
const header = /* @__PURE__ */ jsxs2("span", { className: "flex min-w-0 flex-1 items-start justify-between gap-3", children: [
|
|
309
|
+
/* @__PURE__ */ jsxs2("span", { className: "min-w-0 space-y-0.5", children: [
|
|
310
|
+
/* @__PURE__ */ jsx2("span", { id: headingId, className: `block ${formText.title}`, children: title }),
|
|
311
|
+
description && /* @__PURE__ */ jsx2("span", { className: `block ${formText.muted}`, children: description })
|
|
312
|
+
] }),
|
|
313
|
+
(summary || collapsible) && /* @__PURE__ */ jsxs2("span", { className: `flex shrink-0 items-center gap-2 ${formText.muted}`, children: [
|
|
314
|
+
summary,
|
|
315
|
+
collapsible && /* @__PURE__ */ jsx2(Chevron, { className: "size-4 transition-transform group-open:rotate-180" })
|
|
316
|
+
] })
|
|
317
|
+
] });
|
|
318
|
+
if (!collapsible) {
|
|
319
|
+
return /* @__PURE__ */ jsxs2("section", { "aria-labelledby": headingId, className: "min-w-0 rounded-xl border border-border bg-card", children: [
|
|
320
|
+
/* @__PURE__ */ jsx2("header", { className: "flex px-4 pt-4", children: header }),
|
|
321
|
+
/* @__PURE__ */ jsx2("div", { className: "min-w-0 space-y-4 p-4", children })
|
|
322
|
+
] });
|
|
323
|
+
}
|
|
324
|
+
return /* @__PURE__ */ jsxs2("details", { open: defaultOpen || void 0, className: "group min-w-0 rounded-xl border border-border bg-card", children: [
|
|
325
|
+
/* @__PURE__ */ jsx2("summary", { "aria-labelledby": headingId, className: "flex cursor-pointer list-none rounded-xl p-4 marker:hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring [&::-webkit-details-marker]:hidden", children: header }),
|
|
326
|
+
/* @__PURE__ */ jsx2("div", { className: "min-w-0 space-y-4 border-t border-border p-4", children })
|
|
327
|
+
] });
|
|
328
|
+
}
|
|
329
|
+
var toneClass = {
|
|
330
|
+
neutral: "text-muted-foreground",
|
|
331
|
+
pending: "text-muted-foreground",
|
|
332
|
+
success: "text-[var(--surface-success-text,hsl(var(--success)))]",
|
|
333
|
+
warning: "text-warning-strong",
|
|
334
|
+
error: "text-destructive"
|
|
335
|
+
};
|
|
336
|
+
function StatusGlyph({ tone }) {
|
|
337
|
+
if (tone === "pending") {
|
|
338
|
+
return /* @__PURE__ */ jsx2("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", className: "size-4 shrink-0 animate-spin motion-reduce:animate-none", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", children: /* @__PURE__ */ jsx2("path", { d: "M21 12a9 9 0 1 1-6.2-8.6" }) });
|
|
339
|
+
}
|
|
340
|
+
if (tone === "success") {
|
|
341
|
+
return /* @__PURE__ */ jsxs2("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", className: "size-4 shrink-0", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
342
|
+
/* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "9" }),
|
|
343
|
+
/* @__PURE__ */ jsx2("path", { d: "m8 12 3 3 5-6" })
|
|
344
|
+
] });
|
|
345
|
+
}
|
|
346
|
+
if (tone === "error" || tone === "warning") {
|
|
347
|
+
return /* @__PURE__ */ jsxs2("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", className: "size-4 shrink-0", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
348
|
+
/* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "9" }),
|
|
349
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 8v4M12 16h.01" })
|
|
350
|
+
] });
|
|
351
|
+
}
|
|
352
|
+
return /* @__PURE__ */ jsx2("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", className: "size-4 shrink-0", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "3" }) });
|
|
353
|
+
}
|
|
354
|
+
function StatusLine({ tone, children, id }) {
|
|
355
|
+
return /* @__PURE__ */ jsxs2("p", { id, role: tone === "error" ? "alert" : "status", className: `flex items-start gap-2 text-sm leading-6 ${toneClass[tone]}`, children: [
|
|
356
|
+
/* @__PURE__ */ jsx2("span", { className: "flex h-6 items-center", children: /* @__PURE__ */ jsx2(StatusGlyph, { tone }) }),
|
|
357
|
+
/* @__PURE__ */ jsx2("span", { className: "min-w-0 break-words [overflow-wrap:anywhere]", children })
|
|
358
|
+
] });
|
|
359
|
+
}
|
|
360
|
+
function StatusPill({ tone, children }) {
|
|
361
|
+
return /* @__PURE__ */ jsxs2("span", { className: `inline-flex shrink-0 items-center gap-1.5 text-sm leading-6 ${toneClass[tone]}`, children: [
|
|
362
|
+
tone === "pending" ? /* @__PURE__ */ jsx2(StatusGlyph, { tone: "pending" }) : /* @__PURE__ */ jsx2("span", { "aria-hidden": "true", className: "size-2 rounded-full bg-current" }),
|
|
363
|
+
children
|
|
364
|
+
] });
|
|
365
|
+
}
|
|
366
|
+
function Notice({ tone, children }) {
|
|
367
|
+
return /* @__PURE__ */ jsx2("div", { role: tone === "error" ? "alert" : "status", className: `rounded-lg border p-3 text-sm leading-6 ${tone === "error" ? "border-destructive/40 bg-destructive/5 text-foreground" : "border-border bg-muted/50 text-foreground"}`, children });
|
|
368
|
+
}
|
|
369
|
+
var noAutofill = {
|
|
370
|
+
autoComplete: "off",
|
|
371
|
+
"data-1p-ignore": "true",
|
|
372
|
+
"data-lpignore": "true",
|
|
373
|
+
"data-bwignore": "true",
|
|
374
|
+
"data-form-type": "other",
|
|
375
|
+
spellCheck: false
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/web-react/agent-profile-github-source.tsx
|
|
379
|
+
import { useEffect as useEffect2, useId as useId3, useMemo, useRef as useRef3, useState as useState4 } from "react";
|
|
380
|
+
import { Button as Button2, Input as Input3 } from "@tangle-network/sandbox-ui/primitives";
|
|
381
|
+
import { SegmentedControl } from "@tangle-network/ui/primitives";
|
|
382
|
+
|
|
383
|
+
// src/web-react/agent-profile-suggest-input.tsx
|
|
384
|
+
import { useEffect, useId as useId2, useRef as useRef2, useState as useState3 } from "react";
|
|
385
|
+
import { Input as Input2 } from "@tangle-network/sandbox-ui/primitives";
|
|
386
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
387
|
+
function SuggestInput({
|
|
388
|
+
id,
|
|
389
|
+
value,
|
|
390
|
+
onChange,
|
|
391
|
+
onCommit,
|
|
392
|
+
suggestions,
|
|
393
|
+
loading = false,
|
|
394
|
+
emptyText,
|
|
395
|
+
placeholder,
|
|
396
|
+
disabled = false,
|
|
397
|
+
invalid = false,
|
|
398
|
+
describedBy,
|
|
399
|
+
"aria-label": ariaLabel
|
|
400
|
+
}) {
|
|
401
|
+
const [open, setOpen] = useState3(false);
|
|
402
|
+
const [active, setActive] = useState3(-1);
|
|
403
|
+
const inputRef = useRef2(null);
|
|
404
|
+
const panelRef = useRef2(null);
|
|
405
|
+
const committed = useRef2(value);
|
|
406
|
+
const listId = useId2();
|
|
407
|
+
const optionId = (index) => `${listId}-option-${index}`;
|
|
408
|
+
const showList = open && !disabled && (loading || suggestions.length > 0 || Boolean(emptyText && value.trim()));
|
|
409
|
+
useEffect(() => {
|
|
410
|
+
setActive(-1);
|
|
411
|
+
}, [suggestions]);
|
|
412
|
+
useEffect(() => {
|
|
413
|
+
if (disabled) setOpen(false);
|
|
414
|
+
}, [disabled]);
|
|
415
|
+
function commit(next) {
|
|
416
|
+
setOpen(false);
|
|
417
|
+
setActive(-1);
|
|
418
|
+
if (next !== committed.current) {
|
|
419
|
+
committed.current = next;
|
|
420
|
+
onCommit(next);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function choose(index) {
|
|
424
|
+
const suggestion = suggestions[index];
|
|
425
|
+
if (!suggestion) return;
|
|
426
|
+
onChange(suggestion.value);
|
|
427
|
+
committed.current = "";
|
|
428
|
+
commit(suggestion.value);
|
|
429
|
+
}
|
|
430
|
+
return /* @__PURE__ */ jsxs3("div", { className: "relative min-w-0", children: [
|
|
431
|
+
/* @__PURE__ */ jsx3(
|
|
432
|
+
Input2,
|
|
433
|
+
{
|
|
434
|
+
ref: inputRef,
|
|
435
|
+
id,
|
|
436
|
+
size: "compact",
|
|
437
|
+
value,
|
|
438
|
+
disabled,
|
|
439
|
+
placeholder,
|
|
440
|
+
role: "combobox",
|
|
441
|
+
"aria-autocomplete": "list",
|
|
442
|
+
"aria-expanded": showList,
|
|
443
|
+
"aria-controls": showList ? listId : void 0,
|
|
444
|
+
"aria-activedescendant": showList && active >= 0 ? optionId(active) : void 0,
|
|
445
|
+
"aria-invalid": invalid || void 0,
|
|
446
|
+
"aria-describedby": describedBy,
|
|
447
|
+
"aria-label": ariaLabel,
|
|
448
|
+
...noAutofill,
|
|
449
|
+
onFocus: () => setOpen(true),
|
|
450
|
+
onChange: (event) => {
|
|
451
|
+
onChange(event.target.value);
|
|
452
|
+
setOpen(true);
|
|
453
|
+
},
|
|
454
|
+
onBlur: (event) => {
|
|
455
|
+
if (panelRef.current?.contains(event.relatedTarget)) return;
|
|
456
|
+
commit(value.trim());
|
|
457
|
+
},
|
|
458
|
+
onKeyDown: (event) => {
|
|
459
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
460
|
+
event.preventDefault();
|
|
461
|
+
setOpen(true);
|
|
462
|
+
if (!suggestions.length) return;
|
|
463
|
+
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
464
|
+
setActive((current) => (current + step + suggestions.length) % suggestions.length);
|
|
465
|
+
} else if (event.key === "Enter") {
|
|
466
|
+
event.preventDefault();
|
|
467
|
+
if (showList && active >= 0) choose(active);
|
|
468
|
+
else commit(value.trim());
|
|
469
|
+
} else if (event.key === "Escape" && showList) {
|
|
470
|
+
event.preventDefault();
|
|
471
|
+
event.stopPropagation();
|
|
472
|
+
setOpen(false);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
),
|
|
477
|
+
/* @__PURE__ */ jsxs3(
|
|
478
|
+
PopoverSurface,
|
|
479
|
+
{
|
|
480
|
+
open: showList,
|
|
481
|
+
id: listId,
|
|
482
|
+
role: "listbox",
|
|
483
|
+
"aria-label": ariaLabel ?? "Suggestions",
|
|
484
|
+
triggerRef: inputRef,
|
|
485
|
+
panelRef,
|
|
486
|
+
matchTriggerWidth: true,
|
|
487
|
+
side: "below",
|
|
488
|
+
contentKey: suggestions,
|
|
489
|
+
className: `max-h-72 overflow-y-auto rounded-xl border border-card-edge bg-popover p-1 text-foreground ${OVERLAY_SHADOW}`,
|
|
490
|
+
children: [
|
|
491
|
+
loading && /* @__PURE__ */ jsx3("div", { role: "status", className: "px-3 py-2 text-sm text-muted-foreground", children: "Loading\u2026" }),
|
|
492
|
+
!loading && suggestions.length === 0 && emptyText && /* @__PURE__ */ jsx3("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: emptyText }),
|
|
493
|
+
suggestions.map((suggestion, index) => /* @__PURE__ */ jsxs3(
|
|
494
|
+
"div",
|
|
495
|
+
{
|
|
496
|
+
id: optionId(index),
|
|
497
|
+
role: "option",
|
|
498
|
+
"aria-selected": index === active,
|
|
499
|
+
tabIndex: -1,
|
|
500
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
501
|
+
onMouseEnter: () => setActive(index),
|
|
502
|
+
onClick: () => choose(index),
|
|
503
|
+
className: `flex min-h-9 cursor-pointer flex-col justify-center rounded-md px-3 py-1.5 text-sm ${POPOVER_OPTION_FOCUS} ${index === active ? "bg-accent" : ""}`,
|
|
504
|
+
children: [
|
|
505
|
+
/* @__PURE__ */ jsx3("span", { className: "min-w-0 break-words [overflow-wrap:anywhere]", children: suggestion.label }),
|
|
506
|
+
suggestion.detail && /* @__PURE__ */ jsx3("span", { className: "min-w-0 break-words text-sm text-muted-foreground [overflow-wrap:anywhere]", children: suggestion.detail })
|
|
507
|
+
]
|
|
508
|
+
},
|
|
509
|
+
suggestion.value
|
|
510
|
+
))
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
] });
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// src/web-react/agent-profile-github-source.tsx
|
|
518
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
519
|
+
function useLookup(key, run, delayMs = 0) {
|
|
520
|
+
const [load, setLoad] = useState4({ state: "idle" });
|
|
521
|
+
const runRef = useRef3(run);
|
|
522
|
+
runRef.current = run;
|
|
523
|
+
useEffect2(() => {
|
|
524
|
+
if (key === null) {
|
|
525
|
+
setLoad({ state: "idle" });
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
const controller = new AbortController();
|
|
529
|
+
setLoad({ state: "loading" });
|
|
530
|
+
const timer = setTimeout(() => {
|
|
531
|
+
runRef.current(controller.signal).then((outcome) => {
|
|
532
|
+
if (controller.signal.aborted) return;
|
|
533
|
+
setLoad(outcome.ok ? { state: "done", value: outcome.value } : { state: "failed", failure: outcome });
|
|
534
|
+
}, (cause) => {
|
|
535
|
+
if (controller.signal.aborted) return;
|
|
536
|
+
setLoad({ state: "failed", failure: { ok: false, problem: "unavailable", message: cause instanceof Error ? cause.message : "The lookup failed." } });
|
|
537
|
+
});
|
|
538
|
+
}, delayMs);
|
|
539
|
+
return () => {
|
|
540
|
+
clearTimeout(timer);
|
|
541
|
+
controller.abort();
|
|
542
|
+
};
|
|
543
|
+
}, [key, delayMs]);
|
|
544
|
+
return load;
|
|
545
|
+
}
|
|
546
|
+
function shortSha(sha) {
|
|
547
|
+
return sha.slice(0, 7);
|
|
548
|
+
}
|
|
549
|
+
function relativeDate(iso) {
|
|
550
|
+
if (!iso) return null;
|
|
551
|
+
const time = Date.parse(iso);
|
|
552
|
+
if (Number.isNaN(time)) return null;
|
|
553
|
+
const days = Math.floor((Date.now() - time) / 864e5);
|
|
554
|
+
if (days <= 0) return "today";
|
|
555
|
+
if (days === 1) return "yesterday";
|
|
556
|
+
if (days < 30) return `${days} days ago`;
|
|
557
|
+
return new Date(time).toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
|
|
558
|
+
}
|
|
559
|
+
function describeCommit(commit) {
|
|
560
|
+
const when = relativeDate(commit.committedAt);
|
|
561
|
+
return [shortSha(commit.sha), commit.message, when].filter(Boolean).join(" \xB7 ");
|
|
562
|
+
}
|
|
563
|
+
function rankPaths(files, query, purpose) {
|
|
564
|
+
const needle = query.trim().toLowerCase();
|
|
565
|
+
const candidates = purpose === "skill" ? files.filter((file) => /(^|\/)SKILL\.md$/i.test(file.path)) : files;
|
|
566
|
+
const pool = candidates.length || purpose !== "skill" ? candidates : files;
|
|
567
|
+
return pool.filter((file) => !needle || file.path.toLowerCase().includes(needle)).sort((left, right) => {
|
|
568
|
+
const leftStarts = needle && left.path.toLowerCase().startsWith(needle) ? 0 : 1;
|
|
569
|
+
const rightStarts = needle && right.path.toLowerCase().startsWith(needle) ? 0 : 1;
|
|
570
|
+
return leftStarts - rightStarts || left.path.split("/").length - right.path.split("/").length || left.path.localeCompare(right.path);
|
|
571
|
+
}).slice(0, 50).map((file) => ({ value: file.path, label: file.path }));
|
|
572
|
+
}
|
|
573
|
+
function GitHubSourcePicker({ port, purpose, disabled = false, connectHref, onChoose, actionLabel, children, blocked = null, initial, onCancel }) {
|
|
574
|
+
const uid = useId3();
|
|
575
|
+
const fieldId = (name) => `github-${name}${uid}`;
|
|
576
|
+
const [repositoryText, setRepositoryText] = useState4(initial?.repository ?? "");
|
|
577
|
+
const [repository, setRepository] = useState4(initial?.repository ?? "");
|
|
578
|
+
const [version, setVersion] = useState4(initial?.ref && isCommitSha(initial.ref) ? "pinned" : "latest");
|
|
579
|
+
const [shaText, setShaText] = useState4(initial?.ref && isCommitSha(initial.ref) ? initial.ref : "");
|
|
580
|
+
const [pathText, setPathText] = useState4(initial?.path ?? "");
|
|
581
|
+
const [path, setPath] = useState4(initial?.path ?? "");
|
|
582
|
+
const repositories = useLookup("repositories", (signal) => port.repositories(signal));
|
|
583
|
+
const latest = useLookup(repository || null, (signal) => port.latest(repository, signal));
|
|
584
|
+
const pinnedSha = version === "pinned" && isCommitSha(shaText.trim()) ? shaText.trim().toLowerCase() : null;
|
|
585
|
+
const pinned = useLookup(
|
|
586
|
+
repository && pinnedSha ? `${repository}@${pinnedSha}` : null,
|
|
587
|
+
(signal) => port.commit(repository, pinnedSha, signal),
|
|
588
|
+
300
|
|
589
|
+
);
|
|
590
|
+
const commit = version === "latest" ? latest.state === "done" ? latest.value.commit : null : pinned.state === "done" ? pinned.value : null;
|
|
591
|
+
const files = useLookup(
|
|
592
|
+
repository && commit ? `${repository}@${commit.sha}` : null,
|
|
593
|
+
(signal) => port.files(repository, commit.sha, signal)
|
|
594
|
+
);
|
|
595
|
+
const check = useLookup(
|
|
596
|
+
repository && commit && path ? `${repository}@${commit.sha}:${path}:${purpose}` : null,
|
|
597
|
+
(signal) => port.check({ repository, path, commit: commit.sha, purpose }, signal),
|
|
598
|
+
150
|
|
599
|
+
);
|
|
600
|
+
const notConnected = repositories.state === "failed" && repositories.failure.problem === "not-connected" ? repositories.failure : latest.state === "failed" && latest.failure.problem === "not-connected" ? latest.failure : null;
|
|
601
|
+
const repositorySuggestions = useMemo(() => {
|
|
602
|
+
if (repositories.state !== "done") return [];
|
|
603
|
+
const needle = repositoryText.trim().toLowerCase();
|
|
604
|
+
return repositories.value.repositories.filter((item) => !needle || item.fullName.toLowerCase().includes(needle)).slice(0, 50).map((item) => ({
|
|
605
|
+
value: item.fullName,
|
|
606
|
+
label: item.fullName,
|
|
607
|
+
detail: [item.private ? "Private" : "Public", item.description].filter(Boolean).join(" \xB7 ")
|
|
608
|
+
}));
|
|
609
|
+
}, [repositories, repositoryText]);
|
|
610
|
+
const pathSuggestions = useMemo(
|
|
611
|
+
() => files.state === "done" ? rankPaths(files.value.files, pathText, purpose) : [],
|
|
612
|
+
[files, pathText, purpose]
|
|
613
|
+
);
|
|
614
|
+
function commitRepository(text) {
|
|
615
|
+
const location = parseGitHubLocation(text);
|
|
616
|
+
if (!location) {
|
|
617
|
+
setRepository("");
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
setRepositoryText(location.repository);
|
|
621
|
+
setRepository(location.repository);
|
|
622
|
+
if (location.ref && isCommitSha(location.ref)) {
|
|
623
|
+
setVersion("pinned");
|
|
624
|
+
setShaText(location.ref);
|
|
625
|
+
}
|
|
626
|
+
if (location.path) {
|
|
627
|
+
setPathText(location.path);
|
|
628
|
+
setPath(location.path);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (notConnected) {
|
|
632
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-3", children: [
|
|
633
|
+
/* @__PURE__ */ jsx4(StatusLine, { tone: "neutral", children: notConnected.message }),
|
|
634
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap gap-2", children: [
|
|
635
|
+
connectHref && /* @__PURE__ */ jsx4(Button2, { asChild: true, size: "compact", children: /* @__PURE__ */ jsx4("a", { href: connectHref, children: "Connect GitHub" }) }),
|
|
636
|
+
/* @__PURE__ */ jsx4(Button2, { type: "button", size: "compact", variant: "ghost", onClick: onCancel, children: "Cancel" })
|
|
637
|
+
] })
|
|
638
|
+
] });
|
|
639
|
+
}
|
|
640
|
+
const repositoryInvalid = repositoryText.trim() !== "" && repository === "" && !parseGitHubLocation(repositoryText);
|
|
641
|
+
const repositoryMessage = repositoryInvalid ? /* @__PURE__ */ jsx4("span", { className: formText.error, children: "Enter a repository as owner/repo, or paste its GitHub link." }) : latest.state === "failed" ? /* @__PURE__ */ jsx4("span", { className: formText.error, children: latest.failure.message }) : latest.state === "loading" ? /* @__PURE__ */ jsxs4(StatusLine, { tone: "pending", children: [
|
|
642
|
+
"Checking ",
|
|
643
|
+
repository,
|
|
644
|
+
"\u2026"
|
|
645
|
+
] }) : latest.state === "done" ? /* @__PURE__ */ jsxs4(StatusLine, { tone: "success", children: [
|
|
646
|
+
latest.value.repository.private ? "Private" : "Public",
|
|
647
|
+
" \xB7 default branch ",
|
|
648
|
+
latest.value.repository.defaultBranch
|
|
649
|
+
] }) : repositories.state === "failed" ? /* @__PURE__ */ jsx4("span", { className: formText.muted, children: repositories.failure.message }) : void 0;
|
|
650
|
+
const shaInvalid = version === "pinned" && shaText.trim() !== "" && !isCommitSha(shaText.trim());
|
|
651
|
+
const versionMessage = version === "latest" ? latest.state === "done" ? /* @__PURE__ */ jsx4("span", { className: formText.muted, children: describeCommit(latest.value.commit) }) : void 0 : shaInvalid ? /* @__PURE__ */ jsx4("span", { className: formText.error, children: "Enter the full 40-character commit SHA." }) : pinned.state === "failed" ? /* @__PURE__ */ jsx4("span", { className: formText.error, children: pinned.failure.message }) : pinned.state === "loading" ? /* @__PURE__ */ jsx4(StatusLine, { tone: "pending", children: "Looking up the commit\u2026" }) : pinned.state === "done" ? /* @__PURE__ */ jsx4(StatusLine, { tone: "success", children: describeCommit(pinned.value) }) : void 0;
|
|
652
|
+
const checked = check.state === "done" ? check.value : null;
|
|
653
|
+
const pathMessage = !commit ? void 0 : files.state === "failed" ? /* @__PURE__ */ jsx4("span", { className: formText.error, children: files.failure.message }) : check.state === "loading" ? /* @__PURE__ */ jsxs4(StatusLine, { tone: "pending", children: [
|
|
654
|
+
"Reading ",
|
|
655
|
+
path,
|
|
656
|
+
"\u2026"
|
|
657
|
+
] }) : check.state === "failed" ? /* @__PURE__ */ jsx4("span", { className: formText.error, children: check.failure.message }) : checked ? /* @__PURE__ */ jsx4(StatusLine, { tone: "success", children: checked.skill ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
658
|
+
"Skill ",
|
|
659
|
+
/* @__PURE__ */ jsx4("span", { className: "font-medium", children: checked.skill.name }),
|
|
660
|
+
": ",
|
|
661
|
+
checked.skill.description
|
|
662
|
+
] }) : /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
663
|
+
checked.path,
|
|
664
|
+
" \xB7 ",
|
|
665
|
+
Math.max(1, Math.round(checked.size / 1024)),
|
|
666
|
+
" KB"
|
|
667
|
+
] }) }) : files.state === "done" && files.value.truncated ? /* @__PURE__ */ jsx4("span", { className: formText.muted, children: "This repository is large; type the full path if it is not suggested." }) : void 0;
|
|
668
|
+
const ready = checked !== null && !blocked && !disabled;
|
|
669
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-4", children: [
|
|
670
|
+
/* @__PURE__ */ jsx4(Field, { label: "Repository", htmlFor: fieldId("repository"), error: void 0, hint: repositoryMessage, children: /* @__PURE__ */ jsx4(
|
|
671
|
+
SuggestInput,
|
|
672
|
+
{
|
|
673
|
+
id: fieldId("repository"),
|
|
674
|
+
value: repositoryText,
|
|
675
|
+
disabled,
|
|
676
|
+
placeholder: repositories.state === "done" ? "Search your repositories" : "owner/repo",
|
|
677
|
+
onChange: setRepositoryText,
|
|
678
|
+
onCommit: commitRepository,
|
|
679
|
+
suggestions: repositorySuggestions,
|
|
680
|
+
loading: repositories.state === "loading" && repositoryText === "",
|
|
681
|
+
emptyText: repositories.state === "done" ? "No matching repositories. Press Enter to use what you typed." : void 0,
|
|
682
|
+
invalid: repositoryInvalid || latest.state === "failed",
|
|
683
|
+
describedBy: fieldMessageId(fieldId("repository"))
|
|
684
|
+
}
|
|
685
|
+
) }),
|
|
686
|
+
/* @__PURE__ */ jsxs4("div", { className: formRow, children: [
|
|
687
|
+
/* @__PURE__ */ jsx4(Field, { label: "Version", htmlFor: fieldId("version"), hint: versionMessage, children: /* @__PURE__ */ jsx4(
|
|
688
|
+
SegmentedControl,
|
|
689
|
+
{
|
|
690
|
+
id: fieldId("version"),
|
|
691
|
+
"aria-label": "Version",
|
|
692
|
+
value: version,
|
|
693
|
+
onValueChange: (next) => setVersion(next),
|
|
694
|
+
options: [{ value: "latest", label: "Latest commit" }, { value: "pinned", label: "Pin a commit" }],
|
|
695
|
+
className: "h-[var(--control-height)] w-full flex-nowrap p-0.5 [&_button]:h-full [&_button]:flex-1 [&_button]:justify-center [&_button]:py-0"
|
|
696
|
+
}
|
|
697
|
+
) }),
|
|
698
|
+
version === "pinned" && /* @__PURE__ */ jsx4(Field, { label: "Commit SHA", htmlFor: fieldId("sha"), children: /* @__PURE__ */ jsx4(
|
|
699
|
+
Input3,
|
|
700
|
+
{
|
|
701
|
+
id: fieldId("sha"),
|
|
702
|
+
size: "compact",
|
|
703
|
+
value: shaText,
|
|
704
|
+
disabled,
|
|
705
|
+
placeholder: "40-character SHA",
|
|
706
|
+
"aria-invalid": shaInvalid || pinned.state === "failed" || void 0,
|
|
707
|
+
...noAutofill,
|
|
708
|
+
className: "font-mono",
|
|
709
|
+
onChange: (event) => setShaText(event.target.value)
|
|
710
|
+
}
|
|
711
|
+
) })
|
|
712
|
+
] }),
|
|
713
|
+
/* @__PURE__ */ jsx4(Field, { label: purpose === "skill" ? "Skill file" : "File", htmlFor: fieldId("path"), hint: pathMessage, children: /* @__PURE__ */ jsx4(
|
|
714
|
+
SuggestInput,
|
|
715
|
+
{
|
|
716
|
+
id: fieldId("path"),
|
|
717
|
+
value: pathText,
|
|
718
|
+
disabled: disabled || !commit,
|
|
719
|
+
placeholder: purpose === "skill" ? "skills/research/SKILL.md" : "docs/guide.md",
|
|
720
|
+
onChange: setPathText,
|
|
721
|
+
onCommit: (next) => setPath(next),
|
|
722
|
+
suggestions: pathSuggestions,
|
|
723
|
+
loading: files.state === "loading",
|
|
724
|
+
emptyText: files.state === "done" ? purpose === "skill" ? "No SKILL.md files match." : "No files match." : void 0,
|
|
725
|
+
invalid: check.state === "failed",
|
|
726
|
+
describedBy: fieldMessageId(fieldId("path"))
|
|
727
|
+
}
|
|
728
|
+
) }),
|
|
729
|
+
children?.(checked),
|
|
730
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap gap-2", children: [
|
|
731
|
+
/* @__PURE__ */ jsx4(Button2, { type: "button", size: "compact", disabled: !ready, onClick: () => {
|
|
732
|
+
if (checked) onChoose({ check: checked });
|
|
733
|
+
}, children: actionLabel }),
|
|
734
|
+
/* @__PURE__ */ jsx4(Button2, { type: "button", size: "compact", variant: "ghost", onClick: onCancel, children: "Cancel" })
|
|
735
|
+
] })
|
|
736
|
+
] });
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// src/web-react/agent-profile-mcp-servers.tsx
|
|
740
|
+
import { useEffect as useEffect3, useId as useId4, useMemo as useMemo2, useRef as useRef4, useState as useState5 } from "react";
|
|
741
|
+
import { Button as Button3, Input as Input4, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch } from "@tangle-network/sandbox-ui/primitives";
|
|
742
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
743
|
+
var NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
744
|
+
function enabledConfig(server) {
|
|
745
|
+
if (server.enabled !== false) return server;
|
|
746
|
+
const stored = server.metadata?.enabledConfig;
|
|
747
|
+
if (!stored || typeof stored !== "object") return null;
|
|
748
|
+
const config = stored;
|
|
749
|
+
if (typeof config.url !== "string" && typeof config.command !== "string") return null;
|
|
750
|
+
return config;
|
|
751
|
+
}
|
|
752
|
+
function withoutKeys(value, keys) {
|
|
753
|
+
return Object.fromEntries(Object.entries(value).filter(([key]) => !keys.includes(key)));
|
|
754
|
+
}
|
|
755
|
+
function disableMcpServer(server) {
|
|
756
|
+
if (server.enabled === false) return server;
|
|
757
|
+
const config = withoutKeys(server, ["enabled", "metadata"]);
|
|
758
|
+
return { enabled: false, metadata: { ...server.metadata ?? {}, enabledConfig: config } };
|
|
759
|
+
}
|
|
760
|
+
function enableMcpServer(server) {
|
|
761
|
+
if (server.enabled !== false) return server;
|
|
762
|
+
const config = enabledConfig(server);
|
|
763
|
+
if (!config) return null;
|
|
764
|
+
const metadata = withoutKeys(server.metadata ?? {}, ["enabledConfig"]);
|
|
765
|
+
return { ...config, ...Object.keys(metadata).length ? { metadata } : {} };
|
|
766
|
+
}
|
|
767
|
+
function serverTransport(server) {
|
|
768
|
+
if (!server) return "http";
|
|
769
|
+
if ("command" in server && server.command) return "stdio";
|
|
770
|
+
return "transport" in server && server.transport === "sse" ? "sse" : "http";
|
|
771
|
+
}
|
|
772
|
+
function serverTarget(server) {
|
|
773
|
+
if (!server) return "";
|
|
774
|
+
if ("command" in server && server.command) return server.command;
|
|
775
|
+
return "url" in server && server.url ? server.url : "";
|
|
776
|
+
}
|
|
777
|
+
function healthKey(server) {
|
|
778
|
+
return JSON.stringify(["url" in server ? server.url : null, "transport" in server ? server.transport : null, "headers" in server ? server.headers : null]);
|
|
779
|
+
}
|
|
780
|
+
function healthStatus(health) {
|
|
781
|
+
if (health === "checking") return { tone: "pending", label: "Checking" };
|
|
782
|
+
if (!health) return { tone: "neutral", label: "Not checked" };
|
|
783
|
+
if (health.ok) return { tone: "success", label: `Connected \xB7 ${health.tools.length} ${health.tools.length === 1 ? "tool" : "tools"}` };
|
|
784
|
+
const labels = {
|
|
785
|
+
"auth-required": ["warning", "Needs credentials"],
|
|
786
|
+
"invalid-url": ["error", "Invalid address"],
|
|
787
|
+
"blocked-url": ["error", "Address not allowed"],
|
|
788
|
+
"not-checkable": ["neutral", "Checked at run time"],
|
|
789
|
+
unreachable: ["error", "Unreachable"],
|
|
790
|
+
timeout: ["error", "Timed out"],
|
|
791
|
+
"protocol-error": ["error", "Not an MCP server"],
|
|
792
|
+
unavailable: ["warning", "Check unavailable"]
|
|
793
|
+
};
|
|
794
|
+
const [tone, label] = labels[health.problem];
|
|
795
|
+
return { tone, label };
|
|
796
|
+
}
|
|
797
|
+
function targetProblem(draft, publicHttpsOnly) {
|
|
798
|
+
const target = draft.target.trim();
|
|
799
|
+
if (!target) return null;
|
|
800
|
+
if (draft.transport === "stdio") return /[\u0000-\u001f\u007f]/.test(target) ? "Remove control characters from the command." : null;
|
|
801
|
+
if (publicHttpsOnly) return publicHttpsUrlProblem(target);
|
|
802
|
+
try {
|
|
803
|
+
const url = new URL(target);
|
|
804
|
+
return url.protocol === "https:" || url.protocol === "http:" ? null : "Use an http:// or https:// address.";
|
|
805
|
+
} catch {
|
|
806
|
+
return "Enter a full URL, such as https://example.com/mcp.";
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
function serverFromDraft(draft, previous) {
|
|
810
|
+
const target = draft.target.trim();
|
|
811
|
+
const metadata = previous?.metadata ? withoutKeys(previous.metadata, ["enabledConfig"]) : void 0;
|
|
812
|
+
const keep = metadata && Object.keys(metadata).length ? { metadata } : {};
|
|
813
|
+
const prior = previous ? enabledConfig(previous) : null;
|
|
814
|
+
if (draft.transport === "stdio") {
|
|
815
|
+
const extras = prior && "command" in prior ? withoutKeys(prior, ["command", "transport", "enabled", "metadata", "url", "headers"]) : {};
|
|
816
|
+
return { ...extras, command: target, ...keep };
|
|
817
|
+
}
|
|
818
|
+
const headers = prior && "headers" in prior && prior.headers ? { headers: prior.headers } : {};
|
|
819
|
+
return { transport: draft.transport, url: target, ...headers, ...keep };
|
|
820
|
+
}
|
|
821
|
+
function ServerForm({ draft, onDraft, existingNames, nameEditable, publicHttpsOnly, allowLocalCommand, disabled, submitLabel, onSubmit, onCancel }) {
|
|
822
|
+
const id = useId4();
|
|
823
|
+
const name = draft.name.trim();
|
|
824
|
+
const nameProblem = !nameEditable || !name ? null : !NAME_PATTERN.test(name) ? "Use up to 64 letters, numbers, dots, dashes, or underscores." : existingNames.includes(name) ? "A server with this name already exists." : null;
|
|
825
|
+
const problem = targetProblem(draft, publicHttpsOnly);
|
|
826
|
+
const ready = !disabled && (!nameEditable || name && !nameProblem) && draft.target.trim() && !problem;
|
|
827
|
+
return /* @__PURE__ */ jsxs5("div", { className: "space-y-4 rounded-lg border border-border bg-muted/30 p-4", children: [
|
|
828
|
+
/* @__PURE__ */ jsxs5("div", { className: formRow, children: [
|
|
829
|
+
nameEditable && /* @__PURE__ */ jsx5(Field, { label: "Name", htmlFor: `${id}-name`, error: nameProblem, children: /* @__PURE__ */ jsx5(
|
|
830
|
+
Input4,
|
|
831
|
+
{
|
|
832
|
+
id: `${id}-name`,
|
|
833
|
+
size: "compact",
|
|
834
|
+
value: draft.name,
|
|
835
|
+
disabled,
|
|
836
|
+
placeholder: "search",
|
|
837
|
+
...noAutofill,
|
|
838
|
+
"aria-invalid": nameProblem ? true : void 0,
|
|
839
|
+
"aria-describedby": nameProblem ? fieldMessageId(`${id}-name`) : void 0,
|
|
840
|
+
onChange: (event) => onDraft({ ...draft, name: event.target.value })
|
|
841
|
+
}
|
|
842
|
+
) }),
|
|
843
|
+
/* @__PURE__ */ jsx5(Field, { label: "Connection", htmlFor: `${id}-transport`, children: /* @__PURE__ */ jsxs5(Select, { disabled, value: draft.transport, onValueChange: (value) => onDraft({ ...draft, transport: value }), children: [
|
|
844
|
+
/* @__PURE__ */ jsx5(SelectTrigger, { id: `${id}-transport`, size: "compact", className: "shadow-none", children: /* @__PURE__ */ jsx5(SelectValue, {}) }),
|
|
845
|
+
/* @__PURE__ */ jsxs5(SelectContent, { children: [
|
|
846
|
+
/* @__PURE__ */ jsx5(SelectItem, { value: "http", children: "Streamable HTTP" }),
|
|
847
|
+
/* @__PURE__ */ jsx5(SelectItem, { value: "sse", children: "Server-sent events" }),
|
|
848
|
+
(allowLocalCommand || draft.transport === "stdio") && /* @__PURE__ */ jsx5(SelectItem, { value: "stdio", children: "Local command" })
|
|
849
|
+
] })
|
|
850
|
+
] }) })
|
|
851
|
+
] }),
|
|
852
|
+
/* @__PURE__ */ jsx5(
|
|
853
|
+
Field,
|
|
854
|
+
{
|
|
855
|
+
label: draft.transport === "stdio" ? "Command" : "URL",
|
|
856
|
+
htmlFor: `${id}-target`,
|
|
857
|
+
error: problem,
|
|
858
|
+
hint: draft.transport === "stdio" ? "Runs inside the agent workspace." : void 0,
|
|
859
|
+
children: /* @__PURE__ */ jsx5(
|
|
860
|
+
Input4,
|
|
861
|
+
{
|
|
862
|
+
id: `${id}-target`,
|
|
863
|
+
size: "compact",
|
|
864
|
+
value: draft.target,
|
|
865
|
+
disabled,
|
|
866
|
+
...noAutofill,
|
|
867
|
+
inputMode: draft.transport === "stdio" ? "text" : "url",
|
|
868
|
+
placeholder: draft.transport === "stdio" ? "npx -y @modelcontextprotocol/server-memory" : "https://example.com/mcp",
|
|
869
|
+
"aria-invalid": problem ? true : void 0,
|
|
870
|
+
"aria-describedby": fieldMessageId(`${id}-target`),
|
|
871
|
+
onChange: (event) => onDraft({ ...draft, target: event.target.value }),
|
|
872
|
+
onKeyDown: (event) => {
|
|
873
|
+
if (event.key === "Enter" && ready) {
|
|
874
|
+
event.preventDefault();
|
|
875
|
+
onSubmit();
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
)
|
|
880
|
+
}
|
|
881
|
+
),
|
|
882
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap gap-2", children: [
|
|
883
|
+
/* @__PURE__ */ jsx5(Button3, { type: "button", size: "compact", disabled: !ready, onClick: onSubmit, children: submitLabel }),
|
|
884
|
+
/* @__PURE__ */ jsx5(Button3, { type: "button", size: "compact", variant: "ghost", onClick: onCancel, children: "Cancel" })
|
|
885
|
+
] })
|
|
886
|
+
] });
|
|
887
|
+
}
|
|
888
|
+
function McpServersEditor({ servers, onChange, port, disabled, lockReason, publicHttpsOnly, allowLocalCommand, registry, onPendingChange }) {
|
|
889
|
+
const [health, setHealth] = useState5({});
|
|
890
|
+
const [recheck, setRecheck] = useState5({});
|
|
891
|
+
const [editing, setEditing] = useState5(null);
|
|
892
|
+
const [adding, setAdding] = useState5(null);
|
|
893
|
+
const controllers = useRef4(/* @__PURE__ */ new Map());
|
|
894
|
+
const locked = lockReason !== void 0;
|
|
895
|
+
const entries = useMemo2(() => Object.entries(servers), [servers]);
|
|
896
|
+
useEffect3(() => {
|
|
897
|
+
if (!port) return;
|
|
898
|
+
for (const [name, server] of entries) {
|
|
899
|
+
if (server.enabled === false || "command" in server && server.command) continue;
|
|
900
|
+
const key = `${healthKey(server)}#${recheck[name] ?? 0}`;
|
|
901
|
+
if (health[name]?.key === key) continue;
|
|
902
|
+
controllers.current.get(name)?.abort();
|
|
903
|
+
const controller = new AbortController();
|
|
904
|
+
controllers.current.set(name, controller);
|
|
905
|
+
setHealth((current) => ({ ...current, [name]: { key, result: "checking" } }));
|
|
906
|
+
port.check(server, controller.signal).then((result) => {
|
|
907
|
+
if (!controller.signal.aborted) setHealth((current) => ({ ...current, [name]: { key, result } }));
|
|
908
|
+
}, () => {
|
|
909
|
+
if (!controller.signal.aborted) {
|
|
910
|
+
setHealth((current) => ({ ...current, [name]: { key, result: { ok: false, problem: "unavailable", message: "The check could not run.", checkedAt: (/* @__PURE__ */ new Date()).toISOString() } } }));
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
}, [entries, port, recheck, health]);
|
|
915
|
+
useEffect3(() => () => {
|
|
916
|
+
for (const controller of controllers.current.values()) controller.abort();
|
|
917
|
+
}, []);
|
|
918
|
+
const pending = editing !== null || adding !== null;
|
|
919
|
+
useEffect3(() => {
|
|
920
|
+
onPendingChange?.(pending);
|
|
921
|
+
}, [pending, onPendingChange]);
|
|
922
|
+
function setServer(name, server) {
|
|
923
|
+
const next = { ...servers };
|
|
924
|
+
if (server) next[name] = server;
|
|
925
|
+
else delete next[name];
|
|
926
|
+
return onChange(next);
|
|
927
|
+
}
|
|
928
|
+
function toggle(name, server, on) {
|
|
929
|
+
if (!on) {
|
|
930
|
+
setServer(name, disableMcpServer(server));
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const enabled = enableMcpServer(server);
|
|
934
|
+
if (enabled) {
|
|
935
|
+
setServer(name, enabled);
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
setEditing({ name, draft: { name, transport: "http", target: "" }, reason: "Add the server address to turn it on." });
|
|
939
|
+
}
|
|
940
|
+
return /* @__PURE__ */ jsxs5("div", { className: "space-y-4", children: [
|
|
941
|
+
entries.length === 0 && /* @__PURE__ */ jsx5("p", { className: formText.muted, children: "No MCP servers yet." }),
|
|
942
|
+
entries.length > 0 && /* @__PURE__ */ jsx5("ul", { className: "divide-y divide-border rounded-lg border border-border", children: entries.map(([name, server]) => {
|
|
943
|
+
const on = server.enabled !== false;
|
|
944
|
+
const config = enabledConfig(server);
|
|
945
|
+
const local = serverTransport(config) === "stdio";
|
|
946
|
+
const target = serverTarget(config);
|
|
947
|
+
const result = health[name]?.result;
|
|
948
|
+
const status = !on ? { tone: "neutral", label: "Off" } : local ? { tone: "neutral", label: "Checked at run time" } : port ? healthStatus(result) : { tone: "neutral", label: "Not checked" };
|
|
949
|
+
const description = typeof server.metadata?.description === "string" ? server.metadata.description : null;
|
|
950
|
+
const policyProblem = on && !local && publicHttpsOnly && target ? publicHttpsUrlProblem(target) : null;
|
|
951
|
+
const toggleId = `mcp-${name}-toggle`;
|
|
952
|
+
return /* @__PURE__ */ jsxs5("li", { className: "space-y-3 p-3", "aria-label": `MCP server ${name}`, children: [
|
|
953
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-start gap-3", children: [
|
|
954
|
+
/* @__PURE__ */ jsx5("span", { className: "flex h-6 items-center", children: /* @__PURE__ */ jsx5(
|
|
955
|
+
Switch,
|
|
956
|
+
{
|
|
957
|
+
id: toggleId,
|
|
958
|
+
checked: on,
|
|
959
|
+
disabled: disabled || locked,
|
|
960
|
+
"aria-label": `${on ? "Turn off" : "Turn on"} ${name}`,
|
|
961
|
+
title: lockReason,
|
|
962
|
+
onCheckedChange: (checked) => toggle(name, server, checked)
|
|
963
|
+
}
|
|
964
|
+
) }),
|
|
965
|
+
/* @__PURE__ */ jsxs5("div", { className: "min-w-0 flex-1", children: [
|
|
966
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center justify-between gap-x-3", children: [
|
|
967
|
+
/* @__PURE__ */ jsx5("label", { htmlFor: toggleId, className: `min-w-0 break-words ${formText.label}`, children: name }),
|
|
968
|
+
/* @__PURE__ */ jsx5(StatusPill, { tone: status.tone, children: status.label })
|
|
969
|
+
] }),
|
|
970
|
+
/* @__PURE__ */ jsx5("p", { className: `truncate ${formText.muted}`, title: target || void 0, children: target || "No address yet" }),
|
|
971
|
+
description && /* @__PURE__ */ jsx5("p", { className: formText.muted, children: description }),
|
|
972
|
+
policyProblem && /* @__PURE__ */ jsx5("p", { className: formText.error, children: policyProblem }),
|
|
973
|
+
on && !local && result && result !== "checking" && !result.ok && result.problem !== "not-checkable" && /* @__PURE__ */ jsx5("p", { className: result.problem === "auth-required" || result.problem === "unavailable" ? formText.muted : formText.error, children: result.message }),
|
|
974
|
+
on && result && result !== "checking" && result.ok && result.tools.length > 0 && /* @__PURE__ */ jsxs5("p", { className: `line-clamp-2 ${formText.muted}`, children: [
|
|
975
|
+
"Tools: ",
|
|
976
|
+
result.tools.map((tool) => tool.name).join(", ")
|
|
977
|
+
] })
|
|
978
|
+
] })
|
|
979
|
+
] }),
|
|
980
|
+
!locked && /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap gap-1 pl-9", children: [
|
|
981
|
+
port && on && !local && /* @__PURE__ */ jsx5(
|
|
982
|
+
Button3,
|
|
983
|
+
{
|
|
984
|
+
type: "button",
|
|
985
|
+
size: "compact",
|
|
986
|
+
variant: "ghost",
|
|
987
|
+
disabled: disabled || result === "checking",
|
|
988
|
+
onClick: () => setRecheck((current) => ({ ...current, [name]: (current[name] ?? 0) + 1 })),
|
|
989
|
+
children: "Check again"
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
/* @__PURE__ */ jsx5(
|
|
993
|
+
Button3,
|
|
994
|
+
{
|
|
995
|
+
type: "button",
|
|
996
|
+
size: "compact",
|
|
997
|
+
variant: "ghost",
|
|
998
|
+
disabled,
|
|
999
|
+
"aria-label": `Edit ${name}`,
|
|
1000
|
+
onClick: () => setEditing({ name, draft: { name, transport: serverTransport(config), target } }),
|
|
1001
|
+
children: "Edit"
|
|
1002
|
+
}
|
|
1003
|
+
),
|
|
1004
|
+
/* @__PURE__ */ jsx5(
|
|
1005
|
+
Button3,
|
|
1006
|
+
{
|
|
1007
|
+
type: "button",
|
|
1008
|
+
size: "compact",
|
|
1009
|
+
variant: "ghost",
|
|
1010
|
+
className: "text-destructive hover:text-destructive",
|
|
1011
|
+
disabled,
|
|
1012
|
+
"aria-label": `Remove ${name}`,
|
|
1013
|
+
onClick: () => {
|
|
1014
|
+
if (setServer(name, null) && editing?.name === name) setEditing(null);
|
|
1015
|
+
},
|
|
1016
|
+
children: "Remove"
|
|
1017
|
+
}
|
|
1018
|
+
)
|
|
1019
|
+
] }),
|
|
1020
|
+
editing?.name === name && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 @lg/profile-editor:pl-12", children: [
|
|
1021
|
+
editing.reason && /* @__PURE__ */ jsx5("p", { className: formText.muted, children: editing.reason }),
|
|
1022
|
+
/* @__PURE__ */ jsx5(
|
|
1023
|
+
ServerForm,
|
|
1024
|
+
{
|
|
1025
|
+
draft: editing.draft,
|
|
1026
|
+
onDraft: (draft) => setEditing({ ...editing, draft }),
|
|
1027
|
+
existingNames: [],
|
|
1028
|
+
nameEditable: false,
|
|
1029
|
+
publicHttpsOnly,
|
|
1030
|
+
allowLocalCommand,
|
|
1031
|
+
disabled,
|
|
1032
|
+
submitLabel: "Save",
|
|
1033
|
+
onCancel: () => setEditing(null),
|
|
1034
|
+
onSubmit: () => {
|
|
1035
|
+
if (setServer(name, serverFromDraft(editing.draft, server))) setEditing(null);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
)
|
|
1039
|
+
] })
|
|
1040
|
+
] }, name);
|
|
1041
|
+
}) }),
|
|
1042
|
+
locked && /* @__PURE__ */ jsx5("p", { className: formText.muted, children: lockReason }),
|
|
1043
|
+
!locked && (adding ? /* @__PURE__ */ jsx5(
|
|
1044
|
+
ServerForm,
|
|
1045
|
+
{
|
|
1046
|
+
draft: adding,
|
|
1047
|
+
onDraft: setAdding,
|
|
1048
|
+
existingNames: Object.keys(servers),
|
|
1049
|
+
nameEditable: true,
|
|
1050
|
+
publicHttpsOnly,
|
|
1051
|
+
allowLocalCommand,
|
|
1052
|
+
disabled,
|
|
1053
|
+
submitLabel: "Add server",
|
|
1054
|
+
onCancel: () => setAdding(null),
|
|
1055
|
+
onSubmit: () => {
|
|
1056
|
+
if (setServer(adding.name.trim(), serverFromDraft(adding))) setAdding(null);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
) : /* @__PURE__ */ jsx5(Button3, { type: "button", size: "compact", variant: "outline", disabled, onClick: () => setAdding({ name: "", transport: "http", target: "" }), children: "Add server" })),
|
|
1060
|
+
registry && !locked && /* @__PURE__ */ jsx5(
|
|
1061
|
+
AgentProfileRegistryMcpSearch,
|
|
1062
|
+
{
|
|
1063
|
+
registry,
|
|
1064
|
+
disabled,
|
|
1065
|
+
existingNames: Object.keys(servers),
|
|
1066
|
+
validate: (name, server) => {
|
|
1067
|
+
if (!name.trim()) return "The registry returned a server without a usable name.";
|
|
1068
|
+
if (name in servers) return "A server with that name already exists.";
|
|
1069
|
+
return publicHttpsOnly && "url" in server && server.url ? publicHttpsUrlProblem(server.url) : publicHttpsOnly ? "Use a public HTTPS MCP endpoint." : null;
|
|
1070
|
+
},
|
|
1071
|
+
onAdd: (name, server) => setServer(name, server)
|
|
1072
|
+
}
|
|
1073
|
+
),
|
|
1074
|
+
/* @__PURE__ */ jsx5("p", { className: formText.muted, children: "Headers, environment variables, and secret references are edited in Advanced JSON." })
|
|
1075
|
+
] });
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// src/web-react/agent-profile-files.tsx
|
|
1079
|
+
import { useRef as useRef5, useState as useState6 } from "react";
|
|
1080
|
+
import { Button as Button4 } from "@tangle-network/sandbox-ui/primitives";
|
|
1081
|
+
import { SidebarDropZone, UploadProgress } from "@tangle-network/ui/primitives";
|
|
1082
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1083
|
+
var DEFAULT_RESOURCE_FILE_ACCEPT = [".md", ".markdown", ".txt", ".json", ".yaml", ".yml", ".csv"];
|
|
1084
|
+
function formatBytes(bytes) {
|
|
1085
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
1086
|
+
if (bytes < 1024 * 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`;
|
|
1087
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
1088
|
+
}
|
|
1089
|
+
function safeFileName(name) {
|
|
1090
|
+
const base = name.split(/[\\/]/).pop() ?? name;
|
|
1091
|
+
return base.normalize("NFKC").replace(/[\u0000-\u001f\u007f]/g, "").replace(/\s+/g, "-").replace(/[^A-Za-z0-9._-]/g, "").replace(/^\.+/, "") || "file";
|
|
1092
|
+
}
|
|
1093
|
+
function readText(file, onProgress) {
|
|
1094
|
+
return new Promise((resolve, reject) => {
|
|
1095
|
+
const reader = new FileReader();
|
|
1096
|
+
reader.onprogress = (event) => {
|
|
1097
|
+
if (event.lengthComputable) onProgress(Math.round(event.loaded / event.total * 100));
|
|
1098
|
+
};
|
|
1099
|
+
reader.onerror = () => reject(new Error("The browser could not read this file."));
|
|
1100
|
+
reader.onload = () => {
|
|
1101
|
+
const buffer = reader.result;
|
|
1102
|
+
if (!(buffer instanceof ArrayBuffer)) {
|
|
1103
|
+
reject(new Error("The browser could not read this file."));
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
try {
|
|
1107
|
+
resolve(new TextDecoder("utf-8", { fatal: true }).decode(buffer));
|
|
1108
|
+
} catch {
|
|
1109
|
+
reject(new Error("This is not a text file. Upload UTF-8 text, Markdown, or JSON."));
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
reader.readAsArrayBuffer(file);
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
function ResourceFileDrop({ existingPaths, pathPrefix = "", limits, disabled = false, onAdd, actions }) {
|
|
1116
|
+
const [uploads, setUploads] = useState6([]);
|
|
1117
|
+
const input = useRef5(null);
|
|
1118
|
+
const accept = (limits?.accept ?? DEFAULT_RESOURCE_FILE_ACCEPT).join(",");
|
|
1119
|
+
const maxFileBytes = limits?.maxFileBytes ?? 256 * 1024;
|
|
1120
|
+
const maxFiles = limits?.maxFiles ?? 50;
|
|
1121
|
+
const types = (limits?.accept ?? DEFAULT_RESOURCE_FILE_ACCEPT).map((type) => type.replace(/^\./, "").toUpperCase());
|
|
1122
|
+
const typeList = types.length > 1 ? `${types.slice(0, -1).join(", ")} or ${types[types.length - 1]}` : types[0];
|
|
1123
|
+
function update(id, change) {
|
|
1124
|
+
setUploads((current) => current.map((item) => item.id === id ? { ...item, ...change } : item));
|
|
1125
|
+
}
|
|
1126
|
+
async function receive(list) {
|
|
1127
|
+
if (disabled) return;
|
|
1128
|
+
const files = Array.from(list);
|
|
1129
|
+
if (!files.length) return;
|
|
1130
|
+
const { rejected } = filterAcceptedFiles(files, accept);
|
|
1131
|
+
const batch = [];
|
|
1132
|
+
const taken = new Set(existingPaths);
|
|
1133
|
+
let room = maxFiles - existingPaths.length;
|
|
1134
|
+
const work = [];
|
|
1135
|
+
for (const file of files) {
|
|
1136
|
+
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1137
|
+
const base = { id, name: file.name, size: file.size, status: "pending" };
|
|
1138
|
+
const path = pathPrefix + safeFileName(file.name);
|
|
1139
|
+
let error = null;
|
|
1140
|
+
if (rejected.some((item) => item.file === file)) error = `Only ${typeList} files can be added.`;
|
|
1141
|
+
else if (file.size > maxFileBytes) error = `This file is ${formatBytes(file.size)}. Files can be up to ${formatBytes(maxFileBytes)}.`;
|
|
1142
|
+
else if (file.size === 0) error = "This file is empty.";
|
|
1143
|
+
else if (taken.has(path)) error = `${path} is already in the profile. Remove it first or rename the file.`;
|
|
1144
|
+
else if (room <= 0) error = `The profile can hold ${maxFiles} files. Remove one to add another.`;
|
|
1145
|
+
if (error) {
|
|
1146
|
+
batch.push({ ...base, status: "error", error });
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
taken.add(path);
|
|
1150
|
+
room--;
|
|
1151
|
+
batch.push(base);
|
|
1152
|
+
work.push({ id, file, path });
|
|
1153
|
+
}
|
|
1154
|
+
setUploads((current) => [...current.filter((item) => item.status !== "complete"), ...batch]);
|
|
1155
|
+
const read = [];
|
|
1156
|
+
for (const item of work) {
|
|
1157
|
+
update(item.id, { status: "uploading", progress: 0 });
|
|
1158
|
+
try {
|
|
1159
|
+
const content = await readText(item.file, (progress) => update(item.id, { progress }));
|
|
1160
|
+
read.push({ id: item.id, path: item.path, file: { name: safeFileName(item.file.name), content } });
|
|
1161
|
+
update(item.id, { progress: 100 });
|
|
1162
|
+
} catch (cause) {
|
|
1163
|
+
update(item.id, { status: "error", error: cause instanceof Error ? cause.message : "The file could not be read." });
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
if (!read.length) return;
|
|
1167
|
+
const refused = onAdd(read.map(({ path, file }) => ({ path, file })));
|
|
1168
|
+
for (const item of read) {
|
|
1169
|
+
update(item.id, refused ? { status: "error", error: refused } : { status: "complete", progress: 100 });
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return /* @__PURE__ */ jsxs6("div", { className: "space-y-3", children: [
|
|
1173
|
+
/* @__PURE__ */ jsx6(
|
|
1174
|
+
SidebarDropZone,
|
|
1175
|
+
{
|
|
1176
|
+
persistent: true,
|
|
1177
|
+
disabled,
|
|
1178
|
+
onDrop: (files) => void receive(files),
|
|
1179
|
+
title: "Drop files here",
|
|
1180
|
+
description: `${typeList} up to ${formatBytes(maxFileBytes)} each`,
|
|
1181
|
+
className: "[&_p]:text-sm [&_p]:leading-6 focus-within:border-[var(--focus-border)]"
|
|
1182
|
+
}
|
|
1183
|
+
),
|
|
1184
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1185
|
+
/* @__PURE__ */ jsx6(Button4, { type: "button", size: "compact", variant: "outline", disabled, onClick: () => input.current?.click(), children: "Choose files" }),
|
|
1186
|
+
actions,
|
|
1187
|
+
/* @__PURE__ */ jsx6(
|
|
1188
|
+
"input",
|
|
1189
|
+
{
|
|
1190
|
+
ref: input,
|
|
1191
|
+
type: "file",
|
|
1192
|
+
multiple: true,
|
|
1193
|
+
accept,
|
|
1194
|
+
className: "sr-only",
|
|
1195
|
+
tabIndex: -1,
|
|
1196
|
+
"aria-hidden": "true",
|
|
1197
|
+
onChange: (event) => {
|
|
1198
|
+
const files = event.target.files;
|
|
1199
|
+
if (files) void receive(files);
|
|
1200
|
+
event.target.value = "";
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
),
|
|
1204
|
+
uploads.length > 0 && /* @__PURE__ */ jsx6(Button4, { type: "button", size: "compact", variant: "ghost", onClick: () => setUploads([]), children: "Clear list" })
|
|
1205
|
+
] }),
|
|
1206
|
+
uploads.length > 0 && /* @__PURE__ */ jsx6("div", { "aria-live": "polite", children: /* @__PURE__ */ jsx6(
|
|
1207
|
+
UploadProgress,
|
|
1208
|
+
{
|
|
1209
|
+
files: uploads,
|
|
1210
|
+
onRemove: (id) => setUploads((current) => current.filter((item) => item.id !== id)),
|
|
1211
|
+
className: "[&_.text-xs]:text-sm"
|
|
1212
|
+
}
|
|
1213
|
+
) }),
|
|
1214
|
+
uploads.some((item) => item.status === "error") && /* @__PURE__ */ jsx6("p", { className: formText.muted, children: "Files with an error were not added." })
|
|
1215
|
+
] });
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
// src/web-react/agent-profile-editor.tsx
|
|
1219
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1220
|
+
var AGENT_PROFILE_EDITOR_SECTIONS = ["identity", "prompts", "model", "tools", "skills", "toolFiles", "mcp", "files", "advanced"];
|
|
1221
|
+
var RESOURCE_KIND_LABELS = {
|
|
1222
|
+
files: "Resource files",
|
|
1223
|
+
skills: "Skills",
|
|
1224
|
+
tools: "Tool files",
|
|
1225
|
+
agents: "Agent files",
|
|
1226
|
+
commands: "Command files",
|
|
1227
|
+
instructions: "Resource instructions"
|
|
1228
|
+
};
|
|
1229
|
+
function configuredResourceCount(profile, kind) {
|
|
1230
|
+
const resource = profile.resources?.[kind];
|
|
1231
|
+
return Array.isArray(resource) ? resource.length : resource ? 1 : 0;
|
|
1232
|
+
}
|
|
1233
|
+
function issueMessage(error) {
|
|
1234
|
+
const issue = error.issues[0];
|
|
1235
|
+
return issue ? (issue.path.map(String).join(".") || "Profile") + ": " + issue.message : "Invalid profile";
|
|
1236
|
+
}
|
|
1237
|
+
function validRelativePath(path) {
|
|
1238
|
+
return path.length <= 240 && !path.startsWith("/") && !path.includes("\\") && !/[\u0000-\u001f\u007f]/.test(path) && path.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
1239
|
+
}
|
|
1240
|
+
function normalizedFilePathPrefix(prefix) {
|
|
1241
|
+
const folder = prefix?.trim().replace(/\/+$/, "");
|
|
1242
|
+
return folder ? folder + "/" : void 0;
|
|
1243
|
+
}
|
|
1244
|
+
var SKILL_NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
|
1245
|
+
function githubRefIssue(ref, requireGitHubCommitSha) {
|
|
1246
|
+
if (ref.kind !== "github") return null;
|
|
1247
|
+
const repository = ref.repository ?? "";
|
|
1248
|
+
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repository) || repository.split("/").some((part) => part === "." || part === "..")) {
|
|
1249
|
+
return "Choose the GitHub repository for this file.";
|
|
1250
|
+
}
|
|
1251
|
+
if (!ref.path) return "Choose a file in the repository.";
|
|
1252
|
+
if (requireGitHubCommitSha) {
|
|
1253
|
+
if (!/^[0-9a-f]{40}$/i.test(ref.ref ?? "")) return "Pin this source to a 40-character GitHub commit SHA.";
|
|
1254
|
+
if (!validRelativePath(ref.path) || /[?#%]/.test(ref.path)) return "Use a relative repository path without traversal or URL characters.";
|
|
1255
|
+
}
|
|
1256
|
+
return null;
|
|
1257
|
+
}
|
|
1258
|
+
function inlineSkillSummary(content) {
|
|
1259
|
+
const frontmatter = readSkillFrontmatter(content);
|
|
1260
|
+
if (frontmatter.ok) return frontmatter.description;
|
|
1261
|
+
const line = content.split("\n").map((text) => text.replace(/^#+\s*/, "").trim()).find(Boolean);
|
|
1262
|
+
return line ? line.slice(0, 160) : null;
|
|
1263
|
+
}
|
|
1264
|
+
function sourceLine(ref) {
|
|
1265
|
+
if (ref.kind === "inline") return `Written here \xB7 ${Math.max(1, Math.round(new TextEncoder().encode(ref.content).byteLength / 1024))} KB`;
|
|
1266
|
+
return ["GitHub", ref.repository ? `${ref.repository}/${ref.path}` : ref.path, ref.ref ? `@ ${ref.ref.slice(0, 7)}` : null].filter(Boolean).join(" \xB7 ");
|
|
1267
|
+
}
|
|
1268
|
+
function basename(path) {
|
|
1269
|
+
return path.split("/").filter(Boolean).pop() ?? path;
|
|
1270
|
+
}
|
|
1271
|
+
function suggestedSkillName(check) {
|
|
1272
|
+
const fromFrontmatter = check.skill?.name ?? "";
|
|
1273
|
+
const folder = check.path.split("/").slice(-2, -1)[0] ?? "";
|
|
1274
|
+
const raw = fromFrontmatter || folder || basename(check.path).replace(/\.md$/i, "");
|
|
1275
|
+
return raw.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[^a-z0-9]+/, "").slice(0, 64);
|
|
1276
|
+
}
|
|
1277
|
+
function defaultThinkingLevels({ harness, model }) {
|
|
1278
|
+
const efforts = harness ? reasoningEffortsFor(harness, { supportsReasoning: model?.supportsReasoning !== false }) : REASONING_EFFORTS;
|
|
1279
|
+
return [{ id: "auto", label: "Auto" }, ...effortLevelsFromIds(efforts)];
|
|
1280
|
+
}
|
|
1281
|
+
function AgentProfileEditor({
|
|
1282
|
+
value,
|
|
1283
|
+
onChange,
|
|
1284
|
+
disabled = false,
|
|
1285
|
+
className,
|
|
1286
|
+
config,
|
|
1287
|
+
allowedResourceKinds,
|
|
1288
|
+
filePathPrefix,
|
|
1289
|
+
allowExecutableFiles = true,
|
|
1290
|
+
requireGitHubCommitSha = false,
|
|
1291
|
+
requireUniqueSkillNames = false,
|
|
1292
|
+
showToolsAndPermissions = true,
|
|
1293
|
+
publicHttpsMcpOnly = false,
|
|
1294
|
+
registry,
|
|
1295
|
+
onSaveStateChange
|
|
1296
|
+
}) {
|
|
1297
|
+
const id = useId5();
|
|
1298
|
+
const workspaceFilePrefix = normalizedFilePathPrefix(filePathPrefix);
|
|
1299
|
+
const [error, setError] = useState7(null);
|
|
1300
|
+
const [newTool, setNewTool] = useState7("");
|
|
1301
|
+
const [showAllTools, setShowAllTools] = useState7(false);
|
|
1302
|
+
const [panel, setPanel] = useState7(null);
|
|
1303
|
+
const [inlineDraft, setInlineDraft] = useState7({ name: "", content: "", path: "", executable: false });
|
|
1304
|
+
const [githubName, setGithubName] = useState7({ value: "", touched: false });
|
|
1305
|
+
const [mcpPending, setMcpPending] = useState7(false);
|
|
1306
|
+
const [modelNotice, setModelNotice] = useState7(null);
|
|
1307
|
+
const [json, setJson] = useState7(() => JSON.stringify(value, null, 2));
|
|
1308
|
+
const [jsonDirty, setJsonDirty] = useState7(false);
|
|
1309
|
+
useEffect4(() => {
|
|
1310
|
+
if (!jsonDirty) setJson(JSON.stringify(value, null, 2));
|
|
1311
|
+
}, [value, jsonDirty]);
|
|
1312
|
+
const editingDisabled = disabled || jsonDirty;
|
|
1313
|
+
const sectionAllowed = (section) => !config?.sections || config.sections.includes(section);
|
|
1314
|
+
const allowsResource = (kind) => !allowedResourceKinds || allowedResourceKinds.includes(kind);
|
|
1315
|
+
const show = {
|
|
1316
|
+
identity: sectionAllowed("identity"),
|
|
1317
|
+
prompts: sectionAllowed("prompts"),
|
|
1318
|
+
model: sectionAllowed("model"),
|
|
1319
|
+
tools: sectionAllowed("tools") && showToolsAndPermissions,
|
|
1320
|
+
skills: sectionAllowed("skills") && allowsResource("skills"),
|
|
1321
|
+
toolFiles: sectionAllowed("toolFiles") && allowsResource("tools"),
|
|
1322
|
+
mcp: sectionAllowed("mcp"),
|
|
1323
|
+
files: sectionAllowed("files") && allowsResource("files"),
|
|
1324
|
+
advanced: sectionAllowed("advanced")
|
|
1325
|
+
};
|
|
1326
|
+
const unsupportedResources = Object.keys(RESOURCE_KIND_LABELS).filter((kind) => configuredResourceCount(value, kind) > 0 && !(kind === "skills" && show.skills || kind === "tools" && show.toolFiles || kind === "files" && show.files || allowsResource(kind) && kind !== "skills" && kind !== "tools" && kind !== "files"));
|
|
1327
|
+
const skills = value.resources?.skills ?? [];
|
|
1328
|
+
const toolFiles = value.resources?.tools ?? [];
|
|
1329
|
+
const files = value.resources?.files ?? [];
|
|
1330
|
+
const instructions = value.resources?.instructions;
|
|
1331
|
+
function skillIssue(ref, refs, index) {
|
|
1332
|
+
if (requireUniqueSkillNames) {
|
|
1333
|
+
const name = ref.name ?? "";
|
|
1334
|
+
if (!SKILL_NAME.test(name)) return "Use a lowercase name of up to 64 letters, numbers, dots, dashes, or underscores.";
|
|
1335
|
+
if (refs.some((other, item) => item !== index && other.name === name)) return "Another skill already uses this name.";
|
|
1336
|
+
}
|
|
1337
|
+
if (ref.kind === "inline" && !ref.name.trim()) return "Name this skill.";
|
|
1338
|
+
return githubRefIssue(ref, requireGitHubCommitSha);
|
|
1339
|
+
}
|
|
1340
|
+
function fileIssue(mount, index) {
|
|
1341
|
+
const path = mount.path;
|
|
1342
|
+
if (!path.trim()) return "Enter a workspace path for the file.";
|
|
1343
|
+
if (!validRelativePath(path)) return "Use a relative workspace path without traversal.";
|
|
1344
|
+
if (workspaceFilePrefix && !path.startsWith(workspaceFilePrefix)) return `Place this file under ${workspaceFilePrefix}.`;
|
|
1345
|
+
if (files.some((other, item) => item !== index && other.path === path)) return "Another file already uses this path.";
|
|
1346
|
+
if (!allowExecutableFiles && mount.executable) return "Executable files are not allowed in this product.";
|
|
1347
|
+
if (mount.resource.kind === "inline" && !mount.resource.name.trim()) return "Name this file.";
|
|
1348
|
+
return githubRefIssue(mount.resource, requireGitHubCommitSha);
|
|
1349
|
+
}
|
|
1350
|
+
const constrainedEntryCount = workspaceFilePrefix || !allowExecutableFiles || requireGitHubCommitSha || requireUniqueSkillNames ? files.filter((mount, index) => fileIssue(mount, index)).length + skills.filter((ref, index) => skillIssue(ref, skills, index)).length + toolFiles.filter((ref) => requireGitHubCommitSha && githubRefIssue(ref, true)).length + Number(Boolean(requireGitHubCommitSha && instructions && typeof instructions === "object" && githubRefIssue(instructions, true))) : 0;
|
|
1351
|
+
const invalidMcpCount = publicHttpsMcpOnly ? Object.values(value.mcp ?? {}).filter((server) => server.enabled !== false && (!("url" in server) || !server.url || publicHttpsUrlProblem(server.url) !== null)).length : 0;
|
|
1352
|
+
const pending = jsonDirty || panel !== null || mcpPending || Boolean(newTool.trim());
|
|
1353
|
+
const invalid = Boolean(error || unsupportedResources.length || constrainedEntryCount || invalidMcpCount);
|
|
1354
|
+
useEffect4(() => {
|
|
1355
|
+
onSaveStateChange?.({ pending, invalid });
|
|
1356
|
+
}, [onSaveStateChange, pending, invalid]);
|
|
1357
|
+
useEffect4(() => () => {
|
|
1358
|
+
onSaveStateChange?.({ pending: false, invalid: false });
|
|
1359
|
+
}, [onSaveStateChange]);
|
|
1360
|
+
function emit(next) {
|
|
1361
|
+
if (jsonDirty) {
|
|
1362
|
+
setError("Apply or discard JSON edits first.");
|
|
1363
|
+
return false;
|
|
1364
|
+
}
|
|
1365
|
+
const result = agentProfileSchema.safeParse(next);
|
|
1366
|
+
if (!result.success) {
|
|
1367
|
+
setError(issueMessage(result.error));
|
|
1368
|
+
return false;
|
|
1369
|
+
}
|
|
1370
|
+
setError(null);
|
|
1371
|
+
onChange(result.data);
|
|
1372
|
+
return true;
|
|
1373
|
+
}
|
|
1374
|
+
function prompt(next) {
|
|
1375
|
+
emit({ ...value, prompt: next });
|
|
1376
|
+
}
|
|
1377
|
+
function model(next) {
|
|
1378
|
+
const cleaned = Object.fromEntries(Object.entries(next).filter(([, item]) => item !== void 0 && item !== ""));
|
|
1379
|
+
const { model: _model, ...rest } = value;
|
|
1380
|
+
emit(Object.keys(cleaned).length ? { ...rest, model: cleaned } : rest);
|
|
1381
|
+
}
|
|
1382
|
+
function resources(key, refs) {
|
|
1383
|
+
return emit({ ...value, resources: { ...value.resources, [key]: refs } });
|
|
1384
|
+
}
|
|
1385
|
+
function setFiles(next) {
|
|
1386
|
+
return emit({ ...value, resources: { ...value.resources, files: next } });
|
|
1387
|
+
}
|
|
1388
|
+
function openPanel(next) {
|
|
1389
|
+
setPanel(next);
|
|
1390
|
+
setError(null);
|
|
1391
|
+
setGithubName({ value: "", touched: false });
|
|
1392
|
+
if (next?.kind === "edit") {
|
|
1393
|
+
const ref = next.section === "files" ? files[next.index]?.resource : (next.section === "skills" ? skills : toolFiles)[next.index];
|
|
1394
|
+
const mount = next.section === "files" ? files[next.index] : void 0;
|
|
1395
|
+
setInlineDraft({
|
|
1396
|
+
name: ref?.kind === "inline" ? ref.name : ref?.name ?? "",
|
|
1397
|
+
content: ref?.kind === "inline" ? ref.content : "",
|
|
1398
|
+
path: mount?.path ?? "",
|
|
1399
|
+
executable: mount?.executable ?? false
|
|
1400
|
+
});
|
|
1401
|
+
} else {
|
|
1402
|
+
setInlineDraft({ name: "", content: "", path: next?.section === "files" ? workspaceFilePrefix ?? "" : "", executable: false });
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
function applyJson() {
|
|
1406
|
+
try {
|
|
1407
|
+
const result = agentProfileSchema.safeParse(JSON.parse(json));
|
|
1408
|
+
if (!result.success) {
|
|
1409
|
+
setError(issueMessage(result.error));
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
setError(null);
|
|
1413
|
+
setJsonDirty(false);
|
|
1414
|
+
onChange(result.data);
|
|
1415
|
+
} catch (cause) {
|
|
1416
|
+
setError(cause instanceof Error ? cause.message : "Invalid JSON");
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
const catalog = config?.models;
|
|
1420
|
+
const harness = value.harness;
|
|
1421
|
+
const offeredModels = useMemo3(() => !catalog ? [] : harness ? catalog.models.filter((item) => isModelCompatibleWithHarness(harness, item.id)) : catalog.models, [catalog, harness]);
|
|
1422
|
+
const selectedModel = catalog?.models.find((item) => item.id === value.model?.default);
|
|
1423
|
+
const thinkingLevels = (config?.thinkingLevels ?? defaultThinkingLevels)({ harness, model: selectedModel });
|
|
1424
|
+
function changeHarness(next) {
|
|
1425
|
+
setModelNotice(null);
|
|
1426
|
+
const { harness: _harness, ...rest } = value;
|
|
1427
|
+
let nextModel = value.model;
|
|
1428
|
+
if (next && catalog && value.model?.default && !isModelCompatibleWithHarness(next, value.model.default)) {
|
|
1429
|
+
const ids = catalog.models.map((item) => item.id);
|
|
1430
|
+
const snapped = snapModelToHarness(next, value.model.default, ids);
|
|
1431
|
+
if (snapped !== value.model.default) {
|
|
1432
|
+
nextModel = { ...value.model, default: snapped };
|
|
1433
|
+
const name = catalog.models.find((item) => item.id === snapped)?.name ?? snapped;
|
|
1434
|
+
setModelNotice(`Default model changed to ${name}, which runs on this harness.`);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
emit({ ...rest, ...next ? { harness: next } : {}, ...nextModel ? { model: nextModel } : {} });
|
|
1438
|
+
}
|
|
1439
|
+
function modelField(label, field, info) {
|
|
1440
|
+
const fieldId = `${id}-model-${field}`;
|
|
1441
|
+
const current = value.model?.[field] ?? "";
|
|
1442
|
+
return /* @__PURE__ */ jsx7(Field, { label, htmlFor: fieldId, info, children: catalog ? /* @__PURE__ */ jsx7(
|
|
1443
|
+
ModelPicker,
|
|
1444
|
+
{
|
|
1445
|
+
id: fieldId,
|
|
1446
|
+
variant: "field",
|
|
1447
|
+
value: current,
|
|
1448
|
+
onChange: (next) => model({ ...value.model, [field]: next || void 0 }),
|
|
1449
|
+
models: offeredModels,
|
|
1450
|
+
loading: catalog.loading,
|
|
1451
|
+
error: catalog.error,
|
|
1452
|
+
onRetry: catalog.onRetry,
|
|
1453
|
+
disabled: editingDisabled,
|
|
1454
|
+
defaultOption: { label: catalog.defaultLabel ?? "Product default" }
|
|
1455
|
+
}
|
|
1456
|
+
) : /* @__PURE__ */ jsx7(
|
|
1457
|
+
Input5,
|
|
1458
|
+
{
|
|
1459
|
+
id: fieldId,
|
|
1460
|
+
size: "compact",
|
|
1461
|
+
value: current,
|
|
1462
|
+
disabled: editingDisabled,
|
|
1463
|
+
placeholder: "provider/model",
|
|
1464
|
+
...noAutofill,
|
|
1465
|
+
onChange: (event) => model({ ...value.model, [field]: event.target.value || void 0 })
|
|
1466
|
+
}
|
|
1467
|
+
) });
|
|
1468
|
+
}
|
|
1469
|
+
const github = config?.github;
|
|
1470
|
+
function refFromCheck(check, name) {
|
|
1471
|
+
return github?.storage === "inline" ? { kind: "inline", name, content: check.content } : { kind: "github", repository: check.repository, path: check.path, ref: check.commit.sha, ...name ? { name } : {} };
|
|
1472
|
+
}
|
|
1473
|
+
function addRef(section, ref, index) {
|
|
1474
|
+
const refs = section === "skills" ? skills : toolFiles;
|
|
1475
|
+
const issue = section === "skills" ? skillIssue(ref, refs, index ?? refs.length) : githubRefIssue(ref, requireGitHubCommitSha);
|
|
1476
|
+
if (issue) {
|
|
1477
|
+
setError(issue);
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1480
|
+
const next = index === void 0 ? [...refs, ref] : refs.map((item, position) => position === index ? ref : item);
|
|
1481
|
+
return resources(section, next);
|
|
1482
|
+
}
|
|
1483
|
+
function addFile(mount, index) {
|
|
1484
|
+
const issue = fileIssue(mount, index ?? files.length);
|
|
1485
|
+
if (issue) {
|
|
1486
|
+
setError(issue);
|
|
1487
|
+
return false;
|
|
1488
|
+
}
|
|
1489
|
+
return setFiles(index === void 0 ? [...files, mount] : files.map((item, position) => position === index ? mount : item));
|
|
1490
|
+
}
|
|
1491
|
+
function nameField(check, section) {
|
|
1492
|
+
const fieldId = `${id}-${section}-github-name`;
|
|
1493
|
+
const suggested = check ? section === "skills" ? suggestedSkillName(check) : basename(check.path) : "";
|
|
1494
|
+
const name = githubName.touched ? githubName.value : suggested;
|
|
1495
|
+
const problem = section === "skills" && requireUniqueSkillNames && name ? skillIssue({ kind: "inline", name, content: "" }, skills) : null;
|
|
1496
|
+
return /* @__PURE__ */ jsx7(
|
|
1497
|
+
Field,
|
|
1498
|
+
{
|
|
1499
|
+
label: section === "skills" ? "Skill name" : "File name",
|
|
1500
|
+
htmlFor: fieldId,
|
|
1501
|
+
error: problem,
|
|
1502
|
+
hint: section === "skills" && !problem ? "Shown to the agent in its skill list." : void 0,
|
|
1503
|
+
children: /* @__PURE__ */ jsx7(
|
|
1504
|
+
Input5,
|
|
1505
|
+
{
|
|
1506
|
+
id: fieldId,
|
|
1507
|
+
size: "compact",
|
|
1508
|
+
value: name,
|
|
1509
|
+
disabled: editingDisabled || !check,
|
|
1510
|
+
...noAutofill,
|
|
1511
|
+
"aria-invalid": problem ? true : void 0,
|
|
1512
|
+
"aria-describedby": fieldMessageId(fieldId),
|
|
1513
|
+
onChange: (event) => setGithubName({ value: event.target.value, touched: true })
|
|
1514
|
+
}
|
|
1515
|
+
)
|
|
1516
|
+
}
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
function githubNameValue(check, section) {
|
|
1520
|
+
return (githubName.touched ? githubName.value : section === "skills" ? suggestedSkillName(check) : basename(check.path)).trim();
|
|
1521
|
+
}
|
|
1522
|
+
function inlineEditor(section, index) {
|
|
1523
|
+
const prefix = `${id}-${section}-inline`;
|
|
1524
|
+
const isSkill = section === "skills";
|
|
1525
|
+
const isFile = section === "files";
|
|
1526
|
+
const name = inlineDraft.name.trim();
|
|
1527
|
+
const frontmatter = isSkill && inlineDraft.content.trim() ? readSkillFrontmatter(inlineDraft.content) : null;
|
|
1528
|
+
const mount = isFile ? {
|
|
1529
|
+
path: inlineDraft.path.trim(),
|
|
1530
|
+
resource: { kind: "inline", name: name || basename(inlineDraft.path.trim()), content: inlineDraft.content },
|
|
1531
|
+
...inlineDraft.executable ? { executable: true } : {}
|
|
1532
|
+
} : null;
|
|
1533
|
+
const problem = isFile ? inlineDraft.path.trim() ? fileIssue(mount, index ?? files.length) : null : isSkill && name ? skillIssue({ kind: "inline", name, content: inlineDraft.content }, skills, index ?? skills.length) : null;
|
|
1534
|
+
const ready = !editingDisabled && !problem && (isFile ? inlineDraft.path.trim() !== "" : name !== "");
|
|
1535
|
+
return /* @__PURE__ */ jsxs7("div", { className: "space-y-4 rounded-lg border border-border bg-muted/30 p-4", children: [
|
|
1536
|
+
isFile ? /* @__PURE__ */ jsx7(
|
|
1537
|
+
Field,
|
|
1538
|
+
{
|
|
1539
|
+
label: "Workspace path",
|
|
1540
|
+
htmlFor: `${prefix}-path`,
|
|
1541
|
+
error: problem,
|
|
1542
|
+
hint: !problem && workspaceFilePrefix ? `Files go under ${workspaceFilePrefix}` : void 0,
|
|
1543
|
+
children: /* @__PURE__ */ jsx7(
|
|
1544
|
+
Input5,
|
|
1545
|
+
{
|
|
1546
|
+
id: `${prefix}-path`,
|
|
1547
|
+
size: "compact",
|
|
1548
|
+
value: inlineDraft.path,
|
|
1549
|
+
disabled: editingDisabled,
|
|
1550
|
+
...noAutofill,
|
|
1551
|
+
placeholder: (workspaceFilePrefix ?? "") + "guide.md",
|
|
1552
|
+
"aria-invalid": problem ? true : void 0,
|
|
1553
|
+
"aria-describedby": fieldMessageId(`${prefix}-path`),
|
|
1554
|
+
onChange: (event) => setInlineDraft({ ...inlineDraft, path: event.target.value })
|
|
1555
|
+
}
|
|
1556
|
+
)
|
|
1557
|
+
}
|
|
1558
|
+
) : /* @__PURE__ */ jsx7(Field, { label: isSkill ? "Skill name" : "File name", htmlFor: `${prefix}-name`, error: problem, children: /* @__PURE__ */ jsx7(
|
|
1559
|
+
Input5,
|
|
1560
|
+
{
|
|
1561
|
+
id: `${prefix}-name`,
|
|
1562
|
+
size: "compact",
|
|
1563
|
+
value: inlineDraft.name,
|
|
1564
|
+
disabled: editingDisabled,
|
|
1565
|
+
...noAutofill,
|
|
1566
|
+
placeholder: isSkill ? "research" : "search.ts",
|
|
1567
|
+
"aria-invalid": problem ? true : void 0,
|
|
1568
|
+
"aria-describedby": fieldMessageId(`${prefix}-name`),
|
|
1569
|
+
onChange: (event) => setInlineDraft({ ...inlineDraft, name: event.target.value })
|
|
1570
|
+
}
|
|
1571
|
+
) }),
|
|
1572
|
+
/* @__PURE__ */ jsx7(
|
|
1573
|
+
Field,
|
|
1574
|
+
{
|
|
1575
|
+
label: "Content",
|
|
1576
|
+
htmlFor: `${prefix}-content`,
|
|
1577
|
+
hint: frontmatter && !frontmatter.ok ? "Start the skill with frontmatter that sets name and description, so the agent knows when to use it." : void 0,
|
|
1578
|
+
children: /* @__PURE__ */ jsx7(
|
|
1579
|
+
Textarea,
|
|
1580
|
+
{
|
|
1581
|
+
id: `${prefix}-content`,
|
|
1582
|
+
className: "min-h-40 font-mono text-sm leading-6",
|
|
1583
|
+
disabled: editingDisabled,
|
|
1584
|
+
value: inlineDraft.content,
|
|
1585
|
+
onChange: (event) => setInlineDraft({ ...inlineDraft, content: event.target.value })
|
|
1586
|
+
}
|
|
1587
|
+
)
|
|
1588
|
+
}
|
|
1589
|
+
),
|
|
1590
|
+
isFile && (allowExecutableFiles || inlineDraft.executable) && /* @__PURE__ */ jsxs7("label", { className: `flex items-center gap-3 ${formText.body}`, children: [
|
|
1591
|
+
/* @__PURE__ */ jsx7(
|
|
1592
|
+
Switch2,
|
|
1593
|
+
{
|
|
1594
|
+
disabled: editingDisabled || !allowExecutableFiles && !inlineDraft.executable,
|
|
1595
|
+
checked: inlineDraft.executable,
|
|
1596
|
+
onCheckedChange: (executable) => setInlineDraft({ ...inlineDraft, executable })
|
|
1597
|
+
}
|
|
1598
|
+
),
|
|
1599
|
+
"Executable"
|
|
1600
|
+
] }),
|
|
1601
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-2", children: [
|
|
1602
|
+
/* @__PURE__ */ jsx7(Button5, { type: "button", size: "compact", disabled: !ready, onClick: () => {
|
|
1603
|
+
const saved = isFile ? addFile(mount, index) : addRef(section, { kind: "inline", name, content: inlineDraft.content }, index);
|
|
1604
|
+
if (saved) openPanel(null);
|
|
1605
|
+
}, children: index === void 0 ? isSkill ? "Add skill" : "Add file" : "Save" }),
|
|
1606
|
+
/* @__PURE__ */ jsx7(Button5, { type: "button", size: "compact", variant: "ghost", onClick: () => openPanel(null), children: "Cancel" })
|
|
1607
|
+
] })
|
|
1608
|
+
] });
|
|
1609
|
+
}
|
|
1610
|
+
function githubEditor(section, index) {
|
|
1611
|
+
if (!github) return null;
|
|
1612
|
+
const existing = index === void 0 ? void 0 : section === "files" ? files[index]?.resource : (section === "skills" ? skills : toolFiles)[index];
|
|
1613
|
+
const initial = existing?.kind === "github" ? { repository: existing.repository, path: existing.path, ref: existing.ref } : void 0;
|
|
1614
|
+
const isFile = section === "files";
|
|
1615
|
+
const pathId = `${id}-${section}-github-path`;
|
|
1616
|
+
return /* @__PURE__ */ jsx7("div", { className: "rounded-lg border border-border bg-muted/30 p-4", children: /* @__PURE__ */ jsx7(
|
|
1617
|
+
GitHubSourcePicker,
|
|
1618
|
+
{
|
|
1619
|
+
port: github.port,
|
|
1620
|
+
purpose: section === "skills" ? "skill" : "file",
|
|
1621
|
+
disabled: editingDisabled,
|
|
1622
|
+
connectHref: github.connectHref,
|
|
1623
|
+
initial,
|
|
1624
|
+
onCancel: () => openPanel(null),
|
|
1625
|
+
actionLabel: index !== void 0 ? "Save" : section === "skills" ? "Add skill" : "Add file",
|
|
1626
|
+
blocked: isFile && inlineDraft.path.trim() === "" ? "Enter a workspace path." : null,
|
|
1627
|
+
onChoose: ({ check }) => {
|
|
1628
|
+
if (isFile) {
|
|
1629
|
+
const path = inlineDraft.path.trim() || (workspaceFilePrefix ?? "") + basename(check.path);
|
|
1630
|
+
if (addFile({ path, resource: refFromCheck(check, basename(check.path)) }, index)) openPanel(null);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
const name = githubNameValue(check, section);
|
|
1634
|
+
if (addRef(section, refFromCheck(check, name), index)) openPanel(null);
|
|
1635
|
+
},
|
|
1636
|
+
children: (check) => isFile ? /* @__PURE__ */ jsx7(
|
|
1637
|
+
GitHubFilePath,
|
|
1638
|
+
{
|
|
1639
|
+
check,
|
|
1640
|
+
id: pathId,
|
|
1641
|
+
value: inlineDraft.path,
|
|
1642
|
+
prefix: workspaceFilePrefix ?? "",
|
|
1643
|
+
disabled: editingDisabled,
|
|
1644
|
+
onChange: (path) => setInlineDraft((current) => ({ ...current, path })),
|
|
1645
|
+
issue: inlineDraft.path.trim() && check ? fileIssue({ path: inlineDraft.path.trim(), resource: refFromCheck(check, basename(check.path)) }, index ?? files.length) : null
|
|
1646
|
+
}
|
|
1647
|
+
) : nameField(check, section)
|
|
1648
|
+
}
|
|
1649
|
+
) });
|
|
1650
|
+
}
|
|
1651
|
+
function rowActions2(label, section, index, ref) {
|
|
1652
|
+
const canEdit = ref.kind === "inline" || Boolean(github);
|
|
1653
|
+
return /* @__PURE__ */ jsxs7("div", { className: rowActions, children: [
|
|
1654
|
+
canEdit && /* @__PURE__ */ jsx7(
|
|
1655
|
+
Button5,
|
|
1656
|
+
{
|
|
1657
|
+
type: "button",
|
|
1658
|
+
size: "compact",
|
|
1659
|
+
variant: "ghost",
|
|
1660
|
+
disabled: editingDisabled,
|
|
1661
|
+
"aria-label": `Edit ${label}`,
|
|
1662
|
+
onClick: () => openPanel({ kind: "edit", section, index }),
|
|
1663
|
+
children: "Edit"
|
|
1664
|
+
}
|
|
1665
|
+
),
|
|
1666
|
+
/* @__PURE__ */ jsx7(
|
|
1667
|
+
Button5,
|
|
1668
|
+
{
|
|
1669
|
+
type: "button",
|
|
1670
|
+
size: "compact",
|
|
1671
|
+
variant: "ghost",
|
|
1672
|
+
className: "text-destructive hover:text-destructive",
|
|
1673
|
+
disabled: editingDisabled,
|
|
1674
|
+
"aria-label": `Remove ${label}`,
|
|
1675
|
+
onClick: () => {
|
|
1676
|
+
const removed = section === "files" ? setFiles(files.filter((_, item) => item !== index)) : resources(section, (section === "skills" ? skills : toolFiles).filter((_, item) => item !== index));
|
|
1677
|
+
if (removed && panel?.kind === "edit" && panel.section === section) openPanel(null);
|
|
1678
|
+
},
|
|
1679
|
+
children: "Remove"
|
|
1680
|
+
}
|
|
1681
|
+
)
|
|
1682
|
+
] });
|
|
1683
|
+
}
|
|
1684
|
+
function refList(section, refs, noun) {
|
|
1685
|
+
if (refs.length === 0) return /* @__PURE__ */ jsxs7("p", { className: formText.muted, children: [
|
|
1686
|
+
"No ",
|
|
1687
|
+
noun,
|
|
1688
|
+
"s yet."
|
|
1689
|
+
] });
|
|
1690
|
+
return /* @__PURE__ */ jsx7("ul", { className: "divide-y divide-border rounded-lg border border-border", children: refs.map((ref, index) => {
|
|
1691
|
+
const title = ref.name || (ref.kind === "github" ? basename(ref.path) : `${noun} ${index + 1}`);
|
|
1692
|
+
const issue = section === "skills" ? skillIssue(ref, refs, index) : githubRefIssue(ref, requireGitHubCommitSha);
|
|
1693
|
+
const described = ref.kind === "inline" && section === "skills" ? inlineSkillSummary(ref.content) : null;
|
|
1694
|
+
const words = (text) => text.toLowerCase().replace(/[-_\s]+/g, " ").trim();
|
|
1695
|
+
const summary = described && words(described) !== words(title) ? described : null;
|
|
1696
|
+
const editing = panel?.kind === "edit" && panel.section === section && panel.index === index;
|
|
1697
|
+
return /* @__PURE__ */ jsxs7("li", { className: "space-y-3 p-3", "aria-label": `${noun} ${title}`, children: [
|
|
1698
|
+
/* @__PURE__ */ jsxs7("div", { className: listRow, children: [
|
|
1699
|
+
/* @__PURE__ */ jsxs7("div", { className: "min-w-0", children: [
|
|
1700
|
+
/* @__PURE__ */ jsx7("p", { className: `break-words ${formText.label}`, children: title }),
|
|
1701
|
+
summary && /* @__PURE__ */ jsx7("p", { className: `line-clamp-2 ${formText.muted}`, children: summary }),
|
|
1702
|
+
(ref.kind === "github" || !summary) && /* @__PURE__ */ jsx7("p", { className: `break-words ${formText.muted}`, children: sourceLine(ref) }),
|
|
1703
|
+
issue && /* @__PURE__ */ jsx7("p", { className: formText.error, children: issue })
|
|
1704
|
+
] }),
|
|
1705
|
+
rowActions2(title, section, index, ref)
|
|
1706
|
+
] }),
|
|
1707
|
+
editing && (ref.kind === "github" && github ? githubEditor(section, index) : inlineEditor(section, index))
|
|
1708
|
+
] }, `${section}-${index}`);
|
|
1709
|
+
}) });
|
|
1710
|
+
}
|
|
1711
|
+
function addButtons(section, writeLabel) {
|
|
1712
|
+
if (panel && panel.kind !== "edit" && panel.section === section) {
|
|
1713
|
+
return panel.kind === "add-github" ? githubEditor(section) : inlineEditor(section);
|
|
1714
|
+
}
|
|
1715
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-2", children: [
|
|
1716
|
+
github && /* @__PURE__ */ jsx7(
|
|
1717
|
+
Button5,
|
|
1718
|
+
{
|
|
1719
|
+
type: "button",
|
|
1720
|
+
size: "compact",
|
|
1721
|
+
variant: "outline",
|
|
1722
|
+
disabled: editingDisabled,
|
|
1723
|
+
onClick: () => openPanel({ kind: "add-github", section }),
|
|
1724
|
+
children: "Add from GitHub"
|
|
1725
|
+
}
|
|
1726
|
+
),
|
|
1727
|
+
/* @__PURE__ */ jsx7(
|
|
1728
|
+
Button5,
|
|
1729
|
+
{
|
|
1730
|
+
type: "button",
|
|
1731
|
+
size: "compact",
|
|
1732
|
+
variant: "outline",
|
|
1733
|
+
disabled: editingDisabled,
|
|
1734
|
+
onClick: () => openPanel({ kind: "add-inline", section }),
|
|
1735
|
+
children: writeLabel
|
|
1736
|
+
}
|
|
1737
|
+
)
|
|
1738
|
+
] });
|
|
1739
|
+
}
|
|
1740
|
+
const countLabel = (count, noun) => count ? `${count} ${noun}${count === 1 ? "" : "s"}` : void 0;
|
|
1741
|
+
const toolNames = Object.keys(value.tools ?? {});
|
|
1742
|
+
return /* @__PURE__ */ jsx7(TooltipProvider, { delayDuration: 150, children: /* @__PURE__ */ jsxs7("div", { className: `@container/profile-editor min-w-0 space-y-4 ${className ?? ""}`, "aria-label": "Agent profile editor", children: [
|
|
1743
|
+
error && /* @__PURE__ */ jsx7(Notice, { tone: "error", children: error }),
|
|
1744
|
+
jsonDirty && /* @__PURE__ */ jsx7(Notice, { tone: "info", children: "Apply or discard your Advanced JSON edits before changing other fields." }),
|
|
1745
|
+
unsupportedResources.length > 0 && /* @__PURE__ */ jsxs7(Notice, { tone: "error", children: [
|
|
1746
|
+
"This profile has resources this product does not use: ",
|
|
1747
|
+
unsupportedResources.map((kind) => `${RESOURCE_KIND_LABELS[kind]} (${configuredResourceCount(value, kind)})`).join(", "),
|
|
1748
|
+
". Remove them in Advanced JSON before saving."
|
|
1749
|
+
] }),
|
|
1750
|
+
constrainedEntryCount > 0 && /* @__PURE__ */ jsxs7(Notice, { tone: "error", children: [
|
|
1751
|
+
constrainedEntryCount === 1 ? "One resource needs" : `${constrainedEntryCount} resources need`,
|
|
1752
|
+
" a fix before this profile can be saved. The affected rows say what to change."
|
|
1753
|
+
] }),
|
|
1754
|
+
invalidMcpCount > 0 && /* @__PURE__ */ jsxs7(Notice, { tone: "error", children: [
|
|
1755
|
+
invalidMcpCount === 1 ? "One MCP server needs" : `${invalidMcpCount} MCP servers need`,
|
|
1756
|
+
" a public HTTPS address before this profile can be saved."
|
|
1757
|
+
] }),
|
|
1758
|
+
show.identity && /* @__PURE__ */ jsx7(Section, { title: "Identity", children: /* @__PURE__ */ jsxs7("div", { className: formRow, children: [
|
|
1759
|
+
config?.identity?.nameEditable !== false && /* @__PURE__ */ jsx7(Field, { label: "Name", htmlFor: `${id}-name`, children: /* @__PURE__ */ jsx7(
|
|
1760
|
+
Input5,
|
|
1761
|
+
{
|
|
1762
|
+
id: `${id}-name`,
|
|
1763
|
+
size: "compact",
|
|
1764
|
+
disabled: editingDisabled,
|
|
1765
|
+
value: value.name ?? "",
|
|
1766
|
+
...noAutofill,
|
|
1767
|
+
onChange: (event) => emit({ ...value, name: event.target.value })
|
|
1768
|
+
}
|
|
1769
|
+
) }),
|
|
1770
|
+
/* @__PURE__ */ jsx7(Field, { label: "Description", htmlFor: `${id}-description`, children: /* @__PURE__ */ jsx7(
|
|
1771
|
+
Input5,
|
|
1772
|
+
{
|
|
1773
|
+
id: `${id}-description`,
|
|
1774
|
+
size: "compact",
|
|
1775
|
+
disabled: editingDisabled,
|
|
1776
|
+
value: value.description ?? "",
|
|
1777
|
+
...noAutofill,
|
|
1778
|
+
onChange: (event) => emit({ ...value, description: event.target.value })
|
|
1779
|
+
}
|
|
1780
|
+
) })
|
|
1781
|
+
] }) }),
|
|
1782
|
+
show.prompts && /* @__PURE__ */ jsxs7(Section, { title: "Instructions", description: "What the agent is told before every conversation.", children: [
|
|
1783
|
+
/* @__PURE__ */ jsx7(
|
|
1784
|
+
Field,
|
|
1785
|
+
{
|
|
1786
|
+
label: "System prompt",
|
|
1787
|
+
htmlFor: `${id}-system`,
|
|
1788
|
+
info: "Replaces the harness's built-in system prompt. Leave it empty to keep the built-in prompt.",
|
|
1789
|
+
children: /* @__PURE__ */ jsx7(
|
|
1790
|
+
Textarea,
|
|
1791
|
+
{
|
|
1792
|
+
id: `${id}-system`,
|
|
1793
|
+
className: "min-h-52 text-sm leading-6",
|
|
1794
|
+
disabled: editingDisabled,
|
|
1795
|
+
value: value.prompt?.systemPrompt ?? "",
|
|
1796
|
+
onChange: (event) => prompt({ ...value.prompt, systemPrompt: event.target.value })
|
|
1797
|
+
}
|
|
1798
|
+
)
|
|
1799
|
+
}
|
|
1800
|
+
),
|
|
1801
|
+
/* @__PURE__ */ jsxs7("details", { className: "group/more", open: Boolean(value.prompt?.appendSystemPrompt || value.prompt?.instructions?.length) || void 0, children: [
|
|
1802
|
+
/* @__PURE__ */ jsxs7("summary", { className: "flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-md text-sm font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden", children: [
|
|
1803
|
+
/* @__PURE__ */ jsx7("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", className: "size-4 transition-transform group-open/more:rotate-90", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx7("path", { d: "m9 6 6 6-6 6" }) }),
|
|
1804
|
+
"More instructions"
|
|
1805
|
+
] }),
|
|
1806
|
+
/* @__PURE__ */ jsxs7("div", { className: "mt-4 space-y-4", children: [
|
|
1807
|
+
/* @__PURE__ */ jsx7(
|
|
1808
|
+
Field,
|
|
1809
|
+
{
|
|
1810
|
+
label: "Appended prompt",
|
|
1811
|
+
htmlFor: `${id}-append`,
|
|
1812
|
+
info: "Added after the system prompt, or after the built-in prompt when the system prompt is empty.",
|
|
1813
|
+
children: /* @__PURE__ */ jsx7(
|
|
1814
|
+
Textarea,
|
|
1815
|
+
{
|
|
1816
|
+
id: `${id}-append`,
|
|
1817
|
+
size: "compact",
|
|
1818
|
+
className: "min-h-24 text-sm leading-6",
|
|
1819
|
+
disabled: editingDisabled,
|
|
1820
|
+
value: value.prompt?.appendSystemPrompt ?? "",
|
|
1821
|
+
onChange: (event) => prompt({ ...value.prompt, appendSystemPrompt: event.target.value })
|
|
1822
|
+
}
|
|
1823
|
+
)
|
|
1824
|
+
}
|
|
1825
|
+
),
|
|
1826
|
+
/* @__PURE__ */ jsxs7("div", { role: "group", "aria-labelledby": `${id}-instructions-label`, className: "space-y-2", children: [
|
|
1827
|
+
/* @__PURE__ */ jsx7("div", { className: "flex items-center gap-1.5", children: /* @__PURE__ */ jsx7("span", { id: `${id}-instructions-label`, className: formText.label, children: "Project instructions" }) }),
|
|
1828
|
+
/* @__PURE__ */ jsx7("p", { className: formText.muted, children: "Lower-priority guidance the agent reads like a project file." }),
|
|
1829
|
+
(value.prompt?.instructions ?? []).map((instruction, index) => /* @__PURE__ */ jsxs7("div", { className: "flex items-start gap-2", children: [
|
|
1830
|
+
/* @__PURE__ */ jsx7(
|
|
1831
|
+
Textarea,
|
|
1832
|
+
{
|
|
1833
|
+
"aria-label": `Instruction ${index + 1}`,
|
|
1834
|
+
size: "compact",
|
|
1835
|
+
className: "min-h-20 text-sm leading-6",
|
|
1836
|
+
disabled: editingDisabled,
|
|
1837
|
+
value: instruction,
|
|
1838
|
+
onChange: (event) => prompt({ ...value.prompt, instructions: (value.prompt?.instructions ?? []).map((item, i) => i === index ? event.target.value : item) })
|
|
1839
|
+
}
|
|
1840
|
+
),
|
|
1841
|
+
/* @__PURE__ */ jsx7(
|
|
1842
|
+
Button5,
|
|
1843
|
+
{
|
|
1844
|
+
type: "button",
|
|
1845
|
+
size: "compact",
|
|
1846
|
+
variant: "ghost",
|
|
1847
|
+
className: "text-destructive hover:text-destructive",
|
|
1848
|
+
disabled: editingDisabled,
|
|
1849
|
+
"aria-label": `Remove instruction ${index + 1}`,
|
|
1850
|
+
onClick: () => prompt({ ...value.prompt, instructions: (value.prompt?.instructions ?? []).filter((_, i) => i !== index) }),
|
|
1851
|
+
children: "Remove"
|
|
1852
|
+
}
|
|
1853
|
+
)
|
|
1854
|
+
] }, index)),
|
|
1855
|
+
/* @__PURE__ */ jsx7(
|
|
1856
|
+
Button5,
|
|
1857
|
+
{
|
|
1858
|
+
type: "button",
|
|
1859
|
+
size: "compact",
|
|
1860
|
+
variant: "outline",
|
|
1861
|
+
disabled: editingDisabled,
|
|
1862
|
+
onClick: () => prompt({ ...value.prompt, instructions: [...value.prompt?.instructions ?? [], ""] }),
|
|
1863
|
+
children: "Add instruction"
|
|
1864
|
+
}
|
|
1865
|
+
)
|
|
1866
|
+
] })
|
|
1867
|
+
] })
|
|
1868
|
+
] })
|
|
1869
|
+
] }),
|
|
1870
|
+
show.model && /* @__PURE__ */ jsxs7(Section, { title: "Model and runtime", description: "Defaults for conversations and automations that do not choose their own.", children: [
|
|
1871
|
+
/* @__PURE__ */ jsxs7("div", { className: formRow, children: [
|
|
1872
|
+
modelField("Default model", "default", "Runs when a conversation or automation does not pick a model."),
|
|
1873
|
+
config?.harnesses && config.harnesses.length > 0 && /* @__PURE__ */ jsx7(
|
|
1874
|
+
Field,
|
|
1875
|
+
{
|
|
1876
|
+
label: "Harness",
|
|
1877
|
+
htmlFor: `${id}-harness`,
|
|
1878
|
+
info: "The agent runtime that runs this profile, such as OpenCode or Codex.",
|
|
1879
|
+
children: /* @__PURE__ */ jsx7(
|
|
1880
|
+
HarnessPicker,
|
|
1881
|
+
{
|
|
1882
|
+
id: `${id}-harness`,
|
|
1883
|
+
variant: "field",
|
|
1884
|
+
value: harness ?? "",
|
|
1885
|
+
onChange: changeHarness,
|
|
1886
|
+
available: config.harnesses,
|
|
1887
|
+
defaultOption: { label: catalog?.defaultLabel ?? "Product default" },
|
|
1888
|
+
disabled: editingDisabled
|
|
1889
|
+
}
|
|
1890
|
+
)
|
|
1891
|
+
}
|
|
1892
|
+
),
|
|
1893
|
+
/* @__PURE__ */ jsx7(Field, { label: "Thinking", htmlFor: `${id}-thinking`, info: "How hard the agent reasons before answering. Auto lets the harness decide.", children: /* @__PURE__ */ jsx7(
|
|
1894
|
+
EffortPicker,
|
|
1895
|
+
{
|
|
1896
|
+
id: `${id}-thinking`,
|
|
1897
|
+
variant: "field",
|
|
1898
|
+
label: "",
|
|
1899
|
+
value: value.model?.reasoningEffort ?? "auto",
|
|
1900
|
+
levels: thinkingLevels,
|
|
1901
|
+
disabled: editingDisabled,
|
|
1902
|
+
onChange: (level) => model({ ...value.model, reasoningEffort: level === "auto" ? void 0 : level })
|
|
1903
|
+
}
|
|
1904
|
+
) }),
|
|
1905
|
+
modelField("Small model", "small", "A faster model for short tasks such as titles and summaries.")
|
|
1906
|
+
] }),
|
|
1907
|
+
modelNotice && /* @__PURE__ */ jsx7(StatusLine, { tone: "neutral", children: modelNotice })
|
|
1908
|
+
] }),
|
|
1909
|
+
show.tools && /* @__PURE__ */ jsxs7(
|
|
1910
|
+
Section,
|
|
1911
|
+
{
|
|
1912
|
+
title: "Tools and permissions",
|
|
1913
|
+
description: "Which tools the agent may use, and when it must ask first.",
|
|
1914
|
+
collapsible: true,
|
|
1915
|
+
summary: countLabel(toolNames.length, "rule"),
|
|
1916
|
+
children: [
|
|
1917
|
+
toolNames.length === 0 && /* @__PURE__ */ jsx7("p", { className: formText.muted, children: "No tool rules yet." }),
|
|
1918
|
+
toolNames.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "divide-y divide-border rounded-lg border border-border", children: Object.entries(value.tools ?? {}).slice(0, showAllTools ? void 0 : 6).map(([name, enabled]) => {
|
|
1919
|
+
const switchId = `${id}-tool-${name}`;
|
|
1920
|
+
return /* @__PURE__ */ jsxs7("li", { className: "flex flex-wrap items-center gap-3 p-3", children: [
|
|
1921
|
+
/* @__PURE__ */ jsx7(
|
|
1922
|
+
Switch2,
|
|
1923
|
+
{
|
|
1924
|
+
id: switchId,
|
|
1925
|
+
disabled: editingDisabled,
|
|
1926
|
+
checked: enabled,
|
|
1927
|
+
"aria-label": `Allow ${name}`,
|
|
1928
|
+
onCheckedChange: (checked) => emit({ ...value, tools: { ...value.tools, [name]: checked } })
|
|
1929
|
+
}
|
|
1930
|
+
),
|
|
1931
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: switchId, className: `min-w-24 flex-1 break-words ${formText.label}`, children: name }),
|
|
1932
|
+
/* @__PURE__ */ jsxs7(
|
|
1933
|
+
Select2,
|
|
1934
|
+
{
|
|
1935
|
+
disabled: editingDisabled,
|
|
1936
|
+
value: typeof value.permissions?.[name] === "string" ? value.permissions[name] : "default",
|
|
1937
|
+
onValueChange: (permission) => {
|
|
1938
|
+
const permissions = { ...value.permissions };
|
|
1939
|
+
if (permission !== "default") permissions[name] = permission;
|
|
1940
|
+
else delete permissions[name];
|
|
1941
|
+
emit({ ...value, permissions });
|
|
1942
|
+
},
|
|
1943
|
+
children: [
|
|
1944
|
+
/* @__PURE__ */ jsx7(SelectTrigger2, { size: "compact", "aria-label": `Permission for ${name}`, className: "w-36 shadow-none", children: /* @__PURE__ */ jsx7(SelectValue2, {}) }),
|
|
1945
|
+
/* @__PURE__ */ jsxs7(SelectContent2, { children: [
|
|
1946
|
+
/* @__PURE__ */ jsx7(SelectItem2, { value: "default", children: "Default" }),
|
|
1947
|
+
/* @__PURE__ */ jsx7(SelectItem2, { value: "allow", children: "Allow" }),
|
|
1948
|
+
/* @__PURE__ */ jsx7(SelectItem2, { value: "ask", children: "Ask first" }),
|
|
1949
|
+
/* @__PURE__ */ jsx7(SelectItem2, { value: "deny", children: "Deny" })
|
|
1950
|
+
] })
|
|
1951
|
+
]
|
|
1952
|
+
}
|
|
1953
|
+
),
|
|
1954
|
+
/* @__PURE__ */ jsx7(
|
|
1955
|
+
Button5,
|
|
1956
|
+
{
|
|
1957
|
+
type: "button",
|
|
1958
|
+
size: "compact",
|
|
1959
|
+
variant: "ghost",
|
|
1960
|
+
className: "text-destructive hover:text-destructive",
|
|
1961
|
+
disabled: editingDisabled,
|
|
1962
|
+
"aria-label": `Remove ${name}`,
|
|
1963
|
+
onClick: () => {
|
|
1964
|
+
const tools = { ...value.tools };
|
|
1965
|
+
delete tools[name];
|
|
1966
|
+
emit({ ...value, tools });
|
|
1967
|
+
},
|
|
1968
|
+
children: "Remove"
|
|
1969
|
+
}
|
|
1970
|
+
)
|
|
1971
|
+
] }, name);
|
|
1972
|
+
}) }),
|
|
1973
|
+
toolNames.length > 6 && /* @__PURE__ */ jsx7(Button5, { type: "button", size: "compact", variant: "ghost", onClick: () => setShowAllTools((current) => !current), children: showAllTools ? "Show fewer" : `Show ${toolNames.length - 6} more` }),
|
|
1974
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex gap-2", children: [
|
|
1975
|
+
/* @__PURE__ */ jsx7(
|
|
1976
|
+
Input5,
|
|
1977
|
+
{
|
|
1978
|
+
"aria-label": "New tool name",
|
|
1979
|
+
size: "compact",
|
|
1980
|
+
disabled: editingDisabled,
|
|
1981
|
+
value: newTool,
|
|
1982
|
+
placeholder: "Tool name",
|
|
1983
|
+
...noAutofill,
|
|
1984
|
+
onChange: (event) => setNewTool(event.target.value)
|
|
1985
|
+
}
|
|
1986
|
+
),
|
|
1987
|
+
/* @__PURE__ */ jsx7(Button5, { type: "button", size: "compact", variant: "outline", disabled: editingDisabled || !newTool.trim(), onClick: () => {
|
|
1988
|
+
const name = newTool.trim();
|
|
1989
|
+
if (name in (value.tools ?? {})) {
|
|
1990
|
+
setError("A rule for this tool already exists.");
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
if (emit({ ...value, tools: { ...value.tools, [name]: true } })) setNewTool("");
|
|
1994
|
+
}, children: "Add tool" })
|
|
1995
|
+
] }),
|
|
1996
|
+
/* @__PURE__ */ jsx7("p", { className: formText.muted, children: "Nested permission rules are edited in Advanced JSON." })
|
|
1997
|
+
]
|
|
1998
|
+
}
|
|
1999
|
+
),
|
|
2000
|
+
show.skills && /* @__PURE__ */ jsxs7(
|
|
2001
|
+
Section,
|
|
2002
|
+
{
|
|
2003
|
+
title: "Skills",
|
|
2004
|
+
description: "Instructions the agent loads when a task calls for them.",
|
|
2005
|
+
collapsible: true,
|
|
2006
|
+
defaultOpen: skills.length > 0 || panel?.section === "skills",
|
|
2007
|
+
summary: countLabel(skills.length, "skill"),
|
|
2008
|
+
children: [
|
|
2009
|
+
refList("skills", skills, "Skill"),
|
|
2010
|
+
addButtons("skills", "Write a skill"),
|
|
2011
|
+
registry && /* @__PURE__ */ jsx7(
|
|
2012
|
+
AgentProfileRegistrySkillSearch,
|
|
2013
|
+
{
|
|
2014
|
+
registry,
|
|
2015
|
+
disabled: editingDisabled,
|
|
2016
|
+
existing: skills,
|
|
2017
|
+
validate: (ref) => skillIssue(ref, skills, skills.length),
|
|
2018
|
+
onAdd: (ref) => resources("skills", [...skills, ref])
|
|
2019
|
+
}
|
|
2020
|
+
)
|
|
2021
|
+
]
|
|
2022
|
+
}
|
|
2023
|
+
),
|
|
2024
|
+
show.toolFiles && /* @__PURE__ */ jsxs7(
|
|
2025
|
+
Section,
|
|
2026
|
+
{
|
|
2027
|
+
title: "Tool files",
|
|
2028
|
+
description: "Files that define custom tools.",
|
|
2029
|
+
collapsible: true,
|
|
2030
|
+
defaultOpen: toolFiles.length > 0,
|
|
2031
|
+
summary: countLabel(toolFiles.length, "file"),
|
|
2032
|
+
children: [
|
|
2033
|
+
refList("tools", toolFiles, "Tool file"),
|
|
2034
|
+
addButtons("tools", "Write a tool file")
|
|
2035
|
+
]
|
|
2036
|
+
}
|
|
2037
|
+
),
|
|
2038
|
+
show.mcp && /* @__PURE__ */ jsx7(
|
|
2039
|
+
Section,
|
|
2040
|
+
{
|
|
2041
|
+
title: "MCP servers",
|
|
2042
|
+
description: "Tool servers the agent connects to.",
|
|
2043
|
+
collapsible: true,
|
|
2044
|
+
defaultOpen: Object.keys(value.mcp ?? {}).length > 0,
|
|
2045
|
+
summary: countLabel(Object.keys(value.mcp ?? {}).length, "server"),
|
|
2046
|
+
children: /* @__PURE__ */ jsx7(
|
|
2047
|
+
McpServersEditor,
|
|
2048
|
+
{
|
|
2049
|
+
servers: value.mcp ?? {},
|
|
2050
|
+
disabled: editingDisabled,
|
|
2051
|
+
port: config?.mcp?.port,
|
|
2052
|
+
lockReason: config?.mcp?.lockReason,
|
|
2053
|
+
publicHttpsOnly: publicHttpsMcpOnly,
|
|
2054
|
+
allowLocalCommand: config?.mcp?.allowLocalCommand ?? !publicHttpsMcpOnly,
|
|
2055
|
+
registry,
|
|
2056
|
+
onPendingChange: setMcpPending,
|
|
2057
|
+
onChange: (next) => {
|
|
2058
|
+
const { mcp: _mcp, ...rest } = value;
|
|
2059
|
+
return emit(Object.keys(next).length ? { ...value, mcp: next } : rest);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
)
|
|
2063
|
+
}
|
|
2064
|
+
),
|
|
2065
|
+
show.files && /* @__PURE__ */ jsxs7(
|
|
2066
|
+
Section,
|
|
2067
|
+
{
|
|
2068
|
+
title: "Resource files",
|
|
2069
|
+
description: "Reference files placed in the agent's workspace.",
|
|
2070
|
+
collapsible: true,
|
|
2071
|
+
defaultOpen: files.length > 0 || panel?.section === "files",
|
|
2072
|
+
summary: countLabel(files.length, "file"),
|
|
2073
|
+
children: [
|
|
2074
|
+
files.length === 0 && /* @__PURE__ */ jsx7("p", { className: formText.muted, children: "No resource files yet." }),
|
|
2075
|
+
files.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "divide-y divide-border rounded-lg border border-border", children: files.map((mount, index) => {
|
|
2076
|
+
const issue = fileIssue(mount, index);
|
|
2077
|
+
const editing = panel?.kind === "edit" && panel.section === "files" && panel.index === index;
|
|
2078
|
+
return /* @__PURE__ */ jsxs7("li", { className: "space-y-3 p-3", "aria-label": `Resource file ${mount.path}`, children: [
|
|
2079
|
+
/* @__PURE__ */ jsxs7("div", { className: listRow, children: [
|
|
2080
|
+
/* @__PURE__ */ jsxs7("div", { className: "min-w-0", children: [
|
|
2081
|
+
/* @__PURE__ */ jsx7("p", { className: `break-words [overflow-wrap:anywhere] ${formText.label}`, children: mount.path }),
|
|
2082
|
+
/* @__PURE__ */ jsxs7("p", { className: `break-words ${formText.muted}`, children: [
|
|
2083
|
+
sourceLine(mount.resource),
|
|
2084
|
+
mount.executable ? " \xB7 Executable" : ""
|
|
2085
|
+
] }),
|
|
2086
|
+
issue && /* @__PURE__ */ jsx7("p", { className: formText.error, children: issue })
|
|
2087
|
+
] }),
|
|
2088
|
+
rowActions2(mount.path, "files", index, mount.resource)
|
|
2089
|
+
] }),
|
|
2090
|
+
editing && (mount.resource.kind === "github" && github ? githubEditor("files", index) : inlineEditor("files", index))
|
|
2091
|
+
] }, `${mount.path}-${index}`);
|
|
2092
|
+
}) }),
|
|
2093
|
+
panel && panel.kind !== "edit" && panel.section === "files" && addButtons("files", "Write a file"),
|
|
2094
|
+
/* @__PURE__ */ jsx7(
|
|
2095
|
+
ResourceFileDrop,
|
|
2096
|
+
{
|
|
2097
|
+
existingPaths: files.map((mount) => mount.path),
|
|
2098
|
+
pathPrefix: workspaceFilePrefix,
|
|
2099
|
+
limits: config?.files,
|
|
2100
|
+
disabled: editingDisabled,
|
|
2101
|
+
actions: !(panel && panel.kind !== "edit" && panel.section === "files") && /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
2102
|
+
github && /* @__PURE__ */ jsx7(
|
|
2103
|
+
Button5,
|
|
2104
|
+
{
|
|
2105
|
+
type: "button",
|
|
2106
|
+
size: "compact",
|
|
2107
|
+
variant: "outline",
|
|
2108
|
+
disabled: editingDisabled,
|
|
2109
|
+
onClick: () => openPanel({ kind: "add-github", section: "files" }),
|
|
2110
|
+
children: "Add from GitHub"
|
|
2111
|
+
}
|
|
2112
|
+
),
|
|
2113
|
+
/* @__PURE__ */ jsx7(
|
|
2114
|
+
Button5,
|
|
2115
|
+
{
|
|
2116
|
+
type: "button",
|
|
2117
|
+
size: "compact",
|
|
2118
|
+
variant: "outline",
|
|
2119
|
+
disabled: editingDisabled,
|
|
2120
|
+
onClick: () => openPanel({ kind: "add-inline", section: "files" }),
|
|
2121
|
+
children: "Write a file"
|
|
2122
|
+
}
|
|
2123
|
+
)
|
|
2124
|
+
] }),
|
|
2125
|
+
onAdd: (added) => {
|
|
2126
|
+
const mounts = added.map(({ path, file }) => ({ path, resource: { kind: "inline", name: file.name, content: file.content } }));
|
|
2127
|
+
const next = [...files, ...mounts];
|
|
2128
|
+
const issue = mounts.map((mount, offset) => fileIssue(mount, files.length + offset)).find(Boolean);
|
|
2129
|
+
if (issue) return issue;
|
|
2130
|
+
return setFiles(next) ? null : "The profile did not accept these files.";
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
)
|
|
2134
|
+
]
|
|
2135
|
+
}
|
|
2136
|
+
),
|
|
2137
|
+
show.advanced && /* @__PURE__ */ jsxs7(Section, { title: "Advanced JSON", description: "The complete profile, including hooks, modes, connections, and extensions.", collapsible: true, children: [
|
|
2138
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: `${id}-json`, className: "sr-only", children: "Full profile JSON" }),
|
|
2139
|
+
/* @__PURE__ */ jsx7(
|
|
2140
|
+
Textarea,
|
|
2141
|
+
{
|
|
2142
|
+
id: `${id}-json`,
|
|
2143
|
+
className: "min-h-72 font-mono text-sm leading-6",
|
|
2144
|
+
spellCheck: false,
|
|
2145
|
+
disabled,
|
|
2146
|
+
value: json,
|
|
2147
|
+
onChange: (event) => {
|
|
2148
|
+
setJson(event.target.value);
|
|
2149
|
+
setJsonDirty(true);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
),
|
|
2153
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
2154
|
+
/* @__PURE__ */ jsx7(Button5, { type: "button", size: "compact", variant: "outline", disabled: disabled || !jsonDirty, onClick: applyJson, children: "Apply JSON" }),
|
|
2155
|
+
jsonDirty && /* @__PURE__ */ jsx7(
|
|
2156
|
+
Button5,
|
|
2157
|
+
{
|
|
2158
|
+
type: "button",
|
|
2159
|
+
size: "compact",
|
|
2160
|
+
variant: "ghost",
|
|
2161
|
+
className: "text-destructive hover:text-destructive",
|
|
2162
|
+
disabled,
|
|
2163
|
+
onClick: () => {
|
|
2164
|
+
setJson(JSON.stringify(value, null, 2));
|
|
2165
|
+
setJsonDirty(false);
|
|
2166
|
+
setError(null);
|
|
2167
|
+
},
|
|
2168
|
+
children: "Discard JSON edits"
|
|
2169
|
+
}
|
|
2170
|
+
)
|
|
2171
|
+
] }),
|
|
2172
|
+
/* @__PURE__ */ jsx7("p", { className: formText.muted, children: "Reference credentials by secret name; never paste them into a profile." })
|
|
2173
|
+
] })
|
|
2174
|
+
] }) });
|
|
2175
|
+
}
|
|
2176
|
+
function GitHubFilePath({ check, id, value, prefix, disabled, onChange, issue }) {
|
|
2177
|
+
const suggested = check ? prefix + basename(check.path) : "";
|
|
2178
|
+
useEffect4(() => {
|
|
2179
|
+
if (suggested && !value) onChange(suggested);
|
|
2180
|
+
}, [suggested]);
|
|
2181
|
+
return /* @__PURE__ */ jsx7(Field, { label: "Workspace path", htmlFor: id, error: issue, hint: !issue && prefix ? `Files go under ${prefix}` : void 0, children: /* @__PURE__ */ jsx7(
|
|
2182
|
+
Input5,
|
|
2183
|
+
{
|
|
2184
|
+
id,
|
|
2185
|
+
size: "compact",
|
|
2186
|
+
value,
|
|
2187
|
+
disabled: disabled || !check,
|
|
2188
|
+
placeholder: prefix + "guide.md",
|
|
2189
|
+
...noAutofill,
|
|
2190
|
+
"aria-invalid": issue ? true : void 0,
|
|
2191
|
+
"aria-describedby": fieldMessageId(id),
|
|
2192
|
+
onChange: (event) => onChange(event.target.value)
|
|
2193
|
+
}
|
|
2194
|
+
) });
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
export {
|
|
2198
|
+
AgentProfileRegistryError,
|
|
2199
|
+
AGENT_PROFILE_EDITOR_SECTIONS,
|
|
2200
|
+
AgentProfileEditor
|
|
2201
|
+
};
|
|
2202
|
+
//# sourceMappingURL=chunk-6OQYTH7T.js.map
|