@agent-native/dispatch 0.13.13 → 0.14.1

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.
Files changed (74) hide show
  1. package/dist/actions/delete-destination.d.ts +12 -12
  2. package/dist/actions/navigate.js +1 -1
  3. package/dist/actions/navigate.js.map +1 -1
  4. package/dist/actions/provider-api-audit.d.ts +7 -0
  5. package/dist/actions/provider-api-audit.d.ts.map +1 -0
  6. package/dist/actions/provider-api-audit.js +74 -0
  7. package/dist/actions/provider-api-audit.js.map +1 -0
  8. package/dist/actions/provider-api-catalog.d.ts +1 -1
  9. package/dist/actions/provider-api-request.js +10 -0
  10. package/dist/actions/provider-api-request.js.map +1 -1
  11. package/dist/actions/send-platform-message.d.ts +1 -0
  12. package/dist/actions/send-platform-message.js +43 -22
  13. package/dist/actions/send-platform-message.js.map +1 -1
  14. package/dist/actions/view-screen.js +9 -0
  15. package/dist/actions/view-screen.js.map +1 -1
  16. package/dist/components/layout/Layout.d.ts.map +1 -1
  17. package/dist/components/layout/Layout.js +75 -70
  18. package/dist/components/layout/Layout.js.map +1 -1
  19. package/dist/components/messaging-setup-panel.d.ts.map +1 -1
  20. package/dist/components/messaging-setup-panel.js +203 -127
  21. package/dist/components/messaging-setup-panel.js.map +1 -1
  22. package/dist/routes/index.d.ts.map +1 -1
  23. package/dist/routes/index.js +1 -0
  24. package/dist/routes/index.js.map +1 -1
  25. package/dist/routes/pages/messaging.js +1 -1
  26. package/dist/routes/pages/messaging.js.map +1 -1
  27. package/dist/routes/pages/operations.d.ts +5 -0
  28. package/dist/routes/pages/operations.d.ts.map +1 -0
  29. package/dist/routes/pages/operations.js +51 -0
  30. package/dist/routes/pages/operations.js.map +1 -0
  31. package/dist/routes/pages/overview.d.ts +2 -2
  32. package/dist/server/lib/dispatch-integrations.d.ts +7 -1
  33. package/dist/server/lib/dispatch-integrations.d.ts.map +1 -1
  34. package/dist/server/lib/dispatch-integrations.js +178 -8
  35. package/dist/server/lib/dispatch-integrations.js.map +1 -1
  36. package/dist/server/lib/dispatch-routing.d.ts +6 -0
  37. package/dist/server/lib/dispatch-routing.d.ts.map +1 -0
  38. package/dist/server/lib/dispatch-routing.js +30 -0
  39. package/dist/server/lib/dispatch-routing.js.map +1 -0
  40. package/dist/server/lib/env-config.d.ts.map +1 -1
  41. package/dist/server/lib/env-config.js +50 -0
  42. package/dist/server/lib/env-config.js.map +1 -1
  43. package/dist/server/lib/onboarding-steps.d.ts.map +1 -1
  44. package/dist/server/lib/onboarding-steps.js +25 -0
  45. package/dist/server/lib/onboarding-steps.js.map +1 -1
  46. package/dist/server/lib/provider-api.d.ts +2 -2
  47. package/dist/server/lib/provider-api.d.ts.map +1 -1
  48. package/dist/server/plugins/integrations.d.ts.map +1 -1
  49. package/dist/server/plugins/integrations.js +5 -2
  50. package/dist/server/plugins/integrations.js.map +1 -1
  51. package/package.json +2 -2
  52. package/src/actions/navigate.ts +1 -1
  53. package/src/actions/provider-api-audit.spec.ts +52 -0
  54. package/src/actions/provider-api-audit.ts +88 -0
  55. package/src/actions/provider-api-request.ts +10 -0
  56. package/src/actions/send-platform-message.spec.ts +108 -0
  57. package/src/actions/send-platform-message.ts +73 -25
  58. package/src/actions/view-screen.ts +11 -0
  59. package/src/components/layout/Layout.spec.tsx +154 -0
  60. package/src/components/layout/Layout.tsx +196 -189
  61. package/src/components/messaging-setup-panel.spec.tsx +191 -0
  62. package/src/components/messaging-setup-panel.tsx +472 -193
  63. package/src/routes/index.spec.ts +23 -0
  64. package/src/routes/index.ts +1 -0
  65. package/src/routes/pages/messaging.tsx +1 -1
  66. package/src/routes/pages/operations.tsx +134 -0
  67. package/src/server/lib/dispatch-integrations.spec.ts +113 -0
  68. package/src/server/lib/dispatch-integrations.ts +239 -6
  69. package/src/server/lib/dispatch-routing.spec.ts +44 -0
  70. package/src/server/lib/dispatch-routing.ts +42 -0
  71. package/src/server/lib/env-config.ts +50 -0
  72. package/src/server/lib/onboarding-steps.ts +32 -0
  73. package/src/server/plugins/integrations.ts +5 -2
  74. package/src/styles/dispatch-css.spec.ts +11 -0
