@agenticmail/enterprise 0.5.16 → 0.5.18

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.
Files changed (68) hide show
  1. package/dist/chunk-4F3XGZWR.js +2295 -0
  2. package/dist/chunk-52DDMP6J.js +12666 -0
  3. package/dist/chunk-5M2VVNE5.js +48 -0
  4. package/dist/chunk-76X3FKF5.js +898 -0
  5. package/dist/chunk-7JFYYBVR.js +1987 -0
  6. package/dist/chunk-BCDVBHJY.js +9080 -0
  7. package/dist/chunk-MCOXOTGK.js +889 -0
  8. package/dist/chunk-XNN7WCIP.js +1987 -0
  9. package/dist/cli-recover-UHALNDIN.js +97 -0
  10. package/dist/cli-verify-CN5WNXQI.js +98 -0
  11. package/dist/cli.js +3 -3
  12. package/dist/dashboard/app.js +2 -2
  13. package/dist/dashboard/components/utils.js +19 -0
  14. package/dist/dashboard/pages/activity.js +2 -2
  15. package/dist/dashboard/pages/agent-detail.js +12 -12
  16. package/dist/dashboard/pages/agents.js +4 -4
  17. package/dist/dashboard/pages/approvals.js +2 -2
  18. package/dist/dashboard/pages/community-skills.js +12 -12
  19. package/dist/dashboard/pages/compliance.js +4 -4
  20. package/dist/dashboard/pages/dashboard.js +3 -3
  21. package/dist/dashboard/pages/dlp.js +6 -6
  22. package/dist/dashboard/pages/guardrails.js +17 -17
  23. package/dist/dashboard/pages/journal.js +3 -3
  24. package/dist/dashboard/pages/knowledge-contributions.js +8 -8
  25. package/dist/dashboard/pages/knowledge.js +2 -2
  26. package/dist/dashboard/pages/messages.js +5 -5
  27. package/dist/dashboard/pages/settings.js +9 -9
  28. package/dist/dashboard/pages/skills.js +4 -4
  29. package/dist/dashboard/pages/vault.js +5 -5
  30. package/dist/dashboard/pages/workforce.js +2 -2
  31. package/dist/db-adapter-DZFYOL4K.js +7 -0
  32. package/dist/factory-5C7EC3SE.js +9 -0
  33. package/dist/index.js +6 -6
  34. package/dist/postgres-KG3QMSFU.js +587 -0
  35. package/dist/routes-T6LJPTIF.js +5674 -0
  36. package/dist/runtime-O4FBRIDG.js +47 -0
  37. package/dist/server-47SBCNL5.js +11 -0
  38. package/dist/server-E5KEUNLI.js +11 -0
  39. package/dist/setup-HAVYNSWT.js +20 -0
  40. package/dist/setup-QBFQ5AWO.js +20 -0
  41. package/package.json +1 -1
  42. package/src/dashboard/app.js +2 -2
  43. package/src/dashboard/components/utils.js +19 -0
  44. package/src/dashboard/pages/activity.js +2 -2
  45. package/src/dashboard/pages/agent-detail.js +12 -12
  46. package/src/dashboard/pages/agents.js +4 -4
  47. package/src/dashboard/pages/approvals.js +2 -2
  48. package/src/dashboard/pages/community-skills.js +12 -12
  49. package/src/dashboard/pages/compliance.js +4 -4
  50. package/src/dashboard/pages/dashboard.js +3 -3
  51. package/src/dashboard/pages/dlp.js +6 -6
  52. package/src/dashboard/pages/guardrails.js +17 -17
  53. package/src/dashboard/pages/journal.js +3 -3
  54. package/src/dashboard/pages/knowledge-contributions.js +8 -8
  55. package/src/dashboard/pages/knowledge.js +2 -2
  56. package/src/dashboard/pages/messages.js +5 -5
  57. package/src/dashboard/pages/settings.js +9 -9
  58. package/src/dashboard/pages/skills.js +4 -4
  59. package/src/dashboard/pages/vault.js +5 -5
  60. package/src/dashboard/pages/workforce.js +2 -2
  61. package/src/db/adapter.ts +1 -0
  62. package/src/db/postgres.ts +6 -2
  63. package/src/engine/agent-memory.ts +3 -2
  64. package/src/engine/approvals.ts +2 -1
  65. package/src/engine/communication.ts +2 -1
  66. package/src/engine/compliance.ts +3 -2
  67. package/src/engine/db-adapter.ts +40 -34
  68. package/src/setup/provision.ts +14 -3
