@agenticmail/enterprise 0.5.326 → 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/dist/dashboard/pages/cluster.js +1 -1
- package/logs/cloudflared-error.log +6 -0
- package/logs/enterprise-out.log +2 -0
- package/package.json +1 -1
- package/god_is_great.html +0 -35
- 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
|
@@ -1,1064 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Hierarchy & Management System
|
|
3
|
-
*
|
|
4
|
-
* Enterprise-grade organizational management for AI agent teams.
|
|
5
|
-
* Models real human organizations with all edge cases:
|
|
6
|
-
*
|
|
7
|
-
* HIERARCHY:
|
|
8
|
-
* - Org chart resolution (who reports to whom, depth levels)
|
|
9
|
-
* - Escalation chains (subordinate → manager → manager's manager)
|
|
10
|
-
* - External manager support (human managers via email/messaging)
|
|
11
|
-
*
|
|
12
|
-
* COMMUNICATION:
|
|
13
|
-
* - Channel priority: Google Chat DM > Gmail > AgenticMail internal
|
|
14
|
-
* - Automatic channel resolution per agent pair
|
|
15
|
-
* - External manager notification via configured channel
|
|
16
|
-
*
|
|
17
|
-
* DELEGATION:
|
|
18
|
-
* - Pre-delegation checks: agent online? clocked in? has capacity? has right tools?
|
|
19
|
-
* - SLA tracking with urgency-based deadlines
|
|
20
|
-
* - Auto-check-in cadence (manager monitors subordinate progress)
|
|
21
|
-
* - Crash/timeout detection with auto-escalation
|
|
22
|
-
* - Workload balancing (prevent overloading agents)
|
|
23
|
-
* - Auto-reassignment when agent is offline/overloaded
|
|
24
|
-
*
|
|
25
|
-
* PROMPT INJECTION:
|
|
26
|
-
* - Dynamic — only injected when relevant to the current session context
|
|
27
|
-
* - Agents with no manager and no reports get ZERO management prompt
|
|
28
|
-
* - Managers only get team status when session involves management actions
|
|
29
|
-
* - Subordinates only get task list when they have pending tasks
|
|
30
|
-
*
|
|
31
|
-
* MONITORING:
|
|
32
|
-
* - Periodic task health checks (is assignee still alive?)
|
|
33
|
-
* - Overdue task alerts to manager
|
|
34
|
-
* - Stale task cleanup
|
|
35
|
-
* - Agent crash → auto-notify manager + attempt reassignment
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
import type { EngineDatabase } from './db-adapter.js';
|
|
39
|
-
|
|
40
|
-
// ─── Types ──────────────────────────────────────────────
|
|
41
|
-
|
|
42
|
-
export type CommChannel = 'google_chat' | 'gmail' | 'agenticmail' | 'whatsapp' | 'telegram';
|
|
43
|
-
|
|
44
|
-
export interface AgentCommConfig {
|
|
45
|
-
email?: string;
|
|
46
|
-
enabledGoogleServices?: string[];
|
|
47
|
-
hasGoogleChat: boolean;
|
|
48
|
-
hasGmail: boolean;
|
|
49
|
-
whatsappEnabled: boolean;
|
|
50
|
-
telegramEnabled: boolean;
|
|
51
|
-
agenticmailEnabled: boolean;
|
|
52
|
-
/** All enabled skills/tools for capability checking */
|
|
53
|
-
enabledSkills?: string[];
|
|
54
|
-
/** Tool access map from agent config */
|
|
55
|
-
toolAccess?: Record<string, boolean>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface AgentHierarchyNode {
|
|
59
|
-
agentId: string;
|
|
60
|
-
name: string;
|
|
61
|
-
role: string;
|
|
62
|
-
state: string; // running, stopped, error, etc.
|
|
63
|
-
managerId: string | null;
|
|
64
|
-
managerType: 'internal' | 'external' | 'none';
|
|
65
|
-
managerName?: string;
|
|
66
|
-
managerEmail?: string;
|
|
67
|
-
subordinateIds: string[];
|
|
68
|
-
subordinateCount: number;
|
|
69
|
-
isManager: boolean;
|
|
70
|
-
level: number;
|
|
71
|
-
comm: AgentCommConfig;
|
|
72
|
-
// Live state (populated from usage/config)
|
|
73
|
-
clockedIn: boolean;
|
|
74
|
-
activeTasks: number; // currently assigned tasks (pending + in_progress)
|
|
75
|
-
errorsToday: number;
|
|
76
|
-
lastActivityAt?: string;
|
|
77
|
-
workHours?: { enabled: boolean; start: string; end: string; days?: number[]; timezone?: string };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface DelegatedTask {
|
|
81
|
-
id: string;
|
|
82
|
-
fromAgentId: string;
|
|
83
|
-
toAgentId: string;
|
|
84
|
-
title: string;
|
|
85
|
-
description: string;
|
|
86
|
-
priority: 'low' | 'medium' | 'high' | 'urgent';
|
|
87
|
-
status: 'pending' | 'accepted' | 'in_progress' | 'blocked' | 'completed' | 'rejected' | 'reassigned' | 'expired';
|
|
88
|
-
dueDate?: string;
|
|
89
|
-
slaHours?: number; // Expected completion time in hours
|
|
90
|
-
createdAt: string;
|
|
91
|
-
updatedAt: string;
|
|
92
|
-
completedAt?: string;
|
|
93
|
-
result?: string;
|
|
94
|
-
blockerReason?: string;
|
|
95
|
-
feedback?: string;
|
|
96
|
-
/** Required tools/skills for this task */
|
|
97
|
-
requiredTools?: string[];
|
|
98
|
-
/** Check-in cadence in minutes (manager checks on progress) */
|
|
99
|
-
checkInIntervalMin?: number;
|
|
100
|
-
lastCheckInAt?: string;
|
|
101
|
-
/** Number of times manager has checked in */
|
|
102
|
-
checkInCount: number;
|
|
103
|
-
/** If reassigned, original assignee */
|
|
104
|
-
originalAgentId?: string;
|
|
105
|
-
/** Reason for reassignment */
|
|
106
|
-
reassignReason?: string;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface EscalationRecord {
|
|
110
|
-
id: string;
|
|
111
|
-
fromAgentId: string;
|
|
112
|
-
toAgentId: string;
|
|
113
|
-
subject: string;
|
|
114
|
-
context: string;
|
|
115
|
-
status: 'pending' | 'resolved' | 'forwarded';
|
|
116
|
-
createdAt: string;
|
|
117
|
-
resolvedAt?: string;
|
|
118
|
-
resolution?: string;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface TeamStatus {
|
|
122
|
-
managerId: string;
|
|
123
|
-
managerName: string;
|
|
124
|
-
directReports: {
|
|
125
|
-
agentId: string;
|
|
126
|
-
name: string;
|
|
127
|
-
role: string;
|
|
128
|
-
state: string;
|
|
129
|
-
clockedIn: boolean;
|
|
130
|
-
available: boolean; // running + clocked in + not overloaded
|
|
131
|
-
pendingTasks: number;
|
|
132
|
-
inProgressTasks: number;
|
|
133
|
-
completedTasksToday: number;
|
|
134
|
-
blockedTasks: number;
|
|
135
|
-
overdueTasks: number;
|
|
136
|
-
lastActivity?: string;
|
|
137
|
-
tokenUsageToday: number;
|
|
138
|
-
errorsToday: number;
|
|
139
|
-
capacityPercent: number; // 0-100, 100 = fully loaded
|
|
140
|
-
}[];
|
|
141
|
-
teamSize: number;
|
|
142
|
-
activeCount: number;
|
|
143
|
-
availableCount: number; // agents that can take new work
|
|
144
|
-
totalPendingTasks: number;
|
|
145
|
-
totalOverdueTasks: number;
|
|
146
|
-
totalCompletedToday: number;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** Pre-delegation check result */
|
|
150
|
-
export interface DelegationCheck {
|
|
151
|
-
canDelegate: boolean;
|
|
152
|
-
warnings: string[];
|
|
153
|
-
blockers: string[];
|
|
154
|
-
/** Suggested alternative agent if primary can't take it */
|
|
155
|
-
alternativeAgentId?: string;
|
|
156
|
-
alternativeReason?: string;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/** Max concurrent tasks before agent is considered overloaded */
|
|
160
|
-
const MAX_CONCURRENT_TASKS = 5;
|
|
161
|
-
/** Default SLA hours by priority */
|
|
162
|
-
const DEFAULT_SLA_HOURS: Record<string, number> = { urgent: 1, high: 4, medium: 24, low: 72 };
|
|
163
|
-
/** Default check-in interval by priority (minutes) */
|
|
164
|
-
const DEFAULT_CHECKIN_INTERVAL: Record<string, number> = { urgent: 15, high: 30, medium: 120, low: 480 };
|
|
165
|
-
|
|
166
|
-
// ─── Hierarchy Manager ──────────────────────────────────
|
|
167
|
-
|
|
168
|
-
export class AgentHierarchyManager {
|
|
169
|
-
private db: EngineDatabase;
|
|
170
|
-
private hierarchyCache: Map<string, AgentHierarchyNode> = new Map();
|
|
171
|
-
private cacheExpiry = 0;
|
|
172
|
-
private CACHE_TTL = 30_000; // 30s
|
|
173
|
-
/** Background monitor interval */
|
|
174
|
-
private monitorInterval: ReturnType<typeof setInterval> | null = null;
|
|
175
|
-
|
|
176
|
-
constructor(db: EngineDatabase) {
|
|
177
|
-
this.db = db;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// ─── Lifecycle ────────────────────────────────────────
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Start the background task monitor.
|
|
184
|
-
* Checks for overdue tasks, stale assignments, crashed agents.
|
|
185
|
-
* Runs every 5 minutes.
|
|
186
|
-
*/
|
|
187
|
-
startMonitor(): void {
|
|
188
|
-
if (this.monitorInterval) return;
|
|
189
|
-
this.monitorInterval = setInterval(() => this.runMonitorCycle().catch(e =>
|
|
190
|
-
console.error(`[hierarchy] Monitor error: ${e.message}`)
|
|
191
|
-
), 5 * 60_000);
|
|
192
|
-
console.log('[hierarchy] Task monitor started (5min interval)');
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
stopMonitor(): void {
|
|
196
|
-
if (this.monitorInterval) {
|
|
197
|
-
clearInterval(this.monitorInterval);
|
|
198
|
-
this.monitorInterval = null;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Background monitor cycle:
|
|
204
|
-
* 1. Find overdue tasks → mark as expired, notify manager
|
|
205
|
-
* 2. Find tasks assigned to crashed/stopped agents → auto-reassign or alert
|
|
206
|
-
* 3. Find stale pending tasks (not accepted in 30min) → alert manager
|
|
207
|
-
*/
|
|
208
|
-
private async runMonitorCycle(): Promise<void> {
|
|
209
|
-
const now = new Date().toISOString();
|
|
210
|
-
const hierarchy = await this.buildHierarchy();
|
|
211
|
-
|
|
212
|
-
// 1. Overdue tasks (past SLA)
|
|
213
|
-
try {
|
|
214
|
-
const overdue = await this.db.query<any>(
|
|
215
|
-
`SELECT * FROM agent_delegated_tasks
|
|
216
|
-
WHERE status IN ('pending', 'accepted', 'in_progress')
|
|
217
|
-
AND due_date IS NOT NULL AND due_date < $1`,
|
|
218
|
-
[now]
|
|
219
|
-
);
|
|
220
|
-
for (const task of (overdue || [])) {
|
|
221
|
-
// Mark as expired
|
|
222
|
-
await this.db.query(
|
|
223
|
-
`UPDATE agent_delegated_tasks SET status = 'expired', updated_at = $1 WHERE id = $2 AND status NOT IN ('completed', 'expired', 'reassigned')`,
|
|
224
|
-
[now, task.id]
|
|
225
|
-
);
|
|
226
|
-
console.log(`[hierarchy] Task expired: "${task.title}" (${task.id}) — was assigned to ${task.to_agent_id}`);
|
|
227
|
-
// Manager will see this in their next team_tasks() call or system prompt
|
|
228
|
-
}
|
|
229
|
-
} catch {}
|
|
230
|
-
|
|
231
|
-
// 2. Tasks assigned to offline/stopped agents
|
|
232
|
-
try {
|
|
233
|
-
const activeTasks = await this.db.query<any>(
|
|
234
|
-
`SELECT * FROM agent_delegated_tasks WHERE status IN ('pending', 'accepted', 'in_progress')`
|
|
235
|
-
);
|
|
236
|
-
for (const task of (activeTasks || [])) {
|
|
237
|
-
const assignee = hierarchy.get(task.to_agent_id);
|
|
238
|
-
if (!assignee) continue;
|
|
239
|
-
|
|
240
|
-
// Agent is stopped/error — task can't be worked on
|
|
241
|
-
if (assignee.state === 'stopped' || assignee.state === 'error') {
|
|
242
|
-
// Find an alternative from same manager's team
|
|
243
|
-
const manager = hierarchy.get(task.from_agent_id);
|
|
244
|
-
if (manager) {
|
|
245
|
-
const available = manager.subordinateIds
|
|
246
|
-
.map(id => hierarchy.get(id))
|
|
247
|
-
.filter((n): n is AgentHierarchyNode =>
|
|
248
|
-
!!n && n.agentId !== task.to_agent_id && n.state === 'running' && n.clockedIn && n.activeTasks < MAX_CONCURRENT_TASKS
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
if (available.length > 0) {
|
|
252
|
-
// Auto-reassign to least loaded available agent
|
|
253
|
-
const best = available.sort((a, b) => a.activeTasks - b.activeTasks)[0];
|
|
254
|
-
await this.reassignTask(task.id, best.agentId, `Original assignee ${assignee.name} is ${assignee.state}`);
|
|
255
|
-
console.log(`[hierarchy] Auto-reassigned task "${task.title}" from ${assignee.name} (${assignee.state}) → ${best.name}`);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Stale pending (not accepted in 30 min)
|
|
261
|
-
const createdAt = new Date(task.created_at).getTime();
|
|
262
|
-
const staleMins = (Date.now() - createdAt) / 60_000;
|
|
263
|
-
if (task.status === 'pending' && staleMins > 30) {
|
|
264
|
-
console.log(`[hierarchy] Stale task: "${task.title}" pending for ${Math.round(staleMins)}min — assignee: ${assignee.name}`);
|
|
265
|
-
// Will show as warning in manager's team status
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
} catch {}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// ─── Hierarchy Resolution ─────────────────────────────
|
|
272
|
-
|
|
273
|
-
async buildHierarchy(): Promise<Map<string, AgentHierarchyNode>> {
|
|
274
|
-
if (Date.now() < this.cacheExpiry && this.hierarchyCache.size > 0) {
|
|
275
|
-
return this.hierarchyCache;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const rows = await this.db.query<any>(
|
|
279
|
-
`SELECT id, config, state, usage FROM managed_agents WHERE state != 'destroying'`
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
// Pre-fetch active task counts per agent
|
|
283
|
-
const taskCounts = new Map<string, { pending: number; inProgress: number }>();
|
|
284
|
-
try {
|
|
285
|
-
const tc = await this.db.query<any>(
|
|
286
|
-
`SELECT to_agent_id, status, COUNT(*) as cnt FROM agent_delegated_tasks
|
|
287
|
-
WHERE status IN ('pending', 'accepted', 'in_progress') GROUP BY to_agent_id, status`
|
|
288
|
-
);
|
|
289
|
-
for (const r of (tc || [])) {
|
|
290
|
-
const existing = taskCounts.get(r.to_agent_id) || { pending: 0, inProgress: 0 };
|
|
291
|
-
if (r.status === 'in_progress') existing.inProgress = parseInt(r.cnt) || 0;
|
|
292
|
-
else existing.pending += parseInt(r.cnt) || 0;
|
|
293
|
-
taskCounts.set(r.to_agent_id, existing);
|
|
294
|
-
}
|
|
295
|
-
} catch {}
|
|
296
|
-
|
|
297
|
-
const nodes = new Map<string, AgentHierarchyNode>();
|
|
298
|
-
|
|
299
|
-
for (const row of (rows || [])) {
|
|
300
|
-
const config = typeof row.config === 'string' ? JSON.parse(row.config) : (row.config || {});
|
|
301
|
-
const usage = typeof row.usage === 'string' ? JSON.parse(row.usage) : (row.usage || {});
|
|
302
|
-
const manager = config.manager || {};
|
|
303
|
-
const identity = config.identity || {};
|
|
304
|
-
const gws = config.enabledGoogleServices || [];
|
|
305
|
-
const messaging = config.messagingChannels || {};
|
|
306
|
-
const emailConfig = config.emailConfig || {};
|
|
307
|
-
|
|
308
|
-
const comm: AgentCommConfig = {
|
|
309
|
-
email: emailConfig.email,
|
|
310
|
-
enabledGoogleServices: gws,
|
|
311
|
-
hasGoogleChat: gws.includes('chat'),
|
|
312
|
-
hasGmail: gws.includes('gmail'),
|
|
313
|
-
whatsappEnabled: !!messaging.whatsapp?.enabled,
|
|
314
|
-
telegramEnabled: !!messaging.telegram?.enabled || !!messaging.telegram?.botToken,
|
|
315
|
-
agenticmailEnabled: true,
|
|
316
|
-
enabledSkills: config.skills || [],
|
|
317
|
-
toolAccess: config.toolAccess || {},
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
const tc = taskCounts.get(row.id) || { pending: 0, inProgress: 0 };
|
|
321
|
-
|
|
322
|
-
const node: AgentHierarchyNode = {
|
|
323
|
-
agentId: row.id,
|
|
324
|
-
name: identity.name || config.displayName || config.name || row.id,
|
|
325
|
-
role: identity.role || config.role || 'Agent',
|
|
326
|
-
state: row.state || 'unknown',
|
|
327
|
-
managerId: null,
|
|
328
|
-
managerType: 'none',
|
|
329
|
-
subordinateIds: [],
|
|
330
|
-
subordinateCount: 0,
|
|
331
|
-
isManager: false,
|
|
332
|
-
level: 0,
|
|
333
|
-
comm,
|
|
334
|
-
clockedIn: config.workforce?.clockedIn === true,
|
|
335
|
-
activeTasks: tc.pending + tc.inProgress,
|
|
336
|
-
errorsToday: usage.errorsToday || 0,
|
|
337
|
-
lastActivityAt: usage.lastActivityAt,
|
|
338
|
-
workHours: config.workHours,
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
// Resolve manager
|
|
342
|
-
if (manager.type === 'internal' && manager.agentId) {
|
|
343
|
-
node.managerId = manager.agentId;
|
|
344
|
-
node.managerType = 'internal';
|
|
345
|
-
} else if (manager.type === 'external') {
|
|
346
|
-
node.managerType = 'external';
|
|
347
|
-
node.managerName = manager.name;
|
|
348
|
-
node.managerEmail = manager.email;
|
|
349
|
-
} else if (config.managerId) {
|
|
350
|
-
node.managerId = config.managerId;
|
|
351
|
-
node.managerType = 'internal';
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
nodes.set(row.id, node);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// Populate subordinates
|
|
358
|
-
for (const [id, node] of nodes) {
|
|
359
|
-
if (node.managerId && nodes.has(node.managerId)) {
|
|
360
|
-
const mgr = nodes.get(node.managerId)!;
|
|
361
|
-
mgr.subordinateIds.push(id);
|
|
362
|
-
mgr.subordinateCount++;
|
|
363
|
-
mgr.isManager = true;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// Calculate levels (BFS from roots)
|
|
368
|
-
const visited = new Set<string>();
|
|
369
|
-
const queue: { id: string; level: number }[] = [];
|
|
370
|
-
for (const [id, node] of nodes) {
|
|
371
|
-
if (!node.managerId || !nodes.has(node.managerId)) {
|
|
372
|
-
node.level = 0;
|
|
373
|
-
visited.add(id);
|
|
374
|
-
queue.push({ id, level: 0 });
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
while (queue.length > 0) {
|
|
378
|
-
const { id, level } = queue.shift()!;
|
|
379
|
-
const node = nodes.get(id)!;
|
|
380
|
-
for (const subId of node.subordinateIds) {
|
|
381
|
-
if (!visited.has(subId)) {
|
|
382
|
-
nodes.get(subId)!.level = level + 1;
|
|
383
|
-
visited.add(subId);
|
|
384
|
-
queue.push({ id: subId, level: level + 1 });
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
this.hierarchyCache = nodes;
|
|
390
|
-
this.cacheExpiry = Date.now() + this.CACHE_TTL;
|
|
391
|
-
return nodes;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// ─── Communication Channel Resolution ─────────────────
|
|
395
|
-
|
|
396
|
-
async resolveCommChannel(fromAgentId: string, toAgentId: string): Promise<{
|
|
397
|
-
channel: CommChannel;
|
|
398
|
-
instructions: string;
|
|
399
|
-
fromEmail?: string;
|
|
400
|
-
toEmail?: string;
|
|
401
|
-
}> {
|
|
402
|
-
const hierarchy = await this.buildHierarchy();
|
|
403
|
-
const from = hierarchy.get(fromAgentId);
|
|
404
|
-
const to = hierarchy.get(toAgentId);
|
|
405
|
-
|
|
406
|
-
if (!from || !to) {
|
|
407
|
-
return { channel: 'agenticmail', instructions: `Use agenticmail_message_agent to send a message.` };
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Priority 1: Google Chat DM
|
|
411
|
-
if (from.comm.hasGoogleChat && to.comm.hasGoogleChat && to.comm.email) {
|
|
412
|
-
return {
|
|
413
|
-
channel: 'google_chat',
|
|
414
|
-
instructions: `Send via Google Chat DM. First call google_chat_find_dm(email: "${to.comm.email}") to get the DM space, then google_chat_send_message(spaceId, text).`,
|
|
415
|
-
fromEmail: from.comm.email,
|
|
416
|
-
toEmail: to.comm.email,
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// Priority 2: Gmail
|
|
421
|
-
if (from.comm.hasGmail && to.comm.email) {
|
|
422
|
-
return {
|
|
423
|
-
channel: 'gmail',
|
|
424
|
-
instructions: `Send via email to ${to.comm.email} using gmail_send(to: "${to.comm.email}", subject, body).`,
|
|
425
|
-
fromEmail: from.comm.email,
|
|
426
|
-
toEmail: to.comm.email,
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// Priority 3: AgenticMail internal
|
|
431
|
-
return {
|
|
432
|
-
channel: 'agenticmail',
|
|
433
|
-
instructions: `Use agenticmail_message_agent(agent: "${to.name}", subject, text) to send a message internally.`,
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// ─── Hierarchy Queries ────────────────────────────────
|
|
438
|
-
|
|
439
|
-
async getDirectReports(managerId: string): Promise<AgentHierarchyNode[]> {
|
|
440
|
-
const hierarchy = await this.buildHierarchy();
|
|
441
|
-
const manager = hierarchy.get(managerId);
|
|
442
|
-
if (!manager) return [];
|
|
443
|
-
return manager.subordinateIds
|
|
444
|
-
.map(id => hierarchy.get(id))
|
|
445
|
-
.filter((n): n is AgentHierarchyNode => !!n);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
async getAllSubordinates(managerId: string): Promise<AgentHierarchyNode[]> {
|
|
449
|
-
const hierarchy = await this.buildHierarchy();
|
|
450
|
-
const result: AgentHierarchyNode[] = [];
|
|
451
|
-
const queue = [managerId];
|
|
452
|
-
const visited = new Set<string>();
|
|
453
|
-
while (queue.length > 0) {
|
|
454
|
-
const current = queue.shift()!;
|
|
455
|
-
if (visited.has(current)) continue;
|
|
456
|
-
visited.add(current);
|
|
457
|
-
const node = hierarchy.get(current);
|
|
458
|
-
if (!node) continue;
|
|
459
|
-
for (const subId of node.subordinateIds) {
|
|
460
|
-
const sub = hierarchy.get(subId);
|
|
461
|
-
if (sub) { result.push(sub); queue.push(subId); }
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return result;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
async getEscalationChain(agentId: string): Promise<AgentHierarchyNode[]> {
|
|
468
|
-
const hierarchy = await this.buildHierarchy();
|
|
469
|
-
const chain: AgentHierarchyNode[] = [];
|
|
470
|
-
const visited = new Set<string>();
|
|
471
|
-
let current = hierarchy.get(agentId);
|
|
472
|
-
while (current?.managerId && !visited.has(current.managerId)) {
|
|
473
|
-
visited.add(current.managerId);
|
|
474
|
-
const manager = hierarchy.get(current.managerId);
|
|
475
|
-
if (manager) { chain.push(manager); current = manager; } else break;
|
|
476
|
-
}
|
|
477
|
-
return chain;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
async isManagerOf(managerId: string, subordinateId: string): Promise<boolean> {
|
|
481
|
-
const chain = await this.getEscalationChain(subordinateId);
|
|
482
|
-
return chain.some(n => n.agentId === managerId);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// ─── Pre-Delegation Checks ────────────────────────────
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Run comprehensive checks BEFORE delegating a task.
|
|
489
|
-
* Returns blockers (hard stops) and warnings (proceed with caution).
|
|
490
|
-
*/
|
|
491
|
-
async checkDelegation(fromAgentId: string, toAgentId: string, task: {
|
|
492
|
-
requiredTools?: string[];
|
|
493
|
-
priority?: string;
|
|
494
|
-
}): Promise<DelegationCheck> {
|
|
495
|
-
const hierarchy = await this.buildHierarchy();
|
|
496
|
-
const from = hierarchy.get(fromAgentId);
|
|
497
|
-
const to = hierarchy.get(toAgentId);
|
|
498
|
-
const warnings: string[] = [];
|
|
499
|
-
const blockers: string[] = [];
|
|
500
|
-
|
|
501
|
-
if (!from) { blockers.push('Delegating agent not found.'); return { canDelegate: false, warnings, blockers }; }
|
|
502
|
-
if (!to) { blockers.push(`Target agent not found.`); return { canDelegate: false, warnings, blockers }; }
|
|
503
|
-
|
|
504
|
-
// Check hierarchy relationship
|
|
505
|
-
const isManager = await this.isManagerOf(fromAgentId, toAgentId);
|
|
506
|
-
if (!isManager) {
|
|
507
|
-
blockers.push(`${from.name} is not a manager of ${to.name}. Cannot delegate.`);
|
|
508
|
-
return { canDelegate: false, warnings, blockers };
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
// Check agent state
|
|
512
|
-
if (to.state === 'stopped' || to.state === 'error' || to.state === 'destroying') {
|
|
513
|
-
blockers.push(`${to.name} is ${to.state}. Cannot accept tasks.`);
|
|
514
|
-
// Find alternative
|
|
515
|
-
const alt = await this.findAvailableAlternative(fromAgentId, toAgentId);
|
|
516
|
-
return {
|
|
517
|
-
canDelegate: false, warnings, blockers,
|
|
518
|
-
alternativeAgentId: alt?.agentId,
|
|
519
|
-
alternativeReason: alt ? `${alt.name} is available (${alt.activeTasks} active tasks)` : undefined,
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// Check if clocked in / within work hours
|
|
524
|
-
if (to.workHours?.enabled && !to.clockedIn) {
|
|
525
|
-
warnings.push(`${to.name} is outside work hours. Task will queue until they clock in.`);
|
|
526
|
-
}
|
|
527
|
-
if (!to.clockedIn && to.state === 'running') {
|
|
528
|
-
warnings.push(`${to.name} is not clocked in. They may not process this immediately.`);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
// Check workload
|
|
532
|
-
if (to.activeTasks >= MAX_CONCURRENT_TASKS) {
|
|
533
|
-
warnings.push(`${to.name} has ${to.activeTasks} active tasks (max recommended: ${MAX_CONCURRENT_TASKS}). Consider another agent.`);
|
|
534
|
-
const alt = await this.findAvailableAlternative(fromAgentId, toAgentId);
|
|
535
|
-
if (alt) {
|
|
536
|
-
return {
|
|
537
|
-
canDelegate: true, warnings, blockers,
|
|
538
|
-
alternativeAgentId: alt.agentId,
|
|
539
|
-
alternativeReason: `${alt.name} has fewer tasks (${alt.activeTasks}) and is available`,
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// Check error rate
|
|
545
|
-
if (to.errorsToday > 10) {
|
|
546
|
-
warnings.push(`${to.name} has ${to.errorsToday} errors today. Agent may be degraded.`);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// Check required tools/capabilities
|
|
550
|
-
if (task.requiredTools?.length) {
|
|
551
|
-
const missingTools: string[] = [];
|
|
552
|
-
for (const tool of task.requiredTools) {
|
|
553
|
-
// Check skill enabled
|
|
554
|
-
const hasSkill = to.comm.enabledSkills?.some(s => s.includes(tool) || tool.includes(s));
|
|
555
|
-
// Check tool access not explicitly disabled
|
|
556
|
-
const toolDisabled = to.comm.toolAccess?.[tool] === false;
|
|
557
|
-
if (!hasSkill && !toolDisabled) {
|
|
558
|
-
// Could be a built-in tool, don't block — just warn
|
|
559
|
-
} else if (toolDisabled) {
|
|
560
|
-
missingTools.push(tool);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
if (missingTools.length > 0) {
|
|
564
|
-
blockers.push(`${to.name} has these tools DISABLED: ${missingTools.join(', ')}. Enable them in the dashboard before delegating.`);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
return { canDelegate: blockers.length === 0, warnings, blockers };
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Find the best available agent from the same team to handle a task.
|
|
573
|
-
*/
|
|
574
|
-
private async findAvailableAlternative(managerId: string, excludeId: string): Promise<AgentHierarchyNode | null> {
|
|
575
|
-
const hierarchy = await this.buildHierarchy();
|
|
576
|
-
const manager = hierarchy.get(managerId);
|
|
577
|
-
if (!manager) return null;
|
|
578
|
-
|
|
579
|
-
const candidates = manager.subordinateIds
|
|
580
|
-
.map(id => hierarchy.get(id))
|
|
581
|
-
.filter((n): n is AgentHierarchyNode =>
|
|
582
|
-
!!n && n.agentId !== excludeId && n.state === 'running' && n.activeTasks < MAX_CONCURRENT_TASKS
|
|
583
|
-
)
|
|
584
|
-
.sort((a, b) => a.activeTasks - b.activeTasks); // Least loaded first
|
|
585
|
-
|
|
586
|
-
return candidates[0] || null;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
// ─── Task Delegation ──────────────────────────────────
|
|
590
|
-
|
|
591
|
-
async delegateTask(fromAgentId: string, toAgentId: string, task: {
|
|
592
|
-
title: string;
|
|
593
|
-
description: string;
|
|
594
|
-
priority?: 'low' | 'medium' | 'high' | 'urgent';
|
|
595
|
-
dueDate?: string;
|
|
596
|
-
requiredTools?: string[];
|
|
597
|
-
slaHours?: number;
|
|
598
|
-
}): Promise<DelegatedTask> {
|
|
599
|
-
const priority = task.priority || 'medium';
|
|
600
|
-
const slaHours = task.slaHours || DEFAULT_SLA_HOURS[priority];
|
|
601
|
-
const checkInInterval = DEFAULT_CHECKIN_INTERVAL[priority];
|
|
602
|
-
|
|
603
|
-
// Auto-calculate due date from SLA if not provided
|
|
604
|
-
const dueDate = task.dueDate || new Date(Date.now() + slaHours * 3600_000).toISOString();
|
|
605
|
-
|
|
606
|
-
const id = `task_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
607
|
-
const now = new Date().toISOString();
|
|
608
|
-
|
|
609
|
-
const delegatedTask: DelegatedTask = {
|
|
610
|
-
id, fromAgentId, toAgentId,
|
|
611
|
-
title: task.title,
|
|
612
|
-
description: task.description,
|
|
613
|
-
priority,
|
|
614
|
-
status: 'pending',
|
|
615
|
-
dueDate,
|
|
616
|
-
slaHours,
|
|
617
|
-
createdAt: now, updatedAt: now,
|
|
618
|
-
requiredTools: task.requiredTools,
|
|
619
|
-
checkInIntervalMin: checkInInterval,
|
|
620
|
-
checkInCount: 0,
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
await this.db.query(
|
|
624
|
-
`INSERT INTO agent_delegated_tasks (id, from_agent_id, to_agent_id, title, description, priority, status, due_date, sla_hours, check_in_interval_min, check_in_count, required_tools, created_at, updated_at)
|
|
625
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)`,
|
|
626
|
-
[id, fromAgentId, toAgentId, task.title, task.description, priority, 'pending', dueDate, slaHours, checkInInterval, 0, JSON.stringify(task.requiredTools || []), now, now]
|
|
627
|
-
);
|
|
628
|
-
|
|
629
|
-
// Invalidate cache so next hierarchy build picks up new task count
|
|
630
|
-
this.cacheExpiry = 0;
|
|
631
|
-
|
|
632
|
-
const hierarchy = await this.buildHierarchy();
|
|
633
|
-
const fromNode = hierarchy.get(fromAgentId);
|
|
634
|
-
const toNode = hierarchy.get(toAgentId);
|
|
635
|
-
console.log(`[hierarchy] Task delegated: "${task.title}" [${priority}] from ${fromNode?.name} → ${toNode?.name} (SLA: ${slaHours}h, due: ${dueDate})`);
|
|
636
|
-
|
|
637
|
-
return delegatedTask;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
async updateTaskStatus(taskId: string, agentId: string, update: {
|
|
641
|
-
status?: DelegatedTask['status'];
|
|
642
|
-
result?: string;
|
|
643
|
-
blockerReason?: string;
|
|
644
|
-
}): Promise<void> {
|
|
645
|
-
const now = new Date().toISOString();
|
|
646
|
-
const sets: string[] = ['updated_at = $1'];
|
|
647
|
-
const params: any[] = [now];
|
|
648
|
-
let idx = 2;
|
|
649
|
-
|
|
650
|
-
if (update.status) {
|
|
651
|
-
sets.push(`status = $${idx++}`);
|
|
652
|
-
params.push(update.status);
|
|
653
|
-
if (update.status === 'completed') {
|
|
654
|
-
sets.push(`completed_at = $${idx++}`);
|
|
655
|
-
params.push(now);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
if (update.result !== undefined) { sets.push(`result = $${idx++}`); params.push(update.result); }
|
|
659
|
-
if (update.blockerReason !== undefined) { sets.push(`blocker_reason = $${idx++}`); params.push(update.blockerReason); }
|
|
660
|
-
|
|
661
|
-
params.push(taskId);
|
|
662
|
-
params.push(agentId);
|
|
663
|
-
await this.db.query(
|
|
664
|
-
`UPDATE agent_delegated_tasks SET ${sets.join(', ')} WHERE id = $${idx++} AND to_agent_id = $${idx}`,
|
|
665
|
-
params
|
|
666
|
-
);
|
|
667
|
-
this.cacheExpiry = 0; // Invalidate
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
async provideFeedback(taskId: string, managerId: string, feedback: string): Promise<void> {
|
|
671
|
-
await this.db.query(
|
|
672
|
-
`UPDATE agent_delegated_tasks SET feedback = $1, updated_at = $2 WHERE id = $3 AND from_agent_id = $4`,
|
|
673
|
-
[feedback, new Date().toISOString(), taskId, managerId]
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
async reassignTask(taskId: string, newAgentId: string, reason: string): Promise<void> {
|
|
678
|
-
const now = new Date().toISOString();
|
|
679
|
-
// Get original task
|
|
680
|
-
const rows = await this.db.query<any>(`SELECT * FROM agent_delegated_tasks WHERE id = $1`, [taskId]);
|
|
681
|
-
if (!rows?.[0]) throw new Error('Task not found');
|
|
682
|
-
const task = rows[0];
|
|
683
|
-
|
|
684
|
-
// Mark original as reassigned
|
|
685
|
-
await this.db.query(
|
|
686
|
-
`UPDATE agent_delegated_tasks SET status = 'reassigned', updated_at = $1 WHERE id = $2`,
|
|
687
|
-
[now, taskId]
|
|
688
|
-
);
|
|
689
|
-
|
|
690
|
-
// Create new task for new agent
|
|
691
|
-
const newId = `task_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
692
|
-
await this.db.query(
|
|
693
|
-
`INSERT INTO agent_delegated_tasks (id, from_agent_id, to_agent_id, title, description, priority, status, due_date, sla_hours, check_in_interval_min, check_in_count, required_tools, original_agent_id, reassign_reason, created_at, updated_at)
|
|
694
|
-
VALUES ($1, $2, $3, $4, $5, $6, 'pending', $7, $8, $9, 0, $10, $11, $12, $13, $14)`,
|
|
695
|
-
[newId, task.from_agent_id, newAgentId, task.title, task.description, task.priority, task.due_date, task.sla_hours, task.check_in_interval_min, task.required_tools, task.to_agent_id, reason, now, now]
|
|
696
|
-
);
|
|
697
|
-
|
|
698
|
-
this.cacheExpiry = 0;
|
|
699
|
-
console.log(`[hierarchy] Task reassigned: "${task.title}" → ${newAgentId} (reason: ${reason})`);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
async getTasksForAgent(agentId: string, status?: string): Promise<DelegatedTask[]> {
|
|
703
|
-
const where = status ? ` AND status = $2` : '';
|
|
704
|
-
const params: any[] = [agentId];
|
|
705
|
-
if (status) params.push(status);
|
|
706
|
-
const rows = await this.db.query<any>(
|
|
707
|
-
`SELECT * FROM agent_delegated_tasks WHERE to_agent_id = $1${where} ORDER BY
|
|
708
|
-
CASE priority WHEN 'urgent' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 ELSE 3 END,
|
|
709
|
-
created_at DESC LIMIT 50`,
|
|
710
|
-
params
|
|
711
|
-
);
|
|
712
|
-
return (rows || []).map(this.rowToTask);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
async getTasksByManager(managerId: string, status?: string): Promise<DelegatedTask[]> {
|
|
716
|
-
const where = status ? ` AND status = $2` : '';
|
|
717
|
-
const params: any[] = [managerId];
|
|
718
|
-
if (status) params.push(status);
|
|
719
|
-
const rows = await this.db.query<any>(
|
|
720
|
-
`SELECT * FROM agent_delegated_tasks WHERE from_agent_id = $1${where} ORDER BY created_at DESC LIMIT 50`,
|
|
721
|
-
params
|
|
722
|
-
);
|
|
723
|
-
return (rows || []).map(this.rowToTask);
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
private rowToTask(row: any): DelegatedTask {
|
|
727
|
-
return {
|
|
728
|
-
id: row.id, fromAgentId: row.from_agent_id, toAgentId: row.to_agent_id,
|
|
729
|
-
title: row.title, description: row.description, priority: row.priority,
|
|
730
|
-
status: row.status, dueDate: row.due_date, slaHours: row.sla_hours,
|
|
731
|
-
createdAt: row.created_at, updatedAt: row.updated_at, completedAt: row.completed_at,
|
|
732
|
-
result: row.result, blockerReason: row.blocker_reason, feedback: row.feedback,
|
|
733
|
-
requiredTools: row.required_tools ? (typeof row.required_tools === 'string' ? JSON.parse(row.required_tools) : row.required_tools) : [],
|
|
734
|
-
checkInIntervalMin: row.check_in_interval_min, lastCheckInAt: row.last_check_in_at,
|
|
735
|
-
checkInCount: row.check_in_count || 0,
|
|
736
|
-
originalAgentId: row.original_agent_id, reassignReason: row.reassign_reason,
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
// ─── Escalation ───────────────────────────────────────
|
|
741
|
-
|
|
742
|
-
async escalate(fromAgentId: string, subject: string, context: string): Promise<{
|
|
743
|
-
escalatedTo: AgentHierarchyNode | null;
|
|
744
|
-
externalManager?: { name: string; email: string };
|
|
745
|
-
escalationId: string;
|
|
746
|
-
}> {
|
|
747
|
-
const hierarchy = await this.buildHierarchy();
|
|
748
|
-
const fromNode = hierarchy.get(fromAgentId);
|
|
749
|
-
if (!fromNode) throw new Error('Agent not found');
|
|
750
|
-
|
|
751
|
-
const id = `esc_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
752
|
-
const now = new Date().toISOString();
|
|
753
|
-
let escalatedTo: AgentHierarchyNode | null = null;
|
|
754
|
-
let externalManager: { name: string; email: string } | undefined;
|
|
755
|
-
|
|
756
|
-
if (fromNode.managerId && hierarchy.has(fromNode.managerId)) {
|
|
757
|
-
escalatedTo = hierarchy.get(fromNode.managerId)!;
|
|
758
|
-
} else if (fromNode.managerType === 'external' && fromNode.managerEmail) {
|
|
759
|
-
externalManager = { name: fromNode.managerName || 'Manager', email: fromNode.managerEmail };
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
await this.db.query(
|
|
763
|
-
`INSERT INTO agent_escalations (id, from_agent_id, to_agent_id, subject, context, status, created_at)
|
|
764
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7)`,
|
|
765
|
-
[id, fromAgentId, escalatedTo?.agentId || null, subject, context, 'pending', now]
|
|
766
|
-
);
|
|
767
|
-
|
|
768
|
-
console.log(`[hierarchy] Escalation: ${fromNode.name} → ${escalatedTo?.name || externalManager?.name || 'none'}: "${subject}"`);
|
|
769
|
-
return { escalatedTo, externalManager, escalationId: id };
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
async resolveEscalation(escalationId: string, resolution: string): Promise<void> {
|
|
773
|
-
await this.db.query(
|
|
774
|
-
`UPDATE agent_escalations SET status = 'resolved', resolution = $1, resolved_at = $2 WHERE id = $3`,
|
|
775
|
-
[resolution, new Date().toISOString(), escalationId]
|
|
776
|
-
);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
async forwardEscalation(escalationId: string, fromAgentId: string): Promise<{
|
|
780
|
-
escalatedTo: AgentHierarchyNode | null;
|
|
781
|
-
externalManager?: { name: string; email: string };
|
|
782
|
-
newEscalationId: string;
|
|
783
|
-
}> {
|
|
784
|
-
await this.db.query(
|
|
785
|
-
`UPDATE agent_escalations SET status = 'forwarded', updated_at = $1 WHERE id = $2`,
|
|
786
|
-
[new Date().toISOString(), escalationId]
|
|
787
|
-
);
|
|
788
|
-
const rows = await this.db.query<any>(`SELECT subject, context FROM agent_escalations WHERE id = $1`, [escalationId]);
|
|
789
|
-
const original = rows?.[0];
|
|
790
|
-
if (!original) throw new Error('Escalation not found');
|
|
791
|
-
const result = await this.escalate(fromAgentId, original.subject, `[Forwarded] ${original.context}`);
|
|
792
|
-
return { ...result, newEscalationId: result.escalationId };
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
async getPendingEscalations(managerId: string): Promise<EscalationRecord[]> {
|
|
796
|
-
const rows = await this.db.query<any>(
|
|
797
|
-
`SELECT * FROM agent_escalations WHERE to_agent_id = $1 AND status = 'pending' ORDER BY created_at ASC`,
|
|
798
|
-
[managerId]
|
|
799
|
-
);
|
|
800
|
-
return (rows || []).map((r: any) => ({
|
|
801
|
-
id: r.id, fromAgentId: r.from_agent_id, toAgentId: r.to_agent_id,
|
|
802
|
-
subject: r.subject, context: r.context, status: r.status,
|
|
803
|
-
createdAt: r.created_at, resolvedAt: r.resolved_at, resolution: r.resolution,
|
|
804
|
-
}));
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
// ─── Team Status ──────────────────────────────────────
|
|
808
|
-
|
|
809
|
-
async getTeamStatus(managerId: string): Promise<TeamStatus> {
|
|
810
|
-
const hierarchy = await this.buildHierarchy();
|
|
811
|
-
const manager = hierarchy.get(managerId);
|
|
812
|
-
if (!manager) throw new Error('Manager not found');
|
|
813
|
-
|
|
814
|
-
const directReports: TeamStatus['directReports'] = [];
|
|
815
|
-
const today = new Date().toISOString().split('T')[0];
|
|
816
|
-
|
|
817
|
-
for (const subId of manager.subordinateIds) {
|
|
818
|
-
const sub = hierarchy.get(subId);
|
|
819
|
-
if (!sub) continue;
|
|
820
|
-
|
|
821
|
-
// Task counts by status
|
|
822
|
-
let pendingTasks = 0, inProgressTasks = 0, completedTasksToday = 0, blockedTasks = 0, overdueTasks = 0;
|
|
823
|
-
try {
|
|
824
|
-
const counts = await this.db.query<any>(
|
|
825
|
-
`SELECT status, COUNT(*) as cnt FROM agent_delegated_tasks WHERE to_agent_id = $1 AND status IN ('pending', 'accepted', 'in_progress', 'blocked') GROUP BY status`,
|
|
826
|
-
[subId]
|
|
827
|
-
);
|
|
828
|
-
for (const r of (counts || [])) {
|
|
829
|
-
const c = parseInt(r.cnt) || 0;
|
|
830
|
-
if (r.status === 'pending' || r.status === 'accepted') pendingTasks += c;
|
|
831
|
-
else if (r.status === 'in_progress') inProgressTasks = c;
|
|
832
|
-
else if (r.status === 'blocked') blockedTasks = c;
|
|
833
|
-
}
|
|
834
|
-
const done = await this.db.query<any>(
|
|
835
|
-
`SELECT COUNT(*) as cnt FROM agent_delegated_tasks WHERE to_agent_id = $1 AND status = 'completed' AND completed_at >= $2`,
|
|
836
|
-
[subId, today + 'T00:00:00Z']
|
|
837
|
-
);
|
|
838
|
-
completedTasksToday = parseInt(done?.[0]?.cnt) || 0;
|
|
839
|
-
const od = await this.db.query<any>(
|
|
840
|
-
`SELECT COUNT(*) as cnt FROM agent_delegated_tasks WHERE to_agent_id = $1 AND status IN ('pending', 'accepted', 'in_progress') AND due_date IS NOT NULL AND due_date < $2`,
|
|
841
|
-
[subId, new Date().toISOString()]
|
|
842
|
-
);
|
|
843
|
-
overdueTasks = parseInt(od?.[0]?.cnt) || 0;
|
|
844
|
-
} catch {}
|
|
845
|
-
|
|
846
|
-
const totalActive = pendingTasks + inProgressTasks;
|
|
847
|
-
const capacity = Math.min(100, Math.round((totalActive / MAX_CONCURRENT_TASKS) * 100));
|
|
848
|
-
const available = sub.state === 'running' && sub.clockedIn && totalActive < MAX_CONCURRENT_TASKS;
|
|
849
|
-
|
|
850
|
-
directReports.push({
|
|
851
|
-
agentId: subId,
|
|
852
|
-
name: sub.name,
|
|
853
|
-
role: sub.role,
|
|
854
|
-
state: sub.state,
|
|
855
|
-
clockedIn: sub.clockedIn,
|
|
856
|
-
available,
|
|
857
|
-
pendingTasks,
|
|
858
|
-
inProgressTasks,
|
|
859
|
-
completedTasksToday,
|
|
860
|
-
blockedTasks,
|
|
861
|
-
overdueTasks,
|
|
862
|
-
lastActivity: sub.lastActivityAt,
|
|
863
|
-
tokenUsageToday: 0, // from usage obj
|
|
864
|
-
errorsToday: sub.errorsToday,
|
|
865
|
-
capacityPercent: capacity,
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
return {
|
|
870
|
-
managerId, managerName: manager.name,
|
|
871
|
-
directReports,
|
|
872
|
-
teamSize: directReports.length,
|
|
873
|
-
activeCount: directReports.filter(r => r.state === 'running').length,
|
|
874
|
-
availableCount: directReports.filter(r => r.available).length,
|
|
875
|
-
totalPendingTasks: directReports.reduce((s, r) => s + r.pendingTasks + r.inProgressTasks, 0),
|
|
876
|
-
totalOverdueTasks: directReports.reduce((s, r) => s + r.overdueTasks, 0),
|
|
877
|
-
totalCompletedToday: directReports.reduce((s, r) => s + r.completedTasksToday, 0),
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
// ─── Dynamic System Prompt Builder ────────────────────
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* Build management context for an agent's system prompt.
|
|
885
|
-
* DYNAMIC — only returns content when it's actually needed:
|
|
886
|
-
*
|
|
887
|
-
* - Agent with NO manager and NO reports → returns null (zero overhead)
|
|
888
|
-
* - Manager → gets team roster + any urgent items (overdue, blocked, escalations)
|
|
889
|
-
* - Subordinate → gets pending tasks + manager contact info
|
|
890
|
-
* - Only includes urgent items (not full history)
|
|
891
|
-
*
|
|
892
|
-
* @param sessionContext Optional hint about what this session is for.
|
|
893
|
-
* If 'email' or 'meeting', management context is minimal.
|
|
894
|
-
* If 'task' or 'management', full context is included.
|
|
895
|
-
*/
|
|
896
|
-
async buildManagerPrompt(agentId: string, _sessionContext?: string): Promise<string | null> {
|
|
897
|
-
const hierarchy = await this.buildHierarchy();
|
|
898
|
-
const node = hierarchy.get(agentId);
|
|
899
|
-
if (!node) return null;
|
|
900
|
-
|
|
901
|
-
// Agent with no manager and no reports → nothing to inject
|
|
902
|
-
if (!node.isManager && node.managerType === 'none') return null;
|
|
903
|
-
|
|
904
|
-
const parts: string[] = [];
|
|
905
|
-
|
|
906
|
-
// ─── Manager Context (only if agent has direct reports) ─────
|
|
907
|
-
if (node.isManager) {
|
|
908
|
-
const pendingEscalations = await this.getPendingEscalations(agentId);
|
|
909
|
-
const blockedTasks = await this.getTasksByManager(agentId, 'blocked');
|
|
910
|
-
const overdueTasks = (await this.getTasksByManager(agentId))
|
|
911
|
-
.filter(t => t.dueDate && new Date(t.dueDate) < new Date() && !['completed', 'expired', 'reassigned'].includes(t.status));
|
|
912
|
-
|
|
913
|
-
// Only inject URGENT items, not full team roster (that's what team_status tool is for)
|
|
914
|
-
const urgentItems: string[] = [];
|
|
915
|
-
|
|
916
|
-
if (pendingEscalations.length > 0) {
|
|
917
|
-
urgentItems.push(`${pendingEscalations.length} ESCALATION(S) need your attention`);
|
|
918
|
-
for (const esc of pendingEscalations.slice(0, 3)) {
|
|
919
|
-
const fromNode = hierarchy.get(esc.fromAgentId);
|
|
920
|
-
urgentItems.push(` - From ${fromNode?.name || '?'}: "${esc.subject}"`);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
if (blockedTasks.length > 0) {
|
|
925
|
-
urgentItems.push(`${blockedTasks.length} task(s) BLOCKED by your reports`);
|
|
926
|
-
for (const t of blockedTasks.slice(0, 3)) {
|
|
927
|
-
const sub = hierarchy.get(t.toAgentId);
|
|
928
|
-
urgentItems.push(` - ${sub?.name || '?'}: "${t.title}" — ${t.blockerReason || 'no reason given'}`);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
if (overdueTasks.length > 0) {
|
|
933
|
-
urgentItems.push(`${overdueTasks.length} task(s) OVERDUE`);
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
// Offline agents with active tasks
|
|
937
|
-
const offlineWithTasks = node.subordinateIds
|
|
938
|
-
.map(id => hierarchy.get(id))
|
|
939
|
-
.filter((n): n is AgentHierarchyNode => !!n && (n.state === 'stopped' || n.state === 'error') && n.activeTasks > 0);
|
|
940
|
-
|
|
941
|
-
if (offlineWithTasks.length > 0) {
|
|
942
|
-
urgentItems.push(`${offlineWithTasks.length} agent(s) OFFLINE with active tasks`);
|
|
943
|
-
for (const a of offlineWithTasks) {
|
|
944
|
-
urgentItems.push(` - ${a.name} [${a.state}] has ${a.activeTasks} task(s)`);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
if (urgentItems.length > 0) {
|
|
949
|
-
parts.push(`\n== MANAGER ALERTS (${node.subordinateCount} direct reports) ==`);
|
|
950
|
-
parts.push(urgentItems.join('\n'));
|
|
951
|
-
parts.push(`Use team_status() for full team overview. Use team_tasks() to review task details.`);
|
|
952
|
-
} else {
|
|
953
|
-
// No urgent items — just a light reminder they're a manager
|
|
954
|
-
parts.push(`\n== TEAM: You manage ${node.subordinateCount} agent(s). Use team_status() to check on them. ==`);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
// ─── Subordinate Context (only if has pending tasks) ────
|
|
959
|
-
if (node.managerType !== 'none') {
|
|
960
|
-
const myTasks = await this.getTasksForAgent(agentId);
|
|
961
|
-
const pending = myTasks.filter(t => ['pending', 'accepted', 'in_progress'].includes(t.status));
|
|
962
|
-
const overdue = pending.filter(t => t.dueDate && new Date(t.dueDate) < new Date());
|
|
963
|
-
|
|
964
|
-
if (pending.length > 0) {
|
|
965
|
-
parts.push(`\n== YOUR TASKS (${pending.length} active) ==`);
|
|
966
|
-
for (const task of pending.slice(0, 5)) {
|
|
967
|
-
const dueStr = task.dueDate ? ` [due: ${new Date(task.dueDate).toLocaleString()}]` : '';
|
|
968
|
-
const overdueTag = task.dueDate && new Date(task.dueDate) < new Date() ? ' OVERDUE' : '';
|
|
969
|
-
parts.push(`- [${task.priority.toUpperCase()}${overdueTag}] "${task.title}" — ${task.status}${dueStr}`);
|
|
970
|
-
}
|
|
971
|
-
if (overdue.length > 0) {
|
|
972
|
-
parts.push(`WARNING: ${overdue.length} task(s) are OVERDUE. Update them or inform your manager.`);
|
|
973
|
-
}
|
|
974
|
-
parts.push(`Update tasks: task_update(taskId, status, result). Escalate: escalate(subject, context).`);
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
// Manager contact (only if they have one)
|
|
978
|
-
if (node.managerId && hierarchy.has(node.managerId)) {
|
|
979
|
-
const mgr = hierarchy.get(node.managerId)!;
|
|
980
|
-
const comm = await this.resolveCommChannel(agentId, node.managerId);
|
|
981
|
-
parts.push(`\nManager: ${mgr.name} (${mgr.role}) — reach via ${comm.channel}: ${comm.instructions}`);
|
|
982
|
-
} else if (node.managerType === 'external' && node.managerEmail) {
|
|
983
|
-
parts.push(`\nManager: ${node.managerName} (external) — ${node.managerEmail}`);
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
return parts.length > 0 ? parts.join('\n') : null;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
// ─── Org Chart ────────────────────────────────────────
|
|
991
|
-
|
|
992
|
-
async buildOrgChart(): Promise<string> {
|
|
993
|
-
const hierarchy = await this.buildHierarchy();
|
|
994
|
-
const roots: AgentHierarchyNode[] = [];
|
|
995
|
-
for (const node of hierarchy.values()) {
|
|
996
|
-
if (!node.managerId || !hierarchy.has(node.managerId)) roots.push(node);
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
const lines: string[] = ['Organization Chart:'];
|
|
1000
|
-
const renderTree = (node: AgentHierarchyNode, indent: string, isLast: boolean) => {
|
|
1001
|
-
const connector = indent === '' ? '' : isLast ? '└── ' : '├── ';
|
|
1002
|
-
const stateTag = node.state === 'running' ? (node.clockedIn ? '' : ' [not clocked in]') : ` [${node.state}]`;
|
|
1003
|
-
const taskTag = node.activeTasks > 0 ? ` (${node.activeTasks} tasks)` : '';
|
|
1004
|
-
const mgrTag = node.isManager ? ` — manages ${node.subordinateCount}` : '';
|
|
1005
|
-
const extTag = node.managerType === 'external' ? ` → reports to: ${node.managerName} (external)` : '';
|
|
1006
|
-
lines.push(`${indent}${connector}${node.name} — ${node.role}${stateTag}${taskTag}${mgrTag}${extTag}`);
|
|
1007
|
-
|
|
1008
|
-
const children = node.subordinateIds.map(id => hierarchy.get(id)).filter((n): n is AgentHierarchyNode => !!n);
|
|
1009
|
-
children.forEach((child, i) => {
|
|
1010
|
-
const childIndent = indent + (indent === '' ? '' : isLast ? ' ' : '│ ');
|
|
1011
|
-
renderTree(child, childIndent, i === children.length - 1);
|
|
1012
|
-
});
|
|
1013
|
-
};
|
|
1014
|
-
|
|
1015
|
-
roots.forEach((root, i) => renderTree(root, '', i === roots.length - 1));
|
|
1016
|
-
return lines.join('\n');
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
// ─── Migration SQL ────────────────────────────────────
|
|
1020
|
-
|
|
1021
|
-
static getMigrationSQL(): string[] {
|
|
1022
|
-
return [
|
|
1023
|
-
`CREATE TABLE IF NOT EXISTS agent_delegated_tasks (
|
|
1024
|
-
id TEXT PRIMARY KEY,
|
|
1025
|
-
from_agent_id TEXT NOT NULL,
|
|
1026
|
-
to_agent_id TEXT NOT NULL,
|
|
1027
|
-
title TEXT NOT NULL,
|
|
1028
|
-
description TEXT,
|
|
1029
|
-
priority TEXT DEFAULT 'medium',
|
|
1030
|
-
status TEXT DEFAULT 'pending',
|
|
1031
|
-
due_date TEXT,
|
|
1032
|
-
sla_hours REAL,
|
|
1033
|
-
check_in_interval_min INTEGER,
|
|
1034
|
-
check_in_count INTEGER DEFAULT 0,
|
|
1035
|
-
last_check_in_at TEXT,
|
|
1036
|
-
required_tools TEXT,
|
|
1037
|
-
original_agent_id TEXT,
|
|
1038
|
-
reassign_reason TEXT,
|
|
1039
|
-
result TEXT,
|
|
1040
|
-
blocker_reason TEXT,
|
|
1041
|
-
feedback TEXT,
|
|
1042
|
-
created_at TEXT NOT NULL,
|
|
1043
|
-
updated_at TEXT NOT NULL,
|
|
1044
|
-
completed_at TEXT
|
|
1045
|
-
)`,
|
|
1046
|
-
`CREATE INDEX IF NOT EXISTS idx_dt_to ON agent_delegated_tasks(to_agent_id, status)`,
|
|
1047
|
-
`CREATE INDEX IF NOT EXISTS idx_dt_from ON agent_delegated_tasks(from_agent_id, status)`,
|
|
1048
|
-
`CREATE INDEX IF NOT EXISTS idx_dt_due ON agent_delegated_tasks(due_date) WHERE status IN ('pending','accepted','in_progress')`,
|
|
1049
|
-
`CREATE TABLE IF NOT EXISTS agent_escalations (
|
|
1050
|
-
id TEXT PRIMARY KEY,
|
|
1051
|
-
from_agent_id TEXT NOT NULL,
|
|
1052
|
-
to_agent_id TEXT,
|
|
1053
|
-
subject TEXT NOT NULL,
|
|
1054
|
-
context TEXT,
|
|
1055
|
-
status TEXT DEFAULT 'pending',
|
|
1056
|
-
resolution TEXT,
|
|
1057
|
-
created_at TEXT NOT NULL,
|
|
1058
|
-
resolved_at TEXT,
|
|
1059
|
-
updated_at TEXT
|
|
1060
|
-
)`,
|
|
1061
|
-
`CREATE INDEX IF NOT EXISTS idx_esc_to ON agent_escalations(to_agent_id, status)`,
|
|
1062
|
-
];
|
|
1063
|
-
}
|
|
1064
|
-
}
|