@agenticmail/enterprise 0.5.327 → 0.5.329
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/agent-tools-F3CYENMK.js +13949 -0
- package/dist/browser-tool-P57PLVW2.js +4002 -0
- package/dist/chunk-3RI3AIJN.js +1519 -0
- package/dist/chunk-AD4DFKHR.js +4928 -0
- package/dist/chunk-UQXPVWXG.js +5101 -0
- package/dist/cli-agent-K6UFZRXC.js +2473 -0
- package/dist/cli-serve-4MT7RDEL.js +260 -0
- package/dist/cli.js +3 -3
- package/dist/dashboard/app.js +1 -1
- package/dist/dashboard/components/transport-encryption.js +0 -62
- package/dist/dashboard/pages/agent-detail/index.js +5 -2
- package/dist/dashboard/pages/agent-detail/manager.js +1 -1
- package/dist/dashboard/pages/agent-detail/overview.js +4 -2
- package/dist/dashboard/pages/agent-detail/tool-security.js +1 -1
- package/dist/dashboard/pages/domain-status.js +3 -6
- package/dist/dashboard/pages/memory-transfer.js +1 -1
- package/dist/dashboard/pages/messages.js +0 -1
- package/dist/dashboard/pages/roles.js +0 -2
- package/dist/dashboard/pages/workforce.js +0 -1
- package/dist/index.js +3 -3
- package/dist/runtime-L5ADJORP.js +45 -0
- package/dist/server-KSN56EZQ.js +28 -0
- package/dist/setup-UUNBBOQH.js +20 -0
- package/logs/cloudflared-error.log +42 -0
- package/logs/enterprise-out.log +6 -0
- package/package.json +1 -1
- package/src/admin/page-registry.ts +0 -290
- package/src/admin/routes.ts +0 -2968
- package/src/agent-tools/common.ts +0 -260
- package/src/agent-tools/index.ts +0 -542
- package/src/agent-tools/merge.ts +0 -62
- package/src/agent-tools/middleware.ts +0 -436
- package/src/agent-tools/schema/typebox.ts +0 -25
- package/src/agent-tools/security.ts +0 -352
- package/src/agent-tools/tool-resolver.ts +0 -1018
- package/src/agent-tools/tools/agenticmail.ts +0 -1017
- package/src/agent-tools/tools/bash.ts +0 -179
- package/src/agent-tools/tools/browser-tool.schema.ts +0 -112
- package/src/agent-tools/tools/browser-tool.ts +0 -388
- package/src/agent-tools/tools/browser.ts +0 -764
- package/src/agent-tools/tools/edit.ts +0 -100
- package/src/agent-tools/tools/enterprise-code-sandbox.ts +0 -395
- package/src/agent-tools/tools/enterprise-database.ts +0 -377
- package/src/agent-tools/tools/enterprise-diff.ts +0 -580
- package/src/agent-tools/tools/enterprise-documents.ts +0 -896
- package/src/agent-tools/tools/enterprise-http.ts +0 -485
- package/src/agent-tools/tools/enterprise-security-scan.ts +0 -528
- package/src/agent-tools/tools/enterprise-spreadsheet.ts +0 -825
- package/src/agent-tools/tools/glob.ts +0 -129
- package/src/agent-tools/tools/google/calendar.ts +0 -230
- package/src/agent-tools/tools/google/chat.ts +0 -725
- package/src/agent-tools/tools/google/contacts.ts +0 -209
- package/src/agent-tools/tools/google/docs.ts +0 -162
- package/src/agent-tools/tools/google/drive.ts +0 -392
- package/src/agent-tools/tools/google/forms.ts +0 -367
- package/src/agent-tools/tools/google/gmail.ts +0 -897
- package/src/agent-tools/tools/google/index.ts +0 -86
- package/src/agent-tools/tools/google/maps.ts +0 -543
- package/src/agent-tools/tools/google/meeting-voice.ts +0 -885
- package/src/agent-tools/tools/google/meetings.ts +0 -1094
- package/src/agent-tools/tools/google/sheets.ts +0 -215
- package/src/agent-tools/tools/google/slides.ts +0 -559
- package/src/agent-tools/tools/google/tasks.ts +0 -200
- package/src/agent-tools/tools/grep.ts +0 -178
- package/src/agent-tools/tools/integrations/_factory.ts +0 -102
- package/src/agent-tools/tools/integrations/activecampaign.ts +0 -14
- package/src/agent-tools/tools/integrations/adobe-sign.ts +0 -14
- package/src/agent-tools/tools/integrations/adp.ts +0 -14
- package/src/agent-tools/tools/integrations/airtable.ts +0 -14
- package/src/agent-tools/tools/integrations/apollo.ts +0 -14
- package/src/agent-tools/tools/integrations/asana.ts +0 -14
- package/src/agent-tools/tools/integrations/auth0.ts +0 -14
- package/src/agent-tools/tools/integrations/aws.ts +0 -14
- package/src/agent-tools/tools/integrations/azure-devops.ts +0 -14
- package/src/agent-tools/tools/integrations/bamboohr.ts +0 -14
- package/src/agent-tools/tools/integrations/basecamp.ts +0 -14
- package/src/agent-tools/tools/integrations/bigcommerce.ts +0 -14
- package/src/agent-tools/tools/integrations/bitbucket.ts +0 -14
- package/src/agent-tools/tools/integrations/box.ts +0 -14
- package/src/agent-tools/tools/integrations/brex.ts +0 -14
- package/src/agent-tools/tools/integrations/buffer.ts +0 -14
- package/src/agent-tools/tools/integrations/calendly.ts +0 -14
- package/src/agent-tools/tools/integrations/canva.ts +0 -14
- package/src/agent-tools/tools/integrations/chargebee.ts +0 -14
- package/src/agent-tools/tools/integrations/circleci.ts +0 -14
- package/src/agent-tools/tools/integrations/clickup.ts +0 -14
- package/src/agent-tools/tools/integrations/close.ts +0 -14
- package/src/agent-tools/tools/integrations/cloudflare.ts +0 -14
- package/src/agent-tools/tools/integrations/confluence.ts +0 -14
- package/src/agent-tools/tools/integrations/contentful.ts +0 -14
- package/src/agent-tools/tools/integrations/copper.ts +0 -14
- package/src/agent-tools/tools/integrations/crisp.ts +0 -14
- package/src/agent-tools/tools/integrations/crowdstrike.ts +0 -14
- package/src/agent-tools/tools/integrations/datadog.ts +0 -14
- package/src/agent-tools/tools/integrations/digitalocean.ts +0 -14
- package/src/agent-tools/tools/integrations/discord.ts +0 -14
- package/src/agent-tools/tools/integrations/docker.ts +0 -14
- package/src/agent-tools/tools/integrations/docusign.ts +0 -14
- package/src/agent-tools/tools/integrations/drift.ts +0 -14
- package/src/agent-tools/tools/integrations/dropbox.ts +0 -14
- package/src/agent-tools/tools/integrations/figma.ts +0 -14
- package/src/agent-tools/tools/integrations/firebase.ts +0 -14
- package/src/agent-tools/tools/integrations/flyio.ts +0 -14
- package/src/agent-tools/tools/integrations/freshbooks.ts +0 -14
- package/src/agent-tools/tools/integrations/freshdesk.ts +0 -14
- package/src/agent-tools/tools/integrations/freshsales.ts +0 -14
- package/src/agent-tools/tools/integrations/freshservice.ts +0 -14
- package/src/agent-tools/tools/integrations/front.ts +0 -14
- package/src/agent-tools/tools/integrations/github-actions.ts +0 -14
- package/src/agent-tools/tools/integrations/github.ts +0 -14
- package/src/agent-tools/tools/integrations/gitlab.ts +0 -14
- package/src/agent-tools/tools/integrations/gong.ts +0 -14
- package/src/agent-tools/tools/integrations/google-ads.ts +0 -14
- package/src/agent-tools/tools/integrations/google-analytics.ts +0 -14
- package/src/agent-tools/tools/integrations/google-cloud.ts +0 -14
- package/src/agent-tools/tools/integrations/gotomeeting.ts +0 -14
- package/src/agent-tools/tools/integrations/grafana.ts +0 -14
- package/src/agent-tools/tools/integrations/greenhouse.ts +0 -14
- package/src/agent-tools/tools/integrations/gusto.ts +0 -14
- package/src/agent-tools/tools/integrations/hashicorp-vault.ts +0 -14
- package/src/agent-tools/tools/integrations/heroku.ts +0 -14
- package/src/agent-tools/tools/integrations/hibob.ts +0 -14
- package/src/agent-tools/tools/integrations/hootsuite.ts +0 -14
- package/src/agent-tools/tools/integrations/hubspot.ts +0 -14
- package/src/agent-tools/tools/integrations/huggingface.ts +0 -14
- package/src/agent-tools/tools/integrations/index.ts +0 -474
- package/src/agent-tools/tools/integrations/intercom.ts +0 -14
- package/src/agent-tools/tools/integrations/jira.ts +0 -14
- package/src/agent-tools/tools/integrations/klaviyo.ts +0 -14
- package/src/agent-tools/tools/integrations/kubernetes.ts +0 -14
- package/src/agent-tools/tools/integrations/lattice.ts +0 -14
- package/src/agent-tools/tools/integrations/launchdarkly.ts +0 -14
- package/src/agent-tools/tools/integrations/lever.ts +0 -14
- package/src/agent-tools/tools/integrations/linear.ts +0 -14
- package/src/agent-tools/tools/integrations/linkedin.ts +0 -14
- package/src/agent-tools/tools/integrations/livechat.ts +0 -14
- package/src/agent-tools/tools/integrations/loom.ts +0 -14
- package/src/agent-tools/tools/integrations/mailchimp.ts +0 -14
- package/src/agent-tools/tools/integrations/mailgun.ts +0 -14
- package/src/agent-tools/tools/integrations/miro.ts +0 -14
- package/src/agent-tools/tools/integrations/mixpanel.ts +0 -14
- package/src/agent-tools/tools/integrations/monday.ts +0 -14
- package/src/agent-tools/tools/integrations/mongodb-atlas.ts +0 -14
- package/src/agent-tools/tools/integrations/neon.ts +0 -14
- package/src/agent-tools/tools/integrations/netlify.ts +0 -14
- package/src/agent-tools/tools/integrations/netsuite.ts +0 -14
- package/src/agent-tools/tools/integrations/newrelic.ts +0 -14
- package/src/agent-tools/tools/integrations/notion.ts +0 -14
- package/src/agent-tools/tools/integrations/okta.ts +0 -14
- package/src/agent-tools/tools/integrations/openai.ts +0 -14
- package/src/agent-tools/tools/integrations/opsgenie.ts +0 -14
- package/src/agent-tools/tools/integrations/outreach.ts +0 -14
- package/src/agent-tools/tools/integrations/paddle.ts +0 -14
- package/src/agent-tools/tools/integrations/pagerduty.ts +0 -14
- package/src/agent-tools/tools/integrations/pandadoc.ts +0 -14
- package/src/agent-tools/tools/integrations/paypal.ts +0 -14
- package/src/agent-tools/tools/integrations/personio.ts +0 -14
- package/src/agent-tools/tools/integrations/pinecone.ts +0 -14
- package/src/agent-tools/tools/integrations/pipedrive.ts +0 -14
- package/src/agent-tools/tools/integrations/plaid.ts +0 -14
- package/src/agent-tools/tools/integrations/postmark.ts +0 -14
- package/src/agent-tools/tools/integrations/power-automate.ts +0 -14
- package/src/agent-tools/tools/integrations/quickbooks.ts +0 -14
- package/src/agent-tools/tools/integrations/recurly.ts +0 -14
- package/src/agent-tools/tools/integrations/reddit.ts +0 -14
- package/src/agent-tools/tools/integrations/render.ts +0 -14
- package/src/agent-tools/tools/integrations/ringcentral.ts +0 -14
- package/src/agent-tools/tools/integrations/rippling.ts +0 -14
- package/src/agent-tools/tools/integrations/salesforce.ts +0 -14
- package/src/agent-tools/tools/integrations/salesloft.ts +0 -14
- package/src/agent-tools/tools/integrations/sanity.ts +0 -14
- package/src/agent-tools/tools/integrations/sap.ts +0 -14
- package/src/agent-tools/tools/integrations/segment.ts +0 -14
- package/src/agent-tools/tools/integrations/sendgrid.ts +0 -14
- package/src/agent-tools/tools/integrations/sentry.ts +0 -14
- package/src/agent-tools/tools/integrations/servicenow.ts +0 -14
- package/src/agent-tools/tools/integrations/shopify.ts +0 -14
- package/src/agent-tools/tools/integrations/shortcut.ts +0 -14
- package/src/agent-tools/tools/integrations/slack.ts +0 -14
- package/src/agent-tools/tools/integrations/smartsheet.ts +0 -14
- package/src/agent-tools/tools/integrations/snowflake.ts +0 -14
- package/src/agent-tools/tools/integrations/snyk.ts +0 -14
- package/src/agent-tools/tools/integrations/splunk.ts +0 -14
- package/src/agent-tools/tools/integrations/square.ts +0 -14
- package/src/agent-tools/tools/integrations/statuspage.ts +0 -14
- package/src/agent-tools/tools/integrations/stripe.ts +0 -14
- package/src/agent-tools/tools/integrations/supabase.ts +0 -14
- package/src/agent-tools/tools/integrations/teamwork.ts +0 -14
- package/src/agent-tools/tools/integrations/telegram.ts +0 -14
- package/src/agent-tools/tools/integrations/terraform.ts +0 -14
- package/src/agent-tools/tools/integrations/todoist.ts +0 -14
- package/src/agent-tools/tools/integrations/trello.ts +0 -14
- package/src/agent-tools/tools/integrations/twilio.ts +0 -14
- package/src/agent-tools/tools/integrations/twitter.ts +0 -14
- package/src/agent-tools/tools/integrations/vercel.ts +0 -14
- package/src/agent-tools/tools/integrations/weaviate.ts +0 -14
- package/src/agent-tools/tools/integrations/webex.ts +0 -14
- package/src/agent-tools/tools/integrations/webflow.ts +0 -14
- package/src/agent-tools/tools/integrations/whatsapp.ts +0 -14
- package/src/agent-tools/tools/integrations/whereby.ts +0 -14
- package/src/agent-tools/tools/integrations/woocommerce.ts +0 -14
- package/src/agent-tools/tools/integrations/wordpress.ts +0 -14
- package/src/agent-tools/tools/integrations/workday.ts +0 -14
- package/src/agent-tools/tools/integrations/wrike.ts +0 -14
- package/src/agent-tools/tools/integrations/xero.ts +0 -14
- package/src/agent-tools/tools/integrations/youtube.ts +0 -14
- package/src/agent-tools/tools/integrations/zendesk.ts +0 -14
- package/src/agent-tools/tools/integrations/zoho-crm.ts +0 -14
- package/src/agent-tools/tools/integrations/zoom.ts +0 -14
- package/src/agent-tools/tools/integrations/zuora.ts +0 -14
- package/src/agent-tools/tools/knowledge-search.ts +0 -318
- package/src/agent-tools/tools/local/coding.ts +0 -626
- package/src/agent-tools/tools/local/dependency-manager.ts +0 -647
- package/src/agent-tools/tools/local/file-edit.ts +0 -31
- package/src/agent-tools/tools/local/file-list.ts +0 -39
- package/src/agent-tools/tools/local/file-ops.ts +0 -48
- package/src/agent-tools/tools/local/file-read.ts +0 -39
- package/src/agent-tools/tools/local/file-search.ts +0 -46
- package/src/agent-tools/tools/local/file-write.ts +0 -28
- package/src/agent-tools/tools/local/filesystem.ts +0 -5
- package/src/agent-tools/tools/local/index.ts +0 -55
- package/src/agent-tools/tools/local/resolve-path.ts +0 -18
- package/src/agent-tools/tools/local/shell.ts +0 -277
- package/src/agent-tools/tools/local/system-info.ts +0 -29
- package/src/agent-tools/tools/management.ts +0 -425
- package/src/agent-tools/tools/mcp-bridge.ts +0 -142
- package/src/agent-tools/tools/mcp-server-tools.ts +0 -91
- package/src/agent-tools/tools/meeting-lifecycle.ts +0 -438
- package/src/agent-tools/tools/memory.ts +0 -509
- package/src/agent-tools/tools/messaging/index.ts +0 -6
- package/src/agent-tools/tools/messaging/telegram.ts +0 -167
- package/src/agent-tools/tools/messaging/whatsapp.ts +0 -651
- package/src/agent-tools/tools/microsoft/contacts.ts +0 -176
- package/src/agent-tools/tools/microsoft/excel-vba.ts +0 -331
- package/src/agent-tools/tools/microsoft/excel.ts +0 -261
- package/src/agent-tools/tools/microsoft/graph-api.ts +0 -161
- package/src/agent-tools/tools/microsoft/index.ts +0 -95
- package/src/agent-tools/tools/microsoft/onedrive.ts +0 -429
- package/src/agent-tools/tools/microsoft/onenote.ts +0 -186
- package/src/agent-tools/tools/microsoft/outlook-calendar.ts +0 -286
- package/src/agent-tools/tools/microsoft/outlook-mail.ts +0 -723
- package/src/agent-tools/tools/microsoft/planner.ts +0 -200
- package/src/agent-tools/tools/microsoft/powerbi.ts +0 -266
- package/src/agent-tools/tools/microsoft/powerpoint.ts +0 -186
- package/src/agent-tools/tools/microsoft/sharepoint.ts +0 -328
- package/src/agent-tools/tools/microsoft/teams.ts +0 -463
- package/src/agent-tools/tools/microsoft/todo.ts +0 -181
- package/src/agent-tools/tools/oauth-token-provider.ts +0 -101
- package/src/agent-tools/tools/read.ts +0 -160
- package/src/agent-tools/tools/visual-memory/capture.ts +0 -217
- package/src/agent-tools/tools/visual-memory/diff.ts +0 -283
- package/src/agent-tools/tools/visual-memory/index.ts +0 -698
- package/src/agent-tools/tools/visual-memory/phash.ts +0 -120
- package/src/agent-tools/tools/visual-memory/similarity.ts +0 -354
- package/src/agent-tools/tools/visual-memory/storage.ts +0 -534
- package/src/agent-tools/tools/visual-memory/types.ts +0 -100
- package/src/agent-tools/tools/web-fetch-utils.ts +0 -202
- package/src/agent-tools/tools/web-fetch.ts +0 -464
- package/src/agent-tools/tools/web-search.ts +0 -480
- package/src/agent-tools/tools/web-shared.ts +0 -232
- package/src/agent-tools/tools/write.ts +0 -68
- package/src/agent-tools/types.ts +0 -214
- package/src/agenticmail/index.ts +0 -34
- package/src/agenticmail/manager.ts +0 -253
- package/src/agenticmail/providers/google.ts +0 -391
- package/src/agenticmail/providers/imap.ts +0 -454
- package/src/agenticmail/providers/index.ts +0 -28
- package/src/agenticmail/providers/microsoft.ts +0 -260
- package/src/agenticmail/types.ts +0 -173
- package/src/auth/routes.ts +0 -1589
- package/src/browser/bridge-auth-registry.ts +0 -34
- package/src/browser/bridge-server.ts +0 -93
- package/src/browser/cdp.helpers.ts +0 -180
- package/src/browser/cdp.ts +0 -466
- package/src/browser/chrome.executables.ts +0 -625
- package/src/browser/chrome.profile-decoration.ts +0 -198
- package/src/browser/chrome.ts +0 -349
- package/src/browser/client-actions-core.ts +0 -259
- package/src/browser/client-actions-observe.ts +0 -184
- package/src/browser/client-actions-state.ts +0 -284
- package/src/browser/client-actions-types.ts +0 -16
- package/src/browser/client-actions-url.ts +0 -11
- package/src/browser/client-actions.ts +0 -4
- package/src/browser/client-fetch.ts +0 -253
- package/src/browser/client.ts +0 -337
- package/src/browser/config.ts +0 -301
- package/src/browser/constants.ts +0 -8
- package/src/browser/control-auth.ts +0 -94
- package/src/browser/control-service.ts +0 -81
- package/src/browser/csrf.ts +0 -87
- package/src/browser/enterprise-compat.ts +0 -562
- package/src/browser/extension-relay.ts +0 -834
- package/src/browser/http-auth.ts +0 -63
- package/src/browser/navigation-guard.ts +0 -50
- package/src/browser/paths.ts +0 -49
- package/src/browser/playwright.d.ts +0 -12
- package/src/browser/profiles-service.ts +0 -187
- package/src/browser/profiles.ts +0 -114
- package/src/browser/proxy-files.ts +0 -41
- package/src/browser/pw-ai-module.ts +0 -52
- package/src/browser/pw-ai-state.ts +0 -9
- package/src/browser/pw-ai.ts +0 -65
- package/src/browser/pw-role-snapshot.ts +0 -434
- package/src/browser/pw-session.ts +0 -810
- package/src/browser/pw-tools-core.activity.ts +0 -68
- package/src/browser/pw-tools-core.downloads.ts +0 -281
- package/src/browser/pw-tools-core.interactions.ts +0 -646
- package/src/browser/pw-tools-core.responses.ts +0 -124
- package/src/browser/pw-tools-core.shared.ts +0 -70
- package/src/browser/pw-tools-core.snapshot.ts +0 -213
- package/src/browser/pw-tools-core.state.ts +0 -209
- package/src/browser/pw-tools-core.storage.ts +0 -128
- package/src/browser/pw-tools-core.trace.ts +0 -37
- package/src/browser/pw-tools-core.ts +0 -8
- package/src/browser/resolved-config-refresh.ts +0 -59
- package/src/browser/routes/agent.act.shared.ts +0 -52
- package/src/browser/routes/agent.act.ts +0 -575
- package/src/browser/routes/agent.debug.ts +0 -149
- package/src/browser/routes/agent.shared.ts +0 -143
- package/src/browser/routes/agent.snapshot.ts +0 -333
- package/src/browser/routes/agent.storage.ts +0 -451
- package/src/browser/routes/agent.ts +0 -13
- package/src/browser/routes/basic.ts +0 -202
- package/src/browser/routes/dispatcher.ts +0 -126
- package/src/browser/routes/index.ts +0 -11
- package/src/browser/routes/path-output.ts +0 -1
- package/src/browser/routes/tabs.ts +0 -217
- package/src/browser/routes/types.ts +0 -26
- package/src/browser/routes/utils.ts +0 -73
- package/src/browser/screenshot.ts +0 -54
- package/src/browser/server-context.ts +0 -688
- package/src/browser/server-context.types.ts +0 -65
- package/src/browser/server-lifecycle.ts +0 -48
- package/src/browser/server-middleware.ts +0 -37
- package/src/browser/server.ts +0 -110
- package/src/browser/target-id.ts +0 -30
- package/src/browser/trash.ts +0 -21
- package/src/cli-agent.ts +0 -2452
- package/src/cli-reset-password.ts +0 -138
- package/src/cli-serve.ts +0 -314
- package/src/cli.ts +0 -103
- package/src/dashboard/app.js +0 -579
- package/src/dashboard/assets/brand-logos.js +0 -350
- package/src/dashboard/assets/icons/emoji-icons.js +0 -893
- package/src/dashboard/assets/logo.png +0 -0
- package/src/dashboard/assets/provider-logos.js +0 -139
- package/src/dashboard/components/error-boundary.js +0 -21
- package/src/dashboard/components/help-button.js +0 -65
- package/src/dashboard/components/icons.js +0 -64
- package/src/dashboard/components/knowledge-link.js +0 -79
- package/src/dashboard/components/modal.js +0 -125
- package/src/dashboard/components/org-switcher.js +0 -156
- package/src/dashboard/components/persona-fields.js +0 -460
- package/src/dashboard/components/settings-help.js +0 -193
- package/src/dashboard/components/tag-input.js +0 -96
- package/src/dashboard/components/timezones.js +0 -352
- package/src/dashboard/components/transport-encryption.js +0 -288
- package/src/dashboard/components/utils.js +0 -205
- package/src/dashboard/data/countries.js +0 -255
- package/src/dashboard/docs/activity.html +0 -253
- package/src/dashboard/docs/agent-activity.html +0 -199
- package/src/dashboard/docs/agent-autonomy.html +0 -161
- package/src/dashboard/docs/agent-budget.html +0 -190
- package/src/dashboard/docs/agent-channels.html +0 -189
- package/src/dashboard/docs/agent-communication.html +0 -171
- package/src/dashboard/docs/agent-configuration.html +0 -194
- package/src/dashboard/docs/agent-deployment.html +0 -323
- package/src/dashboard/docs/agent-email.html +0 -184
- package/src/dashboard/docs/agent-guardrails.html +0 -206
- package/src/dashboard/docs/agent-manager.html +0 -226
- package/src/dashboard/docs/agent-memory.html +0 -215
- package/src/dashboard/docs/agent-overview.html +0 -226
- package/src/dashboard/docs/agent-permissions.html +0 -305
- package/src/dashboard/docs/agent-personal.html +0 -155
- package/src/dashboard/docs/agent-security.html +0 -188
- package/src/dashboard/docs/agent-skills.html +0 -224
- package/src/dashboard/docs/agent-tool-security.html +0 -205
- package/src/dashboard/docs/agent-tools.html +0 -238
- package/src/dashboard/docs/agent-whatsapp.html +0 -210
- package/src/dashboard/docs/agent-workforce.html +0 -199
- package/src/dashboard/docs/agents.html +0 -258
- package/src/dashboard/docs/approvals.html +0 -200
- package/src/dashboard/docs/audit.html +0 -206
- package/src/dashboard/docs/browser-providers.html +0 -313
- package/src/dashboard/docs/cluster.html +0 -285
- package/src/dashboard/docs/community-skills.html +0 -253
- package/src/dashboard/docs/compliance.html +0 -221
- package/src/dashboard/docs/dashboard.html +0 -84
- package/src/dashboard/docs/database-access.html +0 -322
- package/src/dashboard/docs/dlp.html +0 -268
- package/src/dashboard/docs/docs-style.css +0 -26
- package/src/dashboard/docs/domain-status.html +0 -294
- package/src/dashboard/docs/guardrails.html +0 -265
- package/src/dashboard/docs/journal.html +0 -197
- package/src/dashboard/docs/knowledge-contributions.html +0 -286
- package/src/dashboard/docs/knowledge.html +0 -268
- package/src/dashboard/docs/memory-transfer.html +0 -311
- package/src/dashboard/docs/messages.html +0 -217
- package/src/dashboard/docs/multi-tenant.html +0 -311
- package/src/dashboard/docs/org-chart.html +0 -239
- package/src/dashboard/docs/organizations.html +0 -182
- package/src/dashboard/docs/roles.html +0 -195
- package/src/dashboard/docs/settings-network.html +0 -321
- package/src/dashboard/docs/settings-security.html +0 -347
- package/src/dashboard/docs/settings-tool-security.html +0 -176
- package/src/dashboard/docs/settings.html +0 -280
- package/src/dashboard/docs/skill-connections.html +0 -270
- package/src/dashboard/docs/skills.html +0 -206
- package/src/dashboard/docs/task-pipeline.html +0 -261
- package/src/dashboard/docs/transport-encryption.html +0 -359
- package/src/dashboard/docs/users.html +0 -225
- package/src/dashboard/docs/vault.html +0 -260
- package/src/dashboard/docs/workforce.html +0 -245
- package/src/dashboard/index.html +0 -444
- package/src/dashboard/pages/activity.js +0 -379
- package/src/dashboard/pages/agent-detail/activity.js +0 -277
- package/src/dashboard/pages/agent-detail/autonomy.js +0 -244
- package/src/dashboard/pages/agent-detail/budget.js +0 -269
- package/src/dashboard/pages/agent-detail/channels.js +0 -494
- package/src/dashboard/pages/agent-detail/communication.js +0 -296
- package/src/dashboard/pages/agent-detail/configuration.js +0 -882
- package/src/dashboard/pages/agent-detail/deployment.js +0 -958
- package/src/dashboard/pages/agent-detail/email.js +0 -674
- package/src/dashboard/pages/agent-detail/guardrails.js +0 -521
- package/src/dashboard/pages/agent-detail/index.js +0 -261
- package/src/dashboard/pages/agent-detail/manager.js +0 -357
- package/src/dashboard/pages/agent-detail/meeting-browser.js +0 -933
- package/src/dashboard/pages/agent-detail/memory.js +0 -368
- package/src/dashboard/pages/agent-detail/overview.js +0 -844
- package/src/dashboard/pages/agent-detail/permissions.js +0 -1163
- package/src/dashboard/pages/agent-detail/personal-details.js +0 -404
- package/src/dashboard/pages/agent-detail/security.js +0 -409
- package/src/dashboard/pages/agent-detail/shared.js +0 -85
- package/src/dashboard/pages/agent-detail/skills-section.js +0 -183
- package/src/dashboard/pages/agent-detail/tool-security.js +0 -380
- package/src/dashboard/pages/agent-detail/tools.js +0 -322
- package/src/dashboard/pages/agent-detail/whatsapp.js +0 -824
- package/src/dashboard/pages/agent-detail/workforce.js +0 -683
- package/src/dashboard/pages/agents.js +0 -1242
- package/src/dashboard/pages/approvals.js +0 -100
- package/src/dashboard/pages/audit.js +0 -198
- package/src/dashboard/pages/cluster.js +0 -512
- package/src/dashboard/pages/community-skills.js +0 -1219
- package/src/dashboard/pages/compliance.js +0 -475
- package/src/dashboard/pages/dashboard.js +0 -180
- package/src/dashboard/pages/database-access.js +0 -812
- package/src/dashboard/pages/dlp.js +0 -293
- package/src/dashboard/pages/domain-status.js +0 -951
- package/src/dashboard/pages/guardrails.js +0 -1035
- package/src/dashboard/pages/journal.js +0 -172
- package/src/dashboard/pages/knowledge-contributions.js +0 -1682
- package/src/dashboard/pages/knowledge-import.js +0 -455
- package/src/dashboard/pages/knowledge.js +0 -582
- package/src/dashboard/pages/login.js +0 -1056
- package/src/dashboard/pages/memory-transfer.js +0 -631
- package/src/dashboard/pages/messages.js +0 -303
- package/src/dashboard/pages/org-chart.js +0 -349
- package/src/dashboard/pages/organizations.js +0 -1081
- package/src/dashboard/pages/roles.js +0 -780
- package/src/dashboard/pages/settings.js +0 -3790
- package/src/dashboard/pages/skill-connections.js +0 -982
- package/src/dashboard/pages/skills.js +0 -879
- package/src/dashboard/pages/task-pipeline.js +0 -684
- package/src/dashboard/pages/users.js +0 -867
- package/src/dashboard/pages/vault.js +0 -791
- package/src/dashboard/pages/workforce.js +0 -851
- package/src/dashboard/vendor/react-dom.development.js +0 -29924
- package/src/dashboard/vendor/react-dom.production.min.js +0 -267
- package/src/dashboard/vendor/react.development.js +0 -3343
- package/src/dashboard/vendor/react.production.min.js +0 -31
- package/src/database-access/agent-tools.ts +0 -193
- package/src/database-access/connection-manager.ts +0 -1341
- package/src/database-access/index.ts +0 -21
- package/src/database-access/query-sanitizer.ts +0 -220
- package/src/database-access/routes.ts +0 -226
- package/src/database-access/types.ts +0 -226
- package/src/db/adapter.ts +0 -510
- package/src/db/dynamodb.ts +0 -454
- package/src/db/factory.ts +0 -129
- package/src/db/mongodb.ts +0 -360
- package/src/db/mysql.ts +0 -531
- package/src/db/postgres.ts +0 -863
- package/src/db/proxy.ts +0 -39
- package/src/db/resolve-driver.ts +0 -29
- package/src/db/sql-schema.ts +0 -124
- package/src/db/sqlite.ts +0 -493
- package/src/db/turso.ts +0 -470
- package/src/deploy/fly.ts +0 -368
- package/src/deploy/managed.ts +0 -235
- package/src/domain-lock/cli-recover.ts +0 -591
- package/src/domain-lock/cli-verify.ts +0 -190
- package/src/domain-lock/index.ts +0 -220
- package/src/engine/activity-routes.ts +0 -154
- package/src/engine/activity.ts +0 -568
- package/src/engine/agent-autonomy.ts +0 -974
- package/src/engine/agent-config.ts +0 -646
- package/src/engine/agent-heartbeat.ts +0 -720
- package/src/engine/agent-hierarchy.ts +0 -1064
- package/src/engine/agent-memory.ts +0 -806
- package/src/engine/agent-notify.ts +0 -50
- package/src/engine/agent-routes.ts +0 -2583
- package/src/engine/agent-status.ts +0 -311
- package/src/engine/ambient-memory.ts +0 -401
- package/src/engine/approvals.ts +0 -615
- package/src/engine/assets/thinking-hum.mp3 +0 -0
- package/src/engine/catalog-routes.ts +0 -232
- package/src/engine/chat-poller.ts +0 -913
- package/src/engine/chat-webhook-routes.ts +0 -304
- package/src/engine/cli-build-skill.ts +0 -285
- package/src/engine/cli-submit-skill.ts +0 -200
- package/src/engine/cli-validate.ts +0 -188
- package/src/engine/cluster.ts +0 -278
- package/src/engine/communication-routes.ts +0 -139
- package/src/engine/communication.ts +0 -765
- package/src/engine/community-registry.ts +0 -1529
- package/src/engine/community-routes.ts +0 -260
- package/src/engine/compliance-routes.ts +0 -133
- package/src/engine/compliance.ts +0 -1679
- package/src/engine/config-bus.ts +0 -103
- package/src/engine/db-adapter.ts +0 -1156
- package/src/engine/db-schema.ts +0 -1945
- package/src/engine/deploy-schema-routes.ts +0 -176
- package/src/engine/deployer.ts +0 -957
- package/src/engine/dlp-routes.ts +0 -101
- package/src/engine/dlp.ts +0 -410
- package/src/engine/email-poller.ts +0 -855
- package/src/engine/emoji.ts +0 -106
- package/src/engine/guardrail-routes.ts +0 -125
- package/src/engine/guardrails.ts +0 -465
- package/src/engine/index.ts +0 -255
- package/src/engine/journal-routes.ts +0 -56
- package/src/engine/journal.ts +0 -249
- package/src/engine/knowledge-contribution-routes.ts +0 -633
- package/src/engine/knowledge-contribution.ts +0 -1386
- package/src/engine/knowledge-import/chunker.ts +0 -241
- package/src/engine/knowledge-import/import-manager.ts +0 -416
- package/src/engine/knowledge-import/index.ts +0 -27
- package/src/engine/knowledge-import/processors/clean.ts +0 -149
- package/src/engine/knowledge-import/processors/extract-gdrive.ts +0 -102
- package/src/engine/knowledge-import/processors/extract-github.ts +0 -74
- package/src/engine/knowledge-import/processors/extract-sharepoint.ts +0 -69
- package/src/engine/knowledge-import/processors/extract-web.ts +0 -275
- package/src/engine/knowledge-import/processors/index.ts +0 -18
- package/src/engine/knowledge-import/processors/pipeline.ts +0 -171
- package/src/engine/knowledge-import/processors/types.ts +0 -78
- package/src/engine/knowledge-import/processors/validate.ts +0 -150
- package/src/engine/knowledge-import/provider-file-upload.ts +0 -95
- package/src/engine/knowledge-import/provider-github.ts +0 -144
- package/src/engine/knowledge-import/provider-google-sites.ts +0 -323
- package/src/engine/knowledge-import/provider-sharepoint.ts +0 -276
- package/src/engine/knowledge-import/provider-url.ts +0 -218
- package/src/engine/knowledge-import/routes.ts +0 -94
- package/src/engine/knowledge-import/types.ts +0 -92
- package/src/engine/knowledge-routes.ts +0 -231
- package/src/engine/knowledge.ts +0 -587
- package/src/engine/lifecycle.ts +0 -1420
- package/src/engine/mcp-process-manager.ts +0 -573
- package/src/engine/meeting-monitor.ts +0 -483
- package/src/engine/meeting-voice-intelligence.ts +0 -340
- package/src/engine/memory-routes.ts +0 -142
- package/src/engine/memory-transfer-routes.ts +0 -339
- package/src/engine/messaging-history.ts +0 -177
- package/src/engine/messaging-poller.ts +0 -786
- package/src/engine/model-fallback.ts +0 -141
- package/src/engine/oauth-connect-routes.ts +0 -603
- package/src/engine/oauth-connect.ts +0 -304
- package/src/engine/onboarding-routes.ts +0 -148
- package/src/engine/onboarding.ts +0 -574
- package/src/engine/org-approval-routes.ts +0 -146
- package/src/engine/org-integration-routes.ts +0 -399
- package/src/engine/org-integrations.ts +0 -608
- package/src/engine/org-policies.ts +0 -502
- package/src/engine/policy-import-routes.ts +0 -125
- package/src/engine/policy-import.ts +0 -1186
- package/src/engine/policy-routes.ts +0 -163
- package/src/engine/routes.ts +0 -1236
- package/src/engine/screen-unlock.ts +0 -136
- package/src/engine/session-router.ts +0 -212
- package/src/engine/skill-updater-routes.ts +0 -132
- package/src/engine/skill-updater.ts +0 -480
- package/src/engine/skill-validator.ts +0 -331
- package/src/engine/skills/agent-management.ts +0 -119
- package/src/engine/skills/agent-memory.ts +0 -19
- package/src/engine/skills/agenticmail.ts +0 -116
- package/src/engine/skills/core-tools.ts +0 -25
- package/src/engine/skills/database-access.ts +0 -78
- package/src/engine/skills/enterprise-code-sandbox.ts +0 -113
- package/src/engine/skills/enterprise-database.ts +0 -123
- package/src/engine/skills/enterprise-diff.ts +0 -95
- package/src/engine/skills/enterprise-documents.ts +0 -162
- package/src/engine/skills/enterprise-http.ts +0 -99
- package/src/engine/skills/enterprise-security-scan.ts +0 -125
- package/src/engine/skills/enterprise-spreadsheet.ts +0 -171
- package/src/engine/skills/gws-admin.ts +0 -18
- package/src/engine/skills/gws-calendar.ts +0 -21
- package/src/engine/skills/gws-chat.ts +0 -29
- package/src/engine/skills/gws-contacts.ts +0 -20
- package/src/engine/skills/gws-docs.ts +0 -18
- package/src/engine/skills/gws-drive.ts +0 -23
- package/src/engine/skills/gws-forms.ts +0 -23
- package/src/engine/skills/gws-gmail.ts +0 -30
- package/src/engine/skills/gws-groups.ts +0 -17
- package/src/engine/skills/gws-keep.ts +0 -17
- package/src/engine/skills/gws-maps.ts +0 -25
- package/src/engine/skills/gws-meet.ts +0 -23
- package/src/engine/skills/gws-sheets.ts +0 -22
- package/src/engine/skills/gws-sites.ts +0 -16
- package/src/engine/skills/gws-slides.ts +0 -27
- package/src/engine/skills/gws-tasks.ts +0 -22
- package/src/engine/skills/gws-vault.ts +0 -17
- package/src/engine/skills/index.ts +0 -159
- package/src/engine/skills/knowledge-search.ts +0 -18
- package/src/engine/skills/local-system.ts +0 -61
- package/src/engine/skills/m365-admin.ts +0 -18
- package/src/engine/skills/m365-bookings.ts +0 -17
- package/src/engine/skills/m365-copilot.ts +0 -17
- package/src/engine/skills/m365-excel.ts +0 -60
- package/src/engine/skills/m365-forms.ts +0 -17
- package/src/engine/skills/m365-onedrive.ts +0 -60
- package/src/engine/skills/m365-onenote.ts +0 -17
- package/src/engine/skills/m365-outlook.ts +0 -27
- package/src/engine/skills/m365-planner.ts +0 -18
- package/src/engine/skills/m365-power-automate.ts +0 -18
- package/src/engine/skills/m365-power-bi.ts +0 -19
- package/src/engine/skills/m365-powerpoint.ts +0 -33
- package/src/engine/skills/m365-sharepoint.ts +0 -20
- package/src/engine/skills/m365-teams.ts +0 -21
- package/src/engine/skills/m365-todo.ts +0 -17
- package/src/engine/skills/m365-whiteboard.ts +0 -16
- package/src/engine/skills/m365-word.ts +0 -42
- package/src/engine/skills/mcp-bridge.ts +0 -45
- package/src/engine/skills/meeting-lifecycle.ts +0 -20
- package/src/engine/skills/messaging.ts +0 -46
- package/src/engine/skills/visual-memory.ts +0 -25
- package/src/engine/skills.ts +0 -688
- package/src/engine/soul-library.ts +0 -142
- package/src/engine/soul-templates.json +0 -1525
- package/src/engine/storage-manager.ts +0 -252
- package/src/engine/storage-routes.ts +0 -113
- package/src/engine/storage.ts +0 -528
- package/src/engine/task-poller.ts +0 -394
- package/src/engine/task-queue-after-spawn.ts +0 -66
- package/src/engine/task-queue-before-spawn.ts +0 -113
- package/src/engine/task-queue-routes.ts +0 -161
- package/src/engine/task-queue.ts +0 -664
- package/src/engine/tenant.ts +0 -409
- package/src/engine/tool-catalog.ts +0 -354
- package/src/engine/vault-routes.ts +0 -134
- package/src/engine/vault.ts +0 -601
- package/src/engine/workforce-routes.ts +0 -331
- package/src/engine/workforce.ts +0 -1161
- package/src/index.ts +0 -77
- package/src/lib/cidr.ts +0 -122
- package/src/lib/config-store.ts +0 -86
- package/src/lib/resilience.ts +0 -326
- package/src/lib/text-search.ts +0 -358
- package/src/mcp/adapters/activecampaign.adapter.ts +0 -391
- package/src/mcp/adapters/adobe-sign.adapter.ts +0 -469
- package/src/mcp/adapters/adp.adapter.ts +0 -358
- package/src/mcp/adapters/airtable.adapter.ts +0 -273
- package/src/mcp/adapters/apollo.adapter.ts +0 -420
- package/src/mcp/adapters/asana.adapter.ts +0 -315
- package/src/mcp/adapters/auth0.adapter.ts +0 -386
- package/src/mcp/adapters/aws.adapter.ts +0 -345
- package/src/mcp/adapters/azure-devops.adapter.ts +0 -389
- package/src/mcp/adapters/bamboohr.adapter.ts +0 -376
- package/src/mcp/adapters/basecamp.adapter.ts +0 -366
- package/src/mcp/adapters/bigcommerce.adapter.ts +0 -429
- package/src/mcp/adapters/bitbucket.adapter.ts +0 -260
- package/src/mcp/adapters/box.adapter.ts +0 -350
- package/src/mcp/adapters/brex.adapter.ts +0 -367
- package/src/mcp/adapters/buffer.adapter.ts +0 -303
- package/src/mcp/adapters/calendly.adapter.ts +0 -262
- package/src/mcp/adapters/canva.adapter.ts +0 -256
- package/src/mcp/adapters/chargebee.adapter.ts +0 -448
- package/src/mcp/adapters/circleci.adapter.ts +0 -216
- package/src/mcp/adapters/clickup.adapter.ts +0 -335
- package/src/mcp/adapters/close.adapter.ts +0 -390
- package/src/mcp/adapters/cloudflare.adapter.ts +0 -378
- package/src/mcp/adapters/confluence.adapter.ts +0 -301
- package/src/mcp/adapters/contentful.adapter.ts +0 -355
- package/src/mcp/adapters/copper.adapter.ts +0 -468
- package/src/mcp/adapters/crisp.adapter.ts +0 -415
- package/src/mcp/adapters/crowdstrike.adapter.ts +0 -413
- package/src/mcp/adapters/datadog.adapter.ts +0 -373
- package/src/mcp/adapters/digitalocean.adapter.ts +0 -336
- package/src/mcp/adapters/discord.adapter.ts +0 -248
- package/src/mcp/adapters/docker.adapter.ts +0 -238
- package/src/mcp/adapters/docusign.adapter.ts +0 -431
- package/src/mcp/adapters/drift.adapter.ts +0 -386
- package/src/mcp/adapters/dropbox.adapter.ts +0 -315
- package/src/mcp/adapters/figma.adapter.ts +0 -302
- package/src/mcp/adapters/firebase.adapter.ts +0 -446
- package/src/mcp/adapters/flyio.adapter.ts +0 -302
- package/src/mcp/adapters/freshbooks.adapter.ts +0 -474
- package/src/mcp/adapters/freshdesk.adapter.ts +0 -441
- package/src/mcp/adapters/freshsales.adapter.ts +0 -457
- package/src/mcp/adapters/freshservice.adapter.ts +0 -481
- package/src/mcp/adapters/front.adapter.ts +0 -357
- package/src/mcp/adapters/github-actions.adapter.ts +0 -329
- package/src/mcp/adapters/github.adapter.ts +0 -387
- package/src/mcp/adapters/gitlab.adapter.ts +0 -368
- package/src/mcp/adapters/gong.adapter.ts +0 -386
- package/src/mcp/adapters/google-ads.adapter.ts +0 -363
- package/src/mcp/adapters/google-analytics.adapter.ts +0 -316
- package/src/mcp/adapters/google-cloud.adapter.ts +0 -312
- package/src/mcp/adapters/gotomeeting.adapter.ts +0 -255
- package/src/mcp/adapters/grafana.adapter.ts +0 -361
- package/src/mcp/adapters/greenhouse.adapter.ts +0 -354
- package/src/mcp/adapters/gusto.adapter.ts +0 -329
- package/src/mcp/adapters/hashicorp-vault.adapter.ts +0 -355
- package/src/mcp/adapters/heroku.adapter.ts +0 -291
- package/src/mcp/adapters/hibob.adapter.ts +0 -334
- package/src/mcp/adapters/hootsuite.adapter.ts +0 -322
- package/src/mcp/adapters/hubspot.adapter.ts +0 -400
- package/src/mcp/adapters/huggingface.adapter.ts +0 -349
- package/src/mcp/adapters/index.ts +0 -524
- package/src/mcp/adapters/intercom.adapter.ts +0 -269
- package/src/mcp/adapters/jira.adapter.ts +0 -482
- package/src/mcp/adapters/klaviyo.adapter.ts +0 -353
- package/src/mcp/adapters/kubernetes.adapter.ts +0 -431
- package/src/mcp/adapters/lattice.adapter.ts +0 -339
- package/src/mcp/adapters/launchdarkly.adapter.ts +0 -368
- package/src/mcp/adapters/lever.adapter.ts +0 -347
- package/src/mcp/adapters/linear.adapter.ts +0 -300
- package/src/mcp/adapters/linkedin.adapter.ts +0 -331
- package/src/mcp/adapters/livechat.adapter.ts +0 -259
- package/src/mcp/adapters/loom.adapter.ts +0 -230
- package/src/mcp/adapters/mailchimp.adapter.ts +0 -394
- package/src/mcp/adapters/mailgun.adapter.ts +0 -425
- package/src/mcp/adapters/miro.adapter.ts +0 -274
- package/src/mcp/adapters/mixpanel.adapter.ts +0 -324
- package/src/mcp/adapters/monday.adapter.ts +0 -308
- package/src/mcp/adapters/mongodb-atlas.adapter.ts +0 -345
- package/src/mcp/adapters/neon.adapter.ts +0 -312
- package/src/mcp/adapters/netlify.adapter.ts +0 -324
- package/src/mcp/adapters/netsuite.adapter.ts +0 -411
- package/src/mcp/adapters/newrelic.adapter.ts +0 -339
- package/src/mcp/adapters/notion.adapter.ts +0 -338
- package/src/mcp/adapters/okta.adapter.ts +0 -394
- package/src/mcp/adapters/openai.adapter.ts +0 -315
- package/src/mcp/adapters/opsgenie.adapter.ts +0 -375
- package/src/mcp/adapters/outreach.adapter.ts +0 -372
- package/src/mcp/adapters/paddle.adapter.ts +0 -467
- package/src/mcp/adapters/pagerduty.adapter.ts +0 -412
- package/src/mcp/adapters/pandadoc.adapter.ts +0 -389
- package/src/mcp/adapters/paypal.adapter.ts +0 -465
- package/src/mcp/adapters/personio.adapter.ts +0 -401
- package/src/mcp/adapters/pinecone.adapter.ts +0 -340
- package/src/mcp/adapters/pipedrive.adapter.ts +0 -324
- package/src/mcp/adapters/plaid.adapter.ts +0 -444
- package/src/mcp/adapters/postmark.adapter.ts +0 -387
- package/src/mcp/adapters/power-automate.adapter.ts +0 -388
- package/src/mcp/adapters/quickbooks.adapter.ts +0 -431
- package/src/mcp/adapters/recurly.adapter.ts +0 -433
- package/src/mcp/adapters/reddit.adapter.ts +0 -371
- package/src/mcp/adapters/render.adapter.ts +0 -332
- package/src/mcp/adapters/ringcentral.adapter.ts +0 -281
- package/src/mcp/adapters/rippling.adapter.ts +0 -287
- package/src/mcp/adapters/salesforce.adapter.ts +0 -321
- package/src/mcp/adapters/salesloft.adapter.ts +0 -413
- package/src/mcp/adapters/sanity.adapter.ts +0 -363
- package/src/mcp/adapters/sap.adapter.ts +0 -483
- package/src/mcp/adapters/segment.adapter.ts +0 -260
- package/src/mcp/adapters/sendgrid.adapter.ts +0 -265
- package/src/mcp/adapters/sentry.adapter.ts +0 -331
- package/src/mcp/adapters/servicenow.adapter.ts +0 -468
- package/src/mcp/adapters/shopify.adapter.ts +0 -451
- package/src/mcp/adapters/shortcut.adapter.ts +0 -290
- package/src/mcp/adapters/slack.adapter.ts +0 -380
- package/src/mcp/adapters/smartsheet.adapter.ts +0 -326
- package/src/mcp/adapters/snowflake.adapter.ts +0 -347
- package/src/mcp/adapters/snyk.adapter.ts +0 -394
- package/src/mcp/adapters/splunk.adapter.ts +0 -403
- package/src/mcp/adapters/square.adapter.ts +0 -467
- package/src/mcp/adapters/statuspage.adapter.ts +0 -401
- package/src/mcp/adapters/stripe.adapter.ts +0 -380
- package/src/mcp/adapters/supabase.adapter.ts +0 -334
- package/src/mcp/adapters/teamwork.adapter.ts +0 -404
- package/src/mcp/adapters/telegram.adapter.ts +0 -299
- package/src/mcp/adapters/terraform.adapter.ts +0 -300
- package/src/mcp/adapters/todoist.adapter.ts +0 -239
- package/src/mcp/adapters/trello.adapter.ts +0 -316
- package/src/mcp/adapters/twilio.adapter.ts +0 -233
- package/src/mcp/adapters/twitter.adapter.ts +0 -348
- package/src/mcp/adapters/vercel.adapter.ts +0 -219
- package/src/mcp/adapters/weaviate.adapter.ts +0 -371
- package/src/mcp/adapters/webex.adapter.ts +0 -237
- package/src/mcp/adapters/webflow.adapter.ts +0 -287
- package/src/mcp/adapters/whatsapp.adapter.ts +0 -273
- package/src/mcp/adapters/whereby.adapter.ts +0 -240
- package/src/mcp/adapters/woocommerce.adapter.ts +0 -454
- package/src/mcp/adapters/wordpress.adapter.ts +0 -455
- package/src/mcp/adapters/workday.adapter.ts +0 -354
- package/src/mcp/adapters/wrike.adapter.ts +0 -349
- package/src/mcp/adapters/xero.adapter.ts +0 -472
- package/src/mcp/adapters/youtube.adapter.ts +0 -401
- package/src/mcp/adapters/zendesk.adapter.ts +0 -399
- package/src/mcp/adapters/zoho-crm.adapter.ts +0 -410
- package/src/mcp/adapters/zoom.adapter.ts +0 -241
- package/src/mcp/adapters/zuora.adapter.ts +0 -476
- package/src/mcp/framework/api-executor.ts +0 -192
- package/src/mcp/framework/aws-sigv4.ts +0 -216
- package/src/mcp/framework/credential-resolver.ts +0 -128
- package/src/mcp/framework/oauth-token-manager.ts +0 -22
- package/src/mcp/framework/skill-mcp-framework.ts +0 -226
- package/src/mcp/framework/types.ts +0 -130
- package/src/mcp/index.ts +0 -124
- package/src/mcp/integration-catalog.ts +0 -178
- package/src/middleware/dns-rebinding.ts +0 -44
- package/src/middleware/egress-filter.ts +0 -104
- package/src/middleware/firewall.ts +0 -192
- package/src/middleware/geo-ip.ts +0 -156
- package/src/middleware/index.ts +0 -390
- package/src/middleware/network-config.ts +0 -90
- package/src/middleware/proxy-config.ts +0 -71
- package/src/middleware/request-limits.ts +0 -59
- package/src/middleware/transport-encryption.ts +0 -398
- package/src/registry/cli.ts +0 -63
- package/src/registry/server.ts +0 -504
- package/src/runtime/agent-loop.ts +0 -779
- package/src/runtime/compaction.ts +0 -638
- package/src/runtime/email-channel.ts +0 -120
- package/src/runtime/environment.ts +0 -300
- package/src/runtime/followup.ts +0 -211
- package/src/runtime/gateway.ts +0 -260
- package/src/runtime/hooks.ts +0 -564
- package/src/runtime/index.ts +0 -1110
- package/src/runtime/llm-client.ts +0 -1056
- package/src/runtime/model-router.ts +0 -97
- package/src/runtime/providers.ts +0 -228
- package/src/runtime/session-manager.ts +0 -345
- package/src/runtime/subagent.ts +0 -153
- package/src/runtime/tool-executor.ts +0 -208
- package/src/runtime/types.ts +0 -255
- package/src/security/brute-force.ts +0 -423
- package/src/security/config.ts +0 -159
- package/src/security/csp.ts +0 -407
- package/src/security/external-content.ts +0 -299
- package/src/security/index.ts +0 -557
- package/src/security/input-sanitizer.ts +0 -452
- package/src/security/output-filter.ts +0 -575
- package/src/security/port-scanner.ts +0 -342
- package/src/security/prompt-guard.ts +0 -387
- package/src/security/sql-guard.ts +0 -338
- package/src/security/threat-logger.ts +0 -484
- package/src/server.ts +0 -828
- package/src/setup/company.ts +0 -183
- package/src/setup/database.ts +0 -153
- package/src/setup/deployment.ts +0 -561
- package/src/setup/domain.ts +0 -112
- package/src/setup/index.ts +0 -171
- package/src/setup/provision.ts +0 -532
- package/src/setup/registration.ts +0 -302
- package/src/system-prompts/catchup.ts +0 -48
- package/src/system-prompts/google/calendar.ts +0 -37
- package/src/system-prompts/google/chat.ts +0 -92
- package/src/system-prompts/google/contacts.ts +0 -25
- package/src/system-prompts/google/docs.ts +0 -29
- package/src/system-prompts/google/drive.ts +0 -34
- package/src/system-prompts/google/forms.ts +0 -25
- package/src/system-prompts/google/gmail.ts +0 -50
- package/src/system-prompts/google/index.ts +0 -23
- package/src/system-prompts/google/maps.ts +0 -20
- package/src/system-prompts/google/meet.ts +0 -130
- package/src/system-prompts/google/sheets.ts +0 -32
- package/src/system-prompts/google/slides.ts +0 -26
- package/src/system-prompts/google/tasks.ts +0 -27
- package/src/system-prompts/index.ts +0 -88
- package/src/system-prompts/microsoft/contacts.ts +0 -34
- package/src/system-prompts/microsoft/excel.ts +0 -52
- package/src/system-prompts/microsoft/index.ts +0 -31
- package/src/system-prompts/microsoft/onedrive.ts +0 -41
- package/src/system-prompts/microsoft/onenote.ts +0 -36
- package/src/system-prompts/microsoft/outlook-calendar.ts +0 -37
- package/src/system-prompts/microsoft/outlook-mail.ts +0 -46
- package/src/system-prompts/microsoft/planner.ts +0 -37
- package/src/system-prompts/microsoft/powerbi.ts +0 -38
- package/src/system-prompts/microsoft/powerpoint.ts +0 -35
- package/src/system-prompts/microsoft/sharepoint.ts +0 -44
- package/src/system-prompts/microsoft/teams.ts +0 -49
- package/src/system-prompts/microsoft/todo.ts +0 -37
- package/src/system-prompts/shared-blocks.ts +0 -87
- package/src/system-prompts/task.ts +0 -21
- package/src/system-prompts/triage.ts +0 -34
- package/src/types/hono-env.ts +0 -18
- package/src/types/optional-deps.d.ts +0 -10
- /package/{src → dist}/dashboard/HELP-TOOLTIPS-GUIDE.md +0 -0
package/src/server.ts
DELETED
|
@@ -1,828 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AgenticMail Enterprise Server
|
|
3
|
-
*
|
|
4
|
-
* Hono-based API server with full middleware stack.
|
|
5
|
-
* Production-ready: rate limiting, audit logging, RBAC,
|
|
6
|
-
* health checks, graceful shutdown.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { Hono } from 'hono';
|
|
10
|
-
import type { AppEnv } from './types/hono-env.js';
|
|
11
|
-
import { cors } from 'hono/cors';
|
|
12
|
-
import { serve } from '@hono/node-server';
|
|
13
|
-
import { readFileSync, existsSync } from 'fs';
|
|
14
|
-
import { homedir } from 'os';
|
|
15
|
-
import { fileURLToPath } from 'url';
|
|
16
|
-
|
|
17
|
-
// ─── Production Log Level Filter ─────────────────────────
|
|
18
|
-
const _LOG_LEVEL = (process.env.LOG_LEVEL || 'info').toLowerCase();
|
|
19
|
-
const _LOG_LEVELS: Record<string, number> = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
20
|
-
const _LOG_THRESHOLD = _LOG_LEVELS[_LOG_LEVEL] ?? 1;
|
|
21
|
-
if (_LOG_THRESHOLD > 1) {
|
|
22
|
-
const _origLog = console.log.bind(console);
|
|
23
|
-
console.log = function(...args: any[]) {
|
|
24
|
-
const first = typeof args[0] === 'string' ? args[0] : '';
|
|
25
|
-
if (first.includes('[error]') || first.includes('[fatal]') || first.includes('ERROR')) _origLog(...args);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (_LOG_THRESHOLD > 2) { console.warn = function() {}; }
|
|
29
|
-
import { dirname, join } from 'path';
|
|
30
|
-
import { createRequire } from 'module';
|
|
31
|
-
|
|
32
|
-
// Resolve version at module load time
|
|
33
|
-
let ENTERPRISE_VERSION = 'unknown';
|
|
34
|
-
try {
|
|
35
|
-
const _require = createRequire(import.meta.url);
|
|
36
|
-
ENTERPRISE_VERSION = _require('../package.json').version;
|
|
37
|
-
} catch {
|
|
38
|
-
try { ENTERPRISE_VERSION = JSON.parse(readFileSync(join(process.cwd(), 'node_modules', '@agenticmail', 'enterprise', 'package.json'), 'utf-8')).version; } catch { /* noop */ }
|
|
39
|
-
}
|
|
40
|
-
import type { DatabaseAdapter } from './db/adapter.js';
|
|
41
|
-
import { createDbProxy, type DbProxy } from './db/proxy.js';
|
|
42
|
-
import { createAdminRoutes } from './admin/routes.js';
|
|
43
|
-
import { createAuthRoutes } from './auth/routes.js';
|
|
44
|
-
import {
|
|
45
|
-
requestIdMiddleware,
|
|
46
|
-
requestLogger,
|
|
47
|
-
rateLimiter,
|
|
48
|
-
securityHeaders,
|
|
49
|
-
requireHttps,
|
|
50
|
-
errorHandler,
|
|
51
|
-
auditLogger,
|
|
52
|
-
requireRole,
|
|
53
|
-
} from './middleware/index.js';
|
|
54
|
-
import { ipAccessControl } from './middleware/firewall.js';
|
|
55
|
-
import { setNetworkDb, invalidateNetworkConfig } from './middleware/network-config.js';
|
|
56
|
-
import { initProxyConfig } from './middleware/proxy-config.js';
|
|
57
|
-
import { dnsRebindingProtection } from './middleware/dns-rebinding.js';
|
|
58
|
-
import { requestBodyLimit } from './middleware/request-limits.js';
|
|
59
|
-
import { geoIpRestriction } from './middleware/geo-ip.js';
|
|
60
|
-
import { HealthMonitor, CircuitBreaker } from './lib/resilience.js';
|
|
61
|
-
|
|
62
|
-
export interface ServerConfig {
|
|
63
|
-
port: number;
|
|
64
|
-
db: DatabaseAdapter;
|
|
65
|
-
jwtSecret: string;
|
|
66
|
-
corsOrigins?: string[];
|
|
67
|
-
/** Requests per minute per IP (default: 120) */
|
|
68
|
-
rateLimit?: number;
|
|
69
|
-
/** Trusted proxy IPs for X-Forwarded-For */
|
|
70
|
-
trustedProxies?: string[];
|
|
71
|
-
/** Enable verbose request logging (default: true) */
|
|
72
|
-
logging?: boolean;
|
|
73
|
-
/** Agent runtime configuration (enables standalone agent execution) */
|
|
74
|
-
runtime?: {
|
|
75
|
-
enabled?: boolean;
|
|
76
|
-
defaultModel?: { provider: 'anthropic' | 'openai'; modelId: string; thinkingLevel?: string };
|
|
77
|
-
apiKeys?: { anthropic?: string; openai?: string };
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface ServerInstance {
|
|
82
|
-
app: Hono<AppEnv>;
|
|
83
|
-
start: () => Promise<{ close: () => void }>;
|
|
84
|
-
healthMonitor: HealthMonitor;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function createServer(config: ServerConfig): ServerInstance {
|
|
88
|
-
const app = new Hono<AppEnv>();
|
|
89
|
-
|
|
90
|
-
// Wrap DB in a transparent proxy for hot-swap support during onboarding
|
|
91
|
-
const dbProxy = createDbProxy(config.db) as DbProxy;
|
|
92
|
-
config.db = dbProxy;
|
|
93
|
-
|
|
94
|
-
// ─── Centralized Network Config ─────────────────────
|
|
95
|
-
// Must be initialized before any middleware that reads network config
|
|
96
|
-
setNetworkDb(config.db);
|
|
97
|
-
// Load initial config + apply proxy env vars
|
|
98
|
-
invalidateNetworkConfig().catch(() => {});
|
|
99
|
-
initProxyConfig();
|
|
100
|
-
|
|
101
|
-
// ─── DB Circuit Breaker ──────────────────────────────
|
|
102
|
-
|
|
103
|
-
const dbBreaker = new CircuitBreaker({
|
|
104
|
-
failureThreshold: 5,
|
|
105
|
-
recoveryTimeMs: 30_000,
|
|
106
|
-
timeout: 10_000,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// ─── Health Monitor ──────────────────────────────────
|
|
110
|
-
|
|
111
|
-
const healthMonitor = new HealthMonitor(
|
|
112
|
-
async () => {
|
|
113
|
-
// Simple connectivity check
|
|
114
|
-
await config.db.getStats();
|
|
115
|
-
},
|
|
116
|
-
{ intervalMs: 30_000, timeoutMs: 5_000, unhealthyThreshold: 3 },
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
healthMonitor.onStatusChange((healthy) => {
|
|
120
|
-
console.log(
|
|
121
|
-
`[${new Date().toISOString()}] ${healthy ? '✅' : '❌'} Database health: ${healthy ? 'healthy' : 'unhealthy'}`,
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// ─── Global Middleware ───────────────────────────────
|
|
126
|
-
|
|
127
|
-
// Request ID (first — everything references it)
|
|
128
|
-
app.use('*', requestIdMiddleware());
|
|
129
|
-
|
|
130
|
-
// Error handler (wraps everything below)
|
|
131
|
-
app.use('*', errorHandler());
|
|
132
|
-
|
|
133
|
-
// Security headers (DB-backed)
|
|
134
|
-
app.use('*', securityHeaders());
|
|
135
|
-
|
|
136
|
-
// HTTPS enforcement (DB-backed)
|
|
137
|
-
app.use('*', requireHttps());
|
|
138
|
-
|
|
139
|
-
// DNS rebinding protection (DB-backed)
|
|
140
|
-
app.use('*', dnsRebindingProtection());
|
|
141
|
-
|
|
142
|
-
// Request body size limits (DB-backed)
|
|
143
|
-
app.use('*', requestBodyLimit());
|
|
144
|
-
|
|
145
|
-
// Geo-IP restrictions (DB-backed, requires reverse proxy country headers)
|
|
146
|
-
app.use('*', geoIpRestriction());
|
|
147
|
-
|
|
148
|
-
// IP access control (firewall, DB-backed with trusted proxy validation)
|
|
149
|
-
app.use('*', ipAccessControl());
|
|
150
|
-
|
|
151
|
-
// CORS — reads from centralized network config (auto-refreshed)
|
|
152
|
-
async function getCorsOrigins(): Promise<string[]> {
|
|
153
|
-
// If config provides explicit origins, use those
|
|
154
|
-
if (config.corsOrigins && config.corsOrigins.length && config.corsOrigins[0] !== '*') {
|
|
155
|
-
return config.corsOrigins;
|
|
156
|
-
}
|
|
157
|
-
// Read from centralized network config (cached 15s, invalidated on save)
|
|
158
|
-
const { getNetworkConfig } = await import('./middleware/network-config.js');
|
|
159
|
-
const netConfig = await getNetworkConfig();
|
|
160
|
-
const origins = netConfig.network?.corsOrigins;
|
|
161
|
-
if (origins && Array.isArray(origins) && origins.length > 0) return origins;
|
|
162
|
-
return []; // empty = allow all
|
|
163
|
-
}
|
|
164
|
-
app.use('*', cors({
|
|
165
|
-
origin: async (origin, _c) => {
|
|
166
|
-
const allowed = await getCorsOrigins();
|
|
167
|
-
// If no CORS configured, allow all (open)
|
|
168
|
-
if (!allowed.length) return origin || '*';
|
|
169
|
-
// If origin matches any allowed origin, permit
|
|
170
|
-
if (origin && allowed.includes(origin)) return origin;
|
|
171
|
-
// Also allow requests with no origin (same-origin, curl, server-to-server)
|
|
172
|
-
if (!origin) return allowed[0];
|
|
173
|
-
// Not allowed — return empty string to deny
|
|
174
|
-
return '';
|
|
175
|
-
},
|
|
176
|
-
credentials: true,
|
|
177
|
-
allowHeaders: ['Content-Type', 'Authorization', 'X-API-Key', 'X-Request-Id', 'X-CSRF-Token'],
|
|
178
|
-
exposeHeaders: ['X-Request-Id', 'X-RateLimit-Limit', 'X-RateLimit-Remaining', 'Retry-After', 'X-Transport-Encrypted'],
|
|
179
|
-
}));
|
|
180
|
-
|
|
181
|
-
// Rate limiting
|
|
182
|
-
app.use('*', rateLimiter({
|
|
183
|
-
limit: config.rateLimit ?? 300,
|
|
184
|
-
windowSec: 60,
|
|
185
|
-
skipPaths: ['/health', '/ready', '/dashboard', '/api/engine/agent-status'],
|
|
186
|
-
}));
|
|
187
|
-
|
|
188
|
-
// Request logging
|
|
189
|
-
if (config.logging !== false) {
|
|
190
|
-
app.use('*', requestLogger());
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// ─── Health Endpoints ────────────────────────────────
|
|
194
|
-
|
|
195
|
-
app.get('/health', (c) => c.json({
|
|
196
|
-
status: 'ok',
|
|
197
|
-
version: '0.4.0',
|
|
198
|
-
uptime: process.uptime(),
|
|
199
|
-
}));
|
|
200
|
-
|
|
201
|
-
app.get('/ready', async (c) => {
|
|
202
|
-
const dbHealthy = healthMonitor.isHealthy();
|
|
203
|
-
const status = dbHealthy ? 200 : 503;
|
|
204
|
-
return c.json({
|
|
205
|
-
ready: dbHealthy,
|
|
206
|
-
checks: {
|
|
207
|
-
database: dbHealthy ? 'ok' : 'unhealthy',
|
|
208
|
-
circuitBreaker: dbBreaker.getState(),
|
|
209
|
-
},
|
|
210
|
-
}, status);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
// One-way latch: once setup is complete, skip the bootstrap injection.
|
|
214
|
-
// Checked once at startup; also flipped by the bootstrap callback.
|
|
215
|
-
let _setupComplete = false;
|
|
216
|
-
(async () => {
|
|
217
|
-
try {
|
|
218
|
-
const stats = await config.db.getStats();
|
|
219
|
-
if (stats.totalUsers > 0) _setupComplete = true;
|
|
220
|
-
} catch { /* not ready yet — will be flipped on first bootstrap */ }
|
|
221
|
-
})();
|
|
222
|
-
|
|
223
|
-
// ─── Auth Routes (public) ───────────────────────────
|
|
224
|
-
|
|
225
|
-
const authRoutes = createAuthRoutes(config.db, config.jwtSecret, {
|
|
226
|
-
onBootstrap: () => { _setupComplete = true; },
|
|
227
|
-
onDbConfigure: (newAdapter) => {
|
|
228
|
-
const old = dbProxy.__swap(newAdapter);
|
|
229
|
-
engineInitialized = false;
|
|
230
|
-
return old;
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
app.route('/auth', authRoutes);
|
|
234
|
-
|
|
235
|
-
// ─── Protected API Routes ───────────────────────────
|
|
236
|
-
|
|
237
|
-
const api = new Hono<AppEnv>();
|
|
238
|
-
|
|
239
|
-
// Authentication middleware
|
|
240
|
-
api.use('*', async (c, next) => {
|
|
241
|
-
// Skip auth for OAuth callback (browser redirect from Google/Microsoft)
|
|
242
|
-
if (c.req.path.endsWith('/oauth/callback') && c.req.method === 'GET') {
|
|
243
|
-
return next();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Skip auth for Google Chat webhook (Google sends POST with its own auth)
|
|
247
|
-
if (c.req.path.includes('/chat-webhook') && c.req.method === 'POST') {
|
|
248
|
-
return next();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Skip auth for agent status (internal communication + dashboard SSE)
|
|
252
|
-
// Skip auth for internal service-to-service calls (localhost only)
|
|
253
|
-
if (c.req.path.includes('/engine/agent-status') || c.req.path.includes('/engine/task-pipeline/webhook') || (c.req.path.includes('/whatsapp/proxy-send') && (c.req.header('host') || '').startsWith('localhost'))) {
|
|
254
|
-
return next();
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Skip auth for runtime/chat and runtime/hooks — internal dispatch from enterprise to agent process
|
|
258
|
-
if (c.req.path.includes('/runtime/chat') && c.req.method === 'POST') {
|
|
259
|
-
return next();
|
|
260
|
-
}
|
|
261
|
-
if (c.req.path.includes('/runtime/hooks/') && c.req.method === 'POST') {
|
|
262
|
-
return next();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Check API key first
|
|
266
|
-
const apiKeyHeader = c.req.header('X-API-Key');
|
|
267
|
-
if (apiKeyHeader) {
|
|
268
|
-
const key = await dbBreaker.execute(() => config.db.validateApiKey(apiKeyHeader));
|
|
269
|
-
if (!key) return c.json({ error: 'Invalid API key' }, 401);
|
|
270
|
-
c.set('userId', key.createdBy);
|
|
271
|
-
c.set('authType', 'api-key');
|
|
272
|
-
c.set('apiKeyScopes', key.scopes);
|
|
273
|
-
return next();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// JWT auth — check httpOnly cookie first, then Authorization header
|
|
277
|
-
const { getCookie } = await import('hono/cookie');
|
|
278
|
-
const cookieToken = getCookie(c, 'em_session');
|
|
279
|
-
const authHeader = c.req.header('Authorization');
|
|
280
|
-
const jwt = cookieToken || (authHeader?.startsWith('Bearer ') ? authHeader.slice(7) : null);
|
|
281
|
-
|
|
282
|
-
if (!jwt) {
|
|
283
|
-
return c.json({ error: 'Authentication required' }, 401);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
try {
|
|
287
|
-
const { jwtVerify } = await import('jose');
|
|
288
|
-
const secret = new TextEncoder().encode(config.jwtSecret);
|
|
289
|
-
const { payload } = await jwtVerify(jwt, secret);
|
|
290
|
-
c.set('userId', payload.sub as string);
|
|
291
|
-
c.set('userRole', (payload.role as string) || '');
|
|
292
|
-
c.set('userEmail', (payload.email as string) || '');
|
|
293
|
-
c.set('userOrgId', (payload.orgId as string) || '');
|
|
294
|
-
c.set('clientOrgId', (payload.clientOrgId as string) || '');
|
|
295
|
-
c.set('impersonatedBy', (payload.impersonatedBy as string) || '');
|
|
296
|
-
c.set('authType', cookieToken ? 'cookie' : 'jwt');
|
|
297
|
-
return next();
|
|
298
|
-
} catch {
|
|
299
|
-
return c.json({ error: 'Invalid or expired token' }, 401);
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
// ─── Org-scoping enforcement for client-bound users ───
|
|
304
|
-
// Users with clientOrgId in JWT can ONLY access their bound org's data
|
|
305
|
-
api.use('*', async (c: any, next: any) => {
|
|
306
|
-
const clientOrgId = c.get('clientOrgId');
|
|
307
|
-
if (!clientOrgId) return next(); // Not org-bound, full access
|
|
308
|
-
|
|
309
|
-
// Override orgId in query params to enforce scoping
|
|
310
|
-
const url = new URL(c.req.url);
|
|
311
|
-
const requestedOrg = url.searchParams.get('orgId');
|
|
312
|
-
if (requestedOrg && requestedOrg !== clientOrgId) {
|
|
313
|
-
return c.json({ error: 'Access denied: you can only access your assigned organization' }, 403);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// INJECT clientOrgId when no orgId is specified — ensures downstream queries are always scoped
|
|
317
|
-
// Store for downstream handlers; also override userOrgId so audit/filtering uses client org
|
|
318
|
-
if (!requestedOrg) {
|
|
319
|
-
c.set('enforcedOrgId', clientOrgId);
|
|
320
|
-
c.set('userOrgId', clientOrgId);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// Block org listing — only return their own org
|
|
324
|
-
const path = c.req.path;
|
|
325
|
-
if (path === '/api/organizations' && c.req.method === 'GET') {
|
|
326
|
-
// Let it through but we'll filter in the response
|
|
327
|
-
// Store the clientOrgId for downstream filtering
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Block access to other orgs' data via path params (e.g., /api/engine/stats/:orgId)
|
|
331
|
-
const orgIdMatch = path.match(/\/stats\/([^/]+)/);
|
|
332
|
-
if (orgIdMatch && orgIdMatch[1] !== clientOrgId) {
|
|
333
|
-
return c.json({ error: 'Access denied: you can only access your assigned organization' }, 403);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return next();
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// Audit logging on all API mutations
|
|
340
|
-
api.use('*', auditLogger(config.db));
|
|
341
|
-
|
|
342
|
-
// Transport encryption middleware — encrypts/decrypts sensitive API calls
|
|
343
|
-
api.use('*', async (c, next) => {
|
|
344
|
-
try {
|
|
345
|
-
const { transportEncryptionMiddleware } = await import('./middleware/transport-encryption.js');
|
|
346
|
-
const mw = transportEncryptionMiddleware();
|
|
347
|
-
return mw(c, next);
|
|
348
|
-
} catch {
|
|
349
|
-
return next();
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// Load transport encryption config from DB early
|
|
354
|
-
import('./middleware/transport-encryption.js').then(({ setSettingsDb, loadConfig }) => {
|
|
355
|
-
setSettingsDb(config.db);
|
|
356
|
-
loadConfig().catch(() => {});
|
|
357
|
-
}).catch(() => {});
|
|
358
|
-
|
|
359
|
-
// Admin routes
|
|
360
|
-
const adminRoutes = createAdminRoutes(config.db);
|
|
361
|
-
api.route('/', adminRoutes);
|
|
362
|
-
|
|
363
|
-
// Engine routes (skills, permissions, deployment, approvals, lifecycle, KB, etc.)
|
|
364
|
-
// Loaded lazily on first request to avoid top-level await.
|
|
365
|
-
// On first hit, also initializes the EngineDatabase and runs engine migrations.
|
|
366
|
-
let engineInitialized = false;
|
|
367
|
-
api.all('/engine/*', async (c, _next) => {
|
|
368
|
-
try {
|
|
369
|
-
const { engineRoutes, setEngineDb } = await import('./engine/routes.js');
|
|
370
|
-
const { EngineDatabase } = await import('./engine/db-adapter.js');
|
|
371
|
-
|
|
372
|
-
// Initialize engine DB on first request
|
|
373
|
-
if (!engineInitialized) {
|
|
374
|
-
engineInitialized = true; // Prevent repeated init attempts on failure
|
|
375
|
-
// Use the adapter's built-in engine DB interface (SQL adapters expose raw query methods)
|
|
376
|
-
const engineDbInterface = config.db.getEngineDB();
|
|
377
|
-
if (!engineDbInterface) {
|
|
378
|
-
return c.json({
|
|
379
|
-
error: 'Engine not available',
|
|
380
|
-
detail: `Engine requires a SQL-compatible database. "${config.db.type}" does not support raw SQL queries. Use postgres, mysql, sqlite, or turso.`,
|
|
381
|
-
}, 501);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// Map adapter dialect to engine dialect
|
|
385
|
-
const adapterDialect = config.db.getDialect();
|
|
386
|
-
const dialectMap: Record<string, string> = {
|
|
387
|
-
sqlite: 'sqlite', postgres: 'postgres', supabase: 'postgres',
|
|
388
|
-
neon: 'postgres', cockroachdb: 'postgres', mysql: 'mysql',
|
|
389
|
-
planetscale: 'mysql', turso: 'turso',
|
|
390
|
-
};
|
|
391
|
-
const engineDialect = (dialectMap[adapterDialect] || adapterDialect) as any;
|
|
392
|
-
|
|
393
|
-
const engineDb = new EngineDatabase(engineDbInterface, engineDialect);
|
|
394
|
-
const migrationResult = await engineDb.migrate();
|
|
395
|
-
console.log(`[engine] Migrations: ${migrationResult.applied} applied, ${migrationResult.total} total`);
|
|
396
|
-
await setEngineDb(engineDb, config.db);
|
|
397
|
-
engineInitialized = true;
|
|
398
|
-
|
|
399
|
-
// Start agent runtime if configured
|
|
400
|
-
if (config.runtime?.enabled) {
|
|
401
|
-
try {
|
|
402
|
-
const { createAgentRuntime } = await import('./runtime/index.js');
|
|
403
|
-
const { mountRuntimeApp, setRuntime } = await import('./engine/routes.js');
|
|
404
|
-
// Import lifecycle for email config access
|
|
405
|
-
let getEmailConfig: ((agentId: string) => any) | undefined;
|
|
406
|
-
let onTokenRefresh: ((agentId: string, tokens: any) => void) | undefined;
|
|
407
|
-
let agentMemoryMgr: any;
|
|
408
|
-
try {
|
|
409
|
-
const { lifecycle: lc, memoryManager: mm } = await import('./engine/routes.js');
|
|
410
|
-
agentMemoryMgr = mm;
|
|
411
|
-
if (lc) {
|
|
412
|
-
getEmailConfig = (agentId: string) => {
|
|
413
|
-
const managed = lc.getAgent(agentId);
|
|
414
|
-
const agentEmailCfg = managed?.config?.emailConfig || null;
|
|
415
|
-
// If agent has its own config, use it
|
|
416
|
-
if (agentEmailCfg?.oauthAccessToken || agentEmailCfg?.smtpHost) return agentEmailCfg;
|
|
417
|
-
// Async resolve from org integrations (cache on agent)
|
|
418
|
-
try {
|
|
419
|
-
const { orgIntegrations: oi } = require('./engine/routes.js');
|
|
420
|
-
if (oi && managed) {
|
|
421
|
-
const orgId = (managed as any).client_org_id || (managed as any).clientOrgId || null;
|
|
422
|
-
oi.resolveEmailConfig(orgId, agentEmailCfg).then((resolved: any) => {
|
|
423
|
-
if (resolved && (resolved.oauthAccessToken || resolved.smtpHost)) {
|
|
424
|
-
if (!managed.config) managed.config = {} as any;
|
|
425
|
-
(managed.config as any).emailConfig = resolved;
|
|
426
|
-
(managed.config as any).emailConfig._fromOrgIntegration = true;
|
|
427
|
-
}
|
|
428
|
-
}).catch(() => {});
|
|
429
|
-
}
|
|
430
|
-
} catch {}
|
|
431
|
-
return agentEmailCfg;
|
|
432
|
-
};
|
|
433
|
-
onTokenRefresh = (agentId: string, tokens: any) => {
|
|
434
|
-
const managed = lc.getAgent(agentId);
|
|
435
|
-
if (managed?.config?.emailConfig) {
|
|
436
|
-
if (tokens.accessToken) managed.config.emailConfig.oauthAccessToken = tokens.accessToken;
|
|
437
|
-
if (tokens.refreshToken) managed.config.emailConfig.oauthRefreshToken = tokens.refreshToken;
|
|
438
|
-
if (tokens.expiresAt) managed.config.emailConfig.oauthTokenExpiry = tokens.expiresAt;
|
|
439
|
-
if (!(managed.config.emailConfig as any)?._fromOrgIntegration) {
|
|
440
|
-
lc.saveAgent(agentId).catch(() => {});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
} catch {}
|
|
446
|
-
const { vault: vaultRef, permissionEngine: permRef, databaseManager: dbMgr } = await import('./engine/routes.js');
|
|
447
|
-
const runtime = createAgentRuntime({
|
|
448
|
-
engineDb,
|
|
449
|
-
adminDb: config.db,
|
|
450
|
-
defaultModel: config.runtime.defaultModel as any,
|
|
451
|
-
apiKeys: config.runtime.apiKeys,
|
|
452
|
-
gatewayEnabled: true,
|
|
453
|
-
getEmailConfig,
|
|
454
|
-
onTokenRefresh,
|
|
455
|
-
agentMemoryManager: agentMemoryMgr,
|
|
456
|
-
vault: vaultRef,
|
|
457
|
-
permissionEngine: permRef,
|
|
458
|
-
databaseManager: dbMgr,
|
|
459
|
-
} as any);
|
|
460
|
-
await runtime.start();
|
|
461
|
-
const runtimeApp = runtime.getApp();
|
|
462
|
-
if (runtimeApp) {
|
|
463
|
-
mountRuntimeApp(runtimeApp);
|
|
464
|
-
}
|
|
465
|
-
setRuntime(runtime);
|
|
466
|
-
console.log('[runtime] Agent runtime started and mounted at /api/engine/runtime/*');
|
|
467
|
-
} catch (runtimeErr: any) {
|
|
468
|
-
console.warn(`[runtime] Failed to start agent runtime: ${runtimeErr.message}`);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// Forward to engine routes — inject auth context as headers
|
|
474
|
-
const originalUrl = new URL(c.req.url);
|
|
475
|
-
const subPath = (c.req.path.replace(/^\/api\/engine/, '') || '/') + originalUrl.search;
|
|
476
|
-
const headers = new Headers(c.req.raw.headers);
|
|
477
|
-
const userId = c.get('userId');
|
|
478
|
-
const userRole = c.get('userRole');
|
|
479
|
-
const userEmail = c.get('userEmail');
|
|
480
|
-
const authType = c.get('authType');
|
|
481
|
-
const requestId = c.get('requestId');
|
|
482
|
-
if (userId) headers.set('X-User-Id', String(userId));
|
|
483
|
-
if (userRole) headers.set('X-User-Role', String(userRole));
|
|
484
|
-
if (userEmail) headers.set('X-User-Email', String(userEmail));
|
|
485
|
-
if (authType) headers.set('X-Auth-Type', String(authType));
|
|
486
|
-
if (requestId) headers.set('X-Request-Id', String(requestId));
|
|
487
|
-
// If transport encryption consumed the body, use the decrypted version
|
|
488
|
-
let subBody: any = undefined;
|
|
489
|
-
if (c.req.method !== 'GET' && c.req.method !== 'HEAD') {
|
|
490
|
-
if ((c as any)._decryptedBody !== undefined) {
|
|
491
|
-
subBody = JSON.stringify((c as any)._decryptedBody);
|
|
492
|
-
} else {
|
|
493
|
-
try {
|
|
494
|
-
// Clone the body to avoid "disturbed or locked" errors
|
|
495
|
-
subBody = c.req.raw.bodyUsed ? null : c.req.raw.body;
|
|
496
|
-
} catch {
|
|
497
|
-
subBody = null;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
const subReq = new Request(new URL(subPath, 'http://localhost'), {
|
|
502
|
-
method: c.req.method,
|
|
503
|
-
headers,
|
|
504
|
-
body: subBody,
|
|
505
|
-
});
|
|
506
|
-
return engineRoutes.fetch(subReq);
|
|
507
|
-
} catch (e: any) {
|
|
508
|
-
console.error('[engine] Error:', e.message);
|
|
509
|
-
return c.json({ error: 'Engine module not available', detail: e.message }, 501);
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
app.route('/api', api);
|
|
514
|
-
|
|
515
|
-
// ─── Dashboard (Admin UI) ─────────────────────────────
|
|
516
|
-
|
|
517
|
-
let dashboardHtml: string | null = null;
|
|
518
|
-
function getDashboardHtml(): string {
|
|
519
|
-
if (!dashboardHtml) {
|
|
520
|
-
try {
|
|
521
|
-
const dir = dirname(fileURLToPath(import.meta.url));
|
|
522
|
-
dashboardHtml = readFileSync(join(dir, 'dashboard', 'index.html'), 'utf-8');
|
|
523
|
-
} catch {
|
|
524
|
-
// Fallback: try relative to cwd
|
|
525
|
-
try {
|
|
526
|
-
dashboardHtml = readFileSync(join(process.cwd(), 'node_modules', '@agenticmail', 'enterprise', 'dist', 'dashboard', 'index.html'), 'utf-8');
|
|
527
|
-
} catch {
|
|
528
|
-
dashboardHtml = '<html><body><h1>Dashboard not found</h1><p>The dashboard HTML file could not be located.</p></body></html>';
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return dashboardHtml;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
async function serveDashboard(c: any) {
|
|
536
|
-
let html = getDashboardHtml();
|
|
537
|
-
// Inject version
|
|
538
|
-
html = html.replace('</head>', `<script>window.__ENTERPRISE_VERSION__="${ENTERPRISE_VERSION}";</script></head>`);
|
|
539
|
-
|
|
540
|
-
if (!_setupComplete) {
|
|
541
|
-
const injection = `<script>window.__EM_SETUP_STATE__=${JSON.stringify({ needsBootstrap: true })};</script>`;
|
|
542
|
-
html = html.replace('</head>', injection + '</head>');
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// Inject branding config
|
|
546
|
-
try {
|
|
547
|
-
const settings0 = await config.db.getSettings();
|
|
548
|
-
const branding = settings0?.branding || {};
|
|
549
|
-
if (settings0?.name && !branding.companyName) branding.companyName = settings0.name;
|
|
550
|
-
if (Object.keys(branding).length > 0) {
|
|
551
|
-
const brandScript = `<script>window.__EM_BRANDING__=${JSON.stringify(branding)};</script>`;
|
|
552
|
-
html = html.replace('</head>', brandScript + '</head>');
|
|
553
|
-
}
|
|
554
|
-
} catch { /* non-blocking */ }
|
|
555
|
-
|
|
556
|
-
// Inject domain verification status (informational, does not block)
|
|
557
|
-
try {
|
|
558
|
-
const settings = await config.db.getSettings();
|
|
559
|
-
if (settings.domain && settings.domainStatus) {
|
|
560
|
-
const domainState = {
|
|
561
|
-
domain: settings.domain,
|
|
562
|
-
status: settings.domainStatus,
|
|
563
|
-
verifiedAt: settings.domainVerifiedAt,
|
|
564
|
-
dnsChallenge: settings.domainDnsChallenge,
|
|
565
|
-
};
|
|
566
|
-
const domainScript = `<script>window.__EM_DOMAIN_STATE__=${JSON.stringify(domainState)};</script>`;
|
|
567
|
-
html = html.replace('</head>', domainScript + '</head>');
|
|
568
|
-
}
|
|
569
|
-
} catch { /* non-blocking */ }
|
|
570
|
-
|
|
571
|
-
return c.html(html);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// Serve branding assets from ~/.agenticmail/branding/
|
|
575
|
-
app.get('/branding/*', (c) => {
|
|
576
|
-
const reqPath = c.req.path.replace('/branding/', '').split('?')[0];
|
|
577
|
-
if (reqPath.includes('..')) return c.json({ error: 'Forbidden' }, 403);
|
|
578
|
-
const ext = reqPath.substring(reqPath.lastIndexOf('.'));
|
|
579
|
-
const mimeMap: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.gif': 'image/gif', '.webp': 'image/webp' };
|
|
580
|
-
const mime = mimeMap[ext];
|
|
581
|
-
if (!mime) return c.json({ error: 'Not found' }, 404);
|
|
582
|
-
const brandDir = join(homedir(), '.agenticmail', 'branding');
|
|
583
|
-
const filePath = join(brandDir, reqPath);
|
|
584
|
-
if (!filePath.startsWith(brandDir) || !existsSync(filePath)) return c.json({ error: 'Not found' }, 404);
|
|
585
|
-
const content = readFileSync(filePath);
|
|
586
|
-
return new Response(content, { status: 200, headers: { 'Content-Type': mime, 'Cache-Control': 'no-cache, no-store, must-revalidate' } });
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
app.get('/', (c) => c.redirect('/dashboard'));
|
|
590
|
-
app.get('/dashboard', serveDashboard);
|
|
591
|
-
|
|
592
|
-
// Serve documentation pages and assets
|
|
593
|
-
app.get('/docs/:file', (c) => {
|
|
594
|
-
const file = c.req.param('file').replace(/[^a-z0-9.-]/gi, '');
|
|
595
|
-
const dir = dirname(fileURLToPath(import.meta.url));
|
|
596
|
-
// Try exact file first, then append .html
|
|
597
|
-
let filePath = join(dir, 'dashboard', 'docs', file);
|
|
598
|
-
if (!existsSync(filePath)) filePath = join(dir, 'dashboard', 'docs', file + '.html');
|
|
599
|
-
if (existsSync(filePath)) {
|
|
600
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
601
|
-
const ct = file.endsWith('.css') ? 'text/css; charset=utf-8' : 'text/html; charset=utf-8';
|
|
602
|
-
return new Response(content, { status: 200, headers: { 'Content-Type': ct } });
|
|
603
|
-
}
|
|
604
|
-
return c.json({ error: 'Documentation page not found' }, 404);
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
// Serve dashboard JS modules and static assets (components/*.js, pages/*.js, app.js, assets/*)
|
|
608
|
-
const STATIC_MIME: Record<string, string> = { '.js': 'application/javascript; charset=utf-8', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.gif': 'image/gif', '.webp': 'image/webp', '.css': 'text/css; charset=utf-8' };
|
|
609
|
-
app.get('/dashboard/*', (c) => {
|
|
610
|
-
const reqPath = c.req.path.replace('/dashboard/', '');
|
|
611
|
-
const ext = reqPath.substring(reqPath.lastIndexOf('.'));
|
|
612
|
-
const mime = STATIC_MIME[ext];
|
|
613
|
-
if (mime) {
|
|
614
|
-
const dir = dirname(fileURLToPath(import.meta.url));
|
|
615
|
-
const filePath = join(dir, 'dashboard', reqPath);
|
|
616
|
-
// Prevent path traversal
|
|
617
|
-
if (!filePath.startsWith(join(dir, 'dashboard'))) {
|
|
618
|
-
return c.json({ error: 'Forbidden' }, 403);
|
|
619
|
-
}
|
|
620
|
-
if (existsSync(filePath)) {
|
|
621
|
-
const content = readFileSync(filePath);
|
|
622
|
-
return new Response(content, { status: 200, headers: { 'Content-Type': mime, 'Cache-Control': 'no-cache, no-store, must-revalidate' } });
|
|
623
|
-
}
|
|
624
|
-
// Static asset not found — return 404, NOT the SPA HTML
|
|
625
|
-
// (returning HTML for missing .js causes browser MIME type errors)
|
|
626
|
-
return c.json({ error: 'Not found', path: c.req.path }, 404);
|
|
627
|
-
}
|
|
628
|
-
// Non-asset path — fall through to SPA handler
|
|
629
|
-
return serveDashboard(c);
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
// ─── 404 Handler ─────────────────────────────────────
|
|
633
|
-
|
|
634
|
-
app.notFound((c) => {
|
|
635
|
-
return c.json({ error: 'Not found', path: c.req.path }, 404);
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
// ─── Server Start ────────────────────────────────────
|
|
639
|
-
|
|
640
|
-
return {
|
|
641
|
-
app,
|
|
642
|
-
healthMonitor,
|
|
643
|
-
start: () => {
|
|
644
|
-
return new Promise((resolve) => {
|
|
645
|
-
const server = serve(
|
|
646
|
-
{ fetch: app.fetch, port: config.port },
|
|
647
|
-
(info) => {
|
|
648
|
-
console.log(`\n🏢 AgenticMail Enterprise v${ENTERPRISE_VERSION}`);
|
|
649
|
-
console.log(` API: http://localhost:${info.port}/api`);
|
|
650
|
-
console.log(` Auth: http://localhost:${info.port}/auth`);
|
|
651
|
-
console.log(` Health: http://localhost:${info.port}/health`);
|
|
652
|
-
console.log('');
|
|
653
|
-
|
|
654
|
-
// Start health monitoring
|
|
655
|
-
healthMonitor.start();
|
|
656
|
-
|
|
657
|
-
// Load saved provider API keys from DB (decrypt via vault, pass via runtime config)
|
|
658
|
-
config.db.getSettings().then(async (settings: any) => {
|
|
659
|
-
const { SecureVault } = await import('./engine/vault.js');
|
|
660
|
-
const vaultInst = new SecureVault();
|
|
661
|
-
const keys = settings?.modelPricingConfig?.providerApiKeys;
|
|
662
|
-
if (keys && typeof keys === 'object') {
|
|
663
|
-
for (const [providerId, apiKey] of Object.entries(keys)) {
|
|
664
|
-
if (apiKey && typeof apiKey === 'string') {
|
|
665
|
-
let decrypted: string;
|
|
666
|
-
try {
|
|
667
|
-
decrypted = vaultInst.decrypt(apiKey);
|
|
668
|
-
} catch {
|
|
669
|
-
decrypted = apiKey; // legacy plaintext fallback
|
|
670
|
-
}
|
|
671
|
-
if (config.runtime?.apiKeys) {
|
|
672
|
-
(config.runtime.apiKeys as Record<string, string>)[providerId] = decrypted;
|
|
673
|
-
}
|
|
674
|
-
console.log(` 🔑 Loaded API key for ${providerId} from DB`);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}).catch(() => {});
|
|
679
|
-
|
|
680
|
-
// Eagerly initialize engine (loads lifecycle, starts chat poller, etc.)
|
|
681
|
-
// Without this, engine only initializes on first dashboard request
|
|
682
|
-
(async () => {
|
|
683
|
-
try {
|
|
684
|
-
const { engineRoutes, setEngineDb } = await import('./engine/routes.js');
|
|
685
|
-
const { EngineDatabase } = await import('./engine/db-adapter.js');
|
|
686
|
-
if (!engineInitialized) {
|
|
687
|
-
engineInitialized = true;
|
|
688
|
-
const engineDbInterface = config.db.getEngineDB();
|
|
689
|
-
if (engineDbInterface) {
|
|
690
|
-
const adapterDialect = config.db.getDialect();
|
|
691
|
-
const dialectMap: Record<string, string> = {
|
|
692
|
-
sqlite: 'sqlite', postgres: 'postgres', supabase: 'postgres',
|
|
693
|
-
neon: 'postgres', cockroachdb: 'postgres', mysql: 'mysql',
|
|
694
|
-
planetscale: 'mysql', turso: 'turso',
|
|
695
|
-
};
|
|
696
|
-
const engineDialect = (dialectMap[adapterDialect] || adapterDialect) as any;
|
|
697
|
-
const engineDb = new EngineDatabase(engineDbInterface, engineDialect);
|
|
698
|
-
const migrationResult = await engineDb.migrate();
|
|
699
|
-
console.log(`[engine] Migrations: ${migrationResult.applied} applied, ${migrationResult.total} total`);
|
|
700
|
-
await setEngineDb(engineDb, config.db);
|
|
701
|
-
|
|
702
|
-
// Start agent runtime if configured
|
|
703
|
-
if (config.runtime?.enabled) {
|
|
704
|
-
try {
|
|
705
|
-
const { createAgentRuntime } = await import('./runtime/index.js');
|
|
706
|
-
const { mountRuntimeApp, setRuntime } = await import('./engine/routes.js');
|
|
707
|
-
let getEmailConfig: ((agentId: string) => any) | undefined;
|
|
708
|
-
let onTokenRefresh: ((agentId: string, tokens: any) => void) | undefined;
|
|
709
|
-
let agentMemoryMgr: any;
|
|
710
|
-
try {
|
|
711
|
-
const { lifecycle: lc, memoryManager: mm } = await import('./engine/routes.js');
|
|
712
|
-
agentMemoryMgr = mm;
|
|
713
|
-
if (lc) {
|
|
714
|
-
getEmailConfig = (agentId: string) => {
|
|
715
|
-
const managed = lc.getAgent(agentId);
|
|
716
|
-
const agentEmailCfg = managed?.config?.emailConfig || null;
|
|
717
|
-
if (agentEmailCfg?.oauthAccessToken || agentEmailCfg?.smtpHost) return agentEmailCfg;
|
|
718
|
-
try {
|
|
719
|
-
const { orgIntegrations: oi } = require('./engine/routes.js');
|
|
720
|
-
if (oi && managed) {
|
|
721
|
-
const orgId = (managed as any).client_org_id || (managed as any).clientOrgId || null;
|
|
722
|
-
oi.resolveEmailConfig(orgId, agentEmailCfg).then((resolved: any) => {
|
|
723
|
-
if (resolved && (resolved.oauthAccessToken || resolved.smtpHost)) {
|
|
724
|
-
if (!managed.config) managed.config = {} as any;
|
|
725
|
-
(managed.config as any).emailConfig = resolved;
|
|
726
|
-
(managed.config as any).emailConfig._fromOrgIntegration = true;
|
|
727
|
-
}
|
|
728
|
-
}).catch(() => {});
|
|
729
|
-
}
|
|
730
|
-
} catch {}
|
|
731
|
-
return agentEmailCfg;
|
|
732
|
-
};
|
|
733
|
-
onTokenRefresh = (agentId: string, tokens: any) => {
|
|
734
|
-
const managed = lc.getAgent(agentId);
|
|
735
|
-
if (managed?.config?.emailConfig) {
|
|
736
|
-
if (tokens.accessToken) managed.config.emailConfig.oauthAccessToken = tokens.accessToken;
|
|
737
|
-
if (tokens.refreshToken) managed.config.emailConfig.oauthRefreshToken = tokens.refreshToken;
|
|
738
|
-
if (tokens.expiresAt) managed.config.emailConfig.oauthTokenExpiry = tokens.expiresAt;
|
|
739
|
-
if (!(managed.config.emailConfig as any)?._fromOrgIntegration) {
|
|
740
|
-
lc.saveAgent(agentId).catch(() => {});
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
} catch {}
|
|
746
|
-
const { vault: vaultRef2, permissionEngine: permRef2, databaseManager: dbMgr2 } = await import('./engine/routes.js');
|
|
747
|
-
const runtime = createAgentRuntime({
|
|
748
|
-
engineDb,
|
|
749
|
-
adminDb: config.db,
|
|
750
|
-
defaultModel: config.runtime.defaultModel as any,
|
|
751
|
-
apiKeys: config.runtime.apiKeys,
|
|
752
|
-
gatewayEnabled: true,
|
|
753
|
-
getEmailConfig,
|
|
754
|
-
onTokenRefresh,
|
|
755
|
-
agentMemoryManager: agentMemoryMgr,
|
|
756
|
-
vault: vaultRef2,
|
|
757
|
-
permissionEngine: permRef2,
|
|
758
|
-
hierarchyManager: (await import('./engine/routes.js')).hierarchyManager ?? undefined,
|
|
759
|
-
databaseManager: dbMgr2,
|
|
760
|
-
} as any);
|
|
761
|
-
await runtime.start();
|
|
762
|
-
const runtimeApp = runtime.getApp();
|
|
763
|
-
if (runtimeApp) mountRuntimeApp(runtimeApp);
|
|
764
|
-
setRuntime(runtime);
|
|
765
|
-
console.log('[runtime] Agent runtime started');
|
|
766
|
-
} catch (runtimeErr: any) {
|
|
767
|
-
console.warn(`[runtime] Failed to start: ${runtimeErr.message}`);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
console.log('[engine] Eagerly initialized');
|
|
771
|
-
|
|
772
|
-
// Auto-check PM2 if any agents use local deployment
|
|
773
|
-
try {
|
|
774
|
-
const { lifecycle: lcRef } = await import('./engine/routes.js');
|
|
775
|
-
if (lcRef) {
|
|
776
|
-
const agents = Array.from((lcRef as any).agents?.values?.() || []);
|
|
777
|
-
const hasLocalPm2 = agents.some((a: any) => {
|
|
778
|
-
const target = a?.config?.deployment?.target;
|
|
779
|
-
const pm = a?.config?.deployment?.config?.local?.processManager;
|
|
780
|
-
return target === 'local' && (!pm || pm === 'pm2');
|
|
781
|
-
});
|
|
782
|
-
if (hasLocalPm2) {
|
|
783
|
-
const { ensurePm2 } = await import('./engine/deployer.js');
|
|
784
|
-
const pm2 = await ensurePm2();
|
|
785
|
-
if (pm2.installed) {
|
|
786
|
-
console.log(`[startup] PM2 v${pm2.version} available for local deployments`);
|
|
787
|
-
} else {
|
|
788
|
-
console.warn(`[startup] PM2 auto-install failed: ${pm2.error}`);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
} catch {}
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
} catch (e: any) {
|
|
796
|
-
console.warn(`[engine] Eager init failed: ${e.message}`);
|
|
797
|
-
}
|
|
798
|
-
})();
|
|
799
|
-
|
|
800
|
-
// Graceful shutdown
|
|
801
|
-
const shutdown = () => {
|
|
802
|
-
console.log('\n⏳ Shutting down gracefully...');
|
|
803
|
-
healthMonitor.stop();
|
|
804
|
-
server.close(() => {
|
|
805
|
-
config.db.disconnect().then(() => {
|
|
806
|
-
console.log('✅ Shutdown complete');
|
|
807
|
-
process.exit(0);
|
|
808
|
-
});
|
|
809
|
-
});
|
|
810
|
-
// Force exit after 10s
|
|
811
|
-
setTimeout(() => { process.exit(1); }, 10_000).unref();
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
process.on('SIGINT', shutdown);
|
|
815
|
-
process.on('SIGTERM', shutdown);
|
|
816
|
-
|
|
817
|
-
resolve({
|
|
818
|
-
close: () => {
|
|
819
|
-
healthMonitor.stop();
|
|
820
|
-
server.close();
|
|
821
|
-
},
|
|
822
|
-
});
|
|
823
|
-
},
|
|
824
|
-
);
|
|
825
|
-
});
|
|
826
|
-
},
|
|
827
|
-
};
|
|
828
|
-
}
|