@agenticmail/enterprise 0.5.327 → 0.5.328
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard/app.js +1 -1
- package/logs/cloudflared-error.log +6 -0
- package/logs/enterprise-out.log +1 -0
- package/package.json +1 -1
- package/src/admin/page-registry.ts +0 -290
- package/src/admin/routes.ts +0 -2968
- package/src/agent-tools/common.ts +0 -260
- package/src/agent-tools/index.ts +0 -542
- package/src/agent-tools/merge.ts +0 -62
- package/src/agent-tools/middleware.ts +0 -436
- package/src/agent-tools/schema/typebox.ts +0 -25
- package/src/agent-tools/security.ts +0 -352
- package/src/agent-tools/tool-resolver.ts +0 -1018
- package/src/agent-tools/tools/agenticmail.ts +0 -1017
- package/src/agent-tools/tools/bash.ts +0 -179
- package/src/agent-tools/tools/browser-tool.schema.ts +0 -112
- package/src/agent-tools/tools/browser-tool.ts +0 -388
- package/src/agent-tools/tools/browser.ts +0 -764
- package/src/agent-tools/tools/edit.ts +0 -100
- package/src/agent-tools/tools/enterprise-code-sandbox.ts +0 -395
- package/src/agent-tools/tools/enterprise-database.ts +0 -377
- package/src/agent-tools/tools/enterprise-diff.ts +0 -580
- package/src/agent-tools/tools/enterprise-documents.ts +0 -896
- package/src/agent-tools/tools/enterprise-http.ts +0 -485
- package/src/agent-tools/tools/enterprise-security-scan.ts +0 -528
- package/src/agent-tools/tools/enterprise-spreadsheet.ts +0 -825
- package/src/agent-tools/tools/glob.ts +0 -129
- package/src/agent-tools/tools/google/calendar.ts +0 -230
- package/src/agent-tools/tools/google/chat.ts +0 -725
- package/src/agent-tools/tools/google/contacts.ts +0 -209
- package/src/agent-tools/tools/google/docs.ts +0 -162
- package/src/agent-tools/tools/google/drive.ts +0 -392
- package/src/agent-tools/tools/google/forms.ts +0 -367
- package/src/agent-tools/tools/google/gmail.ts +0 -897
- package/src/agent-tools/tools/google/index.ts +0 -86
- package/src/agent-tools/tools/google/maps.ts +0 -543
- package/src/agent-tools/tools/google/meeting-voice.ts +0 -885
- package/src/agent-tools/tools/google/meetings.ts +0 -1094
- package/src/agent-tools/tools/google/sheets.ts +0 -215
- package/src/agent-tools/tools/google/slides.ts +0 -559
- package/src/agent-tools/tools/google/tasks.ts +0 -200
- package/src/agent-tools/tools/grep.ts +0 -178
- package/src/agent-tools/tools/integrations/_factory.ts +0 -102
- package/src/agent-tools/tools/integrations/activecampaign.ts +0 -14
- package/src/agent-tools/tools/integrations/adobe-sign.ts +0 -14
- package/src/agent-tools/tools/integrations/adp.ts +0 -14
- package/src/agent-tools/tools/integrations/airtable.ts +0 -14
- package/src/agent-tools/tools/integrations/apollo.ts +0 -14
- package/src/agent-tools/tools/integrations/asana.ts +0 -14
- package/src/agent-tools/tools/integrations/auth0.ts +0 -14
- package/src/agent-tools/tools/integrations/aws.ts +0 -14
- package/src/agent-tools/tools/integrations/azure-devops.ts +0 -14
- package/src/agent-tools/tools/integrations/bamboohr.ts +0 -14
- package/src/agent-tools/tools/integrations/basecamp.ts +0 -14
- package/src/agent-tools/tools/integrations/bigcommerce.ts +0 -14
- package/src/agent-tools/tools/integrations/bitbucket.ts +0 -14
- package/src/agent-tools/tools/integrations/box.ts +0 -14
- package/src/agent-tools/tools/integrations/brex.ts +0 -14
- package/src/agent-tools/tools/integrations/buffer.ts +0 -14
- package/src/agent-tools/tools/integrations/calendly.ts +0 -14
- package/src/agent-tools/tools/integrations/canva.ts +0 -14
- package/src/agent-tools/tools/integrations/chargebee.ts +0 -14
- package/src/agent-tools/tools/integrations/circleci.ts +0 -14
- package/src/agent-tools/tools/integrations/clickup.ts +0 -14
- package/src/agent-tools/tools/integrations/close.ts +0 -14
- package/src/agent-tools/tools/integrations/cloudflare.ts +0 -14
- package/src/agent-tools/tools/integrations/confluence.ts +0 -14
- package/src/agent-tools/tools/integrations/contentful.ts +0 -14
- package/src/agent-tools/tools/integrations/copper.ts +0 -14
- package/src/agent-tools/tools/integrations/crisp.ts +0 -14
- package/src/agent-tools/tools/integrations/crowdstrike.ts +0 -14
- package/src/agent-tools/tools/integrations/datadog.ts +0 -14
- package/src/agent-tools/tools/integrations/digitalocean.ts +0 -14
- package/src/agent-tools/tools/integrations/discord.ts +0 -14
- package/src/agent-tools/tools/integrations/docker.ts +0 -14
- package/src/agent-tools/tools/integrations/docusign.ts +0 -14
- package/src/agent-tools/tools/integrations/drift.ts +0 -14
- package/src/agent-tools/tools/integrations/dropbox.ts +0 -14
- package/src/agent-tools/tools/integrations/figma.ts +0 -14
- package/src/agent-tools/tools/integrations/firebase.ts +0 -14
- package/src/agent-tools/tools/integrations/flyio.ts +0 -14
- package/src/agent-tools/tools/integrations/freshbooks.ts +0 -14
- package/src/agent-tools/tools/integrations/freshdesk.ts +0 -14
- package/src/agent-tools/tools/integrations/freshsales.ts +0 -14
- package/src/agent-tools/tools/integrations/freshservice.ts +0 -14
- package/src/agent-tools/tools/integrations/front.ts +0 -14
- package/src/agent-tools/tools/integrations/github-actions.ts +0 -14
- package/src/agent-tools/tools/integrations/github.ts +0 -14
- package/src/agent-tools/tools/integrations/gitlab.ts +0 -14
- package/src/agent-tools/tools/integrations/gong.ts +0 -14
- package/src/agent-tools/tools/integrations/google-ads.ts +0 -14
- package/src/agent-tools/tools/integrations/google-analytics.ts +0 -14
- package/src/agent-tools/tools/integrations/google-cloud.ts +0 -14
- package/src/agent-tools/tools/integrations/gotomeeting.ts +0 -14
- package/src/agent-tools/tools/integrations/grafana.ts +0 -14
- package/src/agent-tools/tools/integrations/greenhouse.ts +0 -14
- package/src/agent-tools/tools/integrations/gusto.ts +0 -14
- package/src/agent-tools/tools/integrations/hashicorp-vault.ts +0 -14
- package/src/agent-tools/tools/integrations/heroku.ts +0 -14
- package/src/agent-tools/tools/integrations/hibob.ts +0 -14
- package/src/agent-tools/tools/integrations/hootsuite.ts +0 -14
- package/src/agent-tools/tools/integrations/hubspot.ts +0 -14
- package/src/agent-tools/tools/integrations/huggingface.ts +0 -14
- package/src/agent-tools/tools/integrations/index.ts +0 -474
- package/src/agent-tools/tools/integrations/intercom.ts +0 -14
- package/src/agent-tools/tools/integrations/jira.ts +0 -14
- package/src/agent-tools/tools/integrations/klaviyo.ts +0 -14
- package/src/agent-tools/tools/integrations/kubernetes.ts +0 -14
- package/src/agent-tools/tools/integrations/lattice.ts +0 -14
- package/src/agent-tools/tools/integrations/launchdarkly.ts +0 -14
- package/src/agent-tools/tools/integrations/lever.ts +0 -14
- package/src/agent-tools/tools/integrations/linear.ts +0 -14
- package/src/agent-tools/tools/integrations/linkedin.ts +0 -14
- package/src/agent-tools/tools/integrations/livechat.ts +0 -14
- package/src/agent-tools/tools/integrations/loom.ts +0 -14
- package/src/agent-tools/tools/integrations/mailchimp.ts +0 -14
- package/src/agent-tools/tools/integrations/mailgun.ts +0 -14
- package/src/agent-tools/tools/integrations/miro.ts +0 -14
- package/src/agent-tools/tools/integrations/mixpanel.ts +0 -14
- package/src/agent-tools/tools/integrations/monday.ts +0 -14
- package/src/agent-tools/tools/integrations/mongodb-atlas.ts +0 -14
- package/src/agent-tools/tools/integrations/neon.ts +0 -14
- package/src/agent-tools/tools/integrations/netlify.ts +0 -14
- package/src/agent-tools/tools/integrations/netsuite.ts +0 -14
- package/src/agent-tools/tools/integrations/newrelic.ts +0 -14
- package/src/agent-tools/tools/integrations/notion.ts +0 -14
- package/src/agent-tools/tools/integrations/okta.ts +0 -14
- package/src/agent-tools/tools/integrations/openai.ts +0 -14
- package/src/agent-tools/tools/integrations/opsgenie.ts +0 -14
- package/src/agent-tools/tools/integrations/outreach.ts +0 -14
- package/src/agent-tools/tools/integrations/paddle.ts +0 -14
- package/src/agent-tools/tools/integrations/pagerduty.ts +0 -14
- package/src/agent-tools/tools/integrations/pandadoc.ts +0 -14
- package/src/agent-tools/tools/integrations/paypal.ts +0 -14
- package/src/agent-tools/tools/integrations/personio.ts +0 -14
- package/src/agent-tools/tools/integrations/pinecone.ts +0 -14
- package/src/agent-tools/tools/integrations/pipedrive.ts +0 -14
- package/src/agent-tools/tools/integrations/plaid.ts +0 -14
- package/src/agent-tools/tools/integrations/postmark.ts +0 -14
- package/src/agent-tools/tools/integrations/power-automate.ts +0 -14
- package/src/agent-tools/tools/integrations/quickbooks.ts +0 -14
- package/src/agent-tools/tools/integrations/recurly.ts +0 -14
- package/src/agent-tools/tools/integrations/reddit.ts +0 -14
- package/src/agent-tools/tools/integrations/render.ts +0 -14
- package/src/agent-tools/tools/integrations/ringcentral.ts +0 -14
- package/src/agent-tools/tools/integrations/rippling.ts +0 -14
- package/src/agent-tools/tools/integrations/salesforce.ts +0 -14
- package/src/agent-tools/tools/integrations/salesloft.ts +0 -14
- package/src/agent-tools/tools/integrations/sanity.ts +0 -14
- package/src/agent-tools/tools/integrations/sap.ts +0 -14
- package/src/agent-tools/tools/integrations/segment.ts +0 -14
- package/src/agent-tools/tools/integrations/sendgrid.ts +0 -14
- package/src/agent-tools/tools/integrations/sentry.ts +0 -14
- package/src/agent-tools/tools/integrations/servicenow.ts +0 -14
- package/src/agent-tools/tools/integrations/shopify.ts +0 -14
- package/src/agent-tools/tools/integrations/shortcut.ts +0 -14
- package/src/agent-tools/tools/integrations/slack.ts +0 -14
- package/src/agent-tools/tools/integrations/smartsheet.ts +0 -14
- package/src/agent-tools/tools/integrations/snowflake.ts +0 -14
- package/src/agent-tools/tools/integrations/snyk.ts +0 -14
- package/src/agent-tools/tools/integrations/splunk.ts +0 -14
- package/src/agent-tools/tools/integrations/square.ts +0 -14
- package/src/agent-tools/tools/integrations/statuspage.ts +0 -14
- package/src/agent-tools/tools/integrations/stripe.ts +0 -14
- package/src/agent-tools/tools/integrations/supabase.ts +0 -14
- package/src/agent-tools/tools/integrations/teamwork.ts +0 -14
- package/src/agent-tools/tools/integrations/telegram.ts +0 -14
- package/src/agent-tools/tools/integrations/terraform.ts +0 -14
- package/src/agent-tools/tools/integrations/todoist.ts +0 -14
- package/src/agent-tools/tools/integrations/trello.ts +0 -14
- package/src/agent-tools/tools/integrations/twilio.ts +0 -14
- package/src/agent-tools/tools/integrations/twitter.ts +0 -14
- package/src/agent-tools/tools/integrations/vercel.ts +0 -14
- package/src/agent-tools/tools/integrations/weaviate.ts +0 -14
- package/src/agent-tools/tools/integrations/webex.ts +0 -14
- package/src/agent-tools/tools/integrations/webflow.ts +0 -14
- package/src/agent-tools/tools/integrations/whatsapp.ts +0 -14
- package/src/agent-tools/tools/integrations/whereby.ts +0 -14
- package/src/agent-tools/tools/integrations/woocommerce.ts +0 -14
- package/src/agent-tools/tools/integrations/wordpress.ts +0 -14
- package/src/agent-tools/tools/integrations/workday.ts +0 -14
- package/src/agent-tools/tools/integrations/wrike.ts +0 -14
- package/src/agent-tools/tools/integrations/xero.ts +0 -14
- package/src/agent-tools/tools/integrations/youtube.ts +0 -14
- package/src/agent-tools/tools/integrations/zendesk.ts +0 -14
- package/src/agent-tools/tools/integrations/zoho-crm.ts +0 -14
- package/src/agent-tools/tools/integrations/zoom.ts +0 -14
- package/src/agent-tools/tools/integrations/zuora.ts +0 -14
- package/src/agent-tools/tools/knowledge-search.ts +0 -318
- package/src/agent-tools/tools/local/coding.ts +0 -626
- package/src/agent-tools/tools/local/dependency-manager.ts +0 -647
- package/src/agent-tools/tools/local/file-edit.ts +0 -31
- package/src/agent-tools/tools/local/file-list.ts +0 -39
- package/src/agent-tools/tools/local/file-ops.ts +0 -48
- package/src/agent-tools/tools/local/file-read.ts +0 -39
- package/src/agent-tools/tools/local/file-search.ts +0 -46
- package/src/agent-tools/tools/local/file-write.ts +0 -28
- package/src/agent-tools/tools/local/filesystem.ts +0 -5
- package/src/agent-tools/tools/local/index.ts +0 -55
- package/src/agent-tools/tools/local/resolve-path.ts +0 -18
- package/src/agent-tools/tools/local/shell.ts +0 -277
- package/src/agent-tools/tools/local/system-info.ts +0 -29
- package/src/agent-tools/tools/management.ts +0 -425
- package/src/agent-tools/tools/mcp-bridge.ts +0 -142
- package/src/agent-tools/tools/mcp-server-tools.ts +0 -91
- package/src/agent-tools/tools/meeting-lifecycle.ts +0 -438
- package/src/agent-tools/tools/memory.ts +0 -509
- package/src/agent-tools/tools/messaging/index.ts +0 -6
- package/src/agent-tools/tools/messaging/telegram.ts +0 -167
- package/src/agent-tools/tools/messaging/whatsapp.ts +0 -651
- package/src/agent-tools/tools/microsoft/contacts.ts +0 -176
- package/src/agent-tools/tools/microsoft/excel-vba.ts +0 -331
- package/src/agent-tools/tools/microsoft/excel.ts +0 -261
- package/src/agent-tools/tools/microsoft/graph-api.ts +0 -161
- package/src/agent-tools/tools/microsoft/index.ts +0 -95
- package/src/agent-tools/tools/microsoft/onedrive.ts +0 -429
- package/src/agent-tools/tools/microsoft/onenote.ts +0 -186
- package/src/agent-tools/tools/microsoft/outlook-calendar.ts +0 -286
- package/src/agent-tools/tools/microsoft/outlook-mail.ts +0 -723
- package/src/agent-tools/tools/microsoft/planner.ts +0 -200
- package/src/agent-tools/tools/microsoft/powerbi.ts +0 -266
- package/src/agent-tools/tools/microsoft/powerpoint.ts +0 -186
- package/src/agent-tools/tools/microsoft/sharepoint.ts +0 -328
- package/src/agent-tools/tools/microsoft/teams.ts +0 -463
- package/src/agent-tools/tools/microsoft/todo.ts +0 -181
- package/src/agent-tools/tools/oauth-token-provider.ts +0 -101
- package/src/agent-tools/tools/read.ts +0 -160
- package/src/agent-tools/tools/visual-memory/capture.ts +0 -217
- package/src/agent-tools/tools/visual-memory/diff.ts +0 -283
- package/src/agent-tools/tools/visual-memory/index.ts +0 -698
- package/src/agent-tools/tools/visual-memory/phash.ts +0 -120
- package/src/agent-tools/tools/visual-memory/similarity.ts +0 -354
- package/src/agent-tools/tools/visual-memory/storage.ts +0 -534
- package/src/agent-tools/tools/visual-memory/types.ts +0 -100
- package/src/agent-tools/tools/web-fetch-utils.ts +0 -202
- package/src/agent-tools/tools/web-fetch.ts +0 -464
- package/src/agent-tools/tools/web-search.ts +0 -480
- package/src/agent-tools/tools/web-shared.ts +0 -232
- package/src/agent-tools/tools/write.ts +0 -68
- package/src/agent-tools/types.ts +0 -214
- package/src/agenticmail/index.ts +0 -34
- package/src/agenticmail/manager.ts +0 -253
- package/src/agenticmail/providers/google.ts +0 -391
- package/src/agenticmail/providers/imap.ts +0 -454
- package/src/agenticmail/providers/index.ts +0 -28
- package/src/agenticmail/providers/microsoft.ts +0 -260
- package/src/agenticmail/types.ts +0 -173
- package/src/auth/routes.ts +0 -1589
- package/src/browser/bridge-auth-registry.ts +0 -34
- package/src/browser/bridge-server.ts +0 -93
- package/src/browser/cdp.helpers.ts +0 -180
- package/src/browser/cdp.ts +0 -466
- package/src/browser/chrome.executables.ts +0 -625
- package/src/browser/chrome.profile-decoration.ts +0 -198
- package/src/browser/chrome.ts +0 -349
- package/src/browser/client-actions-core.ts +0 -259
- package/src/browser/client-actions-observe.ts +0 -184
- package/src/browser/client-actions-state.ts +0 -284
- package/src/browser/client-actions-types.ts +0 -16
- package/src/browser/client-actions-url.ts +0 -11
- package/src/browser/client-actions.ts +0 -4
- package/src/browser/client-fetch.ts +0 -253
- package/src/browser/client.ts +0 -337
- package/src/browser/config.ts +0 -301
- package/src/browser/constants.ts +0 -8
- package/src/browser/control-auth.ts +0 -94
- package/src/browser/control-service.ts +0 -81
- package/src/browser/csrf.ts +0 -87
- package/src/browser/enterprise-compat.ts +0 -562
- package/src/browser/extension-relay.ts +0 -834
- package/src/browser/http-auth.ts +0 -63
- package/src/browser/navigation-guard.ts +0 -50
- package/src/browser/paths.ts +0 -49
- package/src/browser/playwright.d.ts +0 -12
- package/src/browser/profiles-service.ts +0 -187
- package/src/browser/profiles.ts +0 -114
- package/src/browser/proxy-files.ts +0 -41
- package/src/browser/pw-ai-module.ts +0 -52
- package/src/browser/pw-ai-state.ts +0 -9
- package/src/browser/pw-ai.ts +0 -65
- package/src/browser/pw-role-snapshot.ts +0 -434
- package/src/browser/pw-session.ts +0 -810
- package/src/browser/pw-tools-core.activity.ts +0 -68
- package/src/browser/pw-tools-core.downloads.ts +0 -281
- package/src/browser/pw-tools-core.interactions.ts +0 -646
- package/src/browser/pw-tools-core.responses.ts +0 -124
- package/src/browser/pw-tools-core.shared.ts +0 -70
- package/src/browser/pw-tools-core.snapshot.ts +0 -213
- package/src/browser/pw-tools-core.state.ts +0 -209
- package/src/browser/pw-tools-core.storage.ts +0 -128
- package/src/browser/pw-tools-core.trace.ts +0 -37
- package/src/browser/pw-tools-core.ts +0 -8
- package/src/browser/resolved-config-refresh.ts +0 -59
- package/src/browser/routes/agent.act.shared.ts +0 -52
- package/src/browser/routes/agent.act.ts +0 -575
- package/src/browser/routes/agent.debug.ts +0 -149
- package/src/browser/routes/agent.shared.ts +0 -143
- package/src/browser/routes/agent.snapshot.ts +0 -333
- package/src/browser/routes/agent.storage.ts +0 -451
- package/src/browser/routes/agent.ts +0 -13
- package/src/browser/routes/basic.ts +0 -202
- package/src/browser/routes/dispatcher.ts +0 -126
- package/src/browser/routes/index.ts +0 -11
- package/src/browser/routes/path-output.ts +0 -1
- package/src/browser/routes/tabs.ts +0 -217
- package/src/browser/routes/types.ts +0 -26
- package/src/browser/routes/utils.ts +0 -73
- package/src/browser/screenshot.ts +0 -54
- package/src/browser/server-context.ts +0 -688
- package/src/browser/server-context.types.ts +0 -65
- package/src/browser/server-lifecycle.ts +0 -48
- package/src/browser/server-middleware.ts +0 -37
- package/src/browser/server.ts +0 -110
- package/src/browser/target-id.ts +0 -30
- package/src/browser/trash.ts +0 -21
- package/src/cli-agent.ts +0 -2452
- package/src/cli-reset-password.ts +0 -138
- package/src/cli-serve.ts +0 -314
- package/src/cli.ts +0 -103
- package/src/dashboard/HELP-TOOLTIPS-GUIDE.md +0 -45
- package/src/dashboard/app.js +0 -579
- package/src/dashboard/assets/brand-logos.js +0 -350
- package/src/dashboard/assets/icons/emoji-icons.js +0 -893
- package/src/dashboard/assets/logo.png +0 -0
- package/src/dashboard/assets/provider-logos.js +0 -139
- package/src/dashboard/components/error-boundary.js +0 -21
- package/src/dashboard/components/help-button.js +0 -65
- package/src/dashboard/components/icons.js +0 -64
- package/src/dashboard/components/knowledge-link.js +0 -79
- package/src/dashboard/components/modal.js +0 -125
- package/src/dashboard/components/org-switcher.js +0 -156
- package/src/dashboard/components/persona-fields.js +0 -460
- package/src/dashboard/components/settings-help.js +0 -193
- package/src/dashboard/components/tag-input.js +0 -96
- package/src/dashboard/components/timezones.js +0 -352
- package/src/dashboard/components/transport-encryption.js +0 -288
- package/src/dashboard/components/utils.js +0 -205
- package/src/dashboard/data/countries.js +0 -255
- package/src/dashboard/docs/activity.html +0 -253
- package/src/dashboard/docs/agent-activity.html +0 -199
- package/src/dashboard/docs/agent-autonomy.html +0 -161
- package/src/dashboard/docs/agent-budget.html +0 -190
- package/src/dashboard/docs/agent-channels.html +0 -189
- package/src/dashboard/docs/agent-communication.html +0 -171
- package/src/dashboard/docs/agent-configuration.html +0 -194
- package/src/dashboard/docs/agent-deployment.html +0 -323
- package/src/dashboard/docs/agent-email.html +0 -184
- package/src/dashboard/docs/agent-guardrails.html +0 -206
- package/src/dashboard/docs/agent-manager.html +0 -226
- package/src/dashboard/docs/agent-memory.html +0 -215
- package/src/dashboard/docs/agent-overview.html +0 -226
- package/src/dashboard/docs/agent-permissions.html +0 -305
- package/src/dashboard/docs/agent-personal.html +0 -155
- package/src/dashboard/docs/agent-security.html +0 -188
- package/src/dashboard/docs/agent-skills.html +0 -224
- package/src/dashboard/docs/agent-tool-security.html +0 -205
- package/src/dashboard/docs/agent-tools.html +0 -238
- package/src/dashboard/docs/agent-whatsapp.html +0 -210
- package/src/dashboard/docs/agent-workforce.html +0 -199
- package/src/dashboard/docs/agents.html +0 -258
- package/src/dashboard/docs/approvals.html +0 -200
- package/src/dashboard/docs/audit.html +0 -206
- package/src/dashboard/docs/browser-providers.html +0 -313
- package/src/dashboard/docs/cluster.html +0 -285
- package/src/dashboard/docs/community-skills.html +0 -253
- package/src/dashboard/docs/compliance.html +0 -221
- package/src/dashboard/docs/dashboard.html +0 -84
- package/src/dashboard/docs/database-access.html +0 -322
- package/src/dashboard/docs/dlp.html +0 -268
- package/src/dashboard/docs/docs-style.css +0 -26
- package/src/dashboard/docs/domain-status.html +0 -294
- package/src/dashboard/docs/guardrails.html +0 -265
- package/src/dashboard/docs/journal.html +0 -197
- package/src/dashboard/docs/knowledge-contributions.html +0 -286
- package/src/dashboard/docs/knowledge.html +0 -268
- package/src/dashboard/docs/memory-transfer.html +0 -311
- package/src/dashboard/docs/messages.html +0 -217
- package/src/dashboard/docs/multi-tenant.html +0 -311
- package/src/dashboard/docs/org-chart.html +0 -239
- package/src/dashboard/docs/organizations.html +0 -182
- package/src/dashboard/docs/roles.html +0 -195
- package/src/dashboard/docs/settings-network.html +0 -321
- package/src/dashboard/docs/settings-security.html +0 -347
- package/src/dashboard/docs/settings-tool-security.html +0 -176
- package/src/dashboard/docs/settings.html +0 -280
- package/src/dashboard/docs/skill-connections.html +0 -270
- package/src/dashboard/docs/skills.html +0 -206
- package/src/dashboard/docs/task-pipeline.html +0 -261
- package/src/dashboard/docs/transport-encryption.html +0 -359
- package/src/dashboard/docs/users.html +0 -225
- package/src/dashboard/docs/vault.html +0 -260
- package/src/dashboard/docs/workforce.html +0 -245
- package/src/dashboard/index.html +0 -444
- package/src/dashboard/pages/activity.js +0 -379
- package/src/dashboard/pages/agent-detail/activity.js +0 -277
- package/src/dashboard/pages/agent-detail/autonomy.js +0 -244
- package/src/dashboard/pages/agent-detail/budget.js +0 -269
- package/src/dashboard/pages/agent-detail/channels.js +0 -494
- package/src/dashboard/pages/agent-detail/communication.js +0 -296
- package/src/dashboard/pages/agent-detail/configuration.js +0 -882
- package/src/dashboard/pages/agent-detail/deployment.js +0 -958
- package/src/dashboard/pages/agent-detail/email.js +0 -674
- package/src/dashboard/pages/agent-detail/guardrails.js +0 -521
- package/src/dashboard/pages/agent-detail/index.js +0 -261
- package/src/dashboard/pages/agent-detail/manager.js +0 -357
- package/src/dashboard/pages/agent-detail/meeting-browser.js +0 -933
- package/src/dashboard/pages/agent-detail/memory.js +0 -368
- package/src/dashboard/pages/agent-detail/overview.js +0 -844
- package/src/dashboard/pages/agent-detail/permissions.js +0 -1163
- package/src/dashboard/pages/agent-detail/personal-details.js +0 -404
- package/src/dashboard/pages/agent-detail/security.js +0 -409
- package/src/dashboard/pages/agent-detail/shared.js +0 -85
- package/src/dashboard/pages/agent-detail/skills-section.js +0 -183
- package/src/dashboard/pages/agent-detail/tool-security.js +0 -380
- package/src/dashboard/pages/agent-detail/tools.js +0 -322
- package/src/dashboard/pages/agent-detail/whatsapp.js +0 -824
- package/src/dashboard/pages/agent-detail/workforce.js +0 -683
- package/src/dashboard/pages/agents.js +0 -1242
- package/src/dashboard/pages/approvals.js +0 -100
- package/src/dashboard/pages/audit.js +0 -198
- package/src/dashboard/pages/cluster.js +0 -512
- package/src/dashboard/pages/community-skills.js +0 -1219
- package/src/dashboard/pages/compliance.js +0 -475
- package/src/dashboard/pages/dashboard.js +0 -180
- package/src/dashboard/pages/database-access.js +0 -812
- package/src/dashboard/pages/dlp.js +0 -293
- package/src/dashboard/pages/domain-status.js +0 -951
- package/src/dashboard/pages/guardrails.js +0 -1035
- package/src/dashboard/pages/journal.js +0 -172
- package/src/dashboard/pages/knowledge-contributions.js +0 -1682
- package/src/dashboard/pages/knowledge-import.js +0 -455
- package/src/dashboard/pages/knowledge.js +0 -582
- package/src/dashboard/pages/login.js +0 -1056
- package/src/dashboard/pages/memory-transfer.js +0 -631
- package/src/dashboard/pages/messages.js +0 -303
- package/src/dashboard/pages/org-chart.js +0 -349
- package/src/dashboard/pages/organizations.js +0 -1081
- package/src/dashboard/pages/roles.js +0 -780
- package/src/dashboard/pages/settings.js +0 -3790
- package/src/dashboard/pages/skill-connections.js +0 -982
- package/src/dashboard/pages/skills.js +0 -879
- package/src/dashboard/pages/task-pipeline.js +0 -684
- package/src/dashboard/pages/users.js +0 -867
- package/src/dashboard/pages/vault.js +0 -791
- package/src/dashboard/pages/workforce.js +0 -851
- package/src/dashboard/vendor/react-dom.development.js +0 -29924
- package/src/dashboard/vendor/react-dom.production.min.js +0 -267
- package/src/dashboard/vendor/react.development.js +0 -3343
- package/src/dashboard/vendor/react.production.min.js +0 -31
- package/src/database-access/agent-tools.ts +0 -193
- package/src/database-access/connection-manager.ts +0 -1341
- package/src/database-access/index.ts +0 -21
- package/src/database-access/query-sanitizer.ts +0 -220
- package/src/database-access/routes.ts +0 -226
- package/src/database-access/types.ts +0 -226
- package/src/db/adapter.ts +0 -510
- package/src/db/dynamodb.ts +0 -454
- package/src/db/factory.ts +0 -129
- package/src/db/mongodb.ts +0 -360
- package/src/db/mysql.ts +0 -531
- package/src/db/postgres.ts +0 -863
- package/src/db/proxy.ts +0 -39
- package/src/db/resolve-driver.ts +0 -29
- package/src/db/sql-schema.ts +0 -124
- package/src/db/sqlite.ts +0 -493
- package/src/db/turso.ts +0 -470
- package/src/deploy/fly.ts +0 -368
- package/src/deploy/managed.ts +0 -235
- package/src/domain-lock/cli-recover.ts +0 -591
- package/src/domain-lock/cli-verify.ts +0 -190
- package/src/domain-lock/index.ts +0 -220
- package/src/engine/activity-routes.ts +0 -154
- package/src/engine/activity.ts +0 -568
- package/src/engine/agent-autonomy.ts +0 -974
- package/src/engine/agent-config.ts +0 -646
- package/src/engine/agent-heartbeat.ts +0 -720
- package/src/engine/agent-hierarchy.ts +0 -1064
- package/src/engine/agent-memory.ts +0 -806
- package/src/engine/agent-notify.ts +0 -50
- package/src/engine/agent-routes.ts +0 -2583
- package/src/engine/agent-status.ts +0 -311
- package/src/engine/ambient-memory.ts +0 -401
- package/src/engine/approvals.ts +0 -615
- package/src/engine/assets/thinking-hum.mp3 +0 -0
- package/src/engine/catalog-routes.ts +0 -232
- package/src/engine/chat-poller.ts +0 -913
- package/src/engine/chat-webhook-routes.ts +0 -304
- package/src/engine/cli-build-skill.ts +0 -285
- package/src/engine/cli-submit-skill.ts +0 -200
- package/src/engine/cli-validate.ts +0 -188
- package/src/engine/cluster.ts +0 -278
- package/src/engine/communication-routes.ts +0 -139
- package/src/engine/communication.ts +0 -765
- package/src/engine/community-registry.ts +0 -1529
- package/src/engine/community-routes.ts +0 -260
- package/src/engine/compliance-routes.ts +0 -133
- package/src/engine/compliance.ts +0 -1679
- package/src/engine/config-bus.ts +0 -103
- package/src/engine/db-adapter.ts +0 -1156
- package/src/engine/db-schema.ts +0 -1945
- package/src/engine/deploy-schema-routes.ts +0 -176
- package/src/engine/deployer.ts +0 -957
- package/src/engine/dlp-routes.ts +0 -101
- package/src/engine/dlp.ts +0 -410
- package/src/engine/email-poller.ts +0 -855
- package/src/engine/emoji.ts +0 -106
- package/src/engine/guardrail-routes.ts +0 -125
- package/src/engine/guardrails.ts +0 -465
- package/src/engine/index.ts +0 -255
- package/src/engine/journal-routes.ts +0 -56
- package/src/engine/journal.ts +0 -249
- package/src/engine/knowledge-contribution-routes.ts +0 -633
- package/src/engine/knowledge-contribution.ts +0 -1386
- package/src/engine/knowledge-import/chunker.ts +0 -241
- package/src/engine/knowledge-import/import-manager.ts +0 -416
- package/src/engine/knowledge-import/index.ts +0 -27
- package/src/engine/knowledge-import/processors/clean.ts +0 -149
- package/src/engine/knowledge-import/processors/extract-gdrive.ts +0 -102
- package/src/engine/knowledge-import/processors/extract-github.ts +0 -74
- package/src/engine/knowledge-import/processors/extract-sharepoint.ts +0 -69
- package/src/engine/knowledge-import/processors/extract-web.ts +0 -275
- package/src/engine/knowledge-import/processors/index.ts +0 -18
- package/src/engine/knowledge-import/processors/pipeline.ts +0 -171
- package/src/engine/knowledge-import/processors/types.ts +0 -78
- package/src/engine/knowledge-import/processors/validate.ts +0 -150
- package/src/engine/knowledge-import/provider-file-upload.ts +0 -95
- package/src/engine/knowledge-import/provider-github.ts +0 -144
- package/src/engine/knowledge-import/provider-google-sites.ts +0 -323
- package/src/engine/knowledge-import/provider-sharepoint.ts +0 -276
- package/src/engine/knowledge-import/provider-url.ts +0 -218
- package/src/engine/knowledge-import/routes.ts +0 -94
- package/src/engine/knowledge-import/types.ts +0 -92
- package/src/engine/knowledge-routes.ts +0 -231
- package/src/engine/knowledge.ts +0 -587
- package/src/engine/lifecycle.ts +0 -1420
- package/src/engine/mcp-process-manager.ts +0 -573
- package/src/engine/meeting-monitor.ts +0 -483
- package/src/engine/meeting-voice-intelligence.ts +0 -340
- package/src/engine/memory-routes.ts +0 -142
- package/src/engine/memory-transfer-routes.ts +0 -339
- package/src/engine/messaging-history.ts +0 -177
- package/src/engine/messaging-poller.ts +0 -786
- package/src/engine/model-fallback.ts +0 -141
- package/src/engine/oauth-connect-routes.ts +0 -603
- package/src/engine/oauth-connect.ts +0 -304
- package/src/engine/onboarding-routes.ts +0 -148
- package/src/engine/onboarding.ts +0 -574
- package/src/engine/org-approval-routes.ts +0 -146
- package/src/engine/org-integration-routes.ts +0 -399
- package/src/engine/org-integrations.ts +0 -608
- package/src/engine/org-policies.ts +0 -502
- package/src/engine/policy-import-routes.ts +0 -125
- package/src/engine/policy-import.ts +0 -1186
- package/src/engine/policy-routes.ts +0 -163
- package/src/engine/routes.ts +0 -1236
- package/src/engine/screen-unlock.ts +0 -136
- package/src/engine/session-router.ts +0 -212
- package/src/engine/skill-updater-routes.ts +0 -132
- package/src/engine/skill-updater.ts +0 -480
- package/src/engine/skill-validator.ts +0 -331
- package/src/engine/skills/agent-management.ts +0 -119
- package/src/engine/skills/agent-memory.ts +0 -19
- package/src/engine/skills/agenticmail.ts +0 -116
- package/src/engine/skills/core-tools.ts +0 -25
- package/src/engine/skills/database-access.ts +0 -78
- package/src/engine/skills/enterprise-code-sandbox.ts +0 -113
- package/src/engine/skills/enterprise-database.ts +0 -123
- package/src/engine/skills/enterprise-diff.ts +0 -95
- package/src/engine/skills/enterprise-documents.ts +0 -162
- package/src/engine/skills/enterprise-http.ts +0 -99
- package/src/engine/skills/enterprise-security-scan.ts +0 -125
- package/src/engine/skills/enterprise-spreadsheet.ts +0 -171
- package/src/engine/skills/gws-admin.ts +0 -18
- package/src/engine/skills/gws-calendar.ts +0 -21
- package/src/engine/skills/gws-chat.ts +0 -29
- package/src/engine/skills/gws-contacts.ts +0 -20
- package/src/engine/skills/gws-docs.ts +0 -18
- package/src/engine/skills/gws-drive.ts +0 -23
- package/src/engine/skills/gws-forms.ts +0 -23
- package/src/engine/skills/gws-gmail.ts +0 -30
- package/src/engine/skills/gws-groups.ts +0 -17
- package/src/engine/skills/gws-keep.ts +0 -17
- package/src/engine/skills/gws-maps.ts +0 -25
- package/src/engine/skills/gws-meet.ts +0 -23
- package/src/engine/skills/gws-sheets.ts +0 -22
- package/src/engine/skills/gws-sites.ts +0 -16
- package/src/engine/skills/gws-slides.ts +0 -27
- package/src/engine/skills/gws-tasks.ts +0 -22
- package/src/engine/skills/gws-vault.ts +0 -17
- package/src/engine/skills/index.ts +0 -159
- package/src/engine/skills/knowledge-search.ts +0 -18
- package/src/engine/skills/local-system.ts +0 -61
- package/src/engine/skills/m365-admin.ts +0 -18
- package/src/engine/skills/m365-bookings.ts +0 -17
- package/src/engine/skills/m365-copilot.ts +0 -17
- package/src/engine/skills/m365-excel.ts +0 -60
- package/src/engine/skills/m365-forms.ts +0 -17
- package/src/engine/skills/m365-onedrive.ts +0 -60
- package/src/engine/skills/m365-onenote.ts +0 -17
- package/src/engine/skills/m365-outlook.ts +0 -27
- package/src/engine/skills/m365-planner.ts +0 -18
- package/src/engine/skills/m365-power-automate.ts +0 -18
- package/src/engine/skills/m365-power-bi.ts +0 -19
- package/src/engine/skills/m365-powerpoint.ts +0 -33
- package/src/engine/skills/m365-sharepoint.ts +0 -20
- package/src/engine/skills/m365-teams.ts +0 -21
- package/src/engine/skills/m365-todo.ts +0 -17
- package/src/engine/skills/m365-whiteboard.ts +0 -16
- package/src/engine/skills/m365-word.ts +0 -42
- package/src/engine/skills/mcp-bridge.ts +0 -45
- package/src/engine/skills/meeting-lifecycle.ts +0 -20
- package/src/engine/skills/messaging.ts +0 -46
- package/src/engine/skills/visual-memory.ts +0 -25
- package/src/engine/skills.ts +0 -688
- package/src/engine/soul-library.ts +0 -142
- package/src/engine/soul-templates.json +0 -1525
- package/src/engine/storage-manager.ts +0 -252
- package/src/engine/storage-routes.ts +0 -113
- package/src/engine/storage.ts +0 -528
- package/src/engine/task-poller.ts +0 -394
- package/src/engine/task-queue-after-spawn.ts +0 -66
- package/src/engine/task-queue-before-spawn.ts +0 -113
- package/src/engine/task-queue-routes.ts +0 -161
- package/src/engine/task-queue.ts +0 -664
- package/src/engine/tenant.ts +0 -409
- package/src/engine/tool-catalog.ts +0 -354
- package/src/engine/vault-routes.ts +0 -134
- package/src/engine/vault.ts +0 -601
- package/src/engine/workforce-routes.ts +0 -331
- package/src/engine/workforce.ts +0 -1161
- package/src/index.ts +0 -77
- package/src/lib/cidr.ts +0 -122
- package/src/lib/config-store.ts +0 -86
- package/src/lib/resilience.ts +0 -326
- package/src/lib/text-search.ts +0 -358
- package/src/mcp/adapters/activecampaign.adapter.ts +0 -391
- package/src/mcp/adapters/adobe-sign.adapter.ts +0 -469
- package/src/mcp/adapters/adp.adapter.ts +0 -358
- package/src/mcp/adapters/airtable.adapter.ts +0 -273
- package/src/mcp/adapters/apollo.adapter.ts +0 -420
- package/src/mcp/adapters/asana.adapter.ts +0 -315
- package/src/mcp/adapters/auth0.adapter.ts +0 -386
- package/src/mcp/adapters/aws.adapter.ts +0 -345
- package/src/mcp/adapters/azure-devops.adapter.ts +0 -389
- package/src/mcp/adapters/bamboohr.adapter.ts +0 -376
- package/src/mcp/adapters/basecamp.adapter.ts +0 -366
- package/src/mcp/adapters/bigcommerce.adapter.ts +0 -429
- package/src/mcp/adapters/bitbucket.adapter.ts +0 -260
- package/src/mcp/adapters/box.adapter.ts +0 -350
- package/src/mcp/adapters/brex.adapter.ts +0 -367
- package/src/mcp/adapters/buffer.adapter.ts +0 -303
- package/src/mcp/adapters/calendly.adapter.ts +0 -262
- package/src/mcp/adapters/canva.adapter.ts +0 -256
- package/src/mcp/adapters/chargebee.adapter.ts +0 -448
- package/src/mcp/adapters/circleci.adapter.ts +0 -216
- package/src/mcp/adapters/clickup.adapter.ts +0 -335
- package/src/mcp/adapters/close.adapter.ts +0 -390
- package/src/mcp/adapters/cloudflare.adapter.ts +0 -378
- package/src/mcp/adapters/confluence.adapter.ts +0 -301
- package/src/mcp/adapters/contentful.adapter.ts +0 -355
- package/src/mcp/adapters/copper.adapter.ts +0 -468
- package/src/mcp/adapters/crisp.adapter.ts +0 -415
- package/src/mcp/adapters/crowdstrike.adapter.ts +0 -413
- package/src/mcp/adapters/datadog.adapter.ts +0 -373
- package/src/mcp/adapters/digitalocean.adapter.ts +0 -336
- package/src/mcp/adapters/discord.adapter.ts +0 -248
- package/src/mcp/adapters/docker.adapter.ts +0 -238
- package/src/mcp/adapters/docusign.adapter.ts +0 -431
- package/src/mcp/adapters/drift.adapter.ts +0 -386
- package/src/mcp/adapters/dropbox.adapter.ts +0 -315
- package/src/mcp/adapters/figma.adapter.ts +0 -302
- package/src/mcp/adapters/firebase.adapter.ts +0 -446
- package/src/mcp/adapters/flyio.adapter.ts +0 -302
- package/src/mcp/adapters/freshbooks.adapter.ts +0 -474
- package/src/mcp/adapters/freshdesk.adapter.ts +0 -441
- package/src/mcp/adapters/freshsales.adapter.ts +0 -457
- package/src/mcp/adapters/freshservice.adapter.ts +0 -481
- package/src/mcp/adapters/front.adapter.ts +0 -357
- package/src/mcp/adapters/github-actions.adapter.ts +0 -329
- package/src/mcp/adapters/github.adapter.ts +0 -387
- package/src/mcp/adapters/gitlab.adapter.ts +0 -368
- package/src/mcp/adapters/gong.adapter.ts +0 -386
- package/src/mcp/adapters/google-ads.adapter.ts +0 -363
- package/src/mcp/adapters/google-analytics.adapter.ts +0 -316
- package/src/mcp/adapters/google-cloud.adapter.ts +0 -312
- package/src/mcp/adapters/gotomeeting.adapter.ts +0 -255
- package/src/mcp/adapters/grafana.adapter.ts +0 -361
- package/src/mcp/adapters/greenhouse.adapter.ts +0 -354
- package/src/mcp/adapters/gusto.adapter.ts +0 -329
- package/src/mcp/adapters/hashicorp-vault.adapter.ts +0 -355
- package/src/mcp/adapters/heroku.adapter.ts +0 -291
- package/src/mcp/adapters/hibob.adapter.ts +0 -334
- package/src/mcp/adapters/hootsuite.adapter.ts +0 -322
- package/src/mcp/adapters/hubspot.adapter.ts +0 -400
- package/src/mcp/adapters/huggingface.adapter.ts +0 -349
- package/src/mcp/adapters/index.ts +0 -524
- package/src/mcp/adapters/intercom.adapter.ts +0 -269
- package/src/mcp/adapters/jira.adapter.ts +0 -482
- package/src/mcp/adapters/klaviyo.adapter.ts +0 -353
- package/src/mcp/adapters/kubernetes.adapter.ts +0 -431
- package/src/mcp/adapters/lattice.adapter.ts +0 -339
- package/src/mcp/adapters/launchdarkly.adapter.ts +0 -368
- package/src/mcp/adapters/lever.adapter.ts +0 -347
- package/src/mcp/adapters/linear.adapter.ts +0 -300
- package/src/mcp/adapters/linkedin.adapter.ts +0 -331
- package/src/mcp/adapters/livechat.adapter.ts +0 -259
- package/src/mcp/adapters/loom.adapter.ts +0 -230
- package/src/mcp/adapters/mailchimp.adapter.ts +0 -394
- package/src/mcp/adapters/mailgun.adapter.ts +0 -425
- package/src/mcp/adapters/miro.adapter.ts +0 -274
- package/src/mcp/adapters/mixpanel.adapter.ts +0 -324
- package/src/mcp/adapters/monday.adapter.ts +0 -308
- package/src/mcp/adapters/mongodb-atlas.adapter.ts +0 -345
- package/src/mcp/adapters/neon.adapter.ts +0 -312
- package/src/mcp/adapters/netlify.adapter.ts +0 -324
- package/src/mcp/adapters/netsuite.adapter.ts +0 -411
- package/src/mcp/adapters/newrelic.adapter.ts +0 -339
- package/src/mcp/adapters/notion.adapter.ts +0 -338
- package/src/mcp/adapters/okta.adapter.ts +0 -394
- package/src/mcp/adapters/openai.adapter.ts +0 -315
- package/src/mcp/adapters/opsgenie.adapter.ts +0 -375
- package/src/mcp/adapters/outreach.adapter.ts +0 -372
- package/src/mcp/adapters/paddle.adapter.ts +0 -467
- package/src/mcp/adapters/pagerduty.adapter.ts +0 -412
- package/src/mcp/adapters/pandadoc.adapter.ts +0 -389
- package/src/mcp/adapters/paypal.adapter.ts +0 -465
- package/src/mcp/adapters/personio.adapter.ts +0 -401
- package/src/mcp/adapters/pinecone.adapter.ts +0 -340
- package/src/mcp/adapters/pipedrive.adapter.ts +0 -324
- package/src/mcp/adapters/plaid.adapter.ts +0 -444
- package/src/mcp/adapters/postmark.adapter.ts +0 -387
- package/src/mcp/adapters/power-automate.adapter.ts +0 -388
- package/src/mcp/adapters/quickbooks.adapter.ts +0 -431
- package/src/mcp/adapters/recurly.adapter.ts +0 -433
- package/src/mcp/adapters/reddit.adapter.ts +0 -371
- package/src/mcp/adapters/render.adapter.ts +0 -332
- package/src/mcp/adapters/ringcentral.adapter.ts +0 -281
- package/src/mcp/adapters/rippling.adapter.ts +0 -287
- package/src/mcp/adapters/salesforce.adapter.ts +0 -321
- package/src/mcp/adapters/salesloft.adapter.ts +0 -413
- package/src/mcp/adapters/sanity.adapter.ts +0 -363
- package/src/mcp/adapters/sap.adapter.ts +0 -483
- package/src/mcp/adapters/segment.adapter.ts +0 -260
- package/src/mcp/adapters/sendgrid.adapter.ts +0 -265
- package/src/mcp/adapters/sentry.adapter.ts +0 -331
- package/src/mcp/adapters/servicenow.adapter.ts +0 -468
- package/src/mcp/adapters/shopify.adapter.ts +0 -451
- package/src/mcp/adapters/shortcut.adapter.ts +0 -290
- package/src/mcp/adapters/slack.adapter.ts +0 -380
- package/src/mcp/adapters/smartsheet.adapter.ts +0 -326
- package/src/mcp/adapters/snowflake.adapter.ts +0 -347
- package/src/mcp/adapters/snyk.adapter.ts +0 -394
- package/src/mcp/adapters/splunk.adapter.ts +0 -403
- package/src/mcp/adapters/square.adapter.ts +0 -467
- package/src/mcp/adapters/statuspage.adapter.ts +0 -401
- package/src/mcp/adapters/stripe.adapter.ts +0 -380
- package/src/mcp/adapters/supabase.adapter.ts +0 -334
- package/src/mcp/adapters/teamwork.adapter.ts +0 -404
- package/src/mcp/adapters/telegram.adapter.ts +0 -299
- package/src/mcp/adapters/terraform.adapter.ts +0 -300
- package/src/mcp/adapters/todoist.adapter.ts +0 -239
- package/src/mcp/adapters/trello.adapter.ts +0 -316
- package/src/mcp/adapters/twilio.adapter.ts +0 -233
- package/src/mcp/adapters/twitter.adapter.ts +0 -348
- package/src/mcp/adapters/vercel.adapter.ts +0 -219
- package/src/mcp/adapters/weaviate.adapter.ts +0 -371
- package/src/mcp/adapters/webex.adapter.ts +0 -237
- package/src/mcp/adapters/webflow.adapter.ts +0 -287
- package/src/mcp/adapters/whatsapp.adapter.ts +0 -273
- package/src/mcp/adapters/whereby.adapter.ts +0 -240
- package/src/mcp/adapters/woocommerce.adapter.ts +0 -454
- package/src/mcp/adapters/wordpress.adapter.ts +0 -455
- package/src/mcp/adapters/workday.adapter.ts +0 -354
- package/src/mcp/adapters/wrike.adapter.ts +0 -349
- package/src/mcp/adapters/xero.adapter.ts +0 -472
- package/src/mcp/adapters/youtube.adapter.ts +0 -401
- package/src/mcp/adapters/zendesk.adapter.ts +0 -399
- package/src/mcp/adapters/zoho-crm.adapter.ts +0 -410
- package/src/mcp/adapters/zoom.adapter.ts +0 -241
- package/src/mcp/adapters/zuora.adapter.ts +0 -476
- package/src/mcp/framework/api-executor.ts +0 -192
- package/src/mcp/framework/aws-sigv4.ts +0 -216
- package/src/mcp/framework/credential-resolver.ts +0 -128
- package/src/mcp/framework/oauth-token-manager.ts +0 -22
- package/src/mcp/framework/skill-mcp-framework.ts +0 -226
- package/src/mcp/framework/types.ts +0 -130
- package/src/mcp/index.ts +0 -124
- package/src/mcp/integration-catalog.ts +0 -178
- package/src/middleware/dns-rebinding.ts +0 -44
- package/src/middleware/egress-filter.ts +0 -104
- package/src/middleware/firewall.ts +0 -192
- package/src/middleware/geo-ip.ts +0 -156
- package/src/middleware/index.ts +0 -390
- package/src/middleware/network-config.ts +0 -90
- package/src/middleware/proxy-config.ts +0 -71
- package/src/middleware/request-limits.ts +0 -59
- package/src/middleware/transport-encryption.ts +0 -398
- package/src/registry/cli.ts +0 -63
- package/src/registry/server.ts +0 -504
- package/src/runtime/agent-loop.ts +0 -779
- package/src/runtime/compaction.ts +0 -638
- package/src/runtime/email-channel.ts +0 -120
- package/src/runtime/environment.ts +0 -300
- package/src/runtime/followup.ts +0 -211
- package/src/runtime/gateway.ts +0 -260
- package/src/runtime/hooks.ts +0 -564
- package/src/runtime/index.ts +0 -1110
- package/src/runtime/llm-client.ts +0 -1056
- package/src/runtime/model-router.ts +0 -97
- package/src/runtime/providers.ts +0 -228
- package/src/runtime/session-manager.ts +0 -345
- package/src/runtime/subagent.ts +0 -153
- package/src/runtime/tool-executor.ts +0 -208
- package/src/runtime/types.ts +0 -255
- package/src/security/brute-force.ts +0 -423
- package/src/security/config.ts +0 -159
- package/src/security/csp.ts +0 -407
- package/src/security/external-content.ts +0 -299
- package/src/security/index.ts +0 -557
- package/src/security/input-sanitizer.ts +0 -452
- package/src/security/output-filter.ts +0 -575
- package/src/security/port-scanner.ts +0 -342
- package/src/security/prompt-guard.ts +0 -387
- package/src/security/sql-guard.ts +0 -338
- package/src/security/threat-logger.ts +0 -484
- package/src/server.ts +0 -828
- package/src/setup/company.ts +0 -183
- package/src/setup/database.ts +0 -153
- package/src/setup/deployment.ts +0 -561
- package/src/setup/domain.ts +0 -112
- package/src/setup/index.ts +0 -171
- package/src/setup/provision.ts +0 -532
- package/src/setup/registration.ts +0 -302
- package/src/system-prompts/catchup.ts +0 -48
- package/src/system-prompts/google/calendar.ts +0 -37
- package/src/system-prompts/google/chat.ts +0 -92
- package/src/system-prompts/google/contacts.ts +0 -25
- package/src/system-prompts/google/docs.ts +0 -29
- package/src/system-prompts/google/drive.ts +0 -34
- package/src/system-prompts/google/forms.ts +0 -25
- package/src/system-prompts/google/gmail.ts +0 -50
- package/src/system-prompts/google/index.ts +0 -23
- package/src/system-prompts/google/maps.ts +0 -20
- package/src/system-prompts/google/meet.ts +0 -130
- package/src/system-prompts/google/sheets.ts +0 -32
- package/src/system-prompts/google/slides.ts +0 -26
- package/src/system-prompts/google/tasks.ts +0 -27
- package/src/system-prompts/index.ts +0 -88
- package/src/system-prompts/microsoft/contacts.ts +0 -34
- package/src/system-prompts/microsoft/excel.ts +0 -52
- package/src/system-prompts/microsoft/index.ts +0 -31
- package/src/system-prompts/microsoft/onedrive.ts +0 -41
- package/src/system-prompts/microsoft/onenote.ts +0 -36
- package/src/system-prompts/microsoft/outlook-calendar.ts +0 -37
- package/src/system-prompts/microsoft/outlook-mail.ts +0 -46
- package/src/system-prompts/microsoft/planner.ts +0 -37
- package/src/system-prompts/microsoft/powerbi.ts +0 -38
- package/src/system-prompts/microsoft/powerpoint.ts +0 -35
- package/src/system-prompts/microsoft/sharepoint.ts +0 -44
- package/src/system-prompts/microsoft/teams.ts +0 -49
- package/src/system-prompts/microsoft/todo.ts +0 -37
- package/src/system-prompts/shared-blocks.ts +0 -87
- package/src/system-prompts/task.ts +0 -21
- package/src/system-prompts/triage.ts +0 -34
- package/src/types/hono-env.ts +0 -18
- package/src/types/optional-deps.d.ts +0 -10
package/src/engine/workforce.ts
DELETED
|
@@ -1,1161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Workforce Manager — Working Hours, Clock-In/Out & Task Queue
|
|
3
|
-
*
|
|
4
|
-
* Manages agent work schedules with automatic enforcement:
|
|
5
|
-
* - Per-agent working hours (standard 9-5, shift-based, or custom)
|
|
6
|
-
* - Automated clock-in/out at scheduled times
|
|
7
|
-
* - Off-hours enforcement via guardrails pipeline
|
|
8
|
-
* - Task queue for work continuity between sessions
|
|
9
|
-
* - Automated counter resets (daily/weekly/monthly/annual)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { EngineDatabase } from './db-adapter.js';
|
|
13
|
-
import type { AgentLifecycleManager, ManagedAgent, LifecycleEventType } from './lifecycle.js';
|
|
14
|
-
import type { GuardrailEngine } from './guardrails.js';
|
|
15
|
-
|
|
16
|
-
// ─── Types ──────────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
export interface WorkSchedule {
|
|
19
|
-
id: string;
|
|
20
|
-
agentId: string;
|
|
21
|
-
orgId: string;
|
|
22
|
-
timezone: string; // IANA timezone e.g. "America/New_York"
|
|
23
|
-
scheduleType: 'standard' | 'shift' | 'custom';
|
|
24
|
-
config: {
|
|
25
|
-
standardHours?: {
|
|
26
|
-
start: string; // "09:00"
|
|
27
|
-
end: string; // "17:00"
|
|
28
|
-
daysOfWeek: number[]; // 0=Sun, 1=Mon ... 6=Sat
|
|
29
|
-
};
|
|
30
|
-
shifts?: {
|
|
31
|
-
name: string;
|
|
32
|
-
start: string;
|
|
33
|
-
end: string;
|
|
34
|
-
daysOfWeek: number[];
|
|
35
|
-
}[];
|
|
36
|
-
customRules?: {
|
|
37
|
-
date: string; // "2026-03-15"
|
|
38
|
-
type: 'off' | 'working';
|
|
39
|
-
start?: string;
|
|
40
|
-
end?: string;
|
|
41
|
-
reason?: string;
|
|
42
|
-
}[];
|
|
43
|
-
};
|
|
44
|
-
enforceClockIn: boolean;
|
|
45
|
-
enforceClockOut: boolean;
|
|
46
|
-
autoWakeEnabled: boolean;
|
|
47
|
-
offHoursAction: 'pause' | 'stop' | 'queue';
|
|
48
|
-
gracePeriodMinutes: number;
|
|
49
|
-
enabled: boolean;
|
|
50
|
-
createdAt: string;
|
|
51
|
-
updatedAt: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface ClockRecord {
|
|
55
|
-
id: string;
|
|
56
|
-
agentId: string;
|
|
57
|
-
orgId: string;
|
|
58
|
-
type: 'clock_in' | 'clock_out' | 'auto_pause' | 'auto_wake' | 'overtime_start' | 'overtime_end';
|
|
59
|
-
triggeredBy: string;
|
|
60
|
-
scheduledAt?: string;
|
|
61
|
-
actualAt: string;
|
|
62
|
-
reason?: string;
|
|
63
|
-
metadata: Record<string, any>;
|
|
64
|
-
createdAt: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface QueuedTask {
|
|
68
|
-
id: string;
|
|
69
|
-
agentId: string;
|
|
70
|
-
orgId: string;
|
|
71
|
-
type: 'continue' | 'new' | 'scheduled' | 'delegation';
|
|
72
|
-
title: string;
|
|
73
|
-
description?: string;
|
|
74
|
-
context: Record<string, any>;
|
|
75
|
-
priority: 'low' | 'normal' | 'high' | 'urgent';
|
|
76
|
-
status: 'queued' | 'in_progress' | 'completed' | 'cancelled';
|
|
77
|
-
source: string;
|
|
78
|
-
scheduledFor?: string;
|
|
79
|
-
startedAt?: string;
|
|
80
|
-
completedAt?: string;
|
|
81
|
-
createdAt: string;
|
|
82
|
-
updatedAt: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface WorkforceStatus {
|
|
86
|
-
agents: {
|
|
87
|
-
id: string;
|
|
88
|
-
name: string;
|
|
89
|
-
clockStatus: 'clocked_in' | 'clocked_out' | 'no_schedule';
|
|
90
|
-
schedule?: WorkSchedule;
|
|
91
|
-
nextEvent?: { type: string; at: string };
|
|
92
|
-
queuedTasks: number;
|
|
93
|
-
}[];
|
|
94
|
-
totalClocked: number;
|
|
95
|
-
totalOff: number;
|
|
96
|
-
totalUnscheduled: number;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ─── Workforce Manager ──────────────────────────────────
|
|
100
|
-
|
|
101
|
-
export class WorkforceManager {
|
|
102
|
-
private schedules = new Map<string, WorkSchedule>();
|
|
103
|
-
private clockStatus = new Map<string, 'clocked_in' | 'clocked_out'>();
|
|
104
|
-
private engineDb?: EngineDatabase;
|
|
105
|
-
private lifecycle?: AgentLifecycleManager;
|
|
106
|
-
private guardrails?: GuardrailEngine;
|
|
107
|
-
private schedulerInterval?: NodeJS.Timeout;
|
|
108
|
-
private lastDailyReset: string = '';
|
|
109
|
-
private lastWeeklyReset: string = '';
|
|
110
|
-
private lastMonthlyReset: string = '';
|
|
111
|
-
private lastAnnualReset: string = '';
|
|
112
|
-
private eventListeners: ((event: any) => void)[] = [];
|
|
113
|
-
|
|
114
|
-
constructor(opts?: { lifecycle?: AgentLifecycleManager; guardrails?: GuardrailEngine }) {
|
|
115
|
-
if (opts?.lifecycle) this.lifecycle = opts.lifecycle;
|
|
116
|
-
if (opts?.guardrails) this.guardrails = opts.guardrails;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ─── Database ─────────────────────────────────────────
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Set the database adapter and load schedules from DB.
|
|
123
|
-
* Initializes clock status based on current time vs each agent's schedule.
|
|
124
|
-
*/
|
|
125
|
-
async setDb(db: EngineDatabase): Promise<void> {
|
|
126
|
-
this.engineDb = db;
|
|
127
|
-
await this.loadFromDb();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Load all work schedules from DB and initialize clock status.
|
|
132
|
-
*/
|
|
133
|
-
private async loadFromDb(): Promise<void> {
|
|
134
|
-
if (!this.engineDb) return;
|
|
135
|
-
try {
|
|
136
|
-
const rows = await this.engineDb.query<any>('SELECT * FROM work_schedules WHERE enabled = TRUE');
|
|
137
|
-
for (const r of rows) {
|
|
138
|
-
const schedule: WorkSchedule = {
|
|
139
|
-
id: r.id,
|
|
140
|
-
agentId: r.agent_id,
|
|
141
|
-
orgId: r.org_id,
|
|
142
|
-
timezone: r.timezone || 'UTC',
|
|
143
|
-
scheduleType: r.schedule_type || 'standard',
|
|
144
|
-
config: typeof r.config === 'string' ? JSON.parse(r.config) : (r.config || {}),
|
|
145
|
-
enforceClockIn: !!r.enforce_clock_in,
|
|
146
|
-
enforceClockOut: !!r.enforce_clock_out,
|
|
147
|
-
autoWakeEnabled: !!r.auto_wake_enabled,
|
|
148
|
-
offHoursAction: r.off_hours_action || 'pause',
|
|
149
|
-
gracePeriodMinutes: r.grace_period_minutes ?? 5,
|
|
150
|
-
enabled: !!r.enabled,
|
|
151
|
-
createdAt: r.created_at,
|
|
152
|
-
updatedAt: r.updated_at,
|
|
153
|
-
};
|
|
154
|
-
this.schedules.set(schedule.agentId, schedule);
|
|
155
|
-
|
|
156
|
-
// Determine initial clock status based on current time
|
|
157
|
-
const localNow = this.toTimezone(new Date(), schedule.timezone);
|
|
158
|
-
if (this.isWithinWorkingHours(schedule, localNow)) {
|
|
159
|
-
this.clockStatus.set(schedule.agentId, 'clocked_in');
|
|
160
|
-
} else {
|
|
161
|
-
this.clockStatus.set(schedule.agentId, 'clocked_out');
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
} catch {
|
|
165
|
-
// Table may not exist yet if migrations haven't run
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// ─── Schedule CRUD ────────────────────────────────────
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Create or update a work schedule for an agent.
|
|
173
|
-
*/
|
|
174
|
-
async setSchedule(schedule: WorkSchedule): Promise<void> {
|
|
175
|
-
this.schedules.set(schedule.agentId, schedule);
|
|
176
|
-
|
|
177
|
-
if (this.engineDb) {
|
|
178
|
-
await this.engineDb.execute(
|
|
179
|
-
`INSERT INTO work_schedules (id, agent_id, org_id, timezone, schedule_type, config, enforce_clock_in, enforce_clock_out, auto_wake_enabled, off_hours_action, grace_period_minutes, enabled, created_at, updated_at)
|
|
180
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
181
|
-
ON CONFLICT(agent_id) DO UPDATE SET
|
|
182
|
-
timezone=excluded.timezone, schedule_type=excluded.schedule_type,
|
|
183
|
-
config=excluded.config, enforce_clock_in=excluded.enforce_clock_in,
|
|
184
|
-
enforce_clock_out=excluded.enforce_clock_out, auto_wake_enabled=excluded.auto_wake_enabled,
|
|
185
|
-
off_hours_action=excluded.off_hours_action, grace_period_minutes=excluded.grace_period_minutes,
|
|
186
|
-
enabled=excluded.enabled, updated_at=excluded.updated_at`,
|
|
187
|
-
[
|
|
188
|
-
schedule.id, schedule.agentId, schedule.orgId, schedule.timezone,
|
|
189
|
-
schedule.scheduleType, JSON.stringify(schedule.config),
|
|
190
|
-
schedule.enforceClockIn ? 1 : 0, schedule.enforceClockOut ? 1 : 0,
|
|
191
|
-
schedule.autoWakeEnabled ? 1 : 0, schedule.offHoursAction,
|
|
192
|
-
schedule.gracePeriodMinutes, schedule.enabled ? 1 : 0,
|
|
193
|
-
schedule.createdAt, schedule.updatedAt,
|
|
194
|
-
]
|
|
195
|
-
).catch((err) => { console.error('[workforce] Failed to persist schedule:', err); });
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Initialize clock status for new schedule
|
|
199
|
-
if (!this.clockStatus.has(schedule.agentId)) {
|
|
200
|
-
const localNow = this.toTimezone(new Date(), schedule.timezone);
|
|
201
|
-
if (this.isWithinWorkingHours(schedule, localNow)) {
|
|
202
|
-
this.clockStatus.set(schedule.agentId, 'clocked_in');
|
|
203
|
-
} else {
|
|
204
|
-
this.clockStatus.set(schedule.agentId, 'clocked_out');
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
this.emitEvent('schedule_set', { agentId: schedule.agentId, schedule });
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Remove an agent's work schedule.
|
|
213
|
-
*/
|
|
214
|
-
async removeSchedule(agentId: string): Promise<void> {
|
|
215
|
-
this.schedules.delete(agentId);
|
|
216
|
-
this.clockStatus.delete(agentId);
|
|
217
|
-
|
|
218
|
-
if (this.engineDb) {
|
|
219
|
-
await this.engineDb.execute('DELETE FROM work_schedules WHERE agent_id = ?', [agentId])
|
|
220
|
-
.catch((err) => { console.error('[workforce] Failed to delete schedule:', err); });
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
this.emitEvent('schedule_removed', { agentId });
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Get the work schedule for an agent.
|
|
228
|
-
*/
|
|
229
|
-
getSchedule(agentId: string): WorkSchedule | undefined {
|
|
230
|
-
return this.schedules.get(agentId);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Get all work schedules for an organization.
|
|
235
|
-
*/
|
|
236
|
-
getSchedulesByOrg(orgId: string): WorkSchedule[] {
|
|
237
|
-
const results: WorkSchedule[] = [];
|
|
238
|
-
for (const schedule of this.schedules.values()) {
|
|
239
|
-
if (schedule.orgId === orgId) results.push(schedule);
|
|
240
|
-
}
|
|
241
|
-
return results;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// ─── Clock Operations ────────────────────────────────
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Clock an agent in — mark as working and resume if paused.
|
|
248
|
-
*/
|
|
249
|
-
async clockIn(agentId: string, triggeredBy: string): Promise<ClockRecord> {
|
|
250
|
-
const schedule = this.schedules.get(agentId);
|
|
251
|
-
const orgId = schedule?.orgId || 'default';
|
|
252
|
-
|
|
253
|
-
this.clockStatus.set(agentId, 'clocked_in');
|
|
254
|
-
|
|
255
|
-
const record = await this.recordClockEvent(agentId, orgId, 'clock_in', triggeredBy);
|
|
256
|
-
|
|
257
|
-
// Resume agent if it was paused by guardrails
|
|
258
|
-
if (this.guardrails) {
|
|
259
|
-
try {
|
|
260
|
-
await this.guardrails.resumeAgent(agentId, 'Clock-in: resuming agent', triggeredBy);
|
|
261
|
-
} catch { /* agent may not be paused */ }
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
this.emitEvent('clock_in', { agentId, triggeredBy, record });
|
|
265
|
-
return record;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Clock an agent out — mark as off-duty and enforce off-hours action.
|
|
270
|
-
*/
|
|
271
|
-
async clockOut(agentId: string, triggeredBy: string, reason?: string): Promise<ClockRecord> {
|
|
272
|
-
const schedule = this.schedules.get(agentId);
|
|
273
|
-
const orgId = schedule?.orgId || 'default';
|
|
274
|
-
|
|
275
|
-
this.clockStatus.set(agentId, 'clocked_out');
|
|
276
|
-
|
|
277
|
-
const record = await this.recordClockEvent(agentId, orgId, 'clock_out', triggeredBy, undefined, reason);
|
|
278
|
-
|
|
279
|
-
// Enforce off-hours action based on schedule
|
|
280
|
-
if (schedule) {
|
|
281
|
-
switch (schedule.offHoursAction) {
|
|
282
|
-
case 'pause':
|
|
283
|
-
if (this.guardrails) {
|
|
284
|
-
await this.guardrails.pauseAgent(agentId, reason || 'Clock-out: agent paused', triggeredBy);
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
287
|
-
case 'stop':
|
|
288
|
-
if (this.lifecycle) {
|
|
289
|
-
await this.lifecycle.stop(agentId, triggeredBy, reason || 'Clock-out: agent stopped').catch(() => {});
|
|
290
|
-
}
|
|
291
|
-
break;
|
|
292
|
-
case 'queue':
|
|
293
|
-
// Just mark status — don't interrupt the agent
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
this.emitEvent('clock_out', { agentId, triggeredBy, reason, record });
|
|
299
|
-
return record;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Get the current clock status of an agent.
|
|
304
|
-
* Returns 'no_schedule' if the agent has no work schedule.
|
|
305
|
-
*/
|
|
306
|
-
getClockStatus(agentId: string): 'clocked_in' | 'clocked_out' | 'no_schedule' {
|
|
307
|
-
if (!this.schedules.has(agentId)) return 'no_schedule';
|
|
308
|
-
return this.clockStatus.get(agentId) || 'clocked_out';
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Returns true if the agent has a schedule AND is clocked out.
|
|
313
|
-
* Returns false if no schedule exists (no restrictions apply).
|
|
314
|
-
* Queried by the guardrails status endpoint.
|
|
315
|
-
*/
|
|
316
|
-
isOffDuty(agentId: string): boolean {
|
|
317
|
-
if (!this.schedules.has(agentId)) return false;
|
|
318
|
-
return this.clockStatus.get(agentId) === 'clocked_out';
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Check if an agent should be working RIGHT NOW based on their schedule.
|
|
323
|
-
* Returns { onDuty, schedule, reason } — does not depend on clock status,
|
|
324
|
-
* only the schedule definition.
|
|
325
|
-
*/
|
|
326
|
-
shouldBeWorking(agentId: string): { onDuty: boolean; schedule: WorkSchedule | null; reason: string } {
|
|
327
|
-
const schedule = this.schedules.get(agentId);
|
|
328
|
-
if (!schedule || !schedule.enabled) {
|
|
329
|
-
return { onDuty: true, schedule: null, reason: 'No schedule defined — always on' };
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// Get current time in the agent's timezone
|
|
333
|
-
const tz = schedule.timezone || 'UTC';
|
|
334
|
-
const localNow = this.toTimezone(new Date(), tz);
|
|
335
|
-
const within = this.isWithinWorkingHours(schedule, localNow);
|
|
336
|
-
|
|
337
|
-
if (within) {
|
|
338
|
-
return { onDuty: true, schedule, reason: 'Within scheduled work hours' };
|
|
339
|
-
} else {
|
|
340
|
-
const dayOfWeek = localNow.getDay();
|
|
341
|
-
const timeStr = `${String(localNow.getHours()).padStart(2, '0')}:${String(localNow.getMinutes()).padStart(2, '0')}`;
|
|
342
|
-
return { onDuty: false, schedule, reason: `Off duty (${tz}: ${timeStr}, day ${dayOfWeek})` };
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Get the manager email for an agent (for bypass checks)
|
|
348
|
-
*/
|
|
349
|
-
getManagerEmail(agentId: string): string {
|
|
350
|
-
const agent = this.lifecycle?.getAgent(agentId);
|
|
351
|
-
if (!agent) return '';
|
|
352
|
-
const config = agent.config || {};
|
|
353
|
-
return (config as any).managerEmail
|
|
354
|
-
|| ((config as any).manager?.type === 'external' ? (config as any).manager?.email : '')
|
|
355
|
-
|| '';
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// ─── Task Queue ──────────────────────────────────────
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Add a task to the agent's queue.
|
|
362
|
-
*/
|
|
363
|
-
async addTask(task: Omit<QueuedTask, 'id' | 'createdAt' | 'updatedAt'>): Promise<QueuedTask> {
|
|
364
|
-
const now = new Date().toISOString();
|
|
365
|
-
const queued: QueuedTask = {
|
|
366
|
-
...task,
|
|
367
|
-
id: crypto.randomUUID(),
|
|
368
|
-
createdAt: now,
|
|
369
|
-
updatedAt: now,
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
if (this.engineDb) {
|
|
373
|
-
await this.engineDb.execute(
|
|
374
|
-
`INSERT INTO task_queue (id, agent_id, org_id, type, title, description, context, priority, status, source, scheduled_for, started_at, completed_at, created_at, updated_at)
|
|
375
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
376
|
-
[
|
|
377
|
-
queued.id, queued.agentId, queued.orgId, queued.type,
|
|
378
|
-
queued.title, queued.description || null, JSON.stringify(queued.context),
|
|
379
|
-
queued.priority, queued.status, queued.source,
|
|
380
|
-
queued.scheduledFor || null, queued.startedAt || null,
|
|
381
|
-
queued.completedAt || null, queued.createdAt, queued.updatedAt,
|
|
382
|
-
]
|
|
383
|
-
).catch((err) => { console.error('[workforce] Failed to persist task:', err); });
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
this.emitEvent('task_added', { task: queued });
|
|
387
|
-
return queued;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Get tasks for an agent, optionally filtered by status.
|
|
392
|
-
* Ordered by priority (urgent first) then creation time (oldest first).
|
|
393
|
-
*/
|
|
394
|
-
async getAgentTasks(agentId: string, status?: QueuedTask['status']): Promise<QueuedTask[]> {
|
|
395
|
-
if (!this.engineDb) return [];
|
|
396
|
-
|
|
397
|
-
const priorityOrder = "CASE priority WHEN 'urgent' THEN 0 WHEN 'high' THEN 1 WHEN 'normal' THEN 2 WHEN 'low' THEN 3 END";
|
|
398
|
-
let sql = `SELECT * FROM task_queue WHERE agent_id = ?`;
|
|
399
|
-
const params: any[] = [agentId];
|
|
400
|
-
|
|
401
|
-
if (status) {
|
|
402
|
-
sql += ` AND status = ?`;
|
|
403
|
-
params.push(status);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
sql += ` ORDER BY ${priorityOrder} ASC, created_at ASC`;
|
|
407
|
-
|
|
408
|
-
try {
|
|
409
|
-
const rows = await this.engineDb.query<any>(sql, params);
|
|
410
|
-
return rows.map((r: any) => this.rowToTask(r));
|
|
411
|
-
} catch {
|
|
412
|
-
return [];
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Update fields on a queued task.
|
|
418
|
-
*/
|
|
419
|
-
async updateTask(taskId: string, updates: Partial<Pick<QueuedTask, 'status' | 'startedAt' | 'completedAt' | 'priority'>>): Promise<void> {
|
|
420
|
-
if (!this.engineDb) return;
|
|
421
|
-
|
|
422
|
-
const sets: string[] = [];
|
|
423
|
-
const params: any[] = [];
|
|
424
|
-
|
|
425
|
-
if (updates.status !== undefined) {
|
|
426
|
-
sets.push('status = ?');
|
|
427
|
-
params.push(updates.status);
|
|
428
|
-
}
|
|
429
|
-
if (updates.startedAt !== undefined) {
|
|
430
|
-
sets.push('started_at = ?');
|
|
431
|
-
params.push(updates.startedAt);
|
|
432
|
-
}
|
|
433
|
-
if (updates.completedAt !== undefined) {
|
|
434
|
-
sets.push('completed_at = ?');
|
|
435
|
-
params.push(updates.completedAt);
|
|
436
|
-
}
|
|
437
|
-
if (updates.priority !== undefined) {
|
|
438
|
-
sets.push('priority = ?');
|
|
439
|
-
params.push(updates.priority);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
sets.push('updated_at = ?');
|
|
443
|
-
params.push(new Date().toISOString());
|
|
444
|
-
params.push(taskId);
|
|
445
|
-
|
|
446
|
-
await this.engineDb.execute(
|
|
447
|
-
`UPDATE task_queue SET ${sets.join(', ')} WHERE id = ?`,
|
|
448
|
-
params
|
|
449
|
-
).catch((err) => { console.error('[workforce] Failed to update task:', err); });
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Save the agent's current work context as a 'continue' task.
|
|
454
|
-
* Used at clock-out to preserve work state for the next session.
|
|
455
|
-
*/
|
|
456
|
-
async saveTaskState(agentId: string, context: Record<string, any>): Promise<QueuedTask> {
|
|
457
|
-
const schedule = this.schedules.get(agentId);
|
|
458
|
-
const orgId = schedule?.orgId || 'default';
|
|
459
|
-
|
|
460
|
-
return this.addTask({
|
|
461
|
-
agentId,
|
|
462
|
-
orgId,
|
|
463
|
-
type: 'continue',
|
|
464
|
-
title: 'Continue previous work session',
|
|
465
|
-
description: 'Auto-saved work state from clock-out',
|
|
466
|
-
context,
|
|
467
|
-
priority: 'normal',
|
|
468
|
-
status: 'queued',
|
|
469
|
-
source: 'workforce-scheduler',
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// ─── Scheduler ───────────────────────────────────────
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Start the scheduler loop — runs every 60 seconds.
|
|
477
|
-
*/
|
|
478
|
-
startScheduler(): void {
|
|
479
|
-
this.stopScheduler();
|
|
480
|
-
this.schedulerTick().catch((err) => { console.error('[workforce] Scheduler tick error:', err); });
|
|
481
|
-
this.schedulerInterval = setInterval(() => {
|
|
482
|
-
this.schedulerTick().catch((err) => { console.error('[workforce] Scheduler tick error:', err); });
|
|
483
|
-
}, 60_000);
|
|
484
|
-
|
|
485
|
-
// Sync Gmail vacation responder state on startup (delayed to allow tokens to load)
|
|
486
|
-
setTimeout(() => this.syncVacationState().catch(() => {}), 15_000);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Sync Gmail vacation auto-responder with current clock status.
|
|
491
|
-
* Called on startup to ensure responder matches actual work hours state.
|
|
492
|
-
*/
|
|
493
|
-
private async syncVacationState(): Promise<void> {
|
|
494
|
-
for (const schedule of this.schedules.values()) {
|
|
495
|
-
if (!schedule.enabled) continue;
|
|
496
|
-
const status = this.clockStatus.get(schedule.agentId);
|
|
497
|
-
const isOffDuty = status === 'clocked_out';
|
|
498
|
-
try {
|
|
499
|
-
await this.setGmailVacation(schedule.agentId, isOffDuty, isOffDuty ? schedule : undefined);
|
|
500
|
-
} catch (e: any) {
|
|
501
|
-
// Silent — not all agents may have Gmail
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Stop the scheduler loop.
|
|
508
|
-
*/
|
|
509
|
-
stopScheduler(): void {
|
|
510
|
-
if (this.schedulerInterval) {
|
|
511
|
-
clearInterval(this.schedulerInterval);
|
|
512
|
-
this.schedulerInterval = undefined;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Core automation loop — runs every minute.
|
|
518
|
-
* Checks schedules and auto-clocks agents in/out as needed.
|
|
519
|
-
*/
|
|
520
|
-
private async schedulerTick(): Promise<void> {
|
|
521
|
-
const now = new Date();
|
|
522
|
-
|
|
523
|
-
// Reset counters as needed
|
|
524
|
-
this.checkAndResetCounters(now);
|
|
525
|
-
|
|
526
|
-
// Process each enabled schedule
|
|
527
|
-
for (const schedule of this.schedules.values()) {
|
|
528
|
-
if (!schedule.enabled) continue;
|
|
529
|
-
|
|
530
|
-
try {
|
|
531
|
-
const localNow = this.toTimezone(now, schedule.timezone);
|
|
532
|
-
const shouldBeWorking = this.isWithinWorkingHours(schedule, localNow);
|
|
533
|
-
const currentStatus = this.clockStatus.get(schedule.agentId);
|
|
534
|
-
|
|
535
|
-
if (shouldBeWorking && currentStatus === 'clocked_out' && schedule.autoWakeEnabled) {
|
|
536
|
-
await this.autoClockIn(schedule.agentId, schedule);
|
|
537
|
-
} else if (!shouldBeWorking && currentStatus === 'clocked_in' && schedule.enforceClockOut) {
|
|
538
|
-
await this.autoClockOut(schedule.agentId, schedule);
|
|
539
|
-
}
|
|
540
|
-
} catch (err) {
|
|
541
|
-
console.error(`[workforce] Scheduler error for agent ${schedule.agentId}:`, err);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Automatically clock an agent in at the start of their work hours.
|
|
548
|
-
*/
|
|
549
|
-
private async autoClockIn(agentId: string, schedule: WorkSchedule): Promise<void> {
|
|
550
|
-
// Record the auto-wake clock event
|
|
551
|
-
await this.recordClockEvent(agentId, schedule.orgId, 'auto_wake', 'workforce-scheduler');
|
|
552
|
-
|
|
553
|
-
this.clockStatus.set(agentId, 'clocked_in');
|
|
554
|
-
|
|
555
|
-
// Resume agent via guardrails
|
|
556
|
-
if (this.guardrails) {
|
|
557
|
-
try {
|
|
558
|
-
await this.guardrails.resumeAgent(
|
|
559
|
-
agentId,
|
|
560
|
-
'Scheduled clock-in: start of work hours',
|
|
561
|
-
'workforce-scheduler'
|
|
562
|
-
);
|
|
563
|
-
} catch { /* agent may not be paused */ }
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// Check for pending tasks and notify via lifecycle event
|
|
567
|
-
try {
|
|
568
|
-
const pendingTasks = await this.getAgentTasks(agentId, 'queued');
|
|
569
|
-
if (pendingTasks.length > 0) {
|
|
570
|
-
this.emitEvent('tasks_pending', {
|
|
571
|
-
agentId,
|
|
572
|
-
count: pendingTasks.length,
|
|
573
|
-
tasks: pendingTasks.slice(0, 5).map(t => ({ id: t.id, title: t.title, priority: t.priority })),
|
|
574
|
-
message: `${pendingTasks.length} task(s) waiting in queue from previous session`,
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
} catch { /* best effort */ }
|
|
578
|
-
|
|
579
|
-
this.emitEvent('auto_clock_in', { agentId, schedule: schedule.id });
|
|
580
|
-
|
|
581
|
-
// Disable Gmail vacation auto-responder (agent is back on duty)
|
|
582
|
-
await this.setGmailVacation(agentId, false).catch(e =>
|
|
583
|
-
console.warn(`[workforce] ${agentId}: failed to disable vacation responder: ${e.message}`)
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Automatically clock an agent out at the end of their work hours.
|
|
589
|
-
*/
|
|
590
|
-
private async autoClockOut(agentId: string, schedule: WorkSchedule): Promise<void> {
|
|
591
|
-
const eventType = schedule.offHoursAction === 'pause' ? 'auto_pause' : 'clock_out';
|
|
592
|
-
await this.recordClockEvent(agentId, schedule.orgId, eventType, 'workforce-scheduler');
|
|
593
|
-
|
|
594
|
-
this.clockStatus.set(agentId, 'clocked_out');
|
|
595
|
-
|
|
596
|
-
switch (schedule.offHoursAction) {
|
|
597
|
-
case 'pause':
|
|
598
|
-
if (this.guardrails) {
|
|
599
|
-
try {
|
|
600
|
-
await this.guardrails.pauseAgent(
|
|
601
|
-
agentId,
|
|
602
|
-
'Scheduled clock-out: end of work hours',
|
|
603
|
-
'workforce-scheduler'
|
|
604
|
-
);
|
|
605
|
-
} catch { /* best effort */ }
|
|
606
|
-
}
|
|
607
|
-
break;
|
|
608
|
-
case 'stop':
|
|
609
|
-
if (this.lifecycle) {
|
|
610
|
-
await this.lifecycle.stop(agentId, 'workforce-scheduler', 'End of work hours').catch(() => {});
|
|
611
|
-
}
|
|
612
|
-
break;
|
|
613
|
-
case 'queue':
|
|
614
|
-
// Don't interrupt — just mark the status
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
this.emitEvent('auto_clock_out', { agentId, schedule: schedule.id, action: schedule.offHoursAction });
|
|
619
|
-
|
|
620
|
-
// Enable Gmail vacation auto-responder (agent is off duty)
|
|
621
|
-
await this.setGmailVacation(agentId, true, schedule).catch(e =>
|
|
622
|
-
console.warn(`[workforce] ${agentId}: failed to enable vacation responder: ${e.message}`)
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Check if daily/weekly/monthly/annual counters need resetting.
|
|
628
|
-
* Deduplicates resets using date keys.
|
|
629
|
-
*/
|
|
630
|
-
private checkAndResetCounters(now: Date): void {
|
|
631
|
-
const dateKey = now.toISOString().slice(0, 10);
|
|
632
|
-
const dayOfWeek = now.getUTCDay();
|
|
633
|
-
const dayOfMonth = now.getUTCDate();
|
|
634
|
-
const month = now.getUTCMonth();
|
|
635
|
-
|
|
636
|
-
if (dateKey !== this.lastDailyReset) {
|
|
637
|
-
this.lastDailyReset = dateKey;
|
|
638
|
-
this.lifecycle?.resetDailyCounters();
|
|
639
|
-
}
|
|
640
|
-
if (dayOfWeek === 1 && dateKey !== this.lastWeeklyReset) {
|
|
641
|
-
this.lastWeeklyReset = dateKey;
|
|
642
|
-
this.lifecycle?.resetWeeklyCounters();
|
|
643
|
-
}
|
|
644
|
-
if (dayOfMonth === 1 && dateKey !== this.lastMonthlyReset) {
|
|
645
|
-
this.lastMonthlyReset = dateKey;
|
|
646
|
-
this.lifecycle?.resetMonthlyCounters();
|
|
647
|
-
}
|
|
648
|
-
if (month === 0 && dayOfMonth === 1 && dateKey !== this.lastAnnualReset) {
|
|
649
|
-
this.lastAnnualReset = dateKey;
|
|
650
|
-
this.lifecycle?.resetAnnualCounters();
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
// ─── Working Hours Logic ─────────────────────────────
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Determine if the current local time falls within a schedule's working hours.
|
|
658
|
-
* Checks custom rules first, then standard/shift configuration.
|
|
659
|
-
*/
|
|
660
|
-
private isWithinWorkingHours(schedule: WorkSchedule, localNow: Date): boolean {
|
|
661
|
-
const dayOfWeek = localNow.getDay(); // 0=Sun
|
|
662
|
-
const hours = localNow.getHours();
|
|
663
|
-
const minutes = localNow.getMinutes();
|
|
664
|
-
const timeStr = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
|
|
665
|
-
const dateStr = `${localNow.getFullYear()}-${String(localNow.getMonth() + 1).padStart(2, '0')}-${String(localNow.getDate()).padStart(2, '0')}`;
|
|
666
|
-
|
|
667
|
-
// 1. Check custom rules first — they override everything
|
|
668
|
-
if (schedule.config.customRules) {
|
|
669
|
-
const todayRule = schedule.config.customRules.find(r => r.date === dateStr);
|
|
670
|
-
if (todayRule) {
|
|
671
|
-
if (todayRule.type === 'off') return false;
|
|
672
|
-
if (todayRule.type === 'working') {
|
|
673
|
-
if (todayRule.start && todayRule.end) {
|
|
674
|
-
return timeStr >= todayRule.start && timeStr < todayRule.end;
|
|
675
|
-
}
|
|
676
|
-
return true; // Working day with no time restriction
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// 2. Standard schedule
|
|
682
|
-
if (schedule.scheduleType === 'standard' && schedule.config.standardHours) {
|
|
683
|
-
const { start, end, daysOfWeek } = schedule.config.standardHours;
|
|
684
|
-
if (!daysOfWeek.includes(dayOfWeek)) return false;
|
|
685
|
-
|
|
686
|
-
const grace = schedule.gracePeriodMinutes;
|
|
687
|
-
const effectiveStart = this.subtractMinutes(start, grace);
|
|
688
|
-
const effectiveEnd = this.addMinutes(end, grace);
|
|
689
|
-
|
|
690
|
-
return timeStr >= effectiveStart && timeStr < effectiveEnd;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
// 3. Shift schedule
|
|
694
|
-
if (schedule.scheduleType === 'shift' && schedule.config.shifts) {
|
|
695
|
-
for (const shift of schedule.config.shifts) {
|
|
696
|
-
if (!shift.daysOfWeek.includes(dayOfWeek)) continue;
|
|
697
|
-
|
|
698
|
-
const grace = schedule.gracePeriodMinutes;
|
|
699
|
-
const effectiveStart = this.subtractMinutes(shift.start, grace);
|
|
700
|
-
const effectiveEnd = this.addMinutes(shift.end, grace);
|
|
701
|
-
|
|
702
|
-
// Handle overnight shifts (e.g. 22:00 → 06:00)
|
|
703
|
-
if (effectiveStart > effectiveEnd) {
|
|
704
|
-
// Overnight: either after start OR before end
|
|
705
|
-
if (timeStr >= effectiveStart || timeStr < effectiveEnd) return true;
|
|
706
|
-
} else {
|
|
707
|
-
if (timeStr >= effectiveStart && timeStr < effectiveEnd) return true;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
return false;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// Default: no restrictions — agent can work any time
|
|
714
|
-
return true;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// ─── Clock Records ───────────────────────────────────
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* Persist a clock event to the database and return the record.
|
|
721
|
-
*/
|
|
722
|
-
private async recordClockEvent(
|
|
723
|
-
agentId: string,
|
|
724
|
-
orgId: string,
|
|
725
|
-
type: ClockRecord['type'],
|
|
726
|
-
triggeredBy: string,
|
|
727
|
-
scheduledAt?: string,
|
|
728
|
-
reason?: string,
|
|
729
|
-
): Promise<ClockRecord> {
|
|
730
|
-
const now = new Date().toISOString();
|
|
731
|
-
const record: ClockRecord = {
|
|
732
|
-
id: crypto.randomUUID(),
|
|
733
|
-
agentId,
|
|
734
|
-
orgId,
|
|
735
|
-
type,
|
|
736
|
-
triggeredBy,
|
|
737
|
-
scheduledAt,
|
|
738
|
-
actualAt: now,
|
|
739
|
-
reason,
|
|
740
|
-
metadata: {},
|
|
741
|
-
createdAt: now,
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
if (this.engineDb) {
|
|
745
|
-
await this.engineDb.execute(
|
|
746
|
-
`INSERT INTO clock_records (id, agent_id, org_id, type, triggered_by, scheduled_at, actual_at, reason, metadata, created_at)
|
|
747
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
748
|
-
[
|
|
749
|
-
record.id, record.agentId, record.orgId, record.type,
|
|
750
|
-
record.triggeredBy, record.scheduledAt || null, record.actualAt,
|
|
751
|
-
record.reason || null, JSON.stringify(record.metadata), record.createdAt,
|
|
752
|
-
]
|
|
753
|
-
).catch((err) => { console.error('[workforce] Failed to persist clock record:', err); });
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
return record;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* Query clock records with optional filters.
|
|
761
|
-
*/
|
|
762
|
-
async getClockRecords(opts?: {
|
|
763
|
-
agentId?: string;
|
|
764
|
-
orgId?: string;
|
|
765
|
-
limit?: number;
|
|
766
|
-
since?: string;
|
|
767
|
-
}): Promise<ClockRecord[]> {
|
|
768
|
-
if (!this.engineDb) return [];
|
|
769
|
-
|
|
770
|
-
let sql = 'SELECT * FROM clock_records WHERE 1=1';
|
|
771
|
-
const params: any[] = [];
|
|
772
|
-
|
|
773
|
-
if (opts?.agentId) {
|
|
774
|
-
sql += ' AND agent_id = ?';
|
|
775
|
-
params.push(opts.agentId);
|
|
776
|
-
}
|
|
777
|
-
if (opts?.orgId) {
|
|
778
|
-
sql += ' AND org_id = ?';
|
|
779
|
-
params.push(opts.orgId);
|
|
780
|
-
}
|
|
781
|
-
if (opts?.since) {
|
|
782
|
-
sql += ' AND created_at >= ?';
|
|
783
|
-
params.push(opts.since);
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
sql += ' ORDER BY created_at DESC';
|
|
787
|
-
sql += ` LIMIT ?`;
|
|
788
|
-
params.push(opts?.limit || 100);
|
|
789
|
-
|
|
790
|
-
try {
|
|
791
|
-
const rows = await this.engineDb.query<any>(sql, params);
|
|
792
|
-
return rows.map((r: any) => ({
|
|
793
|
-
id: r.id,
|
|
794
|
-
agentId: r.agent_id,
|
|
795
|
-
orgId: r.org_id,
|
|
796
|
-
type: r.type,
|
|
797
|
-
triggeredBy: r.triggered_by,
|
|
798
|
-
scheduledAt: r.scheduled_at || undefined,
|
|
799
|
-
actualAt: r.actual_at,
|
|
800
|
-
reason: r.reason || undefined,
|
|
801
|
-
metadata: typeof r.metadata === 'string' ? JSON.parse(r.metadata) : (r.metadata || {}),
|
|
802
|
-
createdAt: r.created_at,
|
|
803
|
-
}));
|
|
804
|
-
} catch {
|
|
805
|
-
return [];
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
// ─── Workforce Status ────────────────────────────────
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* Build a complete workforce status report for an organization.
|
|
813
|
-
*/
|
|
814
|
-
async getWorkforceStatus(orgId: string): Promise<WorkforceStatus> {
|
|
815
|
-
const agents: WorkforceStatus['agents'] = [];
|
|
816
|
-
let totalClocked = 0;
|
|
817
|
-
let totalOff = 0;
|
|
818
|
-
let totalUnscheduled = 0;
|
|
819
|
-
|
|
820
|
-
for (const schedule of this.schedules.values()) {
|
|
821
|
-
if (schedule.orgId !== orgId) continue;
|
|
822
|
-
|
|
823
|
-
const status = this.getClockStatus(schedule.agentId);
|
|
824
|
-
let queuedTasks = 0;
|
|
825
|
-
|
|
826
|
-
// Count queued tasks from DB
|
|
827
|
-
if (this.engineDb) {
|
|
828
|
-
try {
|
|
829
|
-
const countRows = await this.engineDb.query<any>(
|
|
830
|
-
"SELECT COUNT(*) as cnt FROM task_queue WHERE agent_id = ? AND status = 'queued'",
|
|
831
|
-
[schedule.agentId]
|
|
832
|
-
);
|
|
833
|
-
queuedTasks = countRows[0]?.cnt || 0;
|
|
834
|
-
} catch { /* best effort */ }
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// Compute next event
|
|
838
|
-
const nextEvent = this.computeNextEvent(schedule);
|
|
839
|
-
|
|
840
|
-
agents.push({
|
|
841
|
-
id: schedule.agentId,
|
|
842
|
-
name: schedule.agentId, // Name resolved externally
|
|
843
|
-
clockStatus: status,
|
|
844
|
-
schedule,
|
|
845
|
-
nextEvent,
|
|
846
|
-
queuedTasks,
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
if (status === 'clocked_in') totalClocked++;
|
|
850
|
-
else if (status === 'clocked_out') totalOff++;
|
|
851
|
-
else totalUnscheduled++;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
return { agents, totalClocked, totalOff, totalUnscheduled };
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
* Compute the next clock event for a schedule based on current status.
|
|
859
|
-
*/
|
|
860
|
-
private computeNextEvent(schedule: WorkSchedule): { type: string; at: string } | undefined {
|
|
861
|
-
const now = new Date();
|
|
862
|
-
const localNow = this.toTimezone(now, schedule.timezone);
|
|
863
|
-
const currentStatus = this.clockStatus.get(schedule.agentId);
|
|
864
|
-
|
|
865
|
-
if (schedule.scheduleType === 'standard' && schedule.config.standardHours) {
|
|
866
|
-
const { start, end, daysOfWeek } = schedule.config.standardHours;
|
|
867
|
-
const today = localNow.getDay();
|
|
868
|
-
|
|
869
|
-
if (currentStatus === 'clocked_in') {
|
|
870
|
-
// Next event is clock-out at end time today
|
|
871
|
-
return { type: 'clock_out', at: this.nextOccurrence(localNow, end, [today]) };
|
|
872
|
-
} else {
|
|
873
|
-
// Next event is clock-in at start time on next working day
|
|
874
|
-
const nextDay = this.findNextWorkingDay(localNow, daysOfWeek);
|
|
875
|
-
return { type: 'clock_in', at: this.nextOccurrence(localNow, start, [nextDay]) };
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
if (schedule.scheduleType === 'shift' && schedule.config.shifts?.length) {
|
|
880
|
-
const shift = schedule.config.shifts[0]; // Use first shift for next event
|
|
881
|
-
if (currentStatus === 'clocked_in') {
|
|
882
|
-
return { type: 'clock_out', at: this.nextOccurrence(localNow, shift.end, shift.daysOfWeek) };
|
|
883
|
-
} else {
|
|
884
|
-
return { type: 'clock_in', at: this.nextOccurrence(localNow, shift.start, shift.daysOfWeek) };
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
return undefined;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* Find the next occurrence of a time on a valid working day.
|
|
893
|
-
*/
|
|
894
|
-
private nextOccurrence(localNow: Date, time: string, daysOfWeek: number[]): string {
|
|
895
|
-
const [h, m] = time.split(':').map(Number);
|
|
896
|
-
const candidate = new Date(localNow);
|
|
897
|
-
candidate.setHours(h, m, 0, 0);
|
|
898
|
-
|
|
899
|
-
// If today's time is in the past or today isn't a working day, advance
|
|
900
|
-
if (candidate <= localNow || !daysOfWeek.includes(candidate.getDay())) {
|
|
901
|
-
candidate.setDate(candidate.getDate() + 1);
|
|
902
|
-
candidate.setHours(h, m, 0, 0);
|
|
903
|
-
while (!daysOfWeek.includes(candidate.getDay())) {
|
|
904
|
-
candidate.setDate(candidate.getDate() + 1);
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
return candidate.toISOString();
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
/**
|
|
912
|
-
* Find the next day that falls on a working day.
|
|
913
|
-
*/
|
|
914
|
-
private findNextWorkingDay(localNow: Date, daysOfWeek: number[]): number {
|
|
915
|
-
let day = localNow.getDay();
|
|
916
|
-
for (let i = 0; i < 7; i++) {
|
|
917
|
-
const check = (day + i) % 7;
|
|
918
|
-
if (daysOfWeek.includes(check)) {
|
|
919
|
-
// If it's today, check if the working hours haven't started yet
|
|
920
|
-
if (i === 0) return check;
|
|
921
|
-
return check;
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
return day; // Fallback
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
// ─── Events ──────────────────────────────────────────
|
|
928
|
-
|
|
929
|
-
/**
|
|
930
|
-
* Subscribe to workforce events. Returns an unsubscribe function.
|
|
931
|
-
*/
|
|
932
|
-
onEvent(listener: (event: any) => void): () => void {
|
|
933
|
-
this.eventListeners.push(listener);
|
|
934
|
-
return () => {
|
|
935
|
-
const idx = this.eventListeners.indexOf(listener);
|
|
936
|
-
if (idx >= 0) this.eventListeners.splice(idx, 1);
|
|
937
|
-
};
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
* Emit a workforce event to all registered listeners.
|
|
942
|
-
*/
|
|
943
|
-
private emitEvent(type: string, data: Record<string, any>): void {
|
|
944
|
-
const event = {
|
|
945
|
-
type,
|
|
946
|
-
timestamp: new Date().toISOString(),
|
|
947
|
-
...data,
|
|
948
|
-
};
|
|
949
|
-
for (const listener of this.eventListeners) {
|
|
950
|
-
try {
|
|
951
|
-
listener(event);
|
|
952
|
-
} catch { /* don't let listener errors break the manager */ }
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
// ─── Lifecycle ───────────────────────────────────────
|
|
957
|
-
|
|
958
|
-
/**
|
|
959
|
-
* Shut down the workforce manager — stop scheduler and clear state.
|
|
960
|
-
*/
|
|
961
|
-
shutdown(): void {
|
|
962
|
-
this.stopScheduler();
|
|
963
|
-
if (this.schedulerInterval) {
|
|
964
|
-
clearInterval(this.schedulerInterval);
|
|
965
|
-
this.schedulerInterval = undefined;
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
// ─── Time Utilities ──────────────────────────────────
|
|
970
|
-
|
|
971
|
-
// ─── Gmail Vacation Auto-Responder ─────────────────
|
|
972
|
-
|
|
973
|
-
/**
|
|
974
|
-
* Toggle Gmail vacation (out-of-office) auto-responder for an agent.
|
|
975
|
-
* Uses the Gmail API `users.settings.updateVacation` endpoint.
|
|
976
|
-
*
|
|
977
|
-
* When enabled, Gmail automatically replies to incoming emails with an
|
|
978
|
-
* out-of-office message. The responder only sends one reply per sender
|
|
979
|
-
* per 4 days (Gmail's built-in rate limiting).
|
|
980
|
-
*
|
|
981
|
-
* restrictToContacts=false ensures ALL senders get the auto-reply.
|
|
982
|
-
* Manager emails still get through to the agent via the poller bypass,
|
|
983
|
-
* but they'll also receive the auto-reply from Gmail (acceptable trade-off).
|
|
984
|
-
*/
|
|
985
|
-
private async setGmailVacation(agentId: string, enable: boolean, schedule?: WorkSchedule): Promise<void> {
|
|
986
|
-
// Get agent's email config for OAuth token
|
|
987
|
-
const agent = this.lifecycle?.getAgent(agentId);
|
|
988
|
-
if (!agent) return;
|
|
989
|
-
|
|
990
|
-
const emailConfig = agent.config?.emailConfig;
|
|
991
|
-
if (!emailConfig?.oauthRefreshToken || emailConfig.provider !== 'google') return;
|
|
992
|
-
|
|
993
|
-
// Refresh the access token
|
|
994
|
-
const tokenRes = await fetch('https://oauth2.googleapis.com/token', {
|
|
995
|
-
method: 'POST',
|
|
996
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
997
|
-
body: new URLSearchParams({
|
|
998
|
-
client_id: emailConfig.oauthClientId,
|
|
999
|
-
client_secret: emailConfig.oauthClientSecret,
|
|
1000
|
-
refresh_token: emailConfig.oauthRefreshToken,
|
|
1001
|
-
grant_type: 'refresh_token',
|
|
1002
|
-
}),
|
|
1003
|
-
});
|
|
1004
|
-
const tokenData = await tokenRes.json() as any;
|
|
1005
|
-
if (!tokenData.access_token) throw new Error('Token refresh failed');
|
|
1006
|
-
|
|
1007
|
-
const accessToken = tokenData.access_token;
|
|
1008
|
-
const agentName = agent.config?.displayName || agent.config?.name || 'Agent';
|
|
1009
|
-
|
|
1010
|
-
// Build vacation settings
|
|
1011
|
-
let body: Record<string, any>;
|
|
1012
|
-
if (enable) {
|
|
1013
|
-
// Calculate next start time from schedule
|
|
1014
|
-
const tz = schedule?.timezone || 'UTC';
|
|
1015
|
-
const nextStart = this.getNextWorkStart(schedule);
|
|
1016
|
-
|
|
1017
|
-
const responseSubject = `Out of Office - ${agentName}`;
|
|
1018
|
-
const responseBody = [
|
|
1019
|
-
`Hi,\n`,
|
|
1020
|
-
`Thank you for your email. I'm currently outside of my working hours and will respond when I'm back.`,
|
|
1021
|
-
schedule ? `\nMy regular working hours are ${this.formatScheduleHours(schedule)} (${tz}).` : '',
|
|
1022
|
-
nextStart ? `\nI expect to be back ${nextStart}.` : '',
|
|
1023
|
-
`\nIf this is urgent, please reach out to my manager directly.`,
|
|
1024
|
-
`\nBest regards,\n${agentName}`,
|
|
1025
|
-
].filter(Boolean).join('\n');
|
|
1026
|
-
|
|
1027
|
-
body = {
|
|
1028
|
-
enableAutoReply: true,
|
|
1029
|
-
responseSubject,
|
|
1030
|
-
responseBodyPlainText: responseBody,
|
|
1031
|
-
restrictToContacts: false,
|
|
1032
|
-
restrictToDomain: false,
|
|
1033
|
-
};
|
|
1034
|
-
} else {
|
|
1035
|
-
body = {
|
|
1036
|
-
enableAutoReply: false,
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
// Call Gmail API
|
|
1041
|
-
const res = await fetch('https://gmail.googleapis.com/gmail/v1/users/me/settings/vacation', {
|
|
1042
|
-
method: 'PUT',
|
|
1043
|
-
headers: {
|
|
1044
|
-
Authorization: `Bearer ${accessToken}`,
|
|
1045
|
-
'Content-Type': 'application/json',
|
|
1046
|
-
},
|
|
1047
|
-
body: JSON.stringify(body),
|
|
1048
|
-
});
|
|
1049
|
-
|
|
1050
|
-
if (!res.ok) {
|
|
1051
|
-
const text = await res.text().catch(() => '');
|
|
1052
|
-
throw new Error(`Gmail API ${res.status}: ${text.slice(0, 200)}`);
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
console.log(`[workforce] ${agentName}: vacation auto-responder ${enable ? 'ENABLED' : 'DISABLED'}`);
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
/**
|
|
1059
|
-
* Get a human-readable description of the next work start time.
|
|
1060
|
-
*/
|
|
1061
|
-
private getNextWorkStart(schedule?: WorkSchedule): string {
|
|
1062
|
-
if (!schedule) return '';
|
|
1063
|
-
|
|
1064
|
-
const tz = schedule.timezone || 'UTC';
|
|
1065
|
-
const now = this.toTimezone(new Date(), tz);
|
|
1066
|
-
const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
1067
|
-
|
|
1068
|
-
if (schedule.scheduleType === 'standard' && schedule.config.standardHours) {
|
|
1069
|
-
const { start, daysOfWeek } = schedule.config.standardHours;
|
|
1070
|
-
// Find next working day
|
|
1071
|
-
for (let d = 0; d <= 7; d++) {
|
|
1072
|
-
const checkDay = (now.getDay() + d) % 7;
|
|
1073
|
-
if (daysOfWeek.includes(checkDay)) {
|
|
1074
|
-
if (d === 0 && `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}` < start) {
|
|
1075
|
-
return `today at ${start} ${tz}`;
|
|
1076
|
-
}
|
|
1077
|
-
if (d === 0) continue; // Already past start time today
|
|
1078
|
-
if (d === 1) return `tomorrow at ${start} ${tz}`;
|
|
1079
|
-
return `${dayNames[checkDay]} at ${start} ${tz}`;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
if (schedule.scheduleType === 'shift' && schedule.config.shifts?.length) {
|
|
1085
|
-
const firstShift = schedule.config.shifts[0];
|
|
1086
|
-
return `next shift at ${firstShift.start} ${tz}`;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
return '';
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
/**
|
|
1093
|
-
* Format schedule hours for the vacation message.
|
|
1094
|
-
*/
|
|
1095
|
-
private formatScheduleHours(schedule: WorkSchedule): string {
|
|
1096
|
-
if (schedule.scheduleType === 'standard' && schedule.config.standardHours) {
|
|
1097
|
-
const { start, end, daysOfWeek } = schedule.config.standardHours;
|
|
1098
|
-
const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
1099
|
-
const days = daysOfWeek.map(d => dayNames[d]).join(', ');
|
|
1100
|
-
return `${start} - ${end}, ${days}`;
|
|
1101
|
-
}
|
|
1102
|
-
if (schedule.scheduleType === 'shift' && schedule.config.shifts?.length) {
|
|
1103
|
-
return schedule.config.shifts.map(s => `${s.name}: ${s.start}-${s.end}`).join(', ');
|
|
1104
|
-
}
|
|
1105
|
-
return 'variable hours';
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
/**
|
|
1109
|
-
* Convert a Date to a specific timezone.
|
|
1110
|
-
*/
|
|
1111
|
-
private toTimezone(date: Date, timezone: string): Date {
|
|
1112
|
-
const str = date.toLocaleString('en-US', { timeZone: timezone });
|
|
1113
|
-
return new Date(str);
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* Add minutes to a time string (HH:MM) and return the new time string.
|
|
1118
|
-
* Wraps around midnight.
|
|
1119
|
-
*/
|
|
1120
|
-
private addMinutes(time: string, minutes: number): string {
|
|
1121
|
-
const [h, m] = time.split(':').map(Number);
|
|
1122
|
-
const total = h * 60 + m + minutes;
|
|
1123
|
-
return `${String(Math.floor(total / 60) % 24).padStart(2, '0')}:${String(total % 60).padStart(2, '0')}`;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
/**
|
|
1127
|
-
* Subtract minutes from a time string (HH:MM) and return the new time string.
|
|
1128
|
-
* Wraps around midnight.
|
|
1129
|
-
*/
|
|
1130
|
-
private subtractMinutes(time: string, minutes: number): string {
|
|
1131
|
-
const [h, m] = time.split(':').map(Number);
|
|
1132
|
-
let total = h * 60 + m - minutes;
|
|
1133
|
-
if (total < 0) total += 1440;
|
|
1134
|
-
return `${String(Math.floor(total / 60) % 24).padStart(2, '0')}:${String(total % 60).padStart(2, '0')}`;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
// ─── Row Mappers ─────────────────────────────────────
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* Map a database row to a QueuedTask.
|
|
1141
|
-
*/
|
|
1142
|
-
private rowToTask(r: any): QueuedTask {
|
|
1143
|
-
return {
|
|
1144
|
-
id: r.id,
|
|
1145
|
-
agentId: r.agent_id,
|
|
1146
|
-
orgId: r.org_id,
|
|
1147
|
-
type: r.type,
|
|
1148
|
-
title: r.title,
|
|
1149
|
-
description: r.description || undefined,
|
|
1150
|
-
context: typeof r.context === 'string' ? JSON.parse(r.context) : (r.context || {}),
|
|
1151
|
-
priority: r.priority,
|
|
1152
|
-
status: r.status,
|
|
1153
|
-
source: r.source,
|
|
1154
|
-
scheduledFor: r.scheduled_for || undefined,
|
|
1155
|
-
startedAt: r.started_at || undefined,
|
|
1156
|
-
completedAt: r.completed_at || undefined,
|
|
1157
|
-
createdAt: r.created_at,
|
|
1158
|
-
updatedAt: r.updated_at,
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
}
|