@field-studio/react 0.0.0-stage → 0.1.3
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/LICENSE +21 -0
- package/README.md +37 -2
- package/dist/agent/AgentEditor.d.ts +16 -0
- package/dist/agent/AgentEditor.js +51 -0
- package/dist/agent/MCPManager.d.ts +12 -0
- package/dist/agent/MCPManager.js +72 -0
- package/dist/agent/SkillImport.d.ts +8 -0
- package/dist/agent/SkillImport.js +31 -0
- package/dist/agent/SkillViewer.d.ts +7 -0
- package/dist/agent/SkillViewer.js +61 -0
- package/dist/agent/catalog.css +205 -0
- package/dist/agent/index.d.ts +7 -0
- package/dist/agent/index.js +5 -0
- package/dist/agent/skillTitle.d.ts +3 -0
- package/dist/agent/skillTitle.js +4 -0
- package/dist/agent/types.d.ts +46 -0
- package/dist/agent/types.js +1 -0
- package/dist/assistant/AssistantPanel.d.ts +15 -0
- package/dist/assistant/AssistantPanel.js +144 -0
- package/dist/assistant/AssistantProvider.d.ts +119 -0
- package/dist/assistant/AssistantProvider.js +427 -0
- package/dist/assistant/QuestionPanel.d.ts +8 -0
- package/dist/assistant/QuestionPanel.js +32 -0
- package/dist/assistant/TaskComposer.d.ts +25 -0
- package/dist/assistant/TaskComposer.js +354 -0
- package/dist/assistant/TaskFiles.d.ts +24 -0
- package/dist/assistant/TaskFiles.js +107 -0
- package/dist/assistant/assistant.css +428 -0
- package/dist/assistant/composer.css +116 -0
- package/dist/assistant/files.css +19 -0
- package/dist/assistant/index.d.ts +10 -0
- package/dist/assistant/index.js +6 -0
- package/dist/assistant/layout.d.ts +7 -0
- package/dist/assistant/layout.js +19 -0
- package/dist/assistant/messages.d.ts +355 -0
- package/dist/assistant/messages.js +239 -0
- package/dist/assistant/questions.css +6 -0
- package/dist/assistant/types.d.ts +85 -0
- package/dist/assistant/types.js +1 -0
- package/dist/auth/AuthShell.d.ts +34 -0
- package/dist/auth/AuthShell.js +195 -0
- package/dist/auth/RoleManager.d.ts +23 -0
- package/dist/auth/RoleManager.js +95 -0
- package/dist/auth/auth.css +67 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +153 -0
- package/dist/ui/Controls.d.ts +78 -0
- package/dist/ui/Controls.js +234 -0
- package/dist/ui/base.css +261 -0
- package/dist/ui/controls.css +35 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/package.json +69 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrew Lyu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @field-studio/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React 19 providers, hooks, and components for Field Studio. The package uses ESM and is licensed under MIT.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @field-studio/sdk @field-studio/react 'react@^19.0.0' 'react-dom@^19.0.0'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { createWorkspaceClient } from '@field-studio/sdk';
|
|
11
|
+
import { PlatformProvider } from '@field-studio/react';
|
|
12
|
+
|
|
13
|
+
const client = createWorkspaceClient({ fetch: authenticatedFetch });
|
|
14
|
+
<PlatformProvider client={client}><Application /></PlatformProvider>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Memoize the client for the current authenticated host. `usePlatform()` returns that client. `useTaskSubscription(id)` reads authoritative task snapshots and releases timers and pending reads when the task, client, or component changes. Unmount the provider when the authenticated identity changes. The host owns CSRF and session expiry handling.
|
|
18
|
+
|
|
19
|
+
`usePlatformActions()` registers and handles host UI actions. The host reports a tab-local view ID, current revision, and whether unsaved input exists. Registered handlers support navigation, filters, and drafts. The bridge rejects expired and stale actions and dirty views, deduplicates execution, and acknowledges results with a stable intent key. A repeated request retries a failed acknowledgement without running the handler again.
|
|
20
|
+
|
|
21
|
+
| Entry point | Exports |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `@field-studio/react` | `PlatformProvider`, task subscriptions, UI actions, and result review controls |
|
|
24
|
+
| `@field-studio/react/assistant` | `AssistantProvider`, `AssistantPageBinding`, `AssistantPanel`, and `useAssistant()` |
|
|
25
|
+
| `@field-studio/react/agent` | `AgentEditor`, `SkillImport`, `SkillViewer`, and `MCPManager` |
|
|
26
|
+
| `@field-studio/react/auth` | `AuthShell`, `useAuth()`, and role management controls |
|
|
27
|
+
| `@field-studio/react/ui` | `Dialog`, `Select`, `Checkbox`, `RadioGroup`, and `FilePicker` |
|
|
28
|
+
|
|
29
|
+
Place `AssistantProvider` inside `PlatformProvider`. `AssistantPageBinding` accepts the host's `taskInput` and `pageContext`. The assistant supports conversations, delegation, files, questions, and host-rendered result actions, findings, and proposals.
|
|
30
|
+
|
|
31
|
+
The host supplies the catalog callbacks and a browser `GET /auth/login` route that starts OIDC sign-in with Hydra. After the callback establishes the application session, `AuthShell` reads it from `GET /api/auth/me` and sends sign-out to `POST /api/auth/logout`. It attaches CSRF credentials to writes. User management uses the host's `/api/admin/users` and `/api/admin/roles` routes to update existing accounts and roles. Provision identities in Kratos and grant access in Field Studio. The component entry points load their styles when imported.
|
|
32
|
+
|
|
33
|
+
## Migrate from the combined SDK package
|
|
34
|
+
|
|
35
|
+
Install `@field-studio/react` alongside the new `@field-studio/sdk`. Update
|
|
36
|
+
`@field-studio/sdk/react` imports to `@field-studio/react` and keep any trailing
|
|
37
|
+
subpath. For example, `@field-studio/sdk/react/assistant` becomes
|
|
38
|
+
`@field-studio/react/assistant`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import './catalog.css';
|
|
2
|
+
import type { Agent, MCPServer, Skill } from './types.js';
|
|
3
|
+
export type AgentDefinition = Pick<Agent, 'name' | 'role' | 'description'> & {
|
|
4
|
+
skill_ids: string[];
|
|
5
|
+
mcp_server_ids: string[];
|
|
6
|
+
interval_prompt: string;
|
|
7
|
+
web_search_enabled: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** Edit an agent's responsibilities, capabilities and assigned skills. */
|
|
10
|
+
export default function AgentEditor({ agent, skills, mcpServers, onSave, onClose, }: {
|
|
11
|
+
agent?: Agent;
|
|
12
|
+
skills: Skill[];
|
|
13
|
+
mcpServers?: MCPServer[];
|
|
14
|
+
onSave: (definition: AgentDefinition) => Promise<void>;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from '../ui/index.js';
|
|
3
|
+
import './catalog.css';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
/** Edit an agent's responsibilities, capabilities and assigned skills. */
|
|
6
|
+
export default function AgentEditor({ agent, skills, mcpServers = [], onSave, onClose, }) {
|
|
7
|
+
const [draft, setDraft] = useState({
|
|
8
|
+
name: agent?.name ?? '',
|
|
9
|
+
role: agent?.role ?? '',
|
|
10
|
+
description: agent?.description ?? '',
|
|
11
|
+
interval_prompt: agent?.interval_prompt ?? '',
|
|
12
|
+
skill_ids: agent?.skill_ids ?? [],
|
|
13
|
+
mcp_server_ids: agent?.mcp_server_ids ?? [],
|
|
14
|
+
web_search_enabled: agent?.web_search_enabled ?? false,
|
|
15
|
+
});
|
|
16
|
+
const [saving, setSaving] = useState(false);
|
|
17
|
+
const [error, setError] = useState('');
|
|
18
|
+
return (_jsxs("form", { onSubmit: async (event) => {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
if (saving)
|
|
21
|
+
return;
|
|
22
|
+
setSaving(true);
|
|
23
|
+
setError('');
|
|
24
|
+
try {
|
|
25
|
+
await onSave(draft);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
setError(error instanceof Error ? error.message : 'Could not save. Try again.');
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
setSaving(false);
|
|
32
|
+
}
|
|
33
|
+
}, children: [_jsxs("div", { className: "dialog-body", children: [_jsxs("label", { children: ["Name", _jsx("input", { required: true, maxLength: 60, value: draft.name, onChange: (e) => setDraft({ ...draft, name: e.target.value }) })] }), _jsxs("label", { children: ["Role", _jsx("input", { required: true, maxLength: 100, value: draft.role, onChange: (e) => setDraft({ ...draft, role: e.target.value }) })] }), _jsxs("label", { children: ["Responsibilities", _jsx("textarea", { required: true, maxLength: 4000, rows: 5, value: draft.description, onChange: (e) => setDraft({ ...draft, description: e.target.value }) })] }), _jsxs("label", { children: ["Default schedule instruction", _jsx("textarea", { maxLength: 4000, rows: 2, placeholder: "Used when creating a schedule. You can change it in the schedule.", value: draft.interval_prompt, onChange: (e) => setDraft({ ...draft, interval_prompt: e.target.value }) })] }), _jsxs("fieldset", { className: "skill-options", children: [_jsx("legend", { children: "Capabilities" }), _jsxs("label", { children: [_jsx(Checkbox, { checked: draft.web_search_enabled, onChange: (e) => setDraft({ ...draft, web_search_enabled: e.target.checked }) }), _jsxs("span", { children: ["WebSearch", _jsx("small", { children: "Allow native web search and the bound search_web tool. Include links to sources in the answer." })] })] })] }), _jsxs("fieldset", { className: "skill-options", children: [_jsx("legend", { children: "Skills to use" }), skills.length === 0 && (_jsx("p", { className: "muted", children: "No skills yet. Save the agent, then add skills in the library." })), skills.map((skill) => (_jsxs("label", { children: [_jsx(Checkbox, { checked: draft.skill_ids.includes(skill.id), onChange: (e) => setDraft({
|
|
34
|
+
...draft,
|
|
35
|
+
skill_ids: e.target.checked
|
|
36
|
+
? [...draft.skill_ids, skill.id]
|
|
37
|
+
: draft.skill_ids.filter((id) => id !== skill.id),
|
|
38
|
+
}) }), _jsxs("span", { children: [skill.name, _jsx("small", { children: skill.description })] })] }, skill.id)))] }), _jsxs("fieldset", { className: "skill-options", children: [_jsx("legend", { children: "MCP connections" }), mcpServers.length === 0 && (_jsx("p", { className: "muted", children: "No MCP connections. Configure a connection before assigning it to this agent." })), mcpServers.map((server) => (_jsxs("label", { children: [_jsx(Checkbox, { checked: draft.mcp_server_ids.includes(server.id), onChange: (e) => setDraft({
|
|
39
|
+
...draft,
|
|
40
|
+
mcp_server_ids: e.target.checked
|
|
41
|
+
? [...draft.mcp_server_ids, server.id]
|
|
42
|
+
: draft.mcp_server_ids.filter((id) => id !== server.id),
|
|
43
|
+
}) }), _jsxs("span", { children: [server.name, _jsx("small", { children: server.enabled
|
|
44
|
+
? `Enabled · ${server.allowed_tools.length.toLocaleString()} read-only tools`
|
|
45
|
+
: 'Disabled and unavailable during tasks' })] })] }, server.id)))] }), _jsx("p", { className: "muted", children: "Changes apply to future tasks. The AI reads selected skills when needed and uses the read-only tools selected for bound MCP connections." }), error && (_jsx("p", { role: "alert", className: "definition-error", children: error }))] }), _jsxs("div", { className: "dialog-footer", children: [_jsx("button", { type: "button", className: "button", disabled: saving, onClick: onClose, children: "Cancel" }), _jsx("button", { className: "button primary", disabled: saving ||
|
|
46
|
+
!draft.name.trim() ||
|
|
47
|
+
!draft.role.trim() ||
|
|
48
|
+
!draft.description.trim() ||
|
|
49
|
+
draft.skill_ids.length > 20 ||
|
|
50
|
+
draft.mcp_server_ids.length > 10, children: saving ? 'Saving…' : 'Save definition' })] })] }));
|
|
51
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './catalog.css';
|
|
2
|
+
import type { MCPServer, MCPTool } from './types.js';
|
|
3
|
+
type Definition = Omit<MCPServer, 'id' | 'builtin' | 'resource_version'>;
|
|
4
|
+
/** Configure trusted MCP connections and explicitly select read-only tools. */
|
|
5
|
+
export default function MCPManager({ servers, onSave, onTest }: {
|
|
6
|
+
servers: MCPServer[];
|
|
7
|
+
onSave: (id: string | null, definition: Definition) => Promise<void>;
|
|
8
|
+
onTest: (definition: Definition) => Promise<{
|
|
9
|
+
tools: MCPTool[];
|
|
10
|
+
}>;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox, Dialog, Select } from '../ui/index.js';
|
|
3
|
+
import './catalog.css';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
const empty = { name: '', transport: 'http', url: '', command: '', args: [], env: {}, headers: {}, allowed_tools: [], enabled: true };
|
|
6
|
+
/** Configure trusted MCP connections and explicitly select read-only tools. */
|
|
7
|
+
export default function MCPManager({ servers, onSave, onTest }) {
|
|
8
|
+
const [draft, setDraft] = useState(null);
|
|
9
|
+
const [id, setId] = useState(null);
|
|
10
|
+
const [args, setArgs] = useState('[]');
|
|
11
|
+
const [variables, setVariables] = useState('{}');
|
|
12
|
+
const [tools, setTools] = useState([]);
|
|
13
|
+
const [busy, setBusy] = useState(false);
|
|
14
|
+
const [error, setError] = useState('');
|
|
15
|
+
const [tested, setTested] = useState(false);
|
|
16
|
+
const builtin = servers.some(server => server.id === id && server.builtin);
|
|
17
|
+
const open = (server) => {
|
|
18
|
+
setId(server?.id ?? null);
|
|
19
|
+
setDraft(server ? { ...server } : { ...empty });
|
|
20
|
+
setArgs(JSON.stringify(server?.args ?? [], null, 2));
|
|
21
|
+
setVariables(JSON.stringify(server?.transport === 'stdio' ? server.env : server?.headers ?? {}, null, 2));
|
|
22
|
+
setTools((server?.allowed_tools ?? []).map(name => ({ name, description: 'Saved tools. Test the connection again for the latest list', read_only: true })));
|
|
23
|
+
setError('');
|
|
24
|
+
setTested(false);
|
|
25
|
+
};
|
|
26
|
+
const close = () => { setDraft(null); };
|
|
27
|
+
const connectionChanged = () => { setTools([]); setTested(false); setDraft(d => d && ({ ...d, allowed_tools: [] })); };
|
|
28
|
+
const definition = () => {
|
|
29
|
+
const parsedArgs = JSON.parse(args), parsedVars = JSON.parse(variables);
|
|
30
|
+
if (!Array.isArray(parsedArgs) || !parsedArgs.every(x => typeof x === 'string'))
|
|
31
|
+
throw new Error('Startup arguments must be a JSON string array');
|
|
32
|
+
if (!parsedVars || typeof parsedVars !== 'object' || Array.isArray(parsedVars) || !Object.values(parsedVars).every(x => typeof x === 'string'))
|
|
33
|
+
throw new Error('The environment variable mapping must be a JSON string object');
|
|
34
|
+
const { id: ignored, builtin: ignoredBuiltin, resource_version: ignoredVersion, ...body } = draft;
|
|
35
|
+
void ignored;
|
|
36
|
+
void ignoredBuiltin;
|
|
37
|
+
void ignoredVersion;
|
|
38
|
+
return { ...body, args: body.transport === 'stdio' ? parsedArgs : [], env: body.transport === 'stdio' ? parsedVars : {}, headers: body.transport === 'http' ? parsedVars : {} };
|
|
39
|
+
};
|
|
40
|
+
return _jsxs("section", { className: "mcp-manager", "aria-labelledby": "mcp-title", children: [_jsxs("div", { className: "mcp-toolbar", children: [_jsxs("div", { children: [_jsx("h2", { id: "mcp-title", children: "MCP connections" }), _jsx("p", { className: "muted", children: "Connect trusted services to provide external query tools for agents." })] }), _jsx("button", { className: "button", disabled: busy, onClick: () => open(), children: "Add MCP" })] }), !servers.length && _jsx("p", { className: "muted", children: "No MCP. Add a connection, then bind it in the agent definition." }), servers.map(server => _jsxs("div", { className: "mcp-row", children: [_jsxs("div", { children: [_jsxs("h3", { children: [server.name, " ", server.builtin && _jsx("span", { className: "tag", children: "Built-in" })] }), _jsx("p", { children: server.transport === 'http' ? server.url : server.command }), _jsxs("small", { children: [server.enabled ? 'Enabled' : 'Disabled', " \u00B7 ", server.allowed_tools.length.toLocaleString(), " tools selected"] })] }), _jsx("button", { className: "button small", "aria-label": `Configure ${server.name}`, disabled: busy, onClick: () => open(server), children: "Configure connection" })] }, server.id)), draft && _jsx(Dialog, { title: id ? 'Edit MCP' : 'Add MCP', closeLabel: "Close MCP dialog", className: "definition-dialog", onClose: () => { if (!busy)
|
|
41
|
+
close(); }, children: _jsxs("form", { onSubmit: async (e) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
setBusy(true);
|
|
44
|
+
setError('');
|
|
45
|
+
try {
|
|
46
|
+
await onSave(id, definition());
|
|
47
|
+
close();
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
setError(e instanceof Error ? e.message : 'Save failed');
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
setBusy(false);
|
|
54
|
+
}
|
|
55
|
+
}, children: [_jsxs("fieldset", { disabled: busy, className: "dialog-body", children: [_jsxs("label", { children: ["Connection name", _jsx("input", { disabled: builtin, required: true, maxLength: 60, value: draft.name, onChange: e => setDraft({ ...draft, name: e.target.value }) })] }), _jsxs("label", { children: ["Transport", _jsxs(Select, { disabled: builtin, value: draft.transport, onChange: e => { setDraft({ ...draft, transport: e.target.value, command: '', url: '', args: [], env: {}, headers: {}, allowed_tools: [] }); setArgs('[]'); setVariables('{}'); setTools([]); setTested(false); }, children: [_jsx("option", { value: "http", children: "Streamable HTTP" }), _jsx("option", { value: "stdio", children: "Local stdio" })] })] }), draft.transport === 'http' ? _jsxs("label", { children: ["MCP URL", _jsx("input", { disabled: builtin, required: true, type: "url", value: draft.url, placeholder: "http://127.0.0.1:9100/mcp", onChange: e => { setDraft({ ...draft, url: e.target.value }); connectionChanged(); } })] }) : _jsxs(_Fragment, { children: [_jsxs("label", { children: ["Startup command", _jsx("input", { required: true, value: draft.command, placeholder: "Path to an executable, such as /path/to/python", onChange: e => { setDraft({ ...draft, command: e.target.value }); connectionChanged(); } })] }), _jsxs("label", { children: ["Startup arguments (JSON array)", _jsx("textarea", { rows: 3, value: args, onChange: e => { setArgs(e.target.value); connectionChanged(); } })] }), _jsx("p", { className: "muted", children: "Testing or running tasks starts this program. Configure only trusted local MCP services." })] }), _jsxs("label", { children: [draft.transport === 'http' ? 'Request headers → server environment variables (JSON)' : 'Process variables → server environment variables (JSON)', _jsx("textarea", { disabled: builtin, rows: 3, value: variables, onChange: e => { setVariables(e.target.value); connectionChanged(); } })] }), _jsxs("p", { className: "muted", children: ["For example, ", draft.transport === 'http' ? '{"Authorization":"MCP_AUTH_HEADER"}' : '{"API_KEY":"MCP_API_KEY"}', ". Set the values on the server. Authorization must begin with the Bearer prefix."] }), _jsx("button", { type: "button", className: "button", disabled: !draft.name.trim() || !(draft.transport === 'http' ? draft.url : draft.command).trim(), onClick: async () => {
|
|
56
|
+
setBusy(true);
|
|
57
|
+
setError('');
|
|
58
|
+
try {
|
|
59
|
+
const response = await onTest(definition());
|
|
60
|
+
setTools(response.tools);
|
|
61
|
+
setTested(true);
|
|
62
|
+
if (!builtin)
|
|
63
|
+
setDraft(d => d && ({ ...d, allowed_tools: d.allowed_tools.filter(name => response.tools.some(t => t.name === name && t.read_only)) }));
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
setError(e instanceof Error ? e.message : 'Connection failed');
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
setBusy(false);
|
|
70
|
+
}
|
|
71
|
+
}, children: busy ? 'Working…' : 'Test connection and load tools' }), tested && _jsxs("p", { role: "status", children: ["Connected. Found ", tools.length.toLocaleString(), " tools"] }), _jsxs("fieldset", { className: "skill-options", children: [_jsx("legend", { children: "Tools the agent can use" }), !tools.length && _jsx("p", { className: "muted", children: "Select tools after testing the connection. AI has no tools available by default." }), tools.map(tool => _jsxs("label", { children: [_jsx(Checkbox, { disabled: builtin || !tool.read_only, checked: draft.allowed_tools.includes(tool.name), onChange: e => setDraft({ ...draft, allowed_tools: e.target.checked ? [...draft.allowed_tools, tool.name] : draft.allowed_tools.filter(n => n !== tool.name) }) }), _jsxs("span", { children: [tool.name, _jsxs("small", { children: [tool.description, !tool.read_only && ' (unavailable because it is not declared read-only)'] })] })] }, tool.name))] }), _jsxs("label", { className: "mcp-enabled", children: [_jsx(Checkbox, { checked: draft.enabled, onChange: e => setDraft({ ...draft, enabled: e.target.checked }) }), "Enable this connection"] }), error && _jsx("p", { role: "alert", className: "definition-error", children: error })] }), _jsxs("div", { className: "dialog-footer", children: [_jsx("button", { type: "button", className: "button", disabled: busy, onClick: close, children: "Cancel" }), _jsx("button", { type: "submit", className: "button primary", disabled: busy || !draft.name.trim(), children: "Save MCP" })] })] }) })] });
|
|
72
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './catalog.css';
|
|
2
|
+
/** Upload one agent-skills ZIP package; the only skill entry point. */
|
|
3
|
+
export default function SkillImport({ onImport }: {
|
|
4
|
+
onImport: (body: {
|
|
5
|
+
filename: string;
|
|
6
|
+
content_base64: string;
|
|
7
|
+
}) => Promise<void>;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import './catalog.css';
|
|
4
|
+
import { Upload } from 'lucide-react';
|
|
5
|
+
/** Upload one agent-skills ZIP package; the only skill entry point. */
|
|
6
|
+
export default function SkillImport({ onImport }) {
|
|
7
|
+
const input = useRef(null);
|
|
8
|
+
const [busy, setBusy] = useState(false);
|
|
9
|
+
const [error, setError] = useState('');
|
|
10
|
+
const pick = async (file) => {
|
|
11
|
+
if (!file)
|
|
12
|
+
return;
|
|
13
|
+
setBusy(true);
|
|
14
|
+
setError('');
|
|
15
|
+
try {
|
|
16
|
+
if (!file.name.toLowerCase().endsWith('.zip'))
|
|
17
|
+
throw new Error('Only ZIP skill packages containing exactly one SKILL.md are supported');
|
|
18
|
+
const content_base64 = await new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = () => resolve(String(reader.result).split(',')[1]); reader.onerror = () => reject(new Error('Could not read the file')); reader.readAsDataURL(file); });
|
|
19
|
+
await onImport({ filename: file.name, content_base64 });
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
setError(e instanceof Error ? e.message : 'Import failed');
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
setBusy(false);
|
|
26
|
+
if (input.current)
|
|
27
|
+
input.current.value = '';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return _jsxs("div", { className: "skill-import", children: [_jsx("input", { ref: input, type: "file", accept: ".zip", hidden: true, disabled: busy, onChange: e => { void pick(e.target.files?.[0]); } }), _jsxs("button", { className: "button", disabled: busy, onClick: () => input.current?.click(), children: [_jsx(Upload, { size: 14 }), busy ? 'Importing…' : 'Upload skill'] }), error && _jsx("p", { role: "alert", className: "definition-error", children: error })] });
|
|
31
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import './catalog.css';
|
|
2
|
+
import type { Skill } from './types.js';
|
|
3
|
+
/** Browse an imported skill package as a file tree over the SKILL.md body and resources. */
|
|
4
|
+
export default function SkillViewer({ skill, onClose }: {
|
|
5
|
+
skill: Skill;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ChevronDown, ChevronRight } from 'lucide-react';
|
|
4
|
+
import { Dialog } from '../ui/index.js';
|
|
5
|
+
import './catalog.css';
|
|
6
|
+
import { skillTitle } from './skillTitle.js';
|
|
7
|
+
const IMAGE_MIME = {
|
|
8
|
+
png: 'image/png',
|
|
9
|
+
jpg: 'image/jpeg',
|
|
10
|
+
jpeg: 'image/jpeg',
|
|
11
|
+
gif: 'image/gif',
|
|
12
|
+
webp: 'image/webp',
|
|
13
|
+
svg: 'image/svg+xml',
|
|
14
|
+
};
|
|
15
|
+
const extension = (path) => path.split('.').pop()?.toLowerCase() ?? '';
|
|
16
|
+
function insert(tree, path, prefix) {
|
|
17
|
+
const parts = path.split('/');
|
|
18
|
+
let node = tree;
|
|
19
|
+
let current = prefix;
|
|
20
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
21
|
+
current = current ? `${current}/${parts[i]}` : parts[i];
|
|
22
|
+
if (!node.dirs.has(parts[i]))
|
|
23
|
+
node.dirs.set(parts[i], { tree: { dirs: new Map(), files: [] }, path: current });
|
|
24
|
+
node = node.dirs.get(parts[i]).tree;
|
|
25
|
+
}
|
|
26
|
+
node.files.push(path);
|
|
27
|
+
}
|
|
28
|
+
function TreeBranch({ tree, depth, selected, collapsed, onToggle, onSelect, }) {
|
|
29
|
+
return (_jsxs(_Fragment, { children: [[...tree.dirs.entries()].map(([name, { tree: sub, path }]) => (_jsxs("li", { children: [_jsxs("button", { type: "button", className: "skill-tree-dir", style: { paddingLeft: depth * 14 + 10 }, "aria-expanded": !collapsed.has(path), onClick: () => onToggle(path), children: [collapsed.has(path) ? _jsx(ChevronRight, { size: 12, "aria-hidden": "true" }) : _jsx(ChevronDown, { size: 12, "aria-hidden": "true" }), name] }), !collapsed.has(path) && (_jsx("ul", { role: "group", children: _jsx(TreeBranch, { tree: sub, depth: depth + 1, selected: selected, collapsed: collapsed, onToggle: onToggle, onSelect: onSelect }) }))] }, name))), tree.files.map(path => (_jsx("li", { children: _jsx("button", { type: "button", className: path === selected ? 'active' : '', style: { paddingLeft: depth * 14 + 28 }, "aria-current": path === selected || undefined, onClick: () => onSelect(path), children: path.split('/').pop() }) }, path)))] }));
|
|
30
|
+
}
|
|
31
|
+
/** Browse an imported skill package as a file tree over the SKILL.md body and resources. */
|
|
32
|
+
export default function SkillViewer({ skill, onClose }) {
|
|
33
|
+
const text = skill.resources ?? {};
|
|
34
|
+
const binary = skill.binary_resources ?? {};
|
|
35
|
+
const tree = { dirs: new Map(), files: [] };
|
|
36
|
+
insert(tree, 'SKILL.md', '');
|
|
37
|
+
for (const path of Object.keys(text))
|
|
38
|
+
insert(tree, path, '');
|
|
39
|
+
for (const path of Object.keys(binary))
|
|
40
|
+
insert(tree, path, '');
|
|
41
|
+
const [selected, setSelected] = useState('SKILL.md');
|
|
42
|
+
const [collapsed, setCollapsed] = useState(new Set());
|
|
43
|
+
const isText = selected !== 'SKILL.md' && selected in text;
|
|
44
|
+
const mime = selected in binary ? IMAGE_MIME[extension(selected)] : undefined;
|
|
45
|
+
const toggle = (path) => setCollapsed(current => {
|
|
46
|
+
const next = new Set(current);
|
|
47
|
+
if (next.has(path))
|
|
48
|
+
next.delete(path);
|
|
49
|
+
else
|
|
50
|
+
next.add(path);
|
|
51
|
+
return next;
|
|
52
|
+
});
|
|
53
|
+
const preview = selected === 'SKILL.md'
|
|
54
|
+
? _jsx("pre", { "aria-label": "SKILL.md Content", children: skill.instructions })
|
|
55
|
+
: isText
|
|
56
|
+
? _jsx("pre", { "aria-label": `${selected} Content`, children: text[selected] })
|
|
57
|
+
: mime
|
|
58
|
+
? _jsx("img", { src: `data:${mime};base64,${binary[selected]}`, alt: selected })
|
|
59
|
+
: _jsxs("div", { className: "skill-viewer-binary", children: [_jsx("p", { children: "Binary reference file. Text preview is unavailable." }), _jsxs("a", { className: "button small", download: selected, href: `data:application/octet-stream;base64,${binary[selected]}`, children: ["Download ", selected] })] });
|
|
60
|
+
return (_jsx(Dialog, { title: skillTitle(skill), closeLabel: "Close skill details", onClose: onClose, className: "skill-viewer", children: _jsxs("div", { className: "skill-viewer-body", children: [_jsx("div", { className: "skill-viewer-tree", children: _jsx("ul", { "aria-label": "Files in package", children: _jsx(TreeBranch, { tree: tree, depth: 0, selected: selected, collapsed: collapsed, onToggle: toggle, onSelect: setSelected }) }) }), _jsx("div", { className: "skill-viewer-preview", children: preview })] }) }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
.mcp-manager {
|
|
2
|
+
margin: 24px 0;
|
|
3
|
+
padding: 20px;
|
|
4
|
+
border: 1px solid #e3e9f1;
|
|
5
|
+
background: white;
|
|
6
|
+
border-radius: 10px;
|
|
7
|
+
}
|
|
8
|
+
.mcp-toolbar {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
gap: 16px;
|
|
13
|
+
margin-bottom: 18px;
|
|
14
|
+
}
|
|
15
|
+
.mcp-toolbar p {
|
|
16
|
+
margin-top: 6px;
|
|
17
|
+
font-size: 12px;
|
|
18
|
+
}
|
|
19
|
+
.mcp-toolbar .button {
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
}
|
|
22
|
+
.mcp-toolbar h2 {
|
|
23
|
+
font-size: 18px;
|
|
24
|
+
}
|
|
25
|
+
.mcp-row {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
gap: 16px;
|
|
30
|
+
padding: 16px 0;
|
|
31
|
+
border-top: 1px solid #edf1f5;
|
|
32
|
+
}
|
|
33
|
+
.mcp-row > div {
|
|
34
|
+
min-width: 0;
|
|
35
|
+
overflow-wrap: anywhere;
|
|
36
|
+
}
|
|
37
|
+
.mcp-row .button {
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
}
|
|
40
|
+
.mcp-row p {
|
|
41
|
+
font-size: 12px;
|
|
42
|
+
color: #586b83;
|
|
43
|
+
margin: 6px 0;
|
|
44
|
+
}
|
|
45
|
+
@media (max-width: 600px) {
|
|
46
|
+
.mcp-toolbar {
|
|
47
|
+
align-items: flex-start;
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
}
|
|
50
|
+
.mcp-manager {
|
|
51
|
+
padding: 16px;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
.dialog-body .mcp-enabled {
|
|
55
|
+
flex-direction: row;
|
|
56
|
+
align-items: center;
|
|
57
|
+
}
|
|
58
|
+
.skill-import {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
align-items: flex-end;
|
|
62
|
+
gap: 6px;
|
|
63
|
+
max-width: 380px;
|
|
64
|
+
text-align: right;
|
|
65
|
+
}
|
|
66
|
+
.skill-import p {
|
|
67
|
+
margin: 0;
|
|
68
|
+
font-size: 12px;
|
|
69
|
+
}
|
|
70
|
+
.definition-dialog {
|
|
71
|
+
width: 560px;
|
|
72
|
+
}
|
|
73
|
+
.definition-dialog textarea {
|
|
74
|
+
resize: vertical;
|
|
75
|
+
min-height: 64px;
|
|
76
|
+
}
|
|
77
|
+
.skill-options {
|
|
78
|
+
border: 1px solid #e3e9f1;
|
|
79
|
+
padding: 12px;
|
|
80
|
+
border-radius: 6px;
|
|
81
|
+
min-width: 0;
|
|
82
|
+
}
|
|
83
|
+
.skill-options legend {
|
|
84
|
+
font-size: 12px;
|
|
85
|
+
color: #586b83;
|
|
86
|
+
padding: 0 5px;
|
|
87
|
+
}
|
|
88
|
+
.skill-options label {
|
|
89
|
+
flex-direction: row;
|
|
90
|
+
align-items: flex-start;
|
|
91
|
+
padding: 8px 0;
|
|
92
|
+
gap: 10px;
|
|
93
|
+
overflow-wrap: anywhere;
|
|
94
|
+
}
|
|
95
|
+
.skill-options input {
|
|
96
|
+
width: auto;
|
|
97
|
+
margin-top: 3px;
|
|
98
|
+
flex-shrink: 0;
|
|
99
|
+
}
|
|
100
|
+
.skill-options small {
|
|
101
|
+
display: block;
|
|
102
|
+
margin-top: 4px;
|
|
103
|
+
}
|
|
104
|
+
.definition-error {
|
|
105
|
+
color: #b42318;
|
|
106
|
+
font-size: 13px;
|
|
107
|
+
}
|
|
108
|
+
.skill-options > label, .dialog-body .mcp-enabled { min-height: 40px; }
|
|
109
|
+
.dialog.skill-viewer {
|
|
110
|
+
width: min(960px, calc(100vw - 32px));
|
|
111
|
+
}
|
|
112
|
+
.skill-viewer-body {
|
|
113
|
+
display: grid;
|
|
114
|
+
grid-template-columns: 232px minmax(0, 1fr);
|
|
115
|
+
height: min(76vh, 720px);
|
|
116
|
+
min-height: 420px;
|
|
117
|
+
}
|
|
118
|
+
.skill-viewer-tree {
|
|
119
|
+
min-width: 0;
|
|
120
|
+
overflow: auto;
|
|
121
|
+
padding: 8px;
|
|
122
|
+
border-right: 1px solid #eef2f7;
|
|
123
|
+
}
|
|
124
|
+
.skill-viewer-tree ul {
|
|
125
|
+
list-style: none;
|
|
126
|
+
margin: 0;
|
|
127
|
+
padding: 0;
|
|
128
|
+
}
|
|
129
|
+
.skill-viewer-tree ul[role="group"] {
|
|
130
|
+
padding-left: 0;
|
|
131
|
+
}
|
|
132
|
+
.skill-viewer-tree li {
|
|
133
|
+
display: block;
|
|
134
|
+
}
|
|
135
|
+
.skill-viewer-tree button {
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
gap: 5px;
|
|
139
|
+
width: 100%;
|
|
140
|
+
padding: 6px 10px;
|
|
141
|
+
padding-left: 10px;
|
|
142
|
+
border-radius: 7px;
|
|
143
|
+
text-align: left;
|
|
144
|
+
font-size: 12px;
|
|
145
|
+
color: #33455c;
|
|
146
|
+
overflow-wrap: anywhere;
|
|
147
|
+
}
|
|
148
|
+
.skill-viewer-tree button svg {
|
|
149
|
+
flex-shrink: 0;
|
|
150
|
+
color: #8a97a8;
|
|
151
|
+
}
|
|
152
|
+
.skill-viewer-tree button:hover {
|
|
153
|
+
background: #f4f8fe;
|
|
154
|
+
}
|
|
155
|
+
.skill-viewer-tree button.active {
|
|
156
|
+
background: #edf3ff;
|
|
157
|
+
color: #2456bf;
|
|
158
|
+
}
|
|
159
|
+
.skill-tree-dir {
|
|
160
|
+
font-weight: 600;
|
|
161
|
+
color: #4b5d75;
|
|
162
|
+
}
|
|
163
|
+
.skill-viewer-preview {
|
|
164
|
+
display: flex;
|
|
165
|
+
flex-direction: column;
|
|
166
|
+
min-width: 0;
|
|
167
|
+
overflow: auto;
|
|
168
|
+
padding: 14px 16px;
|
|
169
|
+
}
|
|
170
|
+
.skill-viewer-preview pre {
|
|
171
|
+
flex: 1;
|
|
172
|
+
margin: 0;
|
|
173
|
+
white-space: pre-wrap;
|
|
174
|
+
overflow-wrap: anywhere;
|
|
175
|
+
font-size: 12px;
|
|
176
|
+
line-height: 1.65;
|
|
177
|
+
color: #2c3e57;
|
|
178
|
+
}
|
|
179
|
+
.skill-viewer-preview img {
|
|
180
|
+
max-width: 100%;
|
|
181
|
+
align-self: flex-start;
|
|
182
|
+
border: 1px solid #e4eaf2;
|
|
183
|
+
border-radius: 8px;
|
|
184
|
+
}
|
|
185
|
+
.skill-viewer-binary {
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-direction: column;
|
|
188
|
+
gap: 10px;
|
|
189
|
+
align-items: flex-start;
|
|
190
|
+
color: #586b83;
|
|
191
|
+
font-size: 12px;
|
|
192
|
+
}
|
|
193
|
+
@media (max-width: 600px) {
|
|
194
|
+
.skill-viewer-body {
|
|
195
|
+
grid-template-columns: 1fr;
|
|
196
|
+
grid-template-rows: auto minmax(180px, 1fr);
|
|
197
|
+
height: auto;
|
|
198
|
+
max-height: min(80vh, 640px);
|
|
199
|
+
}
|
|
200
|
+
.skill-viewer-tree {
|
|
201
|
+
border-right: 0;
|
|
202
|
+
border-bottom: 1px solid #eef2f7;
|
|
203
|
+
max-height: 168px;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { Agent, MCPServer, MCPTool, Skill, } from './types.js';
|
|
2
|
+
export { default as AgentEditor } from './AgentEditor.js';
|
|
3
|
+
export type { AgentDefinition } from './AgentEditor.js';
|
|
4
|
+
export { default as MCPManager } from './MCPManager.js';
|
|
5
|
+
export { default as SkillImport } from './SkillImport.js';
|
|
6
|
+
export { default as SkillViewer } from './SkillViewer.js';
|
|
7
|
+
export { skillTitle } from './skillTitle.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as AgentEditor } from './AgentEditor.js';
|
|
2
|
+
export { default as MCPManager } from './MCPManager.js';
|
|
3
|
+
export { default as SkillImport } from './SkillImport.js';
|
|
4
|
+
export { default as SkillViewer } from './SkillViewer.js';
|
|
5
|
+
export { skillTitle } from './skillTitle.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface Agent {
|
|
2
|
+
archived?: boolean;
|
|
3
|
+
archived_at?: string | null;
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
role: string;
|
|
7
|
+
description: string;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
interval_minutes: number;
|
|
10
|
+
interval_prompt?: string;
|
|
11
|
+
last_run_at: string | null;
|
|
12
|
+
tools: string[];
|
|
13
|
+
skill_ids?: string[];
|
|
14
|
+
mcp_server_ids?: string[];
|
|
15
|
+
web_search_enabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface Skill {
|
|
18
|
+
id: string;
|
|
19
|
+
package_name?: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
instructions: string;
|
|
23
|
+
resources?: Record<string, string>;
|
|
24
|
+
binary_resources?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
export interface MCPServer {
|
|
27
|
+
resource_version?: number;
|
|
28
|
+
requires_web_search?: boolean;
|
|
29
|
+
builtin?: boolean;
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
transport: 'stdio' | 'http';
|
|
33
|
+
command: string;
|
|
34
|
+
args: string[];
|
|
35
|
+
url: string;
|
|
36
|
+
env: Record<string, string>;
|
|
37
|
+
headers: Record<string, string>;
|
|
38
|
+
allowed_tools: string[];
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface MCPTool {
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
read_only: boolean;
|
|
45
|
+
input_schema?: unknown;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AssistantApi } from './AssistantProvider.js';
|
|
2
|
+
import type { Analysis, Task } from './types.js';
|
|
3
|
+
import { type ReactNode } from 'react';
|
|
4
|
+
export interface AssistantPanelProps {
|
|
5
|
+
hiddenEventMessages?: readonly string[];
|
|
6
|
+
renderResultAction?: (result: Analysis) => ReactNode;
|
|
7
|
+
renderFindingAction?: (finding: Analysis['findings'][number]) => ReactNode;
|
|
8
|
+
renderProposals?: (props: {
|
|
9
|
+
task: Task;
|
|
10
|
+
busy: boolean;
|
|
11
|
+
onAction: AssistantApi['decide'];
|
|
12
|
+
}) => ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/** The dockable assistant sidepanel: conversation, waits, proposals and composer. */
|
|
15
|
+
export default function AssistantPanel({ hiddenEventMessages, renderResultAction, renderFindingAction, renderProposals, }: AssistantPanelProps): import("react").JSX.Element;
|