@@ -1,7 +1,7 @@
1
1
  import { createIntegrationsPlugin } from "@agent-native/core/server";
2
2
  import { dispatchActions } from "../../actions/index.js";
3
3
  import { getDispatchConfig } from "../index.js";
4
- import { beforeDispatchProcess, resolveDispatchOwner, } from "../lib/dispatch-integrations.js";
4
+ import { beforeDispatchProcess, resolveDispatchExecutionContext, } from "../lib/dispatch-integrations.js";
5
5
  const dispatchIntegrationActions = {
6
6
  ...dispatchActions,
7
7
  // Messaging integrations should use the core call-agent tool for cross-app
@@ -26,6 +26,9 @@ Default posture:
26
26
 
27
27
  When a user asks for something:
28
28
  - If it belongs to analytics, content, slides, clips, assets, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.
29
+ - Synthetic uptime, health-check, and URL-availability monitors belong to Analytics, even when the monitored target is another app such as Clips. Delegate creation to Analytics and relay its exact monitor URL. Dispatch-native recurring jobs are for reminders, digests, and agent workflows, not HTTP uptime probes.
30
+ - Route by the requested artifact type, not by organization-specific names stored in code. For structured records, databases, tables, queues, boards, and intake forms, resolve the owning app and canonical destination from loaded workspace instructions/resources plus discovered app capabilities; do not assume Content, a database ID, schema, owner, or required fields. Visual designs, mockups, wireframes, screens, and interfaces belong to Design. A trusted Required target agent hint in integration context is authoritative.
31
+ - When delegating structured intake to the resolved owning app, preserve the exact Source thread URL and the workspace instruction context, inspect the destination's current required fields, ask only for missing values, submit once, verify the saved record, and return the exact link.
29
32
  - In messaging integrations, use call-agent for cross-app delegation; do not use ask_app.
30
33
  - After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.
31
34
  - Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.
@@ -53,7 +56,7 @@ const dispatchIntegrationsPlugin = async (nitroApp) => {
53
56
  const plugin = createIntegrationsPlugin({
54
57
  appId: "dispatch",
55
58
  actions: dispatchIntegrationActions,
56
- resolveOwner: resolveDispatchOwner,
59
+ resolveExecutionContext: resolveDispatchExecutionContext,
57
60
  beforeProcess: beforeDispatchProcess,
58
61
  systemPrompt,
59
62
  // Inherit the framework default (claude-sonnet-4-6 from
@@ -1 +1 @@
1
- {"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,0BAA0B,GAAG;IACjC,GAAG,eAAe;IAClB,2EAA2E;IAC3E,6EAA6E;IAC7E,6EAA6E;IAC7E,OAAO,EAAE;QACP,GAAG,eAAe,CAAC,OAAO;QAC1B,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AAEF,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;4FAwBiD,CAAC;AAE7F;;;;GAIG;AACH,MAAM,0BAA0B,GAAG,KAAK,EAAE,QAAa,EAAE,EAAE;IACzD,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,CAAC;IACjD,MAAM,YAAY,GAChB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,OAAO,cAAc,KAAK,UAAU;YACpC,CAAC,CAAC,cAAc,CAAC,kCAAkC,CAAC;YACpD,CAAC,CAAC,kCAAkC,CAAC;IAE3C,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,KAAK,EAAE,UAAU;QACjB,OAAO,EAAE,0BAA0B;QACnC,YAAY,EAAE,oBAAoB;QAClC,aAAa,EAAE,qBAAqB;QACpC,YAAY;QACZ,wDAAwD;QACxD,yEAAyE;QACzE,+DAA+D;QAC/D,6EAA6E;KAC9E,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,0BAA0B,CAAC","sourcesContent":["import { createIntegrationsPlugin } from \"@agent-native/core/server\";\n\nimport { dispatchActions } from \"../../actions/index.js\";\nimport { getDispatchConfig } from \"../index.js\";\nimport {\n beforeDispatchProcess,\n resolveDispatchOwner,\n} from \"../lib/dispatch-integrations.js\";\n\nconst dispatchIntegrationActions = {\n ...dispatchActions,\n // Messaging integrations should use the core call-agent tool for cross-app\n // delegation because it queues A2A continuations when serverless budgets are\n // tight. The MCP-facing ask_app action is still available outside this path.\n ask_app: {\n ...dispatchActions.ask_app,\n agentTool: false,\n },\n};\n\nconst DISPATCH_INTEGRATION_SYSTEM_PROMPT = `You are the central dispatch for this workspace, responding via a messaging platform integration (Slack, Telegram, email, etc.).\n\nDefault posture:\n- Treat Slack, Telegram, and email as shared entrypoints into the workspace.\n- Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), forms (form builder), clips (screen recordings), design (visual designs), and assets (brand libraries plus generated images/videos).\n- Use the available-apps prompt context first, then list-connected-agents when you need fresh details, to see what agents are available before assuming a request must be handled locally.\n- When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.\n- Treat first-party apps such as Mail, Calendar, Analytics, Brain, Assets, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.\n- Integration grants are not provider capability limits. For ad hoc provider inspection, querying, reporting, or troubleshooting, call provider-api-catalog/provider-api-docs, then provider-api-request against the provider's real HTTP API. Use connectionId for a specific shared grant and accountId for a specific OAuth account. Never expose secret values or silently widen app access while doing this.\n- Keep durable memory and operating instructions in resources rather than ephemeral chat.\n- Reply in the originating thread unless the user explicitly asks you to send to a saved destination.\n\nWhen a user asks for something:\n- If it belongs to analytics, content, slides, clips, assets, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.\n- In messaging integrations, use call-agent for cross-app delegation; do not use ask_app.\n- After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.\n- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.\n- If the user asks to create, build, make, scaffold, or generate an \"agent\" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.\n- If a new-app prompt asks for access to Mail, Calendar, Analytics, Brain, Assets, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.\n- If the chat template is used, treat it as scaffolding only: the finished app must be branded as the requested app with its own home screen/navigation/package metadata/manifest, and must not leave visible \"Chat\", \"Starter\", \"Blank app\", or \"New app\" UI behind.\n- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description by default. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/chat or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode \"builder\", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists with name/displayName and description so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode \"local-agent\", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode \"coming-soon\", say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like; do not send them to Builder org/beta settings. If it returns mode \"builder-unavailable\", report the action's message exactly enough to preserve the missing identity/credential detail.\n- For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.\n- Keep responses concise and operational — messaging platforms have character limits.\n- Use markdown sparingly (bold and lists are fine, avoid complex formatting).\n- If a task requires many steps, summarize what you did rather than streaming every detail.`;\n\n/**\n * Defer plugin construction until the Nitro plugin actually fires so the\n * config-aware system prompt resolves AFTER `setupDispatch(config)` has\n * stamped the active config (plugin module load order is not guaranteed).\n */\nconst dispatchIntegrationsPlugin = async (nitroApp: any) => {\n const { integrations = {} } = getDispatchConfig();\n const promptOverride = integrations.systemPrompt;\n const systemPrompt =\n typeof promptOverride === \"string\"\n ? promptOverride\n : typeof promptOverride === \"function\"\n ? promptOverride(DISPATCH_INTEGRATION_SYSTEM_PROMPT)\n : DISPATCH_INTEGRATION_SYSTEM_PROMPT;\n\n const plugin = createIntegrationsPlugin({\n appId: \"dispatch\",\n actions: dispatchIntegrationActions,\n resolveOwner: resolveDispatchOwner,\n beforeProcess: beforeDispatchProcess,\n systemPrompt,\n // Inherit the framework default (claude-sonnet-4-6 from\n // packages/core/src/integrations/plugin.ts). Haiku was tried for latency\n // but hallucinated URLs/IDs after delegated call-agent results\n // (e.g. inventing `https://slides.workspace.com/deck/builder-io-deck-2024`).\n });\n\n return plugin(nitroApp);\n};\n\nexport default dispatchIntegrationsPlugin;\n"]}
1
+ {"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,iCAAiC,CAAC;AAEzC,MAAM,0BAA0B,GAAG;IACjC,GAAG,eAAe;IAClB,2EAA2E;IAC3E,6EAA6E;IAC7E,6EAA6E;IAC7E,OAAO,EAAE;QACP,GAAG,eAAe,CAAC,OAAO;QAC1B,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AAEF,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;4FA2BiD,CAAC;AAE7F;;;;GAIG;AACH,MAAM,0BAA0B,GAAG,KAAK,EAAE,QAAa,EAAE,EAAE;IACzD,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,CAAC;IACjD,MAAM,YAAY,GAChB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,OAAO,cAAc,KAAK,UAAU;YACpC,CAAC,CAAC,cAAc,CAAC,kCAAkC,CAAC;YACpD,CAAC,CAAC,kCAAkC,CAAC;IAE3C,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,KAAK,EAAE,UAAU;QACjB,OAAO,EAAE,0BAA0B;QACnC,uBAAuB,EAAE,+BAA+B;QACxD,aAAa,EAAE,qBAAqB;QACpC,YAAY;QACZ,wDAAwD;QACxD,yEAAyE;QACzE,+DAA+D;QAC/D,6EAA6E;KAC9E,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,0BAA0B,CAAC","sourcesContent":["import { createIntegrationsPlugin } from \"@agent-native/core/server\";\n\nimport { dispatchActions } from \"../../actions/index.js\";\nimport { getDispatchConfig } from \"../index.js\";\nimport {\n beforeDispatchProcess,\n resolveDispatchExecutionContext,\n} from \"../lib/dispatch-integrations.js\";\n\nconst dispatchIntegrationActions = {\n ...dispatchActions,\n // Messaging integrations should use the core call-agent tool for cross-app\n // delegation because it queues A2A continuations when serverless budgets are\n // tight. The MCP-facing ask_app action is still available outside this path.\n ask_app: {\n ...dispatchActions.ask_app,\n agentTool: false,\n },\n};\n\nconst DISPATCH_INTEGRATION_SYSTEM_PROMPT = `You are the central dispatch for this workspace, responding via a messaging platform integration (Slack, Telegram, email, etc.).\n\nDefault posture:\n- Treat Slack, Telegram, and email as shared entrypoints into the workspace.\n- Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), forms (form builder), clips (screen recordings), design (visual designs), and assets (brand libraries plus generated images/videos).\n- Use the available-apps prompt context first, then list-connected-agents when you need fresh details, to see what agents are available before assuming a request must be handled locally.\n- When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.\n- Treat first-party apps such as Mail, Calendar, Analytics, Brain, Assets, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.\n- Integration grants are not provider capability limits. For ad hoc provider inspection, querying, reporting, or troubleshooting, call provider-api-catalog/provider-api-docs, then provider-api-request against the provider's real HTTP API. Use connectionId for a specific shared grant and accountId for a specific OAuth account. Never expose secret values or silently widen app access while doing this.\n- Keep durable memory and operating instructions in resources rather than ephemeral chat.\n- Reply in the originating thread unless the user explicitly asks you to send to a saved destination.\n\nWhen a user asks for something:\n- If it belongs to analytics, content, slides, clips, assets, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.\n- Synthetic uptime, health-check, and URL-availability monitors belong to Analytics, even when the monitored target is another app such as Clips. Delegate creation to Analytics and relay its exact monitor URL. Dispatch-native recurring jobs are for reminders, digests, and agent workflows, not HTTP uptime probes.\n- Route by the requested artifact type, not by organization-specific names stored in code. For structured records, databases, tables, queues, boards, and intake forms, resolve the owning app and canonical destination from loaded workspace instructions/resources plus discovered app capabilities; do not assume Content, a database ID, schema, owner, or required fields. Visual designs, mockups, wireframes, screens, and interfaces belong to Design. A trusted Required target agent hint in integration context is authoritative.\n- When delegating structured intake to the resolved owning app, preserve the exact Source thread URL and the workspace instruction context, inspect the destination's current required fields, ask only for missing values, submit once, verify the saved record, and return the exact link.\n- In messaging integrations, use call-agent for cross-app delegation; do not use ask_app.\n- After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.\n- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.\n- If the user asks to create, build, make, scaffold, or generate an \"agent\" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.\n- If a new-app prompt asks for access to Mail, Calendar, Analytics, Brain, Assets, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.\n- If the chat template is used, treat it as scaffolding only: the finished app must be branded as the requested app with its own home screen/navigation/package metadata/manifest, and must not leave visible \"Chat\", \"Starter\", \"Blank app\", or \"New app\" UI behind.\n- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description by default. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/chat or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode \"builder\", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists with name/displayName and description so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode \"local-agent\", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode \"coming-soon\", say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like; do not send them to Builder org/beta settings. If it returns mode \"builder-unavailable\", report the action's message exactly enough to preserve the missing identity/credential detail.\n- For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.\n- Keep responses concise and operational — messaging platforms have character limits.\n- Use markdown sparingly (bold and lists are fine, avoid complex formatting).\n- If a task requires many steps, summarize what you did rather than streaming every detail.`;\n\n/**\n * Defer plugin construction until the Nitro plugin actually fires so the\n * config-aware system prompt resolves AFTER `setupDispatch(config)` has\n * stamped the active config (plugin module load order is not guaranteed).\n */\nconst dispatchIntegrationsPlugin = async (nitroApp: any) => {\n const { integrations = {} } = getDispatchConfig();\n const promptOverride = integrations.systemPrompt;\n const systemPrompt =\n typeof promptOverride === \"string\"\n ? promptOverride\n : typeof promptOverride === \"function\"\n ? promptOverride(DISPATCH_INTEGRATION_SYSTEM_PROMPT)\n : DISPATCH_INTEGRATION_SYSTEM_PROMPT;\n\n const plugin = createIntegrationsPlugin({\n appId: \"dispatch\",\n actions: dispatchIntegrationActions,\n resolveExecutionContext: resolveDispatchExecutionContext,\n beforeProcess: beforeDispatchProcess,\n systemPrompt,\n // Inherit the framework default (claude-sonnet-4-6 from\n // packages/core/src/integrations/plugin.ts). Haiku was tried for latency\n // but hallucinated URLs/IDs after delegated call-agent results\n // (e.g. inventing `https://slides.workspace.com/deck/builder-io-deck-2024`).\n });\n\n return plugin(nitroApp);\n};\n\nexport default dispatchIntegrationsPlugin;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/dispatch",
3
- "version": "0.13.13",
3
+ "version": "0.14.1",
4
4
  "description": "Dispatch — workspace control plane for agent-native apps. Vault, integrations, destinations, scheduled jobs, and cross-app delegation, shipped as a single drop-in package.",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -94,7 +94,7 @@
94
94
  "typescript-7": "npm:typescript@^7.0.2",
95
95
  "vite": "8.1.0",
96
96
  "vitest": "^4.1.5",
97
- "@agent-native/core": "0.92.1"
97
+ "@agent-native/core": "0.94.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@agent-native/core": ">=0.8.0",
@@ -27,7 +27,7 @@ export default defineAction({
27
27
  .string()
28
28
  .optional()
29
29
  .describe(
30
- "Named dispatch view to navigate to. Built-in views include chat, overview, apps, metrics, new-app, vault, integrations, messaging, workspace, agents, destinations, identities, approvals, automations, audit, thread-debug, dreams, and team. Generated Dispatch extension tabs can also use their nav item id.",
30
+ "Named dispatch view to navigate to. Built-in views include chat, overview, apps, operations (or monitoring, observability, database), metrics, new-app, vault, integrations, messaging, workspace, agents, destinations, identities, approvals, automations, audit, thread-debug, dreams, and team. Generated Dispatch extension tabs can also use their nav item id.",
31
31
  ),
32
32
  path: z.string().optional().describe("URL path to navigate to"),
33
33
  threadId: z
@@ -0,0 +1,52 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import {
4
+ buildProviderApiAuditSummary,
5
+ sanitizeProviderApiAuditPath,
6
+ } from "./provider-api-audit.js";
7
+
8
+ describe("provider API audit summaries", () => {
9
+ it("redacts every query value from relative and absolute request paths", () => {
10
+ expect(
11
+ sanitizeProviderApiAuditPath(
12
+ "/v1/resources?api_key=secret-example&cursor=page-example",
13
+ ),
14
+ ).toBe("/v1/resources?api_key=[redacted]&cursor=[redacted]");
15
+ expect(
16
+ sanitizeProviderApiAuditPath(
17
+ "https://api.example.test/download?X-Amz-Signature=signed-example&part=1",
18
+ ),
19
+ ).toBe(
20
+ "https://api.example.test/download?X-Amz-Signature=[redacted]&part=[redacted]",
21
+ );
22
+ });
23
+
24
+ it("redacts credential-named and opaque path segments", () => {
25
+ expect(
26
+ sanitizeProviderApiAuditPath(
27
+ "/hooks/token/secret-example-value/callback/api_key=another-example",
28
+ ),
29
+ ).toBe("/hooks/token/[redacted]/callback/api_key=[redacted]");
30
+ expect(
31
+ sanitizeProviderApiAuditPath(
32
+ "/download/0123456789abcdef0123456789abcdef/file",
33
+ ),
34
+ ).toBe("/download/[redacted]/file");
35
+ });
36
+
37
+ it("drops fragments and keeps explicit query arguments out of summaries", () => {
38
+ const summary = buildProviderApiAuditSummary({
39
+ method: "get",
40
+ provider: "example",
41
+ path: "/records?filter=customer-example#secret-example-fragment",
42
+ query: { api_key: "query-secret-example" },
43
+ } as Parameters<typeof buildProviderApiAuditSummary>[0] & {
44
+ query: unknown;
45
+ });
46
+
47
+ expect(summary).toBe("GET example /records?filter=[redacted]");
48
+ expect(summary).not.toContain("customer-example");
49
+ expect(summary).not.toContain("secret-example");
50
+ expect(summary).not.toContain("query-secret-example");
51
+ });
52
+ });
@@ -0,0 +1,88 @@
1
+ const REDACTED = "[redacted]";
2
+
3
+ const CREDENTIAL_NAME =
4
+ /^(?:api[-_]?key|access[-_]?token|auth(?:orization)?|bearer|credential|password|secret|signature|sig|token|x-amz-credential|x-amz-signature)$/i;
5
+
6
+ function decodePathSegment(segment: string): string {
7
+ try {
8
+ return decodeURIComponent(segment);
9
+ } catch {
10
+ return segment;
11
+ }
12
+ }
13
+
14
+ function looksLikeCredentialValue(segment: string): boolean {
15
+ const value = decodePathSegment(segment);
16
+ if (/^eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value)) {
17
+ return true;
18
+ }
19
+ if (
20
+ /^(?:sk|pk|rk|ghp|github_pat|xox[baprs]|ya29|AIza)[-_][A-Za-z0-9_-]+$/i.test(
21
+ value,
22
+ )
23
+ ) {
24
+ return true;
25
+ }
26
+ return value.length >= 32 && /^[A-Za-z0-9._~-]+$/.test(value);
27
+ }
28
+
29
+ function sanitizePathname(pathname: string): string {
30
+ let redactNext = false;
31
+ return pathname
32
+ .split("/")
33
+ .map((segment) => {
34
+ if (!segment) return segment;
35
+ const decoded = decodePathSegment(segment);
36
+ if (redactNext) {
37
+ redactNext = false;
38
+ return REDACTED;
39
+ }
40
+
41
+ const assignment = decoded.match(/^([^=:]+)([=:])(.+)$/);
42
+ if (assignment && CREDENTIAL_NAME.test(assignment[1]!)) {
43
+ return `${assignment[1]}${assignment[2]}${REDACTED}`;
44
+ }
45
+ if (CREDENTIAL_NAME.test(decoded)) {
46
+ redactNext = true;
47
+ return segment;
48
+ }
49
+ return looksLikeCredentialValue(segment) ? REDACTED : segment;
50
+ })
51
+ .join("/");
52
+ }
53
+
54
+ function sanitizeQuery(search: string): string {
55
+ if (!search) return "";
56
+ const redacted = Array.from(new URLSearchParams(search).keys(), (key) => {
57
+ const safeKey = encodeURIComponent(key.slice(0, 100));
58
+ return `${safeKey}=${REDACTED}`;
59
+ });
60
+ return redacted.length > 0 ? `?${redacted.join("&")}` : "";
61
+ }
62
+
63
+ export function sanitizeProviderApiAuditPath(path: unknown): string {
64
+ const raw = String(path ?? "");
65
+ const withoutFragment = raw.split("#", 1)[0] ?? "";
66
+
67
+ try {
68
+ const url = new URL(withoutFragment);
69
+ return `${url.protocol}//${url.host}${sanitizePathname(url.pathname)}${sanitizeQuery(url.search)}`;
70
+ } catch {
71
+ const queryIndex = withoutFragment.indexOf("?");
72
+ const pathname =
73
+ queryIndex >= 0 ? withoutFragment.slice(0, queryIndex) : withoutFragment;
74
+ const search = queryIndex >= 0 ? withoutFragment.slice(queryIndex + 1) : "";
75
+ return `${sanitizePathname(pathname)}${sanitizeQuery(search)}`;
76
+ }
77
+ }
78
+
79
+ export function buildProviderApiAuditSummary(args: {
80
+ method?: unknown;
81
+ provider?: unknown;
82
+ path?: unknown;
83
+ }): string {
84
+ const method = String(args.method || "GET").toUpperCase();
85
+ const provider = String(args.provider ?? "");
86
+ const path = sanitizeProviderApiAuditPath(args.path);
87
+ return `${method} ${provider} ${path}`.slice(0, 200);
88
+ }
@@ -7,6 +7,7 @@ import {
7
7
  DISPATCH_APP_ID,
8
8
  executeProviderApiRequest,
9
9
  } from "../server/lib/provider-api.js";
10
+ import { buildProviderApiAuditSummary } from "./provider-api-audit.js";
10
11
 
11
12
  const MethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
12
13
 
@@ -197,6 +198,15 @@ export default defineAction({
197
198
  ),
198
199
  }),
199
200
  http: false,
201
+ audit: {
202
+ recordInputs: false,
203
+ target: (args) => ({
204
+ type: "provider-api",
205
+ id: String(args.provider),
206
+ visibility: "private",
207
+ }),
208
+ summary: (args) => buildProviderApiAuditSummary(args),
209
+ },
200
210
  run: async (args) => {
201
211
  if (args.stageAs) {
202
212
  const ctx = getCredentialContext();
@@ -0,0 +1,108 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ const mocks = vi.hoisted(() => ({
4
+ getInstallation: vi.fn(),
5
+ resolveTokenBundle: vi.fn(),
6
+ resolveSecret: vi.fn(),
7
+ sendMessageToTarget: vi.fn(),
8
+ getDestinationById: vi.fn(),
9
+ slackAdapter: vi.fn(),
10
+ }));
11
+
12
+ vi.mock("@agent-native/core/integrations", () => ({
13
+ listIntegrationInstallations: mocks.getInstallation,
14
+ resolveIntegrationTokenBundle: mocks.resolveTokenBundle,
15
+ }));
16
+
17
+ vi.mock("@agent-native/core/server", () => ({
18
+ getRequestUserEmail: () => "member@example.com",
19
+ getRequestOrgId: () => "org-a",
20
+ resolveSecret: mocks.resolveSecret,
21
+ isEmailConfigured: vi.fn(),
22
+ slackAdapter: mocks.slackAdapter,
23
+ telegramAdapter: vi.fn(),
24
+ emailAdapter: vi.fn(),
25
+ }));
26
+
27
+ vi.mock("../server/lib/dispatch-store.js", () => ({
28
+ getDestinationById: mocks.getDestinationById,
29
+ }));
30
+
31
+ const action = (await import("./send-platform-message.js")).default;
32
+
33
+ describe("send-platform-message tenant scoping", () => {
34
+ beforeEach(() => {
35
+ vi.clearAllMocks();
36
+ mocks.getDestinationById.mockResolvedValue(null);
37
+ mocks.resolveSecret.mockResolvedValue(null);
38
+ mocks.slackAdapter.mockImplementation(
39
+ (options: { resolveBotToken: () => Promise<string | undefined> }) => ({
40
+ formatAgentResponse: (text: string) => ({
41
+ text,
42
+ platformContext: {},
43
+ }),
44
+ sendMessageToTarget: async (...args: unknown[]) => {
45
+ expect(await options.resolveBotToken()).toBe("own-managed-token");
46
+ return mocks.sendMessageToTarget(...args);
47
+ },
48
+ }),
49
+ );
50
+ });
51
+
52
+ it("resolves and uses only the caller org's Slack installation", async () => {
53
+ mocks.getInstallation.mockResolvedValue([
54
+ {
55
+ id: "installation-a",
56
+ installationKey: "team:T1:app:A1",
57
+ teamId: "T1",
58
+ enterpriseId: null,
59
+ },
60
+ ]);
61
+ mocks.resolveTokenBundle.mockResolvedValue({
62
+ accessToken: "own-managed-token",
63
+ });
64
+
65
+ await action.run(
66
+ {
67
+ platform: "slack",
68
+ destination: "C1",
69
+ tenantId: "T1",
70
+ text: "hello",
71
+ },
72
+ {} as never,
73
+ );
74
+
75
+ expect(mocks.getInstallation).toHaveBeenCalledWith(
76
+ {
77
+ userEmail: "member@example.com",
78
+ orgId: "org-a",
79
+ },
80
+ "slack",
81
+ );
82
+ expect(mocks.resolveTokenBundle).toHaveBeenCalledWith(
83
+ "slack",
84
+ "team:T1:app:A1",
85
+ );
86
+ expect(mocks.sendMessageToTarget).toHaveBeenCalledOnce();
87
+ });
88
+
89
+ it("does not use another org's managed installation", async () => {
90
+ mocks.getInstallation.mockResolvedValue([]);
91
+
92
+ await expect(
93
+ action.run(
94
+ {
95
+ platform: "slack",
96
+ destination: "C1",
97
+ tenantId: "T-other",
98
+ text: "hello",
99
+ },
100
+ {} as never,
101
+ ),
102
+ ).rejects.toThrow("That Slack workspace is not connected");
103
+
104
+ expect(mocks.resolveTokenBundle).not.toHaveBeenCalled();
105
+ expect(mocks.slackAdapter).not.toHaveBeenCalled();
106
+ expect(mocks.sendMessageToTarget).not.toHaveBeenCalled();
107
+ });
108
+ });
@@ -1,5 +1,11 @@
1
1
  import { defineAction } from "@agent-native/core";
2
2
  import {
3
+ listIntegrationInstallations,
4
+ resolveIntegrationTokenBundle,
5
+ } from "@agent-native/core/integrations";
6
+ import {
7
+ getRequestOrgId,
8
+ getRequestUserEmail,
3
9
  slackAdapter,
4
10
  telegramAdapter,
5
11
  emailAdapter,
@@ -8,21 +14,52 @@ import {
8
14
  } from "@agent-native/core/server";
9
15
  import { z } from "zod";
10
16
 
11
- import {
12
- getDestinationById,
13
- recordAudit,
14
- } from "../server/lib/dispatch-store.js";
17
+ import { getDestinationById } from "../server/lib/dispatch-store.js";
15
18
 
16
- function getAdapter(platform: "slack" | "telegram" | "email") {
19
+ function getAdapter(
20
+ platform: "slack" | "telegram" | "email",
21
+ slackToken?: string,
22
+ ) {
17
23
  if (platform === "email") return emailAdapter();
18
- return platform === "slack" ? slackAdapter() : telegramAdapter();
24
+ return platform === "slack"
25
+ ? slackAdapter({ resolveBotToken: async () => slackToken })
26
+ : telegramAdapter();
19
27
  }
20
28
 
21
29
  async function assertOutboundConfigured(
22
30
  platform: "slack" | "telegram" | "email",
23
- ) {
24
- if (platform === "slack" && !(await resolveSecret("SLACK_BOT_TOKEN"))) {
25
- throw new Error("Slack outbound messaging is not configured");
31
+ tenantId?: string,
32
+ ): Promise<string | undefined> {
33
+ if (platform === "slack") {
34
+ const userEmail = getRequestUserEmail();
35
+ if (!userEmail) throw new Error("An authenticated user is required");
36
+ const installations = tenantId
37
+ ? await listIntegrationInstallations(
38
+ { userEmail, orgId: getRequestOrgId() ?? null },
39
+ "slack",
40
+ )
41
+ : [];
42
+ const installation =
43
+ installations.find(
44
+ (candidate) =>
45
+ candidate.teamId === tenantId || candidate.enterpriseId === tenantId,
46
+ ) ?? null;
47
+ const managed = installation
48
+ ? await resolveIntegrationTokenBundle(
49
+ "slack",
50
+ installation.installationKey,
51
+ )
52
+ : null;
53
+ const token =
54
+ managed?.accessToken ?? (await resolveSecret("SLACK_BOT_TOKEN"));
55
+ if (!token) {
56
+ throw new Error(
57
+ tenantId
58
+ ? "That Slack workspace is not connected"
59
+ : "Select a Slack workspace for managed outbound messaging",
60
+ );
61
+ }
62
+ return token;
26
63
  }
27
64
  if (platform === "telegram" && !(await resolveSecret("TELEGRAM_BOT_TOKEN"))) {
28
65
  throw new Error("Telegram outbound messaging is not configured");
@@ -45,9 +82,29 @@ export default defineAction({
45
82
  destinationId: z.string().optional().describe("Saved destination id"),
46
83
  destination: z.string().optional().describe("Raw platform destination id"),
47
84
  threadRef: z.string().optional().describe("Optional thread reference"),
85
+ tenantId: z
86
+ .string()
87
+ .optional()
88
+ .describe("Slack workspace/team id for managed installations"),
48
89
  text: z.string().describe("Message to send"),
49
90
  }),
50
- run: async ({ platform, destinationId, destination, threadRef, text }) => {
91
+ audit: {
92
+ recordInputs: false,
93
+ target: (args) => ({
94
+ type: "destination",
95
+ id: args.destinationId || args.destination || "unknown",
96
+ visibility: "private",
97
+ }),
98
+ summary: (args) => `Sent proactive ${args.platform || "saved"} message`,
99
+ },
100
+ run: async ({
101
+ platform,
102
+ destinationId,
103
+ destination,
104
+ threadRef,
105
+ tenantId,
106
+ text,
107
+ }) => {
51
108
  const saved = destinationId
52
109
  ? await getDestinationById(destinationId)
53
110
  : null;
@@ -63,9 +120,12 @@ export default defineAction({
63
120
  throw new Error("A platform and destination are required");
64
121
  }
65
122
 
66
- await assertOutboundConfigured(resolvedPlatform);
123
+ const slackToken = await assertOutboundConfigured(
124
+ resolvedPlatform,
125
+ tenantId,
126
+ );
67
127
 
68
- const adapter = getAdapter(resolvedPlatform);
128
+ const adapter = getAdapter(resolvedPlatform, slackToken);
69
129
  if (!adapter.sendMessageToTarget) {
70
130
  throw new Error(
71
131
  `Platform ${resolvedPlatform} does not support proactive outbound messaging`,
@@ -76,19 +136,7 @@ export default defineAction({
76
136
  destination: resolvedDestination,
77
137
  threadRef: resolvedThreadRef,
78
138
  label: saved?.name || undefined,
79
- });
80
-
81
- await recordAudit({
82
- action: "message.sent",
83
- targetType: "destination",
84
- targetId: destinationId || resolvedDestination,
85
- summary: `Sent proactive ${resolvedPlatform} message${saved?.name ? ` to ${saved.name}` : ""}`,
86
- metadata: {
87
- platform: resolvedPlatform,
88
- destination: resolvedDestination,
89
- threadRef: resolvedThreadRef,
90
- text,
91
- },
139
+ tenantId,
92
140
  });
93
141
 
94
142
  return {
@@ -90,6 +90,17 @@ export default defineAction({
90
90
  screen.connectedAgents = connectedAgents;
91
91
  screen.mcpAppAccess = mcpAccess;
92
92
  }
93
+ if (navigation?.view === "operations") {
94
+ const nav = navigation as { operationsView?: string };
95
+ screen.operatorConsole = {
96
+ view: nav.operationsView === "database" ? "database" : "monitoring",
97
+ monitoring:
98
+ "The shared observability dashboard provides traces, conversations, evaluations, experiments, and feedback.",
99
+ database:
100
+ "The shared database admin is available in Code mode for table browsing and SQL inspection.",
101
+ relatedTools: ["thread-debug", "audit", "destinations", "automations"],
102
+ };
103
+ }
93
104
  if (
94
105
  navigation?.view === "overview" ||
95
106
  navigation?.view === "metrics" ||