@agent-native/dispatch 0.43.0-nightly-20261120212328 → 0.43.7
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/CHANGELOG.md +194 -174
- package/dist/actions/ask_app.d.ts +3 -0
- package/dist/actions/ask_app.js +7 -2
- package/dist/actions/ask_app.js.map +1 -1
- package/dist/actions/ask_app_status.d.ts +3 -0
- package/dist/actions/ask_app_status.js +5 -1
- package/dist/actions/ask_app_status.js.map +1 -1
- package/dist/actions/call_app_action.d.ts +1 -0
- package/dist/actions/call_app_action.js +21 -5
- package/dist/actions/call_app_action.js.map +1 -1
- package/dist/actions/create_embed_session.d.ts +3 -2
- package/dist/actions/create_embed_session.js +4 -2
- package/dist/actions/create_embed_session.js.map +1 -1
- package/dist/actions/create_workspace_app_embed_session.d.ts +3 -2
- package/dist/actions/create_workspace_app_embed_session.js +3 -1
- package/dist/actions/create_workspace_app_embed_session.js.map +1 -1
- package/dist/actions/delete-destination.d.ts +12 -12
- package/dist/actions/execute-action-suggestion.d.ts +44 -0
- package/dist/actions/execute-action-suggestion.d.ts.map +1 -0
- package/dist/actions/execute-action-suggestion.js +148 -0
- package/dist/actions/execute-action-suggestion.js.map +1 -0
- package/dist/actions/import-agent.d.ts +13 -13
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +5 -1
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/list-connected-agents.js +3 -2
- package/dist/actions/list-connected-agents.js.map +1 -1
- package/dist/actions/list-workspace-connections.d.ts +1 -0
- package/dist/actions/list-workspace-connections.d.ts.map +1 -1
- package/dist/actions/list_app_actions.js +1 -1
- package/dist/actions/list_app_actions.js.map +1 -1
- package/dist/actions/list_apps.d.ts +2 -0
- package/dist/actions/list_apps.js +11 -3
- package/dist/actions/list_apps.js.map +1 -1
- package/dist/actions/navigate.js +1 -0
- package/dist/actions/navigate.js.map +1 -1
- package/dist/actions/open_app.d.ts +4 -0
- package/dist/actions/open_app.js +14 -6
- package/dist/actions/open_app.js.map +1 -1
- package/dist/actions/propose-action-suggestions.d.ts +45 -0
- package/dist/actions/propose-action-suggestions.d.ts.map +1 -0
- package/dist/actions/propose-action-suggestions.js +32 -0
- package/dist/actions/propose-action-suggestions.js.map +1 -0
- package/dist/actions/provider-api-register.d.ts +12 -12
- package/dist/actions/read_view.js +1 -1
- package/dist/actions/read_view.js.map +1 -1
- package/dist/actions/remember-pointer.js +1 -1
- package/dist/actions/remember-pointer.js.map +1 -1
- package/dist/actions/resolve-pointer.js +1 -1
- package/dist/actions/resolve-pointer.js.map +1 -1
- package/dist/actions/route-app-intent.d.ts +6 -0
- package/dist/actions/route-app-intent.js +79 -5
- package/dist/actions/route-app-intent.js.map +1 -1
- package/dist/actions/send-code-agent-remote-command.js +4 -0
- package/dist/actions/send-code-agent-remote-command.js.map +1 -1
- package/dist/actions/start-workspace-app-creation.js +1 -1
- package/dist/actions/start-workspace-app-creation.js.map +1 -1
- package/dist/actions/upsert-destination.d.ts +12 -12
- package/dist/actions/view-screen.d.ts +12 -1
- package/dist/actions/view-screen.js +53 -5
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/chat-action-suggestions.d.ts +8 -0
- package/dist/components/chat-action-suggestions.d.ts.map +1 -0
- package/dist/components/chat-action-suggestions.js +191 -0
- package/dist/components/chat-action-suggestions.js.map +1 -0
- package/dist/components/chat-home-apps.d.ts.map +1 -1
- package/dist/components/chat-home-apps.js +1 -1
- package/dist/components/chat-home-apps.js.map +1 -1
- package/dist/components/google-broker-settings-group.d.ts +2 -0
- package/dist/components/google-broker-settings-group.d.ts.map +1 -0
- package/dist/components/google-broker-settings-group.js +53 -0
- package/dist/components/google-broker-settings-group.js.map +1 -0
- package/dist/components/layout/Layout.d.ts +4 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +246 -69
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/messaging-setup-panel.d.ts.map +1 -1
- package/dist/components/messaging-setup-panel.js +47 -15
- package/dist/components/messaging-setup-panel.js.map +1 -1
- package/dist/components/workspace-app-host.d.ts +27 -4
- package/dist/components/workspace-app-host.d.ts.map +1 -1
- package/dist/components/workspace-app-host.js +355 -74
- package/dist/components/workspace-app-host.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/db/google-broker-admission.d.ts +36 -0
- package/dist/db/google-broker-admission.d.ts.map +1 -0
- package/dist/db/google-broker-admission.js +129 -0
- package/dist/db/google-broker-admission.js.map +1 -0
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +42 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/lib/action-suggestions.d.ts +20 -0
- package/dist/lib/action-suggestions.d.ts.map +1 -0
- package/dist/lib/action-suggestions.js +219 -0
- package/dist/lib/action-suggestions.js.map +1 -0
- package/dist/lib/chat-first-app-route.d.ts +11 -5
- package/dist/lib/chat-first-app-route.d.ts.map +1 -1
- package/dist/lib/chat-first-app-route.js +9 -5
- package/dist/lib/chat-first-app-route.js.map +1 -1
- package/dist/lib/chat-first-pane.d.ts +25 -1
- package/dist/lib/chat-first-pane.d.ts.map +1 -1
- package/dist/lib/chat-first-pane.js +67 -1
- package/dist/lib/chat-first-pane.js.map +1 -1
- package/dist/lib/data-intent.d.ts +3 -0
- package/dist/lib/data-intent.d.ts.map +1 -0
- package/dist/lib/data-intent.js +14 -0
- package/dist/lib/data-intent.js.map +1 -0
- package/dist/lib/dispatch-app-identity.d.ts +10 -0
- package/dist/lib/dispatch-app-identity.d.ts.map +1 -0
- package/dist/lib/dispatch-app-identity.js +18 -0
- package/dist/lib/dispatch-app-identity.js.map +1 -0
- package/dist/lib/other-apps.d.ts +15 -0
- package/dist/lib/other-apps.d.ts.map +1 -1
- package/dist/lib/other-apps.js +31 -0
- package/dist/lib/other-apps.js.map +1 -1
- package/dist/lib/workspace-app-frame-view.d.ts +15 -0
- package/dist/lib/workspace-app-frame-view.d.ts.map +1 -0
- package/dist/lib/workspace-app-frame-view.js +72 -0
- package/dist/lib/workspace-app-frame-view.js.map +1 -0
- package/dist/lib/workspace-apps.d.ts +5 -0
- package/dist/lib/workspace-apps.d.ts.map +1 -1
- package/dist/lib/workspace-apps.js +85 -23
- package/dist/lib/workspace-apps.js.map +1 -1
- package/dist/lib/workspace-apps.test.js +6 -0
- package/dist/lib/workspace-apps.test.js.map +1 -1
- package/dist/routes/pages/_index.d.ts +2 -2
- package/dist/routes/pages/chat.d.ts.map +1 -1
- package/dist/routes/pages/chat.js +33 -2
- package/dist/routes/pages/chat.js.map +1 -1
- package/dist/routes/pages/settings-page.d.ts +1 -1
- package/dist/routes/pages/settings-page.d.ts.map +1 -1
- package/dist/routes/pages/settings-page.js +3 -2
- package/dist/routes/pages/settings-page.js.map +1 -1
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/lib/action-suggestions.d.ts +41 -0
- package/dist/server/lib/action-suggestions.d.ts.map +1 -0
- package/dist/server/lib/action-suggestions.js +94 -0
- package/dist/server/lib/action-suggestions.js.map +1 -0
- package/dist/server/lib/app-action-result.d.ts +5 -0
- package/dist/server/lib/app-action-result.d.ts.map +1 -1
- package/dist/server/lib/app-action-result.js +7 -0
- package/dist/server/lib/app-action-result.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +63 -13
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/curated-workspace-templates.d.ts.map +1 -1
- package/dist/server/lib/curated-workspace-templates.js +3 -0
- package/dist/server/lib/curated-workspace-templates.js.map +1 -1
- package/dist/server/lib/dispatch-config.d.ts +5 -0
- package/dist/server/lib/dispatch-config.d.ts.map +1 -0
- package/dist/server/lib/dispatch-config.js +11 -0
- package/dist/server/lib/dispatch-config.js.map +1 -0
- package/dist/server/lib/dispatch-pane-context.d.ts +11 -0
- package/dist/server/lib/dispatch-pane-context.d.ts.map +1 -0
- package/dist/server/lib/dispatch-pane-context.js +35 -0
- package/dist/server/lib/dispatch-pane-context.js.map +1 -0
- package/dist/server/lib/google-broker-provider.d.ts +41 -0
- package/dist/server/lib/google-broker-provider.d.ts.map +1 -0
- package/dist/server/lib/google-broker-provider.js +96 -0
- package/dist/server/lib/google-broker-provider.js.map +1 -0
- package/dist/server/lib/google-broker-rpc.d.ts +26 -0
- package/dist/server/lib/google-broker-rpc.d.ts.map +1 -0
- package/dist/server/lib/google-broker-rpc.js +52 -0
- package/dist/server/lib/google-broker-rpc.js.map +1 -0
- package/dist/server/lib/hosted-apps-settings.d.ts.map +1 -1
- package/dist/server/lib/hosted-apps-settings.js +4 -0
- package/dist/server/lib/hosted-apps-settings.js.map +1 -1
- package/dist/server/lib/mcp-app-discovery.d.ts +17 -0
- package/dist/server/lib/mcp-app-discovery.d.ts.map +1 -0
- package/dist/server/lib/mcp-app-discovery.js +231 -0
- package/dist/server/lib/mcp-app-discovery.js.map +1 -0
- package/dist/server/lib/mcp-gateway.d.ts +64 -21
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +730 -88
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/dist/server/plugins/agent-chat.js +9 -7
- package/dist/server/plugins/agent-chat.js.map +1 -1
- package/dist/server/plugins/auth.d.ts.map +1 -1
- package/dist/server/plugins/auth.js +1 -0
- package/dist/server/plugins/auth.js.map +1 -1
- package/dist/server/plugins/db.d.ts.map +1 -1
- package/dist/server/plugins/db.js +0 -46
- package/dist/server/plugins/db.js.map +1 -1
- package/dist/server/plugins/integrations.d.ts.map +1 -1
- package/dist/server/plugins/integrations.js +4 -1
- package/dist/server/plugins/integrations.js.map +1 -1
- package/dist/shared/chat-first-pane.d.ts +24 -0
- package/dist/shared/chat-first-pane.d.ts.map +1 -1
- package/dist/shared/chat-first-pane.js +34 -0
- package/dist/shared/chat-first-pane.js.map +1 -1
- package/dist/shared/labs.d.ts +1 -0
- package/dist/shared/labs.d.ts.map +1 -1
- package/dist/shared/labs.js +7 -0
- package/dist/shared/labs.js.map +1 -1
- package/package.json +7 -6
- package/src/actions/action-suggestions.spec.ts +342 -0
- package/src/actions/app_actions.spec.ts +103 -0
- package/src/actions/ask_app.ts +9 -2
- package/src/actions/ask_app_status.ts +12 -1
- package/src/actions/call_app_action.ts +28 -8
- package/src/actions/create_embed_session.ts +8 -2
- package/src/actions/create_workspace_app_embed_session.ts +6 -1
- package/src/actions/execute-action-suggestion.ts +177 -0
- package/src/actions/index.spec.ts +6 -3
- package/src/actions/index.ts +5 -1
- package/src/actions/list-connected-agents.spec.ts +26 -1
- package/src/actions/list-connected-agents.ts +7 -4
- package/src/actions/list_app_actions.ts +1 -1
- package/src/actions/list_apps.spec.ts +58 -22
- package/src/actions/list_apps.ts +12 -5
- package/src/actions/navigate.ts +1 -0
- package/src/actions/open_app.spec.ts +17 -1
- package/src/actions/open_app.ts +21 -8
- package/src/actions/propose-action-suggestions.ts +42 -0
- package/src/actions/read_view.ts +1 -1
- package/src/actions/remember-pointer.ts +1 -1
- package/src/actions/resolve-pointer.ts +1 -1
- package/src/actions/route-app-intent.spec.ts +234 -5
- package/src/actions/route-app-intent.ts +89 -4
- package/src/actions/send-code-agent-remote-command.spec.ts +40 -0
- package/src/actions/send-code-agent-remote-command.ts +5 -0
- package/src/actions/start-workspace-app-creation.ts +1 -1
- package/src/actions/view-screen.bundle.spec.ts +15 -2
- package/src/actions/view-screen.spec.ts +81 -3
- package/src/actions/view-screen.ts +60 -4
- package/src/components/chat-action-suggestions.spec.tsx +362 -0
- package/src/components/chat-action-suggestions.tsx +432 -0
- package/src/components/chat-home-apps.spec.tsx +19 -0
- package/src/components/chat-home-apps.tsx +0 -1
- package/src/components/google-broker-settings-group.tsx +186 -0
- package/src/components/layout/Layout.spec.tsx +419 -28
- package/src/components/layout/Layout.tsx +304 -66
- package/src/components/messaging-setup-panel.spec.tsx +278 -4
- package/src/components/messaging-setup-panel.tsx +82 -19
- package/src/components/workspace-app-card.spec.tsx +79 -10
- package/src/components/workspace-app-chat-rail.spec.tsx +81 -3
- package/src/components/workspace-app-host.spec.tsx +269 -16
- package/src/components/workspace-app-host.tsx +464 -87
- package/src/config.ts +5 -0
- package/src/db/google-broker-admission.ts +160 -0
- package/src/db/migrations.spec.ts +165 -2
- package/src/db/migrations.ts +43 -1
- package/src/lib/action-suggestions.ts +267 -0
- package/src/lib/chat-first-app-route.spec.ts +15 -2
- package/src/lib/chat-first-app-route.ts +19 -7
- package/src/lib/chat-first-pane.spec.ts +71 -0
- package/src/lib/chat-first-pane.ts +101 -4
- package/src/lib/data-intent.spec.ts +21 -0
- package/src/lib/data-intent.ts +13 -0
- package/src/lib/dispatch-app-identity.ts +40 -0
- package/src/lib/other-apps.spec.ts +110 -1
- package/src/lib/other-apps.ts +41 -0
- package/src/lib/workspace-app-frame-view.spec.ts +13 -0
- package/src/lib/workspace-app-frame-view.ts +98 -0
- package/src/lib/workspace-apps.spec.ts +101 -0
- package/src/lib/workspace-apps.test.ts +18 -0
- package/src/lib/workspace-apps.ts +102 -24
- package/src/routes/pages/chat.spec.tsx +92 -1
- package/src/routes/pages/chat.tsx +41 -2
- package/src/routes/pages/settings-page.tsx +22 -17
- package/src/routes/pages/settings.spec.tsx +4 -0
- package/src/server/index.ts +6 -6
- package/src/server/lib/action-suggestions.ts +122 -0
- package/src/server/lib/app-action-result.ts +8 -0
- package/src/server/lib/app-creation-store.spec.ts +251 -0
- package/src/server/lib/app-creation-store.ts +72 -12
- package/src/server/lib/community-apps.spec.ts +19 -1
- package/src/server/lib/curated-workspace-templates.spec.ts +12 -0
- package/src/server/lib/curated-workspace-templates.ts +2 -0
- package/src/server/lib/dispatch-config.ts +15 -0
- package/src/server/lib/dispatch-pane-context.spec.ts +54 -0
- package/src/server/lib/dispatch-pane-context.ts +54 -0
- package/src/server/lib/google-broker-provider.ts +121 -0
- package/src/server/lib/google-broker-rpc.spec.ts +95 -0
- package/src/server/lib/google-broker-rpc.ts +107 -0
- package/src/server/lib/hosted-apps-settings.ts +4 -0
- package/src/server/lib/mcp-app-discovery.ts +318 -0
- package/src/server/lib/mcp-gateway.spec.ts +2252 -524
- package/src/server/lib/mcp-gateway.ts +1044 -181
- package/src/server/plugins/agent-chat.direct-mcp.spec.ts +84 -5
- package/src/server/plugins/agent-chat.ts +9 -7
- package/src/server/plugins/auth.spec.ts +5 -1
- package/src/server/plugins/auth.ts +1 -0
- package/src/server/plugins/db.ts +0 -51
- package/src/server/plugins/integrations.ts +4 -1
- package/src/shared/chat-first-pane.spec.ts +36 -0
- package/src/shared/chat-first-pane.ts +55 -0
- package/src/shared/labs.ts +8 -0
- package/src/server/plugins/agent-chat.spec.ts +0 -206
- package/src/server/plugins/integrations.spec.ts +0 -60
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes, } from "node:crypto";
|
|
2
|
+
import { appCapabilityManifestSchema, resolveManifestScreenPath, validateAppManifestPath, } from "@agent-native/core";
|
|
1
3
|
import { A2AClient, canonicalA2AAudience, extractA2APersistedMutationReceipts, getGlobalA2ASecret, signA2AOrgMemberDelegationToken, signA2AOrganizationToken, signA2AToken, stripA2APersistedArtifactMarkers, } from "@agent-native/core/a2a";
|
|
2
|
-
import { fail } from "@agent-native/core/action";
|
|
4
|
+
import { fail, NoWriteError } from "@agent-native/core/action";
|
|
3
5
|
import { getAppConfig } from "@agent-native/core/app-config";
|
|
4
6
|
import { isFeatureFlagEnabled } from "@agent-native/core/feature-flags";
|
|
5
|
-
import { buildMcpToolName, McpClientManager, mcpToolCallWasNotSent, } from "@agent-native/core/mcp-client";
|
|
7
|
+
import { buildMcpToolName, getMcpOAuthAccessToken, listRemoteServers, McpClientManager, mcpToolCallWasNotSent, } from "@agent-native/core/mcp-client";
|
|
6
8
|
import { getOrgA2ASecret, getOrgDomain } from "@agent-native/core/org";
|
|
7
|
-
import { buildDeepLink, buildEmbedStartPath, createEmbedSessionTicket, FULL_APP_EMBED_SCOPE, getAppProductionUrl, getConfiguredAppBasePath, getRequestContext, getRequestOrgId, getRequestUserEmail, resolveAppRuntimeUrl, } from "@agent-native/core/server";
|
|
9
|
+
import { buildDeepLink, buildEmbedStartPath, createEmbedSessionTicket, FULL_APP_EMBED_SCOPE, getAppProductionUrl, getConfiguredAppBasePath, getRequestContext, getRequestOrgId, getRequestRunContext, getRequestUserEmail, platformWaitUntil, resolveAppRuntimeUrl, } from "@agent-native/core/server";
|
|
8
10
|
import { discoverAgents, getBuiltinAgents, } from "@agent-native/core/server/agent-discovery";
|
|
9
11
|
import { EMBED_START_PATH } from "@agent-native/core/shared";
|
|
12
|
+
import { matchDispatchAppCandidates } from "../../lib/dispatch-app-identity.js";
|
|
13
|
+
import { DISPATCH_CHILD_BROWSER_TAB_PARAM } from "../../shared/chat-first-pane.js";
|
|
10
14
|
import { DESKTOP_WORKSPACE_SSO_FLAG } from "../../shared/feature-flags.js";
|
|
11
15
|
import { DISPATCH_WORKSPACE_SSO_FLAG, isWorkspaceSsoAppUrl, } from "../../shared/workspace-sso.js";
|
|
12
16
|
import { listWorkspaceApps } from "./app-creation-store.js";
|
|
17
|
+
import { resolveDispatchChildBrowserTab } from "./dispatch-pane-context.js";
|
|
13
18
|
import { projectEnvironmentUrl, requestEnvironmentLane, } from "./environment-lane.js";
|
|
14
19
|
import { getDispatchMcpAppAccessSettings, isAppAllowedByMcpAccess, } from "./mcp-access-store.js";
|
|
20
|
+
import { discoverDispatchMcpApps, } from "./mcp-app-discovery.js";
|
|
15
21
|
const DISPATCH_APP_ID = "dispatch";
|
|
16
22
|
const DISPATCH_NAME = "Dispatch";
|
|
17
23
|
const DISPATCH_DESCRIPTION = "Workspace control plane for extensions, agents, vault, integrations, approvals, and app routing.";
|
|
@@ -23,6 +29,8 @@ const TARGET_EMBED_SESSION_BUDGET_MS = 95_000;
|
|
|
23
29
|
// open_app answers with its link by then; a panel is worth a short wait, not
|
|
24
30
|
// the full mint budget.
|
|
25
31
|
const OPEN_APP_EMBED_WAIT_MS = 15_000;
|
|
32
|
+
const BROWSER_EMBED_PREFETCH_WAIT_MS = 1_000;
|
|
33
|
+
const PENDING_EMBED_LIMIT = 32;
|
|
26
34
|
const DISPATCH_ASK_APP_DEFAULT_INLINE_WAIT_MS = 20_000;
|
|
27
35
|
const DISPATCH_ASK_APP_MAX_INLINE_WAIT_MS = 20_000;
|
|
28
36
|
const DISPATCH_ASK_APP_POLL_INTERVAL_MS = 1_500;
|
|
@@ -34,12 +42,218 @@ const DISPATCH_ASK_APP_TERMINAL_STATES = new Set([
|
|
|
34
42
|
"canceled",
|
|
35
43
|
"input-required",
|
|
36
44
|
]);
|
|
45
|
+
const DISPATCH_TASK_HANDLE_VERSION = 1;
|
|
46
|
+
const DISPATCH_TASK_HANDLE_TTL_SECONDS = 60 * 60;
|
|
47
|
+
const DISPATCH_TASK_HANDLE_DOMAIN = "agent-native:dispatch-ask-app-task-handle:v1";
|
|
48
|
+
const DISPATCH_TASK_HANDLE_PREFIX = "v1";
|
|
49
|
+
const DISPATCH_TASK_HANDLE_IV_BYTES = 12;
|
|
50
|
+
const DISPATCH_TASK_HANDLE_AUTH_TAG_BYTES = 16;
|
|
51
|
+
const INVALID_DISPATCH_ASK_APP_TASK_HANDLE_ERROR = "Invalid or expired ask_app task handle. To keep polling the same task, " +
|
|
52
|
+
"call ask_app_status with the app and taskId from the ask_app result and " +
|
|
53
|
+
"leave out taskHandle. Do not resubmit ask_app; that can duplicate work.";
|
|
54
|
+
let ephemeralDevTaskHandleSecret = null;
|
|
55
|
+
function getEphemeralDevTaskHandleSecret() {
|
|
56
|
+
if (ephemeralDevTaskHandleSecret === null) {
|
|
57
|
+
ephemeralDevTaskHandleSecret = randomBytes(32).toString("hex");
|
|
58
|
+
}
|
|
59
|
+
return ephemeralDevTaskHandleSecret;
|
|
60
|
+
}
|
|
61
|
+
function dispatchTaskHandleSecrets(orgSecret) {
|
|
62
|
+
const globalA2A = getGlobalA2ASecret()?.trim();
|
|
63
|
+
const betterAuth = process.env.BETTER_AUTH_SECRET?.trim();
|
|
64
|
+
const org = orgSecret?.trim();
|
|
65
|
+
const configured = [globalA2A, betterAuth, org].filter((value) => Boolean(value));
|
|
66
|
+
if (configured.length > 0)
|
|
67
|
+
return [...new Set(configured)];
|
|
68
|
+
if (process.env.NODE_ENV === "production")
|
|
69
|
+
return [];
|
|
70
|
+
return [getEphemeralDevTaskHandleSecret()];
|
|
71
|
+
}
|
|
72
|
+
function dispatchTaskHandleKey(rootSecret) {
|
|
73
|
+
return createHmac("sha256", rootSecret)
|
|
74
|
+
.update(DISPATCH_TASK_HANDLE_DOMAIN)
|
|
75
|
+
.digest();
|
|
76
|
+
}
|
|
77
|
+
function normalizeTaskHandleIdentity(value) {
|
|
78
|
+
return value.trim().toLowerCase();
|
|
79
|
+
}
|
|
80
|
+
function validDispatchTaskTargetUrl(value) {
|
|
81
|
+
const trimmed = value.trim();
|
|
82
|
+
if (!trimmed)
|
|
83
|
+
return null;
|
|
84
|
+
let parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = new URL(trimmed);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// coercion-ok: invalid target URL fails task handle validation closed.
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
if (parsed.username || parsed.password || parsed.search || parsed.hash) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
99
|
+
}
|
|
100
|
+
function sealDispatchAskAppTaskHandle(params) {
|
|
101
|
+
const secrets = dispatchTaskHandleSecrets(params.orgSecret);
|
|
102
|
+
const primarySecret = secrets[0];
|
|
103
|
+
if (!primarySecret)
|
|
104
|
+
return undefined;
|
|
105
|
+
const app = normalizeAppId(params.app);
|
|
106
|
+
const targetUrl = validDispatchTaskTargetUrl(params.targetUrl);
|
|
107
|
+
const taskId = params.taskId.trim();
|
|
108
|
+
const userEmail = normalizeTaskHandleIdentity(params.userEmail);
|
|
109
|
+
const orgId = normalizeTaskHandleIdentity(params.orgId ?? "");
|
|
110
|
+
if (!app || !targetUrl || !taskId || !userEmail)
|
|
111
|
+
return undefined;
|
|
112
|
+
const payload = Buffer.from(JSON.stringify({
|
|
113
|
+
version: DISPATCH_TASK_HANDLE_VERSION,
|
|
114
|
+
app,
|
|
115
|
+
targetUrl,
|
|
116
|
+
taskId,
|
|
117
|
+
userEmail,
|
|
118
|
+
orgId,
|
|
119
|
+
expiresAt: Math.floor(Date.now() / 1000) +
|
|
120
|
+
(params.expiresInSeconds ?? DISPATCH_TASK_HANDLE_TTL_SECONDS),
|
|
121
|
+
}), "utf8");
|
|
122
|
+
const iv = randomBytes(DISPATCH_TASK_HANDLE_IV_BYTES);
|
|
123
|
+
const cipher = createCipheriv("aes-256-gcm", dispatchTaskHandleKey(primarySecret), iv);
|
|
124
|
+
cipher.setAAD(Buffer.from(DISPATCH_TASK_HANDLE_DOMAIN, "utf8"));
|
|
125
|
+
const ciphertext = Buffer.concat([cipher.update(payload), cipher.final()]);
|
|
126
|
+
const authTag = cipher.getAuthTag();
|
|
127
|
+
return [
|
|
128
|
+
DISPATCH_TASK_HANDLE_PREFIX,
|
|
129
|
+
iv.toString("base64url"),
|
|
130
|
+
ciphertext.toString("base64url"),
|
|
131
|
+
authTag.toString("base64url"),
|
|
132
|
+
].join(".");
|
|
133
|
+
}
|
|
134
|
+
function unsealDispatchAskAppTaskHandle(handle, expected) {
|
|
135
|
+
const invalid = () => new Error(INVALID_DISPATCH_ASK_APP_TASK_HANDLE_ERROR);
|
|
136
|
+
const trimmedHandle = handle.trim();
|
|
137
|
+
const expectedApp = normalizeAppId(expected.app);
|
|
138
|
+
const expectedTaskId = expected.taskId.trim();
|
|
139
|
+
const expectedUserEmail = normalizeTaskHandleIdentity(expected.userEmail);
|
|
140
|
+
const expectedOrgId = normalizeTaskHandleIdentity(expected.orgId ?? "");
|
|
141
|
+
if (!trimmedHandle || !expectedApp || !expectedTaskId || !expectedUserEmail) {
|
|
142
|
+
throw invalid();
|
|
143
|
+
}
|
|
144
|
+
const parts = trimmedHandle.split(".");
|
|
145
|
+
const [prefix, ivPart, ciphertextPart, authTagPart] = parts;
|
|
146
|
+
if (parts.length !== 4 ||
|
|
147
|
+
prefix !== DISPATCH_TASK_HANDLE_PREFIX ||
|
|
148
|
+
!ivPart ||
|
|
149
|
+
!ciphertextPart ||
|
|
150
|
+
!authTagPart) {
|
|
151
|
+
throw invalid();
|
|
152
|
+
}
|
|
153
|
+
const iv = Buffer.from(ivPart, "base64url");
|
|
154
|
+
const ciphertext = Buffer.from(ciphertextPart, "base64url");
|
|
155
|
+
const authTag = Buffer.from(authTagPart, "base64url");
|
|
156
|
+
if (iv.length !== DISPATCH_TASK_HANDLE_IV_BYTES ||
|
|
157
|
+
ciphertext.length === 0 ||
|
|
158
|
+
authTag.length !== DISPATCH_TASK_HANDLE_AUTH_TAG_BYTES ||
|
|
159
|
+
iv.toString("base64url") !== ivPart ||
|
|
160
|
+
ciphertext.toString("base64url") !== ciphertextPart ||
|
|
161
|
+
authTag.toString("base64url") !== authTagPart) {
|
|
162
|
+
throw invalid();
|
|
163
|
+
}
|
|
164
|
+
const secrets = dispatchTaskHandleSecrets(expected.orgSecret);
|
|
165
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
166
|
+
for (const rootSecret of secrets) {
|
|
167
|
+
let parsed;
|
|
168
|
+
try {
|
|
169
|
+
const decipher = createDecipheriv("aes-256-gcm", dispatchTaskHandleKey(rootSecret), iv);
|
|
170
|
+
decipher.setAAD(Buffer.from(DISPATCH_TASK_HANDLE_DOMAIN, "utf8"));
|
|
171
|
+
decipher.setAuthTag(authTag);
|
|
172
|
+
const plaintext = Buffer.concat([
|
|
173
|
+
decipher.update(ciphertext),
|
|
174
|
+
decipher.final(),
|
|
175
|
+
]);
|
|
176
|
+
parsed = JSON.parse(plaintext.toString("utf8"));
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const claims = parsed;
|
|
185
|
+
const targetUrl = typeof claims.targetUrl === "string"
|
|
186
|
+
? validDispatchTaskTargetUrl(claims.targetUrl)
|
|
187
|
+
: null;
|
|
188
|
+
if (claims.version !== DISPATCH_TASK_HANDLE_VERSION ||
|
|
189
|
+
claims.app !== expectedApp ||
|
|
190
|
+
claims.taskId !== expectedTaskId ||
|
|
191
|
+
claims.userEmail !== expectedUserEmail ||
|
|
192
|
+
claims.orgId !== expectedOrgId ||
|
|
193
|
+
targetUrl === null ||
|
|
194
|
+
typeof claims.expiresAt !== "number" ||
|
|
195
|
+
!Number.isFinite(claims.expiresAt) ||
|
|
196
|
+
claims.expiresAt <= nowSeconds) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
app: expectedApp,
|
|
201
|
+
targetUrl,
|
|
202
|
+
taskId: expectedTaskId,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
throw invalid();
|
|
206
|
+
}
|
|
37
207
|
class DispatchAskAppInlineDeadlineError extends Error {
|
|
38
208
|
constructor() {
|
|
39
209
|
super("ask_app inline wait deadline reached");
|
|
40
210
|
this.name = "DispatchAskAppInlineDeadlineError";
|
|
41
211
|
}
|
|
42
212
|
}
|
|
213
|
+
const grantedAppManifestCache = new Map();
|
|
214
|
+
/** Registers or clears a parsed capability manifest for a granted app id. */
|
|
215
|
+
export function registerGrantedAppManifest(appId, manifest) {
|
|
216
|
+
const key = normalizeAppId(appId);
|
|
217
|
+
if (!key)
|
|
218
|
+
return undefined;
|
|
219
|
+
if (manifest === undefined || manifest === null) {
|
|
220
|
+
grantedAppManifestCache.delete(key);
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
const parsed = appCapabilityManifestSchema.safeParse(manifest);
|
|
224
|
+
if (!parsed.success)
|
|
225
|
+
return undefined;
|
|
226
|
+
grantedAppManifestCache.set(key, parsed.data);
|
|
227
|
+
return parsed.data;
|
|
228
|
+
}
|
|
229
|
+
/** Clears cached granted app capability manifests. */
|
|
230
|
+
export function clearGrantedAppManifestCache() {
|
|
231
|
+
grantedAppManifestCache.clear();
|
|
232
|
+
}
|
|
233
|
+
function getGrantedAppManifest(target) {
|
|
234
|
+
if (target.manifest) {
|
|
235
|
+
const parsed = appCapabilityManifestSchema.safeParse(target.manifest);
|
|
236
|
+
if (parsed.success)
|
|
237
|
+
return parsed.data;
|
|
238
|
+
}
|
|
239
|
+
return grantedAppManifestCache.get(normalizeAppId(target.id));
|
|
240
|
+
}
|
|
241
|
+
function stripTargetBasePath(target, rawPath) {
|
|
242
|
+
const basePath = appBasePath(target);
|
|
243
|
+
if (!basePath)
|
|
244
|
+
return rawPath;
|
|
245
|
+
const parsed = new URL(rawPath, "https://agent-native.invalid");
|
|
246
|
+
const lowerBase = basePath.toLowerCase();
|
|
247
|
+
const lowerPathname = parsed.pathname.toLowerCase();
|
|
248
|
+
if (lowerPathname === lowerBase) {
|
|
249
|
+
return `/${parsed.search}${parsed.hash}`;
|
|
250
|
+
}
|
|
251
|
+
if (lowerPathname.startsWith(`${lowerBase}/`)) {
|
|
252
|
+
const stripped = parsed.pathname.slice(basePath.length) || "/";
|
|
253
|
+
return `${stripped}${parsed.search}${parsed.hash}`;
|
|
254
|
+
}
|
|
255
|
+
return rawPath;
|
|
256
|
+
}
|
|
43
257
|
function normalizeAppId(value) {
|
|
44
258
|
return value.trim().toLowerCase();
|
|
45
259
|
}
|
|
@@ -98,7 +312,7 @@ function dispatchTaskMutationReceipts(task, app, identity) {
|
|
|
98
312
|
receipt.target.authorityScopeId === identity.orgId);
|
|
99
313
|
});
|
|
100
314
|
}
|
|
101
|
-
function dispatchAskAppTaskResult(app, task, identity) {
|
|
315
|
+
function dispatchAskAppTaskResult(app, task, identity, taskHandle) {
|
|
102
316
|
const status = String(task.status.state);
|
|
103
317
|
const response = stripA2APersistedArtifactMarkers(dispatchTaskText(task));
|
|
104
318
|
const receipts = dispatchTaskMutationReceipts(task, app, identity);
|
|
@@ -133,13 +347,20 @@ function dispatchAskAppTaskResult(app, task, identity) {
|
|
|
133
347
|
}
|
|
134
348
|
return {
|
|
135
349
|
...base,
|
|
350
|
+
...(taskHandle ? { taskHandle } : {}),
|
|
136
351
|
pollAfterMs: DISPATCH_ASK_APP_POLL_INTERVAL_MS,
|
|
137
352
|
poll: {
|
|
138
353
|
tool: "ask_app_status",
|
|
139
|
-
arguments: {
|
|
354
|
+
arguments: {
|
|
355
|
+
app,
|
|
356
|
+
taskId: task.id,
|
|
357
|
+
...(taskHandle ? { taskHandle } : {}),
|
|
358
|
+
},
|
|
140
359
|
},
|
|
141
360
|
message: `ask_app is still ${status}. Call ask_app_status with ` +
|
|
142
|
-
|
|
361
|
+
(taskHandle
|
|
362
|
+
? `taskId "${task.id}" and the returned taskHandle to retrieve the final response.`
|
|
363
|
+
: `taskId "${task.id}" to retrieve the final response.`),
|
|
143
364
|
};
|
|
144
365
|
}
|
|
145
366
|
async function createDispatchA2AClient(input) {
|
|
@@ -175,6 +396,18 @@ async function createDispatchA2AClient(input) {
|
|
|
175
396
|
...(getRequestContext()?.requestOrigin
|
|
176
397
|
? { requestOrigin: getRequestContext()?.requestOrigin }
|
|
177
398
|
: {}),
|
|
399
|
+
...(input.childBrowserTabId
|
|
400
|
+
? { browserTabId: input.childBrowserTabId }
|
|
401
|
+
: {}),
|
|
402
|
+
...(input.viewportMode ? { viewportMode: input.viewportMode } : {}),
|
|
403
|
+
};
|
|
404
|
+
const transportHeaders = {
|
|
405
|
+
...(input.childBrowserTabId
|
|
406
|
+
? { "x-agent-native-browser-tab": input.childBrowserTabId }
|
|
407
|
+
: {}),
|
|
408
|
+
...(input.viewportMode
|
|
409
|
+
? { "x-agent-native-viewport-mode": input.viewportMode }
|
|
410
|
+
: {}),
|
|
178
411
|
};
|
|
179
412
|
const remainingMs = input.deadline == null ? null : input.deadline - Date.now();
|
|
180
413
|
return {
|
|
@@ -183,6 +416,7 @@ async function createDispatchA2AClient(input) {
|
|
|
183
416
|
? DISPATCH_A2A_REQUEST_TIMEOUT_MS
|
|
184
417
|
: Math.max(1, Math.min(DISPATCH_A2A_REQUEST_TIMEOUT_MS, remainingMs)),
|
|
185
418
|
...(apiKeys.length > 1 ? { fallbackApiKeys: apiKeys.slice(1) } : {}),
|
|
419
|
+
...(Object.keys(transportHeaders).length > 0 ? { transportHeaders } : {}),
|
|
186
420
|
}),
|
|
187
421
|
metadata,
|
|
188
422
|
};
|
|
@@ -227,11 +461,12 @@ function dispatchAskAppStatusOriginHost(origin) {
|
|
|
227
461
|
return "unknown";
|
|
228
462
|
}
|
|
229
463
|
}
|
|
230
|
-
function dispatchAskAppStatusReadUnavailableResult(app, taskId, errorCategory, attempts) {
|
|
464
|
+
function dispatchAskAppStatusReadUnavailableResult(app, taskId, errorCategory, attempts, taskHandle) {
|
|
231
465
|
return {
|
|
232
466
|
app,
|
|
233
467
|
routedVia: "a2a",
|
|
234
468
|
taskId,
|
|
469
|
+
...(taskHandle ? { taskHandle } : {}),
|
|
235
470
|
status: "unknown",
|
|
236
471
|
statusRead: "unavailable",
|
|
237
472
|
retryable: true,
|
|
@@ -240,11 +475,17 @@ function dispatchAskAppStatusReadUnavailableResult(app, taskId, errorCategory, a
|
|
|
240
475
|
pollAfterMs: DISPATCH_ASK_APP_POLL_INTERVAL_MS,
|
|
241
476
|
poll: {
|
|
242
477
|
tool: "ask_app_status",
|
|
243
|
-
arguments: {
|
|
478
|
+
arguments: {
|
|
479
|
+
app,
|
|
480
|
+
taskId,
|
|
481
|
+
...(taskHandle ? { taskHandle } : {}),
|
|
482
|
+
},
|
|
244
483
|
},
|
|
245
484
|
message: "The durable ask_app task status could not be read after bounded retries. " +
|
|
246
485
|
"The task may still be running or completed. Retry ask_app_status " +
|
|
247
|
-
|
|
486
|
+
(taskHandle
|
|
487
|
+
? "with the same app, taskId, and taskHandle; do not resubmit ask_app."
|
|
488
|
+
: "with the same app and taskId; do not resubmit ask_app."),
|
|
248
489
|
};
|
|
249
490
|
}
|
|
250
491
|
async function runBeforeDispatchAskAppDeadline(operation, deadline) {
|
|
@@ -470,22 +711,79 @@ function targetEndpointKeepsCredentialsPrivate(endpoint) {
|
|
|
470
711
|
return false;
|
|
471
712
|
}
|
|
472
713
|
}
|
|
473
|
-
function
|
|
714
|
+
function collapseRepeatedLeadingPathSegment(pathname) {
|
|
715
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
716
|
+
if (segments.length < 2)
|
|
717
|
+
return pathname;
|
|
718
|
+
let start = 0;
|
|
719
|
+
while (start + 1 < segments.length) {
|
|
720
|
+
const current = segments[start];
|
|
721
|
+
const next = segments[start + 1];
|
|
722
|
+
if (!current || !next || current.toLowerCase() !== next.toLowerCase()) {
|
|
723
|
+
break;
|
|
724
|
+
}
|
|
725
|
+
start += 1;
|
|
726
|
+
}
|
|
727
|
+
if (start === 0)
|
|
728
|
+
return pathname;
|
|
729
|
+
return `/${segments.slice(start).join("/")}`;
|
|
730
|
+
}
|
|
731
|
+
export function appHomeBaseUrl(app) {
|
|
732
|
+
const normalize = (raw) => {
|
|
733
|
+
const parsed = new URL(raw);
|
|
734
|
+
parsed.pathname = collapseRepeatedLeadingPathSegment(parsed.pathname);
|
|
735
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
736
|
+
};
|
|
474
737
|
const configured = app.homeUrl?.trim();
|
|
475
738
|
if (configured) {
|
|
476
739
|
try {
|
|
477
740
|
const url = new URL(configured);
|
|
478
741
|
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
479
|
-
return
|
|
742
|
+
return normalize(configured);
|
|
480
743
|
}
|
|
481
744
|
}
|
|
482
745
|
catch {
|
|
483
746
|
// coercion-ok: invalid optional home URL falls back to endpoint.
|
|
484
|
-
// Fall back to the registered endpoint below. The endpoint has already
|
|
485
|
-
// passed the app-origin validation before this helper is reached.
|
|
486
747
|
}
|
|
487
748
|
}
|
|
488
|
-
|
|
749
|
+
try {
|
|
750
|
+
return normalize(app.url);
|
|
751
|
+
}
|
|
752
|
+
catch {
|
|
753
|
+
// coercion-ok: fallback preserves pre-validated app base URL string.
|
|
754
|
+
return app.url.replace(/\/+$/, "");
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
export function joinAppBaseUrlAndPath(baseUrl, relPath) {
|
|
758
|
+
const cleanBase = baseUrl.replace(/\/+$/, "");
|
|
759
|
+
let parsedBase;
|
|
760
|
+
let parsedRel;
|
|
761
|
+
try {
|
|
762
|
+
parsedBase = new URL(cleanBase);
|
|
763
|
+
parsedRel = new URL(relPath, "https://agent-native.invalid");
|
|
764
|
+
}
|
|
765
|
+
catch {
|
|
766
|
+
// coercion-ok: fallback preserves direct concatenation for non-URL test inputs.
|
|
767
|
+
return `${cleanBase}${relPath}`;
|
|
768
|
+
}
|
|
769
|
+
const basePath = collapseRepeatedLeadingPathSegment(parsedBase.pathname.replace(/\/+$/, "") || "/");
|
|
770
|
+
const relPathname = collapseRepeatedLeadingPathSegment(parsedRel.pathname || "/");
|
|
771
|
+
const normalizedBasePath = basePath === "/" ? "" : basePath;
|
|
772
|
+
const suffix = `${parsedRel.search}${parsedRel.hash}`;
|
|
773
|
+
if (!normalizedBasePath) {
|
|
774
|
+
return `${parsedBase.origin}${relPathname}${suffix}`;
|
|
775
|
+
}
|
|
776
|
+
const lowerBase = normalizedBasePath.toLowerCase();
|
|
777
|
+
const lowerRel = relPathname.toLowerCase();
|
|
778
|
+
const effectiveRel = lowerRel === lowerBase
|
|
779
|
+
? "/"
|
|
780
|
+
: lowerRel.startsWith(`${lowerBase}/`)
|
|
781
|
+
? relPathname.slice(normalizedBasePath.length)
|
|
782
|
+
: relPathname;
|
|
783
|
+
const joinedPath = effectiveRel === "/"
|
|
784
|
+
? `${normalizedBasePath}/`
|
|
785
|
+
: `${normalizedBasePath}${effectiveRel.startsWith("/") ? effectiveRel : `/${effectiveRel}`}`;
|
|
786
|
+
return `${parsedBase.origin}${joinedPath}${suffix}`;
|
|
489
787
|
}
|
|
490
788
|
function workspaceGatewayMcpUrl(appUrl) {
|
|
491
789
|
const configuredGateway = getAppConfig().workspace.gatewayUrl?.trim();
|
|
@@ -616,21 +914,20 @@ function toAccessibleApp(agent, settings) {
|
|
|
616
914
|
description: typeof agent.description === "string" ? agent.description : "",
|
|
617
915
|
url: projectEnvironmentUrl(agent.url),
|
|
618
916
|
color: agent.color,
|
|
917
|
+
...(agent.source ? { source: agent.source } : {}),
|
|
918
|
+
...(agent.aliases?.length ? { aliases: agent.aliases } : {}),
|
|
619
919
|
granted: isAppAllowedByMcpAccess(agent.id, settings),
|
|
620
920
|
};
|
|
621
921
|
}
|
|
622
922
|
export async function listDispatchMcpApps() {
|
|
623
|
-
const [settings, agents, mountedApps] = await Promise.all([
|
|
923
|
+
const [settings, { agents, mountedApps, degradedSources }] = await Promise.all([
|
|
624
924
|
getDispatchMcpAppAccessSettings(),
|
|
625
|
-
|
|
626
|
-
listWorkspaceApps({ includeAgentCards: false }).catch((error) => {
|
|
627
|
-
console.warn("[dispatch] Workspace app lookup failed during MCP app discovery", { status: httpStatusFromError(error) });
|
|
628
|
-
return [];
|
|
629
|
-
}),
|
|
925
|
+
discoverDispatchMcpApps(),
|
|
630
926
|
]);
|
|
631
927
|
const mountedAppsById = new Map(mountedApps.map((app) => [normalizeAppId(app.id), app]));
|
|
632
928
|
return {
|
|
633
929
|
settings,
|
|
930
|
+
degradedSources,
|
|
634
931
|
apps: [
|
|
635
932
|
dispatchSelfApp(settings),
|
|
636
933
|
...agents
|
|
@@ -645,18 +942,24 @@ export async function listDispatchMcpApps() {
|
|
|
645
942
|
? mountedWorkspaceAppHomeUrl(mountedApp)
|
|
646
943
|
: null;
|
|
647
944
|
if (homeUrl)
|
|
648
|
-
return { ...accessible, homeUrl };
|
|
649
|
-
|
|
650
|
-
|
|
945
|
+
return { ...accessible, homeUrl, workspaceMount: true };
|
|
946
|
+
return agent.source === "workspace" ||
|
|
947
|
+
isDispatchAppPageUrl(accessible.url)
|
|
651
948
|
? { ...accessible, mountedPathUnavailable: true }
|
|
652
949
|
: accessible;
|
|
653
950
|
}),
|
|
654
951
|
],
|
|
655
952
|
};
|
|
656
953
|
}
|
|
954
|
+
export async function listGrantedDispatchMcpAppsWithStatus() {
|
|
955
|
+
const { apps, degradedSources } = await listDispatchMcpApps();
|
|
956
|
+
return {
|
|
957
|
+
degradedSources,
|
|
958
|
+
apps: apps.filter((app) => app.granted && !app.mountedPathUnavailable && safeAppOrigin(app)),
|
|
959
|
+
};
|
|
960
|
+
}
|
|
657
961
|
export async function listGrantedDispatchMcpApps() {
|
|
658
|
-
|
|
659
|
-
return apps.filter((app) => app.granted && !app.mountedPathUnavailable && safeAppOrigin(app));
|
|
962
|
+
return (await listGrantedDispatchMcpAppsWithStatus()).apps;
|
|
660
963
|
}
|
|
661
964
|
export async function listGrantedDispatchMcpAppOrigins() {
|
|
662
965
|
const apps = await listGrantedDispatchMcpApps();
|
|
@@ -667,7 +970,11 @@ export async function resolveGrantedDispatchMcpApp(app) {
|
|
|
667
970
|
if (!target)
|
|
668
971
|
throw new Error("app is required");
|
|
669
972
|
const { apps } = await listDispatchMcpApps();
|
|
670
|
-
const
|
|
973
|
+
const candidates = matchDispatchAppCandidates(apps, target);
|
|
974
|
+
if (candidates.length > 1) {
|
|
975
|
+
throw new Error(`Ambiguous app "${app}". Choose one of: ${candidates.map((candidate) => candidate.id).join(", ")}.`);
|
|
976
|
+
}
|
|
977
|
+
const match = candidates[0];
|
|
671
978
|
if (!match) {
|
|
672
979
|
throw new Error(`Unknown app "${app}". Call list_apps to see apps available through Dispatch MCP.`);
|
|
673
980
|
}
|
|
@@ -728,6 +1035,7 @@ async function listWorkspaceSsoApps() {
|
|
|
728
1035
|
description: app.description,
|
|
729
1036
|
url: app.url,
|
|
730
1037
|
homeUrl,
|
|
1038
|
+
workspaceMount: true,
|
|
731
1039
|
...(mcpUrl ? { mcpUrl } : {}),
|
|
732
1040
|
color: DISPATCH_COLOR,
|
|
733
1041
|
granted: true,
|
|
@@ -757,7 +1065,11 @@ async function resolveWorkspaceSsoApp(app) {
|
|
|
757
1065
|
if (!target)
|
|
758
1066
|
throw new Error("app is required");
|
|
759
1067
|
const apps = await listWorkspaceSsoApps();
|
|
760
|
-
const
|
|
1068
|
+
const candidates = matchDispatchAppCandidates(apps, target);
|
|
1069
|
+
if (candidates.length > 1) {
|
|
1070
|
+
throw new Error(`Ambiguous app "${app}". Choose one of: ${candidates.map((candidate) => candidate.id).join(", ")}.`);
|
|
1071
|
+
}
|
|
1072
|
+
const match = candidates[0];
|
|
761
1073
|
if (!match) {
|
|
762
1074
|
throw new Error(`Workspace app "${app}" is not registered for workspace sign-in.`);
|
|
763
1075
|
}
|
|
@@ -778,6 +1090,11 @@ export async function askGrantedDispatchMcpApp(app, message, options) {
|
|
|
778
1090
|
getOrgA2ASecret(orgId).catch(() => null),
|
|
779
1091
|
])
|
|
780
1092
|
: [null, null];
|
|
1093
|
+
const requestedViewportMode = options?.viewportMode ?? getRequestRunContext()?.viewportMode;
|
|
1094
|
+
const childBrowserTabId = requestedViewportMode === "background"
|
|
1095
|
+
? undefined
|
|
1096
|
+
: await resolveDispatchChildBrowserTab(target);
|
|
1097
|
+
const viewportMode = requestedViewportMode ?? (childBrowserTabId ? "foreground" : undefined);
|
|
781
1098
|
const inlineWaitMs = options?.async === true
|
|
782
1099
|
? 0
|
|
783
1100
|
: boundedDispatchAskAppWaitMs(options?.maxWaitMs);
|
|
@@ -790,6 +1107,8 @@ export async function askGrantedDispatchMcpApp(app, message, options) {
|
|
|
790
1107
|
orgDomain: orgDomain ?? undefined,
|
|
791
1108
|
orgSecret: orgSecret ?? undefined,
|
|
792
1109
|
deadline: submissionDeadline,
|
|
1110
|
+
...(childBrowserTabId ? { childBrowserTabId } : {}),
|
|
1111
|
+
...(viewportMode ? { viewportMode } : {}),
|
|
793
1112
|
});
|
|
794
1113
|
const idempotencyKey = await dispatchAskAppIdempotencyKey(target, trimmedMessage);
|
|
795
1114
|
const task = await client.send({
|
|
@@ -802,17 +1121,28 @@ export async function askGrantedDispatchMcpApp(app, message, options) {
|
|
|
802
1121
|
deadlineMs: submissionDeadline,
|
|
803
1122
|
});
|
|
804
1123
|
const finalOrRunning = await waitForDispatchA2ATask(client, task, deadline);
|
|
1124
|
+
const taskHandle = isTerminalDispatchTask(finalOrRunning)
|
|
1125
|
+
? undefined
|
|
1126
|
+
: sealDispatchAskAppTaskHandle({
|
|
1127
|
+
app: target.id,
|
|
1128
|
+
targetUrl: target.url,
|
|
1129
|
+
taskId: finalOrRunning.id,
|
|
1130
|
+
userEmail,
|
|
1131
|
+
orgId: orgId ?? null,
|
|
1132
|
+
orgSecret: orgSecret ?? null,
|
|
1133
|
+
});
|
|
805
1134
|
return dispatchAskAppTaskResult(target.id, finalOrRunning, {
|
|
806
1135
|
userEmail,
|
|
807
1136
|
orgId: orgId ?? null,
|
|
808
1137
|
orgSecret: orgSecret ?? null,
|
|
809
|
-
});
|
|
1138
|
+
}, taskHandle);
|
|
810
1139
|
}
|
|
811
|
-
export async function getGrantedDispatchMcpAppTask(app, taskId) {
|
|
1140
|
+
export async function getGrantedDispatchMcpAppTask(app, taskId, options) {
|
|
812
1141
|
const trimmedTaskId = taskId.trim();
|
|
813
1142
|
if (!trimmedTaskId)
|
|
814
1143
|
throw new Error("taskId is required");
|
|
815
|
-
|
|
1144
|
+
if (!normalizeAppId(app))
|
|
1145
|
+
throw new Error("app is required");
|
|
816
1146
|
const userEmail = getRequestUserEmail();
|
|
817
1147
|
if (!userEmail)
|
|
818
1148
|
throw new Error("no authenticated user");
|
|
@@ -823,8 +1153,32 @@ export async function getGrantedDispatchMcpAppTask(app, taskId) {
|
|
|
823
1153
|
getOrgA2ASecret(orgId).catch(() => null),
|
|
824
1154
|
])
|
|
825
1155
|
: [null, null];
|
|
1156
|
+
let targetAppId;
|
|
1157
|
+
let targetUrl;
|
|
1158
|
+
let verifiedHandle;
|
|
1159
|
+
if (options?.taskHandle !== undefined) {
|
|
1160
|
+
const verified = unsealDispatchAskAppTaskHandle(options.taskHandle, {
|
|
1161
|
+
app,
|
|
1162
|
+
taskId: trimmedTaskId,
|
|
1163
|
+
userEmail,
|
|
1164
|
+
orgId: orgId ?? null,
|
|
1165
|
+
orgSecret: orgSecret ?? null,
|
|
1166
|
+
});
|
|
1167
|
+
const settings = await getDispatchMcpAppAccessSettings();
|
|
1168
|
+
if (!isAppAllowedByMcpAccess(verified.app, settings)) {
|
|
1169
|
+
throw new Error(`Dispatch MCP access to "${verified.app}" is not granted. Open Dispatch > Agents to change MCP app access.`);
|
|
1170
|
+
}
|
|
1171
|
+
targetAppId = verified.app;
|
|
1172
|
+
targetUrl = verified.targetUrl;
|
|
1173
|
+
verifiedHandle = options.taskHandle.trim();
|
|
1174
|
+
}
|
|
1175
|
+
else {
|
|
1176
|
+
const target = await resolveGrantedDispatchMcpApp(app);
|
|
1177
|
+
targetAppId = target.id;
|
|
1178
|
+
targetUrl = target.url;
|
|
1179
|
+
}
|
|
826
1180
|
const { client } = await createDispatchA2AClient({
|
|
827
|
-
targetUrl
|
|
1181
|
+
targetUrl,
|
|
828
1182
|
userEmail,
|
|
829
1183
|
orgId: orgId ?? undefined,
|
|
830
1184
|
orgDomain: orgDomain ?? undefined,
|
|
@@ -835,11 +1189,11 @@ export async function getGrantedDispatchMcpAppTask(app, taskId) {
|
|
|
835
1189
|
const startedAt = Date.now();
|
|
836
1190
|
try {
|
|
837
1191
|
const task = await client.getTask(trimmedTaskId);
|
|
838
|
-
return dispatchAskAppTaskResult(
|
|
1192
|
+
return dispatchAskAppTaskResult(targetAppId, task, {
|
|
839
1193
|
userEmail,
|
|
840
1194
|
orgId: orgId ?? null,
|
|
841
1195
|
orgSecret: orgSecret ?? null,
|
|
842
|
-
});
|
|
1196
|
+
}, verifiedHandle);
|
|
843
1197
|
}
|
|
844
1198
|
catch (err) {
|
|
845
1199
|
const delayMs = DISPATCH_ASK_APP_STATUS_RETRY_DELAYS_MS[attempt];
|
|
@@ -848,10 +1202,10 @@ export async function getGrantedDispatchMcpAppTask(app, taskId) {
|
|
|
848
1202
|
const willRetry = retryable && delayMs != null;
|
|
849
1203
|
if (retryable) {
|
|
850
1204
|
console.warn("[ask_app_status] tasks/get attempt failed", {
|
|
851
|
-
app:
|
|
1205
|
+
app: targetAppId,
|
|
852
1206
|
routedVia: "a2a",
|
|
853
1207
|
taskId: trimmedTaskId,
|
|
854
|
-
originHost: dispatchAskAppStatusOriginHost(
|
|
1208
|
+
originHost: dispatchAskAppStatusOriginHost(targetUrl),
|
|
855
1209
|
attempt: attempt + 1,
|
|
856
1210
|
maxAttempts,
|
|
857
1211
|
elapsedMs: Date.now() - startedAt,
|
|
@@ -864,37 +1218,72 @@ export async function getGrantedDispatchMcpAppTask(app, taskId) {
|
|
|
864
1218
|
if (!retryable)
|
|
865
1219
|
throw err;
|
|
866
1220
|
if (delayMs == null) {
|
|
867
|
-
return dispatchAskAppStatusReadUnavailableResult(
|
|
1221
|
+
return dispatchAskAppStatusReadUnavailableResult(targetAppId, trimmedTaskId, errorCategory, maxAttempts, verifiedHandle);
|
|
868
1222
|
}
|
|
869
1223
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
870
1224
|
}
|
|
871
1225
|
}
|
|
872
1226
|
throw new Error("ask_app_status retry loop exited unexpectedly.");
|
|
873
1227
|
}
|
|
874
|
-
export async function openGrantedDispatchMcpApp(input) {
|
|
1228
|
+
export async function openGrantedDispatchMcpApp(input, options) {
|
|
1229
|
+
const screen = input.screen?.trim() ?? "";
|
|
875
1230
|
const view = input.view?.trim() ?? "";
|
|
876
1231
|
const hasPathInput = input.path != null;
|
|
877
|
-
|
|
878
|
-
const path = safeAppPath(input.path ?? (view ? undefined : "/"));
|
|
1232
|
+
let path = safeAppPath(input.path ?? (view || screen ? undefined : "/"));
|
|
879
1233
|
if (hasPathInput && !path) {
|
|
880
1234
|
throw new Error("path must be a safe app-relative route");
|
|
881
1235
|
}
|
|
882
1236
|
const target = await resolveGrantedDispatchMcpApp(input.app);
|
|
883
|
-
|
|
1237
|
+
const manifest = getGrantedAppManifest(target);
|
|
1238
|
+
let effectiveParams = input.params;
|
|
1239
|
+
if (screen && !path) {
|
|
1240
|
+
if (manifest?.screens && Object.keys(manifest.screens).length > 0) {
|
|
1241
|
+
const resolvedScreen = resolveManifestScreenPath(manifest, screen, input.params);
|
|
1242
|
+
if ("error" in resolvedScreen) {
|
|
1243
|
+
fail(`Cannot open screen "${screen}" on app "${target.id}": ${resolvedScreen.error}`, { errorCode: "invalid_app_route", statusCode: 400 });
|
|
1244
|
+
}
|
|
1245
|
+
path = safeAppPath(resolvedScreen.path);
|
|
1246
|
+
if (!path) {
|
|
1247
|
+
fail(`Resolved route "${resolvedScreen.path}" for screen "${screen}" on app "${target.id}" is not a safe app-relative route.`, { errorCode: "invalid_app_route", statusCode: 400 });
|
|
1248
|
+
}
|
|
1249
|
+
effectiveParams =
|
|
1250
|
+
Object.keys(resolvedScreen.remainingParams).length > 0
|
|
1251
|
+
? resolvedScreen.remainingParams
|
|
1252
|
+
: undefined;
|
|
1253
|
+
}
|
|
1254
|
+
else if (!view) {
|
|
1255
|
+
path = "/";
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
if (path) {
|
|
884
1259
|
assertAppCanOpenPath(target, path);
|
|
1260
|
+
if (manifest) {
|
|
1261
|
+
const manifestPath = stripTargetBasePath(target, path);
|
|
1262
|
+
const validation = validateAppManifestPath(manifest, manifestPath);
|
|
1263
|
+
if (!validation.valid) {
|
|
1264
|
+
const templates = validation.validTemplates
|
|
1265
|
+
.map((entry) => `${entry.screenId} (${entry.route})`)
|
|
1266
|
+
.join(", ");
|
|
1267
|
+
fail(`Invalid route "${path}" for app "${target.id}". Valid screens: ${templates}.`, { errorCode: "invalid_app_route", statusCode: 400 });
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
885
1271
|
const relUrl = path
|
|
886
|
-
? appendParamsToPath(path,
|
|
1272
|
+
? appendParamsToPath(path, effectiveParams)
|
|
887
1273
|
: buildDeepLink({
|
|
888
1274
|
app: target.id,
|
|
889
|
-
view,
|
|
890
|
-
params:
|
|
1275
|
+
view: view || screen,
|
|
1276
|
+
params: effectiveParams,
|
|
891
1277
|
});
|
|
892
|
-
const url =
|
|
1278
|
+
const url = joinAppBaseUrlAndPath(appHomeBaseUrl(target), relUrl);
|
|
893
1279
|
let embedSession = null;
|
|
894
1280
|
// Says why no session came back, so the caller can tell a plain link it
|
|
895
1281
|
// asked for from a panel that failed to open.
|
|
896
1282
|
let embedUnavailable;
|
|
897
|
-
if (input.embed) {
|
|
1283
|
+
if (options?.prefetchEmbed && input.embed !== false) {
|
|
1284
|
+
prefetchGrantedEmbedSession(target, url);
|
|
1285
|
+
}
|
|
1286
|
+
else if (input.embed) {
|
|
898
1287
|
let timer;
|
|
899
1288
|
const abort = new AbortController();
|
|
900
1289
|
try {
|
|
@@ -927,9 +1316,11 @@ export async function openGrantedDispatchMcpApp(input) {
|
|
|
927
1316
|
}
|
|
928
1317
|
return {
|
|
929
1318
|
app: target.id,
|
|
1319
|
+
...(screen ? { screen } : {}),
|
|
930
1320
|
...(view ? { view } : {}),
|
|
931
1321
|
...(path ? { path } : {}),
|
|
932
1322
|
url,
|
|
1323
|
+
...(input.focus === true ? { focus: true } : {}),
|
|
933
1324
|
...(input.embed === true ? { embed: true } : {}),
|
|
934
1325
|
...(input.chrome ? { chrome: input.chrome } : {}),
|
|
935
1326
|
...(embedSession?.startUrl ? { embedStartUrl: embedSession.startUrl } : {}),
|
|
@@ -1158,17 +1549,83 @@ async function appActionHeaders(request) {
|
|
|
1158
1549
|
if (headers === undefined)
|
|
1159
1550
|
return {};
|
|
1160
1551
|
for (const [name, value] of Object.entries(headers)) {
|
|
1161
|
-
if (name.toLowerCase() === "authorization" ||
|
|
1552
|
+
if (name.toLowerCase() === "authorization" ||
|
|
1553
|
+
name.toLowerCase() === "x-agent-native-browser-tab" ||
|
|
1554
|
+
name.toLowerCase() === "x-agent-native-viewport-mode" ||
|
|
1555
|
+
typeof value !== "string") {
|
|
1162
1556
|
throw new Error(`The app action header provider returned an invalid "${name}" header.`);
|
|
1163
1557
|
}
|
|
1164
1558
|
}
|
|
1165
1559
|
return headers;
|
|
1166
1560
|
}
|
|
1561
|
+
async function findRemoteAppOAuth(mcpUrl, ownerEmail) {
|
|
1562
|
+
try {
|
|
1563
|
+
const resource = new URL(mcpUrl).href;
|
|
1564
|
+
const servers = await listRemoteServers("user", ownerEmail);
|
|
1565
|
+
let reconnectServerId;
|
|
1566
|
+
for (const server of servers) {
|
|
1567
|
+
if (!server.oauthSecretKey ||
|
|
1568
|
+
!URL.canParse(server.url) ||
|
|
1569
|
+
new URL(server.url).href !== resource)
|
|
1570
|
+
continue;
|
|
1571
|
+
reconnectServerId ??= server.id;
|
|
1572
|
+
const options = {
|
|
1573
|
+
key: server.oauthSecretKey,
|
|
1574
|
+
scope: "user",
|
|
1575
|
+
scopeId: ownerEmail,
|
|
1576
|
+
serverUrl: mcpUrl,
|
|
1577
|
+
throwOnTransientRefreshFailure: true,
|
|
1578
|
+
};
|
|
1579
|
+
const token = await getMcpOAuthAccessToken(options);
|
|
1580
|
+
if (!token)
|
|
1581
|
+
continue;
|
|
1582
|
+
return {
|
|
1583
|
+
serverId: server.id,
|
|
1584
|
+
credential: {
|
|
1585
|
+
strategy: "oauth",
|
|
1586
|
+
token,
|
|
1587
|
+
oauthAccessRefresh: {
|
|
1588
|
+
identity: createHash("sha256")
|
|
1589
|
+
.update(JSON.stringify([ownerEmail, server.oauthSecretKey, resource]))
|
|
1590
|
+
.digest("hex"),
|
|
1591
|
+
refresh: () => getMcpOAuthAccessToken({ ...options, forceRefresh: true }),
|
|
1592
|
+
},
|
|
1593
|
+
},
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
return reconnectServerId ? { serverId: reconnectServerId } : {};
|
|
1597
|
+
}
|
|
1598
|
+
catch {
|
|
1599
|
+
throw new NoWriteError("The app's saved connection is unavailable. Try again.", {
|
|
1600
|
+
errorCode: "app_connection_unavailable",
|
|
1601
|
+
statusCode: 503,
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
function appOAuthStartUrl(target, mcpUrl, serverId) {
|
|
1606
|
+
const params = serverId
|
|
1607
|
+
? new URLSearchParams({ scope: "user", serverId })
|
|
1608
|
+
: new URLSearchParams({
|
|
1609
|
+
scope: "user",
|
|
1610
|
+
name: `app-${createHash("sha256").update(mcpUrl).digest("hex").slice(0, 16)}`,
|
|
1611
|
+
url: mcpUrl,
|
|
1612
|
+
description: target.name,
|
|
1613
|
+
});
|
|
1614
|
+
return `${dispatchSelfBaseUrl()}/_agent-native/mcp/servers/oauth/start?${params}`;
|
|
1615
|
+
}
|
|
1616
|
+
function appAuthorizationRequired(target, mcpUrl, serverId) {
|
|
1617
|
+
const authorizationUrl = appOAuthStartUrl(target, mcpUrl, serverId);
|
|
1618
|
+
throw new NoWriteError(`Connect ${target.name} to use its actions.`, {
|
|
1619
|
+
errorCode: "authorization_required",
|
|
1620
|
+
statusCode: 401,
|
|
1621
|
+
details: { app: target.id, authorizationUrl },
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1167
1624
|
// Runs `withClient` against a connected MCP client for the granted app, signed
|
|
1168
1625
|
// as the requesting user, the way embed sessions reach the same target. Without a
|
|
1169
1626
|
// header provider no per-turn grant is attached, so a target action that
|
|
1170
1627
|
// requires a user turn refuses with its own error code.
|
|
1171
|
-
async function withGrantedAppMcp(app, action, withClient) {
|
|
1628
|
+
async function withGrantedAppMcp(app, action, withClient, options) {
|
|
1172
1629
|
if (!dispatchDirectAppActionsEnabled()) {
|
|
1173
1630
|
fail("Direct app actions are not enabled on this Dispatch deployment.", {
|
|
1174
1631
|
errorCode: "direct_app_actions_disabled",
|
|
@@ -1188,14 +1645,43 @@ async function withGrantedAppMcp(app, action, withClient) {
|
|
|
1188
1645
|
throw new Error("App actions need an HTTPS target endpoint.");
|
|
1189
1646
|
}
|
|
1190
1647
|
const firstPartyMcp = isWorkspaceSsoAppUrl({ id: target.id, url: mcpUrl }, { nodeEnv: "production", environmentLane: requestEnvironmentLane() });
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
ownerEmail
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1648
|
+
let remote;
|
|
1649
|
+
const loadRemote = async () => {
|
|
1650
|
+
remote ??= await findRemoteAppOAuth(mcpUrl, ownerEmail);
|
|
1651
|
+
return remote;
|
|
1652
|
+
};
|
|
1653
|
+
if (!firstPartyMcp &&
|
|
1654
|
+
new URL(mcpUrl).origin !== new URL(dispatchSelfBaseUrl()).origin) {
|
|
1655
|
+
await loadRemote();
|
|
1656
|
+
}
|
|
1657
|
+
const prepared = remote?.credential
|
|
1658
|
+
? undefined
|
|
1659
|
+
: await createTargetMcpUserCredentials({
|
|
1660
|
+
mcpUrl,
|
|
1661
|
+
ownerEmail,
|
|
1662
|
+
fullCatalog: true,
|
|
1663
|
+
allowMissing: true,
|
|
1664
|
+
...(firstPartyMcp ? { firstPartyMcp: true } : {}),
|
|
1665
|
+
...(orgId !== undefined ? { orgId } : {}),
|
|
1666
|
+
});
|
|
1667
|
+
const credentials = remote?.credential
|
|
1668
|
+
? [remote.credential]
|
|
1669
|
+
: [...(prepared?.credentials ?? [])];
|
|
1670
|
+
if (credentials.length === 0) {
|
|
1671
|
+
const oauth = await loadRemote();
|
|
1672
|
+
if (oauth.credential)
|
|
1673
|
+
credentials.push(oauth.credential);
|
|
1674
|
+
else
|
|
1675
|
+
appAuthorizationRequired(target, mcpUrl, oauth.serverId);
|
|
1676
|
+
}
|
|
1677
|
+
const requestedViewportMode = options?.viewportMode ?? getRequestRunContext()?.viewportMode;
|
|
1678
|
+
const childBrowserTabId = action === undefined || requestedViewportMode === "background"
|
|
1679
|
+
? undefined
|
|
1680
|
+
: await resolveDispatchChildBrowserTab(target);
|
|
1681
|
+
const viewportMode = action === undefined
|
|
1682
|
+
? undefined
|
|
1683
|
+
: (requestedViewportMode ??
|
|
1684
|
+
(childBrowserTabId ? "foreground" : undefined));
|
|
1199
1685
|
const extraHeaders = await appActionHeaders({
|
|
1200
1686
|
app: target.id,
|
|
1201
1687
|
action,
|
|
@@ -1203,15 +1689,24 @@ async function withGrantedAppMcp(app, action, withClient) {
|
|
|
1203
1689
|
...(orgId !== undefined ? { orgId } : {}),
|
|
1204
1690
|
});
|
|
1205
1691
|
const serverId = "target";
|
|
1206
|
-
let orgMemberTried =
|
|
1692
|
+
let orgMemberTried = credentials.some((credential) => credential.strategy === "org-member-delegation");
|
|
1207
1693
|
for (const [index, credential] of credentials.entries()) {
|
|
1208
1694
|
const manager = new McpClientManager({
|
|
1209
1695
|
servers: {
|
|
1210
1696
|
[serverId]: {
|
|
1211
1697
|
type: "http",
|
|
1212
1698
|
url: mcpUrl,
|
|
1699
|
+
...(credential.oauthAccessRefresh
|
|
1700
|
+
? { oauthAccessRefresh: credential.oauthAccessRefresh }
|
|
1701
|
+
: {}),
|
|
1213
1702
|
headers: {
|
|
1214
1703
|
...extraHeaders,
|
|
1704
|
+
...(childBrowserTabId
|
|
1705
|
+
? { "x-agent-native-browser-tab": childBrowserTabId }
|
|
1706
|
+
: {}),
|
|
1707
|
+
...(viewportMode
|
|
1708
|
+
? { "x-agent-native-viewport-mode": viewportMode }
|
|
1709
|
+
: {}),
|
|
1215
1710
|
Authorization: `Bearer ${credential.token}`,
|
|
1216
1711
|
...(credential.firstPartyMcp
|
|
1217
1712
|
? { "x-agent-native-mcp-inline-apps": "1" }
|
|
@@ -1224,19 +1719,36 @@ async function withGrantedAppMcp(app, action, withClient) {
|
|
|
1224
1719
|
await manager.start();
|
|
1225
1720
|
const status = manager.getConnectErrorStatus(serverId);
|
|
1226
1721
|
if (status === 401 || status === 403) {
|
|
1227
|
-
|
|
1722
|
+
if (credential.strategy === "oauth") {
|
|
1723
|
+
throw new NoWriteError(`The ${target.name} app rejected the saved connection.`, {
|
|
1724
|
+
errorCode: "app_connection_rejected",
|
|
1725
|
+
statusCode: 403,
|
|
1726
|
+
details: {
|
|
1727
|
+
app: target.id,
|
|
1728
|
+
authorizationUrl: appOAuthStartUrl(target, mcpUrl, remote?.serverId),
|
|
1729
|
+
},
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1228
1732
|
if (index === credentials.length - 1 && !orgMemberTried) {
|
|
1229
1733
|
orgMemberTried = true;
|
|
1230
|
-
const orgMember = await prepared
|
|
1734
|
+
const orgMember = await prepared?.loadOrgMemberCredential();
|
|
1231
1735
|
if (orgMember)
|
|
1232
1736
|
credentials.push(orgMember);
|
|
1233
1737
|
}
|
|
1234
1738
|
if (index < credentials.length - 1)
|
|
1235
1739
|
continue;
|
|
1236
|
-
|
|
1740
|
+
const oauth = await loadRemote();
|
|
1741
|
+
if (oauth.credential) {
|
|
1742
|
+
credentials.push(oauth.credential);
|
|
1743
|
+
continue;
|
|
1744
|
+
}
|
|
1745
|
+
appAuthorizationRequired(target, mcpUrl, oauth.serverId);
|
|
1237
1746
|
}
|
|
1238
1747
|
if (!manager.hasServer(serverId)) {
|
|
1239
|
-
throw new
|
|
1748
|
+
throw new NoWriteError(`The ${target.name} app's actions are unreachable.`, {
|
|
1749
|
+
errorCode: "app_connection_unreachable",
|
|
1750
|
+
statusCode: 502,
|
|
1751
|
+
});
|
|
1240
1752
|
}
|
|
1241
1753
|
return await withClient(manager, serverId);
|
|
1242
1754
|
}
|
|
@@ -1246,7 +1758,7 @@ async function withGrantedAppMcp(app, action, withClient) {
|
|
|
1246
1758
|
});
|
|
1247
1759
|
}
|
|
1248
1760
|
}
|
|
1249
|
-
|
|
1761
|
+
appAuthorizationRequired(target, mcpUrl, remote?.serverId);
|
|
1250
1762
|
}
|
|
1251
1763
|
export async function listGrantedDispatchMcpAppActions(app, names) {
|
|
1252
1764
|
return withGrantedAppMcp(app, undefined, async (manager, serverId) => manager
|
|
@@ -1260,6 +1772,9 @@ export async function listGrantedDispatchMcpAppActions(app, names) {
|
|
|
1260
1772
|
? tool.description
|
|
1261
1773
|
: (tool.description.split(/(?<=\.)\s/)[0] ?? "").slice(0, 160),
|
|
1262
1774
|
...(detailed ? { inputSchema: tool.inputSchema } : {}),
|
|
1775
|
+
...(detailed && tool.annotations?.destructiveHint === true
|
|
1776
|
+
? { destructive: true }
|
|
1777
|
+
: {}),
|
|
1263
1778
|
...(tool.annotations?.readOnlyHint === true
|
|
1264
1779
|
? { readOnly: true }
|
|
1265
1780
|
: {}),
|
|
@@ -1279,14 +1794,17 @@ function approvalReviewFrom(result) {
|
|
|
1279
1794
|
...(typeof expiresAt === "number" ? { expiresAt } : {}),
|
|
1280
1795
|
};
|
|
1281
1796
|
}
|
|
1282
|
-
export async function callGrantedDispatchMcpAppAction(app, action, args) {
|
|
1797
|
+
export async function callGrantedDispatchMcpAppAction(app, action, args, options) {
|
|
1283
1798
|
if (TARGET_APP_HIDDEN_ACTIONS.has(action)) {
|
|
1284
|
-
throw new
|
|
1799
|
+
throw new NoWriteError(`"${action}" is not an app action.`, {
|
|
1800
|
+
errorCode: "app_action_not_found",
|
|
1801
|
+
statusCode: 404,
|
|
1802
|
+
});
|
|
1285
1803
|
}
|
|
1286
1804
|
return withGrantedAppMcp(app, action, async (manager, serverId) => {
|
|
1287
1805
|
const toolName = buildMcpToolName(serverId, action);
|
|
1288
1806
|
if (!manager.getTool(toolName)) {
|
|
1289
|
-
throw new
|
|
1807
|
+
throw new NoWriteError(`The app has no action named "${action}". Call list_app_actions to see them.`, { errorCode: "app_action_not_found", statusCode: 404 });
|
|
1290
1808
|
}
|
|
1291
1809
|
let result;
|
|
1292
1810
|
try {
|
|
@@ -1295,9 +1813,11 @@ export async function callGrantedDispatchMcpAppAction(app, action, args) {
|
|
|
1295
1813
|
catch (error) {
|
|
1296
1814
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1297
1815
|
if (mcpToolCallWasNotSent(error)) {
|
|
1298
|
-
|
|
1816
|
+
throw new NoWriteError(`The app action did not run (${reason}).`, {
|
|
1299
1817
|
errorCode: "app_action_not_sent",
|
|
1300
|
-
statusCode: error.statusCode === 403
|
|
1818
|
+
statusCode: error.statusCode === 403
|
|
1819
|
+
? 403
|
|
1820
|
+
: 502,
|
|
1301
1821
|
});
|
|
1302
1822
|
}
|
|
1303
1823
|
fail(`The app action failed before returning a result (${reason}). Its write outcome may be unknown; inspect the app before retrying.`, { errorCode: "app_action_outcome_unknown", statusCode: 502 });
|
|
@@ -1320,7 +1840,7 @@ export async function callGrantedDispatchMcpAppAction(app, action, args) {
|
|
|
1320
1840
|
: {}),
|
|
1321
1841
|
content: result.content,
|
|
1322
1842
|
};
|
|
1323
|
-
});
|
|
1843
|
+
}, options);
|
|
1324
1844
|
}
|
|
1325
1845
|
async function createTargetMcpUserCredentials(input) {
|
|
1326
1846
|
const audience = canonicalA2AAudience(input.mcpUrl);
|
|
@@ -1392,7 +1912,7 @@ async function createTargetMcpUserCredentials(input) {
|
|
|
1392
1912
|
if (orgMemberCredential)
|
|
1393
1913
|
credentials.push(orgMemberCredential);
|
|
1394
1914
|
}
|
|
1395
|
-
if (credentials.length === 0) {
|
|
1915
|
+
if (credentials.length === 0 && !input.allowMissing) {
|
|
1396
1916
|
throw new Error("Cross-app embed sessions require a deployment A2A secret or an organization secret with member delegation enabled on the target.");
|
|
1397
1917
|
}
|
|
1398
1918
|
return { credentials, loadOrgMemberCredential };
|
|
@@ -1408,7 +1928,7 @@ async function resolveEmbedTarget(input, options) {
|
|
|
1408
1928
|
return {
|
|
1409
1929
|
app: explicitApp,
|
|
1410
1930
|
path,
|
|
1411
|
-
url:
|
|
1931
|
+
url: joinAppBaseUrlAndPath(appHomeBaseUrl(explicitApp), path),
|
|
1412
1932
|
};
|
|
1413
1933
|
}
|
|
1414
1934
|
if (!input.url) {
|
|
@@ -1428,7 +1948,7 @@ async function resolveEmbedTarget(input, options) {
|
|
|
1428
1948
|
return {
|
|
1429
1949
|
app: explicitApp,
|
|
1430
1950
|
path,
|
|
1431
|
-
url:
|
|
1951
|
+
url: joinAppBaseUrlAndPath(appHomeBaseUrl(explicitApp), path),
|
|
1432
1952
|
};
|
|
1433
1953
|
}
|
|
1434
1954
|
const apps = explicitApp ? [explicitApp] : await options.listApps();
|
|
@@ -1442,7 +1962,11 @@ async function resolveEmbedTarget(input, options) {
|
|
|
1442
1962
|
if (!path)
|
|
1443
1963
|
throw new Error("Embed URL path is not safe.");
|
|
1444
1964
|
assertAppCanOpenPath(target, path);
|
|
1445
|
-
return {
|
|
1965
|
+
return {
|
|
1966
|
+
app: target,
|
|
1967
|
+
path,
|
|
1968
|
+
url: joinAppBaseUrlAndPath(appHomeBaseUrl(target), path),
|
|
1969
|
+
};
|
|
1446
1970
|
}
|
|
1447
1971
|
async function resolveDispatchEmbedTarget(input) {
|
|
1448
1972
|
return resolveEmbedTarget(input, {
|
|
@@ -1476,31 +2000,123 @@ async function createDispatchSelfEmbedSession(input) {
|
|
|
1476
2000
|
app: DISPATCH_APP_ID,
|
|
1477
2001
|
};
|
|
1478
2002
|
}
|
|
1479
|
-
function publicEmbedSession({ startUrl, targetPath, expiresAt, app, }) {
|
|
2003
|
+
function publicEmbedSession({ startUrl, targetPath, childBrowserTabId, expiresAt, app, }) {
|
|
1480
2004
|
if (!startUrl)
|
|
1481
2005
|
throw new Error("Document embed requires a browser start URL.");
|
|
1482
2006
|
return {
|
|
1483
2007
|
startUrl,
|
|
1484
2008
|
...(targetPath ? { targetPath } : {}),
|
|
2009
|
+
...(childBrowserTabId ? { childBrowserTabId } : {}),
|
|
1485
2010
|
...(typeof expiresAt === "number" ? { expiresAt } : {}),
|
|
1486
2011
|
app,
|
|
1487
2012
|
};
|
|
1488
2013
|
}
|
|
2014
|
+
const pendingGrantedEmbeds = new Map();
|
|
2015
|
+
function grantedEmbedPrefetchKey(ownerEmail, target) {
|
|
2016
|
+
const request = getRequestContext();
|
|
2017
|
+
return JSON.stringify([
|
|
2018
|
+
ownerEmail,
|
|
2019
|
+
getRequestOrgId(),
|
|
2020
|
+
request?.requestOrigin,
|
|
2021
|
+
request?.identityAuthenticatedAtMs,
|
|
2022
|
+
request?.mcpCredentialIssuedAtMs,
|
|
2023
|
+
request?.a2aIdentityAssurance,
|
|
2024
|
+
request?.credentialScope,
|
|
2025
|
+
target.app.id,
|
|
2026
|
+
appMcpUrl(target.app),
|
|
2027
|
+
target.url,
|
|
2028
|
+
]);
|
|
2029
|
+
}
|
|
2030
|
+
function prefetchGrantedEmbedSession(app, url) {
|
|
2031
|
+
const ownerEmail = getRequestUserEmail();
|
|
2032
|
+
if (!ownerEmail || app.id === DISPATCH_APP_ID)
|
|
2033
|
+
return;
|
|
2034
|
+
const work = (async () => {
|
|
2035
|
+
const target = await resolveDispatchEmbedTarget({ resolvedApp: app, url });
|
|
2036
|
+
const key = grantedEmbedPrefetchKey(ownerEmail, target);
|
|
2037
|
+
if (pendingGrantedEmbeds.has(key))
|
|
2038
|
+
return;
|
|
2039
|
+
if (pendingGrantedEmbeds.size >= PENDING_EMBED_LIMIT) {
|
|
2040
|
+
pendingGrantedEmbeds.values().next().value?.abort();
|
|
2041
|
+
}
|
|
2042
|
+
const controller = new AbortController();
|
|
2043
|
+
const result = Promise.race([
|
|
2044
|
+
createEmbedSessionForResolvedApp({
|
|
2045
|
+
ownerEmail,
|
|
2046
|
+
orgId: getRequestOrgId(),
|
|
2047
|
+
target,
|
|
2048
|
+
chrome: "minimal",
|
|
2049
|
+
bindBrowserTab: true,
|
|
2050
|
+
signal: controller.signal,
|
|
2051
|
+
}),
|
|
2052
|
+
new Promise((_resolve, reject) => {
|
|
2053
|
+
controller.signal.addEventListener("abort", () => reject(controller.signal.reason), { once: true });
|
|
2054
|
+
}),
|
|
2055
|
+
]);
|
|
2056
|
+
const release = () => {
|
|
2057
|
+
clearTimeout(timer);
|
|
2058
|
+
if (pendingGrantedEmbeds.get(key) === entry)
|
|
2059
|
+
pendingGrantedEmbeds.delete(key);
|
|
2060
|
+
};
|
|
2061
|
+
const abort = () => {
|
|
2062
|
+
release();
|
|
2063
|
+
controller.abort();
|
|
2064
|
+
};
|
|
2065
|
+
const timer = setTimeout(abort, OPEN_APP_EMBED_WAIT_MS);
|
|
2066
|
+
timer.unref();
|
|
2067
|
+
const entry = { result, release, abort };
|
|
2068
|
+
pendingGrantedEmbeds.set(key, entry);
|
|
2069
|
+
try {
|
|
2070
|
+
await result;
|
|
2071
|
+
}
|
|
2072
|
+
catch {
|
|
2073
|
+
release();
|
|
2074
|
+
}
|
|
2075
|
+
})().catch(() => { });
|
|
2076
|
+
const waitUntil = getRequestRunContext()?.waitUntil ?? platformWaitUntil();
|
|
2077
|
+
waitUntil?.(work);
|
|
2078
|
+
}
|
|
2079
|
+
async function takePrefetchedGrantedEmbedSession(ownerEmail, target) {
|
|
2080
|
+
const key = grantedEmbedPrefetchKey(ownerEmail, target);
|
|
2081
|
+
const entry = pendingGrantedEmbeds.get(key);
|
|
2082
|
+
if (!entry)
|
|
2083
|
+
return;
|
|
2084
|
+
pendingGrantedEmbeds.delete(key);
|
|
2085
|
+
const claimDeadline = setTimeout(entry.abort, BROWSER_EMBED_PREFETCH_WAIT_MS);
|
|
2086
|
+
try {
|
|
2087
|
+
const session = await entry.result;
|
|
2088
|
+
if (session.expiresAt === undefined || session.expiresAt > Date.now())
|
|
2089
|
+
return session;
|
|
2090
|
+
}
|
|
2091
|
+
catch {
|
|
2092
|
+
// coercion-ok: A failed prefetch requires the normal foreground mint.
|
|
2093
|
+
}
|
|
2094
|
+
finally {
|
|
2095
|
+
clearTimeout(claimDeadline);
|
|
2096
|
+
entry.release();
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
1489
2099
|
async function createGrantedDispatchMcpEmbedSessionResult(input) {
|
|
1490
2100
|
const userEmail = getRequestUserEmail();
|
|
1491
2101
|
if (!userEmail)
|
|
1492
2102
|
throw new Error("no authenticated user");
|
|
1493
2103
|
const target = await resolveDispatchEmbedTarget(input);
|
|
2104
|
+
if (input.bindBrowserTab && input.chrome === "minimal") {
|
|
2105
|
+
const prefetched = await takePrefetchedGrantedEmbedSession(userEmail, target);
|
|
2106
|
+
if (prefetched)
|
|
2107
|
+
return prefetched;
|
|
2108
|
+
}
|
|
1494
2109
|
return createEmbedSessionForResolvedApp({
|
|
1495
2110
|
ownerEmail: userEmail,
|
|
1496
2111
|
orgId: getRequestOrgId(),
|
|
1497
2112
|
target,
|
|
1498
2113
|
chrome: input.chrome,
|
|
1499
2114
|
runtime: input.runtime,
|
|
2115
|
+
bindBrowserTab: input.bindBrowserTab,
|
|
1500
2116
|
...(input.signal ? { signal: input.signal } : {}),
|
|
1501
2117
|
});
|
|
1502
2118
|
}
|
|
1503
|
-
export async function createGrantedDispatchMcpEmbedSession(input) {
|
|
2119
|
+
export async function createGrantedDispatchMcpEmbedSession(input, options) {
|
|
1504
2120
|
// Copy only public fields so a caller cannot supply a pre-resolved app.
|
|
1505
2121
|
const { app, url, path, chrome } = input;
|
|
1506
2122
|
return publicEmbedSession(await createGrantedDispatchMcpEmbedSessionResult({
|
|
@@ -1508,6 +2124,7 @@ export async function createGrantedDispatchMcpEmbedSession(input) {
|
|
|
1508
2124
|
...(url === undefined ? {} : { url }),
|
|
1509
2125
|
...(path === undefined ? {} : { path }),
|
|
1510
2126
|
...(chrome === undefined ? {} : { chrome }),
|
|
2127
|
+
...(options?.bindBrowserTab ? { bindBrowserTab: true } : {}),
|
|
1511
2128
|
}));
|
|
1512
2129
|
}
|
|
1513
2130
|
async function createEmbedSessionForResolvedGrantedApp(input) {
|
|
@@ -1546,15 +2163,14 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1546
2163
|
appBaseUrl: appBaseUrl(target.app),
|
|
1547
2164
|
};
|
|
1548
2165
|
}
|
|
1549
|
-
const targetMcpUrl =
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
});
|
|
2166
|
+
const targetMcpUrl = input.runtime && target.app.workspaceMount
|
|
2167
|
+
? `${appHomeBaseUrl(target.app)}/mcp`
|
|
2168
|
+
: appMcpUrl(target.app);
|
|
2169
|
+
const firstPartyMcp = isWorkspaceSsoAppUrl({ id: target.app.id, url: targetMcpUrl }, {
|
|
2170
|
+
nodeEnv: "production",
|
|
2171
|
+
environmentLane: requestEnvironmentLane(),
|
|
2172
|
+
registryRaw: getAppConfig().auth.identitySsoAppRegistryJson,
|
|
2173
|
+
});
|
|
1558
2174
|
if (input.runtime && !firstPartyMcp)
|
|
1559
2175
|
throw new Error("App chat requires a first-party workspace target.");
|
|
1560
2176
|
const targetCredentials = await createTargetMcpUserCredentials({
|
|
@@ -1569,6 +2185,13 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1569
2185
|
mcpUrl: targetMcpUrl,
|
|
1570
2186
|
url: target.url,
|
|
1571
2187
|
});
|
|
2188
|
+
const childBrowserTabId = input.bindBrowserTab
|
|
2189
|
+
? crypto.randomUUID()
|
|
2190
|
+
: undefined;
|
|
2191
|
+
const launchUrl = new URL(target.url);
|
|
2192
|
+
if (childBrowserTabId) {
|
|
2193
|
+
launchUrl.searchParams.set(DISPATCH_CHILD_BROWSER_TAB_PARAM, childBrowserTabId);
|
|
2194
|
+
}
|
|
1572
2195
|
let parsed;
|
|
1573
2196
|
const credentials = [...targetCredentials.credentials];
|
|
1574
2197
|
for (const [index, credential] of credentials.entries()) {
|
|
@@ -1581,7 +2204,7 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1581
2204
|
const result = await callTargetCreateEmbedSession({
|
|
1582
2205
|
mcpUrl: targetMcpUrl,
|
|
1583
2206
|
token: credential.token,
|
|
1584
|
-
url: target.url,
|
|
2207
|
+
url: childBrowserTabId ? launchUrl.toString() : target.url,
|
|
1585
2208
|
...(chrome !== undefined ? { chrome } : {}),
|
|
1586
2209
|
...(input.runtime ? { runtime: input.runtime } : {}),
|
|
1587
2210
|
...(input.signal ? { signal: input.signal } : {}),
|
|
@@ -1634,7 +2257,9 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1634
2257
|
targetPath: parsed.targetPath,
|
|
1635
2258
|
expiresAt: parsed.expiresAt,
|
|
1636
2259
|
app: target.app.id,
|
|
1637
|
-
appBaseUrl:
|
|
2260
|
+
appBaseUrl: target.app.workspaceMount
|
|
2261
|
+
? appHomeBaseUrl(target.app)
|
|
2262
|
+
: appChatBaseUrl(target.app),
|
|
1638
2263
|
};
|
|
1639
2264
|
}
|
|
1640
2265
|
if (!parsed.startUrl || parsed.token) {
|
|
@@ -1654,8 +2279,19 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1654
2279
|
app: target.app.id,
|
|
1655
2280
|
appBaseUrl: appChatBaseUrl(target.app),
|
|
1656
2281
|
};
|
|
1657
|
-
if (parsed.targetPath)
|
|
2282
|
+
if (parsed.targetPath) {
|
|
1658
2283
|
output.targetPath = parsed.targetPath;
|
|
2284
|
+
const safePath = childBrowserTabId && safeAppPath(parsed.targetPath);
|
|
2285
|
+
if (safePath) {
|
|
2286
|
+
const reported = new URL(safePath, launchUrl.origin);
|
|
2287
|
+
if (reported.searchParams.get(DISPATCH_CHILD_BROWSER_TAB_PARAM) ===
|
|
2288
|
+
childBrowserTabId) {
|
|
2289
|
+
reported.searchParams.delete(DISPATCH_CHILD_BROWSER_TAB_PARAM);
|
|
2290
|
+
output.targetPath = reported.pathname + reported.search + reported.hash;
|
|
2291
|
+
output.childBrowserTabId = childBrowserTabId;
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
1659
2295
|
if (typeof parsed.expiresAt === "number")
|
|
1660
2296
|
output.expiresAt = parsed.expiresAt;
|
|
1661
2297
|
return output;
|
|
@@ -1698,12 +2334,18 @@ async function createWorkspaceSsoEmbedSessionResult(input) {
|
|
|
1698
2334
|
target,
|
|
1699
2335
|
chrome: input.chrome,
|
|
1700
2336
|
runtime: input.runtime,
|
|
1701
|
-
|
|
2337
|
+
bindBrowserTab: input.bindBrowserTab,
|
|
1702
2338
|
});
|
|
1703
2339
|
}
|
|
1704
|
-
export async function createWorkspaceSsoEmbedSession(input) {
|
|
2340
|
+
export async function createWorkspaceSsoEmbedSession(input, options) {
|
|
1705
2341
|
const { app, url, path, chrome } = input;
|
|
1706
|
-
return publicEmbedSession(await createWorkspaceSsoEmbedSessionResult({
|
|
2342
|
+
return publicEmbedSession(await createWorkspaceSsoEmbedSessionResult({
|
|
2343
|
+
app,
|
|
2344
|
+
url,
|
|
2345
|
+
path,
|
|
2346
|
+
chrome,
|
|
2347
|
+
...(options?.bindBrowserTab ? { bindBrowserTab: true } : {}),
|
|
2348
|
+
}));
|
|
1707
2349
|
}
|
|
1708
2350
|
export async function createWorkspaceSsoEmbedSessionForWorkspaceAppChat(appId) {
|
|
1709
2351
|
const session = await createWorkspaceSsoEmbedSessionResult({
|