@agenticmail/enterprise 0.5.16 → 0.5.17
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-4F3XGZWR.js +2295 -0
- package/dist/chunk-52DDMP6J.js +12666 -0
- package/dist/chunk-7JFYYBVR.js +1987 -0
- package/dist/chunk-BCDVBHJY.js +9080 -0
- package/dist/chunk-MCOXOTGK.js +889 -0
- package/dist/cli.js +1 -1
- package/dist/dashboard/components/utils.js +12 -0
- package/dist/dashboard/pages/activity.js +2 -2
- package/dist/dashboard/pages/agent-detail.js +12 -12
- package/dist/dashboard/pages/agents.js +4 -4
- package/dist/dashboard/pages/approvals.js +2 -2
- package/dist/dashboard/pages/community-skills.js +12 -12
- package/dist/dashboard/pages/compliance.js +4 -4
- package/dist/dashboard/pages/dashboard.js +3 -3
- package/dist/dashboard/pages/dlp.js +6 -6
- package/dist/dashboard/pages/guardrails.js +17 -17
- package/dist/dashboard/pages/journal.js +3 -3
- package/dist/dashboard/pages/knowledge-contributions.js +8 -8
- package/dist/dashboard/pages/knowledge.js +2 -2
- package/dist/dashboard/pages/messages.js +5 -5
- package/dist/dashboard/pages/settings.js +8 -8
- package/dist/dashboard/pages/skills.js +4 -4
- package/dist/dashboard/pages/vault.js +5 -5
- package/dist/dashboard/pages/workforce.js +2 -2
- package/dist/db-adapter-DZFYOL4K.js +7 -0
- package/dist/index.js +5 -5
- package/dist/routes-T6LJPTIF.js +5674 -0
- package/dist/runtime-O4FBRIDG.js +47 -0
- package/dist/server-47SBCNL5.js +11 -0
- package/dist/setup-QBFQ5AWO.js +20 -0
- package/package.json +1 -1
- package/src/dashboard/components/utils.js +12 -0
- package/src/dashboard/pages/activity.js +2 -2
- package/src/dashboard/pages/agent-detail.js +12 -12
- package/src/dashboard/pages/agents.js +4 -4
- package/src/dashboard/pages/approvals.js +2 -2
- package/src/dashboard/pages/community-skills.js +12 -12
- package/src/dashboard/pages/compliance.js +4 -4
- package/src/dashboard/pages/dashboard.js +3 -3
- package/src/dashboard/pages/dlp.js +6 -6
- package/src/dashboard/pages/guardrails.js +17 -17
- package/src/dashboard/pages/journal.js +3 -3
- package/src/dashboard/pages/knowledge-contributions.js +8 -8
- package/src/dashboard/pages/knowledge.js +2 -2
- package/src/dashboard/pages/messages.js +5 -5
- package/src/dashboard/pages/settings.js +8 -8
- package/src/dashboard/pages/skills.js +4 -4
- package/src/dashboard/pages/vault.js +5 -5
- package/src/dashboard/pages/workforce.js +2 -2
- package/src/engine/agent-memory.ts +3 -2
- package/src/engine/approvals.ts +2 -1
- package/src/engine/communication.ts +2 -1
- package/src/engine/compliance.ts +3 -2
- package/src/engine/db-adapter.ts +40 -34
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, useState, useEffect, Fragment, useApp, engineCall } from '../components/utils.js';
|
|
1
|
+
import { h, useState, useEffect, Fragment, useApp, engineCall , getOrgId } from '../components/utils.js';
|
|
2
2
|
import { I } from '../components/icons.js';
|
|
3
3
|
import { Modal } from '../components/modal.js';
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ export function KnowledgeBasePage() {
|
|
|
13
13
|
|
|
14
14
|
const create = async () => {
|
|
15
15
|
try {
|
|
16
|
-
await engineCall('/knowledge-bases', { method: 'POST', body: JSON.stringify({ name: form.name, description: form.description, orgId:
|
|
16
|
+
await engineCall('/knowledge-bases', { method: 'POST', body: JSON.stringify({ name: form.name, description: form.description, orgId: getOrgId() }) });
|
|
17
17
|
toast('Knowledge base created', 'success');
|
|
18
18
|
setCreating(false); setForm({ name: '', description: '' }); load();
|
|
19
19
|
} catch (e) { toast(e.message, 'error'); }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, useState, useEffect, useRef, Fragment, useApp, engineCall, buildAgentEmailMap, resolveAgentEmail, buildAgentDataMap, renderAgentBadge } from '../components/utils.js';
|
|
1
|
+
import { h, useState, useEffect, useRef, Fragment, useApp, engineCall, buildAgentEmailMap, resolveAgentEmail, buildAgentDataMap, renderAgentBadge , getOrgId } from '../components/utils.js';
|
|
2
2
|
import { I } from '../components/icons.js';
|
|
3
3
|
|
|
4
4
|
export function MessagesPage() {
|
|
@@ -9,19 +9,19 @@ export function MessagesPage() {
|
|
|
9
9
|
const [mainTab, setMainTab] = useState('messages');
|
|
10
10
|
const [subTab, setSubTab] = useState('all');
|
|
11
11
|
const [showModal, setShowModal] = useState(false);
|
|
12
|
-
const [form, setForm] = useState({ orgId:
|
|
12
|
+
const [form, setForm] = useState({ orgId: getOrgId(), fromAgentId: '', toAgentId: '', subject: '', content: '', priority: 'normal' });
|
|
13
13
|
const [selectedNode, setSelectedNode] = useState(null);
|
|
14
14
|
const [nodePositions, setNodePositions] = useState([]);
|
|
15
15
|
const svgRef = useRef(null);
|
|
16
16
|
|
|
17
17
|
const loadMessages = () => {
|
|
18
|
-
engineCall('/messages?orgId=
|
|
18
|
+
engineCall('/messages?orgId=' + getOrgId() + '&limit=100').then(d => setMessages(d.messages || [])).catch(() => {});
|
|
19
19
|
};
|
|
20
20
|
const loadAgents = () => {
|
|
21
|
-
engineCall('/agents?orgId=
|
|
21
|
+
engineCall('/agents?orgId=' + getOrgId()).then(d => setAgents(d.agents || [])).catch(() => {});
|
|
22
22
|
};
|
|
23
23
|
const loadTopology = () => {
|
|
24
|
-
engineCall('/messages/topology?orgId=
|
|
24
|
+
engineCall('/messages/topology?orgId=' + getOrgId()).then(d => setTopology(d.topology || null)).catch(() => {});
|
|
25
25
|
};
|
|
26
26
|
useEffect(() => { loadMessages(); loadAgents(); loadTopology(); }, []);
|
|
27
27
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, useState, useEffect, useCallback, Fragment, useApp, apiCall, engineCall, applyBrandColor, showConfirm } from '../components/utils.js';
|
|
1
|
+
import { h, useState, useEffect, useCallback, Fragment, useApp, apiCall, engineCall, applyBrandColor, showConfirm , getOrgId } from '../components/utils.js';
|
|
2
2
|
import { I } from '../components/icons.js';
|
|
3
3
|
import { Modal } from '../components/modal.js';
|
|
4
4
|
import { TagInput } from '../components/tag-input.js';
|
|
@@ -65,7 +65,7 @@ export function SettingsPage() {
|
|
|
65
65
|
oidcClientId: sso.oidc?.clientId || '', oidcClientSecret: sso.oidc?.clientSecret || '', oidcDiscoveryUrl: sso.oidc?.discoveryUrl || '',
|
|
66
66
|
}));
|
|
67
67
|
}).catch(() => {});
|
|
68
|
-
engineCall('/deploy-credentials?orgId=
|
|
68
|
+
engineCall('/deploy-credentials?orgId=' + getOrgId()).then(d => setDeployCreds(d.credentials || [])).catch(() => {});
|
|
69
69
|
apiCall('/settings/tool-security').then(d => {
|
|
70
70
|
var cfg = d.toolSecurityConfig || {};
|
|
71
71
|
setToolSec({
|
|
@@ -150,11 +150,11 @@ export function SettingsPage() {
|
|
|
150
150
|
|
|
151
151
|
const createDeployCred = async () => {
|
|
152
152
|
try {
|
|
153
|
-
await engineCall('/deploy-credentials', { method: 'POST', body: JSON.stringify({ orgId:
|
|
153
|
+
await engineCall('/deploy-credentials', { method: 'POST', body: JSON.stringify({ orgId: getOrgId(), name: deployForm.name, targetType: deployForm.targetType, config: deployForm.config }) });
|
|
154
154
|
toast('Credential created', 'success');
|
|
155
155
|
setShowDeployModal(false);
|
|
156
156
|
setDeployForm({ name: '', targetType: 'docker', config: {} });
|
|
157
|
-
engineCall('/deploy-credentials?orgId=
|
|
157
|
+
engineCall('/deploy-credentials?orgId=' + getOrgId()).then(d => setDeployCreds(d.credentials || [])).catch(() => {});
|
|
158
158
|
} catch (e) { toast(e.message, 'error'); }
|
|
159
159
|
};
|
|
160
160
|
|
|
@@ -639,7 +639,7 @@ function IntegrationsTab(props) {
|
|
|
639
639
|
|
|
640
640
|
var loadStatuses = useCallback(function() {
|
|
641
641
|
var promises = INTEGRATIONS.map(function(int) {
|
|
642
|
-
return engineCall('/oauth/status/' + int.skillId + '?orgId=
|
|
642
|
+
return engineCall('/oauth/status/' + int.skillId + '?orgId=' + getOrgId())
|
|
643
643
|
.then(function(d) { return { skillId: int.skillId, connected: d.connected, expiresAt: d.expiresAt }; })
|
|
644
644
|
.catch(function() { return { skillId: int.skillId, connected: false }; });
|
|
645
645
|
});
|
|
@@ -660,7 +660,7 @@ function IntegrationsTab(props) {
|
|
|
660
660
|
return;
|
|
661
661
|
}
|
|
662
662
|
setActionLoading(int.skillId);
|
|
663
|
-
engineCall('/oauth/authorize/' + int.skillId + '?orgId=
|
|
663
|
+
engineCall('/oauth/authorize/' + int.skillId + '?orgId=' + getOrgId())
|
|
664
664
|
.then(function(d) {
|
|
665
665
|
if (d.authorizationUrl) {
|
|
666
666
|
var popup = window.open(d.authorizationUrl, 'oauth_connect', 'width=600,height=700,popup=yes');
|
|
@@ -688,7 +688,7 @@ function IntegrationsTab(props) {
|
|
|
688
688
|
.then(function(ok) {
|
|
689
689
|
if (!ok) return;
|
|
690
690
|
setActionLoading(int.skillId);
|
|
691
|
-
engineCall('/oauth/disconnect/' + int.skillId + '?orgId=
|
|
691
|
+
engineCall('/oauth/disconnect/' + int.skillId + '?orgId=' + getOrgId() + '', { method: 'DELETE' })
|
|
692
692
|
.then(function() { toast(int.name + ' disconnected', 'success'); loadStatuses(); })
|
|
693
693
|
.catch(function(e) { toast('Failed: ' + e.message, 'error'); })
|
|
694
694
|
.finally(function() { setActionLoading(null); });
|
|
@@ -698,7 +698,7 @@ function IntegrationsTab(props) {
|
|
|
698
698
|
var handleSaveToken = function() {
|
|
699
699
|
if (!tokenModal || !tokenValue.trim()) return;
|
|
700
700
|
setActionLoading(tokenModal.skillId);
|
|
701
|
-
engineCall('/oauth/authorize/' + tokenModal.skillId + '?orgId=
|
|
701
|
+
engineCall('/oauth/authorize/' + tokenModal.skillId + '?orgId=' + getOrgId() + '', {
|
|
702
702
|
method: 'POST',
|
|
703
703
|
body: JSON.stringify({ token: tokenValue.trim() })
|
|
704
704
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, useState, useEffect, useCallback, Fragment, useApp, engineCall } from '../components/utils.js';
|
|
1
|
+
import { h, useState, useEffect, useCallback, Fragment, useApp, engineCall , getOrgId } from '../components/utils.js';
|
|
2
2
|
import { I } from '../components/icons.js';
|
|
3
3
|
import { Modal } from '../components/modal.js';
|
|
4
4
|
|
|
@@ -52,7 +52,7 @@ export function SkillsPage() {
|
|
|
52
52
|
// Load installed skills + statuses
|
|
53
53
|
var loadInstalled = useCallback(function() {
|
|
54
54
|
setInstalledLoading(true);
|
|
55
|
-
engineCall('/community/installed?orgId=
|
|
55
|
+
engineCall('/community/installed?orgId=' + getOrgId())
|
|
56
56
|
.then(function(d) {
|
|
57
57
|
var items = d.installed || [];
|
|
58
58
|
setInstalled(items);
|
|
@@ -159,7 +159,7 @@ export function SkillsPage() {
|
|
|
159
159
|
try {
|
|
160
160
|
await engineCall('/community/skills/' + skillId + '/' + (enable ? 'enable' : 'disable'), {
|
|
161
161
|
method: 'PUT',
|
|
162
|
-
body: JSON.stringify({ orgId:
|
|
162
|
+
body: JSON.stringify({ orgId: getOrgId() })
|
|
163
163
|
});
|
|
164
164
|
toast('Skill ' + (enable ? 'enabled' : 'disabled'), 'success');
|
|
165
165
|
loadInstalled();
|
|
@@ -177,7 +177,7 @@ export function SkillsPage() {
|
|
|
177
177
|
try {
|
|
178
178
|
await engineCall('/community/skills/' + skillId + '/uninstall', {
|
|
179
179
|
method: 'DELETE',
|
|
180
|
-
body: JSON.stringify({ orgId:
|
|
180
|
+
body: JSON.stringify({ orgId: getOrgId() })
|
|
181
181
|
});
|
|
182
182
|
toast('Skill uninstalled', 'success');
|
|
183
183
|
loadInstalled();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, useState, useEffect, useCallback, Fragment, useApp, engineCall } from '../components/utils.js';
|
|
1
|
+
import { h, useState, useEffect, useCallback, Fragment, useApp, engineCall , getOrgId } from '../components/utils.js';
|
|
2
2
|
import { I } from '../components/icons.js';
|
|
3
3
|
import { Modal } from '../components/modal.js';
|
|
4
4
|
|
|
@@ -63,7 +63,7 @@ export function VaultPage() {
|
|
|
63
63
|
// Load secrets
|
|
64
64
|
var loadSecrets = useCallback(function() {
|
|
65
65
|
setLoading(true);
|
|
66
|
-
engineCall('/vault/secrets?orgId=
|
|
66
|
+
engineCall('/vault/secrets?orgId=' + getOrgId())
|
|
67
67
|
.then(function(d) { setSecrets(d.secrets || d.entries || []); })
|
|
68
68
|
.catch(function(e) { toast(e.message || 'Failed to load secrets', 'error'); })
|
|
69
69
|
.finally(function() { setLoading(false); });
|
|
@@ -71,7 +71,7 @@ export function VaultPage() {
|
|
|
71
71
|
|
|
72
72
|
var loadAudit = useCallback(function() {
|
|
73
73
|
setAuditLoading(true);
|
|
74
|
-
engineCall('/vault/audit-log?orgId=
|
|
74
|
+
engineCall('/vault/audit-log?orgId=' + getOrgId() + '&limit=100')
|
|
75
75
|
.then(function(d) { setAuditLog(d.entries || d.log || []); })
|
|
76
76
|
.catch(function(e) { toast(e.message || 'Failed to load audit log', 'error'); })
|
|
77
77
|
.finally(function() { setAuditLoading(false); });
|
|
@@ -94,7 +94,7 @@ export function VaultPage() {
|
|
|
94
94
|
await engineCall('/vault/secrets', {
|
|
95
95
|
method: 'POST',
|
|
96
96
|
body: JSON.stringify({
|
|
97
|
-
orgId:
|
|
97
|
+
orgId: getOrgId(),
|
|
98
98
|
name: addForm.name,
|
|
99
99
|
value: addForm.value,
|
|
100
100
|
category: addForm.category
|
|
@@ -169,7 +169,7 @@ export function VaultPage() {
|
|
|
169
169
|
try {
|
|
170
170
|
var d = await engineCall('/vault/rotate-all', {
|
|
171
171
|
method: 'POST',
|
|
172
|
-
body: JSON.stringify({ orgId:
|
|
172
|
+
body: JSON.stringify({ orgId: getOrgId() })
|
|
173
173
|
});
|
|
174
174
|
toast('Rotated ' + (d.rotated || 0) + ' secrets', 'success');
|
|
175
175
|
loadSecrets();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, useState, useEffect, useCallback, Fragment, useApp, engineCall, buildAgentEmailMap, resolveAgentEmail, buildAgentDataMap, renderAgentBadge } from '../components/utils.js';
|
|
1
|
+
import { h, useState, useEffect, useCallback, Fragment, useApp, engineCall, buildAgentEmailMap, resolveAgentEmail, buildAgentDataMap, renderAgentBadge , getOrgId } from '../components/utils.js';
|
|
2
2
|
import { I } from '../components/icons.js';
|
|
3
3
|
|
|
4
4
|
export function WorkforcePage() {
|
|
@@ -42,7 +42,7 @@ export function WorkforcePage() {
|
|
|
42
42
|
setSchedules(schedulesRes.schedules || []);
|
|
43
43
|
setBudgetData(budgetRes);
|
|
44
44
|
setClockRecords(recordsRes.records || []);
|
|
45
|
-
engineCall('/agents?orgId=
|
|
45
|
+
engineCall('/agents?orgId=' + getOrgId()).then(d => setAgents(d.agents || [])).catch(() => {});
|
|
46
46
|
} catch (err) { toast('Failed to load workforce data', 'error'); }
|
|
47
47
|
setLoading(false);
|
|
48
48
|
};
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import type { EngineDatabase } from './db-adapter.js';
|
|
17
17
|
import { MemorySearchIndex, tokenize } from '../lib/text-search.js';
|
|
18
18
|
|
|
19
|
+
function sj(v: string|null|undefined, fb: any = {}): any { if(!v) return fb; try { return JSON.parse(v); } catch { return fb; } }
|
|
19
20
|
// ─── Types ──────────────────────────────────────────────
|
|
20
21
|
|
|
21
22
|
export type MemoryCategory =
|
|
@@ -702,8 +703,8 @@ export class AgentMemoryManager {
|
|
|
702
703
|
accessCount: row.access_count || 0,
|
|
703
704
|
lastAccessedAt: row.last_accessed_at || undefined,
|
|
704
705
|
expiresAt: row.expires_at || undefined,
|
|
705
|
-
tags:
|
|
706
|
-
metadata:
|
|
706
|
+
tags: sj(row.tags || '[]'),
|
|
707
|
+
metadata: sj(row.metadata || '{}'),
|
|
707
708
|
createdAt: row.created_at,
|
|
708
709
|
updatedAt: row.updated_at,
|
|
709
710
|
};
|
package/src/engine/approvals.ts
CHANGED
|
@@ -103,6 +103,7 @@ export interface EscalationState {
|
|
|
103
103
|
|
|
104
104
|
import type { EngineDatabase } from './db-adapter.js';
|
|
105
105
|
|
|
106
|
+
function sj(v: string|null|undefined, fb: any = {}): any { if(!v) return fb; try { return JSON.parse(v); } catch { return fb; } }
|
|
106
107
|
export class ApprovalEngine {
|
|
107
108
|
private requests = new Map<string, ApprovalRequest>();
|
|
108
109
|
private policies: ApprovalPolicy[] = [];
|
|
@@ -146,7 +147,7 @@ export class ApprovalEngine {
|
|
|
146
147
|
for (const r of chains) {
|
|
147
148
|
this.escalationChains.set(r.id, {
|
|
148
149
|
id: r.id, orgId: r.org_id, name: r.name, description: r.description,
|
|
149
|
-
levels:
|
|
150
|
+
levels: sj(r.levels), fallbackAction: r.fallback_action,
|
|
150
151
|
enabled: !!r.enabled, createdAt: r.created_at, updatedAt: r.updated_at,
|
|
151
152
|
});
|
|
152
153
|
}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import type { EngineDatabase } from './db-adapter.js';
|
|
26
26
|
import type { AgentLifecycleManager } from './lifecycle.js';
|
|
27
27
|
|
|
28
|
+
function sj(v: string|null|undefined, fb: any = {}): any { if(!v) return fb; try { return JSON.parse(v); } catch { return fb; } }
|
|
28
29
|
// ─── Types ──────────────────────────────────────────────
|
|
29
30
|
|
|
30
31
|
export type MessageType = 'message' | 'task' | 'handoff' | 'broadcast';
|
|
@@ -217,7 +218,7 @@ export class AgentCommunicationBus {
|
|
|
217
218
|
this.messages = rows.map((r: any) => ({
|
|
218
219
|
id: r.id, orgId: r.org_id, fromAgentId: r.from_agent_id, toAgentId: r.to_agent_id,
|
|
219
220
|
type: r.type, subject: r.subject, content: r.content,
|
|
220
|
-
metadata: r.metadata ?
|
|
221
|
+
metadata: r.metadata ? sj(r.metadata) : {},
|
|
221
222
|
status: r.status, parentId: r.parent_id, priority: r.priority || 'normal',
|
|
222
223
|
direction: r.direction || 'internal', channel: r.channel || 'direct',
|
|
223
224
|
deadline: r.deadline, claimedAt: r.claimed_at, completedAt: r.completed_at,
|
package/src/engine/compliance.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import type { EngineDatabase } from './db-adapter.js';
|
|
13
13
|
|
|
14
|
+
function sj(v: string|null|undefined, fb: any = {}): any { if(!v) return fb; try { return JSON.parse(v); } catch { return fb; } }
|
|
14
15
|
// ─── Types ──────────────────────────────────────────────
|
|
15
16
|
|
|
16
17
|
export interface ComplianceReport {
|
|
@@ -47,8 +48,8 @@ export class ComplianceReporter {
|
|
|
47
48
|
);
|
|
48
49
|
this.reports = rows.map((r: any) => ({
|
|
49
50
|
id: r.id, orgId: r.org_id, type: r.type, title: r.title,
|
|
50
|
-
parameters: r.parameters ?
|
|
51
|
-
status: r.status, data: r.data ?
|
|
51
|
+
parameters: r.parameters ? sj(r.parameters) : {},
|
|
52
|
+
status: r.status, data: r.data ? sj(r.data) : undefined,
|
|
52
53
|
format: r.format || 'json', generatedBy: r.generated_by,
|
|
53
54
|
error: r.error, createdAt: r.created_at, completedAt: r.completed_at,
|
|
54
55
|
}));
|
package/src/engine/db-adapter.ts
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { ManagedAgent, AgentState, StateTransition, AgentUsage, LifecycleEvent } from './lifecycle.js';
|
|
11
|
+
|
|
12
|
+
/** Safe JSON parse — returns fallback on malformed data instead of throwing */
|
|
13
|
+
function sj(val: string | null | undefined, fallback: any = {}): any {
|
|
14
|
+
if (!val) return fallback;
|
|
15
|
+
try { return JSON.parse(val); } catch { return fallback; }
|
|
16
|
+
}
|
|
11
17
|
import type { AgentPermissionProfile } from './skills.js';
|
|
12
18
|
import type { Organization, OrgPlan } from './tenant.js';
|
|
13
19
|
import type { ApprovalRequest, ApprovalPolicy } from './approvals.js';
|
|
@@ -292,12 +298,12 @@ export class EngineDatabase {
|
|
|
292
298
|
|
|
293
299
|
async getPermissionProfile(id: string): Promise<AgentPermissionProfile | null> {
|
|
294
300
|
const row = await this.db.get<any>('SELECT * FROM permission_profiles WHERE id = ?', [id]);
|
|
295
|
-
return row ?
|
|
301
|
+
return row ? sj(row.config) : null;
|
|
296
302
|
}
|
|
297
303
|
|
|
298
304
|
async getPermissionProfilesByOrg(orgId: string): Promise<AgentPermissionProfile[]> {
|
|
299
305
|
const rows = await this.db.all<any>('SELECT config FROM permission_profiles WHERE org_id = ? ORDER BY name', [orgId]);
|
|
300
|
-
return rows.map(r =>
|
|
306
|
+
return rows.map(r => sj(r.config));
|
|
301
307
|
}
|
|
302
308
|
|
|
303
309
|
async deletePermissionProfile(id: string): Promise<void> {
|
|
@@ -365,8 +371,8 @@ export class EngineDatabase {
|
|
|
365
371
|
if (!row) return null;
|
|
366
372
|
const kb: any = {
|
|
367
373
|
id: row.id, orgId: row.org_id, name: row.name, description: row.description,
|
|
368
|
-
agentIds:
|
|
369
|
-
stats:
|
|
374
|
+
agentIds: sj(row.agent_ids), config: sj(row.config),
|
|
375
|
+
stats: sj(row.stats), createdAt: row.created_at, updatedAt: row.updated_at,
|
|
370
376
|
documents: [],
|
|
371
377
|
};
|
|
372
378
|
// Load documents
|
|
@@ -378,8 +384,8 @@ export class EngineDatabase {
|
|
|
378
384
|
const rows = await this.db.all<any>('SELECT * FROM knowledge_bases WHERE org_id = ? ORDER BY name', [orgId]);
|
|
379
385
|
return rows.map(r => ({
|
|
380
386
|
id: r.id, orgId: r.org_id, name: r.name, description: r.description,
|
|
381
|
-
agentIds:
|
|
382
|
-
stats:
|
|
387
|
+
agentIds: sj(r.agent_ids), config: sj(r.config),
|
|
388
|
+
stats: sj(r.stats), createdAt: r.created_at, updatedAt: r.updated_at,
|
|
383
389
|
documents: [], // Loaded on demand
|
|
384
390
|
}));
|
|
385
391
|
}
|
|
@@ -422,13 +428,13 @@ export class EngineDatabase {
|
|
|
422
428
|
result.push({
|
|
423
429
|
id: d.id, knowledgeBaseId: d.knowledge_base_id, name: d.name,
|
|
424
430
|
sourceType: d.source_type, sourceUrl: d.source_url, mimeType: d.mime_type,
|
|
425
|
-
size: d.size, metadata:
|
|
431
|
+
size: d.size, metadata: sj(d.metadata), status: d.status, error: d.error,
|
|
426
432
|
createdAt: d.created_at, updatedAt: d.updated_at,
|
|
427
433
|
chunks: chunks.map((c: any) => ({
|
|
428
434
|
id: c.id, documentId: c.document_id, content: c.content,
|
|
429
435
|
tokenCount: c.token_count, position: c.position,
|
|
430
436
|
embedding: c.embedding ? Array.from(new Float32Array(c.embedding)) : undefined,
|
|
431
|
-
metadata:
|
|
437
|
+
metadata: sj(c.metadata),
|
|
432
438
|
})),
|
|
433
439
|
});
|
|
434
440
|
}
|
|
@@ -473,10 +479,10 @@ export class EngineDatabase {
|
|
|
473
479
|
const rows = await this.db.all<any>(`SELECT * FROM tool_calls ${where} ORDER BY created_at DESC LIMIT ?`, params);
|
|
474
480
|
return rows.map(r => ({
|
|
475
481
|
id: r.id, agentId: r.agent_id, orgId: r.org_id, sessionId: r.session_id,
|
|
476
|
-
toolId: r.tool_id, toolName: r.tool_name, parameters:
|
|
477
|
-
result: r.result ?
|
|
478
|
-
timing:
|
|
479
|
-
permission:
|
|
482
|
+
toolId: r.tool_id, toolName: r.tool_name, parameters: sj(r.parameters || '{}'),
|
|
483
|
+
result: r.result ? sj(r.result) : undefined,
|
|
484
|
+
timing: sj(r.timing), cost: r.cost ? sj(r.cost) : undefined,
|
|
485
|
+
permission: sj(r.permission),
|
|
480
486
|
}));
|
|
481
487
|
}
|
|
482
488
|
|
|
@@ -501,7 +507,7 @@ export class EngineDatabase {
|
|
|
501
507
|
const rows = await this.db.all<any>(`SELECT * FROM activity_events ${where} ORDER BY created_at DESC LIMIT ?`, params);
|
|
502
508
|
return rows.map(r => ({
|
|
503
509
|
id: r.id, agentId: r.agent_id, orgId: r.org_id, sessionId: r.session_id,
|
|
504
|
-
type: r.type, data:
|
|
510
|
+
type: r.type, data: sj(r.data), timestamp: r.created_at,
|
|
505
511
|
}));
|
|
506
512
|
}
|
|
507
513
|
|
|
@@ -526,7 +532,7 @@ export class EngineDatabase {
|
|
|
526
532
|
return rows.map(r => ({
|
|
527
533
|
id: r.id, agentId: r.agent_id, sessionId: r.session_id, role: r.role,
|
|
528
534
|
content: r.content, channel: r.channel, tokenCount: r.token_count,
|
|
529
|
-
toolCalls: r.tool_calls ?
|
|
535
|
+
toolCalls: r.tool_calls ? sj(r.tool_calls) : undefined, timestamp: r.created_at,
|
|
530
536
|
}));
|
|
531
537
|
}
|
|
532
538
|
|
|
@@ -564,9 +570,9 @@ export class EngineDatabase {
|
|
|
564
570
|
return rows.map(r => ({
|
|
565
571
|
id: r.id, agentId: r.agent_id, agentName: r.agent_name, toolId: r.tool_id,
|
|
566
572
|
toolName: r.tool_name, reason: r.reason, riskLevel: r.risk_level,
|
|
567
|
-
sideEffects:
|
|
573
|
+
sideEffects: sj(r.side_effects), parameters: r.parameters ? sj(r.parameters) : undefined,
|
|
568
574
|
context: r.context, status: r.status,
|
|
569
|
-
decision: r.decision ?
|
|
575
|
+
decision: r.decision ? sj(r.decision) : undefined,
|
|
570
576
|
createdAt: r.created_at, expiresAt: r.expires_at,
|
|
571
577
|
}));
|
|
572
578
|
}
|
|
@@ -594,8 +600,8 @@ export class EngineDatabase {
|
|
|
594
600
|
const rows = await this.db.all<any>('SELECT * FROM approval_policies WHERE org_id = ? ORDER BY name', [orgId]);
|
|
595
601
|
return rows.map(r => ({
|
|
596
602
|
id: r.id, name: r.name, description: r.description,
|
|
597
|
-
triggers:
|
|
598
|
-
timeout:
|
|
603
|
+
triggers: sj(r.triggers), approvers: sj(r.approvers),
|
|
604
|
+
timeout: sj(r.timeout), notify: sj(r.notify),
|
|
599
605
|
enabled: !!r.enabled,
|
|
600
606
|
}));
|
|
601
607
|
}
|
|
@@ -604,8 +610,8 @@ export class EngineDatabase {
|
|
|
604
610
|
const rows = await this.db.all<any>('SELECT * FROM approval_policies WHERE enabled = 1 ORDER BY name');
|
|
605
611
|
return rows.map(r => ({
|
|
606
612
|
id: r.id, name: r.name, description: r.description,
|
|
607
|
-
triggers:
|
|
608
|
-
timeout:
|
|
613
|
+
triggers: sj(r.triggers), approvers: sj(r.approvers),
|
|
614
|
+
timeout: sj(r.timeout), notify: sj(r.notify),
|
|
609
615
|
enabled: !!r.enabled,
|
|
610
616
|
}));
|
|
611
617
|
}
|
|
@@ -657,7 +663,7 @@ export class EngineDatabase {
|
|
|
657
663
|
private rowToSso(row: any) {
|
|
658
664
|
return {
|
|
659
665
|
id: row.id, orgId: row.org_id, providerType: row.provider_type,
|
|
660
|
-
name: row.name, enabled: !!row.enabled, config:
|
|
666
|
+
name: row.name, enabled: !!row.enabled, config: sj(row.config),
|
|
661
667
|
metadataUrl: row.metadata_url, createdAt: row.created_at, updatedAt: row.updated_at,
|
|
662
668
|
};
|
|
663
669
|
}
|
|
@@ -739,7 +745,7 @@ export class EngineDatabase {
|
|
|
739
745
|
private rowToDeployCred(row: any) {
|
|
740
746
|
return {
|
|
741
747
|
id: row.id, orgId: row.org_id, name: row.name, targetType: row.target_type,
|
|
742
|
-
config:
|
|
748
|
+
config: sj(row.config), createdBy: row.created_by,
|
|
743
749
|
createdAt: row.created_at, updatedAt: row.updated_at,
|
|
744
750
|
};
|
|
745
751
|
}
|
|
@@ -977,8 +983,8 @@ export class EngineDatabase {
|
|
|
977
983
|
id: row.id, name: row.name, description: row.description, version: row.version,
|
|
978
984
|
author: row.author, repository: row.repository, license: row.license,
|
|
979
985
|
category: row.category, risk: row.risk, icon: row.icon,
|
|
980
|
-
tags:
|
|
981
|
-
configSchema:
|
|
986
|
+
tags: sj(row.tags || '[]'), tools: sj(row.tools || '[]'),
|
|
987
|
+
configSchema: sj(row.config_schema || '{}'),
|
|
982
988
|
minEngineVersion: row.min_engine_version, homepage: row.homepage,
|
|
983
989
|
downloads: row.downloads, rating: row.rating, ratingCount: row.rating_count,
|
|
984
990
|
verified: !!row.verified, featured: !!row.featured,
|
|
@@ -989,7 +995,7 @@ export class EngineDatabase {
|
|
|
989
995
|
private rowToInstalledSkill(row: any) {
|
|
990
996
|
return {
|
|
991
997
|
id: row.id, orgId: row.org_id, skillId: row.skill_id, version: row.version,
|
|
992
|
-
enabled: !!row.enabled, config:
|
|
998
|
+
enabled: !!row.enabled, config: sj(row.config || '{}'),
|
|
993
999
|
installedBy: row.installed_by, installedAt: row.installed_at, updatedAt: row.updated_at,
|
|
994
1000
|
};
|
|
995
1001
|
}
|
|
@@ -998,11 +1004,11 @@ export class EngineDatabase {
|
|
|
998
1004
|
return {
|
|
999
1005
|
id: row.id,
|
|
1000
1006
|
orgId: row.org_id,
|
|
1001
|
-
config:
|
|
1007
|
+
config: sj(row.config),
|
|
1002
1008
|
state: row.state,
|
|
1003
1009
|
stateHistory: [], // Loaded separately via getStateHistory
|
|
1004
|
-
health:
|
|
1005
|
-
usage:
|
|
1010
|
+
health: sj(row.health || '{}'),
|
|
1011
|
+
usage: sj(row.usage || '{}'),
|
|
1006
1012
|
createdAt: row.created_at,
|
|
1007
1013
|
updatedAt: row.updated_at,
|
|
1008
1014
|
lastDeployedAt: row.last_deployed_at,
|
|
@@ -1017,12 +1023,12 @@ export class EngineDatabase {
|
|
|
1017
1023
|
name: row.name,
|
|
1018
1024
|
slug: row.slug,
|
|
1019
1025
|
plan: row.plan as OrgPlan,
|
|
1020
|
-
limits:
|
|
1021
|
-
usage:
|
|
1022
|
-
settings:
|
|
1023
|
-
ssoConfig: row.sso_config ?
|
|
1024
|
-
allowedDomains:
|
|
1025
|
-
billing: row.billing ?
|
|
1026
|
+
limits: sj(row.limits || '{}'),
|
|
1027
|
+
usage: sj(row.usage || '{}'),
|
|
1028
|
+
settings: sj(row.settings || '{}'),
|
|
1029
|
+
ssoConfig: row.sso_config ? sj(row.sso_config) : undefined,
|
|
1030
|
+
allowedDomains: sj(row.allowed_domains || '[]'),
|
|
1031
|
+
billing: row.billing ? sj(row.billing) : undefined,
|
|
1026
1032
|
createdAt: row.created_at,
|
|
1027
1033
|
updatedAt: row.updated_at,
|
|
1028
1034
|
};
|