@@ -0,0 +1,97 @@
1
+ import {
2
+ DomainLock
3
+ } from "./chunk-UPU23ZRG.js";
4
+ import "./chunk-KFQGP6VL.js";
5
+
6
+ // src/domain-lock/cli-recover.ts
7
+ function getFlag(args, name) {
8
+ const idx = args.indexOf(name);
9
+ if (idx !== -1 && args[idx + 1]) return args[idx + 1];
10
+ return void 0;
11
+ }
12
+ async function runRecover(args) {
13
+ const { default: inquirer } = await import("inquirer");
14
+ const { default: chalk } = await import("chalk");
15
+ const { default: ora } = await import("ora");
16
+ console.log("");
17
+ console.log(chalk.bold(" AgenticMail Enterprise \u2014 Domain Recovery"));
18
+ console.log(chalk.dim(" Recover your domain registration on a new machine."));
19
+ console.log("");
20
+ let domain = getFlag(args, "--domain");
21
+ if (!domain) {
22
+ const answer = await inquirer.prompt([{
23
+ type: "input",
24
+ name: "domain",
25
+ message: "Domain to recover:",
26
+ suffix: chalk.dim(" (e.g. agents.agenticmail.io)"),
27
+ validate: (v) => v.includes(".") || "Enter a valid domain"
28
+ }]);
29
+ domain = answer.domain;
30
+ }
31
+ let key = getFlag(args, "--key");
32
+ if (!key) {
33
+ const answer = await inquirer.prompt([{
34
+ type: "password",
35
+ name: "key",
36
+ message: "Deployment key:",
37
+ mask: "*",
38
+ validate: (v) => {
39
+ if (v.length !== 64) return "Deployment key should be 64 hex characters";
40
+ if (!/^[0-9a-fA-F]+$/.test(v)) return "Deployment key should be hexadecimal";
41
+ return true;
42
+ }
43
+ }]);
44
+ key = answer.key;
45
+ }
46
+ const spinner = ora("Contacting AgenticMail registry...").start();
47
+ const lock = new DomainLock();
48
+ const result = await lock.recover(domain, key);
49
+ if (!result.success) {
50
+ spinner.fail("Recovery failed");
51
+ console.log("");
52
+ console.error(chalk.red(` ${result.error}`));
53
+ console.log("");
54
+ process.exit(1);
55
+ }
56
+ spinner.succeed("Domain recovery initiated");
57
+ const { default: bcrypt } = await import("bcryptjs");
58
+ const keyHash = await bcrypt.hash(key, 12);
59
+ const dbPath = getFlag(args, "--db");
60
+ const dbType = getFlag(args, "--db-type") || "sqlite";
61
+ if (dbPath) {
62
+ try {
63
+ const spinnerDb = ora("Saving to local database...").start();
64
+ const { createAdapter } = await import("./factory-5C7EC3SE.js");
65
+ const db = await createAdapter({ type: dbType, connectionString: dbPath });
66
+ await db.migrate();
67
+ await db.updateSettings({
68
+ domain,
69
+ deploymentKeyHash: keyHash,
70
+ domainRegistrationId: result.registrationId,
71
+ domainDnsChallenge: result.dnsChallenge,
72
+ domainRegisteredAt: (/* @__PURE__ */ new Date()).toISOString(),
73
+ domainStatus: "pending_dns"
74
+ });
75
+ spinnerDb.succeed("Local database updated");
76
+ await db.disconnect();
77
+ } catch (err) {
78
+ console.log(chalk.yellow(`
79
+ Could not update local DB: ${err.message}`));
80
+ console.log(chalk.dim(" You can manually update settings after setup."));
81
+ }
82
+ }
83
+ console.log("");
84
+ console.log(chalk.green.bold(" Domain recovery successful!"));
85
+ console.log("");
86
+ console.log(chalk.bold(" Update your DNS TXT record:"));
87
+ console.log("");
88
+ console.log(` ${chalk.bold("Host:")} ${chalk.cyan(`_agenticmail-verify.${domain}`)}`);
89
+ console.log(` ${chalk.bold("Type:")} ${chalk.cyan("TXT")}`);
90
+ console.log(` ${chalk.bold("Value:")} ${chalk.cyan(result.dnsChallenge)}`);
91
+ console.log("");
92
+ console.log(chalk.dim(" Then run: npx @agenticmail/enterprise verify-domain"));
93
+ console.log("");
94
+ }
95
+ export {
96
+ runRecover
97
+ };
@@ -0,0 +1,98 @@
1
+ import {
2
+ DomainLock
3
+ } from "./chunk-UPU23ZRG.js";
4
+ import "./chunk-KFQGP6VL.js";
5
+
6
+ // src/domain-lock/cli-verify.ts
7
+ function getFlag(args, name) {
8
+ const idx = args.indexOf(name);
9
+ if (idx !== -1 && args[idx + 1]) return args[idx + 1];
10
+ return void 0;
11
+ }
12
+ async function runVerifyDomain(args) {
13
+ const { default: chalk } = await import("chalk");
14
+ const { default: ora } = await import("ora");
15
+ console.log("");
16
+ console.log(chalk.bold(" AgenticMail Enterprise \u2014 Domain Verification"));
17
+ console.log("");
18
+ let domain = getFlag(args, "--domain");
19
+ let dnsChallenge;
20
+ let dbConnected = false;
21
+ let db = null;
22
+ if (!domain) {
23
+ const dbPath = getFlag(args, "--db");
24
+ const dbType = getFlag(args, "--db-type") || "sqlite";
25
+ if (dbPath) {
26
+ try {
27
+ const { createAdapter } = await import("./factory-5C7EC3SE.js");
28
+ db = await createAdapter({ type: dbType, connectionString: dbPath });
29
+ await db.migrate();
30
+ const settings = await db.getSettings();
31
+ domain = settings?.domain;
32
+ dnsChallenge = settings?.domainDnsChallenge;
33
+ dbConnected = true;
34
+ } catch {
35
+ }
36
+ }
37
+ }
38
+ if (!domain) {
39
+ const { default: inquirer } = await import("inquirer");
40
+ const answer = await inquirer.prompt([{
41
+ type: "input",
42
+ name: "domain",
43
+ message: "Domain to verify:",
44
+ suffix: chalk.dim(" (e.g. agents.agenticmail.io)"),
45
+ validate: (v) => v.includes(".") || "Enter a valid domain"
46
+ }]);
47
+ domain = answer.domain;
48
+ }
49
+ const spinner = ora("Checking DNS verification...").start();
50
+ const lock = new DomainLock();
51
+ const result = await lock.checkVerification(domain);
52
+ if (!result.success) {
53
+ spinner.fail("Verification check failed");
54
+ console.log("");
55
+ console.error(chalk.red(` ${result.error}`));
56
+ console.log("");
57
+ if (db) await db.disconnect();
58
+ process.exit(1);
59
+ }
60
+ if (result.verified) {
61
+ spinner.succeed("Domain verified!");
62
+ if (dbConnected && db) {
63
+ try {
64
+ await db.updateSettings({
65
+ domainStatus: "verified",
66
+ domainVerifiedAt: (/* @__PURE__ */ new Date()).toISOString()
67
+ });
68
+ } catch {
69
+ }
70
+ }
71
+ console.log("");
72
+ console.log(chalk.green.bold(` ${domain} is verified and protected.`));
73
+ console.log(chalk.dim(" Your deployment domain is locked. No other instance can claim it."));
74
+ console.log("");
75
+ } else {
76
+ spinner.info("DNS record not found yet");
77
+ console.log("");
78
+ console.log(chalk.yellow(" The DNS TXT record has not been detected."));
79
+ console.log("");
80
+ console.log(chalk.bold(" Make sure this record exists:"));
81
+ console.log("");
82
+ console.log(` ${chalk.bold("Host:")} ${chalk.cyan(`_agenticmail-verify.${domain}`)}`);
83
+ console.log(` ${chalk.bold("Type:")} ${chalk.cyan("TXT")}`);
84
+ if (dnsChallenge) {
85
+ console.log(` ${chalk.bold("Value:")} ${chalk.cyan(dnsChallenge)}`);
86
+ } else {
87
+ console.log(` ${chalk.bold("Value:")} ${chalk.dim("(check your setup records or dashboard)")}`);
88
+ }
89
+ console.log("");
90
+ console.log(chalk.dim(" DNS changes can take up to 48 hours to propagate."));
91
+ console.log(chalk.dim(" Run this command again after adding the record."));
92
+ console.log("");
93
+ }
94
+ if (db) await db.disconnect();
95
+ }
96
+ export {
97
+ runVerifyDomain
98
+ };
package/dist/cli.js CHANGED
@@ -14,10 +14,10 @@ switch (command) {
14
14
  import("./cli-submit-skill-LDFJGSKO.js").then((m) => m.runSubmitSkill(args.slice(1))).catch(fatal);
15
15
  break;
16
16
  case "recover":
17
- import("./cli-recover-BPRSA6ND.js").then((m) => m.runRecover(args.slice(1))).catch(fatal);
17
+ import("./cli-recover-UHALNDIN.js").then((m) => m.runRecover(args.slice(1))).catch(fatal);
18
18
  break;
19
19
  case "verify-domain":
20
- import("./cli-verify-Y34ZU5GM.js").then((m) => m.runVerifyDomain(args.slice(1))).catch(fatal);
20
+ import("./cli-verify-CN5WNXQI.js").then((m) => m.runVerifyDomain(args.slice(1))).catch(fatal);
21
21
  break;
22
22
  case "--help":
23
23
  case "-h":
@@ -48,7 +48,7 @@ Skill Development:
48
48
  break;
49
49
  case "setup":
50
50
  default:
51
- import("./setup-RWM6G6BK.js").then((m) => m.runSetupWizard()).catch(fatal);
51
+ import("./setup-HAVYNSWT.js").then((m) => m.runSetupWizard()).catch(fatal);
52
52
  break;
53
53
  }
