@agenticmail/enterprise 0.5.99 → 0.5.101
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-2VJ55T2N.js +2194 -0
- package/dist/chunk-CIQEP4QU.js +16106 -0
- package/dist/chunk-GAJWZ5JD.js +898 -0
- package/dist/chunk-KL4U6ZNK.js +2194 -0
- package/dist/chunk-NERC4SQV.js +16106 -0
- package/dist/chunk-Q5DKWAKT.js +898 -0
- package/dist/chunk-RPQRVVZI.js +9289 -0
- package/dist/chunk-ZTE2CLPZ.js +9304 -0
- package/dist/cli.js +1 -1
- package/dist/dashboard/pages/agent-detail.js +13 -0
- package/dist/index.js +4 -4
- package/dist/routes-57DSR7XQ.js +6938 -0
- package/dist/routes-PIXKXDFM.js +6954 -0
- package/dist/runtime-76G4DCS3.js +49 -0
- package/dist/runtime-XPEXCY6Y.js +49 -0
- package/dist/server-2TUDV7SX.js +12 -0
- package/dist/server-KF7WIPLV.js +12 -0
- package/dist/setup-7DIOEWPX.js +20 -0
- package/dist/setup-QELYIXLF.js +20 -0
- package/package.json +1 -1
- package/src/dashboard/pages/agent-detail.js +13 -0
- package/src/engine/agent-routes.ts +18 -0
- package/src/engine/deployer.ts +3 -1
- package/src/engine/lifecycle.ts +34 -11
- package/src/engine/routes.ts +1 -1
|
@@ -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-CIQEP4QU.js";
|
|
18
|
+
import "./chunk-NRF3YRF7.js";
|
|
19
|
+
import "./chunk-TYW5XTOW.js";
|
|
20
|
+
import "./chunk-AQH4DFYV.js";
|
|
21
|
+
import "./chunk-JLSQOQ5L.js";
|
|
22
|
+
import {
|
|
23
|
+
PROVIDER_REGISTRY,
|
|
24
|
+
listAllProviders,
|
|
25
|
+
resolveApiKeyForProvider,
|
|
26
|
+
resolveProvider
|
|
27
|
+
} from "./chunk-67KZYSLU.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-NERC4SQV.js";
|
|
18
|
+
import "./chunk-NRF3YRF7.js";
|
|
19
|
+
import "./chunk-TYW5XTOW.js";
|
|
20
|
+
import "./chunk-AQH4DFYV.js";
|
|
21
|
+
import "./chunk-JLSQOQ5L.js";
|
|
22
|
+
import {
|
|
23
|
+
PROVIDER_REGISTRY,
|
|
24
|
+
listAllProviders,
|
|
25
|
+
resolveApiKeyForProvider,
|
|
26
|
+
resolveProvider
|
|
27
|
+
} from "./chunk-67KZYSLU.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-2VJ55T2N.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-KL4U6ZNK.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-GAJWZ5JD.js";
|
|
10
|
+
import "./chunk-QDXUZP7Y.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-Q5DKWAKT.js";
|
|
10
|
+
import "./chunk-QDXUZP7Y.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
|
@@ -367,6 +367,19 @@ function OverviewSection(props) {
|
|
|
367
367
|
h('div', { className: 'card-header' }, h('span', null, 'Quick Actions')),
|
|
368
368
|
h('div', { className: 'card-body', style: { display: 'flex', flexWrap: 'wrap', gap: 10 } },
|
|
369
369
|
|
|
370
|
+
// Reset state (when in error/degraded)
|
|
371
|
+
(agentState === 'error' || agentState === 'degraded') && h('button', {
|
|
372
|
+
className: 'btn btn-secondary btn-sm',
|
|
373
|
+
disabled: !!acting,
|
|
374
|
+
onClick: function() {
|
|
375
|
+
setActing('reset');
|
|
376
|
+
engineCall('/agents/' + agentId + '/reset-state', { method: 'POST' })
|
|
377
|
+
.then(function() { toast('Agent state reset to ready', 'success'); reload(); })
|
|
378
|
+
.catch(function(err) { toast(err.message, 'error'); })
|
|
379
|
+
.finally(function() { setActing(''); });
|
|
380
|
+
}
|
|
381
|
+
}, I.refresh(), ' Reset State'),
|
|
382
|
+
|
|
370
383
|
// Deploy / Stop / Restart
|
|
371
384
|
(agentState !== 'running' && agentState !== 'active') && h('button', {
|
|
372
385
|
className: 'btn btn-primary btn-sm',
|
|
@@ -72,6 +72,24 @@ export function createAgentRoutes(opts: {
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
router.post('/agents/:id/reset-state', async (c) => {
|
|
76
|
+
try {
|
|
77
|
+
const agent = lifecycle.getAgent(c.req.param('id'));
|
|
78
|
+
if (!agent) return c.json({ error: 'Agent not found' }, 404);
|
|
79
|
+
if (!['error', 'degraded', 'deploying', 'provisioning', 'starting'].includes(agent.state)) {
|
|
80
|
+
return c.json({ error: `Cannot reset from state "${agent.state}"` }, 400);
|
|
81
|
+
}
|
|
82
|
+
// Reset to ready
|
|
83
|
+
(agent as any).state = 'ready';
|
|
84
|
+
(agent as any).stateMessage = 'State reset by admin';
|
|
85
|
+
(agent as any).updatedAt = new Date().toISOString();
|
|
86
|
+
await lifecycle.saveAgent(c.req.param('id'));
|
|
87
|
+
return c.json({ agent, message: 'State reset to ready' });
|
|
88
|
+
} catch (e: any) {
|
|
89
|
+
return c.json({ error: e.message }, 400);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
75
93
|
router.post('/agents/:id/stop', async (c) => {
|
|
76
94
|
const { stoppedBy, reason } = await c.req.json();
|
|
77
95
|
try {
|
package/src/engine/deployer.ts
CHANGED
|
@@ -423,9 +423,11 @@ export class DeploymentEngine {
|
|
|
423
423
|
// 1. Create app (ignore "already exists" errors)
|
|
424
424
|
emit('provision', 'started', `Creating Fly.io app "${appName}"...`);
|
|
425
425
|
try {
|
|
426
|
+
// Fly.io org_slug must be a Fly org slug (e.g. 'personal'), not an internal org ID
|
|
427
|
+
const flyOrg = (cloud.org && cloud.org.length < 30 && /^[a-z0-9-]+$/.test(cloud.org)) ? cloud.org : 'personal';
|
|
426
428
|
await flyFetch('/apps', 'POST', {
|
|
427
429
|
app_name: appName,
|
|
428
|
-
org_slug:
|
|
430
|
+
org_slug: flyOrg,
|
|
429
431
|
});
|
|
430
432
|
emit('provision', 'completed', `App "${appName}" created`);
|
|
431
433
|
} catch (e: any) {
|
package/src/engine/lifecycle.ts
CHANGED
|
@@ -184,6 +184,8 @@ export class AgentLifecycleManager {
|
|
|
184
184
|
private lastBirthdayCheck: string = '';
|
|
185
185
|
/** External callback for sending birthday messages (set via setBirthdaySender) */
|
|
186
186
|
private birthdaySender: ((agent: ManagedAgent) => Promise<void>) | null = null;
|
|
187
|
+
/** Vault for decrypting deploy credentials */
|
|
188
|
+
private vault?: any;
|
|
187
189
|
|
|
188
190
|
constructor(opts?: { db?: EngineDatabase; permissions?: PermissionEngine }) {
|
|
189
191
|
this.engineDb = opts?.db;
|
|
@@ -198,6 +200,10 @@ export class AgentLifecycleManager {
|
|
|
198
200
|
await this.loadFromDb();
|
|
199
201
|
}
|
|
200
202
|
|
|
203
|
+
setVault(vault: any): void {
|
|
204
|
+
this.vault = vault;
|
|
205
|
+
}
|
|
206
|
+
|
|
201
207
|
/**
|
|
202
208
|
* Load all agents from DB into memory
|
|
203
209
|
*/
|
|
@@ -923,6 +929,7 @@ export class AgentLifecycleManager {
|
|
|
923
929
|
* Resolve org-level deploy credentials and merge into agent config.
|
|
924
930
|
* If the agent's deployment config is missing an API token, look up
|
|
925
931
|
* the org's deploy_credentials table for a matching target type.
|
|
932
|
+
* Also sanitizes app names to be valid for the target platform.
|
|
926
933
|
*/
|
|
927
934
|
private async resolveDeployCredentials(agent: ManagedAgent): Promise<void> {
|
|
928
935
|
const target = agent.config?.deployment?.target;
|
|
@@ -931,10 +938,19 @@ export class AgentLifecycleManager {
|
|
|
931
938
|
// Ensure deployment.config exists
|
|
932
939
|
if (!agent.config.deployment.config) agent.config.deployment.config = {} as any;
|
|
933
940
|
|
|
934
|
-
//
|
|
941
|
+
// Sanitize cloud.appName if present (Fly.io requires lowercase alphanumeric + hyphens)
|
|
935
942
|
if (target === 'fly' || target === 'railway') {
|
|
936
|
-
|
|
937
|
-
|
|
943
|
+
if (!agent.config.deployment.config.cloud) agent.config.deployment.config.cloud = {} as any;
|
|
944
|
+
const cloud = agent.config.deployment.config.cloud!;
|
|
945
|
+
|
|
946
|
+
if (cloud.appName) {
|
|
947
|
+
cloud.appName = cloud.appName.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '').slice(0, 30);
|
|
948
|
+
}
|
|
949
|
+
// Ensure provider is set
|
|
950
|
+
if (!cloud.provider) cloud.provider = target as any;
|
|
951
|
+
|
|
952
|
+
// If agent already has a token, we're done
|
|
953
|
+
if (cloud.apiToken) return;
|
|
938
954
|
|
|
939
955
|
// Look up org-level credentials
|
|
940
956
|
if (this.engineDb) {
|
|
@@ -942,14 +958,21 @@ export class AgentLifecycleManager {
|
|
|
942
958
|
const orgId = agent.orgId || 'default';
|
|
943
959
|
const creds = await this.engineDb.getDeployCredentialsByType(orgId, target);
|
|
944
960
|
if (creds.length > 0) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
961
|
+
let credConfig = creds[0].config;
|
|
962
|
+
|
|
963
|
+
// Decrypt if encrypted
|
|
964
|
+
if (credConfig?._encrypted && this.vault) {
|
|
965
|
+
try {
|
|
966
|
+
credConfig = JSON.parse(this.vault.decrypt(credConfig._encrypted));
|
|
967
|
+
} catch (decErr) {
|
|
968
|
+
console.error('[lifecycle] Failed to decrypt deploy credential:', decErr);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
if (credConfig?.apiToken || credConfig?.token) {
|
|
973
|
+
cloud.apiToken = credConfig.apiToken || credConfig.token;
|
|
974
|
+
if (credConfig.region && !cloud.region) cloud.region = credConfig.region;
|
|
975
|
+
}
|
|
953
976
|
}
|
|
954
977
|
} catch (err) {
|
|
955
978
|
console.error('[lifecycle] Failed to resolve deploy credentials:', err);
|
package/src/engine/routes.ts
CHANGED
|
@@ -231,7 +231,7 @@ export async function setEngineDb(
|
|
|
231
231
|
|
|
232
232
|
// Cascade DB to all engine modules for persistent storage
|
|
233
233
|
await Promise.all([
|
|
234
|
-
lifecycle.setDb(db),
|
|
234
|
+
lifecycle.setDb(db).then(() => lifecycle.setVault(vault)),
|
|
235
235
|
approvals.setDb(db),
|
|
236
236
|
knowledgeBase.setDb(db),
|
|
237
237
|
activity.setDb(db),
|