@agent-native/core 0.225.2-nightly-20261106152255 → 0.226.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/agent/actions/get-agentkit-capabilities.d.ts +12 -1
  2. package/dist/agent/actions/get-agentkit-capabilities.js +13 -5
  3. package/dist/agent/production-agent.js +14 -4
  4. package/dist/agentkit/capabilities.d.ts +4 -2
  5. package/dist/agentkit/capabilities.js +71 -18
  6. package/dist/app-config/experience-profiles.d.ts +4 -0
  7. package/dist/app-config/experience-profiles.js +7 -0
  8. package/dist/app-config/onboarding.d.ts +2 -0
  9. package/dist/app-config/onboarding.js +5 -0
  10. package/dist/app-config/schema.d.ts +5 -0
  11. package/dist/app-config/schema.js +2 -0
  12. package/dist/application-state/handlers.d.ts +2 -2
  13. package/dist/client/agent-chat.d.ts +3 -1
  14. package/dist/client/agent-chat.js +8 -0
  15. package/dist/client/agentkit-chat/transport.d.ts +2 -1
  16. package/dist/client/agentkit-chat/transport.js +2 -1
  17. package/dist/client/auth/builder-signup.d.ts +14 -0
  18. package/dist/client/auth/builder-signup.js +75 -0
  19. package/dist/client/chat/agentkit-agent-native.d.ts +4 -0
  20. package/dist/client/chat/agentkit-agent-native.js +25 -0
  21. package/dist/client/chat/composer-draft.d.ts +1 -7
  22. package/dist/client/chat/composer-draft.js +5 -1
  23. package/dist/client/chat/native-uploads.d.ts +11 -0
  24. package/dist/client/chat/native-uploads.js +97 -0
  25. package/dist/client/experience-profiles.d.ts +182 -0
  26. package/dist/client/experience-profiles.js +19 -0
  27. package/dist/client/uploads/index.d.ts +1 -1
  28. package/dist/client/uploads/index.js +1 -1
  29. package/dist/client/use-action.js +3 -0
  30. package/dist/collab/routes.d.ts +1 -1
  31. package/dist/experience-profiles/index.d.ts +13 -0
  32. package/dist/experience-profiles/index.js +10 -0
  33. package/dist/experience-profiles/server.d.ts +38 -0
  34. package/dist/experience-profiles/server.js +76 -0
  35. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  36. package/dist/framework-package-versions.json +11 -11
  37. package/dist/localization/workspace-integration-messages.d.ts +11 -0
  38. package/dist/localization/workspace-integration-messages.js +132 -0
  39. package/dist/mcp/screen-memory-stdio.d.ts +3 -3
  40. package/dist/notifications/routes.d.ts +3 -3
  41. package/dist/org/index.d.ts +1 -1
  42. package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
  43. package/dist/provider-api/actions/provider-api.d.ts +3 -3
  44. package/dist/provider-api/actions/provider-api.js +2 -0
  45. package/dist/provider-api/index.d.ts +7 -1
  46. package/dist/provider-api/index.js +42 -2
  47. package/dist/scripts/resources/read.d.ts +6 -1
  48. package/dist/scripts/resources/read.js +85 -8
  49. package/dist/secrets/routes.d.ts +2 -2
  50. package/dist/server/agent-chat/script-entries.js +27 -6
  51. package/dist/server/agent-chat-plugin.js +102 -33
  52. package/dist/server/agent-engine-api-key-route.d.ts +4 -4
  53. package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
  54. package/dist/server/auth.js +25 -1
  55. package/dist/server/better-auth-instance.d.ts +1 -0
  56. package/dist/server/builder-browser.d.ts +2 -0
  57. package/dist/server/builder-browser.js +8 -4
  58. package/dist/server/builder-signup-experiment.d.ts +67 -0
  59. package/dist/server/builder-signup-experiment.js +345 -0
  60. package/dist/server/core-routes-plugin.d.ts +2 -0
  61. package/dist/server/core-routes-plugin.js +77 -25
  62. package/dist/server/first-touch-route.d.ts +1 -1
  63. package/dist/server/google-oauth.d.ts +2 -0
  64. package/dist/server/google-oauth.js +5 -0
  65. package/dist/server/index.d.ts +1 -1
  66. package/dist/server/index.js +1 -1
  67. package/dist/server/transcribe-voice.d.ts +1 -1
  68. package/dist/shared/agent-chat-references.d.ts +2 -0
  69. package/dist/shared/agent-chat-references.js +8 -0
  70. package/dist/shared/auth-copy.d.ts +1 -0
  71. package/dist/shared/auth-copy.js +11 -0
  72. package/dist/shared/index.d.ts +1 -0
  73. package/dist/shared/index.js +1 -0
  74. package/dist/templates/builder-code-starter/server/lib/composer-reference-messages.ts.patch +44 -0
  75. package/dist/templates/builder-code-starter/server/plugins/agent-chat.ts.patch +10 -1
  76. package/dist/templates/chat/app/components/ChatComposerContext.tsx +31 -0
  77. package/dist/templates/chat/app/components/chat/ChatRouteContent.tsx +3 -0
  78. package/dist/templates/chat/app/components/home/HomePage.tsx +4 -2
  79. package/dist/templates/chat/app/components/layout/AgentInspector.tsx +2 -0
  80. package/dist/templates/chat/app/i18n/ar-SA.ts +7 -0
  81. package/dist/templates/chat/app/i18n/de-DE.ts +8 -0
  82. package/dist/templates/chat/app/i18n/en-US.ts +8 -0
  83. package/dist/templates/chat/app/i18n/es-ES.ts +8 -0
  84. package/dist/templates/chat/app/i18n/fr-FR.ts +8 -0
  85. package/dist/templates/chat/app/i18n/hi-IN.ts +7 -0
  86. package/dist/templates/chat/app/i18n/ja-JP.ts +8 -0
  87. package/dist/templates/chat/app/i18n/ko-KR.ts +8 -0
  88. package/dist/templates/chat/app/i18n/pt-BR.ts +8 -0
  89. package/dist/templates/chat/app/i18n/zh-CN.ts +7 -0
  90. package/dist/templates/chat/app/i18n/zh-TW.ts +7 -0
  91. package/dist/templates/chat/server/lib/composer-reference-messages.ts +34 -0
  92. package/dist/templates/chat/server/lib/composer-references.ts +60 -0
  93. package/dist/templates/chat/server/plugins/agent-chat.ts +13 -0
  94. package/docs/content/components.mdx +7 -2
  95. package/package.json +9 -4
  96. package/src/templates/builder-code-starter/server/lib/composer-reference-messages.ts.patch +44 -0
  97. package/src/templates/builder-code-starter/server/plugins/agent-chat.ts.patch +10 -1
  98. package/src/templates/chat/app/components/ChatComposerContext.tsx +31 -0
  99. package/src/templates/chat/app/components/chat/ChatRouteContent.tsx +3 -0
  100. package/src/templates/chat/app/components/home/HomePage.tsx +4 -2
  101. package/src/templates/chat/app/components/layout/AgentInspector.tsx +2 -0
  102. package/src/templates/chat/app/i18n/ar-SA.ts +7 -0
  103. package/src/templates/chat/app/i18n/de-DE.ts +8 -0
  104. package/src/templates/chat/app/i18n/en-US.ts +8 -0
  105. package/src/templates/chat/app/i18n/es-ES.ts +8 -0
  106. package/src/templates/chat/app/i18n/fr-FR.ts +8 -0
  107. package/src/templates/chat/app/i18n/hi-IN.ts +7 -0
  108. package/src/templates/chat/app/i18n/ja-JP.ts +8 -0
  109. package/src/templates/chat/app/i18n/ko-KR.ts +8 -0
  110. package/src/templates/chat/app/i18n/pt-BR.ts +8 -0
  111. package/src/templates/chat/app/i18n/zh-CN.ts +7 -0
  112. package/src/templates/chat/app/i18n/zh-TW.ts +7 -0
  113. package/src/templates/chat/server/lib/composer-reference-messages.ts +34 -0
  114. package/src/templates/chat/server/lib/composer-references.ts +60 -0
  115. package/src/templates/chat/server/plugins/agent-chat.ts +13 -0
