@agent-native/dispatch 0.40.33 → 0.40.36

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 CHANGED
@@ -1,5 +1,43 @@
1
1
  # @agent-native/dispatch
2
2
 
3
+ ## 0.40.36
4
+
5
+ ### Patch Changes
6
+
7
+ - Release all public npm packages with a patch version bump.
8
+ - Updated dependencies
9
+ - Updated dependencies [31a1f1e]
10
+ - @agent-native/toolkit@0.216.0
11
+
12
+ ## 0.40.35
13
+
14
+ ### Patch Changes
15
+
16
+ - 32ecc17: Refresh the curated community QR file pin to match the tracked template.
17
+ - Release all public npm packages with a patch version bump.
18
+ - 985e9de: Refresh the curated QR template pin after the Core 0.214.0 release.
19
+ - 7d32864: Refresh the QR community app file pins during release versioning so they match the current template.
20
+ - 5f880cd: Keep the QR community app package pin aligned with its current manifest.
21
+ - 7ba1d99: Keep the curated QR app installer pinned to the current reviewed template manifest.
22
+ - 0aa618c: Fix workspace app embeds when the target returns its start URL through MCP metadata.
23
+ - 4b0bb1e: Usage metrics tools now say they only cover this organization's members and return a typed error pointing to the owning app when asked about an external customer's usage.
24
+ - Updated dependencies [f8f4b9e]
25
+ - Updated dependencies [0b58010]
26
+ - Updated dependencies
27
+ - Updated dependencies [4fd6b35]
28
+ - Updated dependencies [11a11d9]
29
+ - Updated dependencies [aa79d54]
30
+ - @agent-native/toolkit@0.215.0
31
+
32
+ ## 0.40.34
33
+
34
+ ### Patch Changes
35
+
36
+ - Release all public npm packages with a patch version bump.
37
+ - Updated dependencies
38
+ - Updated dependencies [05d1481]
39
+ - @agent-native/toolkit@0.214.0
40
+
3
41
  ## 0.40.33
4
42
 
5
43
  ### Patch Changes
@@ -1291,23 +1329,4 @@
1291
1329
 
1292
1330
  - a688849: Add organization groups and privacy controls for workspace apps. New apps use the organization default (organization-wide by default), while creators and organization admins can manage individual, group, and organization access from the shared popover.
1293
1331
 
1294
- ## 0.29.5
1295
-
1296
- ### Patch Changes
1297
-
1298
- - Updated dependencies [0b57293]
1299
- - @agent-native/toolkit@0.16.5
1300
-
1301
- ## 0.29.4
1302
-
1303
- ### Patch Changes
1304
-
1305
- - 0b0085f: Fix workspace app sign-in continuation and mounted-app launches.
1306
-
1307
- ## 0.29.3
1308
-
1309
- ### Patch Changes
1310
-
1311
- - 8cab236: Speed up workspace app opens in Dispatch by reusing the app catalog cache and deferring granted-app discovery until needed.
1312
-
1313
1332
  For the full list of releases, see the [changelog archive](./changelog/archive/CHANGELOG.md).
@@ -2,7 +2,7 @@ import { defineAction } from "@agent-native/core/action";
2
2
  import { z } from "zod";
3
3
  import { listDispatchUsageMetrics } from "../server/lib/usage-metrics-store.js";
