@agent-native/dispatch 0.40.40 → 0.40.41-beta-dispatch-embed-01a15dc9-20261027050558
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 +42 -0
- package/dist/actions/create_embed_session.js +1 -0
- package/dist/actions/create_embed_session.js.map +1 -1
- package/dist/actions/delete-destination.d.ts +12 -12
- package/dist/actions/provider-api-register.d.ts +13 -13
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +8 -11
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/workspace-app-host.d.ts.map +1 -1
- package/dist/components/workspace-app-host.js +23 -10
- package/dist/components/workspace-app-host.js.map +1 -1
- package/dist/lib/workspace-apps.d.ts +2 -2
- package/dist/lib/workspace-apps.d.ts.map +1 -1
- package/dist/lib/workspace-apps.js +35 -5
- package/dist/lib/workspace-apps.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +173 -48
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/community-apps.js +1 -1
- package/dist/server/lib/community-apps.js.map +1 -1
- package/dist/server/lib/mcp-gateway.d.ts +1 -0
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +170 -38
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/dist/server/lib/provider-api.d.ts +2 -2
- package/dist/shared/workspace-app-route.d.ts +2 -0
- package/dist/shared/workspace-app-route.d.ts.map +1 -0
- package/dist/shared/workspace-app-route.js +4 -0
- package/dist/shared/workspace-app-route.js.map +1 -0
- package/package.json +4 -4
- package/src/actions/create_embed_session.ts +1 -0
- package/src/actions/index.spec.ts +3 -0
- package/src/components/layout/Layout.spec.tsx +39 -9
- package/src/components/layout/Layout.tsx +19 -40
- package/src/components/workspace-app-host.spec.tsx +88 -1
- package/src/components/workspace-app-host.tsx +30 -9
- package/src/lib/workspace-apps.spec.ts +64 -5
- package/src/lib/workspace-apps.ts +36 -6
- package/src/routes/pages/apps.$appId.spec.tsx +21 -3
- package/src/server/lib/app-creation-store.spec.ts +502 -11
- package/src/server/lib/app-creation-store.ts +198 -50
- package/src/server/lib/community-apps.ts +1 -1
- package/src/server/lib/mcp-gateway.spec.ts +396 -9
- package/src/server/lib/mcp-gateway.ts +209 -45
- package/src/shared/workspace-app-route.ts +3 -0
|
@@ -33,7 +33,7 @@ export const CURATED_COMMUNITY_APP_SOURCES = [
|
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
path: "actions/generate-qr-code.spec.ts",
|
|
36
|
-
blobSha: "
|
|
36
|
+
blobSha: "42a1a84ecb421e1e6435cc2e7fd00e2f4f2e1ea9",
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
path: "actions/generate-qr-code.ts",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"community-apps.js","sourceRoot":"","sources":["../../../src/server/lib/community-apps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EACL,gCAAgC,EAChC,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,oCAAoC,GAErC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,WAAW,GACZ,MAAM,qBAAqB,CAAC;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AC;YACtB,iBAAiB,EAAE,KAAK;YACxB,eAAe,EAAE,IAAI;SACtB,CAAC,CACH,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC;QAClC,IAAI,KAAK,EAAE,iBAAiB,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;YAC3C,OAAO,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,KAAK;YAAE,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAC/C,OAAO,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,WAAW,CAAC;QAChB,MAAM,EAAE,2CAA2C;QACnD,UAAU,EAAE,eAAe;QAC3B,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,aAAa,MAAM,CAAC,IAAI,6BAA6B;QAC9D,QAAQ,EAAE;YACR,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;YAClD,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB;KACF,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,MAAM,EAAE,MAAM,EAEzB,CAAC;AACJ,CAAC","sourcesContent":["import { fail } from \"@agent-native/core/action\";\nimport { getUserLabEnabled } from \"@agent-native/core/labs/server\";\nimport {\n getWorkspaceAppIdValidationError,\n normalizeWorkspaceAppId,\n} from \"@agent-native/core/shared\";\nimport {\n BUILTIN_AGENT_CATALOG_IDS,\n HIDDEN_FIRST_PARTY_AGENT_IDS,\n} from \"@agent-native/core/shared/first-party-agents\";\n\nimport { COMMUNITY_APPS_LAB } from \"../../shared/labs.js\";\nimport type {\n StartWorkspaceAppCreationResult,\n WorkspaceAppSummary,\n} from \"./app-creation-store.js\";\nimport {\n getAppCreationSettings,\n getWorkspaceInfo,\n isLocalAppCreationRuntime,\n listWorkspaceApps,\n startWorkspaceAppCreation,\n} from \"./app-creation-store.js\";\nimport {\n loadPinnedCommunitySourceAttachments,\n type PinnedCommunitySource,\n} from \"./community-source.js\";\nimport { CURATED_WORKSPACE_TEMPLATES } from \"./curated-workspace-templates.js\";\nimport {\n currentOrgId,\n currentOwnerEmail,\n recordAudit,\n} from \"./dispatch-store.js\";\n\nexport interface CuratedCommunityAppSource extends PinnedCommunitySource {\n id: string;\n name: string;\n description: string;\n appId: string;\n license: string;\n provenance: string;\n}\n\nexport interface CuratedCommunityApp extends CuratedCommunityAppSource {\n installed: boolean;\n pending: boolean;\n installable: boolean;\n installUnavailableReason?:\n | \"workspace-required\"\n | \"app-id-conflict\"\n | \"builder-install-unverified\";\n}\n\nexport const CURATED_COMMUNITY_APP_SOURCES: readonly CuratedCommunityAppSource[] =\n [\n {\n id: \"community-qr\",\n name: \"QR\",\n description: \"Generate public PNG or SVG QR images from links or text.\",\n appId: \"community-qr\",\n repo: \"BuilderIO/agent-native\",\n ref: \"main\",\n license: \"MIT\",\n provenance:\n \"Reviewed Agent-Native Framework template, sanitized for independent installation.\",\n templatePath: \"templates/community/qr\",\n files: [\n {\n path: \"AGENTS.md\",\n blobSha: \"7dc9e18bc426dfd21526f91225cc615759450816\",\n },\n {\n path: \"LICENSE\",\n blobSha: \"69c7182efb3eb1a8b7f6fd5989f3e4fd737d0645\",\n },\n {\n path: \"README.md\",\n blobSha: \"e05e72bb9213732f56ccbc96f7dcb1c3a064cb19\",\n },\n {\n path: \"actions/generate-qr-code.spec.ts\",\n blobSha: \"3459217b7252c6ee0076c68cfdb83001cc74f29e\",\n },\n {\n path: \"actions/generate-qr-code.ts\",\n blobSha: \"98d30e218bfed796d5e402d5ce19a8626d8da0cf\",\n },\n {\n path: \"actions/run.ts\",\n blobSha: \"b46ab15b667c34741364ba08f010f7aca9d0f02e\",\n },\n {\n path: \"agent-native.json\",\n blobSha: \"accc32476792b84557f69e2b48b317c27b5546dc\",\n },\n {\n path: \"package.json\",\n blobSha: \"5815e6665e06176df9954183e89b234acf5c5c37\",\n },\n {\n path: \"server/db/index.ts\",\n blobSha: \"17007b456530f75a72e7209bdfe9f4bd4c9224e0\",\n },\n {\n path: \"server/db/schema.ts\",\n blobSha: \"2e4cd01c5f46463e78bc7beb6e954f3e526c0b57\",\n },\n {\n path: \"server/plugins/db.ts\",\n blobSha: \"78a5b431c1ad1ea14f593123c090f5376a36df10\",\n },\n {\n path: \"tsconfig.json\",\n blobSha: \"5267473a32dcab8e5dc2c9d9a720afed7f40174c\",\n },\n ],\n },\n ];\n\nconst communitySourceById = new Map(\n CURATED_COMMUNITY_APP_SOURCES.map((source) => [source.id, source]),\n);\n\nfunction requireCommunitySource(sourceId: string): CuratedCommunityAppSource {\n const source = communitySourceById.get(sourceId.trim());\n if (!source) {\n fail(\"That community app is not in Dispatch's reviewed install catalog.\", {\n errorCode: \"unknown_community_app_source\",\n statusCode: 404,\n });\n }\n return source;\n}\n\nfunction communitySourceFailureKind(\n error: unknown,\n): \"unavailable\" | \"integrity\" {\n if (!(error instanceof Error) || !(\"failureKind\" in error)) {\n return \"unavailable\";\n }\n return error.failureKind === \"integrity\" ? \"integrity\" : \"unavailable\";\n}\n\nfunction requireNonShadowingCommunityAppId(appId: string): void {\n const error = getWorkspaceAppIdValidationError(appId);\n if (error) {\n fail(error, { errorCode: \"invalid_community_app_id\", statusCode: 400 });\n }\n if (\n CURATED_WORKSPACE_TEMPLATES.some((template) => template.id === appId) ||\n BUILTIN_AGENT_CATALOG_IDS.includes(appId) ||\n HIDDEN_FIRST_PARTY_AGENT_IDS.has(appId)\n ) {\n fail(\"Community apps cannot use a first-party template app id.\", {\n errorCode: \"community_app_id_shadows_first_party\",\n statusCode: 409,\n });\n }\n}\n\nasync function requireCommunityAppsLab(): Promise<void> {\n const userEmail = currentOwnerEmail().trim();\n const orgId = currentOrgId();\n if (!userEmail || !orgId) {\n fail(\"Sign in to an organization to browse community apps.\", {\n errorCode: \"community_apps_identity_required\",\n statusCode: 403,\n });\n }\n const enabled = await getUserLabEnabled(userEmail, COMMUNITY_APPS_LAB, {\n orgId,\n });\n if (!enabled) {\n fail(\"Community app catalog and installs are disabled for this account.\", {\n errorCode: \"community_apps_lab_disabled\",\n statusCode: 403,\n });\n }\n}\n\nasync function hasAssociatedWorkspace(\n localRuntime = isLocalAppCreationRuntime(),\n): Promise<boolean> {\n if (localRuntime) return Boolean(getWorkspaceInfo().rootPath);\n return Boolean((await getAppCreationSettings()).builderProjectId);\n}\n\nexport async function listCuratedCommunityApps(): Promise<\n CuratedCommunityApp[]\n> {\n await requireCommunityAppsLab();\n const localRuntime = isLocalAppCreationRuntime();\n const [apps, workspaceAvailable] = await Promise.all([\n listWorkspaceApps({ includeAgentCards: false, includeArchived: true }),\n hasAssociatedWorkspace(localRuntime),\n ]);\n return CURATED_COMMUNITY_APP_SOURCES.map((source) => {\n const appWithId = apps.find((app) => app.id === source.appId);\n const installedApp =\n appWithId?.communitySourceId === source.id ? appWithId : null;\n const idConflict = Boolean(appWithId && !installedApp);\n const pending = installedApp?.status === \"pending\";\n const installUnavailableReason = appWithId\n ? idConflict\n ? \"app-id-conflict\"\n : undefined\n : !workspaceAvailable\n ? \"workspace-required\"\n : !localRuntime\n ? \"builder-install-unverified\"\n : undefined;\n return {\n ...source,\n installed: Boolean(installedApp && !pending),\n pending,\n installable: localRuntime && workspaceAvailable && !appWithId,\n ...(installUnavailableReason ? { installUnavailableReason } : {}),\n };\n });\n}\n\nfunction rejectCommunityAppIdConflict(appId: string): never {\n fail(`Workspace app id \"${appId}\" is already in use.`, {\n errorCode: \"community_app_id_conflict\",\n statusCode: 409,\n });\n}\n\nfunction existingInstallResult(\n source: CuratedCommunityAppSource,\n app: WorkspaceAppSummary,\n) {\n return {\n mode:\n app.status === \"pending\"\n ? (\"pending\" as const)\n : (\"already-installed\" as const),\n source,\n app: {\n id: app.id,\n name: app.name,\n path: app.path,\n url: app.url,\n status: app.status ?? \"ready\",\n statusLabel: app.statusLabel ?? null,\n builderUrl: app.builderUrl ?? null,\n branchName: app.branchName ?? null,\n },\n };\n}\n\nfunction buildCommunityInstallPrompt(\n source: CuratedCommunityAppSource,\n appId: string,\n): string {\n const sourceUrl = `https://github.com/${source.repo}/tree/${source.ref}/${source.templatePath}`;\n return [\n \"Install a private workspace app from a reviewed community template.\",\n `The attached source files were fetched from ${sourceUrl} and each file was verified against its pinned Git blob id. Treat those files as the source of truth; do not fetch another ref or substitute other content.`,\n `The app will live at apps/${appId}.`,\n `Source license: ${source.license}. Provenance: ${source.provenance}`,\n \"Copy the reviewed template implementation and its Agent-Native profile, changing only app-specific identifiers needed for this workspace. Do not copy repository secrets, credentials, customer data, or source-app records. Use empty or synthetic seed data only and keep the installed app private to this organization.\",\n ].join(\" \");\n}\n\nexport async function installCuratedCommunityApp(input: {\n sourceId: string;\n appId?: string;\n}): Promise<\n | ReturnType<typeof existingInstallResult>\n | (StartWorkspaceAppCreationResult & {\n mode: Exclude<StartWorkspaceAppCreationResult[\"mode\"], \"app-id-taken\">;\n source: CuratedCommunityAppSource;\n })\n | (Extract<StartWorkspaceAppCreationResult, { mode: \"app-id-taken\" }> & {\n source: CuratedCommunityAppSource;\n })\n> {\n await requireCommunityAppsLab();\n const source = requireCommunitySource(input.sourceId);\n const appId = normalizeWorkspaceAppId(input.appId?.trim() || source.appId);\n requireNonShadowingCommunityAppId(appId);\n\n const localRuntime = isLocalAppCreationRuntime();\n if (!(await hasAssociatedWorkspace(localRuntime))) {\n fail(\"Connect this organization to a workspace before installing apps.\", {\n errorCode: \"community_workspace_required\",\n statusCode: 409,\n });\n }\n\n const existing = (\n await listWorkspaceApps({\n includeAgentCards: false,\n includeArchived: true,\n })\n ).find((app) => app.id === appId);\n if (existing) {\n if (existing.communitySourceId === source.id) {\n return existingInstallResult(source, existing);\n }\n rejectCommunityAppIdConflict(appId);\n }\n\n if (!localRuntime) {\n fail(\n \"Community template installs in Builder workspaces are disabled until the generated branch files can be read back and verified.\",\n {\n errorCode: \"community_builder_install_unverified\",\n statusCode: 503,\n },\n );\n }\n\n let attachments: Awaited<\n ReturnType<typeof loadPinnedCommunitySourceAttachments>\n >;\n try {\n attachments = await loadPinnedCommunitySourceAttachments(source, appId);\n } catch (error) {\n fail(\n \"Dispatch could not verify the pinned community template source. Try again later.\",\n {\n errorCode:\n communitySourceFailureKind(error) === \"integrity\"\n ? \"community_source_integrity_failed\"\n : \"community_source_unavailable\",\n statusCode: 503,\n },\n );\n }\n\n const result = await startWorkspaceAppCreation({\n prompt: buildCommunityInstallPrompt(source, appId),\n appId,\n description: source.description,\n template: source.id,\n communitySourceId: source.id,\n attachments,\n });\n\n if (result.mode === \"app-id-taken\") {\n const raced = (\n await listWorkspaceApps({\n includeAgentCards: false,\n includeArchived: true,\n })\n ).find((app) => app.id === appId);\n if (raced?.communitySourceId === source.id) {\n return existingInstallResult(source, raced);\n }\n if (raced) rejectCommunityAppIdConflict(appId);\n return { ...result, source };\n }\n\n await recordAudit({\n action: \"workspace-app.community-install-requested\",\n targetType: \"workspace-app\",\n targetId: appId,\n summary: `Requested ${source.name} community app installation`,\n metadata: {\n sourceId: source.id,\n repo: source.repo,\n ref: source.ref,\n blobShas: source.files.map((file) => file.blobSha),\n license: source.license,\n },\n });\n return { ...result, source } as typeof result & {\n source: CuratedCommunityAppSource;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"community-apps.js","sourceRoot":"","sources":["../../../src/server/lib/community-apps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EACL,gCAAgC,EAChC,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B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C,CAAC;IACH,OAAO,EAAE,GAAG,MAAM,EAAE,MAAM,EAEzB,CAAC;AACJ,CAAC","sourcesContent":["import { fail } from \"@agent-native/core/action\";\nimport { getUserLabEnabled } from \"@agent-native/core/labs/server\";\nimport {\n getWorkspaceAppIdValidationError,\n normalizeWorkspaceAppId,\n} from \"@agent-native/core/shared\";\nimport {\n BUILTIN_AGENT_CATALOG_IDS,\n HIDDEN_FIRST_PARTY_AGENT_IDS,\n} from \"@agent-native/core/shared/first-party-agents\";\n\nimport { COMMUNITY_APPS_LAB } from \"../../shared/labs.js\";\nimport type {\n StartWorkspaceAppCreationResult,\n WorkspaceAppSummary,\n} from \"./app-creation-store.js\";\nimport {\n getAppCreationSettings,\n getWorkspaceInfo,\n isLocalAppCreationRuntime,\n listWorkspaceApps,\n startWorkspaceAppCreation,\n} from \"./app-creation-store.js\";\nimport {\n loadPinnedCommunitySourceAttachments,\n type PinnedCommunitySource,\n} from \"./community-source.js\";\nimport { CURATED_WORKSPACE_TEMPLATES } from \"./curated-workspace-templates.js\";\nimport {\n currentOrgId,\n currentOwnerEmail,\n recordAudit,\n} from \"./dispatch-store.js\";\n\nexport interface CuratedCommunityAppSource extends PinnedCommunitySource {\n id: string;\n name: string;\n description: string;\n appId: string;\n license: string;\n provenance: string;\n}\n\nexport interface CuratedCommunityApp extends CuratedCommunityAppSource {\n installed: boolean;\n pending: boolean;\n installable: boolean;\n installUnavailableReason?:\n | \"workspace-required\"\n | \"app-id-conflict\"\n | \"builder-install-unverified\";\n}\n\nexport const CURATED_COMMUNITY_APP_SOURCES: readonly CuratedCommunityAppSource[] =\n [\n {\n id: \"community-qr\",\n name: \"QR\",\n description: \"Generate public PNG or SVG QR images from links or text.\",\n appId: \"community-qr\",\n repo: \"BuilderIO/agent-native\",\n ref: \"main\",\n license: \"MIT\",\n provenance:\n \"Reviewed Agent-Native Framework template, sanitized for independent installation.\",\n templatePath: \"templates/community/qr\",\n files: [\n {\n path: \"AGENTS.md\",\n blobSha: \"7dc9e18bc426dfd21526f91225cc615759450816\",\n },\n {\n path: \"LICENSE\",\n blobSha: \"69c7182efb3eb1a8b7f6fd5989f3e4fd737d0645\",\n },\n {\n path: \"README.md\",\n blobSha: \"e05e72bb9213732f56ccbc96f7dcb1c3a064cb19\",\n },\n {\n path: \"actions/generate-qr-code.spec.ts\",\n blobSha: \"42a1a84ecb421e1e6435cc2e7fd00e2f4f2e1ea9\",\n },\n {\n path: \"actions/generate-qr-code.ts\",\n blobSha: \"98d30e218bfed796d5e402d5ce19a8626d8da0cf\",\n },\n {\n path: \"actions/run.ts\",\n blobSha: \"b46ab15b667c34741364ba08f010f7aca9d0f02e\",\n },\n {\n path: \"agent-native.json\",\n blobSha: \"accc32476792b84557f69e2b48b317c27b5546dc\",\n },\n {\n path: \"package.json\",\n blobSha: \"5815e6665e06176df9954183e89b234acf5c5c37\",\n },\n {\n path: \"server/db/index.ts\",\n blobSha: \"17007b456530f75a72e7209bdfe9f4bd4c9224e0\",\n },\n {\n path: \"server/db/schema.ts\",\n blobSha: \"2e4cd01c5f46463e78bc7beb6e954f3e526c0b57\",\n },\n {\n path: \"server/plugins/db.ts\",\n blobSha: \"78a5b431c1ad1ea14f593123c090f5376a36df10\",\n },\n {\n path: \"tsconfig.json\",\n blobSha: \"5267473a32dcab8e5dc2c9d9a720afed7f40174c\",\n },\n ],\n },\n ];\n\nconst communitySourceById = new Map(\n CURATED_COMMUNITY_APP_SOURCES.map((source) => [source.id, source]),\n);\n\nfunction requireCommunitySource(sourceId: string): CuratedCommunityAppSource {\n const source = communitySourceById.get(sourceId.trim());\n if (!source) {\n fail(\"That community app is not in Dispatch's reviewed install catalog.\", {\n errorCode: \"unknown_community_app_source\",\n statusCode: 404,\n });\n }\n return source;\n}\n\nfunction communitySourceFailureKind(\n error: unknown,\n): \"unavailable\" | \"integrity\" {\n if (!(error instanceof Error) || !(\"failureKind\" in error)) {\n return \"unavailable\";\n }\n return error.failureKind === \"integrity\" ? \"integrity\" : \"unavailable\";\n}\n\nfunction requireNonShadowingCommunityAppId(appId: string): void {\n const error = getWorkspaceAppIdValidationError(appId);\n if (error) {\n fail(error, { errorCode: \"invalid_community_app_id\", statusCode: 400 });\n }\n if (\n CURATED_WORKSPACE_TEMPLATES.some((template) => template.id === appId) ||\n BUILTIN_AGENT_CATALOG_IDS.includes(appId) ||\n HIDDEN_FIRST_PARTY_AGENT_IDS.has(appId)\n ) {\n fail(\"Community apps cannot use a first-party template app id.\", {\n errorCode: \"community_app_id_shadows_first_party\",\n statusCode: 409,\n });\n }\n}\n\nasync function requireCommunityAppsLab(): Promise<void> {\n const userEmail = currentOwnerEmail().trim();\n const orgId = currentOrgId();\n if (!userEmail || !orgId) {\n fail(\"Sign in to an organization to browse community apps.\", {\n errorCode: \"community_apps_identity_required\",\n statusCode: 403,\n });\n }\n const enabled = await getUserLabEnabled(userEmail, COMMUNITY_APPS_LAB, {\n orgId,\n });\n if (!enabled) {\n fail(\"Community app catalog and installs are disabled for this account.\", {\n errorCode: \"community_apps_lab_disabled\",\n statusCode: 403,\n });\n }\n}\n\nasync function hasAssociatedWorkspace(\n localRuntime = isLocalAppCreationRuntime(),\n): Promise<boolean> {\n if (localRuntime) return Boolean(getWorkspaceInfo().rootPath);\n return Boolean((await getAppCreationSettings()).builderProjectId);\n}\n\nexport async function listCuratedCommunityApps(): Promise<\n CuratedCommunityApp[]\n> {\n await requireCommunityAppsLab();\n const localRuntime = isLocalAppCreationRuntime();\n const [apps, workspaceAvailable] = await Promise.all([\n listWorkspaceApps({ includeAgentCards: false, includeArchived: true }),\n hasAssociatedWorkspace(localRuntime),\n ]);\n return CURATED_COMMUNITY_APP_SOURCES.map((source) => {\n const appWithId = apps.find((app) => app.id === source.appId);\n const installedApp =\n appWithId?.communitySourceId === source.id ? appWithId : null;\n const idConflict = Boolean(appWithId && !installedApp);\n const pending = installedApp?.status === \"pending\";\n const installUnavailableReason = appWithId\n ? idConflict\n ? \"app-id-conflict\"\n : undefined\n : !workspaceAvailable\n ? \"workspace-required\"\n : !localRuntime\n ? \"builder-install-unverified\"\n : undefined;\n return {\n ...source,\n installed: Boolean(installedApp && !pending),\n pending,\n installable: localRuntime && workspaceAvailable && !appWithId,\n ...(installUnavailableReason ? { installUnavailableReason } : {}),\n };\n });\n}\n\nfunction rejectCommunityAppIdConflict(appId: string): never {\n fail(`Workspace app id \"${appId}\" is already in use.`, {\n errorCode: \"community_app_id_conflict\",\n statusCode: 409,\n });\n}\n\nfunction existingInstallResult(\n source: CuratedCommunityAppSource,\n app: WorkspaceAppSummary,\n) {\n return {\n mode:\n app.status === \"pending\"\n ? (\"pending\" as const)\n : (\"already-installed\" as const),\n source,\n app: {\n id: app.id,\n name: app.name,\n path: app.path,\n url: app.url,\n status: app.status ?? \"ready\",\n statusLabel: app.statusLabel ?? null,\n builderUrl: app.builderUrl ?? null,\n branchName: app.branchName ?? null,\n },\n };\n}\n\nfunction buildCommunityInstallPrompt(\n source: CuratedCommunityAppSource,\n appId: string,\n): string {\n const sourceUrl = `https://github.com/${source.repo}/tree/${source.ref}/${source.templatePath}`;\n return [\n \"Install a private workspace app from a reviewed community template.\",\n `The attached source files were fetched from ${sourceUrl} and each file was verified against its pinned Git blob id. Treat those files as the source of truth; do not fetch another ref or substitute other content.`,\n `The app will live at apps/${appId}.`,\n `Source license: ${source.license}. Provenance: ${source.provenance}`,\n \"Copy the reviewed template implementation and its Agent-Native profile, changing only app-specific identifiers needed for this workspace. Do not copy repository secrets, credentials, customer data, or source-app records. Use empty or synthetic seed data only and keep the installed app private to this organization.\",\n ].join(\" \");\n}\n\nexport async function installCuratedCommunityApp(input: {\n sourceId: string;\n appId?: string;\n}): Promise<\n | ReturnType<typeof existingInstallResult>\n | (StartWorkspaceAppCreationResult & {\n mode: Exclude<StartWorkspaceAppCreationResult[\"mode\"], \"app-id-taken\">;\n source: CuratedCommunityAppSource;\n })\n | (Extract<StartWorkspaceAppCreationResult, { mode: \"app-id-taken\" }> & {\n source: CuratedCommunityAppSource;\n })\n> {\n await requireCommunityAppsLab();\n const source = requireCommunitySource(input.sourceId);\n const appId = normalizeWorkspaceAppId(input.appId?.trim() || source.appId);\n requireNonShadowingCommunityAppId(appId);\n\n const localRuntime = isLocalAppCreationRuntime();\n if (!(await hasAssociatedWorkspace(localRuntime))) {\n fail(\"Connect this organization to a workspace before installing apps.\", {\n errorCode: \"community_workspace_required\",\n statusCode: 409,\n });\n }\n\n const existing = (\n await listWorkspaceApps({\n includeAgentCards: false,\n includeArchived: true,\n })\n ).find((app) => app.id === appId);\n if (existing) {\n if (existing.communitySourceId === source.id) {\n return existingInstallResult(source, existing);\n }\n rejectCommunityAppIdConflict(appId);\n }\n\n if (!localRuntime) {\n fail(\n \"Community template installs in Builder workspaces are disabled until the generated branch files can be read back and verified.\",\n {\n errorCode: \"community_builder_install_unverified\",\n statusCode: 503,\n },\n );\n }\n\n let attachments: Awaited<\n ReturnType<typeof loadPinnedCommunitySourceAttachments>\n >;\n try {\n attachments = await loadPinnedCommunitySourceAttachments(source, appId);\n } catch (error) {\n fail(\n \"Dispatch could not verify the pinned community template source. Try again later.\",\n {\n errorCode:\n communitySourceFailureKind(error) === \"integrity\"\n ? \"community_source_integrity_failed\"\n : \"community_source_unavailable\",\n statusCode: 503,\n },\n );\n }\n\n const result = await startWorkspaceAppCreation({\n prompt: buildCommunityInstallPrompt(source, appId),\n appId,\n description: source.description,\n template: source.id,\n communitySourceId: source.id,\n attachments,\n });\n\n if (result.mode === \"app-id-taken\") {\n const raced = (\n await listWorkspaceApps({\n includeAgentCards: false,\n includeArchived: true,\n })\n ).find((app) => app.id === appId);\n if (raced?.communitySourceId === source.id) {\n return existingInstallResult(source, raced);\n }\n if (raced) rejectCommunityAppIdConflict(appId);\n return { ...result, source };\n }\n\n await recordAudit({\n action: \"workspace-app.community-install-requested\",\n targetType: \"workspace-app\",\n targetId: appId,\n summary: `Requested ${source.name} community app installation`,\n metadata: {\n sourceId: source.id,\n repo: source.repo,\n ref: source.ref,\n blobShas: source.files.map((file) => file.blobSha),\n license: source.license,\n },\n });\n return { ...result, source } as typeof result & {\n source: CuratedCommunityAppSource;\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-gateway.d.ts","sourceRoot":"","sources":["../../../src/server/lib/mcp-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mcp-gateway.d.ts","sourceRoot":"","sources":["../../../src/server/lib/mcp-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,2BAA2B,EAChC,KAAK,IAAI,EACV,MAAM,wBAAwB,CAAC;AAkChC,OAAO,EAGL,KAAK,4BAA4B,EAClC,MAAM,uBAAuB,CAAC;AA8B/B,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AA2DD,KAAK,uBAAuB,GAAG,2BAA2B,CAAC;AAiC3D,KAAK,iCAAiC,GAClC,WAAW,GACX,SAAS,GACT,cAAc,GACd,cAAc,CAAC;AAEnB,KAAK,wBAAwB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,aAAa,CAAC,E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AS,CAAC;CAC7B,GAAG,OAAO,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAwCD"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { A2AClient, canonicalA2AAudience, extractA2APersistedMutationReceipts, getGlobalA2ASecret, signA2AOrganizationToken, signA2AToken, stripA2APersistedArtifactMarkers, } from "@agent-native/core/a2a";
|
|
1
|
+
import { A2AClient, canonicalA2AAudience, extractA2APersistedMutationReceipts, getGlobalA2ASecret, signA2AOrgMemberDelegationToken, signA2AOrganizationToken, signA2AToken, stripA2APersistedArtifactMarkers, } from "@agent-native/core/a2a";
|
|
2
|
+
import { getAppConfig } from "@agent-native/core/app-config";
|
|
2
3
|
import { isFeatureFlagEnabled } from "@agent-native/core/feature-flags";
|
|
3
4
|
import { buildMcpToolName, McpClientManager, } from "@agent-native/core/mcp-client";
|
|
4
5
|
import { getOrgA2ASecret, getOrgDomain } from "@agent-native/core/org";
|
|
5
|
-
import { buildDeepLink, buildEmbedStartPath, createEmbedSessionTicket, getRequestContext, getRequestOrgId, getRequestUserEmail, } from "@agent-native/core/server";
|
|
6
|
+
import { buildDeepLink, buildEmbedStartPath, createEmbedSessionTicket, getConfiguredAppBasePath, getRequestContext, getRequestOrgId, getRequestUserEmail, } from "@agent-native/core/server";
|
|
6
7
|
import { discoverAgents, getBuiltinAgents, } from "@agent-native/core/server/agent-discovery";
|
|
8
|
+
import { EMBED_START_PATH } from "@agent-native/core/shared";
|
|
7
9
|
import { DESKTOP_WORKSPACE_SSO_FLAG } from "../../shared/feature-flags.js";
|
|
8
10
|
import { DISPATCH_WORKSPACE_SSO_FLAG, isWorkspaceSsoAppUrl, } from "../../shared/workspace-sso.js";
|
|
9
11
|
import { listWorkspaceApps } from "./app-creation-store.js";
|
|
@@ -424,11 +426,61 @@ function appHomeBaseUrl(app) {
|
|
|
424
426
|
}
|
|
425
427
|
return appBaseUrl(app);
|
|
426
428
|
}
|
|
429
|
+
function workspaceGatewayMcpUrl(appUrl) {
|
|
430
|
+
const configuredGateway = getAppConfig().workspace.gatewayUrl?.trim();
|
|
431
|
+
if (!configuredGateway)
|
|
432
|
+
return undefined;
|
|
433
|
+
let configuredUrl;
|
|
434
|
+
try {
|
|
435
|
+
configuredUrl = new URL(configuredGateway);
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
throw new Error("WORKSPACE_GATEWAY_URL must be a valid absolute HTTP(S) URL.");
|
|
439
|
+
}
|
|
440
|
+
if (configuredUrl.protocol !== "http:" &&
|
|
441
|
+
configuredUrl.protocol !== "https:") {
|
|
442
|
+
throw new Error("WORKSPACE_GATEWAY_URL must use http or https.");
|
|
443
|
+
}
|
|
444
|
+
const gateway = new URL(projectEnvironmentUrl(configuredUrl.toString()));
|
|
445
|
+
if (gateway.protocol !== "http:" && gateway.protocol !== "https:") {
|
|
446
|
+
throw new Error("WORKSPACE_GATEWAY_URL must use http or https.");
|
|
447
|
+
}
|
|
448
|
+
const target = new URL(appUrl);
|
|
449
|
+
if (gateway.origin !== target.origin)
|
|
450
|
+
return undefined;
|
|
451
|
+
const configuredBasePath = getConfiguredAppBasePath();
|
|
452
|
+
const gatewayPath = gateway.pathname.replace(/\/+$/, "");
|
|
453
|
+
const basePath = configuredBasePath &&
|
|
454
|
+
gatewayPath !== configuredBasePath &&
|
|
455
|
+
!gatewayPath.startsWith(`${configuredBasePath}/`)
|
|
456
|
+
? `${configuredBasePath}${gatewayPath}`
|
|
457
|
+
: gatewayPath;
|
|
458
|
+
gateway.pathname = `${basePath}/mcp`;
|
|
459
|
+
gateway.search = "";
|
|
460
|
+
gateway.hash = "";
|
|
461
|
+
return gateway.toString().replace(/\/$/, "");
|
|
462
|
+
}
|
|
463
|
+
function appMcpUrl(app) {
|
|
464
|
+
const explicit = app.mcpUrl?.trim();
|
|
465
|
+
return (explicit?.replace(/\/+$/, "") ??
|
|
466
|
+
workspaceGatewayMcpUrl(app.url) ??
|
|
467
|
+
`${appHomeBaseUrl(app)}/mcp`);
|
|
468
|
+
}
|
|
469
|
+
function appMcpBaseUrl(app) {
|
|
470
|
+
const url = new URL(appMcpUrl(app));
|
|
471
|
+
url.pathname = url.pathname.replace(/\/mcp\/?$/, "") || "/";
|
|
472
|
+
url.search = "";
|
|
473
|
+
url.hash = "";
|
|
474
|
+
return url.toString().replace(/\/$/, "");
|
|
475
|
+
}
|
|
427
476
|
function resolveGrantedAppEmbedStartUrl(app, startUrl) {
|
|
428
477
|
try {
|
|
429
|
-
const baseUrl =
|
|
478
|
+
const baseUrl = appMcpBaseUrl(app);
|
|
430
479
|
const resolved = new URL(startUrl, `${baseUrl}/`);
|
|
431
|
-
|
|
480
|
+
const base = new URL(baseUrl);
|
|
481
|
+
const basePath = base.pathname.replace(/\/+$/, "");
|
|
482
|
+
const expectedPath = `${basePath}${EMBED_START_PATH}`;
|
|
483
|
+
if (resolved.origin !== base.origin || resolved.pathname !== expectedPath) {
|
|
432
484
|
throw new Error("Target app returned an embed start URL outside the granted app.");
|
|
433
485
|
}
|
|
434
486
|
return resolved.toString();
|
|
@@ -565,11 +617,13 @@ async function listWorkspaceSsoApps() {
|
|
|
565
617
|
for (const app of mountedApps) {
|
|
566
618
|
if (app.isDispatch || !app.url)
|
|
567
619
|
continue;
|
|
620
|
+
const mcpUrl = workspaceGatewayMcpUrl(app.url);
|
|
568
621
|
candidatesById.set(app.id, {
|
|
569
622
|
id: app.id,
|
|
570
623
|
name: app.name,
|
|
571
624
|
description: app.description,
|
|
572
625
|
url: app.url,
|
|
626
|
+
...(mcpUrl ? { mcpUrl } : {}),
|
|
573
627
|
color: DISPATCH_COLOR,
|
|
574
628
|
granted: true,
|
|
575
629
|
});
|
|
@@ -834,13 +888,16 @@ function isRetryableTargetMcpError(error) {
|
|
|
834
888
|
return /streamable http|handshake|failed to fetch|fetch failed|networkerror|econnrefused|enotfound|timed out|timeout/i.test(message);
|
|
835
889
|
}
|
|
836
890
|
function targetMcpErrorStatus(error) {
|
|
891
|
+
const status = httpStatusFromError(error);
|
|
892
|
+
if (status !== undefined)
|
|
893
|
+
return status;
|
|
837
894
|
const message = error instanceof Error
|
|
838
895
|
? error.message
|
|
839
896
|
: typeof error === "string"
|
|
840
897
|
? error
|
|
841
898
|
: safeJson(error);
|
|
842
|
-
const
|
|
843
|
-
return
|
|
899
|
+
const matchedStatus = message.match(/\b([45]\d{2})\b/)?.[1];
|
|
900
|
+
return matchedStatus ? Number(matchedStatus) : undefined;
|
|
844
901
|
}
|
|
845
902
|
function targetMcpRequestDetails(input) {
|
|
846
903
|
const targetUrl = new URL(input.url);
|
|
@@ -855,6 +912,20 @@ function targetMcpConnectTimeout(deadline) {
|
|
|
855
912
|
const budget = Math.min(TARGET_EMBED_SESSION_CONNECT_TIMEOUT_MS, remaining);
|
|
856
913
|
return Math.max(1000, budget);
|
|
857
914
|
}
|
|
915
|
+
class TargetMcpAuthenticationRejectedError extends Error {
|
|
916
|
+
status;
|
|
917
|
+
constructor(cause) {
|
|
918
|
+
super("Target MCP authentication was rejected", { cause });
|
|
919
|
+
this.name = "TargetMcpAuthenticationRejectedError";
|
|
920
|
+
const status = httpStatusFromError(cause) ?? targetMcpErrorStatus(cause);
|
|
921
|
+
if (status !== undefined)
|
|
922
|
+
this.status = status;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
function isTargetMcpAuthenticationRejected(error) {
|
|
926
|
+
const status = httpStatusFromError(error);
|
|
927
|
+
return status === 401 || status === 403;
|
|
928
|
+
}
|
|
858
929
|
function targetMcpRetryDelay(attempt) {
|
|
859
930
|
const base = TARGET_EMBED_SESSION_RETRY_BASE_MS * Math.pow(2, Math.max(0, attempt - 1));
|
|
860
931
|
return base + Math.floor(Math.random() * 100);
|
|
@@ -867,21 +938,35 @@ async function callTargetCreateEmbedSession(input) {
|
|
|
867
938
|
servers: {
|
|
868
939
|
[serverId]: {
|
|
869
940
|
type: "http",
|
|
870
|
-
url:
|
|
941
|
+
url: appMcpUrl(input.app),
|
|
871
942
|
headers: {
|
|
872
943
|
Authorization: `Bearer ${input.token}`,
|
|
873
944
|
},
|
|
874
945
|
},
|
|
875
946
|
},
|
|
876
947
|
}, { connectTimeoutMs: targetMcpConnectTimeout(deadline) });
|
|
948
|
+
let connected = false;
|
|
877
949
|
try {
|
|
878
950
|
await manager.start();
|
|
951
|
+
const connectErrorStatus = manager.getConnectErrorStatus(serverId);
|
|
952
|
+
if (connectErrorStatus === 401 || connectErrorStatus === 403) {
|
|
953
|
+
const error = Object.assign(new Error(`HTTP ${connectErrorStatus}`), {
|
|
954
|
+
status: connectErrorStatus,
|
|
955
|
+
});
|
|
956
|
+
throw new TargetMcpAuthenticationRejectedError(error);
|
|
957
|
+
}
|
|
958
|
+
connected = true;
|
|
879
959
|
return await manager.callTool(buildMcpToolName(serverId, "create_embed_session"), {
|
|
880
960
|
url: input.url,
|
|
881
961
|
chrome: input.chrome ?? "full",
|
|
882
962
|
});
|
|
883
963
|
}
|
|
884
964
|
catch (error) {
|
|
965
|
+
if (!connected &&
|
|
966
|
+
!(error instanceof TargetMcpAuthenticationRejectedError) &&
|
|
967
|
+
isTargetMcpAuthenticationRejected(error)) {
|
|
968
|
+
throw new TargetMcpAuthenticationRejectedError(error);
|
|
969
|
+
}
|
|
885
970
|
if (attempt >= TARGET_EMBED_SESSION_ATTEMPTS ||
|
|
886
971
|
!isRetryableTargetMcpError(error) ||
|
|
887
972
|
deadline - Date.now() < TARGET_EMBED_SESSION_RETRY_BASE_MS) {
|
|
@@ -896,17 +981,42 @@ async function callTargetCreateEmbedSession(input) {
|
|
|
896
981
|
}
|
|
897
982
|
}
|
|
898
983
|
}
|
|
899
|
-
async function
|
|
900
|
-
|
|
901
|
-
|
|
984
|
+
async function createTargetMcpUserCredentials(input) {
|
|
985
|
+
const audience = canonicalA2AAudience(appMcpUrl(input.target));
|
|
986
|
+
const orgDomain = input.orgId
|
|
987
|
+
? (await getOrgDomain(input.orgId))?.trim().toLowerCase() || undefined
|
|
988
|
+
: undefined;
|
|
989
|
+
const credentials = [];
|
|
990
|
+
if (getGlobalA2ASecret()) {
|
|
991
|
+
credentials.push({
|
|
992
|
+
strategy: "deployment-user",
|
|
993
|
+
token: await signA2AToken(input.ownerEmail, undefined, undefined, {
|
|
994
|
+
expiresIn: "5m",
|
|
995
|
+
audience,
|
|
996
|
+
preferGlobalSecret: true,
|
|
997
|
+
}),
|
|
998
|
+
});
|
|
902
999
|
}
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
1000
|
+
const loadOrgMemberCredential = async () => {
|
|
1001
|
+
if (!input.orgId || !orgDomain)
|
|
1002
|
+
return undefined;
|
|
1003
|
+
const orgSecret = await getOrgA2ASecret(input.orgId);
|
|
1004
|
+
if (!orgSecret)
|
|
1005
|
+
return undefined;
|
|
1006
|
+
return {
|
|
1007
|
+
strategy: "org-member-delegation",
|
|
1008
|
+
token: await signA2AOrgMemberDelegationToken(input.ownerEmail, orgDomain, orgSecret, audience),
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
if (credentials.length === 0) {
|
|
1012
|
+
const orgMemberCredential = await loadOrgMemberCredential();
|
|
1013
|
+
if (orgMemberCredential)
|
|
1014
|
+
credentials.push(orgMemberCredential);
|
|
1015
|
+
}
|
|
1016
|
+
if (credentials.length === 0) {
|
|
1017
|
+
throw new Error("Cross-app embed sessions require a deployment A2A secret or an organization secret with member delegation enabled on the target.");
|
|
1018
|
+
}
|
|
1019
|
+
return { credentials, loadOrgMemberCredential };
|
|
910
1020
|
}
|
|
911
1021
|
async function resolveEmbedTarget(input, options) {
|
|
912
1022
|
const explicitApp = input.app?.trim()
|
|
@@ -1008,9 +1118,9 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1008
1118
|
chrome,
|
|
1009
1119
|
});
|
|
1010
1120
|
}
|
|
1011
|
-
const
|
|
1121
|
+
const targetCredentials = await createTargetMcpUserCredentials({
|
|
1012
1122
|
ownerEmail,
|
|
1013
|
-
orgId,
|
|
1123
|
+
...(orgId !== undefined ? { orgId } : {}),
|
|
1014
1124
|
target: target.app,
|
|
1015
1125
|
});
|
|
1016
1126
|
const targetDetails = targetMcpRequestDetails({
|
|
@@ -1018,28 +1128,50 @@ async function createEmbedSessionForResolvedApp(input) {
|
|
|
1018
1128
|
url: target.url,
|
|
1019
1129
|
});
|
|
1020
1130
|
let parsed;
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
});
|
|
1025
|
-
try {
|
|
1026
|
-
const result = await callTargetCreateEmbedSession({
|
|
1027
|
-
app: target.app,
|
|
1028
|
-
token: targetToken,
|
|
1029
|
-
url: target.url,
|
|
1030
|
-
chrome,
|
|
1031
|
-
});
|
|
1032
|
-
parsed = parseMcpToolTextResult(result);
|
|
1033
|
-
}
|
|
1034
|
-
catch (error) {
|
|
1035
|
-
console.warn("[dispatch] workspace embed target response", {
|
|
1131
|
+
const credentials = [...targetCredentials.credentials];
|
|
1132
|
+
for (const [index, credential] of credentials.entries()) {
|
|
1133
|
+
console.info("[dispatch] workspace embed target request", {
|
|
1036
1134
|
...targetDetails,
|
|
1037
|
-
authStrategy:
|
|
1038
|
-
status: targetMcpErrorStatus(error),
|
|
1039
|
-
category: isRetryableTargetMcpError(error) ? "transient" : "permanent",
|
|
1135
|
+
authStrategy: credential.strategy,
|
|
1040
1136
|
});
|
|
1041
|
-
|
|
1137
|
+
try {
|
|
1138
|
+
const result = await callTargetCreateEmbedSession({
|
|
1139
|
+
app: target.app,
|
|
1140
|
+
token: credential.token,
|
|
1141
|
+
url: target.url,
|
|
1142
|
+
...(chrome !== undefined ? { chrome } : {}),
|
|
1143
|
+
});
|
|
1144
|
+
parsed = parseMcpToolTextResult(result);
|
|
1145
|
+
break;
|
|
1146
|
+
}
|
|
1147
|
+
catch (error) {
|
|
1148
|
+
if (error instanceof TargetMcpAuthenticationRejectedError &&
|
|
1149
|
+
credential.strategy === "deployment-user" &&
|
|
1150
|
+
index === credentials.length - 1) {
|
|
1151
|
+
const orgMemberCredential = await targetCredentials.loadOrgMemberCredential();
|
|
1152
|
+
if (orgMemberCredential)
|
|
1153
|
+
credentials.push(orgMemberCredential);
|
|
1154
|
+
}
|
|
1155
|
+
if (error instanceof TargetMcpAuthenticationRejectedError &&
|
|
1156
|
+
index < credentials.length - 1) {
|
|
1157
|
+
console.warn("[dispatch] workspace embed auth candidate rejected", {
|
|
1158
|
+
...targetDetails,
|
|
1159
|
+
authStrategy: credential.strategy,
|
|
1160
|
+
status: targetMcpErrorStatus(error),
|
|
1161
|
+
});
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
console.warn("[dispatch] workspace embed target response", {
|
|
1165
|
+
...targetDetails,
|
|
1166
|
+
authStrategy: credential.strategy,
|
|
1167
|
+
status: targetMcpErrorStatus(error),
|
|
1168
|
+
category: isRetryableTargetMcpError(error) ? "transient" : "permanent",
|
|
1169
|
+
});
|
|
1170
|
+
throw error;
|
|
1171
|
+
}
|
|
1042
1172
|
}
|
|
1173
|
+
if (!parsed)
|
|
1174
|
+
throw new Error("Target app did not return an embed session.");
|
|
1043
1175
|
if (!parsed.startUrl) {
|
|
1044
1176
|
throw new Error("Target app did not return an embed start URL.");
|
|
1045
1177
|
}
|