@agenticmail/enterprise 0.5.297 → 0.5.299
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/chunk-55QVWFKC.js +48 -0
- package/dist/chunk-633X6XDY.js +1519 -0
- package/dist/chunk-7FEEWUNJ.js +4254 -0
- package/dist/chunk-DZU6DQ3I.js +1519 -0
- package/dist/chunk-PNOFGWIB.js +4014 -0
- package/dist/cli-agent-4DVE3NDA.js +1778 -0
- package/dist/cli-recover-MFF5AXLN.js +487 -0
- package/dist/cli-serve-BXI7TTNN.js +143 -0
- package/dist/cli-serve-RRKVF3QM.js +143 -0
- package/dist/cli-verify-BTSN7SQ2.js +149 -0
- package/dist/cli.js +5 -5
- package/dist/dashboard/app.js +6 -1
- package/dist/dashboard/components/icons.js +1 -0
- package/dist/dashboard/pages/agent-detail/index.js +20 -0
- package/dist/dashboard/pages/agent-detail/overview.js +110 -0
- package/dist/dashboard/pages/agents.js +12 -2
- package/dist/dashboard/pages/organizations.js +335 -0
- package/dist/dashboard/pages/users.js +128 -12
- package/dist/factory-4JY52C3T.js +9 -0
- package/dist/index.js +3 -3
- package/dist/page-registry-FAWFCYUQ.js +183 -0
- package/dist/page-registry-NV4AIPCF.js +178 -0
- package/dist/postgres-B42FZ72F.js +799 -0
- package/dist/server-CCQIW6GR.js +15 -0
- package/dist/server-KGEYYNHX.js +15 -0
- package/dist/setup-KIAPXKEX.js +20 -0
- package/dist/setup-OL4GJ53G.js +20 -0
- package/dist/sqlite-KQDU2IFO.js +531 -0
- package/package.json +1 -1
- package/src/admin/page-registry.ts +16 -5
- package/src/admin/routes.ts +263 -0
- package/src/dashboard/app.js +6 -1
- package/src/dashboard/components/icons.js +1 -0
- package/src/dashboard/pages/agent-detail/index.js +20 -0
- package/src/dashboard/pages/agent-detail/overview.js +110 -0
- package/src/dashboard/pages/agents.js +12 -2
- package/src/dashboard/pages/organizations.js +335 -0
- package/src/dashboard/pages/users.js +128 -12
- package/src/db/postgres.ts +29 -0
- package/src/db/sqlite.ts +26 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { h, useState, useEffect, useCallback, Fragment, useApp, apiCall } from '../components/utils.js';
|
|
2
|
+
import { I } from '../components/icons.js';
|
|
3
|
+
import { Modal } from '../components/modal.js';
|
|
4
|
+
import { HelpButton } from '../components/help-button.js';
|
|
5
|
+
|
|
6
|
+
function slugify(text) {
|
|
7
|
+
return (text || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function OrganizationsPage() {
|
|
11
|
+
var app = useApp();
|
|
12
|
+
var toast = app.toast;
|
|
13
|
+
|
|
14
|
+
var _orgs = useState([]);
|
|
15
|
+
var orgs = _orgs[0]; var setOrgs = _orgs[1];
|
|
16
|
+
var _loading = useState(true);
|
|
17
|
+
var loading = _loading[0]; var setLoading = _loading[1];
|
|
18
|
+
var _showCreate = useState(false);
|
|
19
|
+
var showCreate = _showCreate[0]; var setShowCreate = _showCreate[1];
|
|
20
|
+
var _editOrg = useState(null);
|
|
21
|
+
var editOrg = _editOrg[0]; var setEditOrg = _editOrg[1];
|
|
22
|
+
var _detailOrg = useState(null);
|
|
23
|
+
var detailOrg = _detailOrg[0]; var setDetailOrg = _detailOrg[1];
|
|
24
|
+
var _detailAgents = useState([]);
|
|
25
|
+
var detailAgents = _detailAgents[0]; var setDetailAgents = _detailAgents[1];
|
|
26
|
+
var _allAgents = useState([]);
|
|
27
|
+
var allAgents = _allAgents[0]; var setAllAgents = _allAgents[1];
|
|
28
|
+
var _assignAgentId = useState('');
|
|
29
|
+
var assignAgentId = _assignAgentId[0]; var setAssignAgentId = _assignAgentId[1];
|
|
30
|
+
var _acting = useState('');
|
|
31
|
+
var acting = _acting[0]; var setActing = _acting[1];
|
|
32
|
+
|
|
33
|
+
// Form state
|
|
34
|
+
var _fname = useState('');
|
|
35
|
+
var fname = _fname[0]; var setFname = _fname[1];
|
|
36
|
+
var _fslug = useState('');
|
|
37
|
+
var fslug = _fslug[0]; var setFslug = _fslug[1];
|
|
38
|
+
var _fcontact = useState('');
|
|
39
|
+
var fcontact = _fcontact[0]; var setFcontact = _fcontact[1];
|
|
40
|
+
var _femail = useState('');
|
|
41
|
+
var femail = _femail[0]; var setFemail = _femail[1];
|
|
42
|
+
var _fdesc = useState('');
|
|
43
|
+
var fdesc = _fdesc[0]; var setFdesc = _fdesc[1];
|
|
44
|
+
var _slugManual = useState(false);
|
|
45
|
+
var slugManual = _slugManual[0]; var setSlugManual = _slugManual[1];
|
|
46
|
+
|
|
47
|
+
var loadOrgs = useCallback(function() {
|
|
48
|
+
setLoading(true);
|
|
49
|
+
apiCall('/organizations').then(function(data) {
|
|
50
|
+
setOrgs(data.organizations || []);
|
|
51
|
+
}).catch(function(err) {
|
|
52
|
+
toast(err.message, 'error');
|
|
53
|
+
}).finally(function() { setLoading(false); });
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
useEffect(function() { loadOrgs(); }, []);
|
|
57
|
+
|
|
58
|
+
var loadAllAgents = function() {
|
|
59
|
+
apiCall('/agents?limit=200').then(function(data) {
|
|
60
|
+
setAllAgents(data.agents || []);
|
|
61
|
+
}).catch(function() {});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var openCreate = function() {
|
|
65
|
+
setFname(''); setFslug(''); setFcontact(''); setFemail(''); setFdesc(''); setSlugManual(false);
|
|
66
|
+
setShowCreate(true);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
var openEdit = function(org) {
|
|
70
|
+
setFname(org.name || ''); setFslug(org.slug || ''); setFcontact(org.contact_name || ''); setFemail(org.contact_email || ''); setFdesc(org.description || '');
|
|
71
|
+
setEditOrg(org);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var openDetail = function(org) {
|
|
75
|
+
setDetailOrg(org);
|
|
76
|
+
loadAllAgents();
|
|
77
|
+
apiCall('/organizations/' + org.id).then(function(data) {
|
|
78
|
+
setDetailAgents(data.agents || []);
|
|
79
|
+
setDetailOrg(data);
|
|
80
|
+
}).catch(function(err) { toast(err.message, 'error'); });
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var doCreate = function() {
|
|
84
|
+
setActing('create');
|
|
85
|
+
apiCall('/organizations', {
|
|
86
|
+
method: 'POST',
|
|
87
|
+
body: JSON.stringify({ name: fname, slug: fslug, contact_name: fcontact, contact_email: femail, description: fdesc })
|
|
88
|
+
}).then(function() {
|
|
89
|
+
toast('Organization created', 'success');
|
|
90
|
+
setShowCreate(false);
|
|
91
|
+
loadOrgs();
|
|
92
|
+
}).catch(function(err) { toast(err.message, 'error'); })
|
|
93
|
+
.finally(function() { setActing(''); });
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var doEdit = function() {
|
|
97
|
+
setActing('edit');
|
|
98
|
+
apiCall('/organizations/' + editOrg.id, {
|
|
99
|
+
method: 'PATCH',
|
|
100
|
+
body: JSON.stringify({ name: fname, contact_name: fcontact, contact_email: femail, description: fdesc })
|
|
101
|
+
}).then(function() {
|
|
102
|
+
toast('Organization updated', 'success');
|
|
103
|
+
setEditOrg(null);
|
|
104
|
+
loadOrgs();
|
|
105
|
+
}).catch(function(err) { toast(err.message, 'error'); })
|
|
106
|
+
.finally(function() { setActing(''); });
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
var doToggle = function(org) {
|
|
110
|
+
setActing('toggle-' + org.id);
|
|
111
|
+
apiCall('/organizations/' + org.id + '/toggle', { method: 'POST' })
|
|
112
|
+
.then(function() {
|
|
113
|
+
toast('Organization ' + (org.is_active ? 'deactivated' : 'activated'), 'success');
|
|
114
|
+
loadOrgs();
|
|
115
|
+
if (detailOrg && detailOrg.id === org.id) openDetail(org);
|
|
116
|
+
}).catch(function(err) { toast(err.message, 'error'); })
|
|
117
|
+
.finally(function() { setActing(''); });
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var doDelete = function(org) {
|
|
121
|
+
if (!window.__showConfirm) return;
|
|
122
|
+
window.__showConfirm({ title: 'Delete Organization', message: 'Are you sure you want to delete "' + org.name + '"? This cannot be undone.' }).then(function(confirmed) {
|
|
123
|
+
if (!confirmed) return;
|
|
124
|
+
setActing('delete-' + org.id);
|
|
125
|
+
apiCall('/organizations/' + org.id, { method: 'DELETE' })
|
|
126
|
+
.then(function() {
|
|
127
|
+
toast('Organization deleted', 'success');
|
|
128
|
+
loadOrgs();
|
|
129
|
+
if (detailOrg && detailOrg.id === org.id) setDetailOrg(null);
|
|
130
|
+
}).catch(function(err) { toast(err.message, 'error'); })
|
|
131
|
+
.finally(function() { setActing(''); });
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var doAssignAgent = function() {
|
|
136
|
+
if (!assignAgentId || !detailOrg) return;
|
|
137
|
+
setActing('assign');
|
|
138
|
+
apiCall('/agents/' + assignAgentId + '/assign-org', {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
body: JSON.stringify({ orgId: detailOrg.id })
|
|
141
|
+
}).then(function() {
|
|
142
|
+
toast('Agent assigned', 'success');
|
|
143
|
+
setAssignAgentId('');
|
|
144
|
+
openDetail(detailOrg);
|
|
145
|
+
loadOrgs();
|
|
146
|
+
}).catch(function(err) { toast(err.message, 'error'); })
|
|
147
|
+
.finally(function() { setActing(''); });
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
var doUnassignAgent = function(agentId) {
|
|
151
|
+
setActing('unassign-' + agentId);
|
|
152
|
+
apiCall('/agents/' + agentId + '/unassign-org', { method: 'POST' })
|
|
153
|
+
.then(function() {
|
|
154
|
+
toast('Agent unassigned', 'success');
|
|
155
|
+
openDetail(detailOrg);
|
|
156
|
+
loadOrgs();
|
|
157
|
+
}).catch(function(err) { toast(err.message, 'error'); })
|
|
158
|
+
.finally(function() { setActing(''); });
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var unassignedAgents = allAgents.filter(function(a) {
|
|
162
|
+
return !a.client_org_id && detailAgents.every(function(da) { return da.id !== a.id; });
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (loading) return h('div', { style: { padding: 40, textAlign: 'center', color: 'var(--text-muted)' } }, 'Loading organizations...');
|
|
166
|
+
|
|
167
|
+
return h(Fragment, null,
|
|
168
|
+
// Header
|
|
169
|
+
h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 } },
|
|
170
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
171
|
+
h('h1', { style: { fontSize: 20, fontWeight: 700 } }, 'Organizations'),
|
|
172
|
+
h(HelpButton, { label: 'Organizations' },
|
|
173
|
+
h('p', null, 'Manage client organizations and assign agents to them. Each organization represents a tenant or client that your agents serve.'),
|
|
174
|
+
h('ul', { style: { paddingLeft: 20, margin: '8px 0' } },
|
|
175
|
+
h('li', null, 'Create organizations for each client or department'),
|
|
176
|
+
h('li', null, 'Assign agents to organizations to control access'),
|
|
177
|
+
h('li', null, 'Toggle organizations active/inactive to suspend all linked agents'),
|
|
178
|
+
h('li', null, 'Delete organizations only after unassigning all agents')
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
),
|
|
182
|
+
h('button', { className: 'btn btn-primary', onClick: openCreate }, I.plus(), ' New Organization')
|
|
183
|
+
),
|
|
184
|
+
|
|
185
|
+
// Org cards
|
|
186
|
+
orgs.length === 0
|
|
187
|
+
? h('div', { className: 'card', style: { textAlign: 'center', padding: 40 } },
|
|
188
|
+
h('div', { style: { fontSize: 48, marginBottom: 12 } }, '🏢'),
|
|
189
|
+
h('div', { style: { fontSize: 15, fontWeight: 600, marginBottom: 4 } }, 'No organizations yet'),
|
|
190
|
+
h('div', { style: { color: 'var(--text-muted)', fontSize: 13, marginBottom: 16 } }, 'Create your first client organization to start managing multi-tenant agent deployments.'),
|
|
191
|
+
h('button', { className: 'btn btn-primary', onClick: openCreate }, I.plus(), ' Create Organization')
|
|
192
|
+
)
|
|
193
|
+
: h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(340px, 1fr))', gap: 16 } },
|
|
194
|
+
orgs.map(function(org) {
|
|
195
|
+
return h('div', { key: org.id, className: 'card', style: { cursor: 'pointer', transition: 'border-color 0.15s', position: 'relative' }, onClick: function() { openDetail(org); } },
|
|
196
|
+
h('div', { className: 'card-body' },
|
|
197
|
+
h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 12 } },
|
|
198
|
+
h('div', null,
|
|
199
|
+
h('div', { style: { fontSize: 16, fontWeight: 700, marginBottom: 2 } }, org.name),
|
|
200
|
+
h('div', { style: { fontSize: 12, color: 'var(--text-muted)', fontFamily: 'var(--font-mono, monospace)' } }, org.slug)
|
|
201
|
+
),
|
|
202
|
+
h('span', { className: 'badge badge-' + (org.is_active ? 'success' : 'warning') }, org.is_active ? 'Active' : 'Inactive')
|
|
203
|
+
),
|
|
204
|
+
org.description && h('div', { style: { fontSize: 13, color: 'var(--text-secondary)', marginBottom: 12, lineHeight: 1.5 } }, org.description),
|
|
205
|
+
h('div', { style: { display: 'flex', gap: 16, fontSize: 12, color: 'var(--text-muted)' } },
|
|
206
|
+
h('span', null, I.agents(), ' ', (org.agent_count || 0), ' agent', (org.agent_count || 0) !== 1 ? 's' : ''),
|
|
207
|
+
org.contact_email && h('span', null, '✉ ', org.contact_email),
|
|
208
|
+
org.created_at && h('span', null, new Date(org.created_at).toLocaleDateString())
|
|
209
|
+
),
|
|
210
|
+
h('div', { style: { display: 'flex', gap: 6, marginTop: 12, borderTop: '1px solid var(--border)', paddingTop: 10 }, onClick: function(e) { e.stopPropagation(); } },
|
|
211
|
+
h('button', { className: 'btn btn-ghost btn-sm', onClick: function() { openEdit(org); } }, I.edit(), ' Edit'),
|
|
212
|
+
h('button', { className: 'btn btn-ghost btn-sm', disabled: acting === 'toggle-' + org.id, onClick: function() { doToggle(org); } },
|
|
213
|
+
org.is_active ? 'Deactivate' : 'Activate'
|
|
214
|
+
),
|
|
215
|
+
(org.agent_count || 0) === 0 && h('button', { className: 'btn btn-ghost btn-sm', style: { color: 'var(--danger)' }, disabled: acting === 'delete-' + org.id, onClick: function() { doDelete(org); } }, I.trash(), ' Delete')
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
);
|
|
219
|
+
})
|
|
220
|
+
),
|
|
221
|
+
|
|
222
|
+
// Create Modal
|
|
223
|
+
showCreate && h(Modal, { title: 'Create Organization', onClose: function() { setShowCreate(false); } },
|
|
224
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 14, padding: 4 } },
|
|
225
|
+
h('div', null,
|
|
226
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Name *'),
|
|
227
|
+
h('input', { className: 'input', value: fname, onInput: function(e) { setFname(e.target.value); if (!slugManual) setFslug(slugify(e.target.value)); }, placeholder: 'Acme Corporation' })
|
|
228
|
+
),
|
|
229
|
+
h('div', null,
|
|
230
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Slug *'),
|
|
231
|
+
h('input', { className: 'input', value: fslug, onInput: function(e) { setFslug(e.target.value); setSlugManual(true); }, placeholder: 'acme-corporation', style: { fontFamily: 'var(--font-mono, monospace)' } })
|
|
232
|
+
),
|
|
233
|
+
h('div', null,
|
|
234
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Contact Name'),
|
|
235
|
+
h('input', { className: 'input', value: fcontact, onInput: function(e) { setFcontact(e.target.value); }, placeholder: 'John Doe' })
|
|
236
|
+
),
|
|
237
|
+
h('div', null,
|
|
238
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Contact Email'),
|
|
239
|
+
h('input', { className: 'input', type: 'email', value: femail, onInput: function(e) { setFemail(e.target.value); }, placeholder: 'john@acme.com' })
|
|
240
|
+
),
|
|
241
|
+
h('div', null,
|
|
242
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Description'),
|
|
243
|
+
h('textarea', { className: 'input', value: fdesc, onInput: function(e) { setFdesc(e.target.value); }, placeholder: 'Brief description...', rows: 3, style: { resize: 'vertical' } })
|
|
244
|
+
),
|
|
245
|
+
h('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 8 } },
|
|
246
|
+
h('button', { className: 'btn btn-secondary', onClick: function() { setShowCreate(false); } }, 'Cancel'),
|
|
247
|
+
h('button', { className: 'btn btn-primary', disabled: !fname || !fslug || acting === 'create', onClick: doCreate }, acting === 'create' ? 'Creating...' : 'Create')
|
|
248
|
+
)
|
|
249
|
+
)
|
|
250
|
+
),
|
|
251
|
+
|
|
252
|
+
// Edit Modal
|
|
253
|
+
editOrg && h(Modal, { title: 'Edit Organization', onClose: function() { setEditOrg(null); } },
|
|
254
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 14, padding: 4 } },
|
|
255
|
+
h('div', null,
|
|
256
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Name'),
|
|
257
|
+
h('input', { className: 'input', value: fname, onInput: function(e) { setFname(e.target.value); } })
|
|
258
|
+
),
|
|
259
|
+
h('div', null,
|
|
260
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Slug'),
|
|
261
|
+
h('input', { className: 'input', value: fslug, disabled: true, style: { fontFamily: 'var(--font-mono, monospace)', opacity: 0.6 } })
|
|
262
|
+
),
|
|
263
|
+
h('div', null,
|
|
264
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Contact Name'),
|
|
265
|
+
h('input', { className: 'input', value: fcontact, onInput: function(e) { setFcontact(e.target.value); } })
|
|
266
|
+
),
|
|
267
|
+
h('div', null,
|
|
268
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Contact Email'),
|
|
269
|
+
h('input', { className: 'input', type: 'email', value: femail, onInput: function(e) { setFemail(e.target.value); } })
|
|
270
|
+
),
|
|
271
|
+
h('div', null,
|
|
272
|
+
h('label', { style: { fontSize: 12, fontWeight: 600, display: 'block', marginBottom: 4 } }, 'Description'),
|
|
273
|
+
h('textarea', { className: 'input', value: fdesc, onInput: function(e) { setFdesc(e.target.value); }, rows: 3, style: { resize: 'vertical' } })
|
|
274
|
+
),
|
|
275
|
+
h('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 8 } },
|
|
276
|
+
h('button', { className: 'btn btn-secondary', onClick: function() { setEditOrg(null); } }, 'Cancel'),
|
|
277
|
+
h('button', { className: 'btn btn-primary', disabled: !fname || acting === 'edit', onClick: doEdit }, acting === 'edit' ? 'Saving...' : 'Save Changes')
|
|
278
|
+
)
|
|
279
|
+
)
|
|
280
|
+
),
|
|
281
|
+
|
|
282
|
+
// Detail Modal
|
|
283
|
+
detailOrg && h(Modal, { title: detailOrg.name || 'Organization Detail', onClose: function() { setDetailOrg(null); }, wide: true },
|
|
284
|
+
h('div', { style: { padding: 4 } },
|
|
285
|
+
// Org info
|
|
286
|
+
h('div', { style: { display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 16, marginBottom: 20 } },
|
|
287
|
+
h('div', null,
|
|
288
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)', textTransform: 'uppercase', fontWeight: 600, marginBottom: 4 } }, 'Slug'),
|
|
289
|
+
h('div', { style: { fontFamily: 'var(--font-mono, monospace)', fontSize: 13 } }, detailOrg.slug)
|
|
290
|
+
),
|
|
291
|
+
h('div', null,
|
|
292
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)', textTransform: 'uppercase', fontWeight: 600, marginBottom: 4 } }, 'Status'),
|
|
293
|
+
h('span', { className: 'badge badge-' + (detailOrg.is_active ? 'success' : 'warning') }, detailOrg.is_active ? 'Active' : 'Inactive')
|
|
294
|
+
),
|
|
295
|
+
h('div', null,
|
|
296
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)', textTransform: 'uppercase', fontWeight: 600, marginBottom: 4 } }, 'Contact'),
|
|
297
|
+
h('div', { style: { fontSize: 13 } }, detailOrg.contact_name || '—'),
|
|
298
|
+
detailOrg.contact_email && h('div', { style: { fontSize: 12, color: 'var(--text-muted)' } }, detailOrg.contact_email)
|
|
299
|
+
)
|
|
300
|
+
),
|
|
301
|
+
detailOrg.description && h('div', { style: { fontSize: 13, color: 'var(--text-secondary)', marginBottom: 16, padding: 12, background: 'var(--bg-tertiary)', borderRadius: 'var(--radius)' } }, detailOrg.description),
|
|
302
|
+
|
|
303
|
+
// Linked agents
|
|
304
|
+
h('div', { style: { fontSize: 14, fontWeight: 700, marginBottom: 10 } }, 'Linked Agents (' + detailAgents.length + ')'),
|
|
305
|
+
detailAgents.length > 0
|
|
306
|
+
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 16 } },
|
|
307
|
+
detailAgents.map(function(a) {
|
|
308
|
+
var stateColor = { active: 'success', running: 'success', suspended: 'warning', archived: 'neutral' }[a.status] || 'neutral';
|
|
309
|
+
return h('div', { key: a.id, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '8px 12px', background: 'var(--bg-tertiary)', borderRadius: 'var(--radius)' } },
|
|
310
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10 } },
|
|
311
|
+
h('span', { style: { fontWeight: 600, fontSize: 13 } }, a.name),
|
|
312
|
+
h('span', { style: { fontSize: 12, color: 'var(--text-muted)', fontFamily: 'var(--font-mono, monospace)' } }, a.email),
|
|
313
|
+
h('span', { className: 'badge badge-' + stateColor, style: { fontSize: 10 } }, a.status)
|
|
314
|
+
),
|
|
315
|
+
h('button', { className: 'btn btn-ghost btn-sm', style: { color: 'var(--danger)' }, disabled: acting === 'unassign-' + a.id, onClick: function() { doUnassignAgent(a.id); } }, 'Unassign')
|
|
316
|
+
);
|
|
317
|
+
})
|
|
318
|
+
)
|
|
319
|
+
: h('div', { style: { padding: 16, textAlign: 'center', color: 'var(--text-muted)', fontSize: 13, background: 'var(--bg-tertiary)', borderRadius: 'var(--radius)', marginBottom: 16 } }, 'No agents assigned to this organization'),
|
|
320
|
+
|
|
321
|
+
// Assign agent
|
|
322
|
+
h('div', { style: { fontSize: 14, fontWeight: 700, marginBottom: 8 } }, 'Assign Agent'),
|
|
323
|
+
h('div', { style: { display: 'flex', gap: 8 } },
|
|
324
|
+
h('select', { className: 'input', value: assignAgentId, onChange: function(e) { setAssignAgentId(e.target.value); }, style: { flex: 1 } },
|
|
325
|
+
h('option', { value: '' }, '— Select an unassigned agent —'),
|
|
326
|
+
unassignedAgents.map(function(a) {
|
|
327
|
+
return h('option', { key: a.id, value: a.id }, a.name + (a.role ? ' (' + a.role + ')' : ''));
|
|
328
|
+
})
|
|
329
|
+
),
|
|
330
|
+
h('button', { className: 'btn btn-primary btn-sm', disabled: !assignAgentId || acting === 'assign', onClick: doAssignAgent }, acting === 'assign' ? 'Assigning...' : 'Assign')
|
|
331
|
+
)
|
|
332
|
+
)
|
|
333
|
+
)
|
|
334
|
+
);
|
|
335
|
+
}
|
|
@@ -6,23 +6,37 @@ import { HelpButton } from '../components/help-button.js';
|
|
|
6
6
|
// ─── Permission Editor Component ───────────────────
|
|
7
7
|
|
|
8
8
|
function PermissionEditor({ userId, userName, currentPerms, pageRegistry, onSave, onClose }) {
|
|
9
|
-
// Deep clone perms
|
|
9
|
+
// Deep clone perms (skip _allowedAgents from page grants)
|
|
10
10
|
var [grants, setGrants] = useState(function() {
|
|
11
11
|
if (currentPerms === '*') {
|
|
12
|
-
// Start with all pages selected (all tabs)
|
|
13
12
|
var all = {};
|
|
14
13
|
Object.keys(pageRegistry).forEach(function(pid) { all[pid] = true; });
|
|
15
14
|
return all;
|
|
16
15
|
}
|
|
17
|
-
// Clone existing
|
|
18
16
|
var c = {};
|
|
19
17
|
Object.keys(currentPerms || {}).forEach(function(pid) {
|
|
18
|
+
if (pid === '_allowedAgents') return; // skip agent field
|
|
20
19
|
var g = currentPerms[pid];
|
|
21
20
|
c[pid] = g === true ? true : (Array.isArray(g) ? g.slice() : true);
|
|
22
21
|
});
|
|
23
22
|
return c;
|
|
24
23
|
});
|
|
25
24
|
var [fullAccess, setFullAccess] = useState(currentPerms === '*');
|
|
25
|
+
|
|
26
|
+
// Agent access control
|
|
27
|
+
var [agents, setAgents] = useState([]);
|
|
28
|
+
var [allowedAgents, setAllowedAgents] = useState(function() {
|
|
29
|
+
if (currentPerms === '*') return '*';
|
|
30
|
+
return (currentPerms || {})._allowedAgents || '*';
|
|
31
|
+
});
|
|
32
|
+
var [allAgentsAccess, setAllAgentsAccess] = useState(function() {
|
|
33
|
+
if (currentPerms === '*') return true;
|
|
34
|
+
return (currentPerms || {})._allowedAgents === '*' || !(currentPerms || {})._allowedAgents;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
useEffect(function() {
|
|
38
|
+
apiCall('/agents').then(function(d) { setAgents(d.agents || d || []); }).catch(function() {});
|
|
39
|
+
}, []);
|
|
26
40
|
var [saving, setSaving] = useState(false);
|
|
27
41
|
var [expandedPage, setExpandedPage] = useState(null);
|
|
28
42
|
|
|
@@ -86,8 +100,11 @@ function PermissionEditor({ userId, userName, currentPerms, pageRegistry, onSave
|
|
|
86
100
|
var all = {};
|
|
87
101
|
Object.keys(pageRegistry).forEach(function(pid) { all[pid] = true; });
|
|
88
102
|
setGrants(all);
|
|
103
|
+
setAllAgentsAccess(true);
|
|
104
|
+
setAllowedAgents('*');
|
|
89
105
|
} else {
|
|
90
106
|
setGrants({});
|
|
107
|
+
setAllAgentsAccess(true);
|
|
91
108
|
}
|
|
92
109
|
};
|
|
93
110
|
|
|
@@ -101,7 +118,17 @@ function PermissionEditor({ userId, userName, currentPerms, pageRegistry, onSave
|
|
|
101
118
|
var doSave = async function() {
|
|
102
119
|
setSaving(true);
|
|
103
120
|
try {
|
|
104
|
-
var permsToSave
|
|
121
|
+
var permsToSave;
|
|
122
|
+
if (fullAccess) {
|
|
123
|
+
permsToSave = '*';
|
|
124
|
+
} else {
|
|
125
|
+
permsToSave = Object.assign({}, grants);
|
|
126
|
+
if (!allAgentsAccess && Array.isArray(allowedAgents)) {
|
|
127
|
+
permsToSave._allowedAgents = allowedAgents;
|
|
128
|
+
} else {
|
|
129
|
+
permsToSave._allowedAgents = '*';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
105
132
|
await onSave(permsToSave);
|
|
106
133
|
} catch(e) { /* handled by parent */ }
|
|
107
134
|
setSaving(false);
|
|
@@ -201,11 +228,61 @@ function PermissionEditor({ userId, userName, currentPerms, pageRegistry, onSave
|
|
|
201
228
|
})
|
|
202
229
|
),
|
|
203
230
|
|
|
231
|
+
// ─── Agent Access ──────────────────────────
|
|
232
|
+
!fullAccess && h('div', { style: { marginTop: 16 } },
|
|
233
|
+
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 } },
|
|
234
|
+
h('div', null,
|
|
235
|
+
h('strong', { style: { fontSize: 13 } }, 'Agent Access'),
|
|
236
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)', marginTop: 1 } }, 'Which agents this user can see and manage')
|
|
237
|
+
),
|
|
238
|
+
h('label', { style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, cursor: 'pointer' } },
|
|
239
|
+
h('input', { type: 'checkbox', checked: allAgentsAccess, onChange: function() {
|
|
240
|
+
var newVal = !allAgentsAccess;
|
|
241
|
+
setAllAgentsAccess(newVal);
|
|
242
|
+
if (newVal) setAllowedAgents('*');
|
|
243
|
+
else setAllowedAgents([]);
|
|
244
|
+
}, style: _checkbox }),
|
|
245
|
+
'All Agents'
|
|
246
|
+
)
|
|
247
|
+
),
|
|
248
|
+
!allAgentsAccess && h('div', { style: { maxHeight: 180, overflowY: 'auto', border: '1px solid var(--border)', borderRadius: 8 } },
|
|
249
|
+
agents.length === 0
|
|
250
|
+
? h('div', { style: { padding: 16, textAlign: 'center', color: 'var(--text-muted)', fontSize: 12 } }, 'No agents found')
|
|
251
|
+
: agents.map(function(a) {
|
|
252
|
+
var checked = Array.isArray(allowedAgents) && allowedAgents.indexOf(a.id) >= 0;
|
|
253
|
+
return h('div', {
|
|
254
|
+
key: a.id,
|
|
255
|
+
style: Object.assign({}, _cs, checked ? { background: 'var(--bg-tertiary)' } : {}),
|
|
256
|
+
onClick: function() {
|
|
257
|
+
setAllowedAgents(function(prev) {
|
|
258
|
+
var arr = Array.isArray(prev) ? prev.slice() : [];
|
|
259
|
+
var idx = arr.indexOf(a.id);
|
|
260
|
+
if (idx >= 0) arr.splice(idx, 1);
|
|
261
|
+
else arr.push(a.id);
|
|
262
|
+
return arr;
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
h('input', { type: 'checkbox', checked: checked, readOnly: true, style: _checkbox }),
|
|
267
|
+
h('div', { style: { flex: 1 } },
|
|
268
|
+
h('div', { style: { fontWeight: 500, fontSize: 13 } }, a.displayName || a.name || a.id),
|
|
269
|
+
a.role && h('div', { style: { fontSize: 11, color: 'var(--text-muted)' } }, a.role)
|
|
270
|
+
),
|
|
271
|
+
a.status && h('span', { className: 'badge badge-' + (a.status === 'active' || a.status === 'running' ? 'success' : 'neutral'), style: { fontSize: 9 } }, a.status)
|
|
272
|
+
);
|
|
273
|
+
})
|
|
274
|
+
),
|
|
275
|
+
!allAgentsAccess && Array.isArray(allowedAgents) && h('div', { style: { marginTop: 4, fontSize: 11, color: 'var(--text-muted)' } },
|
|
276
|
+
allowedAgents.length === 0 ? 'No agents selected — user will see no agents' : allowedAgents.length + ' agent' + (allowedAgents.length !== 1 ? 's' : '') + ' selected'
|
|
277
|
+
)
|
|
278
|
+
),
|
|
279
|
+
|
|
204
280
|
// Summary
|
|
205
281
|
h('div', { style: { marginTop: 12, padding: 8, background: 'var(--bg-tertiary)', borderRadius: 6, fontSize: 11, color: 'var(--text-muted)' } },
|
|
206
282
|
fullAccess
|
|
207
|
-
? 'This user has full access to all pages and
|
|
208
|
-
: 'Access to ' + Object.keys(grants).length + ' of ' + Object.keys(pageRegistry).length + ' pages
|
|
283
|
+
? 'This user has full access to all pages, tabs, and agents.'
|
|
284
|
+
: 'Access to ' + Object.keys(grants).length + ' of ' + Object.keys(pageRegistry).length + ' pages' +
|
|
285
|
+
(allAgentsAccess ? ', all agents.' : ', ' + (Array.isArray(allowedAgents) ? allowedAgents.length : 0) + ' agents.')
|
|
209
286
|
)
|
|
210
287
|
);
|
|
211
288
|
}
|
|
@@ -214,15 +291,31 @@ function PermissionEditor({ userId, userName, currentPerms, pageRegistry, onSave
|
|
|
214
291
|
|
|
215
292
|
function InlinePermissionPicker({ permissions, pageRegistry, onChange }) {
|
|
216
293
|
var [expandedPage, setExpandedPage] = useState(null);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
294
|
+
var [agents, setAgents] = useState([]);
|
|
295
|
+
useEffect(function() { apiCall('/agents').then(function(d) { setAgents(d.agents || d || []); }).catch(function() {}); }, []);
|
|
296
|
+
|
|
297
|
+
// Resolve grants from permissions (skip _allowedAgents)
|
|
298
|
+
var rawGrants = permissions === '*' ? (function() { var a = {}; Object.keys(pageRegistry).forEach(function(p) { a[p] = true; }); return a; })() : (permissions || {});
|
|
299
|
+
var grants = {};
|
|
300
|
+
Object.keys(rawGrants).forEach(function(k) { if (k !== '_allowedAgents') grants[k] = rawGrants[k]; });
|
|
301
|
+
var currentAllowed = permissions === '*' ? '*' : (rawGrants._allowedAgents || '*');
|
|
302
|
+
var allAgentsMode = currentAllowed === '*';
|
|
303
|
+
|
|
304
|
+
var emitChange = function(nextGrants, nextAllowed) {
|
|
305
|
+
var result = Object.assign({}, nextGrants);
|
|
306
|
+
if (nextAllowed !== undefined) result._allowedAgents = nextAllowed;
|
|
307
|
+
else if (currentAllowed !== '*') result._allowedAgents = currentAllowed;
|
|
308
|
+
var allPages = Object.keys(nextGrants).length === Object.keys(pageRegistry).length && Object.values(nextGrants).every(function(v) { return v === true; });
|
|
309
|
+
var allAg = (result._allowedAgents || '*') === '*';
|
|
310
|
+
if (allPages && allAg) return onChange('*');
|
|
311
|
+
onChange(result);
|
|
312
|
+
};
|
|
220
313
|
|
|
221
314
|
var togglePage = function(pid) {
|
|
222
315
|
var next = Object.assign({}, grants);
|
|
223
316
|
if (next[pid]) { delete next[pid]; if (expandedPage === pid) setExpandedPage(null); }
|
|
224
317
|
else { next[pid] = true; }
|
|
225
|
-
|
|
318
|
+
emitChange(next);
|
|
226
319
|
};
|
|
227
320
|
|
|
228
321
|
var toggleTab = function(pid, tabId) {
|
|
@@ -243,7 +336,7 @@ function InlinePermissionPicker({ permissions, pageRegistry, onChange }) {
|
|
|
243
336
|
next[pid] = newArr.length === allTabs.length ? true : newArr;
|
|
244
337
|
}
|
|
245
338
|
}
|
|
246
|
-
|
|
339
|
+
emitChange(next);
|
|
247
340
|
};
|
|
248
341
|
|
|
249
342
|
var isTabChecked = function(pid, tabId) {
|
|
@@ -288,7 +381,30 @@ function InlinePermissionPicker({ permissions, pageRegistry, onChange }) {
|
|
|
288
381
|
);
|
|
289
382
|
})
|
|
290
383
|
);
|
|
291
|
-
})
|
|
384
|
+
}),
|
|
385
|
+
// Agent access section
|
|
386
|
+
agents.length > 0 && h('div', { style: { marginTop: 8 } },
|
|
387
|
+
h('div', { style: { fontSize: 10, fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.05em', color: 'var(--text-muted)', padding: '4px 10px 2px' } }, 'Agent Access'),
|
|
388
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, padding: '4px 10px', fontSize: 12, cursor: 'pointer' }, onClick: function() {
|
|
389
|
+
emitChange(grants, allAgentsMode ? [] : '*');
|
|
390
|
+
} },
|
|
391
|
+
h('input', { type: 'checkbox', checked: allAgentsMode, readOnly: true, style: { width: 14, height: 14, accentColor: 'var(--primary)', cursor: 'pointer' } }),
|
|
392
|
+
h('span', { style: { fontWeight: 500 } }, 'All Agents')
|
|
393
|
+
),
|
|
394
|
+
!allAgentsMode && agents.map(function(a) {
|
|
395
|
+
var checked = Array.isArray(currentAllowed) && currentAllowed.indexOf(a.id) >= 0;
|
|
396
|
+
return h('div', { key: a.id, style: { display: 'flex', alignItems: 'center', gap: 8, padding: '3px 10px 3px 28px', fontSize: 11, cursor: 'pointer' }, onClick: function() {
|
|
397
|
+
var arr = Array.isArray(currentAllowed) ? currentAllowed.slice() : [];
|
|
398
|
+
var idx = arr.indexOf(a.id);
|
|
399
|
+
if (idx >= 0) arr.splice(idx, 1); else arr.push(a.id);
|
|
400
|
+
emitChange(grants, arr);
|
|
401
|
+
} },
|
|
402
|
+
h('input', { type: 'checkbox', checked: checked, readOnly: true, style: { width: 13, height: 13, accentColor: 'var(--primary)', cursor: 'pointer' } }),
|
|
403
|
+
h('span', null, a.displayName || a.name || a.id),
|
|
404
|
+
a.role && h('span', { style: { color: 'var(--text-muted)', marginLeft: 4 } }, '(' + a.role + ')')
|
|
405
|
+
);
|
|
406
|
+
})
|
|
407
|
+
)
|
|
292
408
|
);
|
|
293
409
|
}
|
|
294
410
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
provision,
|
|
3
3
|
runSetupWizard
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-633X6XDY.js";
|
|
5
5
|
import {
|
|
6
6
|
AgenticMailManager,
|
|
7
7
|
GoogleEmailProvider,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
requireRole,
|
|
43
43
|
securityHeaders,
|
|
44
44
|
validate
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-7FEEWUNJ.js";
|
|
46
46
|
import "./chunk-OF4MUWWS.js";
|
|
47
47
|
import {
|
|
48
48
|
PROVIDER_REGISTRY,
|
|
@@ -113,7 +113,7 @@ import {
|
|
|
113
113
|
import {
|
|
114
114
|
createAdapter,
|
|
115
115
|
getSupportedDatabases
|
|
116
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-55QVWFKC.js";
|
|
117
117
|
import {
|
|
118
118
|
AGENTICMAIL_TOOLS,
|
|
119
119
|
ALL_TOOLS,
|