4
4
  export default defineAction({
5
- description: "Get personal or workspace-member agent usage and spend, or aggregate app adoption metrics for Dispatch. Workspace results do not include customer/account/company usage or product data; use the relevant workspace app for those. Results may include active users, tracked app actions, app attribution, prompt previews, and recent activity. billing.unit is unknown when historical usage lacks engine metadata or mixes billing sources; monthlyByUser credits are null in that case. Workspace results also include monthlyByUser credit rows and workspaceAppCreationsByUserMonth rows from the shared token_usage and Dispatch audit tables. App scope is aggregate-only and returns daily/weekly active users plus tracked action counts for the selected app.",
5
+ description: "Reports agent/LLM usage and spend for members of this organization (personal or workspace-wide) plus aggregate app adoption for Dispatch; it does NOT cover usage, credits, or activity of external customers, accounts, companies, or product usage, which belong to the app that owns that data (see <relevant-apps>, or search with describe-workspace-apps). Results may include active users, tracked app actions, app attribution, prompt previews, and recent activity. billing.unit is unknown when historical usage lacks engine metadata or mixes billing sources; monthlyByUser credits are null in that case. Workspace results also include monthlyByUser credit rows and workspaceAppCreationsByUserMonth rows from the shared token_usage and Dispatch audit tables. App scope is aggregate-only and returns daily/weekly active users plus tracked action counts for the selected app.",
6
6
  schema: z.object({
7
7
  sinceDays: z.coerce
8
8
  .number()
@@ -20,7 +20,7 @@ export default defineAction({
20
20
  .trim()
21
21
  .min(1)
22
22
  .optional()
23
- .describe("Optional workspace member email to filter all usage to."),
23
+ .describe("Optional email of a member of this organization to filter all usage to. Not for customers or other external accounts."),
24
24
  appId: z
25
25
  .string()
26
26
  .trim()
@@ -1 +1 @@
1
- {"version":3,"file":"list-dispatch-usage-metrics.js","sourceRoot":"","sources":["../../src/actions/list-dispatch-usage-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,0uBAA0uB;IAC5uB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,SAAS,EAAE,CAAC,CAAC,MAAM;aAChB,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,GAAG,CAAC;aACR,OAAO,CAAC,EAAE,CAAC;aACX,QAAQ,CAAC,0CAA0C,CAAC;QACvD,KAAK,EAAE,CAAC;aACL,IAAI,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;aAChC,OAAO,CAAC,WAAW,CAAC;aACpB,QAAQ,CACP,wFAAwF,CACzF;QACH,SAAS,EAAE,CAAC;aACT,MAAM,EAAE;aACR,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,EAAE;aACV,QAAQ,CAAC,yDAAyD,CAAC;QACtE,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,EAAE;aACV,QAAQ,CACP,+GAA+G,CAChH;KACJ,CAAC;IACF,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;IACvB,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE;QACX,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;KACvB;IACD,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core/action\";\nimport { z } from \"zod\";\n\nimport { listDispatchUsageMetrics } from \"../server/lib/usage-metrics-store.js\";\n\nexport default defineAction({\n description:\n \"Get personal or workspace-member agent usage and spend, or aggregate app adoption metrics for Dispatch. Workspace results do not include customer/account/company usage or product data; use the relevant workspace app for those. Results may include active users, tracked app actions, app attribution, prompt previews, and recent activity. billing.unit is unknown when historical usage lacks engine metadata or mixes billing sources; monthlyByUser credits are null in that case. Workspace results also include monthlyByUser credit rows and workspaceAppCreationsByUserMonth rows from the shared token_usage and Dispatch audit tables. App scope is aggregate-only and returns daily/weekly active users plus tracked action counts for the selected app.\",\n schema: z.object({\n sinceDays: z.coerce\n .number()\n .int()\n .min(1)\n .max(365)\n .default(30)\n .describe(\"Lookback window in days. Defaults to 30.\"),\n scope: z\n .enum([\"me\", \"workspace\", \"app\"])\n .default(\"workspace\")\n .describe(\n \"Whether to inspect your account, the whole workspace, or one app's aggregate adoption.\",\n ),\n userEmail: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\"Optional workspace member email to filter all usage to.\"),\n appId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Workspace app id for scope=app. The app owner or an organization owner/admin can view its aggregate adoption.\",\n ),\n }),\n http: { method: \"GET\" },\n readOnly: true,\n parallelSafe: true,\n publicAgent: {\n expose: true,\n readOnly: true,\n requiresAuth: true,\n isConsequential: false,\n },\n run: async (args) => listDispatchUsageMetrics(args),\n});\n"]}
1
+ {"version":3,"file":"list-dispatch-usage-metrics.js","sourceRoot":"","sources":["../../src/actions/list-dispatch-usage-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,w2BAAw2B;IAC12B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,SAAS,EAAE,CAAC,CAAC,MAAM;aAChB,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,GAAG,CAAC;aACR,OAAO,CAAC,EAAE,CAAC;aACX,QAAQ,CAAC,0CAA0C,CAAC;QACvD,KAAK,EAAE,CAAC;aACL,IAAI,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;aAChC,OAAO,CAAC,WAAW,CAAC;aACpB,QAAQ,CACP,wFAAwF,CACzF;QACH,SAAS,EAAE,CAAC;aACT,MAAM,EAAE;aACR,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,EAAE;aACV,QAAQ,CACP,uHAAuH,CACxH;QACH,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,EAAE;aACV,QAAQ,CACP,+GAA+G,CAChH;KACJ,CAAC;IACF,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;IACvB,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE;QACX,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;KACvB;IACD,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core/action\";\nimport { z } from \"zod\";\n\nimport { listDispatchUsageMetrics } from \"../server/lib/usage-metrics-store.js\";\n\nexport default defineAction({\n description:\n \"Reports agent/LLM usage and spend for members of this organization (personal or workspace-wide) plus aggregate app adoption for Dispatch; it does NOT cover usage, credits, or activity of external customers, accounts, companies, or product usage, which belong to the app that owns that data (see <relevant-apps>, or search with describe-workspace-apps). Results may include active users, tracked app actions, app attribution, prompt previews, and recent activity. billing.unit is unknown when historical usage lacks engine metadata or mixes billing sources; monthlyByUser credits are null in that case. Workspace results also include monthlyByUser credit rows and workspaceAppCreationsByUserMonth rows from the shared token_usage and Dispatch audit tables. App scope is aggregate-only and returns daily/weekly active users plus tracked action counts for the selected app.\",\n schema: z.object({\n sinceDays: z.coerce\n .number()\n .int()\n .min(1)\n .max(365)\n .default(30)\n .describe(\"Lookback window in days. Defaults to 30.\"),\n scope: z\n .enum([\"me\", \"workspace\", \"app\"])\n .default(\"workspace\")\n .describe(\n \"Whether to inspect your account, the whole workspace, or one app's aggregate adoption.\",\n ),\n userEmail: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Optional email of a member of this organization to filter all usage to. Not for customers or other external accounts.\",\n ),\n appId: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\n \"Workspace app id for scope=app. The app owner or an organization owner/admin can view its aggregate adoption.\",\n ),\n }),\n http: { method: \"GET\" },\n readOnly: true,\n parallelSafe: true,\n publicAgent: {\n expose: true,\n readOnly: true,\n requiresAuth: true,\n isConsequential: false,\n },\n run: async (args) => listDispatchUsageMetrics(args),\n});\n"]}
@@ -47,7 +47,10 @@ declare const _default: import("node_modules/@agent-native/core/dist").ActionDef
47
47
  notes?: string | undefined;
48
48
  scope?: "org" | "user" | undefined;
49
49
  }, {
50
- message?: undefined;
50
+ id?: undefined;
51
+ deleted?: undefined;
52
+ provider?: undefined;
53
+ found?: undefined;
51
54
  providers: {
52
55
  id: string;
53
56
  label: string;
@@ -58,48 +61,45 @@ declare const _default: import("node_modules/@agent-native/core/dist").ActionDef
58
61
  updatedAt: number;
59
62
  }[];
60
63
  count: number;
61
- provider?: undefined;
62
- found?: undefined;
63
- deleted?: undefined;
64
64
  registered?: undefined;
65
- id?: undefined;
66
65
  label?: undefined;
67
- } | {
68
66
  message?: undefined;
69
- providers?: undefined;
67
+ } | {
68
+ id?: undefined;
69
+ deleted?: undefined;
70
70
  count?: undefined;
71
+ providers?: undefined;
71
72
  found: boolean;
72
73
  provider: import("node_modules/@agent-native/core/dist/provider-api").CustomProviderConfig;
73
- deleted?: undefined;
74
74
  registered?: undefined;
75
- id?: undefined;
76
75
  label?: undefined;
77
- } | {
78
76
  message?: undefined;
79
- providers?: undefined;
80
- count?: undefined;
77
+ } | {
78
+ deleted?: undefined;
81
79
  provider?: undefined;
80
+ count?: undefined;
81
+ providers?: undefined;
82
82
  found: boolean;
83
83
  id: string;
84
- deleted?: undefined;
85
84
  registered?: undefined;
86
85
  label?: undefined;
87
- } | {
88
86
  message?: undefined;
89
- providers?: undefined;
90
- count?: undefined;
87
+ } | {
91
88
  provider?: undefined;
89
+ count?: undefined;
92
90
  found?: undefined;
91
+ providers?: undefined;
93
92
  deleted: boolean;
94
93
  id: string;
95
94
  registered?: undefined;
96
95
  label?: undefined;
96
+ message?: undefined;
97
97
  } | {
98
- providers?: undefined;
99
- count?: undefined;
98
+ deleted?: undefined;
100
99
  provider?: undefined;
100
+ count?: undefined;
101
101
  found?: undefined;
102
- deleted?: undefined;
102
+ providers?: undefined;
103
103
  registered: boolean;
104
104
  id: string;
105
105
  label: string;
@@ -49,7 +49,7 @@ export const CURATED_COMMUNITY_APP_SOURCES = [
49
49
  },
50
50
  {
51
51
  path: "package.json",
52
- blobSha: "de917f7c794eceef303bb6f5a434ece39a6ab6fd",
52
+ blobSha: "da9e7b9eb37664a191dfde80406c7d5b350bfe0b",
53
53
  },
54
54
  {
55
55
  path: "server/db/index.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,M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,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: \"de917f7c794eceef303bb6f5a434ece39a6ab6fd\",\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,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;AAqB7B,MAAM,CAAC,MAAM,6BAA6B,GACxC;IACE;QACE,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,0DAA0D;QACvE,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,wBAAwB;QAC9B,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,KAAK;QACd,UAAU,EACR,mFAAmF;QACrF,YAAY,EAAE,wBAAwB;QACtC,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,W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I,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: \"da9e7b9eb37664a191dfde80406c7d5b350bfe0b\",\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,EAQL,KAAK,2BAA2B,EAChC,KAAK,IAAI,EACV,MAAM,wBAAwB,CAAC;AA+BhC,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,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;A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AAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAWD;AA0FD,wBAAsB,8BAA8B,CAAC,KAAK,EAAE;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,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"}
@@ -763,19 +763,32 @@ export async function openGrantedDispatchMcpApp(input) {
763
763
  }
764
764
  function parseMcpToolTextResult(result) {
765
765
  if (result && typeof result === "object") {
766
- const structured = result.structuredContent;
767
- if (structured && typeof structured === "object")
768
- return structured;
769
- const parts = Array.isArray(result.content)
770
- ? result.content
766
+ const response = result;
767
+ const meta = response._meta && typeof response._meta === "object"
768
+ ? response._meta
769
+ : undefined;
770
+ const embedStart = meta?.["agent-native/embedStart"] &&
771
+ typeof meta["agent-native/embedStart"] === "object"
772
+ ? meta["agent-native/embedStart"]
773
+ : undefined;
774
+ const withEmbedStart = (parsed) => typeof embedStart?.startUrl === "string"
775
+ ? { ...parsed, startUrl: embedStart.startUrl }
776
+ : parsed;
777
+ const structured = response.structuredContent;
778
+ if (structured && typeof structured === "object") {
779
+ return withEmbedStart(structured);
780
+ }
781
+ const parts = Array.isArray(response.content)
782
+ ? response.content
771
783
  : [];
772
784
  const text = parts.find((part) => part?.type === "text" && typeof part.text === "string")?.text;
773
785
  if (typeof text === "string" && text.trim()) {
774
- if (result.isError)
786
+ if (response.isError)
775
787
  throw new Error(text.trim());
776
788
  const parsed = JSON.parse(text);
777
- if (parsed && typeof parsed === "object")
778
- return parsed;
789
+ if (parsed && typeof parsed === "object") {
790
+ return withEmbedStart(parsed);
791
+ }
779
792
  }
780
793
  }
781
794
  throw new Error("Target app did not return an embed session.");