@agenticmail/enterprise 0.5.327 → 0.5.328
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/dashboard/app.js +1 -1
- package/logs/cloudflared-error.log +6 -0
- package/logs/enterprise-out.log +1 -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/HELP-TOOLTIPS-GUIDE.md +0 -45
- 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/engine/routes.ts
DELETED
|
@@ -1,1236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Engine API Routes — Orchestrator
|
|
3
|
-
*
|
|
4
|
-
* Mounts domain-specific sub-routers on the engine Hono app.
|
|
5
|
-
* Mounted at /api/engine/* on the enterprise server.
|
|
6
|
-
*
|
|
7
|
-
* Sub-apps handle domain-specific route groups:
|
|
8
|
-
* - dlp-routes.ts → /dlp/*
|
|
9
|
-
* - guardrail-routes.ts → /guardrails/*, /anomaly-rules/*
|
|
10
|
-
* - journal-routes.ts → /journal/*
|
|
11
|
-
* - communication-routes.ts → /messages/*, /tasks/*
|
|
12
|
-
* - compliance-routes.ts → /compliance/*
|
|
13
|
-
* - catalog-routes.ts → /skills/*, /souls/*, /profiles/*, /permissions/*, /config/*
|
|
14
|
-
* - agent-routes.ts → /agents/*, /usage/*, /budget/*, /bridge/*
|
|
15
|
-
* - knowledge-routes.ts → /knowledge-bases/*
|
|
16
|
-
* - org-approval-routes.ts → /orgs/*, /approvals/*, /escalation-chains/*
|
|
17
|
-
* - activity-routes.ts → /activity/*, /stats/*
|
|
18
|
-
* - deploy-schema-routes.ts → /deploy-credentials/*, /schema/*
|
|
19
|
-
* - community-routes.ts → /community/*
|
|
20
|
-
* - workforce-routes.ts → /workforce/*
|
|
21
|
-
* - policy-routes.ts → /policies/*
|
|
22
|
-
* - memory-routes.ts → /memory/*
|
|
23
|
-
* - onboarding-routes.ts → /onboarding/*
|
|
24
|
-
* - vault-routes.ts → /vault/*
|
|
25
|
-
* - storage-routes.ts → /storage/*
|
|
26
|
-
* - policy-import-routes.ts→ /policies/import/*
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import { Hono } from 'hono';
|
|
30
|
-
import type { AppEnv } from '../types/hono-env.js';
|
|
31
|
-
import { PermissionEngine, BUILTIN_SKILLS, PRESET_PROFILES, SKILL_SUITES } from './skills.js';
|
|
32
|
-
import { FULL_SKILL_DEFINITIONS } from './skills/index.js';
|
|
33
|
-
import { AgentConfigGenerator } from './agent-config.js';
|
|
34
|
-
import { DeploymentEngine } from './deployer.js';
|
|
35
|
-
import { ApprovalEngine } from './approvals.js';
|
|
36
|
-
import { AgentLifecycleManager } from './lifecycle.js';
|
|
37
|
-
import { KnowledgeBaseEngine } from './knowledge.js';
|
|
38
|
-
import { TenantManager } from './tenant.js';
|
|
39
|
-
import { ActivityTracker } from './activity.js';
|
|
40
|
-
import { DLPEngine } from './dlp.js';
|
|
41
|
-
import { AgentCommunicationBus } from './communication.js';
|
|
42
|
-
import { GuardrailEngine } from './guardrails.js';
|
|
43
|
-
import { ActionJournal } from './journal.js';
|
|
44
|
-
import { ComplianceReporter } from './compliance.js';
|
|
45
|
-
import {
|
|
46
|
-
getSoulTemplates,
|
|
47
|
-
getSoulTemplatesByCategory,
|
|
48
|
-
getSoulTemplate,
|
|
49
|
-
searchSoulTemplates,
|
|
50
|
-
SOUL_CATEGORIES,
|
|
51
|
-
} from './soul-library.js';
|
|
52
|
-
import { createDlpRoutes } from './dlp-routes.js';
|
|
53
|
-
import { createGuardrailRoutes, createAnomalyRoutes } from './guardrail-routes.js';
|
|
54
|
-
import { createJournalRoutes } from './journal-routes.js';
|
|
55
|
-
import { createCommunicationRoutes, createTaskRoutes } from './communication-routes.js';
|
|
56
|
-
import { createComplianceRoutes } from './compliance-routes.js';
|
|
57
|
-
import { createCatalogRoutes } from './catalog-routes.js';
|
|
58
|
-
import { createAgentRoutes } from './agent-routes.js';
|
|
59
|
-
import { createKnowledgeRoutes } from './knowledge-routes.js';
|
|
60
|
-
import { createOrgApprovalRoutes } from './org-approval-routes.js';
|
|
61
|
-
import { createActivityRoutes } from './activity-routes.js';
|
|
62
|
-
import { createDeploySchemaRoutes } from './deploy-schema-routes.js';
|
|
63
|
-
import { CommunitySkillRegistry } from './community-registry.js';
|
|
64
|
-
import { createCommunityRoutes } from './community-routes.js';
|
|
65
|
-
import { WorkforceManager } from './workforce.js';
|
|
66
|
-
import { createWorkforceRoutes } from './workforce-routes.js';
|
|
67
|
-
import { OrgPolicyEngine } from './org-policies.js';
|
|
68
|
-
import { AgentMemoryManager } from './agent-memory.js';
|
|
69
|
-
import { OnboardingManager } from './onboarding.js';
|
|
70
|
-
import { createPolicyRoutes } from './policy-routes.js';
|
|
71
|
-
import { KnowledgeContributionManager } from './knowledge-contribution.js';
|
|
72
|
-
import { createKnowledgeContributionRoutes } from './knowledge-contribution-routes.js';
|
|
73
|
-
import { SkillAutoUpdater } from './skill-updater.js';
|
|
74
|
-
import { createSkillUpdaterRoutes } from './skill-updater-routes.js';
|
|
75
|
-
import { KnowledgeImportManager, createKnowledgeImportRoutes } from './knowledge-import/index.js';
|
|
76
|
-
import { createMemoryRoutes } from './memory-routes.js';
|
|
77
|
-
import { createMemoryTransferRoutes } from './memory-transfer-routes.js';
|
|
78
|
-
import { createOnboardingRoutes } from './onboarding-routes.js';
|
|
79
|
-
import { SecureVault } from './vault.js';
|
|
80
|
-
import { StorageManager } from './storage-manager.js';
|
|
81
|
-
import { PolicyImporter } from './policy-import.js';
|
|
82
|
-
import { createVaultRoutes } from './vault-routes.js';
|
|
83
|
-
import { createStorageRoutes } from './storage-routes.js';
|
|
84
|
-
import { createPolicyImportRoutes } from './policy-import-routes.js';
|
|
85
|
-
import { createOAuthConnectRoutes } from './oauth-connect-routes.js';
|
|
86
|
-
import { OrgIntegrationManager } from './org-integrations.js';
|
|
87
|
-
import { createOrgIntegrationRoutes } from './org-integration-routes.js';
|
|
88
|
-
import { createChatWebhookRoutes } from './chat-webhook-routes.js';
|
|
89
|
-
import { ChatPoller } from './chat-poller.js';
|
|
90
|
-
import { EmailPoller } from './email-poller.js';
|
|
91
|
-
import { MessagingPoller } from './messaging-poller.js';
|
|
92
|
-
import { TaskQueueManager } from './task-queue.js';
|
|
93
|
-
import { createTaskQueueRoutes } from './task-queue-routes.js';
|
|
94
|
-
import type { DatabaseAdapter } from '../db/adapter.js';
|
|
95
|
-
|
|
96
|
-
const engine = new Hono<AppEnv>();
|
|
97
|
-
let _engineApp: Hono<AppEnv> = engine;
|
|
98
|
-
|
|
99
|
-
// Forward declarations (set later via setEngineDb)
|
|
100
|
-
let _engineDb: import('./db-adapter.js').EngineDatabase | null = null;
|
|
101
|
-
let _adminDb: DatabaseAdapter | null = null;
|
|
102
|
-
|
|
103
|
-
// ─── Shared Instances ───────────────────────────────────
|
|
104
|
-
|
|
105
|
-
const permissionEngine = new PermissionEngine(FULL_SKILL_DEFINITIONS);
|
|
106
|
-
{
|
|
107
|
-
const totalTools = FULL_SKILL_DEFINITIONS.reduce((s, sk) => s + sk.tools.length, 0);
|
|
108
|
-
console.log(`[permissions] Registered ${FULL_SKILL_DEFINITIONS.length} skills, ${totalTools} tools`);
|
|
109
|
-
}
|
|
110
|
-
const configGen = new AgentConfigGenerator();
|
|
111
|
-
const deployer = new DeploymentEngine();
|
|
112
|
-
const approvals = new ApprovalEngine();
|
|
113
|
-
const lifecycle = new AgentLifecycleManager({ permissions: permissionEngine });
|
|
114
|
-
const knowledgeBase = new KnowledgeBaseEngine();
|
|
115
|
-
const tenants = new TenantManager();
|
|
116
|
-
const activity = new ActivityTracker();
|
|
117
|
-
import { AgentStatusTracker } from './agent-status.js';
|
|
118
|
-
const agentStatus = new AgentStatusTracker();
|
|
119
|
-
import { ClusterManager } from './cluster.js';
|
|
120
|
-
const cluster = new ClusterManager();
|
|
121
|
-
const dlp = new DLPEngine();
|
|
122
|
-
const commBus = new AgentCommunicationBus();
|
|
123
|
-
const guardrails = new GuardrailEngine({
|
|
124
|
-
stopAgent: async (agentId, by, reason) => { await lifecycle.stop(agentId, by, reason); },
|
|
125
|
-
});
|
|
126
|
-
const journal = new ActionJournal();
|
|
127
|
-
const compliance = new ComplianceReporter();
|
|
128
|
-
const communityRegistry = new CommunitySkillRegistry({ permissions: permissionEngine });
|
|
129
|
-
const workforce = new WorkforceManager({ lifecycle, guardrails });
|
|
130
|
-
const policyEngine = new OrgPolicyEngine();
|
|
131
|
-
const memoryManager = new AgentMemoryManager();
|
|
132
|
-
const onboarding = new OnboardingManager({ policyEngine, memoryManager });
|
|
133
|
-
const vault = new SecureVault();
|
|
134
|
-
const orgIntegrations = new OrgIntegrationManager();
|
|
135
|
-
orgIntegrations.setVault(vault);
|
|
136
|
-
const storageManager = new StorageManager({ vault });
|
|
137
|
-
const policyImporter = new PolicyImporter({ policyEngine, storageManager });
|
|
138
|
-
const knowledgeContribution = new KnowledgeContributionManager({ memoryCallback: async (agentId: string) => memoryManager.queryMemories({ agentId }) });
|
|
139
|
-
|
|
140
|
-
// Agent hierarchy manager (org chart, delegation, escalation)
|
|
141
|
-
import { AgentHierarchyManager } from './agent-hierarchy.js';
|
|
142
|
-
let hierarchyManager: AgentHierarchyManager | null = null;
|
|
143
|
-
const knowledgeImport = new KnowledgeImportManager({ knowledgeContribution });
|
|
144
|
-
const taskQueue = new TaskQueueManager();
|
|
145
|
-
const skillUpdater = new SkillAutoUpdater({ registry: communityRegistry });
|
|
146
|
-
|
|
147
|
-
// Wire onboarding into guardrails for onboarding gate checks
|
|
148
|
-
guardrails.setOnboardingManager(onboarding);
|
|
149
|
-
|
|
150
|
-
// Wire lifecycle events into activity tracker
|
|
151
|
-
lifecycle.onEvent((event) => {
|
|
152
|
-
activity.record({
|
|
153
|
-
agentId: event.agentId,
|
|
154
|
-
orgId: event.orgId,
|
|
155
|
-
type: event.type as any,
|
|
156
|
-
data: event.data,
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// Wire lifecycle into communication bus for agent email registry
|
|
161
|
-
commBus.setLifecycle(lifecycle);
|
|
162
|
-
|
|
163
|
-
// Wire birthday automation — sends a birthday email to each agent on their DOB
|
|
164
|
-
lifecycle.setBirthdaySender(async (agent) => {
|
|
165
|
-
const dob = agent.config?.identity?.dateOfBirth;
|
|
166
|
-
if (!dob) return;
|
|
167
|
-
const age = AgentConfigGenerator.deriveAge(dob);
|
|
168
|
-
const name = agent.config.displayName || agent.config.name;
|
|
169
|
-
const ordinal = age % 10 === 1 && age !== 11 ? 'st' : age % 10 === 2 && age !== 12 ? 'nd' : age % 10 === 3 && age !== 13 ? 'rd' : 'th';
|
|
170
|
-
await commBus.sendMessage({
|
|
171
|
-
orgId: agent.orgId,
|
|
172
|
-
fromAgentId: 'system',
|
|
173
|
-
toAgentId: agent.id,
|
|
174
|
-
subject: `Happy Birthday, ${name}!`,
|
|
175
|
-
content: `Happy ${age}${ordinal} birthday, ${name}! Wishing you a wonderful day full of great conversations and accomplishments. Here's to another year of excellence!`,
|
|
176
|
-
priority: 'normal',
|
|
177
|
-
metadata: { type: 'birthday', age, dateOfBirth: dob },
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
lifecycle.startBirthdayScheduler();
|
|
181
|
-
|
|
182
|
-
// ─── Transport Encryption ───────────────────────────────
|
|
183
|
-
import { transportEncryptionMiddleware, setTransportEncryptionConfig, getConfig as getTransportEncConfig, loadConfig as loadTransportEncConfig, setSettingsDb as setTransportEncSettingsDb } from '../middleware/transport-encryption.js';
|
|
184
|
-
engine.use('*', transportEncryptionMiddleware());
|
|
185
|
-
|
|
186
|
-
// Client key exchange endpoint (returns derived key token for dashboard)
|
|
187
|
-
engine.get('/transport-encryption/client-key', async (c) => {
|
|
188
|
-
const cfg = getTransportEncConfig();
|
|
189
|
-
if (!cfg.enabled) return c.json({ enabled: false });
|
|
190
|
-
// Generate a session-scoped key token derived from the server key
|
|
191
|
-
// The client uses this to derive the same encryption/hmac keys
|
|
192
|
-
const baseKey = process.env.TRANSPORT_ENCRYPTION_KEY || process.env.ENCRYPTION_KEY || process.env.JWT_SECRET || 'agenticmail-transport-default-key';
|
|
193
|
-
const { createHash } = await import('node:crypto');
|
|
194
|
-
const suffix = 'agenticmail-transport-v1';
|
|
195
|
-
const keyToken = createHash('sha256').update(`${baseKey}:${suffix}`).digest('hex');
|
|
196
|
-
return c.json({ enabled: true, keyToken });
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
engine.get('/transport-encryption/config', (c) => c.json(getTransportEncConfig()));
|
|
200
|
-
engine.put('/transport-encryption/config', async (c) => {
|
|
201
|
-
const body = await c.req.json();
|
|
202
|
-
setTransportEncryptionConfig(body);
|
|
203
|
-
return c.json({ success: true });
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
// ─── Auth Context Extraction ────────────────────────────
|
|
207
|
-
// When engine routes are called via the server proxy, auth context
|
|
208
|
-
// is forwarded as custom headers. Extract into Hono context.
|
|
209
|
-
engine.use('*', async (c, next) => {
|
|
210
|
-
const userId = c.req.header('X-User-Id');
|
|
211
|
-
const userRole = c.req.header('X-User-Role');
|
|
212
|
-
const authType = c.req.header('X-Auth-Type');
|
|
213
|
-
const requestId = c.req.header('X-Request-Id');
|
|
214
|
-
if (userId) c.set('userId', userId);
|
|
215
|
-
if (userRole) c.set('userRole', userRole);
|
|
216
|
-
if (authType) c.set('authType', authType);
|
|
217
|
-
if (requestId) c.set('requestId', requestId);
|
|
218
|
-
await next();
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// ─── Mount Sub-Apps ─────────────────────────────────────
|
|
222
|
-
|
|
223
|
-
engine.route('/dlp', createDlpRoutes(dlp));
|
|
224
|
-
engine.route('/guardrails', createGuardrailRoutes(guardrails, {
|
|
225
|
-
getWorkforceOffDuty: (agentId) => workforce.isOffDuty(agentId),
|
|
226
|
-
}));
|
|
227
|
-
engine.route('/anomaly-rules', createAnomalyRoutes(guardrails));
|
|
228
|
-
engine.route('/journal', createJournalRoutes(journal));
|
|
229
|
-
engine.route('/messages', createCommunicationRoutes(commBus));
|
|
230
|
-
engine.route('/tasks', createTaskRoutes(commBus));
|
|
231
|
-
engine.route('/task-pipeline', createTaskQueueRoutes(taskQueue));
|
|
232
|
-
engine.route('/compliance', createComplianceRoutes(compliance));
|
|
233
|
-
|
|
234
|
-
engine.route('/', createCatalogRoutes({
|
|
235
|
-
skills: BUILTIN_SKILLS,
|
|
236
|
-
presets: PRESET_PROFILES,
|
|
237
|
-
permissions: permissionEngine,
|
|
238
|
-
configGen,
|
|
239
|
-
soulLib: { getSoulTemplates, getSoulTemplatesByCategory, getSoulTemplate, searchSoulTemplates, SOUL_CATEGORIES },
|
|
240
|
-
suites: SKILL_SUITES,
|
|
241
|
-
lifecycle,
|
|
242
|
-
}));
|
|
243
|
-
|
|
244
|
-
engine.route('/', createAgentRoutes({
|
|
245
|
-
lifecycle,
|
|
246
|
-
permissions: permissionEngine,
|
|
247
|
-
getAdminDb: () => _adminDb,
|
|
248
|
-
get engineDb() { return _engineDb; },
|
|
249
|
-
}));
|
|
250
|
-
|
|
251
|
-
engine.route('/', createKnowledgeRoutes(knowledgeBase));
|
|
252
|
-
|
|
253
|
-
engine.route('/', createOrgApprovalRoutes({
|
|
254
|
-
tenants,
|
|
255
|
-
approvals,
|
|
256
|
-
}));
|
|
257
|
-
|
|
258
|
-
engine.route('/', createActivityRoutes({
|
|
259
|
-
activity,
|
|
260
|
-
tenants,
|
|
261
|
-
lifecycle,
|
|
262
|
-
}));
|
|
263
|
-
|
|
264
|
-
engine.route('/', createDeploySchemaRoutes(() => _engineDb, () => vault));
|
|
265
|
-
|
|
266
|
-
// ─── Real-Time Agent Status ───────────────────────────
|
|
267
|
-
engine.get('/agent-status', (c) => {
|
|
268
|
-
return c.json({ statuses: agentStatus.getAllStatuses() });
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
engine.get('/agent-status/:agentId', (c) => {
|
|
272
|
-
return c.json(agentStatus.getStatus(c.req.param('agentId')));
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
// Agents POST their status here (internal API, no auth needed for agent-to-server)
|
|
276
|
-
engine.post('/agent-status/:agentId', async (c) => {
|
|
277
|
-
try {
|
|
278
|
-
const body = await c.req.json();
|
|
279
|
-
agentStatus.externalUpdate(c.req.param('agentId'), body);
|
|
280
|
-
return c.json({ ok: true });
|
|
281
|
-
} catch (err: any) { return c.json({ error: err.message }, 400); }
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
engine.get('/agent-status-stream', (c) => {
|
|
285
|
-
const filterAgent = c.req.query('agentId');
|
|
286
|
-
const stream = new ReadableStream({
|
|
287
|
-
start(controller) {
|
|
288
|
-
const encoder = new TextEncoder();
|
|
289
|
-
const send = (data: string) => {
|
|
290
|
-
try { controller.enqueue(encoder.encode(`data: ${data}\n\n`)); }
|
|
291
|
-
catch { unsub(); }
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
// Send current state immediately
|
|
295
|
-
if (filterAgent) {
|
|
296
|
-
send(JSON.stringify({ type: 'status', ...agentStatus.getStatus(filterAgent) }));
|
|
297
|
-
} else {
|
|
298
|
-
for (const s of agentStatus.getAllStatuses()) {
|
|
299
|
-
send(JSON.stringify({ type: 'status', ...s }));
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// Subscribe to updates
|
|
304
|
-
const unsub = agentStatus.subscribe((agentId, snapshot) => {
|
|
305
|
-
if (filterAgent && agentId !== filterAgent) return;
|
|
306
|
-
send(JSON.stringify({ type: 'status', ...snapshot }));
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
// Keepalive
|
|
310
|
-
const hb = setInterval(() => send(JSON.stringify({ type: 'heartbeat' })), 30_000);
|
|
311
|
-
|
|
312
|
-
c.req.raw.signal.addEventListener('abort', () => { unsub(); clearInterval(hb); });
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
return new Response(stream, {
|
|
316
|
-
headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive' },
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// ─── Cluster Management ─────────────────────────────────
|
|
321
|
-
engine.get('/cluster/nodes', (c) => c.json({ nodes: cluster.getAllNodes(), stats: cluster.getStats() }));
|
|
322
|
-
engine.get('/cluster/nodes/:nodeId', (c) => {
|
|
323
|
-
const node = cluster.getNode(c.req.param('nodeId'));
|
|
324
|
-
return node ? c.json(node) : c.json({ error: 'Node not found' }, 404);
|
|
325
|
-
});
|
|
326
|
-
engine.post('/cluster/register', async (c) => {
|
|
327
|
-
const body = await c.req.json();
|
|
328
|
-
if (!body.nodeId || !body.host || !body.port) return c.json({ error: 'nodeId, host, port required' }, 400);
|
|
329
|
-
const node = await cluster.register(body);
|
|
330
|
-
return c.json(node);
|
|
331
|
-
});
|
|
332
|
-
engine.post('/cluster/heartbeat/:nodeId', async (c) => {
|
|
333
|
-
const body = await c.req.json().catch(() => ({}));
|
|
334
|
-
cluster.heartbeat(c.req.param('nodeId'), body);
|
|
335
|
-
return c.json({ ok: true });
|
|
336
|
-
});
|
|
337
|
-
engine.delete('/cluster/nodes/:nodeId', async (c) => {
|
|
338
|
-
await cluster.remove(c.req.param('nodeId'));
|
|
339
|
-
return c.json({ removed: true });
|
|
340
|
-
});
|
|
341
|
-
engine.get('/cluster/best-node', (c) => {
|
|
342
|
-
const caps = c.req.query('capabilities')?.split(',').filter(Boolean);
|
|
343
|
-
const node = cluster.findBestNode(caps);
|
|
344
|
-
return node ? c.json(node) : c.json({ error: 'No suitable node available' }, 404);
|
|
345
|
-
});
|
|
346
|
-
engine.post('/cluster/test-connection', async (c) => {
|
|
347
|
-
const { host, port } = await c.req.json();
|
|
348
|
-
if (!host) return c.json({ error: 'host required' }, 400);
|
|
349
|
-
const p = port || 3101;
|
|
350
|
-
const start = Date.now();
|
|
351
|
-
try {
|
|
352
|
-
const ctrl = new AbortController();
|
|
353
|
-
const timeout = setTimeout(() => ctrl.abort(), 5000);
|
|
354
|
-
const res = await fetch(`http://${host}:${p}/health`, { signal: ctrl.signal }).catch(() => null);
|
|
355
|
-
clearTimeout(timeout);
|
|
356
|
-
if (res && res.ok) {
|
|
357
|
-
const data = await res.json().catch(() => ({}));
|
|
358
|
-
return c.json({ success: true, latencyMs: Date.now() - start, version: data.version, agentId: data.agentId });
|
|
359
|
-
}
|
|
360
|
-
// Try the enterprise status endpoint as fallback
|
|
361
|
-
const ctrl2 = new AbortController();
|
|
362
|
-
const timeout2 = setTimeout(() => ctrl2.abort(), 5000);
|
|
363
|
-
const res2 = await fetch(`http://${host}:${p}/api/status`, { signal: ctrl2.signal }).catch(() => null);
|
|
364
|
-
clearTimeout(timeout2);
|
|
365
|
-
if (res2 && res2.ok) {
|
|
366
|
-
return c.json({ success: true, latencyMs: Date.now() - start, version: 'enterprise' });
|
|
367
|
-
}
|
|
368
|
-
return c.json({ success: false, error: 'No response from ' + host + ':' + p, latencyMs: Date.now() - start });
|
|
369
|
-
} catch (e: any) {
|
|
370
|
-
return c.json({ success: false, error: e.message || 'Connection failed', latencyMs: Date.now() - start });
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
engine.post('/cluster/deploy-via-ssh', async (c) => {
|
|
375
|
-
const body = await c.req.json();
|
|
376
|
-
if (!body.host) return c.json({ error: 'host required' }, 400);
|
|
377
|
-
// Use the deployment engine's SSH infrastructure
|
|
378
|
-
try {
|
|
379
|
-
const dbUrl = process.env.DATABASE_URL || '';
|
|
380
|
-
const enterpriseUrl = process.env.ENTERPRISE_URL || `http://${body.host}:${body.port || 3101}`;
|
|
381
|
-
const nodeId = body.name?.toLowerCase().replace(/[^a-z0-9-]/g, '-') || 'worker-' + body.host.replace(/\./g, '-');
|
|
382
|
-
|
|
383
|
-
// Build remote setup script
|
|
384
|
-
const script = [
|
|
385
|
-
'#!/bin/bash',
|
|
386
|
-
'set -e',
|
|
387
|
-
'export NVM_DIR="$HOME/.nvm"',
|
|
388
|
-
'[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"',
|
|
389
|
-
'',
|
|
390
|
-
'# Install Node.js if not present',
|
|
391
|
-
'if ! command -v node &> /dev/null; then',
|
|
392
|
-
' if command -v apt-get &> /dev/null; then',
|
|
393
|
-
' curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -',
|
|
394
|
-
' sudo apt-get install -y nodejs',
|
|
395
|
-
' elif command -v brew &> /dev/null; then',
|
|
396
|
-
' brew install node',
|
|
397
|
-
' fi',
|
|
398
|
-
'fi',
|
|
399
|
-
'',
|
|
400
|
-
'# Install PM2 and AgenticMail',
|
|
401
|
-
'npm install -g pm2 @agenticmail/enterprise',
|
|
402
|
-
'',
|
|
403
|
-
'# Write env file',
|
|
404
|
-
'mkdir -p ~/.agenticmail',
|
|
405
|
-
`cat > ~/.agenticmail/worker.env << 'ENVEOF'`,
|
|
406
|
-
`ENTERPRISE_URL=${enterpriseUrl}`,
|
|
407
|
-
`WORKER_NODE_ID=${nodeId}`,
|
|
408
|
-
`WORKER_NAME="${body.name || nodeId}"`,
|
|
409
|
-
`DATABASE_URL=${dbUrl}`,
|
|
410
|
-
`PORT=${body.port || 3101}`,
|
|
411
|
-
'LOG_LEVEL=warn',
|
|
412
|
-
'ENVEOF',
|
|
413
|
-
'',
|
|
414
|
-
'# Start agents via PM2',
|
|
415
|
-
...(body.agentIds || []).map((id: string, i: number) =>
|
|
416
|
-
`pm2 start "$(which agenticmail-enterprise || echo npx @agenticmail/enterprise) agent --id ${id}" --name "agent-${i}" --env ~/.agenticmail/worker.env`
|
|
417
|
-
),
|
|
418
|
-
'pm2 save',
|
|
419
|
-
'echo "DEPLOY_SUCCESS"',
|
|
420
|
-
].join('\n');
|
|
421
|
-
|
|
422
|
-
const { execSync } = await import('child_process');
|
|
423
|
-
const sshTarget = `${body.user || 'root'}@${body.host}`;
|
|
424
|
-
const keyOpt = body.privateKey ? `-i /tmp/_am_ssh_key_${Date.now()}` : '';
|
|
425
|
-
|
|
426
|
-
if (body.privateKey) {
|
|
427
|
-
const { writeFileSync, chmodSync } = await import('fs');
|
|
428
|
-
const keyPath = `/tmp/_am_ssh_key_${Date.now()}`;
|
|
429
|
-
writeFileSync(keyPath, body.privateKey, { mode: 0o600 });
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const scriptB64 = Buffer.from(script).toString('base64');
|
|
433
|
-
const sshCmd = `ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 ${keyOpt} ${sshTarget} "echo '${scriptB64}' | base64 -d | bash"`;
|
|
434
|
-
|
|
435
|
-
// Run async — don't block the request
|
|
436
|
-
const { exec } = await import('child_process');
|
|
437
|
-
exec(sshCmd, { timeout: 120_000 }, (err, stdout, _stderr) => {
|
|
438
|
-
if (err) {
|
|
439
|
-
console.warn(`[cluster] SSH deploy to ${body.host} failed:`, err.message);
|
|
440
|
-
} else if (stdout.includes('DEPLOY_SUCCESS')) {
|
|
441
|
-
console.log(`[cluster] SSH deploy to ${body.host} succeeded`);
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
return c.json({ message: 'Deployment started via SSH to ' + sshTarget + '. Check the Cluster page for the node to appear.', nodeId });
|
|
446
|
-
} catch (e: any) {
|
|
447
|
-
return c.json({ error: 'SSH deploy failed: ' + e.message }, 500);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
engine.post('/cluster/nodes/:nodeId/restart', async (c) => {
|
|
452
|
-
const node = cluster.getNode(c.req.param('nodeId'));
|
|
453
|
-
if (!node) return c.json({ error: 'Node not found' }, 404);
|
|
454
|
-
try {
|
|
455
|
-
const ctrl = new AbortController();
|
|
456
|
-
setTimeout(() => ctrl.abort(), 10000);
|
|
457
|
-
await fetch(`${node.url}/restart`, { method: 'POST', signal: ctrl.signal }).catch(() => {});
|
|
458
|
-
return c.json({ ok: true, message: 'Restart signal sent to ' + node.name });
|
|
459
|
-
} catch (e: any) {
|
|
460
|
-
return c.json({ error: e.message }, 500);
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
engine.get('/cluster/stream', (c) => {
|
|
465
|
-
const stream = new ReadableStream({
|
|
466
|
-
start(controller) {
|
|
467
|
-
const encoder = new TextEncoder();
|
|
468
|
-
const send = (d: string) => { try { controller.enqueue(encoder.encode(`data: ${d}\n\n`)); } catch { unsub(); } };
|
|
469
|
-
// Send current state
|
|
470
|
-
for (const n of cluster.getAllNodes()) send(JSON.stringify({ type: 'node', event: 'snapshot', ...n }));
|
|
471
|
-
const unsub = cluster.subscribe((_nodeId, node, event) => send(JSON.stringify({ type: 'node', event, ...node })));
|
|
472
|
-
const hb = setInterval(() => send(JSON.stringify({ type: 'heartbeat' })), 30_000);
|
|
473
|
-
c.req.raw.signal.addEventListener('abort', () => { unsub(); clearInterval(hb); });
|
|
474
|
-
},
|
|
475
|
-
});
|
|
476
|
-
return new Response(stream, { headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive' } });
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
engine.route('/community', createCommunityRoutes(communityRegistry));
|
|
480
|
-
engine.route('/workforce', createWorkforceRoutes(workforce, { lifecycle }));
|
|
481
|
-
engine.route('/policies', createPolicyRoutes(policyEngine));
|
|
482
|
-
engine.route('/memory', createMemoryRoutes(memoryManager));
|
|
483
|
-
engine.route('/memory-transfer', createMemoryTransferRoutes(memoryManager, _engineDb));
|
|
484
|
-
engine.route('/onboarding', createOnboardingRoutes(onboarding));
|
|
485
|
-
engine.route('/vault', createVaultRoutes(vault, dlp));
|
|
486
|
-
engine.route('/storage', createStorageRoutes(storageManager));
|
|
487
|
-
engine.route('/policies', createPolicyImportRoutes(policyImporter));
|
|
488
|
-
engine.route('/knowledge-contribution', createKnowledgeContributionRoutes(knowledgeContribution, { lifecycle }));
|
|
489
|
-
engine.route('/knowledge-import', createKnowledgeImportRoutes(knowledgeImport));
|
|
490
|
-
engine.route('/skill-updates', createSkillUpdaterRoutes(skillUpdater));
|
|
491
|
-
engine.route('/oauth', createOAuthConnectRoutes(vault, lifecycle, () => _adminDb));
|
|
492
|
-
engine.route('/org-integrations', createOrgIntegrationRoutes(orgIntegrations));
|
|
493
|
-
|
|
494
|
-
// Database Access system
|
|
495
|
-
import { DatabaseConnectionManager, createDatabaseAccessRoutes } from '../database-access/index.js';
|
|
496
|
-
const databaseManager = new DatabaseConnectionManager({ vault });
|
|
497
|
-
engine.route('/database', createDatabaseAccessRoutes(databaseManager));
|
|
498
|
-
|
|
499
|
-
// ─── Hierarchy / Management API ─────────────────────────
|
|
500
|
-
engine.get('/hierarchy/org-chart', async (c) => {
|
|
501
|
-
if (!hierarchyManager) return c.json({ error: 'Hierarchy not initialized' }, 503);
|
|
502
|
-
try {
|
|
503
|
-
const chart = await hierarchyManager.buildOrgChart();
|
|
504
|
-
const nodes = await hierarchyManager.buildHierarchy();
|
|
505
|
-
return c.json({ chart, nodes: Array.from(nodes.values()) });
|
|
506
|
-
} catch (e: any) {
|
|
507
|
-
return c.json({ error: e.message }, 500);
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
engine.get('/hierarchy/team/:managerId', async (c) => {
|
|
512
|
-
if (!hierarchyManager) return c.json({ error: 'Hierarchy not initialized' }, 503);
|
|
513
|
-
try {
|
|
514
|
-
const status = await hierarchyManager.getTeamStatus(c.req.param('managerId'));
|
|
515
|
-
return c.json(status);
|
|
516
|
-
} catch (e: any) {
|
|
517
|
-
return c.json({ error: e.message }, 500);
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
engine.get('/hierarchy/tasks/:agentId', async (c) => {
|
|
522
|
-
if (!hierarchyManager) return c.json({ error: 'Hierarchy not initialized' }, 503);
|
|
523
|
-
try {
|
|
524
|
-
const status = c.req.query('status');
|
|
525
|
-
const direction = c.req.query('direction') || 'assigned'; // assigned | delegated
|
|
526
|
-
const tasks = direction === 'delegated'
|
|
527
|
-
? await hierarchyManager.getTasksByManager(c.req.param('agentId'), status || undefined)
|
|
528
|
-
: await hierarchyManager.getTasksForAgent(c.req.param('agentId'), status || undefined);
|
|
529
|
-
return c.json({ tasks });
|
|
530
|
-
} catch (e: any) {
|
|
531
|
-
return c.json({ error: e.message }, 500);
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
engine.get('/hierarchy/escalations/:agentId', async (c) => {
|
|
536
|
-
if (!hierarchyManager) return c.json({ error: 'Hierarchy not initialized' }, 503);
|
|
537
|
-
try {
|
|
538
|
-
const escalations = await hierarchyManager.getPendingEscalations(c.req.param('agentId'));
|
|
539
|
-
return c.json({ escalations });
|
|
540
|
-
} catch (e: any) {
|
|
541
|
-
return c.json({ error: e.message }, 500);
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
// ─── MCP Server Management ──────────────────────────────────────────
|
|
546
|
-
// CRUD for external MCP server connections (stdio, SSE, HTTP)
|
|
547
|
-
engine.get('/mcp-servers', async (c) => {
|
|
548
|
-
try {
|
|
549
|
-
const rows = await _engineDb!.query(`SELECT * FROM mcp_servers WHERE org_id = $1 ORDER BY created_at DESC`, ['default']);
|
|
550
|
-
const servers = (rows || []).map((r: any) => {
|
|
551
|
-
const config = typeof r.config === 'string' ? JSON.parse(r.config) : (r.config || {});
|
|
552
|
-
return { id: r.id, ...config, status: r.status || 'unknown', toolCount: r.tool_count || 0, tools: r.tools ? (typeof r.tools === 'string' ? JSON.parse(r.tools) : r.tools) : [] };
|
|
553
|
-
});
|
|
554
|
-
return c.json({ servers });
|
|
555
|
-
} catch (e: any) {
|
|
556
|
-
// Table may not exist yet
|
|
557
|
-
if (e.message?.includes('does not exist') || e.message?.includes('no such table')) {
|
|
558
|
-
return c.json({ servers: [] });
|
|
559
|
-
}
|
|
560
|
-
return c.json({ error: e.message }, 500);
|
|
561
|
-
}
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
engine.post('/mcp-servers', async (c) => {
|
|
565
|
-
try {
|
|
566
|
-
await _engineDb!.execute(`CREATE TABLE IF NOT EXISTS mcp_servers (
|
|
567
|
-
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
|
|
568
|
-
org_id TEXT NOT NULL DEFAULT 'default',
|
|
569
|
-
config JSONB NOT NULL DEFAULT '{}',
|
|
570
|
-
status TEXT DEFAULT 'unknown',
|
|
571
|
-
tool_count INTEGER DEFAULT 0,
|
|
572
|
-
tools JSONB DEFAULT '[]',
|
|
573
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
574
|
-
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
575
|
-
)`);
|
|
576
|
-
const body = await c.req.json();
|
|
577
|
-
const id = crypto.randomUUID();
|
|
578
|
-
await _engineDb!.execute(`INSERT INTO mcp_servers (id, org_id, config) VALUES ($1, $2, $3)`, [id, 'default', JSON.stringify(body)]);
|
|
579
|
-
return c.json({ ok: true, id });
|
|
580
|
-
} catch (e: any) { return c.json({ error: e.message }, 500); }
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
engine.put('/mcp-servers/:id', async (c) => {
|
|
584
|
-
try {
|
|
585
|
-
const id = c.req.param('id');
|
|
586
|
-
const body = await c.req.json();
|
|
587
|
-
// Merge with existing config
|
|
588
|
-
const rows = await _engineDb!.query(`SELECT config FROM mcp_servers WHERE id = $1`, [id]);
|
|
589
|
-
if (!rows?.length) return c.json({ error: 'Server not found' }, 404);
|
|
590
|
-
const existing = typeof rows[0].config === 'string' ? JSON.parse(rows[0].config) : (rows[0].config || {});
|
|
591
|
-
const merged = { ...existing, ...body };
|
|
592
|
-
await _engineDb!.execute(`UPDATE mcp_servers SET config = $1, updated_at = NOW() WHERE id = $2`, [JSON.stringify(merged), id]);
|
|
593
|
-
return c.json({ ok: true });
|
|
594
|
-
} catch (e: any) { return c.json({ error: e.message }, 500); }
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
engine.delete('/mcp-servers/:id', async (c) => {
|
|
598
|
-
try {
|
|
599
|
-
const id = c.req.param('id');
|
|
600
|
-
// Fetch config before deleting (for agent notification)
|
|
601
|
-
const rows = await _engineDb!.query(`SELECT config, tools FROM mcp_servers WHERE id = $1`, [id]);
|
|
602
|
-
const serverConfig = rows?.[0] ? (typeof rows[0].config === 'string' ? JSON.parse(rows[0].config) : rows[0].config) : null;
|
|
603
|
-
const serverTools = rows?.[0]?.tools ? (typeof rows[0].tools === 'string' ? JSON.parse(rows[0].tools) : rows[0].tools) : [];
|
|
604
|
-
|
|
605
|
-
await _engineDb!.execute(`DELETE FROM mcp_servers WHERE id = $1`, [id]);
|
|
606
|
-
|
|
607
|
-
// Write a memory entry for each assigned agent so they know tools were removed
|
|
608
|
-
if (serverConfig?.assignedAgents?.length && memoryManager) {
|
|
609
|
-
const toolNames = (serverTools || []).map((t: any) => t.name).join(', ');
|
|
610
|
-
for (const agentId of serverConfig.assignedAgents) {
|
|
611
|
-
try {
|
|
612
|
-
await memoryManager.createMemory({
|
|
613
|
-
agentId,
|
|
614
|
-
orgId: 'default',
|
|
615
|
-
category: 'system_notice',
|
|
616
|
-
title: `MCP Server "${serverConfig.name}" was deleted`,
|
|
617
|
-
content: `The MCP server "${serverConfig.name}" has been permanently removed by an administrator. The following tools are no longer available and should NOT be called: ${toolNames || 'unknown'}. If a task requires these tools, inform the user that they are no longer available.`,
|
|
618
|
-
source: 'mcp_server_deletion',
|
|
619
|
-
importance: 'high',
|
|
620
|
-
});
|
|
621
|
-
} catch { /* non-fatal */ }
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
return c.json({ ok: true });
|
|
626
|
-
} catch (e: any) { return c.json({ error: e.message }, 500); }
|
|
627
|
-
});
|
|
628
|
-
|
|
629
|
-
// ─── MCP Server Agent Assignment ─────────────────────
|
|
630
|
-
engine.put('/mcp-servers/:id/agents', async (c) => {
|
|
631
|
-
try {
|
|
632
|
-
const id = c.req.param('id');
|
|
633
|
-
const { agentIds } = await c.req.json<{ agentIds: string[] }>();
|
|
634
|
-
const rows = await _engineDb!.query(`SELECT config FROM mcp_servers WHERE id = $1`, [id]);
|
|
635
|
-
if (!rows?.length) return c.json({ error: 'Server not found' }, 404);
|
|
636
|
-
const existing = typeof rows[0].config === 'string' ? JSON.parse(rows[0].config) : (rows[0].config || {});
|
|
637
|
-
existing.assignedAgents = agentIds || [];
|
|
638
|
-
await _engineDb!.execute(`UPDATE mcp_servers SET config = $1, updated_at = NOW() WHERE id = $2`, [JSON.stringify(existing), id]);
|
|
639
|
-
return c.json({ ok: true });
|
|
640
|
-
} catch (e: any) { return c.json({ error: e.message }, 500); }
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
// ─── MCP Server Reload (after config change) ─────────
|
|
644
|
-
engine.post('/mcp-servers/:id/reload', async (c) => {
|
|
645
|
-
try {
|
|
646
|
-
// Signal to runtime to reload this MCP server
|
|
647
|
-
// The actual reload happens via the mcpProcessManager reference
|
|
648
|
-
return c.json({ ok: true, message: 'Server will be reloaded on next agent session' });
|
|
649
|
-
} catch (e: any) { return c.json({ error: e.message }, 500); }
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
engine.post('/mcp-servers/:id/test', async (c) => {
|
|
653
|
-
try {
|
|
654
|
-
const id = c.req.param('id');
|
|
655
|
-
const rows = await _engineDb!.query(`SELECT config FROM mcp_servers WHERE id = $1`, [id]);
|
|
656
|
-
if (!rows?.length) return c.json({ error: 'Server not found' }, 404);
|
|
657
|
-
const config = typeof rows[0].config === 'string' ? JSON.parse(rows[0].config) : (rows[0].config || {});
|
|
658
|
-
|
|
659
|
-
if (config.type === 'stdio') {
|
|
660
|
-
// Test stdio: spawn process, send initialize, read response
|
|
661
|
-
const { spawn } = await import('node:child_process');
|
|
662
|
-
const args = config.args || [];
|
|
663
|
-
const env = { ...process.env, ...(config.env || {}) };
|
|
664
|
-
const child = spawn(config.command, args, { stdio: ['pipe', 'pipe', 'pipe'], env, timeout: (config.timeout || 30) * 1000 });
|
|
665
|
-
|
|
666
|
-
const initMsg = JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'AgenticMail', version: '1.0' } } });
|
|
667
|
-
child.stdin.write(initMsg + '\n');
|
|
668
|
-
|
|
669
|
-
const result: any = await new Promise((resolve) => {
|
|
670
|
-
let buf = '';
|
|
671
|
-
const timer = setTimeout(() => { child.kill(); resolve({ error: 'Timeout after ' + (config.timeout || 30) + 's' }); }, (config.timeout || 30) * 1000);
|
|
672
|
-
child.stdout.on('data', (chunk: Buffer) => {
|
|
673
|
-
buf += chunk.toString();
|
|
674
|
-
try {
|
|
675
|
-
const parsed = JSON.parse(buf.trim());
|
|
676
|
-
clearTimeout(timer);
|
|
677
|
-
child.kill();
|
|
678
|
-
resolve(parsed);
|
|
679
|
-
} catch { /* wait for more data */ }
|
|
680
|
-
});
|
|
681
|
-
child.on('error', (err: any) => { clearTimeout(timer); resolve({ error: err.message }); });
|
|
682
|
-
child.on('exit', (code: number) => { if (!buf) { clearTimeout(timer); resolve({ error: 'Process exited with code ' + code }); } });
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
if (result.error) return c.json({ error: typeof result.error === 'string' ? result.error : result.error.message || 'Unknown error' });
|
|
686
|
-
|
|
687
|
-
// Now list tools
|
|
688
|
-
const listMsg = JSON.stringify({ jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} });
|
|
689
|
-
const child2 = spawn(config.command, args, { stdio: ['pipe', 'pipe', 'pipe'], env, timeout: 15000 });
|
|
690
|
-
child2.stdin.write(initMsg + '\n');
|
|
691
|
-
|
|
692
|
-
const tools: any[] = await new Promise((resolve) => {
|
|
693
|
-
let phase = 'init';
|
|
694
|
-
let buf2 = '';
|
|
695
|
-
const timer2 = setTimeout(() => { child2.kill(); resolve([]); }, 15000);
|
|
696
|
-
child2.stdout.on('data', (chunk: Buffer) => {
|
|
697
|
-
buf2 += chunk.toString();
|
|
698
|
-
const lines = buf2.split('\n');
|
|
699
|
-
for (const line of lines) {
|
|
700
|
-
if (!line.trim()) continue;
|
|
701
|
-
try {
|
|
702
|
-
const parsed = JSON.parse(line.trim());
|
|
703
|
-
if (phase === 'init' && parsed.id === 1) {
|
|
704
|
-
phase = 'tools';
|
|
705
|
-
buf2 = '';
|
|
706
|
-
child2.stdin.write(listMsg + '\n');
|
|
707
|
-
} else if (phase === 'tools' && parsed.id === 2) {
|
|
708
|
-
clearTimeout(timer2);
|
|
709
|
-
child2.kill();
|
|
710
|
-
resolve(parsed.result?.tools || []);
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
} catch { /* partial line */ }
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
child2.on('error', () => { clearTimeout(timer2); resolve([]); });
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
// Save discovered tools
|
|
720
|
-
await _engineDb!.execute(`UPDATE mcp_servers SET status = 'connected', tool_count = $1, tools = $2, updated_at = NOW() WHERE id = $3`,
|
|
721
|
-
[tools.length, JSON.stringify(tools.map((t: any) => ({ name: t.name, description: t.description }))), id]);
|
|
722
|
-
|
|
723
|
-
return c.json({ ok: true, tools: tools.length, serverInfo: result.result?.serverInfo });
|
|
724
|
-
|
|
725
|
-
} else {
|
|
726
|
-
// Test HTTP/SSE: send initialize via HTTP
|
|
727
|
-
const url = config.url;
|
|
728
|
-
const headers: Record<string, string> = { 'Content-Type': 'application/json', ...(config.headers || {}) };
|
|
729
|
-
if (config.apiKey) headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
730
|
-
|
|
731
|
-
const resp = await fetch(url, {
|
|
732
|
-
method: 'POST',
|
|
733
|
-
headers,
|
|
734
|
-
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'AgenticMail', version: '1.0' } } }),
|
|
735
|
-
signal: AbortSignal.timeout((config.timeout || 30) * 1000),
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
if (!resp.ok) return c.json({ error: `Server returned ${resp.status}` });
|
|
739
|
-
const data = await resp.json() as any;
|
|
740
|
-
if (data.error) return c.json({ error: data.error.message || 'Server error' });
|
|
741
|
-
|
|
742
|
-
// List tools
|
|
743
|
-
const toolResp = await fetch(url, {
|
|
744
|
-
method: 'POST', headers,
|
|
745
|
-
body: JSON.stringify({ jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} }),
|
|
746
|
-
signal: AbortSignal.timeout(15000),
|
|
747
|
-
});
|
|
748
|
-
let tools: any[] = [];
|
|
749
|
-
if (toolResp.ok) {
|
|
750
|
-
const td = await toolResp.json() as any;
|
|
751
|
-
tools = td.result?.tools || [];
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
await _engineDb!.execute(`UPDATE mcp_servers SET status = 'connected', tool_count = $1, tools = $2, updated_at = NOW() WHERE id = $3`,
|
|
755
|
-
[tools.length, JSON.stringify(tools.map((t: any) => ({ name: t.name, description: t.description }))), id]);
|
|
756
|
-
|
|
757
|
-
return c.json({ ok: true, tools: tools.length, serverInfo: data.result?.serverInfo });
|
|
758
|
-
}
|
|
759
|
-
} catch (e: any) {
|
|
760
|
-
// Update status to error
|
|
761
|
-
try { await _engineDb!.execute(`UPDATE mcp_servers SET status = 'error', updated_at = NOW() WHERE id = $1`, [c.req.param('id')]); } catch {}
|
|
762
|
-
return c.json({ error: e.message });
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
// ─── Integration Credentials Management ─────────────────
|
|
767
|
-
engine.put('/integrations/:skillId/credentials', async (c) => {
|
|
768
|
-
try {
|
|
769
|
-
const skillId = c.req.param('skillId');
|
|
770
|
-
const body = await c.req.json();
|
|
771
|
-
const orgId = c.req.query('orgId') || 'default';
|
|
772
|
-
// Store each credential field as a vault secret
|
|
773
|
-
for (const [key, value] of Object.entries(body)) {
|
|
774
|
-
if (!value) continue;
|
|
775
|
-
const secretName = `skill:${skillId}:${key}`;
|
|
776
|
-
// Check if exists, update or create
|
|
777
|
-
try {
|
|
778
|
-
const entries = await vault.getSecretsByOrg(orgId, 'skill_credential');
|
|
779
|
-
const existing = entries.find((e: any) => e.name === secretName);
|
|
780
|
-
if (existing) {
|
|
781
|
-
await vault.updateSecret(existing.id, value as string);
|
|
782
|
-
} else {
|
|
783
|
-
await vault.storeSecret(orgId, secretName, 'skill_credential', value as string);
|
|
784
|
-
}
|
|
785
|
-
} catch {
|
|
786
|
-
await vault.storeSecret(orgId, secretName, 'skill_credential', value as string);
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
return c.json({ ok: true });
|
|
790
|
-
} catch (e: any) { return c.json({ error: e.message }, 500); }
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
engine.delete('/integrations/:skillId/credentials', async (c) => {
|
|
794
|
-
try {
|
|
795
|
-
const skillId = c.req.param('skillId');
|
|
796
|
-
const orgId = c.req.query('orgId') || 'default';
|
|
797
|
-
const entries = await vault.getSecretsByOrg(orgId, 'skill_credential');
|
|
798
|
-
const matching = entries.filter((e: any) => e.name?.startsWith(`skill:${skillId}:`));
|
|
799
|
-
for (const entry of matching) {
|
|
800
|
-
await vault.deleteSecret(entry.id);
|
|
801
|
-
}
|
|
802
|
-
return c.json({ ok: true });
|
|
803
|
-
} catch (e: any) { return c.json({ error: e.message }, 500); }
|
|
804
|
-
});
|
|
805
|
-
|
|
806
|
-
// ─── Integration catalog (serves all 144 MCP adapter integrations) ──
|
|
807
|
-
engine.get('/integrations/catalog', async (c) => {
|
|
808
|
-
try {
|
|
809
|
-
const { INTEGRATION_CATALOG, INTEGRATION_CATEGORIES } = await import('../mcp/integration-catalog.js');
|
|
810
|
-
const orgId = c.req.query('orgId') || 'default';
|
|
811
|
-
// Check which integrations have credentials in the vault
|
|
812
|
-
let connectedSkillIds: Set<string>;
|
|
813
|
-
try {
|
|
814
|
-
const entries = await vault.getSecretsByOrg(orgId, 'skill_credential');
|
|
815
|
-
connectedSkillIds = new Set(
|
|
816
|
-
entries
|
|
817
|
-
.map((e: any) => e.name?.match(/^skill:([^:]+):/)?.[1])
|
|
818
|
-
.filter(Boolean)
|
|
819
|
-
);
|
|
820
|
-
} catch { connectedSkillIds = new Set(); }
|
|
821
|
-
const catalog = INTEGRATION_CATALOG.map(e => ({
|
|
822
|
-
...e,
|
|
823
|
-
connected: connectedSkillIds.has(e.skillId),
|
|
824
|
-
}));
|
|
825
|
-
return c.json({ catalog, categories: INTEGRATION_CATEGORIES });
|
|
826
|
-
} catch (e: any) {
|
|
827
|
-
return c.json({ error: e.message }, 500);
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
|
|
831
|
-
// ─── Integration-specific proxy endpoints ───────────────
|
|
832
|
-
engine.get('/integrations/elevenlabs/voices', async (c) => {
|
|
833
|
-
try {
|
|
834
|
-
const orgId = c.req.query('orgId') || 'default';
|
|
835
|
-
const entries = await vault.getSecretsByOrg(orgId);
|
|
836
|
-
const match = entries.find((e: any) => e.name === 'skill:elevenlabs:access_token');
|
|
837
|
-
if (!match) return c.json({ error: 'ElevenLabs not connected' }, 401);
|
|
838
|
-
const secret = await vault.getSecret(match.id);
|
|
839
|
-
if (!secret) return c.json({ error: 'Key not found' }, 401);
|
|
840
|
-
const resp = await fetch('https://api.elevenlabs.io/v1/voices', {
|
|
841
|
-
headers: { 'xi-api-key': secret.decrypted },
|
|
842
|
-
});
|
|
843
|
-
if (!resp.ok) return c.json({ error: 'ElevenLabs API error: ' + resp.status }, resp.status as any);
|
|
844
|
-
const data = await resp.json() as any;
|
|
845
|
-
return c.json({ voices: data.voices || [] });
|
|
846
|
-
} catch (e: any) {
|
|
847
|
-
return c.json({ error: e.message }, 500);
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
engine.route('/chat-webhook', createChatWebhookRoutes({
|
|
851
|
-
lifecycle,
|
|
852
|
-
getRuntime: () => _runtime,
|
|
853
|
-
projectNumber: '927012824308',
|
|
854
|
-
getStandaloneAgents: () => lifecycle.getStandaloneAgents(),
|
|
855
|
-
}));
|
|
856
|
-
|
|
857
|
-
// ─── Chat Poller Management API ─────────────────────────
|
|
858
|
-
engine.get('/chat-poller/status', (c) => {
|
|
859
|
-
const poller = _chatPoller;
|
|
860
|
-
if (!poller) return c.json({ running: false, reason: 'not_started' });
|
|
861
|
-
return c.json(poller.getStatus());
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
engine.get('/chat-poller/spaces', async (c) => {
|
|
865
|
-
try {
|
|
866
|
-
const db = _engineDb;
|
|
867
|
-
if (!db) return c.json({ spaces: [] });
|
|
868
|
-
const rows = await db.query(`SELECT key, value FROM engine_settings WHERE key = 'chat_spaces'`);
|
|
869
|
-
const spaces = rows?.[0] ? JSON.parse((rows[0] as any).value) : [];
|
|
870
|
-
return c.json({ spaces });
|
|
871
|
-
} catch { return c.json({ spaces: [] }); }
|
|
872
|
-
});
|
|
873
|
-
|
|
874
|
-
engine.post('/chat-poller/spaces', async (c) => {
|
|
875
|
-
try {
|
|
876
|
-
const db = _engineDb;
|
|
877
|
-
if (!db) return c.json({ error: 'Engine DB not ready' }, 500);
|
|
878
|
-
const body = await c.req.json<{ spaces: Array<{ spaceId: string; displayName: string; agentIds: string[]; defaultAgentId?: string }> }>();
|
|
879
|
-
if (!body.spaces || !Array.isArray(body.spaces)) return c.json({ error: 'spaces array required' }, 400);
|
|
880
|
-
|
|
881
|
-
await db.execute(
|
|
882
|
-
`INSERT INTO engine_settings (key, value) VALUES ('chat_spaces', $1)
|
|
883
|
-
ON CONFLICT (key) DO UPDATE SET value = $1`,
|
|
884
|
-
[JSON.stringify(body.spaces)]
|
|
885
|
-
);
|
|
886
|
-
|
|
887
|
-
// Update live poller
|
|
888
|
-
const poller = _chatPoller;
|
|
889
|
-
if (poller) {
|
|
890
|
-
for (const s of body.spaces) {
|
|
891
|
-
poller.addSpace({
|
|
892
|
-
spaceId: s.spaceId,
|
|
893
|
-
displayName: s.displayName,
|
|
894
|
-
agentIds: s.agentIds,
|
|
895
|
-
defaultAgentId: s.defaultAgentId,
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
return c.json({ ok: true, count: body.spaces.length });
|
|
901
|
-
} catch (err: any) {
|
|
902
|
-
return c.json({ error: err.message }, 500);
|
|
903
|
-
}
|
|
904
|
-
});
|
|
905
|
-
|
|
906
|
-
// ─── Email Poller Management API ────────────────────────
|
|
907
|
-
engine.get('/email-poller/status', (c) => {
|
|
908
|
-
const poller = _emailPoller;
|
|
909
|
-
if (!poller) return c.json({ running: false, reason: 'not_started' });
|
|
910
|
-
return c.json(poller.getStatus());
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
engine.post('/email-poller/rediscover', async (c) => {
|
|
914
|
-
const poller = _emailPoller;
|
|
915
|
-
if (!poller) return c.json({ error: 'Email poller not started' }, 500);
|
|
916
|
-
await poller.rediscover();
|
|
917
|
-
return c.json({ ok: true });
|
|
918
|
-
});
|
|
919
|
-
|
|
920
|
-
// ─── setEngineDb ────────────────────────────────────────
|
|
921
|
-
|
|
922
|
-
export async function setEngineDb(
|
|
923
|
-
db: import('./db-adapter.js').EngineDatabase,
|
|
924
|
-
adminDb?: DatabaseAdapter,
|
|
925
|
-
) {
|
|
926
|
-
_engineDb = db;
|
|
927
|
-
if (adminDb) _adminDb = adminDb;
|
|
928
|
-
|
|
929
|
-
// Cascade DB to all engine modules for persistent storage
|
|
930
|
-
await Promise.all([
|
|
931
|
-
lifecycle.setDb(db).then(() => lifecycle.setVault(vault)),
|
|
932
|
-
approvals.setDb(db),
|
|
933
|
-
knowledgeBase.setDb(db),
|
|
934
|
-
activity.setDb(db),
|
|
935
|
-
tenants.setDb(db),
|
|
936
|
-
permissionEngine.setDb(db),
|
|
937
|
-
dlp.setDb(db),
|
|
938
|
-
commBus.setDb(db),
|
|
939
|
-
guardrails.setDb(db),
|
|
940
|
-
journal.setDb(db),
|
|
941
|
-
compliance.setDb(db),
|
|
942
|
-
communityRegistry.setDb(db),
|
|
943
|
-
knowledgeContribution.setDb(db),
|
|
944
|
-
(async () => { knowledgeImport.setDb((db as any)?.db || db); knowledgeImport.setKnowledgeEngine(knowledgeBase); await knowledgeImport.loadJobs(); })(),
|
|
945
|
-
workforce.setDb(db),
|
|
946
|
-
policyEngine.setDb(db),
|
|
947
|
-
(async () => { cluster.setDb(db); await cluster.loadFromDb(); })(),
|
|
948
|
-
memoryManager.setDb(db),
|
|
949
|
-
onboarding.setDb(db),
|
|
950
|
-
vault.setDb(db),
|
|
951
|
-
(async () => { orgIntegrations.setDb(db); orgIntegrations.setLifecycle(lifecycle); (globalThis as any).__orgIntegrations = orgIntegrations; })(),
|
|
952
|
-
storageManager.setDb(db),
|
|
953
|
-
policyImporter.setDb(db),
|
|
954
|
-
(async () => { (taskQueue as any).db = (db as any)?.db || db; await taskQueue.init(); })(),
|
|
955
|
-
databaseManager.setDb(db),
|
|
956
|
-
]);
|
|
957
|
-
// Initialize hierarchy manager + start background task monitor
|
|
958
|
-
hierarchyManager = new AgentHierarchyManager(db);
|
|
959
|
-
hierarchyManager.startMonitor();
|
|
960
|
-
|
|
961
|
-
guardrails.startAnomalyDetection();
|
|
962
|
-
workforce.startScheduler();
|
|
963
|
-
|
|
964
|
-
// Load transport encryption config from settings
|
|
965
|
-
if (adminDb) {
|
|
966
|
-
setTransportEncSettingsDb(adminDb);
|
|
967
|
-
loadTransportEncConfig().catch(() => {});
|
|
968
|
-
}
|
|
969
|
-
knowledgeContribution.startScheduler();
|
|
970
|
-
|
|
971
|
-
// Auto-create contribution schedules for all agents if none exist
|
|
972
|
-
try {
|
|
973
|
-
const agents = lifecycle.getAllAgents();
|
|
974
|
-
const orgId = agents[0]?.orgId;
|
|
975
|
-
const allBases = orgId ? knowledgeContribution.listBases(orgId) : [];
|
|
976
|
-
// Debug removed - schedules auto-create silently
|
|
977
|
-
if (allBases.length > 0) {
|
|
978
|
-
const base = allBases[0];
|
|
979
|
-
for (const agent of agents) {
|
|
980
|
-
const existing = knowledgeContribution.getSchedule(agent.id);
|
|
981
|
-
if (!existing) {
|
|
982
|
-
try {
|
|
983
|
-
knowledgeContribution.createSchedule({
|
|
984
|
-
orgId: agent.orgId || base.orgId,
|
|
985
|
-
agentId: agent.id,
|
|
986
|
-
baseId: base.id,
|
|
987
|
-
frequency: 'daily',
|
|
988
|
-
filters: { minConfidence: 0.6 },
|
|
989
|
-
});
|
|
990
|
-
console.log(`[knowledge-contribution] Auto-created daily schedule for ${agent.config?.identity?.name as any || agent.id}`);
|
|
991
|
-
} catch { /* skip if base not found etc */ }
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
} catch (e: any) { console.log(`[knowledge-contribution] Auto-schedule setup: ${e.message}`); }
|
|
996
|
-
|
|
997
|
-
skillUpdater.startScheduler();
|
|
998
|
-
|
|
999
|
-
// Load community skills from the local community-skills/ directory (if running from git clone)
|
|
1000
|
-
import('path').then(async (path) => {
|
|
1001
|
-
const communityDir = path.resolve(import.meta.dirname || '.', '../../community-skills');
|
|
1002
|
-
const { loaded, errors } = await communityRegistry.loadFromDirectory(communityDir);
|
|
1003
|
-
if (loaded > 0) console.log(`[community] Loaded ${loaded} community skills from directory`);
|
|
1004
|
-
if (errors.length > 0) console.warn(`[community] ${errors.length} skills failed validation`);
|
|
1005
|
-
}).catch(() => { /* community-skills/ dir may not exist in npm installs */ });
|
|
1006
|
-
|
|
1007
|
-
// Start periodic sync from the central GitHub repo (agenticmail/enterprise).
|
|
1008
|
-
// This is how npm-installed deployments get new community skills automatically
|
|
1009
|
-
// without needing an npm update or server restart. Syncs every 6 hours.
|
|
1010
|
-
communityRegistry.startPeriodicSync();
|
|
1011
|
-
|
|
1012
|
-
// Ensure a default org exists for single-tenant / self-hosted deployments
|
|
1013
|
-
await tenants.createDefaultOrg().catch(() => {});
|
|
1014
|
-
|
|
1015
|
-
// ─── Start Google Chat Poller ─────────────────────────
|
|
1016
|
-
// Guard: only start once (setEngineDb can be called multiple times)
|
|
1017
|
-
if (!_chatPoller) {
|
|
1018
|
-
startChatPoller(db).catch(err => console.error(`[chat-poller] Failed to start:`, err));
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
// ─── Start Gmail Email Poller ─────────────────────────
|
|
1022
|
-
if (!_emailPoller) {
|
|
1023
|
-
startEmailPoller(db).catch(err => console.error(`[email-poller] Failed to start:`, err));
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
// ─── Start Messaging Poller (WhatsApp, Telegram) ──
|
|
1027
|
-
if (!_messagingPoller) {
|
|
1028
|
-
startMessagingPoller(db).catch(err => console.error(`[messaging-poller] Failed to start:`, err));
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
// ─── Chat Poller ────────────────────────────────────────
|
|
1033
|
-
|
|
1034
|
-
let _chatPoller: ChatPoller | null = null;
|
|
1035
|
-
|
|
1036
|
-
async function startChatPoller(engineDb: any): Promise<void> {
|
|
1037
|
-
console.log('[chat-poller] Initializing...');
|
|
1038
|
-
// Find agents with chat enabled + OAuth tokens for Chat API access
|
|
1039
|
-
const allAgents = lifecycle.getAllAgents();
|
|
1040
|
-
console.log(`[chat-poller] Found ${allAgents.length} agents total`);
|
|
1041
|
-
for (const a of allAgents) {
|
|
1042
|
-
const services = a.config?.enabledGoogleServices || [];
|
|
1043
|
-
const hasChat = services.includes('chat');
|
|
1044
|
-
const hasOAuth = !!a.config?.emailConfig?.oauthRefreshToken;
|
|
1045
|
-
const agentName = (a.config as any)?.displayName || (a.config as any)?.name || a.id;
|
|
1046
|
-
console.log(`[chat-poller] ${agentName}: services=[${services.join(',')}] chat=${hasChat} oauth=${hasOAuth} state=${a.state}`);
|
|
1047
|
-
}
|
|
1048
|
-
const chatAgents = allAgents.filter(a => {
|
|
1049
|
-
const services = a.config?.enabledGoogleServices || [];
|
|
1050
|
-
return services.includes('chat') && a.config?.emailConfig?.oauthRefreshToken;
|
|
1051
|
-
});
|
|
1052
|
-
console.log(`[chat-poller] Chat-enabled agents: ${chatAgents.length} (${chatAgents.map(a => a.name).join(', ')})`);
|
|
1053
|
-
|
|
1054
|
-
if (chatAgents.length === 0) {
|
|
1055
|
-
console.log('[chat-poller] No chat-enabled agents with OAuth tokens, skipping');
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
// Use the first chat-enabled agent's OAuth token for polling
|
|
1060
|
-
// (all agents in the same org share the same Google Workspace)
|
|
1061
|
-
const tokenAgent = chatAgents[0];
|
|
1062
|
-
const emailConfig = tokenAgent.config!.emailConfig!;
|
|
1063
|
-
|
|
1064
|
-
const refreshToken = async (): Promise<string> => {
|
|
1065
|
-
const res = await fetch('https://oauth2.googleapis.com/token', {
|
|
1066
|
-
method: 'POST',
|
|
1067
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1068
|
-
body: new URLSearchParams({
|
|
1069
|
-
client_id: emailConfig.oauthClientId,
|
|
1070
|
-
client_secret: emailConfig.oauthClientSecret,
|
|
1071
|
-
refresh_token: emailConfig.oauthRefreshToken,
|
|
1072
|
-
grant_type: 'refresh_token',
|
|
1073
|
-
}),
|
|
1074
|
-
});
|
|
1075
|
-
const data = await res.json() as any;
|
|
1076
|
-
if (data.access_token) return data.access_token;
|
|
1077
|
-
throw new Error(`Token refresh failed: ${data.error || 'unknown'}`);
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
// Build agent endpoints from known standalone agents + lifecycle agents
|
|
1081
|
-
const standaloneAgentPorts: Record<string, number> = {};
|
|
1082
|
-
// Check chat-webhook config for known ports
|
|
1083
|
-
try {
|
|
1084
|
-
const rows = await _engineDb!.query(`SELECT key, value FROM engine_settings WHERE key = 'standalone_agents'`);
|
|
1085
|
-
if (rows?.[0]) {
|
|
1086
|
-
const sa = JSON.parse((rows[0] as any).value);
|
|
1087
|
-
for (const a of sa) standaloneAgentPorts[a.id] = a.port;
|
|
1088
|
-
}
|
|
1089
|
-
} catch {}
|
|
1090
|
-
|
|
1091
|
-
const agentEndpoints = chatAgents.map(a => {
|
|
1092
|
-
const identity = a.config?.identity || {};
|
|
1093
|
-
const name = a.config?.name || a.name || 'agent';
|
|
1094
|
-
const displayName = a.config?.displayName || name;
|
|
1095
|
-
const email = a.config?.emailConfig?.email || a.config?.email?.address || '';
|
|
1096
|
-
// Port priority: DB standalone_agents setting → agent deployment config → fallback
|
|
1097
|
-
const dep = a.config?.deployment;
|
|
1098
|
-
const port = standaloneAgentPorts[a.id] || dep?.port || dep?.config?.local?.port || 3100;
|
|
1099
|
-
const host = dep?.host || dep?.config?.local?.host || 'localhost';
|
|
1100
|
-
|
|
1101
|
-
return {
|
|
1102
|
-
id: a.id,
|
|
1103
|
-
name: name.toLowerCase(),
|
|
1104
|
-
displayName,
|
|
1105
|
-
email,
|
|
1106
|
-
port,
|
|
1107
|
-
host,
|
|
1108
|
-
roles: (identity as any).roles || [identity.role].filter(Boolean),
|
|
1109
|
-
keywords: (identity as any).keywords || [],
|
|
1110
|
-
enabled: a.state === 'running',
|
|
1111
|
-
};
|
|
1112
|
-
});
|
|
1113
|
-
|
|
1114
|
-
_chatPoller = new ChatPoller({
|
|
1115
|
-
lifecycle,
|
|
1116
|
-
getToken: refreshToken,
|
|
1117
|
-
engineDb,
|
|
1118
|
-
agents: agentEndpoints,
|
|
1119
|
-
intervalMs: 30_000,
|
|
1120
|
-
workforce,
|
|
1121
|
-
});
|
|
1122
|
-
|
|
1123
|
-
await _chatPoller.start();
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
export function getChatPoller(): ChatPoller | null {
|
|
1127
|
-
return _chatPoller;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
// ─── Email Poller ───────────────────────────────────────
|
|
1131
|
-
|
|
1132
|
-
let _emailPoller: EmailPoller | null = null;
|
|
1133
|
-
|
|
1134
|
-
async function startEmailPoller(engineDb: any): Promise<void> {
|
|
1135
|
-
_emailPoller = new EmailPoller({
|
|
1136
|
-
engineDb,
|
|
1137
|
-
lifecycle,
|
|
1138
|
-
intervalMs: 30_000,
|
|
1139
|
-
workforce,
|
|
1140
|
-
});
|
|
1141
|
-
|
|
1142
|
-
await _emailPoller.start();
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
export function getEmailPoller(): EmailPoller | null {
|
|
1146
|
-
return _emailPoller;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
// ─── Messaging Poller (WhatsApp, Telegram) ─────────
|
|
1150
|
-
|
|
1151
|
-
let _messagingPoller: MessagingPoller | null = null;
|
|
1152
|
-
|
|
1153
|
-
async function startMessagingPoller(engineDb: any): Promise<void> {
|
|
1154
|
-
const allAgents = lifecycle.getAllAgents();
|
|
1155
|
-
const agents = allAgents.filter(a => a.state === 'running' || a.state === 'draft' || a.state === 'stopped' || (a as any).status === 'active').map(a => {
|
|
1156
|
-
const dep = a.config?.deployment;
|
|
1157
|
-
const port = dep?.port || dep?.config?.local?.port || 3100;
|
|
1158
|
-
const host = dep?.host || dep?.config?.local?.host || 'localhost';
|
|
1159
|
-
// Debug removed — dynamic resolution in messaging-poller.resolveEndpoint()
|
|
1160
|
-
return {
|
|
1161
|
-
id: a.id, name: a.name || '', displayName: (a.config as any)?.displayName || a.name || a.id,
|
|
1162
|
-
status: 'active' as const, port, host,
|
|
1163
|
-
};
|
|
1164
|
-
});
|
|
1165
|
-
|
|
1166
|
-
// Check platform capabilities via admin DB (has direct pool access)
|
|
1167
|
-
let capabilities: any = {};
|
|
1168
|
-
try {
|
|
1169
|
-
if (_adminDb && (_adminDb as any).pool) {
|
|
1170
|
-
const r = await (_adminDb as any).pool.query(`SELECT platform_capabilities FROM company_settings LIMIT 1`);
|
|
1171
|
-
capabilities = r.rows?.[0]?.platform_capabilities || {};
|
|
1172
|
-
} else {
|
|
1173
|
-
// Fallback: try getSettings if available
|
|
1174
|
-
const settings = await (_adminDb as any)?.getSettings?.();
|
|
1175
|
-
capabilities = settings?.platformCapabilities || {};
|
|
1176
|
-
}
|
|
1177
|
-
} catch (err: any) {
|
|
1178
|
-
console.log(`[messaging] Failed to read platform capabilities: ${err.message}`);
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
const hasAny = capabilities.whatsapp || capabilities.telegram;
|
|
1182
|
-
if (!hasAny) {
|
|
1183
|
-
console.log('[messaging-poller] No messaging channels enabled in Platform Capabilities');
|
|
1184
|
-
return;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
// Detect public URL for webhook support (fly.io, VPS, tunnel, etc.)
|
|
1188
|
-
const publicUrl = process.env.PUBLIC_URL || process.env.RAILWAY_PUBLIC_DOMAIN
|
|
1189
|
-
? `https://${process.env.RAILWAY_PUBLIC_DOMAIN}` : process.env.FLY_APP_NAME
|
|
1190
|
-
? `https://${process.env.FLY_APP_NAME}.fly.dev` : process.env.RENDER_EXTERNAL_URL
|
|
1191
|
-
|| undefined;
|
|
1192
|
-
|
|
1193
|
-
_messagingPoller = new MessagingPoller({
|
|
1194
|
-
agents: agents as any,
|
|
1195
|
-
dataDir: process.env.DATA_DIR || '/tmp/agenticmail-data',
|
|
1196
|
-
publicUrl,
|
|
1197
|
-
app: (_engineApp || undefined) as any,
|
|
1198
|
-
engineDb,
|
|
1199
|
-
lifecycle: { getAgent: (id: string) => lifecycle.getAgent(id) },
|
|
1200
|
-
getCapability: (key: string) => !!capabilities[key],
|
|
1201
|
-
getAgentChannelConfig: (agentId: string) => {
|
|
1202
|
-
try {
|
|
1203
|
-
const a = lifecycle.getAgent(agentId);
|
|
1204
|
-
return (a?.config as any)?.messagingChannels || null;
|
|
1205
|
-
} catch { return null; }
|
|
1206
|
-
},
|
|
1207
|
-
getVaultKey: (name: string) => {
|
|
1208
|
-
try {
|
|
1209
|
-
const vault = ((lifecycle as any).getVault?.() || (lifecycle as any).vault);
|
|
1210
|
-
return vault?.get?.(name) || null;
|
|
1211
|
-
} catch { return null; }
|
|
1212
|
-
},
|
|
1213
|
-
});
|
|
1214
|
-
await _messagingPoller.start();
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
export function getMessagingPoller(): MessagingPoller | null {
|
|
1218
|
-
return _messagingPoller;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
// ─── Agent Runtime (optional — mounted when runtime is started) ──
|
|
1222
|
-
|
|
1223
|
-
let _runtimeApp: import('hono').Hono | null = null;
|
|
1224
|
-
let _runtime: any = null;
|
|
1225
|
-
|
|
1226
|
-
export function mountRuntimeApp(app: import('hono').Hono): void {
|
|
1227
|
-
_runtimeApp = app;
|
|
1228
|
-
engine.route('/runtime', app);
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
export function setRuntime(runtime: any): void {
|
|
1232
|
-
_runtime = runtime;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
export { engine as engineRoutes };
|
|
1236
|
-
export { permissionEngine, configGen, deployer, approvals, lifecycle, knowledgeBase, tenants, activity, dlp, commBus, guardrails, journal, compliance, communityRegistry, workforce, policyEngine, memoryManager, onboarding, vault, storageManager, policyImporter, knowledgeContribution, skillUpdater, agentStatus, hierarchyManager, databaseManager, orgIntegrations, cluster };
|