54
54
  function fatal(err) {
@@ -1,5 +1,5 @@
1
1
  // ─── Imports ─────────────────────────────────────────────
2
- import { h, useState, useEffect, useCallback, useRef, Fragment, AppContext, useApp, apiCall, authCall, engineCall, applyBrandColor } from './components/utils.js';
2
+ import { h, useState, useEffect, useCallback, useRef, Fragment, AppContext, useApp, apiCall, authCall, engineCall, applyBrandColor, setOrgId } from './components/utils.js';
3
3
  import { I } from './components/icons.js';
4
4
  import { ErrorBoundary } from './components/error-boundary.js';
5
5
  import { Modal } from './components/modal.js';
@@ -113,7 +113,7 @@ function App() {
113
113
  useEffect(() => {
114
114
  if (!authed) return;
115
115
  engineCall('/approvals/pending').then(d => setPendingCount((d.requests || []).length)).catch(() => {});
116
- apiCall('/settings').then(d => { const s = d.settings || d || {}; if (s.primaryColor) applyBrandColor(s.primaryColor); }).catch(() => {});
116
+ apiCall('/settings').then(d => { const s = d.settings || d || {}; if (s.primaryColor) applyBrandColor(s.primaryColor); if (s.orgId) setOrgId(s.orgId); }).catch(() => {});
117
117
  }, [authed]);
118
118
 
119
119
  const logout = useCallback(() => { authCall('/logout', { method: 'POST' }).catch(() => {}).finally(() => { setAuthed(false); setUser(null); }); }, []);
@@ -5,6 +5,25 @@ export { h, useState, useEffect, useCallback, useRef, Fragment, createContext, u
5
5
 
6
6
  export function useApp() { return useContext(AppContext); }
7
7
 
8
+ // Org ID — set from server settings after setup wizard, cached in localStorage
9
+ var _orgIdLoaded = false;
10
+ export function getOrgId() {
11
+ var id = localStorage.getItem('em_org_id');
12
+ if (!id && !_orgIdLoaded) {
13
+ _orgIdLoaded = true;
14
+ // Fetch from server settings (async, will update on next call)
15
+ apiCall('/settings').then(function(s) {
16
+ if (s && s.orgId) {
17
+ localStorage.setItem('em_org_id', s.orgId);
18
+ }
19
+ }).catch(function() {});
20
+ }
21
+ return id || 'default';
22
+ }
23
+ export function setOrgId(id) {
24
+ if (id) localStorage.setItem('em_org_id', id);
25
+ }
26
+
8
27
  // Derive accent color variants from a hex color
9
28
  export function applyBrandColor(hex) {
10
29
  if (!hex || !/^#[0-9a-fA-F]{6}$/.test(hex)) return;
@@ -1,4 +1,4 @@
1
- import { h, useState, useEffect, Fragment, engineCall, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge } from '../components/utils.js';
1
+ import { h, useState, useEffect, Fragment, engineCall, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge , getOrgId } from '../components/utils.js';
2
2
 
3
3
  export function ActivityPage() {
4
4
  const [events, setEvents] = useState([]);
@@ -10,7 +10,7 @@ export function ActivityPage() {
10
10
  useEffect(() => {
11
11
  engineCall('/activity/events?limit=100').then(d => setEvents(d.events || [])).catch(() => {});
12
12
  engineCall('/activity/tool-calls?limit=100').then(d => setToolCalls(d.toolCalls || [])).catch(() => {});
13
- engineCall('/agents?orgId=default').then(d => setAgents(d.agents || [])).catch(() => {});
13
+ engineCall('/agents?orgId=' + getOrgId()).then(d => setAgents(d.agents || [])).catch(() => {});
14
14
  }, []);
15
15
 
16
16
  const emailMap = buildAgentEmailMap(agents);
@@ -1,4 +1,4 @@
1
- import { h, useState, useEffect, useCallback, Fragment, useApp, apiCall, engineCall, formatUptime, buildAgentDataMap, renderAgentBadge, showConfirm } from '../components/utils.js';
1
+ import { h, useState, useEffect, useCallback, Fragment, useApp, apiCall, engineCall, formatUptime, buildAgentDataMap, renderAgentBadge, showConfirm , getOrgId } from '../components/utils.js';
2
2
  import { I } from '../components/icons.js';
3
3
  import { DetailModal } from '../components/modal.js';
4
4
  import { CULTURES, LANGUAGES, DEFAULT_TRAITS, computeAge, PersonaForm } from '../components/persona-fields.js';
@@ -202,7 +202,7 @@ function OverviewSection(props) {
202
202
 
203
203
  var initiateOnboarding = function() {
204
204
  setActing('onboard');
205
- engineCall('/onboarding/initiate/' + agentId, { method: 'POST', body: JSON.stringify({ orgId: 'default' }) })
205
+ engineCall('/onboarding/initiate/' + agentId, { method: 'POST', body: JSON.stringify({ orgId: getOrgId() }) })
206
206
  .then(function() { toast('Onboarding initiated', 'success'); setOnboardingStatus(function(s) { return Object.assign({}, s, { onboarded: true, status: 'in_progress' }); }); reload(); })
207
207
  .catch(function(err) { toast(err.message, 'error'); })
208
208
  .finally(function() { setActing(''); });
@@ -700,7 +700,7 @@ function PermissionsSection(props) {
700
700
  useEffect(function() {
701
701
  setLoading(true);
702
702
  Promise.all([
703
- engineCall('/policies/agent/' + agentId + '?orgId=default').catch(function() { return { policies: [] }; }),
703
+ engineCall('/policies/agent/' + agentId + '?orgId=' + getOrgId()).catch(function() { return { policies: [] }; }),
704
704
  engineCall('/profiles/presets').catch(function() { return { presets: [] }; }),
705
705
  engineCall('/souls/by-category').catch(function() { return { categories: {}, categoryMeta: {} }; })
706
706
  ]).then(function(results) {
@@ -1490,7 +1490,7 @@ function ActivitySection(props) {
1490
1490
  .catch(function() {});
1491
1491
  };
1492
1492
  var loadJournal = function() {
1493
- engineCall('/journal?agentId=' + agentId + '&orgId=default&limit=50')
1493
+ engineCall('/journal?agentId=' + agentId + '&orgId=' + getOrgId() + '&limit=50')
1494
1494
  .then(function(d) { setJournalEntries(d.entries || []); })
1495
1495
  .catch(function() {});
1496
1496
  };
@@ -1500,7 +1500,7 @@ function ActivitySection(props) {
1500
1500
  Promise.all([
1501
1501
  engineCall('/activity/events?agentId=' + agentId + '&limit=50').then(function(d) { setEvents(d.events || []); }).catch(function() {}),
1502
1502
  engineCall('/activity/tool-calls?agentId=' + agentId + '&limit=50').then(function(d) { setToolCalls(d.toolCalls || []); }).catch(function() {}),
1503
- engineCall('/journal?agentId=' + agentId + '&orgId=default&limit=50').then(function(d) { setJournalEntries(d.entries || []); }).catch(function() {}),
1503
+ engineCall('/journal?agentId=' + agentId + '&orgId=' + getOrgId() + '&limit=50').then(function(d) { setJournalEntries(d.entries || []); }).catch(function() {}),
1504
1504
  ]).then(function() { setLoading(false); }).catch(function() { setLoading(false); });
1505
1505
  };
1506
1506
 
@@ -1674,17 +1674,17 @@ function CommunicationSection(props) {
1674
1674
  var form = _form[0]; var setForm = _form[1];
1675
1675
 
1676
1676
  var loadMessages = function() {
1677
- engineCall('/messages?agentId=' + agentId + '&orgId=default&limit=50')
1677
+ engineCall('/messages?agentId=' + agentId + '&orgId=' + getOrgId() + '&limit=50')
1678
1678
  .then(function(d) { setMessages(d.messages || []); })
1679
1679
  .catch(function() {});
1680
1680
  };
1681
1681
  var loadInbox = function() {
1682
- engineCall('/messages/inbox/' + agentId + '?orgId=default')
1682
+ engineCall('/messages/inbox/' + agentId + '?orgId=' + getOrgId())
1683
1683
  .then(function(d) { setInbox(d.messages || []); })
1684
1684
  .catch(function() {});
1685
1685
  };
1686
1686
  var loadTopology = function() {
1687
- engineCall('/messages/topology?agentId=' + agentId + '&orgId=default')
1687
+ engineCall('/messages/topology?agentId=' + agentId + '&orgId=' + getOrgId())
1688
1688
  .then(function(d) { setTopology(d.topology || d || null); })
1689
1689
  .catch(function() {});
1690
1690
  };
@@ -1708,7 +1708,7 @@ function CommunicationSection(props) {
1708
1708
  var body = {
1709
1709
  fromAgentId: agentId,
1710
1710
  toAgentId: form.toAgentId,
1711
- orgId: 'default',
1711
+ orgId: getOrgId(),
1712
1712
  subject: form.subject,
1713
1713
  content: form.content,
1714
1714
  priority: form.priority
@@ -1991,7 +1991,7 @@ function MemorySection(props) {
1991
1991
  var tagsArray = createForm.tags ? createForm.tags.split(',').map(function(s) { return s.trim(); }).filter(Boolean) : [];
1992
1992
  var body = {
1993
1993
  agentId: agentId,
1994
- orgId: 'default',
1994
+ orgId: getOrgId(),
1995
1995
  title: createForm.title,
1996
1996
  content: createForm.content,
1997
1997
  category: createForm.category,
@@ -2549,7 +2549,7 @@ function GuardrailsSection(props) {
2549
2549
  };
2550
2550
 
2551
2551
  var initiateOnboarding = function() {
2552
- engineCall('/onboarding/initiate/' + agentId, { method: 'POST', body: JSON.stringify({ orgId: 'default' }) })
2552
+ engineCall('/onboarding/initiate/' + agentId, { method: 'POST', body: JSON.stringify({ orgId: getOrgId() }) })
2553
2553
  .then(function() { toast('Onboarding initiated', 'success'); loadAll(); })
2554
2554
  .catch(function(err) { toast(err.message, 'error'); });
2555
2555
  };
@@ -3448,7 +3448,7 @@ function AgentDetailPage(props) {
3448
3448
  Promise.all([
3449
3449
  engineCall('/bridge/agents/' + agentId + '/full').catch(function() { return null; }),
3450
3450
  apiCall('/agents/' + agentId).catch(function() { return null; }),
3451
- engineCall('/agents?orgId=default').catch(function() { return { agents: [] }; })
3451
+ engineCall('/agents?orgId=' + getOrgId()).catch(function() { return { agents: [] }; })
3452
3452
  ]).then(function(results) {
3453
3453
  var fullData = results[0];
3454
3454
  var adminData = results[1];
@@ -1,4 +1,4 @@
1
- import { h, useState, useEffect, useCallback, Fragment, useApp, apiCall, engineCall, DEPLOY_PHASES, DEPLOY_PHASE_LABELS, showConfirm } from '../components/utils.js';
1
+ import { h, useState, useEffect, useCallback, Fragment, useApp, apiCall, engineCall, DEPLOY_PHASES, DEPLOY_PHASE_LABELS, showConfirm , getOrgId } from '../components/utils.js';
2
2
  import { I } from '../components/icons.js';
3
3
  import { CULTURES, LANGUAGES, PersonaForm } from '../components/persona-fields.js';
4
4
 
@@ -16,7 +16,7 @@ export function DeployModal({ agentId, agentConfig, onClose, onDeployed, toast }
16
16
  const [error, setError] = useState('');
17
17
 
18
18
  useEffect(() => {
19
- engineCall('/deploy-credentials?orgId=default').then(d => setCredentials(d.credentials || [])).catch(() => {});
19
+ engineCall('/deploy-credentials?orgId=' + getOrgId()).then(d => setCredentials(d.credentials || [])).catch(() => {});
20
20
  }, []);
21
21
 
22
22
  const targets = [
@@ -400,7 +400,7 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
400
400
  setLoading(true);
401
401
  try {
402
402
  const result = await engineCall('/bridge/agents', { method: 'POST', body: JSON.stringify({
403
- orgId: 'default',
403
+ orgId: getOrgId(),
404
404
  name: form.name,
405
405
  displayName: form.name,
406
406
  email: form.email || form.name.toLowerCase().replace(/\s+/g, '.') + '@agenticmail.local',
@@ -436,7 +436,7 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
436
436
 
437
437
  if (form.autoOnboard && agentId) {
438
438
  try {
439
- await engineCall('/onboarding/initiate/' + agentId, { method: 'POST', body: JSON.stringify({ orgId: 'default' }) });
439
+ await engineCall('/onboarding/initiate/' + agentId, { method: 'POST', body: JSON.stringify({ orgId: getOrgId() }) });
440
440
  toast('Agent "' + form.name + '" created and onboarding started', 'success');
441
441
  } catch (e) {
442
442
  toast('Agent created but onboarding failed: ' + e.message, 'warning');
@@ -1,4 +1,4 @@
1
- import { h, useState, useEffect, Fragment, useApp, engineCall, showConfirm, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge } from '../components/utils.js';
1
+ import { h, useState, useEffect, Fragment, useApp, engineCall, showConfirm, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge , getOrgId } from '../components/utils.js';
2
2
  import { I } from '../components/icons.js';
3
3
 
4
4
  export function ApprovalsPage() {
@@ -12,7 +12,7 @@ export function ApprovalsPage() {
12
12
  const load = () => {
13
13
  engineCall('/approvals/pending').then(d => setPending(d.requests || [])).catch(() => {});
14
14
  engineCall('/approvals/history?limit=50').then(d => setHistory(d.requests || [])).catch(() => {});
15
- engineCall('/agents?orgId=default').then(d => setAgents(d.agents || [])).catch(() => {});
15
+ engineCall('/agents?orgId=' + getOrgId()).then(d => setAgents(d.agents || [])).catch(() => {});
16
16
  };
17
17
  useEffect(() => { load(); }, []);
18
18
 
@@ -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
 
4
4
  export function CommunitySkillsPage() {
@@ -37,7 +37,7 @@ export function CommunitySkillsPage() {
37
37
  engineCall('/community/skills?' + params.toString())
38
38
  .then(d => { setSkills(d.skills || []); setTotal(d.total || 0); })
39
39
  .catch(() => {});
40
- engineCall('/community/installed?orgId=default')
40
+ engineCall('/community/installed?orgId=' + getOrgId())
41
41
  .then(d => setInstalled(d.installed || []))
42
42
  .catch(() => {});
43
43
  engineCall('/community/skills/featured')
@@ -52,16 +52,16 @@ export function CommunitySkillsPage() {
52
52
  }, [filters]);
53
53
 
54
54
  var loadUpdates = useCallback(function() {
55
- engineCall('/skill-updates/config?orgId=default')
55
+ engineCall('/skill-updates/config?orgId=' + getOrgId())
56
56
  .then(function(d) { setUpdateConfig(d.config || d || { autoUpdate: false, checkInterval: 'daily', maxRiskLevel: 'medium' }); })
57
57
  .catch(function() {});
58
- engineCall('/skill-updates/available?orgId=default')
58
+ engineCall('/skill-updates/available?orgId=' + getOrgId())
59
59
  .then(function(d) { setAvailableUpdates(d.updates || []); })
60
60
  .catch(function() {});
61
- engineCall('/skill-updates/history?orgId=default')
61
+ engineCall('/skill-updates/history?orgId=' + getOrgId())
62
62
  .then(function(d) { setUpdateHistory(d.history || d.updates || []); })
63
63
  .catch(function() {});
64
- engineCall('/skill-updates/stats?orgId=default')
64
+ engineCall('/skill-updates/stats?orgId=' + getOrgId())
65
65
  .then(function(d) { setUpdateStats(d || {}); })
66
66
  .catch(function() {});
67
67
  }, []);
@@ -87,7 +87,7 @@ export function CommunitySkillsPage() {
87
87
  try {
88
88
  await engineCall('/community/skills/' + skillId + '/install', {
89
89
  method: 'POST',
90
- body: JSON.stringify({ orgId: 'default' })
90
+ body: JSON.stringify({ orgId: getOrgId() })
91
91
  });
92
92
  toast('Skill installed', 'success');
93
93
  load();
@@ -98,7 +98,7 @@ export function CommunitySkillsPage() {
98
98
  try {
99
99
  await engineCall('/community/skills/' + skillId + '/uninstall', {
100
100
  method: 'DELETE',
101
- body: JSON.stringify({ orgId: 'default' })
101
+ body: JSON.stringify({ orgId: getOrgId() })
102
102
  });
103
103
  toast('Skill uninstalled', 'success');
104
104
  load();
@@ -109,7 +109,7 @@ export function CommunitySkillsPage() {
109
109
  try {
110
110
  await engineCall('/community/skills/' + skillId + '/' + (enable ? 'enable' : 'disable'), {
111
111
  method: 'PUT',
112
- body: JSON.stringify({ orgId: 'default' })
112
+ body: JSON.stringify({ orgId: getOrgId() })
113
113
  });
114
114
  toast('Skill ' + (enable ? 'enabled' : 'disabled'), 'success');
115
115
  load();
@@ -166,7 +166,7 @@ export function CommunitySkillsPage() {
166
166
  try {
167
167
  await engineCall('/skill-updates/check', {
168
168
  method: 'POST',
169
- body: JSON.stringify({ orgId: 'default' })
169
+ body: JSON.stringify({ orgId: getOrgId() })
170
170
  });
171
171
  toast('Update check complete', 'success');
172
172
  loadUpdates();
@@ -179,7 +179,7 @@ export function CommunitySkillsPage() {
179
179
  await engineCall('/skill-updates/config', {
180
180
  method: 'PUT',
181
181
  body: JSON.stringify({
182
- orgId: 'default',
182
+ orgId: getOrgId(),
183
183
  autoUpdate: updateConfig.autoUpdate,
184
184
  checkInterval: updateConfig.checkInterval,
185
185
  maxRiskLevel: updateConfig.maxRiskLevel
@@ -210,7 +210,7 @@ export function CommunitySkillsPage() {
210
210
  try {
211
211
  await engineCall('/skill-updates/apply-all', {
212
212
  method: 'POST',
213
- body: JSON.stringify({ orgId: 'default' })
213
+ body: JSON.stringify({ orgId: getOrgId() })
214
214
  });
215
215
  toast('All updates applied', 'success');
216
216
  loadUpdates();
@@ -1,4 +1,4 @@
1
- import { h, useState, useEffect, Fragment, useApp, engineCall, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge } from '../components/utils.js';
1
+ import { h, useState, useEffect, Fragment, useApp, engineCall, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge , getOrgId } from '../components/utils.js';
2
2
  import { I } from '../components/icons.js';
3
3
 
4
4
  export function CompliancePage() {
@@ -6,13 +6,13 @@ export function CompliancePage() {
6
6
  const [reports, setReports] = useState([]);
7
7
  const [tab, setTab] = useState('reports');
8
8
  const [generating, setGenerating] = useState(false);
9
- const [form, setForm] = useState({ type: 'soc2', orgId: 'default', agentId: '', from: new Date(Date.now() - 30 * 86400000).toISOString().split('T')[0], to: new Date().toISOString().split('T')[0] });
9
+ const [form, setForm] = useState({ type: 'soc2', orgId: getOrgId(), agentId: '', from: new Date(Date.now() - 30 * 86400000).toISOString().split('T')[0], to: new Date().toISOString().split('T')[0] });
10
10
 
11
11
  const [agents, setAgents] = useState([]);
12
12
 
13
13
  const load = () => {
14
- engineCall('/compliance/reports?orgId=default').then(d => setReports(d.reports || [])).catch(() => {});
15
- engineCall('/agents?orgId=default').then(d => setAgents(d.agents || [])).catch(() => {});
14
+ engineCall('/compliance/reports?orgId=' + getOrgId()).then(d => setReports(d.reports || [])).catch(() => {});
15
+ engineCall('/agents?orgId=' + getOrgId()).then(d => setAgents(d.agents || [])).catch(() => {});
16
16
  };
17
17
  useEffect(load, []);
18
18
 
@@ -1,5 +1,5 @@
1
- import { h, useState, useEffect, Fragment, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge } from '../components/utils.js';
2
- import { useApp, apiCall, engineCall } from '../components/utils.js';
1
+ import { h, useState, useEffect, Fragment, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge , getOrgId } from '../components/utils.js';
2
+ import { useApp, apiCall, engineCall , getOrgId } from '../components/utils.js';
3
3
  import { I } from '../components/icons.js';
4
4
  import { DetailModal } from '../components/modal.js';
5
5
 
@@ -58,7 +58,7 @@ export function DashboardPage() {
58
58
  useEffect(() => {
59
59
  apiCall('/stats').then(setStats).catch(() => {});
60
60
  apiCall('/agents').then(d => setAgents(d.agents || d || [])).catch(() => {});
61
- engineCall('/agents?orgId=default').then(d => setEngineAgents(d.agents || [])).catch(() => {});
61
+ engineCall('/agents?orgId=' + getOrgId()).then(d => setEngineAgents(d.agents || [])).catch(() => {});
62
62
  engineCall('/activity/events?limit=10').then(d => setEvents(d.events || [])).catch(() => {});
63
63
  }, []);
64
64
 
@@ -1,4 +1,4 @@
1
- import { h, useState, useEffect, Fragment, useApp, engineCall, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge } from '../components/utils.js';
1
+ import { h, useState, useEffect, Fragment, useApp, engineCall, buildAgentEmailMap, buildAgentDataMap, resolveAgentEmail, renderAgentBadge , getOrgId } from '../components/utils.js';
2
2
  import { I } from '../components/icons.js';
3
3
 
4
4
  export function DLPPage() {
@@ -7,16 +7,16 @@ export function DLPPage() {
7
7
  const [violations, setViolations] = useState([]);
8
8
  const [tab, setTab] = useState('rules');
9
9
  const [showModal, setShowModal] = useState(false);
10
- const [form, setForm] = useState({ name: '', orgId: 'default', patternType: 'regex', pattern: '', action: 'block', appliesTo: 'both', severity: 'high', enabled: true });
10
+ const [form, setForm] = useState({ name: '', orgId: getOrgId(), patternType: 'regex', pattern: '', action: 'block', appliesTo: 'both', severity: 'high', enabled: true });
11
11
  const [testContent, setTestContent] = useState('');
12
12
  const [testResults, setTestResults] = useState(null);
13
13
 
14
14
  const [agents, setAgents] = useState([]);
15
15
 
16
16
  const load = () => {
17
- engineCall('/dlp/rules?orgId=default').then(d => setRules(d.rules || [])).catch(() => {});
18
- engineCall('/dlp/violations?orgId=default&limit=100').then(d => setViolations(d.violations || [])).catch(() => {});
19
- engineCall('/agents?orgId=default').then(d => setAgents(d.agents || [])).catch(() => {});
17
+ engineCall('/dlp/rules?orgId=' + getOrgId()).then(d => setRules(d.rules || [])).catch(() => {});
18
+ engineCall('/dlp/violations?orgId=' + getOrgId() + '&limit=100').then(d => setViolations(d.violations || [])).catch(() => {});
19
+ engineCall('/agents?orgId=' + getOrgId()).then(d => setAgents(d.agents || [])).catch(() => {});
20
20
  };
21
21
  useEffect(load, []);
22
22
 
@@ -31,7 +31,7 @@ export function DLPPage() {
31
31
  };
32
32
  const testScan = async () => {
33
33
  if (!testContent) return;
34
- try { const r = await engineCall('/dlp/scan', { method: 'POST', body: JSON.stringify({ orgId: 'default', content: testContent }) }); setTestResults(r); } catch (e) { toast(e.message, 'error'); }
34
+ try { const r = await engineCall('/dlp/scan', { method: 'POST', body: JSON.stringify({ orgId: getOrgId(), content: testContent }) }); setTestResults(r); } catch (e) { toast(e.message, 'error'); }
35
35
  };
36
36
 
37
37
  const severityColor = (s) => s === 'critical' ? 'var(--danger)' : s === 'high' ? 'var(--warning)' : s === 'medium' ? 'var(--info)' : 'var(--text-muted)';