@agenticmail/enterprise 0.5.172 → 0.5.174
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-BAPSCAX3.js +17682 -0
- package/dist/chunk-BZM7M7ZD.js +2195 -0
- package/dist/chunk-EMSCGO7G.js +17682 -0
- package/dist/chunk-GKPFCKNU.js +898 -0
- package/dist/chunk-PWO3XE5P.js +2195 -0
- package/dist/chunk-UQEMQK5I.js +898 -0
- package/dist/cli-agent-HBMWMEM2.js +1007 -0
- package/dist/cli-agent-Y5PR3MEC.js +1007 -0
- package/dist/cli-serve-B6EGE7J6.js +34 -0
- package/dist/cli-serve-TLSS22GA.js +34 -0
- package/dist/cli.js +3 -3
- package/dist/dashboard/pages/agent-detail.js +16 -1
- package/dist/index.js +3 -3
- package/dist/routes-DCKRUU6E.js +6998 -0
- package/dist/routes-H7Q3TAC2.js +7045 -0
- package/dist/runtime-2NMHFRUT.js +49 -0
- package/dist/runtime-6CMR2IND.js +49 -0
- package/dist/server-HI764D36.js +12 -0
- package/dist/server-U5J3SEZM.js +12 -0
- package/dist/setup-CEX46TOT.js +20 -0
- package/dist/setup-UB6MDX5B.js +20 -0
- package/package.json +1 -1
- package/src/dashboard/pages/agent-detail.js +16 -1
- package/src/engine/agent-routes.ts +67 -2
- package/src/engine/oauth-connect-routes.ts +7 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentRuntime,
|
|
3
|
+
EmailChannel,
|
|
4
|
+
FollowUpScheduler,
|
|
5
|
+
SessionManager,
|
|
6
|
+
SubAgentManager,
|
|
7
|
+
ToolRegistry,
|
|
8
|
+
callLLM,
|
|
9
|
+
createAgentRuntime,
|
|
10
|
+
createNoopHooks,
|
|
11
|
+
createRuntimeHooks,
|
|
12
|
+
estimateMessageTokens,
|
|
13
|
+
estimateTokens,
|
|
14
|
+
executeTool,
|
|
15
|
+
runAgentLoop,
|
|
16
|
+
toolsToDefinitions
|
|
17
|
+
} from "./chunk-EMSCGO7G.js";
|
|
18
|
+
import "./chunk-AQH4DFYV.js";
|
|
19
|
+
import "./chunk-JLSQOQ5L.js";
|
|
20
|
+
import {
|
|
21
|
+
PROVIDER_REGISTRY,
|
|
22
|
+
listAllProviders,
|
|
23
|
+
resolveApiKeyForProvider,
|
|
24
|
+
resolveProvider
|
|
25
|
+
} from "./chunk-67KZYSLU.js";
|
|
26
|
+
import "./chunk-NRF3YRF7.js";
|
|
27
|
+
import "./chunk-TYW5XTOW.js";
|
|
28
|
+
import "./chunk-KFQGP6VL.js";
|
|
29
|
+
export {
|
|
30
|
+
AgentRuntime,
|
|
31
|
+
EmailChannel,
|
|
32
|
+
FollowUpScheduler,
|
|
33
|
+
PROVIDER_REGISTRY,
|
|
34
|
+
SessionManager,
|
|
35
|
+
SubAgentManager,
|
|
36
|
+
ToolRegistry,
|
|
37
|
+
callLLM,
|
|
38
|
+
createAgentRuntime,
|
|
39
|
+
createNoopHooks,
|
|
40
|
+
createRuntimeHooks,
|
|
41
|
+
estimateMessageTokens,
|
|
42
|
+
estimateTokens,
|
|
43
|
+
executeTool,
|
|
44
|
+
listAllProviders,
|
|
45
|
+
resolveApiKeyForProvider,
|
|
46
|
+
resolveProvider,
|
|
47
|
+
runAgentLoop,
|
|
48
|
+
toolsToDefinitions
|
|
49
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentRuntime,
|
|
3
|
+
EmailChannel,
|
|
4
|
+
FollowUpScheduler,
|
|
5
|
+
SessionManager,
|
|
6
|
+
SubAgentManager,
|
|
7
|
+
ToolRegistry,
|
|
8
|
+
callLLM,
|
|
9
|
+
createAgentRuntime,
|
|
10
|
+
createNoopHooks,
|
|
11
|
+
createRuntimeHooks,
|
|
12
|
+
estimateMessageTokens,
|
|
13
|
+
estimateTokens,
|
|
14
|
+
executeTool,
|
|
15
|
+
runAgentLoop,
|
|
16
|
+
toolsToDefinitions
|
|
17
|
+
} from "./chunk-BAPSCAX3.js";
|
|
18
|
+
import "./chunk-AQH4DFYV.js";
|
|
19
|
+
import "./chunk-JLSQOQ5L.js";
|
|
20
|
+
import {
|
|
21
|
+
PROVIDER_REGISTRY,
|
|
22
|
+
listAllProviders,
|
|
23
|
+
resolveApiKeyForProvider,
|
|
24
|
+
resolveProvider
|
|
25
|
+
} from "./chunk-67KZYSLU.js";
|
|
26
|
+
import "./chunk-NRF3YRF7.js";
|
|
27
|
+
import "./chunk-TYW5XTOW.js";
|
|
28
|
+
import "./chunk-KFQGP6VL.js";
|
|
29
|
+
export {
|
|
30
|
+
AgentRuntime,
|
|
31
|
+
EmailChannel,
|
|
32
|
+
FollowUpScheduler,
|
|
33
|
+
PROVIDER_REGISTRY,
|
|
34
|
+
SessionManager,
|
|
35
|
+
SubAgentManager,
|
|
36
|
+
ToolRegistry,
|
|
37
|
+
callLLM,
|
|
38
|
+
createAgentRuntime,
|
|
39
|
+
createNoopHooks,
|
|
40
|
+
createRuntimeHooks,
|
|
41
|
+
estimateMessageTokens,
|
|
42
|
+
estimateTokens,
|
|
43
|
+
executeTool,
|
|
44
|
+
listAllProviders,
|
|
45
|
+
resolveApiKeyForProvider,
|
|
46
|
+
resolveProvider,
|
|
47
|
+
runAgentLoop,
|
|
48
|
+
toolsToDefinitions
|
|
49
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServer
|
|
3
|
+
} from "./chunk-PWO3XE5P.js";
|
|
4
|
+
import "./chunk-3SMTCIR4.js";
|
|
5
|
+
import "./chunk-JLSQOQ5L.js";
|
|
6
|
+
import "./chunk-RO537U6H.js";
|
|
7
|
+
import "./chunk-DRXMYYKN.js";
|
|
8
|
+
import "./chunk-67KZYSLU.js";
|
|
9
|
+
import "./chunk-KFQGP6VL.js";
|
|
10
|
+
export {
|
|
11
|
+
createServer
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServer
|
|
3
|
+
} from "./chunk-BZM7M7ZD.js";
|
|
4
|
+
import "./chunk-3SMTCIR4.js";
|
|
5
|
+
import "./chunk-JLSQOQ5L.js";
|
|
6
|
+
import "./chunk-RO537U6H.js";
|
|
7
|
+
import "./chunk-DRXMYYKN.js";
|
|
8
|
+
import "./chunk-67KZYSLU.js";
|
|
9
|
+
import "./chunk-KFQGP6VL.js";
|
|
10
|
+
export {
|
|
11
|
+
createServer
|
|
12
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-GKPFCKNU.js";
|
|
10
|
+
import "./chunk-MHIFVS5L.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-UQEMQK5I.js";
|
|
10
|
+
import "./chunk-MHIFVS5L.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -6120,9 +6120,24 @@ function EmailSection(props) {
|
|
|
6120
6120
|
),
|
|
6121
6121
|
|
|
6122
6122
|
// ─── Actions ──────────────────────────────────────
|
|
6123
|
-
h('div', { style: { display: 'flex', gap: 8, borderTop: '1px solid var(--border)', paddingTop: 16 } },
|
|
6123
|
+
h('div', { style: { display: 'flex', gap: 8, borderTop: '1px solid var(--border)', paddingTop: 16, flexWrap: 'wrap' } },
|
|
6124
6124
|
h('button', { className: 'btn btn-primary', disabled: saving, onClick: handleSave }, saving ? 'Saving...' : 'Save Configuration'),
|
|
6125
6125
|
emailConfig && emailConfig.configured && h('button', { className: 'btn btn-secondary', disabled: testing, onClick: handleTest }, testing ? 'Testing...' : 'Test Connection'),
|
|
6126
|
+
emailConfig && emailConfig.status === 'connected' && emailConfig.oauthProvider === 'google' && h('button', {
|
|
6127
|
+
className: 'btn btn-secondary',
|
|
6128
|
+
onClick: function() {
|
|
6129
|
+
engineCall('/bridge/agents/' + agentId + '/email-config/reauthorize', { method: 'POST', body: JSON.stringify({}) })
|
|
6130
|
+
.then(function(r) {
|
|
6131
|
+
if (r.oauthAuthUrl) {
|
|
6132
|
+
toast('Opening Google re-authorization with ' + r.scopeCount + ' scopes...', 'info');
|
|
6133
|
+
window.open(r.oauthAuthUrl, '_blank', 'width=600,height=700');
|
|
6134
|
+
} else {
|
|
6135
|
+
toast('Failed: ' + (r.error || 'Unknown'), 'error');
|
|
6136
|
+
}
|
|
6137
|
+
})
|
|
6138
|
+
.catch(function(e) { toast('Error: ' + e.message, 'error'); });
|
|
6139
|
+
}
|
|
6140
|
+
}, 'Re-authorize (Update Scopes)'),
|
|
6126
6141
|
emailConfig && emailConfig.configured && h('button', { className: 'btn btn-danger btn-ghost', onClick: function() { if (confirm('Disconnect email? The agent will no longer be able to send/receive.')) handleDisconnect(); } }, 'Disconnect')
|
|
6127
6142
|
)
|
|
6128
6143
|
)
|
|
@@ -542,11 +542,18 @@ export function createAgentRoutes(opts: {
|
|
|
542
542
|
}
|
|
543
543
|
if (!email && provider === 'imap') return c.json({ error: 'email is required' }, 400);
|
|
544
544
|
|
|
545
|
+
// Preserve existing tokens/state when re-configuring (e.g. to pick up new scopes)
|
|
546
|
+
const existingConfig = managed.config?.emailConfig || {};
|
|
545
547
|
const emailConfig: any = {
|
|
546
548
|
provider,
|
|
547
|
-
email: email || managed.config?.identity?.email || managed.config?.email,
|
|
549
|
+
email: email || existingConfig.email || managed.config?.identity?.email || managed.config?.email,
|
|
548
550
|
updatedAt: new Date().toISOString(),
|
|
549
551
|
};
|
|
552
|
+
// Preserve existing OAuth tokens so re-auth doesn't lose refresh_token
|
|
553
|
+
if (existingConfig.oauthRefreshToken) emailConfig.oauthRefreshToken = existingConfig.oauthRefreshToken;
|
|
554
|
+
if (existingConfig.oauthAccessToken) emailConfig.oauthAccessToken = existingConfig.oauthAccessToken;
|
|
555
|
+
if (existingConfig.oauthTokenExpiry) emailConfig.oauthTokenExpiry = existingConfig.oauthTokenExpiry;
|
|
556
|
+
if (existingConfig.lastConnected) emailConfig.lastConnected = existingConfig.lastConnected;
|
|
550
557
|
|
|
551
558
|
if (provider === 'imap') {
|
|
552
559
|
// Auto-detect IMAP/SMTP from well-known providers
|
|
@@ -737,7 +744,10 @@ export function createAgentRoutes(opts: {
|
|
|
737
744
|
|
|
738
745
|
const tokens = await tokenRes.json() as any;
|
|
739
746
|
emailConfig.oauthAccessToken = tokens.access_token;
|
|
740
|
-
|
|
747
|
+
// Only overwrite refresh_token if Google returned one (re-auth may not include it)
|
|
748
|
+
if (tokens.refresh_token) {
|
|
749
|
+
emailConfig.oauthRefreshToken = tokens.refresh_token;
|
|
750
|
+
}
|
|
741
751
|
emailConfig.oauthTokenExpiry = new Date(Date.now() + (tokens.expires_in * 1000)).toISOString();
|
|
742
752
|
|
|
743
753
|
// Get the user's email from Gmail
|
|
@@ -817,6 +827,61 @@ export function createAgentRoutes(opts: {
|
|
|
817
827
|
}
|
|
818
828
|
});
|
|
819
829
|
|
|
830
|
+
/**
|
|
831
|
+
* POST /bridge/agents/:id/email-config/reauthorize — Generate a new OAuth URL with updated scopes.
|
|
832
|
+
* Preserves all existing config/tokens. Just builds a fresh auth URL for re-consent.
|
|
833
|
+
*/
|
|
834
|
+
router.post('/bridge/agents/:id/email-config/reauthorize', async (c) => {
|
|
835
|
+
const agentId = c.req.param('id');
|
|
836
|
+
const managed = lifecycle.getAgent(agentId);
|
|
837
|
+
if (!managed) return c.json({ error: 'Agent not found' }, 404);
|
|
838
|
+
|
|
839
|
+
const emailConfig = managed.config?.emailConfig;
|
|
840
|
+
if (!emailConfig) return c.json({ error: 'No email config found' }, 400);
|
|
841
|
+
|
|
842
|
+
if (emailConfig.oauthProvider === 'google') {
|
|
843
|
+
const clientId = emailConfig.oauthClientId;
|
|
844
|
+
const redirectUri = emailConfig.oauthRedirectUri;
|
|
845
|
+
if (!clientId) return c.json({ error: 'No OAuth client ID configured' }, 400);
|
|
846
|
+
|
|
847
|
+
// Updated scopes
|
|
848
|
+
const scopes = [
|
|
849
|
+
'https://www.googleapis.com/auth/gmail.modify',
|
|
850
|
+
'https://www.googleapis.com/auth/gmail.send',
|
|
851
|
+
'https://www.googleapis.com/auth/gmail.settings.basic',
|
|
852
|
+
'https://www.googleapis.com/auth/calendar',
|
|
853
|
+
'https://www.googleapis.com/auth/drive',
|
|
854
|
+
'https://www.googleapis.com/auth/spreadsheets',
|
|
855
|
+
'https://www.googleapis.com/auth/documents',
|
|
856
|
+
'https://www.googleapis.com/auth/contacts',
|
|
857
|
+
'https://www.googleapis.com/auth/tasks',
|
|
858
|
+
'https://www.googleapis.com/auth/chat.spaces',
|
|
859
|
+
'https://www.googleapis.com/auth/chat.messages',
|
|
860
|
+
'https://www.googleapis.com/auth/chat.memberships',
|
|
861
|
+
'https://www.googleapis.com/auth/presentations',
|
|
862
|
+
'https://www.googleapis.com/auth/forms.body',
|
|
863
|
+
'https://www.googleapis.com/auth/forms.responses.readonly',
|
|
864
|
+
];
|
|
865
|
+
|
|
866
|
+
emailConfig.oauthScopes = scopes;
|
|
867
|
+
const authUrl = `https://accounts.google.com/o/oauth2/v2/auth?` +
|
|
868
|
+
`client_id=${encodeURIComponent(clientId)}&response_type=code&` +
|
|
869
|
+
`redirect_uri=${encodeURIComponent(redirectUri)}&` +
|
|
870
|
+
`scope=${encodeURIComponent(scopes.join(' '))}&` +
|
|
871
|
+
`access_type=offline&prompt=consent&state=${agentId}`;
|
|
872
|
+
emailConfig.oauthAuthUrl = authUrl;
|
|
873
|
+
|
|
874
|
+
const _managed = lifecycle.getAgent(agentId);
|
|
875
|
+
if (_managed) { _managed.config.emailConfig = emailConfig; _managed.updatedAt = new Date().toISOString(); }
|
|
876
|
+
await lifecycle.saveAgent(agentId);
|
|
877
|
+
|
|
878
|
+
return c.json({ success: true, oauthAuthUrl: authUrl, scopeCount: scopes.length });
|
|
879
|
+
} else if (emailConfig.oauthProvider === 'microsoft') {
|
|
880
|
+
return c.json({ error: 'Microsoft re-authorization not yet implemented' }, 400);
|
|
881
|
+
}
|
|
882
|
+
return c.json({ error: 'No OAuth provider configured' }, 400);
|
|
883
|
+
});
|
|
884
|
+
|
|
820
885
|
/**
|
|
821
886
|
* DELETE /bridge/agents/:id/email-config — Disconnect email.
|
|
822
887
|
*/
|
|
@@ -372,7 +372,9 @@ async function handleAgentEmailOAuthCallback(c: any, agentId: string, code: stri
|
|
|
372
372
|
}
|
|
373
373
|
const tokens = await tokenRes.json() as any;
|
|
374
374
|
emailConfig.oauthAccessToken = tokens.access_token;
|
|
375
|
-
|
|
375
|
+
if (tokens.refresh_token) {
|
|
376
|
+
emailConfig.oauthRefreshToken = tokens.refresh_token;
|
|
377
|
+
}
|
|
376
378
|
emailConfig.oauthTokenExpiry = new Date(Date.now() + (tokens.expires_in * 1000)).toISOString();
|
|
377
379
|
|
|
378
380
|
// Get user email from Graph
|
|
@@ -404,7 +406,10 @@ async function handleAgentEmailOAuthCallback(c: any, agentId: string, code: stri
|
|
|
404
406
|
}
|
|
405
407
|
const tokens = await tokenRes.json() as any;
|
|
406
408
|
emailConfig.oauthAccessToken = tokens.access_token;
|
|
407
|
-
|
|
409
|
+
// Only overwrite refresh_token if Google returned one (re-auth may not include it)
|
|
410
|
+
if (tokens.refresh_token) {
|
|
411
|
+
emailConfig.oauthRefreshToken = tokens.refresh_token;
|
|
412
|
+
}
|
|
408
413
|
emailConfig.oauthTokenExpiry = tokens.expires_in
|
|
409
414
|
? new Date(Date.now() + (tokens.expires_in * 1000)).toISOString()
|
|
410
415
|
: undefined;
|