@agent-native/core 0.222.0 → 0.222.1-nightly-20261029063606

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.
@@ -5,7 +5,7 @@ import { fail, isActionContractError, } from "../../action.js";
5
5
  import { getActiveFileUploadProviderForRequest } from "../../file-upload/registry.js";
6
6
  import { areBuiltinMcpCapabilitiesSupported, setBuiltinMcpCapabilityEnabled, } from "../../mcp-client/index.js";
7
7
  import { frameworkMcpTools } from "../../mcp/framework-tools.js";
8
- import { getBuilderBrowserConnectUrlForOwner, resolveBuilderBranchProjectId, } from "../builder-browser.js";
8
+ import { getBuilderBrowserConnectUrlForOwner, resolveBuilderHandoffProjectId, } from "../builder-browser.js";
9
9
  import { getRequestOrgId, getRequestUserEmail } from "../request-context.js";
10
10
  import { getMcpManagerForCurrentRequest } from "./mcp-glue.js";
11
11
  const MAX_EXTENSION_PROMOTION_CONTENT_CHARS = 200_000;
@@ -199,7 +199,7 @@ export function createBuilderBrowserTool(deps) {
199
199
  // re-authorizing renders unconfigured, so the card offers to connect.
200
200
  const configured = (await builderConnectionForRequest(creds, BUILDER_OAUTH_SCOPE))
201
201
  .status === "connected";
202
- const branchProjectId = await resolveBuilderBranchProjectId();
202
+ const branchProjectId = await resolveBuilderHandoffProjectId();
203
203
  let prompt = typeof args?.prompt === "string" ? args.prompt : "";
204
204
  const extensionId = typeof args?.extensionId === "string" ? args.extensionId.trim() : "";
205
205
  let promotion;
@@ -192,7 +192,24 @@ export declare function getBuilderAppHost(): string;
192
192
  export declare function getBuilderApiHost(): string;
193
193
  export declare function getBuilderBranchProjectId(): string;
194
194
  export declare function isBuilderBranchingEnabled(): boolean;
195
+ type BuilderBranchProjectProvider = () => string | undefined | Promise<string | undefined>;
196
+ /**
197
+ * A host that binds each view to a Builder project (Design, mounted inside
198
+ * Builder) names that project here, so a code-change handoff targets the
199
+ * project the user is looking at rather than one deployment-wide setting.
200
+ * Return `undefined` when the request has no bound project; the usual
201
+ * Dispatch, env and secret lookups then apply. See
202
+ * `resolveBuilderHandoffProjectId`.
203
+ */
204
+ export declare function registerBuilderBranchProject(provider: BuilderBranchProjectProvider | null): void;
195
205
  export declare function resolveBuilderBranchProjectId(): Promise<string>;
206
+ /**
207
+ * The project a code-change handoff targets: the one the host binds to the
208
+ * current view when it names one, otherwise the deployment's configured
209
+ * project. Only the handoff uses this. Realtime channels and Builder status
210
+ * keep the deployment's project, so a view bound elsewhere cannot move them.
211
+ */
212
+ export declare function resolveBuilderHandoffProjectId(): Promise<string>;
196
213
  export declare function resolveIsBuilderBranchingEnabled(): Promise<boolean>;
197
214
  export declare const BUILDER_OPENER_PARAM = "_an_opener";
198
215
  /**
@@ -766,6 +766,18 @@ async function resolveDispatchBuilderProjectId() {
766
766
  return { status: "unreadable" };
767
767
  }
768
768
  }
769
+ let builderBranchProjectProvider = null;
770
+ /**
771
+ * A host that binds each view to a Builder project (Design, mounted inside
772
+ * Builder) names that project here, so a code-change handoff targets the
773
+ * project the user is looking at rather than one deployment-wide setting.
774
+ * Return `undefined` when the request has no bound project; the usual
775
+ * Dispatch, env and secret lookups then apply. See
776
+ * `resolveBuilderHandoffProjectId`.
777
+ */
778
+ export function registerBuilderBranchProject(provider) {
779
+ builderBranchProjectProvider = provider;
780
+ }
769
781
  export async function resolveBuilderBranchProjectId() {
770
782
  const dispatchProject = await resolveDispatchBuilderProjectId();
771
783
  if (dispatchProject.status === "unreadable")
@@ -792,6 +804,27 @@ export async function resolveBuilderBranchProjectId() {
792
804
  }
793
805
  return "";
794
806
  }
807
+ /**
808
+ * The project a code-change handoff targets: the one the host binds to the
809
+ * current view when it names one, otherwise the deployment's configured
810
+ * project. Only the handoff uses this. Realtime channels and Builder status
811
+ * keep the deployment's project, so a view bound elsewhere cannot move them.
812
+ */
813
+ export async function resolveBuilderHandoffProjectId() {
814
+ if (builderBranchProjectProvider) {
815
+ try {
816
+ const hostProjectId = (await builderBranchProjectProvider())?.trim();
817
+ if (hostProjectId)
818
+ return hostProjectId;
819
+ }
820
+ catch {
821
+ // coercion-ok: fails closed like an unreadable Dispatch setting, so no
822
+ // other project stands in for the one the host could not name.
823
+ return "";
824
+ }
825
+ }
826
+ return resolveBuilderBranchProjectId();
827
+ }
795
828
  export async function resolveIsBuilderBranchingEnabled() {
796
829
  return !!(await resolveBuilderBranchProjectId());
797
830
  }
@@ -59,7 +59,7 @@ import { createAgentEngineApiKeyHandler } from "./agent-engine-api-key-route.js"
59
59
  import { createAgentEngineDisconnectHandler } from "./agent-engine-default-model-route.js";
60
60
  import { createAgentEngineOllamaModelsHandler } from "./agent-engine-ollama-models-route.js";
61
61
  import { memoizeAgentEngineStatus } from "./agent-engine-status-cache.js";
62
- import { readAnalyticsClientPlatformHeader, readBrowserSessionIdHeader, } from "./agent-run-context.js";
62
+ import { readAnalyticsClientPlatformHeader, readBrowserSessionIdHeader, readBrowserTabIdHeader, } from "./agent-run-context.js";
63
63
  import { isAnonymousWaitlistSessionEmail } from "./anonymous-identity.js";
64
64
  import { getConfiguredAppBasePath, stripAppBasePath } from "./app-base-path.js";
65
65
  import { readAnalyticsSessionId } from "./attribution.js";
@@ -68,7 +68,7 @@ import { createAutomationFailureUnsubscribeHandler } from "./automation-failure-
68
68
  import { registerBackgroundJobStop } from "./background-jobs.js";
69
69
  import { getBetterAuthInternalAdapter, getBetterAuthSync, } from "./better-auth-instance.js";
70
70
  import { isBuilderReauthorizationRequired, resolveBuilderRequestAuthorization, } from "./builder-api-auth.js";
71
- import { BUILDER_CONNECT_PARAM, BUILDER_CONNECT_MODE_PARAM, BUILDER_AGENT_NATIVE_PROVISION_MODE, BUILDER_CONNECT_ATTEMPT_PARAM, BUILDER_CONNECT_STATE_COOKIE, BUILDER_ENV_KEYS, BUILDER_OPENER_PARAM, BUILDER_RELAY_FLOW_HEADER, BUILDER_RELAY_SIGNATURE_HEADER, BUILDER_RELAY_STATE_PARAM, BUILDER_RELAY_TIMESTAMP_HEADER, appendBuilderConnectToken, appendBuilderConnectStateCookie, builderConnectTrackingProperties, BUILDER_UPSTREAM_FAILURE_STATUS, createBuilderConnectState, createBuilderBrowserCallbackErrorPage, createBuilderBrowserCallbackPage, createBuilderRelayRequest, getBuilderConnectCallbackOriginFromUrl, getBuilderConnectTrackingParams, getBuilderBrowserOriginForEvent, getBuilderBrowserStatusForEvent, BuilderAccountProvisioningError, isBuilderAccountAlreadyExistsError, isBuilderAccountProvisioningEnabled, isBuilderConnectCallbackUrlAllowed, isSignedBuilderConnectState, normalizeBuilderAgentContext, parseBuilderConnectStateCookie, provisionBuilderAccount, resolveBuilderBranchProjectId, resolveBuilderConnectCallbackUrl, resolveBuilderConnectCallbackState, resolveBuilderPreviewRelayParentOrigin, removeBuilderConnectStateCookie, runBuilderAgent, sendBuilderPopupErrorPage, verifyBuilderRelayRequest, verifyBuilderPreviewRelayStateForCallback, verifyBuilderConnectTokenAndGetOwner, signBuilderProvisioningToken, verifyBuilderProvisioningToken, withBuilderConnectTrackingParams, } from "./builder-browser.js";
71
+ import { BUILDER_CONNECT_PARAM, BUILDER_CONNECT_MODE_PARAM, BUILDER_AGENT_NATIVE_PROVISION_MODE, BUILDER_CONNECT_ATTEMPT_PARAM, BUILDER_CONNECT_STATE_COOKIE, BUILDER_ENV_KEYS, BUILDER_OPENER_PARAM, BUILDER_RELAY_FLOW_HEADER, BUILDER_RELAY_SIGNATURE_HEADER, BUILDER_RELAY_STATE_PARAM, BUILDER_RELAY_TIMESTAMP_HEADER, appendBuilderConnectToken, appendBuilderConnectStateCookie, builderConnectTrackingProperties, BUILDER_UPSTREAM_FAILURE_STATUS, createBuilderConnectState, createBuilderBrowserCallbackErrorPage, createBuilderBrowserCallbackPage, createBuilderRelayRequest, getBuilderConnectCallbackOriginFromUrl, getBuilderConnectTrackingParams, getBuilderBrowserOriginForEvent, getBuilderBrowserStatusForEvent, BuilderAccountProvisioningError, isBuilderAccountAlreadyExistsError, isBuilderAccountProvisioningEnabled, isBuilderConnectCallbackUrlAllowed, isSignedBuilderConnectState, normalizeBuilderAgentContext, parseBuilderConnectStateCookie, provisionBuilderAccount, resolveBuilderBranchProjectId, resolveBuilderHandoffProjectId, resolveBuilderConnectCallbackUrl, resolveBuilderConnectCallbackState, resolveBuilderPreviewRelayParentOrigin, removeBuilderConnectStateCookie, runBuilderAgent, sendBuilderPopupErrorPage, verifyBuilderRelayRequest, verifyBuilderPreviewRelayStateForCallback, verifyBuilderConnectTokenAndGetOwner, signBuilderProvisioningToken, verifyBuilderProvisioningToken, withBuilderConnectTrackingParams, } from "./builder-browser.js";
72
72
  import { createBuilderDesktopMessagesHandler } from "./builder-desktop-messages-route.js";
73
73
  import { BUILDER_OAUTH_SCOPE, builderOAuthScopeFor, canRoleConnectPersonalBuilder, deleteBuilderOAuthSession, exchangeBuilderOAuthAuthorization, getBuilderOAuthGrants, getBuilderOAuthStoredScope, hasUsableBuilderOAuthSessionForReadiness, hasStoredBuilderOAuthGrant, isBuilderOrgManagerRole, isPersonalBuilderGrantAllowed, saveBuilderOAuthCredentials, startBuilderOAuthAuthorization, } from "./builder-oauth.js";
74
74
  import { captureError, registerErrorCaptureProvider } from "./capture-error.js";
@@ -3491,8 +3491,15 @@ export function createCoreRoutesPlugin(options = {}) {
3491
3491
  // uses. Without this, per-user Builder keys stored in app_secrets are
3492
3492
  // invisible to the run path and the call throws "Builder keys are not
3493
3493
  // configured" even though the status endpoint correctly reports configured=true.
3494
- return runWithRequestContext({ userEmail, orgId: orgId ?? undefined }, async () => {
3495
- const projectId = await resolveBuilderBranchProjectId();
3494
+ // The tab id lets a host's branch-project provider find the view
3495
+ // this click came from (its navigation state is tab-scoped).
3496
+ const browserTabId = readBrowserTabIdHeader(event);
3497
+ return runWithRequestContext({
3498
+ userEmail,
3499
+ ...(orgId ? { orgId } : {}),
3500
+ ...(browserTabId ? { run: { browserTabId } } : {}),
3501
+ }, async () => {
3502
+ const projectId = await resolveBuilderHandoffProjectId();
3496
3503
  if (!projectId) {
3497
3504
  setResponseStatus(event, 403);
3498
3505
  return {
@@ -113,7 +113,7 @@ export { BUILDER_PUBLISH_MCP_RESOURCE, canAuthorizeBuilderApiRequest, hasBuilder
113
113
  export { createFusionAgentFeed, fusionStepToAgentChatEvents, type FusionAgentFeedSummary, } from "./fusion-agent-feed.js";
114
114
  export { BUILDER_ASSETS_WRITE_SCOPE, BUILDER_CONTENT_READ_SCOPE, BUILDER_CONTENT_WRITE_SCOPE, BUILDER_OAUTH_RESOURCE, BUILDER_OAUTH_SCOPE, type BuilderOAuthPermissionScope, } from "./builder-oauth.js";
115
115
  export { assertBuilderDesignSystemCodeIndexingAllowed, builderDesignSystemUrl, builderProjectBranchUrl, buildBuilderDesignSystemIndexFiles, collectBuilderDesignSystemGitHubFiles, createBuilderDesignSystemProxyFields, designSystemTierUpgradeUrl, fetchBuilderDesignSystemDecodeJobStatus, fetchBuilderDesignSystemDocs, fetchBuilderDesignSystemDocumentCount, fetchBuilderDesignSystemRecord, fetchBuilderDesignSystemTierLimit, getBuilderDesignSystemsBaseUrl, hydrateBuilderDesignSystemReference, indexBuilderDesignSystem, isBuilderDesignSystemReadyByCount, localBuilderDesignSystemId, mimeTypeForBuilderDesignSystemFilename, parseBuilderDesignSystemProxyReference, startBuilderDesignSystemIndex, startBuilderDesignSystemUpload, type BuildBuilderDesignSystemIndexFilesOptions, type BuilderDesignSystemCodeFileInput, type BuilderDesignSystemDecodeJobStatus, type BuilderDesignSystemDocsOptions, type BuilderDesignSystemDocument, type BuilderDesignSystemDocumentCountResult, type BuilderDesignSystemHydratedReference, type BuilderDesignSystemIndexFile, type BuilderDesignSystemIndexFromSourcesOptions, type BuilderDesignSystemIndexOptions, type BuilderDesignSystemIndexResult, type BuilderDesignSystemRecord, type BuilderDesignSystemStatus, type BuilderDesignSystemTierLimit, type BuilderDesignSystemGitHubFile, type BuilderDesignSystemGitHubFileCollection, type BuilderDesignSystemGitHubSource, type BuilderDesignSystemUploadAttachment, type BuilderDesignSystemUploadSlot, type BuilderDesignSystemProxyFields, type BuilderDesignSystemProxyFieldsOptions, type BuilderDesignSystemProxyReference, type BuilderDesignSystemSourceKind, } from "./builder-design-systems.js";
116
- export { cdnSafeOriginStatus, createBuilderProject, ensureBuilderProject, findBuilderProjectForRepo, getBuilderBranchProjectId, isBuilderBranchingEnabled, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveIsBuilderBranchingEnabled, normalizeBuilderAgentAttachments, runBuilderAgent, type BuilderAgentAttachment, type BuilderAgentUploadAttachment, type BuilderAgentUrlAttachment, type BuilderProjectResult, type RunBuilderAgentResult, } from "./builder-browser.js";
116
+ export { cdnSafeOriginStatus, createBuilderProject, ensureBuilderProject, findBuilderProjectForRepo, getBuilderBranchProjectId, isBuilderBranchingEnabled, registerBuilderBranchProject, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveBuilderHandoffProjectId, resolveIsBuilderBranchingEnabled, normalizeBuilderAgentAttachments, runBuilderAgent, type BuilderAgentAttachment, type BuilderAgentUploadAttachment, type BuilderAgentUrlAttachment, type BuilderProjectResult, type RunBuilderAgentResult, } from "./builder-browser.js";
117
117
  export { BuilderBranchError, getBuilderBranchStatus, sendBuilderBranchMessage, type BuilderBranchAgentState, type BuilderBranchErrorCode, type BuilderBranchOperation, type BuilderBranchPrStatus, type BuilderBranchRef, type BuilderBranchState, type BuilderBranchStatus, type GetBuilderBranchStatusOptions, type SendBuilderBranchMessageOptions, type SendBuilderBranchMessageResult, } from "./builder-branch.js";
118
118
  export { BuilderBranchFilesError, readBuilderBranchFiles, } from "./builder-branch-files.js";
119
119
  export { ensureFusionContainer, sendFusionBranchMessage, pushFusionBranch, reserveFusionHostingSlug, deployFusionProject, getFusionDeploys, getFusionBranchEditorUrl, getFusionHostingUrl, type FusionBranchRef, type EnsureFusionContainerResult, type SendFusionMessageResult, } from "./fusion-app.js";
@@ -106,7 +106,7 @@ export { BUILDER_PUBLISH_MCP_RESOURCE, canAuthorizeBuilderApiRequest, hasBuilder
106
106
  export { createFusionAgentFeed, fusionStepToAgentChatEvents, } from "./fusion-agent-feed.js";
107
107
  export { BUILDER_ASSETS_WRITE_SCOPE, BUILDER_CONTENT_READ_SCOPE, BUILDER_CONTENT_WRITE_SCOPE, BUILDER_OAUTH_RESOURCE, BUILDER_OAUTH_SCOPE, } from "./builder-oauth.js";
108
108
  export { assertBuilderDesignSystemCodeIndexingAllowed, builderDesignSystemUrl, builderProjectBranchUrl, buildBuilderDesignSystemIndexFiles, collectBuilderDesignSystemGitHubFiles, createBuilderDesignSystemProxyFields, designSystemTierUpgradeUrl, fetchBuilderDesignSystemDecodeJobStatus, fetchBuilderDesignSystemDocs, fetchBuilderDesignSystemDocumentCount, fetchBuilderDesignSystemRecord, fetchBuilderDesignSystemTierLimit, getBuilderDesignSystemsBaseUrl, hydrateBuilderDesignSystemReference, indexBuilderDesignSystem, isBuilderDesignSystemReadyByCount, localBuilderDesignSystemId, mimeTypeForBuilderDesignSystemFilename, parseBuilderDesignSystemProxyReference, startBuilderDesignSystemIndex, startBuilderDesignSystemUpload, } from "./builder-design-systems.js";
109
- export { cdnSafeOriginStatus, createBuilderProject, ensureBuilderProject, findBuilderProjectForRepo, getBuilderBranchProjectId, isBuilderBranchingEnabled, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveIsBuilderBranchingEnabled, normalizeBuilderAgentAttachments, runBuilderAgent, } from "./builder-browser.js";
109
+ export { cdnSafeOriginStatus, createBuilderProject, ensureBuilderProject, findBuilderProjectForRepo, getBuilderBranchProjectId, isBuilderBranchingEnabled, registerBuilderBranchProject, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveBuilderHandoffProjectId, resolveIsBuilderBranchingEnabled, normalizeBuilderAgentAttachments, runBuilderAgent, } from "./builder-browser.js";
110
110
  export { BuilderBranchError, getBuilderBranchStatus, sendBuilderBranchMessage, } from "./builder-branch.js";
111
111
  export { BuilderBranchFilesError, readBuilderBranchFiles, } from "./builder-branch-files.js";
112
112
  export { ensureFusionContainer, sendFusionBranchMessage, pushFusionBranch, reserveFusionHostingSlug, deployFusionProject, getFusionDeploys, getFusionBranchEditorUrl, getFusionHostingUrl, } from "./fusion-app.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.222.0",
3
+ "version": "0.222.1-nightly-20261029063606",
4
4
  "description": "The agentic application framework for building autonomous agents with intuitive UIs",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -742,7 +742,7 @@
742
742
  "yaml": "^2.9.0",
743
743
  "yjs": "^13.6.33",
744
744
  "zod": "^4.3.6",
745
- "@agent-native/agentkit": "^0.222.0",
745
+ "@agent-native/agentkit": "^0.222.1-nightly-20261029063606",
746
746
  "@agent-native/recap-cli": "^0.5.91"
747
747
  },
748
748
  "devDependencies": {
@@ -814,7 +814,7 @@
814
814
  "xlsx": "^0.18.5"
815
815
  },
816
816
  "peerDependencies": {
817
- "@agent-native/core-corpus": ">=0.196.0",
817
+ "@agent-native/core-corpus": "0.222.1-nightly-20261029063606",
818
818
  "@ai-sdk/anthropic": ">=3",
819
819
  "@ai-sdk/cohere": ">=3",
820
820
  "@ai-sdk/google": ">=3",