@@ -1,2 +1,13 @@
1
- declare const _default: import("../../action.js").ActionDefinition<Record<string, never>, import("../../agentkit/capabilities.js").AgentKitCapabilityCatalog>;
1
+ declare const _default: import("../../action.js").ActionDefinition<Record<string, never>, {
2
+ sources: {
3
+ figma: {
4
+ available: boolean;
5
+ };
6
+ };
7
+ integrations: {
8
+ id: string;
9
+ label: string;
10
+ kind: "mcp" | "provider-api";
11
+ }[];
12
+ }>;
2
13
  export default _default;
@@ -1,17 +1,25 @@
1
1
  import { z } from "zod";
2
2
  import { defineAction, fail } from "../../action.js";
3
- import { listAgentKitCapabilities, } from "../../agentkit/capabilities.js";
3
+ import { listAgentKitCapabilities } from "../../agentkit/capabilities.js";
4
4
  export default defineAction({
5
- description: "Read the signed-in user's AgentKit context-source and integration capabilities for Design, Slides, or Slides 2. Returns only supported, connected capability labels and availability; never returns credentials or connection details.",
5
+ description: "Read context-source availability and connected workspace integrations usable by the authenticated caller in the current app. Returns scoped capability labels, never credentials or connection details.",
6
6
  schema: z.object({}),
7
+ outputSchema: z.object({
8
+ sources: z.object({ figma: z.object({ available: z.boolean() }) }),
9
+ integrations: z.array(z.object({
10
+ id: z.string(),
11
+ label: z.string(),
12
+ kind: z.enum(["provider-api", "mcp"]),
13
+ })),
14
+ }),
7
15
  http: { method: "GET" },
8
16
  readOnly: true,
9
17
  agentTool: false,
10
18
  toolCallable: false,
11
19
  run: async (_args, ctx) => {
12
- const appId = ctx?.appId;
13
- if (appId !== "design" && appId !== "slides") {
14
- fail("AgentKit capabilities are only available in Design and Slides.", {
20
+ const appId = ctx?.appId?.trim();
21
+ if (!appId) {
22
+ fail("An app context is required to read workspace integrations.", {
15
23
  errorCode: "agentkit_capabilities_unsupported_app",
16
24
  statusCode: 400,
17
25
  });
@@ -4,12 +4,13 @@ import { AGENT_NATIVE_SUBMISSION_EXPIRES_AT_METADATA_KEY, AGENT_NATIVE_SUBMISSIO
4
4
  import Ajv from "ajv";
5
5
  import Ajv2020 from "ajv/dist/2020.js";
6
6
  import { defineEventHandler, getHeader, setResponseHeader, setResponseStatus, getMethod, } from "h3";
7
- import "../authorization/check-action.js";
8
7
  import { parseA2AAgentActivityPart } from "../a2a/activity.js";
8
+ import "../authorization/check-action.js";
9
9
  import { actionCallIsRetrySafe, actionChangeResource, classifyActionCall, } from "../action-call-classification.js";
10
10
  import { runOutsideActionInvocation, vouchedOutcome } from "../action-frame.js";
11
11
  import { ACTION_CHAT_UI_RECORD_CHANGE_RENDERER, normalizeActionChangeResult, } from "../action-ui.js";
12
12
  import { AgentConnectionRequiredError, describeToolParameterSignature, isActionContractError, isActionHiddenFromEveryAgentSurface, isAgentActionStopError, isAgentConnectionRequiredError, actionCallIntent, ActionInputValidationError, telemetryInvalidPaths, invocationEffect, runPreparedActionCall, boundActionCallIntent, preparedCallArguments, preparedCallNeedsApproval, recordInvalidActionCall, resolveToolMaxResultChars, stripUnsupportedSchemaKeywords, } from "../action.js";
13
+ import { resolveAgentKitIntegrationReferences } from "../agentkit/capabilities.js";
13
14
  import { getAppConfig } from "../app-config/index.js";
14
15
  import { MAX_BACKGROUND_RUN_CONTINUATIONS, MAX_CONSECUTIVE_NO_PROGRESS_CONTINUATIONS, MAX_TURN_WALL_CLOCK_MS, } from "../app-config/run-lifecycle-invariants.js";
15
16
  import { readAppState } from "../application-state/script-helpers.js";
@@ -2779,7 +2780,7 @@ async function enrichMessage(message, references) {
2779
2780
  const fileRefs = references.filter((r) => r.type === "file");
2780
2781
  const skillRefs = references.filter((r) => r.type === "skill");
2781
2782
  const customAgentRefs = references.filter((r) => r.type === "custom-agent");
2782
- const mentionRefs = references.filter((r) => r.type === "mention");
2783
+ const mentionRefs = references.filter((r) => r.type === "mention" && r.refType !== "integration");
2783
2784
  const parts = [];
2784
2785
  if (fileRefs.length > 0) {
2785
2786
  parts.push("Referenced files:\n" +
@@ -10886,6 +10887,14 @@ export function createProductionAgentHandler(options) {
10886
10887
  retryable: false,
10887
10888
  };
10888
10889
  }
10890
+ const integrationCredentialScope = getRequestContext()?.credentialScope;
10891
+ const integrationIntents = await resolveAgentKitIntegrationReferences(options.appId ?? "", requestReferences, {
10892
+ userEmail: getRequestUserEmail() ?? ownerEmail ?? "",
10893
+ orgId: getRequestOrgId() ?? null,
10894
+ ...(integrationCredentialScope
10895
+ ? { credentialScope: integrationCredentialScope }
10896
+ : {}),
10897
+ });
10889
10898
  const contextPrefetchDeadlineAt = Date.now() + 1_300;
10890
10899
  const preparedRequest = await options.prepareRequest?.({
10891
10900
  event,
@@ -11343,7 +11352,8 @@ export function createProductionAgentHandler(options) {
11343
11352
  }
11344
11353
  setupMark("prepDone");
11345
11354
  workerStep("env_config");
11346
- const enrichedMessageThunk = () => enrichMessage(requestMessage, requestReferences);
11355
+ const integrationMessage = [...integrationIntents, requestMessage].join("\n\n");
11356
+ const enrichedMessageThunk = () => enrichMessage(integrationMessage, requestReferences);
11347
11357
  const loopSettingsThunk = () => readAgentLoopSettings({
11348
11358
  userEmail: ownerEmail ?? getRequestUserEmail() ?? null,
11349
11359
  orgId: getRequestOrgId() ?? null,
@@ -11633,7 +11643,7 @@ export function createProductionAgentHandler(options) {
11633
11643
  }),
11634
11644
  presendCap("files", filesContextThunk, "", 12000),
11635
11645
  presendCap("loopSettings", loopSettingsThunk, fallbackLoopSettings, 9000),
11636
- presendCap("enrichedMessage", enrichedMessageThunk, requestMessage, 9000),
11646
+ presendCap("enrichedMessage", enrichedMessageThunk, integrationMessage, 9000),
11637
11647
  presendCap("jevContextCredentials", () => getJevContextCredentials(ownerEmail ?? getRequestUserEmail()), { apiKey: undefined, personalApiKey: undefined, builderAuth: null }, 9000),
11638
11648
  presendCap("priorConnection",
11639
11649
  // The foreground of a dispatched run never prompts the model; the
@@ -1,5 +1,6 @@
1
+ import type { AgentChatReference } from "../agent/types.js";
1
2
  import type { CredentialContext } from "../credentials/index.js";
2
- export type AgentKitCapabilityAppId = "design" | "slides";
3
+ export type AgentKitCapabilityAppId = string;
3
4
  export interface AgentKitIntegrationCapability {
4
5
  id: string;
5
6
  label: string;
@@ -13,10 +14,11 @@ export interface AgentKitCapabilityCatalog {
13
14
  };
14
15
  integrations: AgentKitIntegrationCapability[];
15
16
  }
16
- export declare function isAgentKitFigmaSourceAvailable(context: CredentialContext): Promise<boolean>;
17
+ export declare function isAgentKitFigmaSourceAvailable(context: CredentialContext, appId?: AgentKitCapabilityAppId): Promise<boolean>;
17
18
  export declare function listAgentKitCapabilities(appId: AgentKitCapabilityAppId, context: CredentialContext): Promise<AgentKitCapabilityCatalog>;
18
19
  export declare function readAgentKitIntegrationIntent(appId: AgentKitCapabilityAppId, provider: string, context: CredentialContext): Promise<{
19
20
  id: string;
20
21
  title: string;
21
22
  context: string;
22
23
  } | null>;
24
+ export declare function resolveAgentKitIntegrationReferences(appId: string, references: readonly AgentChatReference[], context: CredentialContext): Promise<string[]>;
@@ -1,7 +1,9 @@
1
+ import { fail } from "../action.js";
2
+ import { workspaceIntegrationMessagesForUser } from "../localization/workspace-integration-messages.js";
1
3
  import { parseMergedKey } from "../mcp-client/remote-store.js";
2
4
  import { isMcpToolAllowedForRequest } from "../mcp-client/visibility.js";
3
5
  import { hasOAuthTokens } from "../oauth-tokens/index.js";
4
- import { defaultProviderApiCredentialResolver, getProviderApiConfig, isProviderApiId, listProviderApiIdsForTemplateUse, } from "../provider-api/index.js";
6
+ import { defaultProviderApiCredentialResolver, getProviderApiConfig, isProviderApiId, getRegisteredProviderApiRuntimeOptions, listRegisteredCustomProviderCapabilities, } from "../provider-api/index.js";
5
7
  import { getMcpManagerForCurrentRequest } from "../server/agent-chat/mcp-glue.js";
6
8
  import { getRequestContext, runWithRequestContext, } from "../server/request-context.js";
7
9
  import { resolveWorkspaceConnectionForApp } from "../workspace-connections/index.js";
@@ -50,19 +52,22 @@ function workspaceProvider(auth) {
50
52
  return "workspaceProvider" in auth ? auth.workspaceProvider : undefined;
51
53
  }
52
54
  async function groupHasCredentials(appId, provider, keys, context) {
53
- const config = getProviderApiConfig(provider);
54
- const resolved = await Promise.all(keys.map((key) => defaultProviderApiCredentialResolver({
55
+ const runtime = getRegisteredProviderApiRuntimeOptions(appId);
56
+ const config = getProviderApiConfig(provider, runtime?.providerOverrides);
57
+ const providerWorkspace = workspaceProvider(config.auth);
58
+ const resolved = await Promise.all(keys.map((key) => (runtime?.resolveCredential ?? defaultProviderApiCredentialResolver)({
55
59
  appId,
56
60
  provider,
57
61
  key,
58
62
  ctx: context,
59
- workspaceProvider: workspaceProvider(config.auth),
60
- localCredentialSource: `${appId}_local`,
63
+ ...(providerWorkspace ? { workspaceProvider: providerWorkspace } : {}),
64
+ localCredentialSource: runtime?.localCredentialSource ?? "app_local",
61
65
  })));
62
66
  return resolved.every(Boolean);
63
67
  }
64
68
  async function isIntegrationAvailable(appId, provider, context) {
65
- const config = getProviderApiConfig(provider);
69
+ const runtime = getRegisteredProviderApiRuntimeOptions(appId);
70
+ const config = getProviderApiConfig(provider, runtime?.providerOverrides);
66
71
  if (config.auth.type === "oauth-bearer") {
67
72
  if (config.auth.workspaceProvider) {
68
73
  const connection = await resolveWorkspaceConnectionForApp({
@@ -140,18 +145,15 @@ async function listConnectedMcpIntegrations() {
140
145
  : [];
141
146
  });
142
147
  }
143
- export async function isAgentKitFigmaSourceAvailable(context) {
144
- return inCapabilityScope(context, () => listProviderApiIdsForTemplateUse("design").includes("figma") &&
145
- isIntegrationAvailable("design", "figma", context));
148
+ export async function isAgentKitFigmaSourceAvailable(context, appId = "design") {
149
+ return inCapabilityScope(context, () => (getRegisteredProviderApiRuntimeOptions(appId)?.providerIds ?? []).includes("figma") && isIntegrationAvailable(appId, "figma", context));
146
150
  }
147
151
  export async function listAgentKitCapabilities(appId, context) {
148
152
  return inCapabilityScope(context, async () => {
149
- const supported = listProviderApiIdsForTemplateUse(appId);
150
- const figmaAvailable = await isAgentKitFigmaSourceAvailable(context);
151
- const integrations = await Promise.all(supported
152
- .filter((provider) => provider !== "figma")
153
- .map(async (id) => {
154
- const config = getProviderApiConfig(id);
153
+ const supported = (getRegisteredProviderApiRuntimeOptions(appId)?.providerIds ?? []).filter(isProviderApiId);
154
+ const figmaAvailable = await isAgentKitFigmaSourceAvailable(context, appId);
155
+ const integrations = await Promise.all(supported.map(async (id) => {
156
+ const config = getProviderApiConfig(id, getRegisteredProviderApiRuntimeOptions(appId)?.providerOverrides);
155
157
  return (await isIntegrationAvailable(appId, id, context))
156
158
  ? {
157
159
  id,
@@ -164,6 +166,7 @@ export async function listAgentKitCapabilities(appId, context) {
164
166
  sources: { figma: { available: figmaAvailable } },
165
167
  integrations: [
166
168
  ...integrations.filter((integration) => integration !== null),
169
+ ...(await listRegisteredCustomProviderCapabilities(appId, context)).map((entry) => ({ ...entry, kind: "provider-api" })),
167
170
  ...(await listConnectedMcpIntegrations()),
168
171
  ],
169
172
  };
@@ -178,6 +181,7 @@ export async function readAgentKitIntegrationIntent(appId, provider, context) {
178
181
  if (!serverId ||
179
182
  !isMcpServerInScope(serverId) ||
180
183
  !manager.hasServer(serverId) ||
184
+ !manager.getStatus().connectedServers.includes(serverId) ||
181
185
  !config ||
182
186
  !manager
183
187
  .getToolsForServer(serverId)
@@ -194,14 +198,23 @@ export async function readAgentKitIntegrationIntent(appId, provider, context) {
194
198
  ].join("\n"),
195
199
  };
196
200
  }
197
- const supported = listProviderApiIdsForTemplateUse(appId);
201
+ if (!isProviderApiId(provider)) {
202
+ const custom = (await listRegisteredCustomProviderCapabilities(appId, context)).find((entry) => entry.id === provider);
203
+ return custom
204
+ ? {
205
+ id: provider,
206
+ title: custom.label,
207
+ context: `The user selected the connected ${custom.label} integration for this request. Use its available provider tools when relevant; this selection is not retrieved data or proof an operation succeeded.`,
208
+ }
209
+ : null;
210
+ }
211
+ const supported = (getRegisteredProviderApiRuntimeOptions(appId)?.providerIds ?? []).filter(isProviderApiId);
198
212
  if (!isProviderApiId(provider) ||
199
213
  !supported.includes(provider) ||
200
- provider === "figma" ||
201
214
  !(await isIntegrationAvailable(appId, provider, context))) {
202
215
  return null;
203
216
  }
204
- const label = displayLabel(getProviderApiConfig(provider).label);
217
+ const label = displayLabel(getProviderApiConfig(provider, getRegisteredProviderApiRuntimeOptions(appId)?.providerOverrides).label);
205
218
  return {
206
219
  id: provider,
207
220
  title: label,
@@ -212,3 +225,43 @@ export async function readAgentKitIntegrationIntent(appId, provider, context) {
212
225
  };
213
226
  });
214
227
  }
228
+ export async function resolveAgentKitIntegrationReferences(appId, references, context) {
229
+ const integrations = references.filter((reference) => reference.refType === "integration" ||
230
+ reference.source === "workspace-integration");
231
+ if (!integrations.length)
232
+ return [];
233
+ const messages = await workspaceIntegrationMessagesForUser(context.userEmail);
234
+ if (integrations.length > 20) {
235
+ fail(messages.limit, {
236
+ errorCode: "workspace_integration_limit",
237
+ statusCode: 400,
238
+ });
239
+ }
240
+ const selected = new Set();
241
+ const intents = [];
242
+ for (const reference of integrations) {
243
+ const id = reference.refId;
244
+ if (!appId.trim() ||
245
+ reference.type !== "mention" ||
246
+ reference.refType !== "integration" ||
247
+ !id ||
248
+ id.length > 200) {
249
+ fail(messages.invalid, {
250
+ errorCode: "workspace_integration_invalid",
251
+ statusCode: 400,
252
+ });
253
+ }
254
+ if (selected.has(id))
255
+ continue;
256
+ selected.add(id);
257
+ const intent = await readAgentKitIntegrationIntent(appId, id, context);
258
+ if (!intent) {
259
+ fail(messages.unavailable, {
260
+ errorCode: "workspace_integration_unavailable",
261
+ statusCode: 403,
262
+ });
263
+ }
264
+ intents.push(intent.context);
265
+ }
266
+ return intents;
267
+ }
@@ -0,0 +1,4 @@
1
+ import { z } from "zod";
2
+ export declare const experienceProfilesConfig: z.ZodObject<{
3
+ referenceEmails: z.ZodDefault<z.ZodArray<z.ZodString>>;
4
+ }, z.core.$strip>;
@@ -0,0 +1,7 @@
1
+ import { z } from "zod";
2
+ export const experienceProfilesConfig = z.object({
3
+ referenceEmails: z.array(z.string().email()).default([]).meta({
4
+ env: "EXPERIENCE_REFERENCE_EMAILS",
5
+ doc: "Reviewers authorized to select the private reference experience. Empty denies reference access.",
6
+ }),
7
+ });
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod";
2
2
  export declare const onboardingConfig: z.ZodObject<{
3
+ builderSignupExperiment: z.ZodDefault<z.ZodBoolean>;
4
+ builderSignupExperimentOverride: z.ZodOptional<z.ZodBoolean>;
3
5
  firstRunCreditsExperiment: z.ZodDefault<z.ZodEnum<{
4
6
  v1: "v1";
5
7
  v2: "v2";
@@ -1,5 +1,10 @@
1
1
  import { z } from "zod";
2
2
  export const onboardingConfig = z.object({
3
+ builderSignupExperiment: z.boolean().default(false),
4
+ builderSignupExperimentOverride: z.boolean().optional().meta({
5
+ env: "BUILDER_SIGNUP_EXPERIMENT",
6
+ doc: "Enable the pre-signup automatic Builder account experiment for Design.",
7
+ }),
3
8
  firstRunCreditsExperiment: z.enum(["v1", "v2"]).default("v1"),
4
9
  firstRunCreditsExperimentOverride: z.literal("v1").optional().meta({
5
10
  env: "FIRST_RUN_CREDITS_EXPERIMENT",
@@ -169,6 +169,9 @@ export declare const appConfigSchema: z.ZodObject<{
169
169
  workspaceOwnerEmails: z.ZodDefault<z.ZodArray<z.ZodString>>;
170
170
  defaultOwnerEmail: z.ZodOptional<z.ZodString>;
171
171
  }, z.core.$strip>>;
172
+ experienceProfiles: z.ZodPrefault<z.ZodObject<{
173
+ referenceEmails: z.ZodDefault<z.ZodArray<z.ZodString>>;
174
+ }, z.core.$strip>>;
172
175
  extensions: z.ZodPrefault<z.ZodObject<{
173
176
  iframeImageSources: z.ZodDefault<z.ZodArray<z.ZodString>>;
174
177
  iframeMediaSources: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -268,6 +271,8 @@ export declare const appConfigSchema: z.ZodObject<{
268
271
  inferredSentimentModel: z.ZodDefault<z.ZodString>;
269
272
  }, z.core.$strip>>;
270
273
  onboarding: z.ZodPrefault<z.ZodObject<{
274
+ builderSignupExperiment: z.ZodDefault<z.ZodBoolean>;
275
+ builderSignupExperimentOverride: z.ZodOptional<z.ZodBoolean>;
271
276
  firstRunCreditsExperiment: z.ZodDefault<z.ZodEnum<{
272
277
  v1: "v1";
273
278
  v2: "v2";
@@ -8,6 +8,7 @@ import { authConfig } from "./auth.js";
8
8
  import { clipsConfig } from "./clips.js";
9
9
  import { decisionsConfig } from "./decisions.js";
10
10
  import { dispatchConfig } from "./dispatch.js";
11
+ import { experienceProfilesConfig } from "./experience-profiles.js";
11
12
  import { extensionsConfig } from "./extensions.js";
12
13
  import { hostedStorageConfig } from "./hosted-storage.js";
13
14
  import { integrationsConfig } from "./integrations.js";
@@ -68,6 +69,7 @@ export const appConfigSchema = z.object({
68
69
  clips: clipsConfig.prefault({}),
69
70
  decisions: decisionsConfig.prefault({}),
70
71
  dispatch: dispatchConfig.prefault({}),
72
+ experienceProfiles: experienceProfilesConfig.prefault({}),
71
73
  extensions: extensionsConfig.prefault({}),
72
74
  hostedStorage: hostedStorageConfig.prefault({}),
73
75
  integrations: integrationsConfig.prefault({}),
@@ -36,18 +36,18 @@ export declare const listComposeDrafts: import("h3").EventHandlerWithFetch<impor
36
36
  export declare const getComposeDraft: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<Record<string, unknown> | null>>;
37
37
  export declare const putComposeDraft: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<any>>;
38
38
  export declare const saveComposeDraft: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
39
- errorCode?: undefined;
40
39
  value?: undefined;
41
40
  error: string;
42
41
  revision?: undefined;
42
+ errorCode?: undefined;
43
43
  details?: undefined;
44
44
  } | {
45
- errorCode?: undefined;
46
45
  error?: undefined;
47
46
  value: {
48
47
  id: string;
49
48
  };
50
49
  revision: string;
50
+ errorCode?: undefined;
51
51
  details?: undefined;
52
52
  } | {
53
53
  value?: undefined;
@@ -1,4 +1,4 @@
1
- import { type AgentActionScope, type AgentChatAttachment, type MentionItemMedia } from "../agent/types.js";
1
+ import { type AgentActionScope, type AgentChatAttachment, type AgentChatReference, type MentionItemMedia } from "../agent/types.js";
2
2
  import type { ReasoningEffort } from "../shared/reasoning-effort.js";
3
3
  import { type McpAppModelContextContentPart } from "./mcp-app-host.js";
4
4
  export { appendAgentChatContextToMessage } from "../shared/agent-chat-context.js";
@@ -19,6 +19,7 @@ export interface AgentChatMessage {
19
19
  uploadedReferenceImages?: string[];
20
20
  images?: string[];
21
21
  attachments?: AgentChatAttachment[];
22
+ references?: AgentChatReference[];
22
23
  /** Stable tab identifier — auto-generated if omitted */
23
24
  tabId?: string;
24
25
  targetTabId?: string;
@@ -190,6 +191,7 @@ export interface ParsedSubmitChat {
190
191
  targetTabId?: string;
191
192
  images?: string[];
192
193
  attachments?: AgentChatAttachment[];
194
+ references?: AgentChatReference[];
193
195
  requestMode?: AgentChatRequestMode;
194
196
  submitMessageId?: string;
195
197
  submissionExpiresAt?: number;
@@ -1,4 +1,5 @@
1
1
  import { normalizeAgentActionScope, tryNormalizeAgentActionScope, } from "../agent/types.js";
2
+ import { parseAgentChatReferences } from "../shared/agent-chat-references.js";
2
3
  import { formatAgentSelectionPreamble } from "../shared/agent-selection.js";
3
4
  import { parseBase64DataUrl } from "../shared/data-url.js";
4
5
  import { trackEvent } from "./analytics.js";
@@ -575,6 +576,7 @@ function isDirectMcpAppEmbedSession() {
575
576
  function hasMcpAppLocalPayload(opts, additionalSubmitMessageId) {
576
577
  return Boolean(opts.attachments?.length ||
577
578
  opts.images?.length ||
579
+ opts.references?.length ||
578
580
  opts.referenceImagePaths?.length ||
579
581
  opts.uploadedReferenceImages?.length ||
580
582
  opts.usageLabel ||
@@ -653,6 +655,7 @@ function mcpAppHostContent(opts) {
653
655
  }
654
656
  function hasMcpAppLocalOnlySemantics(opts, content) {
655
657
  return Boolean(content === null ||
658
+ opts.references?.length ||
656
659
  opts.referenceImagePaths?.length ||
657
660
  opts.uploadedReferenceImages?.length ||
658
661
  opts.usageLabel ||
@@ -805,6 +808,11 @@ export function parseSubmitChatMessage(event) {
805
808
  targetTabId: nonEmptyString(raw.targetTabId),
806
809
  images,
807
810
  attachments: parseSubmitChatAttachments(raw.attachments),
811
+ ...(raw.references === undefined
812
+ ? {}
813
+ : {
814
+ references: parseAgentChatReferences(raw.references),
815
+ }),
808
816
  requestMode: normalizeAgentChatRequestMode(raw.requestMode ?? raw.mode),
809
817
  submitMessageId: typeof raw.submitMessageId === "string" ? raw.submitMessageId : undefined,
810
818
  ...(hasSubmissionExpiresAt
@@ -1 +1,2 @@
1
- export { createAgentNativeAgentKitTransport } from "../chat/agentkit-agent-native.js";
1
+ export { createAgentNativeAgentKitTransport, getAgentNativeAgentKitUploadDriver, clearAgentNativeAgentKitUploads, } from "../chat/agentkit-agent-native.js";
2
+ export { createAgentNativeUploadRuntime, fileUploadUrlForChatApi, } from "../chat/native-uploads.js";
@@ -1 +1,2 @@
1
- export { createAgentNativeAgentKitTransport } from "../chat/agentkit-agent-native.js";
1
+ export { createAgentNativeAgentKitTransport, getAgentNativeAgentKitUploadDriver, clearAgentNativeAgentKitUploads, } from "../chat/agentkit-agent-native.js";
2
+ export { createAgentNativeUploadRuntime, fileUploadUrlForChatApi, } from "../chat/native-uploads.js";
@@ -0,0 +1,14 @@
1
+ export type BuilderSignupAssignment = {
2
+ status: "assigned";
3
+ id: string;
4
+ variant: "control" | "automatic";
5
+ policy: string;
6
+ } | {
7
+ status: "disabled";
8
+ } | {
9
+ status: "unavailable";
10
+ };
11
+ export declare function getBuilderSignupAssignment(): Promise<BuilderSignupAssignment>;
12
+ export declare function acceptBuilderSignupAssignment(assignmentId: string, attemptId: string, method: "password" | "magic-link" | "google", email?: string): Promise<void>;
13
+ export declare function activateBuilderSignupAssignment(): Promise<"connected" | "fallback" | "disabled">;
14
+ export declare function hasPendingBuilderSignupAssignment(): boolean;
@@ -0,0 +1,75 @@
1
+ import { agentNativePath } from "../api-path.js";
2
+ async function request(body, signal = AbortSignal.timeout(8000)) {
3
+ const response = await fetch(agentNativePath("/_agent-native/auth/builder-signup-experiment"), {
4
+ ...(body
5
+ ? {
6
+ method: "POST",
7
+ headers: { "Content-Type": "application/json" },
8
+ body: JSON.stringify(body),
9
+ }
10
+ : {}),
11
+ credentials: "same-origin",
12
+ signal,
13
+ });
14
+ if (!response.ok)
15
+ throw new Error(`Builder signup request failed (${response.status})`);
16
+ const result = await response.json();
17
+ if (!result || typeof result !== "object" || Array.isArray(result))
18
+ throw new Error("Invalid Builder signup response");
19
+ return result;
20
+ }
21
+ export async function getBuilderSignupAssignment() {
22
+ const result = await request();
23
+ if (result.status === "disabled")
24
+ return { status: "disabled" };
25
+ if (result.status === "assigned" &&
26
+ typeof result.id === "string" &&
27
+ typeof result.policy === "string" &&
28
+ (result.variant === "control" || result.variant === "automatic"))
29
+ return {
30
+ status: "assigned",
31
+ id: result.id,
32
+ policy: result.policy,
33
+ variant: result.variant,
34
+ };
35
+ throw new Error("Invalid Builder signup assignment");
36
+ }
37
+ export async function acceptBuilderSignupAssignment(assignmentId, attemptId, method, email) {
38
+ const result = await request({
39
+ operation: "accept",
40
+ assignmentId,
41
+ attemptId,
42
+ method,
43
+ ...(email ? { email } : {}),
44
+ });
45
+ if (result.status !== "accepted")
46
+ throw new Error("Builder signup acceptance was not recorded");
47
+ }
48
+ export async function activateBuilderSignupAssignment() {
49
+ const deadline = Date.now() + 30000;
50
+ const signal = AbortSignal.timeout(30000);
51
+ try {
52
+ while (Date.now() < deadline) {
53
+ const result = await request({ operation: "activate" }, signal);
54
+ if (result.status === "connected" ||
55
+ result.status === "fallback" ||
56
+ result.status === "disabled")
57
+ return result.status;
58
+ if (result.status !== "pending")
59
+ throw new Error("Builder signup activation did not complete");
60
+ await new Promise((resolve) => setTimeout(resolve, Math.min(500, Math.max(0, deadline - Date.now()))));
61
+ }
62
+ throw new Error("Builder signup activation is still pending");
63
+ }
64
+ finally {
65
+ if (typeof document !== "undefined")
66
+ document.cookie =
67
+ "an_builder_signup_pending=; Path=/; Max-Age=0; SameSite=Lax";
68
+ }
69
+ }
70
+ export function hasPendingBuilderSignupAssignment() {
71
+ return (typeof document !== "undefined" &&
72
+ document.cookie
73
+ .split(";")
74
+ .some((value) => value.trim() === "an_builder_signup_pending=1"));
75
+ }
@@ -1,5 +1,9 @@
1
+ import type { AgentKitUploadDriver } from "@agent-native/agentkit";
2
+ import type { AgentTransport } from "@agent-native/agentkit/protocol";
1
3
  import { type AgentKitProtocolAdapter, type CreateAgentKitProtocolAdapterOptions } from "./agentkit-protocol.js";
2
4
  import { type AgentChatRuntime, type CreateAgentNativeChatRuntimeOptions } from "./runtime.js";
5
+ export declare function getAgentNativeAgentKitUploadDriver(transport: AgentTransport): AgentKitUploadDriver | undefined;
6
+ export declare function clearAgentNativeAgentKitUploads(transport: object): void;
3
7
  export interface CreateAgentNativeAgentKitTransportOptions extends CreateAgentNativeChatRuntimeOptions {
4
8
  /** Optional host runtime executed through AgentKit's protocol lifecycle. */
5
9
  readonly runtime?: AgentChatRuntime;
@@ -11,10 +11,18 @@ import { CHAT_CAPABILITY_UNAVAILABLE_MESSAGE, CHAT_CAPABILITY_UNSUPPORTED_MESSAG
11
11
  import { dispatchAgentChatRunning } from "../use-agent-chat-running-threads.js";
12
12
  import { appendChatThreadScopeParams, } from "../use-chat-threads.js";
13
13
  import { AGENT_NATIVE_PROTOCOL_METADATA_KEY, createAgentKitProtocolAdapter, } from "./agentkit-protocol.js";
14
+ import { createAgentNativeUploadRuntime, fileUploadUrlForChatApi, } from "./native-uploads.js";
14
15
  import { trackRunFeedback, trackRunOutcome } from "./run-outcome-telemetry.js";
15
16
  import { runOutcomeForCode } from "./run-outcome.js";
16
17
  import { createAgentNativeChatRuntime, isAgentNativeChatRuntime, } from "./runtime.js";
17
18
  import { trackTurnSubmitted } from "./turn-submitted-telemetry.js";
19
+ const nativeUploadCleanups = new WeakMap();
20
+ export function getAgentNativeAgentKitUploadDriver(transport) {
21
+ return nativeUploadCleanups.has(transport) ? transport.upload : undefined;
22
+ }
23
+ export function clearAgentNativeAgentKitUploads(transport) {
24
+ nativeUploadCleanups.get(transport)?.();
25
+ }
18
26
  const RUN_SLOT_POLL_INTERVAL_MS = 150;
19
27
  const RUN_SLOT_STABLE_POLLS = 2;
20
28
  const SAFE_BOUNDARY_POLL_INTERVAL_MS = 500;
@@ -2267,6 +2275,15 @@ export function createAgentNativeAgentKitTransport(options = {}) {
2267
2275
  const apiUrl = options.apiUrl ?? agentNativePath("/_agent-native/agent-chat");
2268
2276
  const fetcher = options.fetch ?? fetch;
2269
2277
  const now = options.adapter?.now ?? (() => new Date().toISOString());
2278
+ const defaultUploads = !options.operations?.createUpload &&
2279
+ !options.operations?.completeUpload &&
2280
+ !options.operations?.cancelUpload
2281
+ ? createAgentNativeUploadRuntime({
2282
+ url: fileUploadUrlForChatApi(apiUrl),
2283
+ fetch: fetcher,
2284
+ headers: (threadId) => headers({ sessionId: threadId }),
2285
+ })
2286
+ : undefined;
2270
2287
  const promotionClaimIds = new Map();
2271
2288
  const durableAssistantMessageIdsByRun = new Map();
2272
2289
  const assistantHistoryMessageIdsByRun = new Map();
@@ -3545,6 +3562,7 @@ export function createAgentNativeAgentKitTransport(options = {}) {
3545
3562
  connectionRequests: true,
3546
3563
  },
3547
3564
  operations: {
3565
+ ...defaultUploads?.operations,
3548
3566
  getThread: async ({ threadId }) => {
3549
3567
  const thread = await snapshot(threadId);
3550
3568
  if (!thread)
@@ -4081,6 +4099,11 @@ export function createAgentNativeAgentKitTransport(options = {}) {
4081
4099
  : `${apiUrl}/capabilities`;
4082
4100
  transport = {
4083
4101
  ...protocolTransport,
4102
+ ...(defaultUploads ? { upload: defaultUploads.upload } : {}),
4103
+ async dispose() {
4104
+ defaultUploads?.dispose();
4105
+ await protocolTransport.dispose();
4106
+ },
4084
4107
  assertAiSetupReady,
4085
4108
  startRun: (input, context) => startRunTrackingRunningState(input, context),
4086
4109
  async discoverCapabilities(input, context) {
@@ -4331,5 +4354,7 @@ export function createAgentNativeAgentKitTransport(options = {}) {
4331
4354
  }
4332
4355
  },
4333
4356
  };
4357
+ if (defaultUploads)
4358
+ nativeUploadCleanups.set(transport, defaultUploads.dispose);
4334
4359
  return transport;
4335
4360
  }
@@ -2,13 +2,7 @@ import { z } from "zod";
2
2
  declare const composerContextDraftSchema: z.ZodObject<{
3
3
  designSystemId: z.ZodNullable<z.ZodString>;
4
4
  references: z.ZodArray<z.ZodObject<{
5
- source: z.ZodEnum<{
6
- design: "design";
7
- figma: "figma";
8
- integration: "integration";
9
- slides: "slides";
10
- website: "website";
11
- }>;
5
+ source: z.ZodString;
12
6
  id: z.ZodString;
13
7
  title: z.ZodString;
14
8
  url: z.ZodOptional<z.ZodString>;
@@ -7,7 +7,11 @@ const composerContextDraftSchema = z.object({
7
7
  designSystemId: z.string().min(1).max(200).nullable(),
8
8
  references: z
9
9
  .array(z.object({
10
- source: z.enum(["design", "slides", "figma", "website", "integration"]),
10
+ source: z
11
+ .string()
12
+ .min(1)
13
+ .max(128)
14
+ .regex(/^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$/i),
11
15
  id: z.string().min(1).max(2048),
12
16
  title: z.string().max(2048),
13
17
  url: composerWebsiteUrlSchema.optional(),
@@ -0,0 +1,11 @@
1
+ import type { AgentTransport } from "@agent-native/agentkit/protocol";
2
+ export declare function fileUploadUrlForChatApi(apiUrl: string): string;
3
+ export declare function createAgentNativeUploadRuntime(options?: {
4
+ url?: string;
5
+ fetch?: typeof fetch;
6
+ headers?: (threadId: string) => Promise<Headers>;
7
+ }): {
8
+ operations: Required<Pick<AgentTransport, "cancelUpload" | "completeUpload" | "createUpload">>;
9
+ upload: import("@agent-native/agentkit").AgentUploadDriver;
10
+ dispose: () => void;
11
+ };