@field-studio/sdk 0.0.0-stage → 0.1.0
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 +131 -2
- package/dist/index.d.ts +97 -0
- package/dist/index.js +129 -0
- package/dist/node/identity.d.ts +89 -0
- package/dist/node/identity.js +1 -0
- package/dist/node/index.d.ts +41 -0
- package/dist/node/index.js +165 -0
- package/dist/react/agent/AgentEditor.d.ts +16 -0
- package/dist/react/agent/AgentEditor.js +51 -0
- package/dist/react/agent/MCPManager.d.ts +12 -0
- package/dist/react/agent/MCPManager.js +72 -0
- package/dist/react/agent/SkillImport.d.ts +8 -0
- package/dist/react/agent/SkillImport.js +31 -0
- package/dist/react/agent/SkillViewer.d.ts +7 -0
- package/dist/react/agent/SkillViewer.js +61 -0
- package/dist/react/agent/catalog.css +205 -0
- package/dist/react/agent/index.d.ts +7 -0
- package/dist/react/agent/index.js +5 -0
- package/dist/react/agent/skillTitle.d.ts +3 -0
- package/dist/react/agent/skillTitle.js +4 -0
- package/dist/react/agent/types.d.ts +46 -0
- package/dist/react/agent/types.js +1 -0
- package/dist/react/assistant/AssistantPanel.d.ts +15 -0
- package/dist/react/assistant/AssistantPanel.js +144 -0
- package/dist/react/assistant/AssistantProvider.d.ts +119 -0
- package/dist/react/assistant/AssistantProvider.js +427 -0
- package/dist/react/assistant/QuestionPanel.d.ts +8 -0
- package/dist/react/assistant/QuestionPanel.js +32 -0
- package/dist/react/assistant/TaskComposer.d.ts +25 -0
- package/dist/react/assistant/TaskComposer.js +354 -0
- package/dist/react/assistant/TaskFiles.d.ts +24 -0
- package/dist/react/assistant/TaskFiles.js +107 -0
- package/dist/react/assistant/assistant.css +428 -0
- package/dist/react/assistant/composer.css +116 -0
- package/dist/react/assistant/files.css +19 -0
- package/dist/react/assistant/index.d.ts +10 -0
- package/dist/react/assistant/index.js +6 -0
- package/dist/react/assistant/layout.d.ts +7 -0
- package/dist/react/assistant/layout.js +19 -0
- package/dist/react/assistant/messages.d.ts +355 -0
- package/dist/react/assistant/messages.js +239 -0
- package/dist/react/assistant/questions.css +6 -0
- package/dist/react/assistant/types.d.ts +85 -0
- package/dist/react/assistant/types.js +1 -0
- package/dist/react/auth/AuthShell.d.ts +37 -0
- package/dist/react/auth/AuthShell.js +287 -0
- package/dist/react/auth/RoleManager.d.ts +23 -0
- package/dist/react/auth/RoleManager.js +95 -0
- package/dist/react/auth/auth.css +76 -0
- package/dist/react/auth/index.d.ts +2 -0
- package/dist/react/auth/index.js +1 -0
- package/dist/react/index.d.ts +57 -0
- package/dist/react/index.js +177 -0
- package/dist/react/ui/Controls.d.ts +78 -0
- package/dist/react/ui/Controls.js +234 -0
- package/dist/react/ui/base.css +261 -0
- package/dist/react/ui/controls.css +35 -0
- package/dist/react/ui/index.d.ts +2 -0
- package/dist/react/ui/index.js +2 -0
- package/dist/workspace.d.ts +107 -0
- package/dist/workspace.js +139 -0
- package/package.json +86 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import './auth.css';
|
|
3
|
+
import { type RoleDataScopeConfig } from './RoleManager.js';
|
|
4
|
+
export type User = {
|
|
5
|
+
id: string;
|
|
6
|
+
username: string;
|
|
7
|
+
display_name: string;
|
|
8
|
+
role: string;
|
|
9
|
+
role_name?: string;
|
|
10
|
+
permissions?: string[];
|
|
11
|
+
status: 'active' | 'disabled';
|
|
12
|
+
must_change_password: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type Session = {
|
|
15
|
+
user: User;
|
|
16
|
+
csrf_token: string;
|
|
17
|
+
};
|
|
18
|
+
export type AuthHandle = {
|
|
19
|
+
user: User;
|
|
20
|
+
fetch: typeof fetch;
|
|
21
|
+
error: string;
|
|
22
|
+
openUserManagement: () => void;
|
|
23
|
+
openPasswordChange: () => void;
|
|
24
|
+
logout: () => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
export declare const AuthContext: import("react").Context<AuthHandle | null>;
|
|
27
|
+
/** Account session and actions for host-app chrome; null outside an authenticated AuthShell. */
|
|
28
|
+
export declare function useAuth(): AuthHandle | null;
|
|
29
|
+
/** Keep private screens behind a server session and attach CSRF to same-origin API writes. */
|
|
30
|
+
export default function AuthShell({ children, brand, tagline, sessionEventKey, loginDescription, roleDataScope, }: {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
brand?: string;
|
|
33
|
+
tagline?: string;
|
|
34
|
+
sessionEventKey?: string;
|
|
35
|
+
loginDescription?: string;
|
|
36
|
+
roleDataScope?: RoleDataScopeConfig;
|
|
37
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useCallback, useRef, useState, } from 'react';
|
|
3
|
+
import './auth.css';
|
|
4
|
+
import { Dialog, Select } from '../ui/index.js';
|
|
5
|
+
import RoleManager from './RoleManager.js';
|
|
6
|
+
export const AuthContext = createContext(null);
|
|
7
|
+
/** Account session and actions for host-app chrome; null outside an authenticated AuthShell. */
|
|
8
|
+
export function useAuth() {
|
|
9
|
+
return useContext(AuthContext);
|
|
10
|
+
}
|
|
11
|
+
async function readResponse(response) {
|
|
12
|
+
if (response.status === 204)
|
|
13
|
+
return null;
|
|
14
|
+
const data = await response.json().catch(() => ({}));
|
|
15
|
+
if (!response.ok)
|
|
16
|
+
throw new Error(typeof data.detail === 'string' ? data.detail : 'Action failed. Try again');
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
/** Keep private screens behind a server session and attach CSRF to same-origin API writes. */
|
|
20
|
+
export default function AuthShell({ children, brand = 'Field Studio', tagline = '', sessionEventKey = 'field-studio-auth-event', loginDescription = 'Sign in to manage your agents, tasks, and workspace files.', roleDataScope, }) {
|
|
21
|
+
const [session, setSession] = useState(null);
|
|
22
|
+
const [loading, setLoading] = useState(true);
|
|
23
|
+
const [error, setError] = useState('');
|
|
24
|
+
const [view, setView] = useState('app');
|
|
25
|
+
const [epoch, setEpoch] = useState(0);
|
|
26
|
+
const sessionRef = useRef(null);
|
|
27
|
+
const original = useRef(globalThis.fetch);
|
|
28
|
+
const generation = useRef(0);
|
|
29
|
+
function establish(next, announce = false) {
|
|
30
|
+
generation.current += 1;
|
|
31
|
+
sessionRef.current = next;
|
|
32
|
+
setSession(next);
|
|
33
|
+
setEpoch((v) => v + 1);
|
|
34
|
+
setView('app');
|
|
35
|
+
setError('');
|
|
36
|
+
if (announce) {
|
|
37
|
+
try {
|
|
38
|
+
window.localStorage.setItem(sessionEventKey, `${Date.now()}:${Math.random()}`);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
/* Storage may be unavailable in a restricted browser. */
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const authenticatedFetch = useCallback(async (input, init) => {
|
|
46
|
+
const url = new URL(typeof input === 'string' ? input : input instanceof URL ? input.href : input.url, window.location.href);
|
|
47
|
+
if (url.origin !== window.location.origin || !url.pathname.startsWith('/api/'))
|
|
48
|
+
throw new Error('The request URL is outside this application');
|
|
49
|
+
const method = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase();
|
|
50
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
51
|
+
if (!['GET', 'HEAD', 'OPTIONS'].includes(method) && sessionRef.current)
|
|
52
|
+
headers.set('X-CSRF-Token', sessionRef.current.csrf_token);
|
|
53
|
+
const started = generation.current;
|
|
54
|
+
const response = await original.current.call(globalThis, input, {
|
|
55
|
+
...init,
|
|
56
|
+
headers,
|
|
57
|
+
credentials: 'same-origin',
|
|
58
|
+
redirect: 'error',
|
|
59
|
+
});
|
|
60
|
+
if (response.status === 401 && sessionRef.current && started === generation.current)
|
|
61
|
+
establish(null, true);
|
|
62
|
+
return response;
|
|
63
|
+
}, [sessionEventKey]);
|
|
64
|
+
async function load() {
|
|
65
|
+
setLoading(true);
|
|
66
|
+
setError('');
|
|
67
|
+
const started = generation.current;
|
|
68
|
+
try {
|
|
69
|
+
const response = await original.current.call(globalThis, '/api/auth/me', {
|
|
70
|
+
credentials: 'same-origin',
|
|
71
|
+
cache: 'no-store',
|
|
72
|
+
});
|
|
73
|
+
if (started !== generation.current)
|
|
74
|
+
return;
|
|
75
|
+
if (response.status === 401)
|
|
76
|
+
establish(null);
|
|
77
|
+
else
|
|
78
|
+
establish(await readResponse(response));
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
setError(e instanceof Error ? e.message : 'Could not connect to the service');
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
setLoading(false);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const changed = (event) => {
|
|
89
|
+
if (event.key !== sessionEventKey)
|
|
90
|
+
return;
|
|
91
|
+
establish(null);
|
|
92
|
+
void load();
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener('storage', changed);
|
|
95
|
+
void load();
|
|
96
|
+
return () => window.removeEventListener('storage', changed);
|
|
97
|
+
}, [sessionEventKey]);
|
|
98
|
+
async function request(url, method = 'GET', body) {
|
|
99
|
+
return readResponse(await authenticatedFetch(url, {
|
|
100
|
+
method,
|
|
101
|
+
headers: body ? { 'Content-Type': 'application/json' } : undefined,
|
|
102
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
if (loading)
|
|
106
|
+
return (_jsx("main", { className: "auth-loading", role: "status", children: "Checking sign-in\u2026" }));
|
|
107
|
+
if (!session)
|
|
108
|
+
return (_jsx(Login, { brand: brand, tagline: tagline, description: loginDescription, error: error, onRetry: load, onLogin: async (username, password) => establish(await request('/api/auth/login', 'POST', { username, password }), true), onReset: async (token, password) => {
|
|
109
|
+
await request('/api/auth/reset-password', 'POST', { token, password });
|
|
110
|
+
} }));
|
|
111
|
+
const mustChange = session.user.must_change_password;
|
|
112
|
+
const logout = async () => {
|
|
113
|
+
try {
|
|
114
|
+
await request('/api/auth/logout', 'POST');
|
|
115
|
+
establish(null, true);
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
setError(e instanceof Error ? e.message : 'Sign-out failed');
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const handle = {
|
|
122
|
+
user: session.user,
|
|
123
|
+
fetch: authenticatedFetch,
|
|
124
|
+
error,
|
|
125
|
+
openUserManagement: () => setView('users'),
|
|
126
|
+
openPasswordChange: () => setView('password'),
|
|
127
|
+
logout,
|
|
128
|
+
};
|
|
129
|
+
return (_jsxs("div", { className: "authenticated-shell", children: [(mustChange || view !== 'app') && (_jsxs("header", { className: "account-bar", children: [_jsx("span", { children: _jsx("strong", { children: session.user.display_name || session.user.username }) }), !mustChange && view !== 'app' && (_jsx("nav", { "aria-label": "Account actions", children: _jsx("button", { className: "button small", onClick: () => setView('app'), children: "Back to workspace" }) }))] })), error && (_jsx("p", { className: "auth-error", role: "alert", children: error })), mustChange || view === 'password' ? (_jsx(PasswordForm, { required: mustChange, onSave: async (old_password, new_password) => {
|
|
130
|
+
await request('/api/auth/password', 'POST', { old_password, new_password });
|
|
131
|
+
establish(null, true);
|
|
132
|
+
} })) : view === 'users' ? (_jsx(UserManager, { currentUserId: session.user.id, request: request, roleDataScope: roleDataScope })) : (_jsx(AuthContext.Provider, { value: handle, children: _jsx("div", { className: "private-application", children: children }, epoch) }))] }));
|
|
133
|
+
}
|
|
134
|
+
function Login({ brand, tagline, description, error, onRetry, onLogin, onReset, }) {
|
|
135
|
+
const [username, setUsername] = useState('');
|
|
136
|
+
const [password, setPassword] = useState('');
|
|
137
|
+
const [token, setToken] = useState('');
|
|
138
|
+
const [reset, setReset] = useState(false);
|
|
139
|
+
const [busy, setBusy] = useState(false);
|
|
140
|
+
const [issue, setIssue] = useState('');
|
|
141
|
+
const [notice, setNotice] = useState('');
|
|
142
|
+
return (_jsx("main", { className: "auth-page", children: _jsxs("section", { className: "auth-panel", children: [_jsxs("a", { className: "auth-brand", href: "/", children: [brand, " ", _jsx("span", { children: tagline })] }), _jsx("h1", { children: reset ? 'Reset password' : 'Sign in to the workspace' }), _jsx("p", { className: "auth-description", children: reset
|
|
143
|
+
? 'Enter the one-time token from your administrator to set a new password.'
|
|
144
|
+
: description }), (issue || error) && (_jsx("p", { className: "auth-error", role: "alert", children: issue || error })), notice && _jsx("p", { role: "status", children: notice }), _jsxs("form", { onSubmit: async (e) => {
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
setBusy(true);
|
|
147
|
+
setIssue('');
|
|
148
|
+
try {
|
|
149
|
+
if (reset) {
|
|
150
|
+
await onReset(token, password);
|
|
151
|
+
setReset(false);
|
|
152
|
+
setPassword('');
|
|
153
|
+
setToken('');
|
|
154
|
+
setNotice('Password updated. Sign in.');
|
|
155
|
+
}
|
|
156
|
+
else
|
|
157
|
+
await onLogin(username, password);
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
setIssue(e instanceof Error ? e.message : 'Sign-in failed');
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
setBusy(false);
|
|
164
|
+
}
|
|
165
|
+
}, children: [reset ? (_jsxs("label", { children: ["Reset token", _jsx("input", { required: true, autoComplete: "off", value: token, onChange: (e) => setToken(e.target.value) })] })) : (_jsxs("label", { children: ["Username", _jsx("input", { required: true, autoComplete: "username", value: username, onChange: (e) => setUsername(e.target.value) })] })), _jsxs("label", { children: [reset ? 'New password' : 'Password', _jsx("input", { type: "password", required: true, minLength: reset ? 12 : undefined, maxLength: 128, autoComplete: reset ? 'new-password' : 'current-password', value: password, onChange: (e) => setPassword(e.target.value) })] }), _jsx("button", { className: "button primary auth-submit", disabled: busy, children: busy ? 'Submitting…' : reset ? 'Set new password' : 'Sign in' })] }), _jsxs("div", { className: "auth-links", children: [_jsx("button", { type: "button", onClick: () => {
|
|
166
|
+
setReset(!reset);
|
|
167
|
+
setIssue('');
|
|
168
|
+
setPassword('');
|
|
169
|
+
setNotice('');
|
|
170
|
+
}, children: reset ? 'Back to sign-in' : 'Use a reset token' }), error && _jsx("button", { onClick: () => void onRetry(), children: "Reconnect" })] }), _jsx("p", { className: "auth-help", children: "Administrators create accounts. Contact an administrator for an account or reset token." })] }) }));
|
|
171
|
+
}
|
|
172
|
+
function PasswordForm({ required, onSave, }) {
|
|
173
|
+
const [old, setOld] = useState('');
|
|
174
|
+
const [next, setNext] = useState('');
|
|
175
|
+
const [confirm, setConfirm] = useState('');
|
|
176
|
+
const [busy, setBusy] = useState(false);
|
|
177
|
+
const [error, setError] = useState('');
|
|
178
|
+
return (_jsxs("main", { className: "auth-settings", children: [_jsx("h1", { children: required ? 'Change your password first' : 'Change password' }), _jsx("p", { children: "Changing your password ends all sessions. Sign in again afterward." }), _jsxs("form", { className: "auth-panel", onSubmit: async (e) => {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
if (next !== confirm) {
|
|
181
|
+
setError('The new passwords do not match');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
setBusy(true);
|
|
185
|
+
setError('');
|
|
186
|
+
try {
|
|
187
|
+
await onSave(old, next);
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
setError(e instanceof Error ? e.message : 'Update failed');
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
setBusy(false);
|
|
194
|
+
}
|
|
195
|
+
}, children: [_jsxs("label", { children: ["Current password", _jsx("input", { required: true, type: "password", autoComplete: "current-password", value: old, onChange: (e) => setOld(e.target.value) })] }), _jsxs("label", { children: ["New password", _jsx("input", { required: true, minLength: 12, maxLength: 128, type: "password", autoComplete: "new-password", value: next, onChange: (e) => setNext(e.target.value) })] }), _jsxs("label", { children: ["Confirm new password", _jsx("input", { required: true, minLength: 12, maxLength: 128, type: "password", autoComplete: "new-password", value: confirm, onChange: (e) => setConfirm(e.target.value) })] }), error && (_jsx("p", { className: "auth-error", role: "alert", children: error })), _jsx("button", { className: "button primary", disabled: busy, children: "Save new password" })] })] }));
|
|
196
|
+
}
|
|
197
|
+
const defaultRoles = [
|
|
198
|
+
{ id: 'member', name: 'Member' },
|
|
199
|
+
{ id: 'admin', name: 'Administrator' },
|
|
200
|
+
];
|
|
201
|
+
function UserManager({ currentUserId, request, roleDataScope, }) {
|
|
202
|
+
const [users, setUsers] = useState([]);
|
|
203
|
+
const [roles, setRoles] = useState(null);
|
|
204
|
+
const [error, setError] = useState('');
|
|
205
|
+
const [busy, setBusy] = useState(false);
|
|
206
|
+
const [loading, setLoading] = useState(true);
|
|
207
|
+
const [page, setPage] = useState(0);
|
|
208
|
+
const [total, setTotal] = useState(0);
|
|
209
|
+
const [creating, setCreating] = useState(false);
|
|
210
|
+
const [username, setUsername] = useState('');
|
|
211
|
+
const [name, setName] = useState('');
|
|
212
|
+
const [password, setPassword] = useState('');
|
|
213
|
+
const [role, setRole] = useState('member');
|
|
214
|
+
const [reset, setReset] = useState(null);
|
|
215
|
+
async function reloadRoles() {
|
|
216
|
+
const result = await request('/api/admin/roles');
|
|
217
|
+
if (Array.isArray(result))
|
|
218
|
+
setRoles(result);
|
|
219
|
+
}
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
void reloadRoles().catch(setErrorFromRequest);
|
|
222
|
+
}, []);
|
|
223
|
+
function setErrorFromRequest(error) {
|
|
224
|
+
if (roleDataScope)
|
|
225
|
+
setError(error instanceof Error ? error.message : 'Could not load roles');
|
|
226
|
+
}
|
|
227
|
+
async function refresh() {
|
|
228
|
+
const result = await request(`/api/admin/users${page ? `?offset=${page * 50}&limit=50` : ''}`);
|
|
229
|
+
setUsers(result.users);
|
|
230
|
+
setTotal(result.total);
|
|
231
|
+
}
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
let active = true;
|
|
234
|
+
setLoading(true);
|
|
235
|
+
refresh()
|
|
236
|
+
.catch((e) => {
|
|
237
|
+
if (active)
|
|
238
|
+
setError(e.message);
|
|
239
|
+
})
|
|
240
|
+
.finally(() => {
|
|
241
|
+
if (active)
|
|
242
|
+
setLoading(false);
|
|
243
|
+
});
|
|
244
|
+
return () => {
|
|
245
|
+
active = false;
|
|
246
|
+
};
|
|
247
|
+
}, [page]);
|
|
248
|
+
async function action(fn) {
|
|
249
|
+
setBusy(true);
|
|
250
|
+
setError('');
|
|
251
|
+
try {
|
|
252
|
+
await fn();
|
|
253
|
+
await refresh();
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
setError(e instanceof Error ? e.message : 'Action failed');
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
setBusy(false);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return (_jsxs("main", { className: "auth-settings user-management", children: [_jsx("h1", { children: "User management" }), _jsx("p", { children: "Manage platform accounts. Each user has separate agents, tasks, and files." }), error && (_jsx("p", { className: "auth-error", role: "alert", children: error })), reset && (_jsxs("aside", { className: "reset-receipt", role: "status", children: [_jsxs("strong", { children: [reset.username, "'s one-time reset token"] }), _jsx("code", { children: reset.token }), _jsx("p", { children: "Send this token through a secure channel. It is only shown on this page." }), _jsx("button", { className: "button small", onClick: () => setReset(null), children: "Close reset token" })] })), _jsxs("section", { className: "auth-user-section", children: [_jsxs("div", { className: "user-list-header", children: [_jsxs("h2", { children: ["Accounts", ' ', _jsxs("span", { className: "account-scope", children: [total.toLocaleString(), " users"] })] }), _jsx("button", { className: "button", disabled: busy, onClick: () => setCreating(true), children: "Add user" })] }), loading ? (_jsx("p", { role: "status", children: "Loading users\u2026" })) : !users.length ? (_jsx("p", { children: "No users yet" })) : (_jsx("div", { className: "auth-table-scroll", children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Username" }), _jsx("th", { children: "Name" }), _jsx("th", { children: "Role" }), _jsx("th", { children: "Status" }), _jsx("th", { children: "Actions" })] }) }), _jsx("tbody", { children: users.map((user) => (_jsx(UserRow, { user: user, self: currentUserId === user.id, busy: busy, roles: roles ?? defaultRoles, onEdit: (changes) => action(async () => {
|
|
263
|
+
await request(`/api/admin/users/${user.id}`, 'PATCH', changes);
|
|
264
|
+
}), onReset: () => action(async () => {
|
|
265
|
+
const result = await request(`/api/admin/users/${user.id}/reset-password`, 'POST');
|
|
266
|
+
setReset({ username: user.username, token: result.token });
|
|
267
|
+
}) }, user.id))) })] }) })), _jsxs("div", { className: "user-pagination", children: [_jsx("button", { className: "button small", disabled: !page || busy, onClick: () => setPage((p) => p - 1), children: "Previous page" }), _jsxs("span", { children: ["Page ", page + 1] }), _jsx("button", { className: "button small", disabled: (page + 1) * 50 >= total || busy, onClick: () => setPage((p) => p + 1), children: "Next page" })] })] }), roles && _jsx(RoleManager, { roles: roles, reload: reloadRoles, request: request, dataScope: roleDataScope }), creating && (_jsx(Dialog, { title: "Create user", onClose: () => setCreating(false), children: _jsxs("form", { onSubmit: (e) => {
|
|
268
|
+
e.preventDefault();
|
|
269
|
+
void action(async () => {
|
|
270
|
+
await request('/api/admin/users', 'POST', {
|
|
271
|
+
username,
|
|
272
|
+
display_name: name,
|
|
273
|
+
password,
|
|
274
|
+
role,
|
|
275
|
+
});
|
|
276
|
+
setCreating(false);
|
|
277
|
+
setUsername('');
|
|
278
|
+
setName('');
|
|
279
|
+
setPassword('');
|
|
280
|
+
});
|
|
281
|
+
}, children: [_jsxs("div", { className: "dialog-body", children: [_jsxs("label", { children: ["New username", _jsx("input", { required: true, autoComplete: "off", value: username, onChange: (e) => setUsername(e.target.value) })] }), _jsxs("label", { children: ["New user name", _jsx("input", { required: true, value: name, onChange: (e) => setName(e.target.value) })] }), _jsxs("label", { children: ["Initial password", _jsx("input", { required: true, type: "password", minLength: 12, maxLength: 128, autoComplete: "new-password", value: password, onChange: (e) => setPassword(e.target.value) })] }), _jsxs("label", { children: ["New user role", _jsx(Select, { "aria-label": "New user role", value: role, onChange: (e) => setRole(e.target.value), children: (roles ?? defaultRoles).map((role) => _jsx("option", { value: role.id, children: role.name }, role.id)) })] }), error && (_jsx("p", { className: "auth-error", role: "alert", children: error }))] }), _jsxs("div", { className: "dialog-footer", children: [_jsx("button", { type: "button", className: "button", disabled: busy, onClick: () => setCreating(false), children: "Cancel" }), _jsx("button", { className: "button primary", disabled: busy, children: "Create user" })] })] }) }))] }));
|
|
282
|
+
}
|
|
283
|
+
function UserRow({ user, self, busy, roles, onEdit, onReset, }) {
|
|
284
|
+
const [name, setName] = useState(user.display_name);
|
|
285
|
+
useEffect(() => setName(user.display_name), [user.display_name]);
|
|
286
|
+
return (_jsxs("tr", { children: [_jsxs("td", { children: [user.username, self && ' (you)'] }), _jsx("td", { children: _jsxs("div", { className: "user-name-editor", children: [_jsx("input", { "aria-label": `${user.username}'s name`, value: name, onChange: (e) => setName(e.target.value) }), _jsx("button", { className: "button small", disabled: busy || !name.trim() || name === user.display_name, onClick: () => void onEdit({ display_name: name }), children: "Save name" })] }) }), _jsx("td", { children: _jsx(Select, { "aria-label": `${user.username}'s role`, disabled: busy || (user.role === 'admin' && !self), value: user.role, onChange: (e) => void onEdit({ role: e.target.value }), children: roles.map((role) => _jsx("option", { value: role.id, children: role.name }, role.id)) }) }), _jsx("td", { children: user.status === 'active' ? 'Enabled' : 'Disabled' }), _jsx("td", { children: _jsxs("div", { className: "action-row user-actions", children: [_jsx("button", { className: "button small", disabled: busy, onClick: () => void onEdit({ status: user.status === 'active' ? 'disabled' : 'active' }), children: user.status === 'active' ? 'Disable' : 'Enable' }), _jsx("button", { className: "button small", disabled: busy || self, "aria-label": `Reset ${user.username}'s password`, onClick: () => void onReset(), children: "Reset password" })] }) })] }));
|
|
287
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type Scope = {
|
|
2
|
+
read: string[] | null;
|
|
3
|
+
write: string[] | null;
|
|
4
|
+
};
|
|
5
|
+
export type Role = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
permissions: string[];
|
|
9
|
+
app_scopes: Record<string, Scope>;
|
|
10
|
+
};
|
|
11
|
+
export type RoleDataScopeConfig = {
|
|
12
|
+
appId: string;
|
|
13
|
+
label: string;
|
|
14
|
+
optionsEndpoint: string;
|
|
15
|
+
};
|
|
16
|
+
type Requester = (path: string, method?: string, body?: unknown) => Promise<unknown>;
|
|
17
|
+
export default function RoleManager({ roles, reload, request, dataScope, }: {
|
|
18
|
+
roles: Role[];
|
|
19
|
+
reload: () => Promise<void>;
|
|
20
|
+
request: Requester;
|
|
21
|
+
dataScope?: RoleDataScopeConfig;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { Checkbox, Dialog } from '../ui/index.js';
|
|
4
|
+
const permissions = [
|
|
5
|
+
['tasks.run', 'Use the AI assistant and run agents'],
|
|
6
|
+
['tasks.approve', 'Approve business proposals'],
|
|
7
|
+
['catalog.manage', 'Manage agents, skills, and connectors'],
|
|
8
|
+
['automations.manage', 'Manage automations'],
|
|
9
|
+
];
|
|
10
|
+
export default function RoleManager({ roles, reload, request, dataScope, }) {
|
|
11
|
+
const [editing, setEditing] = useState(null);
|
|
12
|
+
const [scoping, setScoping] = useState(null);
|
|
13
|
+
const [name, setName] = useState('');
|
|
14
|
+
const [selected, setSelected] = useState([]);
|
|
15
|
+
const [busy, setBusy] = useState(false);
|
|
16
|
+
const [error, setError] = useState('');
|
|
17
|
+
const [deleting, setDeleting] = useState(false);
|
|
18
|
+
function edit(role) {
|
|
19
|
+
setName(role === 'new' ? '' : role.name);
|
|
20
|
+
setSelected(role === 'new' ? [] : role.permissions);
|
|
21
|
+
setError('');
|
|
22
|
+
setDeleting(false);
|
|
23
|
+
setEditing(role);
|
|
24
|
+
}
|
|
25
|
+
async function save(path, method, body) {
|
|
26
|
+
setBusy(true);
|
|
27
|
+
setError('');
|
|
28
|
+
try {
|
|
29
|
+
await request(path, method, body);
|
|
30
|
+
await reload();
|
|
31
|
+
setEditing(null);
|
|
32
|
+
setScoping(null);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
setError(e instanceof Error ? e.message : 'Save failed');
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
setBusy(false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return (_jsxs("section", { className: "auth-user-section", "aria-label": "Role permissions", children: [_jsxs("div", { className: "user-list-header", children: [_jsx("h2", { children: "Role permissions" }), _jsx("button", { className: "button", onClick: () => edit('new'), children: "Add role" })] }), _jsx("div", { className: "auth-table-scroll", children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Role" }), _jsx("th", { children: "Platform permissions" }), _jsx("th", { children: "Actions" })] }) }), _jsx("tbody", { children: roles.map((role) => (_jsxs("tr", { children: [_jsx("td", { children: role.name }), _jsx("td", { children: permissions.filter(([key]) => role.permissions.includes(key)).map(([, label]) => label).join(', ') || 'None' }), _jsx("td", { children: _jsxs("div", { className: "action-row", children: [role.id !== 'admin' && (_jsx("button", { className: "button small", onClick: () => edit(role), "aria-label": `Edit ${role.name}'s permissions`, children: "Edit permissions" })), dataScope && (_jsx("button", { className: "button small", "aria-label": `Edit ${role.name}'s data permissions`, onClick: () => {
|
|
42
|
+
setError('');
|
|
43
|
+
setScoping(role);
|
|
44
|
+
}, children: dataScope.label }))] }) })] }, role.id))) })] }) }), editing && (_jsx(Dialog, { title: editing === 'new' ? 'Add role' : `Edit ${editing.name}`, closeDisabled: busy, onClose: () => setEditing(null), children: _jsxs("form", { onSubmit: (event) => {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
const updating = editing !== 'new';
|
|
47
|
+
void save(updating ? `/api/admin/roles/${editing.id}` : '/api/admin/roles', updating ? 'PATCH' : 'POST', {
|
|
48
|
+
name: name.trim(), permissions: selected,
|
|
49
|
+
});
|
|
50
|
+
}, children: [_jsxs("div", { className: "dialog-body", children: [_jsxs("label", { children: ["Role name", _jsx("input", { required: true, maxLength: 80, value: name, onChange: (event) => setName(event.target.value) })] }), permissions.map(([key, label]) => (_jsxs("label", { className: "role-permission", children: [_jsx(Checkbox, { checked: selected.includes(key), onChange: ({ target }) => {
|
|
51
|
+
setSelected((previous) => target.checked ? [...previous, key] : previous.filter((item) => item !== key));
|
|
52
|
+
} }), label] }, key))), deleting && _jsx("p", { children: "Deleting this role also removes its permissions." }), error && _jsx("p", { className: "auth-error", role: "alert", children: error })] }), _jsxs("div", { className: "dialog-footer", children: [editing !== 'new' && editing.id !== 'member' && (_jsx("button", { type: "button", className: "button", disabled: busy, onClick: () => {
|
|
53
|
+
if (deleting)
|
|
54
|
+
void save(`/api/admin/roles/${editing.id}`, 'DELETE');
|
|
55
|
+
else
|
|
56
|
+
setDeleting(true);
|
|
57
|
+
}, children: deleting ? 'Confirm role deletion' : 'Delete role' })), _jsx("button", { className: "button primary", disabled: busy || !name.trim(), children: "Save role" })] })] }) })), scoping && dataScope && (_jsx(ScopeEditor, { role: scoping, config: dataScope, request: request, busy: busy, error: error, onClose: () => setScoping(null), onSave: (scope) => void save(`/api/admin/roles/${scoping.id}/data-scope`, 'PUT', scope) }))] }));
|
|
58
|
+
}
|
|
59
|
+
function ScopeEditor({ role, config, request, busy, error, onClose, onSave, }) {
|
|
60
|
+
const [scope, setScope] = useState(() => {
|
|
61
|
+
const fallback = role.id === 'admin' || role.id === 'member' ? null : [];
|
|
62
|
+
return role.app_scopes[config.appId] ?? { read: fallback, write: fallback };
|
|
63
|
+
});
|
|
64
|
+
const [options, setOptions] = useState(null);
|
|
65
|
+
const [loadError, setLoadError] = useState('');
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
let active = true;
|
|
68
|
+
void request(config.optionsEndpoint).then((result) => {
|
|
69
|
+
if (active)
|
|
70
|
+
setOptions(result);
|
|
71
|
+
}).catch((e) => {
|
|
72
|
+
if (active)
|
|
73
|
+
setLoadError(e.message);
|
|
74
|
+
});
|
|
75
|
+
return () => { active = false; };
|
|
76
|
+
}, [config.optionsEndpoint, request]);
|
|
77
|
+
const allowed = (ids, id) => ids === null || ids.includes(id);
|
|
78
|
+
const selected = (ids, remove, checked) => {
|
|
79
|
+
const before = ids ?? options?.map((item) => item.id) ?? [];
|
|
80
|
+
return checked ? [...before, remove] : before.filter((id) => id !== remove);
|
|
81
|
+
};
|
|
82
|
+
return (_jsx(Dialog, { title: `${role.name} · ${config.label}`, closeDisabled: busy, onClose: onClose, children: _jsxs("form", { onSubmit: (event) => { event.preventDefault(); if (options && !busy)
|
|
83
|
+
onSave(scope); }, children: [_jsxs("div", { className: "dialog-body", children: [!options && !loadError && _jsx("p", { role: "status", children: "Loading data scopes\u2026" }), _jsx("div", { className: "auth-table-scroll", children: _jsxs("table", { className: "role-scope-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Data scope" }), _jsx("th", { children: "View" }), _jsx("th", { children: "Edit" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "All" }), _jsx("td", { children: _jsx(Checkbox, { "aria-label": "View all", checked: scope.read === null, onChange: ({ target }) => {
|
|
84
|
+
setScope((current) => target.checked ? { ...current, read: null } : { read: [], write: [] });
|
|
85
|
+
} }) }), _jsx("td", { children: _jsx(Checkbox, { "aria-label": "Edit all", checked: scope.write === null, disabled: scope.read !== null, onChange: ({ target }) => {
|
|
86
|
+
setScope((current) => ({ ...current, write: target.checked ? null : [] }));
|
|
87
|
+
} }) })] }), options?.map(({ id, name }) => (_jsxs("tr", { children: [_jsx("td", { children: name }), _jsx("td", { children: _jsx(Checkbox, { "aria-label": `View ${name}`, checked: allowed(scope.read, id), onChange: ({ target }) => {
|
|
88
|
+
setScope((current) => ({
|
|
89
|
+
read: selected(current.read, id, target.checked),
|
|
90
|
+
write: target.checked ? current.write : selected(current.write, id, false),
|
|
91
|
+
}));
|
|
92
|
+
} }) }), _jsx("td", { children: _jsx(Checkbox, { "aria-label": `Edit ${name}`, checked: allowed(scope.write, id), disabled: !allowed(scope.read, id), onChange: ({ target }) => {
|
|
93
|
+
setScope((current) => ({ ...current, write: selected(current.write, id, target.checked) }));
|
|
94
|
+
} }) })] }, id)))] })] }) }), (error || loadError) && _jsx("p", { className: "auth-error", role: "alert", children: error || loadError })] }), _jsx("div", { className: "dialog-footer", children: _jsx("button", { className: "button primary", disabled: busy || !options, children: "Save data permissions" }) })] }) }));
|
|
95
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.authenticated-shell { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
|
|
2
|
+
.account-bar { min-height: 46px; padding: 7px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #e2e7ee; background: #fff; flex-shrink: 0; }
|
|
3
|
+
.account-bar nav { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
4
|
+
.account-scope { color: #657488; font-size: 12px; margin-left: 12px; font-weight: 400; }
|
|
5
|
+
.private-application { flex: 1; min-height: 0; overflow: hidden; }
|
|
6
|
+
.private-application .app-shell { height: 100%; }
|
|
7
|
+
.auth-page, .auth-loading { min-height: 100dvh; display: grid; place-items: center; background: #f3f6fa; padding: 24px; }
|
|
8
|
+
.auth-panel { width: 100%; max-width: 420px; padding: 32px; background: #fff; border: 1px solid #dfe6ee; border-radius: 8px; }
|
|
9
|
+
.auth-brand { font-size: 22px; font-weight: 700; color: #204f83; text-decoration: none; }
|
|
10
|
+
.auth-brand span { font-size: 14px; font-weight: 500; margin-left: 10px; }
|
|
11
|
+
.auth-panel h1 { font-size: 23px; margin: 30px 0 10px; }
|
|
12
|
+
.auth-description, .auth-help, .auth-settings > p { font-size: 13px; line-height: 1.7; color: #657488; }
|
|
13
|
+
.auth-panel form, .auth-settings form.auth-panel { display: flex; flex-direction: column; gap: 18px; }
|
|
14
|
+
.auth-panel label, .auth-settings label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
|
|
15
|
+
.auth-panel input, .auth-settings input, .auth-settings select { border: 1px solid #cdd7e3; border-radius: 5px; padding: 9px 11px; min-height: 38px; color: #25384c; background: #fff; width: 100%; }
|
|
16
|
+
.auth-submit { justify-content: center; margin-top: 4px; }
|
|
17
|
+
.auth-links { display: flex; justify-content: space-between; margin-top: 18px; gap: 12px; }
|
|
18
|
+
.auth-links button { background: none; padding: 0; color: #235a94; font-size: 12px; }
|
|
19
|
+
.auth-help { margin: 24px 0 0; font-size: 12px; }
|
|
20
|
+
.auth-error { padding: 10px 14px; border: 1px solid #f1cccc; background: #fff5f5; color: #a82d2d; font-size: 13px; overflow-wrap: anywhere; }
|
|
21
|
+
.auth-settings { padding: 28px; overflow: auto; flex: 1; }
|
|
22
|
+
.auth-settings h1 { font-size: 24px; margin: 0 0 8px; }
|
|
23
|
+
.auth-settings h2 { font-size: 16px; margin: 0 0 18px; }
|
|
24
|
+
.auth-settings > p { margin-bottom: 24px; }
|
|
25
|
+
.auth-user-section { padding: 22px 0; border-top: 1px solid #dfe6ee; }
|
|
26
|
+
.user-list-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
27
|
+
.auth-table-scroll { overflow-x: auto; }
|
|
28
|
+
.auth-settings table { border-collapse: collapse; width: 100%; min-width: 700px; text-align: left; font-size: 13px; }
|
|
29
|
+
.auth-settings td, .auth-settings th { padding: 12px; border-bottom: 1px solid #e2e7ee; }
|
|
30
|
+
.auth-settings th { color: #657488; font-weight: 500; }
|
|
31
|
+
.auth-settings td input { max-width: 160px; margin-right: 8px; }
|
|
32
|
+
.user-actions { white-space: nowrap; }
|
|
33
|
+
.user-actions button + button { margin-left: 8px; }
|
|
34
|
+
.user-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 18px; font-size: 12px; }
|
|
35
|
+
.reset-receipt { border: 1px solid #c3d5e9; background: #f1f6fc; padding: 18px; margin: 18px 0; font-size: 13px; }
|
|
36
|
+
.reset-receipt code { display: block; padding: 12px 0; user-select: all; overflow-wrap: anywhere; }
|
|
37
|
+
@media (max-width: 640px) { .account-bar { padding: 8px 12px; align-items: flex-start; } .account-scope { display: block; margin-left: 0; } .auth-panel { padding: 24px; } .auth-settings { padding: 18px; } .account-bar nav { justify-content: flex-end; gap: 5px; } }
|
|
38
|
+
.private-application { overflow: auto; }
|
|
39
|
+
.private-application .app-shell { min-height: 100%; height: auto; }
|
|
40
|
+
/* The account bar never renders alongside the application view, so the sticky
|
|
41
|
+
sidebar spans the full viewport instead of reserving a 46px bar. */
|
|
42
|
+
.private-application .sidebar { position: sticky; top: 0; height: 100dvh; grid-row: 1; }
|
|
43
|
+
|
|
44
|
+
.user-name-editor { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
|
45
|
+
.user-name-editor input { flex: 1 1 130px; }
|
|
46
|
+
.auth-settings .user-name-editor input { margin: 0; }
|
|
47
|
+
.user-actions { min-width: 168px; white-space: normal; }
|
|
48
|
+
.user-actions button + button { margin-left: 0; }
|
|
49
|
+
.auth-settings .ui-select { width: 100%; min-width: 120px; }
|
|
50
|
+
.auth-settings .ui-select-trigger { min-height: 38px; }
|
|
51
|
+
.account-bar > span { min-width: 0; overflow-wrap: anywhere; }
|
|
52
|
+
.account-bar nav { flex-shrink: 0; }
|
|
53
|
+
.user-pagination { flex-wrap: wrap; }
|
|
54
|
+
@media (max-width: 640px) {
|
|
55
|
+
.auth-settings th:first-child, .auth-settings td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
|
|
56
|
+
}
|
|
57
|
+
.dialog-body .role-permission {
|
|
58
|
+
flex-direction: row;
|
|
59
|
+
align-items: center;
|
|
60
|
+
gap: 8px;
|
|
61
|
+
}
|
|
62
|
+
.role-scope-table {
|
|
63
|
+
width: 100%;
|
|
64
|
+
border-collapse: collapse;
|
|
65
|
+
}
|
|
66
|
+
.role-scope-table th,
|
|
67
|
+
.role-scope-table td {
|
|
68
|
+
padding: 8px 12px;
|
|
69
|
+
border-bottom: 1px solid #edf1f5;
|
|
70
|
+
text-align: left;
|
|
71
|
+
}
|
|
72
|
+
.role-scope-table th:not(:first-child),
|
|
73
|
+
.role-scope-table td:not(:first-child) {
|
|
74
|
+
width: 24%;
|
|
75
|
+
text-align: center;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AuthContext, default as AuthShell, useAuth } from './AuthShell.js';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { WorkspaceClient, WorkspaceIntent } from '../index.js';
|
|
3
|
+
/** A server-requested local action, never an authorization for business writes. */
|
|
4
|
+
export interface UIAction {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
arguments: Record<string, unknown>;
|
|
8
|
+
view_instance_id: string;
|
|
9
|
+
revision: number;
|
|
10
|
+
expires_at: string;
|
|
11
|
+
}
|
|
12
|
+
/** The current tab-local state against which an action must be checked. */
|
|
13
|
+
export interface ActionView {
|
|
14
|
+
view_instance_id: string;
|
|
15
|
+
revision: number;
|
|
16
|
+
hasDraft: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Only navigation, filtering and unsubmitted drafts may be registered. */
|
|
19
|
+
export interface LocalAction {
|
|
20
|
+
kind: 'navigation' | 'filter' | 'draft';
|
|
21
|
+
handle: (args: Record<string, unknown>) => unknown | Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
/** A view-bound registry with deduplicated action execution and acknowledgement. */
|
|
24
|
+
export interface ActionBridge {
|
|
25
|
+
registerActions: (handlers: Record<string, LocalAction>, view: (action: UIAction) => ActionView) => () => void;
|
|
26
|
+
handleAction: (taskId: string, action: UIAction) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/** Share one explicit host workspace transport with all platform components. */
|
|
29
|
+
export declare function PlatformProvider({ client, children, }: {
|
|
30
|
+
client: WorkspaceClient;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}): import("react").JSX.Element;
|
|
33
|
+
/** Access the host-provided client without changing global fetch or credentials. */
|
|
34
|
+
export declare function usePlatform(): WorkspaceClient;
|
|
35
|
+
/** Poll authoritative task state; cancel pending reads and timers when the task or host changes. */
|
|
36
|
+
export declare function useTaskSubscription<T extends {
|
|
37
|
+
status: string;
|
|
38
|
+
}>(id: string | null, interval?: number): {
|
|
39
|
+
data: T | null;
|
|
40
|
+
error: Error | null;
|
|
41
|
+
};
|
|
42
|
+
/** Register only local UI effects and handle view-bound server requests. */
|
|
43
|
+
export declare function usePlatformActions(): ActionBridge;
|
|
44
|
+
/** A minimal application-neutral view of a task eligible for result review. */
|
|
45
|
+
export interface ReviewableTask {
|
|
46
|
+
id: string;
|
|
47
|
+
version: number;
|
|
48
|
+
status: string;
|
|
49
|
+
hasResult: boolean;
|
|
50
|
+
reviewStatus?: string | null;
|
|
51
|
+
}
|
|
52
|
+
/** Collect human acceptance or a revision request without invoking business approvals. */
|
|
53
|
+
export declare function TaskReviewControls({ task, busy, onReview, }: {
|
|
54
|
+
task: ReviewableTask;
|
|
55
|
+
busy?: boolean;
|
|
56
|
+
onReview: (decision: 'accepted' | 'changes_requested', comment: string, intent: WorkspaceIntent) => Promise<unknown>;
|
|
57
|
+
}): import("react").JSX.Element